Mercurial > projects > dwt-mac
changeset 69:39340f7612f8
Ported dwt.widgets.Group
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Tue, 23 Dec 2008 23:21:45 +0100 |
parents | cce7edf30dae |
children | 2d5ef909b21d |
files | dwt/internal/cocoa/NSBox.d dwt/internal/cocoa/OS.d dwt/widgets/Group.d |
diffstat | 3 files changed, 20 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/dwt/internal/cocoa/NSBox.d Tue Dec 23 23:16:05 2008 +0100 +++ b/dwt/internal/cocoa/NSBox.d Tue Dec 23 23:21:45 2008 +0100 @@ -71,15 +71,15 @@ } public void setBorderType (NSBorderType aType) { - OS.objc_msgSend(this.id, OS.sel_setBorderType_1, aType); + OS.objc_msgSend(this.id, OS.sel_setBorderType_, aType); } public void setBorderWidth (CGFloat borderWidth) { - OS.objc_msgSend(this.id, OS.sel_setBorderWidth_1, borderWidth); + OS.objc_msgSend(this.id, OS.sel_setBorderWidth_, borderWidth); } public void setBoxType (NSBoxType boxType) { - OS.objc_msgSend(this.id, OS.sel_setBoxType_1, boxType); + OS.objc_msgSend(this.id, OS.sel_setBoxType_, boxType); } public void setContentView (NSView aView) {
--- a/dwt/internal/cocoa/OS.d Tue Dec 23 23:16:05 2008 +0100 +++ b/dwt/internal/cocoa/OS.d Tue Dec 23 23:21:45 2008 +0100 @@ -49,6 +49,7 @@ import dwt.internal.cocoa.NSApplication; import dwt.internal.cocoa.NSBezierPath; import dwt.internal.cocoa.NSBitmapImageRep; +import dwt.internal.cocoa.NSBox; import dwt.internal.cocoa.NSButtonCell; import dwt.internal.cocoa.NSCell; import dwt.internal.cocoa.NSDatePicker; @@ -2737,7 +2738,7 @@ public static const int NSApplicationDelegateReplySuccess = 0; public static const int NSAscendingPageOrder = 1; public static const int NSAtBottom = 5; -public static const int NSAtTop = 2; +alias NSTitlePosition.NSAtTop NSAtTop; public static const int NSAttachmentCharacter = 65532; public static const int NSAutoPagination = 0; public static const int NSAutosaveOperation = 3; @@ -3179,7 +3180,7 @@ public static const int NSNoTabsBezelBorder = 4; public static const int NSNoTabsLineBorder = 5; public static const int NSNoTabsNoBorder = 6; -public static const int NSNoTitle = 0; +alias NSTitlePosition.NSNoTitle NSNoTitle; public static const int NSNoUnderlineStyle = 0; public static const int NSNonStandardCharacterSetFontMask = 8; alias Cocoa.NSWindingRule.NSNonZeroWindingRule NSNonZeroWindingRule;
--- a/dwt/widgets/Group.d Tue Dec 23 23:16:05 2008 +0100 +++ b/dwt/widgets/Group.d Tue Dec 23 23:21:45 2008 +0100 @@ -7,6 +7,9 @@ * * Contributors: * IBM Corporation - initial API and implementation + * + * Port to the D programming language: + * Jacob Carlborg <doob@me.com> *******************************************************************************/ module dwt.widgets.Group; @@ -26,6 +29,8 @@ import dwt.internal.cocoa.SWTBox; import dwt.internal.cocoa.SWTView; +import dwt.widgets.Composite; + /** * Instances of this class provide an etched border * with an optional title. @@ -50,7 +55,7 @@ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> */ public class Group : Composite { - NSView contentView; + NSView contentView_; String text = ""; /** @@ -108,7 +113,7 @@ public Rectangle computeTrim (int x, int y, int width, int height) { checkWidget (); NSBox widget = cast(NSBox)view; - int border = (int)Math.ceil (widget.borderWidth ()); + int border = cast(int)Math.ceil (widget.borderWidth ()); NSSize margins = widget.contentViewMargins(); NSRect frame = contentView.frame(); width += (margins.width + border) * 2; @@ -123,7 +128,7 @@ void deregister () { super.deregister (); display.removeWidget (contentView); - SWTBox box = (SWTBox)view; + SWTBox box = cast(SWTBox)view; display.removeWidget (box.titleCell()); } @@ -131,11 +136,11 @@ NSBox widget = cast(NSBox)(new SWTBox()).alloc(); widget.initWithFrame(NSRect()); widget.setTitlePosition(OS.NSNoTitle); - NSView contentWidget = (NSView)new SWTView().alloc(); + NSView contentWidget = cast(NSView)(new SWTView()).alloc(); contentWidget.initWithFrame(NSRect()); // contentWidget.setDrawsBackground(false); widget.setContentView(contentWidget); - contentView = contentWidget; + contentView_ = contentWidget; view = widget; } @@ -173,18 +178,18 @@ void register () { super.register (); display.addWidget (contentView, this); - SWTBox box = (SWTBox)view; + SWTBox box = cast(SWTBox)view; display.addWidget (box.titleCell(), this); } void releaseHandle () { super.releaseHandle (); if (contentView !is null) contentView.release(); - contentView = null; + contentView_ = null; } void setFont(NSFont font) { - ((NSBox) view).setTitleFont(font); + (cast(NSBox) view).setTitleFont(font); } /** @@ -220,7 +225,7 @@ int length = fixMnemonic (buffer); NSBox box = cast(NSBox)view; box.setTitlePosition(length is 0 ? OS.NSNoTitle : OS.NSAtTop); - box.setTitle(NSString.stringWithCharacters(buffer, length)); + box.setTitle(NSString.stringWithCharacters(buffer.toString16().ptr, length)); } }