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