comparison dwt/widgets/Display.d @ 46:cfa563df4fdd

Updated Widget and Display to 3.514
author Jacob Carlborg <doob@me.com>
date Fri, 05 Dec 2008 16:00:41 +0100
parents d8635bb48c7c
children 9dd4a17513f9
comparison
equal deleted inserted replaced
45:d8635bb48c7c 46:cfa563df4fdd
73 import tango.core.Thread; 73 import tango.core.Thread;
74 74
75 import dwt.dwthelper.Runnable; 75 import dwt.dwthelper.Runnable;
76 import dwt.dwthelper.System; 76 import dwt.dwthelper.System;
77 import dwt.dwthelper.utils; 77 import dwt.dwthelper.utils;
78 78 import dwt.internal.c.Carbon;
79 import dwt.internal.c.carboncore.MacTypes; 79 import dwt.internal.objc.cocoa.Cocoa;
80 import dwt.internal.cocoa.NSInteger;
81 import objc = dwt.internal.objc.runtime; 80 import objc = dwt.internal.objc.runtime;
82
83 import dwt.widgets.Caret; 81 import dwt.widgets.Caret;
84 import dwt.widgets.ColorDialog; 82 import dwt.widgets.ColorDialog;
85 import dwt.widgets.Control; 83 import dwt.widgets.Control;
84 import dwt.widgets.Decorations;
86 import dwt.widgets.Dialog; 85 import dwt.widgets.Dialog;
87 import dwt.widgets.Event; 86 import dwt.widgets.Event;
88 import dwt.widgets.EventTable; 87 import dwt.widgets.EventTable;
89 import dwt.widgets.FontDialog; 88 import dwt.widgets.FontDialog;
90 import dwt.widgets.Listener; 89 import dwt.widgets.Listener;
93 import dwt.widgets.Monitor; 92 import dwt.widgets.Monitor;
94 import dwt.widgets.Shell; 93 import dwt.widgets.Shell;
95 import dwt.widgets.Synchronizer; 94 import dwt.widgets.Synchronizer;
96 import dwt.widgets.Tray; 95 import dwt.widgets.Tray;
97 import dwt.widgets.Widget; 96 import dwt.widgets.Widget;
98
99 //import mambo.io;
100 97
101 /** 98 /**
102 * Instances of this class are responsible for managing the 99 * Instances of this class are responsible for managing the
103 * connection between DWT and the underlying operating 100 * connection between DWT and the underlying operating
104 * system. Their most important function is to implement 101 * system. Their most important function is to implement
200 197
201 Menu menuBar; 198 Menu menuBar;
202 Menu[] menus, popups; 199 Menu[] menus, popups;
203 200
204 NSApplication application; 201 NSApplication application;
205 int /*long*/ applicationClass; 202 objc.Class applicationClass;
206 NSImage dockImage; 203 NSImage dockImage;
207 bool isEmbedded; 204 bool isEmbedded;
208 205
209 Control focusControl; 206 Control focusControl;
210 207
212 NSAutoreleasePool pool; 209 NSAutoreleasePool pool;
213 int loopCounter = 0; 210 int loopCounter = 0;
214 bool idle; 211 bool idle;
215 static final short DWT_IDLE_TYPE = 1; 212 static final short DWT_IDLE_TYPE = 1;
216 213
217 int[] screenID = new int[32]; 214 int[] screenID;
218 NSPoint[] screenCascade = new NSPoint[32]; 215 NSPoint[] screenCascade;
219 static Callback dialogCallback3;
220 static Callback applicationCallback2, applicationCallback3, applicationCallback6;
221 216
222 /* Menus */ 217 /* Menus */
223 // Menu menuBar; 218 // Menu menuBar;
224 // static final int ID_TEMPORARY = 1000; 219 // static final int ID_TEMPORARY = 1000;
225 // static final int ID_START = 1001; 220 // static final int ID_START = 1001;
234 Image errorImage, infoImage, warningImage; 229 Image errorImage, infoImage, warningImage;
235 Cursor [] cursors; 230 Cursor [] cursors;
236 231
237 /* Key Mappings. */ 232 /* Key Mappings. */
238 static int [] [] KeyTable = [ 233 static int [] [] KeyTable = [
239 234
240 /* Keyboard and Mouse Masks */ 235 /* Keyboard and Mouse Masks */
241 {58, DWT.ALT}, 236 [58, DWT.ALT],
242 {56, DWT.SHIFT}, 237 [56, DWT.SHIFT],
243 {59, DWT.CONTROL}, 238 [59, DWT.CONTROL],
244 {55, DWT.COMMAND}, 239 [55, DWT.COMMAND],
245 {61, DWT.ALT}, 240 [61, DWT.ALT],
246 {62, DWT.CONTROL}, 241 [62, DWT.CONTROL],
247 {60, DWT.SHIFT}, 242 [60, DWT.SHIFT],
248 {54, DWT.COMMAND}, 243 [54, DWT.COMMAND],
249 244
250 /* Non-Numeric Keypad Keys */ 245 /* Non-Numeric Keypad Keys */
251 {126, DWT.ARROW_UP}, 246 [126, DWT.ARROW_UP],
252 {125, DWT.ARROW_DOWN}, 247 [125, DWT.ARROW_DOWN],
253 {123, DWT.ARROW_LEFT}, 248 [123, DWT.ARROW_LEFT],
254 {124, DWT.ARROW_RIGHT}, 249 [124, DWT.ARROW_RIGHT],
255 {116, DWT.PAGE_UP}, 250 [116, DWT.PAGE_UP],
256 {121, DWT.PAGE_DOWN}, 251 [121, DWT.PAGE_DOWN],
257 {115, DWT.HOME}, 252 [115, DWT.HOME],
258 {119, DWT.END}, 253 [119, DWT.END],
259 // [??, DWT.INSERT], 254 // [??, DWT.INSERT],
260 255
261 /* Virtual and Ascii Keys */ 256 /* Virtual and Ascii Keys */
262 {51, DWT.BS}, 257 [51, DWT.BS],
263 {36, DWT.CR}, 258 [36, DWT.CR],
264 {117, DWT.DEL}, 259 [117, DWT.DEL],
265 {53, DWT.ESC}, 260 [53, DWT.ESC],
266 {76, DWT.LF}, 261 [76, DWT.LF],
267 {48, DWT.TAB}, 262 [48, DWT.TAB],
268 263
269 /* Functions Keys */ 264 /* Functions Keys */
270 {122, DWT.F1}, 265 [122, DWT.F1],
271 {120, DWT.F2}, 266 [120, DWT.F2],
272 {99, DWT.F3}, 267 [99, DWT.F3],
273 {118, DWT.F4}, 268 [118, DWT.F4],
274 {96, DWT.F5}, 269 [96, DWT.F5],
275 {97, DWT.F6}, 270 [97, DWT.F6],
276 {98, DWT.F7}, 271 [98, DWT.F7],
277 {100, DWT.F8}, 272 [100, DWT.F8],
278 {101, DWT.F9}, 273 [101, DWT.F9],
279 {109, DWT.F10}, 274 [109, DWT.F10],
280 {103, DWT.F11}, 275 [103, DWT.F11],
281 {111, DWT.F12}, 276 [111, DWT.F12],
282 {105, DWT.F13}, 277 [105, DWT.F13],
283 {107, DWT.F14}, 278 [107, DWT.F14],
284 {113, DWT.F15}, 279 [113, DWT.F15],
285 280
286 /* Numeric Keypad Keys */ 281 /* Numeric Keypad Keys */
287 {67, DWT.KEYPAD_MULTIPLY}, 282 [67, DWT.KEYPAD_MULTIPLY],
288 {69, DWT.KEYPAD_ADD}, 283 [69, DWT.KEYPAD_ADD],
289 {76, DWT.KEYPAD_CR}, 284 [76, DWT.KEYPAD_CR],
290 {78, DWT.KEYPAD_SUBTRACT}, 285 [78, DWT.KEYPAD_SUBTRACT],
291 {65, DWT.KEYPAD_DECIMAL}, 286 [65, DWT.KEYPAD_DECIMAL],
292 {75, DWT.KEYPAD_DIVIDE}, 287 [75, DWT.KEYPAD_DIVIDE],
293 {82, DWT.KEYPAD_0}, 288 [82, DWT.KEYPAD_0],
294 {83, DWT.KEYPAD_1}, 289 [83, DWT.KEYPAD_1],
295 {84, DWT.KEYPAD_2}, 290 [84, DWT.KEYPAD_2],
296 {85, DWT.KEYPAD_3}, 291 [85, DWT.KEYPAD_3],
297 {86, DWT.KEYPAD_4}, 292 [86, DWT.KEYPAD_4],
298 {87, DWT.KEYPAD_5}, 293 [87, DWT.KEYPAD_5],
299 {88, DWT.KEYPAD_6}, 294 [88, DWT.KEYPAD_6],
300 {89, DWT.KEYPAD_7}, 295 [89, DWT.KEYPAD_7],
301 {91, DWT.KEYPAD_8}, 296 [91, DWT.KEYPAD_8],
302 {92, DWT.KEYPAD_9}, 297 [92, DWT.KEYPAD_9],
303 {81, DWT.KEYPAD_EQUAL}, 298 [81, DWT.KEYPAD_EQUAL],
304 299
305 /* Other keys */ 300 /* Other keys */
306 {57, DWT.CAPS_LOCK}, 301 [57, DWT.CAPS_LOCK],
307 {71, DWT.NUM_LOCK}, 302 [71, DWT.NUM_LOCK],
308 // [??, DWT.SCROLL_LOCK], 303 // [??, DWT.SCROLL_LOCK],
309 // [??, DWT.PAUSE], 304 // [??, DWT.PAUSE],
310 // [??, DWT.BREAK], 305 // [??, DWT.BREAK],
311 // [??, DWT.PRINT_SCREEN], 306 // [??, DWT.PRINT_SCREEN],
312 {114, DWT.HELP}, 307 [114, DWT.HELP],
313 308
314 ]; 309 ];
315 310
316 static String APP_NAME = "DWT"; 311 static String APP_NAME = "DWT";
317 static const String ADD_WIDGET_KEY = "dwt.internal.addWidget"; 312 static const String ADD_WIDGET_KEY = "dwt.internal.addWidget";
318 static const String DWT_OBJECT = "DWT_OBJECT"; //$NON-NLS-1$ 313 static const String SWT_OBJECT = "SWT_OBJECT"; //$NON-NLS-1$
319 314
320 /* Multiple Displays. */ 315 /* Multiple Displays. */
321 static Display Default; 316 static Display Default;
322 static Display [] Displays; 317 static Display [] Displays;
323 318
505 popups [index] = menu; 500 popups [index] = menu;
506 } 501 }
507 502
508 void addWidget (NSObject view, Widget widget) { 503 void addWidget (NSObject view, Widget widget) {
509 if (view is null) return; 504 if (view is null) return;
510 OS.object_setInstanceVariable (view.id, DWT_OBJECT, widget.jniRef); 505 OS.object_setInstanceVariable (view.id, SWT_OBJECT, widget.jniRef);
511 } 506 }
512 507
513 /** 508 /**
514 * Causes the <code>run()</code> method of the runnable to 509 * Causes the <code>run()</code> method of the runnable to
515 * be invoked by the user-interface thread at the next 510 * be invoked by the user-interface thread at the next
553 OS.NSBeep (); 548 OS.NSBeep ();
554 } 549 }
555 550
556 void cascadeWindow (NSWindow window, NSScreen screen) { 551 void cascadeWindow (NSWindow window, NSScreen screen) {
557 NSDictionary dictionary = screen.deviceDescription(); 552 NSDictionary dictionary = screen.deviceDescription();
558 int screenNumber = new NSNumber(dictionary.objectForKey(NSString.stringWith("NSScreenNumber")).id).intValue(); 553 int screenNumber = (new NSNumber(dictionary.objectForKey(NSString.stringWith("NSScreenNumber")).id)).intValue();
559 int index = 0; 554 int index = 0;
560 while (screenID[index] !is 0 && screenID[index] !is screenNumber) index++; 555 while (screenID[index] !is 0 && screenID[index] !is screenNumber) index++;
561 screenID[index] = screenNumber; 556 screenID[index] = screenNumber;
562 NSPoint cascade = screenCascade[index]; 557 NSPoint cascade = screenCascade[index];
563 if (cascade is null) { 558 if (cascade is null) {
564 NSRect frame = screen.frame(); 559 NSRect frame = screen.frame();
565 cascade = new NSPoint(); 560 cascade = NSPoint();
566 cascade.x = frame.x; 561 cascade.x = frame.x;
567 cascade.y = frame.y + frame.height; 562 cascade.y = frame.y + frame.height;
568 } 563 }
569 screenCascade[index] = window.cascadeTopLeftFromPoint(cascade); 564 screenCascade[index] = window.cascadeTopLeftFromPoint(cascade);
570 } 565 }
619 * 614 *
620 * @param data the device data 615 * @param data the device data
621 */ 616 */
622 public this (DeviceData data) { 617 public this (DeviceData data) {
623 super (data); 618 super (data);
619 screenID = new int[32];
620 screenCascade = new NSPoint[32];
624 cursors = new Cursor [DWT.CURSOR_HAND + 1]; 621 cursors = new Cursor [DWT.CURSOR_HAND + 1];
625 Displays = new Display [4]; 622 Displays = new Display [4];
626 timerDelegate = cast(SWTWindowDelegate)(new SWTWindowDelegate()).alloc().init(); 623 timerDelegate = cast(SWTWindowDelegate)(new SWTWindowDelegate()).alloc().init();
627 624
628 caretTimer = new class(currentCaret) Runnable { 625 caretTimer = new class(currentCaret) Runnable {
642 } else { 639 } else {
643 currentCaret = null; 640 currentCaret = null;
644 } 641 }
645 } 642 }
646 643
644 }
645 };
646
647 hoverTimer = new class(currentControl) Runnable {
648 Control currentControl;
649
650 this (Control currentControl)
651 {
652 this.currentControl = currentControl;
653 }
654
655 public void run () {
656 if (currentControl !is null && !currentControl.isDisposed()) {
657 currentControl.sendMouseEvent (null, DWT.MouseHover, trackingControl !is null);
658 }
647 } 659 }
648 }; 660 };
649 } 661 }
650 662
651 static void checkDisplay (Thread thread, bool multiple) { 663 static void checkDisplay (Thread thread, bool multiple) {
775 * serial number returned by GetCurrentProcess() in the 787 * serial number returned by GetCurrentProcess() in the
776 * call to SetFrontProcess() (ie. kCurrentProcess can be 788 * call to SetFrontProcess() (ie. kCurrentProcess can be
777 * used) but both functions must be called in order for 789 * used) but both functions must be called in order for
778 * windows to come to the front. 790 * windows to come to the front.
779 */ 791 */
780 ProcessSerialNumber* psn; 792 ProcessSerialNumber* psn;
781 if (OS.GetCurrentProcess (psn) is OS.noErr) { 793 if (OS.GetCurrentProcess (psn) is OS.noErr) {
782 int pid = OS.getpid (); 794 int pid = OS.getpid ();
783 int /*long*/ ptr = OS.getenv (ascii ("APP_NAME_" + pid)); 795 char* ptr = OS.getenv (ascii ("APP_NAME_" + pid));
784 if (ptr is 0 && APP_NAME !is null) { 796 if (ptr is null && APP_NAME !is null) {
785 ptr = NSString.stringWith(APP_NAME).UTF8String(); 797 ptr = NSString.stringWith(APP_NAME).UTF8String();
786 } 798 }
787 if (ptr !is 0) OS.CPSSetProcessName (psn, ptr); 799 if (ptr !is null) OS.CPSSetProcessName (psn, ptr);
788 OS.TransformProcessType (psn, OS.kProcessTransformToForegroundApplication); 800 OS.TransformProcessType (psn, OS.kProcessTransformToForegroundApplication);
789 OS.SetFrontProcess (psn); 801 OS.SetFrontProcess (psn);
790 ptr = OS.getenv (ascii ("APP_ICON_" + pid)); 802 ptr = OS.getenv (ascii ("APP_ICON_" + pid));
791 if (ptr !is 0) { 803 if (ptr !is null) {
792 NSString path = NSString.stringWithUTF8String (ptr); 804 NSString path = NSString.stringWithUTF8String (ptr);
793 NSImage image = (NSImage) new NSImage().alloc(); 805 NSImage image = cast(NSImage) (new NSImage()).alloc();
794 image = image.initByReferencingFile(path); 806 image = image.initByReferencingFile(path);
795 dockImage = image; 807 dockImage = image;
796 application.setApplicationIconImage(image); 808 application.setApplicationIconImage(image);
797 } 809 }
798 } 810 }
799 811
800 String className = "SWTApplication"; 812 String className = "SWTApplication";
801 int /*long*/ cls; 813 objc.Class cls;
802 if ((cls = OS.objc_lookUpClass (className)) is 0) { 814 if ((cls = OS.objc_lookUpClass (className)) is null) {
803 Class clazz = getClass(); 815 objc.IMP proc2 = cast(objc.IMP) &applicationProc2;
804 applicationCallback2 = new Callback(clazz, "applicationProc", 2); 816 objc.IMP proc3 = cast(objc.IMP) &applicationProc3;
805 int /*long*/ proc2 = applicationCallback2.getAddress(); 817 objc.IMP proc6 = cast(objc.IMP) &applicationProc6;
806 if (proc2 is 0) error (DWT.ERROR_NO_MORE_CALLBACKS);
807 applicationCallback3 = new Callback(clazz, "applicationProc", 3);
808 int /*long*/ proc3 = applicationCallback3.getAddress();
809 if (proc3 is 0) error (DWT.ERROR_NO_MORE_CALLBACKS);
810 applicationCallback6 = new Callback(clazz, "applicationProc", 6);
811 int /*long*/ proc6 = applicationCallback6.getAddress();
812 if (proc6 is 0) error (DWT.ERROR_NO_MORE_CALLBACKS);
813 cls = OS.objc_allocateClassPair(OS.class_NSApplication, className, 0); 818 cls = OS.objc_allocateClassPair(OS.class_NSApplication, className, 0);
814 OS.class_addMethod(cls, OS.sel_sendEvent_, proc3, "@:@"); 819 OS.class_addMethod(cls, OS.sel_sendEvent_, proc3, "@:@");
815 OS.class_addMethod(cls, OS.sel_nextEventMatchingMask_untilDate_inMode_dequeue_, proc6, "@:i@@B"); 820 OS.class_addMethod(cls, OS.sel_nextEventMatchingMask_untilDate_inMode_dequeue_, proc6, "@:i@@B");
816 OS.class_addMethod(cls, OS.sel_isRunning, proc2, "@:"); 821 OS.class_addMethod(cls, OS.sel_isRunning, proc2, "@:");
817 OS.objc_registerClassPair(cls); 822 OS.objc_registerClassPair(cls);
1001 * </ul> 1006 * </ul>
1002 */ 1007 */
1003 public Shell getActiveShell () { 1008 public Shell getActiveShell () {
1004 checkDevice (); 1009 checkDevice ();
1005 NSArray windows = application.windows(); 1010 NSArray windows = application.windows();
1006 int count = (int)/*64*/windows.count(); 1011 int count = cast(int)/*64*/windows.count();
1007 for (int i = 0; i < count; i++) { 1012 for (int i = 0; i < count; i++) {
1008 NSWindow win = new NSWindow(windows.objectAtIndex(i)); 1013 NSWindow win = new NSWindow(windows.objectAtIndex(i));
1009 if (win.isKeyWindow()) { 1014 if (win.isKeyWindow()) {
1010 Widget widget = getWidget(win.contentView()); 1015 Widget widget = getWidget(win.contentView());
1011 if (widget instanceof Shell) { 1016 if (cast(Shell) widget) {
1012 return cast(Shell)widget; 1017 return cast(Shell)widget;
1013 } 1018 }
1014 } 1019 }
1015 } 1020 }
1016 return null; 1021 return null;
1032 NSArray screens = NSScreen.screens(); 1037 NSArray screens = NSScreen.screens();
1033 return getBounds (screens); 1038 return getBounds (screens);
1034 } 1039 }
1035 1040
1036 Rectangle getBounds (NSArray screens) { 1041 Rectangle getBounds (NSArray screens) {
1037 NSRect primaryFrame = new NSScreen(screens.objectAtIndex(0)).frame(); 1042 NSRect primaryFrame = (new NSScreen(screens.objectAtIndex(0))).frame();
1038 float /*double*/ minX = Float.MAX_VALUE, maxX = Float.MIN_VALUE; 1043 CGFloat minX = Float.MAX_VALUE, maxX = Float.MIN_VALUE;
1039 float /*double*/ minY = Float.MAX_VALUE, maxY = Float.MIN_VALUE; 1044 CGFloat minY = Float.MAX_VALUE, maxY = Float.MIN_VALUE;
1040 int /*long*/ count = screens.count(); 1045 NSUInteger count = screens.count();
1041 for (int i = 0; i < count; i++) { 1046 for (NSUInteger i = 0; i < count; i++) {
1042 NSScreen screen = new NSScreen(screens.objectAtIndex(i)); 1047 NSScreen screen = new NSScreen(screens.objectAtIndex(i));
1043 NSRect frame = screen.frame(); 1048 NSRect frame = screen.frame();
1044 float /*double*/ x1 = frame.x, x2 = frame.x + frame.width; 1049 CGFloat x1 = frame.x, x2 = frame.x + frame.width;
1045 float /*double*/ y1 = primaryFrame.height - frame.y, y2 = primaryFrame.height - (frame.y + frame.height); 1050 CGFloat y1 = primaryFrame.height - frame.y, y2 = primaryFrame.height - (frame.y + frame.height);
1046 if (x1 < minX) minX = x1; 1051 if (x1 < minX) minX = x1;
1047 if (x2 < minX) minX = x2; 1052 if (x2 < minX) minX = x2;
1048 if (x1 > maxX) maxX = x1; 1053 if (x1 > maxX) maxX = x1;
1049 if (x2 > maxX) maxX = x2; 1054 if (x2 > maxX) maxX = x2;
1050 if (y1 < minY) minY = y1; 1055 if (y1 < minY) minY = y1;
1051 if (y2 < minY) minY = y2; 1056 if (y2 < minY) minY = y2;
1052 if (y1 > maxY) maxY = y1; 1057 if (y1 > maxY) maxY = y1;
1053 if (y2 > maxY) maxY = y2; 1058 if (y2 > maxY) maxY = y2;
1054 } 1059 }
1055 return new Rectangle ((int)minX, (int)minY, (int)(maxX - minX), (int)(maxY - minY)); 1060 return new Rectangle (cast(int)minX, cast(int)minY, cast(int)(maxX - minX), cast(int)(maxY - minY));
1056 } 1061 }
1057 1062
1058 /** 1063 /**
1059 * Returns the display which the currently running thread is 1064 * Returns the display which the currently running thread is
1060 * the user-interface thread for, or null if the currently 1065 * the user-interface thread for, or null if the currently
1089 NSArray screens = NSScreen.screens(); 1094 NSArray screens = NSScreen.screens();
1090 if (screens.count() !is 1) return getBounds (screens); 1095 if (screens.count() !is 1) return getBounds (screens);
1091 NSScreen screen = new NSScreen(screens.objectAtIndex(0)); 1096 NSScreen screen = new NSScreen(screens.objectAtIndex(0));
1092 NSRect frame = screen.frame(); 1097 NSRect frame = screen.frame();
1093 NSRect visibleFrame = screen.visibleFrame(); 1098 NSRect visibleFrame = screen.visibleFrame();
1094 float /*double*/ y = frame.height - (visibleFrame.y + visibleFrame.height); 1099 CGFloat y = frame.height - (visibleFrame.y + visibleFrame.height);
1095 return new Rectangle((int)visibleFrame.x, (int)y, (int)visibleFrame.width, (int)visibleFrame.height); 1100 return new Rectangle(cast(int)visibleFrame.x, cast(int)y, cast(int)visibleFrame.width, cast(int)visibleFrame.height);
1096 } 1101 }
1097 1102
1098 /** 1103 /**
1099 * Returns the control which the on-screen pointer is currently 1104 * Returns the control which the on-screen pointer is currently
1100 * over top of, or null if it is not currently over one of the 1105 * over top of, or null if it is not currently over one of the
1223 checkDevice (); 1228 checkDevice ();
1224 return data; 1229 return data;
1225 } 1230 }
1226 1231
1227 /** 1232 /**
1228 * Returns the button dismissal alignment, one of <code>LEFT</code> or <code>RIGHT</code>. 1233 * Returns the button dismissal align_ment, one of <code>LEFT</code> or <code>RIGHT</code>.
1229 * The button dismissal alignment is the ordering that should be used when positioning the 1234 * The button dismissal align_ment is the ordering that should be used when positioning the
1230 * default dismissal button for a dialog. For example, in a dialog that contains an OK and 1235 * default dismissal button for a dialog. For example, in a dialog that contains an OK and
1231 * CANCEL button, on platforms where the button dismissal alignment is <code>LEFT</code>, the 1236 * CANCEL button, on platforms where the button dismissal align_ment is <code>LEFT</code>, the
1232 * button ordering should be OK/CANCEL. When button dismissal alignment is <code>RIGHT</code>, 1237 * button ordering should be OK/CANCEL. When button dismissal align_ment is <code>RIGHT</code>,
1233 * the button ordering should be CANCEL/OK. 1238 * the button ordering should be CANCEL/OK.
1234 * 1239 *
1235 * @return the button dismissal order 1240 * @return the button dismissal order
1236 * 1241 *
1237 * @exception DWTException <ul> 1242 * @exception DWTException <ul>
1291 } 1296 }
1292 NSView view = new NSView(responder.id); 1297 NSView view = new NSView(responder.id);
1293 if (view !is null) { 1298 if (view !is null) {
1294 do { 1299 do {
1295 Widget widget = GetWidget (view.id); 1300 Widget widget = GetWidget (view.id);
1296 if (widget instanceof Control) { 1301 if (cast(Control)widget) {
1297 return (Control)widget; 1302 return cast(Control)widget;
1298 } 1303 }
1299 view = view.superview(); 1304 view = view.superview();
1300 } while (view !is null); 1305 } while (view !is null);
1301 } 1306 }
1302 } 1307 }
1402 * @since 3.0 1407 * @since 3.0
1403 */ 1408 */
1404 public dwt.widgets.Monitor.Monitor [] getMonitors () { 1409 public dwt.widgets.Monitor.Monitor [] getMonitors () {
1405 checkDevice (); 1410 checkDevice ();
1406 NSArray screens = NSScreen.screens(); 1411 NSArray screens = NSScreen.screens();
1407 NSRect primaryFrame = new NSScreen(screens.objectAtIndex(0)).frame(); 1412 NSRect primaryFrame = (new NSScreen(screens.objectAtIndex(0))).frame();
1408 int count = (int)/*64*/screens.count(); 1413 int count = cast(int)/*64*/screens.count();
1409 for (int i=0; i<count; i++) { 1414 for (int i=0; i<count; i++) {
1410 dwt.widgets.Monitor.Monitor monitor = new dwt.widgets.Monitor.Monitor (); 1415 dwt.widgets.Monitor.Monitor monitor = new dwt.widgets.Monitor.Monitor ();
1411 NSScreen screen = new NSScreen(screens.objectAtIndex(i)); 1416 NSScreen screen = new NSScreen(screens.objectAtIndex(i));
1412 NSRect frame = screen.frame(); 1417 NSRect frame = screen.frame();
1413 monitor.x = cast(int)frame.x; 1418 monitor.x = cast(int)frame.x;
1414 monitor.y = (int)(primaryFrame.height - (frame.y + frame.height)); 1419 monitor.y = cast(int)(primaryFrame.height - (frame.y + frame.height));
1415 monitor.width = cast(int)frame.width; 1420 monitor.width = cast(int)frame.width;
1416 monitor.height = cast(int)frame.height; 1421 monitor.height = cast(int)frame.height;
1417 NSRect visibleFrame = screen.visibleFrame(); 1422 NSRect visibleFrame = screen.visibleFrame();
1418 monitor.clientX = cast(int)visibleFrame.x; 1423 monitor.clientX = cast(int)visibleFrame.x;
1419 monitor.clientY = (int)(primaryFrame.height - (visibleFrame.y + visibleFrame.height)); 1424 monitor.clientY = cast(int)(primaryFrame.height - (visibleFrame.y + visibleFrame.height));
1420 monitor.clientWidth = cast(int)visibleFrame.width; 1425 monitor.clientWidth = cast(int)visibleFrame.width;
1421 monitor.clientHeight = cast(int)visibleFrame.height; 1426 monitor.clientHeight = cast(int)visibleFrame.height;
1422 monitors [i] = monitor; 1427 monitors [i] = monitor;
1423 } 1428 }
1424 return monitors; 1429 return monitors;
1425 } 1430 }
1426 1431
1427 NSRect getPrimaryFrame () { 1432 NSRect getPrimaryFrame () {
1428 NSArray screens = NSScreen.screens(); 1433 NSArray screens = NSScreen.screens();
1429 return new NSScreen(screens.objectAtIndex(0)).frame(); 1434 return (new NSScreen(screens.objectAtIndex(0))).frame();
1430 } 1435 }
1431 1436
1432 /** 1437 /**
1433 * Returns the primary monitor for that device. 1438 * Returns the primary monitor for that device.
1434 * 1439 *
1441 dwt.widgets.Monitor.Monitor monitor = new dwt.widgets.Monitor.Monitor (); 1446 dwt.widgets.Monitor.Monitor monitor = new dwt.widgets.Monitor.Monitor ();
1442 NSArray screens = NSScreen.screens(); 1447 NSArray screens = NSScreen.screens();
1443 NSScreen screen = new NSScreen(screens.objectAtIndex(0)); 1448 NSScreen screen = new NSScreen(screens.objectAtIndex(0));
1444 NSRect frame = screen.frame(); 1449 NSRect frame = screen.frame();
1445 monitor.x = cast(int)frame.x; 1450 monitor.x = cast(int)frame.x;
1446 monitor.y = (int)(frame.height - (frame.y + frame.height)); 1451 monitor.y = cast(int)(frame.height - (frame.y + frame.height));
1447 monitor.width = cast(int)frame.width; 1452 monitor.width = cast(int)frame.width;
1448 monitor.height = cast(int)frame.height; 1453 monitor.height = cast(int)frame.height;
1449 NSRect visibleFrame = screen.visibleFrame(); 1454 NSRect visibleFrame = screen.visibleFrame();
1450 monitor.clientX = cast(int)visibleFrame.x; 1455 monitor.clientX = cast(int)visibleFrame.x;
1451 monitor.clientY = (int)(frame.height - (visibleFrame.y + visibleFrame.height)); 1456 monitor.clientY = cast(int)(frame.height - (visibleFrame.y + visibleFrame.height));
1452 monitor.clientWidth = cast(int)visibleFrame.width; 1457 monitor.clientWidth = cast(int)visibleFrame.width;
1453 monitor.clientHeight = cast(int)visibleFrame.height; 1458 monitor.clientHeight = cast(int)visibleFrame.height;
1454 return monitor; 1459 return monitor;
1455 } 1460 }
1456 1461
1467 */ 1472 */
1468 public Shell [] getShells () { 1473 public Shell [] getShells () {
1469 checkDevice (); 1474 checkDevice ();
1470 NSArray windows = application.windows(); 1475 NSArray windows = application.windows();
1471 int index = 0; 1476 int index = 0;
1472 Shell [] result = new Shell [(int)/*64*/windows.count()]; 1477 Shell [] result = new Shell [windows.count()];
1473 for (int i = 0; i < result.length; i++) { 1478 for (int i = 0; i < result.length; i++) {
1474 NSWindow window = new NSWindow(windows.objectAtIndex(i)); 1479 NSWindow window = new NSWindow(windows.objectAtIndex(i));
1475 Widget widget = getWidget(window.contentView()); 1480 Widget widget = getWidget(window.contentView());
1476 if (widget instanceof Shell) { 1481 if (cast(Shell) widget) {
1477 result[index++] = (Shell)widget; 1482 result[index++] = cast(Shell)widget;
1478 } 1483 }
1479 } 1484 }
1480 if (index is result.length) return result; 1485 if (index is result.length) return result;
1481 Shell [] newResult = new Shell [index]; 1486 Shell [] newResult = new Shell [index];
1482 System.arraycopy (result, 0, newResult, 0, index); 1487 System.arraycopy (result, 0, newResult, 0, index);
1568 return super.getSystemColor (id); 1573 return super.getSystemColor (id);
1569 } 1574 }
1570 if (color is null) return super.getSystemColor(id); 1575 if (color is null) return super.getSystemColor(id);
1571 color = color.colorUsingColorSpace(NSColorSpace.deviceRGBColorSpace()); 1576 color = color.colorUsingColorSpace(NSColorSpace.deviceRGBColorSpace());
1572 if (color is null) return super.getSystemColor(id); 1577 if (color is null) return super.getSystemColor(id);
1573 float /*double*/[] components = new float /*double*/[(int)/*64*/color.numberOfComponents()]; 1578 CGFloat[] components = new CGFloat[color.numberOfComponents()];
1574 color.getComponents(components); 1579 color.getComponents(components);
1575 return Color.cocoa_new (this, [cast(float)/*64*/ components[0], cast(float)/*64*/ components[1], cast(float)/*64*/ components[2], cast(float)/*64*/ components[3]]); 1580 return Color.cocoa_new (this, [cast(float)/*64*/ components[0], cast(float)/*64*/ components[1], cast(float)/*64*/ components[2], cast(float)/*64*/ components[3]]);
1576 } 1581 }
1577 1582
1578 /** 1583 /**
1720 checkDevice (); 1725 checkDevice ();
1721 //TODO get OS value (NSTooltipManager?) 1726 //TODO get OS value (NSTooltipManager?)
1722 return 560; 1727 return 560;
1723 } 1728 }
1724 1729
1725 Widget getWidget (int /*long*/ id) { 1730 Widget getWidget (objc.id id) {
1726 return GetWidget (id); 1731 return GetWidget (id);
1727 } 1732 }
1728 1733
1729 static Widget GetWidget (int /*long*/ id) { 1734 static Widget GetWidget (objc.id id) {
1730 if (id is 0) return null; 1735 if (id is null) return null;
1731 int /*long*/ [] jniRef = new int /*long*/ [1]; 1736 void* jniRef;
1732 OS.object_getInstanceVariable(id, DWT_OBJECT, jniRef); 1737 OS.object_getInstanceVariable(id, SWT_OBJECT, jniRef);
1733 if (jniRef[0] is 0) return null; 1738 if (jniRef is null) return null;
1734 return (Widget)OS.JNIGetObject(jniRef[0]); 1739 return cast(Widget)OS.JNIGetObject(jniRef);
1735 } 1740 }
1736 1741
1737 Widget getWidget (NSView view) { 1742 Widget getWidget (NSView view) {
1738 if (view is null) return null; 1743 if (view is null) return null;
1739 return getWidget(view.id); 1744 return getWidget(view.id);
1755 if (!isEmbedded) { 1760 if (!isEmbedded) {
1756 initApplicationDelegate(); 1761 initApplicationDelegate();
1757 application.finishLaunching(); 1762 application.finishLaunching();
1758 } 1763 }
1759 1764
1760 timerDelegate = (SWTWindowDelegate)new SWTWindowDelegate().alloc().init(); 1765 timerDelegate = cast(SWTWindowDelegate)(new SWTWindowDelegate()).alloc().init();
1761 1766
1762 NSTextView textView = cast(NSTextView)(new NSTextView()).alloc(); 1767 NSTextView textView = cast(NSTextView)(new NSTextView()).alloc();
1763 textView.initWithFrame (NSRect ()); 1768 textView.initWithFrame (NSRect ());
1764 markedAttributes = textView.markedTextAttributes (); 1769 markedAttributes = textView.markedTextAttributes ();
1765 markedAttributes.retain (); 1770 markedAttributes.retain ();
1767 } 1772 }
1768 1773
1769 void initApplicationDelegate() { 1774 void initApplicationDelegate() {
1770 String className = "SWTApplicationDelegate"; 1775 String className = "SWTApplicationDelegate";
1771 if (OS.objc_lookUpClass (className) is null) { 1776 if (OS.objc_lookUpClass (className) is null) {
1772 Class clazz = getClass (); 1777 objc.IMP appProc3 = cast(objc.IMP) &applicationDelegateProc;
1773 applicationDelegateCallback3 = new Callback(clazz, "applicationDelegateProc", 3); 1778 objc.Class cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0);
1774 int /*long*/ appProc3 = applicationDelegateCallback3.getAddress();
1775 if (appProc3 is 0) error (DWT.ERROR_NO_MORE_CALLBACKS);
1776 int /*long*/ cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0);
1777 OS.class_addMethod(cls, OS.sel_applicationWillFinishLaunching_, appProc3, "@:@"); 1779 OS.class_addMethod(cls, OS.sel_applicationWillFinishLaunching_, appProc3, "@:@");
1778 OS.class_addMethod(cls, OS.sel_terminate_, appProc3, "@:@"); 1780 OS.class_addMethod(cls, OS.sel_terminate_, appProc3, "@:@");
1779 OS.class_addMethod(cls, OS.sel_orderFrontStandardAboutPanel_, appProc3, "@:@"); 1781 OS.class_addMethod(cls, OS.sel_orderFrontStandardAboutPanel_, appProc3, "@:@");
1780 OS.class_addMethod(cls, OS.sel_hideOtherApplications_, appProc3, "@:@"); 1782 OS.class_addMethod(cls, OS.sel_hideOtherApplications_, appProc3, "@:@");
1781 OS.class_addMethod(cls, OS.sel_hide_, appProc3, "@:@"); 1783 OS.class_addMethod(cls, OS.sel_hide_, appProc3, "@:@");
1787 } 1789 }
1788 applicationDelegate = cast(SWTApplicationDelegate)(new SWTApplicationDelegate()).alloc().init(); 1790 applicationDelegate = cast(SWTApplicationDelegate)(new SWTApplicationDelegate()).alloc().init();
1789 application.setDelegate(applicationDelegate); 1791 application.setDelegate(applicationDelegate);
1790 } 1792 }
1791 1793
1792 void addEventMethods (int /*long*/ cls, int /*long*/ proc2, int /*long*/ proc3, int /*long*/ drawRectProc) { 1794 void addEventMethods (objc.Class cls, objc.IMP proc2, objc.IMP proc3, objc.IMP drawRectProc) {
1793 OS.class_addMethod(cls, OS.sel_mouseDown_, proc3, "@:@"); 1795 OS.class_addMethod(cls, OS.sel_mouseDown_, proc3, "@:@");
1794 OS.class_addMethod(cls, OS.sel_mouseUp_, proc3, "@:@"); 1796 OS.class_addMethod(cls, OS.sel_mouseUp_, proc3, "@:@");
1795 OS.class_addMethod(cls, OS.sel_scrollWheel_, proc3, "@:@"); 1797 OS.class_addMethod(cls, OS.sel_scrollWheel_, proc3, "@:@");
1796 OS.class_addMethod(cls, OS.sel_rightMouseDown_, proc3, "@:@"); 1798 OS.class_addMethod(cls, OS.sel_rightMouseDown_, proc3, "@:@");
1797 OS.class_addMethod(cls, OS.sel_rightMouseUp_, proc3, "@:@"); 1799 OS.class_addMethod(cls, OS.sel_rightMouseUp_, proc3, "@:@");
1808 OS.class_addMethod(cls, OS.sel_keyUp_, proc3, "@:@"); 1810 OS.class_addMethod(cls, OS.sel_keyUp_, proc3, "@:@");
1809 OS.class_addMethod(cls, OS.sel_flagsChanged_, proc3, "@:@"); 1811 OS.class_addMethod(cls, OS.sel_flagsChanged_, proc3, "@:@");
1810 OS.class_addMethod(cls, OS.sel_drawRect_, drawRectProc, "@:{NSRect}"); 1812 OS.class_addMethod(cls, OS.sel_drawRect_, drawRectProc, "@:{NSRect}");
1811 } 1813 }
1812 1814
1813 void addFrameMethods(int /*long*/ cls, int /*long*/ setFrameOriginProc, int /*long*/ setFrameSizeProc) { 1815 void addFrameMethods(objc.Class cls, objc.IMP setFrameOriginProc, objc.IMP setFrameSizeProc) {
1814 OS.class_addMethod(cls, OS.sel_setFrameOrigin_, setFrameOriginProc, "@:{NSPoint}"); 1816 OS.class_addMethod(cls, OS.sel_setFrameOrigin_, setFrameOriginProc, "@:{NSPoint}");
1815 OS.class_addMethod(cls, OS.sel_setFrameSize_, setFrameSizeProc, "@:{NSSize}"); 1817 OS.class_addMethod(cls, OS.sel_setFrameSize_, setFrameSizeProc, "@:{NSSize}");
1816 } 1818 }
1817 1819
1818 void addAccessibilityMethods(int /*long*/ cls, int /*long*/ proc2, int /*long*/ proc3, int /*long*/ proc4, int /*long*/ accessibilityHitTestProc) { 1820 void addAccessibilityMethods(objc.Class cls, objc.IMP proc2, objc.IMP proc3, objc.IMP proc4, objc.IMP accessibilityHitTestProc) {
1819 OS.class_addMethod(cls, OS.sel_accessibilityActionNames, proc2, "@:"); 1821 OS.class_addMethod(cls, OS.sel_accessibilityActionNames, proc2, "@:");
1820 OS.class_addMethod(cls, OS.sel_accessibilityAttributeNames, proc2, "@:"); 1822 OS.class_addMethod(cls, OS.sel_accessibilityAttributeNames, proc2, "@:");
1821 OS.class_addMethod(cls, OS.sel_accessibilityParameterizedAttributeNames, proc2, "@:"); 1823 OS.class_addMethod(cls, OS.sel_accessibilityParameterizedAttributeNames, proc2, "@:");
1822 OS.class_addMethod(cls, OS.sel_accessibilityFocusedUIElement, proc2, "@:"); 1824 OS.class_addMethod(cls, OS.sel_accessibilityFocusedUIElement, proc2, "@:");
1823 OS.class_addMethod(cls, OS.sel_accessibilityIsIgnored, proc2, "@:"); 1825 OS.class_addMethod(cls, OS.sel_accessibilityIsIgnored, proc2, "@:");
1827 OS.class_addMethod(cls, OS.sel_accessibilityAttributeValue_forParameter_, proc4, "@:@@"); 1829 OS.class_addMethod(cls, OS.sel_accessibilityAttributeValue_forParameter_, proc4, "@:@@");
1828 OS.class_addMethod(cls, OS.sel_accessibilityPerformAction_, proc3, "@:@"); 1830 OS.class_addMethod(cls, OS.sel_accessibilityPerformAction_, proc3, "@:@");
1829 OS.class_addMethod(cls, OS.sel_accessibilityActionDescription_, proc3, "@:@"); 1831 OS.class_addMethod(cls, OS.sel_accessibilityActionDescription_, proc3, "@:@");
1830 } 1832 }
1831 1833
1832 int registerCellSubclass(int cellClass, int size, int align, String types) { 1834 objc.Class registerCellSubclass(objc.Class cellClass, int size, int align_, String types) {
1833 String cellClassName = OS.class_getName(cellClass); 1835 String cellClassName = OS.class_getName(cellClass);
1834 int cls = OS.objc_allocateClassPair(cellClass, "DWT" + cellClassName, 0); 1836 objc.Class cls = OS.objc_allocateClassPair(cellClass, "DWT" + cellClassName, 0);
1835 OS.class_addIvar(cls, DWT_OBJECT, size, (byte)align, types); 1837 OS.class_addIvar(cls, SWT_OBJECT, size, cast(byte)align_, types);
1836 OS.objc_registerClassPair(cls); 1838 OS.objc_registerClassPair(cls);
1837 return cls; 1839 return cls;
1838 } 1840 }
1839 1841
1840 void initClasses () { 1842 void initClasses () {
1841 if (OS.objc_lookUpClass ("SWTView") !is null) return; 1843 if (OS.objc_lookUpClass ("SWTView") !is null) return;
1842 1844
1843 Class clazz = getClass (); 1845 objc.IMP dialogProc3 = &dialogProc3;
1844 dialogCallback3 = new Callback(clazz, "dialogProc", 3); 1846 objc.IMP proc3 = &windowDelegateProc3;
1845 int /*long*/ dialogProc3 = dialogCallback3.getAddress(); 1847 objc.IMP proc2 = windowDelegateProc2.getAddress();
1846 if (dialogProc3 is 0) error (DWT.ERROR_NO_MORE_CALLBACKS); 1848 objc.IMP proc4 = windowDelegateProc4.getAddress();
1847 windowDelegateCallback3 = new Callback(clazz, "windowDelegateProc", 3); 1849 objc.IMP proc5 = windowDelegateProc5.getAddress();
1848 int /*long*/ proc3 = windowDelegateCallback3.getAddress(); 1850 objc.IMP proc6 = windowDelegateProc6.getAddress();
1849 1851
1850 objc.IMP drawRectProc = OS.drawRect_CALLBACK(proc3); 1852 objc.IMP drawRectProc = OS.drawRect_CALLBACK(proc3);
1851 int /*long*/ drawInteriorWithFrameInViewProc = OS.drawInteriorWithFrame_inView_CALLBACK (proc4); 1853 objc.IMP drawInteriorWithFrameInViewProc = OS.drawInteriorWithFrame_inView_CALLBACK (proc4);
1852 int /*long*/ setFrameOriginProc = OS.setFrameOrigin_CALLBACK(proc3); 1854 objc.IMP setFrameOriginProc = OS.setFrameOrigin_CALLBACK(proc3);
1853 int /*long*/ setFrameSizeProc = OS.setFrameSize_CALLBACK(proc3); 1855 objc.IMP setFrameSizeProc = OS.setFrameSize_CALLBACK(proc3);
1854 int /*long*/ hitTestProc = OS.hitTest_CALLBACK(proc3); 1856 objc.IMP hitTestProc = OS.hitTest_CALLBACK(proc3);
1855 int /*long*/ markedRangeProc = OS.markedRange_CALLBACK(proc2); 1857 objc.IMP markedRangeProc = OS.markedRange_CALLBACK(proc2);
1856 int /*long*/ selectedRangeProc = OS.selectedRange_CALLBACK(proc2); 1858 objc.IMP selectedRangeProc = OS.selectedRange_CALLBACK(proc2);
1857 int /*long*/ highlightSelectionInClipRectProc = OS.highlightSelectionInClipRect_CALLBACK(proc3); 1859 objc.IMP highlightSelectionInClipRectProc = OS.highlightSelectionInClipRect_CALLBACK(proc3);
1858 int /*long*/ setMarkedText_selectedRangeProc = OS.setMarkedText_selectedRange_CALLBACK(proc4); 1860 objc.IMP setMarkedText_selectedRangeProc = OS.setMarkedText_selectedRange_CALLBACK(proc4);
1859 int /*long*/ attributedSubstringFromRangeProc = OS.attributedSubstringFromRange_CALLBACK(proc3); 1861 objc.IMP attributedSubstringFromRangeProc = OS.attributedSubstringFromRange_CALLBACK(proc3);
1860 int /*long*/ characterIndexForPointProc = OS.characterIndexForPoint_CALLBACK(proc3); 1862 objc.IMP characterIndexForPointProc = OS.characterIndexForPoint_CALLBACK(proc3);
1861 int /*long*/ firstRectForCharacterRangeProc = OS.firstRectForCharacterRange_CALLBACK(proc3); 1863 objc.IMP firstRectForCharacterRangeProc = OS.firstRectForCharacterRange_CALLBACK(proc3);
1862 int /*long*/ textWillChangeSelectionProc = OS.textView_willChangeSelectionFromCharacterRange_toCharacterRange_CALLBACK(proc5); 1864 objc.IMP textWillChangeSelectionProc = OS.textView_willChangeSelectionFromCharacterRange_toCharacterRange_CALLBACK(proc5);
1863 int /*long*/ accessibilityHitTestProc = OS.accessibilityHitTest_CALLBACK(proc3); 1865 objc.IMP accessibilityHitTestProc = OS.accessibilityHitTest_CALLBACK(proc3);
1864 1866
1865 String types = "*"; 1867 String types = "*";
1866 int size = C.PTR_SIZEOF, align = C.PTR_SIZEOF is 4 ? 2 : 3; 1868 size_t size = C.PTR_SIZEOF, align_ = C.PTR_SIZEOF is 4 ? 2 : 3;
1867 1869
1868 String className = "SWTWindowDelegate"; 1870 String className = "SWTWindowDelegate";
1869 int /*long*/ cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0); 1871 objc.Class cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0);
1870 OS.class_addIvar(cls, DWT_OBJECT, size, (byte)align, types); 1872 OS.class_addIvar(cls, SWT_OBJECT, size, cast(byte)align_, types);
1871 OS.class_addMethod(cls, OS.sel_windowDidResize_, proc3, "@:@"); 1873 OS.class_addMethod(cls, OS.sel_windowDidResize_, proc3, "@:@");
1872 OS.class_addMethod(cls, OS.sel_windowDidMove_, proc3, "@:@"); 1874 OS.class_addMethod(cls, OS.sel_windowDidMove_, proc3, "@:@");
1873 OS.class_addMethod(cls, OS.sel_windowShouldClose_, proc3, "@:@"); 1875 OS.class_addMethod(cls, OS.sel_windowShouldClose_, proc3, "@:@");
1874 OS.class_addMethod(cls, OS.sel_windowWillClose_, proc3, "@:@"); 1876 OS.class_addMethod(cls, OS.sel_windowWillClose_, proc3, "@:@");
1875 OS.class_addMethod(cls, OS.sel_windowDidResignKey_, proc3, "@:@"); 1877 OS.class_addMethod(cls, OS.sel_windowDidResignKey_, proc3, "@:@");
1877 OS.class_addMethod(cls, OS.sel_timerProc_, proc3, "@:@"); 1879 OS.class_addMethod(cls, OS.sel_timerProc_, proc3, "@:@");
1878 OS.objc_registerClassPair(cls); 1880 OS.objc_registerClassPair(cls);
1879 1881
1880 className = "SWTPanelDelegate"; 1882 className = "SWTPanelDelegate";
1881 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSObject, className, 0); 1883 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSObject, className, 0);
1882 OS.class_addIvar(cls, DWT_OBJECT, size, (byte)align, types); 1884 OS.class_addIvar(cls, SWT_OBJECT, size, cast(byte)align_, types);
1883 OS.class_addMethod(cls, OS.sel_windowWillClose_, dialogProc3, "@:@"); 1885 OS.class_addMethod(cls, OS.sel_windowWillClose_, dialogProc3, "@:@");
1884 OS.class_addMethod(cls, OS.sel_changeColor_, dialogProc3, "@:@"); 1886 OS.class_addMethod(cls, OS.sel_changeColor_, dialogProc3, "@:@");
1885 OS.class_addMethod(cls, OS.sel_changeFont_, dialogProc3, "@:@"); 1887 OS.class_addMethod(cls, OS.sel_changeFont_, dialogProc3, "@:@");
1886 OS.objc_registerClassPair(cls); 1888 OS.objc_registerClassPair(cls);
1887 1889
1888 className = "SWTMenu"; 1890 className = "SWTMenu";
1889 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSMenu, className, 0); 1891 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSMenu, className, 0);
1890 OS.class_addIvar(cls, DWT_OBJECT, size, (byte)align, types); 1892 OS.class_addIvar(cls, SWT_OBJECT, size, cast(byte)align_, types);
1891 OS.class_addMethod(cls, OS.sel_menuWillOpen_, proc3, "@:@"); 1893 OS.class_addMethod(cls, OS.sel_menuWillOpen_, proc3, "@:@");
1892 OS.class_addMethod(cls, OS.sel_menuDidClose_, proc3, "@:@"); 1894 OS.class_addMethod(cls, OS.sel_menuDidClose_, proc3, "@:@");
1893 OS.class_addMethod(cls, OS.sel_menu_willHighlightItem_, proc4, "@:@@"); 1895 OS.class_addMethod(cls, OS.sel_menu_willHighlightItem_, proc4, "@:@@");
1894 OS.class_addMethod(cls, OS.sel_menuNeedsUpdate_, proc3, "@:@"); 1896 OS.class_addMethod(cls, OS.sel_menuNeedsUpdate_, proc3, "@:@");
1895 OS.objc_registerClassPair(cls); 1897 OS.objc_registerClassPair(cls);
1896 1898
1897 className = "SWTView"; 1899 className = "SWTView";
1898 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSView, className, 0); 1900 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSView, className, 0);
1899 OS.class_addProtocol(cls, OS.objc_getProtocol("NSTextInput")); 1901 OS.class_addProtocol(cls, OS.objc_getProtocol("NSTextInput"));
1900 OS.class_addIvar(cls, DWT_OBJECT, size, (byte)align, types); 1902 OS.class_addIvar(cls, SWT_OBJECT, size, cast(byte)align_, types);
1901 OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:"); 1903 OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
1902 OS.class_addMethod(cls, OS.sel_acceptsFirstResponder, proc2, "@:"); 1904 OS.class_addMethod(cls, OS.sel_acceptsFirstResponder, proc2, "@:");
1903 OS.class_addMethod(cls, OS.sel_isOpaque, proc2, "@:"); 1905 OS.class_addMethod(cls, OS.sel_isOpaque, proc2, "@:");
1904 OS.class_addMethod(cls, OS.sel_hitTest_, hitTestProc, "@:{NSPoint}"); 1906 OS.class_addMethod(cls, OS.sel_hitTest_, hitTestProc, "@:{NSPoint}");
1905 1907
1921 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc); 1923 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
1922 OS.objc_registerClassPair(cls); 1924 OS.objc_registerClassPair(cls);
1923 1925
1924 className = "SWTScrollView"; 1926 className = "SWTScrollView";
1925 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSScrollView, className, 0); 1927 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSScrollView, className, 0);
1926 OS.class_addIvar(cls, DWT_OBJECT, size, (byte)align, types); 1928 OS.class_addIvar(cls, SWT_OBJECT, size, cast(byte)align_, types);
1927 OS.class_addMethod(cls, OS.sel_sendVerticalSelection, proc2, "@:"); 1929 OS.class_addMethod(cls, OS.sel_sendVerticalSelection, proc2, "@:");
1928 OS.class_addMethod(cls, OS.sel_sendHorizontalSelection, proc2, "@:"); 1930 OS.class_addMethod(cls, OS.sel_sendHorizontalSelection, proc2, "@:");
1929 OS.class_addMethod(cls, OS.sel_pageDown_, proc3, "@:@"); 1931 OS.class_addMethod(cls, OS.sel_pageDown_, proc3, "@:@");
1930 OS.class_addMethod(cls, OS.sel_pageUp_, proc3, "@:@"); 1932 OS.class_addMethod(cls, OS.sel_pageUp_, proc3, "@:@");
1931 OS.class_addMethod(cls, OS.sel_reflectScrolledClipView_, proc3, "@:@"); 1933 OS.class_addMethod(cls, OS.sel_reflectScrolledClipView_, proc3, "@:@");
1934 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc); 1936 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
1935 OS.objc_registerClassPair(cls); 1937 OS.objc_registerClassPair(cls);
1936 1938
1937 className = "SWTButton"; 1939 className = "SWTButton";
1938 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSButton, className, 0); 1940 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSButton, className, 0);
1939 OS.class_addIvar(cls, DWT_OBJECT, size, (byte)align, types); 1941 OS.class_addIvar(cls, SWT_OBJECT, size, cast(byte)align_, types);
1940 OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:"); 1942 OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
1941 addEventMethods(cls, proc2, proc3, drawRectProc); 1943 addEventMethods(cls, proc2, proc3, drawRectProc);
1942 addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc); 1944 addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
1943 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc); 1945 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
1944 OS.objc_registerClassPair(cls); 1946 OS.objc_registerClassPair(cls);
1945 1947
1946 cls = registerCellSubclass(NSButton.cellClass(), size, align, types); 1948 cls = registerCellSubclass(NSButton.cellClass(), size, align_, types);
1947 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc); 1949 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
1948 NSButton.setCellClass(cls); 1950 NSButton.setCellClass(cls);
1949 1951
1950 className = "SWTTableView"; 1952 className = "SWTTableView";
1951 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSTableView, className, 0); 1953 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSTableView, className, 0);
1952 OS.class_addIvar(cls, DWT_OBJECT, size, (byte)align, types); 1954 OS.class_addIvar(cls, SWT_OBJECT, size, cast(byte)align_, types);
1953 OS.class_addMethod(cls, OS.sel_highlightSelectionInClipRect_, highlightSelectionInClipRectProc, "@:{NSRect}"); 1955 OS.class_addMethod(cls, OS.sel_highlightSelectionInClipRect_, highlightSelectionInClipRectProc, "@:{NSRect}");
1954 OS.class_addMethod(cls, OS.sel_sendDoubleSelection, proc2, "@:"); 1956 OS.class_addMethod(cls, OS.sel_sendDoubleSelection, proc2, "@:");
1955 OS.class_addMethod(cls, OS.sel_numberOfRowsInTableView_, proc3, "@:@"); 1957 OS.class_addMethod(cls, OS.sel_numberOfRowsInTableView_, proc3, "@:@");
1956 OS.class_addMethod(cls, OS.sel_tableView_objectValueForTableColumn_row_, proc5, "@:@:@:@"); 1958 OS.class_addMethod(cls, OS.sel_tableView_objectValueForTableColumn_row_, proc5, "@:@:@:@");
1957 OS.class_addMethod(cls, OS.sel_tableView_shouldEditTableColumn_row_, proc5, "@:@:@:@"); 1959 OS.class_addMethod(cls, OS.sel_tableView_shouldEditTableColumn_row_, proc5, "@:@:@:@");
1966 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc); 1968 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
1967 OS.objc_registerClassPair(cls); 1969 OS.objc_registerClassPair(cls);
1968 1970
1969 className = "SWTTableHeaderCell"; 1971 className = "SWTTableHeaderCell";
1970 cls = OS.objc_allocateClassPair (OS.class_NSTableHeaderCell, className, 0); 1972 cls = OS.objc_allocateClassPair (OS.class_NSTableHeaderCell, className, 0);
1971 OS.class_addIvar (cls, DWT_OBJECT, size, (byte)align, types); 1973 OS.class_addIvar (cls, SWT_OBJECT, size, cast(byte)align_, types);
1972 OS.class_addMethod (cls, OS.sel_drawInteriorWithFrame_inView_, drawInteriorWithFrameInViewProc, "@:{NSRect}@"); 1974 OS.class_addMethod (cls, OS.sel_drawInteriorWithFrame_inView_, drawInteriorWithFrameInViewProc, "@:{NSRect}@");
1973 OS.objc_registerClassPair (cls); 1975 OS.objc_registerClassPair (cls);
1974 1976
1975 className = "SWTBrowserCell"; 1977 className = "SWTBrowserCell";
1976 cls = OS.objc_allocateClassPair (OS.class_NSBrowserCell, className, 0); 1978 cls = OS.objc_allocateClassPair (OS.class_NSBrowserCell, className, 0);
1977 OS.class_addIvar (cls, DWT_OBJECT, size, (byte)align, types); 1979 OS.class_addIvar (cls, SWT_OBJECT, size, cast(byte)align_, types);
1978 OS.class_addMethod (cls, OS.sel_drawInteriorWithFrame_inView_, drawInteriorWithFrameInViewProc, "@:{NSRect}@"); 1980 OS.class_addMethod (cls, OS.sel_drawInteriorWithFrame_inView_, drawInteriorWithFrameInViewProc, "@:{NSRect}@");
1979 OS.objc_registerClassPair (cls); 1981 OS.objc_registerClassPair (cls);
1980 1982
1981 className = "SWTTableHeaderView"; 1983 className = "SWTTableHeaderView";
1982 cls = OS.objc_allocateClassPair(OS.class_NSTableHeaderView, className, 0); 1984 cls = OS.objc_allocateClassPair(OS.class_NSTableHeaderView, className, 0);
1983 OS.class_addIvar(cls, DWT_OBJECT, size, (byte)align, types); 1985 OS.class_addIvar(cls, SWT_OBJECT, size, cast(byte)align_, types);
1984 OS.class_addMethod(cls, OS.sel_mouseDown_, proc3, "@:@"); 1986 OS.class_addMethod(cls, OS.sel_mouseDown_, proc3, "@:@");
1985 OS.objc_registerClassPair(cls); 1987 OS.objc_registerClassPair(cls);
1986 1988
1987 className = "SWTOutlineView"; 1989 className = "SWTOutlineView";
1988 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSOutlineView, className, 0); 1990 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSOutlineView, className, 0);
1989 OS.class_addIvar(cls, DWT_OBJECT, size, (byte)align, types); 1991 OS.class_addIvar(cls, SWT_OBJECT, size, cast(byte)align_, types);
1990 OS.class_addMethod(cls, OS.sel_highlightSelectionInClipRect_, highlightSelectionInClipRectProc, "@:{NSRect}"); 1992 OS.class_addMethod(cls, OS.sel_highlightSelectionInClipRect_, highlightSelectionInClipRectProc, "@:{NSRect}");
1991 OS.class_addMethod(cls, OS.sel_sendDoubleSelection, proc2, "@:"); 1993 OS.class_addMethod(cls, OS.sel_sendDoubleSelection, proc2, "@:");
1992 OS.class_addMethod(cls, OS.sel_outlineViewSelectionDidChange_, proc3, "@:@"); 1994 OS.class_addMethod(cls, OS.sel_outlineViewSelectionDidChange_, proc3, "@:@");
1993 OS.class_addMethod(cls, OS.sel_outlineViewItemDidExpand_, proc3, "@:@"); 1995 OS.class_addMethod(cls, OS.sel_outlineViewItemDidExpand_, proc3, "@:@");
1994 OS.class_addMethod(cls, OS.sel_outlineView_shouldCollapseItem_, proc4, "@:@@"); 1996 OS.class_addMethod(cls, OS.sel_outlineView_shouldCollapseItem_, proc4, "@:@@");
2007 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc); 2009 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
2008 OS.objc_registerClassPair(cls); 2010 OS.objc_registerClassPair(cls);
2009 2011
2010 className = "SWTTreeItem"; 2012 className = "SWTTreeItem";
2011 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSObject, className, 0); 2013 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSObject, className, 0);
2012 OS.class_addIvar(cls, DWT_OBJECT, size, (byte)align, types); 2014 OS.class_addIvar(cls, SWT_OBJECT, size, cast(byte)align_, types);
2013 OS.objc_registerClassPair(cls); 2015 OS.objc_registerClassPair(cls);
2014 2016
2015 className = "SWTTabView"; 2017 className = "SWTTabView";
2016 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSTabView, className, 0); 2018 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSTabView, className, 0);
2017 OS.class_addIvar(cls, DWT_OBJECT, size, (byte)align, types); 2019 OS.class_addIvar(cls, SWT_OBJECT, size, cast(byte)align_, types);
2018 OS.class_addMethod(cls, OS.sel_tabView_willSelectTabViewItem_, proc4, "@:@@"); 2020 OS.class_addMethod(cls, OS.sel_tabView_willSelectTabViewItem_, proc4, "@:@@");
2019 OS.class_addMethod(cls, OS.sel_tabView_didSelectTabViewItem_, proc4, "@:@@"); 2021 OS.class_addMethod(cls, OS.sel_tabView_didSelectTabViewItem_, proc4, "@:@@");
2020 addEventMethods(cls, proc2, proc3, drawRectProc); 2022 addEventMethods(cls, proc2, proc3, drawRectProc);
2021 addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc); 2023 addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
2022 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc); 2024 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
2023 OS.objc_registerClassPair(cls); 2025 OS.objc_registerClassPair(cls);
2024 2026
2025 className = "SWTBox"; 2027 className = "SWTBox";
2026 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSBox, className, 0); 2028 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSBox, className, 0);
2027 OS.class_addIvar(cls, DWT_OBJECT, size, (byte)align, types); 2029 OS.class_addIvar(cls, SWT_OBJECT, size, cast(byte)align_, types);
2028 addEventMethods(cls, proc2, proc3, drawRectProc); 2030 addEventMethods(cls, proc2, proc3, drawRectProc);
2029 addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc); 2031 addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
2030 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc); 2032 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
2031 OS.objc_registerClassPair(cls); 2033 OS.objc_registerClassPair(cls);
2032 2034
2033 className = "SWTProgressIndicator"; 2035 className = "SWTProgressIndicator";
2034 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSProgressIndicator, className, 0); 2036 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSProgressIndicator, className, 0);
2035 OS.class_addIvar(cls, DWT_OBJECT, size, (byte)align, types); 2037 OS.class_addIvar(cls, SWT_OBJECT, size, cast(byte)align_, types);
2036 addEventMethods(cls, proc2, proc3, drawRectProc); 2038 addEventMethods(cls, proc2, proc3, drawRectProc);
2037 addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc); 2039 addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
2038 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc); 2040 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
2039 OS.objc_registerClassPair(cls); 2041 OS.objc_registerClassPair(cls);
2040 2042
2041 className = "SWTSlider"; 2043 className = "SWTSlider";
2042 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSSlider, className, 0); 2044 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSSlider, className, 0);
2043 OS.class_addIvar(cls, DWT_OBJECT, size, (byte)align, types); 2045 OS.class_addIvar(cls, SWT_OBJECT, size, cast(byte)align_, types);
2044 addEventMethods(cls, proc2, proc3, drawRectProc); 2046 addEventMethods(cls, proc2, proc3, drawRectProc);
2045 addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc); 2047 addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
2046 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc); 2048 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
2047 OS.objc_registerClassPair(cls); 2049 OS.objc_registerClassPair(cls);
2048 2050
2049 cls = registerCellSubclass(NSSlider.cellClass(), size, align, types); 2051 cls = registerCellSubclass(NSSlider.cellClass(), size, align_, types);
2050 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc); 2052 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
2051 NSSlider.setCellClass(cls); 2053 NSSlider.setCellClass(cls);
2052 2054
2053 className = "SWTPopUpButton"; 2055 className = "SWTPopUpButton";
2054 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSPopUpButton, className, 0); 2056 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSPopUpButton, className, 0);
2055 OS.class_addIvar(cls, DWT_OBJECT, size, (byte)align, types); 2057 OS.class_addIvar(cls, SWT_OBJECT, size, cast(byte)align_, types);
2056 OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:"); 2058 OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
2057 addEventMethods(cls, proc2, proc3, drawRectProc); 2059 addEventMethods(cls, proc2, proc3, drawRectProc);
2058 addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc); 2060 addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
2059 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc); 2061 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
2060 OS.objc_registerClassPair(cls); 2062 OS.objc_registerClassPair(cls);
2061 2063
2062 cls = registerCellSubclass(NSPopUpButton.cellClass(), size, align, types); 2064 cls = registerCellSubclass(NSPopUpButton.cellClass(), size, align_, types);
2063 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc); 2065 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
2064 NSPopUpButton.setCellClass(cls); 2066 NSPopUpButton.setCellClass(cls);
2065 2067
2066 className = "SWTComboBox"; 2068 className = "SWTComboBox";
2067 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSComboBox, className, 0); 2069 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSComboBox, className, 0);
2068 OS.class_addIvar(cls, DWT_OBJECT, size, (byte)align, types); 2070 OS.class_addIvar(cls, SWT_OBJECT, size, cast(byte)align_, types);
2069 OS.class_addMethod(cls, OS.sel_comboBoxSelectionDidChange_, proc3, "@:@"); 2071 OS.class_addMethod(cls, OS.sel_comboBoxSelectionDidChange_, proc3, "@:@");
2070 OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:"); 2072 OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
2071 OS.class_addMethod(cls, OS.sel_textDidChange_, proc3, "@:@"); 2073 OS.class_addMethod(cls, OS.sel_textDidChange_, proc3, "@:@");
2072 OS.class_addMethod(cls, OS.sel_textViewDidChangeSelection_, proc3, "@:@"); 2074 OS.class_addMethod(cls, OS.sel_textViewDidChangeSelection_, proc3, "@:@");
2073 OS.class_addMethod(cls, OS.sel_textView_willChangeSelectionFromCharacterRange_toCharacterRange_, textWillChangeSelectionProc, "@:@{NSRange}{NSRange}"); 2075 OS.class_addMethod(cls, OS.sel_textView_willChangeSelectionFromCharacterRange_toCharacterRange_, textWillChangeSelectionProc, "@:@{NSRange}{NSRange}");
2074 addEventMethods(cls, proc2, proc3, drawRectProc); 2076 addEventMethods(cls, proc2, proc3, drawRectProc);
2075 addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc); 2077 addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
2076 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc); 2078 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
2077 OS.objc_registerClassPair(cls); 2079 OS.objc_registerClassPair(cls);
2078 2080
2079 cls = registerCellSubclass(NSComboBox.cellClass(), size, align, types); 2081 cls = registerCellSubclass(NSComboBox.cellClass(), size, align_, types);
2080 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc); 2082 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
2081 NSComboBox.setCellClass(cls); 2083 NSComboBox.setCellClass(cls);
2082 2084
2083 className = "SWTDatePicker"; 2085 className = "SWTDatePicker";
2084 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSDatePicker, className, 0); 2086 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSDatePicker, className, 0);
2085 OS.class_addIvar(cls, DWT_OBJECT, size, (byte)align, types); 2087 OS.class_addIvar(cls, SWT_OBJECT, size, cast(byte)align_, types);
2086 OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:"); 2088 OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
2087 addEventMethods(cls, proc2, proc3, drawRectProc); 2089 addEventMethods(cls, proc2, proc3, drawRectProc);
2088 addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc); 2090 addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
2089 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc); 2091 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
2090 OS.objc_registerClassPair(cls); 2092 OS.objc_registerClassPair(cls);
2091 2093
2092 className = "SWTImageView"; 2094 className = "SWTImageView";
2093 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSImageView, className, 0); 2095 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSImageView, className, 0);
2094 OS.class_addIvar(cls, DWT_OBJECT, size, (byte)align, types); 2096 OS.class_addIvar(cls, SWT_OBJECT, size, cast(byte)align_, types);
2095 addEventMethods(cls, proc2, proc3, drawRectProc); 2097 addEventMethods(cls, proc2, proc3, drawRectProc);
2096 addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc); 2098 addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
2097 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc); 2099 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
2098 OS.objc_registerClassPair(cls); 2100 OS.objc_registerClassPair(cls);
2099 2101
2100 cls = registerCellSubclass(NSImageView.cellClass(), size, align, types); 2102 cls = registerCellSubclass(NSImageView.cellClass(), size, align_, types);
2101 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc); 2103 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
2102 NSImageView.setCellClass(cls); 2104 NSImageView.setCellClass(cls);
2103 2105
2104 className = "SWTStepper"; 2106 className = "SWTStepper";
2105 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSStepper, className, 0); 2107 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSStepper, className, 0);
2106 OS.class_addIvar(cls, DWT_OBJECT, size, (byte)align, types); 2108 OS.class_addIvar(cls, SWT_OBJECT, size, cast(byte)align_, types);
2107 OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:"); 2109 OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
2108 addEventMethods(cls, proc2, proc3, drawRectProc); 2110 addEventMethods(cls, proc2, proc3, drawRectProc);
2109 addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc); 2111 addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
2110 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc); 2112 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
2111 OS.objc_registerClassPair(cls); 2113 OS.objc_registerClassPair(cls);
2112 2114
2113 cls = registerCellSubclass(NSStepper.cellClass(), size, align, types); 2115 cls = registerCellSubclass(NSStepper.cellClass(), size, align_, types);
2114 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc); 2116 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
2115 NSStepper.setCellClass(cls); 2117 NSStepper.setCellClass(cls);
2116 2118
2117 className = "SWTScroller"; 2119 className = "SWTScroller";
2118 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSScroller, className, 0); 2120 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSScroller, className, 0);
2119 OS.class_addIvar(cls, DWT_OBJECT, size, (byte)align, types); 2121 OS.class_addIvar(cls, SWT_OBJECT, size, cast(byte)align_, types);
2120 OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:"); 2122 OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
2121 addEventMethods(cls, proc2, proc3, drawRectProc); 2123 addEventMethods(cls, proc2, proc3, drawRectProc);
2122 addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc); 2124 addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
2123 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc); 2125 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
2124 OS.objc_registerClassPair(cls); 2126 OS.objc_registerClassPair(cls);
2125 2127
2126 className = "SWTMenuItem"; 2128 className = "SWTMenuItem";
2127 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSMenuItem, className, 0); 2129 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSMenuItem, className, 0);
2128 OS.class_addIvar(cls, DWT_OBJECT, size, (byte)align, types); 2130 OS.class_addIvar(cls, SWT_OBJECT, size, cast(byte)align_, types);
2129 OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:"); 2131 OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
2130 OS.objc_registerClassPair(cls); 2132 OS.objc_registerClassPair(cls);
2131 2133
2132 className = "SWTTextView"; 2134 className = "SWTTextView";
2133 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSTextView, className, 0); 2135 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSTextView, className, 0);
2134 OS.class_addIvar(cls, DWT_OBJECT, size, (byte)align, types); 2136 OS.class_addIvar(cls, SWT_OBJECT, size, cast(byte)align_, types);
2135 addEventMethods(cls, proc2, proc3, drawRectProc); 2137 addEventMethods(cls, proc2, proc3, drawRectProc);
2136 addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc); 2138 addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
2137 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc); 2139 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
2138 OS.class_addMethod(cls, OS.sel_insertText_, proc3, "@:@"); 2140 OS.class_addMethod(cls, OS.sel_insertText_, proc3, "@:@");
2139 OS.class_addMethod(cls, OS.sel_doCommandBySelector_, proc3, "@::"); 2141 OS.class_addMethod(cls, OS.sel_doCommandBySelector_, proc3, "@::");
2149 OS.class_addMethod(cls, OS.sel_doCommandBySelector_, proc3, "@::"); 2151 OS.class_addMethod(cls, OS.sel_doCommandBySelector_, proc3, "@::");
2150 OS.objc_registerClassPair(cls); 2152 OS.objc_registerClassPair(cls);
2151 2153
2152 className = "SWTTextField"; 2154 className = "SWTTextField";
2153 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSTextField, className, 0); 2155 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSTextField, className, 0);
2154 OS.class_addIvar(cls, DWT_OBJECT, size, (byte)align, types); 2156 OS.class_addIvar(cls, SWT_OBJECT, size, cast(byte)align_, types);
2155 addEventMethods(cls, proc2, proc3, drawRectProc); 2157 addEventMethods(cls, proc2, proc3, drawRectProc);
2156 addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc); 2158 addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
2157 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc); 2159 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
2158 OS.class_addMethod(cls, OS.sel_textDidChange_, proc3, "@:@"); 2160 OS.class_addMethod(cls, OS.sel_textDidChange_, proc3, "@:@");
2159 OS.class_addMethod(cls, OS.sel_textViewDidChangeSelection_, proc3, "@:@"); 2161 OS.class_addMethod(cls, OS.sel_textViewDidChangeSelection_, proc3, "@:@");
2160 OS.class_addMethod(cls, OS.sel_textView_willChangeSelectionFromCharacterRange_toCharacterRange_, textWillChangeSelectionProc, "@:@{NSRange}{NSRange}"); 2162 OS.class_addMethod(cls, OS.sel_textView_willChangeSelectionFromCharacterRange_toCharacterRange_, textWillChangeSelectionProc, "@:@{NSRange}{NSRange}");
2161 OS.objc_registerClassPair(cls); 2163 OS.objc_registerClassPair(cls);
2162 2164
2163 cls = registerCellSubclass(NSTextField.cellClass(), size, align, types); 2165 cls = registerCellSubclass(NSTextField.cellClass(), size, align_, types);
2164 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc); 2166 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
2165 NSTextField.setCellClass(cls); 2167 NSTextField.setCellClass(cls);
2166 2168
2167 className = "SWTSearchField"; 2169 className = "SWTSearchField";
2168 cls = OS.objc_allocateClassPair(OS.class_NSSearchField, className, 0); 2170 cls = OS.objc_allocateClassPair(OS.class_NSSearchField, className, 0);
2169 OS.class_addIvar(cls, DWT_OBJECT, size, (byte)align, types); 2171 OS.class_addIvar(cls, SWT_OBJECT, size, cast(byte)align_, types);
2170 addEventMethods(cls, proc2, proc3, drawRectProc); 2172 addEventMethods(cls, proc2, proc3, drawRectProc);
2171 addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc); 2173 addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
2172 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc); 2174 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
2173 OS.class_addMethod(cls, OS.sel_textDidChange_, proc3, "@:@"); 2175 OS.class_addMethod(cls, OS.sel_textDidChange_, proc3, "@:@");
2174 OS.class_addMethod(cls, OS.sel_textViewDidChangeSelection_, proc3, "@:@"); 2176 OS.class_addMethod(cls, OS.sel_textViewDidChangeSelection_, proc3, "@:@");
2175 OS.class_addMethod(cls, OS.sel_textView_willChangeSelectionFromCharacterRange_toCharacterRange_, textWillChangeSelectionProc, "@:@{NSRange}{NSRange}"); 2177 OS.class_addMethod(cls, OS.sel_textView_willChangeSelectionFromCharacterRange_toCharacterRange_, textWillChangeSelectionProc, "@:@{NSRange}{NSRange}");
2176 OS.objc_registerClassPair(cls); 2178 OS.objc_registerClassPair(cls);
2177 2179
2178 cls = registerCellSubclass(NSSearchField.cellClass(), size, align, types); 2180 cls = registerCellSubclass(NSSearchField.cellClass(), size, align_, types);
2179 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc); 2181 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
2180 NSSearchField.setCellClass(cls); 2182 NSSearchField.setCellClass(cls);
2181 2183
2182 className = "SWTSecureTextField"; 2184 className = "SWTSecureTextField";
2183 cls = OS.objc_allocateClassPair(OS.class_NSSecureTextField, className, 0); 2185 cls = OS.objc_allocateClassPair(OS.class_NSSecureTextField, className, 0);
2184 OS.class_addIvar(cls, DWT_OBJECT, size, (byte)align, types); 2186 OS.class_addIvar(cls, SWT_OBJECT, size, cast(byte)align_, types);
2185 addEventMethods(cls, proc2, proc3, drawRectProc); 2187 addEventMethods(cls, proc2, proc3, drawRectProc);
2186 addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc); 2188 addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
2187 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc); 2189 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
2188 OS.class_addMethod(cls, OS.sel_textDidChange_, proc3, "@:@"); 2190 OS.class_addMethod(cls, OS.sel_textDidChange_, proc3, "@:@");
2189 OS.class_addMethod(cls, OS.sel_textViewDidChangeSelection_, proc3, "@:@"); 2191 OS.class_addMethod(cls, OS.sel_textViewDidChangeSelection_, proc3, "@:@");
2192 2194
2193 // Don't subclass NSSecureTextFieldCell -- you'll get an NSException from [NSSecureTextField setCellClass:]! 2195 // Don't subclass NSSecureTextFieldCell -- you'll get an NSException from [NSSecureTextField setCellClass:]!
2194 2196
2195 className = "SWTWindow"; 2197 className = "SWTWindow";
2196 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSWindow, className, 0); 2198 cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSWindow, className, 0);
2197 OS.class_addIvar(cls, DWT_OBJECT, size, (byte)align, types); 2199 OS.class_addIvar(cls, SWT_OBJECT, size, cast(byte)align_, types);
2198 OS.class_addMethod(cls, OS.sel_sendEvent_, proc3, "@:@"); 2200 OS.class_addMethod(cls, OS.sel_sendEvent_, proc3, "@:@");
2199 OS.class_addMethod(cls, OS.sel_helpRequested_, proc3, "@:@"); 2201 OS.class_addMethod(cls, OS.sel_helpRequested_, proc3, "@:@");
2200 OS.class_addMethod(cls, OS.sel_canBecomeKeyWindow, proc2, "@:"); 2202 OS.class_addMethod(cls, OS.sel_canBecomeKeyWindow, proc2, "@:");
2201 OS.class_addMethod(cls, OS.sel_makeFirstResponder_, proc3, "@:@"); 2203 OS.class_addMethod(cls, OS.sel_makeFirstResponder_, proc3, "@:@");
2202 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc); 2204 addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
2224 * </ul> 2226 * </ul>
2225 */ 2227 */
2226 public objc.id internal_new_GC (GCData data) { 2228 public objc.id internal_new_GC (GCData data) {
2227 if (isDisposed()) DWT.error(DWT.ERROR_DEVICE_DISPOSED); 2229 if (isDisposed()) DWT.error(DWT.ERROR_DEVICE_DISPOSED);
2228 if (screenWindow is null) { 2230 if (screenWindow is null) {
2229 NSWindow window = (NSWindow) new NSWindow ().alloc (); 2231 NSWindow window = cast(NSWindow) (new NSWindow ()).alloc ();
2230 NSRect rect = new NSRect(); 2232 NSRect rect = NSRect();
2231 window = window.initWithContentRect(rect, OS.NSBorderlessWindowMask, OS.NSBackingStoreBuffered, false); 2233 window = window.initWithContentRect(rect, OS.NSBorderlessWindowMask, OS.NSBackingStoreBuffered, false);
2232 window.setReleasedWhenClosed(false); 2234 window.setReleasedWhenClosed(false);
2233 screenWindow = window; 2235 screenWindow = window;
2234 } 2236 }
2235 NSGraphicsContext context = screenWindow.graphicsContext(); 2237 NSGraphicsContext context = screenWindow.graphicsContext();
2722 */ 2724 */
2723 public bool readAndDispatch () { 2725 public bool readAndDispatch () {
2724 checkDevice (); 2726 checkDevice ();
2725 if (loopCounter is 0) { 2727 if (loopCounter is 0) {
2726 pool.release(); 2728 pool.release();
2727 pool = (NSAutoreleasePool)new NSAutoreleasePool().alloc().init(); 2729 pool = cast(NSAutoreleasePool)(new NSAutoreleasePool()).alloc().init();
2728 } 2730 }
2729 loopCounter ++; 2731 loopCounter ++;
2730 bool events = false; 2732 bool events = false;
2731 events |= runTimers (); 2733 events |= runTimers ();
2732 events |= runContexts (); 2734 events |= runContexts ();
2736 try { 2738 try {
2737 if (event !is null) { 2739 if (event !is null) {
2738 events = true; 2740 events = true;
2739 application.sendEvent(event); 2741 application.sendEvent(event);
2740 } 2742 }
2741 // NSEvent event = NSEvent.otherEventWithType(OS.NSApplicationDefined, new NSPoint(), 0, 0, 0, null, DWT_IDLE_TYPE, 0, 0); 2743 // NSEvent event = NSEvent.otherEventWithType(OS.NSApplicationDefined, NSPoint(), 0, 0, 0, null, DWT_IDLE_TYPE, 0, 0);
2742 // application.postEvent(event, false); 2744 // application.postEvent(event, false);
2743 // idle = true; 2745 // idle = true;
2744 // application.run(); 2746 // application.run();
2745 // events |= !idle; 2747 // events |= !idle;
2746 if (events) { 2748 if (events) {
2949 } 2951 }
2950 2952
2951 Widget removeWidget (NSObject view) { 2953 Widget removeWidget (NSObject view) {
2952 if (view is null) return null; 2954 if (view is null) return null;
2953 int /*long*/ [] jniRef = new int /*long*/ [1]; 2955 int /*long*/ [] jniRef = new int /*long*/ [1];
2954 OS.object_getInstanceVariable(view.id, DWT_OBJECT, jniRef); 2956 OS.object_getInstanceVariable(view.id, SWT_OBJECT, jniRef);
2955 if (jniRef[0] is 0) return null; 2957 if (jniRef[0] is 0) return null;
2956 Widget widget = (Widget)OS.JNIGetObject(jniRef[0]); 2958 Widget widget = cast(Widget)OS.JNIGetObject(jniRef[0]);
2957 OS.object_setInstanceVariable(view.id, DWT_OBJECT, 0); 2959 OS.object_setInstanceVariable(view.id, SWT_OBJECT, 0);
2958 return widget; 2960 return widget;
2959 } 2961 }
2960 2962
2961 void removeMenu (Menu menu) { 2963 void removeMenu (Menu menu) {
2962 if (menus is null) return; 2964 if (menus is null) return;
3086 public static void setAppName (String name) { 3088 public static void setAppName (String name) {
3087 APP_NAME = name; 3089 APP_NAME = name;
3088 } 3090 }
3089 3091
3090 //TODO use custom timer instead of timerExec 3092 //TODO use custom timer instead of timerExec
3091 Runnable hoverTimer = new Runnable () { 3093 Runnable hoverTimer;
3092 public void run () { 3094
3093 if (currentControl !is null && !currentControl.isDisposed()) {
3094 currentControl.sendMouseEvent (null, DWT.MouseHover, trackingControl !is null);
3095 }
3096 }
3097 };
3098 //TODO - use custom timer instead of timerExec 3095 //TODO - use custom timer instead of timerExec
3099 Runnable caretTimer; 3096 Runnable caretTimer;
3100 3097
3101 void setCurrentCaret (Caret caret) { 3098 void setCurrentCaret (Caret caret) {
3102 // if (caretID !is 0) OS.RemoveEventLoopTimer (caretID); 3099 // if (caretID !is 0) OS.RemoveEventLoopTimer (caretID);
3186 public void setData (String key, Object value) { 3183 public void setData (String key, Object value) {
3187 checkDevice (); 3184 checkDevice ();
3188 //if (key is null) error (DWT.ERROR_NULL_ARGUMENT); 3185 //if (key is null) error (DWT.ERROR_NULL_ARGUMENT);
3189 3186
3190 if (key.equals (ADD_WIDGET_KEY)) { 3187 if (key.equals (ADD_WIDGET_KEY)) {
3191 Object [] data = (Object [])value; 3188 Object [] data = cast(Object [])value;
3192 NSObject object = (NSObject)data [0]; 3189 NSObject object = cast(NSObject)data [0];
3193 Widget widget = (Widget)data [1]; 3190 Widget widget = cast(Widget)data [1];
3194 if (widget is null) { 3191 if (widget is null) {
3195 removeWidget (object); 3192 removeWidget (object);
3196 } else { 3193 } else {
3197 addWidget (object, widget); 3194 addWidget (object, widget);
3198 } 3195 }
3556 } 3553 }
3557 Control control = null; 3554 Control control = null;
3558 if (view !is null) { 3555 if (view !is null) {
3559 do { 3556 do {
3560 Widget widget = getWidget (view); 3557 Widget widget = getWidget (view);
3561 if (widget instanceof Control) { 3558 if (cast(Control) widget) {
3562 control = (Control)widget; 3559 control = cast(Control)widget;
3563 break; 3560 break;
3564 } 3561 }
3565 view = view.superview(); 3562 view = view.superview();
3566 } while (view !is null); 3563 } while (view !is null);
3567 } 3564 }
3569 if (control !is null && control.isTrim (view)) control = null; 3566 if (control !is null && control.isTrim (view)) control = null;
3570 } 3567 }
3571 return control; 3568 return control;
3572 } 3569 }
3573 3570
3574 int /*long*/ applicationNextEventMatchingMask (int /*long*/ id, int /*long*/ sel, int /*long*/ mask, int /*long*/ expiration, int /*long*/ mode, int /*long*/ dequeue) { 3571 objc.id applicationNextEventMatchingMask (objc.id id, objc.SEL sel, objc.id mask, objc.id expiration, objc.id mode, objc.id dequeue) {
3575 objc_super super_struct = new objc_super(); 3572 objc_super super_struct = objc_super();
3576 super_struct.receiver = id; 3573 super_struct.receiver = id;
3577 super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass); 3574 super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass);
3578 int /*long*/ result = OS.objc_msgSendSuper(super_struct, sel, mask, expiration, mode, dequeue !is 0); 3575 objc.id result = OS.objc_msgSendSuper(super_struct, sel, mask, expiration, mode, dequeue !is null);
3579 if (result !is 0) { 3576 if (result !is null) {
3580 if (trackingControl !is null && dequeue !is 0) { 3577 if (trackingControl !is null && dequeue !is null) {
3581 NSEvent nsEvent = new NSEvent(result); 3578 NSEvent nsEvent = new NSEvent(result);
3582 applicationSendMouseEvent(nsEvent, true); 3579 applicationSendMouseEvent(nsEvent, true);
3583 } 3580 }
3584 } 3581 }
3585 return result; 3582 return result;
3586 } 3583 }
3587 3584
3588 void applicationSendMouseEvent (NSEvent nsEvent, bool send) { 3585 void applicationSendMouseEvent (NSEvent nsEvent, bool send) {
3589 if (send) runDeferredEvents(); 3586 if (send) runDeferredEvents();
3590 bool up = false; 3587 bool up = false;
3591 int type = (int)/*64*/nsEvent.type(); 3588 int type = cast(int)/*64*/nsEvent.type();
3592 switch (type) { 3589 switch (type) {
3593 case OS.NSLeftMouseDown: 3590 case OS.NSLeftMouseDown:
3594 case OS.NSRightMouseDown: 3591 case OS.NSRightMouseDown:
3595 case OS.NSOtherMouseDown: { 3592 case OS.NSOtherMouseDown: {
3596 Control control = grabControl = findControl(nsEvent, false, true, false); 3593 Control control = grabControl = findControl(nsEvent, false, true, false);
3643 break; 3640 break;
3644 } 3641 }
3645 } 3642 }
3646 } 3643 }
3647 3644
3648 void applicationSendEvent (int /*long*/ id, int /*long*/ sel, int /*long*/ event) { 3645 void applicationSendEvent (objc.id id, objc.SEL sel, objc.id event) {
3649 NSEvent nsEvent = new NSEvent(event); 3646 NSEvent nsEvent = new NSEvent(event);
3650 int type = nsEvent.type (); 3647 int type = nsEvent.type ();
3651 bool beep = false; 3648 bool beep = false;
3652 switch (type) { 3649 switch (type) {
3653 case OS.NSLeftMouseDown: 3650 case OS.NSLeftMouseDown:
3666 case OS.NSOtherMouseUp: 3663 case OS.NSOtherMouseUp:
3667 case OS.NSOtherMouseDragged: 3664 case OS.NSOtherMouseDragged:
3668 case OS.NSScrollWheel: 3665 case OS.NSScrollWheel:
3669 NSWindow window = nsEvent.window (); 3666 NSWindow window = nsEvent.window ();
3670 if (window !is null) { 3667 if (window !is null) {
3671 Shell shell = (Shell) getWidget (window.id); 3668 Shell shell = cast(Shell) getWidget (window.id);
3672 if (shell !is null && shell.getModalShell () !is null) { 3669 if (shell !is null && shell.getModalShell () !is null) {
3673 if (beep) beep (); 3670 if (beep) beep ();
3674 return; 3671 return;
3675 } 3672 }
3676 } 3673 }
3677 break; 3674 break;
3678 } 3675 }
3679 applicationSendMouseEvent (nsEvent, false); 3676 applicationSendMouseEvent (nsEvent, false);
3680 objc_super super_struct = new objc_super (); 3677 objc_super super_struct = objc_super ();
3681 super_struct.receiver = id; 3678 super_struct.receiver = id;
3682 super_struct.super_class = OS.objc_msgSend (id, OS.sel_superclass); 3679 super_struct.super_class = OS.objc_msgSend (id, OS.sel_superclass);
3683 OS.objc_msgSendSuper (super_struct, sel, event); 3680 OS.objc_msgSendSuper (super_struct, sel, event);
3684 // if (nsEvent.type() is OS.NSApplicationDefined && nsEvent.subtype() is DWT_IDLE_TYPE) { 3681 // if (nsEvent.type() is OS.NSApplicationDefined && nsEvent.subtype() is DWT_IDLE_TYPE) {
3685 // idle = true; 3682 // idle = true;
3687 // idle = false; 3684 // idle = false;
3688 // } 3685 // }
3689 // application.stop(null); 3686 // application.stop(null);
3690 } 3687 }
3691 3688
3689 extern (C):
3690
3692 // #245724: [NSApplication isRunning] must return true to allow the AWT to load correctly. 3691 // #245724: [NSApplication isRunning] must return true to allow the AWT to load correctly.
3693 static int /*long*/ applicationProc(int /*long*/ id, int /*long*/ sel) { 3692 static objc.id applicationProc2(objc.id id, objc.SEL sel) {
3694 //TODO optimize getting the display 3693 //TODO optimize getting the display
3695 Display display = getCurrent (); 3694 Display display = getCurrent ();
3696 if (display is null) return 0; 3695 if (display is null) return null;
3697 if (sel is OS.sel_isRunning) { 3696 if (sel is OS.sel_isRunning) {
3698 return display.isDisposed() ? 0 : 1; 3697 return cast(objc.id) (display.isDisposed() ? null : 1);
3699 } 3698 }
3700 return 0; 3699 return null;
3701 } 3700 }
3702 3701
3703 static int /*long*/ applicationProc(int /*long*/ id, int /*long*/ sel, int /*long*/ event) { 3702 static objc.id applicationProc3(objc.id id, objc.SEL sel, objc.id event) {
3704 //TODO optimize getting the display 3703 //TODO optimize getting the display
3705 Display display = getCurrent (); 3704 Display display = getCurrent ();
3706 if (display is null) return 0; 3705 if (display is null) return null;
3707 if (sel is OS.sel_sendEvent_) { 3706 if (sel is OS.sel_sendEvent_) {
3708 display.applicationSendEvent (id, sel, event); 3707 display.applicationSendEvent (id, sel, event);
3709 return 0; 3708 return null;
3710 } 3709 }
3711 return 0; 3710 return null;
3712 } 3711 }
3713 3712
3714 static objc.id applicationProc(objc.id id, objc.SEL sel, objc.id arg0, objc.id arg1, objc.id arg2, objc.id arg3) { 3713 static objc.id applicationProc6(objc.id id, objc.SEL sel, objc.id arg0, objc.id arg1, objc.id arg2, objc.id arg3) {
3715 //TODO optimize getting the display 3714 //TODO optimize getting the display
3716 Display display = getCurrent (); 3715 Display display = getCurrent ();
3717 if (display is null) return null; 3716 if (display is null) return null;
3718 if (sel is OS.sel_nextEventMatchingMask_untilDate_inMode_dequeue_) { 3717 if (sel is OS.sel_nextEventMatchingMask_untilDate_inMode_dequeue_) {
3719 return display.applicationNextEventMatchingMask(id, sel, arg0, arg1, arg2, arg3); 3718 return display.applicationNextEventMatchingMask(id, sel, arg0, arg1, arg2, arg3);
3720 } 3719 }
3721 return 0; 3720 return null;
3722 } 3721 }
3723 3722
3724 static objc.id applicationDelegateProc(objc.id id, objc.SEL sel, objc.id arg0) { 3723 static objc.id applicationDelegateProc(objc.id id, objc.SEL sel, objc.id arg0) {
3725 //TODO optimize getting the display 3724 //TODO optimize getting the display
3726 Display display = getCurrent (); 3725 Display display = getCurrent ();
3727 if (display is null) return 0; 3726 if (display is null) return null;
3728 id applicationDelegate = display.applicationDelegate; 3727 id applicationDelegate = display.applicationDelegate;
3729 NSApplication application = display.application; 3728 NSApplication application = display.application;
3730 if (sel is OS.sel_applicationWillFinishLaunching_) { 3729 if (sel is OS.sel_applicationWillFinishLaunching_) {
3731 NSDictionary dict = NSDictionary.dictionaryWithObject(applicationDelegate, NSString.stringWith("NSOwner")); 3730 NSDictionary dict = NSDictionary.dictionaryWithObject(applicationDelegate, NSString.stringWith("NSOwner"));
3732 NSString nibFile = NSString.stringWith("/System/Library/Frameworks/JavaVM.framework/Resources/English.lproj/DefaultApp.nib"); 3731 NSString nibFile = NSString.stringWith("/System/Library/Frameworks/JavaVM.framework/Resources/English.lproj/DefaultApp.nib");
3744 NSMenuItem ni = new NSMenuItem(ia.objectAtIndex(i)); 3743 NSMenuItem ni = new NSMenuItem(ia.objectAtIndex(i));
3745 NSString title = ni.title().stringByReplacingOccurrencesOfString(NSString.stringWith("%@"), NSString.stringWith(APP_NAME)); 3744 NSString title = ni.title().stringByReplacingOccurrencesOfString(NSString.stringWith("%@"), NSString.stringWith(APP_NAME));
3746 ni.setTitle(title); 3745 ni.setTitle(title);
3747 } 3746 }
3748 } 3747 }
3749 } else if (sel == OS.sel_terminate_) { 3748 } else if (sel is OS.sel_terminate_) {
3750 application.terminate(application); 3749 application.terminate(application);
3751 } else if (sel == OS.sel_orderFrontStandardAboutPanel_) { 3750 } else if (sel is OS.sel_orderFrontStandardAboutPanel_) {
3752 // Event event = new Event (); 3751 // Event event = new Event ();
3753 // sendEvent (DWT.ABORT, event); 3752 // sendEvent (SWT.ABORT, event);
3754 } else if (sel == OS.sel_hideOtherApplications_) { 3753 } else if (sel is OS.sel_hideOtherApplications_) {
3755 application.hideOtherApplications(application); 3754 application.hideOtherApplications(application);
3756 } else if (sel == OS.sel_hide_) { 3755 } else if (sel is OS.sel_hide_) {
3757 application.hide(application); 3756 application.hide(application);
3758 } else if (sel == OS.sel_unhideAllApplications_) { 3757 } else if (sel is OS.sel_unhideAllApplications_) {
3759 application.unhideAllApplications(application); 3758 application.unhideAllApplications(application);
3760 } else if (sel == OS.sel_applicationShouldTerminate_) { 3759 } else if (sel is OS.sel_applicationShouldTerminate_) {
3761 if (!display.disposing) { 3760 if (!display.disposing) {
3762 Event event = new Event (); 3761 Event event = new Event ();
3763 display.sendEvent (DWT.Close, event); 3762 display.sendEvent (SWT.Close, event);
3764 if (event.doit) { 3763 if (event.doit) {
3765 return cast(objc.id) OS.NSTerminateNow; 3764 return OS.NSTerminateNow;
3766 } 3765 }
3767 } 3766 }
3768 return cast(objc.id) OS.NSTerminateCancel; 3767 return OS.NSTerminateCancel;
3769 } else if (sel == OS.sel_applicationWillTerminate_) { 3768 } else if (sel is OS.sel_applicationWillTerminate_) {
3770 display.dispose(); 3769 display.dispose();
3771 } else if (sel == OS.sel_applicationWillResignActive_) { 3770 } else if (sel is OS.sel_applicationWillResignActive_) {
3772 Shell[] shells = display.getShells(); 3771 Shell[] shells = display.getShells();
3773 for (int i = 0; i < shells.length; i++) { 3772 for (int i = 0; i < shells.length; i++) {
3774 shells[i].clearLevel(); 3773 shells[i].clearLevel();
3775 } 3774 }
3776 } 3775 }
3777 } 3776 return null;
3778 } 3777 }
3779 3778
3780 static objc.id dialogProc(objc.id id, objc.SEL selector, objc.id arg0) { 3779 static objc.id dialogProc(objc.id id, objc.SEL selector, objc.id arg0) {
3781 String sel = fromStringz(selector); 3780 void* jniRef;
3782 3781 OS.object_getInstanceVariable(id, SWT_OBJECT, jniRef);
3783 objc.id jniRef; 3782 if (jniRef is null) return null;
3784 OS.object_getInstanceVariable(id, DWT_OBJECT, jniRef);
3785 if (jniRef is null) return 0;
3786 if (sel == OS.sel_changeColor_) { 3783 if (sel == OS.sel_changeColor_) {
3787 ColorDialog dialog = (ColorDialog)OS.JNIGetObject(jniRef); 3784 ColorDialog dialog = cast(ColorDialog)OS.JNIGetObject(jniRef);
3788 if (jniRef is null) return null; 3785 if (jniRef is null) return null;
3789 dialog.changeColor(id, sel, arg0); 3786 dialog.changeColor(id, sel, arg0);
3790 } else if (sel == OS.sel_changeFont_) { 3787 } else if (sel == OS.sel_changeFont_) {
3791 FontDialog dialog = cast(FontDialog)OS.JNIGetObject(jniRef); 3788 FontDialog dialog = cast(FontDialog)OS.JNIGetObject(jniRef);
3792 if (dialog is null) return null; 3789 if (dialog is null) return null;
3793 dialog.changeFont(id, sel, arg0); 3790 dialog.changeFont(id, sel, arg0);
3794 } else if (sel == OS.sel_windowWillClose_) { 3791 } else if (sel == OS.sel_windowWillClose_) {
3795 Object object = OS.JNIGetObject(jniRef[0]); 3792 Object object = OS.JNIGetObject(jniRef);
3796 if (cast(FontDialog) object) { 3793 if (cast(FontDialog) object) {
3797 (cast(FontDialog)object).windowWillClose(id, sel, arg0); 3794 (cast(FontDialog)object).windowWillClose(id, sel, arg0);
3798 } else if (cast(ColorDialog) object) { 3795 } else if (cast(ColorDialog) object) {
3799 (cast(ColorDialog)object).windowWillClose(id, sel, arg0); 3796 (cast(ColorDialog)object).windowWillClose(id, sel, arg0);
3800 } 3797 }
3801 } 3798 }
3802 return null; 3799 return null;
3803 } 3800 }
3804 3801
3805 static int objc.id windowDelegateProc2(objc.id id, objc.SEL selector) { 3802 static objc.id windowDelegateProc2(objc.id id, objc.SEL selector) {
3806 String sel = fromStringz(selector);
3807
3808 Widget widget = GetWidget(id); 3803 Widget widget = GetWidget(id);
3809 if (widget is null) return null; 3804 if (widget is null) return null;
3810 if (sel == OS.sel_sendSelection) { 3805 if (sel is OS.sel_sendSelection) {
3811 widget.sendSelection(); 3806 widget.sendSelection();
3812 } else if (sel == OS.sel_sendDoubleSelection) { 3807 } else if (sel is OS.sel_sendDoubleSelection) {
3813 widget.sendDoubleSelection(); 3808 widget.sendDoubleSelection();
3814 } else if (sel == OS.sel_sendVerticalSelection) { 3809 } else if (sel is OS.sel_sendVerticalSelection) {
3815 widget.sendVerticalSelection(); 3810 widget.sendVerticalSelection();
3816 } else if (sel == OS.sel_sendHorizontalSelection) { 3811 } else if (sel is OS.sel_sendHorizontalSelection) {
3817 widget.sendHorizontalSelection(); 3812 widget.sendHorizontalSelection();
3818 } else if (sel == OS.sel_acceptsFirstResponder) { 3813 } else if (sel is OS.sel_acceptsFirstResponder) {
3819 return widget.acceptsFirstResponder(id, sel) ? cast(objc.id) 1 : null; 3814 return widget.acceptsFirstResponder(id, sel) ? cast(objc.id) 1 : null;
3820 } else if (sel is OS.sel_becomeFirstResponder) { 3815 } else if (sel is OS.sel_becomeFirstResponder) {
3821 return widget.becomeFirstResponder(id, sel) ? cast(objc.id) 1 : null; 3816 return widget.becomeFirstResponder(id, sel) ? cast(objc.id) 1 : null;
3822 } else if (sel is OS.sel_resignFirstResponder) { 3817 } else if (sel is OS.sel_resignFirstResponder) {
3823 return widget.resignFirstResponder(id, sel) ? cast(objc.id) 1 : null; 3818 return widget.resignFirstResponder(id, sel) ? cast(objc.id) 1 : null;
3824 } else if (sel == OS.sel_isFlipped) { 3819 } else if (sel is OS.sel_isFlipped) {
3825 return widget.isFlipped(id, sel) ? cast(objc.id) 1 : null; 3820 return widget.isFlipped(id, sel) ? cast(objc.id) 1 : null;
3826 } else if (sel == OS.sel_isOpaque) { 3821 } else if (sel is OS.sel_isOpaque) {
3827 return widget.isOpaque(id, sel) ? cast(objc.id) 1 : null; 3822 return widget.isOpaque(id, sel) ? cast(objc.id) 1 : null;
3828 } else if (sel is OS.sel_unmarkText) { 3823 } else if (sel is OS.sel_unmarkText) {
3829 //TODO not called? 3824 //TODO not called?
3830 } else if (sel is OS.sel_validAttributesForMarkedText) { 3825 } else if (sel is OS.sel_validAttributesForMarkedText) {
3831 return widget.validAttributesForMarkedText (id, sel); 3826 return widget.validAttributesForMarkedText (id, sel);
3832 } else if (sel is OS.sel_markedRange) { 3827 } else if (sel is OS.sel_markedRange) {
3833 NSRange range = widget.markedRange (id, sel); 3828 NSRange range = widget.markedRange (id, sel);
3834 /* NOTE that this is freed in C */ 3829 /* NOTE that this is freed in C */
3835 int /*long*/ result = OS.malloc (NSRange.sizeof); 3830 objc.id result = OS.malloc (NSRange.sizeof);
3836 OS.memmove (result, range, NSRange.sizeof); 3831 OS.memmove (result, range, NSRange.sizeof);
3837 return result; 3832 return result;
3838 } else if (sel is OS.sel_selectedRange) { 3833 } else if (sel is OS.sel_selectedRange) {
3839 NSRange range = widget.selectedRange (id, sel); 3834 NSRange range = widget.selectedRange (id, sel);
3840 /* NOTE that this is freed in C */ 3835 /* NOTE that this is freed in C */
3841 int /*long*/ result = OS.malloc (NSRange.sizeof); 3836 objc.id result = OS.malloc (NSRange.sizeof);
3842 OS.memmove (result, range, NSRange.sizeof); 3837 OS.memmove (result, range, NSRange.sizeof);
3843 return result; 3838 return result;
3844 } else if (sel is OS.sel_hasMarkedText) { 3839 } else if (sel is OS.sel_hasMarkedText) {
3845 return widget.hasMarkedText (id, sel) ? 1 : 0; 3840 return widget.hasMarkedText (id, sel) ? cast(objc.id) 1 : null;
3846 } else if (sel is OS.sel_canBecomeKeyWindow) { 3841 } else if (sel is OS.sel_canBecomeKeyWindow) {
3847 return widget.canBecomeKeyWindow (id, sel) ? 1 : 0; 3842 return widget.canBecomeKeyWindow (id, sel) ? cast(objc.id) 1 : null;
3848 } else if (sel is OS.sel_accessibilityActionNames) { 3843 } else if (sel is OS.sel_accessibilityActionNames) {
3849 return widget.accessibilityActionNames(id, sel); 3844 return widget.accessibilityActionNames(id, sel);
3850 } else if (sel is OS.sel_accessibilityAttributeNames) { 3845 } else if (sel is OS.sel_accessibilityAttributeNames) {
3851 return widget.accessibilityAttributeNames(id, sel); 3846 return widget.accessibilityAttributeNames(id, sel);
3852 } else if (sel is OS.sel_accessibilityParameterizedAttributeNames) { 3847 } else if (sel is OS.sel_accessibilityParameterizedAttributeNames) {
3853 return widget.accessibilityParameterizedAttributeNames(id, sel); 3848 return widget.accessibilityParameterizedAttributeNames(id, sel);
3854 } else if (sel is OS.sel_accessibilityFocusedUIElement) { 3849 } else if (sel is OS.sel_accessibilityFocusedUIElement) {
3855 return widget.accessibilityFocusedUIElement(id, sel); 3850 return widget.accessibilityFocusedUIElement(id, sel);
3856 } else if (sel is OS.sel_accessibilityIsIgnored) { 3851 } else if (sel is OS.sel_accessibilityIsIgnored) {
3857 return (widget.accessibilityIsIgnored(id, sel) ? 1 : 0); 3852 return (widget.accessibilityIsIgnored(id, sel) ? cast(objc.id) 1 : null);
3858 } 3853 }
3859 return null; 3854 return null;
3860 } 3855 }
3861 3856
3862 static objc.id windowDelegateProc3(objc.id ID, objc.SEL selector, objc.id arg0) { 3857 static objc.id windowDelegateProc3(objc.id ID, objc.SEL selector, objc.id arg0) {
3863 String sel = fromStringz(selector); 3858 if (sel is OS.sel_timerProc_) {
3864
3865 if (sel == OS.sel_timerProc_) {
3866 //TODO optimize getting the display 3859 //TODO optimize getting the display
3867 Display display = getCurrent (); 3860 Display display = getCurrent ();
3868 if (display is null) return null; 3861 if (display is null) return null;
3869 return display.timerProc (id, sel, arg0); 3862 return display.timerProc (id, sel, arg0);
3870
3871 if (sel == OS.sel_timerProc_1) {
3872 return timerProc (arg0_);
3873 } 3863 }
3874 Widget widget = GetWidget(id); 3864 Widget widget = GetWidget(id);
3875 if (widget is null && (sel == OS.sel_keyDown_ ||sel == OS.sel_keyUp_ ||sel == OS.sel_insertText_ ||sel == OS.sel_doCommandBySelector_)) { 3865 if (widget is null && (sel is OS.sel_keyDown_ ||sel is OS.sel_keyUp_ ||sel is OS.sel_insertText_ ||sel is OS.sel_doCommandBySelector_)) {
3876 widget = GetFocusControl (new NSView (id).window ()); 3866 widget = GetFocusControl ((new NSView (id)).window ());
3877 } 3867 }
3878 if (widget is null) return null; 3868 if (widget is null) return 0;
3879 if (sel == OS.sel_windowWillClose_) { 3869 if (sel is OS.sel_windowWillClose_) {
3880 widget.windowWillClose(id, sel, arg0); 3870 widget.windowWillClose(id, sel, arg0);
3881 } else if (sel == OS.sel_drawRect_) { 3871 } else if (sel is OS.sel_drawRect_) {
3882 NSRect rect = NSRect(); 3872 NSRect rect = new NSRect();
3883 OS.memmove(&rect, arg0_, NSRect.sizeof); 3873 OS.memmove(rect, arg0, NSRect.sizeof);
3884 widget.drawRect(id, sel, rect); 3874 widget.drawRect(id, sel, rect);
3885 } else if (sel == OS.sel_setFrameOrigin_) { 3875 } else if (sel is OS.sel_setFrameOrigin_) {
3886 NSPoint point = NSPoint(); 3876 NSPoint point = new NSPoint();
3887 OS.memmove(point, arg0, NSPoint.sizeof); 3877 OS.memmove(point, arg0, NSPoint.sizeof);
3888 widget.setFrameOrigin(id, sel, point); 3878 widget.setFrameOrigin(id, sel, point);
3889 } else if (sel == OS.sel_setFrameSize_) { 3879 } else if (sel is OS.sel_setFrameSize_) {
3890 NSSize size = new NSSize(); 3880 NSSize size = new NSSize();
3891 OS.memmove(size, arg0, NSSize.sizeof); 3881 OS.memmove(size, arg0, NSSize.sizeof);
3892 widget.setFrameSize(id, sel, size); 3882 widget.setFrameSize(id, sel, size);
3893 } else if (sel == OS.sel_hitTest_) { 3883 } else if (sel is OS.sel_hitTest_) {
3894 NSPoint point = new NSPoint(); 3884 NSPoint point = new NSPoint();
3895 OS.memmove(point, arg0, NSPoint.sizeof); 3885 OS.memmove(point, arg0, NSPoint.sizeof);
3896 return widget.hitTest(id, sel, point); 3886 return widget.hitTest(id, sel, point);
3897 } else if (sel == OS.sel_windowShouldClose_) { 3887 } else if (sel is OS.sel_windowShouldClose_) {
3898 return widget.windowShouldClose(id, sel, arg0) ? 1 : 0; 3888 return widget.windowShouldClose(id, sel, arg0) ? cast(objc.id) 1 : null;
3899 } else if (sel == OS.sel_mouseDown_) { 3889 } else if (sel is OS.sel_mouseDown_) {
3900 widget.mouseDown(id, sel, arg0); 3890 widget.mouseDown(id, sel, arg0);
3901 } else if (sel == OS.sel_keyDown_) { 3891 } else if (sel is OS.sel_keyDown_) {
3902 widget.keyDown(id, sel, arg0); 3892 widget.keyDown(id, sel, arg0);
3903 } else if (sel == OS.sel_keyUp_) { 3893 } else if (sel is OS.sel_keyUp_) {
3904 widget.keyUp(id, sel, arg0); 3894 widget.keyUp(id, sel, arg0);
3905 } else if (sel == OS.sel_flagsChanged_) { 3895 } else if (sel is OS.sel_flagsChanged_) {
3906 widget.flagsChanged(id, sel, arg0); 3896 widget.flagsChanged(id, sel, arg0);
3907 } else if (sel == OS.sel_mouseUp_) { 3897 } else if (sel is OS.sel_mouseUp_) {
3908 widget.mouseUp(id, sel, arg0); 3898 widget.mouseUp(id, sel, arg0);
3909 } else if (sel == OS.sel_rightMouseDown_) { 3899 } else if (sel is OS.sel_rightMouseDown_) {
3910 widget.rightMouseDown(id, sel, arg0); 3900 widget.rightMouseDown(id, sel, arg0);
3911 } else if (sel == OS.sel_rightMouseUp_) { 3901 } else if (sel is OS.sel_rightMouseUp_) {
3912 widget.rightMouseUp(id, sel, arg0); 3902 widget.rightMouseUp(id, sel, arg0);
3913 } else if (sel == OS.sel_otherMouseDown_) { 3903 } else if (sel is OS.sel_otherMouseDown_) {
3914 widget.otherMouseDown(id, sel, arg0); 3904 widget.otherMouseDown(id, sel, arg0);
3915 } else if (sel == OS.sel_otherMouseUp_) { 3905 } else if (sel is OS.sel_otherMouseUp_) {
3916 widget.otherMouseUp(id, sel, arg0); 3906 widget.otherMouseUp(id, sel, arg0);
3917 } else if (sel == OS.sel_mouseMoved_) { 3907 } else if (sel is OS.sel_mouseMoved_) {
3918 widget.mouseMoved(id, sel, arg0); 3908 widget.mouseMoved(id, sel, arg0);
3919 } else if (sel == OS.sel_mouseDragged_) { 3909 } else if (sel is OS.sel_mouseDragged_) {
3920 widget.mouseDragged(id, sel, arg0); 3910 widget.mouseDragged(id, sel, arg0);
3921 } else if (sel == OS.sel_mouseEntered_) { 3911 } else if (sel is OS.sel_mouseEntered_) {
3922 widget.mouseEntered(id, sel, arg0); 3912 widget.mouseEntered(id, sel, arg0);
3923 } else if (sel == OS.sel_mouseExited_) { 3913 } else if (sel is OS.sel_mouseExited_) {
3924 widget.mouseExited(id, sel, arg0); 3914 widget.mouseExited(id, sel, arg0);
3925 } else if (sel == OS.sel_menuForEvent_) { 3915 } else if (sel is OS.sel_menuForEvent_) {
3926 return widget.menuForEvent(id, sel, arg0); 3916 return widget.menuForEvent(id, sel, arg0);
3927 } else if (sel == OS.sel_numberOfRowsInTableView_) { 3917 } else if (sel is OS.sel_numberOfRowsInTableView_) {
3928 return widget.numberOfRowsInTableView(id, sel, arg0); 3918 return widget.numberOfRowsInTableView(id, sel, arg0);
3929 } else if (sel is OS.sel_comboBoxSelectionDidChange_) { 3919 } else if (sel is OS.sel_comboBoxSelectionDidChange_) {
3930 widget.comboBoxSelectionDidChange(id, sel, arg0); 3920 widget.comboBoxSelectionDidChange(id, sel, arg0);
3931 } else if (sel is OS.sel_tableViewSelectionDidChange_) { 3921 } else if (sel is OS.sel_tableViewSelectionDidChange_) {
3932 widget.tableViewSelectionDidChange(id, sel, arg0); 3922 widget.tableViewSelectionDidChange(id, sel, arg0);
3967 } else if (sel is OS.sel_characterIndexForPoint_) { 3957 } else if (sel is OS.sel_characterIndexForPoint_) {
3968 return widget.characterIndexForPoint (id, sel, arg0); 3958 return widget.characterIndexForPoint (id, sel, arg0);
3969 } else if (sel is OS.sel_firstRectForCharacterRange_) { 3959 } else if (sel is OS.sel_firstRectForCharacterRange_) {
3970 NSRect rect = widget.firstRectForCharacterRange (id, sel, arg0); 3960 NSRect rect = widget.firstRectForCharacterRange (id, sel, arg0);
3971 /* NOTE that this is freed in C */ 3961 /* NOTE that this is freed in C */
3972 int /*long*/ result = OS.malloc (NSRect.sizeof); 3962 objc.id result = OS.malloc (NSRect.sizeof);
3973 OS.memmove (result, rect, NSRect.sizeof); 3963 OS.memmove (result, rect, NSRect.sizeof);
3974 return result; 3964 return result;
3975 } else if (sel is OS.sel_insertText_) { 3965 } else if (sel is OS.sel_insertText_) {
3976 widget.insertText (id, sel, arg0); 3966 widget.insertText (id, sel, arg0);
3977 } else if (sel is OS.sel_doCommandBySelector_) { 3967 } else if (sel is OS.sel_doCommandBySelector_) {
3985 OS.memmove(point, arg0, NSPoint.sizeof); 3975 OS.memmove(point, arg0, NSPoint.sizeof);
3986 return widget.accessibilityHitTest(id, sel, point); 3976 return widget.accessibilityHitTest(id, sel, point);
3987 } else if (sel is OS.sel_accessibilityAttributeValue_) { 3977 } else if (sel is OS.sel_accessibilityAttributeValue_) {
3988 return widget.accessibilityAttributeValue(id, sel, arg0); 3978 return widget.accessibilityAttributeValue(id, sel, arg0);
3989 } else if (sel is OS.sel_accessibilityIsAttributeSettable_) { 3979 } else if (sel is OS.sel_accessibilityIsAttributeSettable_) {
3990 return (widget.accessibilityIsAttributeSettable(id, sel, arg0) ? 1 : 0); 3980 return (widget.accessibilityIsAttributeSettable(id, sel, arg0) ? cast(objc.id) 1 : null);
3991 } else if (sel is OS.sel_accessibilityPerformAction_) { 3981 } else if (sel is OS.sel_accessibilityPerformAction_) {
3992 widget.accessibilityPerformAction(id, sel, arg0); 3982 widget.accessibilityPerformAction(id, sel, arg0);
3993 } else if (sel is OS.sel_accessibilityActionDescription_) { 3983 } else if (sel is OS.sel_accessibilityActionDescription_) {
3994 widget.accessibilityActionDescription(id, sel, arg0); 3984 widget.accessibilityActionDescription(id, sel, arg0);
3995 } else if (sel is OS.sel_makeFirstResponder_) { 3985 } else if (sel is OS.sel_makeFirstResponder_) {
3996 return widget.makeFirstResponder(id, sel, arg0) ? 1 : 0; 3986 return widget.makeFirstResponder(id, sel, arg0) ? cast(objc.id) 1 : null;
3997 } else if (sel is OS.sel_tableViewColumnDidMove_) { 3987 } else if (sel is OS.sel_tableViewColumnDidMove_) {
3998 widget.tableViewColumnDidMove(id, sel, arg0); 3988 widget.tableViewColumnDidMove(id, sel, arg0);
3999 } else if (sel is OS.sel_tableViewColumnDidResize_) { 3989 } else if (sel is OS.sel_tableViewColumnDidResize_) {
4000 widget.tableViewColumnDidResize(id, sel, arg0); 3990 widget.tableViewColumnDidResize(id, sel, arg0);
4001 } else if (sel is OS.sel_outlineViewColumnDidMove_) { 3991 } else if (sel is OS.sel_outlineViewColumnDidMove_) {
4002 widget.outlineViewColumnDidMove(id, sel, arg0); 3992 widget.outlineViewColumnDidMove(id, sel, arg0);
4003 } else if (sel is OS.sel_outlineViewColumnDidResize_) { 3993 } else if (sel is OS.sel_outlineViewColumnDidResize_) {
4004 widget.outlineViewColumnDidResize(id, sel, arg0); 3994 widget.outlineViewColumnDidResize(id, sel, arg0);
4005 } 3995 }
3996 return null;
4006 } 3997 }
4007 3998
4008 static objc.id windowDelegateProc4(objc.id id, objc.SEL selector, objc.id arg0, objc.id arg1) { 3999 static objc.id windowDelegateProc4(objc.id id, objc.SEL selector, objc.id arg0, objc.id arg1) {
4009 String sel = fromStringz(selector); 4000 Widget widget = GetWidget(id);
4010 4001 if (widget is null) return null;
4011 Widget widget = GetWidget(id); 4002 if (sel is OS.sel_tabView_willSelectTabViewItem_) {
4012
4013 if (sel == OS.sel_tabView_willSelectTabViewItem_) {
4014 widget.tabView_willSelectTabViewItem(id, sel, arg0, arg1); 4003 widget.tabView_willSelectTabViewItem(id, sel, arg0, arg1);
4015 } else if (sel ==is OS.sel_tabView_didSelectTabViewItem_) { 4004 } else if (sel is OS.sel_tabView_didSelectTabViewItem_) {
4016 widget.tabView_didSelectTabViewItem(id, sel, arg0, arg1); 4005 widget.tabView_didSelectTabViewItem(id, sel, arg0, arg1);
4017 } else if (sel == OS.sel_outlineView_isItemExpandable_) { 4006 } else if (sel is OS.sel_outlineView_isItemExpandable_) {
4018 return widget.outlineView_isItemExpandable(id, sel, arg0, arg1) ? 1 : 0; 4007 return widget.outlineView_isItemExpandable(id, sel, arg0, arg1) ? cast(objc.id) 1 : null;
4019 } else if (sel == OS.sel_outlineView_numberOfChildrenOfItem_) { 4008 } else if (sel is OS.sel_outlineView_numberOfChildrenOfItem_) {
4020 return widget.outlineView_numberOfChildrenOfItem(id, sel, arg0, arg1); 4009 return widget.outlineView_numberOfChildrenOfItem(id, sel, arg0, arg1);
4021 } else if (sel == OS.sel_outlineView_shouldCollapseItem_) { 4010 } else if (sel is OS.sel_outlineView_shouldCollapseItem_) {
4022 return widget.outlineView_shouldCollapseItem(id, sel, arg0, arg1) ? 1 : 0; 4011 return widget.outlineView_shouldCollapseItem(id, sel, arg0, arg1) ? cast(objc.id) 1 : null;
4023 } else if (sel == OS.sel_outlineView_shouldExpandItem_) { 4012 } else if (sel is OS.sel_outlineView_shouldExpandItem_) {
4024 return widget.outlineView_shouldExpandItem(id, sel, arg0, arg1) ? 1 : 0; 4013 return widget.outlineView_shouldExpandItem(id, sel, arg0, arg1) ? cast(objc.id) 1 : null;
4025 } else if (sel == OS.sel_menu_willHighlightItem_) { 4014 } else if (sel is OS.sel_menu_willHighlightItem_) {
4026 widget.menu_willHighlightItem(id, sel, arg0, arg1); 4015 widget.menu_willHighlightItem(id, sel, arg0, arg1);
4027 } else if (sel == OS.sel_setMarkedText_selectedRange_) { 4016 } else if (sel is OS.sel_setMarkedText_selectedRange_) {
4028 widget.setMarkedText_selectedRange (id, sel, arg0, arg1); 4017 widget.setMarkedText_selectedRange (id, sel, arg0, arg1);
4029 } else if (sel is OS.sel_drawInteriorWithFrame_inView_) { 4018 } else if (sel is OS.sel_drawInteriorWithFrame_inView_) {
4030 widget.drawInteriorWithFrame_inView (id, sel, arg0, arg1); 4019 widget.drawInteriorWithFrame_inView (id, sel, arg0, arg1);
4031 } else if (sel is OS.sel_accessibilityAttributeValue_forParameter_) { 4020 } else if (sel is OS.sel_accessibilityAttributeValue_forParameter_) {
4032 return widget.accessibilityAttributeValue_forParameter(id, sel, arg0, arg1); 4021 return widget.accessibilityAttributeValue_forParameter(id, sel, arg0, arg1);
4036 widget.outlineView_didClickTableColumn (id, sel, arg0, arg1); 4025 widget.outlineView_didClickTableColumn (id, sel, arg0, arg1);
4037 } 4026 }
4038 return null; 4027 return null;
4039 } 4028 }
4040 4029
4041 objc.id windowDelegateProc5(objc.id id, objc.SEL selector, objc.id arg0, objc.id arg1, objc.id arg2) { 4030 static objc.id windowDelegateProc5(objc.id id, objc.SEL selector, objc.id arg0, objc.id arg1, objc.id arg2) {
4042 String sel = fromStringz(selector); 4031 Widget widget = GetWidget(id);
4043 4032 if (widget is null) return null;
4044 Widget widget = GetWidget(id); 4033 if (sel is OS.sel_tableView_objectValueForTableColumn_row_) {
4045
4046 if (sel == OS.sel_tableView_objectValueForTableColumn_row_) {
4047 return widget.tableView_objectValueForTableColumn_row(id, sel, arg0, arg1, arg2); 4034 return widget.tableView_objectValueForTableColumn_row(id, sel, arg0, arg1, arg2);
4048 } else if (sel == OS.sel_tableView_shouldEditTableColumn_row_) { 4035 } else if (sel is OS.sel_tableView_shouldEditTableColumn_row_) {
4049 return widget.tableView_shouldEditTableColumn_row(id, sel, arg0, arg1, arg2) ? cast(objc.id) 1 : null; 4036 return widget.tableView_shouldEditTableColumn_row(id, sel, arg0, arg1, arg2) ? cast(objc.id) 1 : null;
4050 } else if (sel == OS.sel_textView_clickedOnLink_atIndex_) { 4037 } else if (sel is OS.sel_textView_clickedOnLink_atIndex_) {
4051 return widget.textView_clickOnLink_atIndex(id, sel, arg0, arg1, arg2) ? cast(objc.id) 1 : null; 4038 return widget.textView_clickOnLink_atIndex(id, sel, arg0, arg1, arg2) ? cast(objc.id) 1 : null;
4052 } else if (sel == OS.sel_outlineView_child_ofItem_) { 4039 } else if (sel is OS.sel_outlineView_child_ofItem_) {
4053 return widget.outlineView_child_ofItem(id, sel, arg0, arg1, arg2); 4040 return widget.outlineView_child_ofItem(id, sel, arg0, arg1, arg2);
4054 } else if (sel == OS.sel_outlineView_objectValueForTableColumn_byItem_) { 4041 } else if (sel is OS.sel_outlineView_objectValueForTableColumn_byItem_) {
4055 return widget.outlineView_objectValueForTableColumn_byItem(id, sel, arg0, arg1, arg2); 4042 return widget.outlineView_objectValueForTableColumn_byItem(id, sel, arg0, arg1, arg2);
4056 } else if (sel == OS.sel_textView_willChangeSelectionFromCharacterRange_toCharacterRange_) { 4043 } else if (sel is OS.sel_textView_willChangeSelectionFromCharacterRange_toCharacterRange_) {
4057 NSRange range = widget.textView_willChangeSelectionFromCharacterRange_toCharacterRange(id, sel, arg0, arg1, arg2); 4044 NSRange range = widget.textView_willChangeSelectionFromCharacterRange_toCharacterRange(id, sel, arg0, arg1, arg2);
4058 /* NOTE that this is freed in C */ 4045 /* NOTE that this is freed in C */
4059 void* result = OS.malloc (NSRange.sizeof); 4046 objc.id result = OS.malloc (NSRange.sizeof);
4060 OS.memmove (result, range, NSRange.sizeof); 4047 OS.memmove (result, range, NSRange.sizeof);
4061 return result; 4048 return result;
4062 } 4049 }
4063 return null; 4050 return null;
4064 } 4051 }
4065 4052
4066 objc.id windowDelegateProc6(objc.id id, objc.SEL selector, objc.id arg0, objc.id arg1, objc.id arg2, objc.id arg3) { 4053 static objc.id windowDelegateProc6(objc.id id, objc.SEL selector, objc.id arg0, objc.id arg1, objc.id arg2, objc.id arg3) {
4067 String sel = fromStringz(selector);
4068
4069 Widget widget = GetWidget(id); 4054 Widget widget = GetWidget(id);
4070 4055 if (widget is null) return null;
4071 if (sel == OS.sel_tableView_willDisplayCell_forTableColumn_row_) { 4056 if (sel is OS.sel_tableView_willDisplayCell_forTableColumn_row_) {
4072 widget.tableView_willDisplayCell_forTableColumn_row(id, sel, arg0, arg1, arg2, arg3); 4057 widget.tableView_willDisplayCell_forTableColumn_row(id, sel, arg0, arg1, arg2, arg3);
4073 } else if (sel == OS.sel_outlineView_willDisplayCell_forTableColumn_item_) { 4058 } else if (sel is OS.sel_outlineView_willDisplayCell_forTableColumn_item_) {
4074 widget.outlineView_willDisplayCell_forTableColumn_item(id, sel, arg0, arg1, arg2, arg3); 4059 widget.outlineView_willDisplayCell_forTableColumn_item(id, sel, arg0, arg1, arg2, arg3);
4075 } else if (sel == OS.sel_outlineView_setObjectValue_forTableColumn_byItem_) { 4060 } else if (sel is OS.sel_outlineView_setObjectValue_forTableColumn_byItem_) {
4076 widget.outlineView_setObjectValue_forTableColumn_byItem(id, sel, arg0, arg1, arg2, arg3); 4061 widget.outlineView_setObjectValue_forTableColumn_byItem(id, sel, arg0, arg1, arg2, arg3);
4077 } else if (sel == OS.sel_tableView_setObjectValue_forTableColumn_row_) { 4062 } else if (sel is OS.sel_tableView_setObjectValue_forTableColumn_row_) {
4078 widget.tableView_setObjectValue_forTableColumn_row(id, sel, arg0, arg1, arg2, arg3); 4063 widget.tableView_setObjectValue_forTableColumn_row(id, sel, arg0, arg1, arg2, arg3);
4079 } else if (sel == OS.sel_outlineView_1willDisplayCell_1forTableColumn_1item_1) {
4080 } 4064 }
4081 return null; 4065 return null;
4082 } 4066 }
4083 4067 }
4084 Widget getWidget (objc.id ID)
4085 {
4086 NSInteger* dObject;
4087 OS.object_getInstanceVariable(ID, "dObject", cast(void**)dObject);
4088 if (dObject is null) return null;
4089 return cast(Widget)(*dObject);
4090 }
4091 }