0
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
71
|
3 |
All Rights Reserved
|
0
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
Object subclass:#DeviceWorkstation
|
|
14 |
instanceVariableNames:'displayId
|
71
|
15 |
visualType monitorType
|
|
16 |
depth ncells bitsPerRGB
|
|
17 |
hasColors hasGreyscales
|
|
18 |
width height widthMM heightMM resolutionHor resolutionVer
|
|
19 |
idToViewMapping knownViews knownIds knownBitmaps knownBitmapIds
|
|
20 |
dispatching
|
|
21 |
controlDown shiftDown metaDown altDown
|
|
22 |
motionEventCompression
|
|
23 |
lastId lastView
|
|
24 |
keyboardMap
|
|
25 |
isSlow activeGrab
|
|
26 |
buttonTranslation multiClickTimeDelta'
|
2
|
27 |
classVariableNames: 'ButtonTranslation MultiClickTimeDelta
|
71
|
28 |
DeviceErrorSignal'
|
0
|
29 |
poolDictionaries:''
|
|
30 |
category:'Interface-Graphics'
|
|
31 |
!
|
|
32 |
|
|
33 |
DeviceWorkstation comment:'
|
46
|
34 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
71
|
35 |
All Rights Reserved
|
|
36 |
|
75
|
37 |
$Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.19 1994-10-28 03:14:34 claus Exp $
|
46
|
38 |
'!
|
0
|
39 |
|
46
|
40 |
!DeviceWorkstation class methodsFor:'documentation'!
|
|
41 |
|
|
42 |
copyright
|
|
43 |
"
|
0
|
44 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
71
|
45 |
All Rights Reserved
|
0
|
46 |
|
46
|
47 |
This software is furnished under a license and may be used
|
|
48 |
only in accordance with the terms of that license and with the
|
|
49 |
inclusion of the above copyright notice. This software may not
|
|
50 |
be provided or otherwise made available to, or used by, any
|
|
51 |
other person. No title to or ownership of the software is
|
|
52 |
hereby transferred.
|
|
53 |
"
|
|
54 |
!
|
0
|
55 |
|
46
|
56 |
version
|
|
57 |
"
|
75
|
58 |
$Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.19 1994-10-28 03:14:34 claus Exp $
|
46
|
59 |
"
|
|
60 |
!
|
0
|
61 |
|
|
62 |
documentation
|
|
63 |
"
|
38
|
64 |
this abstract class defines common protocol to all Display types.
|
0
|
65 |
|
38
|
66 |
instance variables:
|
0
|
67 |
|
38
|
68 |
displayId <Number> the device id of the display
|
|
69 |
visualType <Symbol> one of #StaticGray, #PseudoColor, ... #TrueColor
|
|
70 |
monitorType <Symbol> one of #monochrome, #color, #unknown
|
2
|
71 |
|
38
|
72 |
depth <Integer> bits per color
|
|
73 |
ncells <Integer> number of colors (i.e. colormap size; not always == 2^depth)
|
|
74 |
bitsPerRGB <Integer> number of valid bits per rgb component
|
71
|
75 |
(actual number taken in A/D converter; not all devices report the true value)
|
38
|
76 |
hasColors <Boolean> true, if display supports colors
|
|
77 |
hasGreyscales <Boolean> true, if display supports grey-scales (i.e is not b/w display)
|
|
78 |
width <Integer> number of horizontal pixels
|
|
79 |
height <Integer> number of vertical pixels
|
|
80 |
heightMM <Number> screen height in millimeter
|
|
81 |
widthMM <Number> screen width in millimeter
|
|
82 |
resolutionHor <Number> pixels per horizontal millimeter
|
|
83 |
resolutionVer <Number> pixels per vertical millimeter
|
0
|
84 |
|
46
|
85 |
idToViewMapping <Dictionary> maps view-ids to views
|
38
|
86 |
knownViews <Collection> all views known
|
|
87 |
knownIds <Collection> corresponding device-view ids
|
|
88 |
knownBitmaps <Collection> all known device bitmaps
|
|
89 |
knownBitmapIds <Collection> corresponding device-bitmap ids
|
2
|
90 |
|
38
|
91 |
dispatching <Boolean> true, if currently in dispatch loop
|
0
|
92 |
|
38
|
93 |
controlDown <Boolean> true, if control key currently pressed
|
|
94 |
shiftDown <Boolean> true, if shift key currently pressed
|
|
95 |
metaDown <Boolean> true, if meta key (cmd-key) is currently pressed
|
|
96 |
altDown <Boolean> true, if alt key is currently pressed
|
2
|
97 |
|
38
|
98 |
motionEventCompression
|
2
|
99 |
|
51
|
100 |
lastId <Number> the id of the last events view (internal)
|
|
101 |
lastView <View> the last events view (internal, for faster id->view mapping)
|
2
|
102 |
|
38
|
103 |
keyboardMap <KeyBdMap> mapping for keys
|
|
104 |
isSlow <Boolean> set/cleared from startup - used to turn off
|
71
|
105 |
things like popup-shadows etc.
|
0
|
106 |
"
|
|
107 |
! !
|
|
108 |
|
|
109 |
!DeviceWorkstation class methodsFor:'initialization'!
|
|
110 |
|
2
|
111 |
initialize
|
|
112 |
DeviceErrorSignal isNil ifTrue:[
|
71
|
113 |
DeviceErrorSignal := (Signal new) mayProceed:true.
|
|
114 |
DeviceErrorSignal notifierString:'device error'.
|
2
|
115 |
].
|
|
116 |
!
|
|
117 |
|
0
|
118 |
initializeConstants
|
|
119 |
"initialize some (soft) constants"
|
|
120 |
|
51
|
121 |
MultiClickTimeDelta := 300. "a click within 300ms is considered a double one"
|
0
|
122 |
ButtonTranslation := #(1 2 3) "identity translation"
|
|
123 |
! !
|
|
124 |
|
2
|
125 |
!DeviceWorkstation class methodsFor:'signal access'!
|
|
126 |
|
|
127 |
deviceErrorSignal
|
|
128 |
"return the signal used for device error reporting"
|
|
129 |
|
|
130 |
^ DeviceErrorSignal
|
|
131 |
! !
|
|
132 |
|
0
|
133 |
!DeviceWorkstation class methodsFor:'accessing'!
|
|
134 |
|
|
135 |
buttonTranslation:anArray
|
|
136 |
"set the button translation, #(1 2 3) is no-translation,
|
|
137 |
#(3 2 1) is ok for left-handers"
|
|
138 |
|
75
|
139 |
ButtonTranslation := anArray.
|
|
140 |
Display notNil ifTrue:[
|
|
141 |
Display buttonTranslation:anArray
|
|
142 |
].
|
0
|
143 |
! !
|
|
144 |
|
|
145 |
!DeviceWorkstation methodsFor:'initialize / release'!
|
|
146 |
|
|
147 |
initialize
|
|
148 |
"initialize the receiver for a connection to the default display"
|
|
149 |
|
|
150 |
^ self initializeFor:nil
|
|
151 |
!
|
|
152 |
|
|
153 |
initializeFor:aDisplayOrNilForAny
|
|
154 |
"initialize the receiver for a connection to a display. If the
|
|
155 |
argument is non-nil, it should specify which workstation should be
|
|
156 |
connected to (in a device specific manner). For X displays, this is
|
|
157 |
to be the display-string i.e. hostname:displayNr.
|
|
158 |
If the argument is nil, connect to the default display."
|
|
159 |
|
71
|
160 |
^ self subclassResponsibility
|
0
|
161 |
!
|
|
162 |
|
|
163 |
close
|
2
|
164 |
"close down connection to Display - usually never done"
|
|
165 |
|
0
|
166 |
^ self subclassResponsibility
|
|
167 |
!
|
|
168 |
|
|
169 |
reinitialize
|
|
170 |
"reinit after snapin"
|
|
171 |
|
46
|
172 |
|prevKnownViews prevMapping|
|
0
|
173 |
|
|
174 |
displayId := nil.
|
51
|
175 |
dispatching := false.
|
46
|
176 |
|
|
177 |
"/ prevMapping := idToViewMapping.
|
|
178 |
"/ idToViewMapping := nil.
|
|
179 |
|
0
|
180 |
prevKnownViews := knownViews.
|
|
181 |
knownViews := nil.
|
|
182 |
knownIds := nil.
|
|
183 |
|
|
184 |
self initializeFor:nil.
|
|
185 |
|
43
|
186 |
"
|
|
187 |
first, all Forms must be recreated
|
51
|
188 |
(since they may be needed for view recreation as
|
43
|
189 |
background or icons)
|
|
190 |
"
|
0
|
191 |
Form reinitializeAllOn:self.
|
|
192 |
|
46
|
193 |
"/ prevMapping notNil ifTrue:[
|
0
|
194 |
prevKnownViews notNil ifTrue:[
|
71
|
195 |
"
|
|
196 |
first round: flush all device specific stuff
|
|
197 |
"
|
51
|
198 |
"/ prevMapping keysAndValuesDo:[:anId :aView |
|
71
|
199 |
prevKnownViews do:[:aView |
|
|
200 |
aView notNil ifTrue:[
|
|
201 |
aView prepareForReinit
|
|
202 |
]
|
|
203 |
].
|
|
204 |
|
|
205 |
"
|
|
206 |
2nd round: all views should reinstall themself
|
|
207 |
on the new display
|
|
208 |
"
|
51
|
209 |
"/ prevMapping keysAndValuesDo:[:anId :aView |
|
71
|
210 |
prevKnownViews do:[:aView |
|
|
211 |
aView notNil ifTrue:[
|
|
212 |
"have to re-create the view"
|
|
213 |
aView reinitialize
|
|
214 |
]
|
|
215 |
].
|
|
216 |
"
|
|
217 |
3rd round: all views get a chance to handle
|
|
218 |
changed environment (colors, font sizes etc)
|
|
219 |
"
|
51
|
220 |
"/ prevMapping keysAndValuesDo:[:anId :aView |
|
71
|
221 |
prevKnownViews do:[:aView |
|
|
222 |
aView notNil ifTrue:[
|
|
223 |
aView reAdjustGeometry
|
|
224 |
]
|
|
225 |
]
|
0
|
226 |
].
|
8
|
227 |
dispatching := false.
|
0
|
228 |
!
|
|
229 |
|
|
230 |
initializeKeyboardMap
|
|
231 |
"keystrokes from the server are translated via the keyboard map.
|
|
232 |
Untranslated keystrokes arrive either as characters, or symbols
|
|
233 |
(which are the keySyms as symbol). The mapping table which is
|
|
234 |
setup here, is used in sendKeyPress:... later.
|
|
235 |
"
|
|
236 |
|
51
|
237 |
keyboardMap isNil ifTrue:[
|
71
|
238 |
keyboardMap := KeyboardMap new.
|
51
|
239 |
].
|
0
|
240 |
|
|
241 |
"
|
8
|
242 |
no more setup here - moved everything out into 'display.rc' file
|
2
|
243 |
"
|
0
|
244 |
! !
|
|
245 |
|
2
|
246 |
!DeviceWorkstation class methodsFor:'error handling'!
|
|
247 |
|
|
248 |
resourceIdOfLastError
|
|
249 |
"return the resource id responsible for the last error"
|
|
250 |
|
|
251 |
^ self subclassResponsibility
|
|
252 |
!
|
|
253 |
|
|
254 |
lastError
|
54
|
255 |
"return a string describing the last error"
|
2
|
256 |
|
|
257 |
^ self subclassResponsibility
|
|
258 |
!
|
|
259 |
|
|
260 |
errorInterrupt
|
|
261 |
"x-error interrupt"
|
|
262 |
|
54
|
263 |
|badId badResource msg|
|
2
|
264 |
|
|
265 |
badId := self resourceIdOfLastError.
|
|
266 |
badId ~~ 0 ifTrue:[
|
71
|
267 |
badResource := self resourceOfId:badId.
|
2
|
268 |
].
|
54
|
269 |
msg := 'Display error: ' , (self lastError).
|
|
270 |
DeviceErrorSignal isHandled ifFalse:[
|
71
|
271 |
msg printNL
|
54
|
272 |
] ifTrue:[
|
71
|
273 |
^ DeviceErrorSignal
|
|
274 |
raiseRequestWith:badResource errorString:msg
|
54
|
275 |
]
|
2
|
276 |
!
|
|
277 |
|
|
278 |
resourceOfId:id
|
|
279 |
"search thru all device stuff for a resource.
|
|
280 |
Needed for error handling"
|
|
281 |
|
|
282 |
Form allInstances do:[:f |
|
71
|
283 |
f id == id ifTrue:[^ f]
|
2
|
284 |
].
|
|
285 |
|
|
286 |
self allInstances do:[:aDisplay |
|
71
|
287 |
aDisplay allViewsDo:[:aView |
|
|
288 |
aView id == id ifTrue:[^ aView].
|
|
289 |
aView gcId == id ifTrue:[^ aView]
|
|
290 |
].
|
2
|
291 |
|
46
|
292 |
"/ |views|
|
|
293 |
"/ views := aDisplay knownViews.
|
|
294 |
"/ views notNil ifTrue:[
|
|
295 |
"/ views do:[:v |
|
|
296 |
"/ v id == id ifTrue:[^ v].
|
|
297 |
"/ v gcId == id ifTrue:[^ v]
|
|
298 |
"/ ].
|
|
299 |
"/ ].
|
2
|
300 |
].
|
|
301 |
|
|
302 |
Color allInstances do:[:c |
|
71
|
303 |
c colorId == id ifTrue:[^ c]
|
2
|
304 |
].
|
|
305 |
|
|
306 |
Font allInstances do:[:f |
|
71
|
307 |
f fontId == id ifTrue:[^ f]
|
2
|
308 |
].
|
|
309 |
^ nil
|
|
310 |
! !
|
|
311 |
|
0
|
312 |
!DeviceWorkstation methodsFor:'misc'!
|
|
313 |
|
|
314 |
metaDown
|
|
315 |
"return true, if the meta-key (alt-key on systems without meta)
|
43
|
316 |
is currently pressed.
|
|
317 |
WARNING: obsolete, may vanish. Use protocol in WindowSensor."
|
0
|
318 |
|
|
319 |
^ metaDown
|
|
320 |
!
|
|
321 |
|
|
322 |
altDown
|
43
|
323 |
"return true, if the alt-key is currently pressed.
|
|
324 |
WARNING: obsolete, may vanish. Use protocol in WindowSensor."
|
0
|
325 |
|
|
326 |
^ altDown
|
|
327 |
!
|
|
328 |
|
|
329 |
controlDown
|
43
|
330 |
"return true, if the control-key is currently pressed.
|
|
331 |
WARNING: obsolete, may vanish. Use protocol in WindowSensor."
|
0
|
332 |
|
|
333 |
^ controlDown
|
|
334 |
!
|
|
335 |
|
|
336 |
shiftDown
|
43
|
337 |
"return true, if the shift-key is currently pressed.
|
|
338 |
WARNING: obsolete, may vanish. Use protocol in WindowSensor."
|
0
|
339 |
|
|
340 |
^ shiftDown
|
|
341 |
!
|
|
342 |
|
|
343 |
unBuffered
|
|
344 |
"make all drawing be sent immediately to the display"
|
|
345 |
|
|
346 |
^ self
|
|
347 |
!
|
|
348 |
|
|
349 |
buffered
|
|
350 |
"buffer drawing - do not send it immediately to the display"
|
|
351 |
|
|
352 |
^ self
|
|
353 |
!
|
|
354 |
|
|
355 |
synchronizeOutput
|
|
356 |
"send all buffered drawing to the display"
|
|
357 |
|
|
358 |
^ self
|
|
359 |
!
|
|
360 |
|
|
361 |
compressMotionEvents:aBoolean
|
|
362 |
"turn on/off motion event compression
|
|
363 |
- compressions makes always sense except in free-hand drawing of curves"
|
|
364 |
|
|
365 |
motionEventCompression := aBoolean
|
|
366 |
!
|
|
367 |
|
|
368 |
hasColors:aBoolean
|
|
369 |
"set the hasColors flag - needed since some servers dont tell the
|
|
370 |
truth if a monochrome monitor is connected to a color server"
|
|
371 |
|
|
372 |
hasColors := aBoolean
|
|
373 |
!
|
|
374 |
|
|
375 |
hasGreyscales:aBoolean
|
|
376 |
"set the hasGreyscales flag - can be used to simulate b&w behavior"
|
|
377 |
|
|
378 |
hasGreyscales := aBoolean
|
|
379 |
!
|
|
380 |
|
|
381 |
ignoreBackingStore:aBoolean
|
|
382 |
"if the argument is true, the views backingStore setting will be ignored, and
|
|
383 |
no backing store used - this can be used on servers where backing store is
|
|
384 |
very slow (from rc-file)"
|
|
385 |
|
12
|
386 |
^ self
|
|
387 |
!
|
|
388 |
|
|
389 |
isSlow:aBoolean
|
|
390 |
"set/clear the slow flag"
|
|
391 |
|
|
392 |
isSlow := aBoolean
|
0
|
393 |
!
|
|
394 |
|
|
395 |
beep
|
|
396 |
"output an audible beep or bell"
|
|
397 |
|
|
398 |
Stdout nextPut:(Character bell)
|
|
399 |
!
|
|
400 |
|
|
401 |
setInputFocusTo:aWindowId
|
|
402 |
^ self subclassResponsibility
|
|
403 |
! !
|
|
404 |
|
|
405 |
!DeviceWorkstation methodsFor:'enumeration'!
|
|
406 |
|
|
407 |
allViewsDo:aBlock
|
|
408 |
"evaluate the argument, aBlock for all known views"
|
|
409 |
|
46
|
410 |
"/ idToViewMapping notNil ifTrue:[
|
|
411 |
"/ idToViewMapping keysAndValuesDo:[:id :aView |
|
|
412 |
"/ aView notNil ifTrue:[
|
|
413 |
"/ aBlock value:aView
|
|
414 |
"/ ]
|
51
|
415 |
"/ ]
|
|
416 |
|
|
417 |
|
0
|
418 |
knownViews notNil ifTrue:[
|
46
|
419 |
knownViews do:[:aView |
|
71
|
420 |
aView notNil ifTrue:[
|
|
421 |
aBlock value:aView
|
|
422 |
]
|
46
|
423 |
]
|
0
|
424 |
]
|
|
425 |
|
|
426 |
"
|
|
427 |
View defaultStyle:#iris.
|
|
428 |
Display allViewsDo:[:v | v initStyle. v redraw]
|
|
429 |
"
|
|
430 |
"
|
|
431 |
View defaultStyle:#next.
|
|
432 |
Display allViewsDo:[:v | v initStyle. v redraw]
|
|
433 |
"
|
|
434 |
"
|
|
435 |
View defaultStyle:#normal.
|
|
436 |
Display allViewsDo:[:v | v initStyle. v redraw]
|
|
437 |
"
|
|
438 |
! !
|
|
439 |
|
|
440 |
!DeviceWorkstation methodsFor:'accessing & queries'!
|
|
441 |
|
|
442 |
displayFileDescriptor
|
10
|
443 |
"return the file descriptor associated with the display
|
12
|
444 |
if any. If there is no underlying filedescriptor, return nil.
|
|
445 |
(used for event select/polling)"
|
10
|
446 |
|
12
|
447 |
^ nil
|
0
|
448 |
!
|
|
449 |
|
|
450 |
serverVendor
|
12
|
451 |
"return a string describing the server vendor
|
|
452 |
- returns a dummy here"
|
10
|
453 |
|
12
|
454 |
^ 'generic'
|
0
|
455 |
!
|
|
456 |
|
|
457 |
vendorRelease
|
12
|
458 |
"return a workstation release number
|
|
459 |
- returns a dummy here"
|
|
460 |
|
|
461 |
^ 0
|
0
|
462 |
!
|
|
463 |
|
|
464 |
protocolVersion
|
12
|
465 |
"return a protocol version number
|
|
466 |
- returns a dummy here"
|
|
467 |
|
|
468 |
^ 0
|
0
|
469 |
!
|
|
470 |
|
|
471 |
blackpixel
|
|
472 |
"return the colorId of black"
|
|
473 |
|
|
474 |
^ self subclassResponsibility
|
|
475 |
!
|
|
476 |
|
|
477 |
whitepixel
|
|
478 |
"return the colorId of white"
|
|
479 |
|
|
480 |
^ self subclassResponsibility
|
|
481 |
!
|
|
482 |
|
|
483 |
viewIdFromPoint:aPoint in:windowId
|
|
484 |
"given a point in rootWindow, return the viewId of the subview of windowId
|
12
|
485 |
hit by this coordinate. Return nil if no view was hit.
|
0
|
486 |
- use to find window to drop objects after a cross-view drag"
|
|
487 |
|
12
|
488 |
"returning nil here actually makes drag&drop impossible
|
71
|
489 |
- could also be reimplemented to make a search over all knownViews here.
|
|
490 |
This method has to be reimplemented in concrete display classes."
|
12
|
491 |
|
|
492 |
^ nil
|
0
|
493 |
!
|
|
494 |
|
|
495 |
translatePoint:aPoint from:windowId1 to:windowId2
|
|
496 |
"given a point in window1, return the coordinate in window2
|
|
497 |
- use to xlate points from a window to rootwindow"
|
|
498 |
|
71
|
499 |
"This method has to be reimplemented in concrete display classes."
|
0
|
500 |
^ self subclassResponsibility
|
|
501 |
!
|
|
502 |
|
71
|
503 |
viewFromPoint:aPoint
|
|
504 |
"given a point on the screen, return the ST/X view in which that
|
|
505 |
point is (this may be a subview). Return nil, if its not an st/X view
|
|
506 |
or if the point is on the background"
|
|
507 |
|
|
508 |
|view id searchId foundId|
|
|
509 |
|
|
510 |
searchId := RootView id.
|
|
511 |
[searchId notNil] whileTrue:[
|
|
512 |
id := self viewIdFromPoint:aPoint in:searchId.
|
|
513 |
foundId := searchId.
|
|
514 |
searchId := id
|
|
515 |
].
|
|
516 |
view := self viewFromId:foundId.
|
|
517 |
^ view
|
|
518 |
!
|
|
519 |
|
0
|
520 |
id
|
|
521 |
"return the displayId"
|
|
522 |
|
|
523 |
^ displayId
|
|
524 |
!
|
|
525 |
|
|
526 |
ncells
|
12
|
527 |
"return the number of usable color cells, the display has
|
|
528 |
- this is not always the 2 to the power of depth."
|
0
|
529 |
|
|
530 |
^ ncells
|
23
|
531 |
|
|
532 |
"Display ncells"
|
0
|
533 |
!
|
|
534 |
|
|
535 |
depth
|
|
536 |
"return the depth in pixels of the display"
|
|
537 |
|
|
538 |
^ depth
|
23
|
539 |
|
|
540 |
"Display depth"
|
0
|
541 |
!
|
|
542 |
|
|
543 |
bitsPerRGB
|
|
544 |
"return the number of valid bits per rgb component"
|
|
545 |
|
|
546 |
^ bitsPerRGB
|
23
|
547 |
|
|
548 |
"Display bitsPerRGB"
|
0
|
549 |
!
|
|
550 |
|
|
551 |
visualType:aSymbol
|
|
552 |
"set the visual type. The only situation, where this makes sense,
|
|
553 |
is with my plasma-display, which ignores the palette and spits out
|
12
|
554 |
grey scales, independent of LUT definitions.
|
23
|
555 |
(of which the server knows nothing).
|
|
556 |
So, this should be used from a display-specific startup file only."
|
0
|
557 |
|
|
558 |
visualType := aSymbol.
|
|
559 |
(visualType == #StaticGray or:[visualType == #GrayScale]) ifTrue:[
|
71
|
560 |
hasColors := false
|
0
|
561 |
] ifFalse:[
|
71
|
562 |
hasColors := true
|
0
|
563 |
]
|
|
564 |
!
|
|
565 |
|
|
566 |
visualType
|
|
567 |
"return a symbol representing the visual type of the display"
|
|
568 |
|
|
569 |
^ visualType
|
23
|
570 |
|
|
571 |
"Display visualType"
|
0
|
572 |
!
|
|
573 |
|
|
574 |
monitorType
|
|
575 |
"return a symbol representing the monitor type of the display.
|
|
576 |
It is usually set to #unknown, #color or #monochrome.
|
|
577 |
But it can be set to any value from the startup file, for later
|
|
578 |
testing from anywhere. For example the startup for plasma-displays
|
|
579 |
can set it to #plasma to later influence the colors used in widgets
|
|
580 |
(indirectly through the resource file)."
|
|
581 |
|
|
582 |
^ monitorType
|
23
|
583 |
|
|
584 |
"Display monitorType"
|
0
|
585 |
!
|
|
586 |
|
|
587 |
monitorType:aSymbol
|
|
588 |
"set the monitorType - see comment in DeviceWorkstation>>montorType"
|
|
589 |
|
|
590 |
monitorType := aSymbol
|
|
591 |
!
|
|
592 |
|
|
593 |
hasColors
|
|
594 |
"return true, if its a color display"
|
|
595 |
|
|
596 |
^ hasColors
|
23
|
597 |
|
|
598 |
"Display hasColors"
|
0
|
599 |
!
|
|
600 |
|
|
601 |
hasGreyscales
|
|
602 |
"return true, if this workstation supports greyscales
|
|
603 |
(also true for color displays)"
|
|
604 |
|
|
605 |
^ hasGreyscales
|
23
|
606 |
|
|
607 |
"Display hasGreyscales"
|
0
|
608 |
!
|
|
609 |
|
|
610 |
hasShape
|
|
611 |
"return true, if this workstation supports non-rectangular windows"
|
|
612 |
|
|
613 |
^ false
|
|
614 |
!
|
|
615 |
|
|
616 |
hasShm
|
|
617 |
"return true, if this workstation supports shared pixmaps"
|
|
618 |
|
|
619 |
^ false
|
|
620 |
!
|
|
621 |
|
|
622 |
hasFax
|
|
623 |
"return true, if this workstation supports decompression of fax images"
|
|
624 |
|
|
625 |
^ false
|
|
626 |
!
|
|
627 |
|
|
628 |
hasDPS
|
12
|
629 |
"return true, if this workstation supports postscript output into views"
|
0
|
630 |
|
|
631 |
^ false
|
|
632 |
!
|
|
633 |
|
12
|
634 |
isSlow
|
|
635 |
"return true, if this is a relatively slow device -
|
|
636 |
used to turn off things like popup-shadows"
|
|
637 |
|
|
638 |
^ isSlow
|
|
639 |
!
|
|
640 |
|
0
|
641 |
keyboardMap
|
|
642 |
"return the keyboard map"
|
|
643 |
|
|
644 |
^ keyboardMap
|
|
645 |
!
|
|
646 |
|
8
|
647 |
keyboardMap:aMap
|
|
648 |
"set the keyboard map"
|
|
649 |
|
|
650 |
keyboardMap := aMap
|
|
651 |
!
|
|
652 |
|
0
|
653 |
width
|
23
|
654 |
"return the width of the display (in pixels)"
|
0
|
655 |
|
|
656 |
^ width
|
23
|
657 |
|
|
658 |
"Display width"
|
0
|
659 |
!
|
|
660 |
|
|
661 |
height
|
23
|
662 |
"return the height of the display (in pixels)"
|
0
|
663 |
|
|
664 |
^ height
|
23
|
665 |
|
|
666 |
"Display height"
|
|
667 |
!
|
|
668 |
|
|
669 |
extent
|
|
670 |
"return the extent of the display (in pixels)"
|
|
671 |
|
|
672 |
^ width @ height
|
|
673 |
|
|
674 |
"Display extent"
|
0
|
675 |
!
|
|
676 |
|
|
677 |
boundingBox
|
23
|
678 |
"return a rectangle representing the displays bounding box.
|
|
679 |
For Smalltalk-80 compatibility"
|
0
|
680 |
|
|
681 |
^ Rectangle origin:(0 @ 0) extent:(width @ height)
|
|
682 |
!
|
|
683 |
|
|
684 |
widthInMillimeter
|
|
685 |
"return the width in millimeter of the display"
|
|
686 |
|
|
687 |
^ widthMM
|
23
|
688 |
|
|
689 |
"Display widthInMillimeter"
|
0
|
690 |
!
|
|
691 |
|
|
692 |
heightInMillimeter
|
|
693 |
"return the height in millimeter of the display"
|
|
694 |
|
|
695 |
^ heightMM
|
23
|
696 |
|
|
697 |
"Display heightInMillimeter"
|
0
|
698 |
!
|
|
699 |
|
|
700 |
widthInMillimeter:aNumber
|
|
701 |
"set the width in millimeter of the display
|
12
|
702 |
- needed since some displays do not tell the truth or do not know it"
|
0
|
703 |
|
|
704 |
widthMM := aNumber
|
|
705 |
!
|
|
706 |
|
|
707 |
heightInMillimeter:aNumber
|
|
708 |
"set the height in millimeter of the display
|
12
|
709 |
- needed since some displays do not tell the truth or do not know it"
|
0
|
710 |
|
|
711 |
heightMM := aNumber
|
|
712 |
!
|
|
713 |
|
|
714 |
pixelPerMillimeter
|
|
715 |
"return the number of horizontal/vertical pixels per millimeter of the display as Point"
|
|
716 |
|
|
717 |
^ (width / widthMM) @ (height / heightMM)
|
|
718 |
|
|
719 |
"Display pixelPerMillimeter"
|
|
720 |
!
|
|
721 |
|
|
722 |
pixelPerInch
|
|
723 |
"return the number of horizontal/vertical pixels per inch of the display as Point"
|
|
724 |
|
|
725 |
^ ((width / widthMM) @ (height / heightMM)) * 25.4
|
|
726 |
|
|
727 |
"Display pixelPerInch"
|
|
728 |
!
|
|
729 |
|
|
730 |
horizontalPixelPerMillimeter
|
|
731 |
"return the number of horizontal pixels per millimeter of the display"
|
|
732 |
|
|
733 |
^ width / widthMM
|
|
734 |
!
|
|
735 |
|
|
736 |
verticalPixelPerMillimeter
|
|
737 |
"return the number of vertical pixels per millimeter of the display"
|
|
738 |
|
|
739 |
^ height / heightMM
|
|
740 |
!
|
|
741 |
|
|
742 |
horizontalPixelPerInch
|
|
743 |
"return the number of horizontal pixels per inch of the display"
|
|
744 |
|
|
745 |
^ (width / widthMM) * 25.4
|
|
746 |
!
|
|
747 |
|
|
748 |
verticalPixelPerInch
|
|
749 |
"return the number of vertical pixels per inch of the display"
|
|
750 |
|
|
751 |
^ (height / heightMM) * 25.4
|
|
752 |
!
|
|
753 |
|
|
754 |
center
|
|
755 |
"return the centerpoint in pixels of the display"
|
|
756 |
|
|
757 |
^ (width // 2) @ (height // 2)
|
|
758 |
!
|
|
759 |
|
|
760 |
knownViews
|
|
761 |
"return a collection of all known views"
|
|
762 |
|
|
763 |
^ knownViews
|
|
764 |
!
|
|
765 |
|
|
766 |
knownViews:aCollection
|
|
767 |
"set the collection of all known views - take care,
|
|
768 |
bad use of this will create funny results; use only for snapshot support"
|
|
769 |
|
|
770 |
knownViews := aCollection
|
23
|
771 |
!
|
|
772 |
|
71
|
773 |
buttonTranslation
|
|
774 |
^ buttonTranslation
|
|
775 |
!
|
|
776 |
|
75
|
777 |
buttonTranslation:anArray
|
|
778 |
buttonTranslation := anArray
|
|
779 |
!
|
|
780 |
|
71
|
781 |
multiClickTimeDelta
|
|
782 |
^ multiClickTimeDelta
|
|
783 |
!
|
|
784 |
|
|
785 |
multiClickTimeDelta:milliseconds
|
|
786 |
multiClickTimeDelta := milliseconds
|
|
787 |
! !
|
|
788 |
|
|
789 |
!DeviceWorkstation methodsFor:'interactive queries'!
|
|
790 |
|
23
|
791 |
pointFromUser
|
|
792 |
"let user specify a point on the screen"
|
|
793 |
|
|
794 |
|curs p|
|
|
795 |
|
|
796 |
curs := Cursor crossHair on:self.
|
|
797 |
|
|
798 |
self ungrabPointer.
|
75
|
799 |
self grabPointerIn:(RootView id) withCursor:(curs id)
|
|
800 |
pointerMode:#async keyboardMode:#sync confineTo:nil.
|
23
|
801 |
ActiveGrab := RootView.
|
|
802 |
|
|
803 |
[self leftButtonPressed] whileFalse:[].
|
|
804 |
p := self pointerPosition.
|
|
805 |
|
|
806 |
self ungrabPointer.
|
|
807 |
ActiveGrab := nil.
|
|
808 |
|
|
809 |
"flush all events pending on myself"
|
|
810 |
self disposeEvents.
|
|
811 |
|
|
812 |
^ p
|
|
813 |
|
71
|
814 |
"
|
|
815 |
Display pointFromUser
|
|
816 |
"
|
23
|
817 |
!
|
|
818 |
|
|
819 |
rectangleFromUser
|
71
|
820 |
"let user specify a rectangle in the screen, return the rectangle"
|
|
821 |
|
|
822 |
|curs1 curs2 origin corner newCorner|
|
23
|
823 |
|
|
824 |
curs1 := Cursor origin on:self.
|
|
825 |
curs2 := Cursor corner on:self.
|
|
826 |
|
|
827 |
self ungrabPointer.
|
75
|
828 |
self grabPointerIn:(RootView id) withCursor:(curs1 id)
|
|
829 |
pointerMode:#async keyboardMode:#sync confineTo:nil.
|
23
|
830 |
ActiveGrab := RootView.
|
|
831 |
|
|
832 |
[self leftButtonPressed] whileFalse:[].
|
71
|
833 |
origin := self pointerPosition.
|
23
|
834 |
|
|
835 |
self ungrabPointer.
|
75
|
836 |
self grabPointerIn:(RootView id) withCursor:(curs1 id)
|
71
|
837 |
pointerMode:#async keyboardMode:#sync confineTo:nil.
|
23
|
838 |
|
|
839 |
|
|
840 |
RootView noClipByChildren.
|
|
841 |
|
|
842 |
RootView foreground:Color black.
|
|
843 |
RootView background:Color white.
|
|
844 |
|
|
845 |
RootView xoring:[
|
71
|
846 |
corner := origin.
|
|
847 |
RootView displayRectangle:(origin corner:corner).
|
|
848 |
[self leftButtonPressed] whileTrue:[
|
|
849 |
newCorner := self pointerPosition.
|
|
850 |
newCorner ~= corner ifTrue:[
|
|
851 |
RootView displayRectangle:(origin corner:corner).
|
|
852 |
|
|
853 |
self ungrabPointer.
|
|
854 |
self grabPointerIn:RootView id withCursor:curs2 id
|
|
855 |
pointerMode:#async keyboardMode:#sync confineTo:nil.
|
|
856 |
|
|
857 |
corner := newCorner.
|
|
858 |
RootView displayRectangle:(origin corner:corner).
|
|
859 |
self synchronizeOutput.
|
|
860 |
]
|
|
861 |
].
|
|
862 |
RootView displayRectangle:(origin corner:corner).
|
23
|
863 |
].
|
|
864 |
|
|
865 |
self ungrabPointer.
|
|
866 |
ActiveGrab := nil.
|
|
867 |
|
|
868 |
"flush all events pending on my display"
|
|
869 |
self disposeEvents.
|
|
870 |
|
|
871 |
RootView clipByChildren.
|
|
872 |
|
71
|
873 |
^ origin corner:corner
|
|
874 |
|
|
875 |
"
|
|
876 |
Display rectangleFromUser
|
|
877 |
"
|
23
|
878 |
!
|
|
879 |
|
|
880 |
viewFromUser
|
|
881 |
"let user specify a view on the screen; if the selected view is
|
|
882 |
not an st/x view, nil is returned.
|
|
883 |
(send topView to the returned view to get its root-top)"
|
|
884 |
|
71
|
885 |
^ self viewFromPoint:(self pointFromUser)
|
|
886 |
|
|
887 |
"
|
|
888 |
Display viewFromUser
|
|
889 |
"
|
|
890 |
"
|
|
891 |
|v|
|
|
892 |
v := Display viewFromUser.
|
|
893 |
v notNil ifTrue:[v topView] ifFalse:[nil]
|
|
894 |
"
|
|
895 |
!
|
|
896 |
|
|
897 |
topviewFromUser
|
|
898 |
"let user specify a view on the screen; if the selected view is
|
|
899 |
not an st/x view, nil is returned.
|
|
900 |
Otherwise, the topview is returned."
|
|
901 |
|
|
902 |
|v|
|
|
903 |
|
|
904 |
v := self viewFromUser.
|
|
905 |
v notNil ifTrue:[
|
|
906 |
v := v topView
|
23
|
907 |
].
|
71
|
908 |
^ v
|
|
909 |
|
|
910 |
"
|
|
911 |
Display topviewFromUser
|
|
912 |
"
|
0
|
913 |
! !
|
|
914 |
|
|
915 |
!DeviceWorkstation methodsFor:'keyboard mapping'!
|
|
916 |
|
12
|
917 |
sendKeyPress:untranslatedKey x:x y:y to:someone
|
|
918 |
"forward a key-press event to some handler;
|
|
919 |
the key is translated via the translation table here."
|
0
|
920 |
|
51
|
921 |
|xlatedKey|
|
0
|
922 |
|
51
|
923 |
xlatedKey := self translateKey:untranslatedKey.
|
0
|
924 |
xlatedKey notNil ifTrue:[
|
71
|
925 |
someone delegate notNil ifTrue:[
|
|
926 |
someone delegate keyPress:xlatedKey x:x y:y view:someone
|
|
927 |
] ifFalse:[
|
|
928 |
someone keyPress:xlatedKey x:x y:y
|
|
929 |
]
|
0
|
930 |
]
|
51
|
931 |
!
|
|
932 |
|
57
|
933 |
sendKeyRelease:untranslatedKey x:x y:y to:someone
|
|
934 |
"forward a key-release event to some handler;
|
|
935 |
the key is translated via the translation table here."
|
|
936 |
|
|
937 |
|xlatedKey|
|
|
938 |
|
|
939 |
xlatedKey := self translateKey:untranslatedKey.
|
|
940 |
xlatedKey notNil ifTrue:[
|
71
|
941 |
someone delegate notNil ifTrue:[
|
|
942 |
someone delegate keyRelease:xlatedKey x:x y:y view:someone
|
|
943 |
] ifFalse:[
|
|
944 |
someone keyRelease:xlatedKey x:x y:y
|
|
945 |
]
|
57
|
946 |
]
|
|
947 |
!
|
|
948 |
|
51
|
949 |
translateKey:untranslatedKey
|
|
950 |
"Return the key translated via the translation table.
|
|
951 |
|
|
952 |
First, the modifier is prepended, making character X into
|
|
953 |
AltX, CtrlX or CmdX (on most systems, no separate Cmd (or Meta)
|
|
954 |
key exists; on those we always get AltX).
|
|
955 |
Then the result is used as a key into the translation keyboardMap
|
|
956 |
to get the final return value."
|
|
957 |
|
|
958 |
|xlatedKey|
|
|
959 |
|
|
960 |
xlatedKey := untranslatedKey.
|
|
961 |
controlDown ifTrue:[
|
71
|
962 |
(xlatedKey size == 1) ifTrue:[ "a single character"
|
|
963 |
xlatedKey := ('Ctrl' , untranslatedKey asString) asSymbol
|
|
964 |
].
|
51
|
965 |
].
|
|
966 |
metaDown ifTrue:[
|
71
|
967 |
(untranslatedKey isMemberOf:Character) ifTrue:[
|
|
968 |
xlatedKey := ('Cmd' , untranslatedKey asString) asSymbol
|
|
969 |
]
|
51
|
970 |
].
|
|
971 |
altDown ifTrue:[
|
71
|
972 |
(untranslatedKey isMemberOf:Character) ifTrue:[
|
|
973 |
xlatedKey := ('Alt' , untranslatedKey asString) asSymbol
|
|
974 |
]
|
51
|
975 |
].
|
|
976 |
|
|
977 |
xlatedKey := keyboardMap valueFor:xlatedKey.
|
|
978 |
^ xlatedKey
|
0
|
979 |
! !
|
|
980 |
|
54
|
981 |
!DeviceWorkstation methodsFor:'view registration'!
|
0
|
982 |
|
|
983 |
addKnownView:aView withId:aNumber
|
54
|
984 |
"add the View aView with id:aNumber to the list of known views/id's.
|
51
|
985 |
This map is needed later (on event arrival) to get the view from
|
|
986 |
the views id (which is passed along with the devices event) quickly."
|
0
|
987 |
|
54
|
988 |
|freeIdx newArr sz newSize id|
|
46
|
989 |
|
0
|
990 |
knownViews isNil ifTrue:[
|
71
|
991 |
knownViews := WeakArray new:50. "/ OrderedCollection new:50.
|
|
992 |
knownViews addDependent:self.
|
|
993 |
knownIds := Array new:50.
|
|
994 |
freeIdx := 1.
|
54
|
995 |
] ifFalse:[
|
71
|
996 |
1 to:knownViews size do:[:idx |
|
|
997 |
(knownViews at:idx) isNil ifTrue:[
|
|
998 |
id := knownIds at:idx.
|
|
999 |
id notNil ifTrue:[
|
|
1000 |
"/ this one is to be destroyed ...
|
|
1001 |
self destroyView:nil withId:id.
|
|
1002 |
knownIds at:idx put:nil.
|
|
1003 |
].
|
|
1004 |
freeIdx := idx
|
|
1005 |
]
|
|
1006 |
].
|
0
|
1007 |
].
|
46
|
1008 |
|
54
|
1009 |
freeIdx isNil ifTrue:[
|
71
|
1010 |
sz := knownViews size.
|
|
1011 |
newSize := sz * 2.
|
|
1012 |
newArr := WeakArray new:newSize.
|
|
1013 |
newArr replaceFrom:1 to:sz with:knownViews.
|
|
1014 |
knownViews := newArr.
|
|
1015 |
knownViews addDependent:self.
|
|
1016 |
|
|
1017 |
newArr := Array new:newSize.
|
|
1018 |
newArr replaceFrom:1 to:sz with:knownIds.
|
|
1019 |
knownIds := newArr.
|
|
1020 |
freeIdx := sz + 1
|
54
|
1021 |
].
|
|
1022 |
knownViews at:freeIdx put:aView.
|
|
1023 |
knownIds at:freeIdx put:aNumber.
|
0
|
1024 |
!
|
|
1025 |
|
|
1026 |
removeKnownView:aView
|
51
|
1027 |
"remove aView from the list of known views/id's."
|
0
|
1028 |
|
54
|
1029 |
|index|
|
|
1030 |
|
|
1031 |
aView isNil ifTrue:[^ self].
|
|
1032 |
|
46
|
1033 |
"/ idToViewMapping removeValue:aView ifAbsent:[].
|
|
1034 |
"/ lastId := nil.
|
|
1035 |
"/ lastView := nil
|
|
1036 |
|
0
|
1037 |
knownViews notNil ifTrue:[
|
71
|
1038 |
index := knownViews identityIndexOf:aView.
|
|
1039 |
index == 0 ifFalse:[
|
|
1040 |
knownViews at:index put:nil.
|
|
1041 |
knownIds at:index put:nil.
|
|
1042 |
lastId := nil.
|
|
1043 |
lastView := nil
|
|
1044 |
]
|
0
|
1045 |
]
|
|
1046 |
!
|
|
1047 |
|
|
1048 |
viewFromId:aNumber
|
51
|
1049 |
"given an Id, return the corresponding view."
|
0
|
1050 |
|
|
1051 |
|index|
|
|
1052 |
|
46
|
1053 |
"/ ^ idToViewMapping at:aNumber ifAbsent:[nil].
|
|
1054 |
|
8
|
1055 |
index := knownIds identityIndexOf:aNumber.
|
|
1056 |
index == 0 ifTrue:[^ nil].
|
54
|
1057 |
^ knownViews at:index.
|
|
1058 |
!
|
|
1059 |
|
|
1060 |
update:something
|
|
1061 |
|id|
|
|
1062 |
|
|
1063 |
something == knownViews ifTrue:[
|
71
|
1064 |
"
|
|
1065 |
some view was garbage-collected;
|
|
1066 |
destroy it ...
|
|
1067 |
"
|
|
1068 |
1 to:knownViews size do:[:idx |
|
|
1069 |
(knownViews at:idx) isNil ifTrue:[
|
|
1070 |
id := knownIds at:idx.
|
|
1071 |
id notNil ifTrue:[
|
|
1072 |
"/ this one is to be destroyed ...
|
|
1073 |
self destroyView:nil withId:id.
|
|
1074 |
knownIds at:idx put:nil.
|
|
1075 |
].
|
|
1076 |
]
|
|
1077 |
].
|
54
|
1078 |
|
|
1079 |
]
|
0
|
1080 |
! !
|
|
1081 |
|
12
|
1082 |
!DeviceWorkstation methodsFor:'window stuff'!
|
|
1083 |
|
|
1084 |
setCursors:aCursor
|
|
1085 |
"change the cursor of all views to aCursorId"
|
|
1086 |
|
|
1087 |
| id |
|
|
1088 |
|
|
1089 |
id := (aCursor on:self) id.
|
|
1090 |
id notNil ifTrue:[
|
46
|
1091 |
"/ idToViewMapping notNil ifTrue:[
|
51
|
1092 |
"/ idToViewMapping keysAndValuesDo:[:viewId :view |
|
|
1093 |
"/ self setCursor:id in:viewId
|
|
1094 |
"/ ].
|
71
|
1095 |
knownViews do:[:aView |
|
|
1096 |
|vid|
|
|
1097 |
|
|
1098 |
(aView notNil and:[(vid := aView id) notNil]) ifTrue:[
|
|
1099 |
self setCursor:id in:vid
|
|
1100 |
]
|
|
1101 |
].
|
|
1102 |
self synchronizeOutput
|
46
|
1103 |
"/ ]
|
12
|
1104 |
]
|
|
1105 |
|
|
1106 |
"Display setCursors:Cursor wait"
|
|
1107 |
"Display restoreCursors"
|
|
1108 |
!
|
|
1109 |
|
|
1110 |
restoreCursors
|
|
1111 |
"restore the cursors of all views to their current cursor"
|
|
1112 |
|
46
|
1113 |
"/ idToViewMapping notNil ifTrue:[
|
51
|
1114 |
"/ idToViewMapping keysAndValuesDo:[:viewId :view |
|
|
1115 |
"/ |curs cid|
|
|
1116 |
"/ curs := view cursor.
|
|
1117 |
"/ curs notNil ifTrue:[
|
|
1118 |
"/ cid := curs id.
|
|
1119 |
"/ cid notNil ifTrue:[
|
|
1120 |
"/ self setCursor:cid in:viewId
|
|
1121 |
"/ ]
|
|
1122 |
"/ ]
|
|
1123 |
"/ ].
|
46
|
1124 |
"/ self synchronizeOutput
|
|
1125 |
"/ ]
|
|
1126 |
|
12
|
1127 |
knownViews notNil ifTrue:[
|
71
|
1128 |
knownViews do:[:aView |
|
|
1129 |
|c vid cid|
|
|
1130 |
|
|
1131 |
(aView notNil and:[(vid := aView id) notNil]) ifTrue:[
|
|
1132 |
c := aView cursor.
|
|
1133 |
(c notNil and:[(cid := c id) notNil]) ifTrue:[
|
|
1134 |
self setCursor:cid in:vid
|
|
1135 |
]
|
|
1136 |
]
|
|
1137 |
].
|
|
1138 |
self synchronizeOutput
|
12
|
1139 |
]
|
|
1140 |
|
|
1141 |
"Display setCursors:(Cursor wait)"
|
|
1142 |
"Display restoreCursors"
|
|
1143 |
! !
|
|
1144 |
|
|
1145 |
!DeviceWorkstation methodsFor:'events'!
|
|
1146 |
|
|
1147 |
startDispatch
|
|
1148 |
"create the display dispatch process"
|
|
1149 |
|
51
|
1150 |
|inputSema fd p|
|
12
|
1151 |
|
|
1152 |
dispatching ifTrue:[^ self].
|
|
1153 |
dispatching := true.
|
|
1154 |
|
|
1155 |
fd := self displayFileDescriptor.
|
|
1156 |
|
|
1157 |
ProcessorScheduler isPureEventDriven ifTrue:[
|
71
|
1158 |
"
|
|
1159 |
no threads built in;
|
|
1160 |
handle all events by having processor call a block when something
|
|
1161 |
arrives on my filedescriptor
|
|
1162 |
"
|
|
1163 |
Processor enableIOAction:[
|
|
1164 |
dispatching ifTrue:[
|
|
1165 |
[self eventPending] whileTrue:[
|
|
1166 |
self dispatchPendingEvents.
|
|
1167 |
self checkForEndOfDispatch.
|
|
1168 |
].
|
|
1169 |
dispatching ifFalse:[
|
|
1170 |
Processor disableFd:fd
|
|
1171 |
]
|
|
1172 |
]
|
|
1173 |
]
|
|
1174 |
onInput:fd
|
12
|
1175 |
|
|
1176 |
] ifFalse:[
|
71
|
1177 |
"
|
|
1178 |
handle stuff as a process - sitting on a semaphore.
|
|
1179 |
Tell Processor to trigger this semaphore when something arrives
|
|
1180 |
on my filedescriptor. Since a select alone is not enough to
|
|
1181 |
know if events are pending (Xlib reads out event-queue while
|
|
1182 |
doing output), we also have to install a poll-check block.
|
|
1183 |
"
|
|
1184 |
inputSema := Semaphore new.
|
|
1185 |
p := [
|
|
1186 |
[dispatching] whileTrue:[
|
|
1187 |
self eventPending ifFalse:[
|
75
|
1188 |
Processor activeProcess setStateTo:#ioWait if:#active.
|
71
|
1189 |
inputSema wait.
|
|
1190 |
].
|
|
1191 |
|
|
1192 |
"
|
|
1193 |
in case of an error in the dispatch (i.e. WSensor
|
|
1194 |
is broken) AND user presses abort in the debugger,
|
|
1195 |
we want to continue here.
|
|
1196 |
"
|
|
1197 |
Object abortSignal catch:[
|
|
1198 |
self dispatchPendingEvents.
|
|
1199 |
].
|
|
1200 |
self dispatchPendingEvents.
|
|
1201 |
self checkForEndOfDispatch.
|
|
1202 |
|
|
1203 |
dispatching ifFalse:[
|
|
1204 |
Processor disableSemaphore:inputSema.
|
|
1205 |
inputSema := nil
|
|
1206 |
]
|
|
1207 |
]
|
|
1208 |
] forkAt:(Processor userInterruptPriority).
|
|
1209 |
"
|
|
1210 |
give the process a nice name
|
|
1211 |
"
|
|
1212 |
p name:'event dispatcher'.
|
|
1213 |
Processor signal:inputSema onInput:fd orCheck:[self eventPending].
|
12
|
1214 |
]
|
|
1215 |
!
|
|
1216 |
|
|
1217 |
checkForEndOfDispatch
|
46
|
1218 |
"return true, if there are still any views of interrest -
|
|
1219 |
if not, stop dispatch"
|
12
|
1220 |
|
|
1221 |
self == Display ifTrue:[
|
51
|
1222 |
"/ idToViewMapping isEmpty ifTrue:[
|
71
|
1223 |
knownViews isEmpty ifTrue:[
|
|
1224 |
dispatching := false
|
|
1225 |
]
|
12
|
1226 |
]
|
|
1227 |
!
|
|
1228 |
|
|
1229 |
dispatchPendingEvents
|
38
|
1230 |
Object abortSignal catch:[
|
71
|
1231 |
[self eventPending] whileTrue:[
|
|
1232 |
self dispatchEventFor:nil withMask:nil
|
|
1233 |
]
|
12
|
1234 |
]
|
|
1235 |
!
|
|
1236 |
|
21
|
1237 |
dispatchModalWhile:aBlock
|
|
1238 |
"get and process next event for any view as long as the
|
|
1239 |
argument-block evaluates to true.
|
51
|
1240 |
This is a modal loop, not switching to other processes,
|
|
1241 |
effectively polling the device in a (nice) busy loop.
|
|
1242 |
This should only be used for emergency cases.
|
|
1243 |
(such as a graphical debugger, debugging the event-dispatcher itself)"
|
|
1244 |
|
|
1245 |
|myFd|
|
12
|
1246 |
|
51
|
1247 |
"
|
|
1248 |
if this display has a fileDescriptor to wait on,
|
|
1249 |
it is used; otherwise we poll (with a delay to not lock up
|
|
1250 |
the workstation)
|
|
1251 |
"
|
|
1252 |
myFd := self displayFileDescriptor.
|
12
|
1253 |
[aBlock value] whileTrue:[
|
71
|
1254 |
self eventPending ifFalse:[
|
|
1255 |
myFd isNil ifTrue:[
|
|
1256 |
OperatingSystem millisecondDelay:50
|
|
1257 |
] ifFalse:[
|
|
1258 |
OperatingSystem selectOn:myFd withTimeOut:50.
|
|
1259 |
].
|
|
1260 |
Processor evaluateTimeouts.
|
|
1261 |
].
|
|
1262 |
self eventPending ifTrue:[
|
|
1263 |
self dispatchEvent
|
|
1264 |
].
|
51
|
1265 |
]
|
12
|
1266 |
!
|
|
1267 |
|
|
1268 |
dispatchEvent
|
|
1269 |
"get and process next event for any view"
|
|
1270 |
|
|
1271 |
self dispatchEventFor:nil withMask:nil
|
23
|
1272 |
!
|
|
1273 |
|
|
1274 |
eventMaskFor:anEventSymbol
|
|
1275 |
^ self subclassResponsibility
|
|
1276 |
!
|
|
1277 |
|
|
1278 |
setEventMask:aMask in:aWindowId
|
|
1279 |
^ self subclassResponsibility
|
|
1280 |
!
|
|
1281 |
|
|
1282 |
dispatchEventFor:aViewIdOrNil withMask:eventMask
|
|
1283 |
"central event handling method:
|
|
1284 |
get next event and send appropriate message to the view or the sensor,
|
|
1285 |
if the view has one.
|
|
1286 |
If the argument aViewIdOrNil is nil, events for any view are processed,
|
|
1287 |
otherwise only events for the view with given id are processed
|
|
1288 |
(in this case, nothing is done if no events are pending);
|
|
1289 |
if the argument aMask is nonNil, only events for this eventMask are
|
|
1290 |
handled;"
|
|
1291 |
|
|
1292 |
^ self subclassResponsibility
|
|
1293 |
!
|
|
1294 |
|
|
1295 |
disposeEventsWithMask:aMask for:aWindowId
|
|
1296 |
"dispose (throw away) specific events"
|
|
1297 |
|
|
1298 |
^ self subclassResponsibility
|
|
1299 |
!
|
|
1300 |
|
|
1301 |
disposeEvents
|
|
1302 |
"flush all events pending on this display"
|
|
1303 |
|
|
1304 |
[self eventPending] whileTrue:[
|
71
|
1305 |
self getEventFor:nil withMask:nil
|
23
|
1306 |
].
|
|
1307 |
!
|
|
1308 |
|
|
1309 |
eventPending
|
|
1310 |
"return true, if any event is pending"
|
|
1311 |
|
|
1312 |
^ self subclassResponsibility
|
|
1313 |
!
|
|
1314 |
|
|
1315 |
eventPendingWithoutSync
|
|
1316 |
"return true, if any event is pending"
|
|
1317 |
|
|
1318 |
^ self subclassResponsibility
|
|
1319 |
!
|
|
1320 |
|
|
1321 |
eventsPending:anEventMask for:aWindowId
|
|
1322 |
"return true, if any of the masked events is pending"
|
|
1323 |
|
|
1324 |
^ self subclassResponsibility
|
|
1325 |
!
|
|
1326 |
|
|
1327 |
eventPending:anEventSymbol for:aWindowId
|
|
1328 |
"return true, if a specific event is pending"
|
|
1329 |
|
|
1330 |
^ self subclassResponsibility
|
12
|
1331 |
! !
|
|
1332 |
|
|
1333 |
!DeviceWorkstation methodsFor:'bitmap/window creation'!
|
|
1334 |
|
|
1335 |
createFaxImageFromArray:data width:w height:h type:type k:k msbFirst:msbFirst
|
51
|
1336 |
"create a new faxImage in the workstation.
|
|
1337 |
This is a special interface to servers with the fax-image
|
|
1338 |
extension (you won't find it in standard X-servers).
|
|
1339 |
|
12
|
1340 |
type: 0 -> uncompressed
|
71
|
1341 |
1 -> group3 1D (k is void)
|
|
1342 |
2 -> group3 2D
|
|
1343 |
3 -> group4 2D (k is void)
|
51
|
1344 |
"
|
12
|
1345 |
|
|
1346 |
^ nil
|
|
1347 |
!
|
|
1348 |
|
|
1349 |
createBitmapWidth:w height:h
|
|
1350 |
"allocate a bitmap on the Xserver, the contents is undefined
|
|
1351 |
(i.e. random). Return a bitmap id or nil"
|
|
1352 |
|
|
1353 |
^ self subclassResponsibility
|
|
1354 |
!
|
|
1355 |
|
|
1356 |
createPixmapWidth:w height:h depth:d
|
|
1357 |
"allocate a pixmap on the Xserver, the contents is undefined
|
|
1358 |
(i.e. random). Return a bitmap id or nil"
|
|
1359 |
|
|
1360 |
^ self subclassResponsibility
|
|
1361 |
!
|
|
1362 |
|
|
1363 |
createBitmapFromFile:aString for:aForm
|
|
1364 |
^ self subclassResponsibility
|
|
1365 |
!
|
|
1366 |
|
|
1367 |
createBitmapFromArray:anArray width:w height:h
|
|
1368 |
^ self subclassResponsibility
|
|
1369 |
!
|
|
1370 |
|
|
1371 |
destroyPixmap:aDrawableId
|
|
1372 |
^ self subclassResponsibility
|
|
1373 |
!
|
|
1374 |
|
|
1375 |
destroyFaxImage:aFaxImageId
|
|
1376 |
^ self subclassResponsibility
|
|
1377 |
!
|
|
1378 |
|
|
1379 |
rootWindowFor:aView
|
|
1380 |
^ self subclassResponsibility
|
|
1381 |
!
|
|
1382 |
|
|
1383 |
createWindowFor:aView left:xpos top:ypos width:wwidth height:wheight
|
|
1384 |
^ self subclassResponsibility
|
|
1385 |
!
|
|
1386 |
|
|
1387 |
destroyView:aView withId:aWindowId
|
|
1388 |
^ self subclassResponsibility
|
|
1389 |
!
|
|
1390 |
|
|
1391 |
destroyGC:aGCId
|
|
1392 |
"destroy a GC"
|
|
1393 |
|
|
1394 |
^ self subclassResponsibility
|
|
1395 |
!
|
|
1396 |
|
|
1397 |
gcFor:aDrawableId
|
|
1398 |
"create a GC for drawing into aDrawable"
|
|
1399 |
|
|
1400 |
^ self subclassResponsibility
|
|
1401 |
! !
|
|
1402 |
|
0
|
1403 |
!DeviceWorkstation methodsFor:'font stuff'!
|
|
1404 |
|
12
|
1405 |
listOfAvailableFonts
|
|
1406 |
"return a list containing all fonts on this display.
|
|
1407 |
The returned list is an array of 4-element arrays, each
|
|
1408 |
containing family, face, style, size and encoding."
|
|
1409 |
|
|
1410 |
self subclassResponsibility
|
|
1411 |
!
|
|
1412 |
|
0
|
1413 |
fontFamilies
|
|
1414 |
"return a set of all available font families on this display"
|
|
1415 |
|
|
1416 |
|allFonts families family|
|
|
1417 |
|
|
1418 |
allFonts := self listOfAvailableFonts.
|
|
1419 |
allFonts isNil ifTrue:[^ nil].
|
|
1420 |
families := Set new.
|
51
|
1421 |
allFonts do:[:fntDescr |
|
|
1422 |
"/ old:
|
|
1423 |
"/ family := fntDescr at:1.
|
|
1424 |
"/ new:
|
71
|
1425 |
family := fntDescr family.
|
|
1426 |
family notNil ifTrue:[
|
|
1427 |
families add:family
|
|
1428 |
]
|
0
|
1429 |
].
|
|
1430 |
^ families
|
|
1431 |
|
51
|
1432 |
"
|
|
1433 |
Display fontFamilies
|
|
1434 |
"
|
0
|
1435 |
!
|
|
1436 |
|
|
1437 |
facesInFamily:aFamilyName
|
|
1438 |
"return a set of all available font faces in aFamily on this display"
|
|
1439 |
|
75
|
1440 |
|allFonts faces "family face"|
|
0
|
1441 |
|
|
1442 |
allFonts := self listOfAvailableFonts.
|
|
1443 |
allFonts isNil ifTrue:[^ nil].
|
51
|
1444 |
|
0
|
1445 |
faces := Set new.
|
51
|
1446 |
allFonts do:[:fntDescr |
|
|
1447 |
"/ old:
|
|
1448 |
"/ family := fntDescr at:1.
|
|
1449 |
"/ (family = aFamilyName) ifTrue:[
|
|
1450 |
"/ face := fntDescr at:2.
|
|
1451 |
"/ faces add:face
|
|
1452 |
"/ ]
|
|
1453 |
"/ new:
|
75
|
1454 |
aFamilyName = fntDescr family ifTrue:[
|
71
|
1455 |
faces add:(fntDescr face)
|
|
1456 |
]
|
0
|
1457 |
].
|
|
1458 |
^ faces
|
|
1459 |
|
51
|
1460 |
"
|
|
1461 |
Display facesInFamily:'times'
|
|
1462 |
Display facesInFamily:'fixed'
|
|
1463 |
"
|
0
|
1464 |
!
|
|
1465 |
|
|
1466 |
stylesInFamily:aFamilyName face:aFaceName
|
|
1467 |
"return a set of all available font styles in aFamily/aFace on this display"
|
|
1468 |
|
75
|
1469 |
|allFonts styles "family face style"|
|
0
|
1470 |
|
|
1471 |
allFonts := self listOfAvailableFonts.
|
|
1472 |
allFonts isNil ifTrue:[^ nil].
|
51
|
1473 |
|
0
|
1474 |
styles := Set new.
|
51
|
1475 |
allFonts do:[:fntDescr |
|
|
1476 |
"/ old:
|
|
1477 |
"/ family := fntDescr at:1.
|
|
1478 |
"/ (family = aFamilyName) ifTrue:[
|
|
1479 |
"/ face := fntDescr at:2.
|
|
1480 |
"/ (face = aFaceName) ifTrue:[
|
|
1481 |
"/ style := fntDescr at:3.
|
|
1482 |
"/ styles add:style
|
|
1483 |
"/ ]
|
|
1484 |
"/ ]
|
75
|
1485 |
(aFamilyName = fntDescr family) ifTrue:[
|
|
1486 |
(aFaceName = fntDescr face) ifTrue:[
|
71
|
1487 |
styles add:fntDescr style
|
|
1488 |
]
|
|
1489 |
]
|
0
|
1490 |
].
|
|
1491 |
^ styles
|
|
1492 |
|
51
|
1493 |
"
|
|
1494 |
Display stylesInFamily:'times' face:'medium'
|
|
1495 |
Display stylesInFamily:'times' face:'bold'
|
|
1496 |
"
|
0
|
1497 |
!
|
|
1498 |
|
|
1499 |
sizesInFamily:aFamilyName face:aFaceName style:aStyleName
|
|
1500 |
"return a set of all available font sizes in aFamily/aFace/aStyle
|
|
1501 |
on this display"
|
|
1502 |
|
75
|
1503 |
|allFonts sizes "family face style size"|
|
0
|
1504 |
|
|
1505 |
allFonts := self listOfAvailableFonts.
|
|
1506 |
allFonts isNil ifTrue:[^ nil].
|
51
|
1507 |
|
0
|
1508 |
sizes := Set new.
|
51
|
1509 |
allFonts do:[:fntDescr |
|
|
1510 |
"/ family := fntDescr at:1.
|
|
1511 |
"/ (family = aFamilyName) ifTrue:[
|
|
1512 |
"/ face := fntDescr at:2.
|
|
1513 |
"/ (face = aFaceName) ifTrue:[
|
|
1514 |
"/ style := fntDescr at:3.
|
|
1515 |
"/ (style = aStyleName) ifTrue:[
|
|
1516 |
"/ size := fntDescr at:4.
|
|
1517 |
"/ sizes add:size
|
|
1518 |
"/ ]
|
|
1519 |
"/ ]
|
|
1520 |
"/ ]
|
75
|
1521 |
(aFamilyName = fntDescr family) ifTrue:[
|
|
1522 |
(aFaceName = fntDescr face) ifTrue:[
|
|
1523 |
(aStyleName = fntDescr style) ifTrue:[
|
71
|
1524 |
sizes add:fntDescr size
|
|
1525 |
]
|
|
1526 |
]
|
|
1527 |
]
|
0
|
1528 |
].
|
|
1529 |
^ sizes
|
|
1530 |
|
51
|
1531 |
"
|
|
1532 |
Display sizesInFamily:'times' face:'medium' style:'italic'
|
|
1533 |
"
|
8
|
1534 |
!
|
|
1535 |
|
12
|
1536 |
getFontWithFamily:familyString
|
71
|
1537 |
face:faceString
|
|
1538 |
style:styleString
|
|
1539 |
size:sizeArg
|
|
1540 |
encoding:encodingSym
|
0
|
1541 |
|
12
|
1542 |
"try to get the specified font, return id.
|
|
1543 |
If not available, try next smaller font.
|
|
1544 |
If no font fits, return nil"
|
0
|
1545 |
|
|
1546 |
^ self subclassResponsibility
|
|
1547 |
!
|
|
1548 |
|
|
1549 |
getDefaultFont
|
12
|
1550 |
"return a default font id
|
|
1551 |
- used when class Font cannot find anything usable"
|
0
|
1552 |
|
|
1553 |
^ self subclassResponsibility
|
|
1554 |
!
|
|
1555 |
|
|
1556 |
releaseFont:aFontId
|
12
|
1557 |
"free a font"
|
|
1558 |
|
0
|
1559 |
^ self subclassResponsibility
|
|
1560 |
!
|
|
1561 |
|
|
1562 |
ascentOf:aFontId
|
12
|
1563 |
"return the number of pixels above the base line of a font"
|
|
1564 |
|
0
|
1565 |
^ self subclassResponsibility
|
|
1566 |
!
|
|
1567 |
|
|
1568 |
descentOf:aFontId
|
12
|
1569 |
"return the number of pixels below the base line of a font"
|
|
1570 |
|
0
|
1571 |
^ self subclassResponsibility
|
|
1572 |
!
|
|
1573 |
|
|
1574 |
minWidthOfFont:aFontId
|
12
|
1575 |
"return the width in pixels of the smallest character a specific font"
|
|
1576 |
|
0
|
1577 |
^ self subclassResponsibility
|
|
1578 |
!
|
|
1579 |
|
|
1580 |
maxWidthOfFont:aFontId
|
12
|
1581 |
"return the width in pixels of the widest character a specific font"
|
|
1582 |
|
0
|
1583 |
^ self subclassResponsibility
|
|
1584 |
!
|
|
1585 |
|
|
1586 |
widthOf:aString inFont:aFontId
|
12
|
1587 |
"return the width in pixels of a string in a specific font"
|
|
1588 |
|
0
|
1589 |
^ self subclassResponsibility
|
|
1590 |
!
|
|
1591 |
|
|
1592 |
widthOf:aString from:index1 to:index2 inFont:aFontId
|
12
|
1593 |
"return the width in pixels of a substring in a specific font"
|
|
1594 |
|
0
|
1595 |
^ self subclassResponsibility
|
|
1596 |
! !
|
|
1597 |
|
|
1598 |
!DeviceWorkstation methodsFor:'cursor stuff'!
|
|
1599 |
|
|
1600 |
destroyCursor:aCursorId
|
12
|
1601 |
"free a cursor"
|
|
1602 |
|
0
|
1603 |
^ self subclassResponsibility
|
|
1604 |
!
|
|
1605 |
|
|
1606 |
createCursorSourceForm:sourceForm maskForm:maskForm hotX:hx hotY:hy
|
|
1607 |
"create a cursor given 2 bitmaps (source, mask) and a hotspot"
|
|
1608 |
^ self subclassResponsibility
|
|
1609 |
!
|
|
1610 |
|
|
1611 |
createCursorShape:aShape
|
|
1612 |
"create a cursor given a shape-symbol"
|
|
1613 |
|
|
1614 |
^ self subclassResponsibility
|
|
1615 |
!
|
|
1616 |
|
|
1617 |
colorCursor:aCursorId foreground:fgColor background:bgColor
|
|
1618 |
"change a cursors colors"
|
|
1619 |
|
|
1620 |
^ self subclassResponsibility
|
|
1621 |
!
|
|
1622 |
|
|
1623 |
grabKeyboardIn:aWindowId
|
|
1624 |
"grab the keyboard - all keyboard input will be sent to aWindow"
|
|
1625 |
|
|
1626 |
^ self subclassResponsibility
|
|
1627 |
!
|
|
1628 |
|
|
1629 |
ungrabKeyboard
|
|
1630 |
"release the keyboard"
|
10
|
1631 |
|
0
|
1632 |
^ self subclassResponsibility
|
|
1633 |
!
|
|
1634 |
|
75
|
1635 |
grabPointerIn:aWindowId withCursor:cursorId pointerMode:pMode keyboardMode:kMode confineTo:confineId
|
|
1636 |
"grap the pointer - all pointer events will be reported to aWindowId. The cursor will be set to cursorId
|
|
1637 |
for the duration of the grab. For pMode/kMode, see X documentation. The pointer is restricted to
|
|
1638 |
confineId - if non-nil."
|
10
|
1639 |
|
0
|
1640 |
^ self subclassResponsibility
|
|
1641 |
!
|
|
1642 |
|
75
|
1643 |
grabPointerIn:aWindowId
|
|
1644 |
"grap the pointer - return true if ok"
|
|
1645 |
|
|
1646 |
^ self grabPointerIn:aWindowId withCursor:nil pointerMode:#async keyboardMode:#sync confineTo:nil
|
|
1647 |
!
|
|
1648 |
|
0
|
1649 |
ungrabPointer
|
|
1650 |
"release the pointer"
|
10
|
1651 |
|
0
|
1652 |
^ self subclassResponsibility
|
|
1653 |
! !
|
|
1654 |
|
|
1655 |
!DeviceWorkstation methodsFor:'color stuff'!
|
|
1656 |
|
|
1657 |
listOfAvailableColors
|
|
1658 |
"return a list of all available colornames;
|
|
1659 |
This method should not be used, since colornames are
|
12
|
1660 |
very X specific. However, the names defined here are pretty common"
|
0
|
1661 |
|
|
1662 |
^ #('red' 'green' 'blue' 'yellow' 'magenta' 'cyan' 'white' 'black')
|
|
1663 |
!
|
|
1664 |
|
|
1665 |
freeColor:colorIndex
|
|
1666 |
"free a color on the display, when its no longer needed"
|
|
1667 |
|
|
1668 |
^ self subclassResponsibility
|
|
1669 |
!
|
|
1670 |
|
|
1671 |
colorRed:redVal green:greenVal blue:blueVal
|
|
1672 |
"allocate a color with rgb values (0..100) - return index"
|
|
1673 |
|
|
1674 |
^ self subclassResponsibility
|
|
1675 |
!
|
|
1676 |
|
|
1677 |
colorNamed:aString
|
|
1678 |
"allocate a color with color name - return index.
|
|
1679 |
Colors should not be allocated by name, since most colors
|
|
1680 |
are X specific - get colors by rgb instead."
|
|
1681 |
|
|
1682 |
"support some of them ..."
|
|
1683 |
|
|
1684 |
self getRGBFromName:aString into:[:r :g :b |
|
71
|
1685 |
^ self colorRed:r green:g blue:b
|
0
|
1686 |
].
|
|
1687 |
^ nil
|
|
1688 |
!
|
|
1689 |
|
|
1690 |
colorCell
|
|
1691 |
"allocate a color - return index"
|
|
1692 |
|
|
1693 |
^ self subclassResponsibility
|
|
1694 |
!
|
|
1695 |
|
|
1696 |
setColor:index red:redVal green:greenVal blue:blueVal
|
|
1697 |
"change color in map at:index to rgb (0..100)"
|
|
1698 |
|
|
1699 |
^ self subclassResponsibility
|
|
1700 |
!
|
|
1701 |
|
|
1702 |
getRGBFromName:colorName into:aBlock
|
|
1703 |
"get rgb components (0..100) of color named colorName,
|
|
1704 |
and evaluate the 3-arg block, aBlock with them.
|
|
1705 |
The method here only handles some often used colors;
|
|
1706 |
getRGBFromName should not be used, since colorNames other
|
|
1707 |
than those below are X specific."
|
|
1708 |
|
|
1709 |
|idx names triple|
|
|
1710 |
|
|
1711 |
names := #('red' 'green' 'blue' 'yellow' 'magenta' 'cyan' 'white' 'black').
|
8
|
1712 |
idx := names indexOf:colorName.
|
0
|
1713 |
idx == 0 ifTrue:[
|
71
|
1714 |
idx := (names asLowercase) indexOf:colorName.
|
0
|
1715 |
].
|
|
1716 |
idx == 0 ifFalse:[
|
71
|
1717 |
triple := #(
|
|
1718 |
(100 0 0) "red"
|
|
1719 |
( 0 100 0) "green"
|
|
1720 |
( 0 0 100) "blue"
|
|
1721 |
(100 100 0) "yellow"
|
|
1722 |
(100 0 100) "magenta"
|
|
1723 |
( 0 100 100) "cyan"
|
|
1724 |
(100 100 100) "white"
|
|
1725 |
( 0 0 0) "black"
|
|
1726 |
) at:idx.
|
0
|
1727 |
|
71
|
1728 |
^ aBlock value:(triple at:1)
|
|
1729 |
value:(triple at:2)
|
|
1730 |
value:(triple at:3)
|
0
|
1731 |
].
|
|
1732 |
^ nil
|
|
1733 |
!
|
|
1734 |
|
|
1735 |
getRGBFrom:index into:aBlock
|
|
1736 |
"get rgb components (0..100) of color in map at:index,
|
|
1737 |
and evaluate the 3-arg block, aBlock with them"
|
|
1738 |
|
|
1739 |
^ self subclassResponsibility
|
|
1740 |
! !
|
|
1741 |
|
|
1742 |
!DeviceWorkstation methodsFor:'window stuff'!
|
|
1743 |
|
|
1744 |
setBackingStore:how in:aWindowId
|
|
1745 |
"turn on/off backing-store for a window"
|
10
|
1746 |
|
0
|
1747 |
^ self subclassResponsibility
|
|
1748 |
!
|
|
1749 |
|
|
1750 |
setSaveUnder:yesOrNo in:aWindowId
|
|
1751 |
"turn on/off save-under for a window"
|
10
|
1752 |
|
0
|
1753 |
^ self subclassResponsibility
|
|
1754 |
!
|
|
1755 |
|
|
1756 |
setWindowBackground:aColorIndex in:aWindowId
|
10
|
1757 |
"set a windows background color"
|
0
|
1758 |
|
|
1759 |
^ self subclassResponsibility
|
|
1760 |
!
|
|
1761 |
|
|
1762 |
setWindowBackgroundPixmap:aPixmapId in:aWindowId
|
10
|
1763 |
"set a windows background pattern to be a form"
|
|
1764 |
|
0
|
1765 |
^ self subclassResponsibility
|
|
1766 |
!
|
|
1767 |
|
|
1768 |
setWindowBorderColor:aColorIndex in:aWindowId
|
10
|
1769 |
"set a windows border color"
|
|
1770 |
|
0
|
1771 |
^ self subclassResponsibility
|
|
1772 |
!
|
|
1773 |
|
|
1774 |
setWindowBorderPixmap:aPixmapId in:aWindowId
|
10
|
1775 |
"set a windows border pattern"
|
|
1776 |
|
0
|
1777 |
^ self subclassResponsibility
|
|
1778 |
!
|
|
1779 |
|
|
1780 |
setWindowBorderWidth:aNumber in:aWindowId
|
10
|
1781 |
"set a windows border width"
|
|
1782 |
|
0
|
1783 |
^ self subclassResponsibility
|
|
1784 |
!
|
|
1785 |
|
|
1786 |
setWindowBorderShape:aPixmapId in:aWindowId
|
10
|
1787 |
"set a windows border shape"
|
|
1788 |
|
0
|
1789 |
^ self subclassResponsibility
|
|
1790 |
!
|
|
1791 |
|
|
1792 |
setWindowShape:aPixmapId in:aWindowId
|
10
|
1793 |
"set a windows visible shape"
|
|
1794 |
|
0
|
1795 |
^ self subclassResponsibility
|
|
1796 |
!
|
|
1797 |
|
|
1798 |
setCursor:aCursorId in:aWindowId
|
10
|
1799 |
"set a windows visible shape"
|
|
1800 |
|
0
|
1801 |
^ self subclassResponsibility
|
|
1802 |
!
|
|
1803 |
|
|
1804 |
setWindowName:aString in:aWindowId
|
10
|
1805 |
"set a windows name"
|
|
1806 |
|
0
|
1807 |
^ self subclassResponsibility
|
|
1808 |
!
|
|
1809 |
|
|
1810 |
setIconName:aString in:aWindowId
|
10
|
1811 |
"set a windows icon name"
|
|
1812 |
|
0
|
1813 |
^ self subclassResponsibility
|
|
1814 |
!
|
|
1815 |
|
|
1816 |
setWindowIcon:aForm in:aWindowId
|
10
|
1817 |
"set a windows icon"
|
|
1818 |
|
0
|
1819 |
^ self subclassResponsibility
|
|
1820 |
!
|
|
1821 |
|
|
1822 |
setWindowIconWindow:aView in:aWindowId
|
10
|
1823 |
"set a windows icon window"
|
|
1824 |
|
0
|
1825 |
^ self subclassResponsibility
|
|
1826 |
!
|
|
1827 |
|
|
1828 |
clearWindow:aWindowId
|
10
|
1829 |
"clear a windows to its view background"
|
|
1830 |
|
0
|
1831 |
^ self subclassResponsibility
|
|
1832 |
!
|
|
1833 |
|
|
1834 |
clearRectangleX:x y:y width:width height:height in:aWindowId
|
10
|
1835 |
"clear a rectangular area of a window to its view background"
|
|
1836 |
|
0
|
1837 |
^ self subclassResponsibility
|
|
1838 |
!
|
|
1839 |
|
23
|
1840 |
mapView:aView id:aWindowId iconified:aBoolean atX:xPos y:yPos width:w height:h
|
0
|
1841 |
^ self subclassResponsibility
|
|
1842 |
!
|
|
1843 |
|
|
1844 |
mapWindow:aWindowId
|
|
1845 |
^ self subclassResponsibility
|
|
1846 |
!
|
|
1847 |
|
|
1848 |
unmapWindow:aWindowId
|
|
1849 |
^ self subclassResponsibility
|
|
1850 |
!
|
|
1851 |
|
|
1852 |
raiseWindow:aWindowId
|
|
1853 |
^ self subclassResponsibility
|
|
1854 |
!
|
|
1855 |
|
|
1856 |
lowerWindow:aWindowId
|
|
1857 |
^ self subclassResponsibility
|
|
1858 |
!
|
|
1859 |
|
|
1860 |
moveWindow:aWindowId x:x y:y
|
|
1861 |
^ self subclassResponsibility
|
|
1862 |
!
|
|
1863 |
|
|
1864 |
resizeWindow:aWindowId width:w height:h
|
|
1865 |
^ self subclassResponsibility
|
|
1866 |
!
|
|
1867 |
|
|
1868 |
moveResizeWindow:aWindowId x:x y:y width:w height:h
|
|
1869 |
^ self subclassResponsibility
|
|
1870 |
! !
|
|
1871 |
|
|
1872 |
!DeviceWorkstation methodsFor:'graphic context stuff'!
|
|
1873 |
|
|
1874 |
setForeground:fgColorIndex in:aGCId
|
|
1875 |
"set foreground color to be drawn with"
|
|
1876 |
^ self subclassResponsibility
|
|
1877 |
!
|
|
1878 |
|
|
1879 |
setBackground:bgColorIndex in:aGCId
|
|
1880 |
"set background color to be drawn with"
|
|
1881 |
^ self subclassResponsibility
|
|
1882 |
!
|
|
1883 |
|
|
1884 |
setForeground:fgColorIndex background:bgColorIndex in:aGCId
|
|
1885 |
"set foreground and background colors to be drawn with"
|
|
1886 |
^ self subclassResponsibility
|
|
1887 |
!
|
|
1888 |
|
|
1889 |
setForeground:fgColor background:bgColor mask:aBitmapId in:aGCId
|
|
1890 |
"set foreground and background colors to be drawn with using mask or
|
|
1891 |
solid (if aBitmapId is nil)"
|
|
1892 |
^ self subclassResponsibility
|
|
1893 |
!
|
|
1894 |
|
|
1895 |
setLineWidth:aNumber style:lineStyle cap:capStyle join:joinStyle in:aGCId
|
|
1896 |
"set line attributes"
|
|
1897 |
^ self subclassResponsibility
|
|
1898 |
!
|
|
1899 |
|
|
1900 |
setForeground:fgColor background:bgColor mask:aBitmapId lineWidth:lw in:aGCId
|
|
1901 |
"set foreground and background colors to be drawn with using mask or
|
|
1902 |
solid (if aBitmapId is nil); also set lineWidth"
|
|
1903 |
^ self subclassResponsibility
|
|
1904 |
!
|
|
1905 |
|
|
1906 |
setFunction:aFunctionSymbol in:aGCId
|
|
1907 |
"set alu function to be drawn with"
|
|
1908 |
^ self subclassResponsibility
|
|
1909 |
!
|
|
1910 |
|
|
1911 |
setFont:aFontId in:aGCId
|
|
1912 |
"set font to be drawn in"
|
|
1913 |
^ self subclassResponsibility
|
|
1914 |
!
|
|
1915 |
|
|
1916 |
setPixmapMask:aPixmapId in:aGCId
|
|
1917 |
"set or clear the drawing mask - a pixmap mask providing full color"
|
|
1918 |
|
|
1919 |
^ self subclassResponsibility
|
|
1920 |
!
|
|
1921 |
|
|
1922 |
setBitmapMask:aBitmapId in:aGCId
|
|
1923 |
"set or clear the drawing mask - a bitmap mask using current fg/bg"
|
|
1924 |
^ self subclassResponsibility
|
|
1925 |
!
|
|
1926 |
|
|
1927 |
setMaskOriginX:orgX y:orgY in:aGCid
|
|
1928 |
"set the mask origin"
|
|
1929 |
^ self subclassResponsibility
|
|
1930 |
!
|
|
1931 |
|
|
1932 |
setClipByChildren:aBool in:aGCId
|
|
1933 |
"enable/disable drawing into child views"
|
|
1934 |
^ self subclassResponsibility
|
|
1935 |
!
|
|
1936 |
|
|
1937 |
noClipIn:aGCId
|
|
1938 |
"disable clipping rectangle"
|
|
1939 |
^ self subclassResponsibility
|
|
1940 |
!
|
|
1941 |
|
|
1942 |
setClipX:clipX y:clipY width:clipWidth height:clipHeight in:aGCId
|
|
1943 |
"clip to a rectangle"
|
|
1944 |
^ self subclassResponsibility
|
|
1945 |
!
|
|
1946 |
|
|
1947 |
setGraphicsExposures:aBoolean in:aGCId
|
|
1948 |
"set or clear the graphics exposures flag"
|
|
1949 |
|
|
1950 |
^ self subclassResponsibility
|
|
1951 |
! !
|
|
1952 |
|
|
1953 |
!DeviceWorkstation methodsFor:'retrieving pixels'!
|
|
1954 |
|
|
1955 |
getPixelX:x y:y from:aDrawableId
|
|
1956 |
"return the pixel value at x/y"
|
|
1957 |
|
|
1958 |
^ self subclassResponsibility
|
|
1959 |
! !
|
|
1960 |
|
|
1961 |
!DeviceWorkstation methodsFor:'drawing'!
|
|
1962 |
|
75
|
1963 |
displayString:aString x:x y:y in:aDrawableId with:aGCId opaque:opaque
|
38
|
1964 |
"draw a string"
|
0
|
1965 |
|
|
1966 |
^ self subclassResponsibility
|
|
1967 |
!
|
|
1968 |
|
75
|
1969 |
displayString:aString from:i1 to:i2 x:x y:y in:aDrawableId with:aGCId opaque:opaque
|
38
|
1970 |
"draw part of a string"
|
|
1971 |
|
75
|
1972 |
"
|
|
1973 |
should be redefined in concrete subclasses
|
|
1974 |
to avoid creation of throw-away string
|
|
1975 |
"
|
38
|
1976 |
self displayString:(aString copyFrom:i1 to:i2)
|
71
|
1977 |
x:x
|
|
1978 |
y:y
|
|
1979 |
in:aDrawableId
|
|
1980 |
with:aGCId
|
|
1981 |
opaque:opaque
|
38
|
1982 |
!
|
|
1983 |
|
|
1984 |
displayString:aString x:x y:y in:aDrawableId with:aGCId
|
|
1985 |
"draw a string - draw foreground only.
|
|
1986 |
If the coordinates are not integers, retry with rounded."
|
0
|
1987 |
|
75
|
1988 |
self
|
|
1989 |
displayString:aString
|
|
1990 |
x:x
|
|
1991 |
y:y
|
|
1992 |
in:aDrawableId
|
|
1993 |
with:aGCId
|
|
1994 |
opaque:false
|
38
|
1995 |
!
|
|
1996 |
|
|
1997 |
displayString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId
|
|
1998 |
"draw a sub-string - draw foreground only.
|
|
1999 |
If the coordinates are not integers, retry with rounded."
|
|
2000 |
|
75
|
2001 |
self
|
|
2002 |
displayString:aString
|
|
2003 |
from:index1
|
|
2004 |
to:index2
|
|
2005 |
x:x
|
|
2006 |
y:y
|
|
2007 |
in:aDrawableId
|
|
2008 |
with:aGCId
|
|
2009 |
opaque:false
|
0
|
2010 |
!
|
|
2011 |
|
|
2012 |
displayOpaqueString:aString x:x y:y in:aDrawableId with:aGCId
|
38
|
2013 |
"draw a string - draw foreground on background.
|
|
2014 |
If the coordinates are not integers, retry with rounded."
|
0
|
2015 |
|
38
|
2016 |
self displayString:aString
|
71
|
2017 |
x:x
|
|
2018 |
y:y
|
|
2019 |
in:aDrawableId
|
|
2020 |
with:aGCId
|
|
2021 |
opaque:true
|
0
|
2022 |
!
|
|
2023 |
|
|
2024 |
displayOpaqueString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId
|
38
|
2025 |
"draw a sub-string - draw foreground on background.
|
|
2026 |
If the coordinates are not integers, retry with rounded."
|
0
|
2027 |
|
38
|
2028 |
self displayString:aString
|
71
|
2029 |
from:index1
|
|
2030 |
to:index2
|
|
2031 |
x:x
|
|
2032 |
y:y
|
|
2033 |
in:aDrawableId
|
|
2034 |
with:aGCId
|
|
2035 |
opaque:true
|
0
|
2036 |
!
|
|
2037 |
|
23
|
2038 |
displayPointX:x y:y in:aDrawableId with:aGCId
|
0
|
2039 |
"draw a point"
|
|
2040 |
|
|
2041 |
^ self subclassResponsibility
|
|
2042 |
!
|
|
2043 |
|
|
2044 |
displayLineFromX:x0 y:y0 toX:x1 y:y1 in:aDrawableId with:aGCId
|
|
2045 |
"draw a line"
|
10
|
2046 |
|
38
|
2047 |
"could add a bresenham line drawer here ..."
|
0
|
2048 |
^ self subclassResponsibility
|
|
2049 |
!
|
|
2050 |
|
26
|
2051 |
displayRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId
|
0
|
2052 |
"draw a rectangle"
|
|
2053 |
|
75
|
2054 |
"
|
|
2055 |
should draw four lines here
|
|
2056 |
but then, we have to reimplement all line styles here
|
|
2057 |
"
|
0
|
2058 |
^ self subclassResponsibility
|
|
2059 |
!
|
|
2060 |
|
26
|
2061 |
displayPolygon:aPolygon in:aDrawableId with:aGCId
|
0
|
2062 |
"draw a polygon"
|
10
|
2063 |
|
75
|
2064 |
"
|
|
2065 |
should draw the lines here
|
|
2066 |
but then, we have to reimplement all line styles here
|
|
2067 |
"
|
0
|
2068 |
^ self subclassResponsibility
|
|
2069 |
!
|
|
2070 |
|
|
2071 |
copyFromFaxImage:sourceId x:srcX y:srcY to:destId x:dstX y:dstY
|
71
|
2072 |
width:w height:h with:aGCId scaleX:scaleX scaleY:scaleY
|
0
|
2073 |
"do a bit-blt"
|
10
|
2074 |
|
0
|
2075 |
^ self subclassResponsibility
|
|
2076 |
!
|
|
2077 |
|
|
2078 |
copyFromId:sourceId x:srcX y:srcY to:destId x:dstX y:dstY
|
71
|
2079 |
width:w height:h with:aGCId
|
0
|
2080 |
"do a bit-blt"
|
10
|
2081 |
|
0
|
2082 |
^ self subclassResponsibility
|
|
2083 |
!
|
|
2084 |
|
|
2085 |
copyPlaneFromId:sourceId x:srcX y:srcY to:destId x:dstX y:dstY
|
71
|
2086 |
width:w height:h with:aGCId
|
0
|
2087 |
"do a bit-blt"
|
|
2088 |
|
|
2089 |
^ self subclassResponsibility
|
|
2090 |
!
|
|
2091 |
|
12
|
2092 |
displayArcX:x y:y w:width h:height from:startAngle angle:angle
|
71
|
2093 |
in:aDrawableId with:aGCId
|
0
|
2094 |
"draw an arc"
|
10
|
2095 |
|
0
|
2096 |
^ self subclassResponsibility
|
|
2097 |
!
|
|
2098 |
|
|
2099 |
fillArcX:x y:y w:width h:height from:startAngle angle:angle
|
71
|
2100 |
in:aDrawableId with:aGCId
|
0
|
2101 |
"fill an arc"
|
|
2102 |
|
|
2103 |
^ self subclassResponsibility
|
|
2104 |
!
|
|
2105 |
|
|
2106 |
fillRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId
|
|
2107 |
"fill a rectangle"
|
10
|
2108 |
|
0
|
2109 |
^ self subclassResponsibility
|
|
2110 |
!
|
|
2111 |
|
|
2112 |
fillPolygon:aPolygon in:aDrawableId with:aGCId
|
|
2113 |
"fill a polygon"
|
10
|
2114 |
|
0
|
2115 |
^ self subclassResponsibility
|
|
2116 |
!
|
|
2117 |
|
|
2118 |
drawBits:imageBits depth:imageDepth width:imageWidth height:imageHeight
|
71
|
2119 |
x:srcx y:srcy
|
|
2120 |
into:aDrawableId x:dstx y:dsty width:w height:h with:aGCId
|
12
|
2121 |
|
0
|
2122 |
"draw a bitimage which has depth id, width iw and height ih into
|
|
2123 |
the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty.
|
|
2124 |
It has to be checked elsewhere, that server can do it with the given
|
|
2125 |
depth; also it is assumed, that the colormap is setup correctly"
|
10
|
2126 |
|
0
|
2127 |
^ self subclassResponsibility
|
|
2128 |
! !
|