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