Mercurial > projects > dwt-mac
changeset 20:453387bb0706
Ported dwt.widgets.Shell
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Sun, 07 Sep 2008 18:22:28 +0200 |
parents | fba856099f87 |
children | fdbd69a5f101 |
files | dwt/widgets/Control.d dwt/widgets/Shell.d dwt/widgets/Widget.d |
diffstat | 3 files changed, 41 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/dwt/widgets/Control.d Wed Sep 03 20:59:39 2008 +0200 +++ b/dwt/widgets/Control.d Sun Sep 07 18:22:28 2008 +0200 @@ -3080,7 +3080,7 @@ return view; } -bool translateTraversal (int key, NSEvent theEvent, bool [] consume) { +bool translateTraversal (short key, NSEvent theEvent, bool [] consume) { int detail = DWT.TRAVERSE_NONE; int code = traversalCode (key, theEvent); bool all = false; @@ -3139,7 +3139,7 @@ return false; } -int traversalCode (int key, NSEvent theEvent) { +int traversalCode (short key, NSEvent theEvent) { int code = DWT.TRAVERSE_RETURN | DWT.TRAVERSE_TAB_NEXT | DWT.TRAVERSE_TAB_PREVIOUS; Shell shell = getShell (); if (shell.parent !is null) code |= DWT.TRAVERSE_ESCAPE;
--- a/dwt/widgets/Shell.d Wed Sep 03 20:59:39 2008 +0200 +++ b/dwt/widgets/Shell.d Sun Sep 07 18:22:28 2008 +0200 @@ -13,8 +13,6 @@ *******************************************************************************/ module dwt.widgets.Shell; -import dwt.dwthelper.utils; - import dwt.DWT; import dwt.DWTException; import dwt.events.ShellListener; @@ -35,6 +33,22 @@ import dwt.internal.cocoa.SWTWindow; import dwt.internal.cocoa.SWTWindowDelegate; +import dwt.dwthelper.utils; +import dwt.internal.cocoa.NSInteger; +import objc = dwt.internal.objc.runtime; +import dwt.widgets.Composite; +import dwt.widgets.Control; +import dwt.widgets.Decorations; +import dwt.widgets.Display; +import dwt.widgets.Event; +import dwt.widgets.EventTable; +import dwt.widgets.Layout; +import dwt.widgets.Listener; +import dwt.widgets.Menu; +import dwt.widgets.Monitor; +import dwt.widgets.TypedListener; +import dwt.widgets.Widget; + /** * Instances of this class represent the "windows" * which the desktop or "window manager" is managing. @@ -265,7 +279,7 @@ this (display, null, style, 0, false); } -this (Display display, Shell parent, int style, int handle, bool embedded) { +this (Display display, Shell parent, int style, objc.id handle, bool embedded) { super (); checkSubclass (); if (display is null) display = Display.getCurrent (); @@ -279,7 +293,7 @@ this.style = checkStyle (style); this.parent = parent; this.display = display; - if (handle !is 0) { + if (handle !is null) { if (embedded) { view = new NSView(handle); } else { @@ -367,7 +381,7 @@ this (parent !is null ? parent.display : null, parent, style, 0, false); } -public static Shell internal_new (Display display, int handle) { +public static Shell internal_new (Display display, objc.id handle) { return new Shell (display, null, DWT.NO_TRIM, handle, false); } @@ -454,7 +468,7 @@ public Rectangle computeTrim (int x, int y, int width, int height) { checkWidget(); Rectangle trim = super.computeTrim(x, y, width, height); - NSRect rect = new NSRect (); + NSRect rect = NSRect (); rect.x = trim.x; rect.y = trim.y; rect.width = trim.width; @@ -469,11 +483,11 @@ view = window.contentView(); return; } else { - SWTWindow swtWindow = cast(SWTWindow) new SWTWindow ().alloc (); + SWTWindow swtWindow = cast(SWTWindow) (new SWTWindow ()).alloc (); swtWindow.setTag(jniRef); window = cast(NSWindow)swtWindow; - NSRect rect = new NSRect(); - Monitor monitor = getMonitor (); + NSRect rect = NSRect(); + dwt.widgets.Monitor.Monitor monitor = getMonitor (); Rectangle clientArea = monitor.getClientArea (); rect.width = clientArea.width * 5 / 8; rect.height = clientArea.height * 5 / 8; @@ -495,7 +509,7 @@ createHandle (null); window.setContentView (topView()); - windowDelegate = cast(SWTWindowDelegate)new SWTWindowDelegate().alloc().init(); + windowDelegate = cast(SWTWindowDelegate)(new SWTWindowDelegate()).alloc().init(); windowDelegate.setTag(jniRef); window.setDelegate(windowDelegate); } @@ -523,10 +537,10 @@ // if (control is lastActive) setActiveControl (null); } -void flagsChanged(int theEvent) { +void flagsChanged(objc.id theEvent) { Display display = this.display; NSEvent nsEvent = new NSEvent(theEvent); - int modifiers = nsEvent.modifierFlags(); + NSUInteger modifiers = nsEvent.modifierFlags(); int lastModifiers = display.lastModifiers; // int chord = OS.GetCurrentEventButtonState (); int type = DWT.KeyUp; @@ -604,7 +618,7 @@ NSRect rect = window.contentRectForFrameRect_(window.frame()); int width = cast(int)rect.width, height = cast(int)rect.height; if (scrollView !is null) { - NSSize size = new NSSize(); + NSSize size = NSSize(); size.width = width; size.height = height; size = NSScrollView.contentSizeForFrameSize(size, (style & DWT.H_SCROLL) !is 0, (style & DWT.V_SCROLL) !is 0, OS.NSNoBorder); @@ -972,7 +986,7 @@ int setBounds (int x, int y, int width, int height, bool move, bool resize) { // if (fullScreen) setFullScreen (false); if (move && resize) { - NSRect rect = new NSRect (); + NSRect rect = NSRect (); rect.x = x; //TODO - get the screen for the point int screenHeight = cast(int) window.screen().frame().height; @@ -982,7 +996,7 @@ window.setFrame_display_(rect, false); } else { if (move) { - NSPoint point = new NSPoint(); + NSPoint point = NSPoint(); point.x = x; //TODO - get the screen for the point int screenHeight = cast(int) window.screen().frame().height; @@ -1215,12 +1229,12 @@ // } } -public void setText (String string) { +public void setText (String str) { checkWidget(); if (string is null) error (DWT.ERROR_NULL_ARGUMENT); - super.setText (string); - NSString str = NSString.stringWith(string); - window.setTitle(str); + super.setText (str); + NSString nsStr = NSString.stringWith(str); + window.setTitle(nsStr); // str.release(); } @@ -1359,15 +1373,15 @@ void windowWillClose(int notification) { } -void windowSendEvent(int id, int event) { +void windowSendEvent(objc.id ID, objc.id event) { NSEvent nsEvent = new NSEvent(event); - int type = nsEvent.type(); + NSEventType type = nsEvent.type(); if (type is OS.NSKeyDown || type is OS.NSKeyUp) { Control eventTarget = display.getFocusControl(); if (eventTarget !is null) { if (type is OS.NSKeyDown) { bool[] consume = new bool[1]; - int key = nsEvent.keyCode(); + short key = nsEvent.keyCode(); if (eventTarget.translateTraversal(key, nsEvent, consume)) return; if (consume[0]) return; if (eventTarget.isDisposed()) return;
--- a/dwt/widgets/Widget.d Wed Sep 03 20:59:39 2008 +0200 +++ b/dwt/widgets/Widget.d Sun Sep 07 18:22:28 2008 +0200 @@ -26,6 +26,7 @@ import dwt.internal.cocoa.objc_super; import dwt.dwthelper.utils; +import dwt.internal.cocoa.NSInteger; import objc = dwt.internal.objc.runtime; import dwt.widgets.Display; @@ -66,7 +67,7 @@ EventTable eventTable; Object data; - int jniRef; + NSInteger jniRef; /* Global state flags */ static const int DISPOSED = 1 << 0; @@ -1268,7 +1269,7 @@ void windowDidBecomeKey(int notification) { } -void windowSendEvent(objc.id id, int event) { +void windowSendEvent(objc.id id, objc.id event) { callSuper(objc.id, OS.sel_sendEvent_1, event); }