author | Claus Gittinger <cg@exept.de> |
Wed, 29 May 1996 12:19:14 +0200 | |
changeset 192 | e060e80f8e24 |
parent 188 | 3649c62aad46 |
child 209 | 448124e85ccd |
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 |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
16 |
disabledLabelForegroundColor' |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
17 |
classVariableNames:'DefaultLabelForegroundColor DefaultDisabledLabelForegroundColor' |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
18 |
poolDictionaries:'' |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
19 |
category:'Views-Interactors' |
44 | 20 |
! |
21 |
||
22 |
!CheckBox class methodsFor:'documentation'! |
|
23 |
||
100 | 24 |
copyright |
25 |
" |
|
26 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
27 |
All Rights Reserved |
|
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 |
||
44 | 37 |
! |
38 |
||
39 |
documentation |
|
40 |
" |
|
41 |
CheckBox has been added somwehat in a hurry |
|
42 |
- obviously, much more protocol is needed. |
|
43 |
||
44 |
For now, set actions etc. via sends to the components, |
|
45 |
labelView and toggleView. |
|
155 | 46 |
|
47 |
[author:] |
|
48 |
Claus Gittinger |
|
49 |
||
50 |
[see also:] |
|
51 |
Button CheckToggle |
|
52 |
DialogBox |
|
159 | 53 |
ValueHolder |
44 | 54 |
" |
55 |
! |
|
56 |
||
57 |
examples |
|
58 |
" |
|
188 | 59 |
no-op checkBox without a label: |
60 |
[exBegin] |
|
61 |
|b| |
|
62 |
||
63 |
b := CheckBox new. |
|
64 |
b open |
|
65 |
[exEnd] |
|
66 |
||
67 |
||
44 | 68 |
no-op checkBox: |
159 | 69 |
[exBegin] |
44 | 70 |
|b| |
71 |
||
72 |
b := CheckBox new. |
|
73 |
b label:'foo'. |
|
74 |
b open |
|
159 | 75 |
[exEnd] |
44 | 76 |
|
77 |
||
56 | 78 |
no-op checkBox, disabled: |
159 | 79 |
[exBegin] |
56 | 80 |
|b| |
81 |
||
82 |
b := CheckBox new. |
|
83 |
b label:'foo'. |
|
84 |
b disable. |
|
85 |
b open |
|
159 | 86 |
[exEnd] |
56 | 87 |
|
88 |
||
89 |
changing colors |
|
90 |
(a demo only: it is no good style to fight the styleSheet): |
|
159 | 91 |
[exBegin] |
44 | 92 |
|panel b| |
93 |
||
94 |
panel := VerticalPanelView new. |
|
95 |
||
96 |
b := CheckBox in:panel. |
|
97 |
b label:'foo'. |
|
98 |
||
99 |
b := CheckBox in:panel. |
|
100 |
b label:'bar'. |
|
101 |
b labelView foregroundColor:Color red. |
|
102 |
||
103 |
b := CheckBox in:panel. |
|
104 |
b label:'baz'. |
|
105 |
b toggleView activeForegroundColor:Color blue. |
|
106 |
||
107 |
panel open |
|
159 | 108 |
[exEnd] |
44 | 109 |
|
110 |
||
111 |
using action-blocks: |
|
159 | 112 |
[exBegin] |
49 | 113 |
|b| |
44 | 114 |
|
115 |
b := CheckBox new. |
|
116 |
b label:'check'. |
|
184 | 117 |
b action:[:value | Transcript show:'set to: '; showCR:value]. |
44 | 118 |
b open. |
159 | 119 |
[exEnd] |
44 | 120 |
|
121 |
||
49 | 122 |
with a model (default ST-80 behavior, sending #value: to the model): |
123 |
(see changing value in the inspector) |
|
159 | 124 |
[exBegin] |
49 | 125 |
|b model| |
126 |
||
127 |
model := ValueHolder newBoolean. |
|
128 |
||
129 |
b := CheckBox new. |
|
130 |
b label:'check'. |
|
131 |
b model:model. |
|
132 |
b open. |
|
133 |
model inspect. |
|
159 | 134 |
[exEnd] |
49 | 135 |
|
56 | 136 |
|
49 | 137 |
with a model and different changeSelector |
138 |
(using a plug here, for demonstration only): |
|
159 | 139 |
[exBegin] |
44 | 140 |
|b model| |
141 |
||
142 |
model := Plug new. |
|
184 | 143 |
model respondTo:#changeCheck: with:[:arg | Transcript showCR:'change to ' , arg printString]. |
44 | 144 |
|
145 |
b := CheckBox new. |
|
146 |
b label:'check'. |
|
59 | 147 |
b model:model; changeMessage:#changeCheck:. |
44 | 148 |
b open. |
159 | 149 |
[exEnd] |
44 | 150 |
|
56 | 151 |
|
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
152 |
with a model and an enableChannel |
159 | 153 |
[exBegin] |
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
154 |
|b enaToggle enaHolder| |
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
155 |
|
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
156 |
enaHolder := true asValue. |
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
157 |
|
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
158 |
enaToggle := Toggle label:'enable'. |
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
159 |
enaToggle model:enaHolder. |
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
160 |
enaToggle open. |
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
161 |
|
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
162 |
b := CheckBox new. |
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
163 |
b label:'check'. |
184 | 164 |
b action:[:value | Transcript show:'set to: '; showCR:value]. |
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
165 |
b enableChannel:enaHolder. |
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
166 |
b open. |
159 | 167 |
[exEnd] |
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
168 |
|
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
169 |
|
56 | 170 |
with models, one checkBox disabling the others: |
159 | 171 |
[exBegin] |
56 | 172 |
|dialog translator enableChannel val1 val2 val3 eBox box1 box2 box3| |
173 |
||
174 |
translator := Plug new. |
|
175 |
translator respondTo:#enableDisable |
|
159 | 176 |
with:[ |
177 |
enableChannel value |
|
178 |
ifTrue:[ |
|
179 |
box1 enable. |
|
180 |
box2 enable. |
|
181 |
box3 enable. |
|
182 |
] |
|
183 |
ifFalse:[ |
|
184 |
box1 disable. |
|
185 |
box2 disable. |
|
186 |
box3 disable. |
|
187 |
] |
|
188 |
]. |
|
56 | 189 |
|
190 |
enableChannel := true asValue. |
|
191 |
enableChannel onChangeSend:#enableDisable to:translator. |
|
192 |
val1 := true asValue. |
|
193 |
val2 := false asValue. |
|
194 |
val3 := true asValue. |
|
195 |
||
196 |
dialog := Dialog new. |
|
197 |
dialog addCheckBox:'enable' on:enableChannel. |
|
198 |
dialog addVerticalSpace. |
|
199 |
dialog leftIndent:30. |
|
200 |
box1 := dialog addCheckBox:'value1' on:val1. |
|
201 |
dialog addVerticalSpace. |
|
202 |
box2 := dialog addCheckBox:'value2' on:val2. |
|
203 |
dialog addVerticalSpace. |
|
204 |
box3 := dialog addCheckBox:'value3' on:val3. |
|
205 |
dialog addVerticalSpace. |
|
206 |
dialog addOkButton. |
|
207 |
||
208 |
dialog open. |
|
159 | 209 |
[exEnd] |
56 | 210 |
|
211 |
||
49 | 212 |
multiple checkBoxes on a single model (using different aspects) |
159 | 213 |
[exBegin] |
79 | 214 |
|top panel b model value1 value2| |
49 | 215 |
|
216 |
value1 := true. |
|
217 |
value2 := false. |
|
218 |
model := Plug new. |
|
219 |
model respondTo:#value1 with:[value1]. |
|
220 |
model respondTo:#value1: with:[:val | value1 := val]. |
|
221 |
model respondTo:#value2 with:[value2]. |
|
222 |
model respondTo:#value2: with:[:val | value2 := val]. |
|
223 |
||
224 |
top := DialogBox new. |
|
225 |
top extent:200@300. |
|
226 |
||
227 |
panel := VerticalPanelView new. |
|
228 |
||
229 |
b := CheckBox in:panel. |
|
230 |
b label:'check1'. |
|
59 | 231 |
b model:model; aspect:#value1; changeMessage:#value1:. |
49 | 232 |
|
233 |
b := CheckBox in:panel. |
|
234 |
b label:'check2'. |
|
59 | 235 |
b model:model; aspect:#value2; changeMessage:#value2:. |
49 | 236 |
|
237 |
top addComponent:panel. |
|
238 |
top addAbortButton; addOkButton. |
|
239 |
top openModal. |
|
240 |
||
79 | 241 |
top accepted ifTrue:[ |
184 | 242 |
Transcript show:'value1: '; showCR:model value1. |
243 |
Transcript show:'value2: '; showCR:model value2. |
|
49 | 244 |
] |
159 | 245 |
[exEnd] |
44 | 246 |
" |
247 |
! ! |
|
248 |
||
62 | 249 |
!CheckBox class methodsFor:'instance creation'! |
250 |
||
76 | 251 |
label:aStringOrImage model:aModel |
252 |
"create & return a new checkBox, on aModel (typically a ValueHolder), |
|
253 |
with aStringOrImage as label." |
|
254 |
||
255 |
^ (self new model:aModel) label:aStringOrImage |
|
256 |
||
257 |
"Created: 17.9.1995 / 14:20:58 / claus" |
|
44 | 258 |
! |
259 |
||
55 | 260 |
model:aModel |
100 | 261 |
"create & return a new checkBox, on aModel (typically a ValueHolder)" |
79 | 262 |
|
100 | 263 |
^ self new model:aModel |
56 | 264 |
! ! |
265 |
||
112
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
266 |
!CheckBox class methodsFor:'defaults'! |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
267 |
|
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
268 |
updateStyleCache |
134
049f033265f9
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
119
diff
changeset
|
269 |
"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
|
270 |
|
049f033265f9
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
119
diff
changeset
|
271 |
<resource: #style (#checkBoxLabelForegroundColor |
049f033265f9
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
119
diff
changeset
|
272 |
#checkBoxDisabledLabelForegroundColor)> |
049f033265f9
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
119
diff
changeset
|
273 |
|
112
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
274 |
DefaultLabelForegroundColor := StyleSheet colorAt:'checkBoxLabelForegroundColor'. |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
275 |
DefaultDisabledLabelForegroundColor := StyleSheet colorAt:'checkBoxDisabledLabelForegroundColor'. |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
276 |
|
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
277 |
" |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
278 |
self updateStyleCache |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
279 |
" |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
280 |
|
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
281 |
"Created: 14.12.1995 / 14:47:22 / cg" |
134
049f033265f9
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
119
diff
changeset
|
282 |
"Modified: 1.3.1996 / 13:45:47 / cg" |
112
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
283 |
! ! |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
284 |
|
56 | 285 |
!CheckBox methodsFor:'accessing'! |
286 |
||
44 | 287 |
labelView |
49 | 288 |
"return the labelView; allows manipulation of the |
289 |
labels attributes (colors etc.)" |
|
290 |
||
44 | 291 |
^ labelView |
292 |
! |
|
293 |
||
294 |
toggleView |
|
49 | 295 |
"return the toggleView; allows manipulation of the |
296 |
toggles attributes (colors etc.)" |
|
297 |
||
44 | 298 |
^ toggleView |
56 | 299 |
! ! |
300 |
||
100 | 301 |
!CheckBox methodsFor:'accessing-behavior'! |
302 |
||
303 |
action:aBlock |
|
155 | 304 |
"set the actionBlock; forwarded to the toggle" |
100 | 305 |
|
306 |
toggleView action:aBlock |
|
155 | 307 |
|
308 |
"Modified: 25.4.1996 / 16:31:19 / cg" |
|
100 | 309 |
! |
310 |
||
311 |
disable |
|
155 | 312 |
"disable the checkBox; forwarded to toggle & change labels color" |
100 | 313 |
|
112
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
314 |
|clr| |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
315 |
|
100 | 316 |
toggleView disable. |
112
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
317 |
clr := disabledLabelForegroundColor. |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
318 |
clr isNil ifTrue:[ clr := toggleView disabledForegroundColor ]. |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
319 |
labelView foregroundColor:clr. |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
320 |
|
155 | 321 |
"Modified: 25.4.1996 / 16:31:31 / cg" |
100 | 322 |
! |
323 |
||
324 |
enable |
|
155 | 325 |
"enable the checkBox; forwarded to toggle & change labels color" |
100 | 326 |
|
112
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
327 |
|clr| |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
328 |
|
100 | 329 |
toggleView enable. |
112
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
330 |
clr := labelForegroundColor. |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
331 |
clr isNil ifTrue:[ clr := toggleView foregroundColor ]. |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
332 |
labelView foregroundColor:clr. |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
333 |
|
155 | 334 |
"Modified: 25.4.1996 / 16:31:40 / cg" |
100 | 335 |
! |
78 | 336 |
|
100 | 337 |
pressAction:aBlock |
155 | 338 |
"set the pressAction; forwarded to the toggle" |
339 |
||
100 | 340 |
toggleView pressAction:aBlock. |
341 |
||
342 |
"Created: 22.9.1995 / 15:54:04 / claus" |
|
155 | 343 |
"Modified: 25.4.1996 / 16:31:52 / cg" |
100 | 344 |
! |
345 |
||
346 |
releaseAction:aBlock |
|
155 | 347 |
"set the releaseAction; forwarded to the toggle" |
348 |
||
100 | 349 |
toggleView releaseAction:aBlock. |
350 |
||
351 |
"Created: 22.9.1995 / 15:54:11 / claus" |
|
155 | 352 |
"Modified: 25.4.1996 / 16:32:00 / cg" |
78 | 353 |
! ! |
354 |
||
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
355 |
!CheckBox methodsFor:'accessing-channels'! |
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
356 |
|
164 | 357 |
enableChannel |
358 |
"return a valueHolder for enable/disable" |
|
359 |
||
360 |
^ toggleView enableChannel |
|
361 |
||
362 |
"Created: 30.4.1996 / 15:11:13 / cg" |
|
363 |
! |
|
364 |
||
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
365 |
enableChannel:aChannel |
155 | 366 |
"set the enableChannel" |
367 |
||
119
913df6ba1ccc
immediately change fg color when enableChannel is set
Claus Gittinger <cg@exept.de>
parents:
115
diff
changeset
|
368 |
|wasEnabled| |
913df6ba1ccc
immediately change fg color when enableChannel is set
Claus Gittinger <cg@exept.de>
parents:
115
diff
changeset
|
369 |
|
913df6ba1ccc
immediately change fg color when enableChannel is set
Claus Gittinger <cg@exept.de>
parents:
115
diff
changeset
|
370 |
wasEnabled := toggleView enabled. |
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
371 |
toggleView enableChannel:aChannel. |
119
913df6ba1ccc
immediately change fg color when enableChannel is set
Claus Gittinger <cg@exept.de>
parents:
115
diff
changeset
|
372 |
aChannel onChangeSend:#enableStateChanged to:self. |
913df6ba1ccc
immediately change fg color when enableChannel is set
Claus Gittinger <cg@exept.de>
parents:
115
diff
changeset
|
373 |
aChannel value ~~ wasEnabled ifTrue:[ |
155 | 374 |
self enableStateChanged |
119
913df6ba1ccc
immediately change fg color when enableChannel is set
Claus Gittinger <cg@exept.de>
parents:
115
diff
changeset
|
375 |
] |
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
376 |
|
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
377 |
"Created: 17.12.1995 / 16:07:59 / cg" |
155 | 378 |
"Modified: 25.4.1996 / 16:32:34 / cg" |
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
379 |
! ! |
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
380 |
|
56 | 381 |
!CheckBox methodsFor:'accessing-look'! |
44 | 382 |
|
100 | 383 |
activeLogo:anImageOrString |
155 | 384 |
"set the activeLogo; forwarded to the toggle" |
385 |
||
100 | 386 |
toggleView activeLogo:anImageOrString |
56 | 387 |
|
100 | 388 |
"Created: 22.9.1995 / 15:44:08 / claus" |
155 | 389 |
"Modified: 25.4.1996 / 16:32:50 / cg" |
100 | 390 |
! |
391 |
||
114 | 392 |
disabledLabelForegroundColor |
185 | 393 |
"set the disabledLabelForegroundColor; forwarded to the toggle" |
394 |
||
114 | 395 |
disabledLabelForegroundColor isNil ifTrue:[ ^ toggleView disabledForegroundColor ]. |
396 |
^ disabledLabelForegroundColor |
|
397 |
||
398 |
"Created: 16.12.1995 / 19:47:45 / cg" |
|
185 | 399 |
"Modified: 22.5.1996 / 13:16:55 / cg" |
114 | 400 |
! |
401 |
||
100 | 402 |
font |
185 | 403 |
"return the font. Forward from label" |
100 | 404 |
|
405 |
^ labelView font |
|
185 | 406 |
|
407 |
"Modified: 22.5.1996 / 13:17:07 / cg" |
|
49 | 408 |
! |
44 | 409 |
|
56 | 410 |
font:aFont |
185 | 411 |
"set the font. Forward to the label & resize myself. |
412 |
CAVEAT: with the addition of Text objects, |
|
413 |
this method is going to be obsoleted by a textStyle |
|
414 |
method, which allows specific control over |
|
415 |
normalFont/boldFont/italicFont parameters." |
|
55 | 416 |
|
56 | 417 |
labelView font:aFont. |
418 |
labelView forceResize. |
|
79 | 419 |
self layoutChanged. |
420 |
self resize. |
|
185 | 421 |
|
422 |
"Modified: 22.5.1996 / 13:17:28 / cg" |
|
49 | 423 |
! |
424 |
||
56 | 425 |
label |
155 | 426 |
"return the labels logo" |
56 | 427 |
|
428 |
^ labelView label |
|
155 | 429 |
|
430 |
"Modified: 25.4.1996 / 16:33:08 / cg" |
|
79 | 431 |
! |
432 |
||
100 | 433 |
label:aString |
155 | 434 |
"set the logo; forward to label & resize" |
79 | 435 |
|
100 | 436 |
labelView label:aString. |
437 |
labelView forceResize. |
|
438 |
self layoutChanged. |
|
439 |
self resize. |
|
155 | 440 |
|
441 |
"Modified: 25.4.1996 / 16:33:14 / cg" |
|
79 | 442 |
! |
443 |
||
114 | 444 |
labelForegroundColor |
155 | 445 |
"return the labels foregroundColor" |
446 |
||
114 | 447 |
labelForegroundColor isNil ifTrue:[ ^ toggleView foregroundColor ]. |
448 |
^ labelForegroundColor |
|
449 |
||
450 |
"Created: 16.12.1995 / 19:47:20 / cg" |
|
155 | 451 |
"Modified: 25.4.1996 / 16:33:26 / cg" |
114 | 452 |
! |
453 |
||
79 | 454 |
passiveLogo:anImageOrString |
155 | 455 |
"set the passiveLogo; forwarded to the toggle" |
456 |
||
79 | 457 |
toggleView passiveLogo:anImageOrString |
458 |
||
459 |
"Created: 22.9.1995 / 15:44:14 / claus" |
|
155 | 460 |
"Modified: 25.4.1996 / 16:33:41 / cg" |
56 | 461 |
! ! |
462 |
||
100 | 463 |
!CheckBox methodsFor:'accessing-mvc'! |
63 | 464 |
|
100 | 465 |
aspectMessage:aspectSymbol |
155 | 466 |
"set the aspectMessage; forward to label & toggle" |
100 | 467 |
|
468 |
labelView aspectMessage:aspectSymbol. |
|
469 |
toggleView aspectMessage:aspectSymbol |
|
155 | 470 |
|
471 |
"Modified: 25.4.1996 / 16:33:49 / cg" |
|
100 | 472 |
! |
63 | 473 |
|
100 | 474 |
changeMessage:aChangeSelector |
155 | 475 |
"set the changeMessage; forward to toggle" |
100 | 476 |
|
477 |
toggleView changeMessage:aChangeSelector |
|
155 | 478 |
|
479 |
"Modified: 25.4.1996 / 16:33:55 / cg" |
|
100 | 480 |
! |
481 |
||
482 |
model:aModel |
|
155 | 483 |
"set the model; forward to label & toggle" |
100 | 484 |
|
485 |
labelView model:aModel. |
|
486 |
toggleView model:aModel |
|
155 | 487 |
|
488 |
"Modified: 25.4.1996 / 16:34:00 / cg" |
|
63 | 489 |
! ! |
490 |
||
100 | 491 |
!CheckBox methodsFor:'accessing-state'! |
55 | 492 |
|
100 | 493 |
isOn |
155 | 494 |
"return true, if the check is on; false otherwise" |
495 |
||
100 | 496 |
^ toggleView isOn |
155 | 497 |
|
498 |
"Modified: 25.4.1996 / 16:34:15 / cg" |
|
159 | 499 |
! |
500 |
||
501 |
turnOff |
|
502 |
"turn the check off; forwarded to the toggle" |
|
503 |
||
504 |
toggleView turnOff |
|
505 |
||
506 |
"Modified: 25.4.1996 / 16:32:14 / cg" |
|
507 |
! |
|
508 |
||
509 |
turnOn |
|
510 |
"turn the check on; forwarded to the toggle" |
|
511 |
||
512 |
toggleView turnOn |
|
513 |
||
514 |
"Modified: 25.4.1996 / 16:32:21 / cg" |
|
44 | 515 |
! ! |
516 |
||
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
517 |
!CheckBox methodsFor:'change & update'! |
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
518 |
|
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
519 |
enableStateChanged |
155 | 520 |
"handle changes on the enableChannel" |
521 |
||
119
913df6ba1ccc
immediately change fg color when enableChannel is set
Claus Gittinger <cg@exept.de>
parents:
115
diff
changeset
|
522 |
|clr| |
913df6ba1ccc
immediately change fg color when enableChannel is set
Claus Gittinger <cg@exept.de>
parents:
115
diff
changeset
|
523 |
|
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
524 |
toggleView enabled ifTrue:[ |
155 | 525 |
clr := self labelForegroundColor |
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
526 |
] ifFalse:[ |
155 | 527 |
clr := self disabledLabelForegroundColor |
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
528 |
]. |
119
913df6ba1ccc
immediately change fg color when enableChannel is set
Claus Gittinger <cg@exept.de>
parents:
115
diff
changeset
|
529 |
labelView foregroundColor:clr |
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
530 |
|
155 | 531 |
"Modified: 25.4.1996 / 16:34:30 / cg" |
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
532 |
! ! |
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
533 |
|
44 | 534 |
!CheckBox methodsFor:'initialization'! |
535 |
||
112
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
536 |
initStyle |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
537 |
super initStyle. |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
538 |
|
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
539 |
DefaultLabelForegroundColor notNil ifTrue:[ |
119
913df6ba1ccc
immediately change fg color when enableChannel is set
Claus Gittinger <cg@exept.de>
parents:
115
diff
changeset
|
540 |
labelForegroundColor := DefaultLabelForegroundColor on:device. |
112
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
541 |
]. |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
542 |
DefaultDisabledLabelForegroundColor notNil ifTrue:[ |
119
913df6ba1ccc
immediately change fg color when enableChannel is set
Claus Gittinger <cg@exept.de>
parents:
115
diff
changeset
|
543 |
disabledLabelForegroundColor := DefaultDisabledLabelForegroundColor on:device. |
112
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
544 |
]. |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
545 |
|
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
546 |
"Created: 14.12.1995 / 14:50:03 / cg" |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
547 |
! |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
548 |
|
44 | 549 |
initialize |
56 | 550 |
super initialize. |
44 | 551 |
|
56 | 552 |
borderWidth := 0. |
44 | 553 |
|
49 | 554 |
hLayout := #fixLeftSpace. |
44 | 555 |
vLayout := #center. |
556 |
||
557 |
toggleView := CheckToggle in:self. |
|
558 |
||
559 |
labelView := Label in:self. |
|
188 | 560 |
styleSheet name ~~ #motif ifTrue:[ |
561 |
labelView label:'check'; borderWidth:0. |
|
562 |
]. |
|
44 | 563 |
labelView forceResize. |
564 |
labelView adjust:#left. |
|
62 | 565 |
self height:labelView preferredExtent y + ViewSpacing. |
55 | 566 |
|
56 | 567 |
" |
568 |
all of my input goes to the toggle |
|
569 |
" |
|
570 |
self delegate:(KeyboardForwarder toView:toggleView). |
|
44 | 571 |
|
572 |
" |
|
573 |
|b| |
|
574 |
||
575 |
b := CheckBox new. |
|
576 |
b label:'foo'. |
|
577 |
b open |
|
578 |
" |
|
188 | 579 |
|
580 |
"Modified: 24.5.1996 / 15:17:35 / cg" |
|
44 | 581 |
! ! |
100 | 582 |
|
583 |
!CheckBox methodsFor:'private'! |
|
584 |
||
585 |
sendChangeMessageWith:aValue |
|
586 |
"redefined to have mimic changes being sent from the toggle |
|
587 |
instead of myself" |
|
588 |
||
589 |
toggleView sendChangeMessageWith:aValue |
|
590 |
! ! |
|
591 |
||
592 |
!CheckBox methodsFor:'queries'! |
|
593 |
||
594 |
preferredExtent |
|
155 | 595 |
"compute & return the boxes preferredExtent from the components' sizes" |
153 | 596 |
|
100 | 597 |
|prefCheck prefLabel bw2| |
598 |
||
192
e060e80f8e24
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
188
diff
changeset
|
599 |
preferredExtent notNil ifTrue:[ |
e060e80f8e24
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
188
diff
changeset
|
600 |
^ preferredExtent |
e060e80f8e24
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
188
diff
changeset
|
601 |
]. |
e060e80f8e24
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
188
diff
changeset
|
602 |
|
188 | 603 |
labelView label isEmpty ifTrue:[ |
604 |
^ super preferredExtent |
|
605 |
]. |
|
153 | 606 |
^ super preferredExtent + (10@0). |
607 |
||
100 | 608 |
"/ prefCheck := toggleView preferredExtent. |
609 |
"/ prefLabel := labelView preferredExtent. |
|
610 |
"/ bw2 := borderWidth * 2. |
|
611 |
"/ ^ (prefCheck x + prefLabel x + (3 * ViewSpacing)) @ ((prefCheck y max:prefLabel y) + bw2 + 2) |
|
153 | 612 |
|
192
e060e80f8e24
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
188
diff
changeset
|
613 |
"Modified: 29.5.1996 / 12:13:08 / cg" |
100 | 614 |
! ! |
615 |
||
616 |
!CheckBox class methodsFor:'documentation'! |
|
617 |
||
618 |
version |
|
192
e060e80f8e24
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
188
diff
changeset
|
619 |
^ '$Header: /cvs/stx/stx/libwidg2/CheckBox.st,v 1.27 1996-05-29 10:18:36 cg Exp $' |
100 | 620 |
! ! |