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