author | tm |
Wed, 14 Jul 1999 12:45:23 +0200 | |
changeset 1450 | 9994adae5c1c |
parent 1414 | faf0465c333b |
child 1467 | 2d85bd1a8267 |
permissions | -rw-r--r-- |
970
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
1 |
" |
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
2 |
COPYRIGHT (c) 1998 by eXept Software AG |
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
3 |
All Rights Reserved |
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
4 |
|
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
5 |
This software is furnished under a license and may be used |
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
6 |
only in accordance with the terms of that license and with the |
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
7 |
inclusion of the above copyright notice. This software may not |
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
8 |
be provided or otherwise made available to, or used by, any |
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
9 |
other person. No title to or ownership of the software is |
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
10 |
hereby transferred. |
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
11 |
" |
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
12 |
|
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
13 |
|
455 | 14 |
ScrollableView subclass:#SubCanvas |
1412 | 15 |
instanceVariableNames:'builder spec client clientHolder specHolder clientView |
16 |
clientViewIsScrolled' |
|
455 | 17 |
classVariableNames:'' |
18 |
poolDictionaries:'' |
|
19 |
category:'Views-Basic' |
|
20 |
! |
|
21 |
||
970
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
22 |
!SubCanvas class methodsFor:'documentation'! |
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
23 |
|
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
24 |
copyright |
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
25 |
" |
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
26 |
COPYRIGHT (c) 1998 by eXept Software AG |
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
27 |
All Rights Reserved |
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
28 |
|
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
29 |
This software is furnished under a license and may be used |
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
30 |
only in accordance with the terms of that license and with the |
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
31 |
inclusion of the above copyright notice. This software may not |
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
32 |
be provided or otherwise made available to, or used by, any |
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
33 |
other person. No title to or ownership of the software is |
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
34 |
hereby transferred. |
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
35 |
" |
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
36 |
|
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
37 |
! |
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
38 |
|
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
39 |
documentation |
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
40 |
" |
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
41 |
a view for a subApplication. |
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
42 |
|
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
43 |
[author:] |
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
44 |
Claus Atzkern |
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
45 |
" |
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
46 |
|
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
47 |
! ! |
455 | 48 |
|
1414
faf0465c333b
defaults for hasHVScrollbar now defined in a class method.
tm
parents:
1412
diff
changeset
|
49 |
!SubCanvas class methodsFor:'defaults'! |
faf0465c333b
defaults for hasHVScrollbar now defined in a class method.
tm
parents:
1412
diff
changeset
|
50 |
|
faf0465c333b
defaults for hasHVScrollbar now defined in a class method.
tm
parents:
1412
diff
changeset
|
51 |
defaultHorizontalScrollable |
faf0465c333b
defaults for hasHVScrollbar now defined in a class method.
tm
parents:
1412
diff
changeset
|
52 |
^ false |
faf0465c333b
defaults for hasHVScrollbar now defined in a class method.
tm
parents:
1412
diff
changeset
|
53 |
|
faf0465c333b
defaults for hasHVScrollbar now defined in a class method.
tm
parents:
1412
diff
changeset
|
54 |
|
faf0465c333b
defaults for hasHVScrollbar now defined in a class method.
tm
parents:
1412
diff
changeset
|
55 |
! |
faf0465c333b
defaults for hasHVScrollbar now defined in a class method.
tm
parents:
1412
diff
changeset
|
56 |
|
faf0465c333b
defaults for hasHVScrollbar now defined in a class method.
tm
parents:
1412
diff
changeset
|
57 |
defaultVerticalScrollable |
faf0465c333b
defaults for hasHVScrollbar now defined in a class method.
tm
parents:
1412
diff
changeset
|
58 |
^ false |
faf0465c333b
defaults for hasHVScrollbar now defined in a class method.
tm
parents:
1412
diff
changeset
|
59 |
|
faf0465c333b
defaults for hasHVScrollbar now defined in a class method.
tm
parents:
1412
diff
changeset
|
60 |
|
faf0465c333b
defaults for hasHVScrollbar now defined in a class method.
tm
parents:
1412
diff
changeset
|
61 |
! ! |
faf0465c333b
defaults for hasHVScrollbar now defined in a class method.
tm
parents:
1412
diff
changeset
|
62 |
|
455 | 63 |
!SubCanvas methodsFor:'accessing'! |
64 |
||
503 | 65 |
builder |
66 |
"return the value of the instance variable 'builder' (automatically generated)" |
|
455 | 67 |
|
503 | 68 |
^ builder! |
455 | 69 |
|
503 | 70 |
client |
71 |
"return the value of the instance variable 'client' (automatically generated)" |
|
455 | 72 |
|
503 | 73 |
^ client! |
455 | 74 |
|
75 |
client:anApplicationModel |
|
76 |
"release existing components and generate new components from |
|
77 |
the applications windowSpec." |
|
78 |
||
79 |
^ self client:anApplicationModel spec:#windowSpec |
|
80 |
! |
|
81 |
||
503 | 82 |
client:anApplication spec:aWindowSpecOrSelector |
455 | 83 |
"release existing components and generate new components from |
84 |
the applications windowSpec." |
|
85 |
||
503 | 86 |
|aBuilder| |
455 | 87 |
|
503 | 88 |
(anApplication notNil and:[anApplication respondsTo:#builder]) ifTrue:[ |
89 |
aBuilder := anApplication builder |
|
455 | 90 |
] ifFalse:[ |
503 | 91 |
aBuilder := UIBuilder new |
455 | 92 |
]. |
503 | 93 |
^ self client:anApplication spec:aWindowSpecOrSelector builder:aBuilder |
455 | 94 |
! |
95 |
||
503 | 96 |
client:anApplication spec:aWindowSpecOrSpecSymbol builder:aBuilder |
455 | 97 |
"release existing components and generate new components from |
98 |
the given windowSpec, using the given builder." |
|
99 |
||
503 | 100 |
builder := aBuilder. |
101 |
spec := aWindowSpecOrSpecSymbol. |
|
102 |
||
103 |
"/ check for master application |
|
104 |
(anApplication notNil and:[anApplication masterApplication isNil]) ifTrue:[ |
|
105 |
client := nil. |
|
106 |
client := self application. |
|
107 |
client ~~ anApplication ifTrue:[ |
|
108 |
anApplication masterApplication:client |
|
109 |
] |
|
110 |
]. |
|
111 |
client := anApplication. |
|
112 |
self rebuild. |
|
113 |
^ builder |
|
114 |
! |
|
115 |
||
1412 | 116 |
makeClientViewScrollable:aBoolean |
117 |
|vs| |
|
118 |
||
119 |
aBoolean ~~ clientViewIsScrolled ifTrue:[ |
|
120 |
clientView := View new. |
|
121 |
||
122 |
aBoolean ifTrue:[ |
|
123 |
self scrolledView:(vs := ViewScroller new). |
|
124 |
vs scrolledView:clientView. |
|
125 |
] ifFalse:[ |
|
126 |
self scrolledView:clientView. |
|
127 |
]. |
|
128 |
clientViewIsScrolled := aBoolean. |
|
129 |
] |
|
130 |
||
131 |
! |
|
132 |
||
1450 | 133 |
setClient:anApplicationModel |
134 |
"set the client - do NOT rebuild" |
|
135 |
||
136 |
client := anApplicationModel |
|
137 |
! |
|
138 |
||
503 | 139 |
spec |
140 |
"return the value of the instance variable 'spec' (automatically generated)" |
|
141 |
||
142 |
^ spec! |
|
143 |
||
144 |
spec:something |
|
145 |
"set the value of the instance variable 'spec' (automatically generated)" |
|
146 |
||
147 |
spec := something. |
|
148 |
self rebuild. |
|
819 | 149 |
! |
150 |
||
151 |
widget |
|
152 |
"ST80 compatibility. |
|
153 |
I am my own widget" |
|
154 |
||
155 |
^ self |
|
156 |
||
157 |
"Created: / 10.3.1998 / 16:20:52 / stefan" |
|
503 | 158 |
! ! |
159 |
||
160 |
!SubCanvas methodsFor:'accessing channels'! |
|
161 |
||
162 |
clientHolder |
|
163 |
^ clientHolder |
|
164 |
! |
|
165 |
||
166 |
clientHolder:aValueHolder |
|
167 |
||
168 |
clientHolder notNil ifTrue:[ |
|
169 |
clientHolder removeDependent:self |
|
170 |
]. |
|
171 |
(clientHolder := aValueHolder) notNil ifTrue:[ |
|
172 |
clientHolder addDependent:self |
|
173 |
]. |
|
557 | 174 |
self updateFromChannels |
503 | 175 |
! |
176 |
||
177 |
specHolder |
|
178 |
^ specHolder |
|
179 |
! |
|
180 |
||
181 |
specHolder:aValueHolder |
|
182 |
||
183 |
specHolder notNil ifTrue:[ |
|
184 |
specHolder removeDependent:self |
|
185 |
]. |
|
186 |
(specHolder := aValueHolder) notNil ifTrue:[ |
|
187 |
specHolder addDependent:self |
|
188 |
]. |
|
557 | 189 |
self updateFromChannels |
503 | 190 |
! ! |
191 |
||
192 |
!SubCanvas methodsFor:'building'! |
|
193 |
||
194 |
rebuild |
|
195 |
"rebuild |
|
196 |
" |
|
1412 | 197 |
|v subSpec savedView builderClass| |
455 | 198 |
|
1412 | 199 |
clientView notNil ifTrue:[ |
200 |
clientView destroySubViews |
|
455 | 201 |
]. |
202 |
||
203 |
spec notNil ifTrue:[ |
|
970
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
204 |
(subSpec := spec) isSymbol ifTrue:[ |
554 | 205 |
client isNil ifTrue:[ |
1216
c9f8253a9e7c
give a warning with nil client
Claus Gittinger <cg@exept.de>
parents:
973
diff
changeset
|
206 |
'SubCanvas [warning]: no client - cannot build spec' infoPrintCR. |
554 | 207 |
^ self |
553 | 208 |
]. |
970
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
209 |
(subSpec := client class interfaceSpecFor:spec) isNil ifTrue:[ |
1216
c9f8253a9e7c
give a warning with nil client
Claus Gittinger <cg@exept.de>
parents:
973
diff
changeset
|
210 |
"/ Transcript showCR:'SubCanvas: nil spec'. |
503 | 211 |
^ self |
212 |
] |
|
213 |
]. |
|
973 | 214 |
|
554 | 215 |
builder isNil ifTrue:[ |
1383 | 216 |
client isNil ifTrue:[ |
217 |
builderClass := UIBuilder |
|
218 |
] ifFalse:[ |
|
219 |
builderClass := client builderClass |
|
220 |
]. |
|
221 |
builder := builderClass new. |
|
554 | 222 |
]. |
973 | 223 |
|
970
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
224 |
"/ old: |
1412 | 225 |
"/ builder buildFromSpec:subSpec in:clientView. |
970
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
226 |
|
973 | 227 |
"/ new (let app know (somehow) that this is a build |
228 |
"/ for a subcanvas (i.e. it can redefine the buildSubCanvase-method |
|
229 |
"/: |
|
970
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
230 |
savedView := builder window. |
1412 | 231 |
builder window:clientView. |
1450 | 232 |
[ |
233 |
client buildSubCanvas:subSpec withBuilder:builder. |
|
234 |
] valueNowOrOnUnwindDo:[ |
|
235 |
builder window:savedView. |
|
236 |
]. |
|
1412 | 237 |
clientViewIsScrolled ifTrue:[ |
238 |
clientView |
|
239 |
extent:(builder spec window layout rectangleRelativeTo:self bounds preferred:nil) extent. |
|
240 |
]. |
|
241 |
||
503 | 242 |
self realized ifTrue:[ |
1412 | 243 |
clientView realizeAllSubViews |
503 | 244 |
] |
245 |
] |
|
970
8cbadf2b9825
also send #postBuildWith: to the app.
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
246 |
|
973 | 247 |
"Modified: / 20.6.1998 / 14:29:00 / cg" |
503 | 248 |
! |
249 |
||
250 |
releaseAllComponents |
|
1412 | 251 |
clientView destroySubViews. |
503 | 252 |
builder := nil. |
253 |
spec := nil. |
|
254 |
client := nil. |
|
255 |
! ! |
|
256 |
||
257 |
!SubCanvas methodsFor:'change & update'! |
|
258 |
||
259 |
update:something with:aParameter from:changedObject |
|
260 |
"one of my models changed its value |
|
261 |
" |
|
557 | 262 |
(changedObject == clientHolder or:[changedObject == specHolder]) ifTrue:[ |
263 |
self updateFromChannels |
|
264 |
] ifFalse:[ |
|
265 |
super update:something with:aParameter from:changedObject. |
|
266 |
] |
|
267 |
||
268 |
! |
|
269 |
||
270 |
updateFromChannels |
|
271 |
"update canvas from channel |
|
272 |
" |
|
273 |
|client spec| |
|
274 |
||
275 |
clientHolder isNil ifTrue:[ |
|
276 |
client := self application |
|
277 |
] ifFalse:[ |
|
278 |
client := clientHolder value |
|
554 | 279 |
]. |
503 | 280 |
|
557 | 281 |
specHolder isNil ifTrue:[ |
282 |
spec := #windowSpec |
|
283 |
] ifFalse:[ |
|
284 |
spec := specHolder value |
|
285 |
]. |
|
286 |
(client notNil and:[spec notNil]) ifTrue:[ |
|
287 |
self client:client spec:spec |
|
288 |
] ifFalse:[ |
|
1450 | 289 |
spec notNil ifTrue:[ |
290 |
self halt:'spec but no app'. |
|
291 |
]. |
|
557 | 292 |
self client:nil |
293 |
] |
|
503 | 294 |
|
295 |
||
296 |
! ! |
|
297 |
||
298 |
!SubCanvas methodsFor:'initialization'! |
|
299 |
||
609 | 300 |
destroy |
301 |
clientHolder notNil ifTrue:[ |
|
302 |
clientHolder removeDependent:self. |
|
303 |
clientHolder := nil. |
|
304 |
]. |
|
305 |
specHolder notNil ifTrue:[ |
|
306 |
specHolder removeDependent:self. |
|
307 |
specHolder := nil. |
|
308 |
]. |
|
309 |
super destroy. |
|
310 |
! |
|
311 |
||
503 | 312 |
initialize |
1412 | 313 |
|
503 | 314 |
super initialize. |
1412 | 315 |
|
316 |
self scrolledView:(clientView := View new). |
|
317 |
clientViewIsScrolled := false. |
|
318 |
||
503 | 319 |
spec := #windowSpec. |
320 |
! ! |
|
321 |
||
322 |
!SubCanvas methodsFor:'queries'! |
|
323 |
||
324 |
application |
|
325 |
"return the application, under which this view was opened, |
|
326 |
" |
|
327 |
||
328 |
client notNil ifTrue:[ |
|
329 |
^ client |
|
455 | 330 |
]. |
503 | 331 |
^ super application |
332 |
||
455 | 333 |
! ! |
334 |
||
335 |
!SubCanvas class methodsFor:'documentation'! |
|
336 |
||
337 |
version |
|
1450 | 338 |
^ '$Header: /cvs/stx/stx/libwidg2/SubCanvas.st,v 1.14 1999-07-14 10:45:23 tm Exp $' |
455 | 339 |
! ! |