changeset 137:52d360200ae4

Fixed #7
author Jacob Carlborg <doob@me.com>
date Sat, 30 May 2009 23:40:34 +0200
parents 1a0129cab08e
children 3d9eb62cd2e3
files dwt/custom/CCombo.d dwt/internal/cocoa/NSString.d dwt/widgets/Control.d
diffstat 3 files changed, 41 insertions(+), 57 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/custom/CCombo.d	Sat May 30 21:38:21 2009 +0200
+++ b/dwt/custom/CCombo.d	Sat May 30 23:40:34 2009 +0200
@@ -50,8 +50,8 @@
 static import tango.text.convert.Utf;
 static import tango.text.Unicode;
 static import tango.text.convert.Format;
-
 import dwt.dwthelper.utils;
+import dwt.dwthelper.Runnable;
 
 /**
  * The CCombo class represents a selectable user interface object
@@ -95,6 +95,40 @@
     Color foreground, background;
     Font font;
 
+    private class CComboListener : Listener
+    {
+        public void handleEvent (Event event) {
+            if (popup is event.widget) {
+                popupEvent (event);
+                return;
+            }
+            if (text is event.widget) {
+                textEvent (event);
+                return;
+            }
+            if (list is event.widget) {
+                listEvent (event);
+                return;
+            }
+            if (arrow is event.widget) {
+                arrowEvent (event);
+                return;
+            }
+            if (this.outer is event.widget) {
+                comboEvent (event);
+                return;
+            }
+            if (getShell () is event.widget) {
+                getDisplay().asyncExec(new class() Runnable {
+                    public void run() {
+                        if (isDisposed()) return;
+                        handleFocus (DWT.FocusOut);
+                    }
+                });
+            }
+        }
+    }
+
 /**
  * Constructs a new instance of this class given its parent
  * and a style value describing its behavior and appearance.
@@ -134,52 +168,8 @@
     if ((style & DWT.FLAT) !is 0) arrowStyle |= DWT.FLAT;
     arrow = new Button (this, arrowStyle);
 
-    listener = new class(text, list, popup, arrow) Listener {
-
-        Text text;
-        List list;
-        Shell popup;
-        Button arrow;
-
-        this (Text text, List list, Shell popup, Button arrow)
-        {
-            this.text = text;
-            this.list = list;
-            this.popup = popup;
-            this.arrow = arrow;
-        }
-
-        public void handleEvent (Event event) {
-            if (popup is event.widget) {
-                this.outer.popupEvent (event);
-                return;
-            }
-            if (text is event.widget) {
-                this.outer.textEvent (event);
-                return;
-            }
-            if (list is event.widget) {
-                this.outer.listEvent (event);
-                return;
-            }
-            if (arrow is event.widget) {
-                this.outer.arrowEvent (event);
-                return;
-            }
-            if (this.outer is event.widget) {
-                this.outer.comboEvent (event);
-                return;
-            }
-            if (getShell () is event.widget) {
-                getDisplay().asyncExec(new class() Runnable {
-                    public void run() {
-                        if (this.outer.outer.isDisposed()) return;
-                        this.outer.outer.handleFocus (DWT.FocusOut);
-                    }
-                });
-            }
-        }
-    };
+    listener = new CComboListener;
+    
     filter = new class() Listener {
         public void handleEvent(Event event) {
             Shell shell = (cast(Control)event.widget).getShell ();
@@ -546,7 +536,7 @@
     list.deselectAll ();
 }
 void dropDown (bool drop) {
-    if (drop is isDropped () || !isVisible()) return;
+    if (drop is isDropped ()) return;
     if (!drop) {
         popup.setVisible (false);
         if (!isDisposed () && isFocusControl()) {
@@ -554,7 +544,7 @@
         }
         return;
     }
-
+    if (!isVisible()) return;
     if (getShell() !is popup.getParent ()) {
         String[] items = list.getItems ();
         int selectionIndex = list.getSelectionIndex ();
--- a/dwt/internal/cocoa/NSString.d	Sat May 30 21:38:21 2009 +0200
+++ b/dwt/internal/cocoa/NSString.d	Sat May 30 23:40:34 2009 +0200
@@ -13,8 +13,6 @@
  *******************************************************************************/
 module dwt.internal.cocoa.NSString;
 
-import tango = tango.text.convert.Utf;
-
 import dwt.dwthelper.utils;
 import cocoa = dwt.internal.cocoa.id;
 import dwt.internal.cocoa.NSObject;
@@ -40,13 +38,11 @@
 public String getString() {
     wchar[] buffer = new wchar[length()];
     getCharacters(buffer.ptr);
-    return tango.toString(buffer);
+    return dwt.dwthelper.utils.toString(buffer);
 }
 
 public static NSString stringWith(String str) {
-    char[] buffer = new char[str.length];
-    str.getChars(0, buffer.length, buffer, 0);
-    return stringWithCharacters(buffer.toString16().ptr, buffer.length);
+    return stringWithUTF8String((str ~ '\0').ptr);
 }
 
 public /*const*/char* UTF8String() {
--- a/dwt/widgets/Control.d	Sat May 30 21:38:21 2009 +0200
+++ b/dwt/widgets/Control.d	Sat May 30 23:40:34 2009 +0200
@@ -79,8 +79,6 @@
 import dwt.widgets.TypedListener;
 import dwt.widgets.Widget;
 
-import tango.io.Stdout;
-
 /**
  * Control is the abstract superclass of all windowed user interface classes.
  * <p>