Mercurial > projects > dwt-mac
changeset 50:30adfb32d4be
Updated Shell to 3.514
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sun, 07 Dec 2008 21:06:50 +0100 |
parents | 9dd4a17513f9 |
children | e6f04eb518ae |
files | dwt/internal/c/Carbon.d dwt/internal/cocoa/OS.d dwt/widgets/Shell.d |
diffstat | 3 files changed, 63 insertions(+), 47 deletions(-) [+] |
line wrap: on
line diff
--- a/dwt/internal/c/Carbon.d Sun Dec 07 20:41:40 2008 +0100 +++ b/dwt/internal/c/Carbon.d Sun Dec 07 21:06:50 2008 +0100 @@ -331,4 +331,21 @@ alias RgnPtr* RgnHandle; alias bool Boolean; -alias bool BOOL; \ No newline at end of file +alias bool BOOL; + +enum +{ + kQDRegionToRectsMsgInit = 1, + kQDRegionToRectsMsgParse = 2, + kQDRegionToRectsMsgTerminate = 3 +} + +enum +{ + kQDParseRegionFromTop = (1 << 0), + kQDParseRegionFromBottom = (1 << 1), + kQDParseRegionFromLeft = (1 << 2), + kQDParseRegionFromRight = (1 << 3), + kQDParseRegionFromTopLeft = kQDParseRegionFromTop | kQDParseRegionFromLeft, + kQDParseRegionFromBottomRight = kQDParseRegionFromBottom | kQDParseRegionFromRight +} \ No newline at end of file
--- a/dwt/internal/cocoa/OS.d Sun Dec 07 20:41:40 2008 +0100 +++ b/dwt/internal/cocoa/OS.d Sun Dec 07 21:06:50 2008 +0100 @@ -1278,12 +1278,12 @@ alias Carbon.CopyRgn CopyRgn; /** @method flags=dynamic */ alias Carbon.SetRect SetRect; -public static const int kQDParseRegionFromTop = (1 << 0); -public static const int kQDParseRegionFromBottom = (1 << 1); -public static const int kQDParseRegionFromLeft = (1 << 2); -public static const int kQDParseRegionFromRight = (1 << 3); -public static const int kQDParseRegionFromTopLeft = kQDParseRegionFromTop | kQDParseRegionFromLeft; -public static const int kQDRegionToRectsMsgParse = 2; +alias Carbon.kQDParseRegionFromTop kQDParseRegionFromTop; +alias Carbon.kQDParseRegionFromBottom kQDParseRegionFromBottom; +alias Carbon.kQDParseRegionFromLeft kQDParseRegionFromLeft; +alias Carbon.kQDParseRegionFromRight kQDParseRegionFromRight; +alias Carbon.kQDParseRegionFromTopLeft kQDParseRegionFromTopLeft; +alias Carbon.kQDRegionToRectsMsgParse kQDRegionToRectsMsgParse; /** Custom callbacks */
--- a/dwt/widgets/Shell.d Sun Dec 07 20:41:40 2008 +0100 +++ b/dwt/widgets/Shell.d Sun Dec 07 21:06:50 2008 +0100 @@ -21,7 +21,6 @@ import dwt.graphics.Point; import dwt.graphics.Rectangle; import dwt.graphics.Region; -import dwt.internal.Callback; import dwt.internal.cocoa.NSApplication; import dwt.internal.cocoa.NSBezierPath; import dwt.internal.cocoa.NSColor; @@ -40,7 +39,8 @@ import dwt.internal.cocoa.id; import dwt.dwthelper.utils; -import dwt.internal.cocoa.NSInteger; +import dwt.internal.c.Carbon; +import dwt.internal.objc.cocoa.Cocoa; import objc = dwt.internal.objc.runtime; import dwt.widgets.Composite; import dwt.widgets.Control; @@ -407,6 +407,7 @@ * * @since 3.3 */ +public static Shell internal_new (Display display, objc.id handle) { return new Shell (display, null, DWT.NO_TRIM, handle, false); } @@ -428,7 +429,7 @@ * * @since 3.5 */ -public static Shell cocoa_new (Display display, int /*long*/ handle) { +public static Shell cocoa_new (Display display, objc.id handle) { return new Shell (display, null, DWT.NO_TRIM, handle, true); } @@ -443,7 +444,7 @@ return bits; } -bool accessibilityIsIgnored(int /*long*/ id, int /*long*/ sel) { +bool accessibilityIsIgnored(objc.id id, objc.SEL sel) { // The content view of a shell is always ignored. if (id is view.id) return true; return super.accessibilityIsIgnored(id, sel); @@ -488,7 +489,7 @@ } } -bool canBecomeKeyWindow (int /*long*/ id, int /*long*/ sel) { +bool canBecomeKeyWindow (objc.id id, objc.SEL sel) { if (window.styleMask () is OS.NSBorderlessWindowMask) return true; return super.canBecomeKeyWindow (id, sel); } @@ -537,12 +538,13 @@ rect.height = trim.height; NSWindow myWindow = (window !is null ? window : view.window()); rect = myWindow.frameRectForContentRect(rect); + return new Rectangle (cast(int)rect.x, cast(int)rect.y, cast(int)rect.width, cast(int)rect.height); } void createHandle () { state |= HIDDEN; if (window is null) { - window = (NSWindow) new SWTWindow ().alloc (); + window = cast(NSWindow) (new SWTWindow ()).alloc (); NSUInteger styleMask = NSBorderlessWindowMask; if ((style & DWT.NO_TRIM) is 0) { if ((style & DWT.TITLE) !is 0) styleMask |= OS.NSTitledWindowMask; @@ -561,7 +563,7 @@ } display.cascadeWindow(window, screen); NSRect screenFrame = screen.frame(); - float /*double*/ width = screenFrame.width * 5 / 8, height = screenFrame.height * 5 / 8;; + CGFloat width = screenFrame.width * 5 / 8, height = screenFrame.height * 5 / 8;; NSRect frame = window.frame(); NSRect primaryFrame = primaryScreen.frame(); frame.y = primaryFrame.height - ((primaryFrame.height - (frame.y + frame.height)) + height); @@ -581,7 +583,7 @@ style |= DWT.NO_BACKGROUND; } window.setAcceptsMouseMovedEvents(true); - windowDelegate = (SWTWindowDelegate)new SWTWindowDelegate().alloc().init(); + windowDelegate = cast(SWTWindowDelegate)(new SWTWindowDelegate()).alloc().init(); window.setDelegate(windowDelegate); window.disableCursorRects(); id id = window.fieldEditor (true, null); @@ -598,7 +600,7 @@ void fixLevel() { Shell topShell = this; while (topShell.parent !is null) { - if (topShell.parent !is null) topShell = (Shell) topShell.parent; + if (topShell.parent !is null) topShell = cast(Shell) topShell.parent; } Shell[] shells = display.getShells (); for (int i = 0; i < shells.length; i++) { @@ -607,7 +609,7 @@ int level = 0; Shell pShell = shell; while (pShell.parent !is null) { - pShell = (Shell) pShell.parent; + pShell = cast(Shell) pShell.parent; level++; } int newLevel = pShell is topShell ? level : 0; @@ -636,7 +638,7 @@ } } -void drawWidget (int /*long*/ id, NSRect rect) { +void drawWidget (objc.id id, NSRect rect) { if (regionPath !is null && background is null) { NSGraphicsContext context = NSGraphicsContext.currentContext(); context.saveGraphicsState(); @@ -726,7 +728,7 @@ if (window is null) { // In embedded frames, the whole view is the client area. NSRect rect = view.frame(); - int width = (int)rect.width, height = (int)rect.height; + int width = cast(int)rect.width, height = cast(int)rect.height; return new Rectangle (0, 0, width, height); } @@ -791,8 +793,8 @@ checkWidget(); // TODO: frame is relative to superview. What does getLocation mean in the embedded case? NSRect frame = (window !is null ? window.frame() : view.frame()); - float /*double*/ y = display.getPrimaryFrame().height - (int)(frame.y + frame.height); - return new Point ((int)frame.x, (int)y); + CGFloat y = display.getPrimaryFrame().height - cast(int)(frame.y + frame.height); + return new Point (cast(int)frame.x, cast(int)y); } public bool getMaximized () { @@ -942,7 +944,7 @@ return false; } -void helpRequested(int /*long*/ id, int /*long*/ sel, int /*long*/ theEvent) { +void helpRequested(objc.id id, objc.SEL sel, objc.id theEvent) { Control control = display.getFocusControl(); while (control !is null) { if (control.hooks (DWT.Help)) { @@ -967,7 +969,7 @@ return getVisible (); } -bool makeFirstResponder (int /*long*/ id, int /*long*/ sel, int /*long*/ notification) { +bool makeFirstResponder (objc.id id, objc.SEL sel, objc.id notification) { if (display.focusControl is null) display.focusControl = display.getFocusControl (); bool result = super.makeFirstResponder(id, sel, notification); if (result) { @@ -1197,18 +1199,18 @@ // Embedded Shells are not resizable. if (window is null) return; if (fullScreen) setFullScreen (false); - int screenHeight = (int) display.getPrimaryFrame().height; + int screenHeight = cast(int) display.getPrimaryFrame().height; NSRect frame = window.frame(); if (!move) { - x = (int)frame.x; - y = screenHeight - (int)(frame.y + frame.height); + x = cast(int)frame.x; + y = screenHeight - cast(int)(frame.y + frame.height); } if (!resize) { - width = (int)frame.width; - height = (int)frame.height; + width = cast(int)frame.width; + height = cast(int)frame.height; } frame.x = x; - frame.y = screenHeight - (int)(y + height); + frame.y = screenHeight - cast(int)(y + height); frame.width = width; frame.height = height; window.setFrame(frame, false); @@ -1444,30 +1446,27 @@ NSBezierPath getPath(Region region) { if (region is null) return null; - Callback callback = new Callback(this, "regionToRects", 4); - if (callback.getAddress() is 0) DWT.error(DWT.ERROR_NO_MORE_CALLBACKS); NSBezierPath path = NSBezierPath.bezierPath(); path.retain(); - OS.QDRegionToRects(region.handle, OS.kQDParseRegionFromTopLeft, callback.getAddress(), path.id); - callback.dispose(); + OS.QDRegionToRects(region.handle, OS.kQDParseRegionFromTopLeft, cast(RegionToRectsUPP) ®ionToRects, path.id); if (path.isEmpty()) path.appendBezierPathWithRect(NSRect()); return path; } -int /*long*/ regionToRects(int /*long*/ message, int /*long*/ rgn, int /*long*/ r, int /*long*/ path) { +extern (C) static OSStatus regionToRects(ushort message, RgnHandle rgn, Rect* r, void* path) { NSPoint pt = NSPoint(); - short[] rect = new short[4]; + Rect rect; if (message is OS.kQDRegionToRectsMsgParse) { - OS.memmove(rect, r, rect.length * 2); - pt.x = rect[1]; - pt.y = rect[0]; + OS.memmove(&rect, r, rect.length * 2); + pt.x = rect.left; + pt.y = rect.top; OS.objc_msgSend(path, OS.sel_moveToPoint_, pt); - pt.x = rect[3]; + pt.x = rect.right; OS.objc_msgSend(path, OS.sel_lineToPoint_, pt); - pt.x = rect[3]; - pt.y = rect[2]; + pt.x = rect.right; + pt.y = rect.bottom; OS.objc_msgSend(path, OS.sel_lineToPoint_, pt); - pt.x = rect[1]; + pt.x = rect.left; OS.objc_msgSend(path, OS.sel_lineToPoint_, pt); OS.objc_msgSend(path, OS.sel_closePath); } @@ -1592,7 +1591,7 @@ // } } -void windowDidBecomeKey(int /*long*/ id, int /*long*/ sel, int /*long*/ notification) { +void windowDidBecomeKey(objc.id id, objc.SEL sel, objc.id notification) { super.windowDidBecomeKey(id, sel, notification); Display display = this.display; display.setMenuBar (menuBar); @@ -1603,12 +1602,12 @@ // } } -void windowDidMove(int /*long*/ id, int /*long*/ sel, int /*long*/ notification) { +void windowDidMove(objc.id id, objc.SEL sel, objc.id notification) { moved = true; sendEvent(DWT.Move); } -void windowDidResize(int /*long*/ id, int /*long*/ sel, int /*long*/ notification) { +void windowDidResize(objc.id id, objc.SEL sel, objc.id notification) { resized = true; sendEvent (DWT.Resize); if (isDisposed ()) return; @@ -1618,7 +1617,7 @@ } } -void windowDidResignKey(int /*long*/ id, int /*long*/ sel, int /*long*/ notification) { +void windowDidResignKey(objc.id id, objc.SEL sel, objc.id notification) { super.windowDidResignKey(id, sel, notification); // Display display = this.display; sendEvent (DWT.Deactivate); @@ -1638,7 +1637,7 @@ // } } -bool windowShouldClose(int /*long*/ id, int /*long*/ sel, int /*long*/ window) { +bool windowShouldClose(objc.id id, objc.SEL sel, objc.id window) { closeWidget (); return false; }