author | Claus Gittinger <cg@exept.de> |
Tue, 04 Sep 2001 20:58:36 +0200 | |
changeset 1498 | 677de8e0b423 |
parent 1447 | 879dc0a647c2 |
child 1763 | fabe0b506e33 |
permissions | -rw-r--r-- |
88 | 1 |
" |
2 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
734 | 3 |
All Rights Reserved |
88 | 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 |
||
1389 | 13 |
"{ Package: 'stx:libview2' }" |
14 |
||
100 | 15 |
WindowBuilder subclass:#UIBuilder |
734 | 16 |
instanceVariableNames:'view currentMenuSelector spec specStack composite lastComponent |
1324 | 17 |
compositeView menuBar isEditing showDefaults isSubBuilder' |
1032 | 18 |
classVariableNames:'' |
223 | 19 |
poolDictionaries:'' |
20 |
category:'Interface-Support-UI' |
|
66 | 21 |
! |
22 |
||
23 |
!UIBuilder class methodsFor:'documentation'! |
|
24 |
||
125 | 25 |
copyright |
26 |
" |
|
27 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
734 | 28 |
All Rights Reserved |
125 | 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 |
" |
|
88 | 37 |
! |
38 |
||
66 | 39 |
documentation |
40 |
" |
|
775 | 41 |
this class allows parsing windowSpecs as created by ST/X's |
42 |
UIPainter and should be able to handle most of ST-80's specs. |
|
43 |
(and thereby allow to run applications built with this tool). |
|
44 |
However, it is not guaranteed that all of ST-80's winSpecs are understood. |
|
45 |
||
734 | 46 |
It also provides some rudimentary support for building interfaces |
47 |
programatically, by using #newComposite .. #add: .. #endComposite. |
|
48 |
This has been added for ST80-compatibility - we do not recommend using |
|
49 |
that for new ST/X programs. |
|
775 | 50 |
Those were added to allow execution of some PD applications. |
51 |
The programatic building protocol is not complete and certainly not bug free. |
|
223 | 52 |
|
373 | 53 |
Notice: |
775 | 54 |
some of this class was implemented using protocol information |
734 | 55 |
from alpha testers, literature and by reading public domain code |
373 | 56 |
- it may not be complete or compatible to |
57 |
the corresponding ST-80 class. |
|
58 |
If you encounter any incompatibilities, please forward a note |
|
59 |
describing the incompatibility verbal (i.e. no code) to the ST/X team. |
|
60 |
||
775 | 61 |
[instance variables:] |
62 |
view <View> |
|
63 |
temporary - holds the view being built |
|
64 |
when creating components using the |
|
65 |
programmatic building interface. |
|
66 |
||
67 |
currentMenuSelector not yet used |
|
68 |
||
69 |
spec <UISpec> |
|
70 |
temporary - holds the spec being parsed |
|
71 |
when creating components using the |
|
72 |
programmatic building interface. |
|
73 |
||
74 |
specStack <Collection> |
|
75 |
temporary - holds the spec-stack when |
|
76 |
creating composites using newComposite/ |
|
77 |
endComposite, |
|
78 |
while creating components using the |
|
79 |
programmatic building interface. |
|
80 |
||
81 |
composite <SpecCollection> |
|
82 |
temporary - holds the current composite |
|
83 |
when using newComposite/ endComposite, |
|
84 |
while creating components using the |
|
85 |
programmatic building interface. |
|
86 |
||
87 |
lastComponent <View> |
|
88 |
temporary - holds the last component |
|
89 |
being built, |
|
90 |
when creating components using the |
|
91 |
programmatic building interface. |
|
92 |
||
93 |
compositeView <View> |
|
94 |
temporary - holds the current composites |
|
95 |
view, when creating components using the |
|
96 |
programmatic building interface. |
|
97 |
||
98 |
menuBar not yet used |
|
99 |
||
100 |
isEditing <Boolean> |
|
101 |
flag which is set when an interface is built |
|
102 |
by the UIPainter (as opposed to being built |
|
103 |
for the application). |
|
104 |
Changes the way aspects are aquired, |
|
105 |
(actually, no models are created/set) |
|
106 |
to prevent false building when no |
|
107 |
real applicationModel is present. |
|
108 |
(as is the case when the painter builds |
|
109 |
components). |
|
110 |
||
223 | 111 |
[author:] |
112 |
Claus Gittinger |
|
66 | 113 |
" |
114 |
! ! |
|
115 |
||
116 |
!UIBuilder class methodsFor:'initialization'! |
|
117 |
||
118 |
initialize |
|
119 |
Verbose := false "/ debugging flag |
|
120 |
! ! |
|
121 |
||
1498 | 122 |
!UIBuilder methodsFor:'Compatibility - VW'! |
734 | 123 |
|
124 |
wrapper |
|
125 |
"ST/X has no wrappers - return the view here" |
|
126 |
||
1207 | 127 |
^ view ? window |
734 | 128 |
|
129 |
"Created: / 3.3.1997 / 18:28:31 / cg" |
|
130 |
"Modified: / 31.10.1997 / 18:42:52 / cg" |
|
131 |
! ! |
|
132 |
||
86 | 133 |
!UIBuilder methodsFor:'accessing'! |
134 |
||
751 | 135 |
isEditing |
136 |
"true if build from a GUI builder resource ( UIPainter, ... ); if true, no |
|
137 |
models or actions should be set (no application is running) |
|
138 |
" |
|
139 |
^ isEditing ? false |
|
140 |
! |
|
141 |
||
142 |
isEditing:aState |
|
143 |
"true if build from a GUI builder resource ( UIPainter, ... ); if true, no |
|
144 |
models or actions should be set (no application is running) |
|
145 |
" |
|
146 |
isEditing := aState |
|
147 |
! |
|
148 |
||
1324 | 149 |
isSubBuilder |
1325 | 150 |
"return true, if this uiBuilder is for a subCanvas (i.e. a subApp) |
151 |
as opposed to a topApp builder" |
|
152 |
||
1324 | 153 |
^ isSubBuilder ? false |
154 |
||
155 |
"Created: / 29.1.2000 / 16:31:31 / cg" |
|
1325 | 156 |
"Modified: / 31.1.2000 / 15:03:09 / cg" |
1324 | 157 |
! |
158 |
||
159 |
isSubBuilder:aBoolean |
|
1325 | 160 |
"set/clear the flag, which states that this uiBuilder is for a subCanvas (i.e. a subApp) |
161 |
as opposed to a topApp builder. The default is false." |
|
162 |
||
1324 | 163 |
isSubBuilder := aBoolean |
164 |
||
165 |
"Created: / 29.1.2000 / 16:31:19 / cg" |
|
1325 | 166 |
"Modified: / 31.1.2000 / 15:03:37 / cg" |
1324 | 167 |
! |
168 |
||
721
1889d708a951
provide a handle to the applications menuBar
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
169 |
menuBar |
1889d708a951
provide a handle to the applications menuBar
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
170 |
"return the value of the instance variable 'menuBar' (automatically generated)" |
1889d708a951
provide a handle to the applications menuBar
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
171 |
|
1889d708a951
provide a handle to the applications menuBar
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
172 |
^ menuBar |
1889d708a951
provide a handle to the applications menuBar
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
173 |
|
1889d708a951
provide a handle to the applications menuBar
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
174 |
"Created: / 27.10.1997 / 16:30:12 / cg" |
1889d708a951
provide a handle to the applications menuBar
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
175 |
! |
1889d708a951
provide a handle to the applications menuBar
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
176 |
|
1889d708a951
provide a handle to the applications menuBar
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
177 |
menuBar:something |
1889d708a951
provide a handle to the applications menuBar
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
178 |
"set the value of the instance variable 'menuBar' (automatically generated)" |
1889d708a951
provide a handle to the applications menuBar
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
179 |
|
1889d708a951
provide a handle to the applications menuBar
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
180 |
menuBar := something. |
1246 | 181 |
self keyboardProcessor menuBar:menuBar. |
721
1889d708a951
provide a handle to the applications menuBar
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
182 |
|
1889d708a951
provide a handle to the applications menuBar
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
183 |
"Created: / 27.10.1997 / 16:30:13 / cg" |
863 | 184 |
! |
185 |
||
186 |
showDefaults |
|
187 |
"returns true if the builder is in editing mode and the building |
|
188 |
components will build a default contents |
|
189 |
" |
|
190 |
self isEditing ifTrue:[ |
|
191 |
^ showDefaults ? false |
|
192 |
]. |
|
193 |
^ false |
|
194 |
||
195 |
! |
|
196 |
||
197 |
showDefaults:aBool |
|
198 |
"true if the builder is in editing mode and the building |
|
199 |
components will build a default contents |
|
200 |
" |
|
201 |
showDefaults := aBool |
|
1145 | 202 |
! |
203 |
||
204 |
spec |
|
205 |
"return the current spec" |
|
206 |
||
207 |
^ spec |
|
1204 | 208 |
! |
209 |
||
210 |
spec:aSpec |
|
211 |
"set the current spec" |
|
212 |
||
213 |
spec := aSpec |
|
86 | 214 |
! ! |
215 |
||
372
6d7718f3d298
more ST-80 compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
367
diff
changeset
|
216 |
!UIBuilder methodsFor:'building'! |
66 | 217 |
|
734 | 218 |
buildFromSpec:aSpecOrSpecArray |
219 |
window notNil ifTrue:[ |
|
220 |
^ self buildFromSpec:aSpecOrSpecArray in:window |
|
221 |
]. |
|
222 |
||
223 |
spec := UISpecification from:aSpecOrSpecArray. |
|
224 |
window := spec buildViewFor:self. |
|
225 |
||
226 |
^ window |
|
227 |
||
228 |
"Modified: / 5.9.1995 / 21:43:29 / claus" |
|
229 |
"Modified: / 31.10.1997 / 18:41:14 / cg" |
|
230 |
! |
|
231 |
||
232 |
buildFromSpec:aSpecArray in:aView |
|
233 |
spec := UISpecification from:aSpecArray. |
|
234 |
^ spec buildViewFor:self in:aView. |
|
235 |
||
236 |
"Modified: 3.3.1997 / 18:44:02 / cg" |
|
237 |
! |
|
238 |
||
239 |
doFinalHookup |
|
240 |
||
241 |
"Created: 14.2.1997 / 14:52:27 / cg" |
|
242 |
! |
|
243 |
||
244 |
newSubBuilder |
|
245 |
|builder| |
|
246 |
||
247 |
builder := UIBuilder new. |
|
751 | 248 |
|
249 |
builder isEditing:isEditing. |
|
863 | 250 |
builder showDefaults:showDefaults. |
734 | 251 |
builder bindings:(self bindings). |
252 |
builder application:(self application). |
|
854 | 253 |
"/ builder applicationClass:applicationClass. |
751 | 254 |
^ builder |
734 | 255 |
! ! |
256 |
||
257 |
!UIBuilder methodsFor:'building - programatically'! |
|
258 |
||
367 | 259 |
add:aSpec |
1359
f40bfb94f862
allow for application to decide what type of
Claus Gittinger <cg@exept.de>
parents:
1325
diff
changeset
|
260 |
|collectedComponents appWinClass| |
478 | 261 |
|
262 |
composite notNil ifTrue:[ |
|
263 |
(collectedComponents := composite collection) isNil ifTrue:[ |
|
264 |
composite collection:(collectedComponents := OrderedCollection new). |
|
265 |
]. |
|
266 |
collectedComponents add:aSpec. |
|
267 |
view := aSpec buildViewWithLayoutFor:self in:compositeView. |
|
268 |
] ifFalse:[ |
|
269 |
spec isNil ifTrue:[ |
|
270 |
spec := FullSpec new. |
|
271 |
]. |
|
272 |
||
273 |
(aSpec isMemberOf:WindowSpec) ifTrue:[ |
|
274 |
spec window:aSpec |
|
275 |
] ifFalse:[ |
|
276 |
((aSpec isMemberOf:ComponentSpec) |
|
277 |
or:[(aSpec isMemberOf:SpecCollection)]) ifTrue:[ |
|
278 |
spec component:aSpec. |
|
279 |
||
280 |
window isNil ifTrue:[ |
|
1359
f40bfb94f862
allow for application to decide what type of
Claus Gittinger <cg@exept.de>
parents:
1325
diff
changeset
|
281 |
application notNil ifTrue:[ |
f40bfb94f862
allow for application to decide what type of
Claus Gittinger <cg@exept.de>
parents:
1325
diff
changeset
|
282 |
appWinClass := application applicationWindowClass |
f40bfb94f862
allow for application to decide what type of
Claus Gittinger <cg@exept.de>
parents:
1325
diff
changeset
|
283 |
] ifFalse:[ |
f40bfb94f862
allow for application to decide what type of
Claus Gittinger <cg@exept.de>
parents:
1325
diff
changeset
|
284 |
appWinClass := ApplicationWindow |
f40bfb94f862
allow for application to decide what type of
Claus Gittinger <cg@exept.de>
parents:
1325
diff
changeset
|
285 |
]. |
f40bfb94f862
allow for application to decide what type of
Claus Gittinger <cg@exept.de>
parents:
1325
diff
changeset
|
286 |
window := appWinClass new. |
734 | 287 |
window extent:300@300. |
478 | 288 |
]. |
289 |
aSpec buildViewWithLayoutFor:self in:window. |
|
290 |
"/ builder window displayBox |
|
291 |
composite := aSpec. |
|
292 |
compositeView := window. |
|
293 |
] ifFalse:[ |
|
294 |
spec component isNil ifTrue:[ |
|
295 |
spec component:SpecCollection new. |
|
296 |
spec component collection:OrderedCollection new. |
|
297 |
]. |
|
734 | 298 |
composite := spec component. |
299 |
window isNil ifTrue:[ |
|
965
04cadbd21aac
use new ApplicationWindow (instead of StandardSystemView)
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
300 |
window := ApplicationWindow new. |
734 | 301 |
window extent:300@300. |
302 |
]. |
|
303 |
compositeView := window. |
|
478 | 304 |
spec component collection add:aSpec. |
305 |
view := aSpec buildViewWithLayoutFor:self in:compositeView. |
|
306 |
]. |
|
307 |
] |
|
308 |
]. |
|
309 |
||
310 |
lastComponent := view. |
|
367 | 311 |
^ view |
312 |
||
965
04cadbd21aac
use new ApplicationWindow (instead of StandardSystemView)
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
313 |
"Modified: / 18.6.1998 / 19:09:38 / cg" |
478 | 314 |
! |
315 |
||
316 |
endComposite |
|
734 | 317 |
|entry finishedComposite finishedView| |
478 | 318 |
|
497 | 319 |
(specStack notNil and:[specStack notEmpty]) ifTrue:[ |
734 | 320 |
finishedComposite := composite. |
321 |
finishedView := compositeView. |
|
322 |
||
323 |
"/ pop |
|
478 | 324 |
entry := specStack removeLast. |
325 |
composite := entry key. |
|
326 |
compositeView := entry value. |
|
734 | 327 |
|
328 |
lastComponent := finishedView. |
|
329 |
^ finishedComposite |
|
478 | 330 |
]. |
734 | 331 |
self halt. |
478 | 332 |
^ composite |
333 |
||
734 | 334 |
"Created: / 3.3.1997 / 17:17:43 / cg" |
335 |
"Modified: / 30.10.1997 / 23:28:04 / cg" |
|
478 | 336 |
! |
337 |
||
338 |
endCompositeLayout:layout |
|
734 | 339 |
composite compositeSpec isNil ifTrue:[ |
340 |
composite compositeSpec:(CompositeSpec new). |
|
341 |
]. |
|
342 |
composite compositeSpec layout:layout. |
|
479 | 343 |
compositeView layout:layout. |
478 | 344 |
self endComposite |
345 |
||
734 | 346 |
"Modified: / 30.10.1997 / 23:10:10 / cg" |
479 | 347 |
! |
348 |
||
349 |
endCompositeLayout:layout properties:props |
|
350 |
self endCompositeLayout:layout |
|
351 |
||
352 |
"Created: 3.3.1997 / 22:15:17 / cg" |
|
478 | 353 |
! |
354 |
||
355 |
newComposite |
|
356 |
|newComposite| |
|
357 |
||
734 | 358 |
"/ push the composite being built ... |
478 | 359 |
specStack isNil ifTrue:[ |
360 |
specStack := OrderedCollection new |
|
361 |
]. |
|
362 |
specStack addLast:(composite->compositeView). |
|
734 | 363 |
|
364 |
"/ start creating a new one ... |
|
478 | 365 |
newComposite := CompositeSpecCollection new. |
366 |
newComposite compositeSpec:(CompositeSpec new). |
|
367 |
compositeView := self add:newComposite. |
|
368 |
composite := newComposite. |
|
369 |
^ compositeView |
|
370 |
||
734 | 371 |
"Created: / 3.3.1997 / 17:15:36 / cg" |
372 |
"Modified: / 1.11.1997 / 02:48:44 / cg" |
|
100 | 373 |
! ! |
86 | 374 |
|
479 | 375 |
!UIBuilder methodsFor:'initialization'! |
376 |
||
377 |
setupWindowFor:aView |
|
378 |
|ext| |
|
379 |
||
380 |
window notNil ifTrue:[ |
|
381 |
ext := window extent. |
|
382 |
||
383 |
((window isMemberOf:View) |
|
384 |
or:[window isMemberOf:SimpleView]) ifTrue:[ |
|
385 |
aView addSubView:window. |
|
386 |
]. |
|
387 |
]. |
|
388 |
||
389 |
window := aView. |
|
390 |
||
391 |
aView container isNil ifTrue:[ |
|
392 |
spec notNil ifTrue:[ |
|
393 |
spec window setupView:window for:self |
|
394 |
] |
|
395 |
]. |
|
396 |
||
775 | 397 |
"Modified: / 27.1.1998 / 12:27:45 / cg" |
479 | 398 |
! ! |
399 |
||
132 | 400 |
!UIBuilder class methodsFor:'documentation'! |
401 |
||
402 |
version |
|
1498 | 403 |
^ '$Header: /cvs/stx/stx/libview2/UIBuilder.st,v 1.51 2001-09-04 18:58:28 cg Exp $' |
132 | 404 |
! ! |
100 | 405 |
UIBuilder initialize! |