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