Mercurial > projects > dstep
comparison dstep/appkit/NSComboBox.d @ 16:19885b43130e
Huge update, the bridge actually works now
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sun, 03 Jan 2010 22:06:11 +0100 |
parents | |
children | b9de51448c6b |
comparison
equal
deleted
inserted
replaced
15:7ff919f595d5 | 16:19885b43130e |
---|---|
1 /** | |
2 * Copyright: Copyright (c) 2009 Jacob Carlborg. | |
3 * Authors: Jacob Carlborg | |
4 * Version: Initial created: Sep 24, 2009 | |
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) | |
6 */ | |
7 module dstep.appkit.NSComboBox; | |
8 | |
9 import dstep.appkit.NSTextField; | |
10 import dstep.applicationservices.coregraphics.CGBase; | |
11 import dstep.foundation.NSArray; | |
12 import dstep.foundation.NSGeometry; | |
13 import dstep.foundation.NSObjCRuntime; | |
14 import dstep.foundation.NSString; | |
15 import dstep.objc.bridge.Bridge; | |
16 import dstep.objc.objc; | |
17 | |
18 import bindings = dstep.appkit.NSComboBox_bindings; | |
19 | |
20 private | |
21 { | |
22 NSString NSComboBoxWillPopUpNotification_; | |
23 NSString NSComboBoxWillDismissNotification_; | |
24 NSString NSComboBoxSelectionDidChangeNotification_; | |
25 NSString NSComboBoxSelectionIsChangingNotification_; | |
26 } | |
27 | |
28 NSString NSComboBoxWillPopUpNotification () | |
29 { | |
30 if (NSComboBoxWillPopUpNotification_) | |
31 return NSComboBoxWillPopUpNotification_; | |
32 | |
33 return NSComboBoxWillPopUpNotification_ = new NSString(bindings.NSComboBoxWillPopUpNotification); | |
34 } | |
35 | |
36 NSString NSComboBoxWillDismissNotification () | |
37 { | |
38 if (NSComboBoxWillDismissNotification_) | |
39 return NSComboBoxWillDismissNotification_; | |
40 | |
41 return NSComboBoxWillDismissNotification_ = new NSString(bindings.NSComboBoxWillDismissNotification); | |
42 } | |
43 | |
44 NSString NSComboBoxSelectionDidChangeNotification () | |
45 { | |
46 if (NSComboBoxSelectionDidChangeNotification_) | |
47 return NSComboBoxSelectionDidChangeNotification_; | |
48 | |
49 return NSComboBoxSelectionDidChangeNotification_ = new NSString(bindings.NSComboBoxSelectionDidChangeNotification); | |
50 } | |
51 | |
52 NSString NSComboBoxSelectionIsChangingNotification () | |
53 { | |
54 if (NSComboBoxSelectionIsChangingNotification_) | |
55 return NSComboBoxSelectionIsChangingNotification_; | |
56 | |
57 return NSComboBoxSelectionIsChangingNotification_ = new NSString(bindings.NSComboBoxSelectionIsChangingNotification); | |
58 } | |
59 | |
60 class NSComboBox : NSTextField | |
61 { | |
62 mixin (ObjcWrap); | |
63 | |
64 bool hasVerticalScroller () | |
65 { | |
66 return invokeObjcSelf!(bool, "hasVerticalScroller"); | |
67 } | |
68 | |
69 void setHasVerticalScroller (bool flag) | |
70 { | |
71 return invokeObjcSelf!(void, "setHasVerticalScroller:", bool)(flag); | |
72 } | |
73 | |
74 NSSize intercellSpacing () | |
75 { | |
76 return invokeObjcSelf!(NSSize, "intercellSpacing"); | |
77 } | |
78 | |
79 void setIntercellSpacing (NSSize aSize) | |
80 { | |
81 return invokeObjcSelf!(void, "setIntercellSpacing:", NSSize)(aSize); | |
82 } | |
83 | |
84 CGFloat itemHeight () | |
85 { | |
86 return invokeObjcSelf!(CGFloat, "itemHeight"); | |
87 } | |
88 | |
89 void setItemHeight (CGFloat itemHeight) | |
90 { | |
91 return invokeObjcSelf!(void, "setItemHeight:", CGFloat)(itemHeight); | |
92 } | |
93 | |
94 NSInteger numberOfVisibleItems () | |
95 { | |
96 return invokeObjcSelf!(NSInteger, "numberOfVisibleItems"); | |
97 } | |
98 | |
99 void setNumberOfVisibleItems (NSInteger visibleItems) | |
100 { | |
101 return invokeObjcSelf!(void, "setNumberOfVisibleItems:", NSInteger)(visibleItems); | |
102 } | |
103 | |
104 void setButtonBordered (bool flag) | |
105 { | |
106 return invokeObjcSelf!(void, "setButtonBordered:", bool)(flag); | |
107 } | |
108 | |
109 bool isButtonBordered () | |
110 { | |
111 return invokeObjcSelf!(bool, "isButtonBordered"); | |
112 } | |
113 | |
114 void reloadData () | |
115 { | |
116 return invokeObjcSelf!(void, "reloadData"); | |
117 } | |
118 | |
119 void noteNumberOfItemsChanged () | |
120 { | |
121 return invokeObjcSelf!(void, "noteNumberOfItemsChanged"); | |
122 } | |
123 | |
124 void setUsesDataSource (bool flag) | |
125 { | |
126 return invokeObjcSelf!(void, "setUsesDataSource:", bool)(flag); | |
127 } | |
128 | |
129 bool usesDataSource () | |
130 { | |
131 return invokeObjcSelf!(bool, "usesDataSource"); | |
132 } | |
133 | |
134 void scrollItemAtIndexToTop (NSInteger index) | |
135 { | |
136 return invokeObjcSelf!(void, "scrollItemAtIndexToTop:", NSInteger)(index); | |
137 } | |
138 | |
139 void scrollItemAtIndexToVisible (NSInteger index) | |
140 { | |
141 return invokeObjcSelf!(void, "scrollItemAtIndexToVisible:", NSInteger)(index); | |
142 } | |
143 | |
144 void selectItemAtIndex (NSInteger index) | |
145 { | |
146 return invokeObjcSelf!(void, "selectItemAtIndex:", NSInteger)(index); | |
147 } | |
148 | |
149 void deselectItemAtIndex (NSInteger index) | |
150 { | |
151 return invokeObjcSelf!(void, "deselectItemAtIndex:", NSInteger)(index); | |
152 } | |
153 | |
154 NSInteger indexOfSelectedItem () | |
155 { | |
156 return invokeObjcSelf!(NSInteger, "indexOfSelectedItem"); | |
157 } | |
158 | |
159 NSInteger numberOfItems () | |
160 { | |
161 return invokeObjcSelf!(NSInteger, "numberOfItems"); | |
162 } | |
163 | |
164 bool completes () | |
165 { | |
166 return invokeObjcSelf!(bool, "completes"); | |
167 } | |
168 | |
169 void setCompletes (bool completes) | |
170 { | |
171 return invokeObjcSelf!(void, "setCompletes:", bool)(completes); | |
172 } | |
173 | |
174 Object dataSource () | |
175 { | |
176 return invokeObjcSelf!(Object, "dataSource"); | |
177 } | |
178 | |
179 void setDataSource (Object aSource) | |
180 { | |
181 return invokeObjcSelf!(void, "setDataSource:", Object)(aSource); | |
182 } | |
183 | |
184 void addItemWithObjectValue (Object object) | |
185 { | |
186 return invokeObjcSelf!(void, "addItemWithObjectValue:", Object)(object); | |
187 } | |
188 | |
189 void addItemsWithObjectValues (NSArray objects) | |
190 { | |
191 return invokeObjcSelf!(void, "addItemsWithObjectValues:", NSArray)(objects); | |
192 } | |
193 | |
194 void insertItemWithObjectValue (Object object, NSInteger index) | |
195 { | |
196 return invokeObjcSelf!(void, "insertItemWithObjectValue:atIndex:", Object, NSInteger)(object, index); | |
197 } | |
198 | |
199 void removeItemWithObjectValue (Object object) | |
200 { | |
201 return invokeObjcSelf!(void, "removeItemWithObjectValue:", Object)(object); | |
202 } | |
203 | |
204 void removeItemAtIndex (NSInteger index) | |
205 { | |
206 return invokeObjcSelf!(void, "removeItemAtIndex:", NSInteger)(index); | |
207 } | |
208 | |
209 void removeAllItems () | |
210 { | |
211 return invokeObjcSelf!(void, "removeAllItems"); | |
212 } | |
213 | |
214 void selectItemWithObjectValue (Object object) | |
215 { | |
216 return invokeObjcSelf!(void, "selectItemWithObjectValue:", Object)(object); | |
217 } | |
218 | |
219 Object itemObjectValueAtIndex (NSInteger index) | |
220 { | |
221 return invokeObjcSelf!(Object, "itemObjectValueAtIndex:", NSInteger)(index); | |
222 } | |
223 | |
224 Object objectValueOfSelectedItem () | |
225 { | |
226 return invokeObjcSelf!(Object, "objectValueOfSelectedItem"); | |
227 } | |
228 | |
229 NSInteger indexOfItemWithObjectValue (Object object) | |
230 { | |
231 return invokeObjcSelf!(NSInteger, "indexOfItemWithObjectValue:", Object)(object); | |
232 } | |
233 | |
234 NSArray objectValues () | |
235 { | |
236 return invokeObjcSelf!(NSArray, "objectValues"); | |
237 } | |
238 } | |
239 | |
240 const TNSComboBoxDataSource = ` | |
241 | |
242 NSInteger numberOfItemsInComboBox (NSComboBox aComboBox) | |
243 { | |
244 return invokeObjcSelf!(NSInteger, "numberOfItemsInComboBox:", NSComboBox)(aComboBox); | |
245 } | |
246 | |
247 Object comboBox (NSComboBox aComboBox, NSInteger index) | |
248 { | |
249 return invokeObjcSelf!(Object, "comboBox:objectValueForItemAtIndex:", NSComboBox, NSInteger)(aComboBox, index); | |
250 } | |
251 | |
252 NSUInteger comboBox (NSComboBox aComboBox, NSString string) | |
253 { | |
254 return invokeObjcSelf!(NSUInteger, "comboBox:indexOfItemWithStringValue:", NSComboBox, NSString)(aComboBox, string); | |
255 } | |
256 | |
257 NSString comboBox (NSComboBox aComboBox, NSString string) | |
258 { | |
259 return invokeObjcSelf!(NSString, "comboBox:completedString:", NSComboBox, NSString)(aComboBox, string); | |
260 } | |
261 | |
262 //mixin ObjcBindMethod!(numberOfItemsInComboBox, "numberOfItemsInComboBox:"); | |
263 //mixin ObjcBindMethod!(comboBox, "comboBox:objectValueForItemAtIndex:"); | |
264 //mixin ObjcBindMethod!(comboBox, "comboBox:indexOfItemWithStringValue:"); | |
265 //mixin ObjcBindMethod!(comboBox, "comboBox:completedString:"); | |
266 | |
267 `; | |
268 | |
269 const TNSComboBoxNotifications = ` | |
270 | |
271 void comboBoxWillPopUp (NSNotification notification) | |
272 { | |
273 return invokeObjcSelf!(void, "comboBoxWillPopUp:", NSNotification)(notification); | |
274 } | |
275 | |
276 void comboBoxWillDismiss (NSNotification notification) | |
277 { | |
278 return invokeObjcSelf!(void, "comboBoxWillDismiss:", NSNotification)(notification); | |
279 } | |
280 | |
281 void comboBoxSelectionDidChange (NSNotification notification) | |
282 { | |
283 return invokeObjcSelf!(void, "comboBoxSelectionDidChange:", NSNotification)(notification); | |
284 } | |
285 | |
286 void comboBoxSelectionIsChanging (NSNotification notification) | |
287 { | |
288 return invokeObjcSelf!(void, "comboBoxSelectionIsChanging:", NSNotification)(notification); | |
289 } | |
290 | |
291 //mixin ObjcBindMethod!(comboBoxWillPopUp, "comboBoxWillPopUp:"); | |
292 //mixin ObjcBindMethod!(comboBoxWillDismiss, "comboBoxWillDismiss:"); | |
293 //mixin ObjcBindMethod!(comboBoxSelectionDidChange, "comboBoxSelectionDidChange:"); | |
294 //mixin ObjcBindMethod!(comboBoxSelectionIsChanging, "comboBoxSelectionIsChanging:"); | |
295 | |
296 `; | |
297 |