Mercurial > projects > dwt-mac
comparison dwt/widgets/Shell.d @ 37:642f460a0908
Fixed a lot of compile errors, a "hello world" app compiles now
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Fri, 10 Oct 2008 12:29:48 +0200 |
parents | 453387bb0706 |
children | d8635bb48c7c |
comparison
equal
deleted
inserted
replaced
36:db5a898b2119 | 37:642f460a0908 |
---|---|
274 * @see DWT#PRIMARY_MODAL | 274 * @see DWT#PRIMARY_MODAL |
275 * @see DWT#APPLICATION_MODAL | 275 * @see DWT#APPLICATION_MODAL |
276 * @see DWT#SYSTEM_MODAL | 276 * @see DWT#SYSTEM_MODAL |
277 */ | 277 */ |
278 public this (Display display, int style) { | 278 public this (Display display, int style) { |
279 this (display, null, style, 0, false); | 279 this (display, null, style, null, false); |
280 } | 280 } |
281 | 281 |
282 this (Display display, Shell parent, int style, objc.id handle, bool embedded) { | 282 this (Display display, Shell parent, int style, objc.id handle, bool embedded) { |
283 super (); | 283 super (); |
284 checkSubclass (); | 284 checkSubclass (); |
376 * @see DWT#PRIMARY_MODAL | 376 * @see DWT#PRIMARY_MODAL |
377 * @see DWT#APPLICATION_MODAL | 377 * @see DWT#APPLICATION_MODAL |
378 * @see DWT#SYSTEM_MODAL | 378 * @see DWT#SYSTEM_MODAL |
379 */ | 379 */ |
380 public this (Shell parent, int style) { | 380 public this (Shell parent, int style) { |
381 this (parent !is null ? parent.display : null, parent, style, 0, false); | 381 this (parent !is null ? parent.display : null, parent, style, null, false); |
382 } | 382 } |
383 | 383 |
384 public static Shell internal_new (Display display, objc.id handle) { | 384 public static Shell internal_new (Display display, objc.id handle) { |
385 return new Shell (display, null, DWT.NO_TRIM, handle, false); | 385 return new Shell (display, null, DWT.NO_TRIM, handle, false); |
386 } | 386 } |
489 NSRect rect = NSRect(); | 489 NSRect rect = NSRect(); |
490 dwt.widgets.Monitor.Monitor monitor = getMonitor (); | 490 dwt.widgets.Monitor.Monitor monitor = getMonitor (); |
491 Rectangle clientArea = monitor.getClientArea (); | 491 Rectangle clientArea = monitor.getClientArea (); |
492 rect.width = clientArea.width * 5 / 8; | 492 rect.width = clientArea.width * 5 / 8; |
493 rect.height = clientArea.height * 5 / 8; | 493 rect.height = clientArea.height * 5 / 8; |
494 int styleMask = OS.NSBorderlessWindowMask; | 494 NSUInteger styleMask = NSBorderlessWindowMask; |
495 if ((style & DWT.NO_TRIM) is 0) { | 495 if ((style & DWT.NO_TRIM) is 0) { |
496 styleMask = OS.NSTitledWindowMask; | 496 styleMask = OS.NSTitledWindowMask; |
497 if ((style & DWT.CLOSE) !is 0) styleMask |= OS.NSClosableWindowMask; | 497 if ((style & DWT.CLOSE) !is 0) styleMask |= NSClosableWindowMask; |
498 if ((style & DWT.MIN) !is 0) styleMask |= OS.NSMiniaturizableWindowMask; | 498 if ((style & DWT.MIN) !is 0) styleMask |= NSMiniaturizableWindowMask; |
499 if ((style & DWT.MAX) !is 0) styleMask |= OS.NSResizableWindowMask; | 499 if ((style & DWT.MAX) !is 0) styleMask |= NSResizableWindowMask; |
500 if ((style & DWT.RESIZE) !is 0) styleMask |= OS.NSResizableWindowMask; | 500 if ((style & DWT.RESIZE) !is 0) styleMask |= NSResizableWindowMask; |
501 } | 501 } |
502 window = window.initWithContentRect_styleMask_backing_defer_(rect, styleMask, OS.NSBackingStoreBuffered, false); | 502 window = window.initWithContentRect_styleMask_backing_defer_(rect, styleMask, NSBackingStoreBuffered, false); |
503 display.cascade = window.cascadeTopLeftFromPoint(display.cascade); | 503 display.cascade = window.cascadeTopLeftFromPoint(display.cascade); |
504 if ((style & DWT.ON_TOP) !is 0) { | 504 if ((style & DWT.ON_TOP) !is 0) { |
505 window.setLevel(OS.NSFloatingWindowLevel); | 505 window.setLevel(OS.NSFloatingWindowLevel); |
506 } | 506 } |
507 } | 507 } |
508 | 508 |
509 createHandle (null); | 509 (cast(Composite)this).createHandle (null); |
510 | 510 |
511 window.setContentView (topView()); | 511 window.setContentView (topView()); |
512 windowDelegate = cast(SWTWindowDelegate)(new SWTWindowDelegate()).alloc().init(); | 512 windowDelegate = cast(SWTWindowDelegate)(new SWTWindowDelegate()).alloc().init(); |
513 windowDelegate.setTag(jniRef); | 513 windowDelegate.setTag(jniRef); |
514 window.setDelegate(windowDelegate); | 514 window.setDelegate(windowDelegate); |
553 if (type is DWT.KeyUp && (modifiers & OS.NSAlphaShiftKeyMask) is 0 && (lastModifiers & OS.NSAlphaShiftKeyMask) !is 0) { | 553 if (type is DWT.KeyUp && (modifiers & OS.NSAlphaShiftKeyMask) is 0 && (lastModifiers & OS.NSAlphaShiftKeyMask) !is 0) { |
554 if (target !is null) { | 554 if (target !is null) { |
555 Event event = new Event (); | 555 Event event = new Event (); |
556 event.keyCode = DWT.CAPS_LOCK; | 556 event.keyCode = DWT.CAPS_LOCK; |
557 // setInputState (event, DWT.KeyDown, chord, modifiers); | 557 // setInputState (event, DWT.KeyDown, chord, modifiers); |
558 target.sendKeyEvent (DWT.KeyDown, event); | 558 (cast(Widget)target).sendKeyEvent (DWT.KeyDown, event); |
559 } | 559 } |
560 } | 560 } |
561 Event event = new Event (); | 561 Event event = new Event (); |
562 // setInputState (event, type, chord, modifiers); | 562 // setInputState (event, type, chord, modifiers); |
563 if (event.keyCode is 0 && event.character is 0) return; | 563 if (event.keyCode is 0 && event.character is 0) return; |
564 bool result = sendKeyEvent (type, event); | 564 bool result = (cast(Widget)this).sendKeyEvent (type, event); |
565 if (type is DWT.KeyDown && (modifiers & OS.NSAlphaShiftKeyMask) !is 0 && (lastModifiers & OS.NSAlphaShiftKeyMask) is 0) { | 565 if (type is DWT.KeyDown && (modifiers & OS.NSAlphaShiftKeyMask) !is 0 && (lastModifiers & OS.NSAlphaShiftKeyMask) is 0) { |
566 if (target !is null) { | 566 if (target !is null) { |
567 event = new Event (); | 567 event = new Event (); |
568 event.keyCode = DWT.CAPS_LOCK; | 568 event.keyCode = DWT.CAPS_LOCK; |
569 // setInputState (event, DWT.KeyUp, chord, modifiers); | 569 // setInputState (event, DWT.KeyUp, chord, modifiers); |
570 target.sendKeyEvent (DWT.KeyUp, event); | 570 (cast(Widget)target).sendKeyEvent (DWT.KeyUp, event); |
571 } | 571 } |
572 } | 572 } |
573 display.lastModifiers = modifiers; | 573 display.lastModifiers = modifiers; |
574 } | 574 } |
575 | 575 |
619 int width = cast(int)rect.width, height = cast(int)rect.height; | 619 int width = cast(int)rect.width, height = cast(int)rect.height; |
620 if (scrollView !is null) { | 620 if (scrollView !is null) { |
621 NSSize size = NSSize(); | 621 NSSize size = NSSize(); |
622 size.width = width; | 622 size.width = width; |
623 size.height = height; | 623 size.height = height; |
624 size = NSScrollView.contentSizeForFrameSize(size, (style & DWT.H_SCROLL) !is 0, (style & DWT.V_SCROLL) !is 0, OS.NSNoBorder); | 624 size = NSScrollView.contentSizeForFrameSize(size, (style & DWT.H_SCROLL) !is 0, (style & DWT.V_SCROLL) !is 0, NSNoBorder); |
625 width = cast(int)size.width; | 625 width = cast(int)size.width; |
626 height = cast(int)size.height; | 626 height = cast(int)size.height; |
627 } | 627 } |
628 return new Rectangle (0, 0, width, height); | 628 return new Rectangle (0, 0, width, height); |
629 } | 629 } |
1229 // } | 1229 // } |
1230 } | 1230 } |
1231 | 1231 |
1232 public void setText (String str) { | 1232 public void setText (String str) { |
1233 checkWidget(); | 1233 checkWidget(); |
1234 if (string is null) error (DWT.ERROR_NULL_ARGUMENT); | 1234 if (str is null) error (DWT.ERROR_NULL_ARGUMENT); |
1235 super.setText (str); | 1235 super.setText (str); |
1236 NSString nsStr = NSString.stringWith(str); | 1236 NSString nsStr = NSString.stringWith(str); |
1237 window.setTitle(nsStr); | 1237 window.setTitle(nsStr); |
1238 // str.release(); | 1238 // str.release(); |
1239 } | 1239 } |
1261 } | 1261 } |
1262 if (!resized) { | 1262 if (!resized) { |
1263 resized = true; | 1263 resized = true; |
1264 sendEvent (DWT.Resize); | 1264 sendEvent (DWT.Resize); |
1265 if (isDisposed ()) return; | 1265 if (isDisposed ()) return; |
1266 if (layout !is null) { | 1266 if (layout_ !is null) { |
1267 markLayout (false, false); | 1267 markLayout (false, false); |
1268 updateLayout (false); | 1268 updateLayout (false); |
1269 } | 1269 } |
1270 } | 1270 } |
1271 } else { | 1271 } else { |
1299 if (!getMonitor ().equals (display.getPrimaryMonitor ())) return; | 1299 if (!getMonitor ().equals (display.getPrimaryMonitor ())) return; |
1300 bool isActive = false; | 1300 bool isActive = false; |
1301 Shell activeShell = display.getActiveShell (); | 1301 Shell activeShell = display.getActiveShell (); |
1302 Shell current = this; | 1302 Shell current = this; |
1303 while (current !is null) { | 1303 while (current !is null) { |
1304 if (current.equals (activeShell)) { | 1304 if (current.opEquals (activeShell)) { |
1305 isActive = true; | 1305 isActive = true; |
1306 break; | 1306 break; |
1307 } | 1307 } |
1308 current = cast(Shell) current.parent; | 1308 current = cast(Shell) current.parent; |
1309 } | 1309 } |
1336 | 1336 |
1337 void windowDidResize(int notification) { | 1337 void windowDidResize(int notification) { |
1338 resized = true; | 1338 resized = true; |
1339 sendEvent (DWT.Resize); | 1339 sendEvent (DWT.Resize); |
1340 if (isDisposed ()) return; | 1340 if (isDisposed ()) return; |
1341 if (layout !is null) { | 1341 if (layout_ !is null) { |
1342 markLayout (false, false); | 1342 markLayout (false, false); |
1343 updateLayout (false); | 1343 updateLayout (false); |
1344 } | 1344 } |
1345 } | 1345 } |
1346 | 1346 |
1387 if (eventTarget.isDisposed()) return; | 1387 if (eventTarget.isDisposed()) return; |
1388 } | 1388 } |
1389 if (!eventTarget.sendKeyEvent(nsEvent, type is OS.NSKeyDown ? DWT.KeyDown : DWT.KeyUp)) return; | 1389 if (!eventTarget.sendKeyEvent(nsEvent, type is OS.NSKeyDown ? DWT.KeyDown : DWT.KeyUp)) return; |
1390 } | 1390 } |
1391 } | 1391 } |
1392 super.windowSendEvent(id, event); | 1392 super.windowSendEvent(ID, event); |
1393 } | 1393 } |
1394 | 1394 |
1395 } | 1395 } |