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