Toggle.st
author Claus Gittinger <cg@exept.de>
Thu, 09 Nov 2017 20:09:30 +0100
changeset 6225 0122e4e6c587
parent 6060 fcd81f4fe76c
permissions -rw-r--r--
#FEATURE by cg class: GenericToolbarIconLibrary class added: #hideFilter16x16Icon
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     1
"
5
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1989 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
     3
	      All Rights Reserved
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     4
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    11
"
2504
f12dab112227 use new #valueWithOptionalArg
Claus Gittinger <cg@exept.de>
parents: 2167
diff changeset
    12
"{ Package: 'stx:libwidg' }"
f12dab112227 use new #valueWithOptionalArg
Claus Gittinger <cg@exept.de>
parents: 2167
diff changeset
    13
5241
a994c267e55e class: Toggle
Claus Gittinger <cg@exept.de>
parents: 4919
diff changeset
    14
"{ NameSpace: Smalltalk }"
a994c267e55e class: Toggle
Claus Gittinger <cg@exept.de>
parents: 4919
diff changeset
    15
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    16
Button subclass:#Toggle
377
ee53da05e265 image example
ca
parents: 205
diff changeset
    17
	instanceVariableNames:'showLamp lampColor lampWidth lampHeight'
1385
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
    18
	classVariableNames:'DefaultShowLamp DefaultLampColor LampInset'
377
ee53da05e265 image example
ca
parents: 205
diff changeset
    19
	poolDictionaries:''
ee53da05e265 image example
ca
parents: 205
diff changeset
    20
	category:'Views-Interactors'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    21
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    22
22
ac872628ef2d *** empty log message ***
claus
parents: 7
diff changeset
    23
!Toggle class methodsFor:'documentation'!
ac872628ef2d *** empty log message ***
claus
parents: 7
diff changeset
    24
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    25
copyright
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    26
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    27
 COPYRIGHT (c) 1989 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
    28
	      All Rights Reserved
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    29
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    30
 This software is furnished under a license and may be used
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    31
 only in accordance with the terms of that license and with the
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    33
 be provided or otherwise made available to, or used by, any
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    34
 other person.  No title to or ownership of the software is
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    35
 hereby transferred.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    36
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    37
!
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    38
22
ac872628ef2d *** empty log message ***
claus
parents: 7
diff changeset
    39
documentation
ac872628ef2d *** empty log message ***
claus
parents: 7
diff changeset
    40
"
128
claus
parents: 121
diff changeset
    41
    this button changes state whenever clicked upon and stays down (pressed) 
claus
parents: 121
diff changeset
    42
    until clicked again. All the main action is in Button and the controller
claus
parents: 121
diff changeset
    43
    (ToggleController).
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    44
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    45
    The toggle may optionally display a little kind-of-lamp (or LED), which
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    46
    is turned on when the toggle is pressed. (i.e. as in the Interviews toolkit).
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    47
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    48
    whenever the Toggle changes its change, it will evaluate one of
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    49
    pressAction or releaseAction.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    50
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    51
    For ST-80 compatibility, if the model is nonNil, this one gets a new
128
claus
parents: 121
diff changeset
    52
    value and is sent a changed message. Also, the toggle will follow changes 
claus
parents: 121
diff changeset
    53
    in the model and update its display as appropriate.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    54
    If nonNil, the model is supposed to be a ValueHolder holding true or false.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    55
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    56
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
    57
    [instance variables:]
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
    58
        showLamp          <Boolean>     true if a lamp should be displayed
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
    59
        lampColor         <Color>       color of the lamp
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
    60
        lampWidth         <Integer>     width of the lamp in pixel
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
    61
        lampHeight        <Integer>     height of the lamp in pixel
119
claus
parents: 105
diff changeset
    62
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
    63
    [styleSheet values:]
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
    64
        toggleShowLamp    <Boolean>     if true, a lamp is shown; default:false.
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
    65
        toggleLampColor   <Color>       lamps color; default:yellow.
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
    66
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
    67
    [author:]
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
    68
        Claus Gittinger
609
734f451e9ad0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    69
734f451e9ad0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    70
    [see also:]
734f451e9ad0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    71
        Button RadioButton
734f451e9ad0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    72
        ( introduction to view programming :html: programming/viewintro.html#INTER_TOGGLES )
734f451e9ad0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    73
        
734f451e9ad0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    74
        
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    75
"
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    76
!
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    77
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    78
examples
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    79
"
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    80
    Examples:
128
claus
parents: 121
diff changeset
    81
    Try all, to see what is possible.
377
ee53da05e265 image example
ca
parents: 205
diff changeset
    82
        (notice, that these examples are meant to show what can be done;
ee53da05e265 image example
ca
parents: 205
diff changeset
    83
         usually, all style-related stuff is preinitialized - you should not
ee53da05e265 image example
ca
parents: 205
diff changeset
    84
         normally play around with onLevel, offLevel, showLamp: etc)
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    85
128
claus
parents: 121
diff changeset
    86
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    87
      simple:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    88
                                                                        [exBegin]
377
ee53da05e265 image example
ca
parents: 205
diff changeset
    89
        |v t|
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    90
377
ee53da05e265 image example
ca
parents: 205
diff changeset
    91
        v := StandardSystemView new extent:200@200.
ee53da05e265 image example
ca
parents: 205
diff changeset
    92
        t := Toggle label:'press here' in:v.
ee53da05e265 image example
ca
parents: 205
diff changeset
    93
        t origin:10 @ 10.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
    94
        t action:[:value | Transcript show:'toggle state: '; showCR:value.].
377
ee53da05e265 image example
ca
parents: 205
diff changeset
    95
        v open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    96
                                                                        [exEnd]
119
claus
parents: 105
diff changeset
    97
128
claus
parents: 121
diff changeset
    98
119
claus
parents: 105
diff changeset
    99
      separate press/release actions:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   100
                                                                        [exBegin]
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   101
        |v t|
119
claus
parents: 105
diff changeset
   102
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   103
        v := StandardSystemView new extent:200@200.
ee53da05e265 image example
ca
parents: 205
diff changeset
   104
        t := Toggle label:'press here' in:v.
ee53da05e265 image example
ca
parents: 205
diff changeset
   105
        t origin:10 @ 10.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
   106
        t pressAction:[Transcript showCR:'toggle pressed'.].
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
   107
        t releaseAction:[Transcript showCR:'toggle released'.].
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   108
        v open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   109
                                                                        [exEnd]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   110
128
claus
parents: 121
diff changeset
   111
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   112
      changing logo:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   113
                                                                        [exBegin]
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   114
        |v t|
ee53da05e265 image example
ca
parents: 205
diff changeset
   115
ee53da05e265 image example
ca
parents: 205
diff changeset
   116
        v := StandardSystemView new extent:200@200.
ee53da05e265 image example
ca
parents: 205
diff changeset
   117
        t := Toggle label:'eat me' in:v.
ee53da05e265 image example
ca
parents: 205
diff changeset
   118
        t origin:10 @ 10.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
   119
        t pressAction:[Transcript showCR:'smaller'. t label:'drink me'].
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
   120
        t releaseAction:[Transcript showCR:'larger'. t label:'eat me'].
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   121
        v open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   122
                                                                        [exEnd]
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   123
ee53da05e265 image example
ca
parents: 205
diff changeset
   124
378
056af35f401d inline-image example
ca
parents: 377
diff changeset
   125
      changing logo:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   126
                                                                        [exBegin]
378
056af35f401d inline-image example
ca
parents: 377
diff changeset
   127
        |v t|
056af35f401d inline-image example
ca
parents: 377
diff changeset
   128
056af35f401d inline-image example
ca
parents: 377
diff changeset
   129
        v := StandardSystemView new extent:200@200.
056af35f401d inline-image example
ca
parents: 377
diff changeset
   130
        t := Toggle in:v.
056af35f401d inline-image example
ca
parents: 377
diff changeset
   131
        t logo:(Form width:16 height:14 fromArray:#(
056af35f401d inline-image example
ca
parents: 377
diff changeset
   132
                                                        2r00000000 2r00000000
056af35f401d inline-image example
ca
parents: 377
diff changeset
   133
                                                        2r00000000 2r00000000
056af35f401d inline-image example
ca
parents: 377
diff changeset
   134
                                                        2r00000000 2r00000000
056af35f401d inline-image example
ca
parents: 377
diff changeset
   135
                                                        2r00000111 2r11100000
056af35f401d inline-image example
ca
parents: 377
diff changeset
   136
                                                        2r00001100 2r00000000
056af35f401d inline-image example
ca
parents: 377
diff changeset
   137
                                                        2r00011000 2r00000000
056af35f401d inline-image example
ca
parents: 377
diff changeset
   138
                                                        2r00011000 2r00000000
056af35f401d inline-image example
ca
parents: 377
diff changeset
   139
                                                        2r00011000 2r00000000
056af35f401d inline-image example
ca
parents: 377
diff changeset
   140
                                                        2r00011000 2r00000000
056af35f401d inline-image example
ca
parents: 377
diff changeset
   141
                                                        2r00001100 2r00000000
056af35f401d inline-image example
ca
parents: 377
diff changeset
   142
                                                        2r00000111 2r11100000
056af35f401d inline-image example
ca
parents: 377
diff changeset
   143
                                                        2r00000000 2r00000000
056af35f401d inline-image example
ca
parents: 377
diff changeset
   144
                                                        2r00000000 2r00000000
056af35f401d inline-image example
ca
parents: 377
diff changeset
   145
                                                        2r00000000 2r00000000)).
056af35f401d inline-image example
ca
parents: 377
diff changeset
   146
        t origin:10 @ 10.
056af35f401d inline-image example
ca
parents: 377
diff changeset
   147
        v open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   148
                                                                        [exEnd]
378
056af35f401d inline-image example
ca
parents: 377
diff changeset
   149
056af35f401d inline-image example
ca
parents: 377
diff changeset
   150
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   151
      uhh - changing logos and getting bg-colors from the image:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   152
                                                                        [exBegin]
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   153
        |v t i|
ee53da05e265 image example
ca
parents: 205
diff changeset
   154
ee53da05e265 image example
ca
parents: 205
diff changeset
   155
        v := StandardSystemView new extent:200@200.
ee53da05e265 image example
ca
parents: 205
diff changeset
   156
        t := Toggle in:v.
ee53da05e265 image example
ca
parents: 205
diff changeset
   157
        t origin:10 @ 10.
ee53da05e265 image example
ca
parents: 205
diff changeset
   158
        t showLamp:false.
ee53da05e265 image example
ca
parents: 205
diff changeset
   159
        t activeLogo:(i := Image fromFile:'red-ball.gif').
ee53da05e265 image example
ca
parents: 205
diff changeset
   160
        t passiveLogo:(Image fromFile:'green-ball.gif').
ee53da05e265 image example
ca
parents: 205
diff changeset
   161
        t backgroundColor:(i at:0@0).
ee53da05e265 image example
ca
parents: 205
diff changeset
   162
        t enteredBackgroundColor:(t backgroundColor).
ee53da05e265 image example
ca
parents: 205
diff changeset
   163
        t activeBackgroundColor:(t backgroundColor).
ee53da05e265 image example
ca
parents: 205
diff changeset
   164
        v open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   165
                                                                        [exEnd]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   166
128
claus
parents: 121
diff changeset
   167
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   168
      changing logo and freezing size (looks better):
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   169
                                                                        [exBegin]
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   170
        |v t|
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   171
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   172
        v := StandardSystemView new extent:200@200.
ee53da05e265 image example
ca
parents: 205
diff changeset
   173
        'create with large logo; freeze; change to small logo'.
ee53da05e265 image example
ca
parents: 205
diff changeset
   174
        t := Toggle label:'drink me' in:v. 
ee53da05e265 image example
ca
parents: 205
diff changeset
   175
        t sizeFixed:true.
ee53da05e265 image example
ca
parents: 205
diff changeset
   176
        t label:'eat me'.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   177
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   178
        t origin:10 @ 10.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
   179
        t pressAction:[Transcript showCR:'smaller'. t label:'drink me'].
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
   180
        t releaseAction:[Transcript showCR:'larger'. t label:'eat me'].
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   181
        v open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   182
                                                                        [exEnd]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   183
128
claus
parents: 121
diff changeset
   184
119
claus
parents: 105
diff changeset
   185
      adding a lamp (in some view styles, this is the default anyway):
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   186
                                                                        [exBegin]
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   187
        |v t|
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   188
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   189
        v := StandardSystemView new extent:200@200.
ee53da05e265 image example
ca
parents: 205
diff changeset
   190
        t := Toggle label:'off' in:v.
ee53da05e265 image example
ca
parents: 205
diff changeset
   191
        t showLamp:true.
ee53da05e265 image example
ca
parents: 205
diff changeset
   192
        t origin:10 @ 10.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
   193
        t pressAction:[Transcript showCR:'on'. t label:'on'].
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
   194
        t releaseAction:[Transcript showCR:'off'. t label:'off'].
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   195
        v open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   196
                                                                        [exEnd]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   197
128
claus
parents: 121
diff changeset
   198
119
claus
parents: 105
diff changeset
   199
      changing lamps color:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   200
                                                                        [exBegin]
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   201
        |v t|
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   202
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   203
        v := StandardSystemView new extent:200@200.
ee53da05e265 image example
ca
parents: 205
diff changeset
   204
        t := Toggle label:'off' in:v.
ee53da05e265 image example
ca
parents: 205
diff changeset
   205
        t showLamp:true.
ee53da05e265 image example
ca
parents: 205
diff changeset
   206
        t lampColor:Color red.
ee53da05e265 image example
ca
parents: 205
diff changeset
   207
        t origin:10 @ 10.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
   208
        t pressAction:[Transcript showCR:'on'. t label:'on'.].
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
   209
        t releaseAction:[Transcript showCR:'off'. t label:'off'.].
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   210
        v open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   211
                                                                        [exEnd]
119
claus
parents: 105
diff changeset
   212
128
claus
parents: 121
diff changeset
   213
119
claus
parents: 105
diff changeset
   214
      lamp only - no '3D going-in' (this is the default with IRIS style)
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   215
                                                                        [exBegin]
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   216
        |v t|
119
claus
parents: 105
diff changeset
   217
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   218
        v := StandardSystemView new extent:200@200.
ee53da05e265 image example
ca
parents: 205
diff changeset
   219
        t := Toggle label:'off' in:v.
ee53da05e265 image example
ca
parents: 205
diff changeset
   220
        t showLamp:true.
ee53da05e265 image example
ca
parents: 205
diff changeset
   221
        t onLevel:(t offLevel).
ee53da05e265 image example
ca
parents: 205
diff changeset
   222
        t origin:10 @ 10.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
   223
        t pressAction:[Transcript showCR:'on'. t label:'on'].
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
   224
        t releaseAction:[Transcript showCR:'off'. t label:'off'].
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   225
        v open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   226
                                                                        [exEnd]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   227
128
claus
parents: 121
diff changeset
   228
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   229
      lamp and freezing size of the label (looks better):
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   230
                                                                        [exBegin]
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   231
        |v t|
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   232
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   233
        v := StandardSystemView new extent:200@200.
ee53da05e265 image example
ca
parents: 205
diff changeset
   234
        t := Toggle label:'off' in:v.
ee53da05e265 image example
ca
parents: 205
diff changeset
   235
        t showLamp:true.
ee53da05e265 image example
ca
parents: 205
diff changeset
   236
        t sizeFixed:true.
ee53da05e265 image example
ca
parents: 205
diff changeset
   237
        t origin:10 @ 10.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
   238
        t pressAction:[Transcript showCR:'on'. t label:'on'].
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
   239
        t releaseAction:[Transcript showCR:'off'. t label:'off'].
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   240
        v open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   241
                                                                        [exEnd]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   242
128
claus
parents: 121
diff changeset
   243
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   244
      another variation:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   245
                                                                        [exBegin]
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   246
        |v t|
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   247
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   248
        v := StandardSystemView new extent:200@200.
ee53da05e265 image example
ca
parents: 205
diff changeset
   249
        t := Toggle label:'off' in:v.
ee53da05e265 image example
ca
parents: 205
diff changeset
   250
        t showLamp:true.
ee53da05e265 image example
ca
parents: 205
diff changeset
   251
        t sizeFixed:true.
ee53da05e265 image example
ca
parents: 205
diff changeset
   252
        t onLevel:(t offLevel).
ee53da05e265 image example
ca
parents: 205
diff changeset
   253
        t origin:10 @ 10.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
   254
        t pressAction:[Transcript showCR:'on'. t label:'on'].
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
   255
        t releaseAction:[Transcript showCR:'off'. t label:'off'].
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   256
        v open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   257
                                                                        [exEnd]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   258
128
claus
parents: 121
diff changeset
   259
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   260
      and another one:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   261
                                                                        [exBegin]
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   262
        |v t|
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   263
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   264
        v := StandardSystemView new extent:200@200.
ee53da05e265 image example
ca
parents: 205
diff changeset
   265
        t := Toggle label:'off' in:v.
ee53da05e265 image example
ca
parents: 205
diff changeset
   266
        t showLamp:true.
ee53da05e265 image example
ca
parents: 205
diff changeset
   267
        t sizeFixed:true.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   268
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   269
        t showLamp:false.
ee53da05e265 image example
ca
parents: 205
diff changeset
   270
        t offLevel:3.
ee53da05e265 image example
ca
parents: 205
diff changeset
   271
        t onLevel:3.
ee53da05e265 image example
ca
parents: 205
diff changeset
   272
        t origin:10 @ 10.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
   273
        t pressAction:[Transcript showCR:'on'. t showLamp:true. t label:'on'].
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
   274
        t releaseAction:[Transcript showCR:'off'. t showLamp:false. t label:'off'].
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   275
        v open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   276
                                                                        [exEnd]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   277
128
claus
parents: 121
diff changeset
   278
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   279
      another font:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   280
                                                                        [exBegin]
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   281
        |v t|
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   282
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   283
        v := StandardSystemView new extent:200@200.
ee53da05e265 image example
ca
parents: 205
diff changeset
   284
        t := Toggle label:'off' in:v.
ee53da05e265 image example
ca
parents: 205
diff changeset
   285
        t font:(Font family:'times' face:'bold' style:'roman' size:24).
ee53da05e265 image example
ca
parents: 205
diff changeset
   286
        t label:'hello'.
ee53da05e265 image example
ca
parents: 205
diff changeset
   287
        t origin:10 @ 10.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
   288
        t pressAction:[Transcript showCR:'on'.].
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
   289
        t releaseAction:[Transcript showCR:'off'.].
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   290
        v open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   291
                                                                        [exEnd]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   292
128
claus
parents: 121
diff changeset
   293
5953
cba9ab47338d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5630
diff changeset
   294
      another font (no, I don't know what it means :-):
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   295
                                                                        [exBegin]
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   296
        |v t|
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   297
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   298
        v := StandardSystemView new extent:200@200.
ee53da05e265 image example
ca
parents: 205
diff changeset
   299
        t := Toggle label:'off' in:v.
ee53da05e265 image example
ca
parents: 205
diff changeset
   300
        t font:(Font family:'k14' face:nil style:nil size:nil).
ee53da05e265 image example
ca
parents: 205
diff changeset
   301
        t label:(TwoByteString with:(Character value:16r3021)).
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   302
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   303
        t origin:10 @ 10.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
   304
        t pressAction:[Transcript showCR:'on'.].
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
   305
        t releaseAction:[Transcript showCR:'off'.].
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   306
        v open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   307
                                                                        [exEnd]
119
claus
parents: 105
diff changeset
   308
128
claus
parents: 121
diff changeset
   309
claus
parents: 121
diff changeset
   310
    using a model (look at 'value' in the inspector):
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   311
                                                                        [exBegin]
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   312
        |m v t|
119
claus
parents: 105
diff changeset
   313
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   314
        m := ValueHolder newBoolean.
ee53da05e265 image example
ca
parents: 205
diff changeset
   315
        m inspect.
119
claus
parents: 105
diff changeset
   316
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   317
        v := StandardSystemView new extent:200@200.
ee53da05e265 image example
ca
parents: 205
diff changeset
   318
        t := Toggle label:'press here to change value' in:v.
ee53da05e265 image example
ca
parents: 205
diff changeset
   319
        t origin:10 @ 10.
ee53da05e265 image example
ca
parents: 205
diff changeset
   320
        t model:m.
ee53da05e265 image example
ca
parents: 205
diff changeset
   321
        v open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   322
                                                                        [exEnd]
119
claus
parents: 105
diff changeset
   323
128
claus
parents: 121
diff changeset
   324
119
claus
parents: 105
diff changeset
   325
    using a model with different changeSelector:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   326
                                                                        [exBegin]
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   327
        |m v t|
119
claus
parents: 105
diff changeset
   328
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   329
        m := Plug new.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
   330
        m respondTo:#setValue1: with:[:value | Transcript show:'value 1 changed to: '; showCR:value].
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
   331
        m respondTo:#setValue2: with:[:value | Transcript show:'value 2 changed to: '; showCR:value].
119
claus
parents: 105
diff changeset
   332
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   333
        v := StandardSystemView new extent:200@200.
ee53da05e265 image example
ca
parents: 205
diff changeset
   334
        t := Toggle label:'press here for value1' in:v.
ee53da05e265 image example
ca
parents: 205
diff changeset
   335
        t origin:10 @ 10.
ee53da05e265 image example
ca
parents: 205
diff changeset
   336
        t model:m; change:#setValue1:.
ee53da05e265 image example
ca
parents: 205
diff changeset
   337
        t := Toggle label:'press here for value2' in:v.
ee53da05e265 image example
ca
parents: 205
diff changeset
   338
        t origin:10 @ 50.
ee53da05e265 image example
ca
parents: 205
diff changeset
   339
        t model:m; change:#setValue2:.
ee53da05e265 image example
ca
parents: 205
diff changeset
   340
        v open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   341
                                                                        [exEnd]
128
claus
parents: 121
diff changeset
   342
claus
parents: 121
diff changeset
   343
claus
parents: 121
diff changeset
   344
    two toggles on the same model:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   345
                                                                        [exBegin]
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   346
        |m v t|
128
claus
parents: 121
diff changeset
   347
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   348
        m := true asValue.
128
claus
parents: 121
diff changeset
   349
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   350
        v := StandardSystemView new extent:200@200.
ee53da05e265 image example
ca
parents: 205
diff changeset
   351
        t := Toggle label:'press here' in:v.
ee53da05e265 image example
ca
parents: 205
diff changeset
   352
        t origin:10 @ 10.
ee53da05e265 image example
ca
parents: 205
diff changeset
   353
        t model:m.
128
claus
parents: 121
diff changeset
   354
377
ee53da05e265 image example
ca
parents: 205
diff changeset
   355
        t := Toggle label:'or here' in:v.
ee53da05e265 image example
ca
parents: 205
diff changeset
   356
        t origin:10 @ 50.
ee53da05e265 image example
ca
parents: 205
diff changeset
   357
        t model:m.
ee53da05e265 image example
ca
parents: 205
diff changeset
   358
        v open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   359
                                                                        [exEnd]
22
ac872628ef2d *** empty log message ***
claus
parents: 7
diff changeset
   360
"
ac872628ef2d *** empty log message ***
claus
parents: 7
diff changeset
   361
! !
ac872628ef2d *** empty log message ***
claus
parents: 7
diff changeset
   362
119
claus
parents: 105
diff changeset
   363
!Toggle class methodsFor:'defaults'!
claus
parents: 105
diff changeset
   364
claus
parents: 105
diff changeset
   365
updateStyleCache
441
e170bca66a78 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 378
diff changeset
   366
    "extract values from the styleSheet and cache them in class variables"
e170bca66a78 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 378
diff changeset
   367
1353
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1083
diff changeset
   368
    <resource: #style (#'toggle.showLamp'
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1083
diff changeset
   369
                       #'toggle.lampColor')>
441
e170bca66a78 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 378
diff changeset
   370
1873
6a4a05b093bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1553
diff changeset
   371
    DefaultShowLamp := StyleSheet at:#'toggle.showLamp' default:false.
6a4a05b093bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1553
diff changeset
   372
    DefaultLampColor := StyleSheet colorAt:#'toggle.lampColor' default:Color yellow.
1385
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   373
    LampInset := 1 "2".
441
e170bca66a78 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 378
diff changeset
   374
1385
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   375
    "Modified: / 3.11.1997 / 11:42:19 / cg"
119
claus
parents: 105
diff changeset
   376
! !
claus
parents: 105
diff changeset
   377
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   378
!Toggle methodsFor:'accessing-look'!
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   379
1044
fb7a15fa51dc fetch models value when model changes
ca
parents: 1020
diff changeset
   380
lampColor
fb7a15fa51dc fetch models value when model changes
ca
parents: 1020
diff changeset
   381
    "returns the color of the toggle-lamp"
fb7a15fa51dc fetch models value when model changes
ca
parents: 1020
diff changeset
   382
fb7a15fa51dc fetch models value when model changes
ca
parents: 1020
diff changeset
   383
    ^ lampColor
fb7a15fa51dc fetch models value when model changes
ca
parents: 1020
diff changeset
   384
!
fb7a15fa51dc fetch models value when model changes
ca
parents: 1020
diff changeset
   385
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   386
lampColor:aColor
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   387
    "change the color of the toggle-lamp"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   388
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   389
    lampColor := aColor.
993
51cce445b5d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
   390
    shown ifTrue:[
51cce445b5d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
   391
        (showLamp and:[controller pressed]) ifTrue:[
1553
a89b36bd0fd7 redrawNow, when lampColor changes.
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   392
            self invalidateRepairNow:true
993
51cce445b5d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
   393
        ]
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   394
    ]
711
c830bb66598b use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
   395
1553
a89b36bd0fd7 redrawNow, when lampColor changes.
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   396
    "Modified: / 6.6.1998 / 19:32:50 / cg"
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   397
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   398
5241
a994c267e55e class: Toggle
Claus Gittinger <cg@exept.de>
parents: 4919
diff changeset
   399
lampHeight
a994c267e55e class: Toggle
Claus Gittinger <cg@exept.de>
parents: 4919
diff changeset
   400
    ^ lampHeight
a994c267e55e class: Toggle
Claus Gittinger <cg@exept.de>
parents: 4919
diff changeset
   401
!
a994c267e55e class: Toggle
Claus Gittinger <cg@exept.de>
parents: 4919
diff changeset
   402
2957
b6452e647ee1 *** empty log message ***
werner
parents: 2504
diff changeset
   403
lampHeight:something
b6452e647ee1 *** empty log message ***
werner
parents: 2504
diff changeset
   404
    lampHeight := something.
b6452e647ee1 *** empty log message ***
werner
parents: 2504
diff changeset
   405
!
b6452e647ee1 *** empty log message ***
werner
parents: 2504
diff changeset
   406
5241
a994c267e55e class: Toggle
Claus Gittinger <cg@exept.de>
parents: 4919
diff changeset
   407
lampWidth
a994c267e55e class: Toggle
Claus Gittinger <cg@exept.de>
parents: 4919
diff changeset
   408
    ^ lampWidth 
a994c267e55e class: Toggle
Claus Gittinger <cg@exept.de>
parents: 4919
diff changeset
   409
!
a994c267e55e class: Toggle
Claus Gittinger <cg@exept.de>
parents: 4919
diff changeset
   410
2957
b6452e647ee1 *** empty log message ***
werner
parents: 2504
diff changeset
   411
lampWidth: something
b6452e647ee1 *** empty log message ***
werner
parents: 2504
diff changeset
   412
    lampWidth := something
b6452e647ee1 *** empty log message ***
werner
parents: 2504
diff changeset
   413
!
b6452e647ee1 *** empty log message ***
werner
parents: 2504
diff changeset
   414
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   415
showLamp
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   416
    "return true, if I show a lamp"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   417
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   418
    ^ showLamp
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   419
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   420
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   421
showLamp:aBoolean
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   422
    "enable/disable drawing of the lamp"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   423
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   424
    showLamp ~~ aBoolean ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   425
	showLamp := aBoolean.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   426
	self computeLabelSize.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   427
	fixSize ifFalse:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   428
	    self resize
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   429
	]
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   430
    ]
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   431
! !
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   432
1044
fb7a15fa51dc fetch models value when model changes
ca
parents: 1020
diff changeset
   433
!Toggle methodsFor:'accessing-mvc'!
fb7a15fa51dc fetch models value when model changes
ca
parents: 1020
diff changeset
   434
fb7a15fa51dc fetch models value when model changes
ca
parents: 1020
diff changeset
   435
model:aModel
fb7a15fa51dc fetch models value when model changes
ca
parents: 1020
diff changeset
   436
    super model:aModel.
1083
13e64cc1c493 fetch models value when a model is assigned;
Claus Gittinger <cg@exept.de>
parents: 1044
diff changeset
   437
    self getValueFromModel.
1044
fb7a15fa51dc fetch models value when model changes
ca
parents: 1020
diff changeset
   438
1083
13e64cc1c493 fetch models value when a model is assigned;
Claus Gittinger <cg@exept.de>
parents: 1044
diff changeset
   439
    "Modified: 28.2.1997 / 19:09:58 / cg"
1044
fb7a15fa51dc fetch models value when model changes
ca
parents: 1020
diff changeset
   440
! !
fb7a15fa51dc fetch models value when model changes
ca
parents: 1020
diff changeset
   441
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   442
!Toggle methodsFor:'change & update'!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   443
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   444
update:something with:parameter from:changedObject
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   445
    something == aspectMsg ifTrue:[
1470
01dc216e9cee revised for the docu
tz
parents: 1464
diff changeset
   446
        self getValueFromModel.
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   447
    ].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   448
    super update:something with:parameter from:changedObject
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   449
! !
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   450
22
ac872628ef2d *** empty log message ***
claus
parents: 7
diff changeset
   451
!Toggle methodsFor:'initialization'!
ac872628ef2d *** empty log message ***
claus
parents: 7
diff changeset
   452
105
3d064ba4a0cc *** empty log message ***
claus
parents: 95
diff changeset
   453
defaultControllerClass
3d064ba4a0cc *** empty log message ***
claus
parents: 95
diff changeset
   454
    ^ ToggleController
3d064ba4a0cc *** empty log message ***
claus
parents: 95
diff changeset
   455
!
3d064ba4a0cc *** empty log message ***
claus
parents: 95
diff changeset
   456
936
0e8811726930 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   457
fetchDeviceResources
0e8811726930 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   458
    "fetch device colors, to avoid reallocation at redraw time"
0e8811726930 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   459
0e8811726930 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   460
    super fetchDeviceResources.
0e8811726930 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   461
5630
3039e6bec250 device access
Claus Gittinger <cg@exept.de>
parents: 5241
diff changeset
   462
    lampColor notNil ifTrue:[lampColor := lampColor onDevice:device].
936
0e8811726930 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   463
0e8811726930 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   464
    "Created: 13.1.1997 / 23:46:31 / cg"
0e8811726930 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   465
!
0e8811726930 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   466
22
ac872628ef2d *** empty log message ***
claus
parents: 7
diff changeset
   467
initStyle
966
824e0ecc0e6f comments
Claus Gittinger <cg@exept.de>
parents: 936
diff changeset
   468
    "setup viewStyle specifics"
824e0ecc0e6f comments
Claus Gittinger <cg@exept.de>
parents: 936
diff changeset
   469
3262
46408c76531b resource directive
Claus Gittinger <cg@exept.de>
parents: 2964
diff changeset
   470
    <resource: #style (#'toggle.lampWidthMM' 
46408c76531b resource directive
Claus Gittinger <cg@exept.de>
parents: 2964
diff changeset
   471
                       #'toggle.lampHeightMM'
46408c76531b resource directive
Claus Gittinger <cg@exept.de>
parents: 2964
diff changeset
   472
                       #'toggle.activeLevel'
46408c76531b resource directive
Claus Gittinger <cg@exept.de>
parents: 2964
diff changeset
   473
                       #'toggle.passiveLevel'
46408c76531b resource directive
Claus Gittinger <cg@exept.de>
parents: 2964
diff changeset
   474
                       #'toggle.activeForegroundColor'
46408c76531b resource directive
Claus Gittinger <cg@exept.de>
parents: 2964
diff changeset
   475
                       #'toggle.activeBackgroundColor'
46408c76531b resource directive
Claus Gittinger <cg@exept.de>
parents: 2964
diff changeset
   476
                       #'toggle.foregroundColor'
46408c76531b resource directive
Claus Gittinger <cg@exept.de>
parents: 2964
diff changeset
   477
                       #'toggle.backgroundColor'
46408c76531b resource directive
Claus Gittinger <cg@exept.de>
parents: 2964
diff changeset
   478
                      )>
46408c76531b resource directive
Claus Gittinger <cg@exept.de>
parents: 2964
diff changeset
   479
1874
6ff31b38d752 added extra toggle.foreground and toggle.background styles
Claus Gittinger <cg@exept.de>
parents: 1873
diff changeset
   480
    |mm fg bg|
1385
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   481
22
ac872628ef2d *** empty log message ***
claus
parents: 7
diff changeset
   482
    super initStyle.
ac872628ef2d *** empty log message ***
claus
parents: 7
diff changeset
   483
119
claus
parents: 105
diff changeset
   484
    showLamp := DefaultShowLamp.
22
ac872628ef2d *** empty log message ***
claus
parents: 7
diff changeset
   485
    showLamp ifTrue:[
936
0e8811726930 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   486
        onLevel := offLevel.
22
ac872628ef2d *** empty log message ***
claus
parents: 7
diff changeset
   487
5954
a39c4c036662 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5953
diff changeset
   488
        "don't know, if I like this ..."
936
0e8811726930 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   489
        "
0e8811726930 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   490
        activeBgColor := bgColor
0e8811726930 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   491
        "
22
ac872628ef2d *** empty log message ***
claus
parents: 7
diff changeset
   492
    ].
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   493
936
0e8811726930 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   494
    lampColor := DefaultLampColor.
3262
46408c76531b resource directive
Claus Gittinger <cg@exept.de>
parents: 2964
diff changeset
   495
    mm := styleSheet at:#'toggle.lampWidthMM' default:1.5.
5630
3039e6bec250 device access
Claus Gittinger <cg@exept.de>
parents: 5241
diff changeset
   496
    lampWidth := (device horizontalPixelPerMillimeter * mm) rounded.
3262
46408c76531b resource directive
Claus Gittinger <cg@exept.de>
parents: 2964
diff changeset
   497
    mm := styleSheet at:#'toggle.lampHeightMM' default:3.0.
5630
3039e6bec250 device access
Claus Gittinger <cg@exept.de>
parents: 5241
diff changeset
   498
    lampHeight := (device verticalPixelPerMillimeter * mm) rounded.
936
0e8811726930 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   499
1876
d229519bc782 more style options
Claus Gittinger <cg@exept.de>
parents: 1874
diff changeset
   500
    onLevel := styleSheet at:#'toggle.activeLevel' default:onLevel.
d229519bc782 more style options
Claus Gittinger <cg@exept.de>
parents: 1874
diff changeset
   501
    offLevel := styleSheet at:#'toggle.passiveLevel' default:offLevel.
d229519bc782 more style options
Claus Gittinger <cg@exept.de>
parents: 1874
diff changeset
   502
d229519bc782 more style options
Claus Gittinger <cg@exept.de>
parents: 1874
diff changeset
   503
    fg := styleSheet colorAt:#'toggle.activeForegroundColor'.
1874
6ff31b38d752 added extra toggle.foreground and toggle.background styles
Claus Gittinger <cg@exept.de>
parents: 1873
diff changeset
   504
    fg notNil ifTrue:[
1876
d229519bc782 more style options
Claus Gittinger <cg@exept.de>
parents: 1874
diff changeset
   505
        activeFgColor := fg.
d229519bc782 more style options
Claus Gittinger <cg@exept.de>
parents: 1874
diff changeset
   506
    ].
d229519bc782 more style options
Claus Gittinger <cg@exept.de>
parents: 1874
diff changeset
   507
    bg := styleSheet colorAt:#'toggle.activeBackgroundColor'.
d229519bc782 more style options
Claus Gittinger <cg@exept.de>
parents: 1874
diff changeset
   508
    bg notNil ifTrue:[
d229519bc782 more style options
Claus Gittinger <cg@exept.de>
parents: 1874
diff changeset
   509
        activeBgColor := bg.
1874
6ff31b38d752 added extra toggle.foreground and toggle.background styles
Claus Gittinger <cg@exept.de>
parents: 1873
diff changeset
   510
    ].
6ff31b38d752 added extra toggle.foreground and toggle.background styles
Claus Gittinger <cg@exept.de>
parents: 1873
diff changeset
   511
1876
d229519bc782 more style options
Claus Gittinger <cg@exept.de>
parents: 1874
diff changeset
   512
    fg := styleSheet colorAt:#'toggle.foregroundColor'.
d229519bc782 more style options
Claus Gittinger <cg@exept.de>
parents: 1874
diff changeset
   513
    fg notNil ifTrue:[
d229519bc782 more style options
Claus Gittinger <cg@exept.de>
parents: 1874
diff changeset
   514
        self foregroundColor:fg.
d229519bc782 more style options
Claus Gittinger <cg@exept.de>
parents: 1874
diff changeset
   515
    ].
d229519bc782 more style options
Claus Gittinger <cg@exept.de>
parents: 1874
diff changeset
   516
d229519bc782 more style options
Claus Gittinger <cg@exept.de>
parents: 1874
diff changeset
   517
    bg := styleSheet colorAt:#'toggle.backgroundColor'.
1873
6a4a05b093bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1553
diff changeset
   518
    bg notNil ifTrue:[
1876
d229519bc782 more style options
Claus Gittinger <cg@exept.de>
parents: 1874
diff changeset
   519
        self backgroundColor:bg.
5630
3039e6bec250 device access
Claus Gittinger <cg@exept.de>
parents: 5241
diff changeset
   520
        shadowColor := (bg averageColorIn:(0@0 corner:7@7)) darkened onDevice:device.
3039e6bec250 device access
Claus Gittinger <cg@exept.de>
parents: 5241
diff changeset
   521
        lightColor := (bg averageColorIn:(0@0 corner:7@7)) lightened onDevice:device.
1873
6a4a05b093bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1553
diff changeset
   522
    ].
6a4a05b093bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1553
diff changeset
   523
1385
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   524
    "Modified: / 3.11.1997 / 02:22:02 / cg"
22
ac872628ef2d *** empty log message ***
claus
parents: 7
diff changeset
   525
! !
ac872628ef2d *** empty log message ***
claus
parents: 7
diff changeset
   526
ac872628ef2d *** empty log message ***
claus
parents: 7
diff changeset
   527
!Toggle methodsFor:'private'!
ac872628ef2d *** empty log message ***
claus
parents: 7
diff changeset
   528
ac872628ef2d *** empty log message ***
claus
parents: 7
diff changeset
   529
computeLabelOrigin
ac872628ef2d *** empty log message ***
claus
parents: 7
diff changeset
   530
    "compute the origin of the form/text.
ac872628ef2d *** empty log message ***
claus
parents: 7
diff changeset
   531
     redefined to move label to the right if there is a lamp."
ac872628ef2d *** empty log message ***
claus
parents: 7
diff changeset
   532
ac872628ef2d *** empty log message ***
claus
parents: 7
diff changeset
   533
    super computeLabelOrigin.
ac872628ef2d *** empty log message ***
claus
parents: 7
diff changeset
   534
    showLamp ifTrue:[
1385
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   535
        labelOriginX := labelOriginX + hSpace + (self lampImageWidth) + hSpace.
22
ac872628ef2d *** empty log message ***
claus
parents: 7
diff changeset
   536
    ]
1385
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   537
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   538
    "Modified: / 3.11.1997 / 14:27:03 / cg"
22
ac872628ef2d *** empty log message ***
claus
parents: 7
diff changeset
   539
!
ac872628ef2d *** empty log message ***
claus
parents: 7
diff changeset
   540
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   541
getValueFromModel
1464
079d8a07b19c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1385
diff changeset
   542
    "fetch my boolean value from the model (if there is a model around)
079d8a07b19c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1385
diff changeset
   543
     by sending it the aspectMessage, and update my look as required" 
079d8a07b19c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1385
diff changeset
   544
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   545
    |val|
121
claus
parents: 119
diff changeset
   546
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   547
    (model notNil and:[aspectMsg notNil]) ifTrue:[
2963
14df9998d682 *** empty log message ***
werner
parents: 2957
diff changeset
   548
        aspectMsg == #value ifTrue:[
14df9998d682 *** empty log message ***
werner
parents: 2957
diff changeset
   549
            val := model value   "/ faster call
14df9998d682 *** empty log message ***
werner
parents: 2957
diff changeset
   550
        ] ifFalse:[
14df9998d682 *** empty log message ***
werner
parents: 2957
diff changeset
   551
            val := model perform:aspectMsg withOptionalArgument:self.
14df9998d682 *** empty log message ***
werner
parents: 2957
diff changeset
   552
        ].
3571
4739ded1737d do not use asBoolean
Claus Gittinger <cg@exept.de>
parents: 3262
diff changeset
   553
        (val ? false) ifTrue:[  "allowing nil - treat as false"
1464
079d8a07b19c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1385
diff changeset
   554
            self turnOn
079d8a07b19c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1385
diff changeset
   555
        ] ifFalse:[
079d8a07b19c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1385
diff changeset
   556
            self turnOff
079d8a07b19c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1385
diff changeset
   557
        ].
121
claus
parents: 119
diff changeset
   558
    ].
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   559
1464
079d8a07b19c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1385
diff changeset
   560
    "Created: / 14.11.1995 / 21:08:43 / cg"
2167
647f8139f594 tuned #value-sending
Claus Gittinger <cg@exept.de>
parents: 1987
diff changeset
   561
    "Modified: / 1.3.2000 / 15:14:49 / cg"
1385
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   562
!
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   563
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   564
lampImageHeight
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   565
    ^ lampHeight
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   566
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   567
    "Created: / 3.11.1997 / 14:24:47 / cg"
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   568
!
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   569
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   570
lampImageWidth
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   571
    ^ lampWidth
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   572
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   573
    "Created: / 3.11.1997 / 14:25:35 / cg"
4001
12dc99eb1717 computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3761
diff changeset
   574
!
12dc99eb1717 computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3761
diff changeset
   575
12dc99eb1717 computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3761
diff changeset
   576
rawLabelSizeOf:aLogo
12dc99eb1717 computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3761
diff changeset
   577
    "compute the extent needed to hold the label plus the lamp"
12dc99eb1717 computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3761
diff changeset
   578
12dc99eb1717 computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3761
diff changeset
   579
    |ext|
12dc99eb1717 computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3761
diff changeset
   580
12dc99eb1717 computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3761
diff changeset
   581
    ext := super rawLabelSizeOf:aLogo.
12dc99eb1717 computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3761
diff changeset
   582
    showLamp ifTrue:[
12dc99eb1717 computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3761
diff changeset
   583
        ^ (ext x + hSpace + (self lampImageWidth) + hSpace)
12dc99eb1717 computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3761
diff changeset
   584
          @
12dc99eb1717 computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3761
diff changeset
   585
          (ext y max: self lampImageHeight)
12dc99eb1717 computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3761
diff changeset
   586
    ].
12dc99eb1717 computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3761
diff changeset
   587
    ^ ext
12dc99eb1717 computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3761
diff changeset
   588
12dc99eb1717 computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3761
diff changeset
   589
    "Modified: / 3.11.1997 / 14:26:54 / cg"
121
claus
parents: 119
diff changeset
   590
! !
claus
parents: 119
diff changeset
   591
105
3d064ba4a0cc *** empty log message ***
claus
parents: 95
diff changeset
   592
!Toggle methodsFor:'redrawing'!
3d064ba4a0cc *** empty log message ***
claus
parents: 95
diff changeset
   593
1385
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   594
drawToggleImage
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   595
    "drawing of the lamp is done here."
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   596
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   597
    |x y clr l2|
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   598
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   599
    showLamp ifTrue:[
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   600
        x := hSpace + margin.
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   601
        y := (height - self lampImageHeight) // 2.
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   602
        self 
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   603
            drawEdgesForX:x y:y 
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   604
            width:(self lampImageWidth) 
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   605
            height:(self lampImageHeight)
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   606
            level:-1.
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   607
        controller pressed ifTrue:[
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   608
            clr := lampColor.
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   609
        ] ifFalse:[
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   610
            clr := bgColor.
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   611
        ].
6060
fcd81f4fe76c #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5954
diff changeset
   612
        gc paint:clr.
1385
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   613
        l2 := LampInset*2.
6060
fcd81f4fe76c #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5954
diff changeset
   614
        gc
1385
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   615
            fillRectangleX:x+LampInset y:y+LampInset 
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   616
            width:(self lampImageWidth) - l2 
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   617
            height:(self lampImageHeight) - l2
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   618
    ]
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   619
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   620
    "Created: / 3.11.1997 / 12:12:07 / cg"
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   621
    "Modified: / 3.11.1997 / 14:26:33 / cg"
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   622
!
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   623
105
3d064ba4a0cc *** empty log message ***
claus
parents: 95
diff changeset
   624
drawWith:fg and:bg
3d064ba4a0cc *** empty log message ***
claus
parents: 95
diff changeset
   625
    "redraw myself with fg/bg. Use super to draw the label, 
3d064ba4a0cc *** empty log message ***
claus
parents: 95
diff changeset
   626
     drawing of the lamp is done here."
3d064ba4a0cc *** empty log message ***
claus
parents: 95
diff changeset
   627
1385
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   628
    shown ifFalse:[^ self].
6060
fcd81f4fe76c #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5954
diff changeset
   629
    
105
3d064ba4a0cc *** empty log message ***
claus
parents: 95
diff changeset
   630
    super drawWith:fg and:bg.   "this draws the text"
3d064ba4a0cc *** empty log message ***
claus
parents: 95
diff changeset
   631
1385
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   632
    self drawToggleImage.
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   633
691d891fa440 flixiblized for better radioButton
Claus Gittinger <cg@exept.de>
parents: 1353
diff changeset
   634
    "Modified: / 3.11.1997 / 13:19:32 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 95
diff changeset
   635
! !
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   636
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   637
!Toggle class methodsFor:'documentation'!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   638
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   639
version
5630
3039e6bec250 device access
Claus Gittinger <cg@exept.de>
parents: 5241
diff changeset
   640
    ^ '$Header$'
4001
12dc99eb1717 computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3761
diff changeset
   641
!
12dc99eb1717 computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3761
diff changeset
   642
12dc99eb1717 computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3761
diff changeset
   643
version_CVS
5630
3039e6bec250 device access
Claus Gittinger <cg@exept.de>
parents: 5241
diff changeset
   644
    ^ '$Header$'
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   645
! !
4919
8b1ff4b1354a class: Toggle
Stefan Vogel <sv@exept.de>
parents: 4006
diff changeset
   646