Mercurial > projects > dwt-mac
diff dwt/widgets/Display.d @ 15:2952d5604c0a
Ported some widgets, added some stuff to the runtime bindings
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Fri, 29 Aug 2008 21:46:05 +0200 |
parents | 380af2bdd8e5 |
children | 5b53d338c709 |
line wrap: on
line diff
--- a/dwt/widgets/Display.d Sat Aug 23 13:49:00 2008 +0200 +++ b/dwt/widgets/Display.d Fri Aug 29 21:46:05 2008 +0200 @@ -7,11 +7,12 @@ * * Contributors: * IBM Corporation - initial API and implementation + * + * Port to the D programming language: + * Jacob Carlborg <jacob.carlborg@gmail.com> *******************************************************************************/ module dwt.widgets.Display; -import dwt.dwthelper.utils; - import dwt.DWT; import dwt.DWTError; import dwt.DWTException; @@ -56,6 +57,29 @@ import dwt.internal.cocoa.SWTWindowDelegate; import dwt.internal.cocoa.id; +import tango.core.Thread; + +import dwt.dwthelper.Runnable; +import dwt.dwthelper.System; +import dwt.dwthelper.utils; + +import dwt.internal.c.carboncore.MacTypes; + +import dwt.internal.cocoa.NSInteger; + +import dwt.widgets.Caret; +import dwt.widgets.Control; +import dwt.widgets.Dialog; +import dwt.widgets.Event; +import dwt.widgets.EventTable; +import dwt.widgets.Listener; +import dwt.widgets.Menu; +import dwt.widgets.Monitor; +import dwt.widgets.Shell; +import dwt.widgets.Synchronizer; +import dwt.widgets.Tray; +import dwt.widgets.Widget; + /** * Instances of this class are responsible for managing the * connection between DWT and the underlying operating @@ -131,7 +155,7 @@ * @see #sleep * @see Device#dispose */ -public class Display extends Device { +public class Display : Device { /* Windows and Events */ Event [] eventQueue; @@ -152,7 +176,7 @@ NSApplication application; NSAutoreleasePool pool; - NSPoint cascade = new NSPoint(); + NSPoint cascade = NSPoint(); Callback applicationDelegateCallback3; Callback windowDelegateCallback2, windowDelegateCallback3, windowDelegateCallback4, windowDelegateCallback5; @@ -176,98 +200,98 @@ Cursor [] cursors = new Cursor [DWT.CURSOR_HAND + 1]; /* Key Mappings. */ - static int [] [] KeyTable = { + static int [] [] KeyTable = [ - /* Keyboard and Mouse Masks */ -// {58, DWT.ALT}, -// {56, DWT.SHIFT}, -// {59, DWT.CONTROL}, -// {55, DWT.COMMAND}, + /* Keyboard and Mouse Masks */ +// [58, DWT.ALT], +// [56, DWT.SHIFT], +// [59, DWT.CONTROL], +// [55, DWT.COMMAND], - /* Non-Numeric Keypad Keys */ - {OS.NSUpArrowFunctionKey, DWT.ARROW_UP}, - {OS.NSDownArrowFunctionKey, DWT.ARROW_DOWN}, - {OS.NSLeftArrowFunctionKey, DWT.ARROW_LEFT}, - {OS.NSRightArrowFunctionKey, DWT.ARROW_RIGHT}, - {OS.NSPageUpFunctionKey, DWT.PAGE_UP}, - {OS.NSPageDownFunctionKey, DWT.PAGE_DOWN}, - {OS.NSHomeFunctionKey, DWT.HOME}, - {OS.NSEndFunctionKey, DWT.END}, - -// {??, DWT.INSERT}, + /* Non-Numeric Keypad Keys */ + [OS.NSUpArrowFunctionKey, DWT.ARROW_UP], + [OS.NSDownArrowFunctionKey, DWT.ARROW_DOWN], + [OS.NSLeftArrowFunctionKey, DWT.ARROW_LEFT], + [OS.NSRightArrowFunctionKey, DWT.ARROW_RIGHT], + [OS.NSPageUpFunctionKey, DWT.PAGE_UP], + [OS.NSPageDownFunctionKey, DWT.PAGE_DOWN], + [OS.NSHomeFunctionKey, DWT.HOME], + [OS.NSEndFunctionKey, DWT.END], + +// [??, DWT.INSERT], - /* Virtual and Ascii Keys */ - {OS.NSDeleteCharacter, DWT.BS}, -// {36, DWT.CR}, - {OS.NSDeleteFunctionKey, DWT.DEL}, -// {53, DWT.ESC}, -// {76, DWT.LF}, -// {48, DWT.TAB}, - - /* Functions Keys */ - {OS.NSF1FunctionKey, DWT.F1}, - {OS.NSF2FunctionKey, DWT.F2}, - {OS.NSF3FunctionKey, DWT.F3}, - {OS.NSF4FunctionKey, DWT.F4}, - {OS.NSF5FunctionKey, DWT.F5}, - {OS.NSF6FunctionKey, DWT.F6}, - {OS.NSF7FunctionKey, DWT.F7}, - {OS.NSF8FunctionKey, DWT.F8}, - {OS.NSF9FunctionKey, DWT.F9}, - {OS.NSF10FunctionKey, DWT.F10}, - {OS.NSF11FunctionKey, DWT.F11}, - {OS.NSF12FunctionKey, DWT.F12}, - {OS.NSF13FunctionKey, DWT.F13}, - {OS.NSF14FunctionKey, DWT.F14}, - {OS.NSF15FunctionKey, DWT.F15}, - - /* Numeric Keypad Keys */ -// {67, DWT.KEYPAD_MULTIPLY}, -// {69, DWT.KEYPAD_ADD}, -// {76, DWT.KEYPAD_CR}, -// {78, DWT.KEYPAD_SUBTRACT}, -// {65, DWT.KEYPAD_DECIMAL}, -// {75, DWT.KEYPAD_DIVIDE}, -// {82, DWT.KEYPAD_0}, -// {83, DWT.KEYPAD_1}, -// {84, DWT.KEYPAD_2}, -// {85, DWT.KEYPAD_3}, -// {86, DWT.KEYPAD_4}, -// {87, DWT.KEYPAD_5}, -// {88, DWT.KEYPAD_6}, -// {89, DWT.KEYPAD_7}, -// {91, DWT.KEYPAD_8}, -// {92, DWT.KEYPAD_9}, -// {81, DWT.KEYPAD_EQUAL}, + /* Virtual and Ascii Keys */ + [OS.NSDeleteCharacter, DWT.BS], +// [36, DWT.CR], + [OS.NSDeleteFunctionKey, DWT.DEL], +// [53, DWT.ESC], +// [76, DWT.LF], +// [48, DWT.TAB], + + /* Functions Keys */ + [OS.NSF1FunctionKey, DWT.F1], + [OS.NSF2FunctionKey, DWT.F2], + [OS.NSF3FunctionKey, DWT.F3], + [OS.NSF4FunctionKey, DWT.F4], + [OS.NSF5FunctionKey, DWT.F5], + [OS.NSF6FunctionKey, DWT.F6], + [OS.NSF7FunctionKey, DWT.F7], + [OS.NSF8FunctionKey, DWT.F8], + [OS.NSF9FunctionKey, DWT.F9], + [OS.NSF10FunctionKey, DWT.F10], + [OS.NSF11FunctionKey, DWT.F11], + [OS.NSF12FunctionKey, DWT.F12], + [OS.NSF13FunctionKey, DWT.F13], + [OS.NSF14FunctionKey, DWT.F14], + [OS.NSF15FunctionKey, DWT.F15], + + /* Numeric Keypad Keys */ +// [67, DWT.KEYPAD_MULTIPLY], +// [69, DWT.KEYPAD_ADD], +// [76, DWT.KEYPAD_CR], +// [78, DWT.KEYPAD_SUBTRACT], +// [65, DWT.KEYPAD_DECIMAL], +// [75, DWT.KEYPAD_DIVIDE], +// [82, DWT.KEYPAD_0], +// [83, DWT.KEYPAD_1], +// [84, DWT.KEYPAD_2], +// [85, DWT.KEYPAD_3], +// [86, DWT.KEYPAD_4], +// [87, DWT.KEYPAD_5], +// [88, DWT.KEYPAD_6], +// [89, DWT.KEYPAD_7], +// [91, DWT.KEYPAD_8], +// [92, DWT.KEYPAD_9], +// [81, DWT.KEYPAD_EQUAL], - /* Other keys */ -// {??, DWT.CAPS_LOCK}, - -// {71, DWT.NUM_LOCK}, - -// {??, DWT.SCROLL_LOCK}, -// {??, DWT.PAUSE}, -// {??, DWT.BREAK}, -// {??, DWT.PRINT_SCREEN}, - - {OS.NSHelpFunctionKey, DWT.HELP}, - - }; + /* Other keys */ +// [??, DWT.CAPS_LOCK], + +// [71, DWT.NUM_LOCK], + +// [??, DWT.SCROLL_LOCK], +// [??, DWT.PAUSE], +// [??, DWT.BREAK], +// [??, DWT.PRINT_SCREEN], + + [OS.NSHelpFunctionKey, DWT.HELP], + + ]; static String APP_NAME = "DWT"; - static final String ADD_WIDGET_KEY = "dwt.internal.addWidget"; + static const String ADD_WIDGET_KEY = "dwt.internal.addWidget"; /* Multiple Displays. */ static Display Default; static Display [] Displays = new Display [4]; /* Package Name */ - static final String PACKAGE_PREFIX = "dwt.widgets."; + static const String PACKAGE_PREFIX = "dwt.widgets."; /* Timer */ Runnable timerList []; NSTimer nsTimers []; - SWTWindowDelegate timerDelegate = (SWTWindowDelegate)new SWTWindowDelegate().alloc().init(); + SWTWindowDelegate timerDelegate = cast(SWTWindowDelegate)(new SWTWindowDelegate()).alloc().init(); SWTApplicationDelegate applicationDelegate; /* Display Data */ @@ -280,8 +304,8 @@ * gets the current display. This code will * be removed in the future. */ - static { - DeviceFinder = new Runnable () { + static this () { + DeviceFinder = new class Runnable { public void run () { Device device = getCurrent (); if (device is null) { @@ -305,7 +329,7 @@ name.getChars (0, length, chars, 0); byte [] buffer = new byte [length + 1]; for (int i=0; i<length; i++) { - buffer [i] = (byte) chars [i]; + buffer [i] = cast(byte) chars [i]; } return buffer; } @@ -456,7 +480,7 @@ * @see #syncExec */ public void asyncExec (Runnable runnable) { - synchronized (Device.class) { + synchronized (Device.classinfo) { if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED); synchronizer.asyncExec (runnable); } @@ -477,7 +501,7 @@ protected void checkDevice () { if (thread is null) error (DWT.ERROR_WIDGET_DISPOSED); - if (thread !is Thread.currentThread ()) error (DWT.ERROR_THREAD_INVALID_ACCESS); + if (thread !is Thread.getThis ()) error (DWT.ERROR_THREAD_INVALID_ACCESS); if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED); } @@ -494,7 +518,7 @@ * @see Widget#checkSubclass */ protected void checkSubclass () { - if (!Display.isValidClass (getClass ())) error (DWT.ERROR_INVALID_SUBCLASS); + if (!Display.isValidClass (this.classinfo)) error (DWT.ERROR_INVALID_SUBCLASS); } /** @@ -516,7 +540,7 @@ * @see Widget#checkSubclass * @see Shell */ -public Display () { +public this () { this (null); } @@ -525,12 +549,12 @@ * * @param data the device data */ -public Display (DeviceData data) { +public this (DeviceData data) { super (data); } static void checkDisplay (Thread thread, bool multiple) { - synchronized (Device.class) { + synchronized (Device.classinfo) { for (int i=0; i<Displays.length; i++) { if (Displays [i] !is null) { if (!multiple) DWT.error (DWT.ERROR_NOT_IMPLEMENTED, null, " [multiple displays]"); @@ -602,7 +626,7 @@ */ protected void create (DeviceData data) { checkSubclass (); - checkDisplay (thread = Thread.currentThread (), false); + checkDisplay (thread = Thread.getThis (), false); createDisplay (data); register (this); synchronizer = new Synchronizer (this); @@ -611,8 +635,8 @@ void createDisplay (DeviceData data) { if (OS.VERSION < 0x1050) { - System.out.println ("***WARNING: DWT requires MacOS X version " + 10 + "." + 5 + " or greater"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - System.out.println ("***WARNING: Detected: " + Integer.toHexString((OS.VERSION & 0xFF00) >> 8) + "." + Integer.toHexString((OS.VERSION & 0xF0) >> 4) + "." + Integer.toHexString(OS.VERSION & 0xF)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + System.Out.println ("***WARNING: DWT requires MacOS X version {}{}{}{}" , 10 , "." , 5 , " or greater"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + System.Out.println ("***WARNING: Detected: {}{}{}{}{}" , Integer.toHexString((OS.VERSION & 0xFF00) >> 8) , "." , Integer.toHexString((OS.VERSION & 0xF0) >> 4) , "." , Integer.toHexString(OS.VERSION & 0xF)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ error(DWT.ERROR_NOT_IMPLEMENTED); } @@ -629,7 +653,7 @@ * used) but both functions must be called in order for * windows to come to the front. */ - int [] psn = new int [2]; + ProcessSerialNumber* psn; if (OS.GetCurrentProcess (psn) is OS.noErr) { // int pid = OS.getpid (); // byte [] buffer = null; @@ -669,12 +693,12 @@ // } } - pool = (NSAutoreleasePool)new NSAutoreleasePool().alloc().init(); + pool = cast(NSAutoreleasePool)(new NSAutoreleasePool()).alloc().init(); application = NSApplication.sharedApplication(); } static void deregister (Display display) { - synchronized (Device.class) { + synchronized (Device.classinfo) { for (int i=0; i<Displays.length; i++) { if (display is Displays [i]) Displays [i] = null; } @@ -763,14 +787,14 @@ * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> */ -public Widget findWidget (int handle) { +public Widget findWidget (objc.id handle) { checkDevice (); - if (handle !is 0 && OS.objc_msgSend(handle, OS.sel_respondsToSelector_1, OS.sel_tag) !is 0) { - int tag = OS.objc_msgSend(handle, OS.sel_tag); + if (handle !is null && OS.objc_msgSend(handle, OS.sel_respondsToSelector_1, OS.sel_tag) !is null) { + NSInteger tag = cast(NSInteger) OS.objc_msgSend(handle, OS.sel_tag); if (tag !is -1) { Object object = OS.JNIGetObject(tag); - if (object instanceof Widget) { - return (Widget)object; + if (cast(Widget) object) { + return cast(Widget)object; } } } @@ -799,7 +823,7 @@ * * @since 3.1 */ -public Widget findWidget (int handle, int id) { +public Widget findWidget (objc.id handle, int id) { checkDevice (); return null; } @@ -837,7 +861,7 @@ * @return the display for the given thread */ public static Display findDisplay (Thread thread) { - synchronized (Device.class) { + synchronized (Device.classinfo) { for (int i=0; i<Displays.length; i++) { Display display = Displays [i]; if (display !is null && display.thread is thread) { @@ -866,11 +890,11 @@ if (window !is null) { NSView view = window.contentView(); if (view !is null && view.respondsToSelector(OS.sel_tag)) { - int tag = OS.objc_msgSend(view.id, OS.sel_tag); + NSInteger tag = OS.objc_msgSend(view.id_, OS.sel_tag); if (tag !is -1) { Object object = OS.JNIGetObject(tag); - if (object instanceof Shell) { - return (Shell)object; + if (cast(Shell) object) { + return cast(Shell)object; } } } @@ -901,7 +925,7 @@ * @return the current display */ public static Display getCurrent () { - return findDisplay (Thread.currentThread ()); + return findDisplay (Thread.getThis ()); } int getCaretBlinkTime () { @@ -960,7 +984,7 @@ NSPoint location = NSEvent.mouseLocation(); //TODO bad for other screens NSRect rect = NSScreen.mainScreen().frame(); - return new Point ((int) location.x, (int) (rect.height - location.y)); + return new Point (cast(int) location.x, cast(int) (rect.height - location.y)); } /** @@ -977,7 +1001,7 @@ */ public Point [] getCursorSizes () { checkDevice (); - return new Point [] {new Point (16, 16)}; + return new Point [] [new Point (16, 16)]; } /** @@ -988,7 +1012,7 @@ * @return the default display */ public static Display getDefault () { - synchronized (Device.class) { + synchronized (Device.classinfo) { if (Default is null) Default = new Display (); return Default; } @@ -1021,7 +1045,7 @@ */ public Object getData (String key) { checkDevice (); - if (key is null) error (DWT.ERROR_NULL_ARGUMENT); + //if (key is null) error (DWT.ERROR_NULL_ARGUMENT); if (keys is null) return null; for (int i=0; i<keys.length; i++) { if (keys [i].equals (key)) return values [i]; @@ -1116,12 +1140,12 @@ if (window !is null) { NSResponder view = window.firstResponder(); if (view !is null && view.respondsToSelector(OS.sel_tag)) { - int tag = OS.objc_msgSend(view.id, OS.sel_tag); + NSInteger tag = OS.objc_msgSend(view.id_, OS.sel_tag); if (tag !is -1) { Object object = OS.JNIGetObject(tag); - if (object instanceof Control) { + if (cast(Control) object) { //TODO go up hierarchy - return (Control)object; + return cast(Control)object; } } else { /* @@ -1129,17 +1153,17 @@ * delegate as the focus control. */ if (view.isKindOfClass(NSText.static_class())) { - NSText text = new NSText(view.id); + NSText text = new NSText(view.id_); if (text.isFieldEditor()) { - id delegateId = text.delegate(); + id delegateId = text.delegatee(); if (delegateId !is null) { - NSObject delegate = new NSObject(delegateId.id); - if (delegate.respondsToSelector(OS.sel_tag)) { - tag = OS.objc_msgSend(delegate.id, OS.sel_tag); + NSObject delegatee = new NSObject(delegateId.id_); + if (delegatee.respondsToSelector(OS.sel_tag)) { + tag = OS.objc_msgSend(delegatee.id_, OS.sel_tag); if (tag !is 0 && tag !is -1) { Object object = OS.JNIGetObject(tag); - if (object instanceof Control) { - return (Control)object; + if (cast(Control) object) { + return cast(Control)object; } } } @@ -1208,9 +1232,9 @@ */ public Point [] getIconSizes () { checkDevice (); - return new Point [] { + return new Point [] [ new Point (16, 16), new Point (32, 32), - new Point (64, 64), new Point (128, 128)}; + new Point (64, 64), new Point (128, 128)]; } int getLastEventTime () { @@ -1219,7 +1243,7 @@ * in seconds and we need an accurate time in milliseconds. */ // return (int) (OS.GetLastUserEventTime () * 1000.0); - return (int) System.currentTimeMillis (); + return cast(int) System.currentTimeMillis (); } //Menu [] getMenus (Decorations shell) { @@ -1262,24 +1286,24 @@ * * @since 3.0 */ -public Monitor [] getMonitors () { +public dwt.widgets.Monitor.Monitor [] getMonitors () { checkDevice (); NSArray screens = NSScreen.screens(); int count = screens.count(); - Monitor [] monitors = new Monitor [count]; + dwt.widgets.Monitor.Monitor [] monitors = new dwt.widgets.Monitor.Monitor [count]; for (int i=0; i<count; i++) { - Monitor monitor = new Monitor (); + dwt.widgets.Monitor.Monitor monitor = new dwt.widgets.Monitor.Monitor (); NSScreen screen = new NSScreen(screens.objectAtIndex(i)); NSRect frame = screen.frame(); - monitor.x = (int)frame.x; - monitor.y = (int)frame.y; - monitor.width = (int)frame.width; - monitor.height = (int)frame.height; + monitor.x = cast(int)frame.x; + monitor.y = cast(int)frame.y; + monitor.width = cast(int)frame.width; + monitor.height = cast(int)frame.height; NSRect visibleFrame = screen.visibleFrame(); - monitor.clientX = (int)visibleFrame.x; - monitor.clientY = (int)visibleFrame.y; - monitor.clientWidth = (int)visibleFrame.width; - monitor.clientHeight = (int)visibleFrame.height; + monitor.clientX = cast(int)visibleFrame.x; + monitor.clientY = cast(int)visibleFrame.y; + monitor.clientWidth = cast(int)visibleFrame.width; + monitor.clientHeight = cast(int)visibleFrame.height; monitors [i] = monitor; } return monitors; @@ -1292,20 +1316,20 @@ * * @since 3.0 */ -public Monitor getPrimaryMonitor () { +public dwt.widgets.Monitor.Monitor getPrimaryMonitor () { checkDevice (); - Monitor monitor = new Monitor (); + dwt.widgets.Monitor.Monitor monitor = new dwt.widgets.Monitor.Monitor (); NSScreen screen = NSScreen.mainScreen(); NSRect frame = screen.frame(); - monitor.x = (int)frame.x; - monitor.y = (int)frame.y; - monitor.width = (int)frame.width; - monitor.height = (int)frame.height; + monitor.x = cast(int)frame.x; + monitor.y = cast(int)frame.y; + monitor.width = cast(int)frame.width; + monitor.height = cast(int)frame.height; NSRect visibleFrame = screen.visibleFrame(); - monitor.clientX = (int)visibleFrame.x; - monitor.clientY = (int)visibleFrame.y; - monitor.clientWidth = (int)visibleFrame.width; - monitor.clientHeight = (int)visibleFrame.height; + monitor.clientX = cast(int)visibleFrame.x; + monitor.clientY = cast(int)visibleFrame.y; + monitor.clientWidth = cast(int)visibleFrame.width; + monitor.clientHeight = cast(int)visibleFrame.height; return monitor; } @@ -1329,11 +1353,11 @@ NSWindow window = new NSWindow(windows.objectAtIndex(i)); NSView view = window.contentView(); if (view !is null) { - int jniRef = OS.objc_msgSend(view.id, OS.sel_tag); + NSInteger jniRef = OS.objc_msgSend(view.id_, OS.sel_tag); if (jniRef !is 0 && jniRef !is -1) { Object object = OS.JNIGetObject(jniRef); - if (object instanceof Shell) { - result[index++] = (Shell)object; + if (cast(Shell) object) { + result[index++] = cast(Shell)object; } } } @@ -1377,7 +1401,7 @@ * </ul> */ public Thread getSyncThread () { - synchronized (Device.class) { + synchronized (Device.classinfo) { if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED); return synchronizer.syncThread; } @@ -1407,7 +1431,7 @@ NSColor color = null; switch (id) { case DWT.COLOR_INFO_FOREGROUND: return super.getSystemColor (DWT.COLOR_BLACK); - case DWT.COLOR_INFO_BACKGROUND: return Color.cocoa_new (this, new float [] {0xFF / 255f, 0xFF / 255f, 0xE1 / 255f, 1}); + case DWT.COLOR_INFO_BACKGROUND: return Color.cocoa_new (this, new float [] [0xFF / 255f, 0xFF / 255f, 0xE1 / 255f, 1]); case DWT.COLOR_TITLE_FOREGROUND: color = NSColor.windowFrameTextColor(); break; case DWT.COLOR_TITLE_BACKGROUND: color = NSColor.secondarySelectedControlColor(); break; case DWT.COLOR_TITLE_BACKGROUND_GRADIENT: color = NSColor.windowFrameColor(); break; @@ -1433,7 +1457,7 @@ if (color is null) return super.getSystemColor(id); float[] components = new float[color.numberOfComponents()]; color.getComponents(components); - return Color.cocoa_new (this, new float[]{components[0], components[1], components[2], components[3]}); + return Color.cocoa_new (this, new float[][components[0], components[1], components[2], components[3]]); } /** @@ -1564,7 +1588,7 @@ * </ul> */ public Thread getThread () { - synchronized (Device.class) { + synchronized (Device.classinfo) { if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED); return thread; } @@ -1592,7 +1616,7 @@ if (appProc3 is 0) error (DWT.ERROR_NO_MORE_CALLBACKS); String className = "SWTApplicationDelegate"; - int cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0); + objc.Class cls = OS.objc_allocateClassPair(OS.classinfo_NSObject, className, 0); OS.class_addMethod(cls, OS.sel_applicationWillFinishLaunching_1, appProc3, "@:@"); OS.class_addMethod(cls, OS.sel_terminate_1, appProc3, "@:@"); OS.class_addMethod(cls, OS.sel_orderFrontStandardAboutPanel_1, appProc3, "@:@"); @@ -1603,7 +1627,7 @@ OS.class_addMethod(cls, OS.sel_applicationWillTerminate_1, appProc3, "@:@"); OS.objc_registerClassPair(cls); - applicationDelegate = (SWTApplicationDelegate)new SWTApplicationDelegate().alloc().init(); + applicationDelegate = cast(SWTApplicationDelegate)(new SWTApplicationDelegate()).alloc().init(); application.setDelegate(applicationDelegate); } @@ -1631,8 +1655,8 @@ int drawRectProc = OS.drawRect_CALLBACK(proc3); String className = "SWTWindowDelegate"; - int cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0); - OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i"); + objc.Class cls = OS.objc_allocateClassPair(OS.classinfo_NSObject, className, 0); + OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, cast(byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i"); OS.class_addMethod(cls, OS.sel_windowDidResize_1, proc3, "@:@"); OS.class_addMethod(cls, OS.sel_windowShouldClose_1, proc3, "@:@"); OS.class_addMethod(cls, OS.sel_windowWillClose_1, proc3, "@:@"); @@ -1645,8 +1669,8 @@ OS.objc_registerClassPair(cls); className = "SWTPanelDelegate"; - cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0); - OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i"); + cls = OS.objc_allocateClassPair(OS.classinfo_NSObject, className, 0); + OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, cast(byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i"); OS.class_addMethod(cls, OS.sel_windowWillClose_1, dialogProc3, "@:@"); OS.class_addMethod(cls, OS.sel_changeColor_1, dialogProc3, "@:@"); OS.class_addMethod(cls, OS.sel_changeFont_1, dialogProc3, "@:@"); @@ -1655,8 +1679,8 @@ OS.objc_registerClassPair(cls); className = "SWTMenu"; - cls = OS.objc_allocateClassPair(OS.class_NSMenu, className, 0); - OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i"); + cls = OS.objc_allocateClassPair(OS.classinfo_NSMenu, className, 0); + OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, cast(byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i"); OS.class_addMethod(cls, OS.sel_tag, proc2, "@:"); OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i"); // OS.class_addMethod(cls, OS.sel_menuWillOpen_1, proc3, "@:@"); @@ -1667,8 +1691,8 @@ OS.objc_registerClassPair(cls); className = "SWTView"; - cls = OS.objc_allocateClassPair(OS.class_NSView, className, 0); - OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i"); + cls = OS.objc_allocateClassPair(OS.classinfo_NSView, className, 0); + OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, cast(byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i"); OS.class_addMethod(cls, OS.sel_tag, proc2, "@:"); OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i"); OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:"); @@ -1684,8 +1708,8 @@ OS.objc_registerClassPair(cls); className = "SWTScrollView"; - cls = OS.objc_allocateClassPair(OS.class_NSScrollView, className, 0); - OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i"); + cls = OS.objc_allocateClassPair(OS.classinfo_NSScrollView, className, 0); + OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, cast(byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i"); OS.class_addMethod(cls, OS.sel_tag, proc2, "@:"); OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i"); OS.class_addMethod(cls, OS.sel_sendVerticalSelection, proc2, "@:"); @@ -1694,7 +1718,7 @@ OS.objc_registerClassPair(cls); className = "SWTButton"; - cls = OS.objc_allocateClassPair(OS.class_NSButton, className, 0); + cls = OS.objc_allocateClassPair(OS.classinfo_NSButton, className, 0); // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:"); // OS.class_addMethod(cls, OS.sel_mouseDown_1, proc3, "@:@"); OS.class_addMethod(cls, OS.sel_drawRect_1, drawRectProc, "@:i"); @@ -1704,7 +1728,7 @@ OS.objc_registerClassPair(cls); className = "SWTTableView"; - cls = OS.objc_allocateClassPair(OS.class_NSTableView, className, 0); + cls = OS.objc_allocateClassPair(OS.classinfo_NSTableView, className, 0); OS.class_addMethod(cls, OS.sel_sendDoubleSelection, proc2, "@:"); // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:"); OS.class_addMethod(cls, OS.sel_numberOfRowsInTableView_1, proc3, "@:@"); @@ -1717,7 +1741,7 @@ OS.objc_registerClassPair(cls); className = "SWTOutlineView"; - cls = OS.objc_allocateClassPair(OS.class_NSOutlineView, className, 0); + cls = OS.objc_allocateClassPair(OS.classinfo_NSOutlineView, className, 0); OS.class_addMethod(cls, OS.sel_sendDoubleSelection, proc2, "@:"); OS.class_addMethod(cls, OS.sel_outlineViewSelectionDidChange_1, proc3, "@:@"); OS.class_addMethod(cls, OS.sel_outlineView_1shouldCollapseItem_1, proc4, "@:@@"); @@ -1732,17 +1756,17 @@ OS.objc_registerClassPair(cls); className = "SWTTreeItem"; - cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0); + cls = OS.objc_allocateClassPair(OS.classinfo_NSObject, className, 0); // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:"); - OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i"); + OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, cast(byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i"); OS.class_addMethod(cls, OS.sel_tag, proc2, "@:"); OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i"); OS.objc_registerClassPair(cls); className = "SWTTabView"; - cls = OS.objc_allocateClassPair(OS.class_NSTabView, className, 0); + cls = OS.objc_allocateClassPair(OS.classinfo_NSTabView, className, 0); // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:"); - OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i"); + OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, cast(byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i"); OS.class_addMethod(cls, OS.sel_tabView_1willSelectTabViewItem_1, proc4, "@:@@"); OS.class_addMethod(cls, OS.sel_tag, proc2, "@:"); OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i"); @@ -1750,38 +1774,38 @@ OS.objc_registerClassPair(cls); className = "SWTBox"; - cls = OS.objc_allocateClassPair(OS.class_NSBox, className, 0); + cls = OS.objc_allocateClassPair(OS.classinfo_NSBox, className, 0); // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:"); - OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i"); + OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, cast(byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i"); OS.class_addMethod(cls, OS.sel_tag, proc2, "@:"); OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i"); OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@"); OS.objc_registerClassPair(cls); className = "SWTProgressIndicator"; - cls = OS.objc_allocateClassPair(OS.class_NSProgressIndicator, className, 0); + cls = OS.objc_allocateClassPair(OS.classinfo_NSProgressIndicator, className, 0); // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:"); - OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i"); + OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, cast(byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i"); OS.class_addMethod(cls, OS.sel_tag, proc2, "@:"); OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i"); OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@"); OS.objc_registerClassPair(cls); className = "SWTSlider"; - cls = OS.objc_allocateClassPair(OS.class_NSSlider, className, 0); + cls = OS.objc_allocateClassPair(OS.classinfo_NSSlider, className, 0); // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:"); OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@"); OS.objc_registerClassPair(cls); className = "SWTPopUpButton"; - cls = OS.objc_allocateClassPair(OS.class_NSPopUpButton, className, 0); + cls = OS.objc_allocateClassPair(OS.classinfo_NSPopUpButton, className, 0); // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:"); OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:"); OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@"); OS.objc_registerClassPair(cls); className = "SWTComboBox"; - cls = OS.objc_allocateClassPair(OS.class_NSComboBox, className, 0); + cls = OS.objc_allocateClassPair(OS.classinfo_NSComboBox, className, 0); // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:"); OS.class_addMethod(cls, OS.sel_comboBoxSelectionDidChange_1, proc3, "@:@"); OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:"); @@ -1789,14 +1813,14 @@ OS.objc_registerClassPair(cls); className = "SWTDatePicker"; - cls = OS.objc_allocateClassPair(OS.class_NSDatePicker, className, 0); + cls = OS.objc_allocateClassPair(OS.classinfo_NSDatePicker, className, 0); // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:"); OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:"); OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@"); OS.objc_registerClassPair(cls); className = "SWTImageView"; - cls = OS.objc_allocateClassPair(OS.class_NSImageView, className, 0); + cls = OS.objc_allocateClassPair(OS.classinfo_NSImageView, className, 0); // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:"); OS.class_addMethod(cls, OS.sel_drawRect_1, OS.drawRect_CALLBACK(proc3), "@:i"); OS.class_addMethod(cls, OS.sel_mouseDown_1, proc3, "@:@"); @@ -1806,30 +1830,30 @@ OS.objc_registerClassPair(cls); className = "SWTStepper"; - cls = OS.objc_allocateClassPair(OS.class_NSStepper, className, 0); + cls = OS.objc_allocateClassPair(OS.classinfo_NSStepper, className, 0); // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:"); OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:"); OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@"); OS.objc_registerClassPair(cls); className = "SWTScroller"; - cls = OS.objc_allocateClassPair(OS.class_NSScroller, className, 0); + cls = OS.objc_allocateClassPair(OS.classinfo_NSScroller, className, 0); // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:"); OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:"); OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@"); OS.objc_registerClassPair(cls); className = "SWTMenuItem"; - cls = OS.objc_allocateClassPair(OS.class_NSMenuItem, className, 0); + cls = OS.objc_allocateClassPair(OS.classinfo_NSMenuItem, className, 0); // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:"); OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:"); OS.objc_registerClassPair(cls); className = "SWTTextView"; - cls = OS.objc_allocateClassPair(OS.class_NSTextView, className, 0); + cls = OS.objc_allocateClassPair(OS.classinfo_NSTextView, className, 0); // OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:"); // OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:"); - OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i"); + OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, cast(byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i"); OS.class_addMethod(cls, OS.sel_tag, proc2, "@:"); OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i"); OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@"); @@ -1837,13 +1861,13 @@ OS.objc_registerClassPair(cls); className = "SWTTextField"; - cls = OS.objc_allocateClassPair(OS.class_NSTextField, className, 0); + cls = OS.objc_allocateClassPair(OS.classinfo_NSTextField, className, 0); OS.class_addMethod(cls, OS.sel_drawRect_1, drawRectProc, "@:i"); OS.objc_registerClassPair(cls); className = "SWTWindow"; - cls = OS.objc_allocateClassPair(OS.class_NSWindow, className, 0); - OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i"); + cls = OS.objc_allocateClassPair(OS.classinfo_NSWindow, className, 0); + OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, cast(byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i"); OS.class_addMethod(cls, OS.sel_tag, proc2, "@:"); OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i"); OS.class_addMethod(cls, OS.sel_sendEvent_1, proc3, "@:@"); @@ -1872,7 +1896,7 @@ * <li>ERROR_NO_HANDLES if a handle could not be obtained for gc creation</li> * </ul> */ -public int internal_new_GC (GCData data) { +public objc.id internal_new_GC (GCData data) { if (isDisposed()) DWT.error(DWT.ERROR_DEVICE_DISPOSED); NSGraphicsContext context = application.context(); // NSAffineTransform transform = NSAffineTransform.transform(); @@ -1890,7 +1914,7 @@ data.foreground = getSystemColor(DWT.COLOR_BLACK).handle; data.font = getSystemFont(); } - return context.id; + return context.id_; } /** @@ -1912,13 +1936,13 @@ } static bool isValidClass (Class clazz) { - String name = clazz.getName (); + String name = clazz.name; int index = name.lastIndexOf ('.'); return name.substring (0, index + 1).equals (PACKAGE_PREFIX); } bool isValidThread () { - return thread is Thread.currentThread (); + return thread is Thread.getThis (); } /** @@ -1975,7 +1999,7 @@ * */ public bool post(Event event) { - synchronized (Device.class) { + synchronized (Device.classinfo) { if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED); if (event is null) error (DWT.ERROR_NULL_ARGUMENT); // int type = event.type; @@ -2196,12 +2220,12 @@ if (to !is null && to.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT); Point point = new Point (x, y); if (from is to) return point; - NSPoint pt = new NSPoint(); + NSPoint pt = NSPoint(); pt.x = x; pt.y = y; NSWindow fromWindow = from !is null ? from.view.window() : null; NSWindow toWindow = to !is null ? to.view.window() : null; - if (toWindow !is null && fromWindow !is null && toWindow.id is fromWindow.id) { + if (toWindow !is null && fromWindow !is null && toWindow.id_ is fromWindow.id_) { pt = from.view.convertPoint_toView_(pt, to.view); } else { if (from !is null) { @@ -2215,8 +2239,8 @@ pt = to.view.convertPoint_fromView_(pt, null); } } - point.x = (int)pt.x; - point.y = (int)pt.y; + point.x = cast(int)pt.x; + point.y = cast(int)pt.y; return point; } @@ -2306,12 +2330,12 @@ if (to !is null && to.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT); Rectangle rectangle = new Rectangle (x, y, width, height); if (from is to) return rectangle; - NSPoint pt = new NSPoint(); + NSPoint pt = NSPoint(); pt.x = x; pt.y = y; NSWindow fromWindow = from !is null ? from.view.window() : null; NSWindow toWindow = to !is null ? to.view.window() : null; - if (toWindow !is null && fromWindow !is null && toWindow.id is fromWindow.id) { + if (toWindow !is null && fromWindow !is null && toWindow.id_ is fromWindow.id_) { pt = from.view.convertPoint_toView_(pt, to.view); } else { if (from !is null) { @@ -2325,8 +2349,8 @@ pt = to.view.convertPoint_fromView_(pt, null); } } - rectangle.x = (int)pt.x; - rectangle.y = (int)pt.y; + rectangle.x = cast(int)pt.x; + rectangle.y = cast(int)pt.y; return rectangle; } @@ -2356,7 +2380,7 @@ */ public bool readAndDispatch () { checkDevice (); - NSAutoreleasePool pool = (NSAutoreleasePool)new NSAutoreleasePool().alloc().init(); + NSAutoreleasePool pool = cast(NSAutoreleasePool)(new NSAutoreleasePool()).alloc().init(); try { bool events = false; events |= runTimers (); @@ -2376,7 +2400,7 @@ } static void register (Display display) { - synchronized (Device.class) { + synchronized (Device.classinfo) { for (int i=0; i<Displays.length; i++) { if (Displays [i] is null) { Displays [i] = display; @@ -2632,7 +2656,7 @@ } //TODO - use custom timer instead of timerExec -Runnable caretTimer = new Runnable () { +Runnable caretTimer = new class Runnable { public void run () { if (currentCaret !is null) { if (currentCaret is null || currentCaret.isDisposed()) return; @@ -2673,7 +2697,7 @@ */ public void setCursorLocation (int x, int y) { checkDevice (); - CGPoint pt = new CGPoint (); + CGPoint pt = CGPoint (); pt.x = x; pt.y = y; OS.CGWarpMouseCursorPosition (pt); } @@ -2726,7 +2750,7 @@ */ public void setData (String key, Object value) { checkDevice (); - if (key is null) error (DWT.ERROR_NULL_ARGUMENT); + //if (key is null) error (DWT.ERROR_NULL_ARGUMENT); /* Remove the key/value pair */ if (value is null) { @@ -2752,8 +2776,8 @@ /* Add the key/value pair */ if (keys is null) { - keys = new String [] {key}; - values = new Object [] {value}; + keys = new String [] [key]; + values = new Object [] [value]; return; } for (int i=0; i<keys.length; i++) { @@ -2784,7 +2808,7 @@ menuBar = menu; //remove all existing menu items except the application menu NSMenu menubar = application.mainMenu(); - int count = menubar.numberOfItems(); + NSInteger count = menubar.numberOfItems(); while (count > 1) { menubar.removeItemAtIndex(count - 1); count--; @@ -2847,7 +2871,7 @@ if (synchronizer is null) error (DWT.ERROR_NULL_ARGUMENT); if (synchronizer is this.synchronizer) return; Synchronizer oldSynchronizer; - synchronized (Device.class) { + synchronized (Device.classinfo) { oldSynchronizer = this.synchronizer; this.synchronizer = synchronizer; } @@ -2873,7 +2897,7 @@ public bool sleep () { checkDevice (); if (getMessageCount () !is 0) return true; - NSAutoreleasePool pool = (NSAutoreleasePool)new NSAutoreleasePool().alloc().init(); + NSAutoreleasePool pool = cast(NSAutoreleasePool)(new NSAutoreleasePool()).alloc().init(); try { allowTimers = runAsyncMessages = false; NSRunLoop.currentRunLoop().runMode(OS.NSDefaultRunLoopMode, NSDate.distantFuture()); @@ -2912,7 +2936,7 @@ */ public void syncExec (Runnable runnable) { Synchronizer synchronizer; - synchronized (Device.class) { + synchronized (Device.classinfo) { if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED); synchronizer = this.synchronizer; } @@ -2981,7 +3005,7 @@ nsTimers = newTimerIds; } NSNumber userInfo = NSNumber.numberWithInt(index); - NSTimer timer = NSTimer.static_scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(milliseconds / 1000.0, timerDelegate, OS.sel_timerProc_1, userInfo.id, false); + NSTimer timer = NSTimer.static_scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(milliseconds / 1000.0, timerDelegate, OS.sel_timerProc_1, userInfo.id_, false); timer.retain(); if (timer !is null) { nsTimers [index] = timer; @@ -3042,19 +3066,19 @@ * @see #sleep */ public void wake () { - synchronized (Device.class) { + synchronized (Device.classinfo) { if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED); - if (thread is Thread.currentThread ()) return; + if (thread is Thread.getThis ()) return; wakeThread (); } } void wakeThread () { - NSObject object = new NSObject().alloc().init(); + NSObject object = (new NSObject()).alloc().init(); object.performSelectorOnMainThread_withObject_waitUntilDone_(OS.sel_release, null, false); } -int applicationDelegateProc(int id, int sel, int arg0) { +int applicationDelegateProc(int ID, String sel, int arg0) { if (sel is OS.sel_applicationWillFinishLaunching_1) { id dict = NSDictionary.dictionaryWithObject(applicationDelegate, NSString.stringWith("NSOwner")); NSString nibFile = NSString.stringWith("/System/Library/Frameworks/JavaVM.framework/Resources/English.lproj/DefaultApp.nib"); @@ -3101,191 +3125,191 @@ } -int dialogProc(int id, int sel, int arg0) { - int jniRef = OS.objc_msgSend(id, OS.sel_tag); +int dialogProc(int id, String sel, int arg0) { + NSIntger jniRef = cast(NSIntger) OS.objc_msgSend(id, OS.sel_tag); if (jniRef is 0 || jniRef is -1) return 0; - if (sel is OS.sel_changeColor_1) { - ColorDialog dialog = (ColorDialog)OS.JNIGetObject(jniRef); + if (sel == OS.sel_changeColor_1) { + ColorDialog dialog = cast(ColorDialog)OS.JNIGetObject(jniRef); if (dialog is null) return 0; dialog.changeColor(arg0); - } else if (sel is OS.sel_changeFont_1) { - FontDialog dialog = (FontDialog)OS.JNIGetObject(jniRef); + } else if (sel == OS.sel_changeFont_1) { + FontDialog dialog = cast(FontDialog)OS.JNIGetObject(jniRef); if (dialog is null) return 0; dialog.changeFont(arg0); - } else if (sel is OS.sel_windowWillClose_1) { + } else if (sel == OS.sel_windowWillClose_1) { Object object = OS.JNIGetObject(jniRef); - if (object instanceof FontDialog) { - ((FontDialog)object).windowWillClose(arg0); - } else if (object instanceof ColorDialog) { - ((ColorDialog)object).windowWillClose(arg0); + if (cast(FontDialog) object) { + (cast(FontDialog)object).windowWillClose(arg0); + } else if (cast(ColorDialog) object) { + (cast(ColorDialog)object).windowWillClose(arg0); } } return 0; } -int windowDelegateProc(int delegate, int sel) { - if (sel is OS.sel_tag) { - int[] tag = new int[1]; - OS.object_getInstanceVariable(delegate, "tag", tag); +int windowDelegateProc(objc.id delegatee, String sel) { + if (sel == OS.sel_tag) { + int[1] tag; + OS.object_getInstanceVariable(delegatee, "tag", tag); return tag[0]; } - int jniRef = OS.objc_msgSend(delegate, OS.sel_tag); + NSInteger jniRef = cast(NSInteger) OS.objc_msgSend(delegatee, OS.sel_tag); if (jniRef is 0 || jniRef is -1) return 0; - Widget widget = (Widget)OS.JNIGetObject(jniRef); + Widget widget = cast(Widget)OS.JNIGetObject(jniRef); if (widget is null) return 0; - if (sel is OS.sel_isFlipped) { + if (sel == OS.sel_isFlipped) { return widget.isFlipped() ? 1 : 0; } - if (sel is OS.sel_sendSelection) { + if (sel == OS.sel_sendSelection) { widget.sendSelection(); return 0; } - if (sel is OS.sel_sendArrowSelection) { + if (sel == OS.sel_sendArrowSelection) { widget.sendArrowSelection(); return 0; } - if (sel is OS.sel_sendDoubleSelection) { + if (sel == OS.sel_sendDoubleSelection) { widget.sendDoubleSelection(); return 0; } - if (sel is OS.sel_sendVerticalSelection) { + if (sel == OS.sel_sendVerticalSelection) { widget.sendVerticalSelection(); return 0; } - if (sel is OS.sel_sendHorizontalSelection) { + if (sel == OS.sel_sendHorizontalSelection) { widget.sendHorizontalSelection(); return 0; } - if (sel is OS.sel_acceptsFirstResponder) { + if (sel == OS.sel_acceptsFirstResponder) { return widget.acceptsFirstResponder() ? 1 : 0; } - if (sel is OS.sel_becomeFirstResponder) { + if (sel == OS.sel_becomeFirstResponder) { return widget.becomeFirstResponder() ? 1 : 0; } - if (sel is OS.sel_resignFirstResponder) { + if (sel == OS.sel_resignFirstResponder) { return widget.resignFirstResponder() ? 1 : 0; } return 0; } -int windowDelegateProc(int id, int sel, int arg0) { - if (sel is OS.sel_timerProc_1) { +int windowDelegateProc(objc.id ID, int sel, int arg0) { + if (sel == OS.sel_timerProc_1) { return timerProc (arg0); } - if (sel is OS.sel_setTag_1) { + if (sel == OS.sel_setTag_1) { OS.object_setInstanceVariable(id, "tag", arg0); return 0; } - int jniRef = OS.objc_msgSend(id, OS.sel_tag); + int jniRef = OS.objc_msgSend(ID, OS.sel_tag); if (jniRef is 0 || jniRef is -1) return 0; - Widget widget = (Widget)OS.JNIGetObject(jniRef); + Widget widget = cast(Widget)OS.JNIGetObject(jniRef); if (widget is null) return 0; - if (sel is OS.sel_windowWillClose_1) { + if (sel == OS.sel_windowWillClose_1) { widget.windowWillClose(arg0); - } else if (sel is OS.sel_drawRect_1) { - NSRect rect = new NSRect(); + } else if (sel == OS.sel_drawRect_1) { + NSRect rect = NSRect(); OS.memmove(rect, arg0, NSRect.sizeof); - widget.drawRect(id, rect); - } else if (sel is OS.sel_windowShouldClose_1) { + widget.drawRect(ID, rect); + } else if (sel == OS.sel_windowShouldClose_1) { return widget.windowShouldClose(arg0) ? 1 : 0; - } else if (sel is OS.sel_mouseDown_1) { + } else if (sel == OS.sel_mouseDown_1) { widget.mouseDown(arg0); - } else if (sel is OS.sel_rightMouseDown_1) { + } else if (sel == OS.sel_rightMouseDown_1) { widget.rightMouseDown(arg0); - } else if (sel is OS.sel_mouseDragged_1) { + } else if (sel == OS.sel_mouseDragged_1) { widget.mouseDragged(arg0); - } else if (sel is OS.sel_mouseUp_1) { + } else if (sel == OS.sel_mouseUp_1) { widget.mouseUp(arg0); - } else if (sel is OS.sel_mouseEntered_1) { + } else if (sel == OS.sel_mouseEntered_1) { widget.mouseEntered(arg0); - } else if (sel is OS.sel_flagsChanged_1) { + } else if (sel == OS.sel_flagsChanged_1) { widget.flagsChanged(arg0); - } else if (sel is OS.sel_numberOfRowsInTableView_1) { + } else if (sel == OS.sel_numberOfRowsInTableView_1) { return widget.numberOfRowsInTableView(arg0); - } else if (sel is OS.sel_comboBoxSelectionDidChange_1) { + } else if (sel == OS.sel_comboBoxSelectionDidChange_1) { widget.comboBoxSelectionDidChange(arg0); - } else if (sel is OS.sel_tableViewSelectionDidChange_1) { + } else if (sel == OS.sel_tableViewSelectionDidChange_1) { widget.tableViewSelectionDidChange(arg0); - } else if (sel is OS.sel_windowDidResignKey_1) { + } else if (sel == OS.sel_windowDidResignKey_1) { widget.windowDidResignKey(arg0); - } else if (sel is OS.sel_windowDidBecomeKey_1) { + } else if (sel == OS.sel_windowDidBecomeKey_1) { widget.windowDidBecomeKey(arg0); - } else if (sel is OS.sel_windowDidResize_1) { + } else if (sel == OS.sel_windowDidResize_1) { widget.windowDidResize(arg0); - } else if (sel is OS.sel_windowDidMove_1) { + } else if (sel == OS.sel_windowDidMove_1) { widget.windowDidMove(arg0); - } else if (sel is OS.sel_menuForEvent_1) { + } else if (sel == OS.sel_menuForEvent_1) { return widget.menuForEvent(arg0); - } else if (sel is OS.sel_menuWillOpen_1) { + } else if (sel == OS.sel_menuWillOpen_1) { widget.menuWillOpen(arg0); - } else if (sel is OS.sel_menuWillClose_1) { + } else if (sel == OS.sel_menuWillClose_1) { widget.menuWillClose(arg0); - } else if (sel is OS.sel_menuNeedsUpdate_1) { + } else if (sel == OS.sel_menuNeedsUpdate_1) { widget.menuNeedsUpdate(arg0); - } else if (sel is OS.sel_outlineViewSelectionDidChange_1) { + } else if (sel == OS.sel_outlineViewSelectionDidChange_1) { widget.outlineViewSelectionDidChange(arg0); - } else if (sel is OS.sel_sendEvent_1) { + } else if (sel == OS.sel_sendEvent_1) { widget.windowSendEvent(id, arg0); - } else if (sel is OS.sel_helpRequested_1) { + } else if (sel == OS.sel_helpRequested_1) { widget.helpRequested(arg0); } return 0; } -int windowDelegateProc(int delegate, int sel, int arg0, int arg1) { - int jniRef = OS.objc_msgSend(delegate, OS.sel_tag); +int windowDelegateProc(objc.id delegatee, String sel, int arg0, int arg1) { + NSInteger jniRef = cast(NSInteger) OS.objc_msgSend(delegatee, OS.sel_tag); if (jniRef is 0 || jniRef is -1) return 0; - Widget widget = (Widget)OS.JNIGetObject(jniRef); + Widget widget = cast(Widget)OS.JNIGetObject(jniRef); if (widget is null) return 0; - if (sel is OS.sel_tabView_1willSelectTabViewItem_1) { + if (sel == OS.sel_tabView_1willSelectTabViewItem_1) { widget.willSelectTabViewItem(arg0, arg1); - } else if (sel is OS.sel_outlineView_1isItemExpandable_1) { + } else if (sel == OS.sel_outlineView_1isItemExpandable_1) { return widget.outlineView_isItemExpandable(arg0, arg1) ? 1 : 0; - } else if (sel is OS.sel_outlineView_1numberOfChildrenOfItem_1) { + } else if (sel == OS.sel_outlineView_1numberOfChildrenOfItem_1) { return widget.outlineView_numberOfChildrenOfItem(arg0, arg1); - } else if (sel is OS.sel_outlineView_1shouldCollapseItem_1) { + } else if (sel == OS.sel_outlineView_1shouldCollapseItem_1) { return widget.outlineView_shouldCollapseItem(arg0, arg1) ? 1 : 0; - } else if (sel is OS.sel_outlineView_1shouldExpandItem_1) { + } else if (sel == OS.sel_outlineView_1shouldExpandItem_1) { return widget.outlineView_shouldExpandItem(arg0, arg1) ? 1 : 0; - } else if (sel is OS.sel_menu_1willHighlightItem_1) { + } else if (sel == OS.sel_menu_1willHighlightItem_1) { widget.menu_willHighlightItem(arg0, arg1); } return 0; } -int windowDelegateProc(int delegate, int sel, int arg0, int arg1, int arg2) { - int jniRef = OS.objc_msgSend(delegate, OS.sel_tag); +int windowDelegateProc(objc.id delegatee, int sel, int arg0, int arg1, int arg2) { + NSInteger jniRef = cast(NSInteger) OS.objc_msgSend(delegatee, OS.sel_tag); if (jniRef is 0 || jniRef is -1) return 0; - Widget widget = (Widget)OS.JNIGetObject(jniRef); + Widget widget = cast(Widget)OS.JNIGetObject(jniRef); if (widget is null) return 0; - if (sel is OS.sel_tableView_1objectValueForTableColumn_1row_1) { + if (sel == OS.sel_tableView_1objectValueForTableColumn_1row_1) { return widget.tableView_objectValueForTableColumn_row(arg0, arg1, arg2); } - if (sel is OS.sel_tableView_1shouldEditTableColumn_1row_1) { + if (sel == OS.sel_tableView_1shouldEditTableColumn_1row_1) { return widget.tableView_shouldEditTableColumn_row(arg0, arg1, arg2) ? 1 : 0; - } else if (sel is OS.sel_textView_1clickedOnLink_1atIndex_1) { + } else if (sel == OS.sel_textView_1clickedOnLink_1atIndex_1) { return widget.clickOnLink(arg0, arg1, arg2) ? 1 : 0; - } else if (sel is OS.sel_outlineView_1child_1ofItem_1) { + } else if (sel == OS.sel_outlineView_1child_1ofItem_1) { return widget.outlineView_child_ofItem(arg0, arg1, arg2); - } else if (sel is OS.sel_outlineView_1objectValueForTableColumn_1byItem_1) { + } else if (sel == OS.sel_outlineView_1objectValueForTableColumn_1byItem_1) { return widget.outlineView_objectValueForTableColumn_byItem(arg0, arg1, arg2); } return 0; } -int windowDelegateProc(int delegate, int sel, int arg0, int arg1, int arg2, int arg3) { - int jniRef = OS.objc_msgSend(delegate, OS.sel_tag); +int windowDelegateProc(objc.id delegatee, int sel, int arg0, int arg1, int arg2, int arg3) { + NSInteger jniRef = cast(NSInteger) OS.objc_msgSend(delegatee, OS.sel_tag); if (jniRef is 0 || jniRef is -1) return 0; - Widget widget = (Widget)OS.JNIGetObject(jniRef); + Widget widget = cast(Widget)OS.JNIGetObject(jniRef); if (widget is null) return 0; - if (sel is OS.sel_tableView_1willDisplayCell_1forTableColumn_1row_1) { + if (sel == OS.sel_tableView_1willDisplayCell_1forTableColumn_1row_1) { widget.tableView_willDisplayCell_forTableColumn_row(arg0, arg1, arg2, arg3); - } else if (sel is OS.sel_outlineView_1willDisplayCell_1forTableColumn_1item_1) { + } else if (sel == OS.sel_outlineView_1willDisplayCell_1forTableColumn_1item_1) { widget.outlineView_willDisplayCell_forTableColumn_item(arg0, arg1, arg2, arg3); - } else if (sel is OS.sel_outlineView_1setObjectValue_1forTableColumn_1byItem_1) { + } else if (sel == OS.sel_outlineView_1setObjectValue_1forTableColumn_1byItem_1) { widget.outlineView_setObjectValue_forTableColumn_byItem(arg0, arg1, arg2, arg3); - } else if (sel is OS.sel_tableView_1setObjectValue_1forTableColumn_1row_1) { + } else if (sel == OS.sel_tableView_1setObjectValue_1forTableColumn_1row_1) { widget.tableView_setObjectValue_forTableColumn_row(arg0, arg1, arg2, arg3); } return 0;