author | Claus Gittinger <cg@exept.de> |
Mon, 23 Jan 2017 11:00:34 +0100 | |
changeset 3835 | 98c65815a6d3 |
parent 3732 | 90373997e1a1 |
child 4258 | 5fc4985b0d74 |
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 |
||
3622 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
1085 | 16 |
TopView subclass:#ExternalTopView |
1973 | 17 |
instanceVariableNames:'windowClosedPollProcess' |
2594 | 18 |
classVariableNames:'ErrorPrinting' |
1085 | 19 |
poolDictionaries:'' |
2114 | 20 |
category:'Views-Basic' |
1085 | 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 |
||
2594 | 71 |
!ExternalTopView class methodsFor:'accessing'! |
72 |
||
73 |
errorPrinting:something |
|
74 |
"controls errorprinting while checking for alive connection" |
|
75 |
||
76 |
ErrorPrinting := something. |
|
77 |
! ! |
|
78 |
||
1087 | 79 |
!ExternalTopView methodsFor:'private'! |
80 |
||
1973 | 81 |
alienViewHasBeenDestroyed |
2297
68b28da467d4
changed #alienViewHasBeenDestroyed - user #errorPrint or #infoPrint instead of #print
Stefan Vogel <sv@exept.de>
parents:
2150
diff
changeset
|
82 |
'alienViewHasBeenDestroyed' infoPrintCR. |
1973 | 83 |
self sensor notNil ifTrue:[ |
84 |
self sensor destroyedView:self |
|
85 |
] ifFalse:[ |
|
86 |
self destroyed |
|
87 |
] |
|
88 |
! |
|
89 |
||
1087 | 90 |
checkWindowStillAlive |
1101 | 91 |
"check for a destroyed topView |
1973 | 92 |
(must poll, since we do not get any events from X for the alien topView)" |
1101 | 93 |
|
3286 | 94 |
|stillAlive prevErrorPrintingFlag graphicsDevice| |
1973 | 95 |
|
3622 | 96 |
graphicsDevice := device. |
3286 | 97 |
prevErrorPrintingFlag := graphicsDevice class errorPrinting. |
98 |
graphicsDevice class errorPrinting:(ErrorPrinting ? true). |
|
1101 | 99 |
|
3286 | 100 |
self drawableId notNil ifTrue:[ |
101 |
stillAlive := graphicsDevice isValidWindowId:self drawableId. |
|
1973 | 102 |
] ifFalse:[ |
103 |
stillAlive := false |
|
104 |
]. |
|
3286 | 105 |
graphicsDevice flush. |
1101 | 106 |
|
3286 | 107 |
graphicsDevice class errorPrinting:prevErrorPrintingFlag. |
1973 | 108 |
|
109 |
^ stillAlive. |
|
110 |
! |
|
1087 | 111 |
|
2594 | 112 |
checkWindowStillAliveLoop |
113 |
[self checkWindowStillAlive] whileTrue:[ |
|
114 |
Delay waitForSeconds:0.5. |
|
115 |
]. |
|
116 |
||
117 |
self alienViewHasBeenDestroyed |
|
118 |
! |
|
119 |
||
1973 | 120 |
startWindowClosedPollProcess |
121 |
windowClosedPollProcess isNil ifTrue:[ |
|
122 |
windowClosedPollProcess := |
|
123 |
[ |
|
124 |
[ |
|
125 |
self checkWindowStillAliveLoop |
|
3005
ad4fc8754d19
#ensure instead of #valueNowOrOnUnwindDo:
Stefan Vogel <sv@exept.de>
parents:
2594
diff
changeset
|
126 |
] ensure:[ |
1973 | 127 |
windowClosedPollProcess := nil. |
128 |
] |
|
129 |
] fork. |
|
130 |
]. |
|
131 |
! |
|
132 |
||
133 |
stopWindowClosedPollProcess |
|
134 |
windowClosedPollProcess notNil ifTrue:[ |
|
135 |
windowClosedPollProcess terminate. |
|
136 |
windowClosedPollProcess waitUntilTerminated |
|
137 |
]. |
|
1087 | 138 |
! ! |
139 |
||
1085 | 140 |
!ExternalTopView methodsFor:'private accessing'! |
141 |
||
142 |
setWindowID:aWindowID |
|
3286 | 143 |
self setId:aWindowID. |
1086 | 144 |
realized := shown := true. |
145 |
! ! |
|
146 |
||
1088
63cd295128e2
added isExternalTopView query.
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
147 |
!ExternalTopView methodsFor:'queries'! |
63cd295128e2
added isExternalTopView query.
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
148 |
|
63cd295128e2
added isExternalTopView query.
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
149 |
isExternalTopView |
1098 | 150 |
"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
|
151 |
|
63cd295128e2
added isExternalTopView query.
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
152 |
^ true |
63cd295128e2
added isExternalTopView query.
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
153 |
! ! |
63cd295128e2
added isExternalTopView query.
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
154 |
|
1086 | 155 |
!ExternalTopView methodsFor:'redefined'! |
156 |
||
157 |
destroyView |
|
158 |
"never destroyed by ST/X - instead, the view is under |
|
159 |
control of the host application ..." |
|
160 |
||
1973 | 161 |
self stopWindowClosedPollProcess. |
1086 | 162 |
realized := false. |
3286 | 163 |
self setId:nil. |
1086 | 164 |
! |
165 |
||
1087 | 166 |
open |
1098 | 167 |
"redefined to start a watch timeout for closed windows; |
168 |
this is required, since we wont get any closeRequest event for |
|
169 |
external windows (as all of its events are handled by the alien |
|
170 |
application)" |
|
171 |
||
1087 | 172 |
super open. |
1973 | 173 |
"/ self checkWindowStillAlive |
174 |
self startWindowClosedPollProcess. |
|
1087 | 175 |
! |
176 |
||
1086 | 177 |
unmap |
1098 | 178 |
"redefined as a noop; |
179 |
ExternalTopViews are never unmapped by ST/X - instead, the view is under |
|
1086 | 180 |
control of the host application ..." |
181 |
||
182 |
||
1085 | 183 |
! ! |
184 |
||
1102
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
185 |
!ExternalTopView methodsFor:'special'! |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
186 |
|
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
187 |
becomeParentOf:anSTXWindow |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
188 |
"add myself to the windowGroup of anSTXWindow ... |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
189 |
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
|
190 |
|
1973 | 191 |
self old_becomeParentOf:anSTXWindow |
192 |
! |
|
193 |
||
194 |
new_becomeParentOf:anSTXWindow |
|
195 |
"add myself to the windowGroup of anSTXWindow ... |
|
196 |
and reparent anSTXWindow to be the (only) child of myself" |
|
197 |
||
3732 | 198 |
|wg oldTopView retryCount deviceErrorOccurred| |
1973 | 199 |
|
200 |
anSTXWindow borderWidth:0. anSTXWindow forceBorderWidth. |
|
3188 | 201 |
self borderWidth:0. "/ self forceBorderWidth. |
1973 | 202 |
self borderColor:Color red. |
203 |
||
204 |
anSTXWindow createWithAllSubViews. |
|
205 |
oldTopView := anSTXWindow topView. |
|
206 |
||
207 |
wg := anSTXWindow windowGroup. |
|
208 |
wg notNil ifTrue:[ |
|
209 |
windowGroup notNil ifTrue:[ |
|
3188 | 210 |
windowGroup removeView:self. |
1973 | 211 |
]. |
212 |
wg addTopView:self. |
|
213 |
windowGroup := wg. |
|
214 |
]. |
|
215 |
||
216 |
oldTopView == anSTXWindow ifTrue:[ |
|
217 |
oldTopView container:self. |
|
218 |
]. |
|
219 |
||
220 |
self open. "/ not really an open; however it starts its event handler |
|
221 |
wg isNil ifTrue:[ |
|
222 |
oldTopView windowGroup:self windowGroup. |
|
223 |
] ifFalse:[ |
|
2150 | 224 |
windowGroup ~~ anSTXWindow windowGroup ifTrue:[ |
225 |
self halt:'possible inconsistency ?' |
|
226 |
]. |
|
1973 | 227 |
]. |
228 |
||
229 |
"/'childID: ' print. anSTXWindow id displayString printCR. |
|
230 |
"/'parentID: ' print. self id displayString printCR. |
|
231 |
self addSubView:anSTXWindow. |
|
232 |
||
233 |
self checkWindowStillAlive ifFalse:[ Transcript showCR:'x1'. ^ true]. |
|
234 |
||
235 |
||
236 |
anSTXWindow device |
|
237 |
reparentWindow:anSTXWindow id |
|
238 |
to:self id. |
|
239 |
anSTXWindow device unBuffered. |
|
240 |
retryCount := 0. |
|
3732 | 241 |
deviceErrorOccurred := false. |
1973 | 242 |
[ |
243 |
||
244 |
GLXWorkstation deviceErrorSignal handle:[:ex| |
|
3188 | 245 |
'DeviceErrorSignal raised in becomeParentOf: ' infoPrintCR. |
3732 | 246 |
deviceErrorOccurred := true. |
1973 | 247 |
"/ (Delay waitForSeconds: 1). |
248 |
"/ retryCount := retryCount + 1. |
|
249 |
"/ retryCount > 5 ifTrue:[ |
|
250 |
"/ ex proceed |
|
251 |
"/ ]. |
|
252 |
ex proceed |
|
253 |
] do:[ |
|
3732 | 254 |
deviceErrorOccurred := false. |
1973 | 255 |
anSTXWindow enableEvent:#structureNotify. |
256 |
]. |
|
257 |
] ensure:[ |
|
258 |
anSTXWindow device buffered. |
|
259 |
]. |
|
3732 | 260 |
deviceErrorOccurred ifTrue:[^false]. |
1973 | 261 |
|
262 |
||
263 |
self checkWindowStillAlive ifFalse:[ Transcript showCR:'x2'. ^ true]. |
|
264 |
||
265 |
anSTXWindow realize. |
|
266 |
anSTXWindow map. |
|
267 |
^true |
|
268 |
||
269 |
"/ wg notNil ifTrue:[ |
|
270 |
"/ wg removeView:oldTopView. |
|
271 |
"/ wg addView:oldTopView. |
|
272 |
"/ ]. |
|
273 |
||
274 |
"/ anSTXWindow origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
275 |
! |
|
276 |
||
277 |
old_becomeParentOf:anSTXWindow |
|
278 |
"add myself to the windowGroup of anSTXWindow ... |
|
279 |
and reparent anSTXWindow to be the (only) child of myself" |
|
280 |
||
1102
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
281 |
|wg oldTopView| |
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 |
anSTXWindow createWithAllSubViews. |
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 |
oldTopView := anSTXWindow topView. |
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 |
wg := anSTXWindow windowGroup. |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
288 |
wg notNil ifTrue:[ |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
289 |
wg addTopView:self. |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
290 |
]. |
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 |
oldTopView == anSTXWindow ifTrue:[ |
1567 | 293 |
oldTopView setContainer:self. |
1102
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
294 |
]. |
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 |
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
|
297 |
|
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
298 |
wg isNil ifTrue:[ |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
299 |
oldTopView windowGroup:self windowGroup. |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
300 |
]. |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
301 |
|
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
302 |
anSTXWindow device |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
303 |
reparentWindow:anSTXWindow id |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
304 |
to:self id. |
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 |
self addSubView:anSTXWindow. |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
307 |
anSTXWindow enableEvent:#structureNotify. |
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 |
anSTXWindow realize. |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
310 |
anSTXWindow map. |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
311 |
wg notNil ifTrue:[ |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
312 |
wg removeView:oldTopView. |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
313 |
wg addView:oldTopView. |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
314 |
]. |
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 |
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
|
317 |
! ! |
1ee9a1bc9241
took over reparenting method from demo.
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
318 |
|
1085 | 319 |
!ExternalTopView class methodsFor:'documentation'! |
320 |
||
321 |
version |
|
3622 | 322 |
^ '$Header$' |
1085 | 323 |
! ! |
3188 | 324 |