ColorMenu.st
changeset 3344 cd9cf0a541f3
parent 3341 9a89b1f33d2a
child 3348 9e04c0b42717
equal deleted inserted replaced
3343:59113bee857a 3344:cd9cf0a541f3
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 "{ Package: 'stx:libwidg2' }"
    12 "{ Package: 'stx:libwidg2' }"
    13 
    13 
    14 MenuPanel subclass:#ColorMenu
    14 MenuPanel subclass:#ColorMenu
    15 	instanceVariableNames:'enabledChannel labelsAreColored'
    15 	instanceVariableNames:'enabledChannel labelsAreColored colorName'
    16 	classVariableNames:'ColorMenuSpec RecentlyUsedColors'
    16 	classVariableNames:'ColorMenuSpec RecentlyUsedColors'
    17 	poolDictionaries:''
    17 	poolDictionaries:''
    18 	category:'Interface-UIPainter'
    18 	category:'Interface-UIPainter'
    19 !
    19 !
    20 
    20 
   384 !
   384 !
   385 
   385 
   386 color:aColor
   386 color:aColor
   387     "set current color"
   387     "set current color"
   388 
   388 
   389     |holder label|
   389     |label|
   390 
   390 
   391     aColor isColor ifFalse:[
   391     (aColor isColor or:[aColor isSymbol]) ifFalse:[
   392         enabledChannel value:false
   392         enabledChannel value:false
   393     ] ifTrue:[
   393     ] ifTrue:[
   394         self 
   394         aColor isSymbol ifTrue:[
   395             disabledRedrawDo:
   395             label  := aColor asText "emphasis:(#backgroundColor->aColor)".
   396                 [                 
   396         ] ifFalse:[
   397                     holder := self colorHolder.     
   397             label  := Text string: '   ' emphasis:(#backgroundColor->aColor).
   398                     label  := Text string: '   ' emphasis:(#backgroundColor->aColor).
   398         ].
   399                     enabledChannel value:true.
   399         self disabledRedrawDo:[
   400                     holder label:label.
   400             enabledChannel value:true.
   401                     self choseColor:aColor
   401             self colorHolder label:label.
   402                 ]
   402             self choseColor:aColor
       
   403         ]
   403     ]
   404     ]
   404 !
   405 !
   405 
   406 
   406 labelsAreColored: aBoolean
   407 labelsAreColored: aBoolean
   407     "sets whether labels or their backgrounds will be colored"
   408     "sets whether labels or their backgrounds will be colored"
   440 
   441 
   441     RecentlyUsedColors isEmptyOrNil ifTrue:[^ nil].
   442     RecentlyUsedColors isEmptyOrNil ifTrue:[^ nil].
   442 
   443 
   443     menu := Menu new.
   444     menu := Menu new.
   444 
   445 
   445     RecentlyUsedColors do:[:clr |
   446     RecentlyUsedColors do:[:eachRecentlyUsedColor |
   446         |label fgColor item|
   447         |label fgColor item|
   447 
   448 
   448         clr brightness < 0.5 ifTrue:[ fgColor := Color white ]
   449         eachRecentlyUsedColor isSymbol ifTrue:[
   449                              ifFalse:[ fgColor := Color black ].
   450             label := eachRecentlyUsedColor  .
   450 
   451         ] ifFalse:[
   451         label := clr htmlPrintString.
   452             eachRecentlyUsedColor brightness < 0.5 
   452         label := Text string:(' ', label, ' ') foregroundColor:fgColor backgroundColor:clr.
   453                 ifTrue:[ fgColor := Color white ]
       
   454                 ifFalse:[ fgColor := Color black ].
       
   455 
       
   456             label := eachRecentlyUsedColor htmlPrintString.
       
   457             label := Text string:(' ', label, ' ') foregroundColor:fgColor backgroundColor:eachRecentlyUsedColor.
       
   458         ].
       
   459 
   453         item := MenuItem labeled:label.
   460         item := MenuItem labeled:label.
   454         item argument:clr.
   461         item argument:eachRecentlyUsedColor.
   455 
   462 
   456         menu addItem:item.
   463         menu addItem:item.
   457     ].
   464     ].
   458 
   465 
   459     ^ menu.
   466     ^ menu.
   554 ! !
   561 ! !
   555 
   562 
   556 !ColorMenu class methodsFor:'documentation'!
   563 !ColorMenu class methodsFor:'documentation'!
   557 
   564 
   558 version
   565 version
   559     ^ '$Header: /cvs/stx/stx/libwidg2/ColorMenu.st,v 1.44 2008-02-18 08:38:16 cg Exp $'
   566     ^ '$Header: /cvs/stx/stx/libwidg2/ColorMenu.st,v 1.45 2008-02-25 14:10:10 stefan Exp $'
   560 ! !
   567 ! !