comparison dwt/widgets/Display.d @ 15:2952d5604c0a

Ported some widgets, added some stuff to the runtime bindings
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Fri, 29 Aug 2008 21:46:05 +0200
parents 380af2bdd8e5
children 5b53d338c709
comparison
equal deleted inserted replaced
14:762fbe6f17d3 15:2952d5604c0a
5 * which accompanies this distribution, and is available at 5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html 6 * http://www.eclipse.org/legal/epl-v10.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * IBM Corporation - initial API and implementation 9 * IBM Corporation - initial API and implementation
10 *
11 * Port to the D programming language:
12 * Jacob Carlborg <jacob.carlborg@gmail.com>
10 *******************************************************************************/ 13 *******************************************************************************/
11 module dwt.widgets.Display; 14 module dwt.widgets.Display;
12
13 import dwt.dwthelper.utils;
14 15
15 import dwt.DWT; 16 import dwt.DWT;
16 import dwt.DWTError; 17 import dwt.DWTError;
17 import dwt.DWTException; 18 import dwt.DWTException;
18 import dwt.graphics.Color; 19 import dwt.graphics.Color;
54 import dwt.internal.cocoa.OS; 55 import dwt.internal.cocoa.OS;
55 import dwt.internal.cocoa.SWTApplicationDelegate; 56 import dwt.internal.cocoa.SWTApplicationDelegate;
56 import dwt.internal.cocoa.SWTWindowDelegate; 57 import dwt.internal.cocoa.SWTWindowDelegate;
57 import dwt.internal.cocoa.id; 58 import dwt.internal.cocoa.id;
58 59
60 import tango.core.Thread;
61
62 import dwt.dwthelper.Runnable;
63 import dwt.dwthelper.System;
64 import dwt.dwthelper.utils;
65
66 import dwt.internal.c.carboncore.MacTypes;
67
68 import dwt.internal.cocoa.NSInteger;
69
70 import dwt.widgets.Caret;
71 import dwt.widgets.Control;
72 import dwt.widgets.Dialog;
73 import dwt.widgets.Event;
74 import dwt.widgets.EventTable;
75 import dwt.widgets.Listener;
76 import dwt.widgets.Menu;
77 import dwt.widgets.Monitor;
78 import dwt.widgets.Shell;
79 import dwt.widgets.Synchronizer;
80 import dwt.widgets.Tray;
81 import dwt.widgets.Widget;
82
59 /** 83 /**
60 * Instances of this class are responsible for managing the 84 * Instances of this class are responsible for managing the
61 * connection between DWT and the underlying operating 85 * connection between DWT and the underlying operating
62 * system. Their most important function is to implement 86 * system. Their most important function is to implement
63 * the DWT event loop in terms of the platform event model. 87 * the DWT event loop in terms of the platform event model.
129 * @see #wake 153 * @see #wake
130 * @see #readAndDispatch 154 * @see #readAndDispatch
131 * @see #sleep 155 * @see #sleep
132 * @see Device#dispose 156 * @see Device#dispose
133 */ 157 */
134 public class Display extends Device { 158 public class Display : Device {
135 159
136 /* Windows and Events */ 160 /* Windows and Events */
137 Event [] eventQueue; 161 Event [] eventQueue;
138 EventTable eventTable, filterTable; 162 EventTable eventTable, filterTable;
139 bool disposing; 163 bool disposing;
150 Menu menuBar; 174 Menu menuBar;
151 175
152 NSApplication application; 176 NSApplication application;
153 NSAutoreleasePool pool; 177 NSAutoreleasePool pool;
154 178
155 NSPoint cascade = new NSPoint(); 179 NSPoint cascade = NSPoint();
156 180
157 Callback applicationDelegateCallback3; 181 Callback applicationDelegateCallback3;
158 Callback windowDelegateCallback2, windowDelegateCallback3, windowDelegateCallback4, windowDelegateCallback5; 182 Callback windowDelegateCallback2, windowDelegateCallback3, windowDelegateCallback4, windowDelegateCallback5;
159 Callback windowDelegateCallback6; 183 Callback windowDelegateCallback6;
160 Callback dialogCallback3; 184 Callback dialogCallback3;
174 /* System Resources */ 198 /* System Resources */
175 Image errorImage, infoImage, warningImage; 199 Image errorImage, infoImage, warningImage;
176 Cursor [] cursors = new Cursor [DWT.CURSOR_HAND + 1]; 200 Cursor [] cursors = new Cursor [DWT.CURSOR_HAND + 1];
177 201
178 /* Key Mappings. */ 202 /* Key Mappings. */
179 static int [] [] KeyTable = { 203 static int [] [] KeyTable = [
180 204
181 /* Keyboard and Mouse Masks */ 205 /* Keyboard and Mouse Masks */
182 // {58, DWT.ALT}, 206 // [58, DWT.ALT],
183 // {56, DWT.SHIFT}, 207 // [56, DWT.SHIFT],
184 // {59, DWT.CONTROL}, 208 // [59, DWT.CONTROL],
185 // {55, DWT.COMMAND}, 209 // [55, DWT.COMMAND],
186 210
187 /* Non-Numeric Keypad Keys */ 211 /* Non-Numeric Keypad Keys */
188 {OS.NSUpArrowFunctionKey, DWT.ARROW_UP}, 212 [OS.NSUpArrowFunctionKey, DWT.ARROW_UP],
189 {OS.NSDownArrowFunctionKey, DWT.ARROW_DOWN}, 213 [OS.NSDownArrowFunctionKey, DWT.ARROW_DOWN],
190 {OS.NSLeftArrowFunctionKey, DWT.ARROW_LEFT}, 214 [OS.NSLeftArrowFunctionKey, DWT.ARROW_LEFT],
191 {OS.NSRightArrowFunctionKey, DWT.ARROW_RIGHT}, 215 [OS.NSRightArrowFunctionKey, DWT.ARROW_RIGHT],
192 {OS.NSPageUpFunctionKey, DWT.PAGE_UP}, 216 [OS.NSPageUpFunctionKey, DWT.PAGE_UP],
193 {OS.NSPageDownFunctionKey, DWT.PAGE_DOWN}, 217 [OS.NSPageDownFunctionKey, DWT.PAGE_DOWN],
194 {OS.NSHomeFunctionKey, DWT.HOME}, 218 [OS.NSHomeFunctionKey, DWT.HOME],
195 {OS.NSEndFunctionKey, DWT.END}, 219 [OS.NSEndFunctionKey, DWT.END],
196 220
197 // {??, DWT.INSERT}, 221 // [??, DWT.INSERT],
198 222
199 /* Virtual and Ascii Keys */ 223 /* Virtual and Ascii Keys */
200 {OS.NSDeleteCharacter, DWT.BS}, 224 [OS.NSDeleteCharacter, DWT.BS],
201 // {36, DWT.CR}, 225 // [36, DWT.CR],
202 {OS.NSDeleteFunctionKey, DWT.DEL}, 226 [OS.NSDeleteFunctionKey, DWT.DEL],
203 // {53, DWT.ESC}, 227 // [53, DWT.ESC],
204 // {76, DWT.LF}, 228 // [76, DWT.LF],
205 // {48, DWT.TAB}, 229 // [48, DWT.TAB],
206 230
207 /* Functions Keys */ 231 /* Functions Keys */
208 {OS.NSF1FunctionKey, DWT.F1}, 232 [OS.NSF1FunctionKey, DWT.F1],
209 {OS.NSF2FunctionKey, DWT.F2}, 233 [OS.NSF2FunctionKey, DWT.F2],
210 {OS.NSF3FunctionKey, DWT.F3}, 234 [OS.NSF3FunctionKey, DWT.F3],
211 {OS.NSF4FunctionKey, DWT.F4}, 235 [OS.NSF4FunctionKey, DWT.F4],
212 {OS.NSF5FunctionKey, DWT.F5}, 236 [OS.NSF5FunctionKey, DWT.F5],
213 {OS.NSF6FunctionKey, DWT.F6}, 237 [OS.NSF6FunctionKey, DWT.F6],
214 {OS.NSF7FunctionKey, DWT.F7}, 238 [OS.NSF7FunctionKey, DWT.F7],
215 {OS.NSF8FunctionKey, DWT.F8}, 239 [OS.NSF8FunctionKey, DWT.F8],
216 {OS.NSF9FunctionKey, DWT.F9}, 240 [OS.NSF9FunctionKey, DWT.F9],
217 {OS.NSF10FunctionKey, DWT.F10}, 241 [OS.NSF10FunctionKey, DWT.F10],
218 {OS.NSF11FunctionKey, DWT.F11}, 242 [OS.NSF11FunctionKey, DWT.F11],
219 {OS.NSF12FunctionKey, DWT.F12}, 243 [OS.NSF12FunctionKey, DWT.F12],
220 {OS.NSF13FunctionKey, DWT.F13}, 244 [OS.NSF13FunctionKey, DWT.F13],
221 {OS.NSF14FunctionKey, DWT.F14}, 245 [OS.NSF14FunctionKey, DWT.F14],
222 {OS.NSF15FunctionKey, DWT.F15}, 246 [OS.NSF15FunctionKey, DWT.F15],
223 247
224 /* Numeric Keypad Keys */ 248 /* Numeric Keypad Keys */
225 // {67, DWT.KEYPAD_MULTIPLY}, 249 // [67, DWT.KEYPAD_MULTIPLY],
226 // {69, DWT.KEYPAD_ADD}, 250 // [69, DWT.KEYPAD_ADD],
227 // {76, DWT.KEYPAD_CR}, 251 // [76, DWT.KEYPAD_CR],
228 // {78, DWT.KEYPAD_SUBTRACT}, 252 // [78, DWT.KEYPAD_SUBTRACT],
229 // {65, DWT.KEYPAD_DECIMAL}, 253 // [65, DWT.KEYPAD_DECIMAL],
230 // {75, DWT.KEYPAD_DIVIDE}, 254 // [75, DWT.KEYPAD_DIVIDE],
231 // {82, DWT.KEYPAD_0}, 255 // [82, DWT.KEYPAD_0],
232 // {83, DWT.KEYPAD_1}, 256 // [83, DWT.KEYPAD_1],
233 // {84, DWT.KEYPAD_2}, 257 // [84, DWT.KEYPAD_2],
234 // {85, DWT.KEYPAD_3}, 258 // [85, DWT.KEYPAD_3],
235 // {86, DWT.KEYPAD_4}, 259 // [86, DWT.KEYPAD_4],
236 // {87, DWT.KEYPAD_5}, 260 // [87, DWT.KEYPAD_5],
237 // {88, DWT.KEYPAD_6}, 261 // [88, DWT.KEYPAD_6],
238 // {89, DWT.KEYPAD_7}, 262 // [89, DWT.KEYPAD_7],
239 // {91, DWT.KEYPAD_8}, 263 // [91, DWT.KEYPAD_8],
240 // {92, DWT.KEYPAD_9}, 264 // [92, DWT.KEYPAD_9],
241 // {81, DWT.KEYPAD_EQUAL}, 265 // [81, DWT.KEYPAD_EQUAL],
242 266
243 /* Other keys */ 267 /* Other keys */
244 // {??, DWT.CAPS_LOCK}, 268 // [??, DWT.CAPS_LOCK],
245 269
246 // {71, DWT.NUM_LOCK}, 270 // [71, DWT.NUM_LOCK],
247 271
248 // {??, DWT.SCROLL_LOCK}, 272 // [??, DWT.SCROLL_LOCK],
249 // {??, DWT.PAUSE}, 273 // [??, DWT.PAUSE],
250 // {??, DWT.BREAK}, 274 // [??, DWT.BREAK],
251 // {??, DWT.PRINT_SCREEN}, 275 // [??, DWT.PRINT_SCREEN],
252 276
253 {OS.NSHelpFunctionKey, DWT.HELP}, 277 [OS.NSHelpFunctionKey, DWT.HELP],
254 278
255 }; 279 ];
256 280
257 static String APP_NAME = "DWT"; 281 static String APP_NAME = "DWT";
258 static final String ADD_WIDGET_KEY = "dwt.internal.addWidget"; 282 static const String ADD_WIDGET_KEY = "dwt.internal.addWidget";
259 283
260 /* Multiple Displays. */ 284 /* Multiple Displays. */
261 static Display Default; 285 static Display Default;
262 static Display [] Displays = new Display [4]; 286 static Display [] Displays = new Display [4];
263 287
264 /* Package Name */ 288 /* Package Name */
265 static final String PACKAGE_PREFIX = "dwt.widgets."; 289 static const String PACKAGE_PREFIX = "dwt.widgets.";
266 290
267 /* Timer */ 291 /* Timer */
268 Runnable timerList []; 292 Runnable timerList [];
269 NSTimer nsTimers []; 293 NSTimer nsTimers [];
270 SWTWindowDelegate timerDelegate = (SWTWindowDelegate)new SWTWindowDelegate().alloc().init(); 294 SWTWindowDelegate timerDelegate = cast(SWTWindowDelegate)(new SWTWindowDelegate()).alloc().init();
271 SWTApplicationDelegate applicationDelegate; 295 SWTApplicationDelegate applicationDelegate;
272 296
273 /* Display Data */ 297 /* Display Data */
274 Object data; 298 Object data;
275 String [] keys; 299 String [] keys;
278 /* 302 /*
279 * TEMPORARY CODE. Install the runnable that 303 * TEMPORARY CODE. Install the runnable that
280 * gets the current display. This code will 304 * gets the current display. This code will
281 * be removed in the future. 305 * be removed in the future.
282 */ 306 */
283 static { 307 static this () {
284 DeviceFinder = new Runnable () { 308 DeviceFinder = new class Runnable {
285 public void run () { 309 public void run () {
286 Device device = getCurrent (); 310 Device device = getCurrent ();
287 if (device is null) { 311 if (device is null) {
288 device = getDefault (); 312 device = getDefault ();
289 } 313 }
303 int length = name.length (); 327 int length = name.length ();
304 char [] chars = new char [length]; 328 char [] chars = new char [length];
305 name.getChars (0, length, chars, 0); 329 name.getChars (0, length, chars, 0);
306 byte [] buffer = new byte [length + 1]; 330 byte [] buffer = new byte [length + 1];
307 for (int i=0; i<length; i++) { 331 for (int i=0; i<length; i++) {
308 buffer [i] = (byte) chars [i]; 332 buffer [i] = cast(byte) chars [i];
309 } 333 }
310 return buffer; 334 return buffer;
311 } 335 }
312 336
313 static int translateKey (int key) { 337 static int translateKey (int key) {
454 * </ul> 478 * </ul>
455 * 479 *
456 * @see #syncExec 480 * @see #syncExec
457 */ 481 */
458 public void asyncExec (Runnable runnable) { 482 public void asyncExec (Runnable runnable) {
459 synchronized (Device.class) { 483 synchronized (Device.classinfo) {
460 if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED); 484 if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED);
461 synchronizer.asyncExec (runnable); 485 synchronizer.asyncExec (runnable);
462 } 486 }
463 } 487 }
464 488
475 checkDevice (); 499 checkDevice ();
476 } 500 }
477 501
478 protected void checkDevice () { 502 protected void checkDevice () {
479 if (thread is null) error (DWT.ERROR_WIDGET_DISPOSED); 503 if (thread is null) error (DWT.ERROR_WIDGET_DISPOSED);
480 if (thread !is Thread.currentThread ()) error (DWT.ERROR_THREAD_INVALID_ACCESS); 504 if (thread !is Thread.getThis ()) error (DWT.ERROR_THREAD_INVALID_ACCESS);
481 if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED); 505 if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED);
482 } 506 }
483 507
484 /** 508 /**
485 * Checks that this class can be subclassed. 509 * Checks that this class can be subclassed.
492 * </ul> 516 * </ul>
493 * 517 *
494 * @see Widget#checkSubclass 518 * @see Widget#checkSubclass
495 */ 519 */
496 protected void checkSubclass () { 520 protected void checkSubclass () {
497 if (!Display.isValidClass (getClass ())) error (DWT.ERROR_INVALID_SUBCLASS); 521 if (!Display.isValidClass (this.classinfo)) error (DWT.ERROR_INVALID_SUBCLASS);
498 } 522 }
499 523
500 /** 524 /**
501 * Constructs a new instance of this class. 525 * Constructs a new instance of this class.
502 * <p> 526 * <p>
514 * @see #getCurrent 538 * @see #getCurrent
515 * @see #getDefault 539 * @see #getDefault
516 * @see Widget#checkSubclass 540 * @see Widget#checkSubclass
517 * @see Shell 541 * @see Shell
518 */ 542 */
519 public Display () { 543 public this () {
520 this (null); 544 this (null);
521 } 545 }
522 546
523 /** 547 /**
524 * Constructs a new instance of this class using the parameter. 548 * Constructs a new instance of this class using the parameter.
525 * 549 *
526 * @param data the device data 550 * @param data the device data
527 */ 551 */
528 public Display (DeviceData data) { 552 public this (DeviceData data) {
529 super (data); 553 super (data);
530 } 554 }
531 555
532 static void checkDisplay (Thread thread, bool multiple) { 556 static void checkDisplay (Thread thread, bool multiple) {
533 synchronized (Device.class) { 557 synchronized (Device.classinfo) {
534 for (int i=0; i<Displays.length; i++) { 558 for (int i=0; i<Displays.length; i++) {
535 if (Displays [i] !is null) { 559 if (Displays [i] !is null) {
536 if (!multiple) DWT.error (DWT.ERROR_NOT_IMPLEMENTED, null, " [multiple displays]"); 560 if (!multiple) DWT.error (DWT.ERROR_NOT_IMPLEMENTED, null, " [multiple displays]");
537 if (Displays [i].thread is thread) DWT.error (DWT.ERROR_THREAD_INVALID_ACCESS); 561 if (Displays [i].thread is thread) DWT.error (DWT.ERROR_THREAD_INVALID_ACCESS);
538 } 562 }
600 * 624 *
601 * @see #init 625 * @see #init
602 */ 626 */
603 protected void create (DeviceData data) { 627 protected void create (DeviceData data) {
604 checkSubclass (); 628 checkSubclass ();
605 checkDisplay (thread = Thread.currentThread (), false); 629 checkDisplay (thread = Thread.getThis (), false);
606 createDisplay (data); 630 createDisplay (data);
607 register (this); 631 register (this);
608 synchronizer = new Synchronizer (this); 632 synchronizer = new Synchronizer (this);
609 if (Default is null) Default = this; 633 if (Default is null) Default = this;
610 } 634 }
611 635
612 void createDisplay (DeviceData data) { 636 void createDisplay (DeviceData data) {
613 if (OS.VERSION < 0x1050) { 637 if (OS.VERSION < 0x1050) {
614 System.out.println ("***WARNING: DWT requires MacOS X version " + 10 + "." + 5 + " or greater"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 638 System.Out.println ("***WARNING: DWT requires MacOS X version {}{}{}{}" , 10 , "." , 5 , " or greater"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
615 System.out.println ("***WARNING: Detected: " + Integer.toHexString((OS.VERSION & 0xFF00) >> 8) + "." + Integer.toHexString((OS.VERSION & 0xF0) >> 4) + "." + Integer.toHexString(OS.VERSION & 0xF)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 639 System.Out.println ("***WARNING: Detected: {}{}{}{}{}" , Integer.toHexString((OS.VERSION & 0xFF00) >> 8) , "." , Integer.toHexString((OS.VERSION & 0xF0) >> 4) , "." , Integer.toHexString(OS.VERSION & 0xF)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
616 error(DWT.ERROR_NOT_IMPLEMENTED); 640 error(DWT.ERROR_NOT_IMPLEMENTED);
617 } 641 }
618 642
619 /* 643 /*
620 * Feature in the Macintosh. On OS 10.2, it is necessary 644 * Feature in the Macintosh. On OS 10.2, it is necessary
627 * serial number returned by GetCurrentProcess() in the 651 * serial number returned by GetCurrentProcess() in the
628 * call to SetFrontProcess() (ie. kCurrentProcess can be 652 * call to SetFrontProcess() (ie. kCurrentProcess can be
629 * used) but both functions must be called in order for 653 * used) but both functions must be called in order for
630 * windows to come to the front. 654 * windows to come to the front.
631 */ 655 */
632 int [] psn = new int [2]; 656 ProcessSerialNumber* psn;
633 if (OS.GetCurrentProcess (psn) is OS.noErr) { 657 if (OS.GetCurrentProcess (psn) is OS.noErr) {
634 // int pid = OS.getpid (); 658 // int pid = OS.getpid ();
635 // byte [] buffer = null; 659 // byte [] buffer = null;
636 // int ptr = OS.getenv (ascii ("APP_NAME_" + pid)); 660 // int ptr = OS.getenv (ascii ("APP_NAME_" + pid));
637 // if (ptr !is 0) { 661 // if (ptr !is 0) {
667 // OS.SetApplicationDockTileImage (dockImage); 691 // OS.SetApplicationDockTileImage (dockImage);
668 // } 692 // }
669 // } 693 // }
670 } 694 }
671 695
672 pool = (NSAutoreleasePool)new NSAutoreleasePool().alloc().init(); 696 pool = cast(NSAutoreleasePool)(new NSAutoreleasePool()).alloc().init();
673 application = NSApplication.sharedApplication(); 697 application = NSApplication.sharedApplication();
674 } 698 }
675 699
676 static void deregister (Display display) { 700 static void deregister (Display display) {
677 synchronized (Device.class) { 701 synchronized (Device.classinfo) {
678 for (int i=0; i<Displays.length; i++) { 702 for (int i=0; i<Displays.length; i++) {
679 if (display is Displays [i]) Displays [i] = null; 703 if (display is Displays [i]) Displays [i] = null;
680 } 704 }
681 } 705 }
682 } 706 }
761 * @exception DWTException <ul> 785 * @exception DWTException <ul>
762 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 786 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
763 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> 787 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
764 * </ul> 788 * </ul>
765 */ 789 */
766 public Widget findWidget (int handle) { 790 public Widget findWidget (objc.id handle) {
767 checkDevice (); 791 checkDevice ();
768 if (handle !is 0 && OS.objc_msgSend(handle, OS.sel_respondsToSelector_1, OS.sel_tag) !is 0) { 792 if (handle !is null && OS.objc_msgSend(handle, OS.sel_respondsToSelector_1, OS.sel_tag) !is null) {
769 int tag = OS.objc_msgSend(handle, OS.sel_tag); 793 NSInteger tag = cast(NSInteger) OS.objc_msgSend(handle, OS.sel_tag);
770 if (tag !is -1) { 794 if (tag !is -1) {
771 Object object = OS.JNIGetObject(tag); 795 Object object = OS.JNIGetObject(tag);
772 if (object instanceof Widget) { 796 if (cast(Widget) object) {
773 return (Widget)object; 797 return cast(Widget)object;
774 } 798 }
775 } 799 }
776 } 800 }
777 return null; 801 return null;
778 } 802 }
797 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> 821 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
798 * </ul> 822 * </ul>
799 * 823 *
800 * @since 3.1 824 * @since 3.1
801 */ 825 */
802 public Widget findWidget (int handle, int id) { 826 public Widget findWidget (objc.id handle, int id) {
803 checkDevice (); 827 checkDevice ();
804 return null; 828 return null;
805 } 829 }
806 830
807 /** 831 /**
835 * 859 *
836 * @param thread the user-interface thread 860 * @param thread the user-interface thread
837 * @return the display for the given thread 861 * @return the display for the given thread
838 */ 862 */
839 public static Display findDisplay (Thread thread) { 863 public static Display findDisplay (Thread thread) {
840 synchronized (Device.class) { 864 synchronized (Device.classinfo) {
841 for (int i=0; i<Displays.length; i++) { 865 for (int i=0; i<Displays.length; i++) {
842 Display display = Displays [i]; 866 Display display = Displays [i];
843 if (display !is null && display.thread is thread) { 867 if (display !is null && display.thread is thread) {
844 return display; 868 return display;
845 } 869 }
864 checkDevice (); 888 checkDevice ();
865 NSWindow window = application.keyWindow(); 889 NSWindow window = application.keyWindow();
866 if (window !is null) { 890 if (window !is null) {
867 NSView view = window.contentView(); 891 NSView view = window.contentView();
868 if (view !is null && view.respondsToSelector(OS.sel_tag)) { 892 if (view !is null && view.respondsToSelector(OS.sel_tag)) {
869 int tag = OS.objc_msgSend(view.id, OS.sel_tag); 893 NSInteger tag = OS.objc_msgSend(view.id_, OS.sel_tag);
870 if (tag !is -1) { 894 if (tag !is -1) {
871 Object object = OS.JNIGetObject(tag); 895 Object object = OS.JNIGetObject(tag);
872 if (object instanceof Shell) { 896 if (cast(Shell) object) {
873 return (Shell)object; 897 return cast(Shell)object;
874 } 898 }
875 } 899 }
876 } 900 }
877 } 901 }
878 return null; 902 return null;
899 * running thread is not a user-interface thread for any display. 923 * running thread is not a user-interface thread for any display.
900 * 924 *
901 * @return the current display 925 * @return the current display
902 */ 926 */
903 public static Display getCurrent () { 927 public static Display getCurrent () {
904 return findDisplay (Thread.currentThread ()); 928 return findDisplay (Thread.getThis ());
905 } 929 }
906 930
907 int getCaretBlinkTime () { 931 int getCaretBlinkTime () {
908 checkDevice (); 932 checkDevice ();
909 return 560; 933 return 560;
958 public Point getCursorLocation () { 982 public Point getCursorLocation () {
959 checkDevice (); 983 checkDevice ();
960 NSPoint location = NSEvent.mouseLocation(); 984 NSPoint location = NSEvent.mouseLocation();
961 //TODO bad for other screens 985 //TODO bad for other screens
962 NSRect rect = NSScreen.mainScreen().frame(); 986 NSRect rect = NSScreen.mainScreen().frame();
963 return new Point ((int) location.x, (int) (rect.height - location.y)); 987 return new Point (cast(int) location.x, cast(int) (rect.height - location.y));
964 } 988 }
965 989
966 /** 990 /**
967 * Returns an array containing the recommended cursor sizes. 991 * Returns an array containing the recommended cursor sizes.
968 * 992 *
975 * 999 *
976 * @since 3.0 1000 * @since 3.0
977 */ 1001 */
978 public Point [] getCursorSizes () { 1002 public Point [] getCursorSizes () {
979 checkDevice (); 1003 checkDevice ();
980 return new Point [] {new Point (16, 16)}; 1004 return new Point [] [new Point (16, 16)];
981 } 1005 }
982 1006
983 /** 1007 /**
984 * Returns the default display. One is created (making the 1008 * Returns the default display. One is created (making the
985 * thread that invokes this method its user-interface thread) 1009 * thread that invokes this method its user-interface thread)
986 * if it did not already exist. 1010 * if it did not already exist.
987 * 1011 *
988 * @return the default display 1012 * @return the default display
989 */ 1013 */
990 public static Display getDefault () { 1014 public static Display getDefault () {
991 synchronized (Device.class) { 1015 synchronized (Device.classinfo) {
992 if (Default is null) Default = new Display (); 1016 if (Default is null) Default = new Display ();
993 return Default; 1017 return Default;
994 } 1018 }
995 } 1019 }
996 1020
1019 * @see #setData(String, Object) 1043 * @see #setData(String, Object)
1020 * @see #disposeExec(Runnable) 1044 * @see #disposeExec(Runnable)
1021 */ 1045 */
1022 public Object getData (String key) { 1046 public Object getData (String key) {
1023 checkDevice (); 1047 checkDevice ();
1024 if (key is null) error (DWT.ERROR_NULL_ARGUMENT); 1048 //if (key is null) error (DWT.ERROR_NULL_ARGUMENT);
1025 if (keys is null) return null; 1049 if (keys is null) return null;
1026 for (int i=0; i<keys.length; i++) { 1050 for (int i=0; i<keys.length; i++) {
1027 if (keys [i].equals (key)) return values [i]; 1051 if (keys [i].equals (key)) return values [i];
1028 } 1052 }
1029 return null; 1053 return null;
1114 checkDevice (); 1138 checkDevice ();
1115 NSWindow window = application.keyWindow(); 1139 NSWindow window = application.keyWindow();
1116 if (window !is null) { 1140 if (window !is null) {
1117 NSResponder view = window.firstResponder(); 1141 NSResponder view = window.firstResponder();
1118 if (view !is null && view.respondsToSelector(OS.sel_tag)) { 1142 if (view !is null && view.respondsToSelector(OS.sel_tag)) {
1119 int tag = OS.objc_msgSend(view.id, OS.sel_tag); 1143 NSInteger tag = OS.objc_msgSend(view.id_, OS.sel_tag);
1120 if (tag !is -1) { 1144 if (tag !is -1) {
1121 Object object = OS.JNIGetObject(tag); 1145 Object object = OS.JNIGetObject(tag);
1122 if (object instanceof Control) { 1146 if (cast(Control) object) {
1123 //TODO go up hierarchy 1147 //TODO go up hierarchy
1124 return (Control)object; 1148 return cast(Control)object;
1125 } 1149 }
1126 } else { 1150 } else {
1127 /* 1151 /*
1128 * If the first responder is the shared field editor then answer its 1152 * If the first responder is the shared field editor then answer its
1129 * delegate as the focus control. 1153 * delegate as the focus control.
1130 */ 1154 */
1131 if (view.isKindOfClass(NSText.static_class())) { 1155 if (view.isKindOfClass(NSText.static_class())) {
1132 NSText text = new NSText(view.id); 1156 NSText text = new NSText(view.id_);
1133 if (text.isFieldEditor()) { 1157 if (text.isFieldEditor()) {
1134 id delegateId = text.delegate(); 1158 id delegateId = text.delegatee();
1135 if (delegateId !is null) { 1159 if (delegateId !is null) {
1136 NSObject delegate = new NSObject(delegateId.id); 1160 NSObject delegatee = new NSObject(delegateId.id_);
1137 if (delegate.respondsToSelector(OS.sel_tag)) { 1161 if (delegatee.respondsToSelector(OS.sel_tag)) {
1138 tag = OS.objc_msgSend(delegate.id, OS.sel_tag); 1162 tag = OS.objc_msgSend(delegatee.id_, OS.sel_tag);
1139 if (tag !is 0 && tag !is -1) { 1163 if (tag !is 0 && tag !is -1) {
1140 Object object = OS.JNIGetObject(tag); 1164 Object object = OS.JNIGetObject(tag);
1141 if (object instanceof Control) { 1165 if (cast(Control) object) {
1142 return (Control)object; 1166 return cast(Control)object;
1143 } 1167 }
1144 } 1168 }
1145 } 1169 }
1146 } 1170 }
1147 } 1171 }
1206 * 1230 *
1207 * @since 3.0 1231 * @since 3.0
1208 */ 1232 */
1209 public Point [] getIconSizes () { 1233 public Point [] getIconSizes () {
1210 checkDevice (); 1234 checkDevice ();
1211 return new Point [] { 1235 return new Point [] [
1212 new Point (16, 16), new Point (32, 32), 1236 new Point (16, 16), new Point (32, 32),
1213 new Point (64, 64), new Point (128, 128)}; 1237 new Point (64, 64), new Point (128, 128)];
1214 } 1238 }
1215 1239
1216 int getLastEventTime () { 1240 int getLastEventTime () {
1217 /* 1241 /*
1218 * This code is intentionally commented. Event time is 1242 * This code is intentionally commented. Event time is
1219 * in seconds and we need an accurate time in milliseconds. 1243 * in seconds and we need an accurate time in milliseconds.
1220 */ 1244 */
1221 // return (int) (OS.GetLastUserEventTime () * 1000.0); 1245 // return (int) (OS.GetLastUserEventTime () * 1000.0);
1222 return (int) System.currentTimeMillis (); 1246 return cast(int) System.currentTimeMillis ();
1223 } 1247 }
1224 1248
1225 //Menu [] getMenus (Decorations shell) { 1249 //Menu [] getMenus (Decorations shell) {
1226 // if (menus is null) return new Menu [0]; 1250 // if (menus is null) return new Menu [0];
1227 // int count = 0; 1251 // int count = 0;
1260 * 1284 *
1261 * @return the array of monitors 1285 * @return the array of monitors
1262 * 1286 *
1263 * @since 3.0 1287 * @since 3.0
1264 */ 1288 */
1265 public Monitor [] getMonitors () { 1289 public dwt.widgets.Monitor.Monitor [] getMonitors () {
1266 checkDevice (); 1290 checkDevice ();
1267 NSArray screens = NSScreen.screens(); 1291 NSArray screens = NSScreen.screens();
1268 int count = screens.count(); 1292 int count = screens.count();
1269 Monitor [] monitors = new Monitor [count]; 1293 dwt.widgets.Monitor.Monitor [] monitors = new dwt.widgets.Monitor.Monitor [count];
1270 for (int i=0; i<count; i++) { 1294 for (int i=0; i<count; i++) {
1271 Monitor monitor = new Monitor (); 1295 dwt.widgets.Monitor.Monitor monitor = new dwt.widgets.Monitor.Monitor ();
1272 NSScreen screen = new NSScreen(screens.objectAtIndex(i)); 1296 NSScreen screen = new NSScreen(screens.objectAtIndex(i));
1273 NSRect frame = screen.frame(); 1297 NSRect frame = screen.frame();
1274 monitor.x = (int)frame.x; 1298 monitor.x = cast(int)frame.x;
1275 monitor.y = (int)frame.y; 1299 monitor.y = cast(int)frame.y;
1276 monitor.width = (int)frame.width; 1300 monitor.width = cast(int)frame.width;
1277 monitor.height = (int)frame.height; 1301 monitor.height = cast(int)frame.height;
1278 NSRect visibleFrame = screen.visibleFrame(); 1302 NSRect visibleFrame = screen.visibleFrame();
1279 monitor.clientX = (int)visibleFrame.x; 1303 monitor.clientX = cast(int)visibleFrame.x;
1280 monitor.clientY = (int)visibleFrame.y; 1304 monitor.clientY = cast(int)visibleFrame.y;
1281 monitor.clientWidth = (int)visibleFrame.width; 1305 monitor.clientWidth = cast(int)visibleFrame.width;
1282 monitor.clientHeight = (int)visibleFrame.height; 1306 monitor.clientHeight = cast(int)visibleFrame.height;
1283 monitors [i] = monitor; 1307 monitors [i] = monitor;
1284 } 1308 }
1285 return monitors; 1309 return monitors;
1286 } 1310 }
1287 1311
1290 * 1314 *
1291 * @return the primary monitor 1315 * @return the primary monitor
1292 * 1316 *
1293 * @since 3.0 1317 * @since 3.0
1294 */ 1318 */
1295 public Monitor getPrimaryMonitor () { 1319 public dwt.widgets.Monitor.Monitor getPrimaryMonitor () {
1296 checkDevice (); 1320 checkDevice ();
1297 Monitor monitor = new Monitor (); 1321 dwt.widgets.Monitor.Monitor monitor = new dwt.widgets.Monitor.Monitor ();
1298 NSScreen screen = NSScreen.mainScreen(); 1322 NSScreen screen = NSScreen.mainScreen();
1299 NSRect frame = screen.frame(); 1323 NSRect frame = screen.frame();
1300 monitor.x = (int)frame.x; 1324 monitor.x = cast(int)frame.x;
1301 monitor.y = (int)frame.y; 1325 monitor.y = cast(int)frame.y;
1302 monitor.width = (int)frame.width; 1326 monitor.width = cast(int)frame.width;
1303 monitor.height = (int)frame.height; 1327 monitor.height = cast(int)frame.height;
1304 NSRect visibleFrame = screen.visibleFrame(); 1328 NSRect visibleFrame = screen.visibleFrame();
1305 monitor.clientX = (int)visibleFrame.x; 1329 monitor.clientX = cast(int)visibleFrame.x;
1306 monitor.clientY = (int)visibleFrame.y; 1330 monitor.clientY = cast(int)visibleFrame.y;
1307 monitor.clientWidth = (int)visibleFrame.width; 1331 monitor.clientWidth = cast(int)visibleFrame.width;
1308 monitor.clientHeight = (int)visibleFrame.height; 1332 monitor.clientHeight = cast(int)visibleFrame.height;
1309 return monitor; 1333 return monitor;
1310 } 1334 }
1311 1335
1312 /** 1336 /**
1313 * Returns a (possibly empty) array containing all shells which have 1337 * Returns a (possibly empty) array containing all shells which have
1327 Shell [] result = new Shell [windows.count()]; 1351 Shell [] result = new Shell [windows.count()];
1328 for (int i = 0; i < result.length; i++) { 1352 for (int i = 0; i < result.length; i++) {
1329 NSWindow window = new NSWindow(windows.objectAtIndex(i)); 1353 NSWindow window = new NSWindow(windows.objectAtIndex(i));
1330 NSView view = window.contentView(); 1354 NSView view = window.contentView();
1331 if (view !is null) { 1355 if (view !is null) {
1332 int jniRef = OS.objc_msgSend(view.id, OS.sel_tag); 1356 NSInteger jniRef = OS.objc_msgSend(view.id_, OS.sel_tag);
1333 if (jniRef !is 0 && jniRef !is -1) { 1357 if (jniRef !is 0 && jniRef !is -1) {
1334 Object object = OS.JNIGetObject(jniRef); 1358 Object object = OS.JNIGetObject(jniRef);
1335 if (object instanceof Shell) { 1359 if (cast(Shell) object) {
1336 result[index++] = (Shell)object; 1360 result[index++] = cast(Shell)object;
1337 } 1361 }
1338 } 1362 }
1339 } 1363 }
1340 } 1364 }
1341 if (index is result.length) return result; 1365 if (index is result.length) return result;
1375 * @exception DWTException <ul> 1399 * @exception DWTException <ul>
1376 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> 1400 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
1377 * </ul> 1401 * </ul>
1378 */ 1402 */
1379 public Thread getSyncThread () { 1403 public Thread getSyncThread () {
1380 synchronized (Device.class) { 1404 synchronized (Device.classinfo) {
1381 if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED); 1405 if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED);
1382 return synchronizer.syncThread; 1406 return synchronizer.syncThread;
1383 } 1407 }
1384 } 1408 }
1385 1409
1405 public Color getSystemColor (int id) { 1429 public Color getSystemColor (int id) {
1406 checkDevice (); 1430 checkDevice ();
1407 NSColor color = null; 1431 NSColor color = null;
1408 switch (id) { 1432 switch (id) {
1409 case DWT.COLOR_INFO_FOREGROUND: return super.getSystemColor (DWT.COLOR_BLACK); 1433 case DWT.COLOR_INFO_FOREGROUND: return super.getSystemColor (DWT.COLOR_BLACK);
1410 case DWT.COLOR_INFO_BACKGROUND: return Color.cocoa_new (this, new float [] {0xFF / 255f, 0xFF / 255f, 0xE1 / 255f, 1}); 1434 case DWT.COLOR_INFO_BACKGROUND: return Color.cocoa_new (this, new float [] [0xFF / 255f, 0xFF / 255f, 0xE1 / 255f, 1]);
1411 case DWT.COLOR_TITLE_FOREGROUND: color = NSColor.windowFrameTextColor(); break; 1435 case DWT.COLOR_TITLE_FOREGROUND: color = NSColor.windowFrameTextColor(); break;
1412 case DWT.COLOR_TITLE_BACKGROUND: color = NSColor.secondarySelectedControlColor(); break; 1436 case DWT.COLOR_TITLE_BACKGROUND: color = NSColor.secondarySelectedControlColor(); break;
1413 case DWT.COLOR_TITLE_BACKGROUND_GRADIENT: color = NSColor.windowFrameColor(); break; 1437 case DWT.COLOR_TITLE_BACKGROUND_GRADIENT: color = NSColor.windowFrameColor(); break;
1414 case DWT.COLOR_TITLE_INACTIVE_FOREGROUND: color = NSColor.disabledControlTextColor(); break; 1438 case DWT.COLOR_TITLE_INACTIVE_FOREGROUND: color = NSColor.disabledControlTextColor(); break;
1415 case DWT.COLOR_TITLE_INACTIVE_BACKGROUND: color = NSColor.secondarySelectedControlColor(); break; 1439 case DWT.COLOR_TITLE_INACTIVE_BACKGROUND: color = NSColor.secondarySelectedControlColor(); break;
1431 if (color is null) return super.getSystemColor(id); 1455 if (color is null) return super.getSystemColor(id);
1432 color = color.colorUsingColorSpace(NSColorSpace.deviceRGBColorSpace()); 1456 color = color.colorUsingColorSpace(NSColorSpace.deviceRGBColorSpace());
1433 if (color is null) return super.getSystemColor(id); 1457 if (color is null) return super.getSystemColor(id);
1434 float[] components = new float[color.numberOfComponents()]; 1458 float[] components = new float[color.numberOfComponents()];
1435 color.getComponents(components); 1459 color.getComponents(components);
1436 return Color.cocoa_new (this, new float[]{components[0], components[1], components[2], components[3]}); 1460 return Color.cocoa_new (this, new float[][components[0], components[1], components[2], components[3]]);
1437 } 1461 }
1438 1462
1439 /** 1463 /**
1440 * Returns the matching standard platform cursor for the given 1464 * Returns the matching standard platform cursor for the given
1441 * constant, which should be one of the cursor constants 1465 * constant, which should be one of the cursor constants
1562 * @exception DWTException <ul> 1586 * @exception DWTException <ul>
1563 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> 1587 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
1564 * </ul> 1588 * </ul>
1565 */ 1589 */
1566 public Thread getThread () { 1590 public Thread getThread () {
1567 synchronized (Device.class) { 1591 synchronized (Device.classinfo) {
1568 if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED); 1592 if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED);
1569 return thread; 1593 return thread;
1570 } 1594 }
1571 } 1595 }
1572 1596
1590 applicationDelegateCallback3 = new Callback(this, "applicationDelegateProc", 3); 1614 applicationDelegateCallback3 = new Callback(this, "applicationDelegateProc", 3);
1591 int appProc3 = applicationDelegateCallback3.getAddress(); 1615 int appProc3 = applicationDelegateCallback3.getAddress();
1592 if (appProc3 is 0) error (DWT.ERROR_NO_MORE_CALLBACKS); 1616 if (appProc3 is 0) error (DWT.ERROR_NO_MORE_CALLBACKS);
1593 1617
1594 String className = "SWTApplicationDelegate"; 1618 String className = "SWTApplicationDelegate";
1595 int cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0); 1619 objc.Class cls = OS.objc_allocateClassPair(OS.classinfo_NSObject, className, 0);
1596 OS.class_addMethod(cls, OS.sel_applicationWillFinishLaunching_1, appProc3, "@:@"); 1620 OS.class_addMethod(cls, OS.sel_applicationWillFinishLaunching_1, appProc3, "@:@");
1597 OS.class_addMethod(cls, OS.sel_terminate_1, appProc3, "@:@"); 1621 OS.class_addMethod(cls, OS.sel_terminate_1, appProc3, "@:@");
1598 OS.class_addMethod(cls, OS.sel_orderFrontStandardAboutPanel_1, appProc3, "@:@"); 1622 OS.class_addMethod(cls, OS.sel_orderFrontStandardAboutPanel_1, appProc3, "@:@");
1599 OS.class_addMethod(cls, OS.sel_hideOtherApplications_1, appProc3, "@:@"); 1623 OS.class_addMethod(cls, OS.sel_hideOtherApplications_1, appProc3, "@:@");
1600 OS.class_addMethod(cls, OS.sel_hide_1, appProc3, "@:@"); 1624 OS.class_addMethod(cls, OS.sel_hide_1, appProc3, "@:@");
1601 OS.class_addMethod(cls, OS.sel_unhideAllApplications_1, appProc3, "@:@"); 1625 OS.class_addMethod(cls, OS.sel_unhideAllApplications_1, appProc3, "@:@");
1602 OS.class_addMethod(cls, OS.sel_applicationShouldTerminate_1, appProc3, "@:@"); 1626 OS.class_addMethod(cls, OS.sel_applicationShouldTerminate_1, appProc3, "@:@");
1603 OS.class_addMethod(cls, OS.sel_applicationWillTerminate_1, appProc3, "@:@"); 1627 OS.class_addMethod(cls, OS.sel_applicationWillTerminate_1, appProc3, "@:@");
1604 OS.objc_registerClassPair(cls); 1628 OS.objc_registerClassPair(cls);
1605 1629
1606 applicationDelegate = (SWTApplicationDelegate)new SWTApplicationDelegate().alloc().init(); 1630 applicationDelegate = cast(SWTApplicationDelegate)(new SWTApplicationDelegate()).alloc().init();
1607 application.setDelegate(applicationDelegate); 1631 application.setDelegate(applicationDelegate);
1608 } 1632 }
1609 1633
1610 void initClasses () { 1634 void initClasses () {
1611 dialogCallback3 = new Callback(this, "dialogProc", 3); 1635 dialogCallback3 = new Callback(this, "dialogProc", 3);
1629 if (proc6 is 0) error (DWT.ERROR_NO_MORE_CALLBACKS); 1653 if (proc6 is 0) error (DWT.ERROR_NO_MORE_CALLBACKS);
1630 1654
1631 int drawRectProc = OS.drawRect_CALLBACK(proc3); 1655 int drawRectProc = OS.drawRect_CALLBACK(proc3);
1632 1656
1633 String className = "SWTWindowDelegate"; 1657 String className = "SWTWindowDelegate";
1634 int cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0); 1658 objc.Class cls = OS.objc_allocateClassPair(OS.classinfo_NSObject, className, 0);
1635 OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i"); 1659 OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, cast(byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i");
1636 OS.class_addMethod(cls, OS.sel_windowDidResize_1, proc3, "@:@"); 1660 OS.class_addMethod(cls, OS.sel_windowDidResize_1, proc3, "@:@");
1637 OS.class_addMethod(cls, OS.sel_windowShouldClose_1, proc3, "@:@"); 1661 OS.class_addMethod(cls, OS.sel_windowShouldClose_1, proc3, "@:@");
1638 OS.class_addMethod(cls, OS.sel_windowWillClose_1, proc3, "@:@"); 1662 OS.class_addMethod(cls, OS.sel_windowWillClose_1, proc3, "@:@");
1639 OS.class_addMethod(cls, OS.sel_windowWillClose_1, proc3, "@:@"); 1663 OS.class_addMethod(cls, OS.sel_windowWillClose_1, proc3, "@:@");
1640 OS.class_addMethod(cls, OS.sel_windowDidResignKey_1, proc3, "@:@"); 1664 OS.class_addMethod(cls, OS.sel_windowDidResignKey_1, proc3, "@:@");
1643 OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i"); 1667 OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i");
1644 OS.class_addMethod(cls, OS.sel_timerProc_1, proc3, "@:@"); 1668 OS.class_addMethod(cls, OS.sel_timerProc_1, proc3, "@:@");
1645 OS.objc_registerClassPair(cls); 1669 OS.objc_registerClassPair(cls);
1646 1670
1647 className = "SWTPanelDelegate"; 1671 className = "SWTPanelDelegate";
1648 cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0); 1672 cls = OS.objc_allocateClassPair(OS.classinfo_NSObject, className, 0);
1649 OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i"); 1673 OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, cast(byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i");
1650 OS.class_addMethod(cls, OS.sel_windowWillClose_1, dialogProc3, "@:@"); 1674 OS.class_addMethod(cls, OS.sel_windowWillClose_1, dialogProc3, "@:@");
1651 OS.class_addMethod(cls, OS.sel_changeColor_1, dialogProc3, "@:@"); 1675 OS.class_addMethod(cls, OS.sel_changeColor_1, dialogProc3, "@:@");
1652 OS.class_addMethod(cls, OS.sel_changeFont_1, dialogProc3, "@:@"); 1676 OS.class_addMethod(cls, OS.sel_changeFont_1, dialogProc3, "@:@");
1653 OS.class_addMethod(cls, OS.sel_tag, proc2, "@:"); 1677 OS.class_addMethod(cls, OS.sel_tag, proc2, "@:");
1654 OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i"); 1678 OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i");
1655 OS.objc_registerClassPair(cls); 1679 OS.objc_registerClassPair(cls);
1656 1680
1657 className = "SWTMenu"; 1681 className = "SWTMenu";
1658 cls = OS.objc_allocateClassPair(OS.class_NSMenu, className, 0); 1682 cls = OS.objc_allocateClassPair(OS.classinfo_NSMenu, className, 0);
1659 OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i"); 1683 OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, cast(byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i");
1660 OS.class_addMethod(cls, OS.sel_tag, proc2, "@:"); 1684 OS.class_addMethod(cls, OS.sel_tag, proc2, "@:");
1661 OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i"); 1685 OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i");
1662 // OS.class_addMethod(cls, OS.sel_menuWillOpen_1, proc3, "@:@"); 1686 // OS.class_addMethod(cls, OS.sel_menuWillOpen_1, proc3, "@:@");
1663 OS.class_addMethod(cls, OS.sel_menuWillClose_1, proc3, "@:@"); 1687 OS.class_addMethod(cls, OS.sel_menuWillClose_1, proc3, "@:@");
1664 // OS.class_addMethod(cls, OS.sel_numberOfItemsInMenu_1, proc3, "@:@"); 1688 // OS.class_addMethod(cls, OS.sel_numberOfItemsInMenu_1, proc3, "@:@");
1665 OS.class_addMethod(cls, OS.sel_menu_1willHighlightItem_1, proc4, "@:@@"); 1689 OS.class_addMethod(cls, OS.sel_menu_1willHighlightItem_1, proc4, "@:@@");
1666 OS.class_addMethod(cls, OS.sel_menuNeedsUpdate_1, proc3, "@:@"); 1690 OS.class_addMethod(cls, OS.sel_menuNeedsUpdate_1, proc3, "@:@");
1667 OS.objc_registerClassPair(cls); 1691 OS.objc_registerClassPair(cls);
1668 1692
1669 className = "SWTView"; 1693 className = "SWTView";
1670 cls = OS.objc_allocateClassPair(OS.class_NSView, className, 0); 1694 cls = OS.objc_allocateClassPair(OS.classinfo_NSView, className, 0);
1671 OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i"); 1695 OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, cast(byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i");
1672 OS.class_addMethod(cls, OS.sel_tag, proc2, "@:"); 1696 OS.class_addMethod(cls, OS.sel_tag, proc2, "@:");
1673 OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i"); 1697 OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i");
1674 OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:"); 1698 OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
1675 OS.class_addMethod(cls, OS.sel_drawRect_1, drawRectProc, "@:i"); 1699 OS.class_addMethod(cls, OS.sel_drawRect_1, drawRectProc, "@:i");
1676 OS.class_addMethod(cls, OS.sel_mouseDown_1, proc3, "@:@"); 1700 OS.class_addMethod(cls, OS.sel_mouseDown_1, proc3, "@:@");
1682 OS.class_addMethod(cls, OS.sel_resignFirstResponder, proc2, "@:"); 1706 OS.class_addMethod(cls, OS.sel_resignFirstResponder, proc2, "@:");
1683 OS.class_addMethod(cls, OS.sel_becomeFirstResponder, proc2, "@:"); 1707 OS.class_addMethod(cls, OS.sel_becomeFirstResponder, proc2, "@:");
1684 OS.objc_registerClassPair(cls); 1708 OS.objc_registerClassPair(cls);
1685 1709
1686 className = "SWTScrollView"; 1710 className = "SWTScrollView";
1687 cls = OS.objc_allocateClassPair(OS.class_NSScrollView, className, 0); 1711 cls = OS.objc_allocateClassPair(OS.classinfo_NSScrollView, className, 0);
1688 OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i"); 1712 OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, cast(byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i");
1689 OS.class_addMethod(cls, OS.sel_tag, proc2, "@:"); 1713 OS.class_addMethod(cls, OS.sel_tag, proc2, "@:");
1690 OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i"); 1714 OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i");
1691 OS.class_addMethod(cls, OS.sel_sendVerticalSelection, proc2, "@:"); 1715 OS.class_addMethod(cls, OS.sel_sendVerticalSelection, proc2, "@:");
1692 OS.class_addMethod(cls, OS.sel_sendHorizontalSelection, proc2, "@:"); 1716 OS.class_addMethod(cls, OS.sel_sendHorizontalSelection, proc2, "@:");
1693 // OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@"); 1717 // OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
1694 OS.objc_registerClassPair(cls); 1718 OS.objc_registerClassPair(cls);
1695 1719
1696 className = "SWTButton"; 1720 className = "SWTButton";
1697 cls = OS.objc_allocateClassPair(OS.class_NSButton, className, 0); 1721 cls = OS.objc_allocateClassPair(OS.classinfo_NSButton, className, 0);
1698 // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:"); 1722 // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
1699 // OS.class_addMethod(cls, OS.sel_mouseDown_1, proc3, "@:@"); 1723 // OS.class_addMethod(cls, OS.sel_mouseDown_1, proc3, "@:@");
1700 OS.class_addMethod(cls, OS.sel_drawRect_1, drawRectProc, "@:i"); 1724 OS.class_addMethod(cls, OS.sel_drawRect_1, drawRectProc, "@:i");
1701 OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:"); 1725 OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
1702 OS.class_addMethod(cls, OS.sel_sendArrowSelection, proc2, "@:"); 1726 OS.class_addMethod(cls, OS.sel_sendArrowSelection, proc2, "@:");
1703 OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@"); 1727 OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
1704 OS.objc_registerClassPair(cls); 1728 OS.objc_registerClassPair(cls);
1705 1729
1706 className = "SWTTableView"; 1730 className = "SWTTableView";
1707 cls = OS.objc_allocateClassPair(OS.class_NSTableView, className, 0); 1731 cls = OS.objc_allocateClassPair(OS.classinfo_NSTableView, className, 0);
1708 OS.class_addMethod(cls, OS.sel_sendDoubleSelection, proc2, "@:"); 1732 OS.class_addMethod(cls, OS.sel_sendDoubleSelection, proc2, "@:");
1709 // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:"); 1733 // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
1710 OS.class_addMethod(cls, OS.sel_numberOfRowsInTableView_1, proc3, "@:@"); 1734 OS.class_addMethod(cls, OS.sel_numberOfRowsInTableView_1, proc3, "@:@");
1711 OS.class_addMethod(cls, OS.sel_tableView_1objectValueForTableColumn_1row_1, proc5, "@:@:@:@"); 1735 OS.class_addMethod(cls, OS.sel_tableView_1objectValueForTableColumn_1row_1, proc5, "@:@:@:@");
1712 OS.class_addMethod(cls, OS.sel_tableView_1shouldEditTableColumn_1row_1, proc5, "@:@:@:@"); 1736 OS.class_addMethod(cls, OS.sel_tableView_1shouldEditTableColumn_1row_1, proc5, "@:@:@:@");
1715 OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@"); 1739 OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
1716 OS.class_addMethod(cls, OS.sel_tableView_1setObjectValue_1forTableColumn_1row_1, proc6, "@:@@@i"); 1740 OS.class_addMethod(cls, OS.sel_tableView_1setObjectValue_1forTableColumn_1row_1, proc6, "@:@@@i");
1717 OS.objc_registerClassPair(cls); 1741 OS.objc_registerClassPair(cls);
1718 1742
1719 className = "SWTOutlineView"; 1743 className = "SWTOutlineView";
1720 cls = OS.objc_allocateClassPair(OS.class_NSOutlineView, className, 0); 1744 cls = OS.objc_allocateClassPair(OS.classinfo_NSOutlineView, className, 0);
1721 OS.class_addMethod(cls, OS.sel_sendDoubleSelection, proc2, "@:"); 1745 OS.class_addMethod(cls, OS.sel_sendDoubleSelection, proc2, "@:");
1722 OS.class_addMethod(cls, OS.sel_outlineViewSelectionDidChange_1, proc3, "@:@"); 1746 OS.class_addMethod(cls, OS.sel_outlineViewSelectionDidChange_1, proc3, "@:@");
1723 OS.class_addMethod(cls, OS.sel_outlineView_1shouldCollapseItem_1, proc4, "@:@@"); 1747 OS.class_addMethod(cls, OS.sel_outlineView_1shouldCollapseItem_1, proc4, "@:@@");
1724 OS.class_addMethod(cls, OS.sel_outlineView_1shouldExpandItem_1, proc4, "@:@@"); 1748 OS.class_addMethod(cls, OS.sel_outlineView_1shouldExpandItem_1, proc4, "@:@@");
1725 OS.class_addMethod(cls, OS.sel_outlineView_1child_1ofItem_1, proc5, "@:@i@"); 1749 OS.class_addMethod(cls, OS.sel_outlineView_1child_1ofItem_1, proc5, "@:@i@");
1730 OS.class_addMethod(cls, OS.sel_outlineView_1setObjectValue_1forTableColumn_1byItem_1, proc6, "@:@@@@"); 1754 OS.class_addMethod(cls, OS.sel_outlineView_1setObjectValue_1forTableColumn_1byItem_1, proc6, "@:@@@@");
1731 OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@"); 1755 OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
1732 OS.objc_registerClassPair(cls); 1756 OS.objc_registerClassPair(cls);
1733 1757
1734 className = "SWTTreeItem"; 1758 className = "SWTTreeItem";
1735 cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0); 1759 cls = OS.objc_allocateClassPair(OS.classinfo_NSObject, className, 0);
1736 // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:"); 1760 // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
1737 OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i"); 1761 OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, cast(byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i");
1738 OS.class_addMethod(cls, OS.sel_tag, proc2, "@:"); 1762 OS.class_addMethod(cls, OS.sel_tag, proc2, "@:");
1739 OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i"); 1763 OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i");
1740 OS.objc_registerClassPair(cls); 1764 OS.objc_registerClassPair(cls);
1741 1765
1742 className = "SWTTabView"; 1766 className = "SWTTabView";
1743 cls = OS.objc_allocateClassPair(OS.class_NSTabView, className, 0); 1767 cls = OS.objc_allocateClassPair(OS.classinfo_NSTabView, className, 0);
1744 // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:"); 1768 // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
1745 OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i"); 1769 OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, cast(byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i");
1746 OS.class_addMethod(cls, OS.sel_tabView_1willSelectTabViewItem_1, proc4, "@:@@"); 1770 OS.class_addMethod(cls, OS.sel_tabView_1willSelectTabViewItem_1, proc4, "@:@@");
1747 OS.class_addMethod(cls, OS.sel_tag, proc2, "@:"); 1771 OS.class_addMethod(cls, OS.sel_tag, proc2, "@:");
1748 OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i"); 1772 OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i");
1749 OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@"); 1773 OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
1750 OS.objc_registerClassPair(cls); 1774 OS.objc_registerClassPair(cls);
1751 1775
1752 className = "SWTBox"; 1776 className = "SWTBox";
1753 cls = OS.objc_allocateClassPair(OS.class_NSBox, className, 0); 1777 cls = OS.objc_allocateClassPair(OS.classinfo_NSBox, className, 0);
1754 // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:"); 1778 // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
1755 OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i"); 1779 OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, cast(byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i");
1756 OS.class_addMethod(cls, OS.sel_tag, proc2, "@:"); 1780 OS.class_addMethod(cls, OS.sel_tag, proc2, "@:");
1757 OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i"); 1781 OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i");
1758 OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@"); 1782 OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
1759 OS.objc_registerClassPair(cls); 1783 OS.objc_registerClassPair(cls);
1760 1784
1761 className = "SWTProgressIndicator"; 1785 className = "SWTProgressIndicator";
1762 cls = OS.objc_allocateClassPair(OS.class_NSProgressIndicator, className, 0); 1786 cls = OS.objc_allocateClassPair(OS.classinfo_NSProgressIndicator, className, 0);
1763 // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:"); 1787 // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
1764 OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i"); 1788 OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, cast(byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i");
1765 OS.class_addMethod(cls, OS.sel_tag, proc2, "@:"); 1789 OS.class_addMethod(cls, OS.sel_tag, proc2, "@:");
1766 OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i"); 1790 OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i");
1767 OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@"); 1791 OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
1768 OS.objc_registerClassPair(cls); 1792 OS.objc_registerClassPair(cls);
1769 1793
1770 className = "SWTSlider"; 1794 className = "SWTSlider";
1771 cls = OS.objc_allocateClassPair(OS.class_NSSlider, className, 0); 1795 cls = OS.objc_allocateClassPair(OS.classinfo_NSSlider, className, 0);
1772 // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:"); 1796 // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
1773 OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@"); 1797 OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
1774 OS.objc_registerClassPair(cls); 1798 OS.objc_registerClassPair(cls);
1775 1799
1776 className = "SWTPopUpButton"; 1800 className = "SWTPopUpButton";
1777 cls = OS.objc_allocateClassPair(OS.class_NSPopUpButton, className, 0); 1801 cls = OS.objc_allocateClassPair(OS.classinfo_NSPopUpButton, className, 0);
1778 // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:"); 1802 // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
1779 OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:"); 1803 OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
1780 OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@"); 1804 OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
1781 OS.objc_registerClassPair(cls); 1805 OS.objc_registerClassPair(cls);
1782 1806
1783 className = "SWTComboBox"; 1807 className = "SWTComboBox";
1784 cls = OS.objc_allocateClassPair(OS.class_NSComboBox, className, 0); 1808 cls = OS.objc_allocateClassPair(OS.classinfo_NSComboBox, className, 0);
1785 // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:"); 1809 // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
1786 OS.class_addMethod(cls, OS.sel_comboBoxSelectionDidChange_1, proc3, "@:@"); 1810 OS.class_addMethod(cls, OS.sel_comboBoxSelectionDidChange_1, proc3, "@:@");
1787 OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:"); 1811 OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
1788 OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@"); 1812 OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
1789 OS.objc_registerClassPair(cls); 1813 OS.objc_registerClassPair(cls);
1790 1814
1791 className = "SWTDatePicker"; 1815 className = "SWTDatePicker";
1792 cls = OS.objc_allocateClassPair(OS.class_NSDatePicker, className, 0); 1816 cls = OS.objc_allocateClassPair(OS.classinfo_NSDatePicker, className, 0);
1793 // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:"); 1817 // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
1794 OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:"); 1818 OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
1795 OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@"); 1819 OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
1796 OS.objc_registerClassPair(cls); 1820 OS.objc_registerClassPair(cls);
1797 1821
1798 className = "SWTImageView"; 1822 className = "SWTImageView";
1799 cls = OS.objc_allocateClassPair(OS.class_NSImageView, className, 0); 1823 cls = OS.objc_allocateClassPair(OS.classinfo_NSImageView, className, 0);
1800 // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:"); 1824 // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
1801 OS.class_addMethod(cls, OS.sel_drawRect_1, OS.drawRect_CALLBACK(proc3), "@:i"); 1825 OS.class_addMethod(cls, OS.sel_drawRect_1, OS.drawRect_CALLBACK(proc3), "@:i");
1802 OS.class_addMethod(cls, OS.sel_mouseDown_1, proc3, "@:@"); 1826 OS.class_addMethod(cls, OS.sel_mouseDown_1, proc3, "@:@");
1803 OS.class_addMethod(cls, OS.sel_mouseUp_1, proc3, "@:@"); 1827 OS.class_addMethod(cls, OS.sel_mouseUp_1, proc3, "@:@");
1804 OS.class_addMethod(cls, OS.sel_rightMouseDown_1, proc3, "@:@"); 1828 OS.class_addMethod(cls, OS.sel_rightMouseDown_1, proc3, "@:@");
1805 OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@"); 1829 OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
1806 OS.objc_registerClassPair(cls); 1830 OS.objc_registerClassPair(cls);
1807 1831
1808 className = "SWTStepper"; 1832 className = "SWTStepper";
1809 cls = OS.objc_allocateClassPair(OS.class_NSStepper, className, 0); 1833 cls = OS.objc_allocateClassPair(OS.classinfo_NSStepper, className, 0);
1810 // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:"); 1834 // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
1811 OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:"); 1835 OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
1812 OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@"); 1836 OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
1813 OS.objc_registerClassPair(cls); 1837 OS.objc_registerClassPair(cls);
1814 1838
1815 className = "SWTScroller"; 1839 className = "SWTScroller";
1816 cls = OS.objc_allocateClassPair(OS.class_NSScroller, className, 0); 1840 cls = OS.objc_allocateClassPair(OS.classinfo_NSScroller, className, 0);
1817 // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:"); 1841 // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
1818 OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:"); 1842 OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
1819 OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@"); 1843 OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
1820 OS.objc_registerClassPair(cls); 1844 OS.objc_registerClassPair(cls);
1821 1845
1822 className = "SWTMenuItem"; 1846 className = "SWTMenuItem";
1823 cls = OS.objc_allocateClassPair(OS.class_NSMenuItem, className, 0); 1847 cls = OS.objc_allocateClassPair(OS.classinfo_NSMenuItem, className, 0);
1824 // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:"); 1848 // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
1825 OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:"); 1849 OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
1826 OS.objc_registerClassPair(cls); 1850 OS.objc_registerClassPair(cls);
1827 1851
1828 className = "SWTTextView"; 1852 className = "SWTTextView";
1829 cls = OS.objc_allocateClassPair(OS.class_NSTextView, className, 0); 1853 cls = OS.objc_allocateClassPair(OS.classinfo_NSTextView, className, 0);
1830 // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:"); 1854 // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
1831 // OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:"); 1855 // OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
1832 OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i"); 1856 OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, cast(byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i");
1833 OS.class_addMethod(cls, OS.sel_tag, proc2, "@:"); 1857 OS.class_addMethod(cls, OS.sel_tag, proc2, "@:");
1834 OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i"); 1858 OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i");
1835 OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@"); 1859 OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
1836 OS.class_addMethod(cls, OS.sel_textView_1clickedOnLink_1atIndex_1, proc5, "@:@@i"); 1860 OS.class_addMethod(cls, OS.sel_textView_1clickedOnLink_1atIndex_1, proc5, "@:@@i");
1837 OS.objc_registerClassPair(cls); 1861 OS.objc_registerClassPair(cls);
1838 1862
1839 className = "SWTTextField"; 1863 className = "SWTTextField";
1840 cls = OS.objc_allocateClassPair(OS.class_NSTextField, className, 0); 1864 cls = OS.objc_allocateClassPair(OS.classinfo_NSTextField, className, 0);
1841 OS.class_addMethod(cls, OS.sel_drawRect_1, drawRectProc, "@:i"); 1865 OS.class_addMethod(cls, OS.sel_drawRect_1, drawRectProc, "@:i");
1842 OS.objc_registerClassPair(cls); 1866 OS.objc_registerClassPair(cls);
1843 1867
1844 className = "SWTWindow"; 1868 className = "SWTWindow";
1845 cls = OS.objc_allocateClassPair(OS.class_NSWindow, className, 0); 1869 cls = OS.objc_allocateClassPair(OS.classinfo_NSWindow, className, 0);
1846 OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i"); 1870 OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, cast(byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i");
1847 OS.class_addMethod(cls, OS.sel_tag, proc2, "@:"); 1871 OS.class_addMethod(cls, OS.sel_tag, proc2, "@:");
1848 OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i"); 1872 OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i");
1849 OS.class_addMethod(cls, OS.sel_sendEvent_1, proc3, "@:@"); 1873 OS.class_addMethod(cls, OS.sel_sendEvent_1, proc3, "@:@");
1850 OS.class_addMethod(cls, OS.sel_flagsChanged_1, proc3, "@:@"); 1874 OS.class_addMethod(cls, OS.sel_flagsChanged_1, proc3, "@:@");
1851 OS.class_addMethod(cls, OS.sel_helpRequested_1, proc3, "@:@"); 1875 OS.class_addMethod(cls, OS.sel_helpRequested_1, proc3, "@:@");
1870 * </ul> 1894 * </ul>
1871 * @exception DWTError <ul> 1895 * @exception DWTError <ul>
1872 * <li>ERROR_NO_HANDLES if a handle could not be obtained for gc creation</li> 1896 * <li>ERROR_NO_HANDLES if a handle could not be obtained for gc creation</li>
1873 * </ul> 1897 * </ul>
1874 */ 1898 */
1875 public int internal_new_GC (GCData data) { 1899 public objc.id internal_new_GC (GCData data) {
1876 if (isDisposed()) DWT.error(DWT.ERROR_DEVICE_DISPOSED); 1900 if (isDisposed()) DWT.error(DWT.ERROR_DEVICE_DISPOSED);
1877 NSGraphicsContext context = application.context(); 1901 NSGraphicsContext context = application.context();
1878 // NSAffineTransform transform = NSAffineTransform.transform(); 1902 // NSAffineTransform transform = NSAffineTransform.transform();
1879 // NSSize size = handle.size(); 1903 // NSSize size = handle.size();
1880 // transform.translateXBy(0, size.height); 1904 // transform.translateXBy(0, size.height);
1888 data.device = this; 1912 data.device = this;
1889 data.background = getSystemColor(DWT.COLOR_WHITE).handle; 1913 data.background = getSystemColor(DWT.COLOR_WHITE).handle;
1890 data.foreground = getSystemColor(DWT.COLOR_BLACK).handle; 1914 data.foreground = getSystemColor(DWT.COLOR_BLACK).handle;
1891 data.font = getSystemFont(); 1915 data.font = getSystemFont();
1892 } 1916 }
1893 return context.id; 1917 return context.id_;
1894 } 1918 }
1895 1919
1896 /** 1920 /**
1897 * Invokes platform specific functionality to dispose a GC handle. 1921 * Invokes platform specific functionality to dispose a GC handle.
1898 * <p> 1922 * <p>
1910 if (isDisposed()) DWT.error(DWT.ERROR_DEVICE_DISPOSED); 1934 if (isDisposed()) DWT.error(DWT.ERROR_DEVICE_DISPOSED);
1911 1935
1912 } 1936 }
1913 1937
1914 static bool isValidClass (Class clazz) { 1938 static bool isValidClass (Class clazz) {
1915 String name = clazz.getName (); 1939 String name = clazz.name;
1916 int index = name.lastIndexOf ('.'); 1940 int index = name.lastIndexOf ('.');
1917 return name.substring (0, index + 1).equals (PACKAGE_PREFIX); 1941 return name.substring (0, index + 1).equals (PACKAGE_PREFIX);
1918 } 1942 }
1919 1943
1920 bool isValidThread () { 1944 bool isValidThread () {
1921 return thread is Thread.currentThread (); 1945 return thread is Thread.getThis ();
1922 } 1946 }
1923 1947
1924 /** 1948 /**
1925 * Generate a low level system event. 1949 * Generate a low level system event.
1926 * 1950 *
1973 * 1997 *
1974 * @since 3.0 1998 * @since 3.0
1975 * 1999 *
1976 */ 2000 */
1977 public bool post(Event event) { 2001 public bool post(Event event) {
1978 synchronized (Device.class) { 2002 synchronized (Device.classinfo) {
1979 if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED); 2003 if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED);
1980 if (event is null) error (DWT.ERROR_NULL_ARGUMENT); 2004 if (event is null) error (DWT.ERROR_NULL_ARGUMENT);
1981 // int type = event.type; 2005 // int type = event.type;
1982 // switch (type) { 2006 // switch (type) {
1983 // case DWT.KeyDown: 2007 // case DWT.KeyDown:
2194 checkDevice (); 2218 checkDevice ();
2195 if (from !is null && from.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT); 2219 if (from !is null && from.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT);
2196 if (to !is null && to.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT); 2220 if (to !is null && to.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT);
2197 Point point = new Point (x, y); 2221 Point point = new Point (x, y);
2198 if (from is to) return point; 2222 if (from is to) return point;
2199 NSPoint pt = new NSPoint(); 2223 NSPoint pt = NSPoint();
2200 pt.x = x; 2224 pt.x = x;
2201 pt.y = y; 2225 pt.y = y;
2202 NSWindow fromWindow = from !is null ? from.view.window() : null; 2226 NSWindow fromWindow = from !is null ? from.view.window() : null;
2203 NSWindow toWindow = to !is null ? to.view.window() : null; 2227 NSWindow toWindow = to !is null ? to.view.window() : null;
2204 if (toWindow !is null && fromWindow !is null && toWindow.id is fromWindow.id) { 2228 if (toWindow !is null && fromWindow !is null && toWindow.id_ is fromWindow.id_) {
2205 pt = from.view.convertPoint_toView_(pt, to.view); 2229 pt = from.view.convertPoint_toView_(pt, to.view);
2206 } else { 2230 } else {
2207 if (from !is null) { 2231 if (from !is null) {
2208 pt = from.view.convertPoint_toView_(pt, null); 2232 pt = from.view.convertPoint_toView_(pt, null);
2209 pt = fromWindow.convertBaseToScreen(pt); 2233 pt = fromWindow.convertBaseToScreen(pt);
2213 pt.y = toWindow.screen().frame().height - pt.y; 2237 pt.y = toWindow.screen().frame().height - pt.y;
2214 pt = toWindow.convertScreenToBase(pt); 2238 pt = toWindow.convertScreenToBase(pt);
2215 pt = to.view.convertPoint_fromView_(pt, null); 2239 pt = to.view.convertPoint_fromView_(pt, null);
2216 } 2240 }
2217 } 2241 }
2218 point.x = (int)pt.x; 2242 point.x = cast(int)pt.x;
2219 point.y = (int)pt.y; 2243 point.y = cast(int)pt.y;
2220 return point; 2244 return point;
2221 } 2245 }
2222 2246
2223 /** 2247 /**
2224 * Maps a point from one coordinate system to another. 2248 * Maps a point from one coordinate system to another.
2304 checkDevice (); 2328 checkDevice ();
2305 if (from !is null && from.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT); 2329 if (from !is null && from.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT);
2306 if (to !is null && to.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT); 2330 if (to !is null && to.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT);
2307 Rectangle rectangle = new Rectangle (x, y, width, height); 2331 Rectangle rectangle = new Rectangle (x, y, width, height);
2308 if (from is to) return rectangle; 2332 if (from is to) return rectangle;
2309 NSPoint pt = new NSPoint(); 2333 NSPoint pt = NSPoint();
2310 pt.x = x; 2334 pt.x = x;
2311 pt.y = y; 2335 pt.y = y;
2312 NSWindow fromWindow = from !is null ? from.view.window() : null; 2336 NSWindow fromWindow = from !is null ? from.view.window() : null;
2313 NSWindow toWindow = to !is null ? to.view.window() : null; 2337 NSWindow toWindow = to !is null ? to.view.window() : null;
2314 if (toWindow !is null && fromWindow !is null && toWindow.id is fromWindow.id) { 2338 if (toWindow !is null && fromWindow !is null && toWindow.id_ is fromWindow.id_) {
2315 pt = from.view.convertPoint_toView_(pt, to.view); 2339 pt = from.view.convertPoint_toView_(pt, to.view);
2316 } else { 2340 } else {
2317 if (from !is null) { 2341 if (from !is null) {
2318 pt = from.view.convertPoint_toView_(pt, null); 2342 pt = from.view.convertPoint_toView_(pt, null);
2319 pt = fromWindow.convertBaseToScreen(pt); 2343 pt = fromWindow.convertBaseToScreen(pt);
2323 pt.y = toWindow.screen().frame().height - pt.y; 2347 pt.y = toWindow.screen().frame().height - pt.y;
2324 pt = toWindow.convertScreenToBase(pt); 2348 pt = toWindow.convertScreenToBase(pt);
2325 pt = to.view.convertPoint_fromView_(pt, null); 2349 pt = to.view.convertPoint_fromView_(pt, null);
2326 } 2350 }
2327 } 2351 }
2328 rectangle.x = (int)pt.x; 2352 rectangle.x = cast(int)pt.x;
2329 rectangle.y = (int)pt.y; 2353 rectangle.y = cast(int)pt.y;
2330 return rectangle; 2354 return rectangle;
2331 } 2355 }
2332 2356
2333 /** 2357 /**
2334 * Reads an event from the operating system's event queue, 2358 * Reads an event from the operating system's event queue,
2354 * @see #sleep 2378 * @see #sleep
2355 * @see #wake 2379 * @see #wake
2356 */ 2380 */
2357 public bool readAndDispatch () { 2381 public bool readAndDispatch () {
2358 checkDevice (); 2382 checkDevice ();
2359 NSAutoreleasePool pool = (NSAutoreleasePool)new NSAutoreleasePool().alloc().init(); 2383 NSAutoreleasePool pool = cast(NSAutoreleasePool)(new NSAutoreleasePool()).alloc().init();
2360 try { 2384 try {
2361 bool events = false; 2385 bool events = false;
2362 events |= runTimers (); 2386 events |= runTimers ();
2363 NSEvent event = application.nextEventMatchingMask(0, null, OS.NSDefaultRunLoopMode, true); 2387 NSEvent event = application.nextEventMatchingMask(0, null, OS.NSDefaultRunLoopMode, true);
2364 if (event !is null) { 2388 if (event !is null) {
2374 pool.release(); 2398 pool.release();
2375 } 2399 }
2376 } 2400 }
2377 2401
2378 static void register (Display display) { 2402 static void register (Display display) {
2379 synchronized (Device.class) { 2403 synchronized (Device.classinfo) {
2380 for (int i=0; i<Displays.length; i++) { 2404 for (int i=0; i<Displays.length; i++) {
2381 if (Displays [i] is null) { 2405 if (Displays [i] is null) {
2382 Displays [i] = display; 2406 Displays [i] = display;
2383 return; 2407 return;
2384 } 2408 }
2630 public static void setAppName (String name) { 2654 public static void setAppName (String name) {
2631 APP_NAME = name; 2655 APP_NAME = name;
2632 } 2656 }
2633 2657
2634 //TODO - use custom timer instead of timerExec 2658 //TODO - use custom timer instead of timerExec
2635 Runnable caretTimer = new Runnable () { 2659 Runnable caretTimer = new class Runnable {
2636 public void run () { 2660 public void run () {
2637 if (currentCaret !is null) { 2661 if (currentCaret !is null) {
2638 if (currentCaret is null || currentCaret.isDisposed()) return; 2662 if (currentCaret is null || currentCaret.isDisposed()) return;
2639 if (currentCaret.blinkCaret ()) { 2663 if (currentCaret.blinkCaret ()) {
2640 int blinkRate = currentCaret.blinkRate; 2664 int blinkRate = currentCaret.blinkRate;
2671 * 2695 *
2672 * @since 2.1 2696 * @since 2.1
2673 */ 2697 */
2674 public void setCursorLocation (int x, int y) { 2698 public void setCursorLocation (int x, int y) {
2675 checkDevice (); 2699 checkDevice ();
2676 CGPoint pt = new CGPoint (); 2700 CGPoint pt = CGPoint ();
2677 pt.x = x; pt.y = y; 2701 pt.x = x; pt.y = y;
2678 OS.CGWarpMouseCursorPosition (pt); 2702 OS.CGWarpMouseCursorPosition (pt);
2679 } 2703 }
2680 2704
2681 /** 2705 /**
2724 * @see #getData(String) 2748 * @see #getData(String)
2725 * @see #disposeExec(Runnable) 2749 * @see #disposeExec(Runnable)
2726 */ 2750 */
2727 public void setData (String key, Object value) { 2751 public void setData (String key, Object value) {
2728 checkDevice (); 2752 checkDevice ();
2729 if (key is null) error (DWT.ERROR_NULL_ARGUMENT); 2753 //if (key is null) error (DWT.ERROR_NULL_ARGUMENT);
2730 2754
2731 /* Remove the key/value pair */ 2755 /* Remove the key/value pair */
2732 if (value is null) { 2756 if (value is null) {
2733 if (keys is null) return; 2757 if (keys is null) return;
2734 int index = 0; 2758 int index = 0;
2750 return; 2774 return;
2751 } 2775 }
2752 2776
2753 /* Add the key/value pair */ 2777 /* Add the key/value pair */
2754 if (keys is null) { 2778 if (keys is null) {
2755 keys = new String [] {key}; 2779 keys = new String [] [key];
2756 values = new Object [] {value}; 2780 values = new Object [] [value];
2757 return; 2781 return;
2758 } 2782 }
2759 for (int i=0; i<keys.length; i++) { 2783 for (int i=0; i<keys.length; i++) {
2760 if (keys [i].equals (key)) { 2784 if (keys [i].equals (key)) {
2761 values [i] = value; 2785 values [i] = value;
2782 */ 2806 */
2783 if (menu is menuBar) return; 2807 if (menu is menuBar) return;
2784 menuBar = menu; 2808 menuBar = menu;
2785 //remove all existing menu items except the application menu 2809 //remove all existing menu items except the application menu
2786 NSMenu menubar = application.mainMenu(); 2810 NSMenu menubar = application.mainMenu();
2787 int count = menubar.numberOfItems(); 2811 NSInteger count = menubar.numberOfItems();
2788 while (count > 1) { 2812 while (count > 1) {
2789 menubar.removeItemAtIndex(count - 1); 2813 menubar.removeItemAtIndex(count - 1);
2790 count--; 2814 count--;
2791 } 2815 }
2792 //set parent of each item to NULL and add them to menubar 2816 //set parent of each item to NULL and add them to menubar
2845 public void setSynchronizer (Synchronizer synchronizer) { 2869 public void setSynchronizer (Synchronizer synchronizer) {
2846 checkDevice (); 2870 checkDevice ();
2847 if (synchronizer is null) error (DWT.ERROR_NULL_ARGUMENT); 2871 if (synchronizer is null) error (DWT.ERROR_NULL_ARGUMENT);
2848 if (synchronizer is this.synchronizer) return; 2872 if (synchronizer is this.synchronizer) return;
2849 Synchronizer oldSynchronizer; 2873 Synchronizer oldSynchronizer;
2850 synchronized (Device.class) { 2874 synchronized (Device.classinfo) {
2851 oldSynchronizer = this.synchronizer; 2875 oldSynchronizer = this.synchronizer;
2852 this.synchronizer = synchronizer; 2876 this.synchronizer = synchronizer;
2853 } 2877 }
2854 if (oldSynchronizer !is null) { 2878 if (oldSynchronizer !is null) {
2855 oldSynchronizer.runAsyncMessages(true); 2879 oldSynchronizer.runAsyncMessages(true);
2871 * @see #wake 2895 * @see #wake
2872 */ 2896 */
2873 public bool sleep () { 2897 public bool sleep () {
2874 checkDevice (); 2898 checkDevice ();
2875 if (getMessageCount () !is 0) return true; 2899 if (getMessageCount () !is 0) return true;
2876 NSAutoreleasePool pool = (NSAutoreleasePool)new NSAutoreleasePool().alloc().init(); 2900 NSAutoreleasePool pool = cast(NSAutoreleasePool)(new NSAutoreleasePool()).alloc().init();
2877 try { 2901 try {
2878 allowTimers = runAsyncMessages = false; 2902 allowTimers = runAsyncMessages = false;
2879 NSRunLoop.currentRunLoop().runMode(OS.NSDefaultRunLoopMode, NSDate.distantFuture()); 2903 NSRunLoop.currentRunLoop().runMode(OS.NSDefaultRunLoopMode, NSDate.distantFuture());
2880 allowTimers = runAsyncMessages = true; 2904 allowTimers = runAsyncMessages = true;
2881 return true; 2905 return true;
2910 * 2934 *
2911 * @see #asyncExec 2935 * @see #asyncExec
2912 */ 2936 */
2913 public void syncExec (Runnable runnable) { 2937 public void syncExec (Runnable runnable) {
2914 Synchronizer synchronizer; 2938 Synchronizer synchronizer;
2915 synchronized (Device.class) { 2939 synchronized (Device.classinfo) {
2916 if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED); 2940 if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED);
2917 synchronizer = this.synchronizer; 2941 synchronizer = this.synchronizer;
2918 } 2942 }
2919 synchronizer.syncExec (runnable); 2943 synchronizer.syncExec (runnable);
2920 } 2944 }
2979 NSTimer [] newTimerIds = new NSTimer [nsTimers.length + 4]; 3003 NSTimer [] newTimerIds = new NSTimer [nsTimers.length + 4];
2980 System.arraycopy (nsTimers, 0, newTimerIds, 0, nsTimers.length); 3004 System.arraycopy (nsTimers, 0, newTimerIds, 0, nsTimers.length);
2981 nsTimers = newTimerIds; 3005 nsTimers = newTimerIds;
2982 } 3006 }
2983 NSNumber userInfo = NSNumber.numberWithInt(index); 3007 NSNumber userInfo = NSNumber.numberWithInt(index);
2984 NSTimer timer = NSTimer.static_scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(milliseconds / 1000.0, timerDelegate, OS.sel_timerProc_1, userInfo.id, false); 3008 NSTimer timer = NSTimer.static_scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(milliseconds / 1000.0, timerDelegate, OS.sel_timerProc_1, userInfo.id_, false);
2985 timer.retain(); 3009 timer.retain();
2986 if (timer !is null) { 3010 if (timer !is null) {
2987 nsTimers [index] = timer; 3011 nsTimers [index] = timer;
2988 timerList [index] = runnable; 3012 timerList [index] = runnable;
2989 } 3013 }
3040 * </ul> 3064 * </ul>
3041 * 3065 *
3042 * @see #sleep 3066 * @see #sleep
3043 */ 3067 */
3044 public void wake () { 3068 public void wake () {
3045 synchronized (Device.class) { 3069 synchronized (Device.classinfo) {
3046 if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED); 3070 if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED);
3047 if (thread is Thread.currentThread ()) return; 3071 if (thread is Thread.getThis ()) return;
3048 wakeThread (); 3072 wakeThread ();
3049 } 3073 }
3050 } 3074 }
3051 3075
3052 void wakeThread () { 3076 void wakeThread () {
3053 NSObject object = new NSObject().alloc().init(); 3077 NSObject object = (new NSObject()).alloc().init();
3054 object.performSelectorOnMainThread_withObject_waitUntilDone_(OS.sel_release, null, false); 3078 object.performSelectorOnMainThread_withObject_waitUntilDone_(OS.sel_release, null, false);
3055 } 3079 }
3056 3080
3057 int applicationDelegateProc(int id, int sel, int arg0) { 3081 int applicationDelegateProc(int ID, String sel, int arg0) {
3058 if (sel is OS.sel_applicationWillFinishLaunching_1) { 3082 if (sel is OS.sel_applicationWillFinishLaunching_1) {
3059 id dict = NSDictionary.dictionaryWithObject(applicationDelegate, NSString.stringWith("NSOwner")); 3083 id dict = NSDictionary.dictionaryWithObject(applicationDelegate, NSString.stringWith("NSOwner"));
3060 NSString nibFile = NSString.stringWith("/System/Library/Frameworks/JavaVM.framework/Resources/English.lproj/DefaultApp.nib"); 3084 NSString nibFile = NSString.stringWith("/System/Library/Frameworks/JavaVM.framework/Resources/English.lproj/DefaultApp.nib");
3061 if (!NSBundle.loadNibFile(nibFile, dict, null)) { 3085 if (!NSBundle.loadNibFile(nibFile, dict, null)) {
3062 nibFile = NSString.stringWith("/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Resources/English.lproj/DefaultApp.nib"); 3086 nibFile = NSString.stringWith("/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Resources/English.lproj/DefaultApp.nib");
3099 } 3123 }
3100 return 0; 3124 return 0;
3101 } 3125 }
3102 3126
3103 3127
3104 int dialogProc(int id, int sel, int arg0) { 3128 int dialogProc(int id, String sel, int arg0) {
3105 int jniRef = OS.objc_msgSend(id, OS.sel_tag); 3129 NSIntger jniRef = cast(NSIntger) OS.objc_msgSend(id, OS.sel_tag);
3106 if (jniRef is 0 || jniRef is -1) return 0; 3130 if (jniRef is 0 || jniRef is -1) return 0;
3107 if (sel is OS.sel_changeColor_1) { 3131 if (sel == OS.sel_changeColor_1) {
3108 ColorDialog dialog = (ColorDialog)OS.JNIGetObject(jniRef); 3132 ColorDialog dialog = cast(ColorDialog)OS.JNIGetObject(jniRef);
3109 if (dialog is null) return 0; 3133 if (dialog is null) return 0;
3110 dialog.changeColor(arg0); 3134 dialog.changeColor(arg0);
3111 } else if (sel is OS.sel_changeFont_1) { 3135 } else if (sel == OS.sel_changeFont_1) {
3112 FontDialog dialog = (FontDialog)OS.JNIGetObject(jniRef); 3136 FontDialog dialog = cast(FontDialog)OS.JNIGetObject(jniRef);
3113 if (dialog is null) return 0; 3137 if (dialog is null) return 0;
3114 dialog.changeFont(arg0); 3138 dialog.changeFont(arg0);
3115 } else if (sel is OS.sel_windowWillClose_1) { 3139 } else if (sel == OS.sel_windowWillClose_1) {
3116 Object object = OS.JNIGetObject(jniRef); 3140 Object object = OS.JNIGetObject(jniRef);
3117 if (object instanceof FontDialog) { 3141 if (cast(FontDialog) object) {
3118 ((FontDialog)object).windowWillClose(arg0); 3142 (cast(FontDialog)object).windowWillClose(arg0);
3119 } else if (object instanceof ColorDialog) { 3143 } else if (cast(ColorDialog) object) {
3120 ((ColorDialog)object).windowWillClose(arg0); 3144 (cast(ColorDialog)object).windowWillClose(arg0);
3121 } 3145 }
3122 } 3146 }
3123 return 0; 3147 return 0;
3124 } 3148 }
3125 3149
3126 int windowDelegateProc(int delegate, int sel) { 3150 int windowDelegateProc(objc.id delegatee, String sel) {
3127 if (sel is OS.sel_tag) { 3151 if (sel == OS.sel_tag) {
3128 int[] tag = new int[1]; 3152 int[1] tag;
3129 OS.object_getInstanceVariable(delegate, "tag", tag); 3153 OS.object_getInstanceVariable(delegatee, "tag", tag);
3130 return tag[0]; 3154 return tag[0];
3131 } 3155 }
3132 int jniRef = OS.objc_msgSend(delegate, OS.sel_tag); 3156 NSInteger jniRef = cast(NSInteger) OS.objc_msgSend(delegatee, OS.sel_tag);
3133 if (jniRef is 0 || jniRef is -1) return 0; 3157 if (jniRef is 0 || jniRef is -1) return 0;
3134 Widget widget = (Widget)OS.JNIGetObject(jniRef); 3158 Widget widget = cast(Widget)OS.JNIGetObject(jniRef);
3135 if (widget is null) return 0; 3159 if (widget is null) return 0;
3136 if (sel is OS.sel_isFlipped) { 3160 if (sel == OS.sel_isFlipped) {
3137 return widget.isFlipped() ? 1 : 0; 3161 return widget.isFlipped() ? 1 : 0;
3138 } 3162 }
3139 if (sel is OS.sel_sendSelection) { 3163 if (sel == OS.sel_sendSelection) {
3140 widget.sendSelection(); 3164 widget.sendSelection();
3141 return 0; 3165 return 0;
3142 } 3166 }
3143 if (sel is OS.sel_sendArrowSelection) { 3167 if (sel == OS.sel_sendArrowSelection) {
3144 widget.sendArrowSelection(); 3168 widget.sendArrowSelection();
3145 return 0; 3169 return 0;
3146 } 3170 }
3147 if (sel is OS.sel_sendDoubleSelection) { 3171 if (sel == OS.sel_sendDoubleSelection) {
3148 widget.sendDoubleSelection(); 3172 widget.sendDoubleSelection();
3149 return 0; 3173 return 0;
3150 } 3174 }
3151 if (sel is OS.sel_sendVerticalSelection) { 3175 if (sel == OS.sel_sendVerticalSelection) {
3152 widget.sendVerticalSelection(); 3176 widget.sendVerticalSelection();
3153 return 0; 3177 return 0;
3154 } 3178 }
3155 if (sel is OS.sel_sendHorizontalSelection) { 3179 if (sel == OS.sel_sendHorizontalSelection) {
3156 widget.sendHorizontalSelection(); 3180 widget.sendHorizontalSelection();
3157 return 0; 3181 return 0;
3158 } 3182 }
3159 if (sel is OS.sel_acceptsFirstResponder) { 3183 if (sel == OS.sel_acceptsFirstResponder) {
3160 return widget.acceptsFirstResponder() ? 1 : 0; 3184 return widget.acceptsFirstResponder() ? 1 : 0;
3161 } 3185 }
3162 if (sel is OS.sel_becomeFirstResponder) { 3186 if (sel == OS.sel_becomeFirstResponder) {
3163 return widget.becomeFirstResponder() ? 1 : 0; 3187 return widget.becomeFirstResponder() ? 1 : 0;
3164 } 3188 }
3165 if (sel is OS.sel_resignFirstResponder) { 3189 if (sel == OS.sel_resignFirstResponder) {
3166 return widget.resignFirstResponder() ? 1 : 0; 3190 return widget.resignFirstResponder() ? 1 : 0;
3167 } 3191 }
3168 return 0; 3192 return 0;
3169 } 3193 }
3170 3194
3171 int windowDelegateProc(int id, int sel, int arg0) { 3195 int windowDelegateProc(objc.id ID, int sel, int arg0) {
3172 if (sel is OS.sel_timerProc_1) { 3196 if (sel == OS.sel_timerProc_1) {
3173 return timerProc (arg0); 3197 return timerProc (arg0);
3174 } 3198 }
3175 if (sel is OS.sel_setTag_1) { 3199 if (sel == OS.sel_setTag_1) {
3176 OS.object_setInstanceVariable(id, "tag", arg0); 3200 OS.object_setInstanceVariable(id, "tag", arg0);
3177 return 0; 3201 return 0;
3178 } 3202 }
3179 int jniRef = OS.objc_msgSend(id, OS.sel_tag); 3203 int jniRef = OS.objc_msgSend(ID, OS.sel_tag);
3180 if (jniRef is 0 || jniRef is -1) return 0; 3204 if (jniRef is 0 || jniRef is -1) return 0;
3181 Widget widget = (Widget)OS.JNIGetObject(jniRef); 3205 Widget widget = cast(Widget)OS.JNIGetObject(jniRef);
3182 if (widget is null) return 0; 3206 if (widget is null) return 0;
3183 if (sel is OS.sel_windowWillClose_1) { 3207 if (sel == OS.sel_windowWillClose_1) {
3184 widget.windowWillClose(arg0); 3208 widget.windowWillClose(arg0);
3185 } else if (sel is OS.sel_drawRect_1) { 3209 } else if (sel == OS.sel_drawRect_1) {
3186 NSRect rect = new NSRect(); 3210 NSRect rect = NSRect();
3187 OS.memmove(rect, arg0, NSRect.sizeof); 3211 OS.memmove(rect, arg0, NSRect.sizeof);
3188 widget.drawRect(id, rect); 3212 widget.drawRect(ID, rect);
3189 } else if (sel is OS.sel_windowShouldClose_1) { 3213 } else if (sel == OS.sel_windowShouldClose_1) {
3190 return widget.windowShouldClose(arg0) ? 1 : 0; 3214 return widget.windowShouldClose(arg0) ? 1 : 0;
3191 } else if (sel is OS.sel_mouseDown_1) { 3215 } else if (sel == OS.sel_mouseDown_1) {
3192 widget.mouseDown(arg0); 3216 widget.mouseDown(arg0);
3193 } else if (sel is OS.sel_rightMouseDown_1) { 3217 } else if (sel == OS.sel_rightMouseDown_1) {
3194 widget.rightMouseDown(arg0); 3218 widget.rightMouseDown(arg0);
3195 } else if (sel is OS.sel_mouseDragged_1) { 3219 } else if (sel == OS.sel_mouseDragged_1) {
3196 widget.mouseDragged(arg0); 3220 widget.mouseDragged(arg0);
3197 } else if (sel is OS.sel_mouseUp_1) { 3221 } else if (sel == OS.sel_mouseUp_1) {
3198 widget.mouseUp(arg0); 3222 widget.mouseUp(arg0);
3199 } else if (sel is OS.sel_mouseEntered_1) { 3223 } else if (sel == OS.sel_mouseEntered_1) {
3200 widget.mouseEntered(arg0); 3224 widget.mouseEntered(arg0);
3201 } else if (sel is OS.sel_flagsChanged_1) { 3225 } else if (sel == OS.sel_flagsChanged_1) {
3202 widget.flagsChanged(arg0); 3226 widget.flagsChanged(arg0);
3203 } else if (sel is OS.sel_numberOfRowsInTableView_1) { 3227 } else if (sel == OS.sel_numberOfRowsInTableView_1) {
3204 return widget.numberOfRowsInTableView(arg0); 3228 return widget.numberOfRowsInTableView(arg0);
3205 } else if (sel is OS.sel_comboBoxSelectionDidChange_1) { 3229 } else if (sel == OS.sel_comboBoxSelectionDidChange_1) {
3206 widget.comboBoxSelectionDidChange(arg0); 3230 widget.comboBoxSelectionDidChange(arg0);
3207 } else if (sel is OS.sel_tableViewSelectionDidChange_1) { 3231 } else if (sel == OS.sel_tableViewSelectionDidChange_1) {
3208 widget.tableViewSelectionDidChange(arg0); 3232 widget.tableViewSelectionDidChange(arg0);
3209 } else if (sel is OS.sel_windowDidResignKey_1) { 3233 } else if (sel == OS.sel_windowDidResignKey_1) {
3210 widget.windowDidResignKey(arg0); 3234 widget.windowDidResignKey(arg0);
3211 } else if (sel is OS.sel_windowDidBecomeKey_1) { 3235 } else if (sel == OS.sel_windowDidBecomeKey_1) {
3212 widget.windowDidBecomeKey(arg0); 3236 widget.windowDidBecomeKey(arg0);
3213 } else if (sel is OS.sel_windowDidResize_1) { 3237 } else if (sel == OS.sel_windowDidResize_1) {
3214 widget.windowDidResize(arg0); 3238 widget.windowDidResize(arg0);
3215 } else if (sel is OS.sel_windowDidMove_1) { 3239 } else if (sel == OS.sel_windowDidMove_1) {
3216 widget.windowDidMove(arg0); 3240 widget.windowDidMove(arg0);
3217 } else if (sel is OS.sel_menuForEvent_1) { 3241 } else if (sel == OS.sel_menuForEvent_1) {
3218 return widget.menuForEvent(arg0); 3242 return widget.menuForEvent(arg0);
3219 } else if (sel is OS.sel_menuWillOpen_1) { 3243 } else if (sel == OS.sel_menuWillOpen_1) {
3220 widget.menuWillOpen(arg0); 3244 widget.menuWillOpen(arg0);
3221 } else if (sel is OS.sel_menuWillClose_1) { 3245 } else if (sel == OS.sel_menuWillClose_1) {
3222 widget.menuWillClose(arg0); 3246 widget.menuWillClose(arg0);
3223 } else if (sel is OS.sel_menuNeedsUpdate_1) { 3247 } else if (sel == OS.sel_menuNeedsUpdate_1) {
3224 widget.menuNeedsUpdate(arg0); 3248 widget.menuNeedsUpdate(arg0);
3225 } else if (sel is OS.sel_outlineViewSelectionDidChange_1) { 3249 } else if (sel == OS.sel_outlineViewSelectionDidChange_1) {
3226 widget.outlineViewSelectionDidChange(arg0); 3250 widget.outlineViewSelectionDidChange(arg0);
3227 } else if (sel is OS.sel_sendEvent_1) { 3251 } else if (sel == OS.sel_sendEvent_1) {
3228 widget.windowSendEvent(id, arg0); 3252 widget.windowSendEvent(id, arg0);
3229 } else if (sel is OS.sel_helpRequested_1) { 3253 } else if (sel == OS.sel_helpRequested_1) {
3230 widget.helpRequested(arg0); 3254 widget.helpRequested(arg0);
3231 } 3255 }
3232 return 0; 3256 return 0;
3233 } 3257 }
3234 3258
3235 3259
3236 int windowDelegateProc(int delegate, int sel, int arg0, int arg1) { 3260 int windowDelegateProc(objc.id delegatee, String sel, int arg0, int arg1) {
3237 int jniRef = OS.objc_msgSend(delegate, OS.sel_tag); 3261 NSInteger jniRef = cast(NSInteger) OS.objc_msgSend(delegatee, OS.sel_tag);
3238 if (jniRef is 0 || jniRef is -1) return 0; 3262 if (jniRef is 0 || jniRef is -1) return 0;
3239 Widget widget = (Widget)OS.JNIGetObject(jniRef); 3263 Widget widget = cast(Widget)OS.JNIGetObject(jniRef);
3240 if (widget is null) return 0; 3264 if (widget is null) return 0;
3241 if (sel is OS.sel_tabView_1willSelectTabViewItem_1) { 3265 if (sel == OS.sel_tabView_1willSelectTabViewItem_1) {
3242 widget.willSelectTabViewItem(arg0, arg1); 3266 widget.willSelectTabViewItem(arg0, arg1);
3243 } else if (sel is OS.sel_outlineView_1isItemExpandable_1) { 3267 } else if (sel == OS.sel_outlineView_1isItemExpandable_1) {
3244 return widget.outlineView_isItemExpandable(arg0, arg1) ? 1 : 0; 3268 return widget.outlineView_isItemExpandable(arg0, arg1) ? 1 : 0;
3245 } else if (sel is OS.sel_outlineView_1numberOfChildrenOfItem_1) { 3269 } else if (sel == OS.sel_outlineView_1numberOfChildrenOfItem_1) {
3246 return widget.outlineView_numberOfChildrenOfItem(arg0, arg1); 3270 return widget.outlineView_numberOfChildrenOfItem(arg0, arg1);
3247 } else if (sel is OS.sel_outlineView_1shouldCollapseItem_1) { 3271 } else if (sel == OS.sel_outlineView_1shouldCollapseItem_1) {
3248 return widget.outlineView_shouldCollapseItem(arg0, arg1) ? 1 : 0; 3272 return widget.outlineView_shouldCollapseItem(arg0, arg1) ? 1 : 0;
3249 } else if (sel is OS.sel_outlineView_1shouldExpandItem_1) { 3273 } else if (sel == OS.sel_outlineView_1shouldExpandItem_1) {
3250 return widget.outlineView_shouldExpandItem(arg0, arg1) ? 1 : 0; 3274 return widget.outlineView_shouldExpandItem(arg0, arg1) ? 1 : 0;
3251 } else if (sel is OS.sel_menu_1willHighlightItem_1) { 3275 } else if (sel == OS.sel_menu_1willHighlightItem_1) {
3252 widget.menu_willHighlightItem(arg0, arg1); 3276 widget.menu_willHighlightItem(arg0, arg1);
3253 } 3277 }
3254 return 0; 3278 return 0;
3255 } 3279 }
3256 3280
3257 int windowDelegateProc(int delegate, int sel, int arg0, int arg1, int arg2) { 3281 int windowDelegateProc(objc.id delegatee, int sel, int arg0, int arg1, int arg2) {
3258 int jniRef = OS.objc_msgSend(delegate, OS.sel_tag); 3282 NSInteger jniRef = cast(NSInteger) OS.objc_msgSend(delegatee, OS.sel_tag);
3259 if (jniRef is 0 || jniRef is -1) return 0; 3283 if (jniRef is 0 || jniRef is -1) return 0;
3260 Widget widget = (Widget)OS.JNIGetObject(jniRef); 3284 Widget widget = cast(Widget)OS.JNIGetObject(jniRef);
3261 if (widget is null) return 0; 3285 if (widget is null) return 0;
3262 if (sel is OS.sel_tableView_1objectValueForTableColumn_1row_1) { 3286 if (sel == OS.sel_tableView_1objectValueForTableColumn_1row_1) {
3263 return widget.tableView_objectValueForTableColumn_row(arg0, arg1, arg2); 3287 return widget.tableView_objectValueForTableColumn_row(arg0, arg1, arg2);
3264 } 3288 }
3265 if (sel is OS.sel_tableView_1shouldEditTableColumn_1row_1) { 3289 if (sel == OS.sel_tableView_1shouldEditTableColumn_1row_1) {
3266 return widget.tableView_shouldEditTableColumn_row(arg0, arg1, arg2) ? 1 : 0; 3290 return widget.tableView_shouldEditTableColumn_row(arg0, arg1, arg2) ? 1 : 0;
3267 } else if (sel is OS.sel_textView_1clickedOnLink_1atIndex_1) { 3291 } else if (sel == OS.sel_textView_1clickedOnLink_1atIndex_1) {
3268 return widget.clickOnLink(arg0, arg1, arg2) ? 1 : 0; 3292 return widget.clickOnLink(arg0, arg1, arg2) ? 1 : 0;
3269 } else if (sel is OS.sel_outlineView_1child_1ofItem_1) { 3293 } else if (sel == OS.sel_outlineView_1child_1ofItem_1) {
3270 return widget.outlineView_child_ofItem(arg0, arg1, arg2); 3294 return widget.outlineView_child_ofItem(arg0, arg1, arg2);
3271 } else if (sel is OS.sel_outlineView_1objectValueForTableColumn_1byItem_1) { 3295 } else if (sel == OS.sel_outlineView_1objectValueForTableColumn_1byItem_1) {
3272 return widget.outlineView_objectValueForTableColumn_byItem(arg0, arg1, arg2); 3296 return widget.outlineView_objectValueForTableColumn_byItem(arg0, arg1, arg2);
3273 } 3297 }
3274 return 0; 3298 return 0;
3275 } 3299 }
3276 3300
3277 int windowDelegateProc(int delegate, int sel, int arg0, int arg1, int arg2, int arg3) { 3301 int windowDelegateProc(objc.id delegatee, int sel, int arg0, int arg1, int arg2, int arg3) {
3278 int jniRef = OS.objc_msgSend(delegate, OS.sel_tag); 3302 NSInteger jniRef = cast(NSInteger) OS.objc_msgSend(delegatee, OS.sel_tag);
3279 if (jniRef is 0 || jniRef is -1) return 0; 3303 if (jniRef is 0 || jniRef is -1) return 0;
3280 Widget widget = (Widget)OS.JNIGetObject(jniRef); 3304 Widget widget = cast(Widget)OS.JNIGetObject(jniRef);
3281 if (widget is null) return 0; 3305 if (widget is null) return 0;
3282 if (sel is OS.sel_tableView_1willDisplayCell_1forTableColumn_1row_1) { 3306 if (sel == OS.sel_tableView_1willDisplayCell_1forTableColumn_1row_1) {
3283 widget.tableView_willDisplayCell_forTableColumn_row(arg0, arg1, arg2, arg3); 3307 widget.tableView_willDisplayCell_forTableColumn_row(arg0, arg1, arg2, arg3);
3284 } else if (sel is OS.sel_outlineView_1willDisplayCell_1forTableColumn_1item_1) { 3308 } else if (sel == OS.sel_outlineView_1willDisplayCell_1forTableColumn_1item_1) {
3285 widget.outlineView_willDisplayCell_forTableColumn_item(arg0, arg1, arg2, arg3); 3309 widget.outlineView_willDisplayCell_forTableColumn_item(arg0, arg1, arg2, arg3);
3286 } else if (sel is OS.sel_outlineView_1setObjectValue_1forTableColumn_1byItem_1) { 3310 } else if (sel == OS.sel_outlineView_1setObjectValue_1forTableColumn_1byItem_1) {
3287 widget.outlineView_setObjectValue_forTableColumn_byItem(arg0, arg1, arg2, arg3); 3311 widget.outlineView_setObjectValue_forTableColumn_byItem(arg0, arg1, arg2, arg3);
3288 } else if (sel is OS.sel_tableView_1setObjectValue_1forTableColumn_1row_1) { 3312 } else if (sel == OS.sel_tableView_1setObjectValue_1forTableColumn_1row_1) {
3289 widget.tableView_setObjectValue_forTableColumn_row(arg0, arg1, arg2, arg3); 3313 widget.tableView_setObjectValue_forTableColumn_row(arg0, arg1, arg2, arg3);
3290 } 3314 }
3291 return 0; 3315 return 0;
3292 } 3316 }
3293 } 3317 }