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