0
|
1 |
"
|
4
|
2 |
COPYRIGHT (c) 1991 by Claus Gittinger
|
59
|
3 |
All Rights Reserved
|
0
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
Toggle subclass:#CheckToggle
|
59
|
14 |
instanceVariableNames:''
|
130
|
15 |
classVariableNames:'DefaultCheckForm
|
|
16 |
DefaultCheckColor
|
139
|
17 |
DefaultActiveFGColor DefaultActiveBGColor
|
|
18 |
DefaultFGColor DefaultBGColor
|
130
|
19 |
DefaultActiveLevel DefaultPassiveLevel
|
|
20 |
DefaultBorderWidth'
|
59
|
21 |
poolDictionaries:''
|
|
22 |
category:'Views-Interactors'
|
0
|
23 |
!
|
|
24 |
|
|
25 |
CheckToggle comment:'
|
4
|
26 |
COPYRIGHT (c) 1991 by Claus Gittinger
|
59
|
27 |
All Rights Reserved
|
0
|
28 |
|
164
|
29 |
$Header: /cvs/stx/stx/libwidg/CheckToggle.st,v 1.18 1995-10-23 20:06:03 cg Exp $
|
38
|
30 |
'!
|
|
31 |
|
|
32 |
!CheckToggle class methodsFor:'documentation'!
|
|
33 |
|
|
34 |
copyright
|
|
35 |
"
|
|
36 |
COPYRIGHT (c) 1991 by Claus Gittinger
|
59
|
37 |
All Rights Reserved
|
0
|
38 |
|
38
|
39 |
This software is furnished under a license and may be used
|
|
40 |
only in accordance with the terms of that license and with the
|
|
41 |
inclusion of the above copyright notice. This software may not
|
|
42 |
be provided or otherwise made available to, or used by, any
|
|
43 |
other person. No title to or ownership of the software is
|
|
44 |
hereby transferred.
|
|
45 |
"
|
|
46 |
!
|
0
|
47 |
|
38
|
48 |
version
|
|
49 |
"
|
164
|
50 |
$Header: /cvs/stx/stx/libwidg/CheckToggle.st,v 1.18 1995-10-23 20:06:03 cg Exp $
|
38
|
51 |
"
|
|
52 |
!
|
|
53 |
|
|
54 |
documentation
|
|
55 |
"
|
|
56 |
CheckButtons are like Toggles in toggling their state when pressed.
|
|
57 |
However, they show an ok-marker if on; nothing if off.
|
118
|
58 |
CheckButtons are mostly used as part of a checkBox (since normally,
|
147
|
59 |
you want to have some label along the check) and often grouped for
|
|
60 |
many-in-many or one-in-many setups.
|
130
|
61 |
|
|
62 |
StyleSheet values:
|
|
63 |
|
|
64 |
checkToggleCheckColor <Color> color to draw check-image with.
|
|
65 |
defaults to value of #buttonActiveForegroundColor.
|
|
66 |
|
139
|
67 |
checkToggleActiveBackgroundColor background color to draw active checki-image with
|
|
68 |
checkToggleForegroundColor foreground color to use if off
|
|
69 |
checkToggleBackgroundColor background color to use if off
|
130
|
70 |
|
|
71 |
checkToggleBitmapFile <String> name of bitmap file for check-image
|
|
72 |
|
|
73 |
checkToggleStyle <Symbol> default checkForm style.
|
|
74 |
used if above is nil or file not readable
|
|
75 |
can be #cross or #check; defaults to #check
|
|
76 |
|
|
77 |
checkToggleAvtiveLevel <Number> active level - defaults to value of #buttonPassiveLevel
|
|
78 |
checkTogglePassiveLevel <Number> active level - defaults to value of #buttonPassiveLevel
|
|
79 |
checkToggleBorderWidth <Number> borderWidth - defaults buttons default
|
|
80 |
|
139
|
81 |
(if not set in the styleSheet, Toggle values are taken)
|
|
82 |
|
130
|
83 |
See examples.
|
|
84 |
|
147
|
85 |
See also: CheckBox RadioButton RadioButtonGroup Toggle Button
|
118
|
86 |
"
|
|
87 |
!
|
|
88 |
|
|
89 |
examples
|
|
90 |
"
|
|
91 |
checkToggle alone:
|
|
92 |
|
|
93 |
|top check|
|
|
94 |
|
|
95 |
top := StandardSystemView new.
|
|
96 |
top extent:100@100.
|
|
97 |
|
|
98 |
check := CheckToggle in:top.
|
|
99 |
check origin:10@10.
|
|
100 |
|
|
101 |
top open
|
|
102 |
|
|
103 |
give it an action:
|
|
104 |
|
|
105 |
|top check|
|
|
106 |
|
|
107 |
top := StandardSystemView new.
|
|
108 |
top extent:100@100.
|
|
109 |
|
|
110 |
check := CheckToggle in:top.
|
|
111 |
check origin:10@10.
|
|
112 |
check action:[:value | Transcript showCr:'changed to: ' , value printString].
|
|
113 |
|
|
114 |
top open
|
|
115 |
|
|
116 |
give it a model:
|
|
117 |
|
|
118 |
|top check model|
|
|
119 |
|
|
120 |
model := false asValue.
|
|
121 |
|
|
122 |
top := StandardSystemView new.
|
|
123 |
top extent:100@100.
|
|
124 |
|
|
125 |
check := CheckToggle in:top.
|
|
126 |
check origin:10@10.
|
|
127 |
check model:model.
|
|
128 |
|
|
129 |
top openModal.
|
|
130 |
|
|
131 |
Transcript showCr:'value after closing box: ' , model value printString
|
|
132 |
|
|
133 |
multiple checks on a single model (with different change selectors):
|
|
134 |
(using a checkBox here, for the demonstration ...)
|
147
|
135 |
(this is a typical many-in-many setup)
|
118
|
136 |
|
|
137 |
|top model panel ext1 ext2
|
|
138 |
readFlag writeFlag executeFlag|
|
|
139 |
|
|
140 |
readFlag := writeFlag := true.
|
|
141 |
executeFlag := false.
|
|
142 |
|
|
143 |
model := Plug new.
|
|
144 |
model respondTo:#read with:[readFlag].
|
|
145 |
model respondTo:#write with:[writeFlag].
|
|
146 |
model respondTo:#execute with:[executeFlag].
|
|
147 |
model respondTo:#read: with:[:val | readFlag := val].
|
|
148 |
model respondTo:#write: with:[:val | writeFlag := val].
|
|
149 |
model respondTo:#execute: with:[:val | executeFlag := val].
|
|
150 |
|
|
151 |
top := StandardSystemView new.
|
|
152 |
top extent:200@200.
|
|
153 |
top label:'File permissions:'.
|
|
154 |
|
|
155 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
|
|
156 |
|
|
157 |
#(read write execute) do:[:sym |
|
|
158 |
|check|
|
|
159 |
|
|
160 |
check := CheckBox in:panel.
|
|
161 |
check label:sym.
|
147
|
162 |
check model:model; aspect:sym; changeMessage:(sym , ':') asSymbol.
|
118
|
163 |
].
|
|
164 |
|
|
165 |
top openModal.
|
|
166 |
|
|
167 |
Transcript showCr:'settings after closing box:'.
|
|
168 |
Transcript showCr:' read -> ' , readFlag printString.
|
|
169 |
Transcript showCr:' write -> ' , writeFlag printString.
|
|
170 |
Transcript showCr:' execute -> ' , executeFlag printString.
|
130
|
171 |
|
|
172 |
|
|
173 |
checkToggles in a group
|
147
|
174 |
(this is a typical one-in-many setup)
|
130
|
175 |
|
|
176 |
|top panel check1 check2 check3 grp|
|
|
177 |
|
|
178 |
top := StandardSystemView new.
|
|
179 |
top extent:200@300.
|
|
180 |
|
|
181 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
|
|
182 |
|
|
183 |
check1 := CheckToggle in:panel.
|
|
184 |
check2 := CheckToggle in:panel.
|
|
185 |
check3 := CheckToggle in:panel.
|
|
186 |
|
|
187 |
grp := RadioButtonGroup new.
|
|
188 |
grp add:check1.
|
|
189 |
grp add:check2.
|
|
190 |
grp add:check3.
|
|
191 |
|
|
192 |
top open
|
146
|
193 |
|
|
194 |
|
|
195 |
Channel operation
|
|
196 |
-----------------
|
|
197 |
|
|
198 |
enabling other toggles via a toggle
|
|
199 |
|
|
200 |
|top panel t enableChannel|
|
|
201 |
|
|
202 |
top := StandardSystemView new.
|
|
203 |
top extent:(400 @ 200).
|
|
204 |
|
|
205 |
panel := HorizontalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
|
|
206 |
|
|
207 |
enableChannel := false asValue.
|
|
208 |
|
|
209 |
1 to:10 do:[:i |
|
|
210 |
t := CheckToggle in:panel.
|
|
211 |
t enableChannel:enableChannel.
|
|
212 |
].
|
|
213 |
|
|
214 |
t := Toggle in:panel.
|
147
|
215 |
t activeLogo:'enabled'; passiveLogo:'disabled'.
|
146
|
216 |
t controller pressChannel:enableChannel.
|
|
217 |
|
|
218 |
top open
|
38
|
219 |
"
|
|
220 |
! !
|
0
|
221 |
|
|
222 |
!CheckToggle class methodsFor:'defaults'!
|
|
223 |
|
128
|
224 |
updateStyleCache
|
|
225 |
|checkFileName bits|
|
0
|
226 |
|
130
|
227 |
DefaultCheckColor := StyleSheet colorAt:'checkToggleCheckColor'.
|
139
|
228 |
DefaultFGColor := StyleSheet colorAt:'checkToggleForegroundColor'.
|
130
|
229 |
DefaultBGColor := StyleSheet colorAt:'checkToggleBackgroundColor'.
|
139
|
230 |
DefaultActiveFGColor := StyleSheet colorAt:'checkToggleActiveForegroundColor'.
|
130
|
231 |
DefaultActiveBGColor := StyleSheet colorAt:'checkToggleActiveBackgroundColor'.
|
|
232 |
DefaultActiveLevel := StyleSheet at:'checkToggleActiveLevel'.
|
|
233 |
DefaultPassiveLevel := StyleSheet at:'checkTogglePassiveLevel'.
|
|
234 |
DefaultBorderWidth := StyleSheet at:'checkToggleBorderWidth'.
|
|
235 |
|
136
|
236 |
DefaultCheckForm := nil.
|
128
|
237 |
checkFileName := StyleSheet at:'checkToggleBitmapFile' default:'CheckOn.xbm'.
|
|
238 |
checkFileName notNil ifTrue:[
|
|
239 |
DefaultCheckForm := Form fromFile:checkFileName
|
59
|
240 |
resolution:100
|
128
|
241 |
on:Display.
|
130
|
242 |
].
|
|
243 |
DefaultCheckForm isNil ifTrue:[
|
128
|
244 |
(StyleSheet at:'checkToggleStyle' default:#check) == #cross ifTrue:[
|
|
245 |
bits := #[2r10000000 2r00000001
|
|
246 |
2r01000000 2r00000010
|
|
247 |
2r00100000 2r00000100
|
|
248 |
2r00010000 2r00001000
|
|
249 |
2r00001000 2r00010000
|
|
250 |
2r00000100 2r00100000
|
|
251 |
2r00000010 2r01000000
|
|
252 |
2r00000001 2r10000000
|
|
253 |
2r00000001 2r10000000
|
|
254 |
2r00000010 2r01000000
|
|
255 |
2r00000100 2r00100000
|
|
256 |
2r00001000 2r00010000
|
|
257 |
2r00010000 2r00001000
|
|
258 |
2r00100000 2r00000100
|
|
259 |
2r01000000 2r00000010
|
|
260 |
2r10000000 2r00000001]
|
|
261 |
|
|
262 |
] ifFalse:[
|
|
263 |
bits := #[2r00000000 2r00000000
|
|
264 |
2r00000000 2r00000010
|
|
265 |
2r00000000 2r00000010
|
|
266 |
2r00000000 2r00000100
|
|
267 |
2r00000000 2r00000100
|
|
268 |
2r00000000 2r00001000
|
|
269 |
2r00000000 2r00001000
|
|
270 |
2r00000000 2r00010000
|
130
|
271 |
2r01000000 2r00110000
|
|
272 |
2r00100000 2r01100000
|
|
273 |
2r00011000 2r01100000
|
|
274 |
2r00001110 2r11000000
|
|
275 |
2r00000111 2r11000000
|
|
276 |
2r00000011 2r10000000
|
128
|
277 |
2r00000001 2r10000000
|
|
278 |
2r00000000 2r00000000]
|
|
279 |
].
|
|
280 |
DefaultCheckForm := Form width:16 height:16 fromArray:bits on:Display
|
|
281 |
]
|
|
282 |
!
|
|
283 |
|
|
284 |
checkFormOn:aDevice
|
130
|
285 |
"return the form used when checkToggle is turned on.
|
|
286 |
Provided as public entry, to allow other views
|
|
287 |
to share the same check-image."
|
128
|
288 |
|
|
289 |
^ DefaultCheckForm on:aDevice.
|
0
|
290 |
! !
|
|
291 |
|
|
292 |
!CheckToggle methodsFor:'initialization'!
|
|
293 |
|
|
294 |
initialize
|
|
295 |
super initialize.
|
164
|
296 |
passiveLogo := nil.
|
128
|
297 |
self form:activeLogo "/ to let me compute some defaultExtent
|
18
|
298 |
!
|
|
299 |
|
|
300 |
initStyle
|
|
301 |
super initStyle.
|
|
302 |
|
128
|
303 |
onLevel := offLevel.
|
130
|
304 |
DefaultActiveLevel notNil ifTrue:[onLevel := DefaultActiveLevel].
|
136
|
305 |
DefaultPassiveLevel notNil ifTrue:[offLevel := DefaultPassiveLevel].
|
130
|
306 |
|
128
|
307 |
activeLogo := DefaultCheckForm on:device.
|
|
308 |
passiveLogo := nil.
|
|
309 |
|
139
|
310 |
DefaultActiveFGColor notNil ifTrue:[self activeForegroundColor:DefaultActiveFGColor].
|
130
|
311 |
DefaultCheckColor notNil ifTrue:[self activeForegroundColor:DefaultCheckColor].
|
|
312 |
DefaultActiveBGColor notNil ifTrue:[self activeBackgroundColor:DefaultActiveBGColor].
|
139
|
313 |
DefaultFGColor notNil ifTrue:[self foregroundColor:DefaultFGColor].
|
130
|
314 |
DefaultBGColor notNil ifTrue:[self backgroundColor:DefaultBGColor].
|
|
315 |
|
128
|
316 |
showLamp := false.
|
130
|
317 |
|
|
318 |
DefaultBorderWidth notNil ifTrue:[self borderWidth:DefaultBorderWidth].
|
|
319 |
|
|
320 |
offLevel ~~ level ifTrue:[self level:offLevel].
|
0
|
321 |
! !
|
|
322 |
|
|
323 |
!CheckToggle methodsFor:'redrawing'!
|
|
324 |
|
133
|
325 |
drawWith:fg and:bg
|
127
|
326 |
self isOn ifTrue:[
|
59
|
327 |
logo := activeLogo.
|
0
|
328 |
] ifFalse:[
|
164
|
329 |
logo := passiveLogo.
|
133
|
330 |
].
|
|
331 |
super drawWith:fg and:bg
|
164
|
332 |
|
|
333 |
"Modified: 22.9.1995 / 15:45:02 / claus"
|
0
|
334 |
! !
|