changeset 19:fba856099f87

Ported dwt.widgets.Display
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Wed, 03 Sep 2008 20:59:39 +0200
parents b55912b6771e
children 453387bb0706
files dwt/internal/cocoa/OS.d dwt/internal/objc/runtime.d dwt/widgets/Display.d dwt/widgets/Menu.d dwt/widgets/Shell.d
diffstat 5 files changed, 128 insertions(+), 110 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/internal/cocoa/OS.d	Fri Aug 29 22:20:53 2008 +0200
+++ b/dwt/internal/cocoa/OS.d	Wed Sep 03 20:59:39 2008 +0200
@@ -62,7 +62,7 @@
 
     static this ()
     {
-        SInt32[1] response;
+        int[1] response;
         OS.Gestalt(OS.gestaltSystemVersion, response);
         VERSION = response[0] & 0xffff;
         
@@ -154,7 +154,9 @@
     alias dwt.internal.objc.runtime.objc_msgSendSuper objc_msgSendSuper;
     
     version (X86)
-        alias dwt.internal.objc.runtime.objc_msgSend_fpret objc_msgSend_fpret;     
+        alias dwt.internal.objc.runtime.objc_msgSend_fpret objc_msgSend_fpret;
+        
+    alias dwt.internal.objc.runtime.drawRect_1CALLBACK drawRect_1CALLBACK;
 
     /** Classes */
     public static /*const*/ id class_NSScanner;
--- a/dwt/internal/objc/runtime.d	Fri Aug 29 22:20:53 2008 +0200
+++ b/dwt/internal/objc/runtime.d	Wed Sep 03 20:59:39 2008 +0200
@@ -13,6 +13,7 @@
 import dwt.internal.cocoa.NSPoint;
 import dwt.internal.cocoa.NSRange;
 import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSRect;
 static import dwt.internal.objc.bindings;
 
 
@@ -187,4 +188,22 @@
     {
         return dwt.internal.objc.bindings.objc_msgSend_fpret(self, op.ptr, args);
     }
+}
+
+
+// os_custom
+extern (C):
+alias void function (id, SEL, NSRect) funcPtr;
+static IMP drawRect_1CALLBACK;
+
+
+private void drawRect(id obj, SEL sel, NSRect rect)
+{
+    return cast(funcPtr) drawRect_1CALLBACK(obj, sel, &rect);
+}
+
+funcPtr drawRect_1CALLBACK (IMP func)
+{
+    drawRect_1CALLBACK = func;
+    return &drawRect;
 }
\ No newline at end of file
--- a/dwt/widgets/Display.d	Fri Aug 29 22:20:53 2008 +0200
+++ b/dwt/widgets/Display.d	Wed Sep 03 20:59:39 2008 +0200
@@ -24,7 +24,6 @@
 import dwt.graphics.Image;
 import dwt.graphics.Point;
 import dwt.graphics.Rectangle;
-import dwt.internal.Callback;
 import dwt.internal.cocoa.CGPoint;
 import dwt.internal.cocoa.NSApplication;
 import dwt.internal.cocoa.NSArray;
@@ -58,14 +57,15 @@
 import dwt.internal.cocoa.id;
 
 import tango.core.Thread;
+import tango.stdc.stringz;
 
 import dwt.dwthelper.Runnable;
 import dwt.dwthelper.System;
 import dwt.dwthelper.utils;
 
 import dwt.internal.c.carboncore.MacTypes;
-
 import dwt.internal.cocoa.NSInteger;
+import objc = dwt.internal.objc.runtime;
 
 import dwt.widgets.Caret;
 import dwt.widgets.Control;
@@ -177,11 +177,6 @@
     NSAutoreleasePool pool;
 
     NSPoint cascade = NSPoint();
-
-    Callback applicationDelegateCallback3;
-    Callback windowDelegateCallback2, windowDelegateCallback3, windowDelegateCallback4, windowDelegateCallback5;
-    Callback windowDelegateCallback6;
-    Callback dialogCallback3;
     
     /* Menus */
 //  Menu menuBar;
@@ -1611,12 +1606,10 @@
 }
 
 void initApplicationDelegate() {
-    applicationDelegateCallback3 = new Callback(this, "applicationDelegateProc", 3);
-    int appProc3 = applicationDelegateCallback3.getAddress();
-    if (appProc3 is 0) error (DWT.ERROR_NO_MORE_CALLBACKS);
+    auto appProc3 = &applicationDelegateProc;
 
     String className = "SWTApplicationDelegate";
-    objc.Class cls = OS.objc_allocateClassPair(OS.classinfo_NSObject, className, 0);
+    objc.Class cls = OS.objc_allocateClassPair(OS.class_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, "@:@");
@@ -1627,36 +1620,29 @@
     OS.class_addMethod(cls, OS.sel_applicationWillTerminate_1, appProc3, "@:@");
     OS.objc_registerClassPair(cls);
     
-    applicationDelegate = cast(SWTApplicationDelegate)(new SWTApplicationDelegate()).alloc().init();
+    applicationDelegate = cast(SWTApplicationDelegate)(new SWTApplicationDelegate()).alloc().init();    
     application.setDelegate(applicationDelegate);
 }
 
 void initClasses () {
-    dialogCallback3 = new Callback(this, "dialogProc", 3);
-    int dialogProc3 = dialogCallback3.getAddress();
-    if (dialogProc3 is 0) error (DWT.ERROR_NO_MORE_CALLBACKS);
+    auto dialogProc3 = &dialogProc;
     
-    windowDelegateCallback3 = new Callback(this, "windowDelegateProc", 3);
-    int proc3 = windowDelegateCallback3.getAddress();
-    if (proc3 is 0) error (DWT.ERROR_NO_MORE_CALLBACKS);
-    windowDelegateCallback2 = new Callback(this, "windowDelegateProc", 2);
-    int proc2 = windowDelegateCallback2.getAddress();
-    if (proc2 is 0) error (DWT.ERROR_NO_MORE_CALLBACKS);
-    windowDelegateCallback4 = new Callback(this, "windowDelegateProc", 4);
-    int proc4 = windowDelegateCallback4.getAddress();
-    if (proc4 is 0) error (DWT.ERROR_NO_MORE_CALLBACKS);
-    windowDelegateCallback5 = new Callback(this, "windowDelegateProc", 5);
-    int proc5 = windowDelegateCallback5.getAddress();
-    if (proc5 is 0) error (DWT.ERROR_NO_MORE_CALLBACKS);
-    windowDelegateCallback6 = new Callback(this, "windowDelegateProc", 6);
-    int proc6 = windowDelegateCallback6.getAddress();
-    if (proc6 is 0) error (DWT.ERROR_NO_MORE_CALLBACKS);
+    auto proc3 = &windowDelegateProc3;
+    auto proc2 = &windowDelegateProc2;
+    auto proc4 = &windowDelegateProc4;
+    auto proc5 = &windowDelegateProc5;
+    auto proc6 = &windowDelegateProc6;
     
-    int drawRectProc = OS.drawRect_CALLBACK(proc3);
+    auto drawRectProc = OS.drawRect_CALLBACK(proc3);
 
     String className = "SWTWindowDelegate";
     objc.Class cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0);
-    OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, cast(byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i");
+    
+    static if ((void*).sizeof > int.sizeof) // 64bit target
+        OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, cast(byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "q");
+    else
+        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, "@:@");
@@ -1718,7 +1704,7 @@
     OS.objc_registerClassPair(cls);
     
     className = "SWTButton";
-    cls = OS.objc_allocateClassPair(OS.classinfo_NSButton, className, 0);
+    cls = OS.objc_allocateClassPair(OS.class_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");
@@ -1728,7 +1714,7 @@
     OS.objc_registerClassPair(cls);
     
     className = "SWTTableView";
-    cls = OS.objc_allocateClassPair(OS.classinfo_NSTableView, className, 0);
+    cls = OS.objc_allocateClassPair(OS.class_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, "@:@");
@@ -1741,7 +1727,7 @@
     OS.objc_registerClassPair(cls);
     
     className = "SWTOutlineView";
-    cls = OS.objc_allocateClassPair(OS.classinfo_NSOutlineView, className, 0);
+    cls = OS.objc_allocateClassPair(OS.class_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, "@:@@");
@@ -1756,7 +1742,7 @@
     OS.objc_registerClassPair(cls);
 
     className = "SWTTreeItem";
-    cls = OS.objc_allocateClassPair(OS.classinfo_NSObject, className, 0);
+    cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0);
 //  OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
     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, "@:");
@@ -1764,7 +1750,7 @@
     OS.objc_registerClassPair(cls);
 
     className = "SWTTabView";
-    cls = OS.objc_allocateClassPair(OS.classinfo_NSTabView, className, 0);
+    cls = OS.objc_allocateClassPair(OS.class_NSTabView, className, 0);
 //  OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
     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, "@:@@");
@@ -1774,7 +1760,7 @@
     OS.objc_registerClassPair(cls);
     
     className = "SWTBox";
-    cls = OS.objc_allocateClassPair(OS.classinfo_NSBox, className, 0);
+    cls = OS.objc_allocateClassPair(OS.class_NSBox, className, 0);
 //  OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
     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, "@:");
@@ -1783,7 +1769,7 @@
     OS.objc_registerClassPair(cls);
     
     className = "SWTProgressIndicator";
-    cls = OS.objc_allocateClassPair(OS.classinfo_NSProgressIndicator, className, 0);
+    cls = OS.objc_allocateClassPair(OS.class_NSProgressIndicator, className, 0);
 //  OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
     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, "@:");
@@ -1792,20 +1778,20 @@
     OS.objc_registerClassPair(cls); 
 
     className = "SWTSlider";
-    cls = OS.objc_allocateClassPair(OS.classinfo_NSSlider, className, 0);
+    cls = OS.objc_allocateClassPair(OS.class_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.classinfo_NSPopUpButton, className, 0);
+    cls = OS.objc_allocateClassPair(OS.class_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.classinfo_NSComboBox, className, 0);
+    cls = OS.objc_allocateClassPair(OS.class_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, "@:");
@@ -1813,14 +1799,14 @@
     OS.objc_registerClassPair(cls);
     
     className = "SWTDatePicker";
-    cls = OS.objc_allocateClassPair(OS.classinfo_NSDatePicker, className, 0);
+    cls = OS.objc_allocateClassPair(OS.class_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.classinfo_NSImageView, className, 0);
+    cls = OS.objc_allocateClassPair(OS.class_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, "@:@");
@@ -1830,27 +1816,27 @@
     OS.objc_registerClassPair(cls);
 
     className = "SWTStepper";
-    cls = OS.objc_allocateClassPair(OS.classinfo_NSStepper, className, 0);
+    cls = OS.objc_allocateClassPair(OS.class_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.classinfo_NSScroller, className, 0);
+    cls = OS.objc_allocateClassPair(OS.class_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.classinfo_NSMenuItem, className, 0);
+    cls = OS.objc_allocateClassPair(OS.class_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.classinfo_NSTextView, className, 0);
+    cls = OS.objc_allocateClassPair(OS.class_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, cast(byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i");
@@ -1861,7 +1847,7 @@
     OS.objc_registerClassPair(cls);
     
     className = "SWTTextField";
-    cls = OS.objc_allocateClassPair(OS.classinfo_NSTextField, className, 0);
+    cls = OS.objc_allocateClassPair(OS.class_NSTextField, className, 0);
     OS.class_addMethod(cls, OS.sel_drawRect_1, drawRectProc, "@:i");
     OS.objc_registerClassPair(cls);
 
@@ -2488,15 +2474,6 @@
         if (cursors [i] !is null) cursors [i].dispose ();
     }
     cursors = null;
-
-    if (windowDelegateCallback2 !is null) windowDelegateCallback2.dispose ();
-    if (windowDelegateCallback3 !is null) windowDelegateCallback3.dispose ();
-    if (windowDelegateCallback4 !is null) windowDelegateCallback4.dispose ();
-    if (windowDelegateCallback5 !is null) windowDelegateCallback5.dispose ();
-    if (windowDelegateCallback6 !is null) windowDelegateCallback6.dispose ();
-    if (dialogCallback3 !is null) dialogCallback3.dispose ();
-    windowDelegateCallback2 = windowDelegateCallback3 = windowDelegateCallback4 = null;
-    windowDelegateCallback6 = windowDelegateCallback5 = null;
 }
 
 /**
@@ -3078,8 +3055,14 @@
     object.performSelectorOnMainThread_withObject_waitUntilDone_(OS.sel_release, null, false);
 }
 
-int applicationDelegateProc(int ID, String sel, int arg0) {
-    if (sel is OS.sel_applicationWillFinishLaunching_1) {
+extern (C) private static:
+
+objc.id applicationDelegateProc(objc.id ID, objc.SEL selector, objc.id arg0) {
+    Display display = Display.findDisplay(Thread.getThis);
+    String sel = fromStringz(selector);
+    with (display) {
+    
+    if (sel == 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");
         if (!NSBundle.loadNibFile(nibFile, dict, null)) {
@@ -3098,34 +3081,37 @@
                 ni.setTitle(title);
             }
         }
-    } else if (sel is OS.sel_terminate_1) {
+    } else if (sel == OS.sel_terminate_1) {
         application.terminate(application);
-    } else if (sel is OS.sel_orderFrontStandardAboutPanel_1) {
+    } else if (sel == OS.sel_orderFrontStandardAboutPanel_1) {
         Event event = new Event ();
         sendEvent (DWT.ABORT, event);
-    } else if (sel is OS.sel_hideOtherApplications_1) {
+    } else if (sel == OS.sel_hideOtherApplications_1) {
         application.hideOtherApplications(application);
-    } else if (sel is OS.sel_hide_1) {
+    } else if (sel == OS.sel_hide_1) {
         application.hide(application);
-    } else if (sel is OS.sel_unhideAllApplications_1) {
+    } else if (sel == OS.sel_unhideAllApplications_1) {
         application.unhideAllApplications(application);
-    } else if (sel is OS.sel_applicationShouldTerminate_1) {
+    } else if (sel == OS.sel_applicationShouldTerminate_1) {
         if (!disposing) {
             Event event = new Event ();
             sendEvent (DWT.Close, event);
             if (event.doit) {
-                return OS.NSTerminateNow;
+                return cast(objc.id) OS.NSTerminateNow;
             }
         }
-        return OS.NSTerminateCancel;
-    } else if (sel is OS.sel_applicationWillTerminate_1) {
+        return cast(objc.id) OS.NSTerminateCancel;
+    } else if (sel == OS.sel_applicationWillTerminate_1) {
         dispose();
     } 
-    return 0;
+    return null;
+    }
 }
 
 
-int dialogProc(int id, String sel, int arg0) {
+objc.id dialogProc(objc.id id, objc.SEL selector, objc.id arg0) {
+    String sel = fromStringz(selector);
+        
     NSIntger jniRef = cast(NSIntger) OS.objc_msgSend(id, OS.sel_tag);
     if (jniRef is 0 || jniRef is -1) return 0;
     if (sel == OS.sel_changeColor_1) {
@@ -3144,63 +3130,67 @@
             (cast(ColorDialog)object).windowWillClose(arg0);
         }
     }
-    return 0;
+    return null;
 }
 
-int windowDelegateProc(objc.id delegatee, String sel) {
+objc.id windowDelegateProc2(objc.id delegatee, objc.SEL selector) {
+    String sel = fromStringz(selector);
+    
     if (sel == OS.sel_tag) {
-        int[1] tag;
+        NSInteger* tag;
         OS.object_getInstanceVariable(delegatee, "tag", tag);    
         return tag[0];
     }
     NSInteger jniRef = cast(NSInteger) OS.objc_msgSend(delegatee, OS.sel_tag);
-    if (jniRef is 0 || jniRef is -1) return 0;
+    if (jniRef is 0 || jniRef is -1) return null;
     Widget widget = cast(Widget)OS.JNIGetObject(jniRef);
-    if (widget is null) return 0;
+    if (widget is null) return null;
     if (sel == OS.sel_isFlipped) {
-        return widget.isFlipped() ? 1 : 0;
+        return widget.isFlipped() ? cast(objc.id) 1 : null;
     }
     if (sel == OS.sel_sendSelection) {
         widget.sendSelection();
-        return 0;
+        return null;
     }
     if (sel == OS.sel_sendArrowSelection) {
         widget.sendArrowSelection();
-        return 0;
+        return null;
     }
     if (sel == OS.sel_sendDoubleSelection) {
         widget.sendDoubleSelection();
-        return 0;
+        return null;
     }
     if (sel == OS.sel_sendVerticalSelection) {
         widget.sendVerticalSelection();
-        return 0;
+        return null;
     }
     if (sel == OS.sel_sendHorizontalSelection) {
         widget.sendHorizontalSelection();
-        return 0;
+        return null;
     }
     if (sel == OS.sel_acceptsFirstResponder) {
-        return widget.acceptsFirstResponder() ? 1 : 0;
+        return widget.acceptsFirstResponder() ? cast(objc.id) 1 : null;
     }
     if (sel == OS.sel_becomeFirstResponder) {
-        return widget.becomeFirstResponder() ? 1 : 0;
+        return widget.becomeFirstResponder() ? cast(objc.id) 1 : null;
     }
     if (sel == OS.sel_resignFirstResponder) {
-        return widget.resignFirstResponder() ? 1 : 0;
+        return widget.resignFirstResponder() ? cast(objc.id) 1 : null;
     }
-    return 0;
+    return null;
 }
 
-int windowDelegateProc(objc.id ID, int sel, int arg0) {
+objc.id windowDelegateProc3(objc.id ID, objc.SEL selector, objc.id arg0) {
+    String sel = fromStringz(selector);
+    
     if (sel == OS.sel_timerProc_1) {
         return timerProc (arg0);
     }
     if (sel == OS.sel_setTag_1) {
-        OS.object_setInstanceVariable(id, "tag", arg0);
+        OS.object_setInstanceVariable(ID, "tag", cast(NSInteger) arg0);
         return 0;
     }
-    int jniRef = OS.objc_msgSend(ID, OS.sel_tag);
+    NSInteger jniRef = OS.objc_msgSend(ID, OS.sel_tag);
     if (jniRef is 0 || jniRef is -1) return 0;
     Widget widget = cast(Widget)OS.JNIGetObject(jniRef);
     if (widget is null) return 0;
@@ -3249,15 +3239,17 @@
     } else if (sel == OS.sel_outlineViewSelectionDidChange_1) {
         widget.outlineViewSelectionDidChange(arg0);
     } else if (sel == OS.sel_sendEvent_1) {
-        widget.windowSendEvent(id, arg0);
+        widget.windowSendEvent(ID, arg0);
     } else if (sel == OS.sel_helpRequested_1) {
         widget.helpRequested(arg0);
     }
-    return 0;
+    return null;
 }
 
 
-int windowDelegateProc(objc.id delegatee, String sel, int arg0, int arg1) {
+objc.id windowDelegateProc4(objc.id delegatee, objc.SEL selector, objc.id arg0, objc.id arg1) {
+    String sel = fromStringz(selector);
+    
     NSInteger jniRef = cast(NSInteger) OS.objc_msgSend(delegatee, OS.sel_tag);
     if (jniRef is 0 || jniRef is -1) return 0;
     Widget widget = cast(Widget)OS.JNIGetObject(jniRef);
@@ -3265,53 +3257,57 @@
     if (sel == OS.sel_tabView_1willSelectTabViewItem_1) {
         widget.willSelectTabViewItem(arg0, arg1);
     } else if (sel == OS.sel_outlineView_1isItemExpandable_1) {
-        return widget.outlineView_isItemExpandable(arg0, arg1) ? 1 : 0;
+        return widget.outlineView_isItemExpandable(arg0, arg1) ? cast(objc.id) 1 : null;
     } else if (sel == OS.sel_outlineView_1numberOfChildrenOfItem_1) {
         return widget.outlineView_numberOfChildrenOfItem(arg0, arg1);
     } else if (sel == OS.sel_outlineView_1shouldCollapseItem_1) {
-        return widget.outlineView_shouldCollapseItem(arg0, arg1) ? 1 : 0;
+        return widget.outlineView_shouldCollapseItem(arg0, arg1) ? cast(objc.id) 1 : null;
     } else if (sel == OS.sel_outlineView_1shouldExpandItem_1) {
-        return widget.outlineView_shouldExpandItem(arg0, arg1) ? 1 : 0;
+        return widget.outlineView_shouldExpandItem(arg0, arg1) ? cast(objc.id) 1 : null;
     } else if (sel == OS.sel_menu_1willHighlightItem_1) {
         widget.menu_willHighlightItem(arg0, arg1);
     }
-    return 0;
+    return null;
 }
 
-int windowDelegateProc(objc.id delegatee, int sel, int arg0, int arg1, int arg2) {
+objc.id windowDelegateProc5(objc.id delegatee, objc.SEL selector, objc.id arg0, objc.id arg1, objc.id arg2) {
+    String sel = fromStringz(selector);
+    
     NSInteger jniRef = cast(NSInteger) OS.objc_msgSend(delegatee, OS.sel_tag);
     if (jniRef is 0 || jniRef is -1) return 0;
     Widget widget = cast(Widget)OS.JNIGetObject(jniRef);
     if (widget is null) return 0;
     if (sel == OS.sel_tableView_1objectValueForTableColumn_1row_1) {
-        return widget.tableView_objectValueForTableColumn_row(arg0, arg1, arg2);
+        return widget.tableView_objectValueForTableColumn_row(arg0, arg1, cast(NSInteger) arg2);
     }
     if (sel == OS.sel_tableView_1shouldEditTableColumn_1row_1) {
-        return widget.tableView_shouldEditTableColumn_row(arg0, arg1, arg2) ? 1 : 0;
+        return widget.tableView_shouldEditTableColumn_row(arg0, arg1, cast(NSInteger) arg2) ? cast(objc.id) 1 : null;
     } else if (sel == OS.sel_textView_1clickedOnLink_1atIndex_1) {
-         return widget.clickOnLink(arg0, arg1, arg2) ? 1 : 0;
+         return widget.clickOnLink(arg0, arg1, cast(NSUInteger) arg2) ? cast(objc.id) 1 : null;
     } else if (sel == OS.sel_outlineView_1child_1ofItem_1) {
-         return widget.outlineView_child_ofItem(arg0, arg1, arg2);
+         return widget.outlineView_child_ofItem(arg0, arg1, cast(NSInteger) arg2);
     } else if (sel == OS.sel_outlineView_1objectValueForTableColumn_1byItem_1) {
          return widget.outlineView_objectValueForTableColumn_byItem(arg0, arg1, arg2);
     }
-    return 0;
+    return null;
 }
 
-int windowDelegateProc(objc.id delegatee, int sel, int arg0, int arg1, int arg2, int arg3) {
+objc.id windowDelegateProc6(objc.id delegatee, int sel, int arg0, int arg1, int arg2, int arg3) {
+    String sel = fromStringz(selector);
+    
     NSInteger jniRef = cast(NSInteger) OS.objc_msgSend(delegatee, OS.sel_tag);
     if (jniRef is 0 || jniRef is -1) return 0;
     Widget widget = cast(Widget)OS.JNIGetObject(jniRef);
     if (widget is null) return 0;
     if (sel == OS.sel_tableView_1willDisplayCell_1forTableColumn_1row_1) {
-        widget.tableView_willDisplayCell_forTableColumn_row(arg0, arg1, arg2, arg3);
+        widget.tableView_willDisplayCell_forTableColumn_row(arg0, arg1, arg2, cast(NSInteger) arg3);
     } else if (sel == OS.sel_outlineView_1willDisplayCell_1forTableColumn_1item_1) {
         widget.outlineView_willDisplayCell_forTableColumn_item(arg0, arg1, arg2, arg3);
     } else  if (sel == OS.sel_outlineView_1setObjectValue_1forTableColumn_1byItem_1) {
         widget.outlineView_setObjectValue_forTableColumn_byItem(arg0, arg1, arg2, arg3);
     } else if (sel == OS.sel_tableView_1setObjectValue_1forTableColumn_1row_1) {
-        widget.tableView_setObjectValue_forTableColumn_row(arg0, arg1, arg2, arg3);
+        widget.tableView_setObjectValue_forTableColumn_row(arg0, arg1, arg2, cast(NSInteger) arg3);
     }
-    return 0;
+    return null;
 }
 }
--- a/dwt/widgets/Menu.d	Fri Aug 29 22:20:53 2008 +0200
+++ b/dwt/widgets/Menu.d	Wed Sep 03 20:59:39 2008 +0200
@@ -13,8 +13,6 @@
  *******************************************************************************/
 module dwt.widgets.Menu;
 
-import dwt.dwthelper.utils;
-
 
 import dwt.DWT;
 import dwt.DWTException;
--- a/dwt/widgets/Shell.d	Fri Aug 29 22:20:53 2008 +0200
+++ b/dwt/widgets/Shell.d	Wed Sep 03 20:59:39 2008 +0200
@@ -7,6 +7,9 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ *     
+ * Port to the D programming language:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
  *******************************************************************************/
 module dwt.widgets.Shell;