ColorMenu.st
author Claus Gittinger <cg@exept.de>
Tue, 15 Jun 1999 14:31:04 +0200
changeset 1410 be0e2a06be7c
parent 1372 54d8812de860
child 1676 d01663a2356d
permissions -rw-r--r--
unused local removed
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
"
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    12
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    13
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    14
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    15
MenuPanel subclass:#ColorMenu
664
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
    16
	instanceVariableNames:'model enabledChannel labelsAreColored'
666
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
    17
	classVariableNames:''
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    18
	poolDictionaries:''
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    19
	category:'Interface-UIPainter'
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    20
!
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    21
1057
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
    22
SimpleDialog subclass:#DefineColor
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
    23
	instanceVariableNames:'red green blue'
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
    24
	classVariableNames:''
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
    25
	poolDictionaries:''
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
    26
	privateIn:ColorMenu
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
    27
!
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
    28
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    29
!ColorMenu class methodsFor:'documentation'!
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    30
422
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    31
copyright
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    32
"
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    33
 COPYRIGHT (c) 1995 by eXept Software AG
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    34
              All Rights Reserved
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    35
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    36
 This software is furnished under a license and may be used
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    37
 only in accordance with the terms of that license and with the
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    38
 inclusion of the above copyright notice.   This software may not
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    39
 be provided or otherwise made available to, or used by, any
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    40
 other person.  No title to or ownership of the software is
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    41
 hereby transferred.
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    42
"
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    43
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    44
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    45
!
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    46
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    47
documentation
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    48
"
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    49
    ColorMenu used by UIPainter
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    50
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    51
    [see also:]
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    52
        UIPainter
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    53
        ColorMenuSpec
422
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    54
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    55
    [author:]
b28cfebfef40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 412
diff changeset
    56
        Claus Atzkern
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    57
"
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    58
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    59
!
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    60
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    61
examples
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    62
"
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    63
    simple example
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    64
                                                                                [exBegin]                                      
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    65
    |tool top channel|
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    66
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    67
    top := StandardSystemView new.
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    68
    top extent:250@30.
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    69
    channel := (Color red) asValue.
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    70
    tool := self origin:0.0@0.0 corner:1.0@1.0 in:top.
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    71
    tool model:channel.
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    72
    top open.
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    73
                                                                                [exEnd]
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    74
"
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    75
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    76
! !
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    77
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    78
!ColorMenu class methodsFor:'menu spec'!
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    79
666
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
    80
colorDefinition
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
    81
    "color definitions used to build a color menu
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    82
    "
583
4753eec71973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 476
diff changeset
    83
666
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
    84
  ^ #(
668
774e55692416 remove labels in top menu
ca
parents: 666
diff changeset
    85
        #(  gray
666
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
    86
            gray:
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
    87
            #(  white
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
    88
                veryLightGray
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
    89
                lightGray
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
    90
                gray 
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
    91
                darkGray 
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
    92
                veryDarkGray 
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
    93
                black 
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
    94
             )
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
    95
        )
666
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
    96
668
774e55692416 remove labels in top menu
ca
parents: 666
diff changeset
    97
        #(  red
666
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
    98
            red:
854
591cc5592fdf more harmonic color palettes
tz
parents: 832
diff changeset
    99
            #( lightened 100 87 67 50 33)
666
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   100
         )
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   101
668
774e55692416 remove labels in top menu
ca
parents: 666
diff changeset
   102
        #(  green
666
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   103
            green:
854
591cc5592fdf more harmonic color palettes
tz
parents: 832
diff changeset
   104
            #( lightened 100 87 67 50 33)
666
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   105
         )
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   106
668
774e55692416 remove labels in top menu
ca
parents: 666
diff changeset
   107
        #(  blue
666
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   108
            blue:
854
591cc5592fdf more harmonic color palettes
tz
parents: 832
diff changeset
   109
            #( lightened 100 87 67 50 33)
666
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   110
         )
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   111
668
774e55692416 remove labels in top menu
ca
parents: 666
diff changeset
   112
        #(  cyan
854
591cc5592fdf more harmonic color palettes
tz
parents: 832
diff changeset
   113
            cyan:
591cc5592fdf more harmonic color palettes
tz
parents: 832
diff changeset
   114
            #( lightened 100 87 67 50 33)
664
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   115
        )
666
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   116
668
774e55692416 remove labels in top menu
ca
parents: 666
diff changeset
   117
        #(  magenta
854
591cc5592fdf more harmonic color palettes
tz
parents: 832
diff changeset
   118
            magenta:
591cc5592fdf more harmonic color palettes
tz
parents: 832
diff changeset
   119
            #( lightened 100 87 67 50 33)
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   120
        )
666
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   121
668
774e55692416 remove labels in top menu
ca
parents: 666
diff changeset
   122
        #(  yellow
854
591cc5592fdf more harmonic color palettes
tz
parents: 832
diff changeset
   123
            yellow:
591cc5592fdf more harmonic color palettes
tz
parents: 832
diff changeset
   124
            #( lightened 100 87 67 50 33)
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   125
        )
806
abed5a47e545 separators removed and color orange added
tz
parents: 692
diff changeset
   126
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   127
    )
666
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   128
!
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   129
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   130
colorMenu:labelAreColored value:aValue
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   131
    "returns a color menu
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   132
    "
1410
be0e2a06be7c unused local removed
Claus Gittinger <cg@exept.de>
parents: 1372
diff changeset
   133
    |menu mainCol style e|
666
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   134
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   135
    menu  := Menu new.
1372
54d8812de860 care for good contrast in color-menus
Claus Gittinger <cg@exept.de>
parents: 1119
diff changeset
   136
    style := (labelAreColored == false) 
54d8812de860 care for good contrast in color-menus
Claus Gittinger <cg@exept.de>
parents: 1119
diff changeset
   137
                ifTrue:[#backgroundColor] 
54d8812de860 care for good contrast in color-menus
Claus Gittinger <cg@exept.de>
parents: 1119
diff changeset
   138
                ifFalse:[#color].
666
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   139
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   140
    self colorDefinition do:[:aSlice|
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   141
        |size colOp color item smenu|
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   142
668
774e55692416 remove labels in top menu
ca
parents: 666
diff changeset
   143
        mainCol := Color perform:(aSlice at:1).
774e55692416 remove labels in top menu
ca
parents: 666
diff changeset
   144
        item    := MenuItem labeled:(Text string:'  ' emphasis:(#backgroundColor->mainCol)).
666
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   145
        smenu   := Menu new.
668
774e55692416 remove labels in top menu
ca
parents: 666
diff changeset
   146
        colOp   := aSlice at:2.
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   147
668
774e55692416 remove labels in top menu
ca
parents: 666
diff changeset
   148
        (aSlice at:3) do:[:el||sitem label|
666
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   149
            el isSymbol ifTrue:[
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   150
                color := el == #lightened ifTrue:[mainCol perform:el] ifFalse:[Color perform:el].
854
591cc5592fdf more harmonic color palettes
tz
parents: 832
diff changeset
   151
                self colorDefinition first ~~ aSlice 
591cc5592fdf more harmonic color palettes
tz
parents: 832
diff changeset
   152
                    ifTrue: [label := (colOp upTo: $:), ' ', el] 
591cc5592fdf more harmonic color palettes
tz
parents: 832
diff changeset
   153
                    ifFalse:[label := el].
666
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   154
            ] ifFalse:[
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   155
                el isNumber ifTrue:[
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   156
                    color := Color perform:colOp with:el.
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   157
                    label := colOp, ' ', el printString.
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   158
                ] ifFalse:[
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   159
                    color := Color perform:colOp with:(el at:1) with:(el at:2) with:(el at:3).
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   160
                    label := ''.
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   161
                    colOp keywords keysAndValuesDo:[:i :c| label := label, ' ', c, ' ' , (el at:i) printString ].
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   162
                ]
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   163
            ].
1372
54d8812de860 care for good contrast in color-menus
Claus Gittinger <cg@exept.de>
parents: 1119
diff changeset
   164
            e := style->color.
54d8812de860 care for good contrast in color-menus
Claus Gittinger <cg@exept.de>
parents: 1119
diff changeset
   165
            style == #backgroundColor ifTrue:[
54d8812de860 care for good contrast in color-menus
Claus Gittinger <cg@exept.de>
parents: 1119
diff changeset
   166
                color brightness < 0.5 ifTrue:[
54d8812de860 care for good contrast in color-menus
Claus Gittinger <cg@exept.de>
parents: 1119
diff changeset
   167
                    e := Array with:e
54d8812de860 care for good contrast in color-menus
Claus Gittinger <cg@exept.de>
parents: 1119
diff changeset
   168
                               with:(#color->Color white) 
54d8812de860 care for good contrast in color-menus
Claus Gittinger <cg@exept.de>
parents: 1119
diff changeset
   169
                ]
54d8812de860 care for good contrast in color-menus
Claus Gittinger <cg@exept.de>
parents: 1119
diff changeset
   170
            ].
54d8812de860 care for good contrast in color-menus
Claus Gittinger <cg@exept.de>
parents: 1119
diff changeset
   171
            sitem := MenuItem 
54d8812de860 care for good contrast in color-menus
Claus Gittinger <cg@exept.de>
parents: 1119
diff changeset
   172
                        labeled:(Text 
54d8812de860 care for good contrast in color-menus
Claus Gittinger <cg@exept.de>
parents: 1119
diff changeset
   173
                                    string:('Color ', label)
54d8812de860 care for good contrast in color-menus
Claus Gittinger <cg@exept.de>
parents: 1119
diff changeset
   174
                                    emphasis:e).
666
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   175
            sitem argument:color.
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   176
            sitem value:aValue.
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   177
            smenu addItem:sitem.
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   178
        ].
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   179
        item submenu:smenu.
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   180
        item value:nil.
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   181
        menu addItem:item        
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   182
    ].
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   183
    ^ menu
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   184
"
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   185
(ColorMenu colorMenu:true  value:nil) startUp
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   186
(ColorMenu colorMenu:false value:#aSelector:) startUp
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   187
"
592
c7813cfa8794 add more colors
ca
parents: 583
diff changeset
   188
! !
c7813cfa8794 add more colors
ca
parents: 583
diff changeset
   189
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   190
!ColorMenu methodsFor:'accept'!
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   191
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   192
accept:anItem
664
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   193
    "accept current selected item"
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   194
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   195
    |item holder color|
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   196
1058
2a6e0c07b336 ? -> def
tz
parents: 1057
diff changeset
   197
    ((item := super accept:anItem) notNil and: [item label ~= 'def']) 
664
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   198
    ifTrue:
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   199
    [
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   200
        (holder := self colorHolder) == item ifTrue:
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   201
        [
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   202
            enabledChannel value ifTrue:[color := self color]
664
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   203
        ] 
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   204
        ifFalse:
1057
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   205
        [  
666
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   206
            color := item argument.
692
fbf4503f8bc5 selection bug fixed
tz
parents: 668
diff changeset
   207
            holder label:(Text string:'   ' emphasis:(#backgroundColor->color)).
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   208
        ].
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   209
        model notNil ifTrue:[model value:color]
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   210
    ]
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   211
! !
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   212
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   213
!ColorMenu methodsFor:'accessing'!
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   214
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   215
color
664
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   216
    "get current color"
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   217
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   218
    |firstEmphasis|
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   219
    (firstEmphasis := (self colorHolder label emphasis at:1)) isAssociation ifTrue: [^firstEmphasis value].
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   220
    ^(firstEmphasis at: 1) value 
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   221
!
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   222
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   223
color:aColor
664
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   224
    "set current color"
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   225
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   226
    |holder label|
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   227
664
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   228
    aColor isColor 
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   229
    ifFalse:
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   230
    [
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   231
        enabledChannel value:false
664
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   232
    ] 
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   233
    ifTrue:
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   234
    [
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   235
        self disabledRedrawDo:
1057
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   236
        [                 
664
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   237
            holder := self colorHolder.     
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   238
            label  := Text string: '   ' emphasis:(#backgroundColor->aColor).
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   239
            enabledChannel value:true.
1057
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   240
            holder label:label.
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   241
            model value: aColor
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   242
        ]
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   243
    ]
664
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   244
!
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   245
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   246
labelsAreColored: aBoolean
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   247
    "sets whether labels or their backgrounds will be colored"
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   248
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   249
    labelsAreColored := aBoolean ? false.
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   250
    self setupMenu
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   251
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   252
! !
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   253
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   254
!ColorMenu methodsFor:'accessing channels'!
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   255
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   256
model
664
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   257
    "get my color channel"
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   258
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   259
    ^model
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   260
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   261
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   262
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   263
!
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   264
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   265
model:aValueHolder
664
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   266
    "set my color channel"
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   267
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   268
    model notNil ifTrue:[model removeDependent:self].
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   269
664
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   270
    (model := aValueHolder) notNil 
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   271
    ifTrue:
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   272
    [
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   273
        model addDependent:self.
664
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   274
        self color: model value
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   275
    ]
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   276
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   277
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   278
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   279
! !
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   280
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   281
!ColorMenu methodsFor:'accessing look'!
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   282
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   283
showSeparatingLines
664
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   284
    "no drawing of separating lines here"
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   285
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   286
    ^true
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   287
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   288
! !
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   289
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   290
!ColorMenu methodsFor:'change & update'!
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   291
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   292
update:something with:aParameter from:changedObject
664
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   293
    "one of my models changed its value"
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   294
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   295
    changedObject == model ifTrue:[^self color: model value].
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   296
    super update:something with:aParameter from:changedObject
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   297
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   298
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   299
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   300
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   301
! !
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   302
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   303
!ColorMenu methodsFor:'initialization'!
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   304
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   305
destroy
664
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   306
    "release color channel dependency"
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   307
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   308
    self model:nil.
664
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   309
    super destroy
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   310
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   311
!
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   312
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   313
initialize
664
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   314
    "setup menu"
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   315
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   316
    super initialize.
664
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   317
    labelsAreColored := false.
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   318
    self verticalLayout:false.
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   319
    self fitFirstPanel:false.
895
d1c9210e796b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 854
diff changeset
   320
    enabledChannel := ValueHolder with:false.
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   321
    self setupMenu.
895
d1c9210e796b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 854
diff changeset
   322
d1c9210e796b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 854
diff changeset
   323
    "Modified: / 21.5.1998 / 03:07:26 / cg"
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   324
!
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   325
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   326
setupMenu
664
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   327
    "setup menu"
666
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   328
    |menu item|
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   329
666
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   330
    menu := self class colorMenu:labelsAreColored value:nil.
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   331
    menu itemsDo:[:el| el isButton:true].
1058
2a6e0c07b336 ? -> def
tz
parents: 1057
diff changeset
   332
    menu addItem:((MenuItem labeled:'def') value: 
1057
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   333
    [
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   334
        |defineColor|
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   335
        defineColor := DefineColor new color: self color.
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   336
        defineColor open.
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   337
        defineColor accept value ifTrue: [self color: defineColor color]
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   338
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   339
    ]; isButton: true) beforeIndex:8.
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   340
    menu addItem:(MenuItem labeled:'') beforeIndex:8.
806
abed5a47e545 separators removed and color orange added
tz
parents: 692
diff changeset
   341
    menu addItem:(MenuItem labeled:' ') beforeIndex:5.
abed5a47e545 separators removed and color orange added
tz
parents: 692
diff changeset
   342
    menu addItem:(MenuItem labeled:' ') beforeIndex:2.
abed5a47e545 separators removed and color orange added
tz
parents: 692
diff changeset
   343
    menu addItem:(MenuItem labeled:' ') beforeIndex:1.
abed5a47e545 separators removed and color orange added
tz
parents: 692
diff changeset
   344
666
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   345
    item := MenuItem labeled:(Text string:'   ' emphasis:(#backgroundColor->DefaultViewBackgroundColor)).
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   346
    item value:#selection.
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   347
    menu addItem:item beforeIndex:1.
806
abed5a47e545 separators removed and color orange added
tz
parents: 692
diff changeset
   348
abed5a47e545 separators removed and color orange added
tz
parents: 692
diff changeset
   349
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   350
    self menu:menu.
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   351
666
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   352
    self do:[:anItem|
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   353
        (anItem submenu) notNil ifTrue:[
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   354
            anItem enabled:enabledChannel.
666
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   355
        ] ifFalse:[
801db9028157 provides a basic color menu reused by
ca
parents: 664
diff changeset
   356
            anItem value == #selection ifTrue:[anItem indication:enabledChannel] 
1057
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   357
                                      ifFalse:[anItem enabled:false]. 
1058
2a6e0c07b336 ? -> def
tz
parents: 1057
diff changeset
   358
            anItem label = 'def' ifTrue:[anItem enabled:enabledChannel] 
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   359
        ]
664
53f8cdd4462c *** empty log message ***
tz
parents: 617
diff changeset
   360
    ]
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   361
! !
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   362
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   363
!ColorMenu methodsFor:'private'!
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   364
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   365
colorHolder
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   366
    "returns the item which keeps the selected color in its label
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   367
    "
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   368
  ^ self itemAt:#selection
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   369
! !
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   370
1057
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   371
!ColorMenu::DefineColor class methodsFor:'interface specs'!
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   372
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   373
windowSpec
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   374
    "This resource specification was automatically generated
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   375
     by the UIPainter of ST/X."
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   376
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   377
    "Do not manually edit this!! If it is corrupted,
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   378
     the UIPainter may not be able to read the specification."
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   379
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   380
    "
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   381
     UIPainter new openOnClass:ColorMenu::DefineColor andSelector:#windowSpec
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   382
     ColorMenu::DefineColor new openInterface:#windowSpec
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   383
     ColorMenu::DefineColor open
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   384
    "
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   385
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   386
    <resource: #canvas>
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   387
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   388
    ^
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   389
     
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   390
       #(#FullSpec
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   391
          #window: 
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   392
           #(#WindowSpec
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   393
              #name: 'Define Color'
1119
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   394
              #layout: #(#LayoutFrame 13 0 29 0 352 0 159 0)
1057
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   395
              #label: 'Define Color'
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   396
              #min: #(#Point 340 110)
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   397
              #max: #(#Point 1152 900)
1119
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   398
              #bounds: #(#Rectangle 13 29 353 160)
1057
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   399
              #usePreferredExtent: false
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   400
          )
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   401
          #component: 
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   402
           #(#SpecCollection
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   403
              #collection: 
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   404
               #(
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   405
                 #(#VerticalPanelViewSpec
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   406
                    #name: 'VerticalPanel1'
1119
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   407
                    #layout: #(#LayoutFrame 0 0.0 0 0.0 58 0 -40 1.0)
1057
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   408
                    #component: 
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   409
                     #(#SpecCollection
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   410
                        #collection: 
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   411
                         #(
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   412
                           #(#LabelSpec
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   413
                              #name: 'RedLabel'
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   414
                              #label: 'Red:'
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   415
                              #translateLabel: true
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   416
                              #adjust: #right
1119
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   417
                              #extent: #(#Point 58 26)
1057
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   418
                          )
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   419
                           #(#LabelSpec
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   420
                              #name: 'GreenLabel'
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   421
                              #label: 'Green:'
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   422
                              #translateLabel: true
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   423
                              #adjust: #right
1119
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   424
                              #extent: #(#Point 58 27)
1057
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   425
                          )
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   426
                           #(#LabelSpec
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   427
                              #name: 'BlueLabel'
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   428
                              #label: 'Blue:'
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   429
                              #translateLabel: true
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   430
                              #adjust: #right
1119
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   431
                              #extent: #(#Point 58 26)
1057
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   432
                          )
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   433
                        )
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   434
                    )
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   435
                    #horizontalLayout: #fit
1119
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   436
                    #verticalLayout: #fitSpace
1057
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   437
                    #horizontalSpace: 3
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   438
                    #verticalSpace: 3
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   439
                )
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   440
                 #(#VerticalPanelViewSpec
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   441
                    #name: 'VerticalPanel2'
1119
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   442
                    #layout: #(#LayoutFrame 60 0 0 0.0 -160 1.0 -40 1.0)
1057
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   443
                    #component: 
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   444
                     #(#SpecCollection
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   445
                        #collection: 
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   446
                         #(
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   447
                           #(#SliderSpec
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   448
                              #name: 'RedSlider'
1119
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   449
                              #tabable: true
1057
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   450
                              #model: #red
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   451
                              #orientation: #horizontal
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   452
                              #stop: 255
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   453
                              #step: 1
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   454
                              #backgroundColor: #(#Color 100.0 0.0 0.0)
1119
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   455
                              #extent: #(#Point 118 16)
1057
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   456
                          )
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   457
                           #(#SliderSpec
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   458
                              #name: 'GreenSlider'
1119
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   459
                              #tabable: true
1057
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   460
                              #model: #green
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   461
                              #orientation: #horizontal
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   462
                              #stop: 255
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   463
                              #step: 1
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   464
                              #backgroundColor: #(#Color 0.0 100.0 0.0)
1119
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   465
                              #extent: #(#Point 118 16)
1057
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   466
                          )
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   467
                           #(#SliderSpec
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   468
                              #name: 'BlueSlider'
1119
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   469
                              #tabable: true
1057
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   470
                              #model: #blue
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   471
                              #orientation: #horizontal
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   472
                              #stop: 255
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   473
                              #step: 1
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   474
                              #backgroundColor: #(#Color 0.0 0.0 100.0)
1119
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   475
                              #extent: #(#Point 118 16)
1057
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   476
                          )
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   477
                        )
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   478
                    )
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   479
                    #horizontalLayout: #fit
1119
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   480
                    #verticalLayout: #spreadSpace
1057
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   481
                    #horizontalSpace: 3
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   482
                    #verticalSpace: 3
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   483
                )
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   484
                 #(#VerticalPanelViewSpec
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   485
                    #name: 'VerticalPanel3'
1119
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   486
                    #layout: #(#LayoutFrame -158 1 0 0.0 -120 1 -40 1.0)
1057
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   487
                    #component: 
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   488
                     #(#SpecCollection
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   489
                        #collection: 
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   490
                         #(
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   491
                           #(#InputFieldSpec
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   492
                              #name: 'RedField'
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   493
                              #model: #red
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   494
                              #type: #numberInRange
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   495
                              #numChars: 3
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   496
                              #minValue: 0
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   497
                              #maxValue: 255
1119
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   498
                              #extent: #(#Point 38 20)
1057
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   499
                          )
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   500
                           #(#InputFieldSpec
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   501
                              #name: 'GreenField'
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   502
                              #model: #green
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   503
                              #type: #numberInRange
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   504
                              #numChars: 3
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   505
                              #minValue: 0
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   506
                              #maxValue: 255
1119
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   507
                              #extent: #(#Point 38 20)
1057
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   508
                          )
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   509
                           #(#InputFieldSpec
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   510
                              #name: 'BlueField'
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   511
                              #model: #blue
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   512
                              #type: #numberInRange
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   513
                              #numChars: 3
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   514
                              #minValue: 0
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   515
                              #maxValue: 255
1119
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   516
                              #extent: #(#Point 38 20)
1057
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   517
                          )
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   518
                        )
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   519
                    )
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   520
                    #horizontalLayout: #fit
1119
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   521
                    #verticalLayout: #spreadSpace
1057
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   522
                    #horizontalSpace: 3
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   523
                    #verticalSpace: 3
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   524
                )
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   525
                 #(#LabelSpec
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   526
                    #name: 'PreviewBox'
1119
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   527
                    #layout: #(#LayoutFrame -116 1 0 0.0 -2 1.0 -40 1.0)
1057
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   528
                    #label: 'Preview'
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   529
                    #translateLabel: true
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   530
                    #level: -1
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   531
                )
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   532
                 #(#HorizontalPanelViewSpec
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   533
                    #name: 'HorizontalPanel1'
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   534
                    #layout: #(#LayoutFrame 0 0.0 -32 1 0 1.0 0 1.0)
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   535
                    #component: 
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   536
                     #(#SpecCollection
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   537
                        #collection: 
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   538
                         #(
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   539
                           #(#ActionButtonSpec
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   540
                              #name: 'CancelButton'
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   541
                              #label: 'Cancel'
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   542
                              #translateLabel: true
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   543
                              #model: #cancel
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   544
                              #extent: #(#Point 165 26)
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   545
                          )
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   546
                           #(#ActionButtonSpec
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   547
                              #name: 'OKButton'
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   548
                              #label: 'OK'
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   549
                              #translateLabel: true
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   550
                              #model: #accept
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   551
                              #extent: #(#Point 166 26)
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   552
                          )
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   553
                        )
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   554
                    )
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   555
                    #horizontalLayout: #fitSpace
1119
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   556
                    #verticalLayout: #centerMax
1057
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   557
                    #horizontalSpace: 3
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   558
                    #verticalSpace: 3
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   559
                )
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   560
              )
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   561
          )
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   562
      )
1119
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   563
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   564
    "Modified: / 6.9.1998 / 23:04:19 / cg"
1057
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   565
! !
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   566
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   567
!ColorMenu::DefineColor methodsFor:'accessing'!
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   568
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   569
color
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   570
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   571
    ^Color redByte: red value greenByte: green value blueByte: blue value
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   572
  
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   573
!
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   574
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   575
color: aColor
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   576
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   577
    aColor notNil
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   578
    ifTrue:
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   579
    [
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   580
        self red   value: aColor redByte.
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   581
        self green value: aColor greenByte.
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   582
        self blue  value: aColor blueByte.
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   583
    ]
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   584
  
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   585
! !
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   586
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   587
!ColorMenu::DefineColor methodsFor:'aspects'!
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   588
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   589
blue
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   590
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   591
    blue isNil ifTrue:[
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   592
        blue := 0 asValue
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   593
    ].
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   594
    ^blue
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   595
!
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   596
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   597
green
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   598
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   599
    green isNil ifTrue:[
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   600
        green := 0 asValue
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   601
    ].
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   602
    ^green
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   603
!
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   604
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   605
red
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   606
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   607
    red isNil ifTrue:[
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   608
        red := 0 asValue
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   609
    ].
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   610
    ^red
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   611
! !
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   612
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   613
!ColorMenu::DefineColor methodsFor:'startup / release'!
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   614
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   615
postBuildWith:aBuilder
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   616
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   617
    |updateBlock|
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   618
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   619
    super postBuildWith:aBuilder.
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   620
1119
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   621
    updateBlock := [
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   622
        |box clr|
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   623
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   624
        box := builder componentAt: #PreviewBox.
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   625
        clr := self color.
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   626
        box backgroundColor:clr.
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   627
        clr brightness < 0.5 ifTrue:[
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   628
            box foregroundColor:Color white
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   629
        ] ifFalse:[
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   630
            box foregroundColor:Color black
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   631
        ]
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   632
    ].
1057
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   633
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   634
    red   onChangeSend: #value to: updateBlock.
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   635
    green onChangeSend: #value to: updateBlock.
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   636
    blue  onChangeSend: #value to: updateBlock.
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   637
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   638
    updateBlock value
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   639
1119
11cd3ce5171b colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   640
    "Modified: / 6.9.1998 / 22:55:25 / cg"
1057
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   641
! !
db1bd14803e3 free color definition added
tz
parents: 895
diff changeset
   642
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   643
!ColorMenu class methodsFor:'documentation'!
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   644
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   645
version
1410
be0e2a06be7c unused local removed
Claus Gittinger <cg@exept.de>
parents: 1372
diff changeset
   646
    ^ '$Header: /cvs/stx/stx/libwidg2/ColorMenu.st,v 1.19 1999-06-15 12:31:04 cg Exp $'
412
a8ad581658ec intitial checkin
ca
parents:
diff changeset
   647
! !