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