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