# HG changeset patch # User Jacob Carlborg # Date 1228682442 -3600 # Node ID 858e9a565d62dfcbc05a320df96fce937073dd2c # Parent e6f04eb518aea38263b81c5d880a3559ef1dd9ea Updated Button to 3.514 diff -r e6f04eb518ae -r 858e9a565d62 dwt/internal/cocoa/NSButton.d --- a/dwt/internal/cocoa/NSButton.d Sun Dec 07 21:24:13 2008 +0100 +++ b/dwt/internal/cocoa/NSButton.d Sun Dec 07 21:40:42 2008 +0100 @@ -20,10 +20,9 @@ import dwt.internal.cocoa.NSControl; import dwt.internal.cocoa.NSEvent; import dwt.internal.cocoa.NSImage; -import dwt.internal.cocoa.NSInteger; -import dwt.internal.cocoa.NSSound; import dwt.internal.cocoa.NSString; import dwt.internal.cocoa.OS; +import dwt.internal.objc.cocoa.Cocoa; import objc = dwt.internal.objc.runtime; public class NSButton : NSControl { diff -r e6f04eb518ae -r 858e9a565d62 dwt/internal/cocoa/OS.d --- a/dwt/internal/cocoa/OS.d Sun Dec 07 21:24:13 2008 +0100 +++ b/dwt/internal/cocoa/OS.d Sun Dec 07 21:40:42 2008 +0100 @@ -25,6 +25,8 @@ import dwt.internal.cocoa.CGSize; import dwt.internal.cocoa.NSAffineTransformStruct; import dwt.internal.cocoa.NSBitmapImageRep; +import dwt.internal.cocoa.NSButtonCell; +import dwt.internal.cocoa.NSCell; import dwt.internal.cocoa.NSImage; import dwt.internal.cocoa.NSParagraphStyle; import dwt.internal.cocoa.NSPoint; @@ -2915,7 +2917,7 @@ public static const int NSImageInterpolationHigh = 3; public static const int NSImageInterpolationLow = 2; public static const int NSImageInterpolationNone = 1; -public static const int NSImageLeft = 2; +alias NSCellImagePosition.NSImageLeft NSImageLeft; public static const int NSImageLoadStatusCancelled = 1; public static const int NSImageLoadStatusCompleted = 0; public static const int NSImageLoadStatusInvalidData = 2; @@ -2995,7 +2997,7 @@ public static const int NSModeSwitchFunctionKey = 63303; public static const int NSMomentaryChangeButton = 5; public static const int NSMomentaryLight = 7; -public static const int NSMomentaryLightButton = 0; +alias NSButtonType.NSMomentaryLightButton NSMomentaryLightButton; public static const int NSMomentaryPushButton = 0; public static const int NSMomentaryPushInButton = 7; public static const int NSMouseEntered = 8; @@ -3143,20 +3145,20 @@ public static const int NSProgressIndicatorSpinningStyle = 1; public static const int NSPushInCell = 2; public static const int NSPushInCellMask = 2; -public static const int NSPushOnPushOffButton = 1; +alias NSButtonType.NSPushOnPushOffButton NSPushOnPushOffButton; public static const int NSQTMovieLoopingBackAndForthPlayback = 2; public static const int NSQTMovieLoopingPlayback = 1; public static const int NSQTMovieNormalPlayback = 0; public static const int NSRGBColorSpaceModel = 1; public static const int NSRGBModeColorPanel = 1; -public static const int NSRadioButton = 4; +alias NSButtonType.NSRadioButton NSRadioButton; public static const int NSRadioModeMatrix = 0; public static const int NSRangeDateMode = 1; public static const int NSRatingLevelIndicatorStyle = 3; public static const int NSRecessedBezelStyle = 13; public static const int NSRedoFunctionKey = 63300; public static const int NSRegularControlSize = 0; -public static const int NSRegularSquareBezelStyle = 2; +alias NSBezelStyle.NSRegularSquareBezelStyle NSRegularSquareBezelStyle; public static const int NSRelevancyLevelIndicatorStyle = 0; public static const int NSRemoveTraitFontAction = 7; public static const int NSResetCursorRectsRunLoopOrdering = 700000; @@ -3172,12 +3174,12 @@ public static const int NSRightMouseUpMask = 16; public static const int NSRightTabStopType = 1; public static const int NSRightTabsBezelBorder = 3; -public static const int NSRightTextAlignment = 1; +alias NSTextAlignment.NSRightTextAlignment NSRightTextAlignment; public static const int NSRightTextMovement = 20; public static const int NSRoundLineCapStyle = 1; public static const int NSRoundLineJoinStyle = 1; public static const int NSRoundRectBezelStyle = 12; -public static const int NSRoundedBezelStyle = 1; +alias NSBezelStyle.NSRoundedBezelStyle NSRoundedBezelStyle; public static const int NSRoundedDisclosureBezelStyle = 14; public static const int NSRoundedTokenStyle = 2; public static const int NSRuleEditorNestingModeCompound = 2; @@ -3244,7 +3246,7 @@ public static const int NSServiceMalformedServiceDictionaryError = 66564; public static const int NSServiceMiscellaneousError = 66800; public static const int NSServiceRequestTimedOutError = 66562; -public static const int NSShadowlessSquareBezelStyle = 6; +alias NSBezelStyle.NSShadowlessSquareBezelStyle NSShadowlessSquareBezelStyle; public static const int NSShiftKeyMask = 131072; public static const int NSShowControlGlyphs = 1; public static const int NSShowInvisibleGlyphs = 2; @@ -3275,7 +3277,7 @@ public static const int NSStringDrawingUsesFontLeading = 2; public static const int NSStringDrawingUsesLineFragmentOrigin = 1; public static const int NSSubmenuWindowLevel = 3; -public static const int NSSwitchButton = 3; +alias NSButtonType.NSSwitchButton NSSwitchButton; public static const int NSSysReqFunctionKey = 63281; public static const int NSSystemDefined = 14; public static const int NSSystemDefinedMask = 16384; diff -r e6f04eb518ae -r 858e9a565d62 dwt/internal/objc/cocoa/bindings.d --- a/dwt/internal/objc/cocoa/bindings.d Sun Dec 07 21:24:13 2008 +0100 +++ b/dwt/internal/objc/cocoa/bindings.d Sun Dec 07 21:40:42 2008 +0100 @@ -8,7 +8,6 @@ module dwt.internal.objc.cocoa.bindings; import dwt.internal.c.Carbon; -import dwt.internal.cocoa.NSInteger; import dwt.internal.cocoa.NSRect; import dwt.internal.objc.cocoa.Cocoa; import dwt.internal.objc.runtime; diff -r e6f04eb518ae -r 858e9a565d62 dwt/widgets/Button.d --- a/dwt/widgets/Button.d Sun Dec 07 21:24:13 2008 +0100 +++ b/dwt/widgets/Button.d Sun Dec 07 21:40:42 2008 +0100 @@ -144,7 +144,7 @@ if (nsAttributeName.isEqualToString (OS.NSAccessibilityRoleAttribute)) return role.id; else { - int roleDescription = OS.NSAccessibilityRoleDescription(role.id, 0); + objc.id roleDescription = OS.NSAccessibilityRoleDescription(role.id, null); return roleDescription; } } @@ -229,9 +229,9 @@ if ((style & DWT.CENTER) !is 0) { alignment = OS.NSCenterTextAlignment; } else if ((style & DWT.LEFT) !is 0) { - alignment = NSLeftTextAlignment; + alignment = OS.NSLeftTextAlignment; } else { - alignment = NSRightTextAlignment; + alignment = OS.NSRightTextAlignment; } NSMutableParagraphStyle pStyle = cast(NSMutableParagraphStyle)(new NSMutableParagraphStyle()).alloc().init(); pStyle.autorelease(); @@ -248,34 +248,34 @@ void createHandle () { NSButton widget = cast(NSButton)(new SWTButton()).alloc(); - widget.initWithFrame(NSRect()); - NSButtonType type = NSMomentaryLightButton; - if ((style & DWT.PUSH) !is 0) { - if ((style & DWT.FLAT) !is 0) { + widget.initWithFrame(new NSRect()); + NSButtonType type = OS.NSMomentaryLightButton; + if ((style & SWT.PUSH) !is 0) { + if ((style & SWT.FLAT) !is 0) { widget.setBezelStyle(OS.NSShadowlessSquareBezelStyle); -// if ((style & DWT.BORDER) is 0) widget.setShowsBorderOnlyWhileMouseInside(true); +// if ((style & SWT.BORDER) is 0) widget.setShowsBorderOnlyWhileMouseInside(true); } else { widget.setBezelStyle(OS.NSRoundedBezelStyle); } - } else if ((style & DWT.CHECK) !is 0) { - type = NSSwitchButton; + } else if ((style & SWT.CHECK) !is 0) { + type = OS.NSSwitchButton; widget.setAllowsMixedState (true); - } else if ((style & DWT.RADIO) !is 0) { - type = NSRadioButton; - } else if ((style & DWT.TOGGLE) !is 0) { - type = NSPushOnPushOffButton; - widget.setBezelStyle(NSRegularSquareBezelStyle); + } else if ((style & SWT.RADIO) !is 0) { + type = OS.NSRadioButton; + } else if ((style & SWT.TOGGLE) !is 0) { + type = OS.NSPushOnPushOffButton; + if ((style & SWT.FLAT) !is 0) { widget.setBezelStyle(OS.NSShadowlessSquareBezelStyle); -// if ((style & DWT.BORDER) is 0) widget.setShowsBorderOnlyWhileMouseInside(true); +// if ((style & SWT.BORDER) is 0) widget.setShowsBorderOnlyWhileMouseInside(true); } else { widget.setBezelStyle(OS.NSRoundedBezelStyle); } - } else if ((style & DWT.ARROW) !is 0) { - widget.setBezelStyle(NSRegularSquareBezelStyle); + } else if ((style & SWT.ARROW) !is 0) { + widget.setBezelStyle(OS.NSRegularSquareBezelStyle); } widget.setButtonType(type); widget.setTitle(NSString.stringWith("")); - widget.setImagePosition(NSImageLeft); + widget.setImagePosition(OS.NSImageLeft); widget.setTarget(widget); widget.setAction(OS.sel_sendSelection); view = widget; @@ -284,23 +284,23 @@ void deregister () { super.deregister (); - display.removeWidget(((NSControl)view).cell()); + display.removeWidget((cast(NSControl)view).cell()); } -void drawWidget (int /*long*/ id, NSRect rect) { +void drawWidget (objc.id id, NSRect rect) { if ((style & DWT.ARROW) !is 0) { NSRect frame = view.frame(); - int arrowSize = Math.min((int)frame.height, (int)frame.width) / 2; + int arrowSize = Math.min(cast(int)frame.height, cast(int)frame.width) / 2; NSGraphicsContext context = NSGraphicsContext.currentContext(); context.saveGraphicsState(); NSPoint p1 = NSPoint(); - p1.x = (float)Math.floor(-arrowSize / 2); - p1.y = (float)Math.floor(-arrowSize / 2); + p1.x = cast(CGFloat)Math.floor(-arrowSize / 2); + p1.y = cast(CGFloat)Math.floor(-arrowSize / 2); NSPoint p2 = NSPoint(); - p2.x = (float)Math.ceil(arrowSize / 2); + p2.x = cast(CGFloat)Math.ceil(arrowSize / 2); p2.y = p1.y; NSPoint p3 = NSPoint(); - p3.y = (float)Math.ceil(arrowSize / 2); + p3.y = cast(CGFloat)Math.ceil(arrowSize / 2); NSBezierPath path = NSBezierPath.bezierPath(); path.moveToPoint(p1); @@ -442,7 +442,7 @@ void register() { super.register(); - display.addWidget(((NSControl)view).cell(), this); + display.addWidget((cast(NSControl)view).cell(), this); } void releaseWidget () { @@ -610,7 +610,7 @@ void setFont (NSFont font) { if (text !is null) { - ((NSButton)view).setAttributedTitle(createString()); + (cast(NSButton)view).setAttributedTitle(createString()); } }