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'
|
205
|
15 |
classVariableNames:'DownArrowForm UpArrowForm LeftArrowForm RightArrowForm
|
|
16 |
CachedStyle DefaultArrowStyle DefaultBackgroundColor
|
|
17 |
DefaultForegroundColor DefaultActiveBackgroundColor
|
|
18 |
DefaultActiveForegroundColor DefaultEnteredBackgroundColor
|
|
19 |
DefaultEnteredForegroundColor DefaultDisabledForegroundColor
|
|
20 |
DefaultArrowButtonActiveLevel DefaultArrowButtonPassiveLevel
|
|
21 |
DownArrowFormFile UpArrowFormFile LeftArrowFormFile
|
|
22 |
RightArrowFormFile'
|
59
|
23 |
poolDictionaries:''
|
|
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.
|
|
221 |
form clear.
|
|
222 |
form lineWidth:2.
|
|
223 |
form capStyle:#round.
|
|
224 |
form paint:(Color colorId:1).
|
|
225 |
form displayLineFromX:0 y:2 toX:4 y:6.
|
|
226 |
form displayLineFromX:4 y:6 toX:8 y:2
|
|
227 |
] ifFalse:[
|
|
228 |
form := Form width:16 height:16
|
|
229 |
fromArray:#[2r00000000 2r00000000
|
|
230 |
2r00001111 2r11110000
|
|
231 |
2r00001000 2r00010000
|
|
232 |
2r00001000 2r00010000
|
|
233 |
2r00001000 2r00010000
|
|
234 |
2r00001000 2r00010000
|
|
235 |
2r00001000 2r00010000
|
|
236 |
2r01111000 2r00011110
|
|
237 |
2r01000000 2r00000010
|
|
238 |
2r00100000 2r00000100
|
|
239 |
2r00010000 2r00001000
|
|
240 |
2r00001000 2r00010000
|
|
241 |
2r00000100 2r00100000
|
|
242 |
2r00000010 2r01000000
|
|
243 |
2r00000001 2r10000000
|
|
244 |
2r00000000 2r00000000]
|
|
245 |
on:aDevice
|
|
246 |
].
|
1
|
247 |
].
|
38
|
248 |
form := form on:aDevice.
|
|
249 |
|
|
250 |
"
|
|
251 |
remember form for next use
|
|
252 |
"
|
|
253 |
(aDevice == Display) ifTrue:[
|
59
|
254 |
CachedStyle := style.
|
|
255 |
DownArrowForm := form
|
38
|
256 |
].
|
|
257 |
|
|
258 |
^ form
|
1
|
259 |
!
|
|
260 |
|
38
|
261 |
leftArrowButtonForm:style on:aDevice
|
|
262 |
"retun the form used for the scrollLeft Button"
|
|
263 |
|
59
|
264 |
|form|
|
38
|
265 |
|
|
266 |
"
|
|
267 |
use cached form, if device is appropriate
|
|
268 |
"
|
59
|
269 |
CachedStyle ~~ style ifTrue:[
|
|
270 |
UpArrowForm := DownArrowForm := LeftArrowForm := RightArrowForm := nil
|
|
271 |
].
|
|
272 |
|
38
|
273 |
((aDevice == Display) and:[LeftArrowForm notNil]) ifTrue:[
|
59
|
274 |
^ LeftArrowForm
|
38
|
275 |
].
|
|
276 |
|
154
|
277 |
LeftArrowForm := StyleSheet at:'arrowButtonLeftForm' default:nil.
|
|
278 |
LeftArrowForm notNil ifTrue:[
|
|
279 |
^ LeftArrowForm
|
|
280 |
].
|
|
281 |
|
38
|
282 |
"
|
59
|
283 |
special treatment for st80 arrows
|
|
284 |
- they do not really fit into the general (bitmap) scheme ...
|
|
285 |
(i.e. they are computed instead of drawn from a bitmap)
|
38
|
286 |
"
|
59
|
287 |
style ~~ #st80 ifTrue:[
|
130
|
288 |
LeftArrowFormFile notNil ifTrue:[
|
|
289 |
form := Form fromFile:LeftArrowFormFile resolution:100 on:aDevice.
|
|
290 |
form isNil ifTrue:[
|
|
291 |
'ARRBUTTON: no bitmapFile: ' infoPrint. LeftArrowFormFile infoPrintNL.
|
|
292 |
]
|
|
293 |
]
|
38
|
294 |
].
|
6
|
295 |
|
38
|
296 |
"
|
|
297 |
form to use as a fallback, if no bitmap file is present
|
|
298 |
(actually not really needed - just to show something useful, in
|
|
299 |
case of a bad installation)
|
|
300 |
"
|
|
301 |
form isNil ifTrue:[
|
59
|
302 |
style == #st80 ifTrue:[
|
|
303 |
form := Form width:9 height:9 depth:1 on:Display.
|
|
304 |
form clear.
|
|
305 |
form lineWidth:2.
|
|
306 |
form capStyle:#round.
|
|
307 |
form paint:(Color colorId:1).
|
|
308 |
form displayLineFromX:6 y:0 toX:2 y:4.
|
|
309 |
form displayLineFromX:2 y:4 toX:6 y:8.
|
|
310 |
] ifFalse:[
|
|
311 |
form := Form width:16 height:16
|
|
312 |
fromArray:#[2r00000000 2r00000000
|
|
313 |
2r00000001 2r10000000
|
|
314 |
2r00000010 2r10000000
|
|
315 |
2r00000100 2r10000000
|
|
316 |
2r00001000 2r11111110
|
|
317 |
2r00010000 2r00000010
|
|
318 |
2r00100000 2r00000010
|
|
319 |
2r01000000 2r00000010
|
|
320 |
2r01000000 2r00000010
|
|
321 |
2r00100000 2r00000010
|
|
322 |
2r00010000 2r00000010
|
|
323 |
2r00001000 2r11111110
|
|
324 |
2r00000100 2r10000000
|
|
325 |
2r00000010 2r10000000
|
|
326 |
2r00000001 2r10000000
|
|
327 |
2r00000000 2r00000000]
|
|
328 |
on:aDevice
|
|
329 |
].
|
1
|
330 |
].
|
38
|
331 |
form := form on:aDevice.
|
|
332 |
|
|
333 |
"
|
|
334 |
remember form for next use
|
|
335 |
"
|
|
336 |
(aDevice == Display) ifTrue:[
|
59
|
337 |
CachedStyle := style.
|
|
338 |
LeftArrowForm := form
|
38
|
339 |
].
|
|
340 |
|
|
341 |
^ form
|
1
|
342 |
!
|
|
343 |
|
38
|
344 |
rightArrowButtonForm:style on:aDevice
|
|
345 |
"retun the form used for the scrollRight Button"
|
|
346 |
|
59
|
347 |
|form|
|
38
|
348 |
|
|
349 |
"
|
|
350 |
use cached form, if device is appropriate
|
|
351 |
"
|
59
|
352 |
CachedStyle ~~ style ifTrue:[
|
|
353 |
UpArrowForm := DownArrowForm := LeftArrowForm := RightArrowForm := nil
|
|
354 |
].
|
|
355 |
|
38
|
356 |
((aDevice == Display) and:[RightArrowForm notNil]) ifTrue:[
|
59
|
357 |
^ RightArrowForm
|
38
|
358 |
].
|
|
359 |
|
154
|
360 |
RightArrowForm := StyleSheet at:'arrowButtonRightForm' default:nil.
|
|
361 |
RightArrowForm notNil ifTrue:[
|
|
362 |
^ RightArrowForm
|
|
363 |
].
|
|
364 |
|
38
|
365 |
"
|
59
|
366 |
special treatment for st80 arrows
|
|
367 |
- they do not really fit into the general (bitmap) scheme ...
|
|
368 |
(i.e. they are computed instead of drawn from a bitmap)
|
38
|
369 |
"
|
59
|
370 |
style ~~ #st80 ifTrue:[
|
130
|
371 |
RightArrowFormFile notNil ifTrue:[
|
|
372 |
form := Form fromFile:RightArrowFormFile resolution:100 on:aDevice.
|
|
373 |
form isNil ifTrue:[
|
|
374 |
'ARRBUTTON: no bitmapFile: ' infoPrint. RightArrowFormFile infoPrintNL.
|
|
375 |
]
|
|
376 |
]
|
38
|
377 |
].
|
6
|
378 |
|
38
|
379 |
"
|
|
380 |
form to use as a fallback, if no bitmap file is present
|
|
381 |
(actually not really needed - just to show something useful, in
|
|
382 |
case of a bad installation)
|
|
383 |
"
|
|
384 |
form isNil ifTrue:[
|
59
|
385 |
style == #st80 ifTrue:[
|
|
386 |
form := Form width:9 height:9 depth:1 on:Display.
|
|
387 |
form clear.
|
|
388 |
form lineWidth:2.
|
|
389 |
form capStyle:#round.
|
|
390 |
form paint:(Color colorId:1).
|
|
391 |
form displayLineFromX:2 y:0 toX:6 y:4.
|
|
392 |
form displayLineFromX:6 y:4 toX:2 y:8
|
|
393 |
] ifFalse:[
|
|
394 |
form := Form width:16 height:16
|
|
395 |
fromArray:#[2r00000000 2r00000000
|
|
396 |
2r00000001 2r10000000
|
|
397 |
2r00000001 2r01000000
|
|
398 |
2r00000001 2r00100000
|
|
399 |
2r01111111 2r00010000
|
|
400 |
2r01000000 2r00001000
|
|
401 |
2r01000000 2r00000100
|
|
402 |
2r01000000 2r00000010
|
|
403 |
2r01000000 2r00000010
|
|
404 |
2r01000000 2r00000100
|
|
405 |
2r01000000 2r00001000
|
|
406 |
2r01111111 2r00010000
|
|
407 |
2r00000001 2r00100000
|
|
408 |
2r00000001 2r01000000
|
|
409 |
2r00000001 2r10000000
|
|
410 |
2r00000000 2r00000000]
|
|
411 |
on:aDevice
|
|
412 |
].
|
1
|
413 |
].
|
38
|
414 |
form := form on:aDevice.
|
|
415 |
|
|
416 |
"
|
|
417 |
remember form for next use
|
|
418 |
"
|
|
419 |
(aDevice == Display) ifTrue:[
|
59
|
420 |
CachedStyle := style.
|
|
421 |
RightArrowForm := form
|
38
|
422 |
].
|
|
423 |
|
|
424 |
^ form
|
1
|
425 |
!
|
|
426 |
|
205
|
427 |
upArrowButtonForm:style on:aDevice
|
|
428 |
"return the form used for the scrollUp Button"
|
|
429 |
|
|
430 |
|form|
|
|
431 |
|
|
432 |
"
|
|
433 |
use cached form, if device is appropriate
|
|
434 |
"
|
|
435 |
CachedStyle ~~ style ifTrue:[
|
|
436 |
UpArrowForm := DownArrowForm := LeftArrowForm := RightArrowForm := nil
|
|
437 |
].
|
|
438 |
|
|
439 |
((aDevice == Display) and:[UpArrowForm notNil]) ifTrue:[
|
|
440 |
^ UpArrowForm
|
|
441 |
].
|
|
442 |
|
|
443 |
UpArrowForm := StyleSheet at:'arrowButtonUpForm' default:nil.
|
|
444 |
UpArrowForm notNil ifTrue:[
|
|
445 |
^ UpArrowForm
|
|
446 |
].
|
|
447 |
|
|
448 |
"
|
|
449 |
special treatment for st80 arrows
|
|
450 |
- they do not really fit into the general (bitmap) scheme ...
|
|
451 |
(i.e. they are computed instead of drawn from a bitmap)
|
|
452 |
"
|
|
453 |
style ~~ #st80 ifTrue:[
|
|
454 |
UpArrowFormFile notNil ifTrue:[
|
|
455 |
form := Form fromFile:UpArrowFormFile resolution:100 on:aDevice.
|
|
456 |
form isNil ifTrue:[
|
|
457 |
'ARRBUTTON: no bitmapFile: ' infoPrint. UpArrowFormFile infoPrintNL.
|
|
458 |
]
|
|
459 |
]
|
|
460 |
].
|
|
461 |
|
|
462 |
"
|
|
463 |
form to use as a fallback, if no bitmap file is present
|
|
464 |
(actually not really needed - just to show something useful, in
|
|
465 |
case of a bad installation)
|
|
466 |
"
|
|
467 |
form isNil ifTrue:[
|
|
468 |
style == #st80 ifTrue:[
|
|
469 |
form := Form width:9 height:9 depth:1 on:aDevice.
|
|
470 |
form clear.
|
|
471 |
form lineWidth:2.
|
|
472 |
form capStyle:#round.
|
|
473 |
form paint:(Color colorId:1).
|
|
474 |
form displayLineFromX:0 y:6 toX:4 y:2.
|
|
475 |
form displayLineFromX:4 y:2 toX:8 y:6.
|
|
476 |
] ifFalse:[
|
|
477 |
form := Form width:16 height:16
|
|
478 |
fromArray:#[2r00000000 2r00000000
|
|
479 |
2r00000001 2r10000000
|
|
480 |
2r00000010 2r01000000
|
|
481 |
2r00000100 2r00100000
|
|
482 |
2r00001000 2r00010000
|
|
483 |
2r00010000 2r00001000
|
|
484 |
2r00100000 2r00000100
|
|
485 |
2r01000000 2r00000010
|
|
486 |
2r01111000 2r00011110
|
|
487 |
2r00001000 2r00010000
|
|
488 |
2r00001000 2r00010000
|
|
489 |
2r00001000 2r00010000
|
|
490 |
2r00001000 2r00010000
|
|
491 |
2r00001000 2r00010000
|
|
492 |
2r00001111 2r11110000
|
|
493 |
2r00000000 2r00000000]
|
|
494 |
on:aDevice
|
|
495 |
].
|
|
496 |
].
|
|
497 |
|
|
498 |
form := form on:aDevice.
|
|
499 |
|
|
500 |
"
|
|
501 |
remember form for next use
|
|
502 |
"
|
|
503 |
(aDevice == Display) ifTrue:[
|
|
504 |
CachedStyle := style.
|
|
505 |
UpArrowForm := form
|
|
506 |
].
|
|
507 |
|
|
508 |
^ form
|
1
|
509 |
!
|
|
510 |
|
205
|
511 |
updateStyleCache
|
|
512 |
DefaultArrowStyle := StyleSheet at:'arrowButtonStyle' default:StyleSheet name.
|
|
513 |
DefaultArrowStyle := DefaultArrowStyle asSymbol.
|
|
514 |
|
|
515 |
DefaultArrowButtonActiveLevel := StyleSheet at:'arrowButtonActiveLevel' default:nil.
|
|
516 |
DefaultArrowButtonPassiveLevel := StyleSheet at:'arrowButtonPassiveLevel' default:nil.
|
|
517 |
|
|
518 |
DefaultBackgroundColor := StyleSheet colorAt:'arrowButtonBackgroundColor'.
|
|
519 |
DefaultForegroundColor := StyleSheet colorAt:'arrowButtonForegroundColor'.
|
|
520 |
DefaultActiveBackgroundColor := StyleSheet colorAt:'arrowButtonActiveBackgroundColor'.
|
|
521 |
DefaultActiveForegroundColor := StyleSheet colorAt:'arrowButtonActiveForegroundColor'.
|
|
522 |
DefaultEnteredBackgroundColor := StyleSheet colorAt:'arrowButtonEnteredBackgroundColor'.
|
|
523 |
DefaultEnteredForegroundColor := StyleSheet colorAt:'arrowButtonEnteredForegroundColor'.
|
|
524 |
DefaultDisabledForegroundColor := StyleSheet colorAt:'arrowButtonDisabledForegroundColor'.
|
|
525 |
|
|
526 |
DownArrowForm := StyleSheet at:'arrowButtonDownForm' default:nil.
|
|
527 |
UpArrowForm := StyleSheet at:'arrowButtonUpForm' default:nil.
|
|
528 |
LeftArrowForm := StyleSheet at:'arrowButtonLeftForm' default:nil.
|
|
529 |
RightArrowForm := StyleSheet at:'arrowButtonRightForm' default:nil.
|
1
|
530 |
|
205
|
531 |
UpArrowFormFile := DownArrowFormFile := LeftArrowFormFile := RightArrowFormFile := nil.
|
|
532 |
UpArrowForm isNil ifTrue:[
|
|
533 |
UpArrowFormFile := StyleSheet at:'arrowButtonUpFormFile' default:'ScrollUp.xbm'.
|
|
534 |
].
|
|
535 |
DownArrowForm isNil ifTrue:[
|
|
536 |
DownArrowFormFile := StyleSheet at:'arrowButtonDownFormFile' default:'ScrollDn.xbm'.
|
|
537 |
].
|
|
538 |
LeftArrowForm isNil ifTrue:[
|
|
539 |
LeftArrowFormFile := StyleSheet at:'arrowButtonLeftFormFile' default:'ScrollLt.xbm'.
|
|
540 |
].
|
|
541 |
RightArrowForm isNil ifTrue:[
|
|
542 |
RightArrowFormFile := StyleSheet at:'arrowButtonRightFormFile' default:'ScrollRt.xbm'.
|
|
543 |
].
|
|
544 |
|
|
545 |
"
|
|
546 |
self updateStyleCache
|
|
547 |
"
|
|
548 |
|
|
549 |
"Modified: 31.8.1995 / 03:01:14 / claus"
|
1
|
550 |
! !
|
|
551 |
|
|
552 |
!ArrowButton methodsFor:'accessing'!
|
|
553 |
|
|
554 |
direction:aDirectionSymbol
|
6
|
555 |
|form|
|
|
556 |
|
1
|
557 |
aDirectionSymbol == #up ifTrue:[
|
62
|
558 |
form := (self class upArrowButtonForm:arrowStyle on:device).
|
|
559 |
name := 'upButton'.
|
1
|
560 |
].
|
|
561 |
aDirectionSymbol == #down ifTrue:[
|
62
|
562 |
form := (self class downArrowButtonForm:arrowStyle on:device).
|
|
563 |
name := 'downButton'.
|
1
|
564 |
].
|
|
565 |
aDirectionSymbol == #left ifTrue:[
|
62
|
566 |
form := (self class leftArrowButtonForm:arrowStyle on:device).
|
|
567 |
name := 'leftButton'.
|
1
|
568 |
].
|
|
569 |
aDirectionSymbol == #right ifTrue:[
|
62
|
570 |
form := (self class rightArrowButtonForm:arrowStyle on:device).
|
|
571 |
name := 'rightButton'.
|
1
|
572 |
].
|
6
|
573 |
self form:form
|
1
|
574 |
! !
|
|
575 |
|
|
576 |
!ArrowButton methodsFor:'initialization'!
|
|
577 |
|
|
578 |
initStyle
|
|
579 |
super initStyle.
|
59
|
580 |
|
60
|
581 |
DefaultBackgroundColor notNil ifTrue:[
|
|
582 |
bgColor := DefaultBackgroundColor on:device
|
|
583 |
].
|
|
584 |
DefaultForegroundColor notNil ifTrue:[
|
|
585 |
fgColor := DefaultForegroundColor on:device
|
|
586 |
].
|
59
|
587 |
DefaultActiveForegroundColor notNil ifTrue:[
|
|
588 |
activeFgColor := DefaultActiveForegroundColor on:device
|
|
589 |
].
|
|
590 |
DefaultActiveBackgroundColor notNil ifTrue:[
|
|
591 |
activeBgColor := DefaultActiveBackgroundColor on:device
|
|
592 |
].
|
|
593 |
DefaultEnteredForegroundColor notNil ifTrue:[
|
|
594 |
enteredFgColor := DefaultEnteredForegroundColor on:device
|
|
595 |
].
|
|
596 |
DefaultEnteredBackgroundColor notNil ifTrue:[
|
|
597 |
enteredBgColor := DefaultEnteredBackgroundColor on:device
|
|
598 |
].
|
153
|
599 |
DefaultDisabledForegroundColor notNil ifTrue:[
|
|
600 |
disabledFgColor := DefaultDisabledForegroundColor on:device
|
|
601 |
].
|
|
602 |
|
59
|
603 |
arrowStyle := DefaultArrowStyle.
|
|
604 |
|
128
|
605 |
DefaultArrowButtonActiveLevel notNil ifTrue:[onLevel := DefaultArrowButtonActiveLevel].
|
|
606 |
DefaultArrowButtonPassiveLevel notNil ifTrue:[offLevel := DefaultArrowButtonPassiveLevel].
|
|
607 |
offLevel ~~ level ifTrue:[self level:offLevel].
|
|
608 |
|
|
609 |
"/ "
|
|
610 |
"/ special treatment for motif arrows
|
|
611 |
"/ - they do not really fit into the general (bitmap) scheme ...
|
|
612 |
"/ "
|
|
613 |
"/ arrowStyle == #motif ifTrue:[
|
|
614 |
"/ onLevel := 0.
|
|
615 |
"/ offLevel := 0.
|
|
616 |
"/ self level:0.
|
|
617 |
"/ ]
|
205
|
618 |
!
|
|
619 |
|
|
620 |
initialize
|
|
621 |
super initialize.
|
|
622 |
controller beTriggerOnDown.
|
1
|
623 |
! !
|
|
624 |
|
6
|
625 |
!ArrowButton methodsFor:'redrawing'!
|
|
626 |
|
|
627 |
drawWith:fg and:bg
|
|
628 |
"this is a q&d hack for motif ..."
|
|
629 |
|
155
|
630 |
|topLeft botRight noColor allColor isString orgX orgY r|
|
6
|
631 |
|
59
|
632 |
arrowStyle ~~ #motif ifTrue:[
|
|
633 |
^ super drawWith:fg and:bg.
|
6
|
634 |
].
|
|
635 |
|
59
|
636 |
"
|
|
637 |
the code below does a lot of bitmap drawing, but allows
|
|
638 |
to 3D-ify any logo (it draws it displaced by some pixels
|
|
639 |
to the upper left in one-color and displaced to the
|
60
|
640 |
lower right in the other color). It should be rewritten to
|
|
641 |
cache the result for later drawing operations.
|
59
|
642 |
"
|
6
|
643 |
logo notNil ifTrue:[
|
153
|
644 |
self paint:bg.
|
|
645 |
self fillRectangleX:0 y:0 width:width height:height.
|
|
646 |
|
59
|
647 |
shadowColor := shadowColor on:device.
|
|
648 |
lightColor := lightColor on:device.
|
6
|
649 |
|
77
|
650 |
controller pressed ifTrue:[
|
59
|
651 |
topLeft := shadowColor.
|
|
652 |
botRight := lightColor
|
|
653 |
] ifFalse:[
|
|
654 |
topLeft := lightColor.
|
|
655 |
botRight := shadowColor
|
|
656 |
].
|
6
|
657 |
|
153
|
658 |
isString := logo isString.
|
|
659 |
|
|
660 |
isString ifFalse:[
|
|
661 |
logo depth ~~ 1 ifTrue:[
|
|
662 |
"/ allow for 4-bit logos (for motif)
|
155
|
663 |
"/ one catch: if the view background is a complex pixmap
|
|
664 |
"/ we cannot use this as colorMap entry.
|
|
665 |
"/ therefore, compute their average colors and take these
|
|
666 |
"/ (this looks ok for buttons ...)
|
|
667 |
r := (0@0 corner:10@10).
|
|
668 |
logo colorMap:(Array with:(bg averageColorIn:r)
|
|
669 |
with:(topLeft averageColorIn:r)
|
|
670 |
with:(botRight averageColorIn:r)
|
|
671 |
with:(fg averageColorIn:r)).
|
153
|
672 |
logo photometric:#palette.
|
|
673 |
self displayForm:logo x:labelOriginX y:labelOriginY.
|
|
674 |
^ self
|
|
675 |
]
|
|
676 |
].
|
38
|
677 |
|
59
|
678 |
noColor := Color noColor.
|
|
679 |
allColor := Color allColor.
|
6
|
680 |
|
153
|
681 |
isString ifTrue:[
|
139
|
682 |
orgY := height - font height // 2 + font ascent.
|
|
683 |
orgX := width - labelOriginX // 4 - 1.
|
|
684 |
].
|
59
|
685 |
self paint:topLeft.
|
|
686 |
#(-1 0 -1) with:#(-1 -1 0) do:[:dX :dY |
|
139
|
687 |
isString ifTrue:[
|
|
688 |
self displayString:logo x:orgX+dX y:orgY+dY.
|
|
689 |
] ifFalse:[
|
|
690 |
self displayForm:logo x:labelOriginX+dX y:labelOriginY+dY.
|
|
691 |
]
|
59
|
692 |
].
|
6
|
693 |
|
59
|
694 |
self paint:botRight.
|
|
695 |
#(1 1 0) with:#(0 1 1) do:[:dX :dY |
|
139
|
696 |
isString ifTrue:[
|
|
697 |
self displayString:logo x:orgX+dX y:orgY+dY.
|
|
698 |
] ifFalse:[
|
|
699 |
self displayForm:logo x:labelOriginX+dX y:labelOriginY+dY.
|
|
700 |
]
|
59
|
701 |
].
|
6
|
702 |
|
59
|
703 |
"
|
|
704 |
finally, the form itself
|
|
705 |
"
|
|
706 |
self paint:fg.
|
139
|
707 |
isString ifTrue:[
|
|
708 |
self displayString:logo x:orgX y:orgY.
|
|
709 |
] ifFalse:[
|
|
710 |
self displayForm:logo x:labelOriginX y:labelOriginY.
|
|
711 |
]
|
6
|
712 |
]
|
153
|
713 |
|
|
714 |
"Modified: 31.8.1995 / 03:03:12 / claus"
|
6
|
715 |
! !
|
205
|
716 |
|
|
717 |
!ArrowButton class methodsFor:'documentation'!
|
|
718 |
|
|
719 |
version
|
|
720 |
^ '$Header: /cvs/stx/stx/libwidg/ArrowButton.st,v 1.19 1995-11-23 18:19:24 cg Exp $'
|
|
721 |
! !
|