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