0
|
1 |
"
|
6
|
2 |
COPYRIGHT (c) 1992 by Claus Gittinger
|
80
|
3 |
All Rights Reserved
|
0
|
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 |
Object subclass:#Cursor
|
|
14 |
instanceVariableNames:'shape sourceForm maskForm hotX hotY
|
80
|
15 |
device cursorId'
|
23
|
16 |
classVariableNames: 'Lobby
|
80
|
17 |
DefaultFgColor DefaultBgColor
|
0
|
18 |
|
80
|
19 |
NormalCursor HandCursor ArrowCursor
|
|
20 |
WaitCursor CrossHairCursor OriginCursor
|
|
21 |
CornerCursor SquareCursor FourWayCursor
|
|
22 |
UpDownArrowCursor LeftRightArrowCursor'
|
0
|
23 |
poolDictionaries:''
|
|
24 |
category:'Graphics-Support'
|
|
25 |
!
|
|
26 |
|
|
27 |
Cursor comment:'
|
6
|
28 |
COPYRIGHT (c) 1992 by Claus Gittinger
|
80
|
29 |
All Rights Reserved
|
54
|
30 |
|
144
|
31 |
$Header: /cvs/stx/stx/libview/Cursor.st,v 1.17 1995-05-16 17:12:35 claus Exp $
|
0
|
32 |
'!
|
|
33 |
|
|
34 |
!Cursor class methodsFor:'documentation'!
|
|
35 |
|
46
|
36 |
copyright
|
|
37 |
"
|
|
38 |
COPYRIGHT (c) 1992 by Claus Gittinger
|
80
|
39 |
All Rights Reserved
|
46
|
40 |
|
|
41 |
This software is furnished under a license and may be used
|
|
42 |
only in accordance with the terms of that license and with the
|
|
43 |
inclusion of the above copyright notice. This software may not
|
|
44 |
be provided or otherwise made available to, or used by, any
|
|
45 |
other person. No title to or ownership of the software is
|
|
46 |
hereby transferred.
|
|
47 |
"
|
|
48 |
!
|
|
49 |
|
|
50 |
version
|
|
51 |
"
|
144
|
52 |
$Header: /cvs/stx/stx/libview/Cursor.st,v 1.17 1995-05-16 17:12:35 claus Exp $
|
46
|
53 |
"
|
|
54 |
!
|
|
55 |
|
0
|
56 |
documentation
|
38
|
57 |
"
|
|
58 |
I represents cursors in a device independent manner.
|
144
|
59 |
Normally, cursors are defined at view creation time,
|
|
60 |
via 'aView cursor:aCursor'.
|
0
|
61 |
|
38
|
62 |
Instance variables:
|
0
|
63 |
|
80
|
64 |
shape <Symbol> a shape (i.e. #arrow, #hand, ...) or nil
|
|
65 |
sourceForm <Form> if shape is nil, the source bits
|
|
66 |
maskForm <Form> if shape is nil, the mask bits
|
|
67 |
hotX <SmallInteger> if shape is nil, the hotSpot x of the cursor
|
|
68 |
hotY <SmallInteger> if shape is nil, the hotSpot y of the cursor
|
|
69 |
device <aDevice> the device, if associated to one
|
|
70 |
cursorId <anObject> the device-specific id if device is nonNil
|
0
|
71 |
|
38
|
72 |
class variables:
|
0
|
73 |
|
80
|
74 |
Lobby <Registry> keeps track of known device cursors
|
0
|
75 |
|
80
|
76 |
DefaultFgColor <Color> default foreground color for cursors (usually black)
|
|
77 |
DefaultBgColor <Color> default background color for cursors (usually white)
|
0
|
78 |
|
80
|
79 |
NormalCursor <Cursor> cached instance of normal (arrow) cursor
|
|
80 |
...
|
0
|
81 |
|
38
|
82 |
"
|
144
|
83 |
!
|
|
84 |
|
|
85 |
examples
|
|
86 |
"
|
|
87 |
get a standard cursor:
|
|
88 |
|
|
89 |
Cursor wait
|
|
90 |
Cursor stop
|
|
91 |
Cursor normal
|
|
92 |
|
|
93 |
create a custom cursor:
|
|
94 |
|
|
95 |
Cursor extent:16@16
|
|
96 |
fromArray:#[ 2r00000000 2r00000000
|
|
97 |
2r00000000 2r00000000
|
|
98 |
2r00000000 2r00000000
|
|
99 |
2r11111111 2r11111111
|
|
100 |
2r11111111 2r11111111
|
|
101 |
2r00000000 2r00000000
|
|
102 |
2r00000000 2r00000000
|
|
103 |
2r11111111 2r11111111
|
|
104 |
2r11111111 2r11111111
|
|
105 |
2r00000000 2r00000000
|
|
106 |
2r00000000 2r00000000
|
|
107 |
2r11111111 2r11111111
|
|
108 |
2r11111111 2r11111111
|
|
109 |
2r00000000 2r00000000
|
|
110 |
2r00000000 2r00000000
|
|
111 |
2r00000000 2r00000000]
|
|
112 |
offset:-8@-8
|
|
113 |
|
|
114 |
define a cursor for a view:
|
|
115 |
|
|
116 |
|v|
|
|
117 |
|
|
118 |
v := View new.
|
|
119 |
v cursor:Cursor stop.
|
|
120 |
v open.
|
|
121 |
|
|
122 |
with above custom cursor:
|
|
123 |
|
|
124 |
|v|
|
|
125 |
|
|
126 |
v := View new.
|
|
127 |
v cursor:(
|
|
128 |
Cursor extent:16@16
|
|
129 |
fromArray:#[ 2r00000000 2r00000000
|
|
130 |
2r00000000 2r00000000
|
|
131 |
2r00000000 2r00000000
|
|
132 |
2r11111111 2r11111111
|
|
133 |
2r11111111 2r11111111
|
|
134 |
2r00000000 2r00000000
|
|
135 |
2r00000000 2r00000000
|
|
136 |
2r11111111 2r11111111
|
|
137 |
2r11111111 2r11111111
|
|
138 |
2r00000000 2r00000000
|
|
139 |
2r00000000 2r00000000
|
|
140 |
2r11111111 2r11111111
|
|
141 |
2r11111111 2r11111111
|
|
142 |
2r00000000 2r00000000
|
|
143 |
2r00000000 2r00000000
|
|
144 |
2r00000000 2r00000000]
|
|
145 |
offset:-8@-8).
|
|
146 |
v open.
|
|
147 |
|
|
148 |
with multiple views:
|
|
149 |
|
|
150 |
|v1 v2 top|
|
|
151 |
|
|
152 |
top := StandardSystemView new.
|
|
153 |
top extent:300@300.
|
|
154 |
v1 := View origin:0.0@0.0 corner:1.0@0.5 in:top.
|
|
155 |
v1 viewBackground:(Color grey:75).
|
|
156 |
v1 cursor:Cursor thumbsUp.
|
|
157 |
v2 := View origin:0.0@0.5 corner:1.0@1.0 in:top.
|
|
158 |
v2 viewBackground:(Color white).
|
|
159 |
v2 cursor:Cursor wait.
|
|
160 |
top open.
|
|
161 |
|
|
162 |
|
|
163 |
show a cursor in ALL ST/X views for a while:
|
|
164 |
|
|
165 |
Cursor wait
|
|
166 |
showWhile:[
|
|
167 |
(Delay forSeconds:5) wait
|
|
168 |
]
|
|
169 |
|
|
170 |
|
|
171 |
show a cursor in a single view for a while:
|
|
172 |
|
|
173 |
|v1 v2 top|
|
|
174 |
|
|
175 |
top := StandardSystemView new.
|
|
176 |
top extent:300@300.
|
|
177 |
v1 := View origin:0.0@0.0 corner:1.0@0.5 in:top.
|
|
178 |
v1 viewBackground:(Color grey:75).
|
|
179 |
v2 := View origin:0.0@0.5 corner:1.0@1.0 in:top.
|
|
180 |
v2 viewBackground:(Color white).
|
|
181 |
top open.
|
|
182 |
|
|
183 |
v1 withCursor:Cursor wait
|
|
184 |
do:[
|
|
185 |
(Delay forSeconds:10) wait
|
|
186 |
]
|
|
187 |
|
|
188 |
|
|
189 |
show a cursor in all views belonging to a windowGroup:
|
|
190 |
(have to wait until top is visible to access windowGroup)
|
|
191 |
|
|
192 |
|v1 v2 top|
|
|
193 |
|
|
194 |
top := StandardSystemView new.
|
|
195 |
top extent:300@300.
|
|
196 |
v1 := View origin:0.0@0.0 corner:1.0@0.5 in:top.
|
|
197 |
v1 viewBackground:(Color grey:75).
|
|
198 |
v2 := View origin:0.0@0.5 corner:1.0@1.0 in:top.
|
|
199 |
v2 viewBackground:(Color white).
|
|
200 |
top open.
|
|
201 |
|
|
202 |
[top shown] whileFalse:[Processor yield].
|
|
203 |
top windowGroup
|
|
204 |
withCursor:Cursor wait
|
|
205 |
do:[
|
|
206 |
(Delay forSeconds:10) wait
|
|
207 |
]
|
|
208 |
"
|
0
|
209 |
! !
|
|
210 |
|
|
211 |
!Cursor class methodsFor:'initialization'!
|
|
212 |
|
|
213 |
initialize
|
23
|
214 |
Lobby isNil ifTrue:[
|
80
|
215 |
Lobby := Registry new.
|
0
|
216 |
|
80
|
217 |
"want to be informed when returning from snapshot"
|
|
218 |
ObjectMemory addDependent:self
|
0
|
219 |
]
|
|
220 |
!
|
|
221 |
|
|
222 |
flushDeviceCursors
|
|
223 |
"unassign all cursors from their device"
|
|
224 |
|
115
|
225 |
Lobby do:[:aCursor |
|
80
|
226 |
aCursor restored.
|
|
227 |
Lobby changed:aCursor
|
0
|
228 |
]
|
|
229 |
!
|
|
230 |
|
|
231 |
update:something
|
|
232 |
"sent when restarted after a snapIn"
|
|
233 |
|
|
234 |
(something == #restarted) ifTrue:[
|
80
|
235 |
self flushDeviceCursors
|
0
|
236 |
]
|
|
237 |
! !
|
|
238 |
|
|
239 |
!Cursor class methodsFor:'default access'!
|
|
240 |
|
|
241 |
defaultFgColor:fgColor defaultBgColor:bgColor
|
|
242 |
"set the default colors used for cursors"
|
|
243 |
|
|
244 |
DefaultFgColor := fgColor.
|
|
245 |
DefaultBgColor := bgColor
|
|
246 |
! !
|
|
247 |
|
|
248 |
!Cursor class methodsFor:'instance creation'!
|
|
249 |
|
|
250 |
extent:extent fromArray:array offset:offset
|
|
251 |
"create a new bitmap cursor from bits in the array argument
|
|
252 |
- ST-80 compatibility"
|
|
253 |
|
|
254 |
|sourceForm|
|
|
255 |
|
|
256 |
sourceForm := Form extent:extent fromArray:array offset:offset.
|
|
257 |
^ self sourceForm:sourceForm maskForm:sourceForm hotSpot:(offset negated)
|
|
258 |
!
|
|
259 |
|
|
260 |
extent:extent sourceArray:sourceArray maskArray:maskArray offset:offset
|
|
261 |
"create a new bitmap cursor with mask from bits in sourceArray and
|
|
262 |
maskArray"
|
|
263 |
|
|
264 |
|sourceForm maskForm|
|
|
265 |
|
|
266 |
sourceForm := Form extent:extent fromArray:sourceArray offset:offset.
|
|
267 |
maskForm := Form extent:extent fromArray:maskArray offset:offset.
|
|
268 |
^ self sourceForm:sourceForm maskForm:maskForm hotSpot:(offset negated)
|
|
269 |
!
|
|
270 |
|
|
271 |
sourceForm:aForm
|
|
272 |
"return a new cursor.
|
|
273 |
Source- and mask-Bits are taken from aForm; hotSpot is center"
|
|
274 |
|
|
275 |
^ self sourceForm:aForm
|
80
|
276 |
maskForm:aForm
|
|
277 |
hotX:(aForm width // 2)
|
|
278 |
hotY:(aForm height // 2)
|
0
|
279 |
!
|
|
280 |
|
|
281 |
sourceForm:sourceForm maskForm:maskForm
|
|
282 |
"return a new cursor. hotSpot is center"
|
|
283 |
|
|
284 |
^ self sourceForm:sourceForm
|
80
|
285 |
maskForm:maskForm
|
|
286 |
hotX:(sourceForm width // 2)
|
|
287 |
hotY:(sourceForm height // 2)
|
0
|
288 |
!
|
|
289 |
|
|
290 |
sourceForm:sourceForm maskForm:maskForm hotSpot:aPoint
|
|
291 |
"return a new cursor"
|
|
292 |
|
|
293 |
^ self sourceForm:sourceForm
|
80
|
294 |
maskForm:maskForm
|
|
295 |
hotX:(aPoint x)
|
|
296 |
hotY:(aPoint y)
|
0
|
297 |
!
|
|
298 |
|
|
299 |
sourceForm:sourceForm maskForm:maskForm hotX:hotX hotY:hotY
|
|
300 |
"return a new cursor"
|
|
301 |
|
|
302 |
|newCursor|
|
|
303 |
|
|
304 |
"first look if not already known"
|
115
|
305 |
Lobby do:[:aCursor |
|
80
|
306 |
(aCursor sourceForm == sourceForm) ifTrue:[
|
|
307 |
(aCursor maskForm == maskForm) ifTrue:[
|
|
308 |
(aCursor hotX == hotX) ifTrue:[
|
|
309 |
(aCursor hotY == hotY) ifTrue:[
|
|
310 |
^ aCursor
|
|
311 |
]
|
|
312 |
]
|
|
313 |
]
|
|
314 |
]
|
0
|
315 |
].
|
35
|
316 |
(sourceForm isNil or:[maskForm isNil]) ifTrue:[^ nil].
|
|
317 |
|
2
|
318 |
newCursor := self basicNew setSourceForm:sourceForm
|
80
|
319 |
maskForm:maskForm
|
|
320 |
hotX:hotX
|
|
321 |
hotY:hotY.
|
23
|
322 |
Lobby register:newCursor.
|
0
|
323 |
^ newCursor
|
|
324 |
!
|
|
325 |
|
|
326 |
shape:aShape
|
|
327 |
"return one of the standard cursors.
|
|
328 |
Each display may offer different shapes - see for example XWorkstation
|
|
329 |
for details (however a basic minimum set should be supported by all)"
|
|
330 |
|
|
331 |
|newCursor|
|
|
332 |
|
|
333 |
"first look if not already known"
|
115
|
334 |
Lobby do:[:aCursor |
|
80
|
335 |
(aCursor shape == aShape) ifTrue:[
|
|
336 |
^ aCursor
|
|
337 |
]
|
0
|
338 |
].
|
2
|
339 |
newCursor := self basicNew setShape:aShape.
|
23
|
340 |
Lobby register:newCursor.
|
0
|
341 |
^ newCursor
|
|
342 |
!
|
|
343 |
|
71
|
344 |
shape:aShape on:aDevice
|
|
345 |
"return one of the standard cursors already associated to aDevice.
|
|
346 |
This is the same as '(Cursor shape:aShape) on:aDevice' but somwehat faster."
|
|
347 |
|
|
348 |
|newCursor oldCursor|
|
|
349 |
|
|
350 |
"first look if not already known"
|
115
|
351 |
Lobby do:[:aCursor |
|
71
|
352 |
(aCursor shape == aShape) ifTrue:[
|
|
353 |
(aCursor device == aDevice) ifTrue:[^ aCursor].
|
|
354 |
oldCursor := aCursor
|
|
355 |
].
|
|
356 |
].
|
|
357 |
|
|
358 |
"found one with same shape, but different device"
|
|
359 |
oldCursor notNil ifTrue:[
|
|
360 |
^ oldCursor newOn:aDevice
|
|
361 |
].
|
|
362 |
|
|
363 |
newCursor := self basicNew setShape:aShape.
|
|
364 |
Lobby register:newCursor.
|
|
365 |
^ newCursor
|
|
366 |
!
|
|
367 |
|
0
|
368 |
fileCursorNamed:cursorName
|
|
369 |
"return a cursor read from the files 'cursorName_bits.bit' and
|
|
370 |
'cursorName_mask.bit' - return nil if file does not exist"
|
|
371 |
|
|
372 |
|cursorBits maskBits|
|
|
373 |
|
|
374 |
cursorBits := Form fromFile:(cursorName , '_bits.bit').
|
|
375 |
cursorBits notNil ifTrue:[
|
80
|
376 |
maskBits := Form fromFile:(cursorName , '_mask.bit').
|
|
377 |
maskBits notNil ifTrue:[
|
|
378 |
^ self sourceForm:cursorBits maskForm:maskBits
|
|
379 |
]
|
0
|
380 |
].
|
|
381 |
^ nil
|
|
382 |
! !
|
|
383 |
|
|
384 |
!Cursor class methodsFor:'standard cursors'!
|
|
385 |
|
|
386 |
normal
|
|
387 |
"return the normal cursor; an arrow.
|
|
388 |
for ST-80 compatibility"
|
|
389 |
|
|
390 |
NormalCursor isNil ifTrue:[
|
80
|
391 |
NormalCursor := self arrow on:Display
|
0
|
392 |
].
|
|
393 |
^ NormalCursor
|
|
394 |
!
|
|
395 |
|
|
396 |
hand
|
|
397 |
"return a hand cursor"
|
|
398 |
|
|
399 |
HandCursor isNil ifTrue:[
|
80
|
400 |
HandCursor := self shape:#upRightHand on:Display
|
0
|
401 |
].
|
|
402 |
^ HandCursor
|
|
403 |
!
|
|
404 |
|
|
405 |
upRightHand
|
|
406 |
"return an up-right-hand cursor"
|
|
407 |
|
|
408 |
^ self shape:#upRightHand
|
|
409 |
!
|
|
410 |
|
|
411 |
leftHand
|
|
412 |
"return a left-hand cursor"
|
|
413 |
|
|
414 |
^ self shape:#leftHand
|
|
415 |
!
|
|
416 |
|
|
417 |
upDownArrow
|
|
418 |
"return an up-down-arrow cursor"
|
|
419 |
|
|
420 |
UpDownArrowCursor isNil ifTrue:[
|
80
|
421 |
UpDownArrowCursor := self shape:#upDownArrow on:Display
|
0
|
422 |
].
|
|
423 |
^ UpDownArrowCursor
|
|
424 |
!
|
|
425 |
|
|
426 |
leftRightArrow
|
|
427 |
"return a left-right-arrow cursor"
|
|
428 |
|
|
429 |
LeftRightArrowCursor isNil ifTrue:[
|
80
|
430 |
LeftRightArrowCursor := self shape:#leftRightArrow on:Display
|
0
|
431 |
].
|
|
432 |
^ LeftRightArrowCursor
|
|
433 |
!
|
|
434 |
|
|
435 |
upLimitArrow
|
|
436 |
"return an up-arrow-to-limit cursor"
|
|
437 |
|
71
|
438 |
^ self shape:#upLimitArrow on:Display
|
0
|
439 |
!
|
|
440 |
|
|
441 |
downLimitArrow
|
|
442 |
"return a down-arrow-to-limit cursor"
|
|
443 |
|
71
|
444 |
^ self shape:#downLimitArrow on:Display
|
0
|
445 |
!
|
|
446 |
|
|
447 |
leftLimitArrow
|
|
448 |
"return a left-arrow-to-limit cursor"
|
|
449 |
|
71
|
450 |
^ self shape:#leftLimitArrow on:Display
|
0
|
451 |
!
|
|
452 |
|
|
453 |
rightLimitArrowOn
|
|
454 |
"return a right-arrow-to-limit cursor"
|
|
455 |
|
71
|
456 |
^ self shape:#rightLimitArrow on:Display
|
0
|
457 |
!
|
|
458 |
|
|
459 |
text
|
|
460 |
"return a text-cursor"
|
|
461 |
|
71
|
462 |
^ self shape:#text on:Display
|
0
|
463 |
!
|
|
464 |
|
|
465 |
arrow
|
|
466 |
"return an arrow (up-left-arrow) cursor"
|
|
467 |
|
71
|
468 |
^ self shape:#upLeftArrow on:Display
|
0
|
469 |
!
|
|
470 |
|
|
471 |
upLeftArrow
|
|
472 |
"return an up-right-arrow cursor"
|
|
473 |
|
71
|
474 |
^ self shape:#upLeftArrow on:Display
|
0
|
475 |
!
|
|
476 |
|
|
477 |
upRightArrow
|
|
478 |
"return an up-right-arrow cursor"
|
|
479 |
|
71
|
480 |
^ self shape:#upRightArrow on:Display
|
0
|
481 |
!
|
|
482 |
|
|
483 |
questionMark
|
|
484 |
"return a question-mark cursor"
|
|
485 |
|
71
|
486 |
^ self shape:#questionMark on:Display
|
0
|
487 |
!
|
|
488 |
|
|
489 |
cross
|
|
490 |
"return a cross cursor"
|
|
491 |
|
71
|
492 |
^ self shape:#cross on:Display
|
0
|
493 |
!
|
|
494 |
|
|
495 |
origin
|
|
496 |
"return an origin cursor"
|
|
497 |
|
|
498 |
OriginCursor isNil ifTrue:[
|
80
|
499 |
OriginCursor := self shape:#origin on:Display
|
0
|
500 |
].
|
|
501 |
^ OriginCursor
|
|
502 |
!
|
|
503 |
|
|
504 |
corner
|
|
505 |
"return a corner cursor"
|
|
506 |
|
|
507 |
CornerCursor isNil ifTrue:[
|
80
|
508 |
CornerCursor := self shape:#corner on:Display
|
0
|
509 |
].
|
|
510 |
^ CornerCursor
|
|
511 |
!
|
|
512 |
|
80
|
513 |
topRight
|
|
514 |
"return a top-right corner cursor"
|
|
515 |
|
|
516 |
^ self shape:#topRight on:Display
|
|
517 |
!
|
|
518 |
|
|
519 |
bottomLeft
|
|
520 |
"return a bottom-left corner cursor"
|
|
521 |
|
|
522 |
^ self shape:#bottomLeft on:Display
|
|
523 |
!
|
|
524 |
|
|
525 |
bottomRight
|
|
526 |
"return a bottom-right corner cursor"
|
|
527 |
|
|
528 |
^ self corner
|
|
529 |
!
|
|
530 |
|
|
531 |
topLeft
|
|
532 |
"return a top-left corner cursor"
|
|
533 |
|
|
534 |
^ self origin
|
|
535 |
!
|
|
536 |
|
0
|
537 |
crossHair
|
|
538 |
"return a crossHair cursor"
|
|
539 |
|
|
540 |
CrossHairCursor isNil ifTrue:[
|
80
|
541 |
CrossHairCursor := self shape:#crossHair on:Display
|
0
|
542 |
].
|
|
543 |
^ CrossHairCursor
|
|
544 |
!
|
|
545 |
|
|
546 |
fourWay
|
|
547 |
"return a four-way arrow cursor"
|
|
548 |
|
|
549 |
FourWayCursor isNil ifTrue:[
|
80
|
550 |
FourWayCursor := self shape:#fourWay on:Display
|
0
|
551 |
].
|
|
552 |
^ FourWayCursor
|
|
553 |
!
|
|
554 |
|
54
|
555 |
stop
|
71
|
556 |
"return a stop cursor (the default here is a wait-cursor)"
|
54
|
557 |
|
71
|
558 |
^ self wait
|
54
|
559 |
!
|
|
560 |
|
0
|
561 |
wait
|
|
562 |
"return a wait cursor"
|
|
563 |
|
|
564 |
WaitCursor isNil ifTrue:[
|
80
|
565 |
WaitCursor := self shape:#wait on:Display
|
0
|
566 |
].
|
|
567 |
^ WaitCursor
|
|
568 |
!
|
|
569 |
|
|
570 |
read
|
|
571 |
"return a reading-file cursor"
|
|
572 |
|
71
|
573 |
^ self wait
|
0
|
574 |
!
|
|
575 |
|
|
576 |
write
|
|
577 |
"return a writing-file cursor"
|
|
578 |
|
71
|
579 |
^ self wait
|
0
|
580 |
!
|
|
581 |
|
|
582 |
execute
|
|
583 |
"return a execute cursor - ST-80 compatibility"
|
|
584 |
|
71
|
585 |
^ self wait
|
56
|
586 |
!
|
|
587 |
|
|
588 |
thumbsUp
|
|
589 |
"return a hand cursor - ST-80 compatibility"
|
|
590 |
|
|
591 |
^ self hand
|
|
592 |
!
|
|
593 |
|
|
594 |
thumbsDown
|
|
595 |
"return a hand cursor - ST-80 compatibility"
|
|
596 |
|
|
597 |
^ self hand
|
0
|
598 |
! !
|
|
599 |
|
71
|
600 |
!Cursor methodsFor:'copying'!
|
|
601 |
|
|
602 |
postCopy
|
|
603 |
sourceForm := sourceForm copy.
|
|
604 |
maskForm := maskForm copy.
|
|
605 |
device := cursorId := nil
|
|
606 |
! !
|
|
607 |
|
0
|
608 |
!Cursor methodsFor:'instance release'!
|
|
609 |
|
71
|
610 |
shallowCopyForFinalization
|
|
611 |
^ self class basicNew setDevice:device id:cursorId
|
|
612 |
!
|
|
613 |
|
0
|
614 |
disposed
|
|
615 |
"some Cursor has been collected - tell it to the x-server"
|
|
616 |
|
|
617 |
cursorId notNil ifTrue:[
|
80
|
618 |
device destroyCursor:cursorId.
|
0
|
619 |
]
|
|
620 |
! !
|
|
621 |
|
2
|
622 |
!Cursor methodsFor:'private accessing'!
|
|
623 |
|
|
624 |
setShape:aShapeSymbol
|
|
625 |
"set the shape"
|
|
626 |
|
|
627 |
shape := aShapeSymbol.
|
|
628 |
!
|
|
629 |
|
|
630 |
setSourceForm:sForm maskForm:mForm hotX:hx hotY:hy
|
|
631 |
"set the forms and hotspot"
|
|
632 |
|
|
633 |
sourceForm := sForm.
|
|
634 |
maskForm := mForm.
|
|
635 |
hotX := hx.
|
|
636 |
hotY := hy.
|
|
637 |
!
|
|
638 |
|
|
639 |
setDevice:aDevice id:anId
|
|
640 |
"set the device and deviceId of the receiver"
|
|
641 |
|
|
642 |
device := aDevice.
|
|
643 |
cursorId := anId
|
|
644 |
! !
|
|
645 |
|
0
|
646 |
!Cursor methodsFor:'accessing'!
|
|
647 |
|
|
648 |
id
|
|
649 |
"return the cursors deviceId"
|
|
650 |
|
|
651 |
^ cursorId
|
|
652 |
!
|
|
653 |
|
|
654 |
device
|
|
655 |
"return the device I am associated with"
|
|
656 |
|
|
657 |
^ device
|
|
658 |
!
|
|
659 |
|
|
660 |
shape
|
|
661 |
"return the shape"
|
|
662 |
|
|
663 |
^ shape
|
|
664 |
!
|
|
665 |
|
|
666 |
sourceForm
|
|
667 |
"return the source-form of the receiver"
|
|
668 |
|
|
669 |
^ sourceForm
|
|
670 |
!
|
|
671 |
|
|
672 |
sourceForm:aForm
|
|
673 |
"set the source-form of the receiver"
|
|
674 |
|
|
675 |
sourceForm := aForm
|
|
676 |
!
|
|
677 |
|
|
678 |
maskForm
|
|
679 |
"return the mask-form of the receiver"
|
|
680 |
|
|
681 |
^ maskForm
|
|
682 |
!
|
|
683 |
|
|
684 |
maskForm:aForm
|
|
685 |
"set the mask-form of the receiver"
|
|
686 |
|
|
687 |
maskForm := aForm
|
|
688 |
!
|
|
689 |
|
|
690 |
hotX
|
|
691 |
"return the hotspots x-coordinate of the receiver"
|
|
692 |
|
|
693 |
^ hotX
|
|
694 |
!
|
|
695 |
|
|
696 |
hotY
|
|
697 |
"return the hotspots y-coordinate of the receiver"
|
|
698 |
|
|
699 |
^ hotY
|
|
700 |
!
|
|
701 |
|
|
702 |
foreground:fgColor background:bgColor
|
|
703 |
"set the cursor colors"
|
|
704 |
|
|
705 |
device colorCursor:cursorId foreground:fgColor background:bgColor
|
|
706 |
! !
|
|
707 |
|
|
708 |
!Cursor methodsFor:'creating a device cursor'!
|
|
709 |
|
|
710 |
on:aDevice
|
|
711 |
"create a new Cursor representing the same cursor as
|
|
712 |
myself on aDevice; if one already exists, return the one"
|
|
713 |
|
|
714 |
aDevice isNil ifTrue:[
|
80
|
715 |
"this may not happen"
|
|
716 |
self error:'nil device'
|
0
|
717 |
].
|
|
718 |
|
71
|
719 |
"if I am already assigned to that device ..."
|
0
|
720 |
(device == aDevice) ifTrue:[^ self].
|
|
721 |
|
|
722 |
"first look if not already there"
|
115
|
723 |
Lobby do:[:aCursor |
|
80
|
724 |
(aCursor device == aDevice) ifTrue:[
|
|
725 |
shape notNil ifTrue:[
|
|
726 |
(aCursor shape == shape) ifTrue:[
|
|
727 |
^ aCursor
|
|
728 |
]
|
|
729 |
] ifFalse:[
|
|
730 |
(aCursor sourceForm == sourceForm) ifTrue:[
|
|
731 |
(aCursor maskForm == maskForm) ifTrue:[
|
|
732 |
(aCursor hotX == hotX) ifTrue:[
|
|
733 |
(aCursor hotY == hotY) ifTrue:[
|
|
734 |
^ aCursor
|
|
735 |
]
|
|
736 |
]
|
|
737 |
]
|
|
738 |
]
|
|
739 |
]
|
|
740 |
]
|
0
|
741 |
].
|
71
|
742 |
^ self newOn:aDevice
|
|
743 |
! !
|
|
744 |
|
|
745 |
!Cursor methodsFor:'private'!
|
|
746 |
|
|
747 |
newOn:aDevice
|
|
748 |
"create a new Cursor representing the same cursor as
|
|
749 |
myself on aDevice. Dont search the lobby."
|
|
750 |
|
133
|
751 |
|newCursor id sF mF|
|
0
|
752 |
|
|
753 |
"ask that device for the cursor"
|
|
754 |
shape notNil ifTrue:[
|
80
|
755 |
id := aDevice createCursorShape:shape.
|
|
756 |
id isNil ifTrue:[
|
89
|
757 |
'CURSOR: no cursor with shape:' errorPrint. shape errorPrintNewline.
|
80
|
758 |
^ nil
|
|
759 |
].
|
0
|
760 |
] ifFalse:[
|
133
|
761 |
sourceForm notNil ifTrue:[
|
|
762 |
sF := sourceForm on:aDevice.
|
|
763 |
].
|
|
764 |
maskForm notNil ifTrue:[
|
|
765 |
mF := maskForm on:aDevice.
|
|
766 |
].
|
|
767 |
(sF isNil or:[mF isNil]) ifTrue:[
|
|
768 |
'CURSOR: cursor has no form' errorPrintNewline.
|
|
769 |
^ nil
|
|
770 |
].
|
|
771 |
sourceForm := sF.
|
|
772 |
maskForm := mF.
|
|
773 |
|
80
|
774 |
id := aDevice createCursorSourceForm:sourceForm
|
|
775 |
maskForm:maskForm
|
|
776 |
hotX:hotX
|
|
777 |
hotY:hotY.
|
|
778 |
id isNil ifTrue:[
|
89
|
779 |
'CURSOR: cannot create pixmap cursor' errorPrintNewline.
|
80
|
780 |
^ nil
|
|
781 |
].
|
0
|
782 |
].
|
|
783 |
|
|
784 |
"goody for IRIXs red cursor"
|
|
785 |
DefaultFgColor notNil ifTrue:[
|
80
|
786 |
aDevice colorCursor:id foreground:DefaultFgColor
|
|
787 |
background:DefaultBgColor
|
0
|
788 |
].
|
|
789 |
|
|
790 |
device isNil ifTrue:[
|
80
|
791 |
"receiver was not associated - do it now"
|
|
792 |
device := aDevice.
|
|
793 |
cursorId := id.
|
0
|
794 |
|
80
|
795 |
"must re-register, the old registration had a nil cursorId in it"
|
|
796 |
Lobby changed:self.
|
|
797 |
^ self
|
0
|
798 |
].
|
|
799 |
|
|
800 |
"receiver was already associated to another device - need a new cursor"
|
2
|
801 |
newCursor := self class basicNew.
|
0
|
802 |
shape notNil ifTrue:[
|
80
|
803 |
newCursor setShape:shape.
|
0
|
804 |
] ifFalse:[
|
80
|
805 |
newCursor setSourceForm:sourceForm
|
|
806 |
maskForm:maskForm
|
|
807 |
hotX:hotX
|
|
808 |
hotY:hotY
|
0
|
809 |
].
|
2
|
810 |
newCursor setDevice:aDevice id:id.
|
23
|
811 |
Lobby register:newCursor.
|
0
|
812 |
^ newCursor
|
71
|
813 |
!
|
0
|
814 |
|
|
815 |
device:aDevice
|
|
816 |
device := aDevice
|
|
817 |
!
|
|
818 |
|
|
819 |
id:anId
|
|
820 |
"set the cursors deviceId"
|
|
821 |
|
|
822 |
cursorId := anId
|
|
823 |
!
|
|
824 |
|
2
|
825 |
restored
|
0
|
826 |
"set both device and id"
|
|
827 |
|
|
828 |
device := nil.
|
|
829 |
cursorId := nil
|
|
830 |
! !
|
|
831 |
|
|
832 |
!Cursor methodsFor:'displaying'!
|
|
833 |
|
|
834 |
showIn:aView
|
|
835 |
aView cursor:self
|
|
836 |
!
|
|
837 |
|
|
838 |
showIn:aView while:aBlock
|
|
839 |
|savedCursor|
|
|
840 |
|
|
841 |
savedCursor := aView cursor.
|
|
842 |
aView cursor:self.
|
|
843 |
[
|
80
|
844 |
aBlock value.
|
0
|
845 |
] valueNowOrOnUnwindDo:[
|
80
|
846 |
aView cursor:savedCursor
|
0
|
847 |
]
|
|
848 |
!
|
|
849 |
|
|
850 |
showWhile:aBlock
|
|
851 |
"change all views cursors to the receiver.
|
|
852 |
In X this seems to be very slow"
|
|
853 |
|
|
854 |
|v|
|
|
855 |
|
|
856 |
Display setCursors:self.
|
|
857 |
v := aBlock valueNowOrOnUnwindDo:[
|
80
|
858 |
Display restoreCursors.
|
0
|
859 |
].
|
|
860 |
^ v
|
|
861 |
!
|
|
862 |
|
|
863 |
displayOn:aGC at:origin clippingBox:aRectangle rule:aRule mask:aMask
|
|
864 |
"ST-80 compatibility;
|
|
865 |
limited functionality: can only display bitmap cursors (yet)"
|
|
866 |
|
|
867 |
sourceForm notNil ifTrue:[
|
80
|
868 |
sourceForm displayOn:aGC at:origin clippingBox:aRectangle
|
|
869 |
rule:aRule mask:aMask
|
0
|
870 |
]
|
|
871 |
! !
|