author | Claus Gittinger <cg@exept.de> |
Sat, 18 May 1996 17:35:59 +0200 | |
changeset 697 | cba925eed3da |
parent 651 | 7e092e7cd4b8 |
child 698 | 3be775ccac3c |
permissions | -rw-r--r-- |
26 | 1 |
" |
2 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
72 | 3 |
All Rights Reserved |
26 | 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 |
" |
|
11 | 12 |
|
13 |
Object subclass:#WindowGroup |
|
317
7a1271ecb987
use new #cursor:now: if many cursors are switched
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
14 |
instanceVariableNames:'views topViews myProcess mySensor isModal previousGroup focusView |
417 | 15 |
focusSequence preEventHook postEventHook pointerView |
16 |
isForModalSubview' |
|
317
7a1271ecb987
use new #cursor:now: if many cursors are switched
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
17 |
classVariableNames:'LastActiveGroup LastActiveProcess LeaveSignal' |
7a1271ecb987
use new #cursor:now: if many cursors are switched
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
18 |
poolDictionaries:'' |
7a1271ecb987
use new #cursor:now: if many cursors are switched
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
19 |
category:'Interface-Support' |
11 | 20 |
! |
21 |
||
46 | 22 |
!WindowGroup class methodsFor:'documentation'! |
23 |
||
24 |
copyright |
|
25 |
" |
|
26 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
72 | 27 |
All Rights Reserved |
46 | 28 |
|
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
37 |
||
38 |
documentation |
|
39 |
" |
|
103 | 40 |
In Smalltalk/X, the known (ST-80) concept of a controller has been |
297 | 41 |
extended (split) into a WindowGroup which handles process related stuff, |
42 |
and the Controller, which only handles events for a view and defines the user interaction. |
|
43 |
All interaction is via event queues - there is no polling in controllers (not even conceptionally). |
|
103 | 44 |
|
45 |
WindowGroups are responsible to wait for and forward events for a group of |
|
297 | 46 |
windows. All views in a windowGroup share a single windowSensor which holds the |
144 | 47 |
event queue (therefore views all share the same input event queue). |
48 |
||
297 | 49 |
The event queues are filled with incoming events as arriving from the physical display. |
50 |
This is done by a separate process (so called event-dispatcher) which runs at a higher |
|
51 |
priority. The event dispatcher determines the queue into which an event has to be placed |
|
52 |
by the view for which the event is destined (via the views sensor). |
|
53 |
There may be multiple event dispatchers running (to support multiple displays); |
|
54 |
see the documentation/examples in DeviceWorkstation/XWorkstation on how this is done. |
|
55 |
||
103 | 56 |
Except for modal boxes, a separate process is created for each windowGroup |
297 | 57 |
which waits for events to arrive and processes them, by sending corresponding |
144 | 58 |
event messages to the views controller or the view (*). |
297 | 59 |
The controller is determined by asking the view (for which the event is destined); |
60 |
if the returned controller is nil, the event is sent directly to the view. |
|
61 |
This allows for simple views to work without a controller. |
|
62 |
(all of this is actually done in a WindowEvent method) |
|
63 |
||
64 |
Therefore, multiple applications run pseudo parallel. |
|
65 |
Even if some window performs a long time computation, events are still received |
|
66 |
and entered into the corresponding event queues (because the event dispatcher process |
|
67 |
runs at a higher priority). However, the actual processing of the event is only |
|
68 |
possibly if no other process is busy at the same or a higher priority. |
|
69 |
It is possible to change a windowProcesses priority in order to give other windows |
|
70 |
a chance to execute (some views do this while performing longtime actions). |
|
71 |
||
103 | 72 |
Modal boxes create an extra window group for the components of the modal |
297 | 73 |
box, but execute the event-processing loop for this new group in the original process - |
144 | 74 |
therefore, the original windowgroup is blocked for the duration of the modal |
297 | 75 |
interaction. |
76 |
However, the modal-event processing loop peeks into the original groups event queue |
|
77 |
from time to time, and handles expose events. Thus, even while blocked for user input, |
|
78 |
the original group continues to get update/redraw events. |
|
103 | 79 |
|
80 |
Normally, one windowgroup is associated to each topview (StandardSystemView) |
|
144 | 81 |
and all of its subviews. However, this is not strictly required; |
82 |
it is possible to create extra windowgroups for subviews, which will let them |
|
83 |
run in parallel |
|
512 | 84 |
(for example, the FileBrowsers kill-Button is created that |
85 |
way, to allow a kill of an executing unix command, while the browser |
|
86 |
itself reads the pipeStream for incoming text. |
|
87 |
Even if the fileBrowser is busy reading the pipe, the killButton is still |
|
88 |
working and allows terminating the pipe-read action). |
|
144 | 89 |
|
90 |
On the other hand, multiple topviews can be placed into the same windowGroup; |
|
91 |
which allows for multiview applications, of which only one communicates with |
|
103 | 92 |
the user at a time. |
297 | 93 |
Multiple topviews within a windowGropup can be configured to behave like one |
94 |
unit with respect to iconification, deiconification and termination. |
|
95 |
This is done by creating multiple topViews in one group, and setting up a master/slave |
|
96 |
or partner relation among them (see TopView>>beSlave and TopView>>bePartner). |
|
103 | 97 |
|
109 | 98 |
WindowGroups also support a focus window: this is the one that gets the |
103 | 99 |
keyboard input - even if the cursor is located in another subview. |
512 | 100 |
The sequence is defined by the topView or its model (typically an applicationModel). |
101 |
It should return an orderedCollection of subviews when asked via #focusSequence. |
|
102 |
||
103 |
For debugging, windowGroups allow hooks to be installed around the processing of |
|
104 |
events - preEventHook is sent a #procesEvent: message before an event is processed, |
|
105 |
postEventHook is informed after the event has been processed. |
|
106 |
The preEventHook should return true - if it returns true, the event is considered |
|
107 |
being already processed by the hook and ignored. |
|
108 |
This allows for event-tracing, timing or even filtering (if preEventHook returns true). |
|
109 |
(notice: there is also an eventHook facility available in the sensor class.) |
|
103 | 110 |
|
111 |
Finally, windowgroups are the perfect place for things like defining a |
|
112 |
cursor for all associated views, flushing all input, waiting for expose |
|
113 |
events etc. |
|
114 |
||
297 | 115 |
Dont get confused: |
512 | 116 |
You dont have to care for details in the normal case, a windowgroup is |
117 |
created for you automatically, when a view is opened. |
|
118 |
All of the internals are not required to be known for most applications. |
|
297 | 119 |
|
103 | 120 |
|
597 | 121 |
[instance variables:] |
144 | 122 |
|
512 | 123 |
views collection of views of this group |
103 | 124 |
|
512 | 125 |
topViews collection of topviews of this group |
103 | 126 |
|
512 | 127 |
myProcess the process executing the events |
103 | 128 |
|
512 | 129 |
mySensor my input sensor |
103 | 130 |
|
512 | 131 |
isModal true if this is for a modal box |
103 | 132 |
|
512 | 133 |
previousGroup if modal, the group that started this one |
103 | 134 |
|
512 | 135 |
focusView the one that has the focus (or nil) |
103 | 136 |
|
512 | 137 |
focusSequence defines the focus sequence |
103 | 138 |
|
139 |
||
597 | 140 |
[class variables:] |
512 | 141 |
LeaveSignal if raised, a modal box leaves (closes) |
103 | 142 |
|
143 |
||
144 | 144 |
(*) |
512 | 145 |
due to historic reasons, many views have the controller functionality |
146 |
integrated, and handle events themself. The windowSensor takes care |
|
147 |
of this, by checking if a view has a controller, and, if so, forwarding |
|
148 |
the events to it. Otherwise, events are sent directly to the view. |
|
144 | 149 |
|
512 | 150 |
In the future, all views will be rewritten to actually use a controller. |
151 |
Currently (being in the middle of this migration), only some views |
|
152 |
(buttons, toggles and subclasses) do so. |
|
144 | 153 |
|
103 | 154 |
For more information, read 'introduction to view programming' in the |
155 |
doc/online directory. |
|
597 | 156 |
|
612 | 157 |
[author:] |
158 |
Claus Gittinger |
|
159 |
||
597 | 160 |
[see also:] |
598 | 161 |
WindowSensor EventListener KeyboardForwarder |
162 |
DeviceWorkstation |
|
597 | 163 |
View StandardSystemView |
164 |
ApplicationModel |
|
651 | 165 |
Process ProcessorScheduler |
166 |
(``Working with processes'': programming/processes.html#VIEWSNPROCS) |
|
46 | 167 |
" |
168 |
! ! |
|
169 |
||
54 | 170 |
!WindowGroup class methodsFor:'initialization'! |
46 | 171 |
|
172 |
initialize |
|
173 |
LeaveSignal isNil ifTrue:[ |
|
72 | 174 |
LeaveSignal := (Signal new) mayProceed:true. |
175 |
LeaveSignal nameClass:self message:#leaveSignal. |
|
176 |
LeaveSignal notifierString:'unhandled leave signal'. |
|
54 | 177 |
]. |
46 | 178 |
|
179 |
"WindowGroup initialize" |
|
180 |
! ! |
|
181 |
||
244 | 182 |
!WindowGroup class methodsFor:'instance creation'! |
183 |
||
184 |
new |
|
185 |
"create and return a new WindowGroup object" |
|
186 |
||
187 |
^ self basicNew initialize |
|
188 |
! ! |
|
189 |
||
144 | 190 |
!WindowGroup class methodsFor:'Signal constants'! |
72 | 191 |
|
192 |
leaveSignal |
|
109 | 193 |
"return the signal which is used to exit a modal loop. |
144 | 194 |
This private signal, is always cought while a modalbox is active. |
195 |
Raising it will exit the modal loop and return from the views #openModal |
|
196 |
method." |
|
109 | 197 |
|
72 | 198 |
^ LeaveSignal |
199 |
! ! |
|
200 |
||
26 | 201 |
!WindowGroup class methodsFor:'accessing'! |
202 |
||
203 |
activeGroup |
|
180 | 204 |
"return the currently active windowGroup. |
205 |
The returned value may not be fully correct, in case the current process |
|
206 |
handles multiple windowGroups simulaniously. In this case, |
|
207 |
the first group is returned (prefering a modal if there is one). |
|
208 |
(maybe we should return a collection of windowGroups here). |
|
209 |
||
210 |
This method is required to simulate the historic ST-80 single display |
|
211 |
behavior for Cursor>>show / Cursor>>showWhile and some others (raising the |
|
212 |
activeGroups topView when modalBoxes appear) on multiple display screens. |
|
213 |
These methods should change the cursor for the currently |
|
214 |
active windowGroup ONLY, instead of globally affecting the display or |
|
215 |
all views |
|
216 |
(since, depending on the priority, other views could be unaffacted by this |
|
217 |
and an overall cursor change does not make sense.)" |
|
218 |
||
219 |
|activeProcess groups wg| |
|
220 |
||
221 |
Processor isNil ifTrue:[^ nil]. "/ only during very early init phase |
|
26 | 222 |
|
180 | 223 |
activeProcess := Processor activeProcess. |
224 |
" caching the last value ..." |
|
565
6867f1a9a470
oops - leftover global LastActive
Claus Gittinger <cg@exept.de>
parents:
513
diff
changeset
|
225 |
activeProcess == LastActiveProcess ifTrue:[ |
6867f1a9a470
oops - leftover global LastActive
Claus Gittinger <cg@exept.de>
parents:
513
diff
changeset
|
226 |
LastActiveGroup process == LastActiveProcess ifTrue:[ |
180 | 227 |
^ LastActiveGroup |
228 |
] |
|
229 |
]. |
|
230 |
groups := self scheduledWindowGroups |
|
231 |
select:[:wg | wg process == activeProcess]. |
|
232 |
groups size == 1 ifTrue:[ |
|
233 |
wg := groups anElement |
|
234 |
] ifFalse:[ |
|
235 |
wg := groups detect:[:wg | wg isModal] ifNone:nil. |
|
236 |
wg isNil ifTrue:[ |
|
237 |
wg := groups anElement |
|
238 |
] |
|
239 |
]. |
|
240 |
wg notNil ifTrue:[ |
|
241 |
LastActiveProcess := activeProcess. |
|
242 |
LastActiveGroup := wg. |
|
243 |
]. |
|
244 |
^ wg |
|
245 |
||
246 |
" |
|
247 |
WindowGroup activeGroup |
|
248 |
" |
|
249 |
||
250 |
"Modified: 3.9.1995 / 14:49:53 / claus" |
|
54 | 251 |
! |
252 |
||
253 |
scheduledWindowGroups |
|
180 | 254 |
"return a collection of all windowGroups (possibly for different |
255 |
display devices) which are scheduled (i.e. which have a process |
|
256 |
running, handling events)." |
|
257 |
||
258 |
|set screens| |
|
259 |
||
260 |
screens := Screen allScreens. |
|
261 |
screens isNil ifTrue:[^ #()]. |
|
262 |
||
263 |
set := IdentitySet new. |
|
264 |
screens do:[:aDevice | |
|
265 |
aDevice allViewsDo:[:aView | |
|
266 |
|wg| |
|
109 | 267 |
|
180 | 268 |
(wg := aView windowGroup) notNil ifTrue:[ |
269 |
wg process notNil ifTrue:[ |
|
270 |
set add:wg |
|
271 |
] |
|
272 |
]. |
|
273 |
]. |
|
274 |
]. |
|
275 |
^ set asArray |
|
276 |
||
277 |
" |
|
278 |
WindowGroup scheduledWindowGroups |
|
279 |
" |
|
280 |
||
281 |
"Modified: 1.9.1995 / 13:43:09 / claus" |
|
244 | 282 |
! |
283 |
||
284 |
setActiveGroup:aGroup |
|
285 |
"set the currently active windowGroup. |
|
286 |
Temporary; do not use this interface, it will vanish." |
|
287 |
||
288 |
LastActiveProcess := Processor activeProcess. |
|
289 |
LastActiveGroup := aGroup |
|
26 | 290 |
! ! |
291 |
||
11 | 292 |
!WindowGroup methodsFor:'accessing'! |
293 |
||
512 | 294 |
device |
295 |
"return the device, we receive our events from" |
|
296 |
||
297 |
(topViews notNil and:[topViews isEmpty not]) ifTrue:[ |
|
298 |
^ topViews first device |
|
299 |
]. |
|
300 |
(views notNil and:[views isEmpty not]) ifTrue:[ |
|
301 |
^ views first device |
|
302 |
]. |
|
303 |
^ nil |
|
304 |
||
305 |
"Created: 13.12.1995 / 14:00:45 / stefan" |
|
306 |
"Modified: 13.12.1995 / 14:18:11 / stefan" |
|
307 |
! |
|
308 |
||
309 |
isModal |
|
310 |
"return true, if the receiver is in a modal mode |
|
311 |
(i.e. for a modal box)" |
|
312 |
||
313 |
^ isModal |
|
314 |
||
315 |
"Modified: 7.3.1996 / 14:29:46 / cg" |
|
316 |
! |
|
317 |
||
318 |
mainGroup |
|
319 |
"return the main windowgroup (for modal groups only) |
|
320 |
that is the top one, which is not modal. |
|
321 |
NonModal groups return themSelf. |
|
322 |
||
323 |
There is one exception to this: the debugger (which is sort of modal) |
|
324 |
returns itself as mainGroup (not its debuggee)." |
|
325 |
||
326 |
|g prev| |
|
327 |
||
328 |
g := self. |
|
329 |
[g notNil and:[g isModal and:[(prev := g previousGroup) notNil]]] whileTrue:[ |
|
330 |
g := prev |
|
331 |
]. |
|
332 |
^ g |
|
333 |
||
334 |
"Modified: 3.9.1995 / 14:57:20 / claus" |
|
335 |
"Modified: 7.3.1996 / 14:29:28 / cg" |
|
336 |
! |
|
337 |
||
338 |
previousGroup |
|
339 |
"return the windowgroup that started this group. (for modal groups only). |
|
340 |
This may be another modalGroup (for boxes opened by boxes). |
|
341 |
NonModal groups return nil." |
|
342 |
||
343 |
^ previousGroup |
|
344 |
||
345 |
"Modified: 7.3.1996 / 14:28:46 / cg" |
|
346 |
! |
|
347 |
||
348 |
process |
|
349 |
"return the windowGroups process" |
|
350 |
||
351 |
^ myProcess |
|
352 |
! |
|
353 |
||
354 |
sensor |
|
355 |
"return the windowGroups sensor. |
|
356 |
All events for any of the groups views is handled by that sensor." |
|
357 |
||
358 |
^ mySensor |
|
359 |
||
360 |
"Modified: 7.3.1996 / 14:30:21 / cg" |
|
361 |
! |
|
362 |
||
363 |
sensor:aSensor |
|
364 |
"set the windowGroups sensor" |
|
365 |
||
366 |
mySensor := aSensor |
|
367 |
! ! |
|
368 |
||
369 |
!WindowGroup methodsFor:'accessing-hook'! |
|
370 |
||
371 |
postEventHook |
|
372 |
"return the postEventHook if any" |
|
373 |
||
374 |
^ postEventHook |
|
375 |
||
376 |
"Created: 7.3.1996 / 14:42:46 / cg" |
|
377 |
! |
|
378 |
||
379 |
postEventHook:anObject |
|
380 |
"set the postEventHook - this one will get all events |
|
381 |
passed after being processed here (via #processEvent:)." |
|
382 |
||
383 |
postEventHook := anObject |
|
384 |
! |
|
385 |
||
386 |
preEventHook |
|
387 |
"return the preEventHook if any" |
|
388 |
||
389 |
^ preEventHook |
|
390 |
||
391 |
"Created: 7.3.1996 / 14:42:42 / cg" |
|
392 |
! |
|
393 |
||
394 |
preEventHook:anObject |
|
395 |
"set the preEventHook - this one will get all events |
|
396 |
passed before being processed here (via #processEvent:). |
|
397 |
If this returns true, the event is supposed to be already |
|
398 |
processed and ignored here. |
|
399 |
Otherwise, it is processed as usual." |
|
400 |
||
401 |
preEventHook := anObject |
|
402 |
! ! |
|
403 |
||
404 |
!WindowGroup methodsFor:'accessing-views'! |
|
405 |
||
244 | 406 |
addTopView:aView |
407 |
"add a topview to the group" |
|
26 | 408 |
|
244 | 409 |
topViews isNil ifTrue:[ |
500
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
410 |
topViews := OrderedCollection new. |
244 | 411 |
]. |
500
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
412 |
(topViews includesIdentical:aView) ifFalse:[ |
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
413 |
topViews add:aView |
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
414 |
] |
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
415 |
|
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
416 |
"Modified: 6.3.1996 / 15:35:15 / cg" |
26 | 417 |
! |
418 |
||
11 | 419 |
addView:aView |
26 | 420 |
"add aView to the windowGroup" |
421 |
||
11 | 422 |
views isNil ifTrue:[ |
500
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
423 |
views := OrderedCollection new. |
11 | 424 |
]. |
500
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
425 |
(views includesIdentical:aView) ifFalse:[ |
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
426 |
views add:aView |
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
427 |
] |
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
428 |
|
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
429 |
"Modified: 6.3.1996 / 15:35:41 / cg" |
11 | 430 |
! |
431 |
||
26 | 432 |
removeView:aView |
433 |
"remove aView from the windowGroup; |
|
434 |
if this was the last view in this group, |
|
81 | 435 |
also shut down the corresponding process |
436 |
(actually, only wake it up here - it will terminate itself |
|
437 |
when finding out that all views are gone)" |
|
11 | 438 |
|
263 | 439 |
|sema| |
440 |
||
11 | 441 |
views notNil ifTrue:[ |
72 | 442 |
views remove:aView ifAbsent:[]. |
443 |
views isEmpty ifTrue:[ |
|
444 |
views := nil |
|
445 |
] |
|
11 | 446 |
]. |
447 |
topViews notNil ifTrue:[ |
|
72 | 448 |
topViews remove:aView ifAbsent:[]. |
449 |
topViews isEmpty ifTrue:[ |
|
450 |
topViews := nil |
|
451 |
] |
|
11 | 452 |
]. |
54 | 453 |
" |
454 |
wakeup my process to look if last view has been |
|
262
546f42586e3c
only signal sema if there is one (when views are removed)
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
455 |
removed (modalBoxes terminate their modalLoop if so) |
54 | 456 |
" |
262
546f42586e3c
only signal sema if there is one (when views are removed)
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
457 |
mySensor notNil ifTrue:[ |
546f42586e3c
only signal sema if there is one (when views are removed)
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
458 |
(sema := mySensor eventSemaphore) notNil ifTrue:[ |
546f42586e3c
only signal sema if there is one (when views are removed)
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
459 |
sema signal |
546f42586e3c
only signal sema if there is one (when views are removed)
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
460 |
] |
546f42586e3c
only signal sema if there is one (when views are removed)
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
461 |
] |
11 | 462 |
! |
463 |
||
244 | 464 |
topViews |
465 |
"return the topviews accociated to this windowGroup" |
|
172 | 466 |
|
244 | 467 |
^ topViews |
172 | 468 |
! |
469 |
||
244 | 470 |
views |
471 |
"return the views accociated to this windowGroup" |
|
172 | 472 |
|
244 | 473 |
^ views |
54 | 474 |
! ! |
475 |
||
244 | 476 |
!WindowGroup methodsFor:'activation / deactivation'! |
477 |
||
478 |
closeDownViews |
|
479 |
"destroy all views associated to this window group" |
|
480 |
||
481 |
topViews notNil ifTrue:[ |
|
403 | 482 |
topViews do:[:aTopView | aTopView notNil ifTrue:[aTopView destroy]] |
244 | 483 |
]. |
484 |
views := nil. |
|
485 |
topViews := nil. |
|
486 |
mySensor := nil. |
|
487 |
! |
|
488 |
||
489 |
realizeTopViews:isRestart |
|
490 |
"realize all topViews associated to this windowGroup. |
|
491 |
If this is a restart, tell topViews about it." |
|
492 |
||
493 |
topViews notNil ifTrue:[ |
|
494 |
topViews do:[:aView | |
|
495 |
aView realize. |
|
496 |
isRestart ifTrue:[ |
|
497 |
aView restarted |
|
498 |
] |
|
499 |
]. |
|
500 |
]. |
|
501 |
! |
|
180 | 502 |
|
244 | 503 |
restart |
504 |
"restart after a snapin." |
|
180 | 505 |
|
244 | 506 |
topViews notNil ifTrue:[ |
507 |
" |
|
508 |
need a new semaphore, since obsolete processes |
|
509 |
(from our previous live) may still sit on the current semaphore |
|
510 |
" |
|
511 |
mySensor eventSemaphore:Semaphore new. |
|
512 |
isModal ifFalse:[ |
|
513 |
self startup:true |
|
514 |
] |
|
515 |
] |
|
516 |
! |
|
180 | 517 |
|
582
dbb1d19a1065
obsolete shutdown (use shutDown)
Claus Gittinger <cg@exept.de>
parents:
565
diff
changeset
|
518 |
shutDown |
dbb1d19a1065
obsolete shutdown (use shutDown)
Claus Gittinger <cg@exept.de>
parents:
565
diff
changeset
|
519 |
"shutdown the window group; close all views and |
244 | 520 |
terminate process" |
521 |
||
522 |
|p| |
|
523 |
||
524 |
self closeDownViews. |
|
525 |
myProcess notNil ifTrue:[ |
|
582
dbb1d19a1065
obsolete shutdown (use shutDown)
Claus Gittinger <cg@exept.de>
parents:
565
diff
changeset
|
526 |
p := myProcess. |
dbb1d19a1065
obsolete shutdown (use shutDown)
Claus Gittinger <cg@exept.de>
parents:
565
diff
changeset
|
527 |
myProcess := nil. |
dbb1d19a1065
obsolete shutdown (use shutDown)
Claus Gittinger <cg@exept.de>
parents:
565
diff
changeset
|
528 |
p terminate. |
244 | 529 |
] |
582
dbb1d19a1065
obsolete shutdown (use shutDown)
Claus Gittinger <cg@exept.de>
parents:
565
diff
changeset
|
530 |
|
dbb1d19a1065
obsolete shutdown (use shutDown)
Claus Gittinger <cg@exept.de>
parents:
565
diff
changeset
|
531 |
"Created: 22.4.1996 / 17:58:37 / cg" |
180 | 532 |
! |
533 |
||
244 | 534 |
startup:isRestart |
535 |
"startup the window-group; |
|
536 |
this creates a new window group process, which |
|
537 |
does the event processing." |
|
538 |
||
539 |
|top nm dev devNm| |
|
540 |
||
541 |
previousGroup := nil. |
|
542 |
myProcess isNil ifTrue:[ |
|
543 |
isModal := false. |
|
544 |
myProcess := [ |
|
545 |
self realizeTopViews:isRestart. |
|
546 |
self eventLoopWhile:[true] onLeave:[] |
|
547 |
] forkAt:Processor userSchedulingPriority. |
|
180 | 548 |
|
244 | 549 |
(topViews notNil and:[topViews isEmpty not]) ifTrue:[ |
550 |
" |
|
551 |
give the handler process a user friendly name |
|
552 |
" |
|
553 |
top := topViews first. |
|
554 |
nm := top processName. |
|
555 |
(dev := top device) notNil ifTrue:[ |
|
556 |
devNm := dev displayName. |
|
557 |
(devNm notNil and:[devNm ~= Display displayName]) ifTrue:[ |
|
558 |
nm := nm , ' (' , devNm , ')' |
|
559 |
] |
|
560 |
] |
|
561 |
] ifFalse:[ |
|
562 |
nm := 'window handler'. |
|
563 |
]. |
|
564 |
myProcess name:nm. |
|
180 | 565 |
|
313 | 566 |
" |
567 |
when the process gets suspended, there maybe still buffered draw requests. |
|
568 |
Flush them. |
|
569 |
" |
|
570 |
myProcess suspendAction:[ |
|
571 |
|dev| |
|
318 | 572 |
dev := self device. |
313 | 573 |
dev notNil ifTrue:[dev flush]. |
574 |
]. |
|
575 |
||
244 | 576 |
"when the process dies, we have to close-down |
577 |
the views as well |
|
578 |
" |
|
579 |
myProcess exitAction:[self closeDownViews] |
|
580 |
] |
|
313 | 581 |
|
582 |
"Modified: 13.12.1995 / 14:04:53 / stefan" |
|
180 | 583 |
! |
584 |
||
244 | 585 |
startupModal:checkBlock |
301
b57451fd8560
passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
586 |
"startup the window-group in a modal loop |
b57451fd8560
passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
587 |
(i.e. under the currently running process); |
b57451fd8560
passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
588 |
checkBlock is evaluated and the modal loop is left, whenever false is returned." |
b57451fd8560
passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
589 |
|
b57451fd8560
passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
590 |
^ self startupModal:checkBlock forGroup:WindowGroup activeGroup. |
b57451fd8560
passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
591 |
|
b57451fd8560
passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
592 |
"Created: 10.12.1995 / 14:15:11 / cg" |
b57451fd8560
passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
593 |
! |
b57451fd8560
passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
594 |
|
b57451fd8560
passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
595 |
startupModal:checkBlock forGroup:mainGroup |
b57451fd8560
passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
596 |
"startup the window-group in a modal loop |
b57451fd8560
passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
597 |
(i.e. under the currently running process); |
244 | 598 |
checkBlock is evaluated and loop is left, when false is |
301
b57451fd8560
passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
599 |
returned. |
b57451fd8560
passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
600 |
The mainGroup info is required to allow peeking into its |
b57451fd8560
passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
601 |
event queue in order for its expose/redraws to be handled." |
244 | 602 |
|
603 |
"set previousGroup to the main (non-modal) group" |
|
180 | 604 |
|
301
b57451fd8560
passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
605 |
previousGroup := mainGroup. |
244 | 606 |
isModal := true. |
607 |
self realizeTopViews:false. |
|
608 |
self |
|
313 | 609 |
eventLoopWhile:checkBlock |
610 |
onLeave:[ |
|
611 |
" |
|
612 |
cleanup, in case of a terminate |
|
613 |
" |
|
614 |
previousGroup := nil. |
|
615 |
topViews := nil. |
|
616 |
views := nil. |
|
617 |
" |
|
618 |
the following is rubbish; |
|
619 |
the views could be reused .. |
|
620 |
" |
|
244 | 621 |
" |
313 | 622 |
topViews notNil ifTrue:[ |
623 |
topViews do:[:aView | |
|
624 |
aView destroy |
|
625 |
]. |
|
626 |
topViews := nil. |
|
627 |
]. |
|
628 |
views notNil ifTrue:[ |
|
629 |
views do:[:aView | |
|
630 |
aView destroy |
|
631 |
]. |
|
632 |
views := nil. |
|
633 |
]. |
|
244 | 634 |
" |
313 | 635 |
] |
301
b57451fd8560
passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
636 |
|
b57451fd8560
passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
637 |
"Created: 10.12.1995 / 14:14:26 / cg" |
180 | 638 |
! ! |
639 |
||
90 | 640 |
!WindowGroup methodsFor:'enumerating'! |
54 | 641 |
|
642 |
allTopViewsExcept:aView do:aBlock |
|
157 | 643 |
"evaluate aBlock for all topviews except aView in this group. |
644 |
This works on a copy of the view collection, to allow for |
|
158 | 645 |
destroy and other collection changing operations to be done." |
157 | 646 |
|
647 |
topViews notNil ifTrue:[ |
|
648 |
topViews copy do:[:v | |
|
649 |
v ~~ aView ifTrue:[aBlock value:v] |
|
650 |
] |
|
651 |
]. |
|
652 |
! |
|
653 |
||
244 | 654 |
allViewsDo:aBlock |
655 |
"evaluate aBlock for all views & topviews in this group. |
|
656 |
This works on a copy of the view collection, to allow for |
|
657 |
destroy and other collection changing operations to be done." |
|
658 |
||
659 |
topViews notNil ifTrue:[topViews copy do:aBlock]. |
|
660 |
views notNil ifTrue:[views copy do:aBlock] |
|
661 |
! |
|
662 |
||
663 |
partnersDo:aBlock |
|
664 |
"evaluate aBlock for all partnerViews. |
|
665 |
This works on a copy of the view collection, to allow for |
|
666 |
destroy and other collection changing operations to be done." |
|
667 |
||
668 |
topViews notNil ifTrue:[ |
|
669 |
topViews copy do:[:v | |
|
670 |
v notNil ifTrue:[ |
|
671 |
v type == #partner ifTrue:[aBlock value:v]. |
|
672 |
] |
|
673 |
] |
|
674 |
]. |
|
675 |
! |
|
676 |
||
157 | 677 |
slavesDo:aBlock |
678 |
"evaluate aBlock for all slaveViews. |
|
679 |
This works on a copy of the view collection, to allow for |
|
158 | 680 |
destroy and other collection changing operations to be done." |
54 | 681 |
|
682 |
topViews notNil ifTrue:[ |
|
157 | 683 |
topViews copy do:[:v | |
684 |
v notNil ifTrue:[ |
|
685 |
v type == #slave ifTrue:[aBlock value:v]. |
|
686 |
] |
|
687 |
] |
|
688 |
]. |
|
11 | 689 |
! ! |
690 |
||
605
20f960026796
convenient interface for eventTracing ; comments & docu
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
691 |
!WindowGroup methodsFor:'event debugging'! |
20f960026796
convenient interface for eventTracing ; comments & docu
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
692 |
|
20f960026796
convenient interface for eventTracing ; comments & docu
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
693 |
traceEvents:trueOrFalse |
20f960026796
convenient interface for eventTracing ; comments & docu
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
694 |
|hook| |
20f960026796
convenient interface for eventTracing ; comments & docu
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
695 |
|
20f960026796
convenient interface for eventTracing ; comments & docu
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
696 |
trueOrFalse ifFalse:[ |
20f960026796
convenient interface for eventTracing ; comments & docu
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
697 |
"/ |
20f960026796
convenient interface for eventTracing ; comments & docu
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
698 |
"/ remove any eventHook on the receiver |
20f960026796
convenient interface for eventTracing ; comments & docu
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
699 |
"/ |
20f960026796
convenient interface for eventTracing ; comments & docu
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
700 |
self preEventHook:nil. |
697 | 701 |
"/ Transcript showCR:'removed eventHook'. |
605
20f960026796
convenient interface for eventTracing ; comments & docu
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
702 |
] ifTrue:[ |
20f960026796
convenient interface for eventTracing ; comments & docu
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
703 |
"/ |
20f960026796
convenient interface for eventTracing ; comments & docu
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
704 |
"/ set an eventHook on its windowGroup |
20f960026796
convenient interface for eventTracing ; comments & docu
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
705 |
"/ |
20f960026796
convenient interface for eventTracing ; comments & docu
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
706 |
hook := Plug new. |
20f960026796
convenient interface for eventTracing ; comments & docu
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
707 |
hook respondTo:#processEvent: |
20f960026796
convenient interface for eventTracing ; comments & docu
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
708 |
with:[:ev | ev displayString printNL. false]. |
20f960026796
convenient interface for eventTracing ; comments & docu
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
709 |
|
20f960026796
convenient interface for eventTracing ; comments & docu
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
710 |
self preEventHook:hook. |
697 | 711 |
"/ Transcript showCR:'set eventHook for tracing'. |
605
20f960026796
convenient interface for eventTracing ; comments & docu
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
712 |
] |
20f960026796
convenient interface for eventTracing ; comments & docu
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
713 |
|
20f960026796
convenient interface for eventTracing ; comments & docu
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
714 |
"Modified: 7.3.1996 / 14:56:49 / cg" |
20f960026796
convenient interface for eventTracing ; comments & docu
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
715 |
"Created: 24.4.1996 / 10:25:21 / cg" |
20f960026796
convenient interface for eventTracing ; comments & docu
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
716 |
! ! |
20f960026796
convenient interface for eventTracing ; comments & docu
Claus Gittinger <cg@exept.de>
parents:
598
diff
changeset
|
717 |
|
19 | 718 |
!WindowGroup methodsFor:'event handling'! |
11 | 719 |
|
244 | 720 |
eventLoop |
721 |
"loop executed by windowGroup process; |
|
722 |
wait-for and process events forever" |
|
723 |
||
724 |
self eventLoopWhile:[true] onLeave:[] |
|
725 |
! |
|
726 |
||
727 |
eventLoopWhile:aBlock onLeave:cleanupActions |
|
513
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
728 |
"wait-for and process events. |
244 | 729 |
Stay in this loop while there are still any views to dispatch for, |
513
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
730 |
and aBlock evaluates to true. |
244 | 731 |
|
513
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
732 |
Some signals are cought & handled: |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
733 |
LeaveSignal forces an exit from the eventLoop; |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
734 |
AbortSignal brings us back into the loop, processing the next event." |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
735 |
|
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
736 |
|thisProcess sigs| |
244 | 737 |
|
738 |
thisProcess := Processor activeProcess. |
|
739 |
||
513
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
740 |
sigs := SignalSet |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
741 |
with:AbortSignal |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
742 |
with:LeaveSignal |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
743 |
with:ActivityNotificationSignal. |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
744 |
|
244 | 745 |
[ |
513
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
746 |
|p g mainGroup mySema waitSema| |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
747 |
|
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
748 |
waitSema := mySema := mySensor eventSemaphore. |
325
b24d9a1c74dc
stefans modalBox changes (no more polling)
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
749 |
|
513
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
750 |
isModal ifTrue:[ |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
751 |
mainGroup := self mainGroup. |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
752 |
mainGroup == self ifTrue:[ |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
753 |
mainGroup := nil |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
754 |
]. |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
755 |
mainGroup notNil ifTrue:[ |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
756 |
waitSema := SemaphoreSet with:mySema |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
757 |
with:(mainGroup sensor eventSemaphore). |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
758 |
]. |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
759 |
]. |
244 | 760 |
|
513
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
761 |
[aBlock value] whileTrue:[ |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
762 |
LastActiveGroup := self. |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
763 |
LastActiveProcess := thisProcess. |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
764 |
|
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
765 |
(views isNil and:[topViews isNil]) ifTrue:[ |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
766 |
myProcess notNil ifTrue:[ |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
767 |
p := myProcess. |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
768 |
myProcess := nil. |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
769 |
p terminate. |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
770 |
"not reached - there is no life after death" |
429 | 771 |
]. |
513
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
772 |
" |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
773 |
this is the end of a modal loop |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
774 |
(not having a private process ...) |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
775 |
" |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
776 |
^ self |
429 | 777 |
]. |
244 | 778 |
|
513
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
779 |
"/ |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
780 |
"/ on abort, stay in the event loop |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
781 |
"/ |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
782 |
sigs handle:[:ex | |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
783 |
|theSig| |
244 | 784 |
|
513
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
785 |
(theSig := ex signal) == AbortSignal ifTrue:[ |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
786 |
"/ |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
787 |
"/ on abort, stay in loop |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
788 |
"/ |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
789 |
ex return |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
790 |
]. |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
791 |
theSig == LeaveSignal ifTrue:[ |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
792 |
"/ |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
793 |
"/ on leave, exit the event loop |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
794 |
"/ |
429 | 795 |
^ self |
796 |
]. |
|
323
619085d52522
be careful - device may be nil
Claus Gittinger <cg@exept.de>
parents:
319
diff
changeset
|
797 |
|
513
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
798 |
"/ ActivityNotification |
429 | 799 |
"/ |
513
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
800 |
"/ if I am a modal-group, let it be handled |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
801 |
"/ by the outer main-groups handler |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
802 |
"/ otherwise show the activityMessage and continue. |
429 | 803 |
"/ |
513
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
804 |
isModal ifTrue:[ |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
805 |
ex reject |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
806 |
"never reached" |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
807 |
]. |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
808 |
self showActivity:(ex errorString). |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
809 |
ex proceed. |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
810 |
] do:[ |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
811 |
|dev gotSema mainView| |
429 | 812 |
|
513
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
813 |
"/ no more events. Flush device output. This may produce more events. |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
814 |
dev := self device. |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
815 |
dev notNil ifTrue:[dev flush]. |
328 | 816 |
|
513
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
817 |
thisProcess setStateTo:#eventWait if:#active. |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
818 |
gotSema := waitSema wait. |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
819 |
LastActiveGroup := self. |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
820 |
LastActiveProcess := thisProcess. |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
821 |
gotSema == mySema ifTrue:[ |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
822 |
self processEvents |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
823 |
] ifFalse:[ |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
824 |
mainGroup topViews notNil ifTrue:[ |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
825 |
mainView := mainGroup topViews first |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
826 |
]. |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
827 |
mainView notNil ifTrue:[ |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
828 |
(mainGroup sensor hasConfigureEventFor:mainView) ifTrue:[ |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
829 |
topViews first raiseDeiconified |
429 | 830 |
] |
513
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
831 |
]. |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
832 |
" |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
833 |
if modal, also check for redraw events in my maingroup |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
834 |
(we arrive here after we woke up on maingroup sensor eventSemaphore) |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
835 |
" |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
836 |
mainGroup processExposeEvents. |
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
837 |
] |
429 | 838 |
]. |
839 |
]. |
|
244 | 840 |
] valueNowOrOnUnwindDo:[ |
429 | 841 |
cleanupActions notNil ifTrue:[cleanupActions value] |
244 | 842 |
] |
313 | 843 |
|
325
b24d9a1c74dc
stefans modalBox changes (no more polling)
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
844 |
"Modified: 14.12.1995 / 11:12:24 / stefan" |
513
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
845 |
"Modified: 7.3.1996 / 17:48:01 / cg" |
244 | 846 |
! |
847 |
||
848 |
leaveEventLoop |
|
849 |
"immediately leave the event loop, returning way back. |
|
850 |
This can be used to leave (and closedown) a modal group. |
|
851 |
(for normal views, this does not make sense)" |
|
852 |
||
853 |
^ LeaveSignal raise |
|
854 |
! |
|
855 |
||
103 | 856 |
processEvents |
857 |
"process events from either the damage- or user input queues. |
|
858 |
Abort is assumed to be handled elsewhere." |
|
19 | 859 |
|
513
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
860 |
<resource: #keyboard (#Escape )> |
496 | 861 |
|
388
64e43f82d93e
Escape leaves modalBoxes or PopUpViews
Claus Gittinger <cg@exept.de>
parents:
387
diff
changeset
|
862 |
|event ignore key| |
11 | 863 |
|
72 | 864 |
self processExposeEvents. |
180 | 865 |
|
72 | 866 |
[mySensor hasEvents] whileTrue:[ |
496 | 867 |
event := mySensor nextEvent. |
868 |
event notNil ifTrue:[ |
|
869 |
(views notNil or:[topViews notNil]) ifTrue:[ |
|
870 |
ignore := false. |
|
172 | 871 |
|
496 | 872 |
(preEventHook notNil |
873 |
and:[preEventHook processEvent:event]) ifTrue:[ |
|
874 |
ignore := true. |
|
875 |
]. |
|
876 |
ignore ifFalse:[ |
|
877 |
event isKeyPressEvent ifTrue:[ |
|
500
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
878 |
key := event key. |
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
879 |
|
496 | 880 |
key == #Escape ifTrue:[ |
881 |
isModal ifTrue:[ |
|
882 |
topViews first hideRequest |
|
883 |
] |
|
884 |
] |
|
885 |
]. |
|
886 |
event isPointerEnterEvent ifTrue:[ |
|
887 |
pointerView := event view |
|
888 |
]. |
|
889 |
event isPointerLeaveEvent ifTrue:[ |
|
890 |
pointerView := nil |
|
891 |
]. |
|
357
3655807445b7
keep track of pointerView, for implizit focus tracking
Claus Gittinger <cg@exept.de>
parents:
330
diff
changeset
|
892 |
|
496 | 893 |
ignore ifFalse:[ |
894 |
"/ |
|
895 |
"/ button events turn off explicit focus, and revert |
|
896 |
"/ to implicit focus control |
|
897 |
"/ |
|
898 |
(focusView notNil |
|
899 |
and:[event isButtonEvent]) ifTrue:[ |
|
900 |
self focusView:nil |
|
901 |
]. |
|
902 |
"/ |
|
903 |
"/ let the event forward itself |
|
904 |
"/ |
|
905 |
LastActiveGroup := self. |
|
906 |
LastActiveProcess := Processor activeProcess. |
|
907 |
event sendEventWithFocusOn:focusView. |
|
908 |
] |
|
909 |
]. |
|
910 |
postEventHook notNil ifTrue:[ |
|
911 |
postEventHook processEvent:event |
|
912 |
] |
|
913 |
] |
|
914 |
]. |
|
72 | 915 |
] |
357
3655807445b7
keep track of pointerView, for implizit focus tracking
Claus Gittinger <cg@exept.de>
parents:
330
diff
changeset
|
916 |
|
513
47b0f4bf4d89
use a single handler for handled signals
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
917 |
"Modified: 7.3.1996 / 17:46:27 / cg" |
48 | 918 |
! |
919 |
||
920 |
processExposeEvents |
|
103 | 921 |
"process only expose events from the damage queue" |
48 | 922 |
|
180 | 923 |
|event view rect x y w h sensor thisProcess| |
109 | 924 |
|
925 |
(sensor := mySensor) isNil ifTrue:[^ self]. |
|
48 | 926 |
|
180 | 927 |
thisProcess := Processor activeProcess. |
928 |
||
929 |
[sensor hasDamage] whileTrue:[ |
|
930 |
LastActiveGroup := self. |
|
931 |
LastActiveProcess := thisProcess. |
|
932 |
||
933 |
event := sensor nextDamage. |
|
934 |
event notNil ifTrue:[ |
|
935 |
(views notNil or:[topViews notNil]) ifTrue:[ |
|
936 |
(preEventHook notNil |
|
937 |
and:[preEventHook processEvent:event]) ifFalse:[ |
|
938 |
event isDamage ifTrue:[ |
|
939 |
view := event view. |
|
940 |
"/ |
|
941 |
"/ if the view is no longer shown (iconified or closed), |
|
942 |
"/ this is a leftover event and ignored. |
|
943 |
"/ |
|
944 |
view shown ifTrue:[ |
|
945 |
rect := event rectangle. |
|
946 |
x := rect left. |
|
947 |
y := rect top. |
|
948 |
w := rect width. |
|
949 |
h := rect height. |
|
950 |
LastActiveGroup := self. |
|
951 |
LastActiveProcess := thisProcess. |
|
952 |
view transformation notNil ifTrue:[ |
|
953 |
view deviceExposeX:x y:y width:w height:h |
|
954 |
] ifFalse:[ |
|
955 |
view exposeX:x y:y width:w height:h |
|
172 | 956 |
] |
81 | 957 |
] |
180 | 958 |
] ifFalse:[ |
959 |
" |
|
960 |
mhmh - could we possibly arrive here ? |
|
961 |
" |
|
962 |
LastActiveGroup := self. |
|
963 |
LastActiveProcess := thisProcess. |
|
964 |
event sendEvent. |
|
78 | 965 |
] |
180 | 966 |
]. |
967 |
postEventHook notNil ifTrue:[ |
|
968 |
postEventHook processEvent:event |
|
72 | 969 |
] |
970 |
] |
|
971 |
] |
|
90 | 972 |
] |
11 | 973 |
! |
974 |
||
28 | 975 |
waitForExposeFor:aView |
500
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
976 |
"wait for a noExpose event for aView, then process all exposes. |
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
977 |
To be used after a scroll. |
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
978 |
This is very Xspecific and not needed with other systems |
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
979 |
(i.e. a synthetic noExpose may be generated there)." |
28 | 980 |
|
981 |
mySensor waitForExposeFor:aView. |
|
90 | 982 |
AbortSignal catch:[ |
500
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
983 |
self processExposeEvents |
90 | 984 |
] |
500
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
985 |
|
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
986 |
"Modified: 6.3.1996 / 15:58:36 / cg" |
11 | 987 |
! ! |
19 | 988 |
|
90 | 989 |
!WindowGroup methodsFor:'focus control'! |
990 |
||
244 | 991 |
focusNext |
500
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
992 |
"give focus to the next view in the focusSequence" |
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
993 |
|
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
994 |
|index last nextTop nextSequence| |
244 | 995 |
|
507
5098d8e9be3c
oops - when asking for focusSequence, take first nonNil collection from any topView
Claus Gittinger <cg@exept.de>
parents:
500
diff
changeset
|
996 |
focusSequence := self focusSequence. |
5098d8e9be3c
oops - when asking for focusSequence, take first nonNil collection from any topView
Claus Gittinger <cg@exept.de>
parents:
500
diff
changeset
|
997 |
(last := focusSequence size) == 0 ifTrue:[^ self]. |
244 | 998 |
|
999 |
focusView notNil ifTrue:[ |
|
500
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
1000 |
index := (focusSequence indexOf:focusView) + 1. |
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
1001 |
index > last ifTrue:[ |
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
1002 |
index := 1. |
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
1003 |
"/ another topView ? |
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
1004 |
"/ topViews size > 1 ifTrue:[ |
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
1005 |
"/ index := topViews identityIndexOf:(focusView topView). |
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
1006 |
"/ (index ~~ 0 and:[index < topViews size]) ifTrue:[ |
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
1007 |
"/ nextTop := topViews at:index+1. |
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
1008 |
"/ nextSequence := nextTop focusSequence. |
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
1009 |
"/ nextSequence size ~~ 0 ifTrue:[ |
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
1010 |
"/ nextTop raiseDeiconified. |
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
1011 |
"/ focusSequence := nextSequence. |
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
1012 |
"/ ] |
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
1013 |
"/ ] |
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
1014 |
"/ ] |
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
1015 |
]. |
244 | 1016 |
] ifFalse:[ |
500
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
1017 |
index := 1. |
244 | 1018 |
]. |
1019 |
self focusView:(focusSequence at:index) |
|
1020 |
||
1021 |
" |
|
1022 |
|top v1 v2| |
|
1023 |
||
1024 |
top := StandardSystemView new. |
|
1025 |
v1 := EditTextView origin:0.0@0.0 corner:1.0@0.5 in:top. |
|
1026 |
v2 := EditTextView origin:0.0@0.5 corner:1.0@1.0 in:top. |
|
1027 |
top open. |
|
1028 |
top windowGroup focusSequence:(Array with:v1 with:v2). |
|
1029 |
top windowGroup focusOn:v1. |
|
1030 |
(Delay forSeconds:10) wait. |
|
1031 |
top windowGroup focusNext. |
|
1032 |
" |
|
500
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
1033 |
|
507
5098d8e9be3c
oops - when asking for focusSequence, take first nonNil collection from any topView
Claus Gittinger <cg@exept.de>
parents:
500
diff
changeset
|
1034 |
"Modified: 6.3.1996 / 17:50:35 / cg" |
244 | 1035 |
! |
1036 |
||
1037 |
focusPrevious |
|
1038 |
"give focus to previous view in focusSequence" |
|
1039 |
||
1040 |
|index| |
|
1041 |
||
507
5098d8e9be3c
oops - when asking for focusSequence, take first nonNil collection from any topView
Claus Gittinger <cg@exept.de>
parents:
500
diff
changeset
|
1042 |
focusSequence := self focusSequence. |
244 | 1043 |
focusSequence size == 0 ifTrue:[^ self]. |
507
5098d8e9be3c
oops - when asking for focusSequence, take first nonNil collection from any topView
Claus Gittinger <cg@exept.de>
parents:
500
diff
changeset
|
1044 |
|
244 | 1045 |
focusView notNil ifTrue:[ |
500
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
1046 |
index := (focusSequence indexOf:focusView) - 1. |
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
1047 |
index < 1 ifTrue:[index := focusSequence size]. |
244 | 1048 |
] ifFalse:[ |
500
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
1049 |
index := focusSequence size. |
244 | 1050 |
]. |
1051 |
self focusView:(focusSequence at:index) |
|
500
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
1052 |
|
507
5098d8e9be3c
oops - when asking for focusSequence, take first nonNil collection from any topView
Claus Gittinger <cg@exept.de>
parents:
500
diff
changeset
|
1053 |
"Modified: 6.3.1996 / 17:50:43 / cg" |
244 | 1054 |
! |
1055 |
||
135 | 1056 |
focusSequence |
500
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
1057 |
"return my focus sequence for focusNext/focusPrevious. |
135 | 1058 |
Focus is stepped in the order in which subviews occur in |
1059 |
the sequence" |
|
1060 |
||
507
5098d8e9be3c
oops - when asking for focusSequence, take first nonNil collection from any topView
Claus Gittinger <cg@exept.de>
parents:
500
diff
changeset
|
1061 |
focusSequence notNil ifTrue:[^ focusSequence]. |
500
a313e9fda9f0
ask topView for focusSequence; focusKey handling now done in TopView/Controller
Claus Gittinger <cg@exept.de>
parents:
496
diff
changeset
|
1062 |
|
507
5098d8e9be3c
oops - when asking for focusSequence, take first nonNil collection from any topView
Claus Gittinger <cg@exept.de>
parents:
500
diff
changeset
|
1063 |
topViews do:[:top | |
5098d8e9be3c
oops - when asking for focusSequence, take first nonNil collection from any topView
Claus Gittinger <cg@exept.de>
parents:
500
diff
changeset
|
1064 |
focusSequence := top focusSequence. |
5098d8e9be3c
oops - when asking for focusSequence, take first nonNil collection from any topView
Claus Gittinger <cg@exept.de>
parents:
500
diff
changeset
|
1065 |
focusSequence notNil ifTrue:[^ focusSequence]. |
5098d8e9be3c
oops - when asking for focusSequence, take first nonNil collection from any topView
Claus Gittinger <cg@exept.de>
parents:
500
diff
changeset
|
1066 |
]. |
5098d8e9be3c
oops - when asking for focusSequence, take first nonNil collection from any topView
Claus Gittinger <cg@exept.de>
parents:
500
diff
changeset
|
1067 |
|
5098d8e9be3c
oops - when asking for focusSequence, take first nonNil collection from any topView
Claus Gittinger <cg@exept.de>
parents:
500
diff
changeset
|
1068 |
^ nil |
5098d8e9be3c
oops - when asking for focusSequence, take first nonNil collection from any topView
Claus Gittinger <cg@exept.de>
parents:
500
diff
changeset
|
1069 |
|
5098d8e9be3c
oops - when asking for focusSequence, take first nonNil collection from any topView
Claus Gittinger <cg@exept.de>
parents:
500
diff
changeset
|
1070 |
"Modified: 6.3.1996 / 17:50:01 / cg" |
135 | 1071 |
! |
1072 |
||
90 | 1073 |
focusSequence:aSequenceableCollection |
1074 |
"define the focus sequence for focusNext/focusPrevious. |
|
1075 |
Focus is stepped in the order in which subviews occur in |
|
1076 |
the sequence" |
|
1077 |
||
1078 |
focusSequence := aSequenceableCollection |
|
1079 |
! |
|
1080 |
||
1081 |
focusView |
|
135 | 1082 |
"return the view which currently has the focus" |
90 | 1083 |
|
1084 |
^ focusView |
|
1085 |
! |
|
1086 |
||
1087 |
focusView:aViewOrNil |
|
1088 |
"give focus to aViewOrNil" |
|
1089 |
||
410
9d9d03fa5d82
moved Tab handling to topView (which sends #focusNext if no subview handled it)
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1090 |
focusView == aViewOrNil ifTrue:[^ self]. |
9d9d03fa5d82
moved Tab handling to topView (which sends #focusNext if no subview handled it)
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1091 |
|
90 | 1092 |
focusView notNil ifTrue:[ |
417 | 1093 |
"/ lost explicit focus |
1094 |
focusView == aViewOrNil ifTrue:[^ self]. |
|
1095 |
focusView showNoFocus:true. |
|
357
3655807445b7
keep track of pointerView, for implizit focus tracking
Claus Gittinger <cg@exept.de>
parents:
330
diff
changeset
|
1096 |
] ifFalse:[ |
417 | 1097 |
pointerView notNil ifTrue:[ |
1098 |
pointerView ~~ aViewOrNil ifTrue:[ |
|
1099 |
"/ lost implicit focus |
|
1100 |
pointerView showNoFocus:false |
|
1101 |
] |
|
1102 |
]. |
|
90 | 1103 |
]. |
387
aa80487842b8
compile event classes with optSpace;
Claus Gittinger <cg@exept.de>
parents:
385
diff
changeset
|
1104 |
|
90 | 1105 |
focusView := aViewOrNil. |
1106 |
focusView notNil ifTrue:[ |
|
417 | 1107 |
"/ got explicit focus |
1108 |
focusView showFocus:true. |
|
90 | 1109 |
]. |
1110 |
||
1111 |
" |
|
1112 |
|top v1 v2| |
|
1113 |
||
1114 |
top := StandardSystemView new. |
|
1115 |
v1 := EditTextView origin:0.0@0.0 corner:1.0@0.5 in:top. |
|
1116 |
v2 := EditTextView origin:0.0@0.5 corner:1.0@1.0 in:top. |
|
1117 |
top open. |
|
1118 |
top windowGroup focusView:v1. |
|
1119 |
" |
|
357
3655807445b7
keep track of pointerView, for implizit focus tracking
Claus Gittinger <cg@exept.de>
parents:
330
diff
changeset
|
1120 |
|
410
9d9d03fa5d82
moved Tab handling to topView (which sends #focusNext if no subview handled it)
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1121 |
"Modified: 7.2.1996 / 13:02:34 / cg" |
244 | 1122 |
! ! |
1123 |
||
1124 |
!WindowGroup methodsFor:'initialization'! |
|
1125 |
||
1126 |
initialize |
|
1127 |
"setup the windowgroup, by creating a new sensor |
|
1128 |
and an event semaphore" |
|
1129 |
||
1130 |
mySensor := WindowSensor new. |
|
1131 |
mySensor eventSemaphore:Semaphore new. |
|
1132 |
isModal := false. |
|
417 | 1133 |
isForModalSubview := false. |
90 | 1134 |
! |
1135 |
||
244 | 1136 |
reinitialize |
1137 |
"reinitialize the windowgroup after an image restart" |
|
90 | 1138 |
|
244 | 1139 |
"throw away old (zombie) process" |
1140 |
myProcess notNil ifTrue:[ |
|
1141 |
"careful: the old processes exitaction must be cleared |
|
1142 |
otherwise, it might do destroy or other actions when it |
|
1143 |
gets finalized ... |
|
1144 |
" |
|
1145 |
myProcess exitAction:nil. |
|
313 | 1146 |
myProcess suspendAction:nil. |
244 | 1147 |
myProcess := nil. |
1148 |
]. |
|
90 | 1149 |
|
244 | 1150 |
"throw away old events" |
1151 |
mySensor reinitialize |
|
313 | 1152 |
|
1153 |
"Modified: 13.12.1995 / 13:45:35 / stefan" |
|
90 | 1154 |
! ! |
1155 |
||
19 | 1156 |
!WindowGroup methodsFor:'printing'! |
1157 |
||
90 | 1158 |
printOn:aStream |
19 | 1159 |
"return a printed representation; |
144 | 1160 |
just for more user friendlyness: add name of process." |
19 | 1161 |
|
90 | 1162 |
myProcess isNil ifTrue:[ |
1163 |
(previousGroup notNil and:[previousGroup process notNil]) ifTrue:[ |
|
1164 |
aStream nextPutAll:('WindowGroup(modal in ' , previousGroup process nameOrId , ')'). |
|
1165 |
^ self. |
|
1166 |
]. |
|
1167 |
^ super printOn:aStream |
|
1168 |
]. |
|
1169 |
aStream nextPutAll:('WindowGroup(' , myProcess nameOrId , ')') |
|
19 | 1170 |
! ! |
244 | 1171 |
|
1172 |
!WindowGroup methodsFor:'special'! |
|
1173 |
||
1174 |
restoreCursors |
|
1175 |
"restore the original cursors in all of my views" |
|
1176 |
||
330
13a3fa93330c
careful - view could have been destroyed in the meanwhile (in restoreCursors)
Claus Gittinger <cg@exept.de>
parents:
329
diff
changeset
|
1177 |
self allViewsDo:[:aView | |
406 | 1178 |
|c dev id cid| |
244 | 1179 |
|
330
13a3fa93330c
careful - view could have been destroyed in the meanwhile (in restoreCursors)
Claus Gittinger <cg@exept.de>
parents:
329
diff
changeset
|
1180 |
dev := aView device. |
13a3fa93330c
careful - view could have been destroyed in the meanwhile (in restoreCursors)
Claus Gittinger <cg@exept.de>
parents:
329
diff
changeset
|
1181 |
dev notNil ifTrue:[ |
13a3fa93330c
careful - view could have been destroyed in the meanwhile (in restoreCursors)
Claus Gittinger <cg@exept.de>
parents:
329
diff
changeset
|
1182 |
(id := aView id) notNil ifTrue:[ |
417 | 1183 |
c := aView cursor on:dev. |
406 | 1184 |
(cid := c id) notNil ifTrue:[ |
1185 |
dev setCursor:cid in:id. |
|
1186 |
] |
|
330
13a3fa93330c
careful - view could have been destroyed in the meanwhile (in restoreCursors)
Claus Gittinger <cg@exept.de>
parents:
329
diff
changeset
|
1187 |
] |
13a3fa93330c
careful - view could have been destroyed in the meanwhile (in restoreCursors)
Claus Gittinger <cg@exept.de>
parents:
329
diff
changeset
|
1188 |
] |
244 | 1189 |
]. |
1190 |
! |
|
1191 |
||
328 | 1192 |
showActivity:someMessage |
597 | 1193 |
"some activityNotification shalt be communicated to |
1194 |
the user; |
|
1195 |
forward it to my first topView if there is one |
|
1196 |
(that one should know how to deal with it)" |
|
1197 |
||
328 | 1198 |
topViews notNil ifTrue:[ |
597 | 1199 |
topViews first showActivity:someMessage |
328 | 1200 |
] |
1201 |
||
1202 |
"Created: 16.12.1995 / 18:39:40 / cg" |
|
597 | 1203 |
"Modified: 23.4.1996 / 21:36:54 / cg" |
328 | 1204 |
! |
1205 |
||
244 | 1206 |
showCursor:aCursor |
1207 |
"change the cursor to aCursor in all of my views." |
|
1208 |
||
406 | 1209 |
|c id dev| |
244 | 1210 |
|
1211 |
c := aCursor. |
|
1212 |
self allViewsDo:[:aView | |
|
406 | 1213 |
c := c on:(dev := aView device). |
1214 |
(id := c id) notNil ifTrue:[ |
|
407 | 1215 |
dev setCursor:id in:aView id. |
406 | 1216 |
] |
244 | 1217 |
]. |
1218 |
! |
|
1219 |
||
1220 |
withCursor:aCursor do:aBlock |
|
1221 |
"evaluate aBlock while showing aCursor in all |
|
1222 |
my views (used to show wait-cursor while doing something). |
|
1223 |
Return the result as returned by aBlock." |
|
1224 |
||
317
7a1271ecb987
use new #cursor:now: if many cursors are switched
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1225 |
|oldCursors dev| |
7a1271ecb987
use new #cursor:now: if many cursors are switched
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1226 |
|
383 | 1227 |
dev := self device. |
317
7a1271ecb987
use new #cursor:now: if many cursors are switched
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1228 |
dev isNil ifTrue:[ |
330
13a3fa93330c
careful - view could have been destroyed in the meanwhile (in restoreCursors)
Claus Gittinger <cg@exept.de>
parents:
329
diff
changeset
|
1229 |
^ aBlock value |
317
7a1271ecb987
use new #cursor:now: if many cursors are switched
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1230 |
]. |
244 | 1231 |
|
1232 |
" |
|
1233 |
get mapping of view->cursor for all of my subviews |
|
1234 |
" |
|
1235 |
oldCursors := IdentityDictionary new. |
|
1236 |
self allViewsDo:[:aView | |
|
330
13a3fa93330c
careful - view could have been destroyed in the meanwhile (in restoreCursors)
Claus Gittinger <cg@exept.de>
parents:
329
diff
changeset
|
1237 |
oldCursors at:aView put:(aView cursor). |
13a3fa93330c
careful - view could have been destroyed in the meanwhile (in restoreCursors)
Claus Gittinger <cg@exept.de>
parents:
329
diff
changeset
|
1238 |
aView cursor:aCursor now:false |
244 | 1239 |
]. |
329
8a34deadc4ff
sync (not flush) after a cursor change
Claus Gittinger <cg@exept.de>
parents:
328
diff
changeset
|
1240 |
"/ |
8a34deadc4ff
sync (not flush) after a cursor change
Claus Gittinger <cg@exept.de>
parents:
328
diff
changeset
|
1241 |
"/ here sync looks better; flush leads to almost invisible cursors when accepting. |
8a34deadc4ff
sync (not flush) after a cursor change
Claus Gittinger <cg@exept.de>
parents:
328
diff
changeset
|
1242 |
"/ I dont really know why (maybe unix does not context-switch to the Xserver |
8a34deadc4ff
sync (not flush) after a cursor change
Claus Gittinger <cg@exept.de>
parents:
328
diff
changeset
|
1243 |
"/ early enough after the requests have been sent ?) |
8a34deadc4ff
sync (not flush) after a cursor change
Claus Gittinger <cg@exept.de>
parents:
328
diff
changeset
|
1244 |
"/ |
8a34deadc4ff
sync (not flush) after a cursor change
Claus Gittinger <cg@exept.de>
parents:
328
diff
changeset
|
1245 |
"/ dev flush. |
8a34deadc4ff
sync (not flush) after a cursor change
Claus Gittinger <cg@exept.de>
parents:
328
diff
changeset
|
1246 |
dev sync. |
244 | 1247 |
|
1248 |
^ aBlock valueNowOrOnUnwindDo:[ |
|
330
13a3fa93330c
careful - view could have been destroyed in the meanwhile (in restoreCursors)
Claus Gittinger <cg@exept.de>
parents:
329
diff
changeset
|
1249 |
" |
13a3fa93330c
careful - view could have been destroyed in the meanwhile (in restoreCursors)
Claus Gittinger <cg@exept.de>
parents:
329
diff
changeset
|
1250 |
restore cursors from the mapping |
13a3fa93330c
careful - view could have been destroyed in the meanwhile (in restoreCursors)
Claus Gittinger <cg@exept.de>
parents:
329
diff
changeset
|
1251 |
" |
13a3fa93330c
careful - view could have been destroyed in the meanwhile (in restoreCursors)
Claus Gittinger <cg@exept.de>
parents:
329
diff
changeset
|
1252 |
oldCursors keysAndValuesDo:[:view :cursor | |
13a3fa93330c
careful - view could have been destroyed in the meanwhile (in restoreCursors)
Claus Gittinger <cg@exept.de>
parents:
329
diff
changeset
|
1253 |
view cursor:cursor now:false. |
13a3fa93330c
careful - view could have been destroyed in the meanwhile (in restoreCursors)
Claus Gittinger <cg@exept.de>
parents:
329
diff
changeset
|
1254 |
]. |
13a3fa93330c
careful - view could have been destroyed in the meanwhile (in restoreCursors)
Claus Gittinger <cg@exept.de>
parents:
329
diff
changeset
|
1255 |
dev flush "/ sync. |
244 | 1256 |
] |
317
7a1271ecb987
use new #cursor:now: if many cursors are switched
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1257 |
|
329
8a34deadc4ff
sync (not flush) after a cursor change
Claus Gittinger <cg@exept.de>
parents:
328
diff
changeset
|
1258 |
"Modified: 17.12.1995 / 15:45:49 / cg" |
408 | 1259 |
! |
1260 |
||
1261 |
withWaitCursorDo:aBlock |
|
1262 |
"evaluate aBlock while showing a waitCursor in all |
|
1263 |
my views (used to show wait-cursor while doing something time consuming). |
|
1264 |
Return the result as returned by aBlock." |
|
1265 |
||
1266 |
^ self withCursor:(Cursor wait) do:aBlock |
|
1267 |
||
1268 |
"Created: 6.2.1996 / 19:51:53 / cg" |
|
244 | 1269 |
! ! |
1270 |
||
1271 |
!WindowGroup methodsFor:'special accessing'! |
|
1272 |
||
429 | 1273 |
isForModalSubview |
1274 |
"special for windowgroups for modal subviews. |
|
1275 |
These must be flagged specially to avoid the views being reassigned |
|
1276 |
to the maingroup. |
|
1277 |
This is a private interface to the SimpleView class" |
|
1278 |
||
1279 |
^ isForModalSubview |
|
1280 |
! |
|
1281 |
||
1282 |
isForModalSubview:aBoolean |
|
1283 |
"special for windowgroups for modal subviews. |
|
1284 |
These must be flagged specially to avoid the views being reassigned |
|
1285 |
to the maingroup. |
|
1286 |
This is a private interface to the SimpleView class" |
|
1287 |
||
1288 |
isForModalSubview := aBoolean |
|
1289 |
! |
|
1290 |
||
244 | 1291 |
setModal:aBoolean |
1292 |
"special entry for debugger: set the modal flag. |
|
1293 |
Not for public use" |
|
1294 |
||
1295 |
isModal := aBoolean |
|
1296 |
||
1297 |
"Modified: 3.9.1995 / 14:51:04 / claus" |
|
1298 |
! |
|
1299 |
||
1300 |
setPreviousGroup:aGroup |
|
1301 |
"special entry for debugger: |
|
1302 |
set the windowgroup that started this group (for modal groups only). |
|
1303 |
This is not a public interface." |
|
1304 |
||
1305 |
previousGroup := aGroup |
|
1306 |
||
1307 |
"Modified: 3.9.1995 / 14:55:40 / claus" |
|
1308 |
! |
|
1309 |
||
1310 |
setProcess:aProcess |
|
1311 |
"special entry for debugger: set the windowGroups process. |
|
1312 |
Not for public use." |
|
1313 |
||
1314 |
myProcess := aProcess |
|
1315 |
||
1316 |
"Modified: 3.9.1995 / 14:25:38 / claus" |
|
1317 |
! ! |
|
1318 |
||
251 | 1319 |
!WindowGroup class methodsFor:'documentation'! |
1320 |
||
1321 |
version |
|
697 | 1322 |
^ '$Header: /cvs/stx/stx/libview/WindowGroup.st,v 1.80 1996-05-18 15:35:10 cg Exp $' |
251 | 1323 |
! ! |
244 | 1324 |
WindowGroup initialize! |