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