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