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