author | Claus Gittinger <cg@exept.de> |
Fri, 07 Jan 2005 15:35:42 +0100 | |
changeset 2030 | cfe668c44a8c |
parent 1973 | 836eccb0d4cb |
child 2114 | 7cd66cca06f6 |
permissions | -rw-r--r-- |
1085 | 1 |
" |
2 |
COPYRIGHT (c) 1999 by eXept Software AG |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
||
1567 | 14 |
"{ Package: 'stx:libview2' }" |
15 |
||
1085 | 16 |
TopView subclass:#ExternalTopView |
1973 | 17 |
instanceVariableNames:'windowClosedPollProcess' |
1085 | 18 |
classVariableNames:'' |
19 |
poolDictionaries:'' |
|
20 |
category:'Graphics-Support' |
|
21 |
! |
|
22 |
||
23 |
!ExternalTopView class methodsFor:'documentation'! |
|
24 |
||
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 1999 by eXept Software AG |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
||
38 |
! |
|
39 |
||
40 |
documentation |
|
41 |
" |
|
42 |
Represents a view as created by some other application. |
|
43 |
This is a support-class to allow ST/X views to be created |
|
44 |
inside other applications. |
|
45 |
||
1103 | 46 |
A simple demoApplication is found in goodies/stxInExternalWindow |
47 |
(which uses Demos::PlayInAlienWindow as a startup anchor) |
|
1097 | 48 |
|
1085 | 49 |
[author:] |
50 |
Claus Gittinger (cg@exept.de) |
|
51 |
||
52 |
[see also:] |
|
53 |
||
54 |
[instance variables:] |
|
1099 | 55 |
none added here |
1085 | 56 |
|
57 |
[class variables:] |
|
1099 | 58 |
none added here |
1085 | 59 |
" |
60 |
! ! |
|
61 |
||
62 |
!ExternalTopView class methodsFor:'instance creation'! |
|
63 |
||
64 |
newWithID:anAlienWindowID |
|
1103 | 65 |
"create and return a new externalTopView - the windowID |
66 |
as passed in must be from an alien programs view" |
|
67 |
||
1085 | 68 |
^ self new setWindowID:anAlienWindowID |
69 |
! ! |
|
70 |
||
1087 | 71 |
!ExternalTopView methodsFor:'private'! |
72 |
||
1973 | 73 |
alienViewHasBeenDestroyed |
74 |
'alienViewHasBeenDestroyed' printCR. |
|
75 |
self sensor notNil ifTrue:[ |
|
76 |
self sensor destroyedView:self |
|
77 |
] ifFalse:[ |
|
78 |
self destroyed |
|
79 |
] |
|
80 |
! |
|
81 |
||
1087 | 82 |
checkWindowStillAlive |
1101 | 83 |
"check for a destroyed topView |
1973 | 84 |
(must poll, since we do not get any events from X for the alien topView)" |
1101 | 85 |
|
1973 | 86 |
|prevHandler stillAlive prevErrorPrintingFlag| |
87 |
||
88 |
prevErrorPrintingFlag := device class errorPrinting. |
|
89 |
device class errorPrinting:true. |
|
1101 | 90 |
|
1973 | 91 |
drawableId notNil ifTrue:[ |
92 |
stillAlive := device isValidWindowId:drawableId. |
|
93 |
] ifFalse:[ |
|
94 |
stillAlive := false |
|
95 |
]. |
|
96 |
device flush. |
|
1101 | 97 |
|
1973 | 98 |
device class errorPrinting:prevErrorPrintingFlag. |
99 |
||
100 |
^ stillAlive. |
|
101 |
! |
|
1087 | 102 |
|
1973 | 103 |
checkWindowStillAliveLoop |
104 |
[self checkWindowStillAlive] whileTrue:[ |
|
105 |
Delay waitForSeconds:0.5. |
|
106 |
]. |
|
107 |
||
108 |
self alienViewHasBeenDestroyed |
|
109 |
! |
|
110 |
||
111 |
startWindowClosedPollProcess |
|
112 |
windowClosedPollProcess isNil ifTrue:[ |
|
113 |
windowClosedPollProcess := |
|
114 |
[ |
|
115 |
[ |
|
116 |
self checkWindowStillAliveLoop |
|
117 |
] valueNowOrOnUnwindDo:[ |
|
118 |
windowClosedPollProcess := nil. |
|
119 |
] |
|
120 |
] fork. |
|
121 |
]. |
|
122 |
! |
|
123 |
||
124 |
stopWindowClosedPollProcess |
|
125 |
windowClosedPollProcess notNil ifTrue:[ |
|
126 |
windowClosedPollProcess terminate. |
|
127 |
windowClosedPollProcess waitUntilTerminated |
|
128 |
]. |
|
1087 | 129 |
! ! |
130 |
||
1085 | 131 |
!ExternalTopView methodsFor:'private accessing'! |
132 |
||
133 |
setWindowID:aWindowID |
|
134 |
drawableId := aWindowID. |
|
1086 | 135 |
realized := shown := true. |
136 |
! ! |
|
137 |
||
1088
63cd295128e2
added isExternalTopView query.
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
138 |
!ExternalTopView methodsFor:'queries'! |
63cd295128e2
added isExternalTopView query.
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
139 |
|
63cd295128e2
added isExternalTopView query.
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
140 |
isExternalTopView |
1098 | 141 |
"return true, if this is an external topView - always true here" |
1088
63cd295128e2
added isExternalTopView query.
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
142 |
|
63cd295128e2
added isExternalTopView query.
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
143 |
^ true |
63cd295128e2
added isExternalTopView query.
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
144 |
! ! |
63cd295128e2
added isExternalTopView query.
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
145 |
|
1086 | 146 |
!ExternalTopView methodsFor:'redefined'! |
147 |
||
148 |
destroyView |
|
149 |
"never destroyed by ST/X - instead, the view is under |
|
150 |
control of the host application ..." |
|
151 |
||
1973 | 152 |
self stopWindowClosedPollProcess. |
1086 | 153 |
realized := false. |
154 |
drawableId := nil. |
|
1973 | 155 |
|
1086 | 156 |
! |
157 |
||
1087 | 158 |
open |
1098 | 159 |
"redefined to start a watch timeout for closed windows; |
160 |
this is required, since we wont get any closeRequest event for |
|
161 |
external windows (as all of its events are handled by the alien |
|
162 |
application)" |
|
163 |
||
1087 | 164 |
super open. |
1973 | 165 |
"/ self checkWindowStillAlive |
166 |
self startWindowClosedPollProcess. |
|
1087 | 167 |
! |
168 |
||
1086 | 169 |
unmap |
1098 | 170 |
"redefined as a noop; |
171 |
ExternalTopViews are never unmapped by ST/X - instead, the view is under |
|
1086 | 172 |
control of the host application ..." |
173 |
||
174 |
||
1085 | 175 |
! ! |
176 |
||
1102
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
177 |
!ExternalTopView methodsFor:'special'! |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
178 |
|
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
179 |
becomeParentOf:anSTXWindow |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
180 |
"add myself to the windowGroup of anSTXWindow ... |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
181 |
and reparent anSTXWindow to be the (only) child of myself" |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
182 |
|
1973 | 183 |
self old_becomeParentOf:anSTXWindow |
184 |
! |
|
185 |
||
186 |
new_becomeParentOf:anSTXWindow |
|
187 |
"add myself to the windowGroup of anSTXWindow ... |
|
188 |
and reparent anSTXWindow to be the (only) child of myself" |
|
189 |
||
190 |
|wg oldTopView retryCount deviceErrorOccured| |
|
191 |
||
192 |
anSTXWindow borderWidth:0. anSTXWindow forceBorderWidth. |
|
193 |
self borderWidth:0. self forceBorderWidth. |
|
194 |
self borderColor:Color red. |
|
195 |
||
196 |
anSTXWindow createWithAllSubViews. |
|
197 |
oldTopView := anSTXWindow topView. |
|
198 |
||
199 |
wg := anSTXWindow windowGroup. |
|
200 |
wg notNil ifTrue:[ |
|
201 |
windowGroup notNil ifTrue:[ |
|
202 |
self halt. |
|
203 |
windowGroup removeTopView:self. |
|
204 |
]. |
|
205 |
wg addTopView:self. |
|
206 |
windowGroup := wg. |
|
207 |
]. |
|
208 |
||
209 |
oldTopView == anSTXWindow ifTrue:[ |
|
210 |
oldTopView container:self. |
|
211 |
]. |
|
212 |
||
213 |
self open. "/ not really an open; however it starts its event handler |
|
214 |
wg isNil ifTrue:[ |
|
215 |
oldTopView windowGroup:self windowGroup. |
|
216 |
] ifFalse:[ |
|
217 |
windowGroup ~~ anSTXWindow windowGroup ifTrue:[self halt]. |
|
218 |
]. |
|
219 |
||
220 |
"/'childID: ' print. anSTXWindow id displayString printCR. |
|
221 |
"/'parentID: ' print. self id displayString printCR. |
|
222 |
self addSubView:anSTXWindow. |
|
223 |
||
224 |
self checkWindowStillAlive ifFalse:[ Transcript showCR:'x1'. ^ true]. |
|
225 |
||
226 |
||
227 |
anSTXWindow device |
|
228 |
reparentWindow:anSTXWindow id |
|
229 |
to:self id. |
|
230 |
anSTXWindow device unBuffered. |
|
231 |
retryCount := 0. |
|
232 |
deviceErrorOccured := false. |
|
233 |
[ |
|
234 |
||
235 |
GLXWorkstation deviceErrorSignal handle:[:ex| |
|
236 |
'DeviceErrorSignal raised in becomeParentOf: ' printNL. |
|
237 |
deviceErrorOccured := true. |
|
238 |
"/ (Delay waitForSeconds: 1). |
|
239 |
"/ retryCount := retryCount + 1. |
|
240 |
"/ retryCount > 5 ifTrue:[ |
|
241 |
"/ ex proceed |
|
242 |
"/ ]. |
|
243 |
ex proceed |
|
244 |
] do:[ |
|
245 |
deviceErrorOccured := false. |
|
246 |
anSTXWindow enableEvent:#structureNotify. |
|
247 |
]. |
|
248 |
] ensure:[ |
|
249 |
anSTXWindow device buffered. |
|
250 |
]. |
|
251 |
deviceErrorOccured ifTrue:[^false]. |
|
252 |
||
253 |
||
254 |
self checkWindowStillAlive ifFalse:[ Transcript showCR:'x2'. ^ true]. |
|
255 |
||
256 |
anSTXWindow realize. |
|
257 |
anSTXWindow map. |
|
258 |
^true |
|
259 |
||
260 |
"/ wg notNil ifTrue:[ |
|
261 |
"/ wg removeView:oldTopView. |
|
262 |
"/ wg addView:oldTopView. |
|
263 |
"/ ]. |
|
264 |
||
265 |
"/ anSTXWindow origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
266 |
! |
|
267 |
||
268 |
old_becomeParentOf:anSTXWindow |
|
269 |
"add myself to the windowGroup of anSTXWindow ... |
|
270 |
and reparent anSTXWindow to be the (only) child of myself" |
|
271 |
||
1102
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
272 |
|wg oldTopView| |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
273 |
|
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
274 |
anSTXWindow createWithAllSubViews. |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
275 |
|
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
276 |
oldTopView := anSTXWindow topView. |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
277 |
|
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
278 |
wg := anSTXWindow windowGroup. |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
279 |
wg notNil ifTrue:[ |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
280 |
wg addTopView:self. |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
281 |
]. |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
282 |
|
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
283 |
oldTopView == anSTXWindow ifTrue:[ |
1567 | 284 |
oldTopView setContainer:self. |
1102
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
285 |
]. |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
286 |
|
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
287 |
self open. "/ not really an open; however it starts its event handler |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
288 |
|
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
289 |
wg isNil ifTrue:[ |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
290 |
oldTopView windowGroup:self windowGroup. |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
291 |
]. |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
292 |
|
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
293 |
anSTXWindow device |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
294 |
reparentWindow:anSTXWindow id |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
295 |
to:self id. |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
296 |
|
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
297 |
self addSubView:anSTXWindow. |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
298 |
anSTXWindow enableEvent:#structureNotify. |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
299 |
|
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
300 |
anSTXWindow realize. |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
301 |
anSTXWindow map. |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
302 |
wg notNil ifTrue:[ |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
303 |
wg removeView:oldTopView. |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
304 |
wg addView:oldTopView. |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
305 |
]. |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
306 |
|
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
307 |
anSTXWindow origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
308 |
! ! |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
309 |
|
1085 | 310 |
!ExternalTopView class methodsFor:'documentation'! |
311 |
||
312 |
version |
|
1973 | 313 |
^ '$Header: /cvs/stx/stx/libview2/ExternalTopView.st,v 1.12 2004-04-02 16:52:16 werner Exp $' |
1085 | 314 |
! ! |