author | Claus Gittinger <cg@exept.de> |
Thu, 03 Feb 2000 18:34:36 +0100 | |
changeset 1675 | 355c448a2570 |
parent 1652 | 311b68620aff |
child 1696 | f1bae6d68ffe |
permissions | -rw-r--r-- |
44 | 1 |
" |
2 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
49 | 3 |
All Rights Reserved |
44 | 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 |
||
14 |
HorizontalPanelView subclass:#CheckBox |
|
112
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
15 |
instanceVariableNames:'toggleView labelView labelForegroundColor |
817 | 16 |
disabledLabelForegroundColor foregroundChannel backgroundChannel' |
320
bf5e928d027a
option to place the toggle at the right.
Claus Gittinger <cg@exept.de>
parents:
318
diff
changeset
|
17 |
classVariableNames:'DefaultLabelForegroundColor DefaultDisabledLabelForegroundColor |
bf5e928d027a
option to place the toggle at the right.
Claus Gittinger <cg@exept.de>
parents:
318
diff
changeset
|
18 |
CheckToggleLeft' |
112
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
19 |
poolDictionaries:'' |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
20 |
category:'Views-Interactors' |
44 | 21 |
! |
22 |
||
273
01541272ce8d
resource spec updated; cache device form
Claus Gittinger <cg@exept.de>
parents:
268
diff
changeset
|
23 |
!CheckBox class methodsFor:'documentation'! |
44 | 24 |
|
100 | 25 |
copyright |
26 |
" |
|
27 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
||
44 | 38 |
! |
39 |
||
40 |
documentation |
|
41 |
" |
|
313 | 42 |
CheckBoxes consist of a checkToggle and a label; |
43 |
if used without a model, its action block is evaluated |
|
44 |
when toggled (see Toggle for more information). |
|
45 |
Otherwise, a valueHolder on a boolean is the preferred model |
|
46 |
(other models are possible - this may required different aspect |
|
47 |
and/or changeMessage settings; make certain to set those before |
|
48 |
a model is assigned, since the toggle fetches the value when |
|
49 |
a new model is assigned.) |
|
155 | 50 |
|
51 |
[author:] |
|
313 | 52 |
Claus Gittinger |
155 | 53 |
|
54 |
[see also:] |
|
313 | 55 |
Button CheckToggle |
56 |
DialogBox |
|
57 |
ValueHolder |
|
44 | 58 |
" |
59 |
! |
|
60 |
||
61 |
examples |
|
62 |
" |
|
188 | 63 |
no-op checkBox without a label: |
313 | 64 |
[exBegin] |
188 | 65 |
|b| |
66 |
||
67 |
b := CheckBox new. |
|
68 |
b open |
|
313 | 69 |
[exEnd] |
188 | 70 |
|
71 |
||
44 | 72 |
no-op checkBox: |
313 | 73 |
[exBegin] |
44 | 74 |
|b| |
75 |
||
76 |
b := CheckBox new. |
|
77 |
b label:'foo'. |
|
78 |
b open |
|
313 | 79 |
[exEnd] |
80 |
||
81 |
||
82 |
combined instance creation & label setup: |
|
83 |
[exBegin] |
|
84 |
|b| |
|
85 |
||
86 |
b := CheckBox label:'foo'. |
|
87 |
b open |
|
88 |
[exEnd] |
|
44 | 89 |
|
90 |
||
56 | 91 |
no-op checkBox, disabled: |
313 | 92 |
[exBegin] |
56 | 93 |
|b| |
94 |
||
313 | 95 |
b := CheckBox label:'foo'. |
56 | 96 |
b disable. |
97 |
b open |
|
313 | 98 |
[exEnd] |
56 | 99 |
|
100 |
||
101 |
changing colors |
|
102 |
(a demo only: it is no good style to fight the styleSheet): |
|
313 | 103 |
[exBegin] |
44 | 104 |
|panel b| |
105 |
||
106 |
panel := VerticalPanelView new. |
|
107 |
||
313 | 108 |
b := CheckBox label:'foo' in:panel. |
44 | 109 |
|
313 | 110 |
b := CheckBox label:'bar' in:panel. |
44 | 111 |
b labelView foregroundColor:Color red. |
112 |
||
313 | 113 |
b := CheckBox label:'baz' in:panel. |
44 | 114 |
b toggleView activeForegroundColor:Color blue. |
115 |
||
116 |
panel open |
|
313 | 117 |
[exEnd] |
44 | 118 |
|
119 |
||
120 |
using action-blocks: |
|
313 | 121 |
[exBegin] |
49 | 122 |
|b| |
44 | 123 |
|
313 | 124 |
b := CheckBox label:'check'. |
184 | 125 |
b action:[:value | Transcript show:'set to: '; showCR:value]. |
44 | 126 |
b open. |
313 | 127 |
[exEnd] |
44 | 128 |
|
129 |
||
49 | 130 |
with a model (default ST-80 behavior, sending #value: to the model): |
131 |
(see changing value in the inspector) |
|
313 | 132 |
[exBegin] |
133 |
|b model| |
|
134 |
||
135 |
model := ValueHolder newBoolean. |
|
136 |
||
137 |
b := CheckBox label:'check'. |
|
138 |
b model:model. |
|
139 |
b open. |
|
140 |
model inspect. |
|
141 |
[exEnd] |
|
142 |
||
143 |
||
144 |
combined instance creation & model setup: |
|
145 |
[exBegin] |
|
49 | 146 |
|b model| |
147 |
||
148 |
model := ValueHolder newBoolean. |
|
149 |
||
313 | 150 |
b := CheckBox label:'check' model:model . |
49 | 151 |
b open. |
152 |
model inspect. |
|
313 | 153 |
[exEnd] |
49 | 154 |
|
56 | 155 |
|
313 | 156 |
with a model and different aspect & changeSelector |
157 |
setting the aspect to nil suppresses fetching the value from the model. |
|
49 | 158 |
(using a plug here, for demonstration only): |
313 | 159 |
[exBegin] |
44 | 160 |
|b model| |
161 |
||
162 |
model := Plug new. |
|
184 | 163 |
model respondTo:#changeCheck: with:[:arg | Transcript showCR:'change to ' , arg printString]. |
313 | 164 |
model respondTo:#value with:[false]. |
44 | 165 |
|
313 | 166 |
b := CheckBox label:'check'. |
167 |
b aspectMessage:nil; model:model; changeMessage:#changeCheck:. |
|
44 | 168 |
b open. |
313 | 169 |
[exEnd] |
44 | 170 |
|
56 | 171 |
|
313 | 172 |
with an enableChannel |
173 |
[exBegin] |
|
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
174 |
|b enaToggle enaHolder| |
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
175 |
|
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
176 |
enaHolder := true asValue. |
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
177 |
|
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
178 |
enaToggle := Toggle label:'enable'. |
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
179 |
enaToggle model:enaHolder. |
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
180 |
enaToggle open. |
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
181 |
|
313 | 182 |
b := CheckBox label:'check'. |
184 | 183 |
b action:[:value | Transcript show:'set to: '; showCR:value]. |
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
184 |
b enableChannel:enaHolder. |
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
185 |
b open. |
313 | 186 |
[exEnd] |
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
187 |
|
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
188 |
|
56 | 189 |
with models, one checkBox disabling the others: |
313 | 190 |
[exBegin] |
56 | 191 |
|dialog translator enableChannel val1 val2 val3 eBox box1 box2 box3| |
192 |
||
193 |
translator := Plug new. |
|
194 |
translator respondTo:#enableDisable |
|
313 | 195 |
with:[ |
196 |
enableChannel value |
|
197 |
ifTrue:[ |
|
198 |
box1 enable. |
|
199 |
box2 enable. |
|
200 |
box3 enable. |
|
201 |
] |
|
202 |
ifFalse:[ |
|
203 |
box1 disable. |
|
204 |
box2 disable. |
|
205 |
box3 disable. |
|
206 |
] |
|
207 |
]. |
|
56 | 208 |
|
209 |
enableChannel := true asValue. |
|
210 |
enableChannel onChangeSend:#enableDisable to:translator. |
|
211 |
val1 := true asValue. |
|
212 |
val2 := false asValue. |
|
213 |
val3 := true asValue. |
|
214 |
||
215 |
dialog := Dialog new. |
|
216 |
dialog addCheckBox:'enable' on:enableChannel. |
|
217 |
dialog addVerticalSpace. |
|
218 |
dialog leftIndent:30. |
|
219 |
box1 := dialog addCheckBox:'value1' on:val1. |
|
220 |
dialog addVerticalSpace. |
|
221 |
box2 := dialog addCheckBox:'value2' on:val2. |
|
222 |
dialog addVerticalSpace. |
|
223 |
box3 := dialog addCheckBox:'value3' on:val3. |
|
224 |
dialog addVerticalSpace. |
|
225 |
dialog addOkButton. |
|
226 |
||
227 |
dialog open. |
|
313 | 228 |
[exEnd] |
56 | 229 |
|
230 |
||
49 | 231 |
multiple checkBoxes on a single model (using different aspects) |
313 | 232 |
[exBegin] |
79 | 233 |
|top panel b model value1 value2| |
49 | 234 |
|
235 |
value1 := true. |
|
236 |
value2 := false. |
|
237 |
model := Plug new. |
|
238 |
model respondTo:#value1 with:[value1]. |
|
239 |
model respondTo:#value1: with:[:val | value1 := val]. |
|
240 |
model respondTo:#value2 with:[value2]. |
|
241 |
model respondTo:#value2: with:[:val | value2 := val]. |
|
242 |
||
243 |
top := DialogBox new. |
|
244 |
top extent:200@300. |
|
245 |
||
246 |
panel := VerticalPanelView new. |
|
247 |
||
248 |
b := CheckBox in:panel. |
|
249 |
b label:'check1'. |
|
313 | 250 |
b aspect:#value1; model:model; changeMessage:#value1:. |
49 | 251 |
|
252 |
b := CheckBox in:panel. |
|
253 |
b label:'check2'. |
|
313 | 254 |
b aspect:#value2; model:model; changeMessage:#value2:. |
49 | 255 |
|
256 |
top addComponent:panel. |
|
257 |
top addAbortButton; addOkButton. |
|
258 |
top openModal. |
|
259 |
||
79 | 260 |
top accepted ifTrue:[ |
313 | 261 |
Transcript show:'value1: '; showCR:model value1. |
262 |
Transcript show:'value2: '; showCR:model value2. |
|
49 | 263 |
] |
313 | 264 |
[exEnd] |
44 | 265 |
" |
266 |
! ! |
|
267 |
||
273
01541272ce8d
resource spec updated; cache device form
Claus Gittinger <cg@exept.de>
parents:
268
diff
changeset
|
268 |
!CheckBox class methodsFor:'instance creation'! |
62 | 269 |
|
76 | 270 |
label:aStringOrImage model:aModel |
271 |
"create & return a new checkBox, on aModel (typically a ValueHolder), |
|
272 |
with aStringOrImage as label." |
|
273 |
||
313 | 274 |
^ (self model:aModel) label:aStringOrImage |
76 | 275 |
|
276 |
"Created: 17.9.1995 / 14:20:58 / claus" |
|
313 | 277 |
"Modified: 28.2.1997 / 19:23:59 / cg" |
56 | 278 |
! ! |
279 |
||
273
01541272ce8d
resource spec updated; cache device form
Claus Gittinger <cg@exept.de>
parents:
268
diff
changeset
|
280 |
!CheckBox class methodsFor:'defaults'! |
112
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
281 |
|
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
282 |
updateStyleCache |
134
049f033265f9
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
119
diff
changeset
|
283 |
"extract values from the styleSheet and cache them in class variables" |
049f033265f9
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
119
diff
changeset
|
284 |
|
566 | 285 |
<resource: #style (#'checkBox.labelForegroundColor' |
286 |
#'checkBox.disabledLabelForegroundColor' |
|
287 |
#'checkBox.toggleLeft')> |
|
134
049f033265f9
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
119
diff
changeset
|
288 |
|
830 | 289 |
DefaultFont := StyleSheet fontAt:'label.font'. |
290 |
DefaultLabelForegroundColor := StyleSheet colorAt:'checkBox.labelForegroundColor'. |
|
566 | 291 |
DefaultDisabledLabelForegroundColor := StyleSheet colorAt:'checkBox.disabledLabelForegroundColor'. |
830 | 292 |
CheckToggleLeft := StyleSheet at:'checkBox.toggleLeft' default:true |
112
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
293 |
|
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
294 |
" |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
295 |
self updateStyleCache |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
296 |
" |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
297 |
|
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
298 |
"Created: 14.12.1995 / 14:47:22 / cg" |
566 | 299 |
"Modified: 20.10.1997 / 13:51:30 / cg" |
112
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
300 |
! ! |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
301 |
|
100 | 302 |
!CheckBox methodsFor:'accessing-behavior'! |
303 |
||
304 |
action:aBlock |
|
155 | 305 |
"set the actionBlock; forwarded to the toggle" |
100 | 306 |
|
307 |
toggleView action:aBlock |
|
155 | 308 |
|
309 |
"Modified: 25.4.1996 / 16:31:19 / cg" |
|
100 | 310 |
! |
311 |
||
299 | 312 |
enabled |
313 |
"return true, if the checkBox is enabled. |
|
314 |
forwarded to toggle" |
|
315 |
||
316 |
^ toggleView enabled. |
|
317 |
! |
|
318 |
||
1297 | 319 |
enabled:aBoolean |
320 |
"enable/diable the checkBox; forwarded to toggle & change labels color" |
|
321 |
||
1505 | 322 |
|clr cursor| |
1297 | 323 |
|
324 |
toggleView enabled:aBoolean. |
|
325 |
||
326 |
aBoolean ifTrue:[ |
|
327 |
clr := labelForegroundColor. |
|
328 |
clr isNil ifTrue:[ clr := labelView foregroundColor ]. |
|
1505 | 329 |
cursor := Cursor hand. |
1297 | 330 |
] ifFalse:[ |
331 |
clr := disabledLabelForegroundColor. |
|
332 |
clr isNil ifTrue:[ clr := toggleView disabledForegroundColor ]. |
|
1505 | 333 |
cursor := Cursor normal. |
1297 | 334 |
]. |
1505 | 335 |
labelView cursor:cursor. |
336 |
self cursor:cursor. |
|
337 |
toggleView cursor:cursor. |
|
1297 | 338 |
labelView foregroundColor:clr. |
339 |
||
340 |
"Modified: / 25.4.1996 / 16:31:40 / cg" |
|
341 |
"Created: / 30.3.1999 / 14:54:48 / stefan" |
|
342 |
! |
|
343 |
||
100 | 344 |
pressAction:aBlock |
155 | 345 |
"set the pressAction; forwarded to the toggle" |
346 |
||
100 | 347 |
toggleView pressAction:aBlock. |
348 |
||
349 |
"Created: 22.9.1995 / 15:54:04 / claus" |
|
155 | 350 |
"Modified: 25.4.1996 / 16:31:52 / cg" |
100 | 351 |
! |
352 |
||
353 |
releaseAction:aBlock |
|
155 | 354 |
"set the releaseAction; forwarded to the toggle" |
355 |
||
100 | 356 |
toggleView releaseAction:aBlock. |
357 |
||
358 |
"Created: 22.9.1995 / 15:54:11 / claus" |
|
155 | 359 |
"Modified: 25.4.1996 / 16:32:00 / cg" |
78 | 360 |
! ! |
361 |
||
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
362 |
!CheckBox methodsFor:'accessing-channels'! |
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
363 |
|
817 | 364 |
backgroundChannel |
365 |
||
366 |
^labelView backgroundChannel |
|
367 |
! |
|
368 |
||
369 |
backgroundChannel:aChannel |
|
370 |
||
371 |
labelView backgroundChannel: (backgroundChannel := aChannel). |
|
1675
355c448a2570
no need for an extra block to send #enableStateChanged
Claus Gittinger <cg@exept.de>
parents:
1652
diff
changeset
|
372 |
aChannel onChangeSend:#enableStateChanged to:self. |
817 | 373 |
! |
374 |
||
164 | 375 |
enableChannel |
376 |
"return a valueHolder for enable/disable" |
|
377 |
||
378 |
^ toggleView enableChannel |
|
379 |
||
380 |
"Created: 30.4.1996 / 15:11:13 / cg" |
|
381 |
! |
|
382 |
||
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
383 |
enableChannel:aChannel |
155 | 384 |
"set the enableChannel" |
385 |
||
119
913df6ba1ccc
immediately change fg color when enableChannel is set
Claus Gittinger <cg@exept.de>
parents:
115
diff
changeset
|
386 |
|wasEnabled| |
913df6ba1ccc
immediately change fg color when enableChannel is set
Claus Gittinger <cg@exept.de>
parents:
115
diff
changeset
|
387 |
|
913df6ba1ccc
immediately change fg color when enableChannel is set
Claus Gittinger <cg@exept.de>
parents:
115
diff
changeset
|
388 |
wasEnabled := toggleView enabled. |
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
389 |
toggleView enableChannel:aChannel. |
1675
355c448a2570
no need for an extra block to send #enableStateChanged
Claus Gittinger <cg@exept.de>
parents:
1652
diff
changeset
|
390 |
aChannel onChangeSend:#enableStateChanged to:self. |
817 | 391 |
|
119
913df6ba1ccc
immediately change fg color when enableChannel is set
Claus Gittinger <cg@exept.de>
parents:
115
diff
changeset
|
392 |
aChannel value ~~ wasEnabled ifTrue:[ |
817 | 393 |
self enableStateChanged |
119
913df6ba1ccc
immediately change fg color when enableChannel is set
Claus Gittinger <cg@exept.de>
parents:
115
diff
changeset
|
394 |
] |
817 | 395 |
! |
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
396 |
|
817 | 397 |
foregroundChannel |
398 |
||
399 |
^labelView foregroundChannel |
|
400 |
! |
|
401 |
||
402 |
foregroundChannel:aChannel |
|
403 |
||
404 |
labelView foregroundChannel: (foregroundChannel := aChannel). |
|
1675
355c448a2570
no need for an extra block to send #enableStateChanged
Claus Gittinger <cg@exept.de>
parents:
1652
diff
changeset
|
405 |
aChannel onChangeSend:#enableStateChanged to:self. |
817 | 406 |
|
407 |
! |
|
408 |
||
409 |
labelChannel |
|
410 |
||
411 |
^labelView labelChannel |
|
412 |
! |
|
413 |
||
414 |
labelChannel:aChannel |
|
415 |
||
416 |
labelView labelChannel: aChannel |
|
417 |
||
418 |
! ! |
|
419 |
||
420 |
!CheckBox methodsFor:'accessing-colors'! |
|
421 |
||
851 | 422 |
backgroundColor |
423 |
"get backgroundColor of the label view" |
|
424 |
||
425 |
^labelView backgroundColor |
|
426 |
! |
|
427 |
||
817 | 428 |
backgroundColor: backgroundColor |
851 | 429 |
"set backgroundColor only for the label view" |
817 | 430 |
|
903
77a51b230754
viewBackground setting must change mine too
Claus Gittinger <cg@exept.de>
parents:
851
diff
changeset
|
431 |
labelView backgroundColor: backgroundColor. |
817 | 432 |
! |
433 |
||
851 | 434 |
foregroundColor |
435 |
"get foregroundColor of the label view" |
|
436 |
||
437 |
^labelView foregroundColor |
|
438 |
! |
|
439 |
||
817 | 440 |
foregroundColor: foregroundColor |
851 | 441 |
"set foregroundColor only for the label view" |
817 | 442 |
|
443 |
labelView foregroundColor: (labelForegroundColor := foregroundColor). |
|
444 |
foregroundChannel notNil ifTrue: [foregroundChannel value: foregroundColor] |
|
903
77a51b230754
viewBackground setting must change mine too
Claus Gittinger <cg@exept.de>
parents:
851
diff
changeset
|
445 |
! |
77a51b230754
viewBackground setting must change mine too
Claus Gittinger <cg@exept.de>
parents:
851
diff
changeset
|
446 |
|
77a51b230754
viewBackground setting must change mine too
Claus Gittinger <cg@exept.de>
parents:
851
diff
changeset
|
447 |
viewBackground: backgroundColor |
77a51b230754
viewBackground setting must change mine too
Claus Gittinger <cg@exept.de>
parents:
851
diff
changeset
|
448 |
"set backgroundColor" |
77a51b230754
viewBackground setting must change mine too
Claus Gittinger <cg@exept.de>
parents:
851
diff
changeset
|
449 |
|
77a51b230754
viewBackground setting must change mine too
Claus Gittinger <cg@exept.de>
parents:
851
diff
changeset
|
450 |
labelView backgroundColor: backgroundColor. |
77a51b230754
viewBackground setting must change mine too
Claus Gittinger <cg@exept.de>
parents:
851
diff
changeset
|
451 |
super viewBackground: backgroundColor |
817 | 452 |
! ! |
453 |
||
454 |
!CheckBox methodsFor:'accessing-components'! |
|
455 |
||
456 |
labelView |
|
457 |
"return the labelView; allows manipulation of the |
|
458 |
labels attributes (colors etc.)" |
|
459 |
||
460 |
^ labelView |
|
461 |
! |
|
462 |
||
463 |
toggleView |
|
464 |
"return the toggleView; allows manipulation of the |
|
465 |
toggles attributes (colors etc.)" |
|
466 |
||
467 |
^ toggleView |
|
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
468 |
! ! |
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
469 |
|
56 | 470 |
!CheckBox methodsFor:'accessing-look'! |
44 | 471 |
|
100 | 472 |
activeLogo:anImageOrString |
155 | 473 |
"set the activeLogo; forwarded to the toggle" |
474 |
||
100 | 475 |
toggleView activeLogo:anImageOrString |
56 | 476 |
|
100 | 477 |
"Created: 22.9.1995 / 15:44:08 / claus" |
155 | 478 |
"Modified: 25.4.1996 / 16:32:50 / cg" |
100 | 479 |
! |
480 |
||
114 | 481 |
disabledLabelForegroundColor |
185 | 482 |
"set the disabledLabelForegroundColor; forwarded to the toggle" |
483 |
||
114 | 484 |
disabledLabelForegroundColor isNil ifTrue:[ ^ toggleView disabledForegroundColor ]. |
485 |
^ disabledLabelForegroundColor |
|
486 |
||
487 |
"Created: 16.12.1995 / 19:47:45 / cg" |
|
185 | 488 |
"Modified: 22.5.1996 / 13:16:55 / cg" |
114 | 489 |
! |
490 |
||
100 | 491 |
font |
185 | 492 |
"return the font. Forward from label" |
100 | 493 |
|
494 |
^ labelView font |
|
185 | 495 |
|
496 |
"Modified: 22.5.1996 / 13:17:07 / cg" |
|
49 | 497 |
! |
44 | 498 |
|
56 | 499 |
font:aFont |
185 | 500 |
"set the font. Forward to the label & resize myself. |
501 |
CAVEAT: with the addition of Text objects, |
|
268 | 502 |
this method is going to be obsoleted by a textStyle |
503 |
method, which allows specific control over |
|
504 |
normalFont/boldFont/italicFont parameters." |
|
55 | 505 |
|
56 | 506 |
labelView font:aFont. |
507 |
labelView forceResize. |
|
79 | 508 |
self layoutChanged. |
509 |
self resize. |
|
185 | 510 |
|
511 |
"Modified: 22.5.1996 / 13:17:28 / cg" |
|
49 | 512 |
! |
513 |
||
56 | 514 |
label |
155 | 515 |
"return the labels logo" |
56 | 516 |
|
517 |
^ labelView label |
|
155 | 518 |
|
519 |
"Modified: 25.4.1996 / 16:33:08 / cg" |
|
79 | 520 |
! |
521 |
||
100 | 522 |
label:aString |
155 | 523 |
"set the logo; forward to label & resize" |
79 | 524 |
|
100 | 525 |
labelView label:aString. |
526 |
labelView forceResize. |
|
527 |
self layoutChanged. |
|
528 |
self resize. |
|
155 | 529 |
|
530 |
"Modified: 25.4.1996 / 16:33:14 / cg" |
|
79 | 531 |
! |
532 |
||
114 | 533 |
labelForegroundColor |
155 | 534 |
"return the labels foregroundColor" |
535 |
||
817 | 536 |
labelForegroundColor isNil ifTrue:[ ^ labelView foregroundColor ]. |
114 | 537 |
^ labelForegroundColor |
538 |
||
539 |
"Created: 16.12.1995 / 19:47:20 / cg" |
|
155 | 540 |
"Modified: 25.4.1996 / 16:33:26 / cg" |
114 | 541 |
! |
542 |
||
79 | 543 |
passiveLogo:anImageOrString |
155 | 544 |
"set the passiveLogo; forwarded to the toggle" |
545 |
||
79 | 546 |
toggleView passiveLogo:anImageOrString |
547 |
||
548 |
"Created: 22.9.1995 / 15:44:14 / claus" |
|
155 | 549 |
"Modified: 25.4.1996 / 16:33:41 / cg" |
56 | 550 |
! ! |
551 |
||
100 | 552 |
!CheckBox methodsFor:'accessing-mvc'! |
63 | 553 |
|
100 | 554 |
aspectMessage:aspectSymbol |
155 | 555 |
"set the aspectMessage; forward to label & toggle" |
100 | 556 |
|
313 | 557 |
labelView aspectMessage:aspectSymbol. "/ in case the label updates its logo from the model |
100 | 558 |
toggleView aspectMessage:aspectSymbol |
155 | 559 |
|
313 | 560 |
"Modified: 28.2.1997 / 19:50:53 / cg" |
100 | 561 |
! |
63 | 562 |
|
100 | 563 |
changeMessage:aChangeSelector |
155 | 564 |
"set the changeMessage; forward to toggle" |
100 | 565 |
|
566 |
toggleView changeMessage:aChangeSelector |
|
155 | 567 |
|
568 |
"Modified: 25.4.1996 / 16:33:55 / cg" |
|
100 | 569 |
! |
570 |
||
571 |
model:aModel |
|
155 | 572 |
"set the model; forward to label & toggle" |
100 | 573 |
|
574 |
labelView model:aModel. |
|
575 |
toggleView model:aModel |
|
155 | 576 |
|
577 |
"Modified: 25.4.1996 / 16:34:00 / cg" |
|
63 | 578 |
! ! |
579 |
||
100 | 580 |
!CheckBox methodsFor:'accessing-state'! |
55 | 581 |
|
100 | 582 |
isOn |
155 | 583 |
"return true, if the check is on; false otherwise" |
584 |
||
100 | 585 |
^ toggleView isOn |
155 | 586 |
|
587 |
"Modified: 25.4.1996 / 16:34:15 / cg" |
|
159 | 588 |
! |
589 |
||
590 |
turnOff |
|
591 |
"turn the check off; forwarded to the toggle" |
|
592 |
||
593 |
toggleView turnOff |
|
594 |
||
595 |
"Modified: 25.4.1996 / 16:32:14 / cg" |
|
596 |
! |
|
597 |
||
598 |
turnOn |
|
599 |
"turn the check on; forwarded to the toggle" |
|
600 |
||
601 |
toggleView turnOn |
|
602 |
||
603 |
"Modified: 25.4.1996 / 16:32:21 / cg" |
|
44 | 604 |
! ! |
605 |
||
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
606 |
!CheckBox methodsFor:'change & update'! |
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
607 |
|
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
608 |
enableStateChanged |
1675
355c448a2570
no need for an extra block to send #enableStateChanged
Claus Gittinger <cg@exept.de>
parents:
1652
diff
changeset
|
609 |
"handle changes on the enableChannel or fg/bg color, change labels color." |
155 | 610 |
|
119
913df6ba1ccc
immediately change fg color when enableChannel is set
Claus Gittinger <cg@exept.de>
parents:
115
diff
changeset
|
611 |
|clr| |
913df6ba1ccc
immediately change fg color when enableChannel is set
Claus Gittinger <cg@exept.de>
parents:
115
diff
changeset
|
612 |
|
1276 | 613 |
self enabled ifTrue:[ |
820 | 614 |
(foregroundChannel notNil and: [foregroundChannel value notNil]) |
615 |
ifTrue: [labelView foregroundChannel: foregroundChannel] |
|
1652
311b68620aff
foregroundColor of label (if not black; i.e. decWindowsStyle)
Claus Gittinger <cg@exept.de>
parents:
1505
diff
changeset
|
616 |
ifFalse: [labelView foregroundColor:(labelForegroundColor ? (Label defaultForegroundColor))]. |
817 | 617 |
labelForegroundColor := labelView foregroundColor |
1276 | 618 |
] ifFalse:[ |
817 | 619 |
labelView foregroundChannel: nil |
620 |
]. |
|
621 |
||
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
622 |
toggleView enabled ifTrue:[ |
817 | 623 |
clr := self labelForegroundColor. |
1505 | 624 |
cursor := Cursor hand. |
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
625 |
] ifFalse:[ |
1505 | 626 |
clr := self disabledLabelForegroundColor. |
627 |
cursor := Cursor normal. |
|
817 | 628 |
]. |
629 |
labelView foregroundColor:clr. |
|
1505 | 630 |
labelView cursor:cursor. |
631 |
self cursor:cursor. |
|
632 |
toggleView cursor:cursor. |
|
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
633 |
|
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
634 |
! ! |
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
635 |
|
209
448124e85ccd
keyboard delegation made explicit, for space only
Claus Gittinger <cg@exept.de>
parents:
192
diff
changeset
|
636 |
!CheckBox methodsFor:'event handling'! |
448124e85ccd
keyboard delegation made explicit, for space only
Claus Gittinger <cg@exept.de>
parents:
192
diff
changeset
|
637 |
|
341 | 638 |
invalidate |
484 | 639 |
super invalidate. |
341 | 640 |
toggleView invalidate. |
641 |
labelView invalidate |
|
642 |
||
643 |
"Created: 1.4.1997 / 13:22:09 / cg" |
|
484 | 644 |
"Modified: 6.8.1997 / 18:20:12 / cg" |
341 | 645 |
! |
646 |
||
209
448124e85ccd
keyboard delegation made explicit, for space only
Claus Gittinger <cg@exept.de>
parents:
192
diff
changeset
|
647 |
keyPress:aKey x:x y:y |
448124e85ccd
keyboard delegation made explicit, for space only
Claus Gittinger <cg@exept.de>
parents:
192
diff
changeset
|
648 |
aKey == Character space ifTrue:[ |
268 | 649 |
self hasFocus ifTrue:[ |
650 |
^ toggleView toggle |
|
651 |
] |
|
209
448124e85ccd
keyboard delegation made explicit, for space only
Claus Gittinger <cg@exept.de>
parents:
192
diff
changeset
|
652 |
]. |
448124e85ccd
keyboard delegation made explicit, for space only
Claus Gittinger <cg@exept.de>
parents:
192
diff
changeset
|
653 |
super keyPress:aKey x:x y:y |
448124e85ccd
keyboard delegation made explicit, for space only
Claus Gittinger <cg@exept.de>
parents:
192
diff
changeset
|
654 |
|
448124e85ccd
keyboard delegation made explicit, for space only
Claus Gittinger <cg@exept.de>
parents:
192
diff
changeset
|
655 |
"Created: 10.7.1996 / 11:24:16 / cg" |
448124e85ccd
keyboard delegation made explicit, for space only
Claus Gittinger <cg@exept.de>
parents:
192
diff
changeset
|
656 |
"Modified: 10.7.1996 / 11:54:52 / cg" |
448124e85ccd
keyboard delegation made explicit, for space only
Claus Gittinger <cg@exept.de>
parents:
192
diff
changeset
|
657 |
! ! |
448124e85ccd
keyboard delegation made explicit, for space only
Claus Gittinger <cg@exept.de>
parents:
192
diff
changeset
|
658 |
|
1265 | 659 |
!CheckBox methodsFor:'focus handling'! |
1138
14dc9f6791d2
use a checkLabel for win95 style
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
660 |
|
14dc9f6791d2
use a checkLabel for win95 style
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
661 |
showFocus:explicit |
1265 | 662 |
"the button got the keyboard focus |
663 |
(either explicit, via tabbing; or implicit, by pointer movement) |
|
664 |
- change any display attributes as req'd." |
|
665 |
||
1138
14dc9f6791d2
use a checkLabel for win95 style
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
666 |
styleSheet name == #win95 ifTrue:[ |
14dc9f6791d2
use a checkLabel for win95 style
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
667 |
labelView hasFocus:true. |
14dc9f6791d2
use a checkLabel for win95 style
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
668 |
labelView invalidate. |
14dc9f6791d2
use a checkLabel for win95 style
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
669 |
] ifFalse:[ |
14dc9f6791d2
use a checkLabel for win95 style
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
670 |
^ super showFocus:explicit |
14dc9f6791d2
use a checkLabel for win95 style
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
671 |
] |
14dc9f6791d2
use a checkLabel for win95 style
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
672 |
|
14dc9f6791d2
use a checkLabel for win95 style
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
673 |
"Created: / 17.9.1998 / 14:11:49 / cg" |
14dc9f6791d2
use a checkLabel for win95 style
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
674 |
"Modified: / 17.9.1998 / 14:19:33 / cg" |
14dc9f6791d2
use a checkLabel for win95 style
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
675 |
! |
14dc9f6791d2
use a checkLabel for win95 style
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
676 |
|
14dc9f6791d2
use a checkLabel for win95 style
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
677 |
showNoFocus:explicit |
1265 | 678 |
"the button lost the keyboard focus |
679 |
(either explicit, via tabbing; or implicit, by pointer movement) |
|
680 |
- change any display attributes as req'd." |
|
681 |
||
1138
14dc9f6791d2
use a checkLabel for win95 style
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
682 |
styleSheet name == #win95 ifTrue:[ |
14dc9f6791d2
use a checkLabel for win95 style
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
683 |
labelView hasFocus:false. |
14dc9f6791d2
use a checkLabel for win95 style
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
684 |
labelView invalidate. |
14dc9f6791d2
use a checkLabel for win95 style
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
685 |
] ifFalse:[ |
14dc9f6791d2
use a checkLabel for win95 style
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
686 |
^ super showNoFocus:explicit |
14dc9f6791d2
use a checkLabel for win95 style
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
687 |
] |
14dc9f6791d2
use a checkLabel for win95 style
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
688 |
|
14dc9f6791d2
use a checkLabel for win95 style
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
689 |
"Created: / 17.9.1998 / 14:11:49 / cg" |
14dc9f6791d2
use a checkLabel for win95 style
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
690 |
"Modified: / 17.9.1998 / 14:19:22 / cg" |
14dc9f6791d2
use a checkLabel for win95 style
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
691 |
! ! |
14dc9f6791d2
use a checkLabel for win95 style
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
692 |
|
1324 | 693 |
!CheckBox methodsFor:'initialize / release'! |
44 | 694 |
|
218
9b155a06f6e6
handle input to my label (allow clicking on it)
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
695 |
defaultControllerClass |
9b155a06f6e6
handle input to my label (allow clicking on it)
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
696 |
^ ToggleController |
9b155a06f6e6
handle input to my label (allow clicking on it)
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
697 |
|
9b155a06f6e6
handle input to my label (allow clicking on it)
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
698 |
"Created: 18.7.1996 / 11:57:01 / cg" |
9b155a06f6e6
handle input to my label (allow clicking on it)
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
699 |
! |
9b155a06f6e6
handle input to my label (allow clicking on it)
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
700 |
|
757 | 701 |
destroy |
702 |
"release dependencies" |
|
703 |
||
704 |
|channel| |
|
705 |
||
706 |
toggleView notNil ifTrue:[ |
|
707 |
(channel := toggleView enableChannel) notNil ifTrue:[ |
|
708 |
channel retractInterestsFor:self |
|
709 |
] |
|
710 |
]. |
|
711 |
super destroy |
|
712 |
||
713 |
! |
|
714 |
||
112
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
715 |
initStyle |
284 | 716 |
"setup viewStyle specifics" |
717 |
||
112
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
718 |
super initStyle. |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
719 |
|
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
720 |
DefaultLabelForegroundColor notNil ifTrue:[ |
1481 | 721 |
labelForegroundColor := DefaultLabelForegroundColor onDevice:device. |
112
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
722 |
]. |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
723 |
DefaultDisabledLabelForegroundColor notNil ifTrue:[ |
1481 | 724 |
disabledLabelForegroundColor := DefaultDisabledLabelForegroundColor onDevice:device. |
112
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
725 |
]. |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
726 |
|
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
727 |
"Created: 14.12.1995 / 14:50:03 / cg" |
284 | 728 |
"Modified: 22.1.1997 / 11:57:03 / cg" |
817 | 729 |
|
112
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
730 |
! |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
731 |
|
44 | 732 |
initialize |
273
01541272ce8d
resource spec updated; cache device form
Claus Gittinger <cg@exept.de>
parents:
268
diff
changeset
|
733 |
<resource: #style (#name)> |
01541272ce8d
resource spec updated; cache device form
Claus Gittinger <cg@exept.de>
parents:
268
diff
changeset
|
734 |
|
56 | 735 |
super initialize. |
44 | 736 |
|
56 | 737 |
borderWidth := 0. |
44 | 738 |
|
49 | 739 |
hLayout := #fixLeftSpace. |
44 | 740 |
vLayout := #center. |
741 |
||
320
bf5e928d027a
option to place the toggle at the right.
Claus Gittinger <cg@exept.de>
parents:
318
diff
changeset
|
742 |
CheckToggleLeft ~~ false ifTrue:[ |
bf5e928d027a
option to place the toggle at the right.
Claus Gittinger <cg@exept.de>
parents:
318
diff
changeset
|
743 |
"/ toggle first ... |
bf5e928d027a
option to place the toggle at the right.
Claus Gittinger <cg@exept.de>
parents:
318
diff
changeset
|
744 |
toggleView := CheckToggle in:self. |
bf5e928d027a
option to place the toggle at the right.
Claus Gittinger <cg@exept.de>
parents:
318
diff
changeset
|
745 |
]. |
44 | 746 |
|
1138
14dc9f6791d2
use a checkLabel for win95 style
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
747 |
labelView := CheckLabel in:self. |
282 | 748 |
"/ a kludge |
188 | 749 |
styleSheet name ~~ #motif ifTrue:[ |
273
01541272ce8d
resource spec updated; cache device form
Claus Gittinger <cg@exept.de>
parents:
268
diff
changeset
|
750 |
labelView label:'check'; borderWidth:0. |
188 | 751 |
]. |
44 | 752 |
labelView forceResize. |
753 |
labelView adjust:#left. |
|
246 | 754 |
self initialHeight:labelView preferredExtent y + ViewSpacing. |
55 | 755 |
|
320
bf5e928d027a
option to place the toggle at the right.
Claus Gittinger <cg@exept.de>
parents:
318
diff
changeset
|
756 |
CheckToggleLeft == false ifTrue:[ |
bf5e928d027a
option to place the toggle at the right.
Claus Gittinger <cg@exept.de>
parents:
318
diff
changeset
|
757 |
"/ toggle last ... |
bf5e928d027a
option to place the toggle at the right.
Claus Gittinger <cg@exept.de>
parents:
318
diff
changeset
|
758 |
toggleView := CheckToggle in:self. |
bf5e928d027a
option to place the toggle at the right.
Claus Gittinger <cg@exept.de>
parents:
318
diff
changeset
|
759 |
]. |
bf5e928d027a
option to place the toggle at the right.
Claus Gittinger <cg@exept.de>
parents:
318
diff
changeset
|
760 |
|
527 | 761 |
(StyleSheet at:'checkBoxStyle' default:StyleSheet name) == #motif ifTrue:[ |
762 |
toggleView activeLogo:nil. |
|
763 |
toggleView passiveLogo:nil. |
|
764 |
toggleView activeLevel:-2. |
|
765 |
toggleView passiveLevel:2. |
|
766 |
toggleView extent:10@10. |
|
767 |
toggleView sizeFixed:true. |
|
768 |
]. |
|
769 |
||
317
0f8f00dc025a
both components have the same controller
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
770 |
"/ my controller handles both components |
218
9b155a06f6e6
handle input to my label (allow clicking on it)
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
771 |
labelView setController:controller. |
317
0f8f00dc025a
both components have the same controller
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
772 |
toggleView setController:controller. |
218
9b155a06f6e6
handle input to my label (allow clicking on it)
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
773 |
|
579
ba6e90f651d8
pass down background changes to my components
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
774 |
"/ the label can be clicked as well |
ba6e90f651d8
pass down background changes to my components
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
775 |
labelView cursor:Cursor hand. |
ba6e90f651d8
pass down background changes to my components
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
776 |
self cursor:Cursor hand. |
ba6e90f651d8
pass down background changes to my components
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
777 |
|
56 | 778 |
" |
779 |
all of my input goes to the toggle |
|
209
448124e85ccd
keyboard delegation made explicit, for space only
Claus Gittinger <cg@exept.de>
parents:
192
diff
changeset
|
780 |
disabled - normally there is already an outer delegate |
56 | 781 |
" |
209
448124e85ccd
keyboard delegation made explicit, for space only
Claus Gittinger <cg@exept.de>
parents:
192
diff
changeset
|
782 |
"/ self delegate:(KeyboardForwarder toView:toggleView). |
44 | 783 |
|
784 |
" |
|
785 |
|b| |
|
786 |
||
787 |
b := CheckBox new. |
|
788 |
b label:'foo'. |
|
789 |
b open |
|
790 |
" |
|
188 | 791 |
|
1138
14dc9f6791d2
use a checkLabel for win95 style
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
792 |
"Modified: / 17.9.1998 / 14:18:18 / cg" |
44 | 793 |
! ! |
100 | 794 |
|
795 |
!CheckBox methodsFor:'private'! |
|
796 |
||
797 |
sendChangeMessageWith:aValue |
|
798 |
"redefined to have mimic changes being sent from the toggle |
|
799 |
instead of myself" |
|
800 |
||
801 |
toggleView sendChangeMessageWith:aValue |
|
802 |
! ! |
|
803 |
||
804 |
!CheckBox methodsFor:'queries'! |
|
805 |
||
806 |
preferredExtent |
|
155 | 807 |
"compute & return the boxes preferredExtent from the components' sizes" |
153 | 808 |
|
100 | 809 |
|prefCheck prefLabel bw2| |
810 |
||
223 | 811 |
"/ If I have an explicit preferredExtent .. |
812 |
||
192
e060e80f8e24
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
188
diff
changeset
|
813 |
preferredExtent notNil ifTrue:[ |
268 | 814 |
^ preferredExtent |
192
e060e80f8e24
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
188
diff
changeset
|
815 |
]. |
e060e80f8e24
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
188
diff
changeset
|
816 |
|
213
9c8f9be0956d
care for a nil LabelView when computing the preferredExtent
Claus Gittinger <cg@exept.de>
parents:
209
diff
changeset
|
817 |
(labelView isNil or:[labelView label isEmpty]) ifTrue:[ |
268 | 818 |
^ super preferredExtent |
188 | 819 |
]. |
153 | 820 |
^ super preferredExtent + (10@0). |
821 |
||
100 | 822 |
"/ prefCheck := toggleView preferredExtent. |
823 |
"/ prefLabel := labelView preferredExtent. |
|
824 |
"/ bw2 := borderWidth * 2. |
|
825 |
"/ ^ (prefCheck x + prefLabel x + (3 * ViewSpacing)) @ ((prefCheck y max:prefLabel y) + bw2 + 2) |
|
153 | 826 |
|
223 | 827 |
"Modified: 19.7.1996 / 20:43:47 / cg" |
100 | 828 |
! ! |
829 |
||
382
ea14fe927a8b
preps for native window support
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
830 |
!CheckBox methodsFor:'queries - internal'! |
ea14fe927a8b
preps for native window support
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
831 |
|
ea14fe927a8b
preps for native window support
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
832 |
nativeWindowType |
ea14fe927a8b
preps for native window support
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
833 |
"return a symbol describing my native window type |
ea14fe927a8b
preps for native window support
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
834 |
(may be used internally by the device as a native window creation hint)" |
ea14fe927a8b
preps for native window support
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
835 |
|
ea14fe927a8b
preps for native window support
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
836 |
^ #CheckBox |
ea14fe927a8b
preps for native window support
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
837 |
|
ea14fe927a8b
preps for native window support
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
838 |
"Created: 2.5.1997 / 14:41:00 / cg" |
ea14fe927a8b
preps for native window support
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
839 |
! ! |
ea14fe927a8b
preps for native window support
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
840 |
|
273
01541272ce8d
resource spec updated; cache device form
Claus Gittinger <cg@exept.de>
parents:
268
diff
changeset
|
841 |
!CheckBox class methodsFor:'documentation'! |
100 | 842 |
|
843 |
version |
|
1675
355c448a2570
no need for an extra block to send #enableStateChanged
Claus Gittinger <cg@exept.de>
parents:
1652
diff
changeset
|
844 |
^ '$Header: /cvs/stx/stx/libwidg2/CheckBox.st,v 1.64 2000-02-03 17:34:36 cg Exp $' |
100 | 845 |
! ! |