--- a/ColorMenu.st Wed Oct 18 13:14:46 2006 +0200
+++ b/ColorMenu.st Fri Oct 20 11:17:54 2006 +0200
@@ -9,9 +9,6 @@
other person. No title to or ownership of the software is
hereby transferred.
"
-
-
-
"{ Package: 'stx:libwidg2' }"
MenuPanel subclass:#ColorMenu
@@ -125,55 +122,52 @@
colorMenu:labelAreColored value:aValue
"returns a color menu
"
- |menu mainCol style e|
+ |menu style|
+
+ menu := Menu new.
- menu := Menu new.
- style := (labelAreColored == false)
- ifTrue:[#backgroundColor]
- ifFalse:[#color].
+ labelAreColored == false ifTrue:[ style := #backgroundColor ]
+ ifFalse:[ style := #color ].
- self colorDefinition do:[:aSlice|
- |size colOp color item smenu|
+ self colorDefinition do:[:aSlice| |item baseColor getColSel subMenu colorId|
- mainCol := Color perform:(aSlice at:1).
- item := MenuItem labeled:(Text string:' ' emphasis:(#backgroundColor->mainCol)).
- smenu := Menu new.
- colOp := aSlice at:2.
+ subMenu := Menu new.
+ colorId := aSlice at:1.
+ getColSel := aSlice at:2.
+ baseColor := Color perform:colorId.
- (aSlice at:3) do:[:el||sitem label|
+ aSlice last do:[:el||label color|
+ color := label := nil.
+
el isSymbol ifTrue:[
- color := el == #lightened ifTrue:[mainCol perform:el] ifFalse:[Color perform:el].
- self colorDefinition first ~~ aSlice
- ifTrue: [label := (colOp upTo: $:), ' ', el]
- ifFalse:[label := el].
+ el == #lightened ifTrue:[ color := baseColor perform:el ]
+ ifFalse:[ color := Color perform:el ].
+
+ colorId == #gray ifTrue:[ label := el ].
] ifFalse:[
el isNumber ifTrue:[
- color := Color perform:colOp with:el.
- label := colOp, ' ', el printString.
- ] ifFalse:[
- color := Color perform:colOp with:(el at:1) with:(el at:2) with:(el at:3).
- label := ''.
- colOp keywords keysAndValuesDo:[:i :c| label := label, ' ', c, ' ' , (el at:i) printString ].
+ color := Color perform:getColSel with:el.
]
].
- e := style->color.
- style == #backgroundColor ifTrue:[
- color brightness < 0.5 ifTrue:[
- e := Array with:e
- with:(#color->Color white)
- ]
+ color notNil ifTrue:[ |emphasis|
+ label isNil ifTrue:[ label := getColSel, ' ', el printString ].
+
+ emphasis := style->color.
+ style == #backgroundColor ifTrue:[
+ color brightness < 0.5 ifTrue:[
+ emphasis := Array with:emphasis with:(#color->Color white)
+ ]
+ ].
+ item := MenuItem labeled:(Text string:('Color ', label) emphasis:emphasis).
+ item argument:color.
+ item value:aValue.
+ subMenu addItem:item.
].
- sitem := MenuItem
- labeled:(Text
- string:('Color ', label)
- emphasis:e).
- sitem argument:color.
- sitem value:aValue.
- smenu addItem:sitem.
].
- item submenu:smenu.
+ item := MenuItem labeled:(Text string:' ' emphasis:(#backgroundColor->baseColor)).
+ item submenu:subMenu.
item value:nil.
- menu addItem:item
+ menu addItem:item.
].
^ menu
"
@@ -337,5 +331,5 @@
!ColorMenu class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/ColorMenu.st,v 1.34 2006-03-06 10:16:27 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/ColorMenu.st,v 1.35 2006-10-20 09:17:54 ca Exp $'
! !