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
|
90
|
14 |
instanceVariableNames:'views topViews myProcess mySensor isModal previousGroup
|
|
15 |
focusView focusSequence'
|
72
|
16 |
classVariableNames:'ActiveGroup ScheduledWindowGroups LeaveSignal'
|
|
17 |
poolDictionaries:''
|
|
18 |
category:'Interface-Support'
|
11
|
19 |
!
|
|
20 |
|
54
|
21 |
WindowGroup comment:'
|
|
22 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
72
|
23 |
All Rights Reserved
|
54
|
24 |
|
112
|
25 |
$Header: /cvs/stx/stx/libview/WindowGroup.st,v 1.21 1995-03-01 00:12:54 claus Exp $
|
54
|
26 |
'!
|
|
27 |
|
46
|
28 |
!WindowGroup class methodsFor:'documentation'!
|
|
29 |
|
|
30 |
copyright
|
|
31 |
"
|
|
32 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
72
|
33 |
All Rights Reserved
|
46
|
34 |
|
|
35 |
This software is furnished under a license and may be used
|
|
36 |
only in accordance with the terms of that license and with the
|
|
37 |
inclusion of the above copyright notice. This software may not
|
|
38 |
be provided or otherwise made available to, or used by, any
|
|
39 |
other person. No title to or ownership of the software is
|
|
40 |
hereby transferred.
|
|
41 |
"
|
|
42 |
!
|
|
43 |
|
|
44 |
version
|
|
45 |
"
|
112
|
46 |
$Header: /cvs/stx/stx/libview/WindowGroup.st,v 1.21 1995-03-01 00:12:54 claus Exp $
|
46
|
47 |
"
|
|
48 |
!
|
|
49 |
|
|
50 |
documentation
|
|
51 |
"
|
103
|
52 |
In Smalltalk/X, the known (ST-80) concept of a controller has been
|
|
53 |
extended to a WindowGroup which handles process related stuff, and
|
109
|
54 |
the Controller, which handles events only and defines the user interaction.
|
103
|
55 |
There is no polling in controllers (not even conceptionally).
|
|
56 |
|
|
57 |
WindowGroups are responsible to wait for and forward events for a group of
|
|
58 |
windows. All views in a group share a single input event queue.
|
|
59 |
Except for modal boxes, a separate process is created for each windowGroup
|
|
60 |
which waits for and forwards them to a controller (*).
|
109
|
61 |
Therefore, multiple applications run in parallel.
|
103
|
62 |
Modal boxes create an extra window group for the components of the modal
|
109
|
63 |
box, but execute in the original process - therefore, the original windowgroup
|
103
|
64 |
is blocked for the duration of the modal interaction.
|
|
65 |
|
|
66 |
Normally, one windowgroup is associated to each topview (StandardSystemView)
|
|
67 |
and all of its subviews. However, this is not required; it is possible
|
|
68 |
to create extra windowgroups for subviews, which will let them run in
|
109
|
69 |
parallel (for example, the FileBrowsers kill Button is created that way,
|
|
70 |
to allow a kill of an executing unix command, while the browser itself
|
|
71 |
reads the pipe for incoming text).
|
103
|
72 |
On the other hand, multiple topviews can be associated in the same windowGroup;
|
|
73 |
this allows for multiview applications, of which only one communicates with
|
|
74 |
the user at a time.
|
109
|
75 |
|
103
|
76 |
Although currently not implemented, it is planned for a future version,
|
|
77 |
to also handle all topviews of a windowgroup as a unit with respect to
|
|
78 |
iconification and deiconification: if any of a windowgroups topviews gets
|
|
79 |
iconified, all others will be as well.
|
|
80 |
|
109
|
81 |
WindowGroups also support a focus window: this is the one that gets the
|
103
|
82 |
keyboard input - even if the cursor is located in another subview.
|
|
83 |
(this is a brand new feature and not yet released for public use)
|
|
84 |
|
|
85 |
Finally, windowgroups are the perfect place for things like defining a
|
|
86 |
cursor for all associated views, flushing all input, waiting for expose
|
|
87 |
events etc.
|
|
88 |
|
|
89 |
You dont have to care for details in the normal case, a windowgroup is
|
|
90 |
created for you automatically, when a view is opened.
|
|
91 |
|
|
92 |
instance variables:
|
|
93 |
views collection of views of this group
|
|
94 |
|
|
95 |
topViews collection of topviews of this group
|
|
96 |
|
|
97 |
myProcess the process executing the events
|
|
98 |
|
|
99 |
mySensor my input sensor
|
|
100 |
|
|
101 |
isModal true if this is for a modal box
|
|
102 |
|
|
103 |
previousGroup if modal, the group that started this one
|
|
104 |
|
|
105 |
focusView the one that has the focus (or nil)
|
|
106 |
|
|
107 |
focusSequence defines the focus sequence
|
|
108 |
|
|
109 |
|
|
110 |
clas variables:
|
|
111 |
LeaveSignal if raised, a modal box leaves (closes)
|
|
112 |
|
|
113 |
ActiveGroup the currently active windowGroup
|
|
114 |
|
|
115 |
ScheduledWindowGroups -- not currently used --
|
|
116 |
|
|
117 |
|
|
118 |
(*) due to historic reasons, many views have the controller functionality
|
|
119 |
integrated, and handle events themself. The windowSensor takes care
|
|
120 |
of this, by checking if a view has a controller, and, if so, forwarding
|
|
121 |
the events to it. Otherwise, events are sent directly to the view.
|
|
122 |
In the future, all views will be rewritten to actually use a controller;
|
|
123 |
currently, only buttons, toggles and subclasses do so.
|
|
124 |
|
|
125 |
For more information, read 'introduction to view programming' in the
|
|
126 |
doc/online directory.
|
46
|
127 |
"
|
|
128 |
! !
|
|
129 |
|
54
|
130 |
!WindowGroup class methodsFor:'initialization'!
|
46
|
131 |
|
|
132 |
initialize
|
|
133 |
LeaveSignal isNil ifTrue:[
|
72
|
134 |
LeaveSignal := (Signal new) mayProceed:true.
|
|
135 |
LeaveSignal nameClass:self message:#leaveSignal.
|
|
136 |
LeaveSignal notifierString:'unhandled leave signal'.
|
|
137 |
"/ ScheduledWindowGroups := IdentitySet new.
|
54
|
138 |
].
|
46
|
139 |
|
|
140 |
"WindowGroup initialize"
|
|
141 |
! !
|
|
142 |
|
72
|
143 |
!WindowGroup class methodsFor:'signal access'!
|
|
144 |
|
|
145 |
leaveSignal
|
109
|
146 |
"return the signal which is used to exit a modal loop.
|
|
147 |
This private signal, is always cought while a modalbox is active."
|
|
148 |
|
72
|
149 |
^ LeaveSignal
|
|
150 |
! !
|
|
151 |
|
11
|
152 |
!WindowGroup class methodsFor:'instance creation'!
|
|
153 |
|
|
154 |
new
|
26
|
155 |
"create and return a new WindowGroup object"
|
|
156 |
|
11
|
157 |
^ self basicNew initialize
|
|
158 |
! !
|
|
159 |
|
26
|
160 |
!WindowGroup class methodsFor:'accessing'!
|
|
161 |
|
|
162 |
activeGroup
|
|
163 |
"return the currently active windowGroup"
|
|
164 |
|
|
165 |
^ ActiveGroup
|
54
|
166 |
!
|
|
167 |
|
|
168 |
scheduledWindowGroups
|
109
|
169 |
"this is not yet implemented"
|
|
170 |
|
54
|
171 |
^ ScheduledWindowGroups
|
26
|
172 |
! !
|
|
173 |
|
11
|
174 |
!WindowGroup methodsFor:'accessing'!
|
|
175 |
|
26
|
176 |
sensor
|
|
177 |
"return the windowGroups sensor"
|
|
178 |
|
|
179 |
^ mySensor
|
|
180 |
!
|
|
181 |
|
11
|
182 |
addView:aView
|
26
|
183 |
"add aView to the windowGroup"
|
|
184 |
|
11
|
185 |
views isNil ifTrue:[
|
72
|
186 |
views := OrderedCollection new.
|
11
|
187 |
].
|
|
188 |
views add:aView
|
|
189 |
!
|
|
190 |
|
54
|
191 |
addTopView:aView
|
|
192 |
"add a topview to the group"
|
|
193 |
|
|
194 |
topViews isNil ifTrue:[
|
72
|
195 |
topViews := OrderedCollection new.
|
54
|
196 |
].
|
|
197 |
topViews add:aView
|
|
198 |
!
|
|
199 |
|
26
|
200 |
removeView:aView
|
|
201 |
"remove aView from the windowGroup;
|
|
202 |
if this was the last view in this group,
|
81
|
203 |
also shut down the corresponding process
|
|
204 |
(actually, only wake it up here - it will terminate itself
|
|
205 |
when finding out that all views are gone)"
|
11
|
206 |
|
|
207 |
views notNil ifTrue:[
|
72
|
208 |
views remove:aView ifAbsent:[].
|
|
209 |
views isEmpty ifTrue:[
|
|
210 |
views := nil
|
|
211 |
]
|
11
|
212 |
].
|
|
213 |
topViews notNil ifTrue:[
|
72
|
214 |
topViews remove:aView ifAbsent:[].
|
|
215 |
topViews isEmpty ifTrue:[
|
|
216 |
topViews := nil
|
|
217 |
]
|
11
|
218 |
].
|
54
|
219 |
"
|
|
220 |
wakeup my process to look if last view has been
|
|
221 |
removed (and terminate if so)
|
|
222 |
"
|
81
|
223 |
mySensor notNil ifTrue:[mySensor eventSemaphore signal]
|
11
|
224 |
!
|
|
225 |
|
|
226 |
views
|
26
|
227 |
"return the views accociated to this windowGroup"
|
|
228 |
|
11
|
229 |
^ views
|
|
230 |
!
|
|
231 |
|
46
|
232 |
topViews
|
|
233 |
"return the topviews accociated to this windowGroup"
|
|
234 |
|
|
235 |
^ topViews
|
|
236 |
!
|
|
237 |
|
11
|
238 |
process
|
26
|
239 |
"return the windowGroups process"
|
|
240 |
|
11
|
241 |
^ myProcess
|
|
242 |
!
|
|
243 |
|
54
|
244 |
isModal
|
103
|
245 |
"return true, if I am in a modal mode"
|
|
246 |
|
54
|
247 |
^ isModal
|
|
248 |
!
|
|
249 |
|
|
250 |
previousGroup
|
|
251 |
"return the windowgroup that started this group.
|
|
252 |
(for modal groups only)"
|
|
253 |
|
|
254 |
^ previousGroup
|
|
255 |
!
|
|
256 |
|
|
257 |
mainGroup
|
|
258 |
"return the main windowgroup (that is the top one,
|
|
259 |
which is not modal)"
|
|
260 |
|
|
261 |
|g|
|
|
262 |
|
|
263 |
g := self.
|
|
264 |
[g notNil and:[g isModal]] whileTrue:[
|
72
|
265 |
g := g previousGroup
|
54
|
266 |
].
|
|
267 |
^ g
|
|
268 |
!
|
|
269 |
|
11
|
270 |
sensor:aSensor
|
26
|
271 |
"set the windowGroups sensor"
|
|
272 |
|
11
|
273 |
mySensor := aSensor
|
54
|
274 |
! !
|
|
275 |
|
90
|
276 |
!WindowGroup methodsFor:'enumerating'!
|
54
|
277 |
|
|
278 |
allViewsDo:aBlock
|
|
279 |
"evaluate aBlock for all views & topviews in this group"
|
|
280 |
|
|
281 |
topViews notNil ifTrue:[topViews do:aBlock].
|
|
282 |
views notNil ifTrue:[views do:aBlock]
|
|
283 |
!
|
|
284 |
|
|
285 |
allTopViewsExcept:aView do:aBlock
|
|
286 |
"evaluate aBlock for all topviews except aView in this group"
|
|
287 |
|
|
288 |
topViews notNil ifTrue:[
|
72
|
289 |
topViews do:[:v |
|
|
290 |
v ~~ aView ifTrue:[aBlock value:v]
|
|
291 |
]
|
54
|
292 |
].
|
|
293 |
! !
|
|
294 |
|
|
295 |
!WindowGroup methodsFor:'special'!
|
|
296 |
|
|
297 |
showCursor:aCursor
|
|
298 |
"change the cursor to aCursor in all of my views"
|
|
299 |
|
|
300 |
|c|
|
|
301 |
|
|
302 |
c := aCursor.
|
|
303 |
self allViewsDo:[:aView |
|
72
|
304 |
c := c on:(aView device).
|
|
305 |
aView device setCursor:c id in:aView id.
|
54
|
306 |
].
|
11
|
307 |
!
|
|
308 |
|
54
|
309 |
restoreCursors
|
|
310 |
"restore the original cursors in all of my views"
|
|
311 |
|
|
312 |
|c|
|
|
313 |
|
|
314 |
self allViewsDo:[:aView |
|
72
|
315 |
c := aView cursor on:(aView device).
|
|
316 |
aView device setCursor:(c id) in:(aView id).
|
11
|
317 |
].
|
54
|
318 |
!
|
|
319 |
|
|
320 |
withCursor:aCursor do:aBlock
|
|
321 |
"evaluate aBlock while showing aCursor in all
|
|
322 |
my views (used to show wait-cursor while doing something)"
|
|
323 |
|
|
324 |
|oldCursors|
|
|
325 |
|
72
|
326 |
"
|
|
327 |
get mapping of view->cursor for all of my subviews
|
|
328 |
"
|
54
|
329 |
oldCursors := IdentityDictionary new.
|
|
330 |
self allViewsDo:[:aView |
|
72
|
331 |
oldCursors at:aView put:(aView cursor).
|
|
332 |
aView cursor:aCursor
|
54
|
333 |
].
|
|
334 |
|
|
335 |
aBlock valueNowOrOnUnwindDo:[
|
72
|
336 |
"
|
|
337 |
restore cursors
|
|
338 |
"
|
|
339 |
oldCursors keysAndValuesDo:[:view :cursor |
|
|
340 |
view cursor:cursor
|
|
341 |
]
|
54
|
342 |
]
|
11
|
343 |
! !
|
|
344 |
|
19
|
345 |
!WindowGroup methodsFor:'event handling'!
|
11
|
346 |
|
103
|
347 |
processEvents
|
|
348 |
"process events from either the damage- or user input queues.
|
|
349 |
Abort is assumed to be handled elsewhere."
|
19
|
350 |
|
90
|
351 |
|event ignore|
|
11
|
352 |
|
72
|
353 |
self processExposeEvents.
|
|
354 |
[mySensor hasEvents] whileTrue:[
|
|
355 |
event := mySensor nextEvent.
|
90
|
356 |
event notNil ifTrue:[
|
112
|
357 |
(views notNil or:[topViews notNil]) ifTrue:[
|
103
|
358 |
"/
|
|
359 |
"/ FocusStepping is done right here
|
|
360 |
"/
|
90
|
361 |
ignore := false.
|
|
362 |
event isKeyPressEvent ifTrue:[
|
|
363 |
event key == #FocusNext ifTrue:[
|
|
364 |
self focusNext.
|
|
365 |
ignore := true
|
|
366 |
].
|
|
367 |
event key == #FocusPrevious ifTrue:[
|
|
368 |
self focusPrevious.
|
|
369 |
ignore := true
|
|
370 |
].
|
|
371 |
].
|
|
372 |
ignore ifFalse:[
|
103
|
373 |
"/
|
|
374 |
"/ button events turn off explicit focus, and revert
|
|
375 |
"/ to implicit focus control
|
|
376 |
"/
|
|
377 |
(focusView notNil
|
|
378 |
and:[event isButtonEvent]) ifTrue:[
|
|
379 |
self focusView:nil
|
|
380 |
].
|
|
381 |
"/
|
|
382 |
"/ let the event forward itself
|
|
383 |
"/
|
|
384 |
event sendEventWithFocusOn:focusView.
|
90
|
385 |
]
|
|
386 |
]
|
72
|
387 |
].
|
|
388 |
]
|
48
|
389 |
!
|
|
390 |
|
|
391 |
processExposeEvents
|
103
|
392 |
"process only expose events from the damage queue"
|
48
|
393 |
|
109
|
394 |
|event view rect oldActive x y w h sensor|
|
|
395 |
|
|
396 |
(sensor := mySensor) isNil ifTrue:[^ self].
|
48
|
397 |
|
|
398 |
oldActive := ActiveGroup.
|
90
|
399 |
[
|
109
|
400 |
[sensor hasDamage] whileTrue:[
|
90
|
401 |
ActiveGroup := self.
|
109
|
402 |
event := sensor nextDamage.
|
90
|
403 |
event notNil ifTrue:[
|
109
|
404 |
(views notNil or:[topViews notNil]) ifTrue:[
|
90
|
405 |
event isDamage ifTrue:[
|
|
406 |
view := event view.
|
103
|
407 |
"/
|
|
408 |
"/ if the view is no longer shown (iconified or closed),
|
|
409 |
"/ this is a leftover event and ignored.
|
|
410 |
"/
|
90
|
411 |
view shown ifTrue:[
|
|
412 |
rect := event rectangle.
|
|
413 |
x := rect left.
|
|
414 |
y := rect top.
|
|
415 |
w := rect width.
|
|
416 |
h := rect height.
|
|
417 |
view transformation notNil ifTrue:[
|
|
418 |
view deviceExposeX:x y:y width:w height:h
|
|
419 |
] ifFalse:[
|
|
420 |
view exposeX:x y:y width:w height:h
|
|
421 |
]
|
81
|
422 |
]
|
90
|
423 |
] ifFalse:[
|
|
424 |
"
|
|
425 |
mhmh - could we possibly arrive here ?
|
|
426 |
"
|
|
427 |
event sendEvent.
|
78
|
428 |
]
|
72
|
429 |
]
|
|
430 |
]
|
|
431 |
]
|
90
|
432 |
] valueNowOrOnUnwindDo:[
|
|
433 |
ActiveGroup := oldActive.
|
|
434 |
oldActive := nil
|
|
435 |
]
|
11
|
436 |
!
|
|
437 |
|
19
|
438 |
eventLoop
|
|
439 |
"loop executed by windowGroup process;
|
|
440 |
wait-for and process events forever"
|
|
441 |
|
23
|
442 |
self eventLoopWhile:[true]
|
|
443 |
!
|
|
444 |
|
|
445 |
eventLoopWhile:aBlock
|
90
|
446 |
"wait-for and process events.
|
|
447 |
Stay in this loop while there are still any views to dispatch for,
|
|
448 |
and aBlock evaluates to true."
|
78
|
449 |
|
90
|
450 |
|oldActive|
|
78
|
451 |
|
90
|
452 |
oldActive := ActiveGroup.
|
109
|
453 |
[
|
90
|
454 |
"/ ScheduledWindowGroups add:self.
|
78
|
455 |
|
109
|
456 |
"/
|
|
457 |
"/ on leave, exit the event loop
|
|
458 |
"/
|
|
459 |
LeaveSignal handle:[:ex |
|
90
|
460 |
ex return
|
|
461 |
] do:[
|
103
|
462 |
|p g mainGroup thisProcess|
|
54
|
463 |
|
90
|
464 |
isModal ifTrue:[
|
|
465 |
mainGroup := self mainGroup.
|
72
|
466 |
].
|
90
|
467 |
|
103
|
468 |
thisProcess := Processor activeProcess.
|
|
469 |
|
90
|
470 |
aBlock whileTrue:[
|
109
|
471 |
ActiveGroup := self.
|
90
|
472 |
(views isNil and:[topViews isNil]) ifTrue:[
|
|
473 |
myProcess notNil ifTrue:[
|
|
474 |
p := myProcess.
|
|
475 |
myProcess := nil.
|
|
476 |
p terminate.
|
|
477 |
"not reached - there is no life after death"
|
103
|
478 |
].
|
|
479 |
"
|
|
480 |
this is the end of a modal loop
|
|
481 |
(not having a private process ...)
|
|
482 |
"
|
|
483 |
^ self
|
72
|
484 |
].
|
|
485 |
|
103
|
486 |
"/
|
|
487 |
"/ on abort, stay in the event loop
|
|
488 |
"/
|
90
|
489 |
AbortSignal handle:[:ex |
|
|
490 |
ex return
|
|
491 |
] do:[
|
|
492 |
"
|
|
493 |
if modal, break out of the wait after some time
|
|
494 |
to allow servicing update-events of the blocked
|
|
495 |
windowgroup.
|
|
496 |
"
|
103
|
497 |
thisProcess setStateTo:#eventWait if:#active.
|
90
|
498 |
isModal ifTrue:[
|
|
499 |
mySensor eventSemaphore waitWithTimeout:0.2.
|
|
500 |
] ifFalse:[
|
|
501 |
mySensor eventSemaphore wait.
|
|
502 |
].
|
|
503 |
ActiveGroup := self.
|
103
|
504 |
self processEvents
|
90
|
505 |
].
|
|
506 |
|
|
507 |
"
|
|
508 |
if modal, also check for redraw events in my maingroup
|
|
509 |
(we arrive here after every event for myself or after the
|
|
510 |
above timeout)
|
|
511 |
"
|
|
512 |
mainGroup notNil ifTrue:[
|
|
513 |
mainGroup processExposeEvents.
|
|
514 |
]
|
103
|
515 |
].
|
90
|
516 |
].
|
109
|
517 |
] valueNowOrOnUnwindDo:[
|
|
518 |
"/ ScheduledWindowGroups remove:self ifAbsent:[].
|
|
519 |
ActiveGroup := oldActive.
|
|
520 |
oldActive := nil.
|
|
521 |
]
|
28
|
522 |
!
|
|
523 |
|
|
524 |
waitForExposeFor:aView
|
|
525 |
"wait for a noExpose on aView, then process all exposes.
|
|
526 |
To be used after a scroll"
|
|
527 |
|
|
528 |
mySensor waitForExposeFor:aView.
|
90
|
529 |
AbortSignal catch:[
|
|
530 |
self processExposeEvents
|
|
531 |
]
|
46
|
532 |
!
|
|
533 |
|
|
534 |
leaveEventLoop
|
103
|
535 |
"immediately leave the event loop, returning way back.
|
|
536 |
This can be used to leave (and closedown) a modal group.
|
|
537 |
(for normal views, this does not make sense)"
|
|
538 |
|
65
|
539 |
^ LeaveSignal raise
|
19
|
540 |
! !
|
|
541 |
|
|
542 |
!WindowGroup methodsFor:'activation / deactivation'!
|
|
543 |
|
46
|
544 |
restart
|
54
|
545 |
"restart after a snapin."
|
46
|
546 |
|
48
|
547 |
topViews notNil ifTrue:[
|
72
|
548 |
"
|
|
549 |
need a new semaphore, since obsolete processes
|
|
550 |
(from our previous live) may still sit on the current semaphore
|
|
551 |
"
|
|
552 |
mySensor eventSemaphore:Semaphore new.
|
|
553 |
isModal ifFalse:[
|
|
554 |
self startup
|
|
555 |
]
|
48
|
556 |
]
|
46
|
557 |
!
|
|
558 |
|
11
|
559 |
startup
|
19
|
560 |
"startup the window-group;
|
|
561 |
this creates a new window group process, which
|
|
562 |
does the event processing."
|
|
563 |
|
23
|
564 |
|nm|
|
|
565 |
|
54
|
566 |
previousGroup := nil.
|
11
|
567 |
myProcess isNil ifTrue:[
|
72
|
568 |
isModal := false.
|
|
569 |
myProcess := [
|
|
570 |
topViews notNil ifTrue:[
|
|
571 |
topViews do:[:aView |
|
|
572 |
aView realize
|
|
573 |
].
|
|
574 |
].
|
|
575 |
self eventLoopWhile:[true]
|
|
576 |
] forkAt:Processor userSchedulingPriority.
|
19
|
577 |
|
72
|
578 |
(topViews notNil and:[topViews isEmpty not]) ifTrue:[
|
|
579 |
"give the handler process a user friendly name"
|
|
580 |
nm := topViews first name.
|
|
581 |
nm isNil ifTrue:[
|
|
582 |
nm := topViews first label.
|
|
583 |
].
|
|
584 |
myProcess name:(topViews first name)
|
|
585 |
] ifFalse:[
|
|
586 |
myProcess name:'window handler'.
|
|
587 |
].
|
19
|
588 |
|
72
|
589 |
"when the process dies, we have to close-down
|
|
590 |
the views as well
|
|
591 |
"
|
|
592 |
myProcess exitAction:[self closeDownViews]
|
11
|
593 |
]
|
|
594 |
!
|
|
595 |
|
48
|
596 |
startupModal:checkBlock
|
|
597 |
"startup the window-group in a modal loop (i.e. under the
|
|
598 |
currently running process);
|
|
599 |
checkBlock is evaluated and loop is left, when false is
|
|
600 |
returned."
|
|
601 |
|
54
|
602 |
"set previousGroup to the main (non-modal) group"
|
|
603 |
|
|
604 |
previousGroup := WindowGroup activeGroup.
|
|
605 |
isModal := true.
|
48
|
606 |
topViews do:[:aView |
|
72
|
607 |
aView realize.
|
48
|
608 |
].
|
81
|
609 |
[
|
|
610 |
self eventLoopWhile:checkBlock.
|
|
611 |
] valueNowOrOnUnwindDo:[
|
|
612 |
"
|
|
613 |
cleanup, in case of a terminate
|
|
614 |
"
|
|
615 |
previousGroup := nil.
|
|
616 |
topViews := nil.
|
|
617 |
views := nil.
|
86
|
618 |
"
|
|
619 |
the following is rubbish;
|
|
620 |
the views could be reused ..
|
|
621 |
"
|
|
622 |
"
|
81
|
623 |
topViews notNil ifTrue:[
|
|
624 |
topViews do:[:aView |
|
|
625 |
aView destroy
|
|
626 |
].
|
86
|
627 |
topViews := nil.
|
81
|
628 |
].
|
|
629 |
views notNil ifTrue:[
|
|
630 |
views do:[:aView |
|
|
631 |
aView destroy
|
86
|
632 |
].
|
|
633 |
views := nil.
|
81
|
634 |
].
|
86
|
635 |
"
|
81
|
636 |
].
|
48
|
637 |
!
|
|
638 |
|
19
|
639 |
closeDownViews
|
|
640 |
"destroy all views associated to this window group"
|
|
641 |
|
11
|
642 |
topViews notNil ifTrue:[
|
72
|
643 |
topViews do:[:aTopView | aTopView destroy]
|
11
|
644 |
].
|
|
645 |
views := nil.
|
|
646 |
topViews := nil.
|
107
|
647 |
mySensor := nil.
|
90
|
648 |
"/ ScheduledWindowGroups remove:self ifAbsent:[].
|
19
|
649 |
!
|
|
650 |
|
|
651 |
shutdown
|
|
652 |
"shutdow the window group; close all views and
|
|
653 |
terminate process"
|
|
654 |
|
46
|
655 |
|p|
|
|
656 |
|
19
|
657 |
self closeDownViews.
|
11
|
658 |
myProcess notNil ifTrue:[
|
72
|
659 |
p := myProcess.
|
|
660 |
myProcess := nil.
|
90
|
661 |
"/ ScheduledWindowGroups remove:self ifAbsent:[].
|
72
|
662 |
p terminate.
|
11
|
663 |
]
|
|
664 |
! !
|
|
665 |
|
|
666 |
!WindowGroup methodsFor:'initialization'!
|
|
667 |
|
|
668 |
reinitialize
|
72
|
669 |
"reinitialize the windowgroup after an image restart"
|
|
670 |
|
19
|
671 |
"throw away old (zombie) process"
|
72
|
672 |
myProcess notNil ifTrue:[
|
|
673 |
"careful: the old processes exitaction must be cleared
|
|
674 |
otherwise, it might do destroy or other actions when it
|
|
675 |
gets finalized ...
|
|
676 |
"
|
|
677 |
myProcess exitAction:nil.
|
|
678 |
myProcess := nil.
|
|
679 |
].
|
19
|
680 |
|
11
|
681 |
"throw away old events"
|
54
|
682 |
mySensor reinitialize
|
11
|
683 |
!
|
|
684 |
|
|
685 |
initialize
|
19
|
686 |
"setup the windowgroup, by creating a new sensor
|
|
687 |
and an event semaphore"
|
|
688 |
|
11
|
689 |
mySensor := WindowSensor new.
|
72
|
690 |
mySensor eventSemaphore:Semaphore new.
|
|
691 |
isModal := false.
|
11
|
692 |
! !
|
19
|
693 |
|
90
|
694 |
!WindowGroup methodsFor:'focus control'!
|
|
695 |
|
|
696 |
focusSequence:aSequenceableCollection
|
|
697 |
"define the focus sequence for focusNext/focusPrevious.
|
|
698 |
Focus is stepped in the order in which subviews occur in
|
|
699 |
the sequence"
|
|
700 |
|
|
701 |
focusSequence := aSequenceableCollection
|
|
702 |
!
|
|
703 |
|
|
704 |
focusView
|
|
705 |
"return the view which has the focus"
|
|
706 |
|
|
707 |
^ focusView
|
|
708 |
!
|
|
709 |
|
|
710 |
focusView:aViewOrNil
|
|
711 |
"give focus to aViewOrNil"
|
|
712 |
|
|
713 |
focusView notNil ifTrue:[
|
|
714 |
focusView focusOut.
|
|
715 |
].
|
|
716 |
focusView := aViewOrNil.
|
|
717 |
focusView notNil ifTrue:[
|
|
718 |
focusView focusIn
|
|
719 |
].
|
|
720 |
|
|
721 |
"
|
|
722 |
|top v1 v2|
|
|
723 |
|
|
724 |
top := StandardSystemView new.
|
|
725 |
v1 := EditTextView origin:0.0@0.0 corner:1.0@0.5 in:top.
|
|
726 |
v2 := EditTextView origin:0.0@0.5 corner:1.0@1.0 in:top.
|
|
727 |
top open.
|
|
728 |
top windowGroup focusView:v1.
|
|
729 |
"
|
|
730 |
!
|
|
731 |
|
|
732 |
focusNext
|
|
733 |
"give focus to next view in focusSequence"
|
|
734 |
|
|
735 |
|index|
|
|
736 |
|
|
737 |
focusSequence isNil ifTrue:[^ self].
|
|
738 |
focusView notNil ifTrue:[
|
|
739 |
index := (focusSequence indexOf:focusView) + 1.
|
|
740 |
index > focusSequence size ifTrue:[index := 1].
|
|
741 |
] ifFalse:[
|
|
742 |
index := 1.
|
|
743 |
].
|
|
744 |
self focusView:(focusSequence at:index)
|
|
745 |
|
|
746 |
"
|
|
747 |
|top v1 v2|
|
|
748 |
|
|
749 |
top := StandardSystemView new.
|
|
750 |
v1 := EditTextView origin:0.0@0.0 corner:1.0@0.5 in:top.
|
|
751 |
v2 := EditTextView origin:0.0@0.5 corner:1.0@1.0 in:top.
|
|
752 |
top open.
|
|
753 |
top windowGroup focusSequence:(Array with:v1 with:v2).
|
|
754 |
top windowGroup focusOn:v1.
|
|
755 |
(Delay forSeconds:10) wait.
|
|
756 |
top windowGroup focusNext.
|
|
757 |
"
|
|
758 |
!
|
|
759 |
|
|
760 |
focusPrevious
|
|
761 |
"give focus to previous view in focusSequence"
|
|
762 |
|
|
763 |
|index|
|
|
764 |
|
|
765 |
focusSequence isNil ifTrue:[^ self].
|
|
766 |
focusView notNil ifTrue:[
|
|
767 |
index := (focusSequence indexOf:focusView) - 1.
|
|
768 |
index < 1 ifTrue:[index := focusSequence size].
|
|
769 |
] ifFalse:[
|
|
770 |
index := focusSequence size.
|
|
771 |
].
|
|
772 |
self focusView:(focusSequence at:index)
|
|
773 |
! !
|
|
774 |
|
19
|
775 |
!WindowGroup methodsFor:'printing'!
|
|
776 |
|
90
|
777 |
printOn:aStream
|
19
|
778 |
"return a printed representation;
|
|
779 |
just for more user friendlyness, add name of process."
|
|
780 |
|
90
|
781 |
myProcess isNil ifTrue:[
|
|
782 |
(previousGroup notNil and:[previousGroup process notNil]) ifTrue:[
|
|
783 |
aStream nextPutAll:('WindowGroup(modal in ' , previousGroup process nameOrId , ')').
|
|
784 |
^ self.
|
|
785 |
].
|
|
786 |
^ super printOn:aStream
|
|
787 |
].
|
|
788 |
aStream nextPutAll:('WindowGroup(' , myProcess nameOrId , ')')
|
19
|
789 |
! !
|