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