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