changeset 302:bfe1c57259e3

More browser code ported
author John Reimer<terminal.node@gmail.com>
date Tue, 12 Aug 2008 21:11:17 -0700
parents d1474e6bb509
children b72d84d1ba95
files dwt/browser/PromptDialog.d dwt/browser/PromptService2.d dwt/browser/PromptService2Factory.d dwt/browser/SimpleEnumerator.d dwt/browser/StatusTextEvent.d dwt/browser/StatusTextListener.d dwt/browser/TitleEvent.d dwt/browser/TitleListener.d dwt/browser/VisibilityWindowAdapter.d dwt/browser/VisibilityWindowListener.d dwt/browser/WindowCreator2.d dwt/browser/WindowEvent.d
diffstat 12 files changed, 312 insertions(+), 446 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/browser/PromptDialog.d	Tue Aug 12 02:43:31 2008 +0200
+++ b/dwt/browser/PromptDialog.d	Tue Aug 12 21:11:17 2008 -0700
@@ -233,7 +233,7 @@
         }   
     }
 
-    void promptUsernameAndPassword(String title, String text, String check, /* final */ String[] user, /* final */ String[] pass, /* final */ int[] checkValue, /* final */ int[] result) {
+    void promptUsernameAndPassword(String title, String text, String check, ref String user, ref String pass, ref int checkValue, ref int result) {
         Shell parent = getParent();
         /* final */ Shell shell = new Shell(parent, DWT.DIALOG_TRIM | DWT.APPLICATION_MODAL);
         shell.setText(title);
@@ -254,7 +254,7 @@
         //userLabel.setText(DWT.getMessage("SWT_Username")); //$NON-NLS-1$
         userLabel.setText("Username:");
         final Text userText = new Text(shell, DWT.BORDER);
-        if (user[0] !is null) userText.setText(user[0]);
+        if (user !is null) userText.setText(user);
         data = new GridData();
         data.horizontalAlignment = GridData.FILL;
         data.grabExcessHorizontalSpace = true;
@@ -264,7 +264,7 @@
         //passwordLabel.setText(DWT.getMessage("SWT_Password")); //$NON-NLS-1$
         passwordLabel.setText("Password:");
         final Text passwordText = new Text(shell, DWT.PASSWORD | DWT.BORDER);
-        if (pass[0] !is null) passwordText.setText(pass[0]);
+        if (pass !is null) passwordText.setText(pass);
         data = new GridData();
         data.horizontalAlignment = GridData.FILL;
         data.grabExcessHorizontalSpace = true;
@@ -273,17 +273,17 @@
         final Button[] buttons = new Button[3];
         Listener listener = new Listener() {
             public void handleEvent(Event event) {
-                if (buttons[0] !is null) checkValue[0] = buttons[0].getSelection() ? 1 : 0;
-                user[0] = userText.getText();
-                pass[0] = passwordText.getText();
-                result[0] = event.widget is buttons[1] ? 1 : 0;
+                if (buttons[0] !is null) checkValue = buttons[0].getSelection() ? 1 : 0;
+                user = userText.getText();
+                pass = passwordText.getText();
+                result = event.widget is buttons[1] ? 1 : 0;
                 shell.close();
             }   
         };
         if (check !is null) {
             buttons[0] = new Button(shell, DWT.CHECK);
             buttons[0].setText(check);
-            buttons[0].setSelection(checkValue[0] !is 0);
+            buttons[0].setSelection(checkValue !is 0);
             data = new GridData ();
             data.horizontalAlignment = GridData.BEGINNING;
             buttons[0].setLayoutData (data);
--- a/dwt/browser/PromptService2.d	Tue Aug 12 02:43:31 2008 +0200
+++ b/dwt/browser/PromptService2.d	Tue Aug 12 21:11:17 2008 -0700
@@ -12,7 +12,9 @@
  *******************************************************************************/
 module dwt.browser.PromptService2;
 
-import dwt.dwthelper.utils;
+import tango.stdc.stdlib;
+
+//import dwt.dwthelper.utils;
 
 import dwt.DWT;
 //import dwt.internal.C;
@@ -37,85 +39,19 @@
 import dwt.widgets.Shell;
 
 class PromptService2 : nsIPromptService2 {
-    //XPCOMObject supports;
-    //XPCOMObject promptService;
-    //XPCOMObject promptService2;
     int refCount = 0;
 
 this () {
-   // createCOMInterfaces ();
 }
 
 nsrefcnt AddRef () {
     refCount++;
     return refCount;
 }
-/+
-void createCOMInterfaces () {
-    /* Create each of the interfaces that this object implements */
-    supports = new XPCOMObject (new int[] {2, 0, 0}) {
-        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
-        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
-        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
-    };
-    
-    promptService = new XPCOMObject (new int[] {2, 0, 0, 3, 5, 4, 6, 10, 7, 8, 7, 7}) {
-        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
-        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
-        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
-        public int /*long*/ method3 (int /*long*/[] args) {return Alert (args[0], args[1], args[2]);}
-        public int /*long*/ method4 (int /*long*/[] args) {return AlertCheck (args[0], args[1], args[2], args[3], args[4]);}
-        public int /*long*/ method5 (int /*long*/[] args) {return Confirm (args[0], args[1], args[2], args[3]);}
-        public int /*long*/ method6 (int /*long*/[] args) {return ConfirmCheck (args[0], args[1], args[2], args[3], args[4], args[5]);}
-        public int /*long*/ method7 (int /*long*/[] args) {return ConfirmEx (args[0], args[1], args[2], (int)/*64*/args[3], args[4], args[5], args[6], args[7], args[8], args[9]);}
-        public int /*long*/ method8 (int /*long*/[] args) {return Prompt (args[0], args[1], args[2], args[3], args[4], args[5], args[6]);}
-        public int /*long*/ method9 (int /*long*/[] args) {return PromptUsernameAndPassword (args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);}
-        public int /*long*/ method10 (int /*long*/[] args) {return PromptPassword (args[0], args[1], args[2], args[3], args[4], args[5], args[6]);}
-        public int /*long*/ method11 (int /*long*/[] args) {return Select (args[0], args[1], args[2], (int)/*64*/args[3], args[4], args[5], args[6]);}
-    };
-    
-    promptService2 = new XPCOMObject (new int[] {2, 0, 0, 3, 5, 4, 6, 10, 7, 8, 7, 7, 7, 9}) {
-        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
-        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
-        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
-        public int /*long*/ method3 (int /*long*/[] args) {return Alert (args[0], args[1], args[2]);}
-        public int /*long*/ method4 (int /*long*/[] args) {return AlertCheck (args[0], args[1], args[2], args[3], args[4]);}
-        public int /*long*/ method5 (int /*long*/[] args) {return Confirm (args[0], args[1], args[2], args[3]);}
-        public int /*long*/ method6 (int /*long*/[] args) {return ConfirmCheck (args[0], args[1], args[2], args[3], args[4], args[5]);}
-        public int /*long*/ method7 (int /*long*/[] args) {return ConfirmEx (args[0], args[1], args[2], (int)/*64*/args[3], args[4], args[5], args[6], args[7], args[8], args[9]);}
-        public int /*long*/ method8 (int /*long*/[] args) {return Prompt (args[0], args[1], args[2], args[3], args[4], args[5], args[6]);}
-        public int /*long*/ method9 (int /*long*/[] args) {return PromptUsernameAndPassword (args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);}
-        public int /*long*/ method10 (int /*long*/[] args) {return PromptPassword (args[0], args[1], args[2], args[3], args[4], args[5], args[6]);}
-        public int /*long*/ method11 (int /*long*/[] args) {return Select (args[0], args[1], args[2], (int)/*64*/args[3], args[4], args[5], args[6]);}
-        public int /*long*/ method12 (int /*long*/[] args) {return PromptAuth (args[0], args[1], (int)/*64*/args[2], args[3], args[4], args[5], args[6]);}
-        public int /*long*/ method13 (int /*long*/[] args) {return AsyncPromptAuth (args[0], args[1], args[2], args[3], (int)/*64*/args[4], args[5], args[6], args[7], args[8]);}
-    };
-}
 
-void disposeCOMInterfaces () {
-    if (supports !is null) {
-        supports.dispose ();
-        supports = null;
-    }   
-    if (promptService !is null) {
-        promptService.dispose ();
-        promptService = null;   
-    }
-    if (promptService2 !is null) {
-        promptService2.dispose ();
-        promptService2 = null;  
-    }
-}
-
-int /*long*/ getAddress () {
-    return promptService2.getAddress ();
-}
-+/
 nsresult QueryInterface (nsID* riid, void** ppvObject) {
     if (riid is null || ppvObject is null) return XPCOM.NS_ERROR_NO_INTERFACE;
-    //nsID guid = new nsID ();
-    //XPCOM.memmove (guid, riid, nsID.sizeof);
-    
+ 
     if (*riid == nsISupports.IID) {
         *ppvObject = cast(void*)cast(nsISupports)this;
         AddRef ();
@@ -155,7 +91,7 @@
     //result[0] = 0;
     //byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_WINDOWWATCHER_CONTRACTID, true);
     nsIWindowWatcher windowWatcher;
-    rc = serviceManager.GetServiceByContractID (XPCOM.NS_WINDOWWATCHER_CONTRACTID, nsIWindowWatcher.IID, cast(void*)&windowWatcher);
+    rc = serviceManager.GetServiceByContractID (XPCOM.NS_WINDOWWATCHER_CONTRACTID, &nsIWindowWatcher.IID, cast(void**)&windowWatcher);
     if (rc !is XPCOM.NS_OK) Mozilla.error(rc);
     if (windowWatcher is null) Mozilla.error (XPCOM.NS_NOINTERFACE);       
     serviceManager.Release ();
@@ -179,7 +115,7 @@
     //nsIWebBrowserChrome webBrowserChrome = new nsIWebBrowserChrome (result[0]);
     //result[0] = 0;
     nsIEmbeddingSiteWindow embeddingSiteWindow;
-    rc = webBrowserChrome.QueryInterface (nsIEmbeddingSiteWindow.IID, cast(void*)&embeddingSiteWindow);
+    rc = webBrowserChrome.QueryInterface (nsIEmbeddingSiteWindow.IID, cast(void**)&embeddingSiteWindow);
     if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
     if (embeddingSiteWindow is null) Mozilla.error (XPCOM.NS_NOINTERFACE);       
     webBrowserChrome.Release ();
@@ -360,13 +296,12 @@
     
     //int /*long*/[] valueAddr = new int /*long*/[1];
     //XPCOM.memmove (valueAddr, aValue, C.PTR_SIZEOF);
-    if (aValue !is null) {
-        if(*aValue !is null) {
-            span = XPCOM.strlen_PRUnichar (*aValue);
-            //dest = new char[length];
-            //XPCOM.memmove (dest, valueAddr[0], length * 2);
-            valueLabel = Utf.toString ((*aValue)[0 .. span]);
-        }
+    auto valueAddr = aValue;
+    if (valueAddr[0] !is null) {
+        span = XPCOM.strlen_PRUnichar (valueAddr[0]);
+        //dest = new char[length];
+        //XPCOM.memmove (dest, valueAddr[0], length * 2);
+        valueLabel = Utf.toString ((valueAddr[0])[0 .. span]);
     }
     
     if (aCheckMsg !is null) {
@@ -389,116 +324,123 @@
         * User selected OK. User name and password are returned as PRUnichar values. Any default
         * value that we override must be freed using the nsIMemory service.
         */
-        int cnt, size;
-        int /*long*/ ptr;
-        char[] buffer;
-        int /*long*/[] result2 = new int /*long*/[1];
+        int size;
+        void* ptr;
+        wchar[] buffer;
+        nsIServiceManager serviceManager;
         if (valueLabel !is null) {
-            cnt = valueLabel.length;
-            buffer = new char[cnt + 1];
-            valueLabel.getChars (0, cnt, buffer, 0);
+            //cnt = valueLabel.length;
+            //buffer = new wchar[cnt + 1];
+            //valueLabel.getChars (0, cnt, buffer, 0);
+            buffer = Utf.toString16(valueLabel);
             size = buffer.length * 2;
-            ptr = C.malloc (size);
-            XPCOM.memmove (ptr, buffer, size);
-            XPCOM.memmove (aValue, new int /*long*/[] {ptr}, C.PTR_SIZEOF);
+            ptr = tango.stdc.stdlib.malloc (size);
+            (cast(wchar*)ptr)[0 .. buffer.length] = buffer[0 .. $];
+            //XPCOM.memmove (ptr, buffer, size);
+            //XPCOM.memmove (aValue, new int /*long*/[] {ptr}, C.PTR_SIZEOF);
+            *aValue = cast(PRUnichar*)ptr;
 
-            if (valueAddr[0] !is 0) {
-                int rc = XPCOM.NS_GetServiceManager (result2);
+            if (valueAddr[0] !is null) {
+                int rc = XPCOM.NS_GetServiceManager (&serviceManager);
                 if (rc !is XPCOM.NS_OK) DWT.error (rc);
-                if (result2[0] is 0) DWT.error (XPCOM.NS_NOINTERFACE);
+                if (serviceManager is null) DWT.error (XPCOM.NS_NOINTERFACE);
             
-                nsIServiceManager serviceManager = new nsIServiceManager (result2[0]);
-                result2[0] = 0;
-                byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_MEMORY_CONTRACTID, true);
-                rc = serviceManager.GetServiceByContractID (aContractID, nsIMemory.NS_IMEMORY_IID, result2);
+                //nsIServiceManager serviceManager = new nsIServiceManager (result2[0]);
+                //result2[0] = 0;
+                nsIMemory memory;
+                //byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_MEMORY_CONTRACTID, true);
+                rc = serviceManager.GetServiceByContractID (XPCOM.NS_MEMORY_CONTRACTID, &nsIMemory.IID, cast(void**)&memory);
                 if (rc !is XPCOM.NS_OK) DWT.error (rc);
-                if (result2[0] is 0) DWT.error (XPCOM.NS_NOINTERFACE);      
+                if (memory is null) DWT.error (XPCOM.NS_NOINTERFACE);      
                 serviceManager.Release ();
                 
-                nsIMemory memory = new nsIMemory (result2[0]);
-                result2[0] = 0;
+                //nsIMemory memory = new nsIMemory (result2[0]);
+                //result2[0] = 0;
                 memory.Free (valueAddr[0]);
                 memory.Release ();
             }
         }
     }
-    if (aCheckState !is 0) XPCOM.memmove (aCheckState, check, 4);
+    if (aCheckState !is null) *aCheckState = check;
     return XPCOM.NS_OK;
 }
 
-nsresult PromptAuth(int /*long*/ aParent, int /*long*/ aChannel, int level, int /*long*/ authInfo, int /*long*/ checkboxLabel, int /*long*/ checkboxValue, int /*long*/ _retval) {
+nsresult PromptAuth(nsIDOMWindow aParent, nsIChannel aChannel, PRUint32 level, nsIAuthInformation authInfo, PRUnichar* checkboxLabel, PRBool* checkboxValue, PRBool* _retval) {
     Browser browser = getBrowser (aParent);
     String checkLabel = null;
-    int[] checkValue = new int[1];
-    String[] userLabel = new String[1], passLabel = new String[1];
-
-    String title = DWT.getMessage ("SWT_Authentication_Required"); //$NON-NLS-1$
+    //int[] checkValue = new int[1];
+    //String[] userLabel = new String[1], passLabel = new String[1];
+    int checkValue;
+    String userLabel, passLabel;
+    //String title = DWT.getMessage ("SWT_Authentication_Required"); //$NON-NLS-1$
+    String title = "Authentication Required";
 
-    if (checkboxLabel !is 0 && checkboxValue !is 0) {
-        int length = XPCOM.strlen_PRUnichar (checkboxLabel);
-        char[] dest = new char[length];
-        XPCOM.memmove (dest, checkboxLabel, length * 2);
-        checkLabel = new String (dest);
-        XPCOM.memmove (checkValue, checkboxValue, 4); /* PRBool */
+    if (checkboxLabel !is null && checkboxValue !is null) {
+        int span = XPCOM.strlen_PRUnichar (checkboxLabel);
+        //char[] dest = new char[length];
+        //XPCOM.memmove (dest, checkboxLabel, length * 2);
+        checkLabel = Utf.toString (checkboxLabel[0 .. span]);
+        checkValue = *checkboxValue; /* PRBool */
     }
 
     /* get initial username and password values */
 
-    nsIAuthInformation auth = new nsIAuthInformation (authInfo);
+    //nsIAuthInformation auth = new nsIAuthInformation (authInfo);
 
-    int /*long*/ ptr = XPCOM.nsEmbedString_new ();
-    int rc = auth.GetUsername (ptr);
+    scope auto ptr1 = new nsEmbedString;
+    int rc = authInfo.GetUsername (cast(nsAString*)ptr1);
     if (rc !is XPCOM.NS_OK) DWT.error (rc);
-    int length = XPCOM.nsEmbedString_Length (ptr);
-    int /*long*/ buffer = XPCOM.nsEmbedString_get (ptr);
-    char[] chars = new char[length];
-    XPCOM.memmove (chars, buffer, length * 2);
-    userLabel[0] = new String (chars);
-    XPCOM.nsEmbedString_delete (ptr);
+    //int length = XPCOM.nsEmbedString_Length (ptr);
+    //int /*long*/ buffer = XPCOM.nsEmbedString_get (ptr);
+    //char[] chars = new char[length];
+    //XPCOM.memmove (chars, buffer, length * 2);
+    userLabel = ptr1.toString;
+    //XPCOM.nsEmbedString_delete (ptr);
 
-    ptr = XPCOM.nsEmbedString_new ();
-    rc = auth.GetPassword (ptr);
+    scope auto ptr2 = new nsEmbedString;
+    rc = authInfo.GetPassword (ptr2);
     if (rc !is XPCOM.NS_OK) DWT.error (rc);
-    length = XPCOM.nsEmbedString_Length (ptr);
-    buffer = XPCOM.nsEmbedString_get (ptr);
-    chars = new char[length];
-    XPCOM.memmove (chars, buffer, length * 2);
-    passLabel[0] = new String (chars);
-    XPCOM.nsEmbedString_delete (ptr);
+    //length = XPCOM.nsEmbedString_Length (ptr);
+    //buffer = XPCOM.nsEmbedString_get (ptr);
+    //chars = new char[length];
+    //XPCOM.memmove (chars, buffer, length * 2);
+    passLabel = ptr2.toString;
+    //XPCOM.nsEmbedString_delete (ptr);
 
     /* compute the message text */
 
-    ptr = XPCOM.nsEmbedString_new ();
-    rc = auth.GetRealm (ptr);
+    scope auto ptr3 = new nsEmbedString;
+    rc = authInfo.GetRealm (cast(nsAString*)ptr3);
     if (rc !is XPCOM.NS_OK) DWT.error (rc);
-    length = XPCOM.nsEmbedString_Length (ptr);
-    buffer = XPCOM.nsEmbedString_get (ptr);
-    chars = new char[length];
-    XPCOM.memmove (chars, buffer, length * 2);
-    String realm = new String (chars);
-    XPCOM.nsEmbedString_delete (ptr);
+    //length = XPCOM.nsEmbedString_Length (ptr);
+    //buffer = XPCOM.nsEmbedString_get (ptr);
+    //chars = new char[length];
+    //XPCOM.memmove (chars, buffer, length * 2);
+    String realm = ptr3.toString;
+    //XPCOM.nsEmbedString_delete (ptr);
 
-    nsIChannel channel = new nsIChannel (aChannel);
-    int /*long*/[] uri = new int /*long*/[1];
-    rc = channel.GetURI (uri);
+    n///sIChannel channel = new nsIChannel (aChannel);
+    nsIURI uri;
+    rc = channel.GetURI (&uri);
     if (rc !is XPCOM.NS_OK) DWT.error (rc);
-    if (uri[0] is 0) Mozilla.error (XPCOM.NS_NOINTERFACE);
+    if (uri is null) Mozilla.error (XPCOM.NS_NOINTERFACE);
 
-    nsIURI nsURI = new nsIURI (uri[0]);
-    int /*long*/ aSpec = XPCOM.nsEmbedCString_new ();
-    rc = nsURI.GetHost (aSpec);
+    //nsIURI nsURI = new nsIURI (uri[0]);
+    scope auto aSpec = new nsEmbedCString;
+    rc = uri.GetHost (cast(nsACString*)aSpec);
     if (rc !is XPCOM.NS_OK) DWT.error (rc);
-    length = XPCOM.nsEmbedCString_Length (aSpec);
-    buffer = XPCOM.nsEmbedCString_get (aSpec);
-    byte[] bytes = new byte[length];
-    XPCOM.memmove (bytes, buffer, length);
-    XPCOM.nsEmbedCString_delete (aSpec);
-    String host = new String (bytes);
-    nsURI.Release ();
+    //length = XPCOM.nsEmbedCString_Length (aSpec);
+    //buffer = XPCOM.nsEmbedCString_get (aSpec);
+    //byte[] bytes = new byte[length];
+    //XPCOM.memmove (bytes, buffer, length);
+    //XPCOM.nsEmbedCString_delete (aSpec);
+    String host = aSpec.toString;
+    uri.Release ();
 
     String message;
     if (realm.length () > 0 && host.length () > 0) {
-        message = Compatibility.getMessage ("SWT_Enter_Username_and_Password", new String[] {realm, host}); //$NON-NLS-1$
+        //message = Compatibility.getMessage ("SWT_Enter_Username_and_Password", new String[] {realm, host}); //$NON-NLS-1$
+        message = Format("Enter user name and password for {0} at {1}",realm, host);
     } else {
         message = ""; //$NON-NLS-1$
     }
@@ -506,155 +448,168 @@
     /* open the prompter */
     Shell shell = browser is null ? new Shell () : browser.getShell ();
     PromptDialog dialog = new PromptDialog (shell);
-    int[] result = new int[1];
+    int result;
     dialog.promptUsernameAndPassword (title, message, checkLabel, userLabel, passLabel, checkValue, result);
 
-    XPCOM.memmove (_retval, result, 4); /* PRBool */
-    if (result[0] is 1) {   /* User selected OK */
-        nsEmbedString string = new nsEmbedString (userLabel[0]);
-        rc = auth.SetUsername(string.getAddress ());
+    //XPCOM.memmove (_retval, result, 4); /* PRBool */
+    *_retval = result;
+    if (result is 1) {   /* User selected OK */
+        scope auto string1 = new nsEmbedString (userLabel);
+        rc = authInfo.SetUsername(cast(nsAString*)string1);
         if (rc !is XPCOM.NS_OK) DWT.error (rc);
-        string.dispose ();
+        //string.dispose ();
         
-        string = new nsEmbedString (passLabel[0]);
-        rc = auth.SetPassword(string.getAddress ());
+        scope auto string2 = new nsEmbedString (passLabel);
+        rc = authInfo.SetPassword(cast(nsAString*)string2);
         if (rc !is XPCOM.NS_OK) DWT.error (rc);
-        string.dispose ();
+        //string.dispose ();
     }
 
-    if (checkboxValue !is 0) XPCOM.memmove (checkboxValue, checkValue, 4); /* PRBool */
+    if (checkboxValue !is null) *checkboxValue = checkValue; /* PRBool */
     return XPCOM.NS_OK;
 }
 
-nsresult PromptUsernameAndPassword (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int /*long*/ aUsername, int /*long*/ aPassword, int /*long*/ aCheckMsg, int /*long*/ aCheckState, int /*long*/ _retval) {
+nsresult PromptUsernameAndPassword (nsIDOMWindow aParent, PRUnichar* aDialogTitle, PRUnichar* aText, PRUnichar** aUsername, PRUnichar** aPassword, PRUnichar* aCheckMsg, PRBool* aCheckState, PRBool* _retval) {
     Browser browser = getBrowser (aParent);
     String titleLabel, textLabel, checkLabel = null;
-    String[] userLabel = new String[1], passLabel = new String[1];
+    String userLabel, passLabel;
     char[] dest;
-    int length;
-    if (aDialogTitle !is 0) {
-        length = XPCOM.strlen_PRUnichar (aDialogTitle);
-        dest = new char[length];
-        XPCOM.memmove (dest, aDialogTitle, length * 2);
-        titleLabel = new String (dest);
+    int span;
+    if (aDialogTitle !is null) {
+        span = XPCOM.strlen_PRUnichar (aDialogTitle);
+        //dest = new char[length];
+        //XPCOM.memmove (dest, aDialogTitle, length * 2);
+        titleLabel = Utf.toString (aDialogTitle[0 .. span]);
     } else {
-        titleLabel = DWT.getMessage ("SWT_Authentication_Required");    //$NON-NLS-1$
+        //titleLabel = DWT.getMessage ("SWT_Authentication_Required");    //$NON-NLS-1$
+        titleLable = "Authentication Required"
     }
     
-    length = XPCOM.strlen_PRUnichar (aText);
-    dest = new char[length];
-    XPCOM.memmove (dest, aText, length * 2);
-    textLabel = new String (dest);
+    span = XPCOM.strlen_PRUnichar (aText);
+    //dest = new char[length];
+    //XPCOM.memmove (dest, aText, length * 2);
+    textLabel = Utf.toString (aText[0 .. span]);
     
-    int /*long*/[] userAddr = new int /*long*/[1];
-    XPCOM.memmove (userAddr, aUsername, C.PTR_SIZEOF);
-    if (userAddr[0] !is 0) {
-        length = XPCOM.strlen_PRUnichar (userAddr[0]);
-        dest = new char[length];
-        XPCOM.memmove (dest, userAddr[0], length * 2);
-        userLabel[0] = new String (dest);       
+    //int /*long*/[] userAddr = new int /*long*/[1];
+    //XPCOM.memmove (userAddr, aUsername, C.PTR_SIZEOF);
+    auto userAddr = aUsername;
+    if (userAddr[0] !is null) {
+            span = XPCOM.strlen_PRUnichar (userAddr[0]);
+            //dest = new char[length];
+            //XPCOM.memmove (dest, userAddr[0], length * 2);
+            userLabel = Utf.toString((userAddr[0])[0 .. span]);       
     }
     
-    int /*long*/[] passAddr = new int /*long*/[1];
-    XPCOM.memmove (passAddr, aPassword, C.PTR_SIZEOF);
-    if (passAddr[0] !is 0) {
-        length = XPCOM.strlen_PRUnichar (passAddr[0]);
-        dest = new char[length];
-        XPCOM.memmove (dest, passAddr[0], length * 2);
-        passLabel[0] = new String (dest);       
+    //int /*long*/[] passAddr = new int /*long*/[1];
+    //XPCOM.memmove (passAddr, aPassword, C.PTR_SIZEOF);
+    auto passAddr = aPassword;
+    if (passAddr[0] !is null) {
+            span = XPCOM.strlen_PRUnichar (passAddr[0]);
+            //dest = new char[length];
+            //XPCOM.memmove (dest, passAddr[0], length * 2);
+            passLabel = Utf.toString((passAddr[0])[0 .. span]);       
     }
     
-    if (aCheckMsg !is 0) {
-        length = XPCOM.strlen_PRUnichar (aCheckMsg);
-        if (length > 0) {
-            dest = new char[length];
-            XPCOM.memmove (dest, aCheckMsg, length * 2);
-            checkLabel = new String (dest);
+    if (aCheckMsg !is null) {
+        span = XPCOM.strlen_PRUnichar (aCheckMsg);
+        if (span > 0) {
+            //dest = new char[length];
+            //XPCOM.memmove (dest, aCheckMsg, length * 2);
+            checkLabel = Utf.toString (aCheckMsg[0 .. span]);
         }
     }
 
     Shell shell = browser is null ? new Shell () : browser.getShell ();
     PromptDialog dialog = new PromptDialog (shell);
-    int[] check = new int[1], result = new int[1];
-    if (aCheckState !is 0) XPCOM.memmove (check, aCheckState, 4);   /* PRBool */
+    int check, result;
+    if (aCheckState !is null) check = *aCheckState;   /* PRBool */
     dialog.promptUsernameAndPassword (titleLabel, textLabel, checkLabel, userLabel, passLabel, check, result);
 
-    XPCOM.memmove (_retval, result, 4); /* PRBool */
-    if (result[0] is 1) {
+    *_retval = result; /* PRBool */
+    if (result is 1) {
         /* 
         * User selected OK. User name and password are returned as PRUnichar values. Any default
         * value that we override must be freed using the nsIMemory service.
         */
         int cnt, size;
-        int /*long*/ ptr;
-        char[] buffer;
+        void* ptr;
+        wchar[] buffer;
         int /*long*/[] result2 = new int /*long*/[1];
-        if (userLabel[0] !is null) {
-            cnt = userLabel[0].length ();
-            buffer = new char[cnt + 1];
-            userLabel[0].getChars (0, cnt, buffer, 0);
+        if (userLabel !is null) {
+            //cnt = userLabel[0].length ();
+            //buffer = new char[cnt + 1];
+            buffer = Utf.toString16(userLabel);
+            //userLabel[0].getChars (0, cnt, buffer, 0);
             size = buffer.length * 2;
-            ptr = C.malloc (size);
-            XPCOM.memmove (ptr, buffer, size);
-            XPCOM.memmove (aUsername, new int /*long*/[] {ptr}, C.PTR_SIZEOF);
-
-            if (userAddr[0] !is 0) {
-                int rc = XPCOM.NS_GetServiceManager (result2);
+            ptr = tango.stdc.stdlib.malloc (size);
+            (cast(wchar*)ptr)[0 .. buffer.length] = buffer[0 .. $];
+            //XPCOM.memmove (ptr, buffer, size);
+            *aUsername = cast(PRUnichar*)ptr;
+            //XPCOM.memmove (aUsername, new int /*long*/[] {ptr}, C.PTR_SIZEOF);
+            nsIServiceManager serviceManager;
+            
+            if (userAddr[0] !is null) {
+                int rc = XPCOM.NS_GetServiceManager (&serviceManager);
                 if (rc !is XPCOM.NS_OK) DWT.error (rc);
-                if (result2[0] is 0) DWT.error (XPCOM.NS_NOINTERFACE);
+                if (serviceManager is null) DWT.error (XPCOM.NS_NOINTERFACE);
             
-                nsIServiceManager serviceManager = new nsIServiceManager (result2[0]);
-                result2[0] = 0;
-                byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_MEMORY_CONTRACTID, true);
-                rc = serviceManager.GetServiceByContractID (aContractID, nsIMemory.NS_IMEMORY_IID, result2);
+                //nsIServiceManager serviceManager = new nsIServiceManager (result2[0]);
+                //result2[0] = 0;
+                //byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_MEMORY_CONTRACTID, true);
+                nsIMemory memory;
+                rc = serviceManager.GetServiceByContractID (XPCOM.NS_MEMORY_CONTRACTID, nsIMemory.NS_IMEMORY_IID, cast(void**)&memory);
                 if (rc !is XPCOM.NS_OK) DWT.error (rc);
-                if (result[0] is 0) DWT.error (XPCOM.NS_NOINTERFACE);       
+                if (memory is null) DWT.error (XPCOM.NS_NOINTERFACE);       
                 serviceManager.Release ();
                 
-                nsIMemory memory = new nsIMemory (result2[0]);
-                result2[0] = 0;
+                //nsIMemory memory = new nsIMemory (result2[0]);
+                //result2[0] = 0;
                 memory.Free (userAddr[0]);
                 memory.Release ();
             }
         }
-        if (passLabel[0] !is null) {
-            cnt = passLabel[0].length ();
-            buffer = new char[cnt + 1];
-            passLabel[0].getChars (0, cnt, buffer, 0);
+        if (passLabel !is null) {
+            //cnt = passLabel[0].length ();
+            //buffer = new char[cnt + 1];
+            buffer = Utf.toString16( passLabel );
+            //passLabel[0].getChars (0, cnt, buffer, 0);
             size = buffer.length * 2;
-            ptr = C.malloc (size);
-            XPCOM.memmove (ptr, buffer, size);
-            XPCOM.memmove (aPassword, new int /*long*/[] {ptr}, C.PTR_SIZEOF);
+            ptr = tango.stdc.stdlib.malloc (size);
+            (cast(wchar*)ptr)[0 .. buffer.length] = buffer[0 .. $];
+            //XPCOM.memmove (ptr, buffer, size);
+            *aPassword = cast(PRUnichar*)ptr;
+            //XPCOM.memmove (aPassword, new int /*long*/[] {ptr}, C.PTR_SIZEOF);
             
-            if (passAddr[0] !is 0) {
-                int rc = XPCOM.NS_GetServiceManager (result2);
+            if (passAddr[0] !is null) {
+                int rc = XPCOM.NS_GetServiceManager (&serviceManager);
                 if (rc !is XPCOM.NS_OK) DWT.error (rc);
-                if (result2[0] is 0) DWT.error (XPCOM.NS_NOINTERFACE);
+                if (serviceManager is null) DWT.error (XPCOM.NS_NOINTERFACE);
 
-                nsIServiceManager serviceManager = new nsIServiceManager (result2[0]);
-                result2[0] = 0;
-                byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_MEMORY_CONTRACTID, true);
-                rc = serviceManager.GetServiceByContractID (aContractID, nsIMemory.NS_IMEMORY_IID, result2);
+                //nsIServiceManager serviceManager = new nsIServiceManager (result2[0]);
+                //result2[0] = 0;
+                //byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_MEMORY_CONTRACTID, true);
+                nsIMemory memory;
+                rc = serviceManager.GetServiceByContractID (XPCOM.NS_MEMORY_CONTRACTID, nsIMemory.NS_IMEMORY_IID, cast(void**)&memory);
                 if (rc !is XPCOM.NS_OK) DWT.error (rc);
-                if (result2[0] is 0) DWT.error (XPCOM.NS_NOINTERFACE);      
+                if (memory is null) DWT.error (XPCOM.NS_NOINTERFACE);      
                 serviceManager.Release ();
 
-                nsIMemory memory = new nsIMemory (result2[0]);
-                result2[0] = 0;
+                //nsIMemory memory = new nsIMemory (result2[0]);
+                //result2[0] = 0;
                 memory.Free (passAddr[0]);
                 memory.Release ();
             }
         }
     }
-    if (aCheckState !is 0) XPCOM.memmove (aCheckState, check, 4); /* PRBool */
+    if (aCheckState !is null) *aCheckState = check; /* PRBool */
     return XPCOM.NS_OK;
 }
 
-nsresult PromptPassword (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int /*long*/ aPassword, int /*long*/ aCheckMsg, int /*long*/ aCheckState, int /*long*/ _retval) {
+nsresult PromptPassword (nsIDOMWindow aParent, PRUnichar* aDialogTitle, PRUnichar* aText, PRUnichar** aPassword, PRUnichar* aCheckMsg, PRBool* aCheckState, PRBool* _retval) {
     return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
 }
 
-nsresult Select (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int aCount, int /*long*/ aSelectList, int /*long*/ aOutSelection, int /*long*/ _retval) {
+nsresult Select (nsIDOMWindow aParent, PRUnichar* aDialogTitle, PRUnichar* aText, PRUint32 aCount, PRUnichar** aSelectList, PRInt32* aOutSelection, PRBool* _retval) {
     return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
 }
 
--- a/dwt/browser/PromptService2Factory.d	Tue Aug 12 02:43:31 2008 +0200
+++ b/dwt/browser/PromptService2Factory.d	Tue Aug 12 21:11:17 2008 -0700
@@ -7,100 +7,76 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *      John Reimer <terminal.node@gmail.com>
  *******************************************************************************/
 module dwt.browser.PromptService2Factory;
 
-import dwt.dwthelper.utils;
+//import dwt.dwthelper.utils;
 
-import dwt.internal.C;
+//import dwt.internal.C;
 import dwt.internal.mozilla.XPCOM;
-import dwt.internal.mozilla.XPCOMObject;
+//import dwt.internal.mozilla.XPCOMObject;
 import dwt.internal.mozilla.nsID;
 import dwt.internal.mozilla.nsIFactory;
 import dwt.internal.mozilla.nsISupports;
+import dwt.browser.PromptService2;
 
-class PromptService2Factory {
-    XPCOMObject supports;
-    XPCOMObject factory;
+class PromptService2Factory : nsIFactory {
+ //   XPCOMObject supports;
+ //   XPCOMObject factory;
     int refCount = 0;
 
-PromptService2Factory () {
-    createCOMInterfaces ();
+this () {
+//    createCOMInterfaces ();
 }
 
-int AddRef () {
+nsrefcnt AddRef () {
     refCount++;
     return refCount;
 }
 
-void createCOMInterfaces () {
-    /* Create each of the interfaces that this object implements */
-    supports = new XPCOMObject (new int[] {2, 0, 0}) {
-        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
-        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
-        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
-    };
+nsresult QueryInterface (nsID* riid, void** ppvObject) {
+    if (riid is null || ppvObject is null) return XPCOM.NS_ERROR_NO_INTERFACE;
+    //nsID guid = new nsID ();
+    //XPCOM.memmove (guid, riid, nsID.sizeof);
     
-    factory = new XPCOMObject (new int[] {2, 0, 0, 3, 1}) {
-        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
-        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
-        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
-        public int /*long*/ method3 (int /*long*/[] args) {return CreateInstance (args[0], args[1], args[2]);}
-        public int /*long*/ method4 (int /*long*/[] args) {return LockFactory ((int)/*64*/args[0]);}
-    };
-}
-
-void disposeCOMInterfaces () {
-    if (supports !is null) {
-        supports.dispose ();
-        supports = null;
-    }   
-    if (factory !is null) {
-        factory.dispose ();
-        factory = null; 
-    }
-}
-
-int /*long*/ getAddress () {
-    return factory.getAddress ();
-}
-
-int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
-    if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE;
-    nsID guid = new nsID ();
-    XPCOM.memmove (guid, riid, nsID.sizeof);
-    
-    if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) {
-        XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF);
+    if (*riid == nsISupports.IID) {
+        *ppvObject = cast(void*)cast(nsISupports)this;
         AddRef ();
         return XPCOM.NS_OK;
     }
-    if (guid.Equals (nsIFactory.NS_IFACTORY_IID)) {
-        XPCOM.memmove (ppvObject, new int /*long*/[] {factory.getAddress ()}, C.PTR_SIZEOF);
+    if (*riid == nsIFactory.IID) {
+        *ppvObject = cast(void*)cast(nsIFactory)this;
         AddRef ();
         return XPCOM.NS_OK;
     }
     
-    XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
+    *ppvObject = null;
     return XPCOM.NS_ERROR_NO_INTERFACE;
 }
             
-int Release () {
+nsrefcnt Release () {
     refCount--;
-    if (refCount is 0) disposeCOMInterfaces ();
+    //if (refCount is null) disposeCOMInterfaces ();
     return refCount;
 }
     
 /* nsIFactory */
 
-int CreateInstance (int /*long*/ aOuter, int /*long*/ iid, int /*long*/ result) {
-    PromptService2 promptService = new PromptService2 ();
-    promptService.AddRef ();
-    XPCOM.memmove (result, new int /*long*/[] {promptService.getAddress ()}, C.PTR_SIZEOF);
-    return XPCOM.NS_OK;
+nsresult CreateInstance (nsISupports aOuter, nsIID* iid, void** result) {
+    if (result is null) 
+        return XPCOM.NS_ERROR_INVALID_ARG;
+    auto promptService = new PromptService2;
+    nsresult rv = promptService.QueryInterface( iid, result );
+    if (XPCOM.NS_FAILED(rv)) {
+        *result = null;
+        delete promptService;
+    }
+    return rv;
 }
 
-int LockFactory (int lock) {
+nsresult LockFactory (PRBool lock) {
     return XPCOM.NS_OK;
 }
 }
--- a/dwt/browser/SimpleEnumerator.d	Tue Aug 12 02:43:31 2008 +0200
+++ b/dwt/browser/SimpleEnumerator.d	Tue Aug 12 21:11:17 2008 -0700
@@ -7,113 +7,77 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *      John Reimer <terminal.node@gmail.com>
  *******************************************************************************/
 module dwt.browser.SimpleEnumerator;
 
-import dwt.dwthelper.utils;
+//import dwt.dwthelper.utils;
 
-import dwt.internal.C;
+//import dwt.internal.C;
 import dwt.internal.mozilla.XPCOM;
-import dwt.internal.mozilla.XPCOMObject;
+//import dwt.internal.mozilla.XPCOMObject;
 import dwt.internal.mozilla.nsID;
 import dwt.internal.mozilla.nsISimpleEnumerator;
 import dwt.internal.mozilla.nsISupports;
 
-class SimpleEnumerator {
-    XPCOMObject supports;
-    XPCOMObject simpleEnumerator;
+class SimpleEnumerator : nsISimpleEnumerator{
+//    XPCOMObject supports;
+//    XPCOMObject simpleEnumerator;
     int refCount = 0;
     nsISupports[] values;
     int index = 0;
 
-SimpleEnumerator (nsISupports[] values) {
+this (nsISupports[] values) {
     this.values = values;
     for (int i = 0; i < values.length; i++) {
         values[i].AddRef ();
     }
-    createCOMInterfaces ();
+    //createCOMInterfaces ();
 }
 
-int AddRef () {
+nsrefcnt AddRef () {
     refCount++;
     return refCount;
 }
 
-void createCOMInterfaces () {
-    /* Create each of the interfaces that this object implements */
-    supports = new XPCOMObject (new int[] {2, 0, 0}) {
-        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
-        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
-        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
-    };
-
-    simpleEnumerator = new XPCOMObject (new int[] {2, 0, 0, 1, 1}) {
-        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
-        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
-        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
-        public int /*long*/ method3 (int /*long*/[] args) {return HasMoreElements (args[0]);}
-        public int /*long*/ method4 (int /*long*/[] args) {return GetNext (args[0]);}
-    };
-}
+nsresult QueryInterface (nsID* riid, void** ppvObject) {
+    if (riid is null || ppvObject is null) return XPCOM.NS_ERROR_NO_INTERFACE;
+    //nsID guid = new nsID ();
+    //XPCOM.memmove (guid, riid, nsID.sizeof);
 
-void disposeCOMInterfaces () {
-    if (supports !is null) {
-        supports.dispose ();
-        supports = null;
-    }   
-    if (simpleEnumerator !is null) {
-        simpleEnumerator.dispose ();
-        simpleEnumerator = null;    
-    }
-    if (values !is null) {
-        for (int i = 0; i < values.length; i++) {
-            values[i].Release ();
-        }
-        values = null;
-    }
-}
-
-int /*long*/ getAddress () {
-    return simpleEnumerator.getAddress ();
-}
-
-int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
-    if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE;
-    nsID guid = new nsID ();
-    XPCOM.memmove (guid, riid, nsID.sizeof);
-
-    if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) {
-        XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF);
+    if (*riid == nsISupports.IID) {
+        *ppvObject = cast(void*)cast(nsISupports)this;
         AddRef ();
         return XPCOM.NS_OK;
     }
-    if (guid.Equals (nsISimpleEnumerator.NS_ISIMPLEENUMERATOR_IID)) {
-        XPCOM.memmove (ppvObject, new int /*long*/[] {simpleEnumerator.getAddress ()}, C.PTR_SIZEOF);
+    if (*riid == nsISimpleEnumerator.IID) {
+        *ppvObject = cast(void*)cast(nsISimpleEnumerator)this;
         AddRef ();
         return XPCOM.NS_OK;
     }
 
-    XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
+    *ppvObject = null;
     return XPCOM.NS_ERROR_NO_INTERFACE;
 }
 
-int Release () {
+nsresult Release () {
     refCount--;
-    if (refCount is 0) disposeCOMInterfaces ();
+    //if (refCount is 0) disposeCOMInterfaces ();
     return refCount;
 }
 
-int HasMoreElements (int /*long*/ _retval) {
+nsresult HasMoreElements (PRBool* _retval) {
     bool more = values !is null && index < values.length;
-    XPCOM.memmove (_retval, new int[] {more ? 1 : 0}, 4); /*PRBool */
+    *_retval = more ? 1 : 0; /*PRBool */
     return XPCOM.NS_OK;
 }   
     
-int GetNext (int /*long*/ _retval) {
+nsresult GetNext (nsISupports* _retval) {
     if (values is null || index is values.length) return XPCOM.NS_ERROR_UNEXPECTED;
     nsISupports value = values[index++];
     value.AddRef ();
-    XPCOM.memmove (_retval, new int /*long*/[] {value.getAddress ()}, C.PTR_SIZEOF);
+    *_retval = value;
     return XPCOM.NS_OK;
 }       
 }
--- a/dwt/browser/StatusTextEvent.d	Tue Aug 12 02:43:31 2008 +0200
+++ b/dwt/browser/StatusTextEvent.d	Tue Aug 12 21:11:17 2008 -0700
@@ -7,10 +7,12 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *      John Reimer <terminal.node@gmail.com>
  *******************************************************************************/
 module dwt.browser.StatusTextEvent;
 
-import dwt.dwthelper.utils;
+//import dwt.dwthelper.utils;
 
 import dwt.events.TypedEvent;
 import dwt.widgets.Widget;
@@ -23,13 +25,13 @@
  * 
  * @since 3.0
  */
-public class StatusTextEvent extends TypedEvent {
+public class StatusTextEvent : TypedEvent {
     /** status text */
     public String text;
     
     static final long serialVersionUID = 3258407348371600439L;
 
-StatusTextEvent(Widget w) {
+this(Widget w) {
     super(w);
 }
 
@@ -39,10 +41,9 @@
  *
  * @return a string representation of the event
  */
-public String toString() {
-    String string = super.toString ();
-    return string.substring (0, string.length() - 1) // remove trailing '}'
-        + " text=" + text
-        + "}";
+public override String toString() {
+    return Format( "{} {text = {}}", 
+        super.toString[1 .. $-2], text );  
 }
+
 }
--- a/dwt/browser/StatusTextListener.d	Tue Aug 12 02:43:31 2008 +0200
+++ b/dwt/browser/StatusTextListener.d	Tue Aug 12 21:11:17 2008 -0700
@@ -7,10 +7,13 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *      John Reimer <terminal.node@gmail.com>
  *******************************************************************************/
 module dwt.browser.StatusTextListener;
 
-import dwt.dwthelper.utils;
+import dwt.browser.StatusTextEvent;
+//import dwt.dwthelper.utils;
 
 import dwt.internal.DWTEventListener;
 
@@ -24,7 +27,7 @@
  * 
  * @since 3.0
  */
-public interface StatusTextListener extends DWTEventListener {
+public interface StatusTextListener : DWTEventListener {
 
 /**
  * This method is called when the status text is changed. The
--- a/dwt/browser/TitleEvent.d	Tue Aug 12 02:43:31 2008 +0200
+++ b/dwt/browser/TitleEvent.d	Tue Aug 12 21:11:17 2008 -0700
@@ -7,10 +7,12 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *      John Reimer <terminal.node@gmail.com>
  *******************************************************************************/
 module dwt.browser.TitleEvent;
 
-import dwt.dwthelper.utils;
+//import dwt.dwthelper.utils;
 
 import dwt.events.TypedEvent;
 import dwt.widgets.Widget;
@@ -22,13 +24,13 @@
  * 
  * @since 3.0
  */
-public class TitleEvent extends TypedEvent {
+public class TitleEvent : TypedEvent {
     /** the title of the current document */
     public String title;
     
     static final long serialVersionUID = 4121132532906340919L;
 
-TitleEvent(Widget w) {
+this(Widget w) {
     super(w);
 }
 
@@ -38,10 +40,8 @@
  *
  * @return a string representation of the event
  */
-public String toString() {
-    String string = super.toString ();
-    return string.substring (0, string.length() - 1) // remove trailing '}'
-        + " title=" + title
-        + "}";
+public override String toString() {
+    return Format( "{} {text = {}}", 
+        super.toString[1 .. $-2], text );  
 }
 }
--- a/dwt/browser/TitleListener.d	Tue Aug 12 02:43:31 2008 +0200
+++ b/dwt/browser/TitleListener.d	Tue Aug 12 21:11:17 2008 -0700
@@ -7,10 +7,13 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *      John Reimer <terminal.node@gmail.com>
  *******************************************************************************/
 module dwt.browser.TitleListener;
 
-import dwt.dwthelper.utils;
+import dwt.browser.TitleEvent;
+//import dwt.dwthelper.utils;
 
 import dwt.internal.DWTEventListener;
 
@@ -24,7 +27,7 @@
  * 
  * @since 3.0
  */
-public interface TitleListener extends DWTEventListener {
+public interface TitleListener : DWTEventListener {
 
 /**
  * This method is called when the title of the current document
--- a/dwt/browser/VisibilityWindowAdapter.d	Tue Aug 12 02:43:31 2008 +0200
+++ b/dwt/browser/VisibilityWindowAdapter.d	Tue Aug 12 21:11:17 2008 -0700
@@ -7,10 +7,13 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *      John Reimer <terminal.node@gmail.com>
  *******************************************************************************/
 module dwt.browser.VisibilityWindowAdapter;
 
-import dwt.dwthelper.utils;
+import dwt.browser.WindowEvent;
+//import dwt.dwthelper.utils;
 
 /**
  * This adapter class provides default implementations for the
@@ -23,7 +26,7 @@
  * 
  * @since 3.0
  */
-public abstract class VisibilityWindowAdapter implements VisibilityWindowListener {
+public abstract class VisibilityWindowAdapter : VisibilityWindowListener {
 
 public void hide(WindowEvent event) {
 }
--- a/dwt/browser/VisibilityWindowListener.d	Tue Aug 12 02:43:31 2008 +0200
+++ b/dwt/browser/VisibilityWindowListener.d	Tue Aug 12 21:11:17 2008 -0700
@@ -7,10 +7,13 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *      John Reimer <terminal.node@gmail.com>
  *******************************************************************************/
 module dwt.browser.VisibilityWindowListener;
 
-import dwt.dwthelper.utils;
+import dwt.browser.WindowEvent;
+//import dwt.dwthelper.utils;
 
 import dwt.internal.DWTEventListener;
 
@@ -26,7 +29,7 @@
  * 
  * @since 3.0
  */
-public interface VisibilityWindowListener extends DWTEventListener {
+public interface VisibilityWindowListener : DWTEventListener {
     
 /**
  * This method is called when the window hosting a <code>Browser</code> 
--- a/dwt/browser/WindowCreator2.d	Tue Aug 12 02:43:31 2008 +0200
+++ b/dwt/browser/WindowCreator2.d	Tue Aug 12 21:11:17 2008 -0700
@@ -7,17 +7,19 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *      John Reimer <terminal.node@gmail.com>
  *******************************************************************************/
 module dwt.browser.WindowCreator2;
 
-import dwt.dwthelper.utils;
+//import dwt.dwthelper.utils;
 
 import dwt.DWT;
 import dwt.graphics.Point;
-import dwt.internal.C;
+//import dwt.internal.C;
 import dwt.internal.Platform;
 import dwt.internal.mozilla.XPCOM;
-import dwt.internal.mozilla.XPCOMObject;
+//import dwt.internal.mozilla.XPCOMObject;
 import dwt.internal.mozilla.nsIBaseWindow;
 import dwt.internal.mozilla.nsID;
 import dwt.internal.mozilla.nsISupports;
@@ -29,66 +31,22 @@
 import dwt.layout.FillLayout;
 import dwt.widgets.Shell;
 
-class WindowCreator2 {
-    XPCOMObject supports;
-    XPCOMObject windowCreator;
-    XPCOMObject windowCreator2;
+class WindowCreator2 : nsIWindowCreator2{
+//    XPCOMObject supports;
+//    XPCOMObject windowCreator;
+//    XPCOMObject windowCreator2;
     int refCount = 0;
 
-WindowCreator2 () {
-    createCOMInterfaces ();
+this () {
+//    createCOMInterfaces ();
 }
 
-int AddRef () {
+nsrefcnt AddRef () {
     refCount++;
     return refCount;
 }
 
-void createCOMInterfaces () {
-    /* Create each of the interfaces that this object implements */
-    supports = new XPCOMObject (new int[] {2, 0, 0}) {
-        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
-        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
-        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
-    };
-
-    windowCreator = new XPCOMObject (new int[] {2, 0, 0, 3}) {
-        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
-        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
-        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
-        public int /*long*/ method3 (int /*long*/[] args) {return CreateChromeWindow (args[0], (int)/*64*/args[1], args[2]);}
-    };
-
-    windowCreator2 = new XPCOMObject (new int[] {2, 0, 0, 3, 6}) {
-        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
-        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
-        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
-        public int /*long*/ method3 (int /*long*/[] args) {return CreateChromeWindow (args[0], (int)/*64*/args[1], args[2]);}
-        public int /*long*/ method4 (int /*long*/[] args) {return CreateChromeWindow2 (args[0], (int)/*64*/args[1], (int)/*64*/args[2], args[3], args[4], args[5]);}
-    };
-}
-
-void disposeCOMInterfaces () {
-    if (supports !is null) {
-        supports.dispose ();
-        supports = null;
-    }   
-    if (windowCreator !is null) {
-        windowCreator.dispose ();
-        windowCreator = null;   
-    }
-
-    if (windowCreator2 !is null) {
-        windowCreator2.dispose ();
-        windowCreator2 = null;  
-    }
-}
-
-int /*long*/ getAddress () {
-    return windowCreator.getAddress ();
-}
-
-int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
+nsresult QueryInterface (nsID* riid, void** ppvObject) {
     if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE;
     nsID guid = new nsID ();
     XPCOM.memmove (guid, riid, nsID.sizeof);
@@ -113,9 +71,9 @@
     return XPCOM.NS_ERROR_NO_INTERFACE;
 }
             
-int Release () {
+nsresult Release () {
     refCount--;
-    if (refCount is 0) disposeCOMInterfaces ();
+    //if (refCount is 0) disposeCOMInterfaces ();
     return refCount;
 }
     
--- a/dwt/browser/WindowEvent.d	Tue Aug 12 02:43:31 2008 +0200
+++ b/dwt/browser/WindowEvent.d	Tue Aug 12 21:11:17 2008 -0700
@@ -12,7 +12,7 @@
  *******************************************************************************/
 module dwt.browser.WindowEvent;
 
-import dwt.dwthelper.utils;
+//import dwt.dwthelper.utils;
 
 import dwt.events.TypedEvent;
 import dwt.graphics.Point;