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