author | Claus Gittinger <cg@exept.de> |
Fri, 01 Mar 1996 13:58:33 +0100 | |
changeset 134 | 049f033265f9 |
parent 119 | 913df6ba1ccc |
child 153 | 5167176d204b |
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 |
134
049f033265f9
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
119
diff
changeset
|
243 |
"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
|
244 |
|
049f033265f9
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
119
diff
changeset
|
245 |
<resource: #style (#checkBoxLabelForegroundColor |
049f033265f9
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
119
diff
changeset
|
246 |
#checkBoxDisabledLabelForegroundColor)> |
049f033265f9
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
119
diff
changeset
|
247 |
|
112
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
248 |
DefaultLabelForegroundColor := StyleSheet colorAt:'checkBoxLabelForegroundColor'. |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
249 |
DefaultDisabledLabelForegroundColor := StyleSheet colorAt:'checkBoxDisabledLabelForegroundColor'. |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
250 |
|
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
251 |
" |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
252 |
self updateStyleCache |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
253 |
" |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
254 |
|
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
255 |
"Created: 14.12.1995 / 14:47:22 / cg" |
134
049f033265f9
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
119
diff
changeset
|
256 |
"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
|
257 |
! ! |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
258 |
|
56 | 259 |
!CheckBox methodsFor:'accessing'! |
260 |
||
44 | 261 |
labelView |
49 | 262 |
"return the labelView; allows manipulation of the |
263 |
labels attributes (colors etc.)" |
|
264 |
||
44 | 265 |
^ labelView |
266 |
! |
|
267 |
||
268 |
toggleView |
|
49 | 269 |
"return the toggleView; allows manipulation of the |
270 |
toggles attributes (colors etc.)" |
|
271 |
||
44 | 272 |
^ toggleView |
56 | 273 |
! ! |
274 |
||
100 | 275 |
!CheckBox methodsFor:'accessing-behavior'! |
276 |
||
277 |
action:aBlock |
|
278 |
"forward to toggle" |
|
279 |
||
280 |
toggleView action:aBlock |
|
281 |
! |
|
282 |
||
283 |
disable |
|
284 |
"forward to toggle & change labels color" |
|
285 |
||
112
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
286 |
|clr| |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
287 |
|
100 | 288 |
toggleView disable. |
112
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
289 |
clr := disabledLabelForegroundColor. |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
290 |
clr isNil ifTrue:[ clr := toggleView disabledForegroundColor ]. |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
291 |
labelView foregroundColor:clr. |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
292 |
|
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
293 |
"Modified: 14.12.1995 / 14:50:54 / cg" |
100 | 294 |
! |
295 |
||
296 |
enable |
|
297 |
"forward to toggle & change labels color" |
|
298 |
||
112
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
299 |
|clr| |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
300 |
|
100 | 301 |
toggleView enable. |
112
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
302 |
clr := labelForegroundColor. |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
303 |
clr isNil ifTrue:[ clr := toggleView foregroundColor ]. |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
304 |
labelView foregroundColor:clr. |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
305 |
|
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
306 |
"Modified: 14.12.1995 / 14:51:19 / cg" |
100 | 307 |
! |
78 | 308 |
|
100 | 309 |
pressAction:aBlock |
310 |
toggleView pressAction:aBlock. |
|
311 |
||
312 |
"Created: 22.9.1995 / 15:54:04 / claus" |
|
313 |
! |
|
314 |
||
315 |
releaseAction:aBlock |
|
316 |
toggleView releaseAction:aBlock. |
|
317 |
||
318 |
"Created: 22.9.1995 / 15:54:11 / claus" |
|
319 |
! |
|
320 |
||
321 |
turnOff |
|
322 |
"forward to toggle" |
|
323 |
||
324 |
toggleView turnOff |
|
325 |
! |
|
326 |
||
327 |
turnOn |
|
328 |
"forward to toggle" |
|
329 |
||
330 |
toggleView turnOn |
|
78 | 331 |
! ! |
332 |
||
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
333 |
!CheckBox methodsFor:'accessing-channels'! |
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
334 |
|
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
335 |
enableChannel:aChannel |
119
913df6ba1ccc
immediately change fg color when enableChannel is set
Claus Gittinger <cg@exept.de>
parents:
115
diff
changeset
|
336 |
|wasEnabled| |
913df6ba1ccc
immediately change fg color when enableChannel is set
Claus Gittinger <cg@exept.de>
parents:
115
diff
changeset
|
337 |
|
913df6ba1ccc
immediately change fg color when enableChannel is set
Claus Gittinger <cg@exept.de>
parents:
115
diff
changeset
|
338 |
wasEnabled := toggleView enabled. |
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
339 |
toggleView enableChannel:aChannel. |
119
913df6ba1ccc
immediately change fg color when enableChannel is set
Claus Gittinger <cg@exept.de>
parents:
115
diff
changeset
|
340 |
aChannel onChangeSend:#enableStateChanged to:self. |
913df6ba1ccc
immediately change fg color when enableChannel is set
Claus Gittinger <cg@exept.de>
parents:
115
diff
changeset
|
341 |
aChannel value ~~ wasEnabled ifTrue:[ |
913df6ba1ccc
immediately change fg color when enableChannel is set
Claus Gittinger <cg@exept.de>
parents:
115
diff
changeset
|
342 |
self enableStateChanged |
913df6ba1ccc
immediately change fg color when enableChannel is set
Claus Gittinger <cg@exept.de>
parents:
115
diff
changeset
|
343 |
] |
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
344 |
|
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
345 |
"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
|
346 |
"Modified: 24.1.1996 / 20:17:24 / cg" |
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
347 |
! ! |
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
348 |
|
56 | 349 |
!CheckBox methodsFor:'accessing-look'! |
44 | 350 |
|
100 | 351 |
activeLogo:anImageOrString |
352 |
toggleView activeLogo:anImageOrString |
|
56 | 353 |
|
100 | 354 |
"Created: 22.9.1995 / 15:44:08 / claus" |
355 |
! |
|
356 |
||
114 | 357 |
disabledLabelForegroundColor |
358 |
disabledLabelForegroundColor isNil ifTrue:[ ^ toggleView disabledForegroundColor ]. |
|
359 |
^ disabledLabelForegroundColor |
|
360 |
||
361 |
"Created: 16.12.1995 / 19:47:45 / cg" |
|
362 |
"Modified: 16.12.1995 / 19:56:41 / cg" |
|
363 |
! |
|
364 |
||
100 | 365 |
font |
366 |
"forward from label" |
|
367 |
||
368 |
^ labelView font |
|
49 | 369 |
! |
44 | 370 |
|
56 | 371 |
font:aFont |
372 |
"forward to label & resize" |
|
55 | 373 |
|
56 | 374 |
labelView font:aFont. |
375 |
labelView forceResize. |
|
79 | 376 |
self layoutChanged. |
377 |
self resize. |
|
49 | 378 |
! |
379 |
||
56 | 380 |
label |
381 |
"forward from label" |
|
382 |
||
383 |
^ labelView label |
|
79 | 384 |
! |
385 |
||
100 | 386 |
label:aString |
387 |
"forward to label & resize" |
|
79 | 388 |
|
100 | 389 |
labelView label:aString. |
390 |
labelView forceResize. |
|
391 |
self layoutChanged. |
|
392 |
self resize. |
|
79 | 393 |
! |
394 |
||
114 | 395 |
labelForegroundColor |
396 |
labelForegroundColor isNil ifTrue:[ ^ toggleView foregroundColor ]. |
|
397 |
^ labelForegroundColor |
|
398 |
||
399 |
"Created: 16.12.1995 / 19:47:20 / cg" |
|
400 |
"Modified: 16.12.1995 / 19:56:57 / cg" |
|
401 |
! |
|
402 |
||
79 | 403 |
passiveLogo:anImageOrString |
404 |
toggleView passiveLogo:anImageOrString |
|
405 |
||
406 |
"Created: 22.9.1995 / 15:44:14 / claus" |
|
56 | 407 |
! ! |
408 |
||
100 | 409 |
!CheckBox methodsFor:'accessing-mvc'! |
63 | 410 |
|
100 | 411 |
aspectMessage:aspectSymbol |
412 |
"forward to label & toggle" |
|
413 |
||
414 |
labelView aspectMessage:aspectSymbol. |
|
415 |
toggleView aspectMessage:aspectSymbol |
|
416 |
! |
|
63 | 417 |
|
100 | 418 |
changeMessage:aChangeSelector |
419 |
"forward to toggle" |
|
420 |
||
421 |
toggleView changeMessage:aChangeSelector |
|
422 |
! |
|
423 |
||
424 |
model:aModel |
|
425 |
"forward to label & toggle" |
|
426 |
||
427 |
labelView model:aModel. |
|
428 |
toggleView model:aModel |
|
63 | 429 |
! ! |
430 |
||
100 | 431 |
!CheckBox methodsFor:'accessing-state'! |
55 | 432 |
|
100 | 433 |
isOn |
434 |
^ toggleView isOn |
|
44 | 435 |
! ! |
436 |
||
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
437 |
!CheckBox methodsFor:'change & update'! |
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
438 |
|
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
439 |
enableStateChanged |
119
913df6ba1ccc
immediately change fg color when enableChannel is set
Claus Gittinger <cg@exept.de>
parents:
115
diff
changeset
|
440 |
|clr| |
913df6ba1ccc
immediately change fg color when enableChannel is set
Claus Gittinger <cg@exept.de>
parents:
115
diff
changeset
|
441 |
|
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
442 |
toggleView enabled ifTrue:[ |
119
913df6ba1ccc
immediately change fg color when enableChannel is set
Claus Gittinger <cg@exept.de>
parents:
115
diff
changeset
|
443 |
clr := self labelForegroundColor |
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
444 |
] ifFalse:[ |
119
913df6ba1ccc
immediately change fg color when enableChannel is set
Claus Gittinger <cg@exept.de>
parents:
115
diff
changeset
|
445 |
clr := self disabledLabelForegroundColor |
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
446 |
]. |
119
913df6ba1ccc
immediately change fg color when enableChannel is set
Claus Gittinger <cg@exept.de>
parents:
115
diff
changeset
|
447 |
labelView foregroundColor:clr |
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
448 |
|
119
913df6ba1ccc
immediately change fg color when enableChannel is set
Claus Gittinger <cg@exept.de>
parents:
115
diff
changeset
|
449 |
"Modified: 24.1.1996 / 20:04:34 / cg" |
115
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
450 |
! ! |
0147e9d06caa
added support for enableChannel
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
451 |
|
44 | 452 |
!CheckBox methodsFor:'initialization'! |
453 |
||
112
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
454 |
initStyle |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
455 |
super initStyle. |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
456 |
|
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
457 |
DefaultLabelForegroundColor notNil ifTrue:[ |
119
913df6ba1ccc
immediately change fg color when enableChannel is set
Claus Gittinger <cg@exept.de>
parents:
115
diff
changeset
|
458 |
labelForegroundColor := DefaultLabelForegroundColor on:device. |
112
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
459 |
]. |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
460 |
DefaultDisabledLabelForegroundColor notNil ifTrue:[ |
119
913df6ba1ccc
immediately change fg color when enableChannel is set
Claus Gittinger <cg@exept.de>
parents:
115
diff
changeset
|
461 |
disabledLabelForegroundColor := DefaultDisabledLabelForegroundColor on:device. |
112
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
462 |
]. |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
463 |
|
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
464 |
"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
|
465 |
! |
bb2cb6c553d2
allow labels colors to be set from styleSheet
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
466 |
|
44 | 467 |
initialize |
56 | 468 |
super initialize. |
44 | 469 |
|
56 | 470 |
borderWidth := 0. |
44 | 471 |
|
49 | 472 |
hLayout := #fixLeftSpace. |
44 | 473 |
vLayout := #center. |
474 |
||
475 |
toggleView := CheckToggle in:self. |
|
476 |
||
477 |
labelView := Label in:self. |
|
58 | 478 |
labelView label:'check'; borderWidth:0. |
44 | 479 |
labelView forceResize. |
480 |
labelView adjust:#left. |
|
62 | 481 |
self height:labelView preferredExtent y + ViewSpacing. |
55 | 482 |
|
56 | 483 |
" |
484 |
all of my input goes to the toggle |
|
485 |
" |
|
486 |
self delegate:(KeyboardForwarder toView:toggleView). |
|
44 | 487 |
|
488 |
" |
|
489 |
|b| |
|
490 |
||
491 |
b := CheckBox new. |
|
492 |
b label:'foo'. |
|
493 |
b open |
|
494 |
" |
|
495 |
! ! |
|
100 | 496 |
|
497 |
!CheckBox methodsFor:'private'! |
|
498 |
||
499 |
sendChangeMessageWith:aValue |
|
500 |
"redefined to have mimic changes being sent from the toggle |
|
501 |
instead of myself" |
|
502 |
||
503 |
toggleView sendChangeMessageWith:aValue |
|
504 |
! ! |
|
505 |
||
506 |
!CheckBox methodsFor:'queries'! |
|
507 |
||
508 |
preferredExtent |
|
509 |
|prefCheck prefLabel bw2| |
|
510 |
||
511 |
^ super preferredExtent + (10@0). |
|
512 |
"/ prefCheck := toggleView preferredExtent. |
|
513 |
"/ prefLabel := labelView preferredExtent. |
|
514 |
"/ bw2 := borderWidth * 2. |
|
515 |
"/ ^ (prefCheck x + prefLabel x + (3 * ViewSpacing)) @ ((prefCheck y max:prefLabel y) + bw2 + 2) |
|
516 |
! ! |
|
517 |
||
518 |
!CheckBox class methodsFor:'documentation'! |
|
519 |
||
520 |
version |
|
134
049f033265f9
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
119
diff
changeset
|
521 |
^ '$Header: /cvs/stx/stx/libwidg2/CheckBox.st,v 1.19 1996-03-01 12:58:33 cg Exp $' |
100 | 522 |
! ! |