comparison dwt/internal/cocoa/NSScrollView.d @ 45:d8635bb48c7c

Merge with SWT 3.5
author Jacob Carlborg <doob@me.com>
date Mon, 01 Dec 2008 17:07:00 +0100
parents f565d3a95c0a
children 62202ce0039f
comparison
equal deleted inserted replaced
44:ca5e494f2bbf 45:d8635bb48c7c
1 /******************************************************************************* 1 /*******************************************************************************
2 * Copyright (c) 2007 IBM Corporation and others. 2 * Copyright (c) 2000, 2008 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials 3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0 4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at 5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html 6 * http://www.eclipse.org/legal/epl-v10.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * IBM Corporation - initial API and implementation 9 * IBM Corporation - initial API and implementation
10 * 10 *
11 * Port to the D programming language: 11 * Port to the D programming language:
12 * Jacob Carlborg <jacob.carlborg@gmail.com> 12 * Jacob Carlborg <doob@me.com>
13 *******************************************************************************/ 13 *******************************************************************************/
14 module dwt.internal.cocoa.NSScrollView; 14 module dwt.internal.cocoa.NSScrollView;
15 15
16 import dwt.internal.cocoa.id; 16 import dwt.dwthelper.utils;
17 import dwt.internal.cocoa.CGFloat; 17 import cocoa = dwt.internal.cocoa.id;
18 import dwt.internal.cocoa.NSClipView; 18 import dwt.internal.cocoa.NSClipView;
19 import dwt.internal.cocoa.NSColor;
20 import dwt.internal.cocoa.NSCursor;
21 import dwt.internal.cocoa.NSEvent;
22 import dwt.internal.cocoa.NSRect; 19 import dwt.internal.cocoa.NSRect;
23 import dwt.internal.cocoa.NSRulerView;
24 import dwt.internal.cocoa.NSScroller; 20 import dwt.internal.cocoa.NSScroller;
25 import dwt.internal.cocoa.NSSize; 21 import dwt.internal.cocoa.NSSize;
26 import dwt.internal.cocoa.NSView; 22 import dwt.internal.cocoa.NSView;
27 import dwt.internal.cocoa.OS; 23 import dwt.internal.cocoa.OS;
28 import objc = dwt.internal.objc.runtime; 24 import objc = dwt.internal.objc.runtime;
29 25
30 public class NSScrollView : NSView 26 public class NSScrollView : NSView {
31 {
32 27
33 public this () 28 public this() {
34 { 29 super();
35 super(); 30 }
36 }
37 31
38 public this (objc.id id) 32 public this(objc.id id) {
39 { 33 super(id);
40 super(id); 34 }
41 }
42 35
43 public bool autohidesScrollers () 36 public this(cocoa.id id) {
44 { 37 super(id);
45 return OS.objc_msgSend(this.id_, OS.sel_autohidesScrollers) !is null; 38 }
46 }
47 39
48 public NSColor backgroundColor () 40 public NSSize contentSize() {
49 { 41 NSSize result = NSSize();
50 objc.id result = OS.objc_msgSend(this.id_, OS.sel_backgroundColor); 42 OS.objc_msgSend_stret(result, this.id, OS.sel_contentSize);
51 return result !is null ? new NSColor(result) : null; 43 return result;
52 } 44 }
53 45
54 public NSBorderType borderType () 46 public static NSSize contentSizeForFrameSize(NSSize fSize, bool hFlag, bool vFlag, NSBorderType aType) {
55 { 47 NSSize result = NSSize();
56 return cast(NSBorderType) OS.objc_msgSend(this.id_, OS.sel_borderType); 48 OS.objc_msgSend_stret(result, OS.class_NSScrollView, OS.sel_contentSizeForFrameSize_hasHorizontalScroller_hasVerticalScroller_borderType_, fSize, hFlag, vFlag, aType);
57 } 49 return result;
50 }
58 51
59 public NSSize contentSize () 52 public NSClipView contentView() {
60 { 53 objc.id result = OS.objc_msgSend(this.id, OS.sel_contentView);
61 NSSize result; 54 return result !is null ? new NSClipView(result) : null;
62 OS.objc_msgSend_struct(&result, this.id_, OS.sel_contentSize); 55 }
63 return result;
64 }
65 56
66 public static NSSize contentSizeForFrameSize (NSSize fSize, bool hFlag, bool vFlag, NSBorderType aType) 57 public NSView documentView() {
67 { 58 objc.id result = OS.objc_msgSend(this.id, OS.sel_documentView);
68 NSSize result; 59 return result !is null ? new NSView(result) : null;
69 OS.objc_msgSend_stret(&result, OS.class_NSScrollView, 60 }
70 OS.sel_contentSizeForFrameSize_1hasHorizontalScroller_1hasVerticalScroller_1borderType_1, fSize, hFlag, vFlag, aType);
71 return result;
72 }
73 61
74 public NSClipView contentView () 62 public NSRect documentVisibleRect() {
75 { 63 NSRect result = NSRect();
76 objc.id result = OS.objc_msgSend(this.id_, OS.sel_contentView); 64 OS.objc_msgSend_stret(result, this.id, OS.sel_documentVisibleRect);
77 return result !is null ? new NSClipView(result) : null; 65 return result;
78 } 66 }
79 67
80 public NSCursor documentCursor () 68 public static NSSize frameSizeForContentSize(NSSize cSize, bool hFlag, bool vFlag, NSBorderType aType) {
81 { 69 NSSize result = NSSize();
82 objc.id result = OS.objc_msgSend(this.id_, OS.sel_documentCursor); 70 OS.objc_msgSend_stret(result, OS.class_NSScrollView, OS.sel_frameSizeForContentSize_hasHorizontalScroller_hasVerticalScroller_borderType_, cSize, hFlag, vFlag, aType);
83 return result !is null ? new NSCursor(result) : null; 71 return result;
84 } 72 }
85 73
86 public id documentView () 74 public void reflectScrolledClipView(NSClipView cView) {
87 { 75 OS.objc_msgSend(this.id, OS.sel_reflectScrolledClipView_, cView !is null ? cView.id : null);
88 objc.id result = OS.objc_msgSend(this.id_, OS.sel_documentView); 76 }
89 return result !is null ? new id(result) : null;
90 }
91 77
92 public NSRect documentVisibleRect () 78 public void setAutohidesScrollers(bool flag) {
93 { 79 OS.objc_msgSend(this.id, OS.sel_setAutohidesScrollers_, flag);
94 NSRect result; 80 }
95 OS.objc_msgSend_stret(&result, this.id_, OS.sel_documentVisibleRect);
96 return result;
97 }
98 81
99 public bool drawsBackground () 82 public void setBorderType(NSBorderType aType) {
100 { 83 OS.objc_msgSend(this.id, OS.sel_setBorderType_, aType);
101 return OS.objc_msgSend(this.id_, OS.sel_drawsBackground) !is null; 84 }
102 }
103 85
104 public static NSSize frameSizeForContentSize (NSSize cSize, bool hFlag, bool vFlag, NSBorderType aType) 86 public void setDocumentView(NSView aView) {
105 { 87 OS.objc_msgSend(this.id, OS.sel_setDocumentView_, aView !is null ? aView.id : null);
106 NSSize result; 88 }
107 OS.objc_msgSend_struct(&result, OS.class_NSScrollView,
108 OS.sel_frameSizeForContentSize_1hasHorizontalScroller_1hasVerticalScroller_1borderType_1, &cSize, hFlag, vFlag, aType);
109 return result;
110 }
111 89
112 public bool hasHorizontalRuler () 90 public void setDrawsBackground(bool flag) {
113 { 91 OS.objc_msgSend(this.id, OS.sel_setDrawsBackground_, flag);
114 return OS.objc_msgSend(this.id_, OS.sel_hasHorizontalRuler) !is null; 92 }
115 }
116 93
117 public bool hasHorizontalScroller () 94 public void setHasHorizontalScroller(bool flag) {
118 { 95 OS.objc_msgSend(this.id, OS.sel_setHasHorizontalScroller_, flag);
119 return OS.objc_msgSend(this.id_, OS.sel_hasHorizontalScroller) !is null; 96 }
120 }
121 97
122 public bool hasVerticalRuler () 98 public void setHasVerticalScroller(bool flag) {
123 { 99 OS.objc_msgSend(this.id, OS.sel_setHasVerticalScroller_, flag);
124 return OS.objc_msgSend(this.id_, OS.sel_hasVerticalRuler) !is null; 100 }
125 }
126 101
127 public bool hasVerticalScroller () 102 public void setHorizontalScroller(NSScroller anObject) {
128 { 103 OS.objc_msgSend(this.id, OS.sel_setHorizontalScroller_, anObject !is null ? anObject.id : null);
129 return OS.objc_msgSend(this.id_, OS.sel_hasVerticalScroller) !is null; 104 }
130 }
131 105
132 public CGFloat horizontalLineScroll () 106 public void setVerticalScroller(NSScroller anObject) {
133 { 107 OS.objc_msgSend(this.id, OS.sel_setVerticalScroller_, anObject !is null ? anObject.id : null);
134 return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_horizontalLineScroll); 108 }
135 }
136
137 public CGFloat horizontalPageScroll ()
138 {
139 return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_horizontalPageScroll);
140 }
141
142 public NSRulerView horizontalRulerView ()
143 {
144 objc.id result = OS.objc_msgSend(this.id_, OS.sel_horizontalRulerView);
145 return result !is null ? new NSRulerView(result) : null;
146 }
147
148 public NSScroller horizontalScroller ()
149 {
150 objc.id result = OS.objc_msgSend(this.id_, OS.sel_horizontalScroller);
151 return result !is null ? new NSScroller(result) : null;
152 }
153
154 public CGFloat lineScroll ()
155 {
156 return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_lineScroll);
157 }
158
159 public CGFloat pageScroll ()
160 {
161 return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_pageScroll);
162 }
163
164 public void reflectScrolledClipView (NSClipView cView)
165 {
166 OS.objc_msgSend(this.id_, OS.sel_reflectScrolledClipView_1, cView !is null ? cView.id_ : null);
167 }
168
169 public static objc.Class rulerViewClass ()
170 {
171 return cast(objc.Class) OS.objc_msgSend(OS.class_NSScrollView, OS.sel_rulerViewClass);
172 }
173
174 public bool rulersVisible ()
175 {
176 return OS.objc_msgSend(this.id_, OS.sel_rulersVisible) !is null;
177 }
178
179 public void scrollWheel (NSEvent theEvent)
180 {
181 OS.objc_msgSend(this.id_, OS.sel_scrollWheel_1, theEvent !is null ? theEvent.id_ : null);
182 }
183
184 public bool scrollsDynamically ()
185 {
186 return OS.objc_msgSend(this.id_, OS.sel_scrollsDynamically) !is null;
187 }
188
189 public void setAutohidesScrollers (bool flag)
190 {
191 OS.objc_msgSend(this.id_, OS.sel_setAutohidesScrollers_1, flag);
192 }
193
194 public void setBackgroundColor (NSColor color)
195 {
196 OS.objc_msgSend(this.id_, OS.sel_setBackgroundColor_1, color !is null ? color.id_ : null);
197 }
198
199 public void setBorderType (NSBorderType aType)
200 {
201 OS.objc_msgSend(this.id_, OS.sel_setBorderType_1, aType);
202 }
203
204 public void setContentView (NSClipView contentView)
205 {
206 OS.objc_msgSend(this.id_, OS.sel_setContentView_1, contentView !is null ? contentView.id_ : null);
207 }
208
209 public void setDocumentCursor (NSCursor anObj)
210 {
211 OS.objc_msgSend(this.id_, OS.sel_setDocumentCursor_1, anObj !is null ? anObj.id_ : null);
212 }
213
214 public void setDocumentView (NSView aView)
215 {
216 OS.objc_msgSend(this.id_, OS.sel_setDocumentView_1, aView !is null ? aView.id_ : null);
217 }
218
219 public void setDrawsBackground (bool flag)
220 {
221 OS.objc_msgSend(this.id_, OS.sel_setDrawsBackground_1, flag);
222 }
223
224 public void setHasHorizontalRuler (bool flag)
225 {
226 OS.objc_msgSend(this.id_, OS.sel_setHasHorizontalRuler_1, flag);
227 }
228
229 public void setHasHorizontalScroller (bool flag)
230 {
231 OS.objc_msgSend(this.id_, OS.sel_setHasHorizontalScroller_1, flag);
232 }
233
234 public void setHasVerticalRuler (bool flag)
235 {
236 OS.objc_msgSend(this.id_, OS.sel_setHasVerticalRuler_1, flag);
237 }
238
239 public void setHasVerticalScroller (bool flag)
240 {
241 OS.objc_msgSend(this.id_, OS.sel_setHasVerticalScroller_1, flag);
242 }
243
244 public void setHorizontalLineScroll (CGFloat value)
245 {
246 OS.objc_msgSend(this.id_, OS.sel_setHorizontalLineScroll_1, value);
247 }
248
249 public void setHorizontalPageScroll (CGFloat value)
250 {
251 OS.objc_msgSend(this.id_, OS.sel_setHorizontalPageScroll_1, value);
252 }
253
254 public void setHorizontalRulerView (NSRulerView ruler)
255 {
256 OS.objc_msgSend(this.id_, OS.sel_setHorizontalRulerView_1, ruler !is null ? ruler.id_ : null);
257 }
258
259 public void setHorizontalScroller (NSScroller anObject)
260 {
261 OS.objc_msgSend(this.id_, OS.sel_setHorizontalScroller_1, anObject !is null ? anObject.id_ : null);
262 }
263
264 public void setLineScroll (CGFloat value)
265 {
266 OS.objc_msgSend(this.id_, OS.sel_setLineScroll_1, value);
267 }
268
269 public void setPageScroll (CGFloat value)
270 {
271 OS.objc_msgSend(this.id_, OS.sel_setPageScroll_1, value);
272 }
273
274 public static void setRulerViewClass (objc.Class rulerViewClass)
275 {
276 OS.objc_msgSend(OS.class_NSScrollView, OS.sel_setRulerViewClass_1, rulerViewClass);
277 }
278
279 public void setRulersVisible (bool flag)
280 {
281 OS.objc_msgSend(this.id_, OS.sel_setRulersVisible_1, flag);
282 }
283
284 public void setScrollsDynamically (bool flag)
285 {
286 OS.objc_msgSend(this.id_, OS.sel_setScrollsDynamically_1, flag);
287 }
288
289 public void setVerticalLineScroll (CGFloat value)
290 {
291 OS.objc_msgSend(this.id_, OS.sel_setVerticalLineScroll_1, value);
292 }
293
294 public void setVerticalPageScroll (CGFloat value)
295 {
296 OS.objc_msgSend(this.id_, OS.sel_setVerticalPageScroll_1, value);
297 }
298
299 public void setVerticalRulerView (NSRulerView ruler)
300 {
301 OS.objc_msgSend(this.id_, OS.sel_setVerticalRulerView_1, ruler !is null ? ruler.id_ : null);
302 }
303
304 public void setVerticalScroller (NSScroller anObject)
305 {
306 OS.objc_msgSend(this.id_, OS.sel_setVerticalScroller_1, anObject !is null ? anObject.id_ : null);
307 }
308
309 public void tile ()
310 {
311 OS.objc_msgSend(this.id_, OS.sel_tile);
312 }
313
314 public CGFloat verticalLineScroll ()
315 {
316 return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_verticalLineScroll);
317 }
318
319 public CGFloat verticalPageScroll ()
320 {
321 return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_verticalPageScroll);
322 }
323
324 public NSRulerView verticalRulerView ()
325 {
326 objc.id result = OS.objc_msgSend(this.id_, OS.sel_verticalRulerView);
327 return result !is null ? new NSRulerView(result) : null;
328 }
329
330 public NSScroller verticalScroller ()
331 {
332 objc.id result = OS.objc_msgSend(this.id_, OS.sel_verticalScroller);
333 return result !is null ? new NSScroller(result) : null;
334 }
335 109
336 } 110 }