comparison dwt/widgets/Shell.d @ 60:62202ce0039f

Updated and fixed many modules to 3.514
author Jacob Carlborg <doob@me.com>
date Mon, 22 Dec 2008 15:10:19 +0100
parents 30adfb32d4be
children 63a09873578e
comparison
equal deleted inserted replaced
59:83b0ad9d9238 60:62202ce0039f
37 import dwt.internal.cocoa.SWTWindow; 37 import dwt.internal.cocoa.SWTWindow;
38 import dwt.internal.cocoa.SWTWindowDelegate; 38 import dwt.internal.cocoa.SWTWindowDelegate;
39 import dwt.internal.cocoa.id; 39 import dwt.internal.cocoa.id;
40 40
41 import dwt.dwthelper.utils; 41 import dwt.dwthelper.utils;
42 import dwt.internal.c.Carbon; 42 import Carbon = dwt.internal.c.Carbon;
43 import dwt.internal.objc.cocoa.Cocoa; 43 import dwt.internal.objc.cocoa.Cocoa;
44 import objc = dwt.internal.objc.runtime; 44 import objc = dwt.internal.objc.runtime;
45 import dwt.widgets.Composite; 45 import dwt.widgets.Composite;
46 import dwt.widgets.Control; 46 import dwt.widgets.Control;
47 import dwt.widgets.Decorations; 47 import dwt.widgets.Decorations;
561 if ((style & (DWT.NO_TRIM | DWT.BORDER | DWT.SHELL_TRIM)) is 0) { 561 if ((style & (DWT.NO_TRIM | DWT.BORDER | DWT.SHELL_TRIM)) is 0) {
562 window.setHasShadow (true); 562 window.setHasShadow (true);
563 } 563 }
564 display.cascadeWindow(window, screen); 564 display.cascadeWindow(window, screen);
565 NSRect screenFrame = screen.frame(); 565 NSRect screenFrame = screen.frame();
566 CGFloat width = screenFrame.width * 5 / 8, height = screenFrame.height * 5 / 8;; 566 Carbon.CGFloat width = screenFrame.width * 5 / 8, height = screenFrame.height * 5 / 8;;
567 NSRect frame = window.frame(); 567 NSRect frame = window.frame();
568 NSRect primaryFrame = primaryScreen.frame(); 568 NSRect primaryFrame = primaryScreen.frame();
569 frame.y = primaryFrame.height - ((primaryFrame.height - (frame.y + frame.height)) + height); 569 frame.y = primaryFrame.height - ((primaryFrame.height - (frame.y + frame.height)) + height);
570 frame.width = width; 570 frame.width = width;
571 frame.height = height; 571 frame.height = height;
586 windowDelegate = cast(SWTWindowDelegate)(new SWTWindowDelegate()).alloc().init(); 586 windowDelegate = cast(SWTWindowDelegate)(new SWTWindowDelegate()).alloc().init();
587 window.setDelegate(windowDelegate); 587 window.setDelegate(windowDelegate);
588 window.disableCursorRects(); 588 window.disableCursorRects();
589 id id = window.fieldEditor (true, null); 589 id id = window.fieldEditor (true, null);
590 if (id !is null) { 590 if (id !is null) {
591 OS.object_setClass (id.id, OS.objc_getClass ("SWTEditorView")); 591 OS.object_setClass (id.id, cast(objc.Class) OS.objc_getClass ("SWTEditorView"));
592 } 592 }
593 } 593 }
594 594
595 /* 595 /*
596 * Feature in Cocoa. An NSWindow that is the child window of another NSWindow 596 * Feature in Cocoa. An NSWindow that is the child window of another NSWindow
716 } 716 }
717 717
718 public Rectangle getBounds () { 718 public Rectangle getBounds () {
719 checkWidget(); 719 checkWidget();
720 NSRect frame = (window is null ? view.frame() : window.frame()); 720 NSRect frame = (window is null ? view.frame() : window.frame());
721 GCFloat y = display.getPrimaryFrame().height - cast(int)(frame.y + frame.height); 721 Carbon.CGFloat y = display.getPrimaryFrame().height - cast(int)(frame.y + frame.height);
722 return new Rectangle (cast(int)frame.x, cast(int)y, cast(int)frame.width, cast(int)frame.height); 722 return new Rectangle (cast(int)frame.x, cast(int)y, cast(int)frame.width, cast(int)frame.height);
723 } 723 }
724 724
725 public Rectangle getClientArea () { 725 public Rectangle getClientArea () {
726 checkWidget(); 726 checkWidget();
731 int width = cast(int)rect.width, height = cast(int)rect.height; 731 int width = cast(int)rect.width, height = cast(int)rect.height;
732 return new Rectangle (0, 0, width, height); 732 return new Rectangle (0, 0, width, height);
733 } 733 }
734 734
735 NSRect rect = window.contentRectForFrameRect(window.frame()); 735 NSRect rect = window.contentRectForFrameRect(window.frame());
736 int width = cast(int)rect.width, height = cast(int)rect.height;
736 if (scrollView !is null) { 737 if (scrollView !is null) {
737 NSSize size = NSSize(); 738 NSSize size = NSSize();
738 size.width = width; 739 size.width = width;
739 size.height = height; 740 size.height = height;
740 size = NSScrollView.contentSizeForFrameSize(size, (style & DWT.H_SCROLL) !is 0, (style & DWT.V_SCROLL) !is 0, NSNoBorder); 741 size = NSScrollView.contentSizeForFrameSize(size, (style & DWT.H_SCROLL) !is 0, (style & DWT.V_SCROLL) !is 0, OS.NSNoBorder);
741 width = cast(int)size.width; 742 width = cast(int)size.width;
742 height = cast(int)size.height; 743 height = cast(int)size.height;
743 } 744 }
744 return new Rectangle (0, 0, width, height); 745 return new Rectangle (0, 0, width, height);
745 } 746 }
791 792
792 public Point getLocation () { 793 public Point getLocation () {
793 checkWidget(); 794 checkWidget();
794 // TODO: frame is relative to superview. What does getLocation mean in the embedded case? 795 // TODO: frame is relative to superview. What does getLocation mean in the embedded case?
795 NSRect frame = (window !is null ? window.frame() : view.frame()); 796 NSRect frame = (window !is null ? window.frame() : view.frame());
796 CGFloat y = display.getPrimaryFrame().height - cast(int)(frame.y + frame.height); 797 Carbon.CGFloat y = display.getPrimaryFrame().height - cast(int)(frame.y + frame.height);
797 return new Point (cast(int)frame.x, cast(int)y); 798 return new Point (cast(int)frame.x, cast(int)y);
798 } 799 }
799 800
800 public bool getMaximized () { 801 public bool getMaximized () {
801 checkWidget(); 802 checkWidget();
1014 updateModal (); 1015 updateModal ();
1015 } 1016 }
1016 setWindowVisible (true, true); 1017 setWindowVisible (true, true);
1017 if (isDisposed ()) return; 1018 if (isDisposed ()) return;
1018 // if (active) { 1019 // if (active) {
1019 if (!restoreFocus () && !traverseGroup (true)) setFocus (); 1020 if (!restoreFocus () && !traverseGroup (true)) setFocus ();
1020 // } 1021 // }
1021 } 1022 }
1022 1023
1023 public bool print (GC gc) { 1024 public bool print (GC gc) {
1024 checkWidget (); 1025 checkWidget ();
1446 1447
1447 NSBezierPath getPath(Region region) { 1448 NSBezierPath getPath(Region region) {
1448 if (region is null) return null; 1449 if (region is null) return null;
1449 NSBezierPath path = NSBezierPath.bezierPath(); 1450 NSBezierPath path = NSBezierPath.bezierPath();
1450 path.retain(); 1451 path.retain();
1451 OS.QDRegionToRects(region.handle, OS.kQDParseRegionFromTopLeft, cast(RegionToRectsUPP) &regionToRects, path.id); 1452 OS.QDRegionToRects(region.handle, OS.kQDParseRegionFromTopLeft, cast(Carbon.RegionToRectsUPP) &regionToRects, path.id);
1452 if (path.isEmpty()) path.appendBezierPathWithRect(NSRect()); 1453 if (path.isEmpty()) path.appendBezierPathWithRect(NSRect());
1453 return path; 1454 return path;
1454 } 1455 }
1455 1456
1456 extern (C) static OSStatus regionToRects(ushort message, RgnHandle rgn, Rect* r, void* path) { 1457 extern (C) static Carbon.OSStatus regionToRects(ushort message, Carbon.RgnHandle rgn, Carbon.Rect* r, objc.id path) {
1457 NSPoint pt = NSPoint(); 1458 NSPoint pt = NSPoint();
1458 Rect rect; 1459 Carbon.Rect rect;
1459 if (message is OS.kQDRegionToRectsMsgParse) { 1460 if (message is OS.kQDRegionToRectsMsgParse) {
1460 OS.memmove(&rect, r, rect.length * 2); 1461 OS.memmove(&rect, r, rect.sizeof * 2);
1461 pt.x = rect.left; 1462 pt.x = rect.left;
1462 pt.y = rect.top; 1463 pt.y = rect.top;
1463 OS.objc_msgSend(path, OS.sel_moveToPoint_, pt); 1464 OS.objc_msgSend(path, OS.sel_moveToPoint_, pt);
1464 pt.x = rect.right; 1465 pt.x = rect.right;
1465 OS.objc_msgSend(path, OS.sel_lineToPoint_, pt); 1466 OS.objc_msgSend(path, OS.sel_lineToPoint_, pt);
1473 return 0; 1474 return 0;
1474 } 1475 }
1475 1476
1476 public void setText (String str) { 1477 public void setText (String str) {
1477 checkWidget(); 1478 checkWidget();
1478 if (str is null) error (DWT.ERROR_NULL_ARGUMENT); 1479 //if (str is null) error (DWT.ERROR_NULL_ARGUMENT);
1479 if (window is null) return; 1480 if (window is null) return;
1480 NSString nsStr = NSString.stringWith(str); 1481 NSString nsStr = NSString.stringWith(str);
1481 window.setTitle(nsStr); 1482 window.setTitle(nsStr);
1482 } 1483 }
1483 1484