22 altModifiers metaModifiers ctrlModifiers shiftModifiers |
22 altModifiers metaModifiers ctrlModifiers shiftModifiers |
23 supportsDeepIcons preferredIconSize ditherColors fixColors |
23 supportsDeepIcons preferredIconSize ditherColors fixColors |
24 numFixRed numFixGreen numFixBlue copyBuffer lastCopyBuffer |
24 numFixRed numFixGreen numFixBlue copyBuffer lastCopyBuffer |
25 blackColor whiteColor' |
25 blackColor whiteColor' |
26 classVariableNames:'ButtonTranslation MultiClickTimeDelta DeviceErrorSignal |
26 classVariableNames:'ButtonTranslation MultiClickTimeDelta DeviceErrorSignal |
27 ErrorPrinting DefaultScreen AllScreens ExitOnLastClose |
27 DeviceIOErrorSignal ErrorPrinting DefaultScreen AllScreens ExitOnLastClose |
28 CurrentScreenQuerySignal LastActiveScreen LastActiveProcess' |
28 CurrentScreenQuerySignal LastActiveScreen LastActiveProcess' |
29 poolDictionaries:'' |
29 poolDictionaries:'' |
30 category:'Interface-Graphics' |
30 category:'Interface-Graphics' |
31 ! |
31 ! |
32 |
32 |
33 !DeviceWorkstation class methodsFor:'documentation'! |
33 !DeviceWorkstation class methodsFor:'documentation'! |
34 |
34 |
35 copyright |
35 copyright |
36 " |
36 " |
37 COPYRIGHT (c) 1993 by Claus Gittinger |
37 COPYRIGHT (c) 1993 by Claus Gittinger |
38 All Rights Reserved |
38 All Rights Reserved |
39 |
39 |
40 This software is furnished under a license and may be used |
40 This software is furnished under a license and may be used |
41 only in accordance with the terms of that license and with the |
41 only in accordance with the terms of that license and with the |
42 inclusion of the above copyright notice. This software may not |
42 inclusion of the above copyright notice. This software may not |
43 be provided or otherwise made available to, or used by, any |
43 be provided or otherwise made available to, or used by, any |
64 monitorType <Symbol> one of #monochrome, #color, #unknown |
64 monitorType <Symbol> one of #monochrome, #color, #unknown |
65 |
65 |
66 depth <SmallInteger> bits per color |
66 depth <SmallInteger> bits per color |
67 ncells <SmallInteger> number of colors (i.e. colormap size; not always == 2^depth) |
67 ncells <SmallInteger> number of colors (i.e. colormap size; not always == 2^depth) |
68 bitsPerRGB <SmallInteger> number of valid bits per rgb component |
68 bitsPerRGB <SmallInteger> number of valid bits per rgb component |
69 (actual number taken in A/D converter; not all devices report the true value) |
69 (actual number taken in A/D converter; not all devices report the true value) |
70 bitsRed <SmallInteger> number of red bits (only valid for TrueColor displays) |
70 bitsRed <SmallInteger> number of red bits (only valid for TrueColor displays) |
71 bitsGreen <SmallInteger> number of green bits (only valid for TrueColor displays) |
71 bitsGreen <SmallInteger> number of green bits (only valid for TrueColor displays) |
72 bitsBlue <SmallInteger> number of blue bits (only valid for TrueColor displays) |
72 bitsBlue <SmallInteger> number of blue bits (only valid for TrueColor displays) |
73 redMask <SmallInteger> shifted red mask (only useful for TrueColor displays) |
73 redMask <SmallInteger> shifted red mask (only useful for TrueColor displays) |
74 greenMask <SmallInteger> shifted green mask (only useful for TrueColor displays) |
74 greenMask <SmallInteger> shifted green mask (only useful for TrueColor displays) |
98 shiftDown <Boolean> true, if shift key currently pressed |
98 shiftDown <Boolean> true, if shift key currently pressed |
99 metaDown <Boolean> true, if meta key (cmd-key) is currently pressed |
99 metaDown <Boolean> true, if meta key (cmd-key) is currently pressed |
100 altDown <Boolean> true, if alt key is currently pressed |
100 altDown <Boolean> true, if alt key is currently pressed |
101 |
101 |
102 motionEventCompression |
102 motionEventCompression |
103 <Boolean> if true motion events are compressed |
103 <Boolean> if true motion events are compressed |
104 (obsolete: now done in sensor) |
104 (obsolete: now done in sensor) |
105 |
105 |
106 lastId <Number> the id of the last events view (internal) |
106 lastId <Number> the id of the last events view (internal) |
107 lastView <View> the last events view (internal, for faster id->view mapping) |
107 lastView <View> the last events view (internal, for faster id->view mapping) |
108 |
108 |
109 keyboardMap <KeyBdMap> mapping for keys |
109 keyboardMap <KeyBdMap> mapping for keys |
110 rootView <DisplayRootView> this displays root window |
110 rootView <DisplayRootView> this displays root window |
111 isSlow <Boolean> set/cleared from startup - used to turn off |
111 isSlow <Boolean> set/cleared from startup - used to turn off |
112 things like popup-shadows etc. |
112 things like popup-shadows etc. |
113 |
113 |
114 [class variables:] |
114 [class variables:] |
115 |
115 |
116 MultiClickTimeDelta in ms; controls how long of a delay is |
116 MultiClickTimeDelta in ms; controls how long of a delay is |
117 required between two clicks, to NOT take |
117 required between two clicks, to NOT take |
118 it as a multi-click. |
118 it as a multi-click. |
119 |
119 |
120 ErrorPrinting controls low-level (X-) error message printing |
120 ErrorPrinting controls low-level (X-) error message printing |
121 |
121 |
122 AllScreens a collectin of known screens |
122 AllScreens a collectin of known screens |
123 |
123 |
124 ExitOnLastClose if true, the dispatch process terminates when the |
124 ExitOnLastClose if true, the dispatch process terminates when the |
125 last view is closed. (for stand alone apps) |
125 last view is closed. (for stand alone apps) |
126 Should be set to false, if a standAlone app |
126 Should be set to false, if a standAlone app |
127 closes all views and still needs an event dispatcher |
127 closes all views and still needs an event dispatcher |
128 later (i.e. is temporary view-less) |
128 later (i.e. is temporary view-less) |
129 |
129 |
130 [see also:] |
130 [see also:] |
131 GraphicsContext DeviceDrawable |
131 GraphicsContext DeviceDrawable |
132 WindowSensor WindowGroup WindowEvent |
132 WindowSensor WindowGroup WindowEvent |
133 ProcessorScheduler |
133 ProcessorScheduler |
134 PSMedium |
134 PSMedium |
135 |
135 |
136 [author:] |
136 [author:] |
137 Claus Gittinger |
137 Claus Gittinger |
138 " |
138 " |
139 ! |
139 ! |
140 |
140 |
141 events |
141 events |
142 " |
142 " |
155 and CTRL-C handling to be performed even while other processes are running. |
155 and CTRL-C handling to be performed even while other processes are running. |
156 The code executed by the event process is found in startDispatch. |
156 The code executed by the event process is found in startDispatch. |
157 |
157 |
158 Individual events can be enabled or disabled. The ones that are enabled |
158 Individual events can be enabled or disabled. The ones that are enabled |
159 by default are: |
159 by default are: |
160 keypress / keyRelease |
160 keypress / keyRelease |
161 buttonPress / buttonRelease / buttonMotion (i.e. motion with button pressed) |
161 buttonPress / buttonRelease / buttonMotion (i.e. motion with button pressed) |
162 pointerEnter / pointerLeave |
162 pointerEnter / pointerLeave |
163 |
163 |
164 other events have to be enabled by sending a corresponding #enableXXXEvent |
164 other events have to be enabled by sending a corresponding #enableXXXEvent |
165 message to the view which shall receive those events. |
165 message to the view which shall receive those events. |
166 For example, pointerMotion events (i.e. motion without button being pressed) |
166 For example, pointerMotion events (i.e. motion without button being pressed) |
167 are enabled by: 'aView enableMotionEvent' |
167 are enabled by: 'aView enableMotionEvent' |
182 this is the default graphics display, on which new views are created |
182 this is the default graphics display, on which new views are created |
183 (however, provisions exist for multi-display operation) |
183 (however, provisions exist for multi-display operation) |
184 |
184 |
185 Currently, there is are only two concrete display classes (released to the public): |
185 Currently, there is are only two concrete display classes (released to the public): |
186 |
186 |
187 XWorkstation - a plain X window interface |
187 XWorkstation - a plain X window interface |
188 |
188 |
189 GLXWorkstation - an X window interface with a GL(tm) (3D graphic library) |
189 GLXWorkstation - an X window interface with a GL(tm) (3D graphic library) |
190 extension; either simulated (VGL) or a real GL |
190 extension; either simulated (VGL) or a real GL |
191 (real GL is only available on SGI machines) |
191 (real GL is only available on SGI machines) |
192 |
192 |
193 the following are coming soon: |
193 the following are coming soon: |
194 |
194 |
195 OpenGLWorkstation |
195 OpenGLWorkstation |
196 - an X window interface with a openGL(tm) (3D graphic library) |
196 - an X window interface with a openGL(tm) (3D graphic library) |
197 extension; either simulated (MESA) or a real openGL |
197 extension; either simulated (MESA) or a real openGL |
198 (real openGL is only available on SGI/NT machines) |
198 (real openGL is only available on SGI/NT machines) |
199 |
199 |
200 WinWorkstation - what will that be ? |
200 WinWorkstation - what will that be ? |
201 |
201 |
202 An experimental version for a NeXTStep interface exists, but is currently |
202 An experimental version for a NeXTStep interface exists, but is currently |
203 no longer maintained and not released. |
203 no longer maintained and not released. |
204 Also, interfaces for other graphic systems (i.e. OS/2) are |
204 Also, interfaces for other graphic systems (i.e. OS/2) are |
205 planned for and will be available (hopefully) in late 96. |
205 planned for and will be available (hopefully) in late 96. |
217 This does not work with other devices (i.e. Windows). |
217 This does not work with other devices (i.e. Windows). |
218 |
218 |
219 If you want to experiment with multi-display applications, |
219 If you want to experiment with multi-display applications, |
220 you have to: |
220 you have to: |
221 |
221 |
222 - create a new instance of XWorkstation: |
222 - create a new instance of XWorkstation: |
223 |
223 |
224 Smalltalk at:#Display2 put:(XWorkstation new). |
224 Smalltalk at:#Display2 put:(XWorkstation new). |
225 or: |
225 or: |
226 Smalltalk at:#Display2 put:(GLXWorkstation new). |
226 Smalltalk at:#Display2 put:(GLXWorkstation new). |
227 |
227 |
228 |
228 |
229 - have it connect to the display (i.e. the xServer): |
229 - have it connect to the display (i.e. the xServer): |
230 (replace 'localhost' below with the name of your display) |
230 (replace 'localhost' below with the name of your display) |
231 |
231 |
232 Display2 := Display2 initializeFor:'localhost:0.0' |
232 Display2 := Display2 initializeFor:'localhost:0.0' |
233 |
233 |
234 returns nil, if connection is refused |
234 returns nil, if connection is refused |
235 - leaving you with Display2==nil in this case. |
235 - leaving you with Display2==nil in this case. |
236 |
236 |
237 |
237 |
238 - start an event dispatcher process for it: |
238 - start an event dispatcher process for it: |
239 (this is now no longer needed - the first opened view will do it for you) |
239 (this is now no longer needed - the first opened view will do it for you) |
240 |
240 |
241 Display2 startDispatch |
241 Display2 startDispatch |
242 |
242 |
243 |
243 |
244 - optionally set its keyboard map |
244 - optionally set its keyboard map |
245 (since this is usually done for Display in the startup-file, |
245 (since this is usually done for Display in the startup-file, |
246 the new display does not have all your added key bindings) |
246 the new display does not have all your added key bindings) |
247 |
247 |
248 Display2 keyboardMap:(Display keyboardMap) |
248 Display2 keyboardMap:(Display keyboardMap) |
249 |
249 |
250 |
250 |
251 - create a view for it: |
251 - create a view for it: |
252 |
252 |
253 (FileBrowser onDevice:Display2) open |
253 (FileBrowser onDevice:Display2) open |
254 |
254 |
255 (Workspace onDevice:Display2) open |
255 (Workspace onDevice:Display2) open |
256 |
256 |
257 (Launcher onDevice:Display2) open |
257 (Launcher onDevice:Display2) open |
258 does not work with Launcher, since its an ApplicationModel (not a view) |
258 does not work with Launcher, since its an ApplicationModel (not a view) |
259 use: |
259 use: |
260 Launcher openOnDevice:Display2 |
260 Launcher openOnDevice:Display2 |
261 instead. |
261 instead. |
262 |
262 |
263 However, as mentioned above, there may be a few places, where the default |
263 However, as mentioned above, there may be a few places, where the default |
264 display 'Display' is still hard-coded - especially, in contributed and |
264 display 'Display' is still hard-coded - especially, in contributed and |
265 Public domain code, you may find those. |
265 Public domain code, you may find those. |
266 |
266 |
291 |
291 |
292 initialize |
292 initialize |
293 "create local error signals; enable errorPrinting" |
293 "create local error signals; enable errorPrinting" |
294 |
294 |
295 DeviceErrorSignal isNil ifTrue:[ |
295 DeviceErrorSignal isNil ifTrue:[ |
296 DeviceErrorSignal := (Signal new) mayProceed:true. |
296 DeviceErrorSignal := (Signal new) mayProceed:true. |
297 DeviceErrorSignal notifierString:'device error'. |
297 DeviceErrorSignal notifierString:'device error'. |
298 |
298 |
299 CurrentScreenQuerySignal := QuerySignal new. |
299 DeviceIOErrorSignal := (Signal new) mayProceed:false. |
300 CurrentScreenQuerySignal nameClass:self message:#currentScreenQuerySignal. |
300 DeviceIOErrorSignal notifierString:'device IO error'. |
301 CurrentScreenQuerySignal notifierString:'asking for current screen'. |
301 |
|
302 CurrentScreenQuerySignal := QuerySignal new. |
|
303 CurrentScreenQuerySignal nameClass:self message:#currentScreenQuerySignal. |
|
304 CurrentScreenQuerySignal notifierString:'asking for current screen'. |
302 ]. |
305 ]. |
303 ErrorPrinting := true. |
306 ErrorPrinting := true. |
304 ExitOnLastClose := false. |
307 ExitOnLastClose := false. |
305 |
308 |
306 self initializeConstants. |
309 self initializeConstants. |
325 |
328 |
326 "Created: 15.2.1997 / 15:07:20 / cg" |
329 "Created: 15.2.1997 / 15:07:20 / cg" |
327 ! |
330 ! |
328 |
331 |
329 deviceErrorSignal |
332 deviceErrorSignal |
330 "return the signal used for device error reporting" |
333 "return the signal used for device error reporting. |
|
334 In multi-display configurations, this is the parent of |
|
335 all per-instance deviceErrorSignals." |
331 |
336 |
332 ^ DeviceErrorSignal |
337 ^ DeviceErrorSignal |
|
338 ! |
|
339 |
|
340 deviceIOErrorSignal |
|
341 "return the signal used for device I/O error reporting. |
|
342 In multi-display configurations, this is the parent of |
|
343 all per-instance deviceIOErrorSignals." |
|
344 |
|
345 ^ DeviceIOErrorSignal |
|
346 ! ! |
|
347 |
|
348 !DeviceWorkstation methodsFor:'Signal constants'! |
|
349 |
|
350 deviceErrorSignal |
|
351 "return the per-device signal, which is used for error reporting. |
|
352 The default here is the global DeviceErrorSignal (which is the |
|
353 parent of the per-instance signals)." |
|
354 |
|
355 ^ self class deviceErrorSignal |
|
356 ! |
|
357 |
|
358 deviceIOErrorSignal |
|
359 "return the signal used for device I/O error reporting. |
|
360 The default here is the global DeviceIOErrorSignal (which is the |
|
361 parent of the per-instance signals)." |
|
362 |
|
363 ^ self class deviceIOErrorSignal |
333 ! ! |
364 ! ! |
334 |
365 |
335 !DeviceWorkstation class methodsFor:'accessing'! |
366 !DeviceWorkstation class methodsFor:'accessing'! |
336 |
367 |
337 buttonTranslation:anArray |
368 buttonTranslation:anArray |
338 "set the button translation, #(1 2 3) is no-translation, |
369 "set the button translation, #(1 2 3) is no-translation, |
339 #(3 2 1) is ok for left-handers" |
370 #(3 2 1) is ok for left-handers" |
340 |
371 |
341 ButtonTranslation := anArray. |
372 ButtonTranslation := anArray. |
342 Display notNil ifTrue:[ |
373 Display notNil ifTrue:[ |
343 Display buttonTranslation:anArray |
374 Display buttonTranslation:anArray |
344 ]. |
375 ]. |
345 ! ! |
376 ! ! |
346 |
377 |
347 !DeviceWorkstation class methodsFor:'error handling'! |
378 !DeviceWorkstation class methodsFor:'error handling'! |
348 |
379 |
349 errorInterrupt:errID with:aParameter |
380 errorInterrupt:errID with:aParameter |
350 "{ Pragma: +optSpace }" |
381 "{ Pragma: +optSpace }" |
351 |
382 |
352 "an error in the devices low level code (typically Xlib or XtLib) |
383 "an error in the devices low level code (typically Xlib or XtLib) |
353 This is invoked via |
384 This is invoked via |
354 XError->errorInterrupt:#DisplayError->registeredErrorInterruptHandlers |
385 XError->errorInterrupt:#DisplayError->registeredErrorInterruptHandlers |
|
386 or |
|
387 XError->errorInterrupt:#DisplayIOError->registeredErrorInterruptHandlers |
355 |
388 |
356 looks if a signal handler for DeviceErrorSignal is present, |
389 looks if a signal handler for DeviceErrorSignal is present, |
357 and - if so raises the signal. If the signal not handled, simply output a |
390 and - if so raises the signal. |
358 message and continue. |
391 If the signal not handled, simply output a message and continue. |
359 This allows for non disrupted error reporting OR to catch and |
392 This allows for non disrupted error reporting OR to catch and |
360 investigate errors as required." |
393 investigate errors as required. |
361 |
394 However, io-errors are always delivered as a signal raise." |
362 |badId badResource msg| |
395 |
363 |
396 |badId badResource msg theDevice theSignal p| |
364 badId := self resourceIdOfLastError. |
397 |
365 badId ~~ 0 ifTrue:[ |
398 errID notNil ifTrue:[ |
366 badResource := self resourceOfId:badId. |
399 AllScreens do:[:aDisplayDevice | |
367 ]. |
400 aDisplayDevice id = aParameter ifTrue:[ |
368 msg := 'Display error: ' , (self lastErrorString). |
401 theDevice := aDisplayDevice. |
369 |
402 ] |
370 DeviceErrorSignal isHandled ifFalse:[ |
403 ] |
371 ErrorPrinting ifTrue:[ |
404 ]. |
372 ('DeviceWorkstation [error]: ' , msg) errorPrintCR |
405 |
373 ]. |
406 "/ now, we have the bad guy at hand ... |
374 ^ self |
407 "/ get a per-instance signal. |
375 ]. |
408 |
376 |
409 theDevice isNil ifTrue:[ |
377 ^ DeviceErrorSignal |
410 errID == #DisplayIOError ifTrue:[ |
378 raiseRequestWith:badResource |
411 theSignal := self deviceIOErrorSignal. |
379 errorString:msg |
412 ] ifFalse:[ |
380 |
413 theSignal := self deviceErrorSignal |
381 "Modified: 10.1.1997 / 17:48:06 / cg" |
414 ] |
|
415 ] ifFalse:[ |
|
416 errID == #DisplayIOError ifTrue:[ |
|
417 theSignal := theDevice deviceIOErrorSignal. |
|
418 ] ifFalse:[ |
|
419 theSignal := theDevice deviceErrorSignal |
|
420 ] |
|
421 ]. |
|
422 |
|
423 errID == #DisplayIOError ifTrue:[ |
|
424 "/ always raises an exception |
|
425 msg := 'Display I/O Error'. |
|
426 badResource := theDevice. |
|
427 ] ifFalse:[ |
|
428 "/ only raises an exception if handled |
|
429 |
|
430 "/ that will become instance-specific information in |
|
431 "/ the near future ... |
|
432 |
|
433 badId := self resourceIdOfLastError. |
|
434 badId ~~ 0 ifTrue:[ |
|
435 badResource := self resourceOfId:badId. |
|
436 ]. |
|
437 msg := 'Display error: ' , (self lastErrorString). |
|
438 |
|
439 theSignal isHandled ifFalse:[ |
|
440 ErrorPrinting ifTrue:[ |
|
441 ('DeviceWorkstation [error]: ' , msg) errorPrintCR |
|
442 ]. |
|
443 ^ self |
|
444 ] |
|
445 ]. |
|
446 |
|
447 "/ interrupt that dispatcher |
|
448 theDevice notNil ifTrue:[ |
|
449 p := theDevice dispatchProcess. |
|
450 p ~~ Processor activeProcess ifTrue:[ |
|
451 'interrupting: ' print. p displayString printCR. |
|
452 p interruptWith:[ |
|
453 theDevice brokenConnection. |
|
454 |
|
455 theSignal |
|
456 raiseRequestWith:badResource |
|
457 errorString:msg. |
|
458 p terminateWithAllSubprocesses. |
|
459 p terminateNoSignal. "/ just in case |
|
460 ]. |
|
461 Processor reschedule. |
|
462 AbortSignal raise. |
|
463 ]. |
|
464 ]. |
|
465 |
|
466 theDevice brokenConnection. |
|
467 theSignal |
|
468 raiseRequestWith:badResource |
|
469 errorString:msg. |
|
470 |
|
471 AbortSignal raise. |
|
472 |
|
473 "Modified: 11.4.1997 / 11:28:27 / cg" |
382 ! |
474 ! |
383 |
475 |
384 errorPrinting |
476 errorPrinting |
385 "return the `errorPrinting-is-on' flag" |
477 "return the `errorPrinting-is-on' flag" |
386 |
478 |
477 "/ |
569 "/ |
478 "/ if there is only one screen, |
570 "/ if there is only one screen, |
479 "/ take that ... it ought to be display |
571 "/ take that ... it ought to be display |
480 "/ |
572 "/ |
481 AllScreens size <= 1 ifTrue:[ |
573 AllScreens size <= 1 ifTrue:[ |
482 ^ Display |
574 ^ Display |
483 ]. |
575 ]. |
484 |
576 |
485 "/ |
577 "/ |
486 "/ someone willing to tell me ? |
578 "/ someone willing to tell me ? |
487 "/ |
579 "/ |
488 (dev := CurrentScreenQuerySignal raise) notNil ifTrue:[ |
580 (dev := CurrentScreenQuerySignal raise) notNil ifTrue:[ |
489 ^ dev |
581 ^ dev |
490 ]. |
582 ]. |
491 |
583 |
492 thisProcess := Processor activeProcess. |
584 thisProcess := Processor activeProcess. |
493 LastActiveScreen notNil ifTrue:[ |
585 LastActiveScreen notNil ifTrue:[ |
494 LastActiveProcess == thisProcess ifTrue:[ |
586 LastActiveProcess == thisProcess ifTrue:[ |
495 ^ LastActiveScreen |
587 ^ LastActiveScreen |
496 ] |
588 ] |
497 ]. |
589 ]. |
498 |
590 |
499 "/ |
591 "/ |
500 "/ mhmh - multiple screens are active; |
592 "/ mhmh - multiple screens are active; |
501 "/ look for the active windowGroups screen. |
593 "/ look for the active windowGroups screen. |
502 "/ Be careful, to not run into an error in case |
594 "/ Be careful, to not run into an error in case |
503 "/ the current windowGroup got corrupted somehow ... |
595 "/ the current windowGroup got corrupted somehow ... |
504 |
596 |
505 (wg := WindowGroup activeGroup) notNil ifTrue:[ |
597 (wg := WindowGroup activeGroup) notNil ifTrue:[ |
506 "/ |
598 "/ |
507 "/ ok, not a background process or scheduler ... |
599 "/ ok, not a background process or scheduler ... |
508 "/ |
600 "/ |
509 (dev := wg graphicsDevice) notNil ifTrue:[ |
601 (dev := wg graphicsDevice) notNil ifTrue:[ |
510 LastActiveScreen := dev. |
602 LastActiveScreen := dev. |
511 LastActiveProcess := thisProcess. |
603 LastActiveProcess := thisProcess. |
512 ^ dev |
604 ^ dev |
513 ]. |
605 ]. |
514 ]. |
606 ]. |
515 |
607 |
516 "/ |
608 "/ |
517 "/ in all other cases, return the default display |
609 "/ in all other cases, return the default display |
518 "/ |
610 "/ |
599 |
691 |
600 zoom:startRect to:endRect duration:milliseconds |
692 zoom:startRect to:endRect duration:milliseconds |
601 "animate a rubber-rectangle from startRect to endRect. |
693 "animate a rubber-rectangle from startRect to endRect. |
602 Can be used by buttons, which open some dialog for nicer user feedback. |
694 Can be used by buttons, which open some dialog for nicer user feedback. |
603 Notice: since the displays window manager typically allows a topWindow |
695 Notice: since the displays window manager typically allows a topWindow |
604 to be placed by the user, this should not be used for modeless |
696 to be placed by the user, this should not be used for modeless |
605 topViews. |
697 topViews. |
606 " |
698 " |
607 |
699 |
608 |steps dExt dOrg org ext root| |
700 |steps dExt dOrg org ext root| |
609 |
701 |
610 root := self rootView. |
702 root := self rootView. |
611 |
703 |
612 steps := 10. |
704 steps := 10. |
613 dExt := (endRect extent - startRect extent) / steps. |
705 dExt := (endRect extent - startRect extent) / steps. |
614 dOrg := (endRect origin - startRect origin) / steps. |
706 dOrg := (endRect origin - startRect origin) / steps. |
615 0 to:steps do:[:step | |
707 0 to:steps do:[:step | |
616 org := (startRect origin + (dOrg * step)) rounded. |
708 org := (startRect origin + (dOrg * step)) rounded. |
617 ext := (startRect extent + (dExt * step)) rounded. |
709 ext := (startRect extent + (dExt * step)) rounded. |
618 rootView clippedByChildren:false. |
710 rootView clippedByChildren:false. |
619 rootView xoring:[ |
711 rootView xoring:[ |
620 rootView displayRectangleX:org x y:org y width:ext x height:ext y |
712 rootView displayRectangleX:org x y:org y width:ext x height:ext y |
621 ]. |
713 ]. |
622 Delay waitForMilliseconds:(milliseconds // steps). |
714 Delay waitForMilliseconds:(milliseconds // steps). |
623 rootView xoring:[ |
715 rootView xoring:[ |
624 rootView displayRectangleX:org x y:org y width:ext x height:ext y |
716 rootView displayRectangleX:org x y:org y width:ext x height:ext y |
625 ]. |
717 ]. |
626 ]. |
718 ]. |
627 rootView clippedByChildren:true. |
719 rootView clippedByChildren:true. |
628 |
720 |
629 " |
721 " |
630 Screen current zoom:(10@10 corner:20@20) to:(20@20 corner:1000@1000) duration:1000 |
722 Screen current zoom:(10@10 corner:20@20) to:(20@20 corner:1000@1000) duration:1000 |
1827 ^ self subclassResponsibility |
1919 ^ self subclassResponsibility |
1828 ! |
1920 ! |
1829 |
1921 |
1830 createSubWindowFor:aView origin:org extent:ext borderWidth:bw subViewOf:sv inputOnly:inp cursor:cursor |
1922 createSubWindowFor:aView origin:org extent:ext borderWidth:bw subViewOf:sv inputOnly:inp cursor:cursor |
1831 ^ self |
1923 ^ self |
1832 createWindowFor:aView |
1924 createWindowFor:aView |
1833 type:nil |
1925 type:nil |
1834 origin:org |
1926 origin:org |
1835 extent:ext |
1927 extent:ext |
1836 minExtent:nil |
1928 minExtent:nil |
1837 maxExtent:nil |
1929 maxExtent:nil |
1838 borderWidth:bw |
1930 borderWidth:bw |
1839 subViewOf:sv |
1931 subViewOf:sv |
1840 onTop:false |
1932 onTop:false |
1841 inputOnly:inp |
1933 inputOnly:inp |
1842 label:nil |
1934 label:nil |
1843 cursor:cursor |
1935 cursor:cursor |
1844 icon:nil iconMask:nil |
1936 icon:nil iconMask:nil |
1845 iconView:nil |
1937 iconView:nil |
1846 ! |
1938 ! |
1847 |
1939 |
1848 createWindowFor:aView left:xpos top:ypos width:wwidth height:wheight |
1940 createWindowFor:aView left:xpos top:ypos width:wwidth height:wheight |
1849 "will vanish - for compatibility with previous versions" |
1941 "will vanish - for compatibility with previous versions" |
1850 |
1942 |
1851 ^ self |
1943 ^ self |
1852 createWindowFor:aView |
1944 createWindowFor:aView |
1853 type:nil |
1945 type:nil |
1854 origin:(xpos @ ypos) |
1946 origin:(xpos @ ypos) |
1855 extent:(wwidth @ wheight) |
1947 extent:(wwidth @ wheight) |
1856 minExtent:(aView minExtent) |
1948 minExtent:(aView minExtent) |
1857 maxExtent:(aView maxExtent) |
1949 maxExtent:(aView maxExtent) |
1858 borderWidth:(aView borderWidth) |
1950 borderWidth:(aView borderWidth) |
1859 subViewOf:(aView superView) |
1951 subViewOf:(aView superView) |
1860 onTop:(aView isPopUpView) |
1952 onTop:(aView isPopUpView) |
1861 inputOnly:(aView isInputOnly) |
1953 inputOnly:(aView isInputOnly) |
1862 label:(aView label) |
1954 label:(aView label) |
1863 cursor:(aView cursor) |
1955 cursor:(aView cursor) |
1864 icon:(aView icon) iconMask:(aView iconMask) |
1956 icon:(aView icon) iconMask:(aView iconMask) |
1865 iconView:(aView iconView) |
1957 iconView:(aView iconView) |
1866 |
1958 |
1867 "Modified: 1.6.1996 / 13:22:48 / cg" |
1959 "Modified: 1.6.1996 / 13:22:48 / cg" |
1868 ! |
1960 ! |
1869 |
1961 |
1870 createWindowFor:aView type:typeSymbol origin:org extent:ext minExtent:minE maxExtent:maxE borderWidth:bw subViewOf:sv onTop:onTop inputOnly:inp label:label cursor:curs icon:icn iconMask:icnM iconView:icnV |
1962 createWindowFor:aView type:typeSymbol origin:org extent:ext minExtent:minE maxExtent:maxE borderWidth:bw subViewOf:sv onTop:onTop inputOnly:inp label:label cursor:curs icon:icn iconMask:icnM iconView:icnV |
2415 displayString:aString x:x y:y in:aDrawableId with:aGCId |
2507 displayString:aString x:x y:y in:aDrawableId with:aGCId |
2416 "draw a string - draw foreground only. |
2508 "draw a string - draw foreground only. |
2417 If the coordinates are not integers, retry with rounded." |
2509 If the coordinates are not integers, retry with rounded." |
2418 |
2510 |
2419 self |
2511 self |
2420 displayString:aString |
2512 displayString:aString |
2421 x:x |
2513 x:x |
2422 y:y |
2514 y:y |
2423 in:aDrawableId |
2515 in:aDrawableId |
2424 with:aGCId |
2516 with:aGCId |
2425 opaque:false |
2517 opaque:false |
2426 ! |
2518 ! |
2427 |
2519 |
2428 displayString:aString x:x y:y in:aDrawableId with:aGCId opaque:opaque |
2520 displayString:aString x:x y:y in:aDrawableId with:aGCId opaque:opaque |
2429 "draw a string" |
2521 "draw a string" |
2430 |
2522 |
2431 self displayString:aString |
2523 self displayString:aString |
2432 from:1 |
2524 from:1 |
2433 to:aString size |
2525 to:aString size |
2434 x:x |
2526 x:x |
2435 y:y |
2527 y:y |
2436 in:aDrawableId |
2528 in:aDrawableId |
2437 with:aGCId |
2529 with:aGCId |
2438 opaque:opaque |
2530 opaque:opaque |
2439 ! |
2531 ! |
2440 |
2532 |
2441 drawBits:imageBits depth:imageDepth width:imageWidth height:imageHeight |
2533 drawBits:imageBits depth:imageDepth width:imageWidth height:imageHeight |
2442 x:srcx y:srcy |
2534 x:srcx y:srcy |
2443 into:aDrawableId x:dstx y:dsty width:w height:h with:aGCId |
2535 into:aDrawableId x:dstx y:dsty width:w height:h with:aGCId |
2444 |
2536 |
2445 "draw a bitimage which has depth id, width iw and height ih into |
2537 "draw a bitimage which has depth id, width iw and height ih into |
2446 the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty. |
2538 the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty. |
2447 It has to be checked elsewhere, that server can do it with the given |
2539 It has to be checked elsewhere, that server can do it with the given |
2448 depth; also it is assumed, that the colormap is setup correctly" |
2540 depth; also it is assumed, that the colormap is setup correctly" |
2449 |
2541 |
2450 ^ self subclassResponsibility |
2542 ^ self subclassResponsibility |
2451 ! |
2543 ! |
2452 |
2544 |
2453 fillArcX:x y:y width:width height:height from:startAngle angle:angle |
2545 fillArcX:x y:y width:width height:height from:startAngle angle:angle |
2454 in:aDrawableId with:aGCId |
2546 in:aDrawableId with:aGCId |
2455 "fill an arc" |
2547 "fill an arc" |
2456 |
2548 |
2457 ^ self subclassResponsibility |
2549 ^ self subclassResponsibility |
2458 |
2550 |
2459 "Created: 8.5.1996 / 08:45:11 / cg" |
2551 "Created: 8.5.1996 / 08:45:11 / cg" |
2615 "forward a configure for some view" |
2707 "forward a configure for some view" |
2616 |
2708 |
2617 |sensor| |
2709 |sensor| |
2618 |
2710 |
2619 (sensor := aView sensor) notNil ifTrue:[ |
2711 (sensor := aView sensor) notNil ifTrue:[ |
2620 sensor configureX:x y:y width:w height:h view:aView |
2712 sensor configureX:x y:y width:w height:h view:aView |
2621 ] ifFalse:[ |
2713 ] ifFalse:[ |
2622 " |
2714 " |
2623 if there is no sensor ... |
2715 if there is no sensor ... |
2624 " |
2716 " |
2625 aView configureX:x y:y width:w height:h |
2717 aView configureX:x y:y width:w height:h |
2626 ] |
2718 ] |
2627 ! |
2719 ! |
2628 |
2720 |
2629 coveredBy:otherView view:aView |
2721 coveredBy:otherView view:aView |
2630 "forward a covered for some view" |
2722 "forward a covered for some view" |
2631 |
2723 |
2632 |sensor| |
2724 |sensor| |
2633 |
2725 |
2634 (sensor := aView sensor) notNil ifTrue:[ |
2726 (sensor := aView sensor) notNil ifTrue:[ |
2635 sensor coveredBy:otherView view:aView |
2727 sensor coveredBy:otherView view:aView |
2636 ] ifFalse:[ |
2728 ] ifFalse:[ |
2637 " |
2729 " |
2638 if there is no sensor ... |
2730 if there is no sensor ... |
2639 " |
2731 " |
2640 aView coveredBy:otherView |
2732 aView coveredBy:otherView |
2641 ] |
2733 ] |
2642 ! |
2734 ! |
2643 |
2735 |
2644 destroyedView:aView |
2736 destroyedView:aView |
2645 "forward a destroyed event for some view" |
2737 "forward a destroyed event for some view" |
2646 |
2738 |
2647 |sensor| |
2739 |sensor| |
2648 |
2740 |
2649 (sensor := aView sensor) notNil ifTrue:[ |
2741 (sensor := aView sensor) notNil ifTrue:[ |
2650 sensor destroyedView:aView |
2742 sensor destroyedView:aView |
2651 ] ifFalse:[ |
2743 ] ifFalse:[ |
2652 " |
2744 " |
2653 if there is no sensor ... |
2745 if there is no sensor ... |
2654 " |
2746 " |
2655 aView destroyed |
2747 aView destroyed |
2656 ] |
2748 ] |
2657 ! |
2749 ! |
2658 |
2750 |
2659 exposeX:x y:y width:w height:h view:aView |
2751 exposeX:x y:y width:w height:h view:aView |
2660 "forward an expose for some view" |
2752 "forward an expose for some view" |
2661 |
2753 |
2662 |sensor| |
2754 |sensor| |
2663 |
2755 |
2664 (sensor := aView sensor) notNil ifTrue:[ |
2756 (sensor := aView sensor) notNil ifTrue:[ |
2665 sensor exposeX:x y:y width:w height:h view:aView |
2757 sensor exposeX:x y:y width:w height:h view:aView |
2666 ] ifFalse:[ |
2758 ] ifFalse:[ |
2667 " |
2759 " |
2668 if there is no sensor ... |
2760 if there is no sensor ... |
2669 " |
2761 " |
2670 WindowEvent |
2762 WindowEvent |
2671 sendEvent:#exposeX:y:width:height: |
2763 sendEvent:#exposeX:y:width:height: |
2672 arguments:(Array with:x with:y with:w with:h) |
2764 arguments:(Array with:x with:y with:w with:h) |
2673 view:aView |
2765 view:aView |
2674 ] |
2766 ] |
2675 ! |
2767 ! |
2676 |
2768 |
2677 focusInView:aView |
2769 focusInView:aView |
2678 "forward a focusIn event for some view" |
2770 "forward a focusIn event for some view" |
2679 |
2771 |
2680 |sensor| |
2772 |sensor| |
2681 |
2773 |
2682 (sensor := aView sensor) notNil ifTrue:[ |
2774 (sensor := aView sensor) notNil ifTrue:[ |
2683 sensor focusInView:aView |
2775 sensor focusInView:aView |
2684 ] ifFalse:[ |
2776 ] ifFalse:[ |
2685 " |
2777 " |
2686 if there is no sensor ... |
2778 if there is no sensor ... |
2687 " |
2779 " |
2688 WindowEvent |
2780 WindowEvent |
2689 sendEvent:#focusIn |
2781 sendEvent:#focusIn |
2690 arguments:nil |
2782 arguments:nil |
2691 view:aView |
2783 view:aView |
2692 ] |
2784 ] |
2693 ! |
2785 ! |
2694 |
2786 |
2695 focusOutView:aView |
2787 focusOutView:aView |
2696 "forward a focusOut event for some view" |
2788 "forward a focusOut event for some view" |
2697 |
2789 |
2698 |sensor| |
2790 |sensor| |
2699 |
2791 |
2700 (sensor := aView sensor) notNil ifTrue:[ |
2792 (sensor := aView sensor) notNil ifTrue:[ |
2701 sensor focusOutView:aView |
2793 sensor focusOutView:aView |
2702 ] ifFalse:[ |
2794 ] ifFalse:[ |
2703 " |
2795 " |
2704 if there is no sensor ... |
2796 if there is no sensor ... |
2705 " |
2797 " |
2706 WindowEvent |
2798 WindowEvent |
2707 sendEvent:#focusOut |
2799 sendEvent:#focusOut |
2708 arguments:nil |
2800 arguments:nil |
2709 view:aView |
2801 view:aView |
2710 ] |
2802 ] |
2711 ! |
2803 ! |
2712 |
2804 |
2713 graphicsExposeX:x y:y width:w height:h final:final view:aView |
2805 graphicsExposeX:x y:y width:w height:h final:final view:aView |
2714 "forward a graphic expose for some view" |
2806 "forward a graphic expose for some view" |
2715 |
2807 |
2716 |sensor| |
2808 |sensor| |
2717 |
2809 |
2718 (sensor := aView sensor) notNil ifTrue:[ |
2810 (sensor := aView sensor) notNil ifTrue:[ |
2719 sensor graphicsExposeX:x y:y width:w height:h final:final view:aView |
2811 sensor graphicsExposeX:x y:y width:w height:h final:final view:aView |
2720 ] ifFalse:[ |
2812 ] ifFalse:[ |
2721 " |
2813 " |
2722 if there is no sensor ... |
2814 if there is no sensor ... |
2723 " |
2815 " |
2724 WindowEvent |
2816 WindowEvent |
2725 sendEvent:#graphicsExposeX:y:width:height:final: |
2817 sendEvent:#graphicsExposeX:y:width:height:final: |
2726 arguments:(Array with:x with:y with:w with:h with:final) |
2818 arguments:(Array with:x with:y with:w with:h with:final) |
2727 view:aView |
2819 view:aView |
2728 ] |
2820 ] |
2729 ! |
2821 ! |
2730 |
2822 |
2731 keyPress:untranslatedKey x:x y:y view:aView |
2823 keyPress:untranslatedKey x:x y:y view:aView |
2732 "forward a key-press event for some view" |
2824 "forward a key-press event for some view" |
2737 |
2829 |
2738 "/ |
2830 "/ |
2739 "/ ctrl-Esc gives up focus |
2831 "/ ctrl-Esc gives up focus |
2740 "/ |
2832 "/ |
2741 untranslatedKey == #Escape ifTrue:[ |
2833 untranslatedKey == #Escape ifTrue:[ |
2742 ctrlDown ifTrue:[ |
2834 ctrlDown ifTrue:[ |
2743 self ungrabPointer. |
2835 self ungrabPointer. |
2744 self setInputFocusTo:nil |
2836 self setInputFocusTo:nil |
2745 ] |
2837 ] |
2746 ]. |
2838 ]. |
2747 |
2839 |
2748 self modifierKeyProcessing:untranslatedKey down:true. |
2840 self modifierKeyProcessing:untranslatedKey down:true. |
2749 |
2841 |
2750 (sensor := aView sensor) notNil ifTrue:[ |
2842 (sensor := aView sensor) notNil ifTrue:[ |
2751 sensor keyPress:untranslatedKey x:x y:y view:aView |
2843 sensor keyPress:untranslatedKey x:x y:y view:aView |
2752 ] ifFalse:[ |
2844 ] ifFalse:[ |
2753 aView shown ifTrue:[ "/ could be a late event arrival |
2845 aView shown ifTrue:[ "/ could be a late event arrival |
2754 " |
2846 " |
2755 if there is no sensor ... |
2847 if there is no sensor ... |
2756 " |
2848 " |
2757 xlatedKey := self translateKey:untranslatedKey. |
2849 xlatedKey := self translateKey:untranslatedKey. |
2758 xlatedKey notNil ifTrue:[ |
2850 xlatedKey notNil ifTrue:[ |
2759 WindowEvent |
2851 WindowEvent |
2760 sendEvent:#keyPress:x:y: |
2852 sendEvent:#keyPress:x:y: |
2761 arguments:(Array with:xlatedKey with:x with:y) |
2853 arguments:(Array with:xlatedKey with:x with:y) |
2762 view:aView |
2854 view:aView |
2763 ] |
2855 ] |
2764 ] |
2856 ] |
2765 ] |
2857 ] |
2766 |
2858 |
2767 "Modified: 26.2.1997 / 15:03:28 / cg" |
2859 "Modified: 26.2.1997 / 15:03:28 / cg" |
2768 ! |
2860 ! |
2769 |
2861 |
2798 "forward a mapped event for some view" |
2890 "forward a mapped event for some view" |
2799 |
2891 |
2800 |sensor| |
2892 |sensor| |
2801 |
2893 |
2802 (sensor := aView sensor) notNil ifTrue:[ |
2894 (sensor := aView sensor) notNil ifTrue:[ |
2803 sensor mappedView:aView |
2895 sensor mappedView:aView |
2804 ] ifFalse:[ |
2896 ] ifFalse:[ |
2805 " |
2897 " |
2806 if there is no sensor ... |
2898 if there is no sensor ... |
2807 " |
2899 " |
2808 aView mapped |
2900 aView mapped |
2809 ] |
2901 ] |
2810 ! |
2902 ! |
2811 |
2903 |
2812 noExposeView:aView |
2904 noExposeView:aView |
2813 "forward a noExpose event for some view" |
2905 "forward a noExpose event for some view" |
2814 |
2906 |
2815 |sensor| |
2907 |sensor| |
2816 |
2908 |
2817 (sensor := aView sensor) notNil ifTrue:[ |
2909 (sensor := aView sensor) notNil ifTrue:[ |
2818 sensor noExposeView:aView |
2910 sensor noExposeView:aView |
2819 ] ifFalse:[ |
2911 ] ifFalse:[ |
2820 " |
2912 " |
2821 if there is no sensor ... |
2913 if there is no sensor ... |
2822 " |
2914 " |
2823 aView noExpose |
2915 aView noExpose |
2824 ] |
2916 ] |
2825 ! |
2917 ! |
2826 |
2918 |
2827 pointerEnter:buttonState x:x y:y view:aView |
2919 pointerEnter:buttonState x:x y:y view:aView |
2828 "forward a pointer enter for some view" |
2920 "forward a pointer enter for some view" |
2829 |
2921 |
2830 |sensor| |
2922 |sensor| |
2831 |
2923 |
2832 (sensor := aView sensor) notNil ifTrue:[ |
2924 (sensor := aView sensor) notNil ifTrue:[ |
2833 sensor pointerEnter:buttonState x:x y:y view:aView |
2925 sensor pointerEnter:buttonState x:x y:y view:aView |
2834 ] ifFalse:[ |
2926 ] ifFalse:[ |
2835 " |
2927 " |
2836 if there is no sensor ... |
2928 if there is no sensor ... |
2837 " |
2929 " |
2838 WindowEvent |
2930 WindowEvent |
2839 sendEvent:#pointerEnter:x:y: |
2931 sendEvent:#pointerEnter:x:y: |
2840 arguments:(Array with:buttonState with:x with:y) |
2932 arguments:(Array with:buttonState with:x with:y) |
2841 view:aView |
2933 view:aView |
2842 ] |
2934 ] |
2843 ! |
2935 ! |
2844 |
2936 |
2845 pointerLeave:buttonState view:aView |
2937 pointerLeave:buttonState view:aView |
2846 "forward a pointer leave for some view" |
2938 "forward a pointer leave for some view" |
2847 |
2939 |
2848 |sensor| |
2940 |sensor| |
2849 |
2941 |
2850 (sensor := aView sensor) notNil ifTrue:[ |
2942 (sensor := aView sensor) notNil ifTrue:[ |
2851 sensor pointerLeave:buttonState view:aView |
2943 sensor pointerLeave:buttonState view:aView |
2852 ] ifFalse:[ |
2944 ] ifFalse:[ |
2853 " |
2945 " |
2854 if there is no sensor ... |
2946 if there is no sensor ... |
2855 " |
2947 " |
2856 WindowEvent |
2948 WindowEvent |
2857 sendEvent:#pointerLeave: |
2949 sendEvent:#pointerLeave: |
2858 arguments:(Array with:buttonState) |
2950 arguments:(Array with:buttonState) |
2859 view:aView |
2951 view:aView |
2860 ] |
2952 ] |
2861 ! |
2953 ! |
2862 |
2954 |
2863 saveAndTerminateView:aView |
2955 saveAndTerminateView:aView |
2864 "forward a saveAndTerminate event for some view" |
2956 "forward a saveAndTerminate event for some view" |
2865 |
2957 |
2866 |sensor| |
2958 |sensor| |
2867 |
2959 |
2868 (sensor := aView sensor) notNil ifTrue:[ |
2960 (sensor := aView sensor) notNil ifTrue:[ |
2869 sensor saveAndTerminateView:aView |
2961 sensor saveAndTerminateView:aView |
2870 ] ifFalse:[ |
2962 ] ifFalse:[ |
2871 " |
2963 " |
2872 if there is no sensor ... |
2964 if there is no sensor ... |
2873 " |
2965 " |
2874 aView saveAndTerminate |
2966 aView saveAndTerminate |
2875 ] |
2967 ] |
2876 ! |
2968 ! |
2877 |
2969 |
2878 terminateView:aView |
2970 terminateView:aView |
2879 "forward a terminate event for some view" |
2971 "forward a terminate event for some view" |
2880 |
2972 |
2881 |sensor| |
2973 |sensor| |
2882 |
2974 |
2883 (sensor := aView sensor) notNil ifTrue:[ |
2975 (sensor := aView sensor) notNil ifTrue:[ |
2884 sensor terminateView:aView |
2976 sensor terminateView:aView |
2885 ] ifFalse:[ |
2977 ] ifFalse:[ |
2886 " |
2978 " |
2887 if there is no sensor ... |
2979 if there is no sensor ... |
2888 " |
2980 " |
2889 aView terminate |
2981 aView terminate |
2890 ] |
2982 ] |
2891 ! |
2983 ! |
2892 |
2984 |
2893 unmappedView:aView |
2985 unmappedView:aView |
2894 "forward an unmapped event for some view" |
2986 "forward an unmapped event for some view" |
2895 |
2987 |
2896 |sensor| |
2988 |sensor| |
2897 |
2989 |
2898 (sensor := aView sensor) notNil ifTrue:[ |
2990 (sensor := aView sensor) notNil ifTrue:[ |
2899 sensor unmappedView:aView |
2991 sensor unmappedView:aView |
2900 ] ifFalse:[ |
2992 ] ifFalse:[ |
2901 " |
2993 " |
2902 if there is no sensor ... |
2994 if there is no sensor ... |
2903 " |
2995 " |
2904 aView unmapped |
2996 aView unmapped |
2905 ] |
2997 ] |
2906 ! ! |
2998 ! ! |
2907 |
2999 |
2908 !DeviceWorkstation methodsFor:'event handling'! |
3000 !DeviceWorkstation methodsFor:'event handling'! |
2909 |
3001 |
2914 We only do this for displays other that the default Display." |
3006 We only do this for displays other that the default Display." |
2915 |
3007 |
2916 dispatching ifFalse:[^ self]. |
3008 dispatching ifFalse:[^ self]. |
2917 |
3009 |
2918 self == Display ifTrue:[ |
3010 self == Display ifTrue:[ |
2919 ExitOnLastClose ifFalse:[^ self]. |
3011 ExitOnLastClose ifFalse:[^ self]. |
2920 ]. |
3012 ]. |
2921 |
3013 |
2922 knownViews notNil ifTrue:[ |
3014 knownViews notNil ifTrue:[ |
2923 (knownViews findFirst:[:slot | |
3015 (knownViews findFirst:[:slot | |
2924 slot notNil |
3016 slot notNil |
2925 and:[slot ~~ 0 |
3017 and:[slot ~~ 0 |
2926 and:[slot isRootView not |
3018 and:[slot isRootView not |
2927 and:[slot superView isNil |
3019 and:[slot superView isNil |
2928 and:[slot realized]]]]]) == 0 ifTrue:[ |
3020 and:[slot realized]]]]]) == 0 ifTrue:[ |
2929 "/ my last view was closed |
3021 "/ my last view was closed |
2930 dispatching := false. |
3022 dispatching := false. |
2931 'DeviceWorkstation [info]: finished dispatch (last view closed)' infoPrintCR. |
3023 'DeviceWorkstation [info]: finished dispatch (last view closed)' infoPrintCR. |
2932 ] |
3024 ] |
2933 ]. |
3025 ]. |
2934 |
3026 |
2935 "Modified: 19.9.1995 / 11:31:54 / claus" |
3027 "Modified: 19.9.1995 / 11:31:54 / claus" |
2936 "Modified: 18.3.1997 / 10:42:11 / cg" |
3028 "Modified: 18.3.1997 / 10:42:11 / cg" |
2937 ! |
3029 ! |
2970 it is used; otherwise we poll (with a delay to not lock up |
3062 it is used; otherwise we poll (with a delay to not lock up |
2971 the workstation) |
3063 the workstation) |
2972 " |
3064 " |
2973 myFd := self displayFileDescriptor. |
3065 myFd := self displayFileDescriptor. |
2974 [aBlock value] whileTrue:[ |
3066 [aBlock value] whileTrue:[ |
2975 self eventPending ifFalse:[ |
3067 self eventPending ifFalse:[ |
2976 myFd isNil ifTrue:[ |
3068 myFd isNil ifTrue:[ |
2977 OperatingSystem millisecondDelay:50 |
3069 OperatingSystem millisecondDelay:50 |
2978 ] ifFalse:[ |
3070 ] ifFalse:[ |
2979 OperatingSystem selectOn:myFd withTimeOut:50. |
3071 OperatingSystem selectOn:myFd withTimeOut:50. |
2980 ]. |
3072 ]. |
2981 Processor evaluateTimeouts. |
3073 Processor evaluateTimeouts. |
2982 ]. |
3074 ]. |
2983 self eventPending ifTrue:[ |
3075 self eventPending ifTrue:[ |
2984 self dispatchEvent |
3076 self dispatchEvent |
2985 ]. |
3077 ]. |
2986 ] |
3078 ] |
2987 ! |
3079 ! |
2988 |
3080 |
2989 dispatchPendingEvents |
3081 dispatchPendingEvents |
2990 "go dispatch events as long as there is one. |
3082 "go dispatch events as long as there is one. |
2991 This is only used with modal operation. |
3083 This is only used with modal operation. |
2992 (i.e. when in the modal debugger)" |
3084 (i.e. when in the modal debugger)" |
2993 |
3085 |
2994 [self eventPending] whileTrue:[ |
3086 [self eventPending] whileTrue:[ |
2995 self dispatchEventFor:nil withMask:nil |
3087 self dispatchEventFor:nil withMask:nil |
2996 ] |
3088 ] |
2997 ! |
3089 ! |
2998 |
3090 |
2999 disposeButtonEventsFor:aViewIdOrNil |
3091 disposeButtonEventsFor:aViewIdOrNil |
3000 "dispose (i.e. forget) all pending button events on this display" |
3092 "dispose (i.e. forget) all pending button events on this display" |
3091 "/ on my filedescriptor. Since a select alone is not enough to |
3183 "/ on my filedescriptor. Since a select alone is not enough to |
3092 "/ know if events are pending (Xlib reads out event-queue while |
3184 "/ know if events are pending (Xlib reads out event-queue while |
3093 "/ doing output), we also have to install a poll-check block. |
3185 "/ doing output), we also have to install a poll-check block. |
3094 |
3186 |
3095 OperatingSystem supportsSelect ifTrue:[ |
3187 OperatingSystem supportsSelect ifTrue:[ |
3096 inputSema := Semaphore new name:'display inputSema'. |
3188 inputSema := Semaphore new name:'display inputSema'. |
3097 ]. |
3189 ]. |
3098 |
3190 |
3099 p := [ |
3191 p := [ |
3100 self initializeDeviceResources. |
3192 self initializeDeviceResources. |
3101 |
3193 |
3102 [dispatching] whileTrue:[ |
3194 [dispatching] whileTrue:[ |
3103 AbortSignal handle:[:ex | |
3195 AbortSignal handle:[:ex | |
3104 ex return |
3196 ex return |
3105 ] do:[ |
3197 ] do:[ |
3106 self eventPending ifFalse:[ |
3198 self eventPending ifFalse:[ |
3107 Processor activeProcess setStateTo:#ioWait if:#active. |
3199 Processor activeProcess setStateTo:#ioWait if:#active. |
3108 inputSema notNil ifTrue:[ |
3200 inputSema notNil ifTrue:[ |
3109 inputSema wait. |
3201 inputSema wait. |
3110 ] ifFalse:[ |
3202 ] ifFalse:[ |
3111 Delay waitForMilliseconds:50 |
3203 Delay waitForMilliseconds:50 |
3112 ] |
3204 ] |
3113 ]. |
3205 ]. |
3114 |
3206 |
3115 self dispatchPendingEvents. |
3207 self dispatchPendingEvents. |
3116 ] |
3208 ] |
3117 ]. |
3209 ]. |
3118 inputSema notNil ifTrue:[ |
3210 inputSema notNil ifTrue:[ |
3119 Processor disableSemaphore:inputSema. |
3211 Processor disableSemaphore:inputSema. |
3120 inputSema := nil. |
3212 inputSema := nil. |
3121 ]. |
3213 ]. |
3122 AllScreens remove:self. |
3214 AllScreens remove:self. |
3123 dispatchProcess := nil. |
3215 dispatchProcess := nil. |
3124 self close. |
3216 self close. |
3125 ] newProcess. |
3217 ] newProcess. |
3126 |
3218 |
3127 "/ |
3219 "/ |
3128 "/ give the process a nice name (for the processMonitor) |
3220 "/ give the process a nice name (for the processMonitor) |
3129 "/ |
3221 "/ |
3130 (nm := self displayName) notNil ifTrue:[ |
3222 (nm := self displayName) notNil ifTrue:[ |
3131 nm := 'event dispatcher (' , nm , ')'. |
3223 nm := 'event dispatcher (' , nm , ')'. |
3132 ] ifFalse:[ |
3224 ] ifFalse:[ |
3133 nm := 'event dispatcher'. |
3225 nm := 'event dispatcher'. |
3134 ]. |
3226 ]. |
3135 p name:nm. |
3227 p name:nm. |
3136 p priority:(Processor userInterruptPriority). |
3228 p priority:(Processor userInterruptPriority). |
3137 dispatchProcess := p. |
3229 dispatchProcess := p. |
3138 p resume. |
3230 p resume. |
3139 |
3231 |
3140 "/ finally, arrange for the processor to signal that semaphore on input |
3232 "/ finally, arrange for the processor to signal that semaphore on input |
3141 |
3233 |
3142 inputSema notNil ifTrue:[ |
3234 inputSema notNil ifTrue:[ |
3143 Processor signal:inputSema onInput:fd orCheck:[self eventPending]. |
3235 Processor signal:inputSema onInput:fd orCheck:[self eventPending]. |
3144 ] |
3236 ] |
3145 |
3237 |
3146 "Modified: 12.12.1995 / 20:52:57 / stefan" |
3238 "Modified: 12.12.1995 / 20:52:57 / stefan" |
3147 "Modified: 1.2.1997 / 12:17:26 / cg" |
3239 "Modified: 1.2.1997 / 12:17:26 / cg" |
3148 ! ! |
3240 ! ! |
3832 " |
3924 " |
3833 Form reinitializeAllOn:self. |
3925 Form reinitializeAllOn:self. |
3834 |
3926 |
3835 "/ prevMapping notNil ifTrue:[ |
3927 "/ prevMapping notNil ifTrue:[ |
3836 prevKnownViews notNil ifTrue:[ |
3928 prevKnownViews notNil ifTrue:[ |
3837 " |
3929 " |
3838 first round: flush all device specific stuff |
3930 first round: flush all device specific stuff |
3839 " |
3931 " |
3840 "/ prevMapping keysAndValuesDo:[:anId :aView | |
3932 "/ prevMapping keysAndValuesDo:[:anId :aView | |
3841 prevKnownViews do:[:aView | |
3933 prevKnownViews do:[:aView | |
3842 (aView notNil and:[aView ~~ 0]) ifTrue:[ |
3934 (aView notNil and:[aView ~~ 0]) ifTrue:[ |
3843 aView prepareForReinit |
3935 aView prepareForReinit |
3844 ] |
3936 ] |
3845 ]. |
3937 ]. |
3846 |
3938 |
3847 " |
3939 " |
3848 2nd round: all views should reinstall themself |
3940 2nd round: all views should reinstall themself |
3849 on the new display |
3941 on the new display |
3850 " |
3942 " |
3851 "/ prevMapping keysAndValuesDo:[:anId :aView | |
3943 "/ prevMapping keysAndValuesDo:[:anId :aView | |
3852 |
3944 |
3853 prevKnownViews do:[:aView | |
3945 prevKnownViews do:[:aView | |
3854 (aView notNil and:[aView ~~ 0]) ifTrue:[ |
3946 (aView notNil and:[aView ~~ 0]) ifTrue:[ |
3855 "have to re-create the view" |
3947 "have to re-create the view" |
3856 AbortSignal catch:[ |
3948 AbortSignal catch:[ |
3857 aView reinitialize |
3949 aView reinitialize |
3858 ] |
3950 ] |
3859 ] |
3951 ] |
3860 ]. |
3952 ]. |
3861 |
3953 |
3862 (prevWidth ~~ width |
3954 (prevWidth ~~ width |
3863 or:[prevHeight ~~ height]) ifTrue:[ |
3955 or:[prevHeight ~~ height]) ifTrue:[ |
3864 " |
3956 " |
3865 3rd round: all views get a chance to handle |
3957 3rd round: all views get a chance to handle |
3866 changed environment (colors, font sizes etc) |
3958 changed environment (colors, font sizes etc) |
3867 " |
3959 " |
3868 "/ prevMapping keysAndValuesDo:[:anId :aView | |
3960 "/ prevMapping keysAndValuesDo:[:anId :aView | |
3869 prevKnownViews do:[:aView | |
3961 prevKnownViews do:[:aView | |
3870 (aView notNil and:[aView ~~ 0]) ifTrue:[ |
3962 (aView notNil and:[aView ~~ 0]) ifTrue:[ |
3871 aView reAdjustGeometry |
3963 aView reAdjustGeometry |
3872 ] |
3964 ] |
3873 ] |
3965 ] |
3874 ] |
3966 ] |
3875 ]. |
3967 ]. |
3876 dispatching := false. |
3968 dispatching := false. |
3877 |
3969 |
3878 "Modified: 23.1.1997 / 21:32:10 / cg" |
3970 "Modified: 23.1.1997 / 21:32:10 / cg" |
3879 ! |
3971 ! |
3880 |
3972 |
3881 releaseDeviceResources |
3973 releaseDeviceResources |
3882 "release any cached device resources" |
3974 "release any cached device resources" |
3883 |
3975 |
3884 blackColor on:nil. "/ release those colors |
3976 blackColor notNil ifTrue:[ |
3885 blackColor := nil. |
3977 blackColor on:nil. |
3886 whiteColor on:nil. |
3978 blackColor := nil. |
3887 whiteColor := nil. |
3979 ]. |
|
3980 whiteColor notNil ifTrue:[ |
|
3981 whiteColor on:nil. |
|
3982 whiteColor := nil. |
|
3983 ]. |
3888 |
3984 |
3889 Image releaseResourcesOnDevice:self. |
3985 Image releaseResourcesOnDevice:self. |
3890 Color releaseResourcesOnDevice:self. |
3986 Color releaseResourcesOnDevice:self. |
3891 Cursor releaseResourcesOnDevice:self. |
3987 Cursor releaseResourcesOnDevice:self. |
3892 Font releaseResourcesOnDevice:self. |
3988 Font releaseResourcesOnDevice:self. |
3922 |
4018 |
3923 root noClipByChildren. |
4019 root noClipByChildren. |
3924 root foreground:blackColor background:whiteColor. |
4020 root foreground:blackColor background:whiteColor. |
3925 |
4021 |
3926 root xoring:[ |
4022 root xoring:[ |
3927 |left right top bottom newOrigin newCorner p| |
4023 |left right top bottom newOrigin newCorner p| |
3928 |
4024 |
3929 rect := origin extent:extent. |
4025 rect := origin extent:extent. |
3930 root displayRectangle:rect. |
4026 root displayRectangle:rect. |
3931 |
4027 |
3932 self |
4028 self |
3933 grabPointerIn:root id |
4029 grabPointerIn:root id |
3934 withCursor:curs id |
4030 withCursor:curs id |
3935 pointerMode:#async |
4031 pointerMode:#async |
3936 keyboardMode:#sync |
4032 keyboardMode:#sync |
3937 confineTo:nil. |
4033 confineTo:nil. |
3938 |
4034 |
3939 [self leftButtonPressed] whileTrue:[ |
4035 [self leftButtonPressed] whileTrue:[ |
3940 newOrigin := self pointerPosition. |
4036 newOrigin := self pointerPosition. |
3941 |
4037 |
3942 (newOrigin ~= origin) ifTrue:[ |
4038 (newOrigin ~= origin) ifTrue:[ |
3943 root displayRectangle:rect. |
4039 root displayRectangle:rect. |
3944 |
4040 |
3945 self |
4041 self |
3946 grabPointerIn:root id |
4042 grabPointerIn:root id |
3947 withCursor:curs id |
4043 withCursor:curs id |
3948 pointerMode:#async |
4044 pointerMode:#async |
3949 keyboardMode:#sync |
4045 keyboardMode:#sync |
3950 confineTo:nil. |
4046 confineTo:nil. |
3951 |
4047 |
3952 rect := newOrigin extent:extent. |
4048 rect := newOrigin extent:extent. |
3953 root displayRectangle:rect. |
4049 root displayRectangle:rect. |
3954 self disposeButtonEventsFor:nil. |
4050 self disposeButtonEventsFor:nil. |
3955 self flush. |
4051 self flush. |
3956 origin := newOrigin. |
4052 origin := newOrigin. |
3957 ] ifFalse:[ |
4053 ] ifFalse:[ |
3958 Processor yield |
4054 Processor yield |
3959 ] |
4055 ] |
3960 ]. |
4056 ]. |
3961 root displayRectangle:rect. |
4057 root displayRectangle:rect. |
3962 self ungrabPointer. |
4058 self ungrabPointer. |
3963 ]. |
4059 ]. |
3964 |
4060 |
3965 self ungrabPointer. |
4061 self ungrabPointer. |
3966 |
4062 |
3967 "flush all events pending on my display" |
4063 "flush all events pending on my display" |
4074 |
4170 |
4075 root noClipByChildren. |
4171 root noClipByChildren. |
4076 root foreground:blackColor background:whiteColor. |
4172 root foreground:blackColor background:whiteColor. |
4077 |
4173 |
4078 root xoring:[ |
4174 root xoring:[ |
4079 |left right top bottom newOrigin newCorner p curs| |
4175 |left right top bottom newOrigin newCorner p curs| |
4080 |
4176 |
4081 corner := origin. |
4177 corner := origin. |
4082 rect := origin corner:corner. |
4178 rect := origin corner:corner. |
4083 root displayRectangle:rect. |
4179 root displayRectangle:rect. |
4084 |
4180 |
4085 self |
4181 self |
4086 grabPointerIn:root id |
4182 grabPointerIn:root id |
4087 withCursor:curs1 id |
4183 withCursor:curs1 id |
4088 pointerMode:#async |
4184 pointerMode:#async |
4089 keyboardMode:#sync |
4185 keyboardMode:#sync |
4090 confineTo:nil. |
4186 confineTo:nil. |
4091 |
4187 |
4092 " |
4188 " |
4093 just in case; wait for button to be down ... |
4189 just in case; wait for button to be down ... |
4094 " |
4190 " |
4095 [self leftButtonPressed] whileFalse:[Processor yield]. |
4191 [self leftButtonPressed] whileFalse:[Processor yield]. |
4096 |
4192 |
4097 [self leftButtonPressed] whileTrue:[ |
4193 [self leftButtonPressed] whileTrue:[ |
4098 left := initialRectangle origin x. |
4194 left := initialRectangle origin x. |
4099 top := initialRectangle origin y. |
4195 top := initialRectangle origin y. |
4100 right := initialRectangle corner x. |
4196 right := initialRectangle corner x. |
4101 bottom := initialRectangle corner y. |
4197 bottom := initialRectangle corner y. |
4102 |
4198 |
4103 p := self pointerPosition. |
4199 p := self pointerPosition. |
4104 p x < initialRectangle left ifTrue:[ |
4200 p x < initialRectangle left ifTrue:[ |
4105 p y < initialRectangle top ifTrue:[ |
4201 p y < initialRectangle top ifTrue:[ |
4106 curs := Cursor topLeft. |
4202 curs := Cursor topLeft. |
4107 left := p x. |
4203 left := p x. |
4108 top := p y. |
4204 top := p y. |
4109 ] ifFalse:[ |
4205 ] ifFalse:[ |
4110 curs := Cursor bottomLeft. |
4206 curs := Cursor bottomLeft. |
4111 left := p x. |
4207 left := p x. |
4112 bottom := p y |
4208 bottom := p y |
4113 ] |
4209 ] |
4114 ] ifFalse:[ |
4210 ] ifFalse:[ |
4115 p y < initialRectangle top ifTrue:[ |
4211 p y < initialRectangle top ifTrue:[ |
4116 curs := Cursor topRight. |
4212 curs := Cursor topRight. |
4117 right := p x. |
4213 right := p x. |
4118 top := p y |
4214 top := p y |
4119 ] ifFalse:[ |
4215 ] ifFalse:[ |
4120 curs := Cursor bottomRight. |
4216 curs := Cursor bottomRight. |
4121 right := p x. |
4217 right := p x. |
4122 bottom := p y |
4218 bottom := p y |
4123 ] |
4219 ] |
4124 ]. |
4220 ]. |
4125 |
4221 |
4126 newOrigin := left @ top. |
4222 newOrigin := left @ top. |
4127 newCorner := right @ bottom. |
4223 newCorner := right @ bottom. |
4128 |
4224 |
4129 ((newOrigin ~= origin) or:[newCorner ~= corner]) ifTrue:[ |
4225 ((newOrigin ~= origin) or:[newCorner ~= corner]) ifTrue:[ |
4130 root displayRectangle:rect. |
4226 root displayRectangle:rect. |
4131 |
4227 |
4132 self grabPointerIn:root id withCursor:curs id |
4228 self grabPointerIn:root id withCursor:curs id |
4133 pointerMode:#async keyboardMode:#sync confineTo:nil. |
4229 pointerMode:#async keyboardMode:#sync confineTo:nil. |
4134 |
4230 |
4135 origin := newOrigin. |
4231 origin := newOrigin. |
4136 corner := newCorner. |
4232 corner := newCorner. |
4137 rect := origin corner:corner. |
4233 rect := origin corner:corner. |
4138 root displayRectangle:rect. |
4234 root displayRectangle:rect. |
4139 self disposeButtonEventsFor:nil. |
4235 self disposeButtonEventsFor:nil. |
4140 self flush. |
4236 self flush. |
4141 ] ifFalse:[ |
4237 ] ifFalse:[ |
4142 Processor yield |
4238 Processor yield |
4143 ] |
4239 ] |
4144 ]. |
4240 ]. |
4145 root displayRectangle:rect. |
4241 root displayRectangle:rect. |
4146 self ungrabPointer. |
4242 self ungrabPointer. |
4147 ]. |
4243 ]. |
4148 |
4244 |
4149 self ungrabPointer. |
4245 self ungrabPointer. |
4150 |
4246 |
4151 "flush all events pending on my display" |
4247 "flush all events pending on my display" |
4332 |
4428 |
4333 "/ the next statement will vanish .... |
4429 "/ the next statement will vanish .... |
4334 (untranslatedKey == #Control |
4430 (untranslatedKey == #Control |
4335 or:[untranslatedKey == #'Control_L' |
4431 or:[untranslatedKey == #'Control_L' |
4336 or:[untranslatedKey == #'Control_R']]) ifTrue:[ |
4432 or:[untranslatedKey == #'Control_R']]) ifTrue:[ |
4337 ^ #Ctrl |
4433 ^ #Ctrl |
4338 ]. |
4434 ]. |
4339 |
4435 |
4340 (untranslatedKey == #Ctrl |
4436 (untranslatedKey == #Ctrl |
4341 or:[untranslatedKey == #'Ctrl_L' |
4437 or:[untranslatedKey == #'Ctrl_L' |
4342 or:[untranslatedKey == #'Ctrl_R']]) ifTrue:[ |
4438 or:[untranslatedKey == #'Ctrl_R']]) ifTrue:[ |
4343 ^ #Ctrl |
4439 ^ #Ctrl |
4344 ]. |
4440 ]. |
4345 (untranslatedKey == #'Shift' |
4441 (untranslatedKey == #'Shift' |
4346 or:[untranslatedKey == #'Shift_L' |
4442 or:[untranslatedKey == #'Shift_L' |
4347 or:[untranslatedKey == #'Shift_R']]) ifTrue:[ |
4443 or:[untranslatedKey == #'Shift_R']]) ifTrue:[ |
4348 ^ #Shift |
4444 ^ #Shift |
4349 ]. |
4445 ]. |
4350 (untranslatedKey == #'Alt' |
4446 (untranslatedKey == #'Alt' |
4351 or:[untranslatedKey == #'Alt_L' |
4447 or:[untranslatedKey == #'Alt_L' |
4352 or:[untranslatedKey == #'Alt_R']]) ifTrue:[ |
4448 or:[untranslatedKey == #'Alt_R']]) ifTrue:[ |
4353 ^ #Alt |
4449 ^ #Alt |
4354 ]. |
4450 ]. |
4355 (untranslatedKey == #'Meta' |
4451 (untranslatedKey == #'Meta' |
4356 or:[untranslatedKey == #'Meta_L' |
4452 or:[untranslatedKey == #'Meta_L' |
4357 or:[untranslatedKey == #'Meta_R']]) ifTrue:[ |
4453 or:[untranslatedKey == #'Meta_R']]) ifTrue:[ |
4358 ^ #Meta |
4454 ^ #Meta |
4359 ]. |
4455 ]. |
4360 (untranslatedKey == #'Cmd' |
4456 (untranslatedKey == #'Cmd' |
4361 or:[untranslatedKey == #'Cmd_L' |
4457 or:[untranslatedKey == #'Cmd_L' |
4362 or:[untranslatedKey == #'Cmd_R']]) ifTrue:[ |
4458 or:[untranslatedKey == #'Cmd_R']]) ifTrue:[ |
4363 ^ #Cmd |
4459 ^ #Cmd |
4364 ]. |
4460 ]. |
4365 ^ nil |
4461 ^ nil |
4366 |
4462 |
4367 "Created: 28.2.1996 / 16:40:46 / cg" |
4463 "Created: 28.2.1996 / 16:40:46 / cg" |
4368 "Modified: 28.2.1996 / 17:11:34 / cg" |
4464 "Modified: 28.2.1996 / 17:11:34 / cg" |
4395 modifier := self modifierKeyTranslationFor:untranslatedKey. |
4491 modifier := self modifierKeyTranslationFor:untranslatedKey. |
4396 "/ |
4492 "/ |
4397 "/ only prepend, if this is not a modifier |
4493 "/ only prepend, if this is not a modifier |
4398 "/ |
4494 "/ |
4399 modifier isNil ifTrue:[ |
4495 modifier isNil ifTrue:[ |
4400 s := xlatedKey asString. |
4496 s := xlatedKey asString. |
4401 ctrlDown ifTrue:[ |
4497 ctrlDown ifTrue:[ |
4402 xlatedKey := 'Ctrl' , s |
4498 xlatedKey := 'Ctrl' , s |
4403 ]. |
4499 ]. |
4404 metaDown ifTrue:[ |
4500 metaDown ifTrue:[ |
4405 xlatedKey := 'Cmd' , s |
4501 xlatedKey := 'Cmd' , s |
4406 ]. |
4502 ]. |
4407 altDown ifTrue:[ |
4503 altDown ifTrue:[ |
4408 xlatedKey := 'Alt' , s |
4504 xlatedKey := 'Alt' , s |
4409 ]. |
4505 ]. |
4410 xlatedKey isCharacter ifFalse:[ |
4506 xlatedKey isCharacter ifFalse:[ |
4411 xlatedKey := xlatedKey asSymbol |
4507 xlatedKey := xlatedKey asSymbol |
4412 ]. |
4508 ]. |
4413 ]. |
4509 ]. |
4414 |
4510 |
4415 xlatedKey := keyboardMap valueFor:xlatedKey. |
4511 xlatedKey := keyboardMap valueFor:xlatedKey. |
4416 xlatedKey isCharacter ifFalse:[ |
4512 xlatedKey isCharacter ifFalse:[ |
4417 xlatedKey := xlatedKey asSymbol |
4513 xlatedKey := xlatedKey asSymbol |
4418 ]. |
4514 ]. |
4419 ^ xlatedKey |
4515 ^ xlatedKey |
4420 |
4516 |
4421 "Modified: 28.2.1996 / 17:12:16 / cg" |
4517 "Modified: 28.2.1996 / 17:12:16 / cg" |
4422 ! ! |
4518 ! ! |
4791 |freeIdx newArr sz newSize wasBlocked| |
4887 |freeIdx newArr sz newSize wasBlocked| |
4792 |
4888 |
4793 wasBlocked := OperatingSystem blockInterrupts. |
4889 wasBlocked := OperatingSystem blockInterrupts. |
4794 |
4890 |
4795 knownViews isNil ifTrue:[ |
4891 knownViews isNil ifTrue:[ |
4796 knownViews := WeakArray new:50. |
4892 knownViews := WeakArray new:50. |
4797 knownIds := Array new:50. |
4893 knownIds := Array new:50. |
4798 freeIdx := 1. |
4894 freeIdx := 1. |
4799 ] ifFalse:[ |
4895 ] ifFalse:[ |
4800 freeIdx := knownViews identityIndexOf:nil. |
4896 freeIdx := knownViews identityIndexOf:nil. |
4801 freeIdx == 0 ifTrue:[ |
4897 freeIdx == 0 ifTrue:[ |
4802 freeIdx := knownViews identityIndexOf:0. |
4898 freeIdx := knownViews identityIndexOf:0. |
4803 [freeIdx ~~ 0 |
4899 [freeIdx ~~ 0 |
4804 and:[(knownIds at:freeIdx) notNil]] whileTrue:[ |
4900 and:[(knownIds at:freeIdx) notNil]] whileTrue:[ |
4805 'XXX ' print. (knownIds at:freeIdx) displayString printCR. |
4901 'XXX ' print. (knownIds at:freeIdx) displayString printCR. |
4806 freeIdx := knownViews identityIndexOf:0 startingAt:(freeIdx + 1). |
4902 freeIdx := knownViews identityIndexOf:0 startingAt:(freeIdx + 1). |
4807 ]. |
4903 ]. |
4808 ]. |
4904 ]. |
4809 ]. |
4905 ]. |
4810 |
4906 |
4811 freeIdx == 0 ifTrue:[ |
4907 freeIdx == 0 ifTrue:[ |
4812 sz := knownViews size. |
4908 sz := knownViews size. |
4813 newSize := sz * 2. |
4909 newSize := sz * 2. |
4814 newArr := WeakArray new:newSize. |
4910 newArr := WeakArray new:newSize. |
4815 newArr replaceFrom:1 to:sz with:knownViews. |
4911 newArr replaceFrom:1 to:sz with:knownViews. |
4816 knownViews := newArr. |
4912 knownViews := newArr. |
4817 |
4913 |
4818 newArr := Array new:newSize. |
4914 newArr := Array new:newSize. |
4819 newArr replaceFrom:1 to:sz with:knownIds. |
4915 newArr replaceFrom:1 to:sz with:knownIds. |
4820 knownIds := newArr. |
4916 knownIds := newArr. |
4821 freeIdx := sz + 1. |
4917 freeIdx := sz + 1. |
4822 ]. |
4918 ]. |
4823 knownViews at:freeIdx put:aView. |
4919 knownViews at:freeIdx put:aView. |
4824 knownIds at:freeIdx put:aWindowID. |
4920 knownIds at:freeIdx put:aWindowID. |
4825 wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
4921 wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
4826 |
4922 |
4827 idToTableIndexMapping notNil ifTrue:[ |
4923 idToTableIndexMapping notNil ifTrue:[ |
4828 idToTableIndexMapping at:aWindowID put:freeIdx. |
4924 idToTableIndexMapping at:aWindowID put:freeIdx. |
4829 ]. |
4925 ]. |
4830 |
4926 |
4831 "/ dispatching ifFalse:[ |
4927 "/ dispatching ifFalse:[ |
4832 "/ self startDispatch |
4928 "/ self startDispatch |
4833 "/ ]. |
4929 "/ ]. |
4842 |
4938 |
4843 lastId := nil. |
4939 lastId := nil. |
4844 lastView := nil. |
4940 lastView := nil. |
4845 |
4941 |
4846 knownViews notNil ifTrue:[ |
4942 knownViews notNil ifTrue:[ |
4847 wasBlocked := OperatingSystem blockInterrupts. |
4943 wasBlocked := OperatingSystem blockInterrupts. |
4848 |
4944 |
4849 index := 0. |
4945 index := 0. |
4850 aViewId notNil ifTrue:[ |
4946 aViewId notNil ifTrue:[ |
4851 idToTableIndexMapping notNil ifTrue:[ |
4947 idToTableIndexMapping notNil ifTrue:[ |
4852 index := idToTableIndexMapping at:aViewId ifAbsent:0. |
4948 index := idToTableIndexMapping at:aViewId ifAbsent:0. |
4853 ] |
4949 ] |
4854 ]. |
4950 ]. |
4855 index == 0 ifTrue:[ |
4951 index == 0 ifTrue:[ |
4856 aView notNil ifTrue:[ |
4952 aView notNil ifTrue:[ |
4857 index := knownViews identityIndexOf:aView. |
4953 index := knownViews identityIndexOf:aView. |
4858 ]. |
4954 ]. |
4859 ]. |
4955 ]. |
4860 |
4956 |
4861 index ~~ 0 ifTrue:[ |
4957 index ~~ 0 ifTrue:[ |
4862 idToTableIndexMapping notNil ifTrue:[ |
4958 idToTableIndexMapping notNil ifTrue:[ |
4863 aViewId notNil ifTrue:[ |
4959 aViewId notNil ifTrue:[ |
4864 idToTableIndexMapping removeKey:aViewId ifAbsent:nil |
4960 idToTableIndexMapping removeKey:aViewId ifAbsent:nil |
4865 ] ifFalse:[ |
4961 ] ifFalse:[ |
4866 id := knownIds at:index. |
4962 id := knownIds at:index. |
4867 id notNil ifTrue:[ |
4963 id notNil ifTrue:[ |
4868 idToTableIndexMapping removeKey:id ifAbsent:nil. |
4964 idToTableIndexMapping removeKey:id ifAbsent:nil. |
4869 ] |
4965 ] |
4870 ] |
4966 ] |
4871 ]. |
4967 ]. |
4872 knownViews at:index put:nil. |
4968 knownViews at:index put:nil. |
4873 knownIds at:index put:nil. |
4969 knownIds at:index put:nil. |
4874 lastId := nil. |
4970 lastId := nil. |
4875 lastView := nil. |
4971 lastView := nil. |
4876 ]. |
4972 ]. |
4877 |
4973 |
4878 wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
4974 wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
4879 |
4975 |
4880 aView notNil ifTrue:[ |
4976 aView notNil ifTrue:[ |
4881 aView isTopView ifTrue:[ |
4977 aView isTopView ifTrue:[ |
4882 "/ check for sparsely filled knownViews - array |
4978 "/ check for sparsely filled knownViews - array |
4883 wasBlocked := OperatingSystem blockInterrupts. |
4979 wasBlocked := OperatingSystem blockInterrupts. |
4884 n := 0. |
4980 n := 0. |
4885 knownViews do:[:v | |
4981 knownViews do:[:v | |
4886 (v notNil and:[v ~~ 0]) ifTrue:[ |
4982 (v notNil and:[v ~~ 0]) ifTrue:[ |
4887 n := n + 1 |
4983 n := n + 1 |
4888 ]. |
4984 ]. |
4889 ]. |
4985 ]. |
4890 n < (knownViews size * 2 // 3) ifTrue:[ |
4986 n < (knownViews size * 2 // 3) ifTrue:[ |
4891 newSize := n * 3 // 2. |
4987 newSize := n * 3 // 2. |
4892 newSize > 50 ifTrue:[ |
4988 newSize > 50 ifTrue:[ |
4893 nV := WeakArray new:newSize. |
4989 nV := WeakArray new:newSize. |
4894 nI := Array new:newSize. |
4990 nI := Array new:newSize. |
4895 dstIdx := 1. |
4991 dstIdx := 1. |
4896 1 to:knownViews size do:[:srcIdx | |
4992 1 to:knownViews size do:[:srcIdx | |
4897 v := knownViews at:srcIdx. |
4993 v := knownViews at:srcIdx. |
4898 (v notNil and:[v ~~ 0]) ifTrue:[ |
4994 (v notNil and:[v ~~ 0]) ifTrue:[ |
4899 nV at:dstIdx put:v. |
4995 nV at:dstIdx put:v. |
4900 nI at:dstIdx put:(knownIds at:srcIdx). |
4996 nI at:dstIdx put:(knownIds at:srcIdx). |
4901 dstIdx := dstIdx + 1. |
4997 dstIdx := dstIdx + 1. |
4902 ]. |
4998 ]. |
4903 ]. |
4999 ]. |
4904 knownViews := nV. |
5000 knownViews := nV. |
4905 knownIds := nI. |
5001 knownIds := nI. |
4906 idToTableIndexMapping := Dictionary new. |
5002 idToTableIndexMapping := Dictionary new. |
4907 knownIds keysAndValuesDo:[:idx :id | |
5003 knownIds keysAndValuesDo:[:idx :id | |
4908 id notNil ifTrue:[ |
5004 id notNil ifTrue:[ |
4909 idToTableIndexMapping at:id put:idx |
5005 idToTableIndexMapping at:id put:idx |
4910 ] |
5006 ] |
4911 ]. |
5007 ]. |
4912 ]. |
5008 ]. |
4913 ]. |
5009 ]. |
4914 wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
5010 wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
4915 ]. |
5011 ]. |
4916 ]. |
5012 ]. |
4917 self checkForEndOfDispatch. |
5013 self checkForEndOfDispatch. |
4918 ] |
5014 ] |
4919 |
5015 |
4920 "Created: 22.3.1997 / 14:56:20 / cg" |
5016 "Created: 22.3.1997 / 14:56:20 / cg" |
4921 "Modified: 27.3.1997 / 17:13:28 / cg" |
5017 "Modified: 27.3.1997 / 17:13:28 / cg" |
4922 ! |
5018 ! |
4925 "given an Id, return the corresponding view." |
5021 "given an Id, return the corresponding view." |
4926 |
5022 |
4927 |index v idx| |
5023 |index v idx| |
4928 |
5024 |
4929 aWindowID = lastId ifTrue:[ |
5025 aWindowID = lastId ifTrue:[ |
4930 lastView notNil ifTrue:[ |
5026 lastView notNil ifTrue:[ |
4931 ^ lastView |
5027 ^ lastView |
4932 ] |
5028 ] |
4933 ]. |
5029 ]. |
4934 |
5030 |
4935 idToTableIndexMapping notNil ifTrue:[ |
5031 idToTableIndexMapping notNil ifTrue:[ |
4936 idx := idToTableIndexMapping at:aWindowID ifAbsent:nil. |
5032 idx := idToTableIndexMapping at:aWindowID ifAbsent:nil. |
4937 idx notNil ifTrue:[ |
5033 idx notNil ifTrue:[ |
4938 v := knownViews at:idx. |
5034 v := knownViews at:idx. |
4939 (v notNil and:[v ~~ 0]) ifTrue:[ |
5035 (v notNil and:[v ~~ 0]) ifTrue:[ |
4940 lastView := v. |
5036 lastView := v. |
4941 lastId := aWindowID. |
5037 lastId := aWindowID. |
4942 ^ v |
5038 ^ v |
4943 ]. |
5039 ]. |
4944 ] |
5040 ] |
4945 ]. |
5041 ]. |
4946 |
5042 |
4947 index := knownIds indexOf:aWindowID. |
5043 index := knownIds indexOf:aWindowID. |
4948 index == 0 ifTrue:[ |
5044 index == 0 ifTrue:[ |
4949 ^ nil |
5045 ^ nil |
4950 ]. |
5046 ]. |
4951 |
5047 |
4952 v := knownViews at:index. |
5048 v := knownViews at:index. |
4953 v == 0 ifTrue:[ |
5049 v == 0 ifTrue:[ |
4954 knownViews at:index put:nil. |
5050 knownViews at:index put:nil. |
4955 knownIds at:index put:nil. |
5051 knownIds at:index put:nil. |
4956 ^ nil |
5052 ^ nil |
4957 ]. |
5053 ]. |
4958 |
5054 |
4959 lastId := aWindowID. |
5055 lastId := aWindowID. |
4960 lastView := v. |
5056 lastView := v. |
4961 |
5057 |