Mercurial > projects > dstep
comparison dstep/appkit/NSButton.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.NSButton; | |
8 | |
9 import dstep.appkit.NSButtonCell; | |
10 import dstep.appkit.NSControl; | |
11 import dstep.appkit.NSEvent; | |
12 import dstep.appkit.NSImage; | |
13 import dstep.appkit.NSSound; | |
14 import dstep.appkit.NSUserInterfaceValidation; | |
15 import dstep.foundation.NSAttributedString; | |
16 import dstep.foundation.NSObjCRuntime; | |
17 import dstep.foundation.NSString; | |
18 import dstep.objc.bridge.Bridge; | |
19 import dstep.objc.objc; | |
20 | |
21 const TNSButtonMixedState = ` | |
22 | |
23 void setAllowsMixedState (bool flag) | |
24 { | |
25 return invokeObjcSelf!(void, "setAllowsMixedState:", bool)(flag); | |
26 } | |
27 | |
28 bool allowsMixedState () | |
29 { | |
30 return invokeObjcSelf!(bool, "allowsMixedState"); | |
31 } | |
32 | |
33 void setNextState () | |
34 { | |
35 return invokeObjcSelf!(void, "setNextState"); | |
36 } | |
37 | |
38 //mixin ObjcBindMethod!(setAllowsMixedState, "setAllowsMixedState:"); | |
39 //mixin ObjcBindMethod!(allowsMixedState, "allowsMixedState"); | |
40 //mixin ObjcBindMethod!(setNextState, "setNextState"); | |
41 | |
42 `; | |
43 | |
44 const TNSButtonAttributedStringMethods = ` | |
45 | |
46 NSAttributedString attributedTitle () | |
47 { | |
48 return invokeObjcSelf!(NSAttributedString, "attributedTitle"); | |
49 } | |
50 | |
51 void setAttributedTitle (NSAttributedString aString) | |
52 { | |
53 return invokeObjcSelf!(void, "setAttributedTitle:", NSAttributedString)(aString); | |
54 } | |
55 | |
56 NSAttributedString attributedAlternateTitle () | |
57 { | |
58 return invokeObjcSelf!(NSAttributedString, "attributedAlternateTitle"); | |
59 } | |
60 | |
61 void setAttributedAlternateTitle (NSAttributedString obj) | |
62 { | |
63 return invokeObjcSelf!(void, "setAttributedAlternateTitle:", NSAttributedString)(obj); | |
64 } | |
65 | |
66 //mixin ObjcBindMethod!(attributedTitle, "attributedTitle"); | |
67 //mixin ObjcBindMethod!(setAttributedTitle, "setAttributedTitle:"); | |
68 //mixin ObjcBindMethod!(attributedAlternateTitle, "attributedAlternateTitle"); | |
69 //mixin ObjcBindMethod!(setAttributedAlternateTitle, "setAttributedAlternateTitle:"); | |
70 | |
71 `; | |
72 | |
73 const TNSButtonSoundExtensions = ` | |
74 | |
75 void setSound (NSSound aSound) | |
76 { | |
77 return invokeObjcSelf!(void, "setSound:", NSSound)(aSound); | |
78 } | |
79 | |
80 NSSound sound () | |
81 { | |
82 return invokeObjcSelf!(NSSound, "sound"); | |
83 } | |
84 | |
85 //mixin ObjcBindMethod!(setSound, "setSound:"); | |
86 //mixin ObjcBindMethod!(sound, "sound"); | |
87 | |
88 `; | |
89 | |
90 const TNSButtonBezelStyles = ` | |
91 | |
92 void setBezelStyle (uint bezelStyle) | |
93 { | |
94 return invokeObjcSelf!(void, "setBezelStyle:", uint)(bezelStyle); | |
95 } | |
96 | |
97 uint bezelStyle () | |
98 { | |
99 return invokeObjcSelf!(uint, "bezelStyle"); | |
100 } | |
101 | |
102 //mixin ObjcBindMethod!(setBezelStyle, "setBezelStyle:"); | |
103 //mixin ObjcBindMethod!(bezelStyle, "bezelStyle"); | |
104 | |
105 `; | |
106 | |
107 const TNSButtonBorder = ` | |
108 | |
109 void setShowsBorderOnlyWhileMouseInside (bool show) | |
110 { | |
111 return invokeObjcSelf!(void, "setShowsBorderOnlyWhileMouseInside:", bool)(show); | |
112 } | |
113 | |
114 bool showsBorderOnlyWhileMouseInside () | |
115 { | |
116 return invokeObjcSelf!(bool, "showsBorderOnlyWhileMouseInside"); | |
117 } | |
118 | |
119 //mixin ObjcBindMethod!(setShowsBorderOnlyWhileMouseInside, "setShowsBorderOnlyWhileMouseInside:"); | |
120 //mixin ObjcBindMethod!(showsBorderOnlyWhileMouseInside, "showsBorderOnlyWhileMouseInside"); | |
121 | |
122 `; | |
123 | |
124 class NSButton : NSControl, INSUserInterfaceValidations | |
125 { | |
126 mixin (ObjcWrap); | |
127 | |
128 NSString title () | |
129 { | |
130 return invokeObjcSelf!(NSString, "title"); | |
131 } | |
132 | |
133 void setTitle (NSString aString) | |
134 { | |
135 return invokeObjcSelf!(void, "setTitle:", NSString)(aString); | |
136 } | |
137 | |
138 NSString alternateTitle () | |
139 { | |
140 return invokeObjcSelf!(NSString, "alternateTitle"); | |
141 } | |
142 | |
143 void setAlternateTitle (NSString aString) | |
144 { | |
145 return invokeObjcSelf!(void, "setAlternateTitle:", NSString)(aString); | |
146 } | |
147 | |
148 NSImage image () | |
149 { | |
150 return invokeObjcSelf!(NSImage, "image"); | |
151 } | |
152 | |
153 void setImage (NSImage image) | |
154 { | |
155 return invokeObjcSelf!(void, "setImage:", NSImage)(image); | |
156 } | |
157 | |
158 NSImage alternateImage () | |
159 { | |
160 return invokeObjcSelf!(NSImage, "alternateImage"); | |
161 } | |
162 | |
163 void setAlternateImage (NSImage image) | |
164 { | |
165 return invokeObjcSelf!(void, "setAlternateImage:", NSImage)(image); | |
166 } | |
167 | |
168 uint imagePosition () | |
169 { | |
170 return invokeObjcSelf!(uint, "imagePosition"); | |
171 } | |
172 | |
173 void setImagePosition (uint aPosition) | |
174 { | |
175 return invokeObjcSelf!(void, "setImagePosition:", uint)(aPosition); | |
176 } | |
177 | |
178 void setButtonType (uint aType) | |
179 { | |
180 return invokeObjcSelf!(void, "setButtonType:", uint)(aType); | |
181 } | |
182 | |
183 NSInteger state () | |
184 { | |
185 return invokeObjcSelf!(NSInteger, "state"); | |
186 } | |
187 | |
188 void setState (NSInteger value) | |
189 { | |
190 return invokeObjcSelf!(void, "setState:", NSInteger)(value); | |
191 } | |
192 | |
193 bool isBordered () | |
194 { | |
195 return invokeObjcSelf!(bool, "isBordered"); | |
196 } | |
197 | |
198 void setBordered (bool flag) | |
199 { | |
200 return invokeObjcSelf!(void, "setBordered:", bool)(flag); | |
201 } | |
202 | |
203 bool isTransparent () | |
204 { | |
205 return invokeObjcSelf!(bool, "isTransparent"); | |
206 } | |
207 | |
208 void setTransparent (bool flag) | |
209 { | |
210 return invokeObjcSelf!(void, "setTransparent:", bool)(flag); | |
211 } | |
212 | |
213 void setPeriodicDelay (float delay, float interval) | |
214 { | |
215 return invokeObjcSelf!(void, "setPeriodicDelay:interval:", float, float)(delay, interval); | |
216 } | |
217 | |
218 void getPeriodicDelay (float* delay, float* interval) | |
219 { | |
220 return invokeObjcSelf!(void, "getPeriodicDelay:interval:", float*, float*)(delay, interval); | |
221 } | |
222 | |
223 NSString keyEquivalent () | |
224 { | |
225 return invokeObjcSelf!(NSString, "keyEquivalent"); | |
226 } | |
227 | |
228 void setKeyEquivalent (NSString charCode) | |
229 { | |
230 return invokeObjcSelf!(void, "setKeyEquivalent:", NSString)(charCode); | |
231 } | |
232 | |
233 NSUInteger keyEquivalentModifierMask () | |
234 { | |
235 return invokeObjcSelf!(NSUInteger, "keyEquivalentModifierMask"); | |
236 } | |
237 | |
238 void setKeyEquivalentModifierMask (NSUInteger mask) | |
239 { | |
240 return invokeObjcSelf!(void, "setKeyEquivalentModifierMask:", NSUInteger)(mask); | |
241 } | |
242 | |
243 void highlight (bool flag) | |
244 { | |
245 return invokeObjcSelf!(void, "highlight:", bool)(flag); | |
246 } | |
247 | |
248 bool performKeyEquivalent (NSEvent key) | |
249 { | |
250 return invokeObjcSelf!(bool, "performKeyEquivalent:", NSEvent)(key); | |
251 } | |
252 | |
253 bool validateUserInterfaceItem (INSValidatedUserInterfaceItem anItem) | |
254 { | |
255 return invokeObjcSelf!(bool, "validateUserInterfaceItem:", INSValidatedUserInterfaceItem)(anItem); | |
256 } | |
257 | |
258 // NSButtonMixedState | |
259 void setAllowsMixedState (bool flag) | |
260 { | |
261 return invokeObjcSelf!(void, "setAllowsMixedState:", bool)(flag); | |
262 } | |
263 | |
264 bool allowsMixedState () | |
265 { | |
266 return invokeObjcSelf!(bool, "allowsMixedState"); | |
267 } | |
268 | |
269 void setNextState () | |
270 { | |
271 return invokeObjcSelf!(void, "setNextState"); | |
272 } | |
273 | |
274 // NSButtonAttributedStringMethods | |
275 NSAttributedString attributedTitle () | |
276 { | |
277 return invokeObjcSelf!(NSAttributedString, "attributedTitle"); | |
278 } | |
279 | |
280 void setAttributedTitle (NSAttributedString aString) | |
281 { | |
282 return invokeObjcSelf!(void, "setAttributedTitle:", NSAttributedString)(aString); | |
283 } | |
284 | |
285 NSAttributedString attributedAlternateTitle () | |
286 { | |
287 return invokeObjcSelf!(NSAttributedString, "attributedAlternateTitle"); | |
288 } | |
289 | |
290 void setAttributedAlternateTitle (NSAttributedString obj) | |
291 { | |
292 return invokeObjcSelf!(void, "setAttributedAlternateTitle:", NSAttributedString)(obj); | |
293 } | |
294 | |
295 // NSButtonSoundExtensions | |
296 void setSound (NSSound aSound) | |
297 { | |
298 return invokeObjcSelf!(void, "setSound:", NSSound)(aSound); | |
299 } | |
300 | |
301 NSSound sound () | |
302 { | |
303 return invokeObjcSelf!(NSSound, "sound"); | |
304 } | |
305 | |
306 // NSButtonBezelStyles | |
307 void setBezelStyle (uint bezelStyle) | |
308 { | |
309 return invokeObjcSelf!(void, "setBezelStyle:", uint)(bezelStyle); | |
310 } | |
311 | |
312 uint bezelStyle () | |
313 { | |
314 return invokeObjcSelf!(uint, "bezelStyle"); | |
315 } | |
316 | |
317 // NSButtonBorder | |
318 void setShowsBorderOnlyWhileMouseInside (bool show) | |
319 { | |
320 return invokeObjcSelf!(void, "setShowsBorderOnlyWhileMouseInside:", bool)(show); | |
321 } | |
322 | |
323 bool showsBorderOnlyWhileMouseInside () | |
324 { | |
325 return invokeObjcSelf!(bool, "showsBorderOnlyWhileMouseInside"); | |
326 } | |
327 } |