author | Claus Gittinger <cg@exept.de> |
Fri, 27 Jun 1997 11:56:45 +0200 | |
changeset 1254 | c9e604f03e6a |
parent 1137 | 5ec9db9453f1 |
child 1284 | 8c3f71ee81bc |
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 |
|
1053
b9f8bf97815c
remember direction; new-creation defaults to #up
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
14 |
instanceVariableNames:'arrowStyle direction' |
440
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 |
||
899 | 27 |
!ArrowButton class methodsFor:'documentation'! |
38 | 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: |
593 | 83 |
[exBegin] |
84 |
|v p b1 b2 b3 b4| |
|
38 | 85 |
|
593 | 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 |
|
593 | 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 |
|
593 | 98 |
v open |
99 |
[exEnd] |
|
38 | 100 |
|
1 | 101 |
|
38 | 102 |
example2: |
593 | 103 |
[exBegin] |
104 |
|v p b1 b2 b3 b4| |
|
59 | 105 |
|
593 | 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. |
|
59 | 112 |
|
593 | 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 ...']. |
|
59 | 117 |
|
593 | 118 |
v open |
119 |
[exEnd] |
|
120 |
||
59 | 121 |
|
122 |
example3: |
|
593 | 123 |
[exBegin] |
124 |
|v p b1 b2 b3 b4| |
|
59 | 125 |
|
593 | 126 |
v := StandardSystemView extent:200@200. |
127 |
p := View origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:v. |
|
128 |
b1 := (ArrowButton upIn:p) origin:(0.33 @ 0.0) corner:(0.67 @ 0.33). |
|
129 |
b3 := (ArrowButton leftIn:p) origin:(0.0 @ 0.33) corner:(0.33 @ 0.67). |
|
130 |
b4 := (ArrowButton rightIn:p) origin:(0.67 @ 0.33) corner:(1.0 @ 0.67). |
|
131 |
b2 := (ArrowButton downIn:p) origin:(0.33 @ 0.67) corner:(0.67 @ 1.0). |
|
38 | 132 |
|
593 | 133 |
b1 action:['whatEver you like here ...']. |
134 |
b2 action:['whatEver you like here ...']. |
|
135 |
b3 action:['whatEver you like here ...']. |
|
136 |
b4 action:['whatEver you like here ...']. |
|
59 | 137 |
|
593 | 138 |
v open |
139 |
[exEnd] |
|
140 |
||
59 | 141 |
|
65 | 142 |
example4 (not good coding style, to explicitely use a particular style, |
593 | 143 |
just a demonstration how it looks ..): |
144 |
[exBegin] |
|
145 |
|v p b1 b2 b3 b4 oldStyle| |
|
59 | 146 |
|
593 | 147 |
oldStyle := View defaultStyle. |
148 |
View defaultStyle:#motif. |
|
38 | 149 |
|
593 | 150 |
v := StandardSystemView extent:100@100. |
151 |
p := View origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:v. |
|
59 | 152 |
|
593 | 153 |
b1 := (ArrowButton upIn:p) origin:(0.33 @ 0.0) corner:(0.67 @ 0.33). |
154 |
b3 := (ArrowButton leftIn:p) origin:(0.0 @ 0.33) corner:(0.33 @ 0.67). |
|
155 |
b4 := (ArrowButton rightIn:p) origin:(0.67 @ 0.33) corner:(1.0 @ 0.67). |
|
156 |
b2 := (ArrowButton downIn:p) origin:(0.33 @ 0.67) corner:(0.67 @ 1.0). |
|
38 | 157 |
|
593 | 158 |
b1 action:['whatEver you like here ...']. |
159 |
b2 action:['whatEver you like here ...']. |
|
160 |
b3 action:['whatEver you like here ...']. |
|
161 |
b4 action:['whatEver you like here ...']. |
|
59 | 162 |
|
593 | 163 |
View defaultStyle:oldStyle. |
164 |
v open |
|
165 |
[exEnd] |
|
38 | 166 |
" |
167 |
! ! |
|
1 | 168 |
|
899 | 169 |
!ArrowButton class methodsFor:'instance creation'! |
59 | 170 |
|
205 | 171 |
downIn:aView |
966 | 172 |
"create and return a new down-button in aView" |
173 |
||
205 | 174 |
^ (super in:aView) direction:#down |
966 | 175 |
|
176 |
"Modified: 22.1.1997 / 11:59:08 / cg" |
|
205 | 177 |
! |
59 | 178 |
|
205 | 179 |
leftIn:aView |
966 | 180 |
"create and return a new left-button in aView" |
181 |
||
205 | 182 |
^ (super in:aView) direction:#left |
966 | 183 |
|
184 |
"Modified: 22.1.1997 / 11:59:14 / cg" |
|
59 | 185 |
! |
186 |
||
1053
b9f8bf97815c
remember direction; new-creation defaults to #up
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
187 |
new |
b9f8bf97815c
remember direction; new-creation defaults to #up
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
188 |
"return a new arrowButton - direction defaults to #up" |
b9f8bf97815c
remember direction; new-creation defaults to #up
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
189 |
|
b9f8bf97815c
remember direction; new-creation defaults to #up
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
190 |
^ super new direction:#up |
b9f8bf97815c
remember direction; new-creation defaults to #up
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
191 |
! |
b9f8bf97815c
remember direction; new-creation defaults to #up
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
192 |
|
205 | 193 |
rightIn:aView |
966 | 194 |
"create and return a new right-button in aView" |
195 |
||
205 | 196 |
^ (super in:aView) direction:#right |
966 | 197 |
|
198 |
"Modified: 22.1.1997 / 11:59:21 / cg" |
|
205 | 199 |
! |
6 | 200 |
|
205 | 201 |
upIn:aView |
966 | 202 |
"create and return a new up-button in aView" |
203 |
||
205 | 204 |
^ (super in:aView) direction:#up |
966 | 205 |
|
206 |
"Modified: 22.1.1997 / 11:59:27 / cg" |
|
205 | 207 |
! ! |
38 | 208 |
|
899 | 209 |
!ArrowButton class methodsFor:'defaults'! |
1 | 210 |
|
1005 | 211 |
defaultDownArrowButtonForm |
212 |
"return the default form used for the scrollDown Button |
|
213 |
(if no styleSheet value is defined, and no form can be constructed)" |
|
214 |
||
215 |
<resource: #image> |
|
216 |
||
217 |
^ Form width:16 height:16 |
|
218 |
fromArray:#[2r00000000 2r00000000 |
|
219 |
2r00001111 2r11110000 |
|
220 |
2r00001000 2r00010000 |
|
221 |
2r00001000 2r00010000 |
|
222 |
2r00001000 2r00010000 |
|
223 |
2r00001000 2r00010000 |
|
224 |
2r00001000 2r00010000 |
|
225 |
2r01111000 2r00011110 |
|
226 |
2r01000000 2r00000010 |
|
227 |
2r00100000 2r00000100 |
|
228 |
2r00010000 2r00001000 |
|
229 |
2r00001000 2r00010000 |
|
230 |
2r00000100 2r00100000 |
|
231 |
2r00000010 2r01000000 |
|
232 |
2r00000001 2r10000000 |
|
233 |
2r00000000 2r00000000] |
|
1008 | 234 |
|
235 |
" |
|
236 |
self defaultDownArrowButtonForm |
|
237 |
" |
|
238 |
||
1005 | 239 |
! |
240 |
||
241 |
defaultLeftArrowButtonForm |
|
242 |
"return the default form used for the scrollLeft Button |
|
243 |
(if no styleSheet value is defined, and no form can be constructed)" |
|
244 |
||
245 |
<resource: #image> |
|
246 |
||
247 |
^ Form width:16 height:16 |
|
248 |
fromArray:#[2r00000000 2r00000000 |
|
249 |
2r00000001 2r10000000 |
|
250 |
2r00000010 2r10000000 |
|
251 |
2r00000100 2r10000000 |
|
252 |
2r00001000 2r11111110 |
|
253 |
2r00010000 2r00000010 |
|
254 |
2r00100000 2r00000010 |
|
255 |
2r01000000 2r00000010 |
|
256 |
2r01000000 2r00000010 |
|
257 |
2r00100000 2r00000010 |
|
258 |
2r00010000 2r00000010 |
|
259 |
2r00001000 2r11111110 |
|
260 |
2r00000100 2r10000000 |
|
261 |
2r00000010 2r10000000 |
|
262 |
2r00000001 2r10000000 |
|
263 |
2r00000000 2r00000000] |
|
264 |
||
1008 | 265 |
" |
266 |
self defaultLeftArrowButtonForm |
|
267 |
" |
|
268 |
||
1005 | 269 |
! |
270 |
||
271 |
defaultRightArrowButtonForm |
|
272 |
"return the default form used for the scrollRight Button |
|
273 |
(if no styleSheet value is defined, and no form can be constructed)" |
|
274 |
||
275 |
<resource: #image> |
|
276 |
||
277 |
^ Form width:16 height:16 |
|
278 |
fromArray:#[2r00000000 2r00000000 |
|
279 |
2r00000001 2r10000000 |
|
280 |
2r00000001 2r01000000 |
|
281 |
2r00000001 2r00100000 |
|
282 |
2r01111111 2r00010000 |
|
283 |
2r01000000 2r00001000 |
|
284 |
2r01000000 2r00000100 |
|
285 |
2r01000000 2r00000010 |
|
286 |
2r01000000 2r00000010 |
|
287 |
2r01000000 2r00000100 |
|
288 |
2r01000000 2r00001000 |
|
289 |
2r01111111 2r00010000 |
|
290 |
2r00000001 2r00100000 |
|
291 |
2r00000001 2r01000000 |
|
292 |
2r00000001 2r10000000 |
|
293 |
2r00000000 2r00000000] |
|
294 |
||
1008 | 295 |
" |
296 |
self defaultRightArrowButtonForm |
|
297 |
" |
|
298 |
||
1005 | 299 |
! |
300 |
||
301 |
defaultUpArrowButtonForm |
|
302 |
"return the default form used for the scrollUp Button |
|
303 |
(if no styleSheet value is defined, and no form can be constructed)" |
|
304 |
||
305 |
<resource: #image> |
|
306 |
||
307 |
^ Form width:16 height:16 |
|
308 |
fromArray:#[2r00000000 2r00000000 |
|
309 |
2r00000001 2r10000000 |
|
310 |
2r00000010 2r01000000 |
|
311 |
2r00000100 2r00100000 |
|
312 |
2r00001000 2r00010000 |
|
313 |
2r00010000 2r00001000 |
|
314 |
2r00100000 2r00000100 |
|
315 |
2r01000000 2r00000010 |
|
316 |
2r01111000 2r00011110 |
|
317 |
2r00001000 2r00010000 |
|
318 |
2r00001000 2r00010000 |
|
319 |
2r00001000 2r00010000 |
|
320 |
2r00001000 2r00010000 |
|
321 |
2r00001000 2r00010000 |
|
322 |
2r00001111 2r11110000 |
|
323 |
2r00000000 2r00000000] |
|
324 |
||
1008 | 325 |
" |
326 |
self defaultUpArrowButtonForm |
|
327 |
" |
|
328 |
||
1005 | 329 |
! |
330 |
||
38 | 331 |
downArrowButtonForm:style on:aDevice |
959 | 332 |
"return the form used for the scrollDown Button" |
1 | 333 |
|
923
a6ee1a239fc0
resource spec updated; cache device form
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
334 |
<resource: #style (#arrowButtonDownForm)> |
a6ee1a239fc0
resource spec updated; cache device form
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
335 |
|
59 | 336 |
|form| |
38 | 337 |
|
338 |
" |
|
339 |
use cached form, if device is appropriate |
|
340 |
" |
|
59 | 341 |
CachedStyle ~~ style ifTrue:[ |
657 | 342 |
UpArrowForm := DownArrowForm := LeftArrowForm := RightArrowForm := nil |
59 | 343 |
]. |
344 |
||
38 | 345 |
((aDevice == Display) and:[DownArrowForm notNil]) ifTrue:[ |
657 | 346 |
^ DownArrowForm |
38 | 347 |
]. |
348 |
||
154 | 349 |
DownArrowForm := StyleSheet at:'arrowButtonDownForm' default:nil. |
350 |
DownArrowForm notNil ifTrue:[ |
|
925 | 351 |
^ DownArrowForm |
154 | 352 |
]. |
353 |
||
38 | 354 |
" |
59 | 355 |
special treatment for st80 arrows |
356 |
- they do not really fit into the general (bitmap) scheme ... |
|
357 |
(i.e. they are computed instead of drawn from a bitmap) |
|
38 | 358 |
" |
59 | 359 |
style ~~ #st80 ifTrue:[ |
657 | 360 |
DownArrowFormFile notNil ifTrue:[ |
899 | 361 |
form := Image fromFile:DownArrowFormFile resolution:100 on:aDevice. |
657 | 362 |
form isNil ifTrue:[ |
899 | 363 |
form := Image fromFile:('bitmaps/' , DownArrowFormFile) resolution:100 on:aDevice. |
364 |
form isNil ifTrue:[ |
|
926 | 365 |
'ArrowButton [info]: no bitmapFile: ' infoPrint. DownArrowFormFile infoPrintCR. |
899 | 366 |
] |
657 | 367 |
] |
368 |
] |
|
38 | 369 |
]. |
6 | 370 |
|
38 | 371 |
" |
372 |
form to use as a fallback, if no bitmap file is present |
|
373 |
(actually not really needed - just to show something useful, in |
|
374 |
case of a bad installation) |
|
375 |
" |
|
376 |
form isNil ifTrue:[ |
|
657 | 377 |
style == #st80 ifTrue:[ |
378 |
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
|
379 |
form isNil ifTrue:[^ nil]. |
657 | 380 |
form clear. |
381 |
form lineWidth:2. |
|
382 |
form capStyle:#round. |
|
383 |
form paint:(Color colorId:1). |
|
384 |
form displayLineFromX:0 y:2 toX:4 y:6. |
|
901 | 385 |
form displayLineFromX:4 y:6 toX:8 y:2. |
386 |
form beImmediateForm. |
|
657 | 387 |
] ifFalse:[ |
1005 | 388 |
form := self defaultDownArrowButtonForm on:aDevice. |
270
aa6a36e199e7
be tolerant in case form creation fails
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
389 |
form isNil ifTrue:[^ nil]. |
657 | 390 |
]. |
1 | 391 |
]. |
38 | 392 |
|
393 |
" |
|
394 |
remember form for next use |
|
395 |
" |
|
396 |
(aDevice == Display) ifTrue:[ |
|
657 | 397 |
CachedStyle := style. |
398 |
DownArrowForm := form |
|
38 | 399 |
]. |
400 |
||
401 |
^ form |
|
657 | 402 |
|
959 | 403 |
"Modified: 17.1.1997 / 23:15:17 / cg" |
1 | 404 |
! |
405 |
||
38 | 406 |
leftArrowButtonForm:style on:aDevice |
959 | 407 |
"return the form used for the scrollLeft Button" |
38 | 408 |
|
923
a6ee1a239fc0
resource spec updated; cache device form
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
409 |
<resource: #style (#arrowButtonLeftForm)> |
a6ee1a239fc0
resource spec updated; cache device form
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
410 |
|
59 | 411 |
|form| |
38 | 412 |
|
413 |
" |
|
414 |
use cached form, if device is appropriate |
|
415 |
" |
|
59 | 416 |
CachedStyle ~~ style ifTrue:[ |
657 | 417 |
UpArrowForm := DownArrowForm := LeftArrowForm := RightArrowForm := nil |
59 | 418 |
]. |
419 |
||
38 | 420 |
((aDevice == Display) and:[LeftArrowForm notNil]) ifTrue:[ |
657 | 421 |
^ LeftArrowForm |
38 | 422 |
]. |
423 |
||
154 | 424 |
LeftArrowForm := StyleSheet at:'arrowButtonLeftForm' default:nil. |
425 |
LeftArrowForm notNil ifTrue:[ |
|
657 | 426 |
^ LeftArrowForm |
154 | 427 |
]. |
428 |
||
38 | 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:[ |
657 | 435 |
LeftArrowFormFile notNil ifTrue:[ |
899 | 436 |
form := Image fromFile:LeftArrowFormFile resolution:100 on:aDevice. |
657 | 437 |
form isNil ifTrue:[ |
899 | 438 |
form := Image fromFile:'bitmaps/' , LeftArrowFormFile resolution:100 on:aDevice. |
439 |
form isNil ifTrue:[ |
|
926 | 440 |
'ArrowButton [info]: no bitmapFile: ' infoPrint. LeftArrowFormFile infoPrintCR. |
899 | 441 |
] |
657 | 442 |
] |
443 |
] |
|
38 | 444 |
]. |
6 | 445 |
|
38 | 446 |
" |
447 |
form to use as a fallback, if no bitmap file is present |
|
448 |
(actually not really needed - just to show something useful, in |
|
449 |
case of a bad installation) |
|
450 |
" |
|
451 |
form isNil ifTrue:[ |
|
657 | 452 |
style == #st80 ifTrue:[ |
453 |
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
|
454 |
form isNil ifTrue:[^ nil]. |
657 | 455 |
form clear. |
456 |
form lineWidth:2. |
|
457 |
form capStyle:#round. |
|
458 |
form paint:(Color colorId:1). |
|
459 |
form displayLineFromX:6 y:0 toX:2 y:4. |
|
460 |
form displayLineFromX:2 y:4 toX:6 y:8. |
|
901 | 461 |
form beImmediateForm. |
657 | 462 |
] ifFalse:[ |
1005 | 463 |
form := self defaultLeftArrowButtonForm on:aDevice. |
270
aa6a36e199e7
be tolerant in case form creation fails
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
464 |
form isNil ifTrue:[^ nil]. |
657 | 465 |
]. |
1 | 466 |
]. |
38 | 467 |
|
468 |
" |
|
469 |
remember form for next use |
|
470 |
" |
|
471 |
(aDevice == Display) ifTrue:[ |
|
657 | 472 |
CachedStyle := style. |
473 |
LeftArrowForm := form |
|
38 | 474 |
]. |
475 |
||
476 |
^ form |
|
657 | 477 |
|
959 | 478 |
"Modified: 17.1.1997 / 23:15:14 / cg" |
1 | 479 |
! |
480 |
||
38 | 481 |
rightArrowButtonForm:style on:aDevice |
959 | 482 |
"return the form used for the scrollRight Button" |
38 | 483 |
|
923
a6ee1a239fc0
resource spec updated; cache device form
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
484 |
<resource: #style (#arrowButtonRightForm)> |
a6ee1a239fc0
resource spec updated; cache device form
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
485 |
|
59 | 486 |
|form| |
38 | 487 |
|
488 |
" |
|
489 |
use cached form, if device is appropriate |
|
490 |
" |
|
59 | 491 |
CachedStyle ~~ style ifTrue:[ |
657 | 492 |
UpArrowForm := DownArrowForm := LeftArrowForm := RightArrowForm := nil |
59 | 493 |
]. |
494 |
||
38 | 495 |
((aDevice == Display) and:[RightArrowForm notNil]) ifTrue:[ |
657 | 496 |
^ RightArrowForm |
38 | 497 |
]. |
498 |
||
154 | 499 |
RightArrowForm := StyleSheet at:'arrowButtonRightForm' default:nil. |
500 |
RightArrowForm notNil ifTrue:[ |
|
657 | 501 |
^ RightArrowForm |
154 | 502 |
]. |
503 |
||
38 | 504 |
" |
59 | 505 |
special treatment for st80 arrows |
506 |
- they do not really fit into the general (bitmap) scheme ... |
|
507 |
(i.e. they are computed instead of drawn from a bitmap) |
|
38 | 508 |
" |
59 | 509 |
style ~~ #st80 ifTrue:[ |
657 | 510 |
RightArrowFormFile notNil ifTrue:[ |
899 | 511 |
form := Image fromFile:RightArrowFormFile resolution:100 on:aDevice. |
657 | 512 |
form isNil ifTrue:[ |
899 | 513 |
form := Image fromFile:'bitmaps/' , RightArrowFormFile resolution:100 on:aDevice. |
514 |
form isNil ifTrue:[ |
|
926 | 515 |
'ArrowButton [info]: no bitmapFile: ' infoPrint. RightArrowFormFile infoPrintCR. |
899 | 516 |
] |
657 | 517 |
] |
518 |
] |
|
38 | 519 |
]. |
6 | 520 |
|
38 | 521 |
" |
522 |
form to use as a fallback, if no bitmap file is present |
|
523 |
(actually not really needed - just to show something useful, in |
|
524 |
case of a bad installation) |
|
525 |
" |
|
526 |
form isNil ifTrue:[ |
|
657 | 527 |
style == #st80 ifTrue:[ |
528 |
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
|
529 |
form isNil ifTrue:[^ nil]. |
657 | 530 |
form clear. |
531 |
form lineWidth:2. |
|
532 |
form capStyle:#round. |
|
533 |
form paint:(Color colorId:1). |
|
534 |
form displayLineFromX:2 y:0 toX:6 y:4. |
|
901 | 535 |
form displayLineFromX:6 y:4 toX:2 y:8. |
536 |
form beImmediateForm. |
|
657 | 537 |
] ifFalse:[ |
1005 | 538 |
form := self defaultRightArrowButtonForm on:aDevice. |
270
aa6a36e199e7
be tolerant in case form creation fails
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
539 |
form isNil ifTrue:[^ nil]. |
657 | 540 |
]. |
1 | 541 |
]. |
38 | 542 |
|
543 |
" |
|
544 |
remember form for next use |
|
545 |
" |
|
546 |
(aDevice == Display) ifTrue:[ |
|
657 | 547 |
CachedStyle := style. |
548 |
RightArrowForm := form |
|
38 | 549 |
]. |
550 |
||
551 |
^ form |
|
657 | 552 |
|
959 | 553 |
"Modified: 17.1.1997 / 23:15:20 / cg" |
1 | 554 |
! |
555 |
||
205 | 556 |
upArrowButtonForm:style on:aDevice |
557 |
"return the form used for the scrollUp Button" |
|
558 |
||
923
a6ee1a239fc0
resource spec updated; cache device form
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
559 |
<resource: #style (#arrowButtonUpForm)> |
a6ee1a239fc0
resource spec updated; cache device form
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
560 |
|
205 | 561 |
|form| |
562 |
||
563 |
" |
|
564 |
use cached form, if device is appropriate |
|
565 |
" |
|
566 |
CachedStyle ~~ style ifTrue:[ |
|
657 | 567 |
UpArrowForm := DownArrowForm := LeftArrowForm := RightArrowForm := nil |
205 | 568 |
]. |
569 |
||
570 |
((aDevice == Display) and:[UpArrowForm notNil]) ifTrue:[ |
|
657 | 571 |
^ UpArrowForm |
205 | 572 |
]. |
573 |
||
574 |
UpArrowForm := StyleSheet at:'arrowButtonUpForm' default:nil. |
|
575 |
UpArrowForm notNil ifTrue:[ |
|
925 | 576 |
^ UpArrowForm |
205 | 577 |
]. |
578 |
||
579 |
" |
|
580 |
special treatment for st80 arrows |
|
581 |
- they do not really fit into the general (bitmap) scheme ... |
|
582 |
(i.e. they are computed instead of drawn from a bitmap) |
|
583 |
" |
|
584 |
style ~~ #st80 ifTrue:[ |
|
657 | 585 |
UpArrowFormFile notNil ifTrue:[ |
899 | 586 |
form := Image fromFile:UpArrowFormFile resolution:100 on:aDevice. |
657 | 587 |
form isNil ifTrue:[ |
899 | 588 |
form := Image fromFile:'bitmaps/' , UpArrowFormFile resolution:100 on:aDevice. |
589 |
form isNil ifTrue:[ |
|
926 | 590 |
'ArrowButton [info]: no bitmapFile: ' infoPrint. UpArrowFormFile infoPrintCR. |
899 | 591 |
] |
657 | 592 |
] |
593 |
] |
|
205 | 594 |
]. |
595 |
||
596 |
" |
|
597 |
form to use as a fallback, if no bitmap file is present |
|
598 |
(actually not really needed - just to show something useful, in |
|
599 |
case of a bad installation) |
|
600 |
" |
|
601 |
form isNil ifTrue:[ |
|
657 | 602 |
style == #st80 ifTrue:[ |
603 |
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
|
604 |
form isNil ifTrue:[^ nil]. |
657 | 605 |
form clear. |
606 |
form lineWidth:2. |
|
607 |
form capStyle:#round. |
|
608 |
form paint:(Color colorId:1). |
|
609 |
form displayLineFromX:0 y:6 toX:4 y:2. |
|
610 |
form displayLineFromX:4 y:2 toX:8 y:6. |
|
901 | 611 |
form beImmediateForm. |
657 | 612 |
] ifFalse:[ |
1005 | 613 |
form := self defaultUpArrowButtonForm on:aDevice. |
657 | 614 |
form isNil ifTrue:[^ nil]. |
615 |
]. |
|
205 | 616 |
]. |
617 |
||
618 |
" |
|
619 |
remember form for next use |
|
620 |
" |
|
621 |
(aDevice == Display) ifTrue:[ |
|
657 | 622 |
CachedStyle := style. |
623 |
UpArrowForm := form |
|
205 | 624 |
]. |
625 |
||
626 |
^ form |
|
657 | 627 |
|
926 | 628 |
"Modified: 10.1.1997 / 15:15:20 / cg" |
1 | 629 |
! |
630 |
||
205 | 631 |
updateStyleCache |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
632 |
"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
|
633 |
|
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
634 |
<resource: #style (#arrowButtonStyle |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
635 |
#arrowButtonActiveLevel #arrowButtonPassiveLevel |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
636 |
#arrowButtonBackgroundColor #arrowButtonForegroundColor |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
637 |
#arrowButtonActiveBackgroundColor #arrowButtonActiveForegroundColor |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
638 |
#arrowButtonEnteredBackgroundColor #arrowButtonEnteredForegroundColor |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
639 |
#arrowButtonDisabledForegroundColor |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
640 |
#arrowButtonDownForm #arrowButtonUpForm |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
641 |
#arrowButtonLeftForm #arrowButtonRightForm |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
642 |
#arrowButtonDownFormFile #arrowButtonUpFormFile |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
643 |
#arrowButtonLeftFormFile #arrowButtonRightFormFile)> |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
644 |
|
205 | 645 |
DefaultArrowStyle := StyleSheet at:'arrowButtonStyle' default:StyleSheet name. |
646 |
DefaultArrowStyle := DefaultArrowStyle asSymbol. |
|
647 |
||
648 |
DefaultArrowButtonActiveLevel := StyleSheet at:'arrowButtonActiveLevel' default:nil. |
|
649 |
DefaultArrowButtonPassiveLevel := StyleSheet at:'arrowButtonPassiveLevel' default:nil. |
|
650 |
||
651 |
DefaultBackgroundColor := StyleSheet colorAt:'arrowButtonBackgroundColor'. |
|
652 |
DefaultForegroundColor := StyleSheet colorAt:'arrowButtonForegroundColor'. |
|
653 |
DefaultActiveBackgroundColor := StyleSheet colorAt:'arrowButtonActiveBackgroundColor'. |
|
654 |
DefaultActiveForegroundColor := StyleSheet colorAt:'arrowButtonActiveForegroundColor'. |
|
655 |
DefaultEnteredBackgroundColor := StyleSheet colorAt:'arrowButtonEnteredBackgroundColor'. |
|
656 |
DefaultEnteredForegroundColor := StyleSheet colorAt:'arrowButtonEnteredForegroundColor'. |
|
657 |
DefaultDisabledForegroundColor := StyleSheet colorAt:'arrowButtonDisabledForegroundColor'. |
|
658 |
||
659 |
DownArrowForm := StyleSheet at:'arrowButtonDownForm' default:nil. |
|
660 |
UpArrowForm := StyleSheet at:'arrowButtonUpForm' default:nil. |
|
661 |
LeftArrowForm := StyleSheet at:'arrowButtonLeftForm' default:nil. |
|
662 |
RightArrowForm := StyleSheet at:'arrowButtonRightForm' default:nil. |
|
1 | 663 |
|
205 | 664 |
UpArrowFormFile := DownArrowFormFile := LeftArrowFormFile := RightArrowFormFile := nil. |
665 |
UpArrowForm isNil ifTrue:[ |
|
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
666 |
UpArrowFormFile := StyleSheet at:'arrowButtonUpFormFile' default:'ScrollUp.xbm'. |
205 | 667 |
]. |
668 |
DownArrowForm isNil ifTrue:[ |
|
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
669 |
DownArrowFormFile := StyleSheet at:'arrowButtonDownFormFile' default:'ScrollDn.xbm'. |
205 | 670 |
]. |
671 |
LeftArrowForm isNil ifTrue:[ |
|
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
672 |
LeftArrowFormFile := StyleSheet at:'arrowButtonLeftFormFile' default:'ScrollLt.xbm'. |
205 | 673 |
]. |
674 |
RightArrowForm isNil ifTrue:[ |
|
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
675 |
RightArrowFormFile := StyleSheet at:'arrowButtonRightFormFile' default:'ScrollRt.xbm'. |
205 | 676 |
]. |
677 |
||
678 |
" |
|
679 |
self updateStyleCache |
|
680 |
" |
|
681 |
||
682 |
"Modified: 31.8.1995 / 03:01:14 / claus" |
|
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
683 |
"Modified: 1.3.1996 / 13:45:57 / cg" |
1 | 684 |
! ! |
685 |
||
686 |
!ArrowButton methodsFor:'accessing'! |
|
687 |
||
1053
b9f8bf97815c
remember direction; new-creation defaults to #up
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
688 |
direction |
b9f8bf97815c
remember direction; new-creation defaults to #up
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
689 |
"return the buttons direction - a symbol" |
b9f8bf97815c
remember direction; new-creation defaults to #up
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
690 |
|
b9f8bf97815c
remember direction; new-creation defaults to #up
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
691 |
^ direction |
b9f8bf97815c
remember direction; new-creation defaults to #up
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
692 |
! |
b9f8bf97815c
remember direction; new-creation defaults to #up
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
693 |
|
1 | 694 |
direction:aDirectionSymbol |
966 | 695 |
"create and return a new arrow button in aView" |
696 |
||
6 | 697 |
|form| |
698 |
||
1 | 699 |
aDirectionSymbol == #up ifTrue:[ |
966 | 700 |
form := (self class upArrowButtonForm:arrowStyle on:device). |
1 | 701 |
]. |
702 |
aDirectionSymbol == #down ifTrue:[ |
|
966 | 703 |
form := (self class downArrowButtonForm:arrowStyle on:device). |
1 | 704 |
]. |
705 |
aDirectionSymbol == #left ifTrue:[ |
|
966 | 706 |
form := (self class leftArrowButtonForm:arrowStyle on:device). |
1 | 707 |
]. |
708 |
aDirectionSymbol == #right ifTrue:[ |
|
966 | 709 |
form := (self class rightArrowButtonForm:arrowStyle on:device). |
1 | 710 |
]. |
1053
b9f8bf97815c
remember direction; new-creation defaults to #up
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
711 |
direction := aDirectionSymbol. |
6 | 712 |
self form:form |
966 | 713 |
|
1041 | 714 |
"Modified: 24.2.1997 / 21:19:59 / cg" |
1 | 715 |
! ! |
716 |
||
717 |
!ArrowButton methodsFor:'initialization'! |
|
718 |
||
719 |
initStyle |
|
966 | 720 |
"setup viewStyle specifics" |
721 |
||
1 | 722 |
super initStyle. |
59 | 723 |
|
60 | 724 |
DefaultBackgroundColor notNil ifTrue:[ |
966 | 725 |
bgColor := DefaultBackgroundColor on:device |
60 | 726 |
]. |
727 |
DefaultForegroundColor notNil ifTrue:[ |
|
966 | 728 |
fgColor := DefaultForegroundColor on:device |
60 | 729 |
]. |
59 | 730 |
DefaultActiveForegroundColor notNil ifTrue:[ |
966 | 731 |
activeFgColor := DefaultActiveForegroundColor on:device |
59 | 732 |
]. |
733 |
DefaultActiveBackgroundColor notNil ifTrue:[ |
|
966 | 734 |
activeBgColor := DefaultActiveBackgroundColor on:device |
59 | 735 |
]. |
736 |
DefaultEnteredForegroundColor notNil ifTrue:[ |
|
966 | 737 |
enteredFgColor := DefaultEnteredForegroundColor on:device |
59 | 738 |
]. |
739 |
DefaultEnteredBackgroundColor notNil ifTrue:[ |
|
966 | 740 |
enteredBgColor := DefaultEnteredBackgroundColor on:device |
59 | 741 |
]. |
153 | 742 |
DefaultDisabledForegroundColor notNil ifTrue:[ |
966 | 743 |
disabledFgColor := DefaultDisabledForegroundColor on:device |
153 | 744 |
]. |
745 |
||
59 | 746 |
arrowStyle := DefaultArrowStyle. |
747 |
||
128 | 748 |
DefaultArrowButtonActiveLevel notNil ifTrue:[onLevel := DefaultArrowButtonActiveLevel]. |
749 |
DefaultArrowButtonPassiveLevel notNil ifTrue:[offLevel := DefaultArrowButtonPassiveLevel]. |
|
750 |
offLevel ~~ level ifTrue:[self level:offLevel]. |
|
751 |
||
752 |
"/ " |
|
753 |
"/ special treatment for motif arrows |
|
754 |
"/ - they do not really fit into the general (bitmap) scheme ... |
|
755 |
"/ " |
|
756 |
"/ arrowStyle == #motif ifTrue:[ |
|
757 |
"/ onLevel := 0. |
|
758 |
"/ offLevel := 0. |
|
759 |
"/ self level:0. |
|
760 |
"/ ] |
|
966 | 761 |
|
762 |
"Modified: 22.1.1997 / 11:57:00 / cg" |
|
205 | 763 |
! |
764 |
||
765 |
initialize |
|
1105
980fe41d7f0a
assign colorMap AFTER conversion to a device form
Claus Gittinger <cg@exept.de>
parents:
1053
diff
changeset
|
766 |
|
205 | 767 |
super initialize. |
1105
980fe41d7f0a
assign colorMap AFTER conversion to a device form
Claus Gittinger <cg@exept.de>
parents:
1053
diff
changeset
|
768 |
hSpace := vSpace := 0. |
205 | 769 |
controller beTriggerOnDown. |
1105
980fe41d7f0a
assign colorMap AFTER conversion to a device form
Claus Gittinger <cg@exept.de>
parents:
1053
diff
changeset
|
770 |
|
980fe41d7f0a
assign colorMap AFTER conversion to a device form
Claus Gittinger <cg@exept.de>
parents:
1053
diff
changeset
|
771 |
"Modified: 6.3.1997 / 20:58:49 / cg" |
1 | 772 |
! ! |
773 |
||
6 | 774 |
!ArrowButton methodsFor:'redrawing'! |
775 |
||
776 |
drawWith:fg and:bg |
|
777 |
"this is a q&d hack for motif ..." |
|
778 |
||
1137
5ec9db9453f1
must release cached device image, when topLeft/botRight
Claus Gittinger <cg@exept.de>
parents:
1105
diff
changeset
|
779 |
|topLeft botRight noColor allColor isString orgX orgY r colors| |
6 | 780 |
|
59 | 781 |
arrowStyle ~~ #motif ifTrue:[ |
765
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
782 |
^ super drawWith:fg and:bg. |
6 | 783 |
]. |
784 |
||
59 | 785 |
" |
786 |
the code below does a lot of bitmap drawing, but allows |
|
787 |
to 3D-ify any logo (it draws it displaced by some pixels |
|
788 |
to the upper left in one-color and displaced to the |
|
60 | 789 |
lower right in the other color). It should be rewritten to |
790 |
cache the result for later drawing operations. |
|
59 | 791 |
" |
6 | 792 |
logo notNil ifTrue:[ |
765
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
793 |
self paint:bg. |
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
794 |
self fillRectangleX:0 y:0 width:width height:height. |
6 | 795 |
|
765
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
796 |
shadowColor := shadowColor on:device. |
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
797 |
lightColor := lightColor on:device. |
153 | 798 |
|
765
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
799 |
controller pressed ifTrue:[ |
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
800 |
topLeft := shadowColor. |
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
801 |
botRight := lightColor |
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
802 |
] ifFalse:[ |
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
803 |
topLeft := lightColor. |
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
804 |
botRight := shadowColor |
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
805 |
]. |
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
806 |
|
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
807 |
isString := logo isString. |
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
808 |
|
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
809 |
isString ifFalse:[ |
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
810 |
logo depth ~~ 1 ifTrue:[ |
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
811 |
"/ allow for deep logos (for motif) |
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
812 |
"/ one catch: if the view background is a complex pixmap |
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
813 |
"/ we cannot use this as colorMap entry. |
1105
980fe41d7f0a
assign colorMap AFTER conversion to a device form
Claus Gittinger <cg@exept.de>
parents:
1053
diff
changeset
|
814 |
"/ therefore, compute the average colors and take these |
765
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
815 |
"/ (this looks ok for buttons ...) |
38 | 816 |
|
1137
5ec9db9453f1
must release cached device image, when topLeft/botRight
Claus Gittinger <cg@exept.de>
parents:
1105
diff
changeset
|
817 |
r := (0@0 corner:10@10). |
1105
980fe41d7f0a
assign colorMap AFTER conversion to a device form
Claus Gittinger <cg@exept.de>
parents:
1053
diff
changeset
|
818 |
|
1137
5ec9db9453f1
must release cached device image, when topLeft/botRight
Claus Gittinger <cg@exept.de>
parents:
1105
diff
changeset
|
819 |
colors := (Array with:(bg averageColorIn:r) |
5ec9db9453f1
must release cached device image, when topLeft/botRight
Claus Gittinger <cg@exept.de>
parents:
1105
diff
changeset
|
820 |
with:(topLeft averageColorIn:r) |
5ec9db9453f1
must release cached device image, when topLeft/botRight
Claus Gittinger <cg@exept.de>
parents:
1105
diff
changeset
|
821 |
with:(botRight averageColorIn:r) |
5ec9db9453f1
must release cached device image, when topLeft/botRight
Claus Gittinger <cg@exept.de>
parents:
1105
diff
changeset
|
822 |
with:(fg averageColorIn:r)). |
5ec9db9453f1
must release cached device image, when topLeft/botRight
Claus Gittinger <cg@exept.de>
parents:
1105
diff
changeset
|
823 |
colors ~= logo colorMap ifTrue:[ |
5ec9db9453f1
must release cached device image, when topLeft/botRight
Claus Gittinger <cg@exept.de>
parents:
1105
diff
changeset
|
824 |
logo release. |
5ec9db9453f1
must release cached device image, when topLeft/botRight
Claus Gittinger <cg@exept.de>
parents:
1105
diff
changeset
|
825 |
logo colorMap:colors. |
765
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
826 |
]. |
1137
5ec9db9453f1
must release cached device image, when topLeft/botRight
Claus Gittinger <cg@exept.de>
parents:
1105
diff
changeset
|
827 |
logo photometric:#palette. |
5ec9db9453f1
must release cached device image, when topLeft/botRight
Claus Gittinger <cg@exept.de>
parents:
1105
diff
changeset
|
828 |
logo := logo on:device. |
5ec9db9453f1
must release cached device image, when topLeft/botRight
Claus Gittinger <cg@exept.de>
parents:
1105
diff
changeset
|
829 |
|
765
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
830 |
self displayForm:logo x:labelOriginX y:labelOriginY. |
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
831 |
^ self |
1105
980fe41d7f0a
assign colorMap AFTER conversion to a device form
Claus Gittinger <cg@exept.de>
parents:
1053
diff
changeset
|
832 |
]. |
980fe41d7f0a
assign colorMap AFTER conversion to a device form
Claus Gittinger <cg@exept.de>
parents:
1053
diff
changeset
|
833 |
logo := logo on:device. |
1137
5ec9db9453f1
must release cached device image, when topLeft/botRight
Claus Gittinger <cg@exept.de>
parents:
1105
diff
changeset
|
834 |
orgX := labelOriginX. |
5ec9db9453f1
must release cached device image, when topLeft/botRight
Claus Gittinger <cg@exept.de>
parents:
1105
diff
changeset
|
835 |
orgY := labelOriginY. |
5ec9db9453f1
must release cached device image, when topLeft/botRight
Claus Gittinger <cg@exept.de>
parents:
1105
diff
changeset
|
836 |
] ifTrue:[ |
765
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
837 |
orgY := height - font height // 2 + font ascent. |
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
838 |
orgX := width - labelOriginX // 4 - 1. |
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
839 |
]. |
1105
980fe41d7f0a
assign colorMap AFTER conversion to a device form
Claus Gittinger <cg@exept.de>
parents:
1053
diff
changeset
|
840 |
|
765
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
841 |
self paint:topLeft. |
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
842 |
#(-1 0 -1) with:#(-1 -1 0) do:[:dX :dY | |
1137
5ec9db9453f1
must release cached device image, when topLeft/botRight
Claus Gittinger <cg@exept.de>
parents:
1105
diff
changeset
|
843 |
|x y| |
5ec9db9453f1
must release cached device image, when topLeft/botRight
Claus Gittinger <cg@exept.de>
parents:
1105
diff
changeset
|
844 |
|
5ec9db9453f1
must release cached device image, when topLeft/botRight
Claus Gittinger <cg@exept.de>
parents:
1105
diff
changeset
|
845 |
x := orgX + dX. |
5ec9db9453f1
must release cached device image, when topLeft/botRight
Claus Gittinger <cg@exept.de>
parents:
1105
diff
changeset
|
846 |
y := orgY + dY. |
5ec9db9453f1
must release cached device image, when topLeft/botRight
Claus Gittinger <cg@exept.de>
parents:
1105
diff
changeset
|
847 |
|
765
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
848 |
isString ifTrue:[ |
1137
5ec9db9453f1
must release cached device image, when topLeft/botRight
Claus Gittinger <cg@exept.de>
parents:
1105
diff
changeset
|
849 |
self displayString:logo x:x y:y. |
765
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
850 |
] ifFalse:[ |
1137
5ec9db9453f1
must release cached device image, when topLeft/botRight
Claus Gittinger <cg@exept.de>
parents:
1105
diff
changeset
|
851 |
self displayForm:logo x:x y:y. |
765
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
852 |
] |
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
853 |
]. |
6 | 854 |
|
765
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
855 |
self paint:botRight. |
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
856 |
#(1 1 0) with:#(0 1 1) do:[:dX :dY | |
1137
5ec9db9453f1
must release cached device image, when topLeft/botRight
Claus Gittinger <cg@exept.de>
parents:
1105
diff
changeset
|
857 |
|x y| |
5ec9db9453f1
must release cached device image, when topLeft/botRight
Claus Gittinger <cg@exept.de>
parents:
1105
diff
changeset
|
858 |
|
5ec9db9453f1
must release cached device image, when topLeft/botRight
Claus Gittinger <cg@exept.de>
parents:
1105
diff
changeset
|
859 |
x := orgX + dX. |
5ec9db9453f1
must release cached device image, when topLeft/botRight
Claus Gittinger <cg@exept.de>
parents:
1105
diff
changeset
|
860 |
y := orgY + dY. |
5ec9db9453f1
must release cached device image, when topLeft/botRight
Claus Gittinger <cg@exept.de>
parents:
1105
diff
changeset
|
861 |
|
765
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
862 |
isString ifTrue:[ |
1137
5ec9db9453f1
must release cached device image, when topLeft/botRight
Claus Gittinger <cg@exept.de>
parents:
1105
diff
changeset
|
863 |
self displayString:logo x:x y:y. |
765
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
864 |
] ifFalse:[ |
1137
5ec9db9453f1
must release cached device image, when topLeft/botRight
Claus Gittinger <cg@exept.de>
parents:
1105
diff
changeset
|
865 |
self displayForm:logo x:x y:y. |
765
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
866 |
] |
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
867 |
]. |
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
868 |
|
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
869 |
" |
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
870 |
finally, the form itself |
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
871 |
" |
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
872 |
self paint:fg. |
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
873 |
isString ifTrue:[ |
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
874 |
self displayString:logo x:orgX y:orgY. |
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
875 |
] ifFalse:[ |
1137
5ec9db9453f1
must release cached device image, when topLeft/botRight
Claus Gittinger <cg@exept.de>
parents:
1105
diff
changeset
|
876 |
self displayForm:logo x:orgX y:orgY. |
765
ea6ecf2a5b30
keep deep device image cached
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
877 |
] |
6 | 878 |
] |
153 | 879 |
|
880 |
"Modified: 31.8.1995 / 03:03:12 / claus" |
|
1137
5ec9db9453f1
must release cached device image, when topLeft/botRight
Claus Gittinger <cg@exept.de>
parents:
1105
diff
changeset
|
881 |
"Modified: 19.3.1997 / 17:11:22 / cg" |
6 | 882 |
! ! |
205 | 883 |
|
899 | 884 |
!ArrowButton class methodsFor:'documentation'! |
205 | 885 |
|
886 |
version |
|
1137
5ec9db9453f1
must release cached device image, when topLeft/botRight
Claus Gittinger <cg@exept.de>
parents:
1105
diff
changeset
|
887 |
^ '$Header: /cvs/stx/stx/libwidg/Attic/ArrButton.st,v 1.41 1997-03-19 16:12:21 cg Exp $' |
205 | 888 |
! ! |