changeset 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 762fbe6f17d3
children fb2555104d70
files .hgignore dwt/dwthelper/System.d dwt/dwthelper/utils.d dwt/graphics/Device.d dwt/internal/Callback.d dwt/internal/c/callback.d dwt/internal/c/carboncore/MacTypes.d dwt/internal/cocoa/NSRect.d dwt/internal/cocoa/OS.d dwt/internal/objc/appkit/NSAccessibility.d dwt/internal/objc/appkit/NSAttributedString.d dwt/internal/objc/appkit/NSGraphics.d dwt/internal/objc/appkit/NSScreen.d dwt/internal/objc/appkit/bindings.d dwt/internal/objc/foundation/NSHFSFileTypes.d dwt/internal/objc/foundation/NSRunLoop.d dwt/internal/objc/foundation/bindings.d dwt/internal/objc/runtime.d dwt/widgets/Caret.d dwt/widgets/Control.d dwt/widgets/Dialog.d dwt/widgets/Display.d dwt/widgets/Event.d dwt/widgets/EventTable.d dwt/widgets/Item.d dwt/widgets/Layout.d dwt/widgets/Listener.d dwt/widgets/Monitor.d dwt/widgets/RunnableLock.d dwt/widgets/Synchronizer.d dwt/widgets/Tray.d dwt/widgets/TypedListener.d
diffstat 32 files changed, 770 insertions(+), 551 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Sat Aug 23 13:49:00 2008 +0200
+++ b/.hgignore	Fri Aug 29 21:46:05 2008 +0200
@@ -2,4 +2,5 @@
 *.DS_Store
 *.o
 dsss_objs
-dsss.last
\ No newline at end of file
+dsss.last
+*.a
\ No newline at end of file
--- a/dwt/dwthelper/System.d	Sat Aug 23 13:49:00 2008 +0200
+++ b/dwt/dwthelper/System.d	Fri Aug 29 21:46:05 2008 +0200
@@ -87,6 +87,27 @@
     }
 }
 
+struct OutS
+{
+    static Print!(char) delegate(char[] fmt,...) println;
+    static Print!(char) delegate(char[] fmt,...) print;
+    static this ()
+    {
+        println = &Stdout.formatln;
+        print = &Stdout.format;
+    }
+}
+
+struct Err
+{
+    static Print!(char) delegate(char[] fmt,...) println;
+    static Print!(char) delegate(char[] fmt,...) print;
+    static this ()
+    {
+        println = &Stderr.formatln;
+        print = &Stderr.format;
+    }
+}
 
 class System {
 
@@ -141,5 +162,7 @@
         default: return null;
         }
     }
+    
+    static OutS Out;
+    static Err err;
 }
-
--- a/dwt/dwthelper/utils.d	Sat Aug 23 13:49:00 2008 +0200
+++ b/dwt/dwthelper/utils.d	Fri Aug 29 21:46:05 2008 +0200
@@ -31,6 +31,8 @@
 alias Exception Throwable;
 alias Exception RuntimeException;
 
+alias ClassInfo Class;
+
 void implMissing( String file, uint line ){
     Stderr.formatln( "implementation missing in file {} line {}", file, line );
     Stderr.formatln( "exiting ..." );
--- a/dwt/graphics/Device.d	Sat Aug 23 13:49:00 2008 +0200
+++ b/dwt/graphics/Device.d	Fri Aug 29 21:46:05 2008 +0200
@@ -27,13 +27,15 @@
 import dwt.internal.cocoa.OS;
 import dwt.internal.cocoa.id;
 
+import dwt.graphics.Drawable;
+
 /**
  * This class is the abstract superclass of all device objects,
  * such as the Display device and the Printer device. Devices
  * can have a graphics context (GC) created for them, and they
  * can be drawn on by sending messages to the associated GC.
  */
-public abstract class Device implements Drawable {
+public abstract class Device : Drawable {
     
     /* Debugging */
     public static bool DEBUG;
--- a/dwt/internal/Callback.d	Sat Aug 23 13:49:00 2008 +0200
+++ b/dwt/internal/Callback.d	Fri Aug 29 21:46:05 2008 +0200
@@ -13,9 +13,8 @@
  *******************************************************************************/
 module dwt.internal.Callback;
 
-import dwt.dwthelper.utils;
+
 import dwt.internal.C;
-import c = dwt.internal.c.callback;
 
 /**
  * Instances of this class represent entry points into Java
--- a/dwt/internal/c/callback.d	Sat Aug 23 13:49:00 2008 +0200
+++ b/dwt/internal/c/callback.d	Fri Aug 29 21:46:05 2008 +0200
@@ -18,6 +18,7 @@
  */
 
 import tango.stdc.string;
+import tango.stdc.posix.sys.mman;
 
 import dwt.dwthelper.utils;
 import dwt.internal.Callback;
--- a/dwt/internal/c/carboncore/MacTypes.d	Sat Aug 23 13:49:00 2008 +0200
+++ b/dwt/internal/c/carboncore/MacTypes.d	Fri Aug 29 21:46:05 2008 +0200
@@ -82,6 +82,14 @@
 
 struct UnsignedWide
 {
-    UInt32 hi;
-    UInt32 lo;
+    uint hi;
+    uint lo;
 }
+
+struct ProcessSerialNumber 
+{
+    uint highLongOfPSN;
+    uint lowLongOfPSN;
+}
+
+alias ProcessSerialNumber * ProcessSerialNumberPtr;
\ No newline at end of file
--- a/dwt/internal/cocoa/NSRect.d	Sat Aug 23 13:49:00 2008 +0200
+++ b/dwt/internal/cocoa/NSRect.d	Fri Aug 29 21:46:05 2008 +0200
@@ -37,12 +37,10 @@
 {
     NSPoint origin;
     NSSize size;
-}
-
-/*public class NSRect {
- public float x;
- public float y;
- public float width;
- public float height;
- public static final int sizeof = 16;
- }*/
+    
+    // for dwt compatibility
+    alias origin.x x;
+    alias origin.y y;
+    alias size.width width;
+    alias size.height height;
+}
\ No newline at end of file
--- a/dwt/internal/cocoa/OS.d	Sat Aug 23 13:49:00 2008 +0200
+++ b/dwt/internal/cocoa/OS.d	Fri Aug 29 21:46:05 2008 +0200
@@ -20,9 +20,20 @@
 import dwt.internal.Library;
 import dwt.internal.Platform;
 
+static import Gestalt = dwt.internal.c.carboncore.Gestalt;
+import dwt.internal.c.carboncore.MacTypes;
+static import Processes = dwt.internal.c.hiservices.Processes;
 static import dwt.internal.c.qd.Quickdraw;
-import dwt.internal.objc.cocoa.Cocoa;
-//import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSString;
+static import NSAccessibility = dwt.internal.objc.appkit.NSAccessibility;
+static import NSAttributedString = dwt.internal.objc.appkit.NSAttributedString;
+static import NSGraphics = dwt.internal.objc.appkit.NSGraphics;
+static import NSScreen = dwt.internal.objc.appkit.NSScreen;
+static import CGRemoteOperation = dwt.internal.objc.coregraphics.CGRemoteOperation;
+static import NSGeometry = dwt.internal.objc.foundation.NSGeometry;
+static import NSHFSFileTypes = dwt.internal.objc.foundation.NSHFSFileTypes;
+static import NSRunLoop = dwt.internal.objc.foundation.NSRunLoop;
 static import dwt.internal.objc.runtime;
 
 private alias dwt.internal.objc.runtime.objc_object objc_object;
@@ -51,8 +62,8 @@
 
     static this ()
     {
-        int[] response = new int[1];
-        //OS.Gestalt(OS.gestaltSystemVersion, response);
+        SInt32[1] response;
+        OS.Gestalt(OS.gestaltSystemVersion, response);
         VERSION = response[0] & 0xffff;
         
         OS.sel_sendSelection = OS.sel_registerName("sendSelection");
@@ -62,10 +73,7 @@
         OS.sel_sendHorizontalSelection = OS.sel_registerName("sendHorizontalSelection");
         OS.sel_drawAtPoint_ = OS.sel_registerName("drawAtPoint:");
         OS.sel_timerProc_1 = OS.sel_registerName("timerProc:");
-        
-        
-        
-        
+
         foreach (data ; classesData)
             *data.var = objc_getClass(data.arg);
             
@@ -74,11 +82,11 @@
     }
     
     //TODO - don't hard code
-    public static const size_t PTR_SIZEOF = size_t.sizeof;
+    public static const size_t PTR_SIZEOF = (void*).sizeof;
     
-    public static const int gestaltSystemVersion = ('s'<<24) + ('y'<<16) + ('s'<<8) + 'v';
-    public static const int noErr = 0;
-    public static const int kProcessTransformToForegroundApplication = 1;
+    public static const uint gestaltSystemVersion = ('s'<<24) + ('y'<<16) + ('s'<<8) + 'v';
+    public static const short noErr = 0;
+    alias Processes.kProcessTransformToForegroundApplication kProcessTransformToForegroundApplication;
     public static const int kAlertCautionIcon = ('c'<<24) + ('a'<<16) + ('u'<<8) + 't';
     public static const int kAlertNoteIcon = ('n'<<24) + ('o'<<16) + ('t'<<8) + 'e';
     public static const int kAlertStopIcon = ('s'<<24) + ('t'<<16) + ('o'<<8) + 'p';
@@ -91,6 +99,18 @@
     public static const String sel_drawAtPoint_;
     public static const String sel_timerProc_1;
     
+    Object JNIGetObject(NSInteger globalRef)
+    {
+        return cast(Object) globalRef;
+    }
+    
+    alias Gestalt.Gestalt Gestalt;
+    alias Processes.GetCurrentProcess GetCurrentProcess;
+    alias Processes.SetFrontProcess SetFrontProcess;
+    alias Processes.TransformProcessType TransformProcessType;
+    alias NSGeometry.NSIntersectionRect NSIntersectionRect;
+    alias CGRemoteOperation.CGWarpMouseCursorPosition CGWarpMouseCursorPosition;
+    
     /** QuickDraw calls */
     alias dwt.internal.c.qd.Quickdraw.RegionToRectsProcPtr RegionToRectsProcPtr;
     alias dwt.internal.c.qd.Quickdraw.RegionToRectsUPP RegionToRectsUPP;
@@ -13937,7 +13957,7 @@
     ];
 
     /** Constants */
-/+    public static const int NSAWTEventType = 16;
+    public static const int NSAWTEventType = 16;
     public static const int NSAboveBottom = 4;
     public static const int NSAboveTop = 1;
     public static const int NSAddTraitFontAction = 2;
@@ -14928,9 +14948,9 @@
     public static const int NSDateFormatterMediumStyle = 2;
     public static const int NSDateFormatterNoStyle = 0;
     public static const int NSDateFormatterShortStyle = 1;
-    public static const int NSDayCalendarUnit = 16;+/
+    public static const int NSDayCalendarUnit = 16;
     public static const int NSDecimalMaxSize = 8;
-    /+public static const int NSDecimalNoScale = 32767;
+    public static const int NSDecimalNoScale = 32767;
     public static const int NSDemoApplicationDirectory = 2;
     public static const int NSDesktopDirectory = 12;
     public static const int NSDeveloperApplicationDirectory = 3;
@@ -15813,7 +15833,7 @@
 //  public static const native int NSAccessibilityPickAction();
 //  public static const native int NSAccessibilityPointsUnitValue();
 //  public static const native int NSAccessibilityPopUpButtonRole();
-//  public static const native int NSAccessibilityPositionAttribute(); commented by Jacob Carlborg
+    alias NSAccessibility.NSAccessibilityPositionAttribute NSAccessibilityPositionAttribute;
 //  public static const native int NSAccessibilityPressAction();
 //  public static const native int NSAccessibilityPreviousContentsAttribute();
 //  public static const native int NSAccessibilityProgressIndicatorRole();
@@ -15860,7 +15880,7 @@
 //  public static const native int NSAccessibilitySheetRole();
 //  public static const native int NSAccessibilityShowMenuAction();
 //  public static const native int NSAccessibilityShownMenuAttribute();
-//  public static const native int NSAccessibilitySizeAttribute(); commented by Jacob Carlborg
+    alias NSAccessibility.NSAccessibilitySizeAttribute NSAccessibilitySizeAttribute;
 //  public static const native int NSAccessibilitySliderRole();
 //  public static const native int NSAccessibilitySortButtonRole();
 //  public static const native int NSAccessibilitySortDirectionAttribute();
@@ -15964,8 +15984,7 @@
 //  public static const native int NSAttachmentAttributeName();
 //  public static const native int NSAttributedStringBinding();
 //  public static const native int NSAuthorDocumentAttribute();
-//  public static const NSString NSBackgroundColorAttributeName = new NSString(OS.NSBackgroundColorAttributeName()); commented by Jacob Carlborg
-//  public static const native int NSBackgroundColorAttributeName(); commented by Jacob Carlborg
+    alias NSAttributedString.NSBackgroundColorAttributeName NSBackgroundColorAttributeName;
 //  public static const native int NSBackgroundColorDocumentAttribute();
 //  public static const native int NSBadBitmapParametersException();
 //  public static const native int NSBadComparisonException();
@@ -15974,7 +15993,7 @@
 //  public static const native int NSBadRTFFontTableException();
 //  public static const native int NSBadRTFStyleSheetException();
 //  public static const native int NSBaseURLDocumentOption();
-//  public static const native int NSBaselineOffsetAttributeName(); commented by Jacob Carlborg
+    alias NSAttributedString.NSBaselineOffsetAttributeName NSBaselineOffsetAttributeName;
 //  public static const native int NSBlack();
 //  public static const native int NSBottomMarginDocumentAttribute();
 //  public static const native int NSBrowserColumnConfigurationDidChangeNotification();
@@ -16036,8 +16055,8 @@
 //  public static const native int NSDeviceColorSpaceName();
 //  public static const native int NSDeviceIsPrinter();
 //  public static const native int NSDeviceIsScreen();
-//  public static const native int NSDeviceRGBColorSpace();
-//  public static const native int NSDeviceResolution(); commented by Jacob Carlborg
+    alias NSGraphics.NSDeviceRGBColorSpace NSDeviceRGBColorSpace;
+    alias NSScreen.NSDeviceResolution NSDeviceResolution;
 //  public static const native int NSDeviceSize();
 //  public static const native int NSDeviceWhiteColorSpace();
 //  public static const native int NSDirectoryFileType();
@@ -16073,7 +16092,7 @@
 //  public static const native int NSFindPanelSearchOptionsPboardType();
 //  public static const native int NSFindPanelSubStringMatch();
 //  public static const native int NSFindPboard();
-//  public static const native int NSFontAttributeName(); commented by Jacob Carlborg
+    alias NSAttributedString.NSFontAttributeName NSFontAttributeName;
 //  public static const native int NSFontBinding();
 //  public static const native int NSFontBoldBinding();
 //  public static const native int NSFontCascadeListAttribute();
@@ -16108,7 +16127,7 @@
 //  public static const native int NSFontVisibleNameAttribute();
 //  public static const native int NSFontWeightTrait();
 //  public static const native int NSFontWidthTrait();
-//  public static const native int NSForegroundColorAttributeName(); commented by Jacob Carlborg
+    alias NSAttributedString.NSForegroundColorAttributeName NSForegroundColorAttributeName;
 //  public static const native int NSFullScreenModeAllScreens();
 //  public static const native int NSFullScreenModeSetting();
 //  public static const native int NSFullScreenModeWindowLevel();
@@ -16200,7 +16219,7 @@
 //  public static const native int NSLeftMarginDocumentAttribute();
 //  public static const native int NSLigatureAttributeName();
 //  public static const native int NSLightGray();
-//  public static const native int NSLinkAttributeName(); commented by Jacob Carlborg
+    alias NSAttributedString.NSLinkAttributeName NSLinkAttributeName;
 //  public static const native int NSLocalizedKeyDictionaryBinding();
 //  public static const native int NSMacSimpleTextDocumentType();
 //  public static const native int NSManagedObjectContextBinding();
@@ -16255,7 +16274,7 @@
 //  public static const native int NSPPDIncludeStackUnderflowException();
 //  public static const native int NSPPDParseException();
 //  public static const native int NSPaperSizeDocumentAttribute();
-//  public static const native int NSParagraphStyleAttributeName(); commented by Jacob Carlborg
+    alias NSAttributedString.NSParagraphStyleAttributeName NSParagraphStyleAttributeName;
 //  public static const native int NSPasteboardCommunicationException();
 //  public static const native int NSPatternColorSpace();
 //  public static const native int NSPlainFileType();
@@ -16403,8 +16422,8 @@
 //  public static const native int NSSpellingStateAttributeName();
 //  public static const native int NSSplitViewDidResizeSubviewsNotification();
 //  public static const native int NSSplitViewWillResizeSubviewsNotification();
-//  public static const native int NSStrikethroughColorAttributeName(); commented by Jacob Carlborg
-//  public static const native int NSStrikethroughStyleAttributeName(); commented by Jacob Carlborg
+    alias NSAttributedString.NSStrikethroughColorAttributeName NSStrikethroughColorAttributeName;
+    alias NSAttributedString.NSStrikethroughStyleAttributeName NSStrikethroughStyleAttributeName;
 //  public static const native int NSStringPboardType();
 //  public static const native int NSStrokeColorAttributeName();
 //  public static const native int NSStrokeWidthAttributeName();
@@ -16455,9 +16474,9 @@
 //  public static const native int NSTypedStreamVersionException();
 //  public static const native int NSURLPboardType();
 //  public static const native int NSUnderlineByWordMask();
-//  public static const native int NSUnderlineColorAttributeName(); commented by Jacob Carlborg
+    alias NSAttributedString.NSUnderlineColorAttributeName NSUnderlineColorAttributeName;
 //  public static const native int NSUnderlineStrikethroughMask();
-//  public static const native int NSUnderlineStyleAttributeName(); commented by Jacob Carlborg
+    alias NSAttributedString.NSUnderlineStyleAttributeName NSUnderlineStyleAttributeName;
 //  public static const native int NSVCardPboardType();
 //  public static const native int NSValidatesImmediatelyBindingOption();
 //  public static const native int NSValueBinding();
@@ -16567,8 +16586,7 @@
 //  public static const native int NSDecimalNumberExactnessException();
 //  public static const native int NSDecimalNumberOverflowException();
 //  public static const native int NSDecimalNumberUnderflowException();
-//  public static const NSString NSDefaultRunLoopMode = new NSString(OS.NSDefaultRunLoopMode()); commented by Jacob Carlborg
-//  public static const native int NSDefaultRunLoopMode(); commented by Jacob Carlborg
+    alias NSRunLoop.NSDefaultRunLoopMode NSDefaultRunLoopMode;
 //  public static const native int NSDestinationInvalidException();
 //  public static const native int NSDidBecomeSingleThreadedNotification();
 //  public static const native int NSDistinctUnionOfArraysKeyValueOperator();
@@ -16847,7 +16865,7 @@
 //  public static const native void NSBeginCriticalAlertSheet(int title, int defaultButton, int alternateButton, int otherButton, int docWindow, int modalDelegate, int didEndSelector, int didDismissSelector, int contextInfo, int msgFormat);
 //  public static const native void NSBeginInformationalAlertSheet(int title, int defaultButton, int alternateButton, int otherButton, int docWindow, int modalDelegate, int didEndSelector, int didDismissSelector, int contextInfo, int msgFormat);
 //  public static const native int NSBestDepth(int colorSpace, int bps, int bpp, bool planar, int exactMatch);
-//  public static const native int NSBitsPerPixelFromDepth(int depth); commented by Jacob Calborg
+    alias NSGraphics.NSBitsPerPixelFromDepth NSBitsPerPixelFromDepth;
 //  public static const native int NSBitsPerSampleFromDepth(int depth);
 //  public static const native int NSColorSpaceFromDepth(int depth);
 //  public static const native int NSConvertGlyphsToPackedGlyphs(int glBuf, int count, int packing, int packedGlyphs);
@@ -16970,7 +16988,7 @@
 //  public static const native bool NSEqualRects(NSRect aRect, NSRect bRect);
 //  public static const native bool NSEqualSizes(NSSize aSize, NSSize bSize);
 //  public static const native int NSExtraRefCount(int object);
-//  public static const native int NSFileTypeForHFSTypeCode(int hfsFileTypeCode); commented by Jacob Carlborg
+    alias NSHFSFileTypes.NSFileTypeForHFSTypeCode NSFileTypeForHFSTypeCode;
 //  public static const native int NSFrameAddress(int frame);
 //  public static const native void NSFreeHashTable(int table);
 //  public static const native void NSFreeMapTable(int table);
@@ -17102,5 +17120,4 @@
 //  public static const native int NSZoneRealloc(int zone, int ptr, int size);
 //  public static const native int NXReadNSObjectFromCoder(int decoder);
 
-+/
 }
--- a/dwt/internal/objc/appkit/NSAccessibility.d	Sat Aug 23 13:49:00 2008 +0200
+++ b/dwt/internal/objc/appkit/NSAccessibility.d	Fri Aug 29 21:46:05 2008 +0200
@@ -7,12 +7,15 @@
  */
 module dwt.internal.objc.appkit.NSAccessibility;
 
+import dwt.internal.cocoa.NSString;
 import bindings = dwt.internal.objc.appkit.bindings;
 
-template NSAccessibility ()
+NSString NSAccessibilityPositionAttribute ()
 {
-    extern(C):
-        
-    id* NSAccessibilityPositionAttribute;
-    id* NSAccessibilitySizeAttribute;
+    return new NSString(bindings.DCB_NSAccessibilityPositionAttribute());
 }
+
+NSString NSAccessibilitySizeAttribute ()
+{
+    return new NSString(bindings.DCB_NSAccessibilitySizeAttribute());
+}
\ No newline at end of file
--- a/dwt/internal/objc/appkit/NSAttributedString.d	Sat Aug 23 13:49:00 2008 +0200
+++ b/dwt/internal/objc/appkit/NSAttributedString.d	Fri Aug 29 21:46:05 2008 +0200
@@ -7,20 +7,55 @@
  */
 module dwt.internal.objc.appkit.NSAttributedString;
 
+import dwt.internal.cocoa.NSString;
 import bindings = dwt.internal.objc.appkit.bindings;
 
-template NSAttributedString ()
+NSString NSBackgroundColorAttributeName ()
+{
+    return new NSString(bindings.DCB_NSBackgroundColorAttributeName());
+}
+
+NSString NSBaselineOffsetAttributeName ()
+{
+    return new NSString(bindings.DCB_NSBaselineOffsetAttributeName());
+}
+
+NSString NSFontAttributeName ()
+{
+    return new NSString(bindings.DCB_NSFontAttributeName());
+}
+
+NSString NSForegroundColorAttributeName ()
+{
+    return new NSString(bindings.DCB_NSForegroundColorAttributeName());
+}
+
+NSString NSLinkAttributeName ()
 {
-    extern (C):
-        
-    id* NSBackgroundColorAttributeName;
-    id* NSBaselineOffsetAttributeName;
-    id* NSFontAttributeName;
-    id* NSForegroundColorAttributeName;
-    id* NSLinkAttributeName;
-    id* NSParagraphStyleAttributeName;
-    id* NSStrikethroughColorAttributeName;
-    id* NSStrikethroughStyleAttributeName;
-    id* NSUnderlineColorAttributeName;
-    id* NSUnderlineStyleAttributeName;
+    return new NSString(bindings.DCB_NSLinkAttributeName());
+}
+
+NSString NSParagraphStyleAttributeName ()
+{
+    return new NSString(bindings.DCB_NSParagraphStyleAttributeName());
+}
+
+NSString NSStrikethroughColorAttributeName ()
+{
+    return new NSString(bindings.DCB_NSStrikethroughColorAttributeName());
 }
+
+NSString NSStrikethroughStyleAttributeName ()
+{
+    return new NSString(bindings.DCB_NSStrikethroughStyleAttributeName());
+}
+
+NSString NSUnderlineColorAttributeName ()
+{
+    return new NSString(bindings.DCB_NSUnderlineColorAttributeName());
+}
+
+NSString NSUnderlineStyleAttributeName ()
+{
+    return new NSString(bindings.DCB_NSUnderlineStyleAttributeName());
+}
\ No newline at end of file
--- a/dwt/internal/objc/appkit/NSGraphics.d	Sat Aug 23 13:49:00 2008 +0200
+++ b/dwt/internal/objc/appkit/NSGraphics.d	Fri Aug 29 21:46:05 2008 +0200
@@ -7,11 +7,11 @@
  */
 module dwt.internal.objc.appkit.NSGraphics;
 
-import bindings = dwt.internal.objc.appkit.bindings : NSBitsPerPixelFromDepth;
-import dwt.internal.objc.runtime;
+import bindings = dwt.internal.objc.appkit.bindings : NSBitsPerPixelFromDepth, DCB_NSDeviceRGBColorSpace;
+
+alias bindings.NSBitsPerPixelFromDepth NSBitsPerPixelFromDepth;
 
-template NSGraphics ()
+NSString NSDeviceRGBColorSpace ()
 {
-    extern(C) id* NSDeviceRGBColorSpace;
-    alias bindings.NSBitsPerPixelFromDepth NSBitsPerPixelFromDepth;
-}
+    return new NSString(bindings.DCB_NSDeviceRGBColorSpace());
+}
\ No newline at end of file
--- a/dwt/internal/objc/appkit/NSScreen.d	Sat Aug 23 13:49:00 2008 +0200
+++ b/dwt/internal/objc/appkit/NSScreen.d	Fri Aug 29 21:46:05 2008 +0200
@@ -7,9 +7,9 @@
  */
 module dwt.internal.objc.appkit.NSScreen;
 
-import dwt.internal.objc.runtime;
+import bindings = dwt.internal.objc.appkit.bindings : DCB_NSDeviceResolution;
 
-template NSScreen ()
+NSString NSDeviceResolution ()
 {
-    extern(C) id* NSDeviceResolution;
-}
+    return new NSString(bindings.DCB_NSDeviceResolution());
+}
\ No newline at end of file
--- a/dwt/internal/objc/appkit/bindings.d	Sat Aug 23 13:49:00 2008 +0200
+++ b/dwt/internal/objc/appkit/bindings.d	Fri Aug 29 21:46:05 2008 +0200
@@ -7,23 +7,28 @@
  */
 module dwt.internal.objc.appkit.bindings;
 
+import dwt.internal.objc.runtime;
+
 extern (C):
     
-/*void *NSDeviceRGBColorSpace();
-void *NSAccessibilityPositionAttribute ();
-void *NSAccessibilitySizeAttribute ();
-void *NSBackgroundColorAttributeName ();
-void *NSBaselineOffsetAttributeName ();
-void *NSDeviceResolution ();
-void *NSFontAttributeName ();
-void *NSForegroundColorAttributeName ();
-void *NSLinkAttributeName ();
-void *NSParagraphStyleAttributeName ();
-void *NSStrikethroughColorAttributeName ();
-void *NSStrikethroughStyleAttributeName ();
-void *NSUnderlineColorAttributeName ();
-void *NSUnderlineStyleAttributeName ();*/
+id DCB_NSDeviceRGBColorSpace();
+id DCB_NSAccessibilityPositionAttribute ();
+id DCB_NSAccessibilitySizeAttribute ();
+id DCB_NSBackgroundColorAttributeName ();
+id DCB_NSBaselineOffsetAttributeName ();
+id DCB_NSDeviceResolution ();
+id DCB_NSFontAttributeName ();
+id DCB_NSForegroundColorAttributeName ();
+id DCB_NSLinkAttributeName ();
+id DCB_NSParagraphStyleAttributeName ();
+id DCB_NSStrikethroughColorAttributeName ();
+id DCB_NSStrikethroughStyleAttributeName ();
+id DCB_NSUnderlineColorAttributeName ();
+id DCB_NSUnderlineStyleAttributeName ();
 int NSBitsPerPixelFromDepth (int depth);
 
 version (build)
+{
     pragma(link, "objc");
+    pragma(link, "dwt-cocoa-bindings");
+}
\ No newline at end of file
--- a/dwt/internal/objc/foundation/NSHFSFileTypes.d	Sat Aug 23 13:49:00 2008 +0200
+++ b/dwt/internal/objc/foundation/NSHFSFileTypes.d	Fri Aug 29 21:46:05 2008 +0200
@@ -7,9 +7,9 @@
  */
 module dwt.internal.objc.foundation.NSHFSFileTypes;
 
-import bindings = dwt.internal.objc.foundation.bindings : NSFileTypeForHFSTypeCode;
+import bindings = dwt.internal.objc.foundation.bindings;
 
-template NSHFSFileTypes ()
+NSString NSFileTypeForHFSTypeCode (uint hfsFileTypeCode)
 {
-    alias bindings.NSFileTypeForHFSTypeCode NSFileTypeForHFSTypeCode;
-}
+    return new NSString(bindings.NSFileTypeForHFSTypeCode(hfsFileTypeCode));
+}
\ No newline at end of file
--- a/dwt/internal/objc/foundation/NSRunLoop.d	Sat Aug 23 13:49:00 2008 +0200
+++ b/dwt/internal/objc/foundation/NSRunLoop.d	Fri Aug 29 21:46:05 2008 +0200
@@ -7,9 +7,12 @@
  */
 module dwt.internal.objc.foundation.NSRunLoop;
 
-import dwt.internal.objc.runtime;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.objc.foundation.bindings;
+
+const NSString NSDefaultRunLoopMode;
 
-template NSRunLoop ()
+static this ()
 {
-    extern(C) id* NSDefaultRunLoopMode;
-}
+    NSDefaultRunLoopMode = new NSString(DCB_NSDefaultRunLoopMode());
+}
\ No newline at end of file
--- a/dwt/internal/objc/foundation/bindings.d	Sat Aug 23 13:49:00 2008 +0200
+++ b/dwt/internal/objc/foundation/bindings.d	Fri Aug 29 21:46:05 2008 +0200
@@ -7,7 +7,14 @@
  */
 module dwt.internal.objc.foundation.bindings;
 
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.objc.runtime;
+
 extern (C):
     
-//void* NSDefaultRunLoopMode ();
-void* NSFileTypeForHFSTypeCode (int hfsFileTypeCode);
+id DCB_NSDefaultRunLoopMode ();
+id NSFileTypeForHFSTypeCode (uint hfsFileTypeCode);
+NSRect NSIntersectionRect (NSRect aRect, NSRect bRect);
+
+version (build)
+    pragma (link, "dwt-cocoa-bindings");
\ No newline at end of file
--- a/dwt/internal/objc/runtime.d	Sat Aug 23 13:49:00 2008 +0200
+++ b/dwt/internal/objc/runtime.d	Fri Aug 29 21:46:05 2008 +0200
@@ -37,7 +37,7 @@
     id receiver;
     Class clazz;
     
-    /// for dwt compatibility
+    // for dwt compatibility
     alias clazz cls;
 }
 
@@ -119,9 +119,9 @@
     return dwt.internal.objc.bindings.class_addIvar(cls, name.ptr, size, alignment, types.ptr);
 }
 
-bool class_addMethod (Class cls, SEL name, IMP imp, String types)
+bool class_addMethod (Class cls, String name, IMP imp, String types)
 {
-    return dwt.internal.objc.bindings.class_addMethod(cls, name, imp, types.ptr);
+    return dwt.internal.objc.bindings.class_addMethod(cls, name.ptr, imp, types.ptr);
 }
 
 Class objc_allocateClassPair (Class superclass, String name, size_t extraBytes)
--- a/dwt/widgets/Caret.d	Sat Aug 23 13:49:00 2008 +0200
+++ b/dwt/widgets/Caret.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.Caret;
 
-import dwt.dwthelper.utils;
-
 
 import dwt.DWT;
 import dwt.DWTException;
@@ -22,6 +23,10 @@
 import dwt.internal.cocoa.NSRect;
 import dwt.internal.cocoa.NSSize;
 
+import dwt.dwthelper.utils;
+import dwt.widgets.Canvas;
+import dwt.widgets.Widget;
+
 /**
  * Instances of this class provide an i-beam that is typically used
  * as the insertion point for text.
@@ -36,7 +41,7 @@
  * within the DWT implementation.
  * </p>
  */
-public class Caret extends Widget {
+public class Caret : Widget {
     Canvas parent;
     int x, y, width, height;
     bool isVisible, isShowing;
@@ -74,7 +79,7 @@
  * @see Widget#checkSubclass
  * @see Widget#getStyle
  */
-public Caret (Canvas parent, int style) {
+public this (Canvas parent, int style) {
     super (parent, style);
     this.parent = parent;
     createWidget ();
@@ -103,10 +108,10 @@
     if (nWidth <= 0) nWidth = DEFAULT_WIDTH;
     if (image !is null) {
         NSSize size = image.handle.size();
-        nWidth = (int)size.width;
-        nHeight = (int)size.height;
+        nWidth = cast(int)size.width;
+        nHeight = cast(int)size.height;
     }
-    NSRect rect = new NSRect();
+    NSRect rect = NSRect();
     rect.x = x;
     rect.y = y;
     rect.width = nWidth;
--- a/dwt/widgets/Control.d	Sat Aug 23 13:49:00 2008 +0200
+++ b/dwt/widgets/Control.d	Fri Aug 29 21:46:05 2008 +0200
@@ -7,10 +7,12 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ *     
+ * Port to the D programming language:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
  *******************************************************************************/
 module dwt.widgets.Control;
 
-import dwt.dwthelper.utils;
 
 import dwt.DWT;
 import dwt.DWTException;
@@ -51,6 +53,25 @@
 import dwt.internal.cocoa.OS;
 import dwt.internal.cocoa.objc_super;
 
+import tango.core.Thread;
+
+import dwt.dwthelper.utils;
+import dwt.dwthelper.System;
+import objc = dwt.internal.objc.runtime;
+import dwt.widgets.Composite;
+import dwt.widgets.Decorations;
+import dwt.widgets.Display;
+import dwt.widgets.Event;
+import dwt.widgets.Listener;
+import dwt.widgets.Menu;
+import dwt.widgets.Monitor;
+import dwt.widgets.Shell;
+import dwt.widgets.TypedListener;
+import dwt.widgets.Widget;
+
+
+
+
 /**
  * Control is the abstract superclass of all windowed user interface classes.
  * <p>
@@ -69,7 +90,7 @@
  * within the DWT implementation.
  * </p>
  */
-public abstract class Control extends Widget implements Drawable {
+public abstract class Control : Widget , Drawable {
     /**
      * the handle to the OS resource 
      * (Warning: This field is platform dependent)
@@ -97,7 +118,7 @@
 
 //  static final String RESET_VISIBLE_REGION = "dwt.internal.resetVisibleRegion";
 
-Control () {
+this () {
     /* Do nothing */
 }
 
@@ -129,35 +150,35 @@
  * @see Widget#checkSubclass
  * @see Widget#getStyle
  */
-public Control (Composite parent, int style) {
+public this (Composite parent, int style) {
     super (parent, style);
     this.parent = parent;
     createWidget ();
 }
 
 bool acceptsFirstResponder () {
-    objc_super super_struct = new objc_super();
-    super_struct.receiver = view.id;
-    super_struct.cls = OS.objc_msgSend(view.id, OS.sel_superclass);
-    return OS.objc_msgSendSuper(super_struct, OS.sel_acceptsFirstResponder) !is 0;
+    objc_super super_struct = objc_super();
+    super_struct.receiver = view.id_;
+    super_struct.cls = cast(objc.Class) OS.objc_msgSend(view.id_, OS.sel_superclass);
+    return OS.objc_msgSendSuper(super_struct, OS.sel_acceptsFirstResponder) !is null;
 }
 
 bool becomeFirstResponder () {
 //TODO - query focusControl() in DWT.FocusIn/Out is the control
     sendEvent (DWT.FocusIn);
-    objc_super super_struct = new objc_super();
-    super_struct.receiver = view.id;
-    super_struct.cls = OS.objc_msgSend(view.id, OS.sel_superclass);
-    return OS.objc_msgSendSuper(super_struct, OS.sel_becomeFirstResponder) !is 0;
+    objc_super super_struct = objc_super();
+    super_struct.receiver = view.id_;
+    super_struct.cls = OS.objc_msgSend(view.id_, OS.sel_superclass);
+    return OS.objc_msgSendSuper(super_struct, OS.sel_becomeFirstResponder) !is null;
 }
 
 bool resignFirstResponder () {
 //TODO - query focusControl() in DWT.FocusIn/Out is the control
     sendEvent (DWT.FocusOut);
-    objc_super super_struct = new objc_super();
-    super_struct.receiver = view.id;
-    super_struct.cls = OS.objc_msgSend(view.id, OS.sel_superclass);
-    return OS.objc_msgSendSuper(super_struct, OS.sel_resignFirstResponder) !is 0;
+    objc_super super_struct = objc_super();
+    super_struct.receiver = view.id_;
+    super_struct.cls = OS.objc_msgSend(view.id_, OS.sel_superclass);
+    return OS.objc_msgSendSuper(super_struct, OS.sel_resignFirstResponder) !is null;
 }
 
 /**
@@ -600,12 +621,12 @@
 //  width += border * 2;
 //  height += border * 2;
 //  return new Point (width, height);
-    if (topView() instanceof NSControl) {
+    if (cast(NSControl) topView()) {
         NSRect oldRect = topView().frame();
-        ((NSControl)topView()).sizeToFit();
+        (cast(NSControl)topView()).sizeToFit();
         NSRect newRect = topView().frame();
         topView().setFrame (oldRect);
-        return new Point ((int)newRect.width, (int)newRect.height);
+        return new Point (cast(int)newRect.width, cast(int)newRect.height);
     }
     return new Point (width, height);
 }
@@ -618,7 +639,7 @@
 Control[] computeTabList() {
     if (isTabGroup()) {
         if (getVisible() && getEnabled()) {
-            return new Control[] {this};
+            return new Control[] [this];
         }
     }
     return new Control[0];
@@ -655,8 +676,8 @@
 
 Font defaultFont () {
     //TODO - Controls only, does this leak?
-    if (view instanceof NSControl) {
-        NSFont nsFont = ((NSControl)view).font ();
+    if (cast(NSControl) view) {
+        NSFont nsFont = (cast(NSControl)view).font ();
         if (nsFont !is null) {
             return Font.cocoa_new (display, nsFont);
         }
@@ -795,10 +816,10 @@
     GC gc = GC.cocoa_new (this, data);
     Event event = new Event ();
     event.gc = gc;
-    event.x = (int)rect.x;
-    event.y = (int)rect.y;
-    event.width = (int)rect.width;
-    event.height = (int)rect.height;
+    event.x = cast(int)rect.x;
+    event.y = cast(int)rect.y;
+    event.width = cast(int)rect.width;
+    event.height = cast(int)rect.height;
     sendEvent (DWT.Paint, event);
     event.gc = null;
     gc.dispose ();
@@ -806,8 +827,8 @@
 
 void enableWidget (bool enabled) {
     //TODO - other views
-    if (view instanceof NSControl) {
-        ((NSControl)view).setEnabled(enabled);
+    if (cast(NSControl) view) {
+        (cast(NSControl)view).setEnabled(enabled);
     }
 }
 
@@ -822,7 +843,7 @@
 }
 
 Menu [] findMenus (Control control) {
-    if (menu !is null && this !is control) return new Menu [] {menu};
+    if (menu !is null && this !is control) return new Menu [] [menu];
     return new Menu [0];
 }
 
@@ -965,7 +986,7 @@
 public Rectangle getBounds () {
     checkWidget();
     NSRect rect = topView().frame();
-    return new Rectangle((int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height);
+    return new Rectangle(cast(int)rect.x, cast(int)rect.y, cast(int)rect.width, cast(int)rect.height);
 }
 
 /**
@@ -1090,7 +1111,7 @@
 public Point getLocation () {
     checkWidget();
     NSRect rect = topView().frame();
-    return new Point((int)rect.x, (int)rect.y);
+    return new Point(cast(int)rect.x, cast(int)rect.y);
 }
 
 /**
@@ -1124,9 +1145,9 @@
  * 
  * @since 3.0
  */
-public Monitor getMonitor () {
+public dwt.widgets.Monitor.Monitor getMonitor () {
     checkWidget();
-    Monitor [] monitors = display.getMonitors ();
+    dwt.widgets.Monitor.Monitor [] monitors = display.getMonitors ();
     if (monitors.length is 1) return monitors [0];
     int index = -1, value = -1;
     Rectangle bounds = getBounds ();
@@ -1231,7 +1252,7 @@
 public Point getSize () {
     checkWidget();
     NSRect rect = topView().frame();
-    return new Point((int)rect.width, (int)rect.height);
+    return new Point(cast(int)rect.width, cast(int)rect.height);
 }
 
 /**
@@ -1293,13 +1314,13 @@
  * @param data the platform specific GC data 
  * @return the platform specific GC handle
  */
-public int internal_new_GC (GCData data) {
+public objc.id internal_new_GC (GCData data) {
     checkWidget();
-    int context = 0;
+    objc.id context = null;
     if (data !is null && data.paintRect !is null) {
-        context = NSGraphicsContext.currentContext().id;
+        context = NSGraphicsContext.currentContext().id_;
     } else {
-        context = NSGraphicsContext.graphicsContextWithWindow(view.window()).id;
+        context = NSGraphicsContext.graphicsContextWithWindow(view.window()).id_;
     }
     if (data !is null) {
         int mask = DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT;
@@ -1360,7 +1381,7 @@
 }
 
 bool isFocusAncestor (Control control) {
-    while (control !is null && control !is this && !(control instanceof Shell)) {
+    while (control !is null && control !is this && !(cast(Shell) control)) {
         control = control.parent;
     }
     return control is this;
@@ -1461,12 +1482,12 @@
     return getVisible () && parent.isVisible ();
 }
 
-int menuForEvent (int nsEvent) {
+objc.id menuForEvent (objc.id nsEvent) {
     NSPoint pt = NSEvent.mouseLocation();   
     NSWindow window = view.window();
-    pt.y = (int) (window.screen().frame().height - pt.y);
-    int x = (int) pt.x;
-    int y = (int) pt.y;
+    pt.y = cast(int) (window.screen().frame().height - pt.y);
+    int x = cast(int) pt.x;
+    int y = cast(int) pt.y;
     Event event = new Event ();
     event.x = x;
     event.y = y;
@@ -1477,11 +1498,11 @@
         if (x !is event.x || y !is event.y) {
             menu.setLocation (event.x, event.y);
         }
-        return menu.nsMenu.id;
+        return menu.nsMenu.id_;
     }
-    objc_super super_struct = new objc_super();
-    super_struct.receiver = view.id;
-    super_struct.cls = OS.objc_msgSend(view.id, OS.sel_superclass);
+    objc_super super_struct = objc_super();
+    super_struct.receiver = view.id_;
+    super_struct.cls = OS.objc_msgSend(view.id_, OS.sel_superclass);
     return OS.objc_msgSendSuper(super_struct, OS.sel_menuForEvent_1, nsEvent);
 }
 
@@ -1547,8 +1568,8 @@
     event.count = nsEvent.clickCount();
     NSPoint location = nsEvent.locationInWindow();
     NSPoint point = view.convertPoint_fromView_(location, null);
-    event.x = (int) point.x;
-    event.y = (int) point.y;
+    event.x = cast(int) point.x;
+    event.y = cast(int) point.y;
     setInputState (event, nsEvent, type);
     sendEvent (type, event);
 }
@@ -1558,12 +1579,12 @@
     sendMouseEvent (nsEvent, DWT.MouseDown, 1);
 }
 
-void mouseDragged(int theEvent) {
-    NSEvent nsEvent = new NSEvent (theEvent);
+void mouseDragged(objc.id theEvent) {
+    NSEvent nsEvent = new NSEvent (objc.id);
     sendMouseEvent (nsEvent, DWT.MouseMove, 1);
 }
 
-void mouseUp(int theEvent) {
+void mouseUp(objc.id theEvent) {
     NSEvent nsEvent = new NSEvent (theEvent);
     sendMouseEvent (nsEvent, DWT.MouseUp, 1);
 }
@@ -1587,7 +1608,7 @@
         if (keyCode !is 0) {
             event.keyCode = keyCode;
         } else {
-            event.character = (char) keys.characterAtIndex (i);
+            event.character = cast(char) keys.characterAtIndex (i);
             //TODO - get unshifted values for Shift+1
             event.keyCode = keyCodes.characterAtIndex (i);
         }
@@ -1794,7 +1815,7 @@
  */
 public void redraw (int x, int y, int width, int height, bool all) {
     checkWidget ();
-    NSRect rect = new NSRect();
+    NSRect rect = NSRect();
     rect.x = x;
     rect.y = y;
     rect.width = width;
@@ -1805,7 +1826,7 @@
 void releaseHandle () {
     super.releaseHandle ();
     if (view !is null) {
-        OS.objc_msgSend(view.id, OS.sel_setTag_1, -1);
+        OS.objc_msgSend(view.id_, OS.sel_setTag_1, -1);
         view.release();
     }
     view = null;
@@ -2370,7 +2391,7 @@
     } else if (move) {
         if (rect.x !is x || rect.y !is y) {
             result |= MOVED;
-            NSPoint point = new NSPoint();
+            NSPoint point = NSPoint();
             point.x = x;
             point.y = y;
             topView.setFrameOrigin(point);
@@ -2378,7 +2399,7 @@
     } else if (resize) {
         if (rect.width !is width || rect.height !is height) {
             result |= RESIZED;
-            NSSize size = new NSSize();
+            NSSize size = NSSize();
             size.width = width;
             size.height = height;
             topView.setFrameSize(size);
@@ -2566,8 +2587,8 @@
 
 void setFont (NSFont font) {
     //TODO - bad cast
-    if (view instanceof NSControl) {
-        ((NSControl)view).setFont(font);
+    if (cast(NSControl) view) {
+        (cast(NSControl)view).setFont(font);
     }
 }
 
--- a/dwt/widgets/Dialog.d	Sat Aug 23 13:49:00 2008 +0200
+++ b/dwt/widgets/Dialog.d	Fri Aug 29 21:46:05 2008 +0200
@@ -7,15 +7,21 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ *     
+ * Port to the D programming language:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
  *******************************************************************************/
 module dwt.widgets.Dialog;
 
-import dwt.dwthelper.utils;
-
 
 import dwt.DWT;
 import dwt.DWTException;
 
+import dwt.dwthelper.utils;
+import dwt.widgets.Display;
+import dwt.widgets.Shell;
+import dwt.widgets.Widget;
+
 /**
  * This class is the abstract superclass of the classes
  * that represent the built in platform dialogs.
@@ -94,7 +100,7 @@
  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
  * </ul>
  */
-public Dialog (Shell parent) {
+public this (Shell parent) {
     this (parent, DWT.PRIMARY_MODAL);
 }
 
@@ -124,7 +130,7 @@
  * @see DWT#APPLICATION_MODAL
  * @see DWT#SYSTEM_MODAL
  */
-public Dialog (Shell parent, int style) {
+public this (Shell parent, int style) {
     checkParent (parent);
     this.parent = parent;
     this.style = style;
@@ -144,7 +150,7 @@
  * @see Widget#checkSubclass
  */
 protected void checkSubclass () {
-    if (!Display.isValidClass (getClass ())) {
+    if (!Display.isValidClass (this.classinfo)) {
         error (DWT.ERROR_INVALID_SUBCLASS);
     }
 }
@@ -256,7 +262,7 @@
  * </ul>
  */
 public void setText (String string) {
-    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    //if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
     title = string;
 }
 
--- 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;
--- a/dwt/widgets/Event.d	Sat Aug 23 13:49:00 2008 +0200
+++ b/dwt/widgets/Event.d	Fri Aug 29 21:46:05 2008 +0200
@@ -7,15 +7,23 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ *     
+ * Port to the D programming language:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
  *******************************************************************************/
 module dwt.widgets.Event;
 
-import dwt.dwthelper.utils;
-
 
 import dwt.graphics.GC;
 import dwt.graphics.Rectangle;
 
+import tango.text.convert.Format;
+
+import dwt.dwthelper.utils;
+
+import dwt.widgets.Widget;
+import dwt.widgets.Display;
+
 /**
  * Instances of this class provide a description of a particular
  * event which occurred within DWT. The DWT <em>untyped listener</em>
@@ -217,6 +225,7 @@
  * @return a string representation of the event
  */
 public String toString () {
-    return "Event {type=" + type + " " + widget + " time=" + time + " data=" + data + " x=" + x + " y=" + y + " width=" + width + " height=" + height + " detail=" + detail + "}";  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
+    return Format( "Event {{type={} {} time={} data={} x={} y={} width={} height={} detail={}}",
+        type, widget, time, data, x, y, width, height, detail );  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
 }
 }
--- a/dwt/widgets/EventTable.d	Sat Aug 23 13:49:00 2008 +0200
+++ b/dwt/widgets/EventTable.d	Fri Aug 29 21:46:05 2008 +0200
@@ -7,14 +7,23 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ *     
+ * Port to the D programming language:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
  *******************************************************************************/
 module dwt.widgets.EventTable;
 
-import dwt.dwthelper.utils;
 
 import dwt.DWT;
 import dwt.internal.DWTEventListener;
 
+import dwt.dwthelper.System;
+import dwt.dwthelper.utils;
+
+import dwt.widgets.Event;
+import dwt.widgets.Listener;
+import dwt.widgets.TypedListener;
+
 /**
  * Instances of this class implement a simple
  * look up mechanism that maps an event type
@@ -26,7 +35,7 @@
     int [] types;
     Listener [] listeners;
     int level;
-    static final int GROW_SIZE = 4;
+    static const int GROW_SIZE = 4;
     
 public Listener [] getListeners (int eventType) {
     if (types is null) return new Listener [0];
@@ -59,7 +68,7 @@
         System.arraycopy (types, 0, newTypes, 0, length);
         types = newTypes;
         Listener [] newListeners = new Listener [length + GROW_SIZE];
-        System.arraycopy (listeners, 0, newListeners, 0, length);
+        SimpleType!(Listener).arraycopy (listeners, 0, newListeners, 0, length);
         listeners = newListeners;
     }
     types [index] = eventType;
@@ -118,7 +127,7 @@
     if (level is 0) {
         int end = types.length - 1;
         System.arraycopy (types, index + 1, types, index, end - index);
-        System.arraycopy (listeners, index + 1, listeners, index, end - index);
+        SimpleType!(Listener).arraycopy (listeners, index + 1, listeners, index, end - index);
         index = end;
     } else {
         if (level > 0) level = -level;
@@ -141,8 +150,8 @@
     if (types is null) return;
     for (int i=0; i<types.length; i++) {
         if (types [i] is eventType) {
-            if (listeners [i] instanceof TypedListener) {
-                TypedListener typedListener = (TypedListener) listeners [i];
+            if (cast(TypedListener) listeners [i]) {
+                TypedListener typedListener = cast(TypedListener) listeners [i];
                 if (typedListener.getEventListener () is listener) {
                     remove (i);
                     return;
--- a/dwt/widgets/Item.d	Sat Aug 23 13:49:00 2008 +0200
+++ b/dwt/widgets/Item.d	Fri Aug 29 21:46:05 2008 +0200
@@ -7,16 +7,20 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ *     
+ * Port to the D programming language:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
  *******************************************************************************/
 module dwt.widgets.Item;
 
-import dwt.dwthelper.utils;
-
 
 import dwt.DWT;
 import dwt.DWTException;
 import dwt.graphics.Image;
 
+import dwt.dwthelper.utils;
+import dwt.widgets.Widget;
+
 /**
  * This class is the abstract superclass of all non-windowed
  * user interface objects that occur within specific controls.
@@ -29,7 +33,7 @@
  * </dl>
  */
 
-public abstract class Item extends Widget {
+public abstract class Item : Widget {
     String text;
     Image image;
 
@@ -60,7 +64,7 @@
  * @see DWT
  * @see Widget#getStyle
  */
-public Item (Widget parent, int style) {
+public this (Widget parent, int style) {
     super (parent, style);
     text = "";
 }
@@ -95,7 +99,7 @@
  * @see DWT
  * @see Widget#getStyle
  */
-public Item (Widget parent, int style, int index) {
+public this (Widget parent, int style, int index) {
     this (parent, style);
 }
 
@@ -180,7 +184,7 @@
  */
 public void setText (String string) {
     checkWidget ();
-    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    //if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
     text = string;
 }
 
--- a/dwt/widgets/Layout.d	Sat Aug 23 13:49:00 2008 +0200
+++ b/dwt/widgets/Layout.d	Fri Aug 29 21:46:05 2008 +0200
@@ -7,14 +7,19 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ *     
+ * Port to the D programming language:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
  *******************************************************************************/
 module dwt.widgets.Layout;
 
-import dwt.dwthelper.utils;
-
 
 import dwt.graphics.Point;
 
+import dwt.dwthelper.utils;
+import dwt.widgets.Control;
+import dwt.widgets.Composite;
+
 /**
  * A layout controls the position and size
  * of the children of a composite widget.
--- a/dwt/widgets/Listener.d	Sat Aug 23 13:49:00 2008 +0200
+++ b/dwt/widgets/Listener.d	Fri Aug 29 21:46:05 2008 +0200
@@ -7,11 +7,14 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ *     
+ * Port to the D programming language:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
  *******************************************************************************/
 module dwt.widgets.Listener;
 
-import dwt.dwthelper.utils;
 
+import dwt.widgets.Event;
 
 /**
  * Implementers of <code>Listener</code> provide a simple 
--- a/dwt/widgets/Monitor.d	Sat Aug 23 13:49:00 2008 +0200
+++ b/dwt/widgets/Monitor.d	Fri Aug 29 21:46:05 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.Monitor;
 
@@ -29,7 +32,7 @@
 /**
  * Prevents uninitialized instances from being created outside the package.
  */
-Monitor () {    
+this () {    
 }
     
 /**
@@ -42,10 +45,10 @@
  *
  * @see #hashCode()
  */
-public bool equals (Object object) {
+public bool opEquals (Object object) {
     if (object is this) return true;
-    if (!(object instanceof Monitor)) return false;
-    Monitor monitor = (Monitor) object;
+    if (!(cast(dwt.widgets.Monitor.Monitor) object)) return false;
+    dwt.widgets.Monitor.Monitor monitor = cast(dwt.widgets.Monitor.Monitor) object;
     return handle is monitor.handle;
 }
 
@@ -80,8 +83,8 @@
  *
  * @see #equals(Object)
  */
-public int hashCode () {
-    return (int)/*64*/handle;
+public hash_t toHash () {
+    return cast(hash_t)/*64*/handle;
 }
 
 }
--- a/dwt/widgets/RunnableLock.d	Sat Aug 23 13:49:00 2008 +0200
+++ b/dwt/widgets/RunnableLock.d	Fri Aug 29 21:46:05 2008 +0200
@@ -7,9 +7,15 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ *     
+ * Port to the D programming language:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
  *******************************************************************************/
 module dwt.widgets.RunnableLock;
 
+import tango.core.Thread;
+
+import dwt.dwthelper.Runnable;
 import dwt.dwthelper.utils;
 
 
@@ -25,7 +31,7 @@
     Thread thread;
     Throwable throwable;
     
-RunnableLock (Runnable runnable) {
+this (Runnable runnable) {
     this.runnable = runnable;
 }
 
--- a/dwt/widgets/Synchronizer.d	Sat Aug 23 13:49:00 2008 +0200
+++ b/dwt/widgets/Synchronizer.d	Fri Aug 29 21:46:05 2008 +0200
@@ -7,16 +7,25 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ *     
+ * Port to the D programming language:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
  *******************************************************************************/
 module dwt.widgets.Synchronizer;
 
-import dwt.dwthelper.utils;
-
 
 import dwt.DWT;
 import dwt.DWTException;
 import dwt.graphics.Device;
 import dwt.internal.Compatibility;
+
+import tango.core.Thread;
+import tango.core.Exception;
+
+import dwt.dwthelper.Runnable;
+import dwt.dwthelper.utils;
+import dwt.widgets.Display;
+import dwt.widgets.RunnableLock;
  
 /**
  * Instances of this class provide synchronization support
@@ -41,18 +50,18 @@
     RunnableLock [] messages;
     Object messageLock = new Object ();
     Thread syncThread;
-    static final int GROW_SIZE = 4;
-    static final int MESSAGE_LIMIT = 64;
+    static const int GROW_SIZE = 4;
+    static const int MESSAGE_LIMIT = 64;
 
     //TEMPORARY CODE
-    static final bool IS_CARBON = "carbon".equals (DWT.getPlatform ());
+    static const bool IS_CARBON = "carbon".equals (DWT.getPlatform ());
 
 /**
  * Constructs a new instance of this class.
  * 
  * @param display the display to create the synchronizer on
  */
-public Synchronizer (Display display) {
+public this (Display display) {
     this.display = display;
 }
     
@@ -161,7 +170,7 @@
  */
 protected void syncExec (Runnable runnable) {
     RunnableLock lock = null;
-    synchronized (Device.class) {
+    synchronized (Device.classinfo) {
         if (display is null || display.isDisposed ()) DWT.error (DWT.ERROR_DEVICE_DISPOSED);
         if (!display.isValidThread ()) {
             if (runnable is null) {
@@ -172,7 +181,7 @@
             /*
              * Only remember the syncThread for syncExec.
              */
-            lock.thread = Thread.currentThread();
+            lock.thread = Thread.getThis();
             addLast (lock);
         }
     }
--- a/dwt/widgets/Tray.d	Sat Aug 23 13:49:00 2008 +0200
+++ b/dwt/widgets/Tray.d	Fri Aug 29 21:46:05 2008 +0200
@@ -7,15 +7,21 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ *     
+ * Port to the D programming language:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
  *******************************************************************************/
 module dwt.widgets.Tray;
 
-import dwt.dwthelper.utils;
-
 
 import dwt.DWT;
 import dwt.DWTException;
 
+import dwt.dwthelper.utils;
+import dwt.widgets.Display;
+import dwt.widgets.Widget;
+import dwt.widgets.TrayItem;
+
 /**
  * Instances of this class represent the system tray that is part
  * of the task bar status area on some operating systems.
@@ -34,11 +40,11 @@
  * 
  * @since 3.0
  */
-public class Tray extends Widget {
+public class Tray : Widget {
     int itemCount;
     TrayItem [] items = new TrayItem [4];
 
-Tray (Display display, int style) {
+this (Display display, int style) {
     if (display is null) display = Display.getCurrent ();
     if (display is null) display = Display.getDefault ();
     if (!display.isValidThread ()) {
--- a/dwt/widgets/TypedListener.d	Sat Aug 23 13:49:00 2008 +0200
+++ b/dwt/widgets/TypedListener.d	Fri Aug 29 21:46:05 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.TypedListener;
 
@@ -55,6 +58,8 @@
 import dwt.events.VerifyListener;
 import dwt.internal.DWTEventListener;
 
+import dwt.widgets.Listener;
+
 /**  
  * Instances of this class are <em>internal DWT implementation</em>
  * objects which provide a mapping between the typed and untyped 
@@ -68,7 +73,7 @@
  *
  * @see Listener
  */
-public class TypedListener implements Listener {
+public class TypedListener : Listener {
     
     /**
      * The receiver's event listener
@@ -86,7 +91,7 @@
  *
  * @param listener the event listener to store in the receiver
  */
-public TypedListener (DWTEventListener listener) {
+public this (DWTEventListener listener) {
     eventListener = listener;
 }
 
@@ -118,166 +123,166 @@
 public void handleEvent (Event e) {
     switch (e.type) {
         case DWT.Activate: {
-            ((ShellListener) eventListener).shellActivated(new ShellEvent(e));
+            (cast(ShellListener) eventListener).shellActivated(new ShellEvent(e));
             break;
         }
         case DWT.Arm: {
-            ((ArmListener) eventListener).widgetArmed (new ArmEvent (e));
+            (cast(ArmListener) eventListener).widgetArmed (new ArmEvent (e));
             break;
         }
         case DWT.Close: {
             /* Fields set by Decorations */
             ShellEvent event = new ShellEvent (e);
-            ((ShellListener) eventListener).shellClosed(event);
+            (cast(ShellListener) eventListener).shellClosed(event);
             e.doit = event.doit;
             break;
         }
         case DWT.Collapse: {
-            if (eventListener instanceof TreeListener) {
-                ((TreeListener) eventListener).treeCollapsed(new TreeEvent(e));
+            if (cast(TreeListener) eventListener) {
+                (cast(TreeListener) eventListener).treeCollapsed(new TreeEvent(e));
             } else {
-                ((ExpandListener) eventListener).itemCollapsed(new ExpandEvent(e)); 
+                (cast(ExpandListener) eventListener).itemCollapsed(new ExpandEvent(e)); 
             }
             break;
         }
         case DWT.Deactivate: {
-            ((ShellListener) eventListener).shellDeactivated(new ShellEvent(e));
+            (cast(ShellListener) eventListener).shellDeactivated(new ShellEvent(e));
             break;
         }
         case DWT.Deiconify: {
-            ((ShellListener) eventListener).shellDeiconified(new ShellEvent(e));
+            (cast(ShellListener) eventListener).shellDeiconified(new ShellEvent(e));
             break;
         }
         case DWT.DefaultSelection: {
-            ((SelectionListener)eventListener).widgetDefaultSelected(new SelectionEvent(e));
+            (cast(SelectionListener)eventListener).widgetDefaultSelected(new SelectionEvent(e));
             break;
         }
         case DWT.Dispose: {
-            ((DisposeListener) eventListener).widgetDisposed(new DisposeEvent(e));
+            (cast(DisposeListener) eventListener).widgetDisposed(new DisposeEvent(e));
             break;
         }
         case DWT.DragDetect: {
-            ((DragDetectListener) eventListener).dragDetected(new DragDetectEvent(e));
+            (cast(DragDetectListener) eventListener).dragDetected(new DragDetectEvent(e));
             break;
         }
         case DWT.Expand: {
-            if (eventListener instanceof TreeListener) {
-                ((TreeListener) eventListener).treeExpanded(new TreeEvent(e));
+            if (cast(TreeListener) eventListener) {
+                (cast(TreeListener) eventListener).treeExpanded(new TreeEvent(e));
             } else {
-                ((ExpandListener) eventListener).itemExpanded(new ExpandEvent(e));  
+                (cast(ExpandListener) eventListener).itemExpanded(new ExpandEvent(e));  
             }
             break;
         }
         case DWT.FocusIn: {
-            ((FocusListener) eventListener).focusGained(new FocusEvent(e));
+            (cast(FocusListener) eventListener).focusGained(new FocusEvent(e));
             break;
         }
         case DWT.FocusOut: {
-            ((FocusListener) eventListener).focusLost(new FocusEvent(e));
+            (cast(FocusListener) eventListener).focusLost(new FocusEvent(e));
             break;
         }
         case DWT.Help: {
-            ((HelpListener) eventListener).helpRequested (new HelpEvent (e));
+            (cast(HelpListener) eventListener).helpRequested (new HelpEvent (e));
             break;
         }
         case DWT.Hide: {
-            ((MenuListener) eventListener).menuHidden(new MenuEvent(e));
+            (cast(MenuListener) eventListener).menuHidden(new MenuEvent(e));
             break;
         }
         case DWT.Iconify: {
-            ((ShellListener) eventListener).shellIconified(new ShellEvent(e));
+            (cast(ShellListener) eventListener).shellIconified(new ShellEvent(e));
             break;
         }
         case DWT.KeyDown: {
             /* Fields set by Control */
             KeyEvent event = new KeyEvent(e);
-            ((KeyListener) eventListener).keyPressed(event);
+            (cast(KeyListener) eventListener).keyPressed(event);
             e.doit = event.doit;
             break;
         }
         case DWT.KeyUp: {
             /* Fields set by Control */
             KeyEvent event = new KeyEvent(e);
-            ((KeyListener) eventListener).keyReleased(event);
+            (cast(KeyListener) eventListener).keyReleased(event);
             e.doit = event.doit;
             break;
         }
         case DWT.Modify: {
-            ((ModifyListener) eventListener).modifyText(new ModifyEvent(e));
+            (cast(ModifyListener) eventListener).modifyText(new ModifyEvent(e));
             break;
         }
         case DWT.MenuDetect: {
             MenuDetectEvent event = new MenuDetectEvent(e);
-            ((MenuDetectListener) eventListener).menuDetected(event);
+            (cast(MenuDetectListener) eventListener).menuDetected(event);
             e.x = event.x;
             e.y = event.y;
             e.doit = event.doit;
             break;
         }
         case DWT.MouseDown: {
-            ((MouseListener) eventListener).mouseDown(new MouseEvent(e));
+            (cast(MouseListener) eventListener).mouseDown(new MouseEvent(e));
             break;
         }
         case DWT.MouseDoubleClick: {
-            ((MouseListener) eventListener).mouseDoubleClick(new MouseEvent(e));
+            (cast(MouseListener) eventListener).mouseDoubleClick(new MouseEvent(e));
             break;
         }
         case DWT.MouseEnter: {
-            ((MouseTrackListener) eventListener).mouseEnter (new MouseEvent (e));
+            (cast(MouseTrackListener) eventListener).mouseEnter (new MouseEvent (e));
             break;
         }
         case DWT.MouseExit: {
-            ((MouseTrackListener) eventListener).mouseExit (new MouseEvent (e));
+            (cast(MouseTrackListener) eventListener).mouseExit (new MouseEvent (e));
             break;
         }
         case DWT.MouseHover: {
-            ((MouseTrackListener) eventListener).mouseHover (new MouseEvent (e));
+            (cast(MouseTrackListener) eventListener).mouseHover (new MouseEvent (e));
             break;
         }
         case DWT.MouseMove: {
-            ((MouseMoveListener) eventListener).mouseMove(new MouseEvent(e));
+            (cast(MouseMoveListener) eventListener).mouseMove(new MouseEvent(e));
             return;
         }
         case DWT.MouseWheel: {
-            ((MouseWheelListener) eventListener).mouseScrolled(new MouseEvent(e));
+            (cast(MouseWheelListener) eventListener).mouseScrolled(new MouseEvent(e));
             return;
         }
         case DWT.MouseUp: {
-            ((MouseListener) eventListener).mouseUp(new MouseEvent(e));
+            (cast(MouseListener) eventListener).mouseUp(new MouseEvent(e));
             break;
         }
         case DWT.Move: {
-            ((ControlListener) eventListener).controlMoved(new ControlEvent(e));
+            (cast(ControlListener) eventListener).controlMoved(new ControlEvent(e));
             break;
         }
         case DWT.Paint: {
             /* Fields set by Control */
             PaintEvent event = new PaintEvent (e);
-            ((PaintListener) eventListener).paintControl (event);
+            (cast(PaintListener) eventListener).paintControl (event);
             e.gc = event.gc;
             break;
         }
         case DWT.Resize: {
-            ((ControlListener) eventListener).controlResized(new ControlEvent(e));
+            (cast(ControlListener) eventListener).controlResized(new ControlEvent(e));
             break;
         }
         case DWT.Selection: {
             /* Fields set by Sash */
             SelectionEvent event = new SelectionEvent (e);
-            ((SelectionListener) eventListener).widgetSelected (event);         
+            (cast(SelectionListener) eventListener).widgetSelected (event);         
             e.x = event.x;
             e.y = event.y;
             e.doit = event.doit;
             break;
         }
         case DWT.Show: {
-            ((MenuListener) eventListener).menuShown(new MenuEvent(e));
+            (cast(MenuListener) eventListener).menuShown(new MenuEvent(e));
             break;
         }
         case DWT.Traverse: {
             /* Fields set by Control */
             TraverseEvent event = new TraverseEvent (e);
-            ((TraverseListener) eventListener).keyTraversed (event);
+            (cast(TraverseListener) eventListener).keyTraversed (event);
             e.detail = event.detail;
             e.doit = event.doit;
             break;
@@ -285,7 +290,7 @@
         case DWT.Verify: {
             /* Fields set by Text, RichText */
             VerifyEvent event = new VerifyEvent (e);
-            ((VerifyListener) eventListener).verifyText (event);
+            (cast(VerifyListener) eventListener).verifyText (event);
             e.text = event.text;
             e.doit = event.doit;
             break;