diff dwtx/ui/forms/FormColors.d @ 104:04b47443bb01

Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections. These new wrappers now use the tango.util.containers instead of the tango.util.collections.
author Frank Benoit <benoit@tionex.de>
date Thu, 07 Aug 2008 15:01:33 +0200
parents 4ac9946b9fb5
children
line wrap: on
line diff
--- a/dwtx/ui/forms/FormColors.d	Sun Aug 03 17:01:51 2008 +0200
+++ b/dwtx/ui/forms/FormColors.d	Thu Aug 07 15:01:33 2008 +0200
@@ -20,7 +20,7 @@
 import dwt.widgets.Display;
 
 import dwt.dwthelper.utils;
-import tango.util.collection.HashMap;
+import dwtx.dwtxhelper.Collection;
 
 /**
  * Manages colors that will be applied to forms and form widgets. The colors are
@@ -96,7 +96,7 @@
      */
     public static const String TB_TOGGLE_HOVER = IFormColors.TB_TOGGLE_HOVER;
 
-    protected HashMap!(String,Object) colorRegistry;
+    protected Map colorRegistry;
 
     protected Color background;
 
@@ -115,7 +115,7 @@
      *            the display to use
      */
     public this(Display display) {
-        colorRegistry = new HashMap!(String,Object);
+        colorRegistry = new HashMap(10);
         this.display = display;
         initialize();
     }
@@ -258,10 +258,10 @@
      */
     public Color createColor(String key, int r, int g, int b) {
         Color c = new Color(display, r, g, b);
-        Color prevC = cast(Color) (colorRegistry.containsKey(key) ? colorRegistry.get(key) : null );
+        Color prevC = cast(Color) colorRegistry.get(key);
         if (prevC !is null)
             prevC.dispose();
-        colorRegistry.add(key, c);
+        colorRegistry.put(key, c);
         return c;
     }
 
@@ -368,9 +368,9 @@
      * Disposes all the colors in the registry.
      */
     public void dispose() {
-        foreach( k, v; colorRegistry )
-            (cast(Color) v).dispose();
-
+        Iterator e = colorRegistry.values().iterator();
+        while (e.hasNext())
+            (cast(Color) e.next()).dispose();
         colorRegistry = null;
     }
 
@@ -621,7 +621,7 @@
     private void disposeIfFound(String key) {
         Color color = getColor(key);
         if (color !is null) {
-            colorRegistry.removeKey(key);
+            colorRegistry.remove(key);
             color.dispose();
         }
     }