Mercurial > projects > dwt-mac
comparison dwt/internal/cocoa/NSControl.d @ 45:d8635bb48c7c
Merge with SWT 3.5
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Mon, 01 Dec 2008 17:07:00 +0100 |
parents | 642f460a0908 |
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.NSControl; | 14 module dwt.internal.cocoa.NSControl; |
15 | 15 |
16 import dwt.dwthelper.utils; | 16 import dwt.dwthelper.utils; |
17 import dwt.internal.cocoa.id; | 17 import cocoa = dwt.internal.cocoa.id; |
18 import dwt.internal.cocoa.NSAttributedString; | |
19 import dwt.internal.cocoa.NSCell; | 18 import dwt.internal.cocoa.NSCell; |
20 import dwt.internal.cocoa.NSEvent; | |
21 import dwt.internal.cocoa.NSFont; | 19 import dwt.internal.cocoa.NSFont; |
22 import dwt.internal.cocoa.NSFormatter; | 20 import dwt.internal.cocoa.NSFormatter; |
23 import dwt.internal.cocoa.NSInteger; | |
24 import dwt.internal.cocoa.NSString; | 21 import dwt.internal.cocoa.NSString; |
25 import dwt.internal.cocoa.NSText; | 22 import dwt.internal.cocoa.NSText; |
26 import dwt.internal.cocoa.NSView; | 23 import dwt.internal.cocoa.NSView; |
27 import dwt.internal.cocoa.OS; | 24 import dwt.internal.cocoa.OS; |
28 import obj = dwt.internal.objc.runtime; | 25 import objc = dwt.internal.objc.runtime; |
29 | 26 |
30 public class NSControl : NSView | 27 public class NSControl : NSView { |
31 { | |
32 | 28 |
33 public this () | 29 public this() { |
34 { | 30 super(); |
35 super(); | 31 } |
36 } | |
37 | 32 |
38 public this (objc.id id) | 33 public this(objc.id id) { |
39 { | 34 super(id); |
40 super(id); | 35 } |
41 } | |
42 | 36 |
43 public bool abortEditing () | 37 public this(cocoa.id id) { |
44 { | 38 super(id); |
45 return OS.objc_msgSend(this.id_, OS.sel_abortEditing) !is null; | 39 } |
46 } | |
47 | 40 |
48 public String action () | 41 public objc.SEL action() { |
49 { | 42 return cast(objc.SEL) OS.objc_msgSend(this.id, OS.sel_action); |
50 return fromStringz(cast(objc.SEL) OS.objc_msgSend(this.id_, OS.sel_action)); | 43 } |
51 } | |
52 | 44 |
53 public objc.id alignment () | 45 public NSCell cell() { |
54 { | 46 objc.id result = OS.objc_msgSend(this.id, OS.sel_cell); |
55 return OS.objc_msgSend(this.id_, OS.sel_alignment); | 47 return result !is null ? new NSCell(result) : null; |
56 } | 48 } |
57 | 49 |
58 public NSAttributedString attributedStringValue () | 50 public static objc.Class cellClass() { |
59 { | 51 return cast(objc.Class) OS.objc_msgSend(OS.class_NSControl, OS.sel_cellClass); |
60 objc.id result = OS.objc_msgSend(this.id_, OS.sel_attributedStringValue); | 52 } |
61 return result !is null ? new NSAttributedString(result) : null; | |
62 } | |
63 | 53 |
64 public objc.id baseWritingDirection () | 54 public NSText currentEditor() { |
65 { | 55 objc.id result = OS.objc_msgSend(this.id, OS.sel_currentEditor); |
66 return OS.objc_msgSend(this.id_, OS.sel_baseWritingDirection); | 56 return result !is null ? new NSText(result) : null; |
67 } | 57 } |
68 | 58 |
69 public void calcSize () | 59 public double doubleValue() { |
70 { | 60 return OS.objc_msgSend_fpret(this.id, OS.sel_doubleValue); |
71 OS.objc_msgSend(this.id_, OS.sel_calcSize); | 61 } |
72 } | |
73 | 62 |
74 public objc.id cell () | 63 public NSFont font() { |
75 { | 64 objc.id result = OS.objc_msgSend(this.id, OS.sel_font); |
76 objc.id result = OS.objc_msgSend(this.id_, OS.sel_cell); | 65 return result !is null ? new NSFont(result) : null; |
77 return result !is null ? result : null; | 66 } |
78 } | |
79 | 67 |
80 public static objc.Class cellClass () | 68 public bool sendAction(objc.SEL theAction, cocoa.id theTarget) { |
81 { | 69 return OS.objc_msgSend_bool(this.id, OS.sel_sendAction_to_, theAction, theTarget !is null ? theTarget.id : null); |
82 return cast(objc.Class) OS.objc_msgSend(OS.class_NSControl, OS.sel_cellClass); | 70 } |
83 } | |
84 | 71 |
85 public NSText currentEditor () | 72 public void setAction(objc.SEL aSelector) { |
86 { | 73 OS.objc_msgSend(this.id, OS.sel_setAction_, aSelector); |
87 objc.id result = OS.objc_msgSend(this.id_, OS.sel_currentEditor); | 74 } |
88 return result !is null ? new NSText(result) : null; | |
89 } | |
90 | 75 |
91 public double doubleValue () | 76 public void setAlignment(NSTextAlignment mode) { |
92 { | 77 OS.objc_msgSend(this.id, OS.sel_setAlignment_, mode); |
93 return OS.objc_msgSend_fpret(this.id_, OS.sel_doubleValue); | 78 } |
94 } | |
95 | 79 |
96 public void drawCell (NSCell aCell) | 80 public static void setCellClass(objc.Class factoryId) { |
97 { | 81 OS.objc_msgSend(OS.class_NSControl, OS.sel_setCellClass_, factoryId); |
98 OS.objc_msgSend(this.id_, OS.sel_drawCell_1, aCell !is null ? aCell.id_ : null); | 82 } |
99 } | |
100 | 83 |
101 public void drawCellInside (NSCell aCell) | 84 public void setDoubleValue(double aDouble) { |
102 { | 85 OS.objc_msgSend(this.id, OS.sel_setDoubleValue_, aDouble); |
103 OS.objc_msgSend(this.id_, OS.sel_drawCellInside_1, aCell !is null ? aCell.id_ : null); | 86 } |
104 } | |
105 | 87 |
106 public float floatValue () | 88 public void setEnabled(bool flag) { |
107 { | 89 OS.objc_msgSend(this.id, OS.sel_setEnabled_, flag); |
108 return cast(float) OS.objc_msgSend_fpret(this.id_, OS.sel_floatValue); | 90 } |
109 } | |
110 | 91 |
111 public NSFont font () | 92 public void setFont(NSFont fontObj) { |
112 { | 93 OS.objc_msgSend(this.id, OS.sel_setFont_, fontObj !is null ? fontObj.id : null); |
113 objc.id result = OS.objc_msgSend(this.id_, OS.sel_font); | 94 } |
114 return result !is null ? new NSFont(result) : null; | |
115 } | |
116 | 95 |
117 public id formatter () | 96 public void setFormatter(NSFormatter newFormatter) { |
118 { | 97 OS.objc_msgSend(this.id, OS.sel_setFormatter_, newFormatter !is null ? newFormatter.id : null); |
119 objc.id result = OS.objc_msgSend(this.id_, OS.sel_formatter); | 98 } |
120 return result !is null ? new id(result) : null; | |
121 } | |
122 | 99 |
123 public bool ignoresMultiClick () | 100 public void setStringValue(NSString aString) { |
124 { | 101 OS.objc_msgSend(this.id, OS.sel_setStringValue_, aString !is null ? aString.id : null); |
125 return OS.objc_msgSend(this.id_, OS.sel_ignoresMultiClick) !is null; | 102 } |
126 } | |
127 | 103 |
128 public int intValue () | 104 public void setTarget(cocoa.id anObject) { |
129 { | 105 OS.objc_msgSend(this.id, OS.sel_setTarget_, anObject !is null ? anObject.id : null); |
130 return cast(int) OS.objc_msgSend(this.id_, OS.sel_intValue); | 106 } |
131 } | |
132 | 107 |
133 public NSInteger integerValue () | 108 public void sizeToFit() { |
134 { | 109 OS.objc_msgSend(this.id, OS.sel_sizeToFit); |
135 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_integerValue); | 110 } |
136 } | |
137 | 111 |
138 public bool isContinuous () | 112 public NSString stringValue() { |
139 { | 113 objc.id result = OS.objc_msgSend(this.id, OS.sel_stringValue); |
140 return OS.objc_msgSend(this.id_, OS.sel_isContinuous) !is null; | 114 return result !is null ? new NSString(result) : null; |
141 } | 115 } |
142 | 116 |
143 public bool isEnabled () | 117 public cocoa.id target() { |
144 { | 118 objc.id result = OS.objc_msgSend(this.id, OS.sel_target); |
145 return OS.objc_msgSend(this.id_, OS.sel_isEnabled) !is null; | 119 return result !is null ? new id(result) : null; |
146 } | 120 } |
147 | |
148 public void mouseDown (NSEvent theEvent) | |
149 { | |
150 OS.objc_msgSend(this.id_, OS.sel_mouseDown_1, theEvent !is null ? theEvent.id_ : null); | |
151 } | |
152 | |
153 public id objectValue () | |
154 { | |
155 objc.id result = OS.objc_msgSend(this.id_, OS.sel_objectValue); | |
156 return result !is null ? new id(result) : null; | |
157 } | |
158 | |
159 public void performClick (id sender) | |
160 { | |
161 OS.objc_msgSend(this.id_, OS.sel_performClick_1, sender !is null ? sender.id_ : null); | |
162 } | |
163 | |
164 public bool refusesFirstResponder () | |
165 { | |
166 return OS.objc_msgSend(this.id_, OS.sel_refusesFirstResponder) !is null; | |
167 } | |
168 | |
169 public void selectCell (NSCell aCell) | |
170 { | |
171 OS.objc_msgSend(this.id_, OS.sel_selectCell_1, aCell !is null ? aCell.id_ : null); | |
172 } | |
173 | |
174 public id selectedCell () | |
175 { | |
176 objc.id result = OS.objc_msgSend(this.id_, OS.sel_selectedCell); | |
177 return result !is null ? new id(result) : null; | |
178 } | |
179 | |
180 public NSInteger selectedTag () | |
181 { | |
182 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_selectedTag); | |
183 } | |
184 | |
185 public bool sendAction (String theAction, id theTarget) | |
186 { | |
187 return OS.objc_msgSend(this.id_, OS.sel_sendAction_1to_1, theAction.ptr, theTarget !is null ? theTarget.id_ : null) !is null; | |
188 } | |
189 | |
190 public NSInteger sendActionOn (NSInteger mask) | |
191 { | |
192 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_sendActionOn_1, mask); | |
193 } | |
194 | |
195 public void setAction (String aSelector) | |
196 { | |
197 OS.objc_msgSend(this.id_, OS.sel_setAction_1, aSelector.ptr); | |
198 } | |
199 | |
200 public void setAlignment (objc.id mode) | |
201 { | |
202 OS.objc_msgSend(this.id_, OS.sel_setAlignment_1, mode); | |
203 } | |
204 | |
205 public void setAttributedStringValue (NSAttributedString obj) | |
206 { | |
207 OS.objc_msgSend(this.id_, OS.sel_setAttributedStringValue_1, obj !is null ? obj.id_ : null); | |
208 } | |
209 | |
210 public void setBaseWritingDirection (objc.id writingDirection) | |
211 { | |
212 OS.objc_msgSend(this.id_, OS.sel_setBaseWritingDirection_1, writingDirection); | |
213 } | |
214 | |
215 public void setCell (NSCell aCell) | |
216 { | |
217 OS.objc_msgSend(this.id_, OS.sel_setCell_1, aCell !is null ? aCell.id_ : null); | |
218 } | |
219 | |
220 public static void setCellClass (objc.Class factoryId) | |
221 { | |
222 OS.objc_msgSend(OS.class_NSControl, OS.sel_setCellClass_1, factoryId); | |
223 } | |
224 | |
225 public void setContinuous (bool flag) | |
226 { | |
227 OS.objc_msgSend(this.id_, OS.sel_setContinuous_1, flag); | |
228 } | |
229 | |
230 public void setDoubleValue (double aDouble) | |
231 { | |
232 OS.objc_msgSend(this.id_, OS.sel_setDoubleValue_1, aDouble); | |
233 } | |
234 | |
235 public void setEnabled (bool flag) | |
236 { | |
237 OS.objc_msgSend(this.id_, OS.sel_setEnabled_1, flag); | |
238 } | |
239 | |
240 public void setFloatValue (float aFloat) | |
241 { | |
242 OS.objc_msgSend(this.id_, OS.sel_setFloatValue_1, aFloat); | |
243 } | |
244 | |
245 public void setFloatingPointFormat (bool autoRange, NSUInteger leftDigits, NSUInteger rightDigits) | |
246 { | |
247 OS.objc_msgSend(this.id_, OS.sel_setFloatingPointFormat_1left_1right_1, autoRange, leftDigits, rightDigits); | |
248 } | |
249 | |
250 public void setFont (NSFont fontObj) | |
251 { | |
252 OS.objc_msgSend(this.id_, OS.sel_setFont_1, fontObj !is null ? fontObj.id_ : null); | |
253 } | |
254 | |
255 public void setFormatter (NSFormatter newFormatter) | |
256 { | |
257 OS.objc_msgSend(this.id_, OS.sel_setFormatter_1, newFormatter !is null ? newFormatter.id_ : null); | |
258 } | |
259 | |
260 public void setIgnoresMultiClick (bool flag) | |
261 { | |
262 OS.objc_msgSend(this.id_, OS.sel_setIgnoresMultiClick_1, flag); | |
263 } | |
264 | |
265 public void setIntValue (int anInt) | |
266 { | |
267 OS.objc_msgSend(this.id_, OS.sel_setIntValue_1, anInt); | |
268 } | |
269 | |
270 public void setIntegerValue (NSInteger anInteger) | |
271 { | |
272 OS.objc_msgSend(this.id_, OS.sel_setIntegerValue_1, anInteger); | |
273 } | |
274 | |
275 public void setNeedsDisplay () | |
276 { | |
277 OS.objc_msgSend(this.id_, OS.sel_setNeedsDisplay); | |
278 } | |
279 | |
280 public void setObjectValue (id obj) | |
281 { | |
282 OS.objc_msgSend(this.id_, OS.sel_setObjectValue_1, obj !is null ? obj.id_ : null); | |
283 } | |
284 | |
285 public void setRefusesFirstResponder (bool flag) | |
286 { | |
287 OS.objc_msgSend(this.id_, OS.sel_setRefusesFirstResponder_1, flag); | |
288 } | |
289 | |
290 public void setStringValue (NSString aString) | |
291 { | |
292 OS.objc_msgSend(this.id_, OS.sel_setStringValue_1, aString !is null ? aString.id_ : null); | |
293 } | |
294 | |
295 public void setTag (NSInteger anInt) | |
296 { | |
297 OS.objc_msgSend(this.id_, OS.sel_setTag_1, anInt); | |
298 } | |
299 | |
300 public void setTarget (id anObject) | |
301 { | |
302 OS.objc_msgSend(this.id_, OS.sel_setTarget_1, anObject !is null ? anObject.id_ : null); | |
303 } | |
304 | |
305 public void sizeToFit () | |
306 { | |
307 OS.objc_msgSend(this.id_, OS.sel_sizeToFit); | |
308 } | |
309 | |
310 public NSString stringValue () | |
311 { | |
312 objc.id result = OS.objc_msgSend(this.id_, OS.sel_stringValue); | |
313 return result !is null ? new NSString(result) : null; | |
314 } | |
315 | |
316 public NSInteger tag () | |
317 { | |
318 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_tag); | |
319 } | |
320 | |
321 public void takeDoubleValueFrom (id sender) | |
322 { | |
323 OS.objc_msgSend(this.id_, OS.sel_takeDoubleValueFrom_1, sender !is null ? sender.id_ : null); | |
324 } | |
325 | |
326 public void takeFloatValueFrom (id sender) | |
327 { | |
328 OS.objc_msgSend(this.id_, OS.sel_takeFloatValueFrom_1, sender !is null ? sender.id_ : null); | |
329 } | |
330 | |
331 public void takeIntValueFrom (id sender) | |
332 { | |
333 OS.objc_msgSend(this.id_, OS.sel_takeIntValueFrom_1, sender !is null ? sender.id_ : null); | |
334 } | |
335 | |
336 public void takeIntegerValueFrom (id sender) | |
337 { | |
338 OS.objc_msgSend(this.id_, OS.sel_takeIntegerValueFrom_1, sender !is null ? sender.id_ : null); | |
339 } | |
340 | |
341 public void takeObjectValueFrom (id sender) | |
342 { | |
343 OS.objc_msgSend(this.id_, OS.sel_takeObjectValueFrom_1, sender !is null ? sender.id_ : null); | |
344 } | |
345 | |
346 public void takeStringValueFrom (id sender) | |
347 { | |
348 OS.objc_msgSend(this.id_, OS.sel_takeStringValueFrom_1, sender !is null ? sender.id_ : null); | |
349 } | |
350 | |
351 public id target () | |
352 { | |
353 objc.id result = OS.objc_msgSend(this.id_, OS.sel_target); | |
354 return result !is null ? new id(result) : null; | |
355 } | |
356 | |
357 public void updateCell (NSCell aCell) | |
358 { | |
359 OS.objc_msgSend(this.id_, OS.sel_updateCell_1, aCell !is null ? aCell.id_ : null); | |
360 } | |
361 | |
362 public void updateCellInside (NSCell aCell) | |
363 { | |
364 OS.objc_msgSend(this.id_, OS.sel_updateCellInside_1, aCell !is null ? aCell.id_ : null); | |
365 } | |
366 | |
367 public void validateEditing () | |
368 { | |
369 OS.objc_msgSend(this.id_, OS.sel_validateEditing); | |
370 } | |
371 | 121 |
372 } | 122 } |