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