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