Mercurial > projects > dwt-mac
comparison dwt/widgets/Button.d @ 37:642f460a0908
Fixed a lot of compile errors, a "hello world" app compiles now
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Fri, 10 Oct 2008 12:29:48 +0200 |
parents | db5a898b2119 |
children | d8635bb48c7c |
comparison
equal
deleted
inserted
replaced
36:db5a898b2119 | 37:642f460a0908 |
---|---|
31 import dwt.internal.cocoa.OS; | 31 import dwt.internal.cocoa.OS; |
32 import dwt.internal.cocoa.SWTButton; | 32 import dwt.internal.cocoa.SWTButton; |
33 | 33 |
34 import dwt.dwthelper.utils; | 34 import dwt.dwthelper.utils; |
35 import dwt.internal.cocoa.CGFloat; | 35 import dwt.internal.cocoa.CGFloat; |
36 import dwt.internal.cocoa.NSCell; | |
36 import dwt.internal.cocoa.NSInteger; | 37 import dwt.internal.cocoa.NSInteger; |
38 import dwt.internal.cocoa.NSText; | |
37 import dwt.widgets.Composite; | 39 import dwt.widgets.Composite; |
38 import dwt.widgets.Control; | 40 import dwt.widgets.Control; |
39 import dwt.widgets.Decorations; | 41 import dwt.widgets.Decorations; |
40 import dwt.widgets.TypedListener; | 42 import dwt.widgets.TypedListener; |
41 | 43 |
165 dict.setObject(color, OS.NSForegroundColorAttributeName()); | 167 dict.setObject(color, OS.NSForegroundColorAttributeName()); |
166 } | 168 } |
167 if (font !is null) { | 169 if (font !is null) { |
168 dict.setObject(font.handle, OS.NSFontAttributeName()); | 170 dict.setObject(font.handle, OS.NSFontAttributeName()); |
169 } | 171 } |
170 int alignment; | 172 NSTextAlignment alignment; |
171 if ((style & DWT.CENTER) !is 0) { | 173 if ((style & DWT.CENTER) !is 0) { |
172 alignment = OS.NSCenterTextAlignment; | 174 alignment = NSCenterTextAlignment; |
173 } else if ((style & DWT.LEFT) !is 0) { | 175 } else if ((style & DWT.LEFT) !is 0) { |
174 alignment = OS.NSLeftTextAlignment; | 176 alignment = NSLeftTextAlignment; |
175 } else { | 177 } else { |
176 alignment = OS.NSRightTextAlignment; | 178 alignment = NSRightTextAlignment; |
177 } | 179 } |
178 NSMutableParagraphStyle pStyle = cast(NSMutableParagraphStyle)(new NSMutableParagraphStyle()).alloc().init(); | 180 NSMutableParagraphStyle pStyle = cast(NSMutableParagraphStyle)(new NSMutableParagraphStyle()).alloc().init(); |
179 pStyle.autorelease(); | 181 pStyle.autorelease(); |
180 pStyle.setAlignment(alignment); | 182 pStyle.setAlignment(alignment); |
181 dict.setObject(pStyle, OS.NSParagraphStyleAttributeName()); | 183 dict.setObject(pStyle, OS.NSParagraphStyleAttributeName()); |
189 } | 191 } |
190 | 192 |
191 void createHandle () { | 193 void createHandle () { |
192 NSButton widget = cast(NSButton)(new SWTButton()).alloc(); | 194 NSButton widget = cast(NSButton)(new SWTButton()).alloc(); |
193 widget.initWithFrame(NSRect()); | 195 widget.initWithFrame(NSRect()); |
194 int type = OS.NSMomentaryPushButton; | 196 NSButtonType type = NSMomentaryPushButton; |
195 if ((style & DWT.PUSH) !is 0) { | 197 if ((style & DWT.PUSH) !is 0) { |
196 widget.setBezelStyle(OS.NSRoundedBezelStyle); | 198 widget.setBezelStyle(NSRoundedBezelStyle); |
197 } else if ((style & DWT.CHECK) !is 0) { | 199 } else if ((style & DWT.CHECK) !is 0) { |
198 type = OS.NSSwitchButton; | 200 type = NSSwitchButton; |
199 widget.setAllowsMixedState (true); | 201 widget.setAllowsMixedState (true); |
200 } else if ((style & DWT.RADIO) !is 0) { | 202 } else if ((style & DWT.RADIO) !is 0) { |
201 type = OS.NSRadioButton; | 203 type = NSRadioButton; |
202 } else if ((style & DWT.TOGGLE) !is 0) { | 204 } else if ((style & DWT.TOGGLE) !is 0) { |
203 type = OS.NSPushOnPushOffButton; | 205 type = NSPushOnPushOffButton; |
204 widget.setBezelStyle(OS.NSRegularSquareBezelStyle); | 206 widget.setBezelStyle(NSRegularSquareBezelStyle); |
205 } else if ((style & DWT.ARROW) !is 0) { | 207 } else if ((style & DWT.ARROW) !is 0) { |
206 widget.setBezelStyle(OS.NSRoundedDisclosureBezelStyle); | 208 widget.setBezelStyle(NSRoundedDisclosureBezelStyle); |
207 } | 209 } |
208 widget.setButtonType(type); | 210 widget.setButtonType(type); |
209 widget.setTitle(NSString.stringWith("")); | 211 widget.setTitle(NSString.stringWith("")); |
210 widget.setImagePosition(OS.NSImageLeft); | 212 widget.setImagePosition(NSImageLeft); |
211 widget.setTarget(widget); | 213 widget.setTarget(widget); |
212 widget.setAction(OS.sel_sendSelection); | 214 widget.setAction(OS.sel_sendSelection); |
213 widget.setTag(jniRef); | 215 widget.setTag(jniRef); |
214 view = widget; | 216 view = widget; |
215 parent.contentView().addSubview_(widget); | 217 parent.contentView().addSubview_(widget); |