diff dwt/widgets/Display.d @ 37:642f460a0908

Fixed a lot of compile errors, a "hello world" app compiles now
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Fri, 10 Oct 2008 12:29:48 +0200
parents db5a898b2119
children 198549365851
line wrap: on
line diff
--- a/dwt/widgets/Display.d	Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/widgets/Display.d	Fri Oct 10 12:29:48 2008 +0200
@@ -57,7 +57,6 @@
 import dwt.internal.cocoa.id;
 
 import tango.core.Thread;
-import tango.stdc.stringz;
 
 import dwt.dwthelper.Runnable;
 import dwt.dwthelper.System;
@@ -68,18 +67,23 @@
 import objc = dwt.internal.objc.runtime;
 
 import dwt.widgets.Caret;
+import dwt.widgets.ColorDialog;
 import dwt.widgets.Control;
 import dwt.widgets.Dialog;
 import dwt.widgets.Event;
 import dwt.widgets.EventTable;
+import dwt.widgets.FontDialog;
 import dwt.widgets.Listener;
 import dwt.widgets.Menu;
+import dwt.widgets.MenuItem;
 import dwt.widgets.Monitor;
 import dwt.widgets.Shell;
 import dwt.widgets.Synchronizer;
 import dwt.widgets.Tray;
 import dwt.widgets.Widget;
 
+import mambo.io;
+
 /**
  * Instances of this class are responsible for managing the
  * connection between DWT and the underlying operating
@@ -192,7 +196,7 @@
     
     /* System Resources */
     Image errorImage, infoImage, warningImage;
-    Cursor [] cursors = new Cursor [DWT.CURSOR_HAND + 1];
+    Cursor [] cursors;
     
     /* Key Mappings. */
     static int [] [] KeyTable = [
@@ -278,7 +282,7 @@
 
     /* Multiple Displays. */
     static Display Default;
-    static Display [] Displays = new Display [4];
+    static Display [] Displays;
                 
     /* Package Name */
     static const String PACKAGE_PREFIX = "dwt.widgets.";
@@ -286,7 +290,7 @@
     /* Timer */
     Runnable timerList [];
     NSTimer nsTimers [];
-    SWTWindowDelegate timerDelegate = cast(SWTWindowDelegate)(new SWTWindowDelegate()).alloc().init();
+    SWTWindowDelegate timerDelegate;
     SWTApplicationDelegate applicationDelegate;
     
     /* Display Data */
@@ -546,6 +550,31 @@
  */
 public this (DeviceData data) {
     super (data);
+    cursors = new Cursor [DWT.CURSOR_HAND + 1];
+    Displays = new Display [4];
+    timerDelegate = cast(SWTWindowDelegate)(new SWTWindowDelegate()).alloc().init();
+    
+    caretTimer = new class(currentCaret) Runnable {
+        Caret currentCaret;
+        
+        this (Caret currentCaret)
+        {
+            this.currentCaret = currentCaret;
+        }
+        
+        public void run () {
+            if (currentCaret !is null) {
+                if (currentCaret is null || currentCaret.isDisposed()) return;
+                if (currentCaret.blinkCaret ()) {
+                    int blinkRate = currentCaret.blinkRate;
+                    if (blinkRate !is 0) timerExec (blinkRate, this);
+                } else {
+                    currentCaret = null;
+                }
+            }
+            
+        }
+    };
 }
 
 static void checkDisplay (Thread thread, bool multiple) {
@@ -745,7 +774,7 @@
         }
     }
     Runnable [] newDisposeList = new Runnable [disposeList.length + 4];
-    System.arraycopy (disposeList, 0, newDisposeList, 0, disposeList.length);
+    SimpleType!(Runnable).arraycopy (disposeList, 0, newDisposeList, 0, disposeList.length);
     newDisposeList [disposeList.length] = runnable;
     disposeList = newDisposeList;
 }
@@ -885,7 +914,7 @@
     if (window !is null) {
         NSView view = window.contentView();
         if (view !is null && view.respondsToSelector(OS.sel_tag)) {
-            NSInteger tag = OS.objc_msgSend(view.id_, OS.sel_tag);
+            NSInteger tag = cast(NSInteger) OS.objc_msgSend(view.id_, OS.sel_tag);
             if (tag !is -1) {
                 Object object = OS.JNIGetObject(tag);
                 if (cast(Shell) object) {
@@ -996,7 +1025,7 @@
  */
 public Point [] getCursorSizes () {
     checkDevice ();
-    return new Point [] [new Point (16, 16)];
+    return [new Point (16, 16)];
 }
 
 /**
@@ -1135,7 +1164,7 @@
     if (window !is null) {
         NSResponder view = window.firstResponder();
         if (view !is null && view.respondsToSelector(OS.sel_tag)) {
-            NSInteger tag = OS.objc_msgSend(view.id_, OS.sel_tag);
+            NSInteger tag = cast(NSInteger) OS.objc_msgSend(view.id_, OS.sel_tag);
             if (tag !is -1) {
                 Object object = OS.JNIGetObject(tag);
                 if (cast(Control) object) {
@@ -1150,11 +1179,11 @@
                 if (view.isKindOfClass(NSText.static_class())) {
                     NSText text = new NSText(view.id_);
                     if (text.isFieldEditor()) {
-                        id delegateId = text.delegatee();
+                        id delegateId = text.delegate_();
                         if (delegateId !is null) {
-                            NSObject delegatee = new NSObject(delegateId.id_);
-                            if (delegatee.respondsToSelector(OS.sel_tag)) {
-                                tag = OS.objc_msgSend(delegatee.id_, OS.sel_tag);
+                            NSObject delegate_ = new NSObject(delegateId.id_);
+                            if (delegate_.respondsToSelector(OS.sel_tag)) {
+                                tag = cast(NSInteger) OS.objc_msgSend(delegate_.id_, OS.sel_tag);
                                 if (tag !is 0 && tag !is -1) {
                                     Object object = OS.JNIGetObject(tag);
                                     if (cast(Control) object) {
@@ -1227,7 +1256,7 @@
  */
 public Point [] getIconSizes () {
     checkDevice ();
-    return new Point [] [ 
+    return [ 
         new Point (16, 16), new Point (32, 32), 
         new Point (64, 64), new Point (128, 128)];  
 }
@@ -1348,7 +1377,7 @@
         NSWindow window = new NSWindow(windows.objectAtIndex(i));
         NSView view = window.contentView();
         if (view !is null) {
-            NSInteger jniRef = OS.objc_msgSend(view.id_, OS.sel_tag);
+            NSInteger jniRef = cast(NSInteger) OS.objc_msgSend(view.id_, OS.sel_tag);
             if (jniRef !is 0 && jniRef !is -1) {
                 Object object = OS.JNIGetObject(jniRef);
                 if (cast(Shell) object) {
@@ -1426,7 +1455,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, [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;
@@ -1452,7 +1481,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, [components[0], components[1], components[2], components[3]]);
 }
 
 /**
@@ -1550,7 +1579,7 @@
         default:
             return null;
     }
-    NSImage nsImage = NSWorkspace.sharedWorkspace().iconForFileType(new NSString(OS.NSFileTypeForHFSTypeCode(code)));
+    NSImage nsImage = NSWorkspace.sharedWorkspace().iconForFileType(OS.NSFileTypeForHFSTypeCode(code));
     if (nsImage is null) return null;
     return Image.cocoa_new(this, DWT.ICON, nsImage);
 }
@@ -1606,10 +1635,10 @@
 }
 
 void initApplicationDelegate() {
-    auto appProc3 = &applicationDelegateProc;
+    objc.IMP appProc3 = cast(objc.IMP) &applicationDelegateProc;
 
     String className = "SWTApplicationDelegate";
-    objc.Class cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0);
+    objc.Class cls = OS.objc_allocateClassPair(cast(objc.Class) 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, "@:@");
@@ -1625,18 +1654,18 @@
 }
 
 void initClasses () {
-    auto dialogProc3 = &dialogProc;
+    objc.IMP dialogProc3 = cast(objc.IMP) &dialogProc;
     
-    auto proc3 = &windowDelegateProc3;
-    auto proc2 = &windowDelegateProc2;
-    auto proc4 = &windowDelegateProc4;
-    auto proc5 = &windowDelegateProc5;
-    auto proc6 = &windowDelegateProc6;
+    objc.IMP proc3 = cast(objc.IMP) &windowDelegateProc3;
+    objc.IMP proc2 = cast(objc.IMP) &windowDelegateProc2;
+    objc.IMP proc4 = cast(objc.IMP) &windowDelegateProc4;
+    objc.IMP proc5 = cast(objc.IMP) &windowDelegateProc5;
+    objc.IMP proc6 = cast(objc.IMP) &windowDelegateProc6;
     
-    auto drawRectProc = OS.drawRect_CALLBACK(proc3);
+    objc.IMP drawRectProc = OS.drawRect_CALLBACK(proc3);
 
     String className = "SWTWindowDelegate";
-    objc.Class cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0);
+    objc.Class cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSObject, className, 0);
     
     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");
@@ -1655,7 +1684,7 @@
     OS.objc_registerClassPair(cls);
     
     className = "SWTPanelDelegate";
-    cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0);
+    cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_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, "@:@");
@@ -1665,7 +1694,7 @@
     OS.objc_registerClassPair(cls);
     
     className = "SWTMenu";
-    cls = OS.objc_allocateClassPair(OS.class_NSMenu, className, 0);
+    cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_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");
@@ -1677,7 +1706,7 @@
     OS.objc_registerClassPair(cls);
 
     className = "SWTView";
-    cls = OS.objc_allocateClassPair(OS.class_NSView, className, 0);
+    cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_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");
@@ -1694,7 +1723,7 @@
     OS.objc_registerClassPair(cls);
     
     className = "SWTScrollView";
-    cls = OS.objc_allocateClassPair(OS.class_NSScrollView, className, 0);
+    cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_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");
@@ -1704,7 +1733,7 @@
     OS.objc_registerClassPair(cls);
     
     className = "SWTButton";
-    cls = OS.objc_allocateClassPair(OS.class_NSButton, className, 0);
+    cls = OS.objc_allocateClassPair(cast(objc.Class) 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");
@@ -1714,7 +1743,7 @@
     OS.objc_registerClassPair(cls);
     
     className = "SWTTableView";
-    cls = OS.objc_allocateClassPair(OS.class_NSTableView, className, 0);
+    cls = OS.objc_allocateClassPair(cast(objc.Class) 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, "@:@");
@@ -1727,7 +1756,7 @@
     OS.objc_registerClassPair(cls);
     
     className = "SWTOutlineView";
-    cls = OS.objc_allocateClassPair(OS.class_NSOutlineView, className, 0);
+    cls = OS.objc_allocateClassPair(cast(objc.Class) 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, "@:@@");
@@ -1742,7 +1771,7 @@
     OS.objc_registerClassPair(cls);
 
     className = "SWTTreeItem";
-    cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0);
+    cls = OS.objc_allocateClassPair(cast(objc.Class) 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, "@:");
@@ -1750,7 +1779,7 @@
     OS.objc_registerClassPair(cls);
 
     className = "SWTTabView";
-    cls = OS.objc_allocateClassPair(OS.class_NSTabView, className, 0);
+    cls = OS.objc_allocateClassPair(cast(objc.Class) 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, "@:@@");
@@ -1760,7 +1789,7 @@
     OS.objc_registerClassPair(cls);
     
     className = "SWTBox";
-    cls = OS.objc_allocateClassPair(OS.class_NSBox, className, 0);
+    cls = OS.objc_allocateClassPair(cast(objc.Class) 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, "@:");
@@ -1769,7 +1798,7 @@
     OS.objc_registerClassPair(cls);
     
     className = "SWTProgressIndicator";
-    cls = OS.objc_allocateClassPair(OS.class_NSProgressIndicator, className, 0);
+    cls = OS.objc_allocateClassPair(cast(objc.Class) 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, "@:");
@@ -1778,20 +1807,20 @@
     OS.objc_registerClassPair(cls); 
 
     className = "SWTSlider";
-    cls = OS.objc_allocateClassPair(OS.class_NSSlider, className, 0);
+    cls = OS.objc_allocateClassPair(cast(objc.Class) 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.class_NSPopUpButton, className, 0);
+    cls = OS.objc_allocateClassPair(cast(objc.Class) 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.class_NSComboBox, className, 0);
+    cls = OS.objc_allocateClassPair(cast(objc.Class) 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, "@:");
@@ -1799,14 +1828,14 @@
     OS.objc_registerClassPair(cls);
     
     className = "SWTDatePicker";
-    cls = OS.objc_allocateClassPair(OS.class_NSDatePicker, className, 0);
+    cls = OS.objc_allocateClassPair(cast(objc.Class) 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.class_NSImageView, className, 0);
+    cls = OS.objc_allocateClassPair(cast(objc.Class) 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, "@:@");
@@ -1816,27 +1845,27 @@
     OS.objc_registerClassPair(cls);
 
     className = "SWTStepper";
-    cls = OS.objc_allocateClassPair(OS.class_NSStepper, className, 0);
+    cls = OS.objc_allocateClassPair(cast(objc.Class) 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.class_NSScroller, className, 0);
+    cls = OS.objc_allocateClassPair(cast(objc.Class) 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.class_NSMenuItem, className, 0);
+    cls = OS.objc_allocateClassPair(cast(objc.Class) 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.class_NSTextView, className, 0);
+    cls = OS.objc_allocateClassPair(cast(objc.Class) 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");
@@ -1847,12 +1876,12 @@
     OS.objc_registerClassPair(cls);
     
     className = "SWTTextField";
-    cls = OS.objc_allocateClassPair(OS.class_NSTextField, className, 0);
+    cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_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);
+    cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_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");
@@ -1916,14 +1945,16 @@
  * @param hDC the platform specific GC handle
  * @param data the platform specific GC data 
  */
-public void internal_dispose_GC (int context, GCData data) {
+public override void internal_dispose_GC (objc.id context, GCData data) {
     if (isDisposed()) DWT.error(DWT.ERROR_DEVICE_DISPOSED);
     
 }
 
-static bool isValidClass (Class clazz) {
+static bool isValidClass (ClassInfo clazz) {
     String name = clazz.name;
     int index = name.lastIndexOf ('.');
+    name = name[0 .. index];
+    index = name.lastIndexOf ('.');
     return name.substring (0, index + 1).equals (PACKAGE_PREFIX);
 }
 
@@ -2566,9 +2597,9 @@
         /* Take an event off the queue */
         Event event = eventQueue [0];
         if (event is null) break;
-        int length = eventQueue.length;
-        System.arraycopy (eventQueue, 1, eventQueue, 0, --length);
-        eventQueue [length] = null;
+        int length_ = eventQueue.length;
+        System.arraycopy (eventQueue, 1, eventQueue, 0, --length_);
+        eventQueue [length_] = null;
 
         /* Run the event */
         Widget widget = event.widget;
@@ -2633,20 +2664,8 @@
 }
 
 //TODO - use custom timer instead of timerExec
-Runnable caretTimer = new class Runnable {
-    public void run () {
-        if (currentCaret !is null) {
-            if (currentCaret is null || currentCaret.isDisposed()) return;
-            if (currentCaret.blinkCaret ()) {
-                int blinkRate = currentCaret.blinkRate;
-                if (blinkRate !is 0) timerExec (blinkRate, this);
-            } else {
-                currentCaret = null;
-            }
-        }
-        
-    }
-};
+Runnable caretTimer;
+    
 void setCurrentCaret (Caret caret) {
 //  if (caretID !is 0) OS.RemoveEventLoopTimer (caretID);
 //  caretID = 0;
@@ -2753,8 +2772,8 @@
     
     /* Add the key/value pair */
     if (keys is null) {
-        keys = new String [] [key];
-        values = new Object [] [value];
+        keys = [key];
+        values = [value];
         return;
     }
     for (int i=0; i<keys.length; i++) {
@@ -2975,7 +2994,7 @@
     }
     if (index is timerList.length) {
         Runnable [] newTimerList = new Runnable [timerList.length + 4];
-        System.arraycopy (timerList, 0, newTimerList, 0, timerList.length);
+        SimpleType!(Runnable).arraycopy (timerList, 0, newTimerList, 0, timerList.length);
         timerList = newTimerList;
         NSTimer [] newTimerIds = new NSTimer [nsTimers.length + 4];
         System.arraycopy (nsTimers, 0, newTimerIds, 0, nsTimers.length);
@@ -2990,11 +3009,11 @@
     }
 }
 
-int timerProc (int id) {
-    NSTimer timer = new NSTimer (id);
+objc.id timerProc (objc.id ID) {
+    NSTimer timer = new NSTimer (ID);
     NSNumber number = new NSNumber(timer.userInfo());
     int index = number.intValue();
-    if (timerList is null) return 0;
+    if (timerList is null) return null;
     if (0 <= index && index < timerList.length) {
         if (allowTimers) {
             Runnable runnable = timerList [index];
@@ -3007,7 +3026,7 @@
         }
     }
     timer.release();
-    return 0;
+    return null;
 }
 
 /**
@@ -3057,8 +3076,9 @@
 
 extern (C) private static:
 
-objc.id applicationDelegateProc(objc.id ID, objc.SEL selector, objc.id arg0) {
+objc.id applicationDelegateProc(objc.id ID, objc.SEL selector, objc.id arg0_) {
     Display display = Display.findDisplay(Thread.getThis);
+    int arg0 = cast(int) arg0_;
     String sel = fromStringz(selector);
     with (display) {
     
@@ -3109,18 +3129,19 @@
 }
 
 
-objc.id dialogProc(objc.id id, objc.SEL selector, objc.id arg0) {
+objc.id dialogProc(objc.id id, objc.SEL selector, objc.id arg0_) {
     String sel = fromStringz(selector);
+    int arg0 = cast(int) arg0_;
         
-    NSIntger jniRef = cast(NSIntger) OS.objc_msgSend(id, OS.sel_tag);
-    if (jniRef is 0 || jniRef is -1) return 0;
+    NSInteger jniRef = cast(NSInteger) OS.objc_msgSend(id, OS.sel_tag);
+    if (jniRef is 0 || jniRef is -1) return null;
     if (sel == OS.sel_changeColor_1) {
         ColorDialog dialog = cast(ColorDialog)OS.JNIGetObject(jniRef);
-        if (dialog is null) return 0;
+        if (dialog is null) return null;
         dialog.changeColor(arg0);
     } else if (sel == OS.sel_changeFont_1) {
-        FontDialog dialog = cast(FontDialog)OS.JNIGetObject(jniRef);
-        if (dialog is null) return 0;
+        FontDialog dialog = cast(FontDialog )OS.JNIGetObject(jniRef);
+        if (dialog is null) return null;
         dialog.changeFont(arg0);
     } else if (sel == OS.sel_windowWillClose_1) {
         Object object = OS.JNIGetObject(jniRef);
@@ -3132,16 +3153,16 @@
     }
     return null;
 }
-
-objc.id windowDelegateProc2(objc.id delegatee, objc.SEL selector) {
+	
+objc.id windowDelegateProc2(objc.id delegate_, objc.SEL selector) {
     String sel = fromStringz(selector);
     
     if (sel == OS.sel_tag) {
         NSInteger* tag;
-        OS.object_getInstanceVariable(delegatee, "tag", tag);    
-        return tag[0];
+        OS.object_getInstanceVariable(delegate_, "tag", cast(void**) &tag);    
+        return cast(objc.id) tag[0];
     }
-    NSInteger jniRef = cast(NSInteger) OS.objc_msgSend(delegatee, OS.sel_tag);
+    NSInteger jniRef = *cast(NSInteger*) OS.objc_msgSend(delegate_, OS.sel_tag);
     if (jniRef is 0 || jniRef is -1) return null;
     Widget widget = cast(Widget)OS.JNIGetObject(jniRef);
     if (widget is null) return null;
@@ -3180,28 +3201,32 @@
     return null;
 }
 
-objc.id windowDelegateProc3(objc.id ID, objc.SEL selector, objc.id arg0) {
+objc.id windowDelegateProc3(objc.id ID, objc.SEL selector, objc.id arg0_) {
+    Display display = Display.findDisplay(Thread.getThis);
     String sel = fromStringz(selector);
+    int arg0 = cast(int) arg0_;
+    
+    with (display) {
     
     if (sel == OS.sel_timerProc_1) {
-        return timerProc (arg0);
+        return timerProc (arg0_);
     }
     if (sel == OS.sel_setTag_1) {
-        OS.object_setInstanceVariable(ID, "tag", cast(NSInteger) arg0);
-        return 0;
+        OS.object_setInstanceVariable(ID, "tag", &arg0);
+        return null;
     }
-    NSInteger jniRef = OS.objc_msgSend(ID, OS.sel_tag);
-    if (jniRef is 0 || jniRef is -1) return 0;
+    NSInteger jniRef = cast(NSInteger) OS.objc_msgSend(ID, OS.sel_tag);
+    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_windowWillClose_1) {
         widget.windowWillClose(arg0);
     } else if (sel == OS.sel_drawRect_1) {
         NSRect rect = NSRect();
-        OS.memmove(rect, arg0, NSRect.sizeof);
+        OS.memmove(&rect, arg0_, NSRect.sizeof);
         widget.drawRect(ID, rect);
     } else if (sel == OS.sel_windowShouldClose_1) {
-        return widget.windowShouldClose(arg0) ? 1 : 0;
+        return widget.windowShouldClose(arg0) ? cast(objc.id) 1 : null;
     } else if (sel == OS.sel_mouseDown_1) {
         widget.mouseDown(arg0);
     } else if (sel == OS.sel_rightMouseDown_1) {
@@ -3215,7 +3240,7 @@
     } else if (sel == OS.sel_flagsChanged_1) {
         widget.flagsChanged(arg0);
     } else if (sel == OS.sel_numberOfRowsInTableView_1) {
-        return widget.numberOfRowsInTableView(arg0);
+        return cast(objc.id) widget.numberOfRowsInTableView(arg0);
     } else if (sel == OS.sel_comboBoxSelectionDidChange_1) {
         widget.comboBoxSelectionDidChange(arg0);
     } else if (sel == OS.sel_tableViewSelectionDidChange_1) {
@@ -3229,7 +3254,7 @@
     } else if (sel == OS.sel_windowDidMove_1) {
         widget.windowDidMove(arg0);
     } else if (sel == OS.sel_menuForEvent_1) {
-        return widget.menuForEvent(arg0);
+        return cast(objc.id) widget.menuForEvent(arg0);
     } else if (sel == OS.sel_menuWillOpen_1) {
         widget.menuWillOpen(arg0);
     } else if (sel == OS.sel_menuWillClose_1) {
@@ -3239,27 +3264,30 @@
     } 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 null;
+    }
 }
 
 
-objc.id windowDelegateProc4(objc.id delegatee, objc.SEL selector, objc.id arg0, objc.id arg1) {
+objc.id windowDelegateProc4(objc.id delegate_, objc.SEL selector, objc.id arg0_, objc.id arg1_) {
     String sel = fromStringz(selector);
+    int arg0 = cast(int) arg0_;
+    int arg1 = cast(int) arg1_;
     
-    NSInteger jniRef = cast(NSInteger) OS.objc_msgSend(delegatee, OS.sel_tag);
-    if (jniRef is 0 || jniRef is -1) return 0;
+    NSInteger jniRef = cast(NSInteger) OS.objc_msgSend(delegate_, OS.sel_tag);
+    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_tabView_1willSelectTabViewItem_1) {
         widget.willSelectTabViewItem(arg0, arg1);
     } else if (sel == OS.sel_outlineView_1isItemExpandable_1) {
         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);
+        return cast(objc.id) widget.outlineView_numberOfChildrenOfItem(arg0, arg1);
     } else if (sel == OS.sel_outlineView_1shouldCollapseItem_1) {
         return widget.outlineView_shouldCollapseItem(arg0, arg1) ? cast(objc.id) 1 : null;
     } else if (sel == OS.sel_outlineView_1shouldExpandItem_1) {
@@ -3270,35 +3298,42 @@
     return null;
 }
 
-objc.id windowDelegateProc5(objc.id delegatee, objc.SEL selector, objc.id arg0, objc.id arg1, objc.id arg2) {
+objc.id windowDelegateProc5(objc.id delegate_, objc.SEL selector, objc.id arg0_, objc.id arg1_, objc.id arg2_) {
     String sel = fromStringz(selector);
+    int arg0 = cast(int) arg0_;
+    int arg1 = cast(int) arg1_;
+    int arg2 = cast(int) arg2_;
     
-    NSInteger jniRef = cast(NSInteger) OS.objc_msgSend(delegatee, OS.sel_tag);
-    if (jniRef is 0 || jniRef is -1) return 0;
+    NSInteger jniRef = cast(NSInteger) OS.objc_msgSend(delegate_, OS.sel_tag);
+    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_tableView_1objectValueForTableColumn_1row_1) {
-        return widget.tableView_objectValueForTableColumn_row(arg0, arg1, cast(NSInteger) arg2);
+        return cast(objc.id) widget.tableView_objectValueForTableColumn_row(arg0, arg1, arg2);
     }
     if (sel == OS.sel_tableView_1shouldEditTableColumn_1row_1) {
-        return widget.tableView_shouldEditTableColumn_row(arg0, arg1, cast(NSInteger) arg2) ? cast(objc.id) 1 : null;
+        return cast(objc.id) widget.tableView_shouldEditTableColumn_row(arg0, arg1, arg2) ? cast(objc.id) 1 : null;
     } else if (sel == OS.sel_textView_1clickedOnLink_1atIndex_1) {
-         return widget.clickOnLink(arg0, arg1, cast(NSUInteger) arg2) ? cast(objc.id) 1 : null;
+         return cast(objc.id) widget.clickOnLink(arg0, arg1, arg2) ? cast(objc.id) 1 : null;
     } else if (sel == OS.sel_outlineView_1child_1ofItem_1) {
-         return widget.outlineView_child_ofItem(arg0, arg1, cast(NSInteger) arg2);
+         return cast(objc.id) widget.outlineView_child_ofItem(arg0, arg1, arg2);
     } else if (sel == OS.sel_outlineView_1objectValueForTableColumn_1byItem_1) {
-         return widget.outlineView_objectValueForTableColumn_byItem(arg0, arg1, arg2);
+         return cast(objc.id) widget.outlineView_objectValueForTableColumn_byItem(arg0, arg1, arg2);
     }
     return null;
 }
 
-objc.id windowDelegateProc6(objc.id delegatee, int sel, int arg0, int arg1, int arg2, int arg3) {
+objc.id windowDelegateProc6(objc.id delegate_, objc.SEL selector, objc.id arg0_, objc.id arg1_, objc.id arg2_, objc.id arg3_) {
     String sel = fromStringz(selector);
+    int arg0 = cast(int) arg0_;
+    int arg1 = cast(int) arg1_;
+    int arg2 = cast(int) arg2_;
+    int arg3 = cast(int) arg3_;
     
-    NSInteger jniRef = cast(NSInteger) OS.objc_msgSend(delegatee, OS.sel_tag);
-    if (jniRef is 0 || jniRef is -1) return 0;
+    NSInteger jniRef = cast(NSInteger) OS.objc_msgSend(delegate_, OS.sel_tag);
+    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_tableView_1willDisplayCell_1forTableColumn_1row_1) {
         widget.tableView_willDisplayCell_forTableColumn_row(arg0, arg1, arg2, cast(NSInteger) arg3);
     } else if (sel == OS.sel_outlineView_1willDisplayCell_1forTableColumn_1item_1) {