author | Claus Gittinger <cg@exept.de> |
Fri, 22 Mar 1996 15:38:51 +0100 | |
changeset 513 | 97fe3c60042b |
parent 440 | 2beb33cb0146 |
child 580 | a31ba5bcc4c0 |
permissions | -rw-r--r-- |
1 | 1 |
" |
2 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
59 | 3 |
All Rights Reserved |
1 | 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 |
Button subclass:#ArrowButton |
|
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
14 |
instanceVariableNames:'arrowStyle' |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
15 |
classVariableNames:'DownArrowForm UpArrowForm LeftArrowForm RightArrowForm |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
16 |
CachedStyle DefaultArrowStyle DefaultBackgroundColor |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
17 |
DefaultForegroundColor DefaultActiveBackgroundColor |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
18 |
DefaultActiveForegroundColor DefaultEnteredBackgroundColor |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
19 |
DefaultEnteredForegroundColor DefaultDisabledForegroundColor |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
20 |
DefaultArrowButtonActiveLevel DefaultArrowButtonPassiveLevel |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
21 |
DownArrowFormFile UpArrowFormFile LeftArrowFormFile |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
22 |
RightArrowFormFile' |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
23 |
poolDictionaries:'' |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
24 |
category:'Views-Interactors' |
1 | 25 |
! |
26 |
||
38 | 27 |
!ArrowButton class methodsFor:'documentation'! |
28 |
||
29 |
copyright |
|
30 |
" |
|
31 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
59 | 32 |
All Rights Reserved |
38 | 33 |
|
34 |
This software is furnished under a license and may be used |
|
35 |
only in accordance with the terms of that license and with the |
|
36 |
inclusion of the above copyright notice. This software may not |
|
37 |
be provided or otherwise made available to, or used by, any |
|
38 |
other person. No title to or ownership of the software is |
|
39 |
hereby transferred. |
|
40 |
" |
|
41 |
! |
|
42 |
||
43 |
documentation |
|
44 |
" |
|
59 | 45 |
ArrowButtons display an arrow as their label; they are mainly |
38 | 46 |
used for scrollbars, but can be useful on their own in some applications. |
59 | 47 |
Beside the contents, their default behavior is to perform their action |
48 |
when pressed - not (as is the default for normal buttons) when released. |
|
38 | 49 |
|
65 | 50 |
Indivdual ArrowButtons can be created by sending one of: |
59 | 51 |
ArrowButton upIn:aView /downIn: / leftIn: or rightIn: |
38 | 52 |
passing the parent view as argument. |
65 | 53 |
|
54 |
styleSheet parameters: |
|
55 |
||
56 |
arrowButtonStyle <Symbol> the style of the button; |
|
57 |
#motif, #st80 or nil (default) |
|
58 |
arrowButtonForegroundColor <nil | Color> foregroundColor |
|
59 |
arrowButtonBackgroundColor <nil | Color> backgroundColor |
|
60 |
||
61 |
arrowButtonActiveForegroundColor foregroundColor when pressed |
|
62 |
arrowButtonActiveBackgroundColor backgroundColor when pressed |
|
63 |
||
64 |
arrowButtonEnteredForegroundColor foregroundColor when mouse pointer entered |
|
65 |
arrowButtonEnteredBackgroundColor backgroundColor when mouse pointer entered |
|
130 | 66 |
|
67 |
See examples. |
|
68 |
||
69 |
See also: Button Toggle CheckToggle CheckBox |
|
70 |
ScrollBar |
|
71 |
||
62 | 72 |
" |
73 |
! |
|
1 | 74 |
|
62 | 75 |
examples |
76 |
" |
|
38 | 77 |
example1: |
59 | 78 |
|
79 |
|v p b1 b2 b3 b4| |
|
38 | 80 |
|
59 | 81 |
v := StandardSystemView extent:200@200. |
82 |
p := HorizontalPanelView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:v. |
|
83 |
b1 := ArrowButton upIn:p. |
|
84 |
b2 := ArrowButton downIn:p. |
|
85 |
b3 := ArrowButton leftIn:p. |
|
86 |
b4 := ArrowButton rightIn:p. |
|
38 | 87 |
|
59 | 88 |
b1 action:['whatEver you like here ...']. |
89 |
b2 action:['whatEver you like here ...']. |
|
90 |
b3 action:['whatEver you like here ...']. |
|
91 |
b4 action:['whatEver you like here ...']. |
|
38 | 92 |
|
59 | 93 |
v open |
38 | 94 |
|
1 | 95 |
|
38 | 96 |
example2: |
59 | 97 |
|
98 |
|v p b1 b2 b3 b4| |
|
99 |
||
100 |
v := StandardSystemView extent:200@200. |
|
101 |
p := HorizontalPanelView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:v. |
|
102 |
b1 := (ArrowButton upIn:p) extent:30@30. |
|
103 |
b2 := (ArrowButton downIn:p) extent:30@30. |
|
104 |
b3 := (ArrowButton leftIn:p) extent:30@30. |
|
105 |
b4 := (ArrowButton rightIn:p) extent:30@30. |
|
106 |
||
107 |
b1 action:['whatEver you like here ...']. |
|
108 |
b2 action:['whatEver you like here ...']. |
|
109 |
b3 action:['whatEver you like here ...']. |
|
110 |
b4 action:['whatEver you like here ...']. |
|
111 |
||
112 |
v open |
|
113 |
||
114 |
example3: |
|
115 |
||
116 |
|v p b1 b2 b3 b4| |
|
117 |
||
118 |
v := StandardSystemView extent:200@200. |
|
119 |
p := View origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:v. |
|
120 |
b1 := (ArrowButton upIn:p) origin:(0.33 @ 0.0) corner:(0.67 @ 0.33). |
|
121 |
b3 := (ArrowButton leftIn:p) origin:(0.0 @ 0.33) corner:(0.33 @ 0.67). |
|
122 |
b4 := (ArrowButton rightIn:p) origin:(0.67 @ 0.33) corner:(1.0 @ 0.67). |
|
123 |
b2 := (ArrowButton downIn:p) origin:(0.33 @ 0.67) corner:(0.67 @ 1.0). |
|
38 | 124 |
|
59 | 125 |
b1 action:['whatEver you like here ...']. |
126 |
b2 action:['whatEver you like here ...']. |
|
127 |
b3 action:['whatEver you like here ...']. |
|
128 |
b4 action:['whatEver you like here ...']. |
|
129 |
||
130 |
v open |
|
131 |
||
65 | 132 |
example4 (not good coding style, to explicitely use a particular style, |
59 | 133 |
just a demonstration how it looks ..): |
134 |
||
135 |
|v p b1 b2 b3 b4 oldStyle| |
|
136 |
||
137 |
oldStyle := View defaultStyle. |
|
138 |
View defaultStyle:#motif. |
|
38 | 139 |
|
59 | 140 |
v := StandardSystemView extent:100@100. |
141 |
p := View origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:v. |
|
142 |
||
143 |
b1 := (ArrowButton upIn:p) origin:(0.33 @ 0.0) corner:(0.67 @ 0.33). |
|
144 |
b3 := (ArrowButton leftIn:p) origin:(0.0 @ 0.33) corner:(0.33 @ 0.67). |
|
145 |
b4 := (ArrowButton rightIn:p) origin:(0.67 @ 0.33) corner:(1.0 @ 0.67). |
|
146 |
b2 := (ArrowButton downIn:p) origin:(0.33 @ 0.67) corner:(0.67 @ 1.0). |
|
38 | 147 |
|
59 | 148 |
b1 action:['whatEver you like here ...']. |
149 |
b2 action:['whatEver you like here ...']. |
|
150 |
b3 action:['whatEver you like here ...']. |
|
151 |
b4 action:['whatEver you like here ...']. |
|
152 |
||
153 |
View defaultStyle:oldStyle. |
|
154 |
v open |
|
38 | 155 |
" |
156 |
! ! |
|
1 | 157 |
|
205 | 158 |
!ArrowButton class methodsFor:'instance creation'! |
59 | 159 |
|
205 | 160 |
downIn:aView |
161 |
^ (super in:aView) direction:#down |
|
162 |
! |
|
59 | 163 |
|
205 | 164 |
leftIn:aView |
165 |
^ (super in:aView) direction:#left |
|
59 | 166 |
! |
167 |
||
205 | 168 |
rightIn:aView |
169 |
^ (super in:aView) direction:#right |
|
170 |
! |
|
6 | 171 |
|
205 | 172 |
upIn:aView |
173 |
^ (super in:aView) direction:#up |
|
174 |
! ! |
|
38 | 175 |
|
205 | 176 |
!ArrowButton class methodsFor:'defaults'! |
1 | 177 |
|
38 | 178 |
downArrowButtonForm:style on:aDevice |
1 | 179 |
"retun the form used for the scrollDown Button" |
180 |
||
59 | 181 |
|form| |
38 | 182 |
|
183 |
" |
|
184 |
use cached form, if device is appropriate |
|
185 |
" |
|
59 | 186 |
CachedStyle ~~ style ifTrue:[ |
187 |
UpArrowForm := DownArrowForm := LeftArrowForm := RightArrowForm := nil |
|
188 |
]. |
|
189 |
||
38 | 190 |
((aDevice == Display) and:[DownArrowForm notNil]) ifTrue:[ |
59 | 191 |
^ DownArrowForm |
38 | 192 |
]. |
193 |
||
154 | 194 |
DownArrowForm := StyleSheet at:'arrowButtonDownForm' default:nil. |
195 |
DownArrowForm notNil ifTrue:[ |
|
196 |
^ DownArrowForm |
|
197 |
]. |
|
198 |
||
38 | 199 |
" |
59 | 200 |
special treatment for st80 arrows |
201 |
- they do not really fit into the general (bitmap) scheme ... |
|
202 |
(i.e. they are computed instead of drawn from a bitmap) |
|
38 | 203 |
" |
59 | 204 |
style ~~ #st80 ifTrue:[ |
130 | 205 |
DownArrowFormFile notNil ifTrue:[ |
206 |
form := Form fromFile:DownArrowFormFile resolution:100 on:aDevice. |
|
207 |
form isNil ifTrue:[ |
|
208 |
'ARRBUTTON: no bitmapFile: ' infoPrint. DownArrowFormFile infoPrintNL. |
|
209 |
] |
|
210 |
] |
|
38 | 211 |
]. |
6 | 212 |
|
38 | 213 |
" |
214 |
form to use as a fallback, if no bitmap file is present |
|
215 |
(actually not really needed - just to show something useful, in |
|
216 |
case of a bad installation) |
|
217 |
" |
|
218 |
form isNil ifTrue:[ |
|
59 | 219 |
style == #st80 ifTrue:[ |
220 |
form := Form width:9 height:9 depth:1 on:Display. |
|
270
aa6a36e199e7
be tolerant in case form creation fails
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
221 |
form isNil ifTrue:[^ nil]. |
59 | 222 |
form clear. |
223 |
form lineWidth:2. |
|
224 |
form capStyle:#round. |
|
225 |
form paint:(Color colorId:1). |
|
226 |
form displayLineFromX:0 y:2 toX:4 y:6. |
|
227 |
form displayLineFromX:4 y:6 toX:8 y:2 |
|
228 |
] ifFalse:[ |
|
229 |
form := Form width:16 height:16 |
|
230 |
fromArray:#[2r00000000 2r00000000 |
|
231 |
2r00001111 2r11110000 |
|
232 |
2r00001000 2r00010000 |
|
233 |
2r00001000 2r00010000 |
|
234 |
2r00001000 2r00010000 |
|
235 |
2r00001000 2r00010000 |
|
236 |
2r00001000 2r00010000 |
|
237 |
2r01111000 2r00011110 |
|
238 |
2r01000000 2r00000010 |
|
239 |
2r00100000 2r00000100 |
|
240 |
2r00010000 2r00001000 |
|
241 |
2r00001000 2r00010000 |
|
242 |
2r00000100 2r00100000 |
|
243 |
2r00000010 2r01000000 |
|
244 |
2r00000001 2r10000000 |
|
245 |
2r00000000 2r00000000] |
|
270
aa6a36e199e7
be tolerant in case form creation fails
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
246 |
on:aDevice. |
aa6a36e199e7
be tolerant in case form creation fails
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
247 |
form isNil ifTrue:[^ nil]. |
59 | 248 |
]. |
1 | 249 |
]. |
38 | 250 |
form := form on:aDevice. |
251 |
||
252 |
" |
|
253 |
remember form for next use |
|
254 |
" |
|
255 |
(aDevice == Display) ifTrue:[ |
|
59 | 256 |
CachedStyle := style. |
257 |
DownArrowForm := form |
|
38 | 258 |
]. |
259 |
||
260 |
^ form |
|
1 | 261 |
! |
262 |
||
38 | 263 |
leftArrowButtonForm:style on:aDevice |
264 |
"retun the form used for the scrollLeft Button" |
|
265 |
||
59 | 266 |
|form| |
38 | 267 |
|
268 |
" |
|
269 |
use cached form, if device is appropriate |
|
270 |
" |
|
59 | 271 |
CachedStyle ~~ style ifTrue:[ |
272 |
UpArrowForm := DownArrowForm := LeftArrowForm := RightArrowForm := nil |
|
273 |
]. |
|
274 |
||
38 | 275 |
((aDevice == Display) and:[LeftArrowForm notNil]) ifTrue:[ |
59 | 276 |
^ LeftArrowForm |
38 | 277 |
]. |
278 |
||
154 | 279 |
LeftArrowForm := StyleSheet at:'arrowButtonLeftForm' default:nil. |
280 |
LeftArrowForm notNil ifTrue:[ |
|
281 |
^ LeftArrowForm |
|
282 |
]. |
|
283 |
||
38 | 284 |
" |
59 | 285 |
special treatment for st80 arrows |
286 |
- they do not really fit into the general (bitmap) scheme ... |
|
287 |
(i.e. they are computed instead of drawn from a bitmap) |
|
38 | 288 |
" |
59 | 289 |
style ~~ #st80 ifTrue:[ |
130 | 290 |
LeftArrowFormFile notNil ifTrue:[ |
291 |
form := Form fromFile:LeftArrowFormFile resolution:100 on:aDevice. |
|
292 |
form isNil ifTrue:[ |
|
293 |
'ARRBUTTON: no bitmapFile: ' infoPrint. LeftArrowFormFile infoPrintNL. |
|
294 |
] |
|
295 |
] |
|
38 | 296 |
]. |
6 | 297 |
|
38 | 298 |
" |
299 |
form to use as a fallback, if no bitmap file is present |
|
300 |
(actually not really needed - just to show something useful, in |
|
301 |
case of a bad installation) |
|
302 |
" |
|
303 |
form isNil ifTrue:[ |
|
59 | 304 |
style == #st80 ifTrue:[ |
305 |
form := Form width:9 height:9 depth:1 on:Display. |
|
270
aa6a36e199e7
be tolerant in case form creation fails
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
306 |
form isNil ifTrue:[^ nil]. |
59 | 307 |
form clear. |
308 |
form lineWidth:2. |
|
309 |
form capStyle:#round. |
|
310 |
form paint:(Color colorId:1). |
|
311 |
form displayLineFromX:6 y:0 toX:2 y:4. |
|
312 |
form displayLineFromX:2 y:4 toX:6 y:8. |
|
313 |
] ifFalse:[ |
|
314 |
form := Form width:16 height:16 |
|
315 |
fromArray:#[2r00000000 2r00000000 |
|
316 |
2r00000001 2r10000000 |
|
317 |
2r00000010 2r10000000 |
|
318 |
2r00000100 2r10000000 |
|
319 |
2r00001000 2r11111110 |
|
320 |
2r00010000 2r00000010 |
|
321 |
2r00100000 2r00000010 |
|
322 |
2r01000000 2r00000010 |
|
323 |
2r01000000 2r00000010 |
|
324 |
2r00100000 2r00000010 |
|
325 |
2r00010000 2r00000010 |
|
326 |
2r00001000 2r11111110 |
|
327 |
2r00000100 2r10000000 |
|
328 |
2r00000010 2r10000000 |
|
329 |
2r00000001 2r10000000 |
|
330 |
2r00000000 2r00000000] |
|
270
aa6a36e199e7
be tolerant in case form creation fails
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
331 |
on:aDevice. |
aa6a36e199e7
be tolerant in case form creation fails
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
332 |
form isNil ifTrue:[^ nil]. |
59 | 333 |
]. |
1 | 334 |
]. |
38 | 335 |
form := form on:aDevice. |
336 |
||
337 |
" |
|
338 |
remember form for next use |
|
339 |
" |
|
340 |
(aDevice == Display) ifTrue:[ |
|
59 | 341 |
CachedStyle := style. |
342 |
LeftArrowForm := form |
|
38 | 343 |
]. |
344 |
||
345 |
^ form |
|
1 | 346 |
! |
347 |
||
38 | 348 |
rightArrowButtonForm:style on:aDevice |
349 |
"retun the form used for the scrollRight Button" |
|
350 |
||
59 | 351 |
|form| |
38 | 352 |
|
353 |
" |
|
354 |
use cached form, if device is appropriate |
|
355 |
" |
|
59 | 356 |
CachedStyle ~~ style ifTrue:[ |
357 |
UpArrowForm := DownArrowForm := LeftArrowForm := RightArrowForm := nil |
|
358 |
]. |
|
359 |
||
38 | 360 |
((aDevice == Display) and:[RightArrowForm notNil]) ifTrue:[ |
59 | 361 |
^ RightArrowForm |
38 | 362 |
]. |
363 |
||
154 | 364 |
RightArrowForm := StyleSheet at:'arrowButtonRightForm' default:nil. |
365 |
RightArrowForm notNil ifTrue:[ |
|
366 |
^ RightArrowForm |
|
367 |
]. |
|
368 |
||
38 | 369 |
" |
59 | 370 |
special treatment for st80 arrows |
371 |
- they do not really fit into the general (bitmap) scheme ... |
|
372 |
(i.e. they are computed instead of drawn from a bitmap) |
|
38 | 373 |
" |
59 | 374 |
style ~~ #st80 ifTrue:[ |
130 | 375 |
RightArrowFormFile notNil ifTrue:[ |
376 |
form := Form fromFile:RightArrowFormFile resolution:100 on:aDevice. |
|
377 |
form isNil ifTrue:[ |
|
378 |
'ARRBUTTON: no bitmapFile: ' infoPrint. RightArrowFormFile infoPrintNL. |
|
379 |
] |
|
380 |
] |
|
38 | 381 |
]. |
6 | 382 |
|
38 | 383 |
" |
384 |
form to use as a fallback, if no bitmap file is present |
|
385 |
(actually not really needed - just to show something useful, in |
|
386 |
case of a bad installation) |
|
387 |
" |
|
388 |
form isNil ifTrue:[ |
|
59 | 389 |
style == #st80 ifTrue:[ |
390 |
form := Form width:9 height:9 depth:1 on:Display. |
|
270
aa6a36e199e7
be tolerant in case form creation fails
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
391 |
form isNil ifTrue:[^ nil]. |
59 | 392 |
form clear. |
393 |
form lineWidth:2. |
|
394 |
form capStyle:#round. |
|
395 |
form paint:(Color colorId:1). |
|
396 |
form displayLineFromX:2 y:0 toX:6 y:4. |
|
397 |
form displayLineFromX:6 y:4 toX:2 y:8 |
|
398 |
] ifFalse:[ |
|
399 |
form := Form width:16 height:16 |
|
400 |
fromArray:#[2r00000000 2r00000000 |
|
401 |
2r00000001 2r10000000 |
|
402 |
2r00000001 2r01000000 |
|
403 |
2r00000001 2r00100000 |
|
404 |
2r01111111 2r00010000 |
|
405 |
2r01000000 2r00001000 |
|
406 |
2r01000000 2r00000100 |
|
407 |
2r01000000 2r00000010 |
|
408 |
2r01000000 2r00000010 |
|
409 |
2r01000000 2r00000100 |
|
410 |
2r01000000 2r00001000 |
|
411 |
2r01111111 2r00010000 |
|
412 |
2r00000001 2r00100000 |
|
413 |
2r00000001 2r01000000 |
|
414 |
2r00000001 2r10000000 |
|
415 |
2r00000000 2r00000000] |
|
270
aa6a36e199e7
be tolerant in case form creation fails
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
416 |
on:aDevice. |
aa6a36e199e7
be tolerant in case form creation fails
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
417 |
form isNil ifTrue:[^ nil]. |
59 | 418 |
]. |
1 | 419 |
]. |
38 | 420 |
form := form on:aDevice. |
421 |
||
422 |
" |
|
423 |
remember form for next use |
|
424 |
" |
|
425 |
(aDevice == Display) ifTrue:[ |
|
59 | 426 |
CachedStyle := style. |
427 |
RightArrowForm := form |
|
38 | 428 |
]. |
429 |
||
430 |
^ form |
|
1 | 431 |
! |
432 |
||
205 | 433 |
upArrowButtonForm:style on:aDevice |
434 |
"return the form used for the scrollUp Button" |
|
435 |
||
436 |
|form| |
|
437 |
||
438 |
" |
|
439 |
use cached form, if device is appropriate |
|
440 |
" |
|
441 |
CachedStyle ~~ style ifTrue:[ |
|
442 |
UpArrowForm := DownArrowForm := LeftArrowForm := RightArrowForm := nil |
|
443 |
]. |
|
444 |
||
445 |
((aDevice == Display) and:[UpArrowForm notNil]) ifTrue:[ |
|
446 |
^ UpArrowForm |
|
447 |
]. |
|
448 |
||
449 |
UpArrowForm := StyleSheet at:'arrowButtonUpForm' default:nil. |
|
450 |
UpArrowForm notNil ifTrue:[ |
|
451 |
^ UpArrowForm |
|
452 |
]. |
|
453 |
||
454 |
" |
|
455 |
special treatment for st80 arrows |
|
456 |
- they do not really fit into the general (bitmap) scheme ... |
|
457 |
(i.e. they are computed instead of drawn from a bitmap) |
|
458 |
" |
|
459 |
style ~~ #st80 ifTrue:[ |
|
460 |
UpArrowFormFile notNil ifTrue:[ |
|
461 |
form := Form fromFile:UpArrowFormFile resolution:100 on:aDevice. |
|
462 |
form isNil ifTrue:[ |
|
463 |
'ARRBUTTON: no bitmapFile: ' infoPrint. UpArrowFormFile infoPrintNL. |
|
464 |
] |
|
465 |
] |
|
466 |
]. |
|
467 |
||
468 |
" |
|
469 |
form to use as a fallback, if no bitmap file is present |
|
470 |
(actually not really needed - just to show something useful, in |
|
471 |
case of a bad installation) |
|
472 |
" |
|
473 |
form isNil ifTrue:[ |
|
474 |
style == #st80 ifTrue:[ |
|
475 |
form := Form width:9 height:9 depth:1 on:aDevice. |
|
270
aa6a36e199e7
be tolerant in case form creation fails
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
476 |
form isNil ifTrue:[^ nil]. |
205 | 477 |
form clear. |
478 |
form lineWidth:2. |
|
479 |
form capStyle:#round. |
|
480 |
form paint:(Color colorId:1). |
|
481 |
form displayLineFromX:0 y:6 toX:4 y:2. |
|
482 |
form displayLineFromX:4 y:2 toX:8 y:6. |
|
483 |
] ifFalse:[ |
|
484 |
form := Form width:16 height:16 |
|
485 |
fromArray:#[2r00000000 2r00000000 |
|
486 |
2r00000001 2r10000000 |
|
487 |
2r00000010 2r01000000 |
|
488 |
2r00000100 2r00100000 |
|
489 |
2r00001000 2r00010000 |
|
490 |
2r00010000 2r00001000 |
|
491 |
2r00100000 2r00000100 |
|
492 |
2r01000000 2r00000010 |
|
493 |
2r01111000 2r00011110 |
|
494 |
2r00001000 2r00010000 |
|
495 |
2r00001000 2r00010000 |
|
496 |
2r00001000 2r00010000 |
|
497 |
2r00001000 2r00010000 |
|
498 |
2r00001000 2r00010000 |
|
499 |
2r00001111 2r11110000 |
|
500 |
2r00000000 2r00000000] |
|
270
aa6a36e199e7
be tolerant in case form creation fails
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
501 |
on:aDevice. |
aa6a36e199e7
be tolerant in case form creation fails
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
502 |
form isNil ifTrue:[^ nil]. |
205 | 503 |
]. |
504 |
]. |
|
505 |
||
506 |
form := form on:aDevice. |
|
507 |
||
508 |
" |
|
509 |
remember form for next use |
|
510 |
" |
|
511 |
(aDevice == Display) ifTrue:[ |
|
512 |
CachedStyle := style. |
|
513 |
UpArrowForm := form |
|
514 |
]. |
|
515 |
||
516 |
^ form |
|
1 | 517 |
! |
518 |
||
205 | 519 |
updateStyleCache |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
520 |
"extract values from the styleSheet and cache them in class variables" |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
521 |
|
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
522 |
<resource: #style (#arrowButtonStyle |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
523 |
#arrowButtonActiveLevel #arrowButtonPassiveLevel |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
524 |
#arrowButtonBackgroundColor #arrowButtonForegroundColor |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
525 |
#arrowButtonActiveBackgroundColor #arrowButtonActiveForegroundColor |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
526 |
#arrowButtonEnteredBackgroundColor #arrowButtonEnteredForegroundColor |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
527 |
#arrowButtonDisabledForegroundColor |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
528 |
#arrowButtonDownForm #arrowButtonUpForm |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
529 |
#arrowButtonLeftForm #arrowButtonRightForm |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
530 |
#arrowButtonDownFormFile #arrowButtonUpFormFile |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
531 |
#arrowButtonLeftFormFile #arrowButtonRightFormFile)> |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
532 |
|
205 | 533 |
DefaultArrowStyle := StyleSheet at:'arrowButtonStyle' default:StyleSheet name. |
534 |
DefaultArrowStyle := DefaultArrowStyle asSymbol. |
|
535 |
||
536 |
DefaultArrowButtonActiveLevel := StyleSheet at:'arrowButtonActiveLevel' default:nil. |
|
537 |
DefaultArrowButtonPassiveLevel := StyleSheet at:'arrowButtonPassiveLevel' default:nil. |
|
538 |
||
539 |
DefaultBackgroundColor := StyleSheet colorAt:'arrowButtonBackgroundColor'. |
|
540 |
DefaultForegroundColor := StyleSheet colorAt:'arrowButtonForegroundColor'. |
|
541 |
DefaultActiveBackgroundColor := StyleSheet colorAt:'arrowButtonActiveBackgroundColor'. |
|
542 |
DefaultActiveForegroundColor := StyleSheet colorAt:'arrowButtonActiveForegroundColor'. |
|
543 |
DefaultEnteredBackgroundColor := StyleSheet colorAt:'arrowButtonEnteredBackgroundColor'. |
|
544 |
DefaultEnteredForegroundColor := StyleSheet colorAt:'arrowButtonEnteredForegroundColor'. |
|
545 |
DefaultDisabledForegroundColor := StyleSheet colorAt:'arrowButtonDisabledForegroundColor'. |
|
546 |
||
547 |
DownArrowForm := StyleSheet at:'arrowButtonDownForm' default:nil. |
|
548 |
UpArrowForm := StyleSheet at:'arrowButtonUpForm' default:nil. |
|
549 |
LeftArrowForm := StyleSheet at:'arrowButtonLeftForm' default:nil. |
|
550 |
RightArrowForm := StyleSheet at:'arrowButtonRightForm' default:nil. |
|
1 | 551 |
|
205 | 552 |
UpArrowFormFile := DownArrowFormFile := LeftArrowFormFile := RightArrowFormFile := nil. |
553 |
UpArrowForm isNil ifTrue:[ |
|
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
554 |
UpArrowFormFile := StyleSheet at:'arrowButtonUpFormFile' default:'ScrollUp.xbm'. |
205 | 555 |
]. |
556 |
DownArrowForm isNil ifTrue:[ |
|
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
557 |
DownArrowFormFile := StyleSheet at:'arrowButtonDownFormFile' default:'ScrollDn.xbm'. |
205 | 558 |
]. |
559 |
LeftArrowForm isNil ifTrue:[ |
|
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
560 |
LeftArrowFormFile := StyleSheet at:'arrowButtonLeftFormFile' default:'ScrollLt.xbm'. |
205 | 561 |
]. |
562 |
RightArrowForm isNil ifTrue:[ |
|
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
563 |
RightArrowFormFile := StyleSheet at:'arrowButtonRightFormFile' default:'ScrollRt.xbm'. |
205 | 564 |
]. |
565 |
||
566 |
" |
|
567 |
self updateStyleCache |
|
568 |
" |
|
569 |
||
570 |
"Modified: 31.8.1995 / 03:01:14 / claus" |
|
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
571 |
"Modified: 1.3.1996 / 13:45:57 / cg" |
1 | 572 |
! ! |
573 |
||
574 |
!ArrowButton methodsFor:'accessing'! |
|
575 |
||
576 |
direction:aDirectionSymbol |
|
6 | 577 |
|form| |
578 |
||
1 | 579 |
aDirectionSymbol == #up ifTrue:[ |
62 | 580 |
form := (self class upArrowButtonForm:arrowStyle on:device). |
581 |
name := 'upButton'. |
|
1 | 582 |
]. |
583 |
aDirectionSymbol == #down ifTrue:[ |
|
62 | 584 |
form := (self class downArrowButtonForm:arrowStyle on:device). |
585 |
name := 'downButton'. |
|
1 | 586 |
]. |
587 |
aDirectionSymbol == #left ifTrue:[ |
|
62 | 588 |
form := (self class leftArrowButtonForm:arrowStyle on:device). |
589 |
name := 'leftButton'. |
|
1 | 590 |
]. |
591 |
aDirectionSymbol == #right ifTrue:[ |
|
62 | 592 |
form := (self class rightArrowButtonForm:arrowStyle on:device). |
593 |
name := 'rightButton'. |
|
1 | 594 |
]. |
6 | 595 |
self form:form |
1 | 596 |
! ! |
597 |
||
598 |
!ArrowButton methodsFor:'initialization'! |
|
599 |
||
600 |
initStyle |
|
601 |
super initStyle. |
|
59 | 602 |
|
60 | 603 |
DefaultBackgroundColor notNil ifTrue:[ |
604 |
bgColor := DefaultBackgroundColor on:device |
|
605 |
]. |
|
606 |
DefaultForegroundColor notNil ifTrue:[ |
|
607 |
fgColor := DefaultForegroundColor on:device |
|
608 |
]. |
|
59 | 609 |
DefaultActiveForegroundColor notNil ifTrue:[ |
610 |
activeFgColor := DefaultActiveForegroundColor on:device |
|
611 |
]. |
|
612 |
DefaultActiveBackgroundColor notNil ifTrue:[ |
|
613 |
activeBgColor := DefaultActiveBackgroundColor on:device |
|
614 |
]. |
|
615 |
DefaultEnteredForegroundColor notNil ifTrue:[ |
|
616 |
enteredFgColor := DefaultEnteredForegroundColor on:device |
|
617 |
]. |
|
618 |
DefaultEnteredBackgroundColor notNil ifTrue:[ |
|
619 |
enteredBgColor := DefaultEnteredBackgroundColor on:device |
|
620 |
]. |
|
153 | 621 |
DefaultDisabledForegroundColor notNil ifTrue:[ |
622 |
disabledFgColor := DefaultDisabledForegroundColor on:device |
|
623 |
]. |
|
624 |
||
59 | 625 |
arrowStyle := DefaultArrowStyle. |
626 |
||
128 | 627 |
DefaultArrowButtonActiveLevel notNil ifTrue:[onLevel := DefaultArrowButtonActiveLevel]. |
628 |
DefaultArrowButtonPassiveLevel notNil ifTrue:[offLevel := DefaultArrowButtonPassiveLevel]. |
|
629 |
offLevel ~~ level ifTrue:[self level:offLevel]. |
|
630 |
||
631 |
"/ " |
|
632 |
"/ special treatment for motif arrows |
|
633 |
"/ - they do not really fit into the general (bitmap) scheme ... |
|
634 |
"/ " |
|
635 |
"/ arrowStyle == #motif ifTrue:[ |
|
636 |
"/ onLevel := 0. |
|
637 |
"/ offLevel := 0. |
|
638 |
"/ self level:0. |
|
639 |
"/ ] |
|
205 | 640 |
! |
641 |
||
642 |
initialize |
|
643 |
super initialize. |
|
644 |
controller beTriggerOnDown. |
|
1 | 645 |
! ! |
646 |
||
6 | 647 |
!ArrowButton methodsFor:'redrawing'! |
648 |
||
649 |
drawWith:fg and:bg |
|
650 |
"this is a q&d hack for motif ..." |
|
651 |
||
155 | 652 |
|topLeft botRight noColor allColor isString orgX orgY r| |
6 | 653 |
|
59 | 654 |
arrowStyle ~~ #motif ifTrue:[ |
655 |
^ super drawWith:fg and:bg. |
|
6 | 656 |
]. |
657 |
||
59 | 658 |
" |
659 |
the code below does a lot of bitmap drawing, but allows |
|
660 |
to 3D-ify any logo (it draws it displaced by some pixels |
|
661 |
to the upper left in one-color and displaced to the |
|
60 | 662 |
lower right in the other color). It should be rewritten to |
663 |
cache the result for later drawing operations. |
|
59 | 664 |
" |
6 | 665 |
logo notNil ifTrue:[ |
153 | 666 |
self paint:bg. |
667 |
self fillRectangleX:0 y:0 width:width height:height. |
|
668 |
||
59 | 669 |
shadowColor := shadowColor on:device. |
670 |
lightColor := lightColor on:device. |
|
6 | 671 |
|
77 | 672 |
controller pressed ifTrue:[ |
59 | 673 |
topLeft := shadowColor. |
674 |
botRight := lightColor |
|
675 |
] ifFalse:[ |
|
676 |
topLeft := lightColor. |
|
677 |
botRight := shadowColor |
|
678 |
]. |
|
6 | 679 |
|
153 | 680 |
isString := logo isString. |
681 |
||
682 |
isString ifFalse:[ |
|
683 |
logo depth ~~ 1 ifTrue:[ |
|
684 |
"/ allow for 4-bit logos (for motif) |
|
155 | 685 |
"/ one catch: if the view background is a complex pixmap |
686 |
"/ we cannot use this as colorMap entry. |
|
687 |
"/ therefore, compute their average colors and take these |
|
688 |
"/ (this looks ok for buttons ...) |
|
689 |
r := (0@0 corner:10@10). |
|
690 |
logo colorMap:(Array with:(bg averageColorIn:r) |
|
691 |
with:(topLeft averageColorIn:r) |
|
692 |
with:(botRight averageColorIn:r) |
|
693 |
with:(fg averageColorIn:r)). |
|
153 | 694 |
logo photometric:#palette. |
695 |
self displayForm:logo x:labelOriginX y:labelOriginY. |
|
696 |
^ self |
|
697 |
] |
|
698 |
]. |
|
38 | 699 |
|
59 | 700 |
noColor := Color noColor. |
701 |
allColor := Color allColor. |
|
6 | 702 |
|
153 | 703 |
isString ifTrue:[ |
139 | 704 |
orgY := height - font height // 2 + font ascent. |
705 |
orgX := width - labelOriginX // 4 - 1. |
|
706 |
]. |
|
59 | 707 |
self paint:topLeft. |
708 |
#(-1 0 -1) with:#(-1 -1 0) do:[:dX :dY | |
|
139 | 709 |
isString ifTrue:[ |
710 |
self displayString:logo x:orgX+dX y:orgY+dY. |
|
711 |
] ifFalse:[ |
|
712 |
self displayForm:logo x:labelOriginX+dX y:labelOriginY+dY. |
|
713 |
] |
|
59 | 714 |
]. |
6 | 715 |
|
59 | 716 |
self paint:botRight. |
717 |
#(1 1 0) with:#(0 1 1) do:[:dX :dY | |
|
139 | 718 |
isString ifTrue:[ |
719 |
self displayString:logo x:orgX+dX y:orgY+dY. |
|
720 |
] ifFalse:[ |
|
721 |
self displayForm:logo x:labelOriginX+dX y:labelOriginY+dY. |
|
722 |
] |
|
59 | 723 |
]. |
6 | 724 |
|
59 | 725 |
" |
726 |
finally, the form itself |
|
727 |
" |
|
728 |
self paint:fg. |
|
139 | 729 |
isString ifTrue:[ |
730 |
self displayString:logo x:orgX y:orgY. |
|
731 |
] ifFalse:[ |
|
732 |
self displayForm:logo x:labelOriginX y:labelOriginY. |
|
733 |
] |
|
6 | 734 |
] |
153 | 735 |
|
736 |
"Modified: 31.8.1995 / 03:03:12 / claus" |
|
6 | 737 |
! ! |
205 | 738 |
|
739 |
!ArrowButton class methodsFor:'documentation'! |
|
740 |
||
741 |
version |
|
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
742 |
^ '$Header: /cvs/stx/stx/libwidg/ArrowButton.st,v 1.21 1996-03-01 12:59:16 cg Exp $' |
205 | 743 |
! ! |