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