symbolic colors
authorStefan Vogel <sv@exept.de>
Mon, 25 Feb 2008 15:10:10 +0100
changeset 3344 cd9cf0a541f3
parent 3343 59113bee857a
child 3345 088090deaffb
symbolic colors
ColorMenu.st
--- a/ColorMenu.st	Mon Feb 18 19:30:34 2008 +0100
+++ b/ColorMenu.st	Mon Feb 25 15:10:10 2008 +0100
@@ -12,7 +12,7 @@
 "{ Package: 'stx:libwidg2' }"
 
 MenuPanel subclass:#ColorMenu
-	instanceVariableNames:'enabledChannel labelsAreColored'
+	instanceVariableNames:'enabledChannel labelsAreColored colorName'
 	classVariableNames:'ColorMenuSpec RecentlyUsedColors'
 	poolDictionaries:''
 	category:'Interface-UIPainter'
@@ -386,20 +386,21 @@
 color:aColor
     "set current color"
 
-    |holder label|
+    |label|
 
-    aColor isColor ifFalse:[
+    (aColor isColor or:[aColor isSymbol]) ifFalse:[
         enabledChannel value:false
     ] ifTrue:[
-        self 
-            disabledRedrawDo:
-                [                 
-                    holder := self colorHolder.     
-                    label  := Text string: '   ' emphasis:(#backgroundColor->aColor).
-                    enabledChannel value:true.
-                    holder label:label.
-                    self choseColor:aColor
-                ]
+        aColor isSymbol ifTrue:[
+            label  := aColor asText "emphasis:(#backgroundColor->aColor)".
+        ] ifFalse:[
+            label  := Text string: '   ' emphasis:(#backgroundColor->aColor).
+        ].
+        self disabledRedrawDo:[
+            enabledChannel value:true.
+            self colorHolder label:label.
+            self choseColor:aColor
+        ]
     ]
 !
 
@@ -442,16 +443,22 @@
 
     menu := Menu new.
 
-    RecentlyUsedColors do:[:clr |
+    RecentlyUsedColors do:[:eachRecentlyUsedColor |
         |label fgColor item|
 
-        clr brightness < 0.5 ifTrue:[ fgColor := Color white ]
-                             ifFalse:[ fgColor := Color black ].
+        eachRecentlyUsedColor isSymbol ifTrue:[
+            label := eachRecentlyUsedColor  .
+        ] ifFalse:[
+            eachRecentlyUsedColor brightness < 0.5 
+                ifTrue:[ fgColor := Color white ]
+                ifFalse:[ fgColor := Color black ].
 
-        label := clr htmlPrintString.
-        label := Text string:(' ', label, ' ') foregroundColor:fgColor backgroundColor:clr.
+            label := eachRecentlyUsedColor htmlPrintString.
+            label := Text string:(' ', label, ' ') foregroundColor:fgColor backgroundColor:eachRecentlyUsedColor.
+        ].
+
         item := MenuItem labeled:label.
-        item argument:clr.
+        item argument:eachRecentlyUsedColor.
 
         menu addItem:item.
     ].
@@ -556,5 +563,5 @@
 !ColorMenu class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/ColorMenu.st,v 1.44 2008-02-18 08:38:16 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/ColorMenu.st,v 1.45 2008-02-25 14:10:10 stefan Exp $'
 ! !