0
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
71
|
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:#DeviceWorkstation
|
|
14 |
instanceVariableNames:'displayId
|
71
|
15 |
visualType monitorType
|
|
16 |
depth ncells bitsPerRGB
|
|
17 |
hasColors hasGreyscales
|
|
18 |
width height widthMM heightMM resolutionHor resolutionVer
|
|
19 |
idToViewMapping knownViews knownIds knownBitmaps knownBitmapIds
|
|
20 |
dispatching
|
|
21 |
controlDown shiftDown metaDown altDown
|
|
22 |
motionEventCompression
|
|
23 |
lastId lastView
|
134
|
24 |
keyboardMap rootView
|
133
|
25 |
isSlow
|
|
26 |
activeKeyboardGrab activePointerGrab
|
71
|
27 |
buttonTranslation multiClickTimeDelta'
|
2
|
28 |
classVariableNames: 'ButtonTranslation MultiClickTimeDelta
|
71
|
29 |
DeviceErrorSignal'
|
0
|
30 |
poolDictionaries:''
|
|
31 |
category:'Interface-Graphics'
|
|
32 |
!
|
|
33 |
|
|
34 |
DeviceWorkstation comment:'
|
46
|
35 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
71
|
36 |
All Rights Reserved
|
|
37 |
|
146
|
38 |
$Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.37 1995-05-18 15:39:16 claus Exp $
|
46
|
39 |
'!
|
0
|
40 |
|
46
|
41 |
!DeviceWorkstation class methodsFor:'documentation'!
|
|
42 |
|
|
43 |
copyright
|
|
44 |
"
|
0
|
45 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
71
|
46 |
All Rights Reserved
|
0
|
47 |
|
46
|
48 |
This software is furnished under a license and may be used
|
|
49 |
only in accordance with the terms of that license and with the
|
|
50 |
inclusion of the above copyright notice. This software may not
|
|
51 |
be provided or otherwise made available to, or used by, any
|
|
52 |
other person. No title to or ownership of the software is
|
|
53 |
hereby transferred.
|
|
54 |
"
|
|
55 |
!
|
0
|
56 |
|
46
|
57 |
version
|
|
58 |
"
|
146
|
59 |
$Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.37 1995-05-18 15:39:16 claus Exp $
|
46
|
60 |
"
|
|
61 |
!
|
0
|
62 |
|
|
63 |
documentation
|
|
64 |
"
|
38
|
65 |
this abstract class defines common protocol to all Display types.
|
0
|
66 |
|
38
|
67 |
instance variables:
|
0
|
68 |
|
134
|
69 |
displayId <Number> the device id of the display
|
|
70 |
visualType <Symbol> one of #StaticGray, #PseudoColor, ... #TrueColor
|
|
71 |
monitorType <Symbol> one of #monochrome, #color, #unknown
|
|
72 |
|
|
73 |
depth <Integer> bits per color
|
|
74 |
ncells <Integer> number of colors (i.e. colormap size; not always == 2^depth)
|
|
75 |
bitsPerRGB <Integer> number of valid bits per rgb component
|
|
76 |
(actual number taken in A/D converter; not all devices report the true value)
|
|
77 |
hasColors <Boolean> true, if display supports colors
|
|
78 |
hasGreyscales <Boolean> true, if display supports grey-scales (i.e is not b/w display)
|
|
79 |
width <Integer> number of horizontal pixels
|
|
80 |
height <Integer> number of vertical pixels
|
|
81 |
heightMM <Number> screen height in millimeter
|
|
82 |
widthMM <Number> screen width in millimeter
|
|
83 |
resolutionHor <Number> pixels per horizontal millimeter
|
|
84 |
resolutionVer <Number> pixels per vertical millimeter
|
|
85 |
|
|
86 |
idToViewMapping <Dictionary> maps view-ids to views
|
|
87 |
knownViews <Collection> all views known
|
|
88 |
knownIds <Collection> corresponding device-view ids
|
|
89 |
knownBitmaps <Collection> all known device bitmaps
|
|
90 |
knownBitmapIds <Collection> corresponding device-bitmap ids
|
|
91 |
|
|
92 |
dispatching <Boolean> true, if currently in dispatch loop
|
|
93 |
|
|
94 |
controlDown <Boolean> true, if control key currently pressed
|
|
95 |
shiftDown <Boolean> true, if shift key currently pressed
|
|
96 |
metaDown <Boolean> true, if meta key (cmd-key) is currently pressed
|
|
97 |
altDown <Boolean> true, if alt key is currently pressed
|
|
98 |
|
|
99 |
motionEventCompression
|
|
100 |
<Boolean> if true motion events are compressed
|
|
101 |
(obsolete: now done in sensor)
|
|
102 |
|
|
103 |
lastId <Number> the id of the last events view (internal)
|
|
104 |
lastView <View> the last events view (internal, for faster id->view mapping)
|
|
105 |
|
|
106 |
keyboardMap <KeyBdMap> mapping for keys
|
|
107 |
rootView <DisplayRootView> this displays root window
|
|
108 |
isSlow <Boolean> set/cleared from startup - used to turn off
|
|
109 |
things like popup-shadows etc.
|
0
|
110 |
"
|
|
111 |
! !
|
|
112 |
|
|
113 |
!DeviceWorkstation class methodsFor:'initialization'!
|
|
114 |
|
2
|
115 |
initialize
|
|
116 |
DeviceErrorSignal isNil ifTrue:[
|
71
|
117 |
DeviceErrorSignal := (Signal new) mayProceed:true.
|
|
118 |
DeviceErrorSignal notifierString:'device error'.
|
2
|
119 |
].
|
134
|
120 |
self initializeConstants.
|
2
|
121 |
!
|
|
122 |
|
0
|
123 |
initializeConstants
|
|
124 |
"initialize some (soft) constants"
|
|
125 |
|
51
|
126 |
MultiClickTimeDelta := 300. "a click within 300ms is considered a double one"
|
0
|
127 |
ButtonTranslation := #(1 2 3) "identity translation"
|
|
128 |
! !
|
|
129 |
|
144
|
130 |
!DeviceWorkstation class methodsFor:'Signal constants'!
|
2
|
131 |
|
|
132 |
deviceErrorSignal
|
|
133 |
"return the signal used for device error reporting"
|
|
134 |
|
|
135 |
^ DeviceErrorSignal
|
|
136 |
! !
|
|
137 |
|
0
|
138 |
!DeviceWorkstation class methodsFor:'accessing'!
|
|
139 |
|
|
140 |
buttonTranslation:anArray
|
|
141 |
"set the button translation, #(1 2 3) is no-translation,
|
|
142 |
#(3 2 1) is ok for left-handers"
|
|
143 |
|
75
|
144 |
ButtonTranslation := anArray.
|
|
145 |
Display notNil ifTrue:[
|
|
146 |
Display buttonTranslation:anArray
|
|
147 |
].
|
0
|
148 |
! !
|
|
149 |
|
|
150 |
!DeviceWorkstation methodsFor:'initialize / release'!
|
|
151 |
|
|
152 |
initialize
|
|
153 |
"initialize the receiver for a connection to the default display"
|
|
154 |
|
|
155 |
^ self initializeFor:nil
|
|
156 |
!
|
|
157 |
|
|
158 |
initializeFor:aDisplayOrNilForAny
|
|
159 |
"initialize the receiver for a connection to a display. If the
|
|
160 |
argument is non-nil, it should specify which workstation should be
|
|
161 |
connected to (in a device specific manner). For X displays, this is
|
|
162 |
to be the display-string i.e. hostname:displayNr.
|
|
163 |
If the argument is nil, connect to the default display."
|
|
164 |
|
71
|
165 |
^ self subclassResponsibility
|
0
|
166 |
!
|
|
167 |
|
|
168 |
close
|
2
|
169 |
"close down connection to Display - usually never done"
|
|
170 |
|
0
|
171 |
^ self subclassResponsibility
|
|
172 |
!
|
|
173 |
|
|
174 |
reinitialize
|
|
175 |
"reinit after snapin"
|
|
176 |
|
46
|
177 |
|prevKnownViews prevMapping|
|
0
|
178 |
|
|
179 |
displayId := nil.
|
51
|
180 |
dispatching := false.
|
46
|
181 |
|
|
182 |
"/ prevMapping := idToViewMapping.
|
|
183 |
"/ idToViewMapping := nil.
|
|
184 |
|
0
|
185 |
prevKnownViews := knownViews.
|
|
186 |
knownViews := nil.
|
|
187 |
knownIds := nil.
|
|
188 |
|
|
189 |
self initializeFor:nil.
|
|
190 |
|
43
|
191 |
"
|
|
192 |
first, all Forms must be recreated
|
51
|
193 |
(since they may be needed for view recreation as
|
43
|
194 |
background or icons)
|
|
195 |
"
|
0
|
196 |
Form reinitializeAllOn:self.
|
|
197 |
|
46
|
198 |
"/ prevMapping notNil ifTrue:[
|
0
|
199 |
prevKnownViews notNil ifTrue:[
|
71
|
200 |
"
|
|
201 |
first round: flush all device specific stuff
|
|
202 |
"
|
51
|
203 |
"/ prevMapping keysAndValuesDo:[:anId :aView |
|
71
|
204 |
prevKnownViews do:[:aView |
|
|
205 |
aView notNil ifTrue:[
|
|
206 |
aView prepareForReinit
|
|
207 |
]
|
|
208 |
].
|
|
209 |
|
|
210 |
"
|
|
211 |
2nd round: all views should reinstall themself
|
|
212 |
on the new display
|
|
213 |
"
|
51
|
214 |
"/ prevMapping keysAndValuesDo:[:anId :aView |
|
71
|
215 |
prevKnownViews do:[:aView |
|
|
216 |
aView notNil ifTrue:[
|
|
217 |
"have to re-create the view"
|
|
218 |
aView reinitialize
|
|
219 |
]
|
|
220 |
].
|
|
221 |
"
|
|
222 |
3rd round: all views get a chance to handle
|
|
223 |
changed environment (colors, font sizes etc)
|
|
224 |
"
|
51
|
225 |
"/ prevMapping keysAndValuesDo:[:anId :aView |
|
71
|
226 |
prevKnownViews do:[:aView |
|
|
227 |
aView notNil ifTrue:[
|
|
228 |
aView reAdjustGeometry
|
|
229 |
]
|
|
230 |
]
|
0
|
231 |
].
|
8
|
232 |
dispatching := false.
|
0
|
233 |
!
|
|
234 |
|
|
235 |
initializeKeyboardMap
|
|
236 |
"keystrokes from the server are translated via the keyboard map.
|
|
237 |
Untranslated keystrokes arrive either as characters, or symbols
|
|
238 |
(which are the keySyms as symbol). The mapping table which is
|
|
239 |
setup here, is used in sendKeyPress:... later.
|
|
240 |
"
|
|
241 |
|
51
|
242 |
keyboardMap isNil ifTrue:[
|
71
|
243 |
keyboardMap := KeyboardMap new.
|
51
|
244 |
].
|
0
|
245 |
|
|
246 |
"
|
8
|
247 |
no more setup here - moved everything out into 'display.rc' file
|
2
|
248 |
"
|
0
|
249 |
! !
|
|
250 |
|
103
|
251 |
!DeviceWorkstation class methodsFor:'queries'!
|
|
252 |
|
|
253 |
platformName
|
106
|
254 |
"ST-80 compatibility.
|
|
255 |
Return a string describing the display systems platform.
|
|
256 |
Returns a dummy here. This method is redefined in concrete classes."
|
103
|
257 |
|
|
258 |
^ 'unknown'
|
106
|
259 |
!
|
|
260 |
|
|
261 |
default
|
|
262 |
"ST-80 compatibility.
|
|
263 |
Return the default screen"
|
|
264 |
|
|
265 |
^ Display
|
103
|
266 |
! !
|
|
267 |
|
2
|
268 |
!DeviceWorkstation class methodsFor:'error handling'!
|
|
269 |
|
|
270 |
resourceIdOfLastError
|
|
271 |
"return the resource id responsible for the last error"
|
|
272 |
|
|
273 |
^ self subclassResponsibility
|
|
274 |
!
|
|
275 |
|
134
|
276 |
lastErrorString
|
54
|
277 |
"return a string describing the last error"
|
2
|
278 |
|
|
279 |
^ self subclassResponsibility
|
|
280 |
!
|
|
281 |
|
146
|
282 |
errorInterrupt:errID
|
144
|
283 |
"DisplayError interrupt.
|
|
284 |
This is invoked via
|
|
285 |
XError->errorInterrupt:#DisplayError->registeredErrorInterruptHandlers
|
|
286 |
|
|
287 |
looks if a signal handler for DeviceErrorSignal is present,
|
|
288 |
and - if so raises the signal. If the signal not handled, simply output a
|
|
289 |
message and continue.
|
|
290 |
This allows for non disrupted error reporting OR to catch and
|
|
291 |
investigate errors as required."
|
2
|
292 |
|
54
|
293 |
|badId badResource msg|
|
2
|
294 |
|
144
|
295 |
badId := self resourceIdOfLastError.
|
|
296 |
badId ~~ 0 ifTrue:[
|
|
297 |
badResource := self resourceOfId:badId.
|
|
298 |
].
|
|
299 |
msg := 'Display error: ' , (self lastErrorString).
|
|
300 |
|
|
301 |
DeviceErrorSignal isHandled ifFalse:[
|
|
302 |
msg errorPrintNL.
|
|
303 |
^ self
|
|
304 |
].
|
|
305 |
|
|
306 |
^ DeviceErrorSignal
|
142
|
307 |
raiseRequestWith:badResource
|
|
308 |
errorString:msg
|
2
|
309 |
!
|
|
310 |
|
|
311 |
resourceOfId:id
|
|
312 |
"search thru all device stuff for a resource.
|
|
313 |
Needed for error handling"
|
|
314 |
|
|
315 |
Form allInstances do:[:f |
|
71
|
316 |
f id == id ifTrue:[^ f]
|
2
|
317 |
].
|
|
318 |
|
|
319 |
self allInstances do:[:aDisplay |
|
71
|
320 |
aDisplay allViewsDo:[:aView |
|
|
321 |
aView id == id ifTrue:[^ aView].
|
|
322 |
aView gcId == id ifTrue:[^ aView]
|
|
323 |
].
|
2
|
324 |
|
46
|
325 |
"/ |views|
|
|
326 |
"/ views := aDisplay knownViews.
|
|
327 |
"/ views notNil ifTrue:[
|
|
328 |
"/ views do:[:v |
|
|
329 |
"/ v id == id ifTrue:[^ v].
|
|
330 |
"/ v gcId == id ifTrue:[^ v]
|
|
331 |
"/ ].
|
|
332 |
"/ ].
|
2
|
333 |
].
|
|
334 |
|
|
335 |
Color allInstances do:[:c |
|
71
|
336 |
c colorId == id ifTrue:[^ c]
|
2
|
337 |
].
|
|
338 |
|
|
339 |
Font allInstances do:[:f |
|
71
|
340 |
f fontId == id ifTrue:[^ f]
|
2
|
341 |
].
|
|
342 |
^ nil
|
|
343 |
! !
|
|
344 |
|
0
|
345 |
!DeviceWorkstation methodsFor:'misc'!
|
|
346 |
|
|
347 |
metaDown
|
|
348 |
"return true, if the meta-key (alt-key on systems without meta)
|
43
|
349 |
is currently pressed.
|
|
350 |
WARNING: obsolete, may vanish. Use protocol in WindowSensor."
|
0
|
351 |
|
|
352 |
^ metaDown
|
|
353 |
!
|
|
354 |
|
|
355 |
altDown
|
43
|
356 |
"return true, if the alt-key is currently pressed.
|
|
357 |
WARNING: obsolete, may vanish. Use protocol in WindowSensor."
|
0
|
358 |
|
|
359 |
^ altDown
|
|
360 |
!
|
|
361 |
|
|
362 |
controlDown
|
43
|
363 |
"return true, if the control-key is currently pressed.
|
|
364 |
WARNING: obsolete, may vanish. Use protocol in WindowSensor."
|
0
|
365 |
|
|
366 |
^ controlDown
|
|
367 |
!
|
|
368 |
|
|
369 |
shiftDown
|
43
|
370 |
"return true, if the shift-key is currently pressed.
|
|
371 |
WARNING: obsolete, may vanish. Use protocol in WindowSensor."
|
0
|
372 |
|
|
373 |
^ shiftDown
|
|
374 |
!
|
|
375 |
|
|
376 |
unBuffered
|
|
377 |
"make all drawing be sent immediately to the display"
|
|
378 |
|
|
379 |
^ self
|
|
380 |
!
|
|
381 |
|
|
382 |
buffered
|
|
383 |
"buffer drawing - do not send it immediately to the display"
|
|
384 |
|
|
385 |
^ self
|
|
386 |
!
|
|
387 |
|
|
388 |
synchronizeOutput
|
|
389 |
"send all buffered drawing to the display"
|
|
390 |
|
|
391 |
^ self
|
|
392 |
!
|
|
393 |
|
|
394 |
compressMotionEvents:aBoolean
|
|
395 |
"turn on/off motion event compression
|
|
396 |
- compressions makes always sense except in free-hand drawing of curves"
|
|
397 |
|
|
398 |
motionEventCompression := aBoolean
|
|
399 |
!
|
|
400 |
|
|
401 |
hasColors:aBoolean
|
|
402 |
"set the hasColors flag - needed since some servers dont tell the
|
|
403 |
truth if a monochrome monitor is connected to a color server"
|
|
404 |
|
|
405 |
hasColors := aBoolean
|
|
406 |
!
|
|
407 |
|
|
408 |
hasGreyscales:aBoolean
|
|
409 |
"set the hasGreyscales flag - can be used to simulate b&w behavior"
|
|
410 |
|
|
411 |
hasGreyscales := aBoolean
|
|
412 |
!
|
|
413 |
|
|
414 |
ignoreBackingStore:aBoolean
|
|
415 |
"if the argument is true, the views backingStore setting will be ignored, and
|
|
416 |
no backing store used - this can be used on servers where backing store is
|
|
417 |
very slow (from rc-file)"
|
|
418 |
|
12
|
419 |
^ self
|
|
420 |
!
|
|
421 |
|
|
422 |
isSlow:aBoolean
|
|
423 |
"set/clear the slow flag"
|
|
424 |
|
|
425 |
isSlow := aBoolean
|
0
|
426 |
!
|
|
427 |
|
|
428 |
beep
|
|
429 |
"output an audible beep or bell"
|
|
430 |
|
|
431 |
Stdout nextPut:(Character bell)
|
|
432 |
!
|
|
433 |
|
|
434 |
setInputFocusTo:aWindowId
|
|
435 |
^ self subclassResponsibility
|
|
436 |
! !
|
|
437 |
|
89
|
438 |
!DeviceWorkstation methodsFor:'enumerating'!
|
0
|
439 |
|
|
440 |
allViewsDo:aBlock
|
|
441 |
"evaluate the argument, aBlock for all known views"
|
|
442 |
|
46
|
443 |
"/ idToViewMapping notNil ifTrue:[
|
|
444 |
"/ idToViewMapping keysAndValuesDo:[:id :aView |
|
|
445 |
"/ aView notNil ifTrue:[
|
|
446 |
"/ aBlock value:aView
|
|
447 |
"/ ]
|
51
|
448 |
"/ ]
|
|
449 |
|
|
450 |
|
0
|
451 |
knownViews notNil ifTrue:[
|
46
|
452 |
knownViews do:[:aView |
|
71
|
453 |
aView notNil ifTrue:[
|
|
454 |
aBlock value:aView
|
|
455 |
]
|
46
|
456 |
]
|
0
|
457 |
]
|
|
458 |
|
|
459 |
"
|
|
460 |
View defaultStyle:#iris.
|
|
461 |
Display allViewsDo:[:v | v initStyle. v redraw]
|
|
462 |
"
|
|
463 |
"
|
|
464 |
View defaultStyle:#next.
|
|
465 |
Display allViewsDo:[:v | v initStyle. v redraw]
|
|
466 |
"
|
|
467 |
"
|
|
468 |
View defaultStyle:#normal.
|
|
469 |
Display allViewsDo:[:v | v initStyle. v redraw]
|
|
470 |
"
|
|
471 |
! !
|
|
472 |
|
133
|
473 |
!DeviceWorkstation methodsFor:'printing & storing'!
|
|
474 |
|
|
475 |
printOn:aStream
|
|
476 |
|displayName|
|
|
477 |
|
|
478 |
super printOn:aStream.
|
|
479 |
|
|
480 |
aStream nextPut:$(.
|
|
481 |
(displayName := self displayName isNil) ifTrue:[
|
|
482 |
aStream nextPutAll:'defaultDisplay'
|
|
483 |
] ifFalse:[
|
|
484 |
aStream nextPutAll:displayName.
|
|
485 |
].
|
|
486 |
aStream nextPut:$)
|
|
487 |
! !
|
|
488 |
|
0
|
489 |
!DeviceWorkstation methodsFor:'accessing & queries'!
|
|
490 |
|
|
491 |
displayFileDescriptor
|
10
|
492 |
"return the file descriptor associated with the display
|
12
|
493 |
if any. If there is no underlying filedescriptor, return nil.
|
|
494 |
(used for event select/polling)"
|
10
|
495 |
|
12
|
496 |
^ nil
|
0
|
497 |
!
|
|
498 |
|
133
|
499 |
displayName
|
|
500 |
"return the display name
|
|
501 |
- nothing known here, but maybe redefined in subclasses."
|
|
502 |
|
|
503 |
^ nil
|
|
504 |
!
|
|
505 |
|
98
|
506 |
platformName
|
|
507 |
"return a string describing the display systems platform.
|
|
508 |
Returns a dummy here."
|
|
509 |
|
103
|
510 |
^ self class platformName
|
98
|
511 |
!
|
|
512 |
|
0
|
513 |
serverVendor
|
98
|
514 |
"return a string describing the display systems server vendor.
|
|
515 |
Returns a dummy here"
|
10
|
516 |
|
12
|
517 |
^ 'generic'
|
0
|
518 |
!
|
|
519 |
|
|
520 |
vendorRelease
|
98
|
521 |
"return the display systems release number.
|
|
522 |
Returns a dummy here."
|
12
|
523 |
|
|
524 |
^ 0
|
0
|
525 |
!
|
|
526 |
|
|
527 |
protocolVersion
|
98
|
528 |
"return the display systems protocol version number.
|
|
529 |
Returns a dummy here"
|
12
|
530 |
|
|
531 |
^ 0
|
0
|
532 |
!
|
|
533 |
|
|
534 |
blackpixel
|
|
535 |
"return the colorId of black"
|
|
536 |
|
|
537 |
^ self subclassResponsibility
|
|
538 |
!
|
|
539 |
|
|
540 |
whitepixel
|
|
541 |
"return the colorId of white"
|
|
542 |
|
|
543 |
^ self subclassResponsibility
|
|
544 |
!
|
|
545 |
|
|
546 |
viewIdFromPoint:aPoint in:windowId
|
|
547 |
"given a point in rootWindow, return the viewId of the subview of windowId
|
12
|
548 |
hit by this coordinate. Return nil if no view was hit.
|
0
|
549 |
- use to find window to drop objects after a cross-view drag"
|
|
550 |
|
12
|
551 |
"returning nil here actually makes drag&drop impossible
|
71
|
552 |
- could also be reimplemented to make a search over all knownViews here.
|
|
553 |
This method has to be reimplemented in concrete display classes."
|
12
|
554 |
|
|
555 |
^ nil
|
0
|
556 |
!
|
|
557 |
|
|
558 |
translatePoint:aPoint from:windowId1 to:windowId2
|
|
559 |
"given a point in window1, return the coordinate in window2
|
|
560 |
- use to xlate points from a window to rootwindow"
|
|
561 |
|
71
|
562 |
"This method has to be reimplemented in concrete display classes."
|
0
|
563 |
^ self subclassResponsibility
|
|
564 |
!
|
|
565 |
|
71
|
566 |
viewFromPoint:aPoint
|
|
567 |
"given a point on the screen, return the ST/X view in which that
|
|
568 |
point is (this may be a subview). Return nil, if its not an st/X view
|
|
569 |
or if the point is on the background"
|
|
570 |
|
|
571 |
|view id searchId foundId|
|
|
572 |
|
134
|
573 |
searchId := self rootView id.
|
71
|
574 |
[searchId notNil] whileTrue:[
|
|
575 |
id := self viewIdFromPoint:aPoint in:searchId.
|
|
576 |
foundId := searchId.
|
|
577 |
searchId := id
|
|
578 |
].
|
|
579 |
view := self viewFromId:foundId.
|
|
580 |
^ view
|
|
581 |
!
|
|
582 |
|
0
|
583 |
id
|
|
584 |
"return the displayId"
|
|
585 |
|
|
586 |
^ displayId
|
|
587 |
!
|
|
588 |
|
|
589 |
ncells
|
12
|
590 |
"return the number of usable color cells, the display has
|
|
591 |
- this is not always the 2 to the power of depth."
|
0
|
592 |
|
|
593 |
^ ncells
|
23
|
594 |
|
|
595 |
"Display ncells"
|
0
|
596 |
!
|
|
597 |
|
|
598 |
depth
|
|
599 |
"return the depth in pixels of the display"
|
|
600 |
|
|
601 |
^ depth
|
23
|
602 |
|
|
603 |
"Display depth"
|
0
|
604 |
!
|
|
605 |
|
|
606 |
bitsPerRGB
|
|
607 |
"return the number of valid bits per rgb component"
|
|
608 |
|
|
609 |
^ bitsPerRGB
|
23
|
610 |
|
|
611 |
"Display bitsPerRGB"
|
0
|
612 |
!
|
|
613 |
|
|
614 |
visualType:aSymbol
|
|
615 |
"set the visual type. The only situation, where this makes sense,
|
|
616 |
is with my plasma-display, which ignores the palette and spits out
|
12
|
617 |
grey scales, independent of LUT definitions.
|
23
|
618 |
(of which the server knows nothing).
|
|
619 |
So, this should be used from a display-specific startup file only."
|
0
|
620 |
|
|
621 |
visualType := aSymbol.
|
|
622 |
(visualType == #StaticGray or:[visualType == #GrayScale]) ifTrue:[
|
71
|
623 |
hasColors := false
|
0
|
624 |
] ifFalse:[
|
71
|
625 |
hasColors := true
|
0
|
626 |
]
|
|
627 |
!
|
|
628 |
|
|
629 |
visualType
|
|
630 |
"return a symbol representing the visual type of the display"
|
|
631 |
|
|
632 |
^ visualType
|
23
|
633 |
|
|
634 |
"Display visualType"
|
0
|
635 |
!
|
|
636 |
|
|
637 |
monitorType
|
|
638 |
"return a symbol representing the monitor type of the display.
|
|
639 |
It is usually set to #unknown, #color or #monochrome.
|
|
640 |
But it can be set to any value from the startup file, for later
|
|
641 |
testing from anywhere. For example the startup for plasma-displays
|
|
642 |
can set it to #plasma to later influence the colors used in widgets
|
|
643 |
(indirectly through the resource file)."
|
|
644 |
|
|
645 |
^ monitorType
|
23
|
646 |
|
|
647 |
"Display monitorType"
|
0
|
648 |
!
|
|
649 |
|
|
650 |
monitorType:aSymbol
|
|
651 |
"set the monitorType - see comment in DeviceWorkstation>>montorType"
|
|
652 |
|
|
653 |
monitorType := aSymbol
|
|
654 |
!
|
|
655 |
|
|
656 |
hasColors
|
|
657 |
"return true, if its a color display"
|
|
658 |
|
|
659 |
^ hasColors
|
23
|
660 |
|
|
661 |
"Display hasColors"
|
0
|
662 |
!
|
|
663 |
|
|
664 |
hasGreyscales
|
|
665 |
"return true, if this workstation supports greyscales
|
|
666 |
(also true for color displays)"
|
|
667 |
|
|
668 |
^ hasGreyscales
|
23
|
669 |
|
|
670 |
"Display hasGreyscales"
|
0
|
671 |
!
|
|
672 |
|
|
673 |
hasShape
|
|
674 |
"return true, if this workstation supports non-rectangular windows"
|
|
675 |
|
|
676 |
^ false
|
|
677 |
!
|
|
678 |
|
|
679 |
hasShm
|
|
680 |
"return true, if this workstation supports shared pixmaps"
|
|
681 |
|
|
682 |
^ false
|
|
683 |
!
|
|
684 |
|
|
685 |
hasFax
|
|
686 |
"return true, if this workstation supports decompression of fax images"
|
|
687 |
|
|
688 |
^ false
|
|
689 |
!
|
|
690 |
|
|
691 |
hasDPS
|
12
|
692 |
"return true, if this workstation supports postscript output into views"
|
0
|
693 |
|
|
694 |
^ false
|
|
695 |
!
|
|
696 |
|
12
|
697 |
isSlow
|
|
698 |
"return true, if this is a relatively slow device -
|
|
699 |
used to turn off things like popup-shadows"
|
|
700 |
|
|
701 |
^ isSlow
|
|
702 |
!
|
|
703 |
|
81
|
704 |
supportsDeepIcons
|
|
705 |
"return true, if this device supports non b&w (i.e. greyScale
|
|
706 |
or colored icons). We really dont know here."
|
|
707 |
|
|
708 |
"This method has to be reimplemented in concrete display classes."
|
|
709 |
^ self subclassResponsibility
|
|
710 |
!
|
|
711 |
|
|
712 |
supportsViewGravity
|
|
713 |
"return true, if this device supports gravity attributes.
|
|
714 |
We do not depend on the being implemented, but some resizing operations
|
|
715 |
are faster, it is is."
|
|
716 |
|
|
717 |
"This method should to be reimplemented in concrete display classes."
|
|
718 |
^ false
|
|
719 |
!
|
|
720 |
|
0
|
721 |
keyboardMap
|
|
722 |
"return the keyboard map"
|
|
723 |
|
|
724 |
^ keyboardMap
|
|
725 |
!
|
|
726 |
|
8
|
727 |
keyboardMap:aMap
|
|
728 |
"set the keyboard map"
|
|
729 |
|
|
730 |
keyboardMap := aMap
|
|
731 |
!
|
|
732 |
|
0
|
733 |
width
|
23
|
734 |
"return the width of the display (in pixels)"
|
0
|
735 |
|
|
736 |
^ width
|
23
|
737 |
|
|
738 |
"Display width"
|
0
|
739 |
!
|
|
740 |
|
|
741 |
height
|
23
|
742 |
"return the height of the display (in pixels)"
|
0
|
743 |
|
|
744 |
^ height
|
23
|
745 |
|
|
746 |
"Display height"
|
|
747 |
!
|
|
748 |
|
|
749 |
extent
|
|
750 |
"return the extent of the display (in pixels)"
|
|
751 |
|
|
752 |
^ width @ height
|
|
753 |
|
106
|
754 |
"
|
|
755 |
Display extent
|
|
756 |
"
|
|
757 |
!
|
|
758 |
|
|
759 |
bounds
|
|
760 |
"return a rectangle representing the displays bounding box.
|
|
761 |
For Smalltalk-80 4.x compatibility"
|
|
762 |
|
|
763 |
^ Rectangle origin:(0 @ 0) extent:(width @ height)
|
|
764 |
|
|
765 |
"
|
|
766 |
Screen default bounds
|
|
767 |
"
|
|
768 |
"/ thats the same as:
|
|
769 |
"
|
|
770 |
Display bounds
|
|
771 |
"
|
0
|
772 |
!
|
|
773 |
|
|
774 |
boundingBox
|
23
|
775 |
"return a rectangle representing the displays bounding box.
|
106
|
776 |
For Smalltalk-80 2.x compatibility"
|
|
777 |
|
|
778 |
^ self bounds
|
0
|
779 |
!
|
|
780 |
|
|
781 |
widthInMillimeter
|
|
782 |
"return the width in millimeter of the display"
|
|
783 |
|
|
784 |
^ widthMM
|
23
|
785 |
|
|
786 |
"Display widthInMillimeter"
|
0
|
787 |
!
|
|
788 |
|
|
789 |
heightInMillimeter
|
|
790 |
"return the height in millimeter of the display"
|
|
791 |
|
|
792 |
^ heightMM
|
23
|
793 |
|
|
794 |
"Display heightInMillimeter"
|
0
|
795 |
!
|
|
796 |
|
|
797 |
widthInMillimeter:aNumber
|
|
798 |
"set the width in millimeter of the display
|
12
|
799 |
- needed since some displays do not tell the truth or do not know it"
|
0
|
800 |
|
|
801 |
widthMM := aNumber
|
|
802 |
!
|
|
803 |
|
|
804 |
heightInMillimeter:aNumber
|
|
805 |
"set the height in millimeter of the display
|
12
|
806 |
- needed since some displays do not tell the truth or do not know it"
|
0
|
807 |
|
|
808 |
heightMM := aNumber
|
|
809 |
!
|
|
810 |
|
|
811 |
pixelPerMillimeter
|
|
812 |
"return the number of horizontal/vertical pixels per millimeter of the display as Point"
|
|
813 |
|
|
814 |
^ (width / widthMM) @ (height / heightMM)
|
|
815 |
|
|
816 |
"Display pixelPerMillimeter"
|
|
817 |
!
|
|
818 |
|
|
819 |
pixelPerInch
|
|
820 |
"return the number of horizontal/vertical pixels per inch of the display as Point"
|
|
821 |
|
|
822 |
^ ((width / widthMM) @ (height / heightMM)) * 25.4
|
|
823 |
|
|
824 |
"Display pixelPerInch"
|
|
825 |
!
|
|
826 |
|
|
827 |
horizontalPixelPerMillimeter
|
|
828 |
"return the number of horizontal pixels per millimeter of the display"
|
|
829 |
|
|
830 |
^ width / widthMM
|
|
831 |
!
|
|
832 |
|
|
833 |
verticalPixelPerMillimeter
|
|
834 |
"return the number of vertical pixels per millimeter of the display"
|
|
835 |
|
|
836 |
^ height / heightMM
|
|
837 |
!
|
|
838 |
|
|
839 |
horizontalPixelPerInch
|
|
840 |
"return the number of horizontal pixels per inch of the display"
|
|
841 |
|
|
842 |
^ (width / widthMM) * 25.4
|
|
843 |
!
|
|
844 |
|
|
845 |
verticalPixelPerInch
|
|
846 |
"return the number of vertical pixels per inch of the display"
|
|
847 |
|
|
848 |
^ (height / heightMM) * 25.4
|
|
849 |
!
|
|
850 |
|
|
851 |
center
|
|
852 |
"return the centerpoint in pixels of the display"
|
|
853 |
|
|
854 |
^ (width // 2) @ (height // 2)
|
|
855 |
!
|
|
856 |
|
|
857 |
knownViews
|
|
858 |
"return a collection of all known views"
|
|
859 |
|
|
860 |
^ knownViews
|
|
861 |
!
|
|
862 |
|
|
863 |
knownViews:aCollection
|
|
864 |
"set the collection of all known views - take care,
|
|
865 |
bad use of this will create funny results; use only for snapshot support"
|
|
866 |
|
|
867 |
knownViews := aCollection
|
23
|
868 |
!
|
|
869 |
|
71
|
870 |
buttonTranslation
|
|
871 |
^ buttonTranslation
|
|
872 |
!
|
|
873 |
|
75
|
874 |
buttonTranslation:anArray
|
|
875 |
buttonTranslation := anArray
|
|
876 |
!
|
|
877 |
|
81
|
878 |
buttonMotionMask:aMask includesButton:aButton
|
|
879 |
"given a device button mask, return true if a logical button
|
133
|
880 |
(1 .. 3 for left .. right) is included."
|
81
|
881 |
|
|
882 |
|buttonNr|
|
|
883 |
|
|
884 |
"reverse buttonTranslation"
|
|
885 |
buttonTranslation notNil ifTrue:[
|
|
886 |
buttonNr := buttonTranslation indexOf:aButton ifAbsent:[1].
|
|
887 |
] ifFalse:[
|
|
888 |
buttonNr := aButton.
|
|
889 |
].
|
|
890 |
^ (aMask bitTest:(self buttonMotionMask:buttonNr))
|
|
891 |
!
|
|
892 |
|
71
|
893 |
multiClickTimeDelta
|
|
894 |
^ multiClickTimeDelta
|
|
895 |
!
|
|
896 |
|
|
897 |
multiClickTimeDelta:milliseconds
|
|
898 |
multiClickTimeDelta := milliseconds
|
|
899 |
! !
|
|
900 |
|
133
|
901 |
!DeviceWorkstation methodsFor:'pointer queries'!
|
|
902 |
|
|
903 |
rootPositionOfLastEvent
|
|
904 |
"return the position in root-window coordinates
|
|
905 |
of the last button, key or pointer event.
|
|
906 |
Must be redefined by concrete subclasses."
|
|
907 |
|
|
908 |
^ self subclassResponsibility
|
|
909 |
!
|
|
910 |
|
|
911 |
pointerPosition
|
|
912 |
"return the current pointer position in root-window coordinates.
|
|
913 |
Must be redefined by concrete subclasses."
|
|
914 |
|
|
915 |
^ self subclassResponsibility
|
|
916 |
!
|
|
917 |
|
|
918 |
buttonStates
|
|
919 |
"return an integer representing the state of the pointer buttons;
|
|
920 |
a one-bit represents a pressed button. The bit positions are device specific
|
|
921 |
and to be returned by the *ButtonStateMask methods.
|
|
922 |
Must be redefined by concrete subclasses."
|
|
923 |
|
|
924 |
^ self subclassResponsibility
|
|
925 |
!
|
|
926 |
|
|
927 |
leftButtonStateMask
|
|
928 |
"return an integer for masking out the left button from a
|
|
929 |
buttonStates value. This is very device specific and to
|
|
930 |
be redefined by concrete subclasses."
|
|
931 |
|
|
932 |
^ self subclassResponsibility
|
|
933 |
!
|
|
934 |
|
|
935 |
middleButtonStateMask
|
|
936 |
"return an integer for masking out the middle button from a
|
|
937 |
buttonStates value. This is very device specific and to
|
|
938 |
be redefined by concrete subclasses."
|
|
939 |
|
|
940 |
^ self subclassResponsibility
|
|
941 |
!
|
|
942 |
|
|
943 |
rightButtonStateMask
|
|
944 |
"return an integer for masking out the right button from a
|
|
945 |
buttonStates value. This is very device specific and to
|
|
946 |
be redefined by concrete subclasses."
|
|
947 |
|
|
948 |
^ self subclassResponsibility
|
|
949 |
!
|
|
950 |
|
|
951 |
leftButtonPressed
|
|
952 |
"return true, if the left button is currently pressed"
|
|
953 |
|
|
954 |
^ (self buttonStates bitAnd:self leftButtonStateMask) ~~ 0
|
|
955 |
!
|
|
956 |
|
|
957 |
middleButtonPressed
|
|
958 |
"return true, if the middle button is currently pressed"
|
|
959 |
|
|
960 |
^ (self buttonStates bitAnd:self middleButtonStateMask) ~~ 0
|
|
961 |
!
|
|
962 |
|
|
963 |
rightButtonPressed
|
|
964 |
"return true, if the right button is currently pressed"
|
|
965 |
|
|
966 |
^ (self buttonStates bitAnd:self rightButtonStateMask) ~~ 0
|
|
967 |
! !
|
|
968 |
|
71
|
969 |
!DeviceWorkstation methodsFor:'interactive queries'!
|
|
970 |
|
81
|
971 |
pointFromUserShowing:aCursor
|
|
972 |
"let user specify a point on the screen (by pressing leftButton).
|
|
973 |
Show aCursor while waiting."
|
|
974 |
|
|
975 |
|p|
|
23
|
976 |
|
|
977 |
self ungrabPointer.
|
134
|
978 |
self grabPointerIn:(self rootView id) withCursor:((aCursor on:self) id)
|
75
|
979 |
pointerMode:#async keyboardMode:#sync confineTo:nil.
|
134
|
980 |
activePointerGrab := rootView.
|
81
|
981 |
|
|
982 |
[self leftButtonPressed] whileFalse:[Processor yield].
|
23
|
983 |
p := self pointerPosition.
|
|
984 |
|
|
985 |
self ungrabPointer.
|
|
986 |
|
|
987 |
"flush all events pending on myself"
|
81
|
988 |
self disposeButtonEventsFor:nil.
|
23
|
989 |
^ p
|
|
990 |
|
71
|
991 |
"
|
81
|
992 |
Display pointFromUserShowing:(Cursor stop)
|
133
|
993 |
Display pointFromUserShowing:(Cursor crossHair)
|
81
|
994 |
Display pointFromUser
|
|
995 |
"
|
|
996 |
!
|
|
997 |
|
|
998 |
pointFromUser
|
133
|
999 |
"let user specify a point on the screen (by pressing the left button)"
|
81
|
1000 |
|
|
1001 |
^ self pointFromUserShowing:(Cursor crossHair).
|
|
1002 |
|
|
1003 |
"
|
71
|
1004 |
Display pointFromUser
|
|
1005 |
"
|
23
|
1006 |
!
|
|
1007 |
|
81
|
1008 |
rectangleFromUser:initialRectangle
|
|
1009 |
"let user specify a rectangle on the screen, return the rectangle.
|
133
|
1010 |
Start with initialRectangle.
|
|
1011 |
A helper for rectangleFromUser; can also be used for resizing operations."
|
81
|
1012 |
|
|
1013 |
|curs1 curs2 origin corner root rect|
|
23
|
1014 |
|
|
1015 |
curs1 := Cursor origin on:self.
|
|
1016 |
curs2 := Cursor corner on:self.
|
|
1017 |
|
134
|
1018 |
root := self rootView.
|
81
|
1019 |
|
|
1020 |
"
|
|
1021 |
grab and wait for leftButton being pressed
|
|
1022 |
"
|
|
1023 |
origin := initialRectangle origin.
|
|
1024 |
|
|
1025 |
root noClipByChildren.
|
|
1026 |
root foreground:Color black background:Color white.
|
|
1027 |
|
|
1028 |
root xoring:[
|
|
1029 |
|left right top bottom newOrigin newCorner p curs|
|
|
1030 |
|
71
|
1031 |
corner := origin.
|
81
|
1032 |
rect := origin corner:corner.
|
|
1033 |
root displayRectangle:rect.
|
|
1034 |
|
|
1035 |
self grabPointerIn:root id withCursor:curs2 id
|
|
1036 |
pointerMode:#async keyboardMode:#sync confineTo:nil.
|
|
1037 |
|
71
|
1038 |
[self leftButtonPressed] whileTrue:[
|
81
|
1039 |
left := initialRectangle origin x.
|
|
1040 |
top := initialRectangle origin y.
|
|
1041 |
right := initialRectangle corner x.
|
|
1042 |
bottom := initialRectangle corner y.
|
|
1043 |
|
|
1044 |
p := self pointerPosition.
|
|
1045 |
p x < initialRectangle left ifTrue:[
|
|
1046 |
p y < initialRectangle top ifTrue:[
|
|
1047 |
curs := Cursor topLeft.
|
|
1048 |
left := p x.
|
|
1049 |
top := p y.
|
|
1050 |
] ifFalse:[
|
|
1051 |
curs := Cursor bottomLeft.
|
|
1052 |
left := p x.
|
|
1053 |
bottom := p y
|
|
1054 |
]
|
|
1055 |
] ifFalse:[
|
|
1056 |
p y < initialRectangle top ifTrue:[
|
|
1057 |
curs := Cursor topRight.
|
|
1058 |
right := p x.
|
|
1059 |
top := p y
|
|
1060 |
] ifFalse:[
|
|
1061 |
curs := Cursor bottomRight.
|
|
1062 |
right := p x.
|
|
1063 |
bottom := p y
|
|
1064 |
]
|
|
1065 |
].
|
|
1066 |
|
|
1067 |
newOrigin := left @ top.
|
|
1068 |
newCorner := right @ bottom.
|
|
1069 |
|
|
1070 |
((newOrigin ~= origin) or:[newCorner ~= corner]) ifTrue:[
|
|
1071 |
root displayRectangle:rect.
|
|
1072 |
|
|
1073 |
self grabPointerIn:root id withCursor:curs id
|
71
|
1074 |
pointerMode:#async keyboardMode:#sync confineTo:nil.
|
|
1075 |
|
81
|
1076 |
origin := newOrigin.
|
71
|
1077 |
corner := newCorner.
|
81
|
1078 |
rect := origin corner:corner.
|
|
1079 |
root displayRectangle:rect.
|
|
1080 |
self disposeButtonEventsFor:nil.
|
71
|
1081 |
self synchronizeOutput.
|
|
1082 |
]
|
|
1083 |
].
|
81
|
1084 |
root displayRectangle:rect.
|
|
1085 |
self ungrabPointer.
|
23
|
1086 |
].
|
|
1087 |
|
|
1088 |
self ungrabPointer.
|
|
1089 |
|
|
1090 |
"flush all events pending on my display"
|
81
|
1091 |
|
|
1092 |
root clipByChildren.
|
|
1093 |
|
|
1094 |
self synchronizeOutput.
|
|
1095 |
self disposeButtonEventsFor:nil.
|
|
1096 |
|
|
1097 |
^ rect
|
|
1098 |
!
|
|
1099 |
|
|
1100 |
rectangleFromUser
|
|
1101 |
"let user specify a rectangle in the screen, return the rectangle"
|
|
1102 |
|
|
1103 |
|origin|
|
|
1104 |
|
|
1105 |
"
|
|
1106 |
get origin
|
|
1107 |
"
|
|
1108 |
origin := self pointFromUserShowing:(Cursor origin on:self).
|
|
1109 |
|
|
1110 |
"
|
|
1111 |
get corner
|
|
1112 |
"
|
|
1113 |
^ self rectangleFromUser:(origin corner:origin).
|
71
|
1114 |
|
|
1115 |
"
|
133
|
1116 |
Display rectangleFromUser
|
71
|
1117 |
"
|
23
|
1118 |
!
|
|
1119 |
|
|
1120 |
viewFromUser
|
|
1121 |
"let user specify a view on the screen; if the selected view is
|
133
|
1122 |
not an ST/X view, nil is returned.
|
|
1123 |
This returns the view being clicked in, which is not always a topView.
|
|
1124 |
(send topView to the returned view or use topviewFromUser,
|
|
1125 |
to get the topview)"
|
23
|
1126 |
|
71
|
1127 |
^ self viewFromPoint:(self pointFromUser)
|
|
1128 |
|
|
1129 |
"
|
133
|
1130 |
Display viewFromUser
|
71
|
1131 |
"
|
|
1132 |
"
|
|
1133 |
|v|
|
|
1134 |
v := Display viewFromUser.
|
|
1135 |
v notNil ifTrue:[v topView] ifFalse:[nil]
|
|
1136 |
"
|
|
1137 |
!
|
|
1138 |
|
|
1139 |
topviewFromUser
|
|
1140 |
"let user specify a view on the screen; if the selected view is
|
133
|
1141 |
not an ST/X view, nil is returned.
|
71
|
1142 |
Otherwise, the topview is returned."
|
|
1143 |
|
|
1144 |
|v|
|
|
1145 |
|
|
1146 |
v := self viewFromUser.
|
|
1147 |
v notNil ifTrue:[
|
|
1148 |
v := v topView
|
23
|
1149 |
].
|
71
|
1150 |
^ v
|
|
1151 |
|
|
1152 |
"
|
|
1153 |
Display topviewFromUser
|
|
1154 |
"
|
0
|
1155 |
! !
|
|
1156 |
|
|
1157 |
!DeviceWorkstation methodsFor:'keyboard mapping'!
|
|
1158 |
|
51
|
1159 |
translateKey:untranslatedKey
|
|
1160 |
"Return the key translated via the translation table.
|
89
|
1161 |
Your application program should never depend on the values returned
|
|
1162 |
by this method, but instead use symbolic keys (such as #FindNext).
|
|
1163 |
Doing so allows easier reconfiguration by changing the translation map
|
|
1164 |
in the 'smalltalk.rc' or 'display.rc' startup files.
|
51
|
1165 |
|
|
1166 |
First, the modifier is prepended, making character X into
|
|
1167 |
AltX, CtrlX or CmdX (on most systems, no separate Cmd (or Meta)
|
|
1168 |
key exists; on those we always get AltX).
|
89
|
1169 |
If multiple modifiers are active, the symbol becoms the concatenation
|
|
1170 |
as in AltCtrlq (for control-alt-q). Shift will affect the last component,
|
|
1171 |
thus the above with shift becoms: AltCtrlQ instead.
|
|
1172 |
Some keyboards offer both Alt and Meta keys - on those, the first has a
|
|
1173 |
prefix of Alt, the second has Cmd as prefix. Keyboards with only an Alt
|
|
1174 |
key will will create prefix codes of Cmd for that.
|
|
1175 |
For symbolic keys (i.e.Tab, Backspace etc, shift is ignored).
|
51
|
1176 |
Then the result is used as a key into the translation keyboardMap
|
|
1177 |
to get the final return value."
|
|
1178 |
|
145
|
1179 |
|xlatedKey dontTranslate|
|
51
|
1180 |
|
|
1181 |
xlatedKey := untranslatedKey.
|
145
|
1182 |
|
|
1183 |
"should this come from a configurable variable ?"
|
|
1184 |
dontTranslate := (untranslatedKey == #Control
|
|
1185 |
or:[untranslatedKey == #'Control_L'
|
|
1186 |
or:[untranslatedKey == #'Control_R'
|
|
1187 |
or:[untranslatedKey == #'Shift'
|
|
1188 |
or:[untranslatedKey == #'Shift_L'
|
|
1189 |
or:[untranslatedKey == #'Shift_R'
|
|
1190 |
or:[untranslatedKey == #'Alt'
|
|
1191 |
or:[untranslatedKey == #'Alt_L'
|
|
1192 |
or:[untranslatedKey == #'Alt_R'
|
|
1193 |
or:[untranslatedKey == #'Meta'
|
|
1194 |
or:[untranslatedKey == #'Meta_L'
|
|
1195 |
or:[untranslatedKey == #'Meta_R'
|
|
1196 |
or:[untranslatedKey == #'Cmd'
|
|
1197 |
or:[untranslatedKey == #'Cmd_L'
|
|
1198 |
or:[untranslatedKey == #'Cmd_R']]]]]]]]]]]]]]).
|
|
1199 |
|
51
|
1200 |
controlDown ifTrue:[
|
145
|
1201 |
dontTranslate ifFalse:[
|
144
|
1202 |
xlatedKey := ('Ctrl' , xlatedKey asString) asSymbol
|
|
1203 |
]
|
51
|
1204 |
].
|
|
1205 |
metaDown ifTrue:[
|
145
|
1206 |
dontTranslate ifFalse:[
|
144
|
1207 |
xlatedKey := ('Cmd' , xlatedKey asString) asSymbol
|
|
1208 |
]
|
51
|
1209 |
].
|
|
1210 |
altDown ifTrue:[
|
145
|
1211 |
dontTranslate ifFalse:[
|
144
|
1212 |
xlatedKey := ('Alt' , xlatedKey asString) asSymbol
|
|
1213 |
]
|
51
|
1214 |
].
|
|
1215 |
|
|
1216 |
xlatedKey := keyboardMap valueFor:xlatedKey.
|
|
1217 |
^ xlatedKey
|
0
|
1218 |
! !
|
|
1219 |
|
115
|
1220 |
!DeviceWorkstation methodsFor:'event forwarding'!
|
|
1221 |
|
|
1222 |
keyPress:untranslatedKey x:x y:y view:aView
|
|
1223 |
"forward a key-press event for some view"
|
|
1224 |
|
|
1225 |
|xlatedKey sensor|
|
|
1226 |
|
|
1227 |
(sensor := aView sensor) notNil ifTrue:[
|
|
1228 |
sensor keyPress:untranslatedKey x:x y:y view:aView
|
|
1229 |
] ifFalse:[
|
|
1230 |
"
|
|
1231 |
if there is no sensor ...
|
|
1232 |
"
|
|
1233 |
xlatedKey := self translateKey:untranslatedKey.
|
|
1234 |
xlatedKey notNil ifTrue:[
|
|
1235 |
WindowEvent
|
|
1236 |
sendEvent:#keyPress:x:y:
|
|
1237 |
arguments:(Array with:xlatedKey with:x with:y)
|
|
1238 |
view:aView
|
|
1239 |
]
|
|
1240 |
]
|
|
1241 |
!
|
|
1242 |
|
|
1243 |
keyRelease:untranslatedKey x:x y:y view:aView
|
|
1244 |
"forward a key-release event for some view"
|
|
1245 |
|
|
1246 |
|xlatedKey sensor|
|
|
1247 |
|
|
1248 |
(sensor := aView sensor) notNil ifTrue:[
|
|
1249 |
sensor keyRelease:untranslatedKey x:x y:y view:aView
|
|
1250 |
] ifFalse:[
|
|
1251 |
"
|
|
1252 |
if there is no sensor ...
|
|
1253 |
"
|
|
1254 |
xlatedKey := self translateKey:untranslatedKey.
|
|
1255 |
xlatedKey notNil ifTrue:[
|
|
1256 |
WindowEvent
|
|
1257 |
sendEvent:#keyRelease:x:y:
|
|
1258 |
arguments:(Array with:xlatedKey with:x with:y)
|
|
1259 |
view:aView
|
|
1260 |
]
|
|
1261 |
]
|
|
1262 |
!
|
|
1263 |
|
|
1264 |
buttonPress:button x:x y:y view:aView
|
|
1265 |
"forward a button-press event for some view"
|
|
1266 |
|
|
1267 |
|sensor|
|
|
1268 |
|
|
1269 |
(sensor := aView sensor) notNil ifTrue:[
|
|
1270 |
sensor buttonPress:button x:x y:y view:aView
|
|
1271 |
] ifFalse:[
|
|
1272 |
"
|
|
1273 |
if there is no sensor ...
|
|
1274 |
"
|
|
1275 |
WindowEvent
|
|
1276 |
sendEvent:#buttonPress:x:y:
|
|
1277 |
arguments:(Array with:button with:x with:y)
|
|
1278 |
view:aView
|
|
1279 |
]
|
|
1280 |
!
|
|
1281 |
|
|
1282 |
buttonShiftPress:button x:x y:y view:aView
|
|
1283 |
"forward a button-shift-press event for some view"
|
|
1284 |
|
|
1285 |
|sensor|
|
|
1286 |
|
|
1287 |
(sensor := aView sensor) notNil ifTrue:[
|
|
1288 |
sensor buttonShiftPress:button x:x y:y view:aView
|
|
1289 |
] ifFalse:[
|
|
1290 |
"
|
|
1291 |
if there is no sensor ...
|
|
1292 |
"
|
|
1293 |
WindowEvent
|
|
1294 |
sendEvent:#buttonShiftPress:x:y:
|
|
1295 |
arguments:(Array with:button with:x with:y)
|
|
1296 |
view:aView
|
|
1297 |
]
|
|
1298 |
!
|
|
1299 |
|
|
1300 |
buttonMultiPress:button x:x y:y view:aView
|
|
1301 |
"forward a button-multi-press event for some view"
|
|
1302 |
|
|
1303 |
|sensor|
|
|
1304 |
|
|
1305 |
(sensor := aView sensor) notNil ifTrue:[
|
|
1306 |
sensor buttonMultiPress:button x:x y:y view:aView
|
|
1307 |
] ifFalse:[
|
|
1308 |
"
|
|
1309 |
if there is no sensor ...
|
|
1310 |
"
|
|
1311 |
WindowEvent
|
|
1312 |
sendEvent:#buttonMultiPress:x:y:
|
|
1313 |
arguments:(Array with:button with:x with:y)
|
|
1314 |
view:aView
|
|
1315 |
]
|
|
1316 |
!
|
|
1317 |
|
|
1318 |
buttonRelease:button x:x y:y view:aView
|
|
1319 |
"forward a button-release event for some view"
|
|
1320 |
|
|
1321 |
|sensor|
|
|
1322 |
|
|
1323 |
(sensor := aView sensor) notNil ifTrue:[
|
|
1324 |
sensor buttonRelease:button x:x y:y view:aView
|
|
1325 |
] ifFalse:[
|
|
1326 |
"
|
|
1327 |
if there is no sensor ...
|
|
1328 |
"
|
|
1329 |
WindowEvent
|
|
1330 |
sendEvent:#buttonRelease:x:y:
|
|
1331 |
arguments:(Array with:button with:x with:y)
|
|
1332 |
view:aView
|
|
1333 |
]
|
|
1334 |
!
|
|
1335 |
|
|
1336 |
buttonMotion:button x:x y:y view:aView
|
|
1337 |
"forward a button-motion for some view"
|
|
1338 |
|
|
1339 |
|sensor|
|
|
1340 |
|
|
1341 |
(sensor := aView sensor) notNil ifTrue:[
|
|
1342 |
sensor buttonMotion:button x:x y:y view:aView
|
|
1343 |
] ifFalse:[
|
|
1344 |
"
|
|
1345 |
if there is no sensor ...
|
|
1346 |
"
|
|
1347 |
WindowEvent
|
|
1348 |
sendEvent:#buttonMotion:x:y:
|
|
1349 |
arguments:(Array with:button with:x with:y)
|
|
1350 |
view:aView
|
|
1351 |
]
|
|
1352 |
!
|
|
1353 |
|
|
1354 |
pointerEnter:buttonState x:x y:y view:aView
|
|
1355 |
"forward a pointer enter for some view"
|
|
1356 |
|
|
1357 |
|sensor|
|
|
1358 |
|
|
1359 |
(sensor := aView sensor) notNil ifTrue:[
|
|
1360 |
sensor pointerEnter:buttonState x:x y:y view:aView
|
|
1361 |
] ifFalse:[
|
|
1362 |
"
|
|
1363 |
if there is no sensor ...
|
|
1364 |
"
|
|
1365 |
WindowEvent
|
|
1366 |
sendEvent:#pointerEnter:x:y:
|
|
1367 |
arguments:(Array with:buttonState with:x with:y)
|
|
1368 |
view:aView
|
|
1369 |
]
|
|
1370 |
!
|
|
1371 |
|
|
1372 |
pointerLeave:buttonState view:aView
|
|
1373 |
"forward a pointer leave for some view"
|
|
1374 |
|
|
1375 |
|sensor|
|
|
1376 |
|
|
1377 |
(sensor := aView sensor) notNil ifTrue:[
|
|
1378 |
sensor pointerLeave:buttonState view:aView
|
|
1379 |
] ifFalse:[
|
|
1380 |
"
|
|
1381 |
if there is no sensor ...
|
|
1382 |
"
|
|
1383 |
WindowEvent
|
|
1384 |
sendEvent:#pointerLeave:
|
|
1385 |
arguments:(Array with:buttonState)
|
|
1386 |
view:aView
|
|
1387 |
]
|
|
1388 |
!
|
|
1389 |
|
|
1390 |
focusInView:aView
|
|
1391 |
"forward a focusIn event for some view"
|
|
1392 |
|
|
1393 |
|sensor|
|
|
1394 |
|
|
1395 |
(sensor := aView sensor) notNil ifTrue:[
|
|
1396 |
sensor focusInView:aView
|
|
1397 |
] ifFalse:[
|
|
1398 |
"
|
|
1399 |
if there is no sensor ...
|
|
1400 |
"
|
|
1401 |
WindowEvent
|
|
1402 |
sendEvent:#focusIn
|
|
1403 |
arguments:nil
|
|
1404 |
view:aView
|
|
1405 |
]
|
|
1406 |
!
|
|
1407 |
|
|
1408 |
focusOutView:aView
|
|
1409 |
"forward a focusOut event for some view"
|
|
1410 |
|
|
1411 |
|sensor|
|
|
1412 |
|
|
1413 |
(sensor := aView sensor) notNil ifTrue:[
|
|
1414 |
sensor focusOutView:aView
|
|
1415 |
] ifFalse:[
|
|
1416 |
"
|
|
1417 |
if there is no sensor ...
|
|
1418 |
"
|
|
1419 |
WindowEvent
|
|
1420 |
sendEvent:#focusOut
|
|
1421 |
arguments:nil
|
|
1422 |
view:aView
|
|
1423 |
]
|
|
1424 |
!
|
|
1425 |
|
|
1426 |
terminateView:aView
|
|
1427 |
"forward a terminate event for some view"
|
|
1428 |
|
|
1429 |
|sensor|
|
|
1430 |
|
|
1431 |
(sensor := aView sensor) notNil ifTrue:[
|
|
1432 |
sensor terminateView:aView
|
|
1433 |
] ifFalse:[
|
|
1434 |
"
|
|
1435 |
if there is no sensor ...
|
|
1436 |
"
|
|
1437 |
aView terminate
|
|
1438 |
]
|
|
1439 |
!
|
|
1440 |
|
|
1441 |
saveAndTerminateView:aView
|
|
1442 |
"forward a saveAndTerminate event for some view"
|
|
1443 |
|
|
1444 |
|sensor|
|
|
1445 |
|
|
1446 |
(sensor := aView sensor) notNil ifTrue:[
|
|
1447 |
sensor saveAndTerminateView:aView
|
|
1448 |
] ifFalse:[
|
|
1449 |
"
|
|
1450 |
if there is no sensor ...
|
|
1451 |
"
|
|
1452 |
aView saveAndTerminate
|
|
1453 |
]
|
|
1454 |
!
|
|
1455 |
|
|
1456 |
destroyedView:aView
|
|
1457 |
"forward a destroyed event for some view"
|
|
1458 |
|
|
1459 |
|sensor|
|
|
1460 |
|
|
1461 |
(sensor := aView sensor) notNil ifTrue:[
|
|
1462 |
sensor destroyedView:aView
|
|
1463 |
] ifFalse:[
|
|
1464 |
"
|
|
1465 |
if there is no sensor ...
|
|
1466 |
"
|
|
1467 |
aView destroyed
|
|
1468 |
]
|
|
1469 |
!
|
|
1470 |
|
|
1471 |
unmappedView:aView
|
|
1472 |
"forward an unmapped event for some view"
|
|
1473 |
|
|
1474 |
|sensor|
|
|
1475 |
|
|
1476 |
(sensor := aView sensor) notNil ifTrue:[
|
|
1477 |
sensor unmappedView:aView
|
|
1478 |
] ifFalse:[
|
|
1479 |
"
|
|
1480 |
if there is no sensor ...
|
|
1481 |
"
|
|
1482 |
aView unmapped
|
|
1483 |
]
|
|
1484 |
!
|
|
1485 |
|
|
1486 |
mappedView:aView
|
|
1487 |
"forward a mapped event for some view"
|
|
1488 |
|
|
1489 |
|sensor|
|
|
1490 |
|
|
1491 |
(sensor := aView sensor) notNil ifTrue:[
|
|
1492 |
sensor mappedView:aView
|
|
1493 |
] ifFalse:[
|
|
1494 |
"
|
|
1495 |
if there is no sensor ...
|
|
1496 |
"
|
|
1497 |
aView mapped
|
|
1498 |
]
|
|
1499 |
!
|
|
1500 |
|
|
1501 |
coveredBy:otherView view:aView
|
|
1502 |
"forward a covered for some view"
|
|
1503 |
|
|
1504 |
|sensor|
|
|
1505 |
|
|
1506 |
(sensor := aView sensor) notNil ifTrue:[
|
|
1507 |
sensor coveredBy:otherView view:aView
|
|
1508 |
] ifFalse:[
|
|
1509 |
"
|
|
1510 |
if there is no sensor ...
|
|
1511 |
"
|
|
1512 |
aView coveredBy:otherView
|
|
1513 |
]
|
|
1514 |
!
|
|
1515 |
|
|
1516 |
configureX:x y:y width:w height:h view:aView
|
|
1517 |
"forward a configure for some view"
|
|
1518 |
|
|
1519 |
|sensor|
|
|
1520 |
|
|
1521 |
(sensor := aView sensor) notNil ifTrue:[
|
|
1522 |
sensor configureX:x y:y width:w height:h view:aView
|
|
1523 |
] ifFalse:[
|
|
1524 |
"
|
|
1525 |
if there is no sensor ...
|
|
1526 |
"
|
|
1527 |
aView configureX:x y:y width:w height:h
|
|
1528 |
]
|
|
1529 |
!
|
|
1530 |
|
|
1531 |
exposeX:x y:y width:w height:h view:aView
|
|
1532 |
"forward an expose for some view"
|
|
1533 |
|
|
1534 |
|sensor|
|
|
1535 |
|
|
1536 |
(sensor := aView sensor) notNil ifTrue:[
|
|
1537 |
sensor exposeX:x y:y width:w height:h view:aView
|
|
1538 |
] ifFalse:[
|
|
1539 |
"
|
|
1540 |
if there is no sensor ...
|
|
1541 |
"
|
|
1542 |
WindowEvent
|
|
1543 |
sendEvent:#exposeX:y:width:height:
|
|
1544 |
arguments:(Array with:x with:y with:width with:height)
|
|
1545 |
view:aView
|
|
1546 |
]
|
|
1547 |
!
|
|
1548 |
|
|
1549 |
graphicExposeX:x y:y width:w height:h view:aView
|
|
1550 |
"forward a graphic expose for some view"
|
|
1551 |
|
|
1552 |
|sensor|
|
|
1553 |
|
|
1554 |
(sensor := aView sensor) notNil ifTrue:[
|
|
1555 |
sensor graphicExposeX:x y:y width:w height:h view:aView
|
|
1556 |
] ifFalse:[
|
|
1557 |
"
|
|
1558 |
if there is no sensor ...
|
|
1559 |
"
|
|
1560 |
WindowEvent
|
|
1561 |
sendEvent:#graphicExposeX:y:width:height:
|
|
1562 |
arguments:(Array with:x with:y with:width with:height)
|
|
1563 |
view:aView
|
|
1564 |
]
|
|
1565 |
!
|
|
1566 |
|
|
1567 |
noExposeView:aView
|
|
1568 |
"forward a noExpose event for some view"
|
|
1569 |
|
|
1570 |
|sensor|
|
|
1571 |
|
|
1572 |
(sensor := aView sensor) notNil ifTrue:[
|
|
1573 |
sensor noExposeView:aView
|
|
1574 |
] ifFalse:[
|
|
1575 |
"
|
|
1576 |
if there is no sensor ...
|
|
1577 |
"
|
|
1578 |
aView noExpose
|
|
1579 |
]
|
|
1580 |
! !
|
|
1581 |
|
54
|
1582 |
!DeviceWorkstation methodsFor:'view registration'!
|
0
|
1583 |
|
|
1584 |
addKnownView:aView withId:aNumber
|
54
|
1585 |
"add the View aView with id:aNumber to the list of known views/id's.
|
51
|
1586 |
This map is needed later (on event arrival) to get the view from
|
|
1587 |
the views id (which is passed along with the devices event) quickly."
|
0
|
1588 |
|
54
|
1589 |
|freeIdx newArr sz newSize id|
|
46
|
1590 |
|
0
|
1591 |
knownViews isNil ifTrue:[
|
118
|
1592 |
knownViews := WeakArray new:50.
|
71
|
1593 |
knownIds := Array new:50.
|
|
1594 |
freeIdx := 1.
|
54
|
1595 |
] ifFalse:[
|
118
|
1596 |
freeIdx := knownViews identityIndexOf:nil.
|
|
1597 |
|
|
1598 |
"/ 1 to:knownViews size do:[:idx |
|
|
1599 |
"/ (knownViews at:idx) isNil ifTrue:[
|
|
1600 |
"/ freeIdx := idx
|
|
1601 |
"/ id := knownIds at:idx.
|
|
1602 |
"/ id notNil ifTrue:[
|
|
1603 |
"/ "/ this one is no longer valid ...
|
|
1604 |
"/ knownIds at:idx put:nil.
|
|
1605 |
"/ ].
|
133
|
1606 |
"/ ]
|
|
1607 |
"/ ].
|
0
|
1608 |
].
|
46
|
1609 |
|
118
|
1610 |
freeIdx == 0 ifTrue:[
|
71
|
1611 |
sz := knownViews size.
|
|
1612 |
newSize := sz * 2.
|
|
1613 |
newArr := WeakArray new:newSize.
|
|
1614 |
newArr replaceFrom:1 to:sz with:knownViews.
|
|
1615 |
knownViews := newArr.
|
|
1616 |
|
|
1617 |
newArr := Array new:newSize.
|
|
1618 |
newArr replaceFrom:1 to:sz with:knownIds.
|
|
1619 |
knownIds := newArr.
|
|
1620 |
freeIdx := sz + 1
|
54
|
1621 |
].
|
|
1622 |
knownViews at:freeIdx put:aView.
|
|
1623 |
knownIds at:freeIdx put:aNumber.
|
0
|
1624 |
!
|
|
1625 |
|
|
1626 |
removeKnownView:aView
|
51
|
1627 |
"remove aView from the list of known views/id's."
|
0
|
1628 |
|
54
|
1629 |
|index|
|
|
1630 |
|
|
1631 |
aView isNil ifTrue:[^ self].
|
|
1632 |
|
46
|
1633 |
"/ idToViewMapping removeValue:aView ifAbsent:[].
|
|
1634 |
"/ lastId := nil.
|
|
1635 |
"/ lastView := nil
|
|
1636 |
|
0
|
1637 |
knownViews notNil ifTrue:[
|
71
|
1638 |
index := knownViews identityIndexOf:aView.
|
|
1639 |
index == 0 ifFalse:[
|
|
1640 |
knownViews at:index put:nil.
|
|
1641 |
knownIds at:index put:nil.
|
|
1642 |
lastId := nil.
|
|
1643 |
lastView := nil
|
|
1644 |
]
|
0
|
1645 |
]
|
|
1646 |
!
|
|
1647 |
|
|
1648 |
viewFromId:aNumber
|
51
|
1649 |
"given an Id, return the corresponding view."
|
0
|
1650 |
|
|
1651 |
|index|
|
|
1652 |
|
46
|
1653 |
"/ ^ idToViewMapping at:aNumber ifAbsent:[nil].
|
|
1654 |
|
8
|
1655 |
index := knownIds identityIndexOf:aNumber.
|
|
1656 |
index == 0 ifTrue:[^ nil].
|
54
|
1657 |
^ knownViews at:index.
|
|
1658 |
!
|
|
1659 |
|
|
1660 |
update:something
|
|
1661 |
|id|
|
|
1662 |
|
118
|
1663 |
"/ no longer called for ...
|
|
1664 |
"/
|
54
|
1665 |
something == knownViews ifTrue:[
|
71
|
1666 |
"
|
|
1667 |
some view was garbage-collected;
|
|
1668 |
destroy it ...
|
|
1669 |
"
|
|
1670 |
1 to:knownViews size do:[:idx |
|
|
1671 |
(knownViews at:idx) isNil ifTrue:[
|
|
1672 |
id := knownIds at:idx.
|
|
1673 |
id notNil ifTrue:[
|
|
1674 |
knownIds at:idx put:nil.
|
|
1675 |
].
|
|
1676 |
]
|
|
1677 |
].
|
54
|
1678 |
|
|
1679 |
]
|
0
|
1680 |
! !
|
|
1681 |
|
12
|
1682 |
!DeviceWorkstation methodsFor:'window stuff'!
|
|
1683 |
|
|
1684 |
setCursors:aCursor
|
|
1685 |
"change the cursor of all views to aCursorId"
|
|
1686 |
|
|
1687 |
| id |
|
|
1688 |
|
|
1689 |
id := (aCursor on:self) id.
|
|
1690 |
id notNil ifTrue:[
|
46
|
1691 |
"/ idToViewMapping notNil ifTrue:[
|
51
|
1692 |
"/ idToViewMapping keysAndValuesDo:[:viewId :view |
|
|
1693 |
"/ self setCursor:id in:viewId
|
|
1694 |
"/ ].
|
71
|
1695 |
knownViews do:[:aView |
|
|
1696 |
|vid|
|
|
1697 |
|
|
1698 |
(aView notNil and:[(vid := aView id) notNil]) ifTrue:[
|
|
1699 |
self setCursor:id in:vid
|
|
1700 |
]
|
|
1701 |
].
|
|
1702 |
self synchronizeOutput
|
46
|
1703 |
"/ ]
|
12
|
1704 |
]
|
|
1705 |
|
|
1706 |
"Display setCursors:Cursor wait"
|
|
1707 |
"Display restoreCursors"
|
|
1708 |
!
|
|
1709 |
|
|
1710 |
restoreCursors
|
|
1711 |
"restore the cursors of all views to their current cursor"
|
|
1712 |
|
46
|
1713 |
"/ idToViewMapping notNil ifTrue:[
|
51
|
1714 |
"/ idToViewMapping keysAndValuesDo:[:viewId :view |
|
|
1715 |
"/ |curs cid|
|
|
1716 |
"/ curs := view cursor.
|
|
1717 |
"/ curs notNil ifTrue:[
|
|
1718 |
"/ cid := curs id.
|
|
1719 |
"/ cid notNil ifTrue:[
|
|
1720 |
"/ self setCursor:cid in:viewId
|
|
1721 |
"/ ]
|
|
1722 |
"/ ]
|
|
1723 |
"/ ].
|
46
|
1724 |
"/ self synchronizeOutput
|
|
1725 |
"/ ]
|
|
1726 |
|
12
|
1727 |
knownViews notNil ifTrue:[
|
71
|
1728 |
knownViews do:[:aView |
|
|
1729 |
|c vid cid|
|
|
1730 |
|
|
1731 |
(aView notNil and:[(vid := aView id) notNil]) ifTrue:[
|
|
1732 |
c := aView cursor.
|
|
1733 |
(c notNil and:[(cid := c id) notNil]) ifTrue:[
|
|
1734 |
self setCursor:cid in:vid
|
|
1735 |
]
|
|
1736 |
]
|
|
1737 |
].
|
|
1738 |
self synchronizeOutput
|
12
|
1739 |
]
|
|
1740 |
|
|
1741 |
"Display setCursors:(Cursor wait)"
|
|
1742 |
"Display restoreCursors"
|
|
1743 |
! !
|
|
1744 |
|
86
|
1745 |
!DeviceWorkstation methodsFor:'event handling'!
|
12
|
1746 |
|
|
1747 |
startDispatch
|
|
1748 |
"create the display dispatch process"
|
|
1749 |
|
51
|
1750 |
|inputSema fd p|
|
12
|
1751 |
|
|
1752 |
dispatching ifTrue:[^ self].
|
|
1753 |
dispatching := true.
|
|
1754 |
|
|
1755 |
fd := self displayFileDescriptor.
|
|
1756 |
|
|
1757 |
ProcessorScheduler isPureEventDriven ifTrue:[
|
71
|
1758 |
"
|
|
1759 |
no threads built in;
|
|
1760 |
handle all events by having processor call a block when something
|
|
1761 |
arrives on my filedescriptor
|
|
1762 |
"
|
|
1763 |
Processor enableIOAction:[
|
|
1764 |
dispatching ifTrue:[
|
|
1765 |
[self eventPending] whileTrue:[
|
|
1766 |
self dispatchPendingEvents.
|
|
1767 |
self checkForEndOfDispatch.
|
|
1768 |
].
|
|
1769 |
dispatching ifFalse:[
|
|
1770 |
Processor disableFd:fd
|
|
1771 |
]
|
|
1772 |
]
|
|
1773 |
]
|
|
1774 |
onInput:fd
|
12
|
1775 |
|
|
1776 |
] ifFalse:[
|
71
|
1777 |
"
|
|
1778 |
handle stuff as a process - sitting on a semaphore.
|
|
1779 |
Tell Processor to trigger this semaphore when something arrives
|
|
1780 |
on my filedescriptor. Since a select alone is not enough to
|
|
1781 |
know if events are pending (Xlib reads out event-queue while
|
|
1782 |
doing output), we also have to install a poll-check block.
|
|
1783 |
"
|
|
1784 |
inputSema := Semaphore new.
|
|
1785 |
p := [
|
|
1786 |
[dispatching] whileTrue:[
|
94
|
1787 |
AbortSignal handle:[:ex |
|
|
1788 |
ex return
|
|
1789 |
] do:[
|
|
1790 |
self eventPending ifFalse:[
|
|
1791 |
Processor activeProcess setStateTo:#ioWait if:#active.
|
|
1792 |
inputSema wait.
|
|
1793 |
].
|
|
1794 |
|
|
1795 |
self dispatchPendingEvents.
|
|
1796 |
self checkForEndOfDispatch.
|
71
|
1797 |
]
|
94
|
1798 |
].
|
|
1799 |
Processor disableSemaphore:inputSema.
|
|
1800 |
inputSema := nil
|
71
|
1801 |
] forkAt:(Processor userInterruptPriority).
|
|
1802 |
"
|
|
1803 |
give the process a nice name
|
|
1804 |
"
|
133
|
1805 |
self displayName notNil ifTrue:[
|
|
1806 |
p name:'event dispatcher (' , self displayName , ')'.
|
|
1807 |
] ifFalse:[
|
|
1808 |
p name:'event dispatcher'.
|
|
1809 |
].
|
71
|
1810 |
Processor signal:inputSema onInput:fd orCheck:[self eventPending].
|
12
|
1811 |
]
|
|
1812 |
!
|
|
1813 |
|
|
1814 |
checkForEndOfDispatch
|
46
|
1815 |
"return true, if there are still any views of interrest -
|
|
1816 |
if not, stop dispatch"
|
12
|
1817 |
|
|
1818 |
self == Display ifTrue:[
|
51
|
1819 |
"/ idToViewMapping isEmpty ifTrue:[
|
71
|
1820 |
knownViews isEmpty ifTrue:[
|
|
1821 |
dispatching := false
|
|
1822 |
]
|
12
|
1823 |
]
|
|
1824 |
!
|
|
1825 |
|
|
1826 |
dispatchPendingEvents
|
83
|
1827 |
[self eventPending] whileTrue:[
|
|
1828 |
self dispatchEventFor:nil withMask:nil
|
12
|
1829 |
]
|
|
1830 |
!
|
|
1831 |
|
21
|
1832 |
dispatchModalWhile:aBlock
|
|
1833 |
"get and process next event for any view as long as the
|
|
1834 |
argument-block evaluates to true.
|
51
|
1835 |
This is a modal loop, not switching to other processes,
|
|
1836 |
effectively polling the device in a (nice) busy loop.
|
|
1837 |
This should only be used for emergency cases.
|
|
1838 |
(such as a graphical debugger, debugging the event-dispatcher itself)"
|
|
1839 |
|
|
1840 |
|myFd|
|
12
|
1841 |
|
51
|
1842 |
"
|
|
1843 |
if this display has a fileDescriptor to wait on,
|
|
1844 |
it is used; otherwise we poll (with a delay to not lock up
|
|
1845 |
the workstation)
|
|
1846 |
"
|
|
1847 |
myFd := self displayFileDescriptor.
|
12
|
1848 |
[aBlock value] whileTrue:[
|
71
|
1849 |
self eventPending ifFalse:[
|
|
1850 |
myFd isNil ifTrue:[
|
|
1851 |
OperatingSystem millisecondDelay:50
|
|
1852 |
] ifFalse:[
|
|
1853 |
OperatingSystem selectOn:myFd withTimeOut:50.
|
|
1854 |
].
|
|
1855 |
Processor evaluateTimeouts.
|
|
1856 |
].
|
|
1857 |
self eventPending ifTrue:[
|
|
1858 |
self dispatchEvent
|
|
1859 |
].
|
51
|
1860 |
]
|
12
|
1861 |
!
|
|
1862 |
|
|
1863 |
dispatchEvent
|
|
1864 |
"get and process next event for any view"
|
|
1865 |
|
|
1866 |
self dispatchEventFor:nil withMask:nil
|
23
|
1867 |
!
|
|
1868 |
|
|
1869 |
eventMaskFor:anEventSymbol
|
|
1870 |
^ self subclassResponsibility
|
|
1871 |
!
|
|
1872 |
|
|
1873 |
setEventMask:aMask in:aWindowId
|
|
1874 |
^ self subclassResponsibility
|
|
1875 |
!
|
|
1876 |
|
|
1877 |
dispatchEventFor:aViewIdOrNil withMask:eventMask
|
|
1878 |
"central event handling method:
|
|
1879 |
get next event and send appropriate message to the view or the sensor,
|
|
1880 |
if the view has one.
|
|
1881 |
If the argument aViewIdOrNil is nil, events for any view are processed,
|
|
1882 |
otherwise only events for the view with given id are processed
|
|
1883 |
(in this case, nothing is done if no events are pending);
|
|
1884 |
if the argument aMask is nonNil, only events for this eventMask are
|
|
1885 |
handled;"
|
|
1886 |
|
|
1887 |
^ self subclassResponsibility
|
|
1888 |
!
|
|
1889 |
|
|
1890 |
disposeEventsWithMask:aMask for:aWindowId
|
|
1891 |
"dispose (throw away) specific events"
|
|
1892 |
|
|
1893 |
^ self subclassResponsibility
|
|
1894 |
!
|
|
1895 |
|
|
1896 |
disposeEvents
|
|
1897 |
"flush all events pending on this display"
|
|
1898 |
|
|
1899 |
[self eventPending] whileTrue:[
|
71
|
1900 |
self getEventFor:nil withMask:nil
|
23
|
1901 |
].
|
|
1902 |
!
|
|
1903 |
|
81
|
1904 |
disposeButtonEventsFor:aViewIdOrNil
|
|
1905 |
"flush (i.e. forget) all pending button events on this display"
|
|
1906 |
|
|
1907 |
|mask|
|
|
1908 |
|
|
1909 |
mask := self eventMaskFor:#buttonPress.
|
|
1910 |
mask := mask bitOr:(self eventMaskFor:#buttonRelease).
|
|
1911 |
mask := mask bitOr:(self eventMaskFor:#buttonMotion).
|
|
1912 |
self disposeEventsWithMask:mask for:aViewIdOrNil
|
|
1913 |
!
|
|
1914 |
|
23
|
1915 |
eventPending
|
|
1916 |
"return true, if any event is pending"
|
|
1917 |
|
|
1918 |
^ self subclassResponsibility
|
|
1919 |
!
|
|
1920 |
|
|
1921 |
eventPendingWithoutSync
|
|
1922 |
"return true, if any event is pending"
|
|
1923 |
|
|
1924 |
^ self subclassResponsibility
|
|
1925 |
!
|
|
1926 |
|
|
1927 |
eventsPending:anEventMask for:aWindowId
|
|
1928 |
"return true, if any of the masked events is pending"
|
|
1929 |
|
|
1930 |
^ self subclassResponsibility
|
|
1931 |
!
|
|
1932 |
|
|
1933 |
eventPending:anEventSymbol for:aWindowId
|
|
1934 |
"return true, if a specific event is pending"
|
|
1935 |
|
|
1936 |
^ self subclassResponsibility
|
12
|
1937 |
! !
|
|
1938 |
|
|
1939 |
!DeviceWorkstation methodsFor:'bitmap/window creation'!
|
|
1940 |
|
|
1941 |
createFaxImageFromArray:data width:w height:h type:type k:k msbFirst:msbFirst
|
51
|
1942 |
"create a new faxImage in the workstation.
|
|
1943 |
This is a special interface to servers with the fax-image
|
|
1944 |
extension (you won't find it in standard X-servers).
|
|
1945 |
|
12
|
1946 |
type: 0 -> uncompressed
|
71
|
1947 |
1 -> group3 1D (k is void)
|
|
1948 |
2 -> group3 2D
|
|
1949 |
3 -> group4 2D (k is void)
|
51
|
1950 |
"
|
12
|
1951 |
|
|
1952 |
^ nil
|
|
1953 |
!
|
|
1954 |
|
|
1955 |
createBitmapWidth:w height:h
|
|
1956 |
"allocate a bitmap on the Xserver, the contents is undefined
|
|
1957 |
(i.e. random). Return a bitmap id or nil"
|
|
1958 |
|
|
1959 |
^ self subclassResponsibility
|
|
1960 |
!
|
|
1961 |
|
|
1962 |
createPixmapWidth:w height:h depth:d
|
|
1963 |
"allocate a pixmap on the Xserver, the contents is undefined
|
|
1964 |
(i.e. random). Return a bitmap id or nil"
|
|
1965 |
|
|
1966 |
^ self subclassResponsibility
|
|
1967 |
!
|
|
1968 |
|
|
1969 |
createBitmapFromFile:aString for:aForm
|
|
1970 |
^ self subclassResponsibility
|
|
1971 |
!
|
|
1972 |
|
|
1973 |
createBitmapFromArray:anArray width:w height:h
|
|
1974 |
^ self subclassResponsibility
|
|
1975 |
!
|
|
1976 |
|
|
1977 |
destroyPixmap:aDrawableId
|
|
1978 |
^ self subclassResponsibility
|
|
1979 |
!
|
|
1980 |
|
|
1981 |
destroyFaxImage:aFaxImageId
|
|
1982 |
^ self subclassResponsibility
|
|
1983 |
!
|
|
1984 |
|
|
1985 |
rootWindowFor:aView
|
|
1986 |
^ self subclassResponsibility
|
|
1987 |
!
|
|
1988 |
|
|
1989 |
createWindowFor:aView left:xpos top:ypos width:wwidth height:wheight
|
|
1990 |
^ self subclassResponsibility
|
|
1991 |
!
|
|
1992 |
|
|
1993 |
destroyView:aView withId:aWindowId
|
|
1994 |
^ self subclassResponsibility
|
|
1995 |
!
|
|
1996 |
|
|
1997 |
destroyGC:aGCId
|
|
1998 |
"destroy a GC"
|
|
1999 |
|
|
2000 |
^ self subclassResponsibility
|
|
2001 |
!
|
|
2002 |
|
|
2003 |
gcFor:aDrawableId
|
|
2004 |
"create a GC for drawing into aDrawable"
|
|
2005 |
|
|
2006 |
^ self subclassResponsibility
|
|
2007 |
! !
|
|
2008 |
|
0
|
2009 |
!DeviceWorkstation methodsFor:'font stuff'!
|
|
2010 |
|
12
|
2011 |
listOfAvailableFonts
|
|
2012 |
"return a list containing all fonts on this display.
|
|
2013 |
The returned list is an array of 4-element arrays, each
|
|
2014 |
containing family, face, style, size and encoding."
|
|
2015 |
|
|
2016 |
self subclassResponsibility
|
|
2017 |
!
|
|
2018 |
|
0
|
2019 |
fontFamilies
|
|
2020 |
"return a set of all available font families on this display"
|
|
2021 |
|
|
2022 |
|allFonts families family|
|
|
2023 |
|
|
2024 |
allFonts := self listOfAvailableFonts.
|
|
2025 |
allFonts isNil ifTrue:[^ nil].
|
|
2026 |
families := Set new.
|
51
|
2027 |
allFonts do:[:fntDescr |
|
71
|
2028 |
family := fntDescr family.
|
|
2029 |
family notNil ifTrue:[
|
|
2030 |
families add:family
|
|
2031 |
]
|
0
|
2032 |
].
|
89
|
2033 |
^ families asSortedCollection
|
0
|
2034 |
|
51
|
2035 |
"
|
|
2036 |
Display fontFamilies
|
|
2037 |
"
|
0
|
2038 |
!
|
|
2039 |
|
|
2040 |
facesInFamily:aFamilyName
|
|
2041 |
"return a set of all available font faces in aFamily on this display"
|
|
2042 |
|
75
|
2043 |
|allFonts faces "family face"|
|
0
|
2044 |
|
|
2045 |
allFonts := self listOfAvailableFonts.
|
|
2046 |
allFonts isNil ifTrue:[^ nil].
|
51
|
2047 |
|
0
|
2048 |
faces := Set new.
|
51
|
2049 |
allFonts do:[:fntDescr |
|
75
|
2050 |
aFamilyName = fntDescr family ifTrue:[
|
71
|
2051 |
faces add:(fntDescr face)
|
|
2052 |
]
|
0
|
2053 |
].
|
89
|
2054 |
^ faces asSortedCollection
|
0
|
2055 |
|
51
|
2056 |
"
|
|
2057 |
Display facesInFamily:'times'
|
|
2058 |
Display facesInFamily:'fixed'
|
|
2059 |
"
|
0
|
2060 |
!
|
|
2061 |
|
|
2062 |
stylesInFamily:aFamilyName face:aFaceName
|
|
2063 |
"return a set of all available font styles in aFamily/aFace on this display"
|
|
2064 |
|
75
|
2065 |
|allFonts styles "family face style"|
|
0
|
2066 |
|
|
2067 |
allFonts := self listOfAvailableFonts.
|
|
2068 |
allFonts isNil ifTrue:[^ nil].
|
51
|
2069 |
|
0
|
2070 |
styles := Set new.
|
51
|
2071 |
allFonts do:[:fntDescr |
|
75
|
2072 |
(aFamilyName = fntDescr family) ifTrue:[
|
|
2073 |
(aFaceName = fntDescr face) ifTrue:[
|
71
|
2074 |
styles add:fntDescr style
|
|
2075 |
]
|
|
2076 |
]
|
0
|
2077 |
].
|
89
|
2078 |
^ styles asSortedCollection
|
0
|
2079 |
|
51
|
2080 |
"
|
|
2081 |
Display stylesInFamily:'times' face:'medium'
|
|
2082 |
Display stylesInFamily:'times' face:'bold'
|
|
2083 |
"
|
0
|
2084 |
!
|
|
2085 |
|
|
2086 |
sizesInFamily:aFamilyName face:aFaceName style:aStyleName
|
|
2087 |
"return a set of all available font sizes in aFamily/aFace/aStyle
|
|
2088 |
on this display"
|
|
2089 |
|
75
|
2090 |
|allFonts sizes "family face style size"|
|
0
|
2091 |
|
|
2092 |
allFonts := self listOfAvailableFonts.
|
|
2093 |
allFonts isNil ifTrue:[^ nil].
|
51
|
2094 |
|
0
|
2095 |
sizes := Set new.
|
51
|
2096 |
allFonts do:[:fntDescr |
|
|
2097 |
"/ family := fntDescr at:1.
|
|
2098 |
"/ (family = aFamilyName) ifTrue:[
|
|
2099 |
"/ face := fntDescr at:2.
|
|
2100 |
"/ (face = aFaceName) ifTrue:[
|
|
2101 |
"/ style := fntDescr at:3.
|
|
2102 |
"/ (style = aStyleName) ifTrue:[
|
|
2103 |
"/ size := fntDescr at:4.
|
|
2104 |
"/ sizes add:size
|
|
2105 |
"/ ]
|
|
2106 |
"/ ]
|
|
2107 |
"/ ]
|
75
|
2108 |
(aFamilyName = fntDescr family) ifTrue:[
|
|
2109 |
(aFaceName = fntDescr face) ifTrue:[
|
|
2110 |
(aStyleName = fntDescr style) ifTrue:[
|
71
|
2111 |
sizes add:fntDescr size
|
|
2112 |
]
|
|
2113 |
]
|
|
2114 |
]
|
0
|
2115 |
].
|
|
2116 |
^ sizes
|
|
2117 |
|
51
|
2118 |
"
|
|
2119 |
Display sizesInFamily:'times' face:'medium' style:'italic'
|
|
2120 |
"
|
8
|
2121 |
!
|
|
2122 |
|
12
|
2123 |
getFontWithFamily:familyString
|
71
|
2124 |
face:faceString
|
|
2125 |
style:styleString
|
|
2126 |
size:sizeArg
|
|
2127 |
encoding:encodingSym
|
0
|
2128 |
|
12
|
2129 |
"try to get the specified font, return id.
|
|
2130 |
If not available, try next smaller font.
|
|
2131 |
If no font fits, return nil"
|
0
|
2132 |
|
|
2133 |
^ self subclassResponsibility
|
|
2134 |
!
|
|
2135 |
|
|
2136 |
getDefaultFont
|
12
|
2137 |
"return a default font id
|
|
2138 |
- used when class Font cannot find anything usable"
|
0
|
2139 |
|
|
2140 |
^ self subclassResponsibility
|
|
2141 |
!
|
|
2142 |
|
|
2143 |
releaseFont:aFontId
|
12
|
2144 |
"free a font"
|
|
2145 |
|
0
|
2146 |
^ self subclassResponsibility
|
|
2147 |
!
|
|
2148 |
|
|
2149 |
ascentOf:aFontId
|
12
|
2150 |
"return the number of pixels above the base line of a font"
|
|
2151 |
|
0
|
2152 |
^ self subclassResponsibility
|
|
2153 |
!
|
|
2154 |
|
|
2155 |
descentOf:aFontId
|
12
|
2156 |
"return the number of pixels below the base line of a font"
|
|
2157 |
|
0
|
2158 |
^ self subclassResponsibility
|
|
2159 |
!
|
|
2160 |
|
|
2161 |
minWidthOfFont:aFontId
|
12
|
2162 |
"return the width in pixels of the smallest character a specific font"
|
|
2163 |
|
0
|
2164 |
^ self subclassResponsibility
|
|
2165 |
!
|
|
2166 |
|
|
2167 |
maxWidthOfFont:aFontId
|
12
|
2168 |
"return the width in pixels of the widest character a specific font"
|
|
2169 |
|
0
|
2170 |
^ self subclassResponsibility
|
|
2171 |
!
|
|
2172 |
|
|
2173 |
widthOf:aString inFont:aFontId
|
12
|
2174 |
"return the width in pixels of a string in a specific font"
|
|
2175 |
|
0
|
2176 |
^ self subclassResponsibility
|
|
2177 |
!
|
|
2178 |
|
|
2179 |
widthOf:aString from:index1 to:index2 inFont:aFontId
|
12
|
2180 |
"return the width in pixels of a substring in a specific font"
|
|
2181 |
|
0
|
2182 |
^ self subclassResponsibility
|
|
2183 |
! !
|
|
2184 |
|
|
2185 |
!DeviceWorkstation methodsFor:'cursor stuff'!
|
|
2186 |
|
|
2187 |
destroyCursor:aCursorId
|
12
|
2188 |
"free a cursor"
|
|
2189 |
|
0
|
2190 |
^ self subclassResponsibility
|
|
2191 |
!
|
|
2192 |
|
|
2193 |
createCursorSourceForm:sourceForm maskForm:maskForm hotX:hx hotY:hy
|
|
2194 |
"create a cursor given 2 bitmaps (source, mask) and a hotspot"
|
|
2195 |
^ self subclassResponsibility
|
|
2196 |
!
|
|
2197 |
|
|
2198 |
createCursorShape:aShape
|
|
2199 |
"create a cursor given a shape-symbol"
|
|
2200 |
|
|
2201 |
^ self subclassResponsibility
|
|
2202 |
!
|
|
2203 |
|
|
2204 |
colorCursor:aCursorId foreground:fgColor background:bgColor
|
|
2205 |
"change a cursors colors"
|
|
2206 |
|
|
2207 |
^ self subclassResponsibility
|
81
|
2208 |
! !
|
|
2209 |
|
|
2210 |
!DeviceWorkstation methodsFor:'grabbing '!
|
|
2211 |
|
|
2212 |
grabKeyboardInView:aView
|
|
2213 |
"grab the keyboard - all keyboard input will be sent to aView.
|
|
2214 |
Return true if ok, false if it failed for some reason."
|
|
2215 |
|
|
2216 |
activeKeyboardGrab notNil ifTrue:[
|
|
2217 |
self ungrabKeyboard.
|
|
2218 |
activeKeyboardGrab := nil
|
|
2219 |
].
|
|
2220 |
(self grabKeyboardIn:(aView id)) ifTrue:[
|
|
2221 |
activeKeyboardGrab := aView.
|
|
2222 |
^ true
|
|
2223 |
].
|
|
2224 |
^ false
|
0
|
2225 |
!
|
|
2226 |
|
|
2227 |
grabKeyboardIn:aWindowId
|
81
|
2228 |
"grab the keyboard - all keyboard input will be sent to the view
|
|
2229 |
with id aWindowId"
|
0
|
2230 |
|
|
2231 |
^ self subclassResponsibility
|
|
2232 |
!
|
|
2233 |
|
|
2234 |
ungrabKeyboard
|
|
2235 |
"release the keyboard"
|
10
|
2236 |
|
0
|
2237 |
^ self subclassResponsibility
|
|
2238 |
!
|
|
2239 |
|
81
|
2240 |
activeKeyboardGrab
|
|
2241 |
"return the view, which currently has the keyboard grabbed,
|
|
2242 |
or nil, if there is none"
|
|
2243 |
|
|
2244 |
^ activeKeyboardGrab
|
|
2245 |
!
|
|
2246 |
|
|
2247 |
grabPointerInView:aView
|
|
2248 |
"grap the pointer; all pointer events will be reported to
|
|
2249 |
aView. Return true if ok, false if it failed for some reason."
|
|
2250 |
|
|
2251 |
activePointerGrab notNil ifTrue:[
|
|
2252 |
self ungrabPointer.
|
|
2253 |
activePointerGrab := nil
|
|
2254 |
].
|
|
2255 |
(self grabPointerIn:(aView id)) ifTrue:[
|
|
2256 |
activePointerGrab := aView.
|
|
2257 |
^ true
|
|
2258 |
].
|
|
2259 |
^ false
|
|
2260 |
!
|
|
2261 |
|
75
|
2262 |
grabPointerIn:aWindowId withCursor:cursorId pointerMode:pMode keyboardMode:kMode confineTo:confineId
|
|
2263 |
"grap the pointer - all pointer events will be reported to aWindowId. The cursor will be set to cursorId
|
|
2264 |
for the duration of the grab. For pMode/kMode, see X documentation. The pointer is restricted to
|
|
2265 |
confineId - if non-nil."
|
10
|
2266 |
|
0
|
2267 |
^ self subclassResponsibility
|
|
2268 |
!
|
|
2269 |
|
75
|
2270 |
grabPointerIn:aWindowId
|
81
|
2271 |
"grap the pointer; all pointer events will be reported to the view
|
|
2272 |
with id aWindowId. Return true if ok, false if it failed for some reason."
|
75
|
2273 |
|
|
2274 |
^ self grabPointerIn:aWindowId withCursor:nil pointerMode:#async keyboardMode:#sync confineTo:nil
|
|
2275 |
!
|
|
2276 |
|
0
|
2277 |
ungrabPointer
|
|
2278 |
"release the pointer"
|
10
|
2279 |
|
0
|
2280 |
^ self subclassResponsibility
|
81
|
2281 |
!
|
|
2282 |
|
|
2283 |
activePointerGrab
|
|
2284 |
"return the view, which currently has the pointer grabbed,
|
|
2285 |
or nil, if there is none"
|
|
2286 |
|
|
2287 |
^ activePointerGrab
|
|
2288 |
!
|
|
2289 |
|
|
2290 |
setActivePointerGrab:aView
|
|
2291 |
"DO NOT USE. private kludge - will vanish"
|
|
2292 |
|
|
2293 |
activePointerGrab := aView
|
0
|
2294 |
! !
|
|
2295 |
|
|
2296 |
!DeviceWorkstation methodsFor:'color stuff'!
|
|
2297 |
|
|
2298 |
listOfAvailableColors
|
|
2299 |
"return a list of all available colornames;
|
|
2300 |
This method should not be used, since colornames are
|
12
|
2301 |
very X specific. However, the names defined here are pretty common"
|
0
|
2302 |
|
|
2303 |
^ #('red' 'green' 'blue' 'yellow' 'magenta' 'cyan' 'white' 'black')
|
|
2304 |
!
|
|
2305 |
|
|
2306 |
freeColor:colorIndex
|
|
2307 |
"free a color on the display, when its no longer needed"
|
|
2308 |
|
|
2309 |
^ self subclassResponsibility
|
|
2310 |
!
|
|
2311 |
|
|
2312 |
colorRed:redVal green:greenVal blue:blueVal
|
|
2313 |
"allocate a color with rgb values (0..100) - return index"
|
|
2314 |
|
|
2315 |
^ self subclassResponsibility
|
|
2316 |
!
|
|
2317 |
|
|
2318 |
colorNamed:aString
|
|
2319 |
"allocate a color with color name - return index.
|
|
2320 |
Colors should not be allocated by name, since most colors
|
|
2321 |
are X specific - get colors by rgb instead."
|
|
2322 |
|
|
2323 |
"support some of them ..."
|
|
2324 |
|
|
2325 |
self getRGBFromName:aString into:[:r :g :b |
|
71
|
2326 |
^ self colorRed:r green:g blue:b
|
0
|
2327 |
].
|
|
2328 |
^ nil
|
|
2329 |
!
|
|
2330 |
|
|
2331 |
colorCell
|
|
2332 |
"allocate a color - return index"
|
|
2333 |
|
|
2334 |
^ self subclassResponsibility
|
|
2335 |
!
|
|
2336 |
|
|
2337 |
setColor:index red:redVal green:greenVal blue:blueVal
|
|
2338 |
"change color in map at:index to rgb (0..100)"
|
|
2339 |
|
|
2340 |
^ self subclassResponsibility
|
|
2341 |
!
|
|
2342 |
|
89
|
2343 |
redComponentOfColor:colorId
|
|
2344 |
"get red component (0..100) of color in map at:index"
|
|
2345 |
|
|
2346 |
self getRGBFrom:colorId into:[:r :g :b | ^ r]
|
|
2347 |
!
|
|
2348 |
|
|
2349 |
greenComponentOfColor:colorId
|
|
2350 |
"get green component (0..100) of color in map at:index"
|
|
2351 |
|
|
2352 |
self getRGBFrom:colorId into:[:r :g :b | ^ g]
|
|
2353 |
!
|
|
2354 |
|
|
2355 |
blueComponentOfColor:colorId
|
|
2356 |
"get blue component (0..100) of color in map at:index"
|
|
2357 |
|
|
2358 |
self getRGBFrom:colorId into:[:r :g :b | ^ b]
|
|
2359 |
!
|
|
2360 |
|
0
|
2361 |
getRGBFromName:colorName into:aBlock
|
|
2362 |
"get rgb components (0..100) of color named colorName,
|
|
2363 |
and evaluate the 3-arg block, aBlock with them.
|
|
2364 |
The method here only handles some often used colors;
|
|
2365 |
getRGBFromName should not be used, since colorNames other
|
|
2366 |
than those below are X specific."
|
|
2367 |
|
|
2368 |
|idx names triple|
|
|
2369 |
|
|
2370 |
names := #('red' 'green' 'blue' 'yellow' 'magenta' 'cyan' 'white' 'black').
|
8
|
2371 |
idx := names indexOf:colorName.
|
0
|
2372 |
idx == 0 ifTrue:[
|
71
|
2373 |
idx := (names asLowercase) indexOf:colorName.
|
0
|
2374 |
].
|
|
2375 |
idx == 0 ifFalse:[
|
71
|
2376 |
triple := #(
|
|
2377 |
(100 0 0) "red"
|
|
2378 |
( 0 100 0) "green"
|
|
2379 |
( 0 0 100) "blue"
|
|
2380 |
(100 100 0) "yellow"
|
|
2381 |
(100 0 100) "magenta"
|
|
2382 |
( 0 100 100) "cyan"
|
|
2383 |
(100 100 100) "white"
|
|
2384 |
( 0 0 0) "black"
|
|
2385 |
) at:idx.
|
0
|
2386 |
|
71
|
2387 |
^ aBlock value:(triple at:1)
|
|
2388 |
value:(triple at:2)
|
|
2389 |
value:(triple at:3)
|
0
|
2390 |
].
|
|
2391 |
^ nil
|
|
2392 |
!
|
|
2393 |
|
|
2394 |
getRGBFrom:index into:aBlock
|
|
2395 |
"get rgb components (0..100) of color in map at:index,
|
|
2396 |
and evaluate the 3-arg block, aBlock with them"
|
|
2397 |
|
|
2398 |
^ self subclassResponsibility
|
|
2399 |
! !
|
|
2400 |
|
|
2401 |
!DeviceWorkstation methodsFor:'window stuff'!
|
|
2402 |
|
|
2403 |
setBackingStore:how in:aWindowId
|
|
2404 |
"turn on/off backing-store for a window"
|
10
|
2405 |
|
0
|
2406 |
^ self subclassResponsibility
|
|
2407 |
!
|
|
2408 |
|
|
2409 |
setSaveUnder:yesOrNo in:aWindowId
|
|
2410 |
"turn on/off save-under for a window"
|
10
|
2411 |
|
0
|
2412 |
^ self subclassResponsibility
|
|
2413 |
!
|
|
2414 |
|
|
2415 |
setWindowBackground:aColorIndex in:aWindowId
|
10
|
2416 |
"set a windows background color"
|
0
|
2417 |
|
|
2418 |
^ self subclassResponsibility
|
|
2419 |
!
|
|
2420 |
|
|
2421 |
setWindowBackgroundPixmap:aPixmapId in:aWindowId
|
10
|
2422 |
"set a windows background pattern to be a form"
|
|
2423 |
|
0
|
2424 |
^ self subclassResponsibility
|
|
2425 |
!
|
|
2426 |
|
|
2427 |
setWindowBorderColor:aColorIndex in:aWindowId
|
10
|
2428 |
"set a windows border color"
|
|
2429 |
|
0
|
2430 |
^ self subclassResponsibility
|
|
2431 |
!
|
|
2432 |
|
|
2433 |
setWindowBorderPixmap:aPixmapId in:aWindowId
|
10
|
2434 |
"set a windows border pattern"
|
|
2435 |
|
0
|
2436 |
^ self subclassResponsibility
|
|
2437 |
!
|
|
2438 |
|
|
2439 |
setWindowBorderWidth:aNumber in:aWindowId
|
10
|
2440 |
"set a windows border width"
|
|
2441 |
|
0
|
2442 |
^ self subclassResponsibility
|
|
2443 |
!
|
|
2444 |
|
|
2445 |
setWindowBorderShape:aPixmapId in:aWindowId
|
10
|
2446 |
"set a windows border shape"
|
|
2447 |
|
0
|
2448 |
^ self subclassResponsibility
|
|
2449 |
!
|
|
2450 |
|
|
2451 |
setWindowShape:aPixmapId in:aWindowId
|
10
|
2452 |
"set a windows visible shape"
|
|
2453 |
|
0
|
2454 |
^ self subclassResponsibility
|
|
2455 |
!
|
|
2456 |
|
|
2457 |
setCursor:aCursorId in:aWindowId
|
10
|
2458 |
"set a windows visible shape"
|
|
2459 |
|
0
|
2460 |
^ self subclassResponsibility
|
|
2461 |
!
|
|
2462 |
|
|
2463 |
setWindowName:aString in:aWindowId
|
10
|
2464 |
"set a windows name"
|
|
2465 |
|
0
|
2466 |
^ self subclassResponsibility
|
|
2467 |
!
|
|
2468 |
|
|
2469 |
setIconName:aString in:aWindowId
|
10
|
2470 |
"set a windows icon name"
|
|
2471 |
|
0
|
2472 |
^ self subclassResponsibility
|
|
2473 |
!
|
|
2474 |
|
|
2475 |
setWindowIcon:aForm in:aWindowId
|
10
|
2476 |
"set a windows icon"
|
|
2477 |
|
0
|
2478 |
^ self subclassResponsibility
|
|
2479 |
!
|
|
2480 |
|
|
2481 |
setWindowIconWindow:aView in:aWindowId
|
10
|
2482 |
"set a windows icon window"
|
|
2483 |
|
0
|
2484 |
^ self subclassResponsibility
|
|
2485 |
!
|
|
2486 |
|
|
2487 |
clearWindow:aWindowId
|
10
|
2488 |
"clear a windows to its view background"
|
|
2489 |
|
0
|
2490 |
^ self subclassResponsibility
|
|
2491 |
!
|
|
2492 |
|
|
2493 |
clearRectangleX:x y:y width:width height:height in:aWindowId
|
10
|
2494 |
"clear a rectangular area of a window to its view background"
|
|
2495 |
|
0
|
2496 |
^ self subclassResponsibility
|
|
2497 |
!
|
|
2498 |
|
23
|
2499 |
mapView:aView id:aWindowId iconified:aBoolean atX:xPos y:yPos width:w height:h
|
0
|
2500 |
^ self subclassResponsibility
|
|
2501 |
!
|
|
2502 |
|
|
2503 |
mapWindow:aWindowId
|
|
2504 |
^ self subclassResponsibility
|
|
2505 |
!
|
|
2506 |
|
|
2507 |
unmapWindow:aWindowId
|
|
2508 |
^ self subclassResponsibility
|
|
2509 |
!
|
|
2510 |
|
|
2511 |
raiseWindow:aWindowId
|
|
2512 |
^ self subclassResponsibility
|
|
2513 |
!
|
|
2514 |
|
|
2515 |
lowerWindow:aWindowId
|
|
2516 |
^ self subclassResponsibility
|
|
2517 |
!
|
|
2518 |
|
|
2519 |
moveWindow:aWindowId x:x y:y
|
|
2520 |
^ self subclassResponsibility
|
|
2521 |
!
|
|
2522 |
|
|
2523 |
resizeWindow:aWindowId width:w height:h
|
|
2524 |
^ self subclassResponsibility
|
|
2525 |
!
|
|
2526 |
|
|
2527 |
moveResizeWindow:aWindowId x:x y:y width:w height:h
|
|
2528 |
^ self subclassResponsibility
|
|
2529 |
! !
|
|
2530 |
|
|
2531 |
!DeviceWorkstation methodsFor:'graphic context stuff'!
|
|
2532 |
|
|
2533 |
setForeground:fgColorIndex in:aGCId
|
|
2534 |
"set foreground color to be drawn with"
|
133
|
2535 |
|
0
|
2536 |
^ self subclassResponsibility
|
|
2537 |
!
|
|
2538 |
|
|
2539 |
setBackground:bgColorIndex in:aGCId
|
|
2540 |
"set background color to be drawn with"
|
133
|
2541 |
|
0
|
2542 |
^ self subclassResponsibility
|
|
2543 |
!
|
|
2544 |
|
|
2545 |
setForeground:fgColorIndex background:bgColorIndex in:aGCId
|
|
2546 |
"set foreground and background colors to be drawn with"
|
133
|
2547 |
|
0
|
2548 |
^ self subclassResponsibility
|
|
2549 |
!
|
|
2550 |
|
|
2551 |
setForeground:fgColor background:bgColor mask:aBitmapId in:aGCId
|
|
2552 |
"set foreground and background colors to be drawn with using mask or
|
|
2553 |
solid (if aBitmapId is nil)"
|
133
|
2554 |
|
0
|
2555 |
^ self subclassResponsibility
|
|
2556 |
!
|
|
2557 |
|
|
2558 |
setLineWidth:aNumber style:lineStyle cap:capStyle join:joinStyle in:aGCId
|
|
2559 |
"set line attributes"
|
133
|
2560 |
|
0
|
2561 |
^ self subclassResponsibility
|
|
2562 |
!
|
|
2563 |
|
|
2564 |
setForeground:fgColor background:bgColor mask:aBitmapId lineWidth:lw in:aGCId
|
|
2565 |
"set foreground and background colors to be drawn with using mask or
|
|
2566 |
solid (if aBitmapId is nil); also set lineWidth"
|
133
|
2567 |
|
0
|
2568 |
^ self subclassResponsibility
|
|
2569 |
!
|
|
2570 |
|
|
2571 |
setFunction:aFunctionSymbol in:aGCId
|
|
2572 |
"set alu function to be drawn with"
|
133
|
2573 |
|
0
|
2574 |
^ self subclassResponsibility
|
|
2575 |
!
|
|
2576 |
|
|
2577 |
setFont:aFontId in:aGCId
|
|
2578 |
"set font to be drawn in"
|
133
|
2579 |
|
0
|
2580 |
^ self subclassResponsibility
|
|
2581 |
!
|
|
2582 |
|
|
2583 |
setPixmapMask:aPixmapId in:aGCId
|
|
2584 |
"set or clear the drawing mask - a pixmap mask providing full color"
|
|
2585 |
|
|
2586 |
^ self subclassResponsibility
|
|
2587 |
!
|
|
2588 |
|
|
2589 |
setBitmapMask:aBitmapId in:aGCId
|
|
2590 |
"set or clear the drawing mask - a bitmap mask using current fg/bg"
|
133
|
2591 |
|
0
|
2592 |
^ self subclassResponsibility
|
|
2593 |
!
|
|
2594 |
|
|
2595 |
setMaskOriginX:orgX y:orgY in:aGCid
|
|
2596 |
"set the mask origin"
|
133
|
2597 |
|
0
|
2598 |
^ self subclassResponsibility
|
|
2599 |
!
|
|
2600 |
|
|
2601 |
setClipByChildren:aBool in:aGCId
|
|
2602 |
"enable/disable drawing into child views"
|
133
|
2603 |
|
0
|
2604 |
^ self subclassResponsibility
|
|
2605 |
!
|
|
2606 |
|
|
2607 |
noClipIn:aGCId
|
|
2608 |
"disable clipping rectangle"
|
133
|
2609 |
|
0
|
2610 |
^ self subclassResponsibility
|
|
2611 |
!
|
|
2612 |
|
|
2613 |
setClipX:clipX y:clipY width:clipWidth height:clipHeight in:aGCId
|
|
2614 |
"clip to a rectangle"
|
133
|
2615 |
|
0
|
2616 |
^ self subclassResponsibility
|
|
2617 |
!
|
|
2618 |
|
|
2619 |
setGraphicsExposures:aBoolean in:aGCId
|
|
2620 |
"set or clear the graphics exposures flag"
|
|
2621 |
|
|
2622 |
^ self subclassResponsibility
|
|
2623 |
! !
|
|
2624 |
|
|
2625 |
!DeviceWorkstation methodsFor:'retrieving pixels'!
|
|
2626 |
|
|
2627 |
getPixelX:x y:y from:aDrawableId
|
|
2628 |
"return the pixel value at x/y"
|
|
2629 |
|
|
2630 |
^ self subclassResponsibility
|
|
2631 |
! !
|
|
2632 |
|
|
2633 |
!DeviceWorkstation methodsFor:'drawing'!
|
|
2634 |
|
75
|
2635 |
displayString:aString x:x y:y in:aDrawableId with:aGCId opaque:opaque
|
38
|
2636 |
"draw a string"
|
0
|
2637 |
|
|
2638 |
^ self subclassResponsibility
|
|
2639 |
!
|
|
2640 |
|
75
|
2641 |
displayString:aString from:i1 to:i2 x:x y:y in:aDrawableId with:aGCId opaque:opaque
|
38
|
2642 |
"draw part of a string"
|
|
2643 |
|
75
|
2644 |
"
|
|
2645 |
should be redefined in concrete subclasses
|
|
2646 |
to avoid creation of throw-away string
|
|
2647 |
"
|
38
|
2648 |
self displayString:(aString copyFrom:i1 to:i2)
|
71
|
2649 |
x:x
|
|
2650 |
y:y
|
|
2651 |
in:aDrawableId
|
|
2652 |
with:aGCId
|
|
2653 |
opaque:opaque
|
38
|
2654 |
!
|
|
2655 |
|
|
2656 |
displayString:aString x:x y:y in:aDrawableId with:aGCId
|
|
2657 |
"draw a string - draw foreground only.
|
|
2658 |
If the coordinates are not integers, retry with rounded."
|
0
|
2659 |
|
75
|
2660 |
self
|
|
2661 |
displayString:aString
|
|
2662 |
x:x
|
|
2663 |
y:y
|
|
2664 |
in:aDrawableId
|
|
2665 |
with:aGCId
|
|
2666 |
opaque:false
|
38
|
2667 |
!
|
|
2668 |
|
|
2669 |
displayString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId
|
|
2670 |
"draw a sub-string - draw foreground only.
|
|
2671 |
If the coordinates are not integers, retry with rounded."
|
|
2672 |
|
75
|
2673 |
self
|
|
2674 |
displayString:aString
|
|
2675 |
from:index1
|
|
2676 |
to:index2
|
|
2677 |
x:x
|
|
2678 |
y:y
|
|
2679 |
in:aDrawableId
|
|
2680 |
with:aGCId
|
|
2681 |
opaque:false
|
0
|
2682 |
!
|
|
2683 |
|
|
2684 |
displayOpaqueString:aString x:x y:y in:aDrawableId with:aGCId
|
38
|
2685 |
"draw a string - draw foreground on background.
|
|
2686 |
If the coordinates are not integers, retry with rounded."
|
0
|
2687 |
|
38
|
2688 |
self displayString:aString
|
71
|
2689 |
x:x
|
|
2690 |
y:y
|
|
2691 |
in:aDrawableId
|
|
2692 |
with:aGCId
|
|
2693 |
opaque:true
|
0
|
2694 |
!
|
|
2695 |
|
|
2696 |
displayOpaqueString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId
|
38
|
2697 |
"draw a sub-string - draw foreground on background.
|
|
2698 |
If the coordinates are not integers, retry with rounded."
|
0
|
2699 |
|
38
|
2700 |
self displayString:aString
|
71
|
2701 |
from:index1
|
|
2702 |
to:index2
|
|
2703 |
x:x
|
|
2704 |
y:y
|
|
2705 |
in:aDrawableId
|
|
2706 |
with:aGCId
|
|
2707 |
opaque:true
|
0
|
2708 |
!
|
|
2709 |
|
23
|
2710 |
displayPointX:x y:y in:aDrawableId with:aGCId
|
0
|
2711 |
"draw a point"
|
|
2712 |
|
|
2713 |
^ self subclassResponsibility
|
|
2714 |
!
|
|
2715 |
|
|
2716 |
displayLineFromX:x0 y:y0 toX:x1 y:y1 in:aDrawableId with:aGCId
|
|
2717 |
"draw a line"
|
10
|
2718 |
|
38
|
2719 |
"could add a bresenham line drawer here ..."
|
0
|
2720 |
^ self subclassResponsibility
|
|
2721 |
!
|
|
2722 |
|
26
|
2723 |
displayRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId
|
0
|
2724 |
"draw a rectangle"
|
|
2725 |
|
75
|
2726 |
"
|
|
2727 |
should draw four lines here
|
133
|
2728 |
but then, we have to reimplement all line and join styles here
|
75
|
2729 |
"
|
0
|
2730 |
^ self subclassResponsibility
|
|
2731 |
!
|
|
2732 |
|
26
|
2733 |
displayPolygon:aPolygon in:aDrawableId with:aGCId
|
0
|
2734 |
"draw a polygon"
|
10
|
2735 |
|
75
|
2736 |
"
|
|
2737 |
should draw the lines here
|
133
|
2738 |
but then, we have to reimplement all line and join styles here
|
75
|
2739 |
"
|
0
|
2740 |
^ self subclassResponsibility
|
|
2741 |
!
|
|
2742 |
|
|
2743 |
copyFromFaxImage:sourceId x:srcX y:srcY to:destId x:dstX y:dstY
|
71
|
2744 |
width:w height:h with:aGCId scaleX:scaleX scaleY:scaleY
|
0
|
2745 |
"do a bit-blt"
|
10
|
2746 |
|
0
|
2747 |
^ self subclassResponsibility
|
|
2748 |
!
|
|
2749 |
|
|
2750 |
copyFromId:sourceId x:srcX y:srcY to:destId x:dstX y:dstY
|
71
|
2751 |
width:w height:h with:aGCId
|
0
|
2752 |
"do a bit-blt"
|
10
|
2753 |
|
0
|
2754 |
^ self subclassResponsibility
|
|
2755 |
!
|
|
2756 |
|
|
2757 |
copyPlaneFromId:sourceId x:srcX y:srcY to:destId x:dstX y:dstY
|
71
|
2758 |
width:w height:h with:aGCId
|
133
|
2759 |
"do a bit-blt, using the low-bit plane of the source only"
|
0
|
2760 |
|
|
2761 |
^ self subclassResponsibility
|
|
2762 |
!
|
|
2763 |
|
12
|
2764 |
displayArcX:x y:y w:width h:height from:startAngle angle:angle
|
71
|
2765 |
in:aDrawableId with:aGCId
|
0
|
2766 |
"draw an arc"
|
10
|
2767 |
|
0
|
2768 |
^ self subclassResponsibility
|
|
2769 |
!
|
|
2770 |
|
|
2771 |
fillArcX:x y:y w:width h:height from:startAngle angle:angle
|
71
|
2772 |
in:aDrawableId with:aGCId
|
0
|
2773 |
"fill an arc"
|
|
2774 |
|
|
2775 |
^ self subclassResponsibility
|
|
2776 |
!
|
|
2777 |
|
|
2778 |
fillRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId
|
|
2779 |
"fill a rectangle"
|
10
|
2780 |
|
0
|
2781 |
^ self subclassResponsibility
|
|
2782 |
!
|
|
2783 |
|
|
2784 |
fillPolygon:aPolygon in:aDrawableId with:aGCId
|
|
2785 |
"fill a polygon"
|
10
|
2786 |
|
0
|
2787 |
^ self subclassResponsibility
|
|
2788 |
!
|
|
2789 |
|
|
2790 |
drawBits:imageBits depth:imageDepth width:imageWidth height:imageHeight
|
71
|
2791 |
x:srcx y:srcy
|
|
2792 |
into:aDrawableId x:dstx y:dsty width:w height:h with:aGCId
|
12
|
2793 |
|
0
|
2794 |
"draw a bitimage which has depth id, width iw and height ih into
|
|
2795 |
the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty.
|
|
2796 |
It has to be checked elsewhere, that server can do it with the given
|
|
2797 |
depth; also it is assumed, that the colormap is setup correctly"
|
10
|
2798 |
|
0
|
2799 |
^ self subclassResponsibility
|
|
2800 |
! !
|