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