author | ca |
Tue, 25 Feb 1997 14:23:40 +0100 | |
changeset 1044 | fb7a15fa51dc |
parent 1020 | e48ca624b904 |
child 1083 | 13e64cc1c493 |
permissions | -rw-r--r-- |
0 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
59 | 3 |
All Rights Reserved |
0 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
Button subclass:#Toggle |
|
377 | 14 |
instanceVariableNames:'showLamp lampColor lampWidth lampHeight' |
15 |
classVariableNames:'DefaultShowLamp DefaultLampColor' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'Views-Interactors' |
|
0 | 18 |
! |
19 |
||
22 | 20 |
!Toggle class methodsFor:'documentation'! |
21 |
||
38 | 22 |
copyright |
23 |
" |
|
24 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
59 | 25 |
All Rights Reserved |
38 | 26 |
|
27 |
This software is furnished under a license and may be used |
|
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
35 |
||
22 | 36 |
documentation |
37 |
" |
|
128 | 38 |
this button changes state whenever clicked upon and stays down (pressed) |
39 |
until clicked again. All the main action is in Button and the controller |
|
40 |
(ToggleController). |
|
38 | 41 |
|
42 |
The toggle may optionally display a little kind-of-lamp (or LED), which |
|
43 |
is turned on when the toggle is pressed. (i.e. as in the Interviews toolkit). |
|
44 |
||
45 |
whenever the Toggle changes its change, it will evaluate one of |
|
46 |
pressAction or releaseAction. |
|
47 |
||
48 |
For ST-80 compatibility, if the model is nonNil, this one gets a new |
|
128 | 49 |
value and is sent a changed message. Also, the toggle will follow changes |
50 |
in the model and update its display as appropriate. |
|
38 | 51 |
If nonNil, the model is supposed to be a ValueHolder holding true or false. |
52 |
||
53 |
||
585 | 54 |
[instance variables:] |
55 |
showLamp <Boolean> true if a lamp should be displayed |
|
56 |
lampColor <Color> color of the lamp |
|
57 |
lampWidth <Integer> width of the lamp in pixel |
|
58 |
lampHeight <Integer> height of the lamp in pixel |
|
119 | 59 |
|
585 | 60 |
[styleSheet values:] |
61 |
toggleShowLamp <Boolean> if true, a lamp is shown; default:false. |
|
62 |
toggleLampColor <Color> lamps color; default:yellow. |
|
63 |
||
64 |
[author:] |
|
65 |
Claus Gittinger |
|
609 | 66 |
|
67 |
[see also:] |
|
68 |
Button RadioButton |
|
69 |
( introduction to view programming :html: programming/viewintro.html#INTER_TOGGLES ) |
|
70 |
||
71 |
||
63 | 72 |
" |
73 |
! |
|
38 | 74 |
|
63 | 75 |
examples |
76 |
" |
|
38 | 77 |
Examples: |
128 | 78 |
Try all, to see what is possible. |
377 | 79 |
(notice, that these examples are meant to show what can be done; |
80 |
usually, all style-related stuff is preinitialized - you should not |
|
81 |
normally play around with onLevel, offLevel, showLamp: etc) |
|
38 | 82 |
|
128 | 83 |
|
38 | 84 |
simple: |
593 | 85 |
[exBegin] |
377 | 86 |
|v t| |
38 | 87 |
|
377 | 88 |
v := StandardSystemView new extent:200@200. |
89 |
t := Toggle label:'press here' in:v. |
|
90 |
t origin:10 @ 10. |
|
655 | 91 |
t action:[:value | Transcript show:'toggle state: '; showCR:value.]. |
377 | 92 |
v open |
593 | 93 |
[exEnd] |
119 | 94 |
|
128 | 95 |
|
119 | 96 |
separate press/release actions: |
593 | 97 |
[exBegin] |
377 | 98 |
|v t| |
119 | 99 |
|
377 | 100 |
v := StandardSystemView new extent:200@200. |
101 |
t := Toggle label:'press here' in:v. |
|
102 |
t origin:10 @ 10. |
|
655 | 103 |
t pressAction:[Transcript showCR:'toggle pressed'.]. |
104 |
t releaseAction:[Transcript showCR:'toggle released'.]. |
|
377 | 105 |
v open |
593 | 106 |
[exEnd] |
38 | 107 |
|
128 | 108 |
|
38 | 109 |
changing logo: |
593 | 110 |
[exBegin] |
377 | 111 |
|v t| |
112 |
||
113 |
v := StandardSystemView new extent:200@200. |
|
114 |
t := Toggle label:'eat me' in:v. |
|
115 |
t origin:10 @ 10. |
|
655 | 116 |
t pressAction:[Transcript showCR:'smaller'. t label:'drink me']. |
117 |
t releaseAction:[Transcript showCR:'larger'. t label:'eat me']. |
|
377 | 118 |
v open |
593 | 119 |
[exEnd] |
377 | 120 |
|
121 |
||
378 | 122 |
changing logo: |
593 | 123 |
[exBegin] |
378 | 124 |
|v t| |
125 |
||
126 |
v := StandardSystemView new extent:200@200. |
|
127 |
t := Toggle in:v. |
|
128 |
t logo:(Form width:16 height:14 fromArray:#( |
|
129 |
2r00000000 2r00000000 |
|
130 |
2r00000000 2r00000000 |
|
131 |
2r00000000 2r00000000 |
|
132 |
2r00000111 2r11100000 |
|
133 |
2r00001100 2r00000000 |
|
134 |
2r00011000 2r00000000 |
|
135 |
2r00011000 2r00000000 |
|
136 |
2r00011000 2r00000000 |
|
137 |
2r00011000 2r00000000 |
|
138 |
2r00001100 2r00000000 |
|
139 |
2r00000111 2r11100000 |
|
140 |
2r00000000 2r00000000 |
|
141 |
2r00000000 2r00000000 |
|
142 |
2r00000000 2r00000000)). |
|
143 |
t origin:10 @ 10. |
|
144 |
v open |
|
593 | 145 |
[exEnd] |
378 | 146 |
|
147 |
||
377 | 148 |
uhh - changing logos and getting bg-colors from the image: |
593 | 149 |
[exBegin] |
377 | 150 |
|v t i| |
151 |
||
152 |
v := StandardSystemView new extent:200@200. |
|
153 |
t := Toggle in:v. |
|
154 |
t origin:10 @ 10. |
|
155 |
t showLamp:false. |
|
156 |
t activeLogo:(i := Image fromFile:'red-ball.gif'). |
|
157 |
t passiveLogo:(Image fromFile:'green-ball.gif'). |
|
158 |
t backgroundColor:(i at:0@0). |
|
159 |
t enteredBackgroundColor:(t backgroundColor). |
|
160 |
t activeBackgroundColor:(t backgroundColor). |
|
161 |
v open |
|
593 | 162 |
[exEnd] |
38 | 163 |
|
128 | 164 |
|
38 | 165 |
changing logo and freezing size (looks better): |
593 | 166 |
[exBegin] |
377 | 167 |
|v t| |
38 | 168 |
|
377 | 169 |
v := StandardSystemView new extent:200@200. |
170 |
'create with large logo; freeze; change to small logo'. |
|
171 |
t := Toggle label:'drink me' in:v. |
|
172 |
t sizeFixed:true. |
|
173 |
t label:'eat me'. |
|
38 | 174 |
|
377 | 175 |
t origin:10 @ 10. |
655 | 176 |
t pressAction:[Transcript showCR:'smaller'. t label:'drink me']. |
177 |
t releaseAction:[Transcript showCR:'larger'. t label:'eat me']. |
|
377 | 178 |
v open |
593 | 179 |
[exEnd] |
38 | 180 |
|
128 | 181 |
|
119 | 182 |
adding a lamp (in some view styles, this is the default anyway): |
593 | 183 |
[exBegin] |
377 | 184 |
|v t| |
38 | 185 |
|
377 | 186 |
v := StandardSystemView new extent:200@200. |
187 |
t := Toggle label:'off' in:v. |
|
188 |
t showLamp:true. |
|
189 |
t origin:10 @ 10. |
|
655 | 190 |
t pressAction:[Transcript showCR:'on'. t label:'on']. |
191 |
t releaseAction:[Transcript showCR:'off'. t label:'off']. |
|
377 | 192 |
v open |
593 | 193 |
[exEnd] |
38 | 194 |
|
128 | 195 |
|
119 | 196 |
changing lamps color: |
593 | 197 |
[exBegin] |
377 | 198 |
|v t| |
38 | 199 |
|
377 | 200 |
v := StandardSystemView new extent:200@200. |
201 |
t := Toggle label:'off' in:v. |
|
202 |
t showLamp:true. |
|
203 |
t lampColor:Color red. |
|
204 |
t origin:10 @ 10. |
|
655 | 205 |
t pressAction:[Transcript showCR:'on'. t label:'on'.]. |
206 |
t releaseAction:[Transcript showCR:'off'. t label:'off'.]. |
|
377 | 207 |
v open |
593 | 208 |
[exEnd] |
119 | 209 |
|
128 | 210 |
|
119 | 211 |
lamp only - no '3D going-in' (this is the default with IRIS style) |
593 | 212 |
[exBegin] |
377 | 213 |
|v t| |
119 | 214 |
|
377 | 215 |
v := StandardSystemView new extent:200@200. |
216 |
t := Toggle label:'off' in:v. |
|
217 |
t showLamp:true. |
|
218 |
t onLevel:(t offLevel). |
|
219 |
t origin:10 @ 10. |
|
655 | 220 |
t pressAction:[Transcript showCR:'on'. t label:'on']. |
221 |
t releaseAction:[Transcript showCR:'off'. t label:'off']. |
|
377 | 222 |
v open |
593 | 223 |
[exEnd] |
38 | 224 |
|
128 | 225 |
|
38 | 226 |
lamp and freezing size of the label (looks better): |
593 | 227 |
[exBegin] |
377 | 228 |
|v t| |
38 | 229 |
|
377 | 230 |
v := StandardSystemView new extent:200@200. |
231 |
t := Toggle label:'off' in:v. |
|
232 |
t showLamp:true. |
|
233 |
t sizeFixed:true. |
|
234 |
t origin:10 @ 10. |
|
655 | 235 |
t pressAction:[Transcript showCR:'on'. t label:'on']. |
236 |
t releaseAction:[Transcript showCR:'off'. t label:'off']. |
|
377 | 237 |
v open |
593 | 238 |
[exEnd] |
38 | 239 |
|
128 | 240 |
|
38 | 241 |
another variation: |
593 | 242 |
[exBegin] |
377 | 243 |
|v t| |
38 | 244 |
|
377 | 245 |
v := StandardSystemView new extent:200@200. |
246 |
t := Toggle label:'off' in:v. |
|
247 |
t showLamp:true. |
|
248 |
t sizeFixed:true. |
|
249 |
t onLevel:(t offLevel). |
|
250 |
t origin:10 @ 10. |
|
655 | 251 |
t pressAction:[Transcript showCR:'on'. t label:'on']. |
252 |
t releaseAction:[Transcript showCR:'off'. t label:'off']. |
|
377 | 253 |
v open |
593 | 254 |
[exEnd] |
38 | 255 |
|
128 | 256 |
|
38 | 257 |
and another one: |
593 | 258 |
[exBegin] |
377 | 259 |
|v t| |
38 | 260 |
|
377 | 261 |
v := StandardSystemView new extent:200@200. |
262 |
t := Toggle label:'off' in:v. |
|
263 |
t showLamp:true. |
|
264 |
t sizeFixed:true. |
|
38 | 265 |
|
377 | 266 |
t showLamp:false. |
267 |
t offLevel:3. |
|
268 |
t onLevel:3. |
|
269 |
t origin:10 @ 10. |
|
655 | 270 |
t pressAction:[Transcript showCR:'on'. t showLamp:true. t label:'on']. |
271 |
t releaseAction:[Transcript showCR:'off'. t showLamp:false. t label:'off']. |
|
377 | 272 |
v open |
593 | 273 |
[exEnd] |
38 | 274 |
|
128 | 275 |
|
38 | 276 |
another font: |
593 | 277 |
[exBegin] |
377 | 278 |
|v t| |
38 | 279 |
|
377 | 280 |
v := StandardSystemView new extent:200@200. |
281 |
t := Toggle label:'off' in:v. |
|
282 |
t font:(Font family:'times' face:'bold' style:'roman' size:24). |
|
283 |
t label:'hello'. |
|
284 |
t origin:10 @ 10. |
|
655 | 285 |
t pressAction:[Transcript showCR:'on'.]. |
286 |
t releaseAction:[Transcript showCR:'off'.]. |
|
377 | 287 |
v open |
593 | 288 |
[exEnd] |
38 | 289 |
|
128 | 290 |
|
38 | 291 |
another font (no, I dont know what it means :-): |
593 | 292 |
[exBegin] |
377 | 293 |
|v t| |
38 | 294 |
|
377 | 295 |
v := StandardSystemView new extent:200@200. |
296 |
t := Toggle label:'off' in:v. |
|
297 |
t font:(Font family:'k14' face:nil style:nil size:nil). |
|
298 |
t label:(TwoByteString with:(Character value:16r3021)). |
|
38 | 299 |
|
377 | 300 |
t origin:10 @ 10. |
655 | 301 |
t pressAction:[Transcript showCR:'on'.]. |
302 |
t releaseAction:[Transcript showCR:'off'.]. |
|
377 | 303 |
v open |
593 | 304 |
[exEnd] |
119 | 305 |
|
128 | 306 |
|
307 |
using a model (look at 'value' in the inspector): |
|
593 | 308 |
[exBegin] |
377 | 309 |
|m v t| |
119 | 310 |
|
377 | 311 |
m := ValueHolder newBoolean. |
312 |
m inspect. |
|
119 | 313 |
|
377 | 314 |
v := StandardSystemView new extent:200@200. |
315 |
t := Toggle label:'press here to change value' in:v. |
|
316 |
t origin:10 @ 10. |
|
317 |
t model:m. |
|
318 |
v open |
|
593 | 319 |
[exEnd] |
119 | 320 |
|
128 | 321 |
|
119 | 322 |
using a model with different changeSelector: |
593 | 323 |
[exBegin] |
377 | 324 |
|m v t| |
119 | 325 |
|
377 | 326 |
m := Plug new. |
655 | 327 |
m respondTo:#setValue1: with:[:value | Transcript show:'value 1 changed to: '; showCR:value]. |
328 |
m respondTo:#setValue2: with:[:value | Transcript show:'value 2 changed to: '; showCR:value]. |
|
119 | 329 |
|
377 | 330 |
v := StandardSystemView new extent:200@200. |
331 |
t := Toggle label:'press here for value1' in:v. |
|
332 |
t origin:10 @ 10. |
|
333 |
t model:m; change:#setValue1:. |
|
334 |
t := Toggle label:'press here for value2' in:v. |
|
335 |
t origin:10 @ 50. |
|
336 |
t model:m; change:#setValue2:. |
|
337 |
v open |
|
593 | 338 |
[exEnd] |
128 | 339 |
|
340 |
||
341 |
two toggles on the same model: |
|
593 | 342 |
[exBegin] |
377 | 343 |
|m v t| |
128 | 344 |
|
377 | 345 |
m := true asValue. |
128 | 346 |
|
377 | 347 |
v := StandardSystemView new extent:200@200. |
348 |
t := Toggle label:'press here' in:v. |
|
349 |
t origin:10 @ 10. |
|
350 |
t model:m. |
|
128 | 351 |
|
377 | 352 |
t := Toggle label:'or here' in:v. |
353 |
t origin:10 @ 50. |
|
354 |
t model:m. |
|
355 |
v open |
|
593 | 356 |
[exEnd] |
22 | 357 |
" |
358 |
! ! |
|
359 |
||
119 | 360 |
!Toggle class methodsFor:'defaults'! |
361 |
||
362 |
updateStyleCache |
|
441
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
378
diff
changeset
|
363 |
"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
|
364 |
|
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
378
diff
changeset
|
365 |
<resource: #style (#toggleShowLamp |
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
378
diff
changeset
|
366 |
#toggleLampColor)> |
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
378
diff
changeset
|
367 |
|
119 | 368 |
DefaultShowLamp := StyleSheet at:'toggleShowLamp' default:false. |
369 |
DefaultLampColor := StyleSheet colorAt:'toggleLampColor' default:Color yellow. |
|
441
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
378
diff
changeset
|
370 |
|
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
378
diff
changeset
|
371 |
"Modified: 1.3.1996 / 13:50:30 / cg" |
119 | 372 |
! ! |
373 |
||
593 | 374 |
!Toggle methodsFor:'accessing-look'! |
205 | 375 |
|
1044 | 376 |
lampColor |
377 |
"returns the color of the toggle-lamp" |
|
378 |
||
379 |
^ lampColor |
|
380 |
! |
|
381 |
||
205 | 382 |
lampColor:aColor |
383 |
"change the color of the toggle-lamp" |
|
384 |
||
385 |
lampColor := aColor. |
|
993 | 386 |
shown ifTrue:[ |
387 |
(showLamp and:[controller pressed]) ifTrue:[ |
|
388 |
self invalidate |
|
389 |
] |
|
205 | 390 |
] |
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
391 |
|
993 | 392 |
"Modified: 8.2.1997 / 15:17:27 / cg" |
205 | 393 |
! |
394 |
||
395 |
showLamp |
|
396 |
"return true, if I show a lamp" |
|
397 |
||
398 |
^ showLamp |
|
399 |
! |
|
400 |
||
401 |
showLamp:aBoolean |
|
402 |
"enable/disable drawing of the lamp" |
|
403 |
||
404 |
showLamp ~~ aBoolean ifTrue:[ |
|
405 |
showLamp := aBoolean. |
|
406 |
self computeLabelSize. |
|
407 |
fixSize ifFalse:[ |
|
408 |
self resize |
|
409 |
] |
|
410 |
] |
|
411 |
! ! |
|
412 |
||
1044 | 413 |
!Toggle methodsFor:'accessing-mvc'! |
414 |
||
415 |
model:aModel |
|
416 |
super model:aModel. |
|
417 |
realized ifTrue:[ |
|
418 |
self getValueFromModel. |
|
419 |
] |
|
420 |
||
421 |
! ! |
|
422 |
||
205 | 423 |
!Toggle methodsFor:'change & update'! |
424 |
||
425 |
update:something with:parameter from:changedObject |
|
426 |
something == aspectMsg ifTrue:[ |
|
427 |
self getValueFromModel. |
|
428 |
^ self |
|
429 |
]. |
|
430 |
super update:something with:parameter from:changedObject |
|
431 |
! ! |
|
432 |
||
22 | 433 |
!Toggle methodsFor:'initialization'! |
434 |
||
105 | 435 |
defaultControllerClass |
436 |
^ ToggleController |
|
437 |
! |
|
438 |
||
936 | 439 |
fetchDeviceResources |
440 |
"fetch device colors, to avoid reallocation at redraw time" |
|
441 |
||
442 |
super fetchDeviceResources. |
|
443 |
||
444 |
lampColor notNil ifTrue:[lampColor := lampColor on:device]. |
|
445 |
||
446 |
"Created: 13.1.1997 / 23:46:31 / cg" |
|
447 |
! |
|
448 |
||
22 | 449 |
initStyle |
966 | 450 |
"setup viewStyle specifics" |
451 |
||
22 | 452 |
super initStyle. |
453 |
||
119 | 454 |
showLamp := DefaultShowLamp. |
22 | 455 |
showLamp ifTrue:[ |
936 | 456 |
onLevel := offLevel. |
22 | 457 |
|
936 | 458 |
"dont know, if I like this ..." |
459 |
" |
|
460 |
activeBgColor := bgColor |
|
461 |
" |
|
22 | 462 |
]. |
38 | 463 |
|
936 | 464 |
lampColor := DefaultLampColor. |
38 | 465 |
lampWidth := (device horizontalPixelPerMillimeter * 1.8) rounded. |
466 |
lampHeight := (device verticalPixelPerMillimeter * 3.5) rounded. |
|
936 | 467 |
|
966 | 468 |
"Modified: 22.1.1997 / 11:57:55 / cg" |
119 | 469 |
! |
470 |
||
471 |
realize |
|
472 |
"/ |
|
473 |
"/ get my initial state from the model (if there is one) |
|
474 |
"/ |
|
475 |
self getValueFromModel. |
|
476 |
super realize |
|
22 | 477 |
! ! |
478 |
||
479 |
!Toggle methodsFor:'private'! |
|
480 |
||
481 |
computeLabelOrigin |
|
482 |
"compute the origin of the form/text. |
|
483 |
redefined to move label to the right if there is a lamp." |
|
484 |
||
485 |
super computeLabelOrigin. |
|
486 |
showLamp ifTrue:[ |
|
59 | 487 |
labelOriginX := labelOriginX + hSpace + lampWidth + hSpace. |
22 | 488 |
] |
489 |
! |
|
490 |
||
491 |
computeLabelSize |
|
492 |
"compute the extent needed to hold the label plus the lamp" |
|
493 |
||
494 |
super computeLabelSize. |
|
495 |
showLamp ifTrue:[ |
|
59 | 496 |
labelWidth := labelWidth + hSpace + lampWidth + hSpace. |
497 |
labelHeight := labelHeight max: lampHeight |
|
22 | 498 |
] |
205 | 499 |
! |
0 | 500 |
|
205 | 501 |
getValueFromModel |
502 |
|val| |
|
121 | 503 |
|
205 | 504 |
(model notNil and:[aspectMsg notNil]) ifTrue:[ |
505 |
aspectMsg numArgs == 0 ifTrue:[ |
|
506 |
val := model perform:aspectMsg |
|
507 |
] ifFalse:[ |
|
508 |
val := model perform:aspectMsg with:self |
|
509 |
]. |
|
510 |
val ifTrue:[ |
|
511 |
self turnOn |
|
512 |
] ifFalse:[ |
|
513 |
self turnOff |
|
514 |
]. |
|
121 | 515 |
]. |
205 | 516 |
|
517 |
"Created: 14.11.1995 / 21:08:43 / cg" |
|
121 | 518 |
! ! |
519 |
||
1020 | 520 |
!Toggle methodsFor:'queries'! |
521 |
||
522 |
preferredExtent |
|
523 |
"return my preferred extent - this is the minimum size I would like to have" |
|
524 |
||
525 |
|pref x y| |
|
526 |
||
527 |
"/ If I have an explicit preferredExtent .. |
|
528 |
||
529 |
preferredExtent notNil ifTrue:[ |
|
530 |
^ preferredExtent |
|
531 |
]. |
|
532 |
||
533 |
pref := super preferredExtent. |
|
534 |
||
535 |
showLamp ifTrue:[ |
|
536 |
"/ add some space for the lamp. |
|
537 |
||
538 |
x := pref x + lampWidth + hSpace. |
|
539 |
y := pref y max:(lampHeight). |
|
540 |
pref := x @ y. |
|
541 |
]. |
|
542 |
^ pref |
|
543 |
||
544 |
"Modified: 18.2.1997 / 13:12:51 / cg" |
|
545 |
! ! |
|
546 |
||
105 | 547 |
!Toggle methodsFor:'redrawing'! |
548 |
||
549 |
drawWith:fg and:bg |
|
550 |
"redraw myself with fg/bg. Use super to draw the label, |
|
551 |
drawing of the lamp is done here." |
|
552 |
||
553 |
|x y clr| |
|
554 |
||
555 |
super drawWith:fg and:bg. "this draws the text" |
|
556 |
||
557 |
showLamp ifTrue:[ |
|
558 |
x := hSpace + margin. |
|
559 |
y := (height - lampHeight) // 2. |
|
560 |
self drawEdgesForX:x y:y width:lampWidth height:lampHeight level:-1. |
|
561 |
controller pressed ifTrue:[ |
|
562 |
clr := lampColor. |
|
563 |
] ifFalse:[ |
|
564 |
clr := bgColor. |
|
565 |
]. |
|
566 |
self paint:clr. |
|
567 |
self fillRectangleX:x+2 y:y+2 width:lampWidth - 4 height:lampHeight - 4 |
|
568 |
] |
|
569 |
! ! |
|
205 | 570 |
|
571 |
!Toggle class methodsFor:'documentation'! |
|
572 |
||
573 |
version |
|
1044 | 574 |
^ '$Header: /cvs/stx/stx/libwidg/Toggle.st,v 1.36 1997-02-25 13:23:40 ca Exp $' |
205 | 575 |
! ! |