# HG changeset patch # User Jacob Carlborg # Date 1230117207 -3600 # Node ID 8e8040261b20827fe0a13b1cbf192ba14b57fdb9 # Parent 16f9078aa1ff0de27b674973b2deee8b13c0e355 Ported dwt.widgets.Sash diff -r 16f9078aa1ff -r 8e8040261b20 dwt/widgets/Sash.d --- a/dwt/widgets/Sash.d Tue Dec 23 23:53:37 2008 +0100 +++ b/dwt/widgets/Sash.d Wed Dec 24 12:13:27 2008 +0100 @@ -7,6 +7,9 @@ * * Contributors: * IBM Corporation - initial API and implementation + * + * Port to the D programming language: + * Jacob Carlborg *******************************************************************************/ module dwt.widgets.Sash; @@ -31,7 +34,13 @@ import dwt.internal.cocoa.NSView; import dwt.internal.cocoa.OS; import dwt.internal.cocoa.SWTView; -import dwt.internal.cocoa.id; +import cocoa = dwt.internal.cocoa.id; + +import dwt.internal.objc.cocoa.Cocoa; +import objc = dwt.internal.objc.runtime; +import dwt.widgets.Composite; +import dwt.widgets.Control; +import dwt.widgets.TypedListener; /** * Instances of the receiver represent a selectable user interface object @@ -97,7 +106,7 @@ sizeCursor = new Cursor (display, cursorStyle); } -int accessibilityAttributeNames(int /*long*/ id, int /*long*/ sel) { +objc.id accessibilityAttributeNames(objc.id id, objc.SEL sel) { if (accessibilityAttributes is null) { NSMutableArray ourAttributes = NSMutableArray.arrayWithCapacity(10); ourAttributes.addObject(OS.NSAccessibilityRoleAttribute); @@ -140,17 +149,17 @@ return accessibilityAttributes.id; } -public int accessibilityAttributeValue(int /*long*/ id, int /*long*/ sel, int /*long*/ arg0) { - int returnValue = 0; +public objc.id accessibilityAttributeValue(objc.id id, objc.SEL sel, objc.id arg0) { + objc.id returnValue = null; NSString attributeName = new NSString(arg0); if (accessible !is null) { - id returnObject = accessible.internal_accessibilityAttributeValue(attributeName, ACC.CHILDID_SELF); + cocoa.id returnObject = accessible.internal_accessibilityAttributeValue(attributeName, ACC.CHILDID_SELF); if (returnObject !is null) returnValue = returnObject.id; } - if (returnValue !is 0) return returnValue; + if (returnValue !is null) return returnValue; if (attributeName.isEqualToString (OS.NSAccessibilityRoleAttribute) || attributeName.isEqualToString (OS.NSAccessibilityRoleDescriptionAttribute)) { NSString roleText = OS.NSAccessibilitySplitterRole; @@ -158,7 +167,7 @@ if (attributeName.isEqualToString (OS.NSAccessibilityRoleAttribute)) { return roleText.id; } else { // NSAccessibilityRoleDescriptionAttribute - return OS.NSAccessibilityRoleDescription (roleText.id, 0); + return OS.NSAccessibilityRoleDescription (roleText.id, null); } } else if (attributeName.isEqualToString (OS.NSAccessibilityEnabledAttribute)) { return NSNumber.numberWithBool(isEnabled()).id; @@ -174,7 +183,7 @@ float maxValue = (style & DWT.VERTICAL) !is 0 ? parentBounds.width : parentBounds.height; - return NSNumber.numberWithInt((int)maxValue).id; + return NSNumber.numberWithInt(cast(int)maxValue).id; } else if (attributeName.isEqualToString (OS.NSAccessibilityMinValueAttribute)) { return NSNumber.numberWithInt(0).id; } else if (attributeName.isEqualToString (OS.NSAccessibilityNextContentsAttribute)) { @@ -214,7 +223,7 @@ return super.accessibilityAttributeValue(id, sel, arg0); } -bool accessibilityIsIgnored(int /*long*/ id, int /*long*/ sel) { +bool accessibilityIsIgnored(objc.id id, objc.SEL sel) { return false; } @@ -259,7 +268,7 @@ return checkBits (style, DWT.HORIZONTAL, DWT.VERTICAL, 0, 0, 0, 0); } -bool becomeFirstResponder (int /*long*/ id, int /*long*/ sel) { +bool becomeFirstResponder (objc.id id, objc.SEL sel) { bool result = super.becomeFirstResponder(id, sel); NSRect frame = view.frame(); lastX = cast(int)frame.x; @@ -281,12 +290,12 @@ } void createHandle () { - NSView widget = cast(NSView)new SWTView().alloc(); + NSView widget = cast(NSView)(new SWTView()).alloc(); widget.initWithFrame (NSRect()); view = widget; } -void drawWidget (int /*long*/ id, NSRect rect) { +void drawWidget (objc.id id, NSRect rect) { NSGraphicsContext context = NSGraphicsContext.currentContext(); fillBackground (view, context, rect); super.drawWidget (id, rect); @@ -303,7 +312,7 @@ bool sendKeyEvent(NSEvent nsEvent, int type) { //TODO consumed - int keyCode = nsEvent.keyCode(); + ushort keyCode = nsEvent.keyCode(); switch (keyCode) { case 126: /* Up arrow */ case 123: /* Left arrow */ @@ -311,7 +320,7 @@ case 124: /* Right arrow */ { int xChange = 0, yChange = 0; int stepSize = PAGE_INCREMENT; - int /*long*/ modifiers = nsEvent.modifierFlags(); + NSUInteger modifiers = nsEvent.modifierFlags(); if ((modifiers & OS.NSControlKeyMask) !is 0) stepSize = INCREMENT; if ((style & DWT.VERTICAL) !is 0) { if (keyCode is 126 || keyCode is 125) break; @@ -360,7 +369,7 @@ return true; } -void mouseDown(int /*long*/ id, int /*long*/ sel, int /*long*/ theEvent) { +void mouseDown(objc.id id, objc.SEL sel, objc.id theEvent) { //TODO use sendMouseEvent // super.mouseDown(id, sel, theEvent); NSEvent nsEvent = new NSEvent(theEvent); @@ -385,7 +394,7 @@ } } -void mouseDragged(int /*long*/ id, int /*long*/ sel, int /*long*/ theEvent) { +void mouseDragged(objc.id id, objc.SEL sel, objc.id theEvent) { //TODO use sendMouseEvent // super.mouseDragged(id, sel, theEvent); if (!dragging) return; @@ -415,7 +424,7 @@ } } -void mouseUp(int /*long*/ id, int /*long*/ sel, int /*long*/ theEvent) { +void mouseUp(objc.id id, objc.SEL sel, objc.id theEvent) { //TODO use sendMouseEvent // super.mouseUp(id, sel, theEvent); if (!dragging) return;