Mercurial > projects > dwt-addons
comparison 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 |
comparison
equal
deleted
inserted
replaced
103:2d6540440fe6 | 104:04b47443bb01 |
---|---|
18 import dwt.graphics.Color; | 18 import dwt.graphics.Color; |
19 import dwt.graphics.RGB; | 19 import dwt.graphics.RGB; |
20 import dwt.widgets.Display; | 20 import dwt.widgets.Display; |
21 | 21 |
22 import dwt.dwthelper.utils; | 22 import dwt.dwthelper.utils; |
23 import tango.util.collection.HashMap; | 23 import dwtx.dwtxhelper.Collection; |
24 | 24 |
25 /** | 25 /** |
26 * Manages colors that will be applied to forms and form widgets. The colors are | 26 * Manages colors that will be applied to forms and form widgets. The colors are |
27 * chosen to make the widgets look correct in the editor area. If a different | 27 * chosen to make the widgets look correct in the editor area. If a different |
28 * set of colors is needed, subclass this class and override 'initialize' and/or | 28 * set of colors is needed, subclass this class and override 'initialize' and/or |
94 * @since 3.1 | 94 * @since 3.1 |
95 * @deprecated use <code>IFormColors.TB_TOGGLE_HOVER</code>. | 95 * @deprecated use <code>IFormColors.TB_TOGGLE_HOVER</code>. |
96 */ | 96 */ |
97 public static const String TB_TOGGLE_HOVER = IFormColors.TB_TOGGLE_HOVER; | 97 public static const String TB_TOGGLE_HOVER = IFormColors.TB_TOGGLE_HOVER; |
98 | 98 |
99 protected HashMap!(String,Object) colorRegistry; | 99 protected Map colorRegistry; |
100 | 100 |
101 protected Color background; | 101 protected Color background; |
102 | 102 |
103 protected Color foreground; | 103 protected Color foreground; |
104 | 104 |
113 * | 113 * |
114 * @param display | 114 * @param display |
115 * the display to use | 115 * the display to use |
116 */ | 116 */ |
117 public this(Display display) { | 117 public this(Display display) { |
118 colorRegistry = new HashMap!(String,Object); | 118 colorRegistry = new HashMap(10); |
119 this.display = display; | 119 this.display = display; |
120 initialize(); | 120 initialize(); |
121 } | 121 } |
122 | 122 |
123 /** | 123 /** |
256 * blue value | 256 * blue value |
257 * @return the allocated color object | 257 * @return the allocated color object |
258 */ | 258 */ |
259 public Color createColor(String key, int r, int g, int b) { | 259 public Color createColor(String key, int r, int g, int b) { |
260 Color c = new Color(display, r, g, b); | 260 Color c = new Color(display, r, g, b); |
261 Color prevC = cast(Color) (colorRegistry.containsKey(key) ? colorRegistry.get(key) : null ); | 261 Color prevC = cast(Color) colorRegistry.get(key); |
262 if (prevC !is null) | 262 if (prevC !is null) |
263 prevC.dispose(); | 263 prevC.dispose(); |
264 colorRegistry.add(key, c); | 264 colorRegistry.put(key, c); |
265 return c; | 265 return c; |
266 } | 266 } |
267 | 267 |
268 /** | 268 /** |
269 * Computes the border color relative to the background. Allocated border | 269 * Computes the border color relative to the background. Allocated border |
366 | 366 |
367 /** | 367 /** |
368 * Disposes all the colors in the registry. | 368 * Disposes all the colors in the registry. |
369 */ | 369 */ |
370 public void dispose() { | 370 public void dispose() { |
371 foreach( k, v; colorRegistry ) | 371 Iterator e = colorRegistry.values().iterator(); |
372 (cast(Color) v).dispose(); | 372 while (e.hasNext()) |
373 | 373 (cast(Color) e.next()).dispose(); |
374 colorRegistry = null; | 374 colorRegistry = null; |
375 } | 375 } |
376 | 376 |
377 /** | 377 /** |
378 * Marks the colors shared. This prevents toolkits that share this object | 378 * Marks the colors shared. This prevents toolkits that share this object |
619 } | 619 } |
620 | 620 |
621 private void disposeIfFound(String key) { | 621 private void disposeIfFound(String key) { |
622 Color color = getColor(key); | 622 Color color = getColor(key); |
623 if (color !is null) { | 623 if (color !is null) { |
624 colorRegistry.removeKey(key); | 624 colorRegistry.remove(key); |
625 color.dispose(); | 625 color.dispose(); |
626 } | 626 } |
627 } | 627 } |
628 | 628 |
629 private void createFormHeaderColors() { | 629 private void createFormHeaderColors() { |