WindowGroup.st
author Claus Gittinger <cg@exept.de>
Fri, 24 Nov 1995 19:36:33 +0100
changeset 263 7b6f806ee693
parent 262 546f42586e3c
child 275 51cf1cb8af5a
permissions -rw-r--r--
oops
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26
ac9f66dc8f53 *** empty log message ***
claus
parents: 23
diff changeset
     1
"
ac9f66dc8f53 *** empty log message ***
claus
parents: 23
diff changeset
     2
 COPYRIGHT (c) 1993 by Claus Gittinger
72
3e84121988c3 *** empty log message ***
claus
parents: 65
diff changeset
     3
	      All Rights Reserved
26
ac9f66dc8f53 *** empty log message ***
claus
parents: 23
diff changeset
     4
ac9f66dc8f53 *** empty log message ***
claus
parents: 23
diff changeset
     5
 This software is furnished under a license and may be used
ac9f66dc8f53 *** empty log message ***
claus
parents: 23
diff changeset
     6
 only in accordance with the terms of that license and with the
ac9f66dc8f53 *** empty log message ***
claus
parents: 23
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
ac9f66dc8f53 *** empty log message ***
claus
parents: 23
diff changeset
     8
 be provided or otherwise made available to, or used by, any
ac9f66dc8f53 *** empty log message ***
claus
parents: 23
diff changeset
     9
 other person.  No title to or ownership of the software is
ac9f66dc8f53 *** empty log message ***
claus
parents: 23
diff changeset
    10
 hereby transferred.
ac9f66dc8f53 *** empty log message ***
claus
parents: 23
diff changeset
    11
"
11
bc3949e465a0 Initial revision
claus
parents:
diff changeset
    12
bc3949e465a0 Initial revision
claus
parents:
diff changeset
    13
Object subclass:#WindowGroup
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
    14
	 instanceVariableNames:'views topViews myProcess mySensor isModal previousGroup focusView
262
546f42586e3c only signal sema if there is one (when views are removed)
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
    15
		focusSequence preEventHook postEventHook'
180
claus
parents: 172
diff changeset
    16
	 classVariableNames:'LastActiveGroup LastActiveProcess LeaveSignal'
72
3e84121988c3 *** empty log message ***
claus
parents: 65
diff changeset
    17
	 poolDictionaries:''
3e84121988c3 *** empty log message ***
claus
parents: 65
diff changeset
    18
	 category:'Interface-Support'
11
bc3949e465a0 Initial revision
claus
parents:
diff changeset
    19
!
bc3949e465a0 Initial revision
claus
parents:
diff changeset
    20
46
7b331e9012fd *** empty log message ***
claus
parents: 28
diff changeset
    21
!WindowGroup class methodsFor:'documentation'!
7b331e9012fd *** empty log message ***
claus
parents: 28
diff changeset
    22
7b331e9012fd *** empty log message ***
claus
parents: 28
diff changeset
    23
copyright
7b331e9012fd *** empty log message ***
claus
parents: 28
diff changeset
    24
"
7b331e9012fd *** empty log message ***
claus
parents: 28
diff changeset
    25
 COPYRIGHT (c) 1993 by Claus Gittinger
72
3e84121988c3 *** empty log message ***
claus
parents: 65
diff changeset
    26
	      All Rights Reserved
46
7b331e9012fd *** empty log message ***
claus
parents: 28
diff changeset
    27
7b331e9012fd *** empty log message ***
claus
parents: 28
diff changeset
    28
 This software is furnished under a license and may be used
7b331e9012fd *** empty log message ***
claus
parents: 28
diff changeset
    29
 only in accordance with the terms of that license and with the
7b331e9012fd *** empty log message ***
claus
parents: 28
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
7b331e9012fd *** empty log message ***
claus
parents: 28
diff changeset
    31
 be provided or otherwise made available to, or used by, any
7b331e9012fd *** empty log message ***
claus
parents: 28
diff changeset
    32
 other person.  No title to or ownership of the software is
7b331e9012fd *** empty log message ***
claus
parents: 28
diff changeset
    33
 hereby transferred.
7b331e9012fd *** empty log message ***
claus
parents: 28
diff changeset
    34
"
7b331e9012fd *** empty log message ***
claus
parents: 28
diff changeset
    35
!
7b331e9012fd *** empty log message ***
claus
parents: 28
diff changeset
    36
7b331e9012fd *** empty log message ***
claus
parents: 28
diff changeset
    37
documentation
7b331e9012fd *** empty log message ***
claus
parents: 28
diff changeset
    38
"
103
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    39
    In Smalltalk/X, the known (ST-80) concept of a controller has been
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    40
    extended to a WindowGroup which handles process related stuff, and
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 107
diff changeset
    41
    the Controller, which handles events only and defines the user interaction.
103
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    42
    There is no polling in controllers (not even conceptionally).
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    43
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    44
    WindowGroups are responsible to wait for and forward events for a group of 
144
claus
parents: 141
diff changeset
    45
    windows. All views in a group share a single windowSensor which holdes the
claus
parents: 141
diff changeset
    46
    event queue (therefore views all share the same input event queue).
claus
parents: 141
diff changeset
    47
103
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    48
    Except for modal boxes, a separate process is created for each windowGroup 
144
claus
parents: 141
diff changeset
    49
    which waits for events and processes them, by sending corresponding
claus
parents: 141
diff changeset
    50
    event messages to the views controller or the view (*). 
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 107
diff changeset
    51
    Therefore, multiple applications run in parallel.
103
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    52
    Modal boxes create an extra window group for the components of the modal
144
claus
parents: 141
diff changeset
    53
    box, but execute the event-processing loop in the original process - 
claus
parents: 141
diff changeset
    54
    therefore, the original windowgroup is blocked for the duration of the modal 
claus
parents: 141
diff changeset
    55
    interaction (**).
103
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    56
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    57
    Normally, one windowgroup is associated to each topview (StandardSystemView)
144
claus
parents: 141
diff changeset
    58
    and all of its subviews. However, this is not strictly required; 
claus
parents: 141
diff changeset
    59
    it is possible to create extra windowgroups for subviews, which will let them
claus
parents: 141
diff changeset
    60
    run in parallel 
claus
parents: 141
diff changeset
    61
	(for example, the FileBrowsers kill Button is created that 
claus
parents: 141
diff changeset
    62
	 way, to allow a kill of an executing unix command, while the browser 
claus
parents: 141
diff changeset
    63
	 itself reads the pipeStream for incoming text).
claus
parents: 141
diff changeset
    64
claus
parents: 141
diff changeset
    65
    On the other hand, multiple topviews can be placed into the same windowGroup;
claus
parents: 141
diff changeset
    66
    which allows for multiview applications, of which only one communicates with
103
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    67
    the user at a time.
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 107
diff changeset
    68
103
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    69
    Although currently not implemented, it is planned for a future version,
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    70
    to also handle all topviews of a windowgroup as a unit with respect to
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    71
    iconification and deiconification: if any of a windowgroups topviews gets
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    72
    iconified, all others will be as well.
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    73
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 107
diff changeset
    74
    WindowGroups also support a focus window: this is the one that gets the
103
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    75
    keyboard input - even if the cursor is located in another subview.
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    76
    (this is a brand new feature and not yet released for public use)
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    77
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    78
    Finally, windowgroups are the perfect place for things like defining a
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    79
    cursor for all associated views, flushing all input, waiting for expose
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    80
    events etc.
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    81
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    82
    You dont have to care for details in the normal case, a windowgroup is
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    83
    created for you automatically, when a view is opened.
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    84
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    85
    instance variables:
144
claus
parents: 141
diff changeset
    86
103
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    87
	views                   collection of views of this group
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    88
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    89
	topViews                collection of topviews of this group
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    90
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    91
	myProcess               the process executing the events
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    92
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    93
	mySensor                my input sensor
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    94
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    95
	isModal                 true if this is for a modal box
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    96
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    97
	previousGroup           if modal, the group that started this one
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    98
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
    99
	focusView               the one that has the focus (or nil)
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
   100
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
   101
	focusSequence           defines the focus sequence
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
   102
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
   103
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
   104
    clas variables:
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
   105
	LeaveSignal             if raised, a modal box leaves (closes)
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
   106
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
   107
144
claus
parents: 141
diff changeset
   108
    (*) 
claus
parents: 141
diff changeset
   109
	due to historic reasons, many views have the controller functionality
103
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
   110
	integrated, and handle events themself. The windowSensor takes care
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
   111
	of this, by checking if a view has a controller, and, if so, forwarding 
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
   112
	the events to it. Otherwise, events are sent directly to the view.
144
claus
parents: 141
diff changeset
   113
claus
parents: 141
diff changeset
   114
	In the future, all views will be rewritten to actually use a controller.
claus
parents: 141
diff changeset
   115
	Currently (being in the middle of this migration), only some views
claus
parents: 141
diff changeset
   116
	(buttons, toggles and subclasses) do so.
claus
parents: 141
diff changeset
   117
claus
parents: 141
diff changeset
   118
    (**)
claus
parents: 141
diff changeset
   119
	the modal-event loop peeks into the original groups damage queue
claus
parents: 141
diff changeset
   120
	in regular time intervals - therefore, view updating is still done in
claus
parents: 141
diff changeset
   121
	the blocked group.
103
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
   122
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
   123
    For more information, read 'introduction to view programming' in the
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
   124
    doc/online directory.
46
7b331e9012fd *** empty log message ***
claus
parents: 28
diff changeset
   125
"
7b331e9012fd *** empty log message ***
claus
parents: 28
diff changeset
   126
! !
7b331e9012fd *** empty log message ***
claus
parents: 28
diff changeset
   127
54
29a6b2f8e042 *** empty log message ***
claus
parents: 48
diff changeset
   128
!WindowGroup class methodsFor:'initialization'!
46
7b331e9012fd *** empty log message ***
claus
parents: 28
diff changeset
   129
7b331e9012fd *** empty log message ***
claus
parents: 28
diff changeset
   130
initialize
7b331e9012fd *** empty log message ***
claus
parents: 28
diff changeset
   131
    LeaveSignal isNil ifTrue:[
72
3e84121988c3 *** empty log message ***
claus
parents: 65
diff changeset
   132
	LeaveSignal := (Signal new) mayProceed:true.
3e84121988c3 *** empty log message ***
claus
parents: 65
diff changeset
   133
	LeaveSignal nameClass:self message:#leaveSignal.
3e84121988c3 *** empty log message ***
claus
parents: 65
diff changeset
   134
	LeaveSignal notifierString:'unhandled leave signal'.
54
29a6b2f8e042 *** empty log message ***
claus
parents: 48
diff changeset
   135
    ].
46
7b331e9012fd *** empty log message ***
claus
parents: 28
diff changeset
   136
7b331e9012fd *** empty log message ***
claus
parents: 28
diff changeset
   137
    "WindowGroup initialize"
7b331e9012fd *** empty log message ***
claus
parents: 28
diff changeset
   138
! !
7b331e9012fd *** empty log message ***
claus
parents: 28
diff changeset
   139
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   140
!WindowGroup class methodsFor:'instance creation'!
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   141
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   142
new
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   143
    "create and return a new WindowGroup object"
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   144
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   145
    ^ self basicNew initialize
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   146
! !
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   147
144
claus
parents: 141
diff changeset
   148
!WindowGroup class methodsFor:'Signal constants'!
72
3e84121988c3 *** empty log message ***
claus
parents: 65
diff changeset
   149
3e84121988c3 *** empty log message ***
claus
parents: 65
diff changeset
   150
leaveSignal
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 107
diff changeset
   151
    "return the signal which is used to exit a modal loop.
144
claus
parents: 141
diff changeset
   152
     This private signal, is always cought while a modalbox is active.
claus
parents: 141
diff changeset
   153
     Raising it will exit the modal loop and return from the views #openModal
claus
parents: 141
diff changeset
   154
     method."
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 107
diff changeset
   155
72
3e84121988c3 *** empty log message ***
claus
parents: 65
diff changeset
   156
    ^ LeaveSignal
3e84121988c3 *** empty log message ***
claus
parents: 65
diff changeset
   157
! !
3e84121988c3 *** empty log message ***
claus
parents: 65
diff changeset
   158
26
ac9f66dc8f53 *** empty log message ***
claus
parents: 23
diff changeset
   159
!WindowGroup class methodsFor:'accessing'!
ac9f66dc8f53 *** empty log message ***
claus
parents: 23
diff changeset
   160
ac9f66dc8f53 *** empty log message ***
claus
parents: 23
diff changeset
   161
activeGroup
180
claus
parents: 172
diff changeset
   162
    "return the currently active windowGroup.
claus
parents: 172
diff changeset
   163
     The returned value may not be fully correct, in case the current process
claus
parents: 172
diff changeset
   164
     handles multiple windowGroups simulaniously. In this case, 
claus
parents: 172
diff changeset
   165
     the first group is returned (prefering a modal if there is one). 
claus
parents: 172
diff changeset
   166
     (maybe we should return a collection of windowGroups here).
claus
parents: 172
diff changeset
   167
claus
parents: 172
diff changeset
   168
     This method is required to simulate the historic ST-80 single display
claus
parents: 172
diff changeset
   169
     behavior for Cursor>>show / Cursor>>showWhile and some others (raising the
claus
parents: 172
diff changeset
   170
     activeGroups topView when modalBoxes appear) on multiple display screens. 
claus
parents: 172
diff changeset
   171
     These methods should change the cursor for the currently 
claus
parents: 172
diff changeset
   172
     active windowGroup ONLY, instead of globally affecting the display or
claus
parents: 172
diff changeset
   173
     all views
claus
parents: 172
diff changeset
   174
     (since, depending on the priority, other views could be unaffacted by this 
claus
parents: 172
diff changeset
   175
      and an overall cursor change does not make sense.)"
claus
parents: 172
diff changeset
   176
claus
parents: 172
diff changeset
   177
    |activeProcess groups wg|
claus
parents: 172
diff changeset
   178
claus
parents: 172
diff changeset
   179
    Processor isNil ifTrue:[^ nil]. "/ only during very early init phase
26
ac9f66dc8f53 *** empty log message ***
claus
parents: 23
diff changeset
   180
180
claus
parents: 172
diff changeset
   181
    activeProcess := Processor activeProcess.
claus
parents: 172
diff changeset
   182
    " caching the last value ..."
claus
parents: 172
diff changeset
   183
    activeProcess == LastActive ifTrue:[
claus
parents: 172
diff changeset
   184
	LastActiveGroup process == LastActive ifTrue:[
claus
parents: 172
diff changeset
   185
	    ^ LastActiveGroup
claus
parents: 172
diff changeset
   186
	]
claus
parents: 172
diff changeset
   187
    ].
claus
parents: 172
diff changeset
   188
    groups := self scheduledWindowGroups 
claus
parents: 172
diff changeset
   189
		select:[:wg | wg process == activeProcess].
claus
parents: 172
diff changeset
   190
    groups size == 1 ifTrue:[
claus
parents: 172
diff changeset
   191
	wg := groups anElement
claus
parents: 172
diff changeset
   192
    ] ifFalse:[
claus
parents: 172
diff changeset
   193
	wg := groups detect:[:wg | wg isModal] ifNone:nil.
claus
parents: 172
diff changeset
   194
	wg isNil ifTrue:[
claus
parents: 172
diff changeset
   195
	    wg := groups anElement
claus
parents: 172
diff changeset
   196
	]
claus
parents: 172
diff changeset
   197
    ].
claus
parents: 172
diff changeset
   198
    wg notNil ifTrue:[
claus
parents: 172
diff changeset
   199
	LastActiveProcess := activeProcess.
claus
parents: 172
diff changeset
   200
	LastActiveGroup := wg.
claus
parents: 172
diff changeset
   201
    ].
claus
parents: 172
diff changeset
   202
    ^ wg
claus
parents: 172
diff changeset
   203
claus
parents: 172
diff changeset
   204
    "
claus
parents: 172
diff changeset
   205
     WindowGroup activeGroup 
claus
parents: 172
diff changeset
   206
    "
claus
parents: 172
diff changeset
   207
claus
parents: 172
diff changeset
   208
    "Modified: 3.9.1995 / 14:49:53 / claus"
54
29a6b2f8e042 *** empty log message ***
claus
parents: 48
diff changeset
   209
!
29a6b2f8e042 *** empty log message ***
claus
parents: 48
diff changeset
   210
29a6b2f8e042 *** empty log message ***
claus
parents: 48
diff changeset
   211
scheduledWindowGroups
180
claus
parents: 172
diff changeset
   212
    "return a collection of all windowGroups (possibly for different
claus
parents: 172
diff changeset
   213
     display devices) which are scheduled (i.e. which have a process 
claus
parents: 172
diff changeset
   214
     running, handling events)."
claus
parents: 172
diff changeset
   215
claus
parents: 172
diff changeset
   216
    |set screens|
claus
parents: 172
diff changeset
   217
claus
parents: 172
diff changeset
   218
    screens := Screen allScreens.
claus
parents: 172
diff changeset
   219
    screens isNil ifTrue:[^ #()].
claus
parents: 172
diff changeset
   220
claus
parents: 172
diff changeset
   221
    set := IdentitySet new.
claus
parents: 172
diff changeset
   222
    screens do:[:aDevice |
claus
parents: 172
diff changeset
   223
	aDevice allViewsDo:[:aView |
claus
parents: 172
diff changeset
   224
	    |wg|
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 107
diff changeset
   225
180
claus
parents: 172
diff changeset
   226
	    (wg := aView windowGroup) notNil ifTrue:[
claus
parents: 172
diff changeset
   227
		wg process notNil ifTrue:[
claus
parents: 172
diff changeset
   228
		    set add:wg
claus
parents: 172
diff changeset
   229
		]
claus
parents: 172
diff changeset
   230
	    ].
claus
parents: 172
diff changeset
   231
	].
claus
parents: 172
diff changeset
   232
    ].
claus
parents: 172
diff changeset
   233
    ^ set asArray
claus
parents: 172
diff changeset
   234
claus
parents: 172
diff changeset
   235
    "
claus
parents: 172
diff changeset
   236
     WindowGroup scheduledWindowGroups   
claus
parents: 172
diff changeset
   237
    "
claus
parents: 172
diff changeset
   238
claus
parents: 172
diff changeset
   239
    "Modified: 1.9.1995 / 13:43:09 / claus"
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   240
!
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   241
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   242
setActiveGroup:aGroup
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   243
    "set the currently active windowGroup.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   244
     Temporary; do not use this interface, it will vanish."
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   245
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   246
    LastActiveProcess := Processor activeProcess.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   247
    LastActiveGroup := aGroup
26
ac9f66dc8f53 *** empty log message ***
claus
parents: 23
diff changeset
   248
! !
ac9f66dc8f53 *** empty log message ***
claus
parents: 23
diff changeset
   249
11
bc3949e465a0 Initial revision
claus
parents:
diff changeset
   250
!WindowGroup methodsFor:'accessing'!
bc3949e465a0 Initial revision
claus
parents:
diff changeset
   251
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   252
addTopView:aView
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   253
    "add a topview to the group"
26
ac9f66dc8f53 *** empty log message ***
claus
parents: 23
diff changeset
   254
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   255
    topViews isNil ifTrue:[
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   256
	topViews := OrderedCollection new.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   257
    ].
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   258
    topViews add:aView
26
ac9f66dc8f53 *** empty log message ***
claus
parents: 23
diff changeset
   259
!
ac9f66dc8f53 *** empty log message ***
claus
parents: 23
diff changeset
   260
11
bc3949e465a0 Initial revision
claus
parents:
diff changeset
   261
addView:aView
26
ac9f66dc8f53 *** empty log message ***
claus
parents: 23
diff changeset
   262
    "add aView to the windowGroup"
ac9f66dc8f53 *** empty log message ***
claus
parents: 23
diff changeset
   263
11
bc3949e465a0 Initial revision
claus
parents:
diff changeset
   264
    views isNil ifTrue:[
72
3e84121988c3 *** empty log message ***
claus
parents: 65
diff changeset
   265
	views := OrderedCollection new.
11
bc3949e465a0 Initial revision
claus
parents:
diff changeset
   266
    ].
bc3949e465a0 Initial revision
claus
parents:
diff changeset
   267
    views add:aView
bc3949e465a0 Initial revision
claus
parents:
diff changeset
   268
!
bc3949e465a0 Initial revision
claus
parents:
diff changeset
   269
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   270
isModal
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   271
    "return true, if I am in a modal mode"
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   272
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   273
    ^ isModal
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   274
!
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   275
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   276
mainGroup
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   277
    "return the main windowgroup 
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   278
     (that is the top one, which is not modal).
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   279
     There is one exception to this: the debugger (which is sort of modal)
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   280
     returns itself as mainGroup (not its debuggee)."
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   281
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   282
    |g prev|
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   283
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   284
    g := self.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   285
    [g notNil and:[g isModal and:[(prev := g previousGroup) notNil]]] whileTrue:[
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   286
	g := prev
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   287
    ].
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   288
    ^ g
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   289
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   290
    "Modified: 3.9.1995 / 14:57:20 / claus"
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   291
!
54
29a6b2f8e042 *** empty log message ***
claus
parents: 48
diff changeset
   292
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   293
postEventHook:anObject 
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   294
    "set the postEventHook - this one will get all events
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   295
     passed after being processed here (via #processEvent:)."
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   296
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   297
    postEventHook := anObject
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   298
!
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   299
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   300
preEventHook:anObject 
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   301
    "set the preEventHook - this one will get all events
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   302
     passed before being processed here (via #processEvent:).
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   303
     If this returns true, the event is supposed to be already
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   304
     processed and ignored here.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   305
     Otherwise, it is processed as usual."
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   306
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   307
    preEventHook := anObject
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   308
!
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   309
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   310
previousGroup
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   311
    "return the windowgroup that started this group.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   312
     (for modal groups only)"
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   313
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   314
    ^ previousGroup
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   315
!
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   316
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   317
process 
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   318
    "return the windowGroups process"
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   319
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   320
    ^ myProcess
54
29a6b2f8e042 *** empty log message ***
claus
parents: 48
diff changeset
   321
!
29a6b2f8e042 *** empty log message ***
claus
parents: 48
diff changeset
   322
26
ac9f66dc8f53 *** empty log message ***
claus
parents: 23
diff changeset
   323
removeView:aView
ac9f66dc8f53 *** empty log message ***
claus
parents: 23
diff changeset
   324
    "remove aView from the windowGroup;
ac9f66dc8f53 *** empty log message ***
claus
parents: 23
diff changeset
   325
     if this was the last view in this group, 
81
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
   326
     also shut down the corresponding process 
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
   327
     (actually, only wake it up here - it will terminate itself 
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
   328
      when finding out that all views are gone)"
11
bc3949e465a0 Initial revision
claus
parents:
diff changeset
   329
263
Claus Gittinger <cg@exept.de>
parents: 262
diff changeset
   330
    |sema|
Claus Gittinger <cg@exept.de>
parents: 262
diff changeset
   331
11
bc3949e465a0 Initial revision
claus
parents:
diff changeset
   332
    views notNil ifTrue:[
72
3e84121988c3 *** empty log message ***
claus
parents: 65
diff changeset
   333
	views remove:aView ifAbsent:[].
3e84121988c3 *** empty log message ***
claus
parents: 65
diff changeset
   334
	views isEmpty ifTrue:[
3e84121988c3 *** empty log message ***
claus
parents: 65
diff changeset
   335
	    views := nil
3e84121988c3 *** empty log message ***
claus
parents: 65
diff changeset
   336
	]
11
bc3949e465a0 Initial revision
claus
parents:
diff changeset
   337
    ].
bc3949e465a0 Initial revision
claus
parents:
diff changeset
   338
    topViews notNil ifTrue:[
72
3e84121988c3 *** empty log message ***
claus
parents: 65
diff changeset
   339
	topViews remove:aView ifAbsent:[].
3e84121988c3 *** empty log message ***
claus
parents: 65
diff changeset
   340
	topViews isEmpty ifTrue:[
3e84121988c3 *** empty log message ***
claus
parents: 65
diff changeset
   341
	    topViews := nil
3e84121988c3 *** empty log message ***
claus
parents: 65
diff changeset
   342
	]
11
bc3949e465a0 Initial revision
claus
parents:
diff changeset
   343
    ].
54
29a6b2f8e042 *** empty log message ***
claus
parents: 48
diff changeset
   344
    "
29a6b2f8e042 *** empty log message ***
claus
parents: 48
diff changeset
   345
     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
   346
     removed (modalBoxes terminate their modalLoop if so)
54
29a6b2f8e042 *** empty log message ***
claus
parents: 48
diff changeset
   347
    "
262
546f42586e3c only signal sema if there is one (when views are removed)
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   348
    mySensor notNil ifTrue:[
546f42586e3c only signal sema if there is one (when views are removed)
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   349
	(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
   350
	    sema signal
546f42586e3c only signal sema if there is one (when views are removed)
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   351
	]
546f42586e3c only signal sema if there is one (when views are removed)
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   352
    ]
11
bc3949e465a0 Initial revision
claus
parents:
diff changeset
   353
!
bc3949e465a0 Initial revision
claus
parents:
diff changeset
   354
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   355
sensor
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   356
    "return the windowGroups sensor"
103
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
   357
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   358
    ^ mySensor
54
29a6b2f8e042 *** empty log message ***
claus
parents: 48
diff changeset
   359
!
29a6b2f8e042 *** empty log message ***
claus
parents: 48
diff changeset
   360
11
bc3949e465a0 Initial revision
claus
parents:
diff changeset
   361
sensor:aSensor
26
ac9f66dc8f53 *** empty log message ***
claus
parents: 23
diff changeset
   362
    "set the windowGroups sensor"
ac9f66dc8f53 *** empty log message ***
claus
parents: 23
diff changeset
   363
11
bc3949e465a0 Initial revision
claus
parents:
diff changeset
   364
    mySensor := aSensor
172
claus
parents: 162
diff changeset
   365
!
claus
parents: 162
diff changeset
   366
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   367
topViews
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   368
    "return the topviews accociated to this windowGroup"
172
claus
parents: 162
diff changeset
   369
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   370
    ^ topViews
172
claus
parents: 162
diff changeset
   371
!
claus
parents: 162
diff changeset
   372
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   373
views
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   374
    "return the views accociated to this windowGroup"
172
claus
parents: 162
diff changeset
   375
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   376
    ^ views
54
29a6b2f8e042 *** empty log message ***
claus
parents: 48
diff changeset
   377
! !
29a6b2f8e042 *** empty log message ***
claus
parents: 48
diff changeset
   378
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   379
!WindowGroup methodsFor:'activation / deactivation'!
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   380
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   381
closeDownViews
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   382
    "destroy all views associated to this window group"
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   383
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   384
    topViews notNil ifTrue:[
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   385
	topViews do:[:aTopView | aTopView destroy]
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   386
    ].
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   387
    views := nil.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   388
    topViews := nil.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   389
    mySensor := nil.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   390
!
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   391
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   392
realizeTopViews:isRestart
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   393
    "realize all topViews associated to this windowGroup.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   394
     If this is a restart, tell topViews about it."
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   395
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   396
    topViews notNil ifTrue:[
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   397
	topViews do:[:aView |
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   398
	    aView realize.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   399
	    isRestart ifTrue:[
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   400
		aView restarted
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   401
	    ]
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   402
	].
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   403
    ].
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   404
!
180
claus
parents: 172
diff changeset
   405
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   406
restart
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   407
    "restart after a snapin."
180
claus
parents: 172
diff changeset
   408
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   409
    topViews notNil ifTrue:[
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   410
	"
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   411
	 need a new semaphore, since obsolete processes 
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   412
	 (from our previous live) may still sit on the current semaphore
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   413
	"
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   414
	mySensor eventSemaphore:Semaphore new.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   415
	isModal ifFalse:[
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   416
	    self startup:true 
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   417
	]
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   418
    ]
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   419
!
180
claus
parents: 172
diff changeset
   420
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   421
shutdown
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   422
    "shutdow the window group; close all views and
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   423
     terminate process"
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   424
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   425
    |p|
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   426
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   427
    self closeDownViews.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   428
    myProcess notNil ifTrue:[
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   429
	p := myProcess.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   430
	myProcess := nil.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   431
	p terminate.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   432
    ]
180
claus
parents: 172
diff changeset
   433
!
claus
parents: 172
diff changeset
   434
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   435
startup:isRestart
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   436
    "startup the window-group;
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   437
     this creates a new window group process, which
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   438
     does the event processing."
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   439
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   440
    |top nm dev devNm|
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   441
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   442
    previousGroup := nil.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   443
    myProcess isNil ifTrue:[
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   444
	isModal := false.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   445
	myProcess := [
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   446
	    self realizeTopViews:isRestart.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   447
	    self eventLoopWhile:[true] onLeave:[]
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   448
	] forkAt:Processor userSchedulingPriority.
180
claus
parents: 172
diff changeset
   449
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   450
	(topViews notNil and:[topViews isEmpty not]) ifTrue:[
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   451
	    "
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   452
	     give the handler process a user friendly name
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   453
	    "
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   454
	    top := topViews first.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   455
	    nm := top processName.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   456
	    (dev := top device) notNil ifTrue:[
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   457
		devNm := dev displayName.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   458
		(devNm notNil and:[devNm ~= Display displayName]) ifTrue:[
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   459
		    nm := nm , ' (' , devNm , ')'
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   460
		]
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   461
	    ]
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   462
	] ifFalse:[
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   463
	    nm := 'window handler'.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   464
	].
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   465
	myProcess name:nm.
180
claus
parents: 172
diff changeset
   466
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   467
	"when the process dies, we have to close-down
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   468
	 the views as well
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   469
	"
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   470
	myProcess exitAction:[self closeDownViews]
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   471
    ]
180
claus
parents: 172
diff changeset
   472
!
claus
parents: 172
diff changeset
   473
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   474
startupModal:checkBlock
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   475
    "startup the window-group in a modal loop (i.e. under the
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   476
     currently running process);
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   477
     checkBlock is evaluated and loop is left, when false is
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   478
     returned."
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   479
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   480
    "set previousGroup to the main (non-modal) group"
180
claus
parents: 172
diff changeset
   481
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   482
    previousGroup := WindowGroup activeGroup.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   483
    isModal := true.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   484
    self realizeTopViews:false.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   485
    self 
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   486
	eventLoopWhile:checkBlock 
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   487
	onLeave:[
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   488
	    "
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   489
	     cleanup, in case of a terminate
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   490
	    "
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   491
	    previousGroup := nil.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   492
	    topViews := nil.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   493
	    views := nil.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   494
	    "
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   495
	     the following is rubbish;
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   496
	     the views could be reused ..
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   497
	    "
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   498
"
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   499
	    topViews notNil ifTrue:[
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   500
		topViews do:[:aView |
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   501
		    aView destroy
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   502
		].
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   503
		topViews := nil.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   504
	    ].
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   505
	    views notNil ifTrue:[
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   506
		views do:[:aView |
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   507
		    aView destroy
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   508
		].
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   509
		views := nil.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   510
	    ].
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   511
"
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   512
	]
180
claus
parents: 172
diff changeset
   513
! !
claus
parents: 172
diff changeset
   514
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   515
!WindowGroup methodsFor:'enumerating'!
54
29a6b2f8e042 *** empty log message ***
claus
parents: 48
diff changeset
   516
29a6b2f8e042 *** empty log message ***
claus
parents: 48
diff changeset
   517
allTopViewsExcept:aView do:aBlock
157
claus
parents: 152
diff changeset
   518
    "evaluate aBlock for all topviews except aView in this group.
claus
parents: 152
diff changeset
   519
     This works on a copy of the view collection, to allow for
158
claus
parents: 157
diff changeset
   520
     destroy and other collection changing operations to be done."
157
claus
parents: 152
diff changeset
   521
claus
parents: 152
diff changeset
   522
    topViews notNil ifTrue:[
claus
parents: 152
diff changeset
   523
	topViews copy do:[:v |
claus
parents: 152
diff changeset
   524
	    v ~~ aView ifTrue:[aBlock value:v]
claus
parents: 152
diff changeset
   525
	]
claus
parents: 152
diff changeset
   526
    ].
claus
parents: 152
diff changeset
   527
!
claus
parents: 152
diff changeset
   528
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   529
allViewsDo:aBlock
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   530
    "evaluate aBlock for all views & topviews in this group.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   531
     This works on a copy of the view collection, to allow for
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   532
     destroy and other collection changing operations to be done."
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   533
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   534
    topViews notNil ifTrue:[topViews copy do:aBlock].
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   535
    views notNil ifTrue:[views copy do:aBlock]
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   536
!
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   537
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   538
partnersDo:aBlock
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   539
    "evaluate aBlock for all partnerViews.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   540
     This works on a copy of the view collection, to allow for
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   541
     destroy and other collection changing operations to be done."
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   542
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   543
    topViews notNil ifTrue:[
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   544
	topViews copy do:[:v |
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   545
	    v notNil ifTrue:[
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   546
		v type == #partner ifTrue:[aBlock value:v].
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   547
	    ]
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   548
	]
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   549
    ].
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   550
!
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   551
157
claus
parents: 152
diff changeset
   552
slavesDo:aBlock
claus
parents: 152
diff changeset
   553
    "evaluate aBlock for all slaveViews.
claus
parents: 152
diff changeset
   554
     This works on a copy of the view collection, to allow for
158
claus
parents: 157
diff changeset
   555
     destroy and other collection changing operations to be done."
54
29a6b2f8e042 *** empty log message ***
claus
parents: 48
diff changeset
   556
29a6b2f8e042 *** empty log message ***
claus
parents: 48
diff changeset
   557
    topViews notNil ifTrue:[
157
claus
parents: 152
diff changeset
   558
	topViews copy do:[:v |
claus
parents: 152
diff changeset
   559
	    v notNil ifTrue:[
claus
parents: 152
diff changeset
   560
		v type == #slave ifTrue:[aBlock value:v].
claus
parents: 152
diff changeset
   561
	    ]
claus
parents: 152
diff changeset
   562
	]
claus
parents: 152
diff changeset
   563
    ].
11
bc3949e465a0 Initial revision
claus
parents:
diff changeset
   564
! !
bc3949e465a0 Initial revision
claus
parents:
diff changeset
   565
19
74683e998f36 *** empty log message ***
claus
parents: 17
diff changeset
   566
!WindowGroup methodsFor:'event handling'!
11
bc3949e465a0 Initial revision
claus
parents:
diff changeset
   567
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   568
eventLoop
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   569
    "loop executed by windowGroup process;
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   570
     wait-for and process events forever"
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   571
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   572
   self eventLoopWhile:[true] onLeave:[]
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   573
!
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   574
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   575
eventLoopWhile:aBlock onLeave:cleanupActions
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   576
    "wait-for and process events. 
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   577
     Stay in this loop while there are still any views to dispatch for,
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   578
     and aBlock evaluates to true."
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   579
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   580
    |thisProcess|
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   581
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   582
    thisProcess := Processor activeProcess.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   583
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   584
    [
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   585
	"/
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   586
	"/ on leave, exit the event loop
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   587
	"/
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   588
	LeaveSignal handle:[:ex |
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   589
	    ex return
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   590
	] do:[
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   591
	    |p g mainGroup|
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   592
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   593
	    isModal ifTrue:[
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   594
		mainGroup := self mainGroup.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   595
	    ].
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   596
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   597
	    aBlock whileTrue:[ 
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   598
		LastActiveGroup := self.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   599
		LastActiveProcess := thisProcess.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   600
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   601
		(views isNil and:[topViews isNil]) ifTrue:[
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   602
		    myProcess notNil ifTrue:[
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   603
			p := myProcess.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   604
			myProcess := nil.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   605
			p terminate.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   606
			"not reached - there is no life after death"
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   607
		    ].
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   608
		    "
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   609
		     this is the end of a modal loop
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   610
		     (not having a private process ...)
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   611
		    "
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   612
		    ^ self
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   613
		].
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   614
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   615
		"/
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   616
		"/ on abort, stay in the event loop
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   617
		"/
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   618
		AbortSignal handle:[:ex |
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   619
		    ex return
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   620
		] do:[
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   621
		    "
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   622
		     if modal, break out of the wait after some time
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   623
		     to allow servicing update-events of the blocked
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   624
		     windowgroup.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   625
		    "
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   626
		    thisProcess setStateTo:#eventWait if:#active.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   627
		    isModal ifTrue:[
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   628
			mySensor eventSemaphore waitWithTimeout:0.2.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   629
		    ] ifFalse:[
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   630
			mySensor eventSemaphore wait.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   631
		    ].
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   632
		    LastActiveGroup := self.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   633
		    LastActiveProcess := thisProcess.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   634
		    self processEvents.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   635
		].
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   636
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   637
		"
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   638
		 if modal, also check for redraw events in my maingroup
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   639
		 (we arrive here after every event for myself or after the
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   640
		  above timeout)
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   641
		"
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   642
		mainGroup notNil ifTrue:[
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   643
		    mainGroup processExposeEvents.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   644
		]
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   645
	    ].
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   646
	].
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   647
    ] valueNowOrOnUnwindDo:[
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   648
	cleanupActions notNil ifTrue:[cleanupActions value]
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   649
    ]
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   650
!
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   651
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   652
leaveEventLoop
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   653
    "immediately leave the event loop, returning way back.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   654
     This can be used to leave (and closedown) a modal group.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   655
     (for normal views, this does not make sense)"
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   656
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   657
    ^ LeaveSignal raise
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   658
!
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   659
103
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
   660
processEvents
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
   661
    "process events from either the damage- or user input queues.
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
   662
     Abort is assumed to be handled elsewhere."
19
74683e998f36 *** empty log message ***
claus
parents: 17
diff changeset
   663
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   664
    |event ignore|
11
bc3949e465a0 Initial revision
claus
parents:
diff changeset
   665
72
3e84121988c3 *** empty log message ***
claus
parents: 65
diff changeset
   666
    self processExposeEvents.
180
claus
parents: 172
diff changeset
   667
72
3e84121988c3 *** empty log message ***
claus
parents: 65
diff changeset
   668
    [mySensor hasEvents] whileTrue:[
3e84121988c3 *** empty log message ***
claus
parents: 65
diff changeset
   669
	event := mySensor nextEvent.
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   670
	event notNil ifTrue:[
112
88383d87f382 *** empty log message ***
claus
parents: 109
diff changeset
   671
	    (views notNil or:[topViews notNil]) ifTrue:[
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   672
		ignore := false.
172
claus
parents: 162
diff changeset
   673
claus
parents: 162
diff changeset
   674
		(preEventHook  notNil 
claus
parents: 162
diff changeset
   675
		and:[preEventHook processEvent:event]) ifTrue:[
claus
parents: 162
diff changeset
   676
		    ignore := true.
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   677
		].
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   678
		ignore ifFalse:[
103
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
   679
		    "/
172
claus
parents: 162
diff changeset
   680
		    "/ FocusStepping is done right here
103
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
   681
		    "/
172
claus
parents: 162
diff changeset
   682
		    event isKeyPressEvent ifTrue:[
claus
parents: 162
diff changeset
   683
			event key == #FocusNext ifTrue:[
claus
parents: 162
diff changeset
   684
			    self focusNext.
claus
parents: 162
diff changeset
   685
			    ignore := true
claus
parents: 162
diff changeset
   686
			].
claus
parents: 162
diff changeset
   687
			event key == #FocusPrevious ifTrue:[
claus
parents: 162
diff changeset
   688
			    self focusPrevious.
claus
parents: 162
diff changeset
   689
			    ignore := true
claus
parents: 162
diff changeset
   690
			].
103
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
   691
		    ].
172
claus
parents: 162
diff changeset
   692
		    ignore ifFalse:[
claus
parents: 162
diff changeset
   693
			"/
claus
parents: 162
diff changeset
   694
			"/  button events turn off explicit focus, and revert
claus
parents: 162
diff changeset
   695
			"/  to implicit focus control
claus
parents: 162
diff changeset
   696
			"/
claus
parents: 162
diff changeset
   697
			(focusView notNil
claus
parents: 162
diff changeset
   698
			and:[event isButtonEvent]) ifTrue:[
claus
parents: 162
diff changeset
   699
			    self focusView:nil
claus
parents: 162
diff changeset
   700
			].
claus
parents: 162
diff changeset
   701
			"/
claus
parents: 162
diff changeset
   702
			"/ let the event forward itself
claus
parents: 162
diff changeset
   703
			"/
180
claus
parents: 172
diff changeset
   704
			LastActiveGroup := self.
claus
parents: 172
diff changeset
   705
			LastActiveProcess := Processor activeProcess.
172
claus
parents: 162
diff changeset
   706
			event sendEventWithFocusOn:focusView.
claus
parents: 162
diff changeset
   707
		    ]
claus
parents: 162
diff changeset
   708
		].
claus
parents: 162
diff changeset
   709
		postEventHook notNil ifTrue:[
claus
parents: 162
diff changeset
   710
		    postEventHook processEvent:event
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   711
		]
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   712
	    ]
72
3e84121988c3 *** empty log message ***
claus
parents: 65
diff changeset
   713
	].
3e84121988c3 *** empty log message ***
claus
parents: 65
diff changeset
   714
    ]
48
9e584329a6da last version with separate queue
claus
parents: 46
diff changeset
   715
!
9e584329a6da last version with separate queue
claus
parents: 46
diff changeset
   716
9e584329a6da last version with separate queue
claus
parents: 46
diff changeset
   717
processExposeEvents
103
6156d12a414d *** empty log message ***
claus
parents: 90
diff changeset
   718
    "process only expose events from the damage queue"
48
9e584329a6da last version with separate queue
claus
parents: 46
diff changeset
   719
180
claus
parents: 172
diff changeset
   720
    |event view rect x y w h sensor thisProcess|
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 107
diff changeset
   721
ba47d9d6bda8 *** empty log message ***
claus
parents: 107
diff changeset
   722
    (sensor := mySensor) isNil ifTrue:[^ self].
48
9e584329a6da last version with separate queue
claus
parents: 46
diff changeset
   723
180
claus
parents: 172
diff changeset
   724
    thisProcess := Processor activeProcess.
claus
parents: 172
diff changeset
   725
claus
parents: 172
diff changeset
   726
    [sensor hasDamage] whileTrue:[
claus
parents: 172
diff changeset
   727
	LastActiveGroup := self.
claus
parents: 172
diff changeset
   728
	LastActiveProcess := thisProcess.
claus
parents: 172
diff changeset
   729
claus
parents: 172
diff changeset
   730
	event := sensor nextDamage.
claus
parents: 172
diff changeset
   731
	event notNil ifTrue:[
claus
parents: 172
diff changeset
   732
	    (views notNil or:[topViews notNil]) ifTrue:[
claus
parents: 172
diff changeset
   733
		(preEventHook notNil 
claus
parents: 172
diff changeset
   734
		and:[preEventHook processEvent:event]) ifFalse:[
claus
parents: 172
diff changeset
   735
		    event isDamage ifTrue:[
claus
parents: 172
diff changeset
   736
			view := event view.
claus
parents: 172
diff changeset
   737
			"/
claus
parents: 172
diff changeset
   738
			"/ if the view is no longer shown (iconified or closed),
claus
parents: 172
diff changeset
   739
			"/ this is a leftover event and ignored.
claus
parents: 172
diff changeset
   740
			"/
claus
parents: 172
diff changeset
   741
			view shown ifTrue:[
claus
parents: 172
diff changeset
   742
			    rect := event rectangle.
claus
parents: 172
diff changeset
   743
			    x := rect left.
claus
parents: 172
diff changeset
   744
			    y := rect top.
claus
parents: 172
diff changeset
   745
			    w := rect width.
claus
parents: 172
diff changeset
   746
			    h := rect height.
claus
parents: 172
diff changeset
   747
			    LastActiveGroup := self.
claus
parents: 172
diff changeset
   748
			    LastActiveProcess := thisProcess.
claus
parents: 172
diff changeset
   749
			    view transformation notNil ifTrue:[
claus
parents: 172
diff changeset
   750
				view deviceExposeX:x y:y width:w height:h
claus
parents: 172
diff changeset
   751
			    ] ifFalse:[
claus
parents: 172
diff changeset
   752
				view exposeX:x y:y width:w height:h
172
claus
parents: 162
diff changeset
   753
			    ]
81
4ba554473294 *** empty log message ***
claus
parents: 78
diff changeset
   754
			]
180
claus
parents: 172
diff changeset
   755
		    ] ifFalse:[
claus
parents: 172
diff changeset
   756
			"
claus
parents: 172
diff changeset
   757
			 mhmh - could we possibly arrive here ?
claus
parents: 172
diff changeset
   758
			"
claus
parents: 172
diff changeset
   759
			LastActiveGroup := self.
claus
parents: 172
diff changeset
   760
			LastActiveProcess := thisProcess.
claus
parents: 172
diff changeset
   761
			event sendEvent.
78
1c9c22df3251 *** empty log message ***
claus
parents: 72
diff changeset
   762
		    ]
180
claus
parents: 172
diff changeset
   763
		].
claus
parents: 172
diff changeset
   764
		postEventHook notNil ifTrue:[
claus
parents: 172
diff changeset
   765
		    postEventHook processEvent:event
72
3e84121988c3 *** empty log message ***
claus
parents: 65
diff changeset
   766
		]
3e84121988c3 *** empty log message ***
claus
parents: 65
diff changeset
   767
	    ]
3e84121988c3 *** empty log message ***
claus
parents: 65
diff changeset
   768
	]
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   769
    ]
11
bc3949e465a0 Initial revision
claus
parents:
diff changeset
   770
!
bc3949e465a0 Initial revision
claus
parents:
diff changeset
   771
28
3879ff2138f1 *** empty log message ***
claus
parents: 26
diff changeset
   772
waitForExposeFor:aView
3879ff2138f1 *** empty log message ***
claus
parents: 26
diff changeset
   773
    "wait for a noExpose on aView, then process all exposes.
3879ff2138f1 *** empty log message ***
claus
parents: 26
diff changeset
   774
     To be used after a scroll"
3879ff2138f1 *** empty log message ***
claus
parents: 26
diff changeset
   775
3879ff2138f1 *** empty log message ***
claus
parents: 26
diff changeset
   776
    mySensor waitForExposeFor:aView.
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   777
    AbortSignal catch:[
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   778
	self processExposeEvents
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   779
    ]
11
bc3949e465a0 Initial revision
claus
parents:
diff changeset
   780
! !
19
74683e998f36 *** empty log message ***
claus
parents: 17
diff changeset
   781
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   782
!WindowGroup methodsFor:'focus control'!
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   783
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   784
focusNext
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   785
    "give focus to next view in focusSequence"
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   786
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   787
    |index|
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   788
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   789
    focusSequence size == 0 ifTrue:[^ self].
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   790
    focusView notNil ifTrue:[
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   791
	index := (focusSequence indexOf:focusView) + 1.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   792
	index > focusSequence size ifTrue:[index := 1].
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   793
    ] ifFalse:[
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   794
	index := 1.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   795
    ].
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   796
    self focusView:(focusSequence at:index)
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   797
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   798
    "
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   799
     |top v1 v2|
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   800
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   801
     top := StandardSystemView new.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   802
     v1 := EditTextView origin:0.0@0.0 corner:1.0@0.5 in:top.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   803
     v2 := EditTextView origin:0.0@0.5 corner:1.0@1.0 in:top.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   804
     top open.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   805
     top windowGroup focusSequence:(Array with:v1 with:v2).
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   806
     top windowGroup focusOn:v1.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   807
     (Delay forSeconds:10) wait.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   808
     top windowGroup focusNext.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   809
    "
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   810
!
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   811
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   812
focusPrevious
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   813
    "give focus to previous view in focusSequence"
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   814
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   815
    |index|
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   816
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   817
    focusSequence size == 0 ifTrue:[^ self].
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   818
    focusView notNil ifTrue:[
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   819
	index := (focusSequence indexOf:focusView) - 1.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   820
	index < 1 ifTrue:[index := focusSequence size].
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   821
    ] ifFalse:[
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   822
	index := focusSequence size.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   823
    ].
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   824
    self focusView:(focusSequence at:index)
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   825
!
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   826
135
claus
parents: 121
diff changeset
   827
focusSequence
claus
parents: 121
diff changeset
   828
    "return the focus sequence for focusNext/focusPrevious.
claus
parents: 121
diff changeset
   829
     Focus is stepped in the order in which subviews occur in
claus
parents: 121
diff changeset
   830
     the sequence"
claus
parents: 121
diff changeset
   831
claus
parents: 121
diff changeset
   832
    ^ focusSequence
claus
parents: 121
diff changeset
   833
!
claus
parents: 121
diff changeset
   834
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   835
focusSequence:aSequenceableCollection
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   836
    "define the focus sequence for focusNext/focusPrevious.
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   837
     Focus is stepped in the order in which subviews occur in
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   838
     the sequence"
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   839
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   840
    focusSequence := aSequenceableCollection
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   841
!
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   842
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   843
focusView
135
claus
parents: 121
diff changeset
   844
    "return the view which currently has the focus"
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   845
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   846
    ^ focusView
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   847
!
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   848
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   849
focusView:aViewOrNil
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   850
    "give focus to aViewOrNil"
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   851
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   852
    focusView notNil ifTrue:[
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   853
	focusView focusOut.
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   854
    ].
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   855
    focusView := aViewOrNil.
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   856
    focusView notNil ifTrue:[
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   857
	focusView focusIn
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   858
    ].
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   859
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   860
    "
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   861
     |top v1 v2|
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   862
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   863
     top := StandardSystemView new.
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   864
     v1 := EditTextView origin:0.0@0.0 corner:1.0@0.5 in:top.
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   865
     v2 := EditTextView origin:0.0@0.5 corner:1.0@1.0 in:top.
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   866
     top open.
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   867
     top windowGroup focusView:v1.
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   868
    "
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   869
! !
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   870
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   871
!WindowGroup methodsFor:'initialization'!
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   872
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   873
initialize
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   874
    "setup the windowgroup, by creating a new sensor
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   875
     and an event semaphore"
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   876
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   877
    mySensor := WindowSensor new.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   878
    mySensor eventSemaphore:Semaphore new.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   879
    isModal := false.
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   880
!
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   881
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   882
reinitialize
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   883
    "reinitialize the windowgroup after an image restart"
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   884
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   885
    "throw away old (zombie) process"
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   886
    myProcess notNil ifTrue:[
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   887
	"careful: the old processes exitaction must be cleared
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   888
	 otherwise, it might do destroy or other actions when it
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   889
	 gets finalized ...
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   890
	"
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   891
	myProcess exitAction:nil.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   892
	myProcess := nil.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   893
    ].
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   894
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   895
    "throw away old events"
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   896
    mySensor reinitialize
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   897
! !
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   898
19
74683e998f36 *** empty log message ***
claus
parents: 17
diff changeset
   899
!WindowGroup methodsFor:'printing'!
74683e998f36 *** empty log message ***
claus
parents: 17
diff changeset
   900
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   901
printOn:aStream
19
74683e998f36 *** empty log message ***
claus
parents: 17
diff changeset
   902
    "return a printed representation;
144
claus
parents: 141
diff changeset
   903
     just for more user friendlyness: add name of process."
19
74683e998f36 *** empty log message ***
claus
parents: 17
diff changeset
   904
90
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   905
    myProcess isNil ifTrue:[
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   906
	(previousGroup notNil and:[previousGroup process notNil]) ifTrue:[
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   907
	    aStream nextPutAll:('WindowGroup(modal in ' , previousGroup process nameOrId , ')').
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   908
	    ^ self.
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   909
	].
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   910
	^ super printOn:aStream
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   911
    ].
b1f1d7fc96eb *** empty log message ***
claus
parents: 86
diff changeset
   912
    aStream nextPutAll:('WindowGroup(' , myProcess nameOrId , ')')
19
74683e998f36 *** empty log message ***
claus
parents: 17
diff changeset
   913
! !
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   914
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   915
!WindowGroup methodsFor:'special'!
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   916
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   917
restoreCursors
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   918
    "restore the original cursors in all of my views"
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   919
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   920
    |c|
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   921
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   922
    self allViewsDo:[:aView |  
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   923
	c := aView cursor on:(aView device).
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   924
	aView device setCursor:(c id) in:(aView id).
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   925
    ].
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   926
!
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   927
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   928
showCursor:aCursor
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   929
    "change the cursor to aCursor in all of my views."
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   930
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   931
    |c|
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   932
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   933
    c := aCursor.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   934
    self allViewsDo:[:aView |  
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   935
	c := c on:(aView device).
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   936
	aView device setCursor:c id in:aView id.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   937
    ].
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   938
!
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   939
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   940
withCursor:aCursor do:aBlock
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   941
    "evaluate aBlock while showing aCursor in all
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   942
     my views (used to show wait-cursor while doing something).
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   943
     Return the result as returned by aBlock."
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   944
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   945
    |oldCursors|
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   946
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   947
    "
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   948
     get mapping of view->cursor for all of my subviews
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   949
    "
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   950
    oldCursors := IdentityDictionary new.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   951
    self allViewsDo:[:aView |
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   952
	oldCursors at:aView put:(aView cursor).
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   953
	aView cursor:aCursor
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   954
    ].
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   955
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   956
    ^ aBlock valueNowOrOnUnwindDo:[
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   957
	"
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   958
	 restore cursors from the mapping
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   959
	"
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   960
	oldCursors keysAndValuesDo:[:view :cursor |
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   961
	    view cursor:cursor
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   962
	]
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   963
    ]
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   964
! !
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   965
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   966
!WindowGroup methodsFor:'special accessing'!
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   967
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   968
setModal:aBoolean
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   969
    "special entry for debugger: set the modal flag.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   970
     Not for public use"
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   971
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   972
    isModal := aBoolean
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   973
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   974
    "Modified: 3.9.1995 / 14:51:04 / claus"
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   975
!
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   976
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   977
setPreviousGroup:aGroup
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   978
    "special entry for debugger:
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   979
     set the windowgroup that started this group (for modal groups only).
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   980
     This is not a public interface."
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   981
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   982
    previousGroup := aGroup
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   983
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   984
    "Modified: 3.9.1995 / 14:55:40 / claus"
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   985
!
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   986
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   987
setProcess:aProcess 
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   988
    "special entry for debugger: set the windowGroups process.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   989
     Not for public use."
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   990
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   991
    myProcess := aProcess
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   992
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   993
    "Modified: 3.9.1995 / 14:25:38 / claus"
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   994
! !
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   995
251
915de9a65169 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
   996
!WindowGroup class methodsFor:'documentation'!
915de9a65169 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
   997
915de9a65169 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
   998
version
263
Claus Gittinger <cg@exept.de>
parents: 262
diff changeset
   999
    ^ '$Header: /cvs/stx/stx/libview/WindowGroup.st,v 1.39 1995-11-24 18:36:33 cg Exp $'
251
915de9a65169 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
  1000
! !
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
  1001
WindowGroup initialize!