ColorMenu.st
author Claus Gittinger <cg@exept.de>
Mon, 24 Jan 2011 20:35:06 +0100
changeset 3998 b0ef8a3d446c
parent 3997 35c107962304
child 4003 ed34e80d3840
permissions -rw-r--r--
class definition added:44 methods changed: #version_CVS category of:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
422
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
     1
"
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
     2
 COPYRIGHT (c) 1995 by eXept Software AG
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
     3
              All Rights Reserved
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
     4
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
     5
 This software is furnished under a license and may be used
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
     6
 only in accordance with the terms of that license and with the
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
     8
 be provided or otherwise made available to, or used by, any
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
     9
 other person.  No title to or ownership of the software is
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    10
 hereby transferred.
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    11
"
2935
e3fa9d1a7a64 Moved ColorMenu and FontMenu from libtool2
Stefan Vogel <sv@exept.de>
parents: 2704
diff changeset
    12
"{ Package: 'stx:libwidg2' }"
1803
ad801646be62 category change
Claus Gittinger <cg@exept.de>
parents: 1676
diff changeset
    13
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    14
MenuPanel subclass:#ColorMenu
3996
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
    15
	instanceVariableNames:'overwriteDefaultToggleChannel enabledChannel labelsAreColored
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
    16
		color colorName allowSymbolicColors showDefaultToggle
3997
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
    17
		acceptAction useDefaultColorToggleVisibleHolder allowNilColor
3998
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
    18
		hasNilColorHolder'
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
    19
	classVariableNames:'ColorMenuSpec RecentlyUsedColors'
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    20
	poolDictionaries:''
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    21
	category:'Interface-UIPainter'
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    22
!
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    23
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    24
!ColorMenu class methodsFor:'documentation'!
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    25
422
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    26
copyright
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    27
"
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    28
 COPYRIGHT (c) 1995 by eXept Software AG
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    29
              All Rights Reserved
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    30
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    31
 This software is furnished under a license and may be used
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    32
 only in accordance with the terms of that license and with the
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    33
 inclusion of the above copyright notice.   This software may not
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    34
 be provided or otherwise made available to, or used by, any
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    35
 other person.  No title to or ownership of the software is
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    36
 hereby transferred.
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    37
"
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    38
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    39
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    40
!
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    41
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    42
documentation
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    43
"
2183
5c69691590eb code cleanup; now inherit model instVar.
Claus Gittinger <cg@exept.de>
parents: 2167
diff changeset
    44
    A simple ColorMenu used by the UIPainter
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    45
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    46
    [see also:]
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    47
        UIPainter
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    48
        ColorMenuSpec
422
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    49
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    50
    [author:]
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    51
        Claus Atzkern
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    52
"
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    53
!
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    54
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    55
examples
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    56
"
2183
5c69691590eb code cleanup; now inherit model instVar.
Claus Gittinger <cg@exept.de>
parents: 2167
diff changeset
    57
  very simple example
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    58
                                                                                [exBegin]                                      
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    59
    |tool top channel|
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    60
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    61
    top := StandardSystemView new.
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    62
    top extent:250@30.
2183
5c69691590eb code cleanup; now inherit model instVar.
Claus Gittinger <cg@exept.de>
parents: 2167
diff changeset
    63
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    64
    channel := (Color red) asValue.
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    65
    tool := self origin:0.0@0.0 corner:1.0@1.0 in:top.
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    66
    tool model:channel.
2183
5c69691590eb code cleanup; now inherit model instVar.
Claus Gittinger <cg@exept.de>
parents: 2167
diff changeset
    67
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    68
    top open.
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    69
                                                                                [exEnd]
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    70
"
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    71
! !
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    72
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
    73
!ColorMenu class methodsFor:'instance creation'!
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
    74
3995
4917660dba28 added: #resolveMenuItem:value:labelsAreColored:
Claus Gittinger <cg@exept.de>
parents: 3981
diff changeset
    75
colorMenu:labelsAreColored value:aValue
4917660dba28 added: #resolveMenuItem:value:labelsAreColored:
Claus Gittinger <cg@exept.de>
parents: 3981
diff changeset
    76
    "returns a color menu"
4917660dba28 added: #resolveMenuItem:value:labelsAreColored:
Claus Gittinger <cg@exept.de>
parents: 3981
diff changeset
    77
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
    78
    |menu|
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
    79
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
    80
    menu := Menu new.
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
    81
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
    82
    self colorMenu itemsDo:[:el|
3995
4917660dba28 added: #resolveMenuItem:value:labelsAreColored:
Claus Gittinger <cg@exept.de>
parents: 3981
diff changeset
    83
        menu addItem:(self resolveMenuItem:el value:aValue labelsAreColored:labelsAreColored).
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
    84
    ].
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
    85
    ^ menu
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
    86
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
    87
    "
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
    88
     (ColorMenu colorMenu:true  value:nil) startUp
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
    89
     (ColorMenu colorMenu:false value:#aSelector:) startUp
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
    90
    "
3995
4917660dba28 added: #resolveMenuItem:value:labelsAreColored:
Claus Gittinger <cg@exept.de>
parents: 3981
diff changeset
    91
4917660dba28 added: #resolveMenuItem:value:labelsAreColored:
Claus Gittinger <cg@exept.de>
parents: 3981
diff changeset
    92
    "Modified: / 23-01-2011 / 14:58:32 / cg"
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
    93
! !
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
    94
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
    95
!ColorMenu class methodsFor:'adding & removing user defined items'!
3280
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
    96
3292
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
    97
addUserDefinedColors:aColors labels:labelsOrNil title:aTitle
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
    98
    "add user colors to ALL colormenus"
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
    99
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   100
    "cg: I think this is a bad hack, as it is too global."
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   101
3292
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   102
    |size submenu item label fgColor bgColor labels defLabel|
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   103
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   104
    submenu := self userDefinedSubmenu.
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   105
    size    := aColors size.
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   106
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   107
    size == 0 ifTrue:[  "/ separator
3862
754cfd6ed4b5 changed: #addUserDefinedColors:labels:title:
Claus Gittinger <cg@exept.de>
parents: 3738
diff changeset
   108
        submenu addSeparator.
3292
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   109
        ^ self
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   110
    ].
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   111
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   112
    labels   := labelsOrNil ? #().
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   113
    bgColor  := aColors first.
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   114
    defLabel := '        '.
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   115
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   116
    bgColor brightness < 0.5 ifTrue:[ fgColor := Color white ]
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   117
                            ifFalse:[ fgColor := Color black ].
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   118
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   119
    aTitle isEmptyOrNil ifTrue:[ label := labels at:1 ifAbsent:defLabel ]
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   120
                       ifFalse:[ label := aTitle ].
3280
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   121
3294
da0fdfe54c4e *** empty log message ***
ca
parents: 3293
diff changeset
   122
    label := Text string:(' ', label, ' ') foregroundColor:fgColor backgroundColor:bgColor.
3292
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   123
    item  := MenuItem labeled:label.
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   124
    submenu addItem:item.
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   125
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   126
    size == 1 ifTrue:[
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   127
        item argument:bgColor.
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   128
    ] ifFalse:[
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   129
        item submenu:(submenu := Menu new).
3280
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   130
3292
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   131
        aColors keysAndValuesDo:[:idx :aBgColor|
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   132
            aBgColor brightness < 0.5 ifTrue:[ fgColor := Color white ]
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   133
                                     ifFalse:[ fgColor := Color black ].
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   134
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   135
            label := labels at:idx ifAbsent:defLabel.
3294
da0fdfe54c4e *** empty log message ***
ca
parents: 3293
diff changeset
   136
            label := Text string:(' ', label, ' ') foregroundColor:fgColor backgroundColor:aBgColor.
3292
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   137
            item  := MenuItem labeled:label.
3293
1ae2428ad1e5 *** empty log message ***
ca
parents: 3292
diff changeset
   138
            item argument:aBgColor.
3292
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   139
            
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   140
            submenu addItem:item.
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   141
        ].
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   142
    ].
3280
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   143
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   144
"
3292
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   145
    ColorMenu  removeAllUserDefinedColors.
3280
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   146
3292
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   147
    #(
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   148
        #(  Black       16r000000 )
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   149
        #(  Red         16rff0000 )
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   150
        nil
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   151
        #(  Rust        16rff6600 16rff8533 16rffa366 16rffc299 16rffe0cc )
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   152
        #(  Tangerine   16rff9933 16rffad5c 16rffc285 16rffd6ad 16rffebd6 )
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   153
        #(  Sunflower   16rffcc00 16rfed633 16rfee066 16rffeb99 16rfff5cc )  
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   154
        #(  Mango       16rffcc99 16rffd6ad 16rffe0c2 16rffebd6 16rfff5eb )
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   155
        #(  Buttercup   16rffff66 16rffff85 16rffffa3 16rffffc2 16rffffe0 )
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   156
        #(  Lemon       16rffffcc 16rffffd6 16rffffe0 16rffffeb 16rfffff5 )
3280
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   157
3292
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   158
    ) do:[:aDef| |colors title labels percentage|
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   159
        aDef isEmptyOrNil ifTrue:[
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   160
            colors := labels := title := nil.
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   161
        ] ifFalse:[
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   162
            title      := aDef first.
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   163
            colors     := OrderedCollection new.
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   164
            labels     := OrderedCollection new.
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   165
            percentage := 100.
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   166
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   167
            aDef from:2 do:[:rgb|
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   168
                colors add:(Color rgbValue:rgb).
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   169
                labels add:('%1    %2 %%' bindWith:title with:percentage).
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   170
                percentage := percentage - 20.
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   171
            ].
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   172
        ].
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   173
        ColorMenu addUserDefinedColors:colors labels:labels title:title.
3280
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   174
    ].
3292
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   175
"
3280
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   176
!
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   177
3283
a0388721f027 *** empty log message ***
ca
parents: 3280
diff changeset
   178
removeAllUserDefinedColors
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   179
    "flush user defined colors"
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   180
3292
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   181
    ColorMenuSpec := nil.
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   182
!
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   183
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   184
userDefinedSubmenu
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   185
    "answer the menu entry under which the userdefined color entries are placed"
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   186
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   187
    |menu submenu item icon|
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   188
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   189
    menu := self colorMenu.
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   190
    item := menu detectItem:[:el| (el nameKey == #userDefined and:[el submenu notNil]) ]
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   191
                     ifNone:nil.
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   192
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   193
    item isNil ifTrue:[
3323
b4aef3ba5d24 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3322
diff changeset
   194
        icon := ToolbarIconLibrary colorHistory16x16Icon.
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   195
        item := MenuItem labeled:icon.
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   196
        item nameKey:#userDefined.
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   197
        item activeHelpKey:#userDefinedColors.
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   198
        menu addItem:item beforeIndex:1.
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   199
    ].
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   200
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   201
    (submenu := item submenu) isNil ifTrue:[
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   202
        submenu := Menu new.
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   203
        item submenu:submenu.
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   204
    ].
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   205
    ^ submenu
3280
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   206
! !
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   207
3709
d8f3b30013c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3708
diff changeset
   208
!ColorMenu class methodsFor:'history'!
d8f3b30013c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3708
diff changeset
   209
d8f3b30013c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3708
diff changeset
   210
rememberRecentlyUsedColor:aColor
d8f3b30013c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3708
diff changeset
   211
    aColor notNil ifTrue:[
d8f3b30013c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3708
diff changeset
   212
        RecentlyUsedColors isNil ifTrue:[
d8f3b30013c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3708
diff changeset
   213
            RecentlyUsedColors := OrderedCollection new.
d8f3b30013c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3708
diff changeset
   214
        ].
d8f3b30013c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3708
diff changeset
   215
        RecentlyUsedColors remove:aColor ifAbsent:[].
d8f3b30013c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3708
diff changeset
   216
        RecentlyUsedColors addFirst:aColor.
d8f3b30013c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3708
diff changeset
   217
        RecentlyUsedColors size > 20 ifTrue:[
d8f3b30013c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3708
diff changeset
   218
            RecentlyUsedColors removeLast
d8f3b30013c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3708
diff changeset
   219
        ].
d8f3b30013c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3708
diff changeset
   220
    ].
d8f3b30013c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3708
diff changeset
   221
! !
d8f3b30013c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3708
diff changeset
   222
3341
9a89b1f33d2a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3323
diff changeset
   223
!ColorMenu class methodsFor:'menu specs'!
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   224
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   225
colorMenuSpec
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   226
    "color definitions used to build a color menu
3292
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   227
    "
3996
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   228
"because it is cached, you have to:
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   229
    ColorMenuSpec := nil.
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   230
when changing
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   231
"
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   232
  ^ #(
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   233
        #(  gray
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   234
            gray:
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   235
            #(  white
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   236
                veryLightGray
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   237
                lightGray
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   238
                gray 
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   239
                darkGray 
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   240
                veryDarkGray 
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   241
                black 
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   242
             )
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   243
        )
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   244
"/ nil                         "/ separator
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   245
        #(  red
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   246
            red:
3707
380dcd111024 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3698
diff changeset
   247
            #( veryLight lightened 100 87 67 50 33 25)
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   248
         )
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   249
        #(  green
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   250
            green:
3707
380dcd111024 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3698
diff changeset
   251
            #( veryLight lightened 100 87 67 50 33 25)
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   252
         )
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   253
        #(  blue
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   254
            blue:
3707
380dcd111024 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3698
diff changeset
   255
            #( veryLight lightened 100 87 67 50 33 25)
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   256
         )
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   257
"/ nil                         "/ separator
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   258
        #(  cyan
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   259
            cyan:
3707
380dcd111024 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3698
diff changeset
   260
            #( veryLight lightened 100 87 67 50 33 25)
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   261
        )
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   262
        #(  magenta
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   263
            magenta:
3707
380dcd111024 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3698
diff changeset
   264
            #( veryLight lightened 100 87 67 50 33 25)
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   265
        )
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   266
        #(  yellow
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   267
            yellow:
3707
380dcd111024 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3698
diff changeset
   268
            #( veryLight lightened 100 87 67 50 33 25)
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   269
        )
3996
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   270
        #(  brown
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   271
            brown:
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   272
            #( veryLight lightened brown darkened veryDark)
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   273
        )
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   274
    )
3292
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   275
3996
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   276
    "Modified: / 23-01-2011 / 16:33:33 / cg"
3292
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   277
! !
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   278
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   279
!ColorMenu class methodsFor:'private'!
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   280
3280
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   281
colorMenu
3404
18dae88f0f2d help spec
Claus Gittinger <cg@exept.de>
parents: 3401
diff changeset
   282
    |menu menuItem subItem baseColor color label getColSel submenu colorId|
18dae88f0f2d help spec
Claus Gittinger <cg@exept.de>
parents: 3401
diff changeset
   283
3707
380dcd111024 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3698
diff changeset
   284
    "
380dcd111024 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3698
diff changeset
   285
     ColorMenuSpec := nil
380dcd111024 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3698
diff changeset
   286
    "
3292
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   287
3280
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   288
    ColorMenuSpec notNil ifTrue:[ ^ ColorMenuSpec ].
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   289
3404
18dae88f0f2d help spec
Claus Gittinger <cg@exept.de>
parents: 3401
diff changeset
   290
    menu := Menu new.
3280
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   291
    self colorMenuSpec do:[:aSlice|
3404
18dae88f0f2d help spec
Claus Gittinger <cg@exept.de>
parents: 3401
diff changeset
   292
        menu addItem:(menuItem := MenuItem new).
3280
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   293
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   294
        aSlice notNil ifTrue:[
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   295
            colorId   := aSlice at:1.
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   296
            getColSel := aSlice at:2.
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   297
            baseColor := Color perform:colorId.
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   298
3323
b4aef3ba5d24 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3322
diff changeset
   299
            menuItem label:(Text string:' ' emphasis:(#backgroundColor->baseColor)).
3280
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   300
            menuItem submenu:(submenu := Menu new).
3292
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   301
            menuItem isButton:true.
3404
18dae88f0f2d help spec
Claus Gittinger <cg@exept.de>
parents: 3401
diff changeset
   302
            menuItem activeHelpKey:('shadesOf',colorId asUppercaseFirst) asSymbol.
3280
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   303
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   304
            aSlice last do:[:el|         
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   305
                color := label := nil.
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   306
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   307
                el isSymbol ifTrue:[
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   308
                    el == #veryLight ifTrue:[ 
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   309
                        color := baseColor lightened lightened
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   310
                    ] ifFalse:[ el == #lightened ifTrue:[ 
3996
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   311
                        color := baseColor lightened 
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   312
                    ] ifFalse:[ el == #darkened ifTrue:[ 
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   313
                        color := baseColor darkened 
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   314
                    ] ifFalse:[ el == #veryDark ifTrue:[ 
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   315
                        color := baseColor darkened darkened 
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   316
                    ] ifFalse:[ 
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   317
                        color := Color perform:el 
3996
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   318
                    ]]]].
3280
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   319
                    colorId == #gray ifTrue:[ label := el ].
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   320
                ] ifFalse:[
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   321
                    el isNumber ifTrue:[
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   322
                        color := Color perform:getColSel with:el.
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   323
                    ].
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   324
                ].
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   325
                color notNil ifTrue:[
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   326
                    label isNil ifTrue:[
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   327
                        label := getColSel, ' ', el printString.
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   328
                    ].
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   329
                    subItem := MenuItem label:' ',label,' '.
3280
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   330
                    subItem argument:color.
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   331
                    submenu addItem:subItem.
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   332
                ].
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   333
            ]
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   334
        ].
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   335
    ].
3404
18dae88f0f2d help spec
Claus Gittinger <cg@exept.de>
parents: 3401
diff changeset
   336
    ColorMenuSpec := menu.
18dae88f0f2d help spec
Claus Gittinger <cg@exept.de>
parents: 3401
diff changeset
   337
    ^ menu
3996
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   338
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   339
    "Modified: / 23-01-2011 / 16:34:45 / cg"
3280
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   340
!
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   341
3995
4917660dba28 added: #resolveMenuItem:value:labelsAreColored:
Claus Gittinger <cg@exept.de>
parents: 3981
diff changeset
   342
resolveMenuItem:aMenuItem value:aValue labelsAreColored:labelsAreColored
3292
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   343
    |menuItem label color fgColor submenu|
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   344
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   345
    label    := aMenuItem rawLabel ? ''.
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   346
    menuItem := MenuItem label:label.
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   347
    menuItem isButton:(aMenuItem isButton).
3404
18dae88f0f2d help spec
Claus Gittinger <cg@exept.de>
parents: 3401
diff changeset
   348
    menuItem activeHelpKey:(aMenuItem activeHelpKey).
3292
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   349
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   350
    aMenuItem hasSubmenu ifFalse:[
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   351
        color := aMenuItem argument.
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   352
        menuItem argument:color.
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   353
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   354
        (color isColor and:[label isText not]) ifTrue:[
3995
4917660dba28 added: #resolveMenuItem:value:labelsAreColored:
Claus Gittinger <cg@exept.de>
parents: 3981
diff changeset
   355
            labelsAreColored ifTrue:[
3292
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   356
                label := Text string:label color:color.
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   357
            ] ifFalse:[
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   358
                color brightness < 0.5 ifTrue:[ fgColor := Color white ]
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   359
                                      ifFalse:[ fgColor := Color black ].
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   360
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   361
                label := Text string:label foregroundColor:fgColor backgroundColor:color.
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   362
            ].
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   363
            menuItem label:label.
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   364
            menuItem value:aValue.
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   365
        ].
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   366
        ^ menuItem
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   367
    ].
3995
4917660dba28 added: #resolveMenuItem:value:labelsAreColored:
Claus Gittinger <cg@exept.de>
parents: 3981
diff changeset
   368
3292
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   369
    submenu := Menu new.
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   370
    aMenuItem submenu itemsDo:[:el|
3995
4917660dba28 added: #resolveMenuItem:value:labelsAreColored:
Claus Gittinger <cg@exept.de>
parents: 3981
diff changeset
   371
        submenu addItem:(self resolveMenuItem:el value:aValue labelsAreColored:labelsAreColored).
3292
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   372
    ].
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   373
    menuItem submenu:submenu.
07786876f1fa *** empty log message ***
ca
parents: 3283
diff changeset
   374
    ^ menuItem
3995
4917660dba28 added: #resolveMenuItem:value:labelsAreColored:
Claus Gittinger <cg@exept.de>
parents: 3981
diff changeset
   375
4917660dba28 added: #resolveMenuItem:value:labelsAreColored:
Claus Gittinger <cg@exept.de>
parents: 3981
diff changeset
   376
    "Created: / 23-01-2011 / 14:59:19 / cg"
592
c7813cfa8794 add more colors
ca
parents: 583
diff changeset
   377
! !
c7813cfa8794 add more colors
ca
parents: 583
diff changeset
   378
1808
e8628b502a49 methodCategory change
Claus Gittinger <cg@exept.de>
parents: 1803
diff changeset
   379
!ColorMenu methodsFor:'accepting'!
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   380
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   381
accept:anItem
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   382
    "accept the current selected item"
664
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   383
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   384
    |item holder color|
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   385
3413
c7be2e00d9bc Bug D000092: if mark is switched off, show transparent background
Stefan Vogel <sv@exept.de>
parents: 3412
diff changeset
   386
    item := super accept:anItem.
3738
d05d10503c67 halfway fix
sr
parents: 3736
diff changeset
   387
3413
c7be2e00d9bc Bug D000092: if mark is switched off, show transparent background
Stefan Vogel <sv@exept.de>
parents: 3412
diff changeset
   388
    (item notNil and:[((item nameKey ? '') startsWith:'pseudo') not]) ifTrue:[
c7be2e00d9bc Bug D000092: if mark is switched off, show transparent background
Stefan Vogel <sv@exept.de>
parents: 3412
diff changeset
   389
        holder := self colorHolder.
c7be2e00d9bc Bug D000092: if mark is switched off, show transparent background
Stefan Vogel <sv@exept.de>
parents: 3412
diff changeset
   390
        holder == item ifTrue:[
3996
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   391
            self overwriteDefaultToggleChannel value ifTrue:[
3413
c7be2e00d9bc Bug D000092: if mark is switched off, show transparent background
Stefan Vogel <sv@exept.de>
parents: 3412
diff changeset
   392
                color := self color.
c7be2e00d9bc Bug D000092: if mark is switched off, show transparent background
Stefan Vogel <sv@exept.de>
parents: 3412
diff changeset
   393
            ] ifFalse:[
c7be2e00d9bc Bug D000092: if mark is switched off, show transparent background
Stefan Vogel <sv@exept.de>
parents: 3412
diff changeset
   394
                holder label:(Text string:'   ').
c7be2e00d9bc Bug D000092: if mark is switched off, show transparent background
Stefan Vogel <sv@exept.de>
parents: 3412
diff changeset
   395
            ].
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   396
        ] ifFalse:[  
3998
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   397
            item value == #hasNilColorHolder: ifTrue:[
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   398
                self overwriteDefaultToggleChannel value ifFalse:[
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   399
                    model value:nil withoutNotifying:self
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   400
                ].
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   401
            ] ifFalse:[
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   402
                color := item argument.
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   403
                holder label:(Text string:'   ' emphasis:(#backgroundColor->color)).
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   404
                self chooseColor:color.
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   405
            ].
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   406
        ].
3709
d8f3b30013c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3708
diff changeset
   407
        self class rememberRecentlyUsedColor:color.
3738
d05d10503c67 halfway fix
sr
parents: 3736
diff changeset
   408
        acceptAction notNil ifTrue:[
d05d10503c67 halfway fix
sr
parents: 3736
diff changeset
   409
            acceptAction value:color
d05d10503c67 halfway fix
sr
parents: 3736
diff changeset
   410
        ].
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   411
    ]
3996
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   412
3998
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   413
    "Modified: / 24-01-2011 / 20:22:07 / cg"
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   414
!
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   415
3708
de8fd46e5363 changes to use ColorMenu for expecco
Claus Gittinger <cg@exept.de>
parents: 3707
diff changeset
   416
chooseColor:aColor
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   417
    "accept the current selected item"
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   418
3350
5950d4d4a57c care for symbolic color
Claus Gittinger <cg@exept.de>
parents: 3349
diff changeset
   419
    (model notNil 
5950d4d4a57c care for symbolic color
Claus Gittinger <cg@exept.de>
parents: 3349
diff changeset
   420
    and:[ model isSymbol not]) ifTrue:[
3998
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   421
        model value:aColor.
3708
de8fd46e5363 changes to use ColorMenu for expecco
Claus Gittinger <cg@exept.de>
parents: 3707
diff changeset
   422
    ].
3709
d8f3b30013c0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3708
diff changeset
   423
    color := aColor.
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   424
! !
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   425
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   426
!ColorMenu methodsFor:'accessing'!
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   427
3738
d05d10503c67 halfway fix
sr
parents: 3736
diff changeset
   428
acceptAction:something
d05d10503c67 halfway fix
sr
parents: 3736
diff changeset
   429
    acceptAction := something.
d05d10503c67 halfway fix
sr
parents: 3736
diff changeset
   430
!
d05d10503c67 halfway fix
sr
parents: 3736
diff changeset
   431
3997
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   432
allowNilColor
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   433
    ^ allowNilColor
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   434
!
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   435
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   436
allowNilColor:aBoolean
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   437
    allowNilColor ~~ aBoolean ifTrue:[
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   438
        allowNilColor := aBoolean.
3998
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   439
        allowNilColor ifTrue:[      
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   440
            self overwriteDefaultToggleChannel value:true.
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   441
            self hasNilColorHolder value:(color notNil).
3997
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   442
        ].
3998
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   443
        self setupMenu.
3997
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   444
    ].
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   445
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   446
    "Created: / 24-01-2011 / 10:02:25 / cg"
3998
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   447
    "Modified: / 24-01-2011 / 20:06:28 / cg"
3997
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   448
!
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   449
3349
fb7d0dea3876 Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents: 3348
diff changeset
   450
allowSymbolicColors
fb7d0dea3876 Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents: 3348
diff changeset
   451
    ^ allowSymbolicColors
fb7d0dea3876 Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents: 3348
diff changeset
   452
!
fb7d0dea3876 Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents: 3348
diff changeset
   453
3397
e2ed0ef2c908 default for labelsAreColored is FALSE
Claus Gittinger <cg@exept.de>
parents: 3350
diff changeset
   454
allowSymbolicColors:aBoolean
e2ed0ef2c908 default for labelsAreColored is FALSE
Claus Gittinger <cg@exept.de>
parents: 3350
diff changeset
   455
    allowSymbolicColors := aBoolean.
3349
fb7d0dea3876 Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents: 3348
diff changeset
   456
!
fb7d0dea3876 Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents: 3348
diff changeset
   457
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   458
color
664
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   459
    "get current color"
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   460
3998
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   461
    self overwriteDefaultToggleChannel value ifFalse:[^ nil].
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   462
    ^ color
3997
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   463
3998
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   464
    "Modified: / 24-01-2011 / 20:14:27 / cg"
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   465
!
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   466
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   467
color:aColor
664
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   468
    "set current color"
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   469
3349
fb7d0dea3876 Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents: 3348
diff changeset
   470
    |label newColor|
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   471
3998
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   472
    self hasNilColorHolder setValue:aColor isNil.
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   473
3344
cd9cf0a541f3 symbolic colors
Stefan Vogel <sv@exept.de>
parents: 3341
diff changeset
   474
    (aColor isColor or:[aColor isSymbol]) ifFalse:[
3996
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   475
        self overwriteDefaultToggleChannel value:false.
3445
714802384d86 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3439
diff changeset
   476
        self colorHolder label:'   '.
3998
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   477
        (aColor isNil and:[allowNilColor]) ifTrue:[
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   478
            self chooseColor:aColor
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   479
        ]
2184
16d3b72ca431 use inherited functionality
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
   480
    ] ifTrue:[
3349
fb7d0dea3876 Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents: 3348
diff changeset
   481
        newColor := aColor.
3344
cd9cf0a541f3 symbolic colors
Stefan Vogel <sv@exept.de>
parents: 3341
diff changeset
   482
        aColor isSymbol ifTrue:[
3349
fb7d0dea3876 Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents: 3348
diff changeset
   483
            allowSymbolicColors ifTrue:[
3412
edde712ea6ed If allowSymbolicColors is false, do not allow 'color names' like halt or error.
Stefan Vogel <sv@exept.de>
parents: 3406
diff changeset
   484
                label  := aColor.
3349
fb7d0dea3876 Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents: 3348
diff changeset
   485
            ] ifFalse:[
3412
edde712ea6ed If allowSymbolicColors is false, do not allow 'color names' like halt or error.
Stefan Vogel <sv@exept.de>
parents: 3406
diff changeset
   486
                "our caller does not handle symbolic colors (UIPainter does) - convert now.
edde712ea6ed If allowSymbolicColors is false, do not allow 'color names' like halt or error.
Stefan Vogel <sv@exept.de>
parents: 3406
diff changeset
   487
                 Be careful - for security reasons - do not perform arbitrary symbols here 
edde712ea6ed If allowSymbolicColors is false, do not allow 'color names' like halt or error.
Stefan Vogel <sv@exept.de>
parents: 3406
diff changeset
   488
                (could be #halt, #error)!!"
edde712ea6ed If allowSymbolicColors is false, do not allow 'color names' like halt or error.
Stefan Vogel <sv@exept.de>
parents: 3406
diff changeset
   489
edde712ea6ed If allowSymbolicColors is false, do not allow 'color names' like halt or error.
Stefan Vogel <sv@exept.de>
parents: 3406
diff changeset
   490
                newColor := Color name:aColor ifIllegal:[color "keep old"].
3349
fb7d0dea3876 Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents: 3348
diff changeset
   491
            ].
3412
edde712ea6ed If allowSymbolicColors is false, do not allow 'color names' like halt or error.
Stefan Vogel <sv@exept.de>
parents: 3406
diff changeset
   492
        ].
edde712ea6ed If allowSymbolicColors is false, do not allow 'color names' like halt or error.
Stefan Vogel <sv@exept.de>
parents: 3406
diff changeset
   493
        newColor isSymbol ifFalse:[
edde712ea6ed If allowSymbolicColors is false, do not allow 'color names' like halt or error.
Stefan Vogel <sv@exept.de>
parents: 3406
diff changeset
   494
            "show the selected color in the label"
3349
fb7d0dea3876 Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents: 3348
diff changeset
   495
            label  := Text string: '   ' emphasis:(#backgroundColor->newColor).
3344
cd9cf0a541f3 symbolic colors
Stefan Vogel <sv@exept.de>
parents: 3341
diff changeset
   496
        ].
3349
fb7d0dea3876 Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents: 3348
diff changeset
   497
        color := newColor.
3344
cd9cf0a541f3 symbolic colors
Stefan Vogel <sv@exept.de>
parents: 3341
diff changeset
   498
        self disabledRedrawDo:[
3996
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   499
            self overwriteDefaultToggleChannel value:true.
3344
cd9cf0a541f3 symbolic colors
Stefan Vogel <sv@exept.de>
parents: 3341
diff changeset
   500
            self colorHolder label:label.
3708
de8fd46e5363 changes to use ColorMenu for expecco
Claus Gittinger <cg@exept.de>
parents: 3707
diff changeset
   501
            self chooseColor:aColor
3344
cd9cf0a541f3 symbolic colors
Stefan Vogel <sv@exept.de>
parents: 3341
diff changeset
   502
        ]
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   503
    ]
3996
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   504
3998
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   505
    "Modified: / 24-01-2011 / 20:09:39 / cg"
664
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   506
!
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   507
3406
28d99375fcc7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3404
diff changeset
   508
colorHolder
28d99375fcc7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3404
diff changeset
   509
    "returns the item which keeps the selected color in its label"
28d99375fcc7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3404
diff changeset
   510
3738
d05d10503c67 halfway fix
sr
parents: 3736
diff changeset
   511
    ^ self itemAt:#selection
3406
28d99375fcc7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3404
diff changeset
   512
!
28d99375fcc7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3404
diff changeset
   513
3698
bd2778e6a26b +contents
Claus Gittinger <cg@exept.de>
parents: 3530
diff changeset
   514
contents
bd2778e6a26b +contents
Claus Gittinger <cg@exept.de>
parents: 3530
diff changeset
   515
    ^ self color
bd2778e6a26b +contents
Claus Gittinger <cg@exept.de>
parents: 3530
diff changeset
   516
!
bd2778e6a26b +contents
Claus Gittinger <cg@exept.de>
parents: 3530
diff changeset
   517
3996
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   518
enableChannel:aValueHolder
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   519
    super enableChannel:aValueHolder.
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   520
    self updateEnableChannel
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   521
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   522
    "Created: / 23-01-2011 / 16:08:52 / cg"
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   523
!
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   524
3981
d6cb72181559 enableChan
Claus Gittinger <cg@exept.de>
parents: 3862
diff changeset
   525
enabledChannel
3996
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   526
    ^ self overwriteDefaultToggleChannel
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   527
"/    ^ enabledChannel
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   528
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   529
    "Modified: / 23-01-2011 / 16:24:12 / cg"
3981
d6cb72181559 enableChan
Claus Gittinger <cg@exept.de>
parents: 3862
diff changeset
   530
!
d6cb72181559 enableChan
Claus Gittinger <cg@exept.de>
parents: 3862
diff changeset
   531
3997
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   532
hasNilColorHolder
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   533
    hasNilColorHolder isNil ifTrue:[
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   534
        hasNilColorHolder := false asValue.
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   535
        hasNilColorHolder onChangeSend:#hasNilColorHolderChanged to:self.
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   536
    ].
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   537
    ^ hasNilColorHolder
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   538
3998
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   539
    "Created: / 24-01-2011 / 19:22:49 / cg"
3997
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   540
!
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   541
3397
e2ed0ef2c908 default for labelsAreColored is FALSE
Claus Gittinger <cg@exept.de>
parents: 3350
diff changeset
   542
labelsAreColored
e2ed0ef2c908 default for labelsAreColored is FALSE
Claus Gittinger <cg@exept.de>
parents: 3350
diff changeset
   543
    "controls if labels or their backgrounds will be colored"
e2ed0ef2c908 default for labelsAreColored is FALSE
Claus Gittinger <cg@exept.de>
parents: 3350
diff changeset
   544
e2ed0ef2c908 default for labelsAreColored is FALSE
Claus Gittinger <cg@exept.de>
parents: 3350
diff changeset
   545
    ^ labelsAreColored
e2ed0ef2c908 default for labelsAreColored is FALSE
Claus Gittinger <cg@exept.de>
parents: 3350
diff changeset
   546
!
e2ed0ef2c908 default for labelsAreColored is FALSE
Claus Gittinger <cg@exept.de>
parents: 3350
diff changeset
   547
664
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   548
labelsAreColored: aBoolean
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   549
    "sets whether labels or their backgrounds will be colored"
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   550
3280
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   551
    |bool|
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   552
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   553
    bool := aBoolean ? false.
664
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   554
3280
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   555
    labelsAreColored ~~ bool ifTrue:[
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   556
        labelsAreColored := bool.
3998
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   557
        self setupMenu
3280
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   558
    ].
3981
d6cb72181559 enableChan
Claus Gittinger <cg@exept.de>
parents: 3862
diff changeset
   559
!
d6cb72181559 enableChan
Claus Gittinger <cg@exept.de>
parents: 3862
diff changeset
   560
3996
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   561
overwriteDefaultToggleChannel
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   562
    overwriteDefaultToggleChannel isNil ifTrue:[
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   563
        overwriteDefaultToggleChannel := false asValue.
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   564
    ].
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   565
    ^ overwriteDefaultToggleChannel
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   566
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   567
    "Modified: / 23-01-2011 / 16:24:00 / cg"
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   568
!
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   569
3981
d6cb72181559 enableChan
Claus Gittinger <cg@exept.de>
parents: 3862
diff changeset
   570
useDefaultColorToggleVisibleHolder
d6cb72181559 enableChan
Claus Gittinger <cg@exept.de>
parents: 3862
diff changeset
   571
    useDefaultColorToggleVisibleHolder isNil ifTrue:[
d6cb72181559 enableChan
Claus Gittinger <cg@exept.de>
parents: 3862
diff changeset
   572
        useDefaultColorToggleVisibleHolder := true asValue
d6cb72181559 enableChan
Claus Gittinger <cg@exept.de>
parents: 3862
diff changeset
   573
    ].
d6cb72181559 enableChan
Claus Gittinger <cg@exept.de>
parents: 3862
diff changeset
   574
    ^ useDefaultColorToggleVisibleHolder
d6cb72181559 enableChan
Claus Gittinger <cg@exept.de>
parents: 3862
diff changeset
   575
d6cb72181559 enableChan
Claus Gittinger <cg@exept.de>
parents: 3862
diff changeset
   576
    "Created: / 18-12-2010 / 13:03:48 / cg"
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   577
! !
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   578
1818
fe99c5c721e9 category changes
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
   579
!ColorMenu methodsFor:'accessing-channels'!
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   580
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   581
model:aValueHolder
664
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   582
    "set my color channel"
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   583
2184
16d3b72ca431 use inherited functionality
Claus Gittinger <cg@exept.de>
parents: 2183
diff changeset
   584
    super model:aValueHolder.
2183
5c69691590eb code cleanup; now inherit model instVar.
Claus Gittinger <cg@exept.de>
parents: 2167
diff changeset
   585
    model notNil ifTrue:[
2186
05b16a66bb3d updateFromModel
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   586
        self updateFromModel
664
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   587
    ]
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   588
! !
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   589
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   590
!ColorMenu methodsFor:'change & update'!
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   591
3997
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   592
hasNilColorHolderChanged
3998
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   593
    self overwriteDefaultToggleChannel value:(self hasNilColorHolder value not).
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   594
"/    self hasNilColorHolder value ifTrue:[
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   595
"/        self color:nil
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   596
"/    ].
3997
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   597
3998
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   598
    "Modified: / 24-01-2011 / 20:14:01 / cg"
3997
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   599
!
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   600
2186
05b16a66bb3d updateFromModel
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   601
updateFromModel
3998
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   602
    self color:(model value)
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   603
! !
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   604
3439
e6af2a8f0cd4 flybyhelp
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
   605
!ColorMenu methodsFor:'help'!
e6af2a8f0cd4 flybyhelp
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
   606
e6af2a8f0cd4 flybyhelp
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
   607
flyByHelpSpec
e6af2a8f0cd4 flybyhelp
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
   608
    "This resource specification was automatically generated
e6af2a8f0cd4 flybyhelp
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
   609
     by the UIHelpTool of ST/X."
e6af2a8f0cd4 flybyhelp
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
   610
e6af2a8f0cd4 flybyhelp
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
   611
    "Do not manually edit this!! If it is corrupted,
e6af2a8f0cd4 flybyhelp
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
   612
     the UIHelpTool may not be able to read the specification."
e6af2a8f0cd4 flybyhelp
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
   613
e6af2a8f0cd4 flybyhelp
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
   614
    "
e6af2a8f0cd4 flybyhelp
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
   615
     UIHelpTool openOnClass:ColorEditDialog    
e6af2a8f0cd4 flybyhelp
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
   616
    "
e6af2a8f0cd4 flybyhelp
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
   617
e6af2a8f0cd4 flybyhelp
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
   618
    <resource: #help>
e6af2a8f0cd4 flybyhelp
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
   619
e6af2a8f0cd4 flybyhelp
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
   620
    ^ super flyByHelpSpec addPairsFrom:#(
e6af2a8f0cd4 flybyhelp
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
   621
e6af2a8f0cd4 flybyhelp
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
   622
#useDefaultColorToggle
e6af2a8f0cd4 flybyhelp
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
   623
'Turn on, to specify the color here. Turn off to use the default'
e6af2a8f0cd4 flybyhelp
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
   624
e6af2a8f0cd4 flybyhelp
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
   625
#toggleSymbolicColor
e6af2a8f0cd4 flybyhelp
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
   626
'Turn on, to specify a symbolic color. Turn off to specify a concrete color'
e6af2a8f0cd4 flybyhelp
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
   627
e6af2a8f0cd4 flybyhelp
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
   628
#recentlyUsedColors
e6af2a8f0cd4 flybyhelp
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
   629
'Recently used colors'
e6af2a8f0cd4 flybyhelp
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
   630
e6af2a8f0cd4 flybyhelp
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
   631
#openColorEditor
e6af2a8f0cd4 flybyhelp
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
   632
'Open a color editor'
e6af2a8f0cd4 flybyhelp
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
   633
e6af2a8f0cd4 flybyhelp
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
   634
#pickColorFromScreen
e6af2a8f0cd4 flybyhelp
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
   635
'Pick a color from the screen'
e6af2a8f0cd4 flybyhelp
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
   636
e6af2a8f0cd4 flybyhelp
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
   637
)
e6af2a8f0cd4 flybyhelp
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
   638
! !
e6af2a8f0cd4 flybyhelp
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
   639
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   640
!ColorMenu methodsFor:'initialization'!
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   641
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   642
colorHistorySubmenu
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   643
    |menu|
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   644
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   645
    RecentlyUsedColors isEmptyOrNil ifTrue:[^ nil].
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   646
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   647
    menu := Menu new.
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   648
3344
cd9cf0a541f3 symbolic colors
Stefan Vogel <sv@exept.de>
parents: 3341
diff changeset
   649
    RecentlyUsedColors do:[:eachRecentlyUsedColor |
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   650
        |label fgColor item|
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   651
3344
cd9cf0a541f3 symbolic colors
Stefan Vogel <sv@exept.de>
parents: 3341
diff changeset
   652
        eachRecentlyUsedColor isSymbol ifTrue:[
cd9cf0a541f3 symbolic colors
Stefan Vogel <sv@exept.de>
parents: 3341
diff changeset
   653
            label := eachRecentlyUsedColor  .
cd9cf0a541f3 symbolic colors
Stefan Vogel <sv@exept.de>
parents: 3341
diff changeset
   654
        ] ifFalse:[
cd9cf0a541f3 symbolic colors
Stefan Vogel <sv@exept.de>
parents: 3341
diff changeset
   655
            eachRecentlyUsedColor brightness < 0.5 
cd9cf0a541f3 symbolic colors
Stefan Vogel <sv@exept.de>
parents: 3341
diff changeset
   656
                ifTrue:[ fgColor := Color white ]
cd9cf0a541f3 symbolic colors
Stefan Vogel <sv@exept.de>
parents: 3341
diff changeset
   657
                ifFalse:[ fgColor := Color black ].
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   658
3344
cd9cf0a541f3 symbolic colors
Stefan Vogel <sv@exept.de>
parents: 3341
diff changeset
   659
            label := eachRecentlyUsedColor htmlPrintString.
cd9cf0a541f3 symbolic colors
Stefan Vogel <sv@exept.de>
parents: 3341
diff changeset
   660
            label := Text string:(' ', label, ' ') foregroundColor:fgColor backgroundColor:eachRecentlyUsedColor.
cd9cf0a541f3 symbolic colors
Stefan Vogel <sv@exept.de>
parents: 3341
diff changeset
   661
        ].
cd9cf0a541f3 symbolic colors
Stefan Vogel <sv@exept.de>
parents: 3341
diff changeset
   662
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   663
        item := MenuItem labeled:label.
3344
cd9cf0a541f3 symbolic colors
Stefan Vogel <sv@exept.de>
parents: 3341
diff changeset
   664
        item argument:eachRecentlyUsedColor.
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   665
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   666
        menu addItem:item.
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   667
    ].
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   668
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   669
    ^ menu.
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   670
!
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   671
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   672
destroy
664
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   673
    "release color channel dependency"
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   674
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   675
    self model:nil.
664
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   676
    super destroy
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   677
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   678
!
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   679
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   680
initialize
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   681
    super initialize.
3397
e2ed0ef2c908 default for labelsAreColored is FALSE
Claus Gittinger <cg@exept.de>
parents: 3350
diff changeset
   682
    labelsAreColored    := false.
3349
fb7d0dea3876 Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents: 3348
diff changeset
   683
    verticalLayout      := false.
fb7d0dea3876 Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents: 3348
diff changeset
   684
    allowSymbolicColors := false.
3997
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   685
    allowNilColor       := false.
2254
ebd685bcba77 starting removing #menuAdornmentAt:
ca
parents: 2186
diff changeset
   686
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   687
    self fitFirstPanel:false.
3996
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   688
    "/ enabledChannel := ValueHolder with:false.
3998
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   689
    self setupMenu.
895
d1c9210e796b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 854
diff changeset
   690
3998
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   691
    "Modified: / 24-01-2011 / 19:20:55 / cg"
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   692
!
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   693
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   694
setupMenu
3707
380dcd111024 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3698
diff changeset
   695
    |menu toggleItem|
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   696
666
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   697
    menu := self class colorMenu:labelsAreColored value:nil.
3280
c42ab6572f32 support adding user defined colors
ca
parents: 3129
diff changeset
   698
2183
5c69691590eb code cleanup; now inherit model instVar.
Claus Gittinger <cg@exept.de>
parents: 2167
diff changeset
   699
    menu 
5c69691590eb code cleanup; now inherit model instVar.
Claus Gittinger <cg@exept.de>
parents: 2167
diff changeset
   700
        addItem:(
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   701
            (MenuItem labeled:nil) 
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   702
                labelImage:(ToolbarIconLibrary palette16x16Icon);
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   703
                value:[ self openColorEditDialog ]; 
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   704
                nameKey:#pseudoDef;
3404
18dae88f0f2d help spec
Claus Gittinger <cg@exept.de>
parents: 3401
diff changeset
   705
                activeHelpKey:#openColorEditor;
18dae88f0f2d help spec
Claus Gittinger <cg@exept.de>
parents: 3401
diff changeset
   706
                isButton: true) 
18dae88f0f2d help spec
Claus Gittinger <cg@exept.de>
parents: 3401
diff changeset
   707
        beforeIndex:1.
806
abed5a47e545 separators removed and color orange added
tz
parents: 692
diff changeset
   708
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   709
    menu 
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   710
        addItem:(
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   711
            (MenuItem labeled:nil) 
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   712
                labelImage:(ToolbarIconLibrary pipette16x16Icon);
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   713
                value:[ self pickColorFromScreen ]; 
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   714
                nameKey:#pseudoPick;
3404
18dae88f0f2d help spec
Claus Gittinger <cg@exept.de>
parents: 3401
diff changeset
   715
                activeHelpKey:#pickColorFromScreen;
18dae88f0f2d help spec
Claus Gittinger <cg@exept.de>
parents: 3401
diff changeset
   716
                isButton: true) 
18dae88f0f2d help spec
Claus Gittinger <cg@exept.de>
parents: 3401
diff changeset
   717
        beforeIndex:1.
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   718
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   719
    menu 
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   720
        addItem:(
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   721
            (MenuItem labeled:nil)
3707
380dcd111024 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3698
diff changeset
   722
                labelImage:(ToolbarIconLibrary colorHistory16x16Icon);
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   723
                submenuChannel:[ self colorHistorySubmenu ]; 
3401
583c48ec0ab8 ongoing work - dont use
Claus Gittinger <cg@exept.de>
parents: 3397
diff changeset
   724
                nameKey:#pseudoHistory;
3404
18dae88f0f2d help spec
Claus Gittinger <cg@exept.de>
parents: 3401
diff changeset
   725
                activeHelpKey:#recentlyUsedColors;
3995
4917660dba28 added: #resolveMenuItem:value:labelsAreColored:
Claus Gittinger <cg@exept.de>
parents: 3981
diff changeset
   726
                isButton: true) 
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   727
        beforeIndex:1.
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   728
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   729
    "/ menu addItem:(MenuItem label:'') beforeIndex:1.
3738
d05d10503c67 halfway fix
sr
parents: 3736
diff changeset
   730
"/    (showDefaultToggle ? true) ifTrue:[
d05d10503c67 halfway fix
sr
parents: 3736
diff changeset
   731
        toggleItem := MenuItem labeled:(Text string:' ' emphasis:(#backgroundColor->DefaultViewBackgroundColor)).
d05d10503c67 halfway fix
sr
parents: 3736
diff changeset
   732
        toggleItem value:#selection.
d05d10503c67 halfway fix
sr
parents: 3736
diff changeset
   733
        toggleItem isButton: false.
d05d10503c67 halfway fix
sr
parents: 3736
diff changeset
   734
        toggleItem activeHelpKey:#useDefaultColorToggle.    
3981
d6cb72181559 enableChan
Claus Gittinger <cg@exept.de>
parents: 3862
diff changeset
   735
        toggleItem isVisible:(self useDefaultColorToggleVisibleHolder).    
3738
d05d10503c67 halfway fix
sr
parents: 3736
diff changeset
   736
        menu addItem:toggleItem beforeIndex:1.
d05d10503c67 halfway fix
sr
parents: 3736
diff changeset
   737
"/    ].
806
abed5a47e545 separators removed and color orange added
tz
parents: 692
diff changeset
   738
3997
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   739
    allowNilColor ifTrue:[
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   740
        toggleItem := MenuItem labeled:'No Color'.
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   741
        toggleItem isButton:false.
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   742
        toggleItem activeHelpKey:#noColor.    
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   743
        toggleItem indication:self hasNilColorHolder.
3998
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   744
        toggleItem value:#'hasNilColorHolder:'.
3997
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   745
        menu addItem:toggleItem.
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   746
    ].
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   747
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   748
    self menu:menu.
3996
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   749
    self updateEnableChannel
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   750
3998
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   751
    "Modified: / 24-01-2011 / 19:35:23 / cg"
3996
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   752
!
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   753
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   754
updateEnableChannel
666
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   755
    self do:[:anItem|
3404
18dae88f0f2d help spec
Claus Gittinger <cg@exept.de>
parents: 3401
diff changeset
   756
        anItem value == #selection ifTrue:[
3996
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   757
            anItem indication:self overwriteDefaultToggleChannel.
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   758
            "/ anItem enabled:enabledChannel.
666
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   759
        ] ifFalse:[
3998
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   760
            anItem value == #hasNilColorHolder: ifTrue:[
3997
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   761
            ] ifFalse:[
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   762
                anItem enabled:self overwriteDefaultToggleChannel.
35c107962304 class definition
Claus Gittinger <cg@exept.de>
parents: 3996
diff changeset
   763
            ]
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   764
        ]
664
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   765
    ]
3981
d6cb72181559 enableChan
Claus Gittinger <cg@exept.de>
parents: 3862
diff changeset
   766
3996
4ef9b35afcdc class definition
Claus Gittinger <cg@exept.de>
parents: 3995
diff changeset
   767
    "Created: / 23-01-2011 / 16:08:06 / cg"
3998
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   768
    "Modified: / 24-01-2011 / 19:35:52 / cg"
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   769
! !
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   770
3406
28d99375fcc7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3404
diff changeset
   771
!ColorMenu methodsFor:'user actions'!
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   772
3530
8c5d769c024c keepColorHolderIndicationAlwaysEnabled
sr
parents: 3445
diff changeset
   773
keepColorHolderIndicationAlwaysEnabled
8c5d769c024c keepColorHolderIndicationAlwaysEnabled
sr
parents: 3445
diff changeset
   774
    self colorHolder indication:true.
8c5d769c024c keepColorHolderIndicationAlwaysEnabled
sr
parents: 3445
diff changeset
   775
    self colorHolder isButton:true.
8c5d769c024c keepColorHolderIndicationAlwaysEnabled
sr
parents: 3445
diff changeset
   776
!
8c5d769c024c keepColorHolderIndicationAlwaysEnabled
sr
parents: 3445
diff changeset
   777
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   778
openColorEditDialog
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   779
    |defineColorDialog|
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   780
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   781
    defineColorDialog := ColorEditDialog new color: self color.
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   782
    defineColorDialog open.
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   783
    defineColorDialog accept value ifTrue: [
3736
1aa04cb6d849 ColorEditDialog was grazy - adapted to changed protocol
Claus Gittinger <cg@exept.de>
parents: 3709
diff changeset
   784
        self color:defineColorDialog colorNameOrColor
3322
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   785
    ]
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   786
!
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   787
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   788
pickColorFromScreen
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   789
    |color|
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   790
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   791
    color := Color fromUser.
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   792
    color notNil ifTrue:[
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   793
        self color:color.
1a51da8de402 much improved; code cleanup
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   794
    ]
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   795
! !
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   796
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   797
!ColorMenu class methodsFor:'documentation'!
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   798
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   799
version
3998
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   800
    ^ '$Header: /cvs/stx/stx/libwidg2/ColorMenu.st,v 1.69 2011-01-24 19:35:06 cg Exp $'
3862
754cfd6ed4b5 changed: #addUserDefinedColors:labels:title:
Claus Gittinger <cg@exept.de>
parents: 3738
diff changeset
   801
!
754cfd6ed4b5 changed: #addUserDefinedColors:labels:title:
Claus Gittinger <cg@exept.de>
parents: 3738
diff changeset
   802
754cfd6ed4b5 changed: #addUserDefinedColors:labels:title:
Claus Gittinger <cg@exept.de>
parents: 3738
diff changeset
   803
version_CVS
3998
b0ef8a3d446c class definition
Claus Gittinger <cg@exept.de>
parents: 3997
diff changeset
   804
    ^ '$Header: /cvs/stx/stx/libwidg2/ColorMenu.st,v 1.69 2011-01-24 19:35:06 cg Exp $'
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   805
! !