diff -r 4ef9b35afcdc -r 35c107962304 ColorMenu.st --- a/ColorMenu.st Sun Jan 23 20:35:29 2011 +0100 +++ b/ColorMenu.st Mon Jan 24 11:25:37 2011 +0100 @@ -14,7 +14,8 @@ MenuPanel subclass:#ColorMenu instanceVariableNames:'overwriteDefaultToggleChannel enabledChannel labelsAreColored color colorName allowSymbolicColors showDefaultToggle - acceptAction useDefaultColorToggleVisibleHolder' + acceptAction useDefaultColorToggleVisibleHolder allowNilColor + haveMenu hasNilColorHolder' classVariableNames:'ColorMenuSpec RecentlyUsedColors' poolDictionaries:'' category:'Interface-UIPainter' @@ -411,9 +412,11 @@ (model notNil and:[ model isSymbol not]) ifTrue:[ - model value:aColor. + model value:(self hasNilColorHolder value ifTrue:[nil] ifFalse:[aColor]). ]. color := aColor. + + "Modified: / 24-01-2011 / 10:27:57 / cg" ! ! !ColorMenu methodsFor:'accessing'! @@ -422,6 +425,23 @@ acceptAction := something. ! +allowNilColor + ^ allowNilColor + + "Created: / 24-01-2011 / 10:01:55 / cg" +! + +allowNilColor:aBoolean + allowNilColor ~~ aBoolean ifTrue:[ + allowNilColor := aBoolean. + haveMenu ifTrue:[ + self setupMenu. + ]. + ]. + + "Created: / 24-01-2011 / 10:02:25 / cg" +! + allowSymbolicColors ^ allowSymbolicColors ! @@ -433,7 +453,9 @@ color "get current color" - ^ color + ^ (self hasNilColorHolder value ifTrue:[nil] ifFalse:[color]) + + "Modified: / 24-01-2011 / 10:28:13 / cg" ! color:aColor @@ -475,7 +497,12 @@ colorHolder "returns the item which keeps the selected color in its label" + haveMenu ifFalse:[ + self setupMenu + ]. ^ self itemAt:#selection + + "Modified: / 24-01-2011 / 10:10:55 / cg" ! contents @@ -496,6 +523,16 @@ "Modified: / 23-01-2011 / 16:24:12 / cg" ! +hasNilColorHolder + hasNilColorHolder isNil ifTrue:[ + hasNilColorHolder := false asValue. + hasNilColorHolder onChangeSend:#hasNilColorHolderChanged to:self. + ]. + ^ hasNilColorHolder + + "Created: / 24-01-2011 / 10:21:52 / cg" +! + labelsAreColored "controls if labels or their backgrounds will be colored" @@ -511,8 +548,12 @@ labelsAreColored ~~ bool ifTrue:[ labelsAreColored := bool. - self setupMenu + haveMenu ifTrue:[ + self setupMenu. + ]. ]. + + "Modified: / 24-01-2011 / 10:08:59 / cg" ! overwriteDefaultToggleChannel @@ -546,8 +587,19 @@ !ColorMenu methodsFor:'change & update'! +hasNilColorHolderChanged + overwriteDefaultToggleChannel value:(hasNilColorHolder value) + + "Created: / 24-01-2011 / 10:35:57 / cg" +! + updateFromModel - self color:(model value) + |clr| + + self color:(clr := model value). + self hasNilColorHolder value:clr isNil. + + "Modified: / 24-01-2011 / 10:26:20 / cg" ! ! !ColorMenu methodsFor:'help'! @@ -630,12 +682,29 @@ labelsAreColored := false. verticalLayout := false. allowSymbolicColors := false. + allowNilColor := false. self fitFirstPanel:false. "/ enabledChannel := ValueHolder with:false. - self setupMenu. + "/ self setupMenu. + + "Modified: / 24-01-2011 / 10:07:25 / cg" +! + +menu:aMenu + haveMenu := true. + super menu:aMenu - "Modified: / 23-01-2011 / 16:05:31 / cg" + "Created: / 24-01-2011 / 10:07:47 / cg" +! + +realized + super realized. + haveMenu ifFalse:[ + self setupMenu. + ]. + + "Created: / 24-01-2011 / 10:06:37 / cg" ! setupMenu @@ -683,11 +752,19 @@ menu addItem:toggleItem beforeIndex:1. "/ ]. + allowNilColor ifTrue:[ + toggleItem := MenuItem labeled:'No Color'. + toggleItem value:#noColor. + toggleItem isButton:false. + toggleItem activeHelpKey:#noColor. + toggleItem indication:self hasNilColorHolder. + menu addItem:toggleItem. + ]. + self menu:menu. - self updateEnableChannel - "Modified: / 23-01-2011 / 16:08:18 / cg" + "Modified: / 24-01-2011 / 10:31:08 / cg" ! updateEnableChannel @@ -696,11 +773,15 @@ anItem indication:self overwriteDefaultToggleChannel. "/ anItem enabled:enabledChannel. ] ifFalse:[ - anItem enabled:self overwriteDefaultToggleChannel. + anItem value == #noColor ifTrue:[ + ] ifFalse:[ + anItem enabled:self overwriteDefaultToggleChannel. + ] ] ] "Created: / 23-01-2011 / 16:08:06 / cg" + "Modified: / 24-01-2011 / 10:30:03 / cg" ! ! !ColorMenu methodsFor:'user actions'! @@ -732,9 +813,9 @@ !ColorMenu class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libwidg2/ColorMenu.st,v 1.67 2011-01-23 19:35:29 cg Exp $' + ^ '$Header: /cvs/stx/stx/libwidg2/ColorMenu.st,v 1.68 2011-01-24 10:25:37 cg Exp $' ! version_CVS - ^ '$Header: /cvs/stx/stx/libwidg2/ColorMenu.st,v 1.67 2011-01-23 19:35:29 cg Exp $' + ^ '$Header: /cvs/stx/stx/libwidg2/ColorMenu.st,v 1.68 2011-01-24 10:25:37 cg Exp $' ! !