Mercurial > projects > dwt-mac
comparison dwt/widgets/Shell.d @ 7:e831403a80a9
Add 'cast' to casts
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Wed, 27 Aug 2008 14:30:35 +0200 |
parents | 1a8b3cb347e0 |
children | fba856099f87 |
comparison
equal
deleted
inserted
replaced
6:b903c16b6f48 | 7:e831403a80a9 |
---|---|
140 static int DEFAULT_CLIENT_WIDTH = -1; | 140 static int DEFAULT_CLIENT_WIDTH = -1; |
141 static int DEFAULT_CLIENT_HEIGHT = -1; | 141 static int DEFAULT_CLIENT_HEIGHT = -1; |
142 | 142 |
143 /** | 143 /** |
144 * Constructs a new instance of this class. This is equivalent | 144 * Constructs a new instance of this class. This is equivalent |
145 * to calling <code>Shell((Display) null)</code>. | 145 * to calling <code>Shell(cast(Display) null)</code>. |
146 * | 146 * |
147 * @exception DWTException <ul> | 147 * @exception DWTException <ul> |
148 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> | 148 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> |
149 * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> | 149 * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> |
150 * </ul> | 150 * </ul> |
151 */ | 151 */ |
152 public this () { | 152 public this () { |
153 this ((Display) null); | 153 this (cast(Display) null); |
154 } | 154 } |
155 | 155 |
156 /** | 156 /** |
157 * Constructs a new instance of this class given only the style | 157 * Constructs a new instance of this class given only the style |
158 * value describing its behavior and appearance. This is equivalent | 158 * value describing its behavior and appearance. This is equivalent |
159 * to calling <code>Shell((Display) null, style)</code>. | 159 * to calling <code>Shell(cast(Display) null, style)</code>. |
160 * <p> | 160 * <p> |
161 * The style value is either one of the style constants defined in | 161 * The style value is either one of the style constants defined in |
162 * class <code>DWT</code> which is applicable to instances of this | 162 * class <code>DWT</code> which is applicable to instances of this |
163 * class, or must be built by <em>bitwise OR</em>'ing together | 163 * class, or must be built by <em>bitwise OR</em>'ing together |
164 * (that is, using the <code>int</code> "|" operator) two or more | 164 * (that is, using the <code>int</code> "|" operator) two or more |
187 * @see DWT#PRIMARY_MODAL | 187 * @see DWT#PRIMARY_MODAL |
188 * @see DWT#APPLICATION_MODAL | 188 * @see DWT#APPLICATION_MODAL |
189 * @see DWT#SYSTEM_MODAL | 189 * @see DWT#SYSTEM_MODAL |
190 */ | 190 */ |
191 public this (int style) { | 191 public this (int style) { |
192 this ((Display) null, style); | 192 this (cast(Display) null, style); |
193 } | 193 } |
194 | 194 |
195 /** | 195 /** |
196 * Constructs a new instance of this class given only the display | 196 * Constructs a new instance of this class given only the display |
197 * to create it on. It is created with style <code>DWT.SHELL_TRIM</code>. | 197 * to create it on. It is created with style <code>DWT.SHELL_TRIM</code>. |
455 rect.x = trim.x; | 455 rect.x = trim.x; |
456 rect.y = trim.y; | 456 rect.y = trim.y; |
457 rect.width = trim.width; | 457 rect.width = trim.width; |
458 rect.height = trim.height; | 458 rect.height = trim.height; |
459 rect = NSWindow.static_frameRectForContentRect_styleMask_(rect, window.styleMask()); | 459 rect = NSWindow.static_frameRectForContentRect_styleMask_(rect, window.styleMask()); |
460 return new Rectangle ((int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height); | 460 return new Rectangle (cast(int)rect.x, cast(int)rect.y, cast(int)rect.width, cast(int)rect.height); |
461 } | 461 } |
462 | 462 |
463 void createHandle () { | 463 void createHandle () { |
464 state |= CANVAS;// | GRAB | HIDDEN; | 464 state |= CANVAS;// | GRAB | HIDDEN; |
465 if (window !is null) { | 465 if (window !is null) { |
466 view = window.contentView(); | 466 view = window.contentView(); |
467 return; | 467 return; |
468 } else { | 468 } else { |
469 SWTWindow swtWindow = (SWTWindow) new SWTWindow ().alloc (); | 469 SWTWindow swtWindow = cast(SWTWindow) new SWTWindow ().alloc (); |
470 swtWindow.setTag(jniRef); | 470 swtWindow.setTag(jniRef); |
471 window = (NSWindow)swtWindow; | 471 window = cast(NSWindow)swtWindow; |
472 NSRect rect = new NSRect(); | 472 NSRect rect = new NSRect(); |
473 Monitor monitor = getMonitor (); | 473 Monitor monitor = getMonitor (); |
474 Rectangle clientArea = monitor.getClientArea (); | 474 Rectangle clientArea = monitor.getClientArea (); |
475 rect.width = clientArea.width * 5 / 8; | 475 rect.width = clientArea.width * 5 / 8; |
476 rect.height = clientArea.height * 5 / 8; | 476 rect.height = clientArea.height * 5 / 8; |
490 } | 490 } |
491 | 491 |
492 createHandle (null); | 492 createHandle (null); |
493 | 493 |
494 window.setContentView (topView()); | 494 window.setContentView (topView()); |
495 windowDelegate = (SWTWindowDelegate)new SWTWindowDelegate().alloc().init(); | 495 windowDelegate = cast(SWTWindowDelegate)new SWTWindowDelegate().alloc().init(); |
496 windowDelegate.setTag(jniRef); | 496 windowDelegate.setTag(jniRef); |
497 window.setDelegate(windowDelegate); | 497 window.setDelegate(windowDelegate); |
498 } | 498 } |
499 | 499 |
500 void destroyWidget () { | 500 void destroyWidget () { |
584 // OS.SetFrontProcessWithOptions (new int [] {0, OS.kCurrentProcess}, OS.kSetFrontProcessFrontWindowOnly); | 584 // OS.SetFrontProcessWithOptions (new int [] {0, OS.kCurrentProcess}, OS.kSetFrontProcessFrontWindowOnly); |
585 } | 585 } |
586 | 586 |
587 public int getAlpha () { | 587 public int getAlpha () { |
588 checkWidget (); | 588 checkWidget (); |
589 return (int)(window.alphaValue() * 255); | 589 return cast(int)(window.alphaValue() * 255); |
590 } | 590 } |
591 | 591 |
592 public Rectangle getBounds () { | 592 public Rectangle getBounds () { |
593 checkWidget(); | 593 checkWidget(); |
594 NSRect frame = window.frame (); | 594 NSRect frame = window.frame (); |
595 return new Rectangle ((int)frame.x, (int) frame.y, (int) frame.width, (int) frame.height); | 595 return new Rectangle (cast(int)frame.x, cast(int) frame.y, cast(int) frame.width, cast(int) frame.height); |
596 } | 596 } |
597 | 597 |
598 public Rectangle getClientArea () { | 598 public Rectangle getClientArea () { |
599 checkWidget(); | 599 checkWidget(); |
600 //TODO why super implementation fails | 600 //TODO why super implementation fails |
601 NSRect rect = window.contentRectForFrameRect_(window.frame()); | 601 NSRect rect = window.contentRectForFrameRect_(window.frame()); |
602 int width = (int)rect.width, height = (int)rect.height; | 602 int width = cast(int)rect.width, height = cast(int)rect.height; |
603 if (scrollView !is null) { | 603 if (scrollView !is null) { |
604 NSSize size = new NSSize(); | 604 NSSize size = new NSSize(); |
605 size.width = width; | 605 size.width = width; |
606 size.height = height; | 606 size.height = height; |
607 size = NSScrollView.contentSizeForFrameSize(size, (style & DWT.H_SCROLL) !is 0, (style & DWT.V_SCROLL) !is 0, OS.NSNoBorder); | 607 size = NSScrollView.contentSizeForFrameSize(size, (style & DWT.H_SCROLL) !is 0, (style & DWT.V_SCROLL) !is 0, OS.NSNoBorder); |
608 width = (int)size.width; | 608 width = cast(int)size.width; |
609 height = (int)size.height; | 609 height = cast(int)size.height; |
610 } | 610 } |
611 return new Rectangle (0, 0, width, height); | 611 return new Rectangle (0, 0, width, height); |
612 } | 612 } |
613 | 613 |
614 int getDrawCount (int control) { | 614 int getDrawCount (int control) { |
644 } | 644 } |
645 | 645 |
646 public Point getLocation () { | 646 public Point getLocation () { |
647 checkWidget(); | 647 checkWidget(); |
648 NSRect frame = window.frame (); | 648 NSRect frame = window.frame (); |
649 return new Point ((int) frame.x, (int) frame.y); | 649 return new Point (cast(int) frame.x, cast(int) frame.y); |
650 } | 650 } |
651 | 651 |
652 public bool getMaximized () { | 652 public bool getMaximized () { |
653 checkWidget(); | 653 checkWidget(); |
654 //NOT DONE | 654 //NOT DONE |
681 checkWidget(); | 681 checkWidget(); |
682 // Rect rect = new Rect (); | 682 // Rect rect = new Rect (); |
683 // OS.GetWindowStructureWidths (shellHandle, rect); | 683 // OS.GetWindowStructureWidths (shellHandle, rect); |
684 // CGPoint inMinLimits = new CGPoint (), inMaxLimits = new CGPoint (); | 684 // CGPoint inMinLimits = new CGPoint (), inMaxLimits = new CGPoint (); |
685 // OS.GetWindowResizeLimits (shellHandle, inMinLimits, inMaxLimits); | 685 // OS.GetWindowResizeLimits (shellHandle, inMinLimits, inMaxLimits); |
686 // int width = Math.max (1, (int) inMinLimits.x + (rect.left + rect.right)); | 686 // int width = Math.max (1, cast(int) inMinLimits.x + (rect.left + rect.right)); |
687 // int height = Math.max (1, (int) inMinLimits.y + (rect.top + rect.bottom)); | 687 // int height = Math.max (1, cast(int) inMinLimits.y + (rect.top + rect.bottom)); |
688 // return new Point (width, height); | 688 // return new Point (width, height); |
689 return null; | 689 return null; |
690 } | 690 } |
691 | 691 |
692 float [] getParentBackground () { | 692 float [] getParentBackground () { |
755 } | 755 } |
756 | 756 |
757 public Point getSize () { | 757 public Point getSize () { |
758 checkWidget(); | 758 checkWidget(); |
759 NSRect frame = window.frame (); | 759 NSRect frame = window.frame (); |
760 return new Point ((int) frame.width, (int) frame.height); | 760 return new Point (cast(int) frame.width, cast(int) frame.height); |
761 } | 761 } |
762 | 762 |
763 bool hasBorder () { | 763 bool hasBorder () { |
764 return false; | 764 return false; |
765 } | 765 } |
970 // if (fullScreen) setFullScreen (false); | 970 // if (fullScreen) setFullScreen (false); |
971 if (move && resize) { | 971 if (move && resize) { |
972 NSRect rect = new NSRect (); | 972 NSRect rect = new NSRect (); |
973 rect.x = x; | 973 rect.x = x; |
974 //TODO - get the screen for the point | 974 //TODO - get the screen for the point |
975 int screenHeight = (int) window.screen().frame().height; | 975 int screenHeight = cast(int) window.screen().frame().height; |
976 rect.y = screenHeight - y; | 976 rect.y = screenHeight - y; |
977 rect.width = width; | 977 rect.width = width; |
978 rect.height = height; | 978 rect.height = height; |
979 window.setFrame_display_(rect, false); | 979 window.setFrame_display_(rect, false); |
980 } else { | 980 } else { |
981 if (move) { | 981 if (move) { |
982 NSPoint point = new NSPoint(); | 982 NSPoint point = new NSPoint(); |
983 point.x = x; | 983 point.x = x; |
984 //TODO - get the screen for the point | 984 //TODO - get the screen for the point |
985 int screenHeight = (int) window.screen().frame().height; | 985 int screenHeight = cast(int) window.screen().frame().height; |
986 point.y = screenHeight - y; | 986 point.y = screenHeight - y; |
987 window.setFrameTopLeftPoint (point); | 987 window.setFrameTopLeftPoint (point); |
988 } else { | 988 } else { |
989 if (resize) { | 989 if (resize) { |
990 NSRect rect = window.frame(); | 990 NSRect rect = window.frame(); |
1020 // OS.GetAvailableWindowPositioningBounds (gdevice, rect); | 1020 // OS.GetAvailableWindowPositioningBounds (gdevice, rect); |
1021 // screen.height -= rect.top; | 1021 // screen.height -= rect.top; |
1022 // screen.y += rect.top; | 1022 // screen.y += rect.top; |
1023 // } | 1023 // } |
1024 // Rect rect = new Rect (); | 1024 // Rect rect = new Rect (); |
1025 // OS.SetRect (rect, (short) screen.x, (short) screen.y, (short) (screen.x + screen.width), (short) (screen.y + screen.height)); | 1025 // OS.SetRect (rect, cast(short) screen.x, cast(short) screen.y, cast(short) (screen.x + screen.width), cast(short) (screen.y + screen.height)); |
1026 // OS.SetWindowBounds (shellHandle, (short) OS.kWindowStructureRgn, rect); | 1026 // OS.SetWindowBounds (shellHandle, cast(short) OS.kWindowStructureRgn, rect); |
1027 // } else { | 1027 // } else { |
1028 // int attributes = 0; | 1028 // int attributes = 0; |
1029 // if ((style & DWT.RESIZE) !is 0) { | 1029 // if ((style & DWT.RESIZE) !is 0) { |
1030 // attributes |= OS.kWindowResizableAttribute; | 1030 // attributes |= OS.kWindowResizableAttribute; |
1031 // /* | 1031 // /* |
1042 // OS.SetSystemUIMode (OS.kUIModeNormal, 0); | 1042 // OS.SetSystemUIMode (OS.kUIModeNormal, 0); |
1043 // if (maximized) { | 1043 // if (maximized) { |
1044 // setMaximized (true); | 1044 // setMaximized (true); |
1045 // } else { | 1045 // } else { |
1046 // Rect rect = new Rect (); | 1046 // Rect rect = new Rect (); |
1047 // if (normalBounds !is null) OS.SetRect (rect, (short) normalBounds.x, (short) normalBounds.y, (short) (normalBounds.x + normalBounds.width), (short) (normalBounds.y + normalBounds.height)); | 1047 // if (normalBounds !is null) OS.SetRect (rect, cast(short) normalBounds.x, cast(short) normalBounds.y, cast(short) (normalBounds.x + normalBounds.width), cast(short) (normalBounds.y + normalBounds.height)); |
1048 // OS.SetWindowBounds (shellHandle, (short) OS.kWindowStructureRgn, rect); | 1048 // OS.SetWindowBounds (shellHandle, cast(short) OS.kWindowStructureRgn, rect); |
1049 // } | 1049 // } |
1050 // normalBounds = null; | 1050 // normalBounds = null; |
1051 // } | 1051 // } |
1052 } | 1052 } |
1053 | 1053 |
1085 // dwt.internal.carbon.Point pt = new dwt.internal.carbon.Point (); | 1085 // dwt.internal.carbon.Point pt = new dwt.internal.carbon.Point (); |
1086 // if (maximized) { | 1086 // if (maximized) { |
1087 // Rect rect = new Rect (); | 1087 // Rect rect = new Rect (); |
1088 // int gdevice = OS.GetMainDevice (); | 1088 // int gdevice = OS.GetMainDevice (); |
1089 // OS.GetAvailableWindowPositioningBounds (gdevice, rect); | 1089 // OS.GetAvailableWindowPositioningBounds (gdevice, rect); |
1090 // pt.h = (short) (rect.right - rect.left); | 1090 // pt.h = cast(short) (rect.right - rect.left); |
1091 // pt.v = (short) (rect.bottom - rect.top); | 1091 // pt.v = cast(short) (rect.bottom - rect.top); |
1092 // } | 1092 // } |
1093 // short inPartCode = (short) (maximized ? OS.inZoomOut : OS.inZoomIn); | 1093 // short inPartCode = cast(short) (maximized ? OS.inZoomOut : OS.inZoomIn); |
1094 // OS.ZoomWindowIdeal (shellHandle, inPartCode, pt); | 1094 // OS.ZoomWindowIdeal (shellHandle, inPartCode, pt); |
1095 } | 1095 } |
1096 | 1096 |
1097 public void setMinimized (bool minimized) { | 1097 public void setMinimized (bool minimized) { |
1098 checkWidget(); | 1098 checkWidget(); |
1191 // if (region is null) { | 1191 // if (region is null) { |
1192 // rgnRect = null; | 1192 // rgnRect = null; |
1193 // } else { | 1193 // } else { |
1194 // if (rgnRect is null) { | 1194 // if (rgnRect is null) { |
1195 // rgnRect = new Rect (); | 1195 // rgnRect = new Rect (); |
1196 // OS.GetWindowBounds (shellHandle, (short) OS.kWindowStructureRgn, rgnRect); | 1196 // OS.GetWindowBounds (shellHandle, cast(short) OS.kWindowStructureRgn, rgnRect); |
1197 // OS.SetRect (rgnRect, (short) 0, (short) 0, (short) (rgnRect.right - rgnRect.left), (short) (rgnRect.bottom - rgnRect.top)); | 1197 // OS.SetRect (rgnRect, cast(short) 0, cast(short) 0, cast(short) (rgnRect.right - rgnRect.left), cast(short) (rgnRect.bottom - rgnRect.top)); |
1198 // } | 1198 // } |
1199 // } | 1199 // } |
1200 // this.region = region; | 1200 // this.region = region; |
1201 // /* | 1201 // /* |
1202 // * Bug in the Macintosh. Calling ReshapeCustomWindow() from a | 1202 // * Bug in the Macintosh. Calling ReshapeCustomWindow() from a |
1286 while (current !is null) { | 1286 while (current !is null) { |
1287 if (current.equals (activeShell)) { | 1287 if (current.equals (activeShell)) { |
1288 isActive = true; | 1288 isActive = true; |
1289 break; | 1289 break; |
1290 } | 1290 } |
1291 current = (Shell) current.parent; | 1291 current = cast(Shell) current.parent; |
1292 } | 1292 } |
1293 if (!isActive) return; | 1293 if (!isActive) return; |
1294 // if (fullScreen) { | 1294 // if (fullScreen) { |
1295 // int mode = OS.kUIModeAllHidden; | 1295 // int mode = OS.kUIModeAllHidden; |
1296 // if (menuBar !is null) { | 1296 // if (menuBar !is null) { |