author | Claus Gittinger <cg@exept.de> |
Tue, 17 Jan 2006 13:12:39 +0100 | |
changeset 2083 | e49e0761e827 |
parent 2071 | 9be6a5197cec |
child 2361 | 3dad3198f1c4 |
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 |
||
1763 | 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 |
|
1970 | 214 |
! |
215 |
||
216 |
view |
|
217 |
||
218 |
^view |
|
219 |
! |
|
220 |
||
221 |
view: something |
|
222 |
||
223 |
view := something |
|
224 |
! |
|
225 |
||
226 |
view:viewArg spec:specArg |
|
227 |
"set instance variables (automatically generated)" |
|
228 |
||
229 |
view := viewArg. |
|
230 |
spec := specArg. |
|
86 | 231 |
! ! |
232 |
||
372
6d7718f3d298
more ST-80 compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
367
diff
changeset
|
233 |
!UIBuilder methodsFor:'building'! |
66 | 234 |
|
734 | 235 |
buildFromSpec:aSpecOrSpecArray |
2071 | 236 |
spec := UISpecification from:aSpecOrSpecArray. |
734 | 237 |
window notNil ifTrue:[ |
2071 | 238 |
spec buildViewFor:self in:window. |
239 |
] ifFalse:[ |
|
240 |
window := spec buildViewFor:self in:nil. |
|
734 | 241 |
]. |
242 |
^ window |
|
243 |
! |
|
244 |
||
245 |
buildFromSpec:aSpecArray in:aView |
|
246 |
spec := UISpecification from:aSpecArray. |
|
247 |
^ spec buildViewFor:self in:aView. |
|
248 |
||
249 |
"Modified: 3.3.1997 / 18:44:02 / cg" |
|
250 |
! |
|
251 |
||
252 |
doFinalHookup |
|
253 |
||
254 |
"Created: 14.2.1997 / 14:52:27 / cg" |
|
255 |
! |
|
256 |
||
257 |
newSubBuilder |
|
258 |
|builder| |
|
259 |
||
260 |
builder := UIBuilder new. |
|
751 | 261 |
|
262 |
builder isEditing:isEditing. |
|
863 | 263 |
builder showDefaults:showDefaults. |
734 | 264 |
builder bindings:(self bindings). |
265 |
builder application:(self application). |
|
854 | 266 |
"/ builder applicationClass:applicationClass. |
751 | 267 |
^ builder |
734 | 268 |
! ! |
269 |
||
1772 | 270 |
!UIBuilder methodsFor:'building-programatically'! |
734 | 271 |
|
367 | 272 |
add:aSpec |
1359
f40bfb94f862
allow for application to decide what type of
Claus Gittinger <cg@exept.de>
parents:
1325
diff
changeset
|
273 |
|collectedComponents appWinClass| |
478 | 274 |
|
275 |
composite notNil ifTrue:[ |
|
276 |
(collectedComponents := composite collection) isNil ifTrue:[ |
|
277 |
composite collection:(collectedComponents := OrderedCollection new). |
|
278 |
]. |
|
279 |
collectedComponents add:aSpec. |
|
280 |
view := aSpec buildViewWithLayoutFor:self in:compositeView. |
|
281 |
] ifFalse:[ |
|
282 |
spec isNil ifTrue:[ |
|
283 |
spec := FullSpec new. |
|
284 |
]. |
|
285 |
||
286 |
(aSpec isMemberOf:WindowSpec) ifTrue:[ |
|
287 |
spec window:aSpec |
|
288 |
] ifFalse:[ |
|
289 |
((aSpec isMemberOf:ComponentSpec) |
|
290 |
or:[(aSpec isMemberOf:SpecCollection)]) ifTrue:[ |
|
291 |
spec component:aSpec. |
|
292 |
||
293 |
window isNil ifTrue:[ |
|
1359
f40bfb94f862
allow for application to decide what type of
Claus Gittinger <cg@exept.de>
parents:
1325
diff
changeset
|
294 |
application notNil ifTrue:[ |
f40bfb94f862
allow for application to decide what type of
Claus Gittinger <cg@exept.de>
parents:
1325
diff
changeset
|
295 |
appWinClass := application applicationWindowClass |
f40bfb94f862
allow for application to decide what type of
Claus Gittinger <cg@exept.de>
parents:
1325
diff
changeset
|
296 |
] ifFalse:[ |
f40bfb94f862
allow for application to decide what type of
Claus Gittinger <cg@exept.de>
parents:
1325
diff
changeset
|
297 |
appWinClass := ApplicationWindow |
f40bfb94f862
allow for application to decide what type of
Claus Gittinger <cg@exept.de>
parents:
1325
diff
changeset
|
298 |
]. |
f40bfb94f862
allow for application to decide what type of
Claus Gittinger <cg@exept.de>
parents:
1325
diff
changeset
|
299 |
window := appWinClass new. |
734 | 300 |
window extent:300@300. |
478 | 301 |
]. |
302 |
aSpec buildViewWithLayoutFor:self in:window. |
|
303 |
"/ builder window displayBox |
|
304 |
composite := aSpec. |
|
305 |
compositeView := window. |
|
306 |
] ifFalse:[ |
|
307 |
spec component isNil ifTrue:[ |
|
308 |
spec component:SpecCollection new. |
|
309 |
spec component collection:OrderedCollection new. |
|
310 |
]. |
|
734 | 311 |
composite := spec component. |
312 |
window isNil ifTrue:[ |
|
965
04cadbd21aac
use new ApplicationWindow (instead of StandardSystemView)
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
313 |
window := ApplicationWindow new. |
734 | 314 |
window extent:300@300. |
315 |
]. |
|
316 |
compositeView := window. |
|
478 | 317 |
spec component collection add:aSpec. |
318 |
view := aSpec buildViewWithLayoutFor:self in:compositeView. |
|
319 |
]. |
|
320 |
] |
|
321 |
]. |
|
322 |
||
323 |
lastComponent := view. |
|
367 | 324 |
^ view |
325 |
||
965
04cadbd21aac
use new ApplicationWindow (instead of StandardSystemView)
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
326 |
"Modified: / 18.6.1998 / 19:09:38 / cg" |
478 | 327 |
! |
328 |
||
329 |
endComposite |
|
734 | 330 |
|entry finishedComposite finishedView| |
478 | 331 |
|
2083 | 332 |
(specStack notEmptyOrNil) ifTrue:[ |
734 | 333 |
finishedComposite := composite. |
334 |
finishedView := compositeView. |
|
335 |
||
336 |
"/ pop |
|
478 | 337 |
entry := specStack removeLast. |
338 |
composite := entry key. |
|
339 |
compositeView := entry value. |
|
734 | 340 |
|
341 |
lastComponent := finishedView. |
|
342 |
^ finishedComposite |
|
478 | 343 |
]. |
734 | 344 |
self halt. |
478 | 345 |
^ composite |
346 |
||
734 | 347 |
"Created: / 3.3.1997 / 17:17:43 / cg" |
348 |
"Modified: / 30.10.1997 / 23:28:04 / cg" |
|
478 | 349 |
! |
350 |
||
351 |
endCompositeLayout:layout |
|
734 | 352 |
composite compositeSpec isNil ifTrue:[ |
353 |
composite compositeSpec:(CompositeSpec new). |
|
354 |
]. |
|
355 |
composite compositeSpec layout:layout. |
|
479 | 356 |
compositeView layout:layout. |
478 | 357 |
self endComposite |
358 |
||
734 | 359 |
"Modified: / 30.10.1997 / 23:10:10 / cg" |
479 | 360 |
! |
361 |
||
362 |
endCompositeLayout:layout properties:props |
|
363 |
self endCompositeLayout:layout |
|
364 |
||
365 |
"Created: 3.3.1997 / 22:15:17 / cg" |
|
478 | 366 |
! |
367 |
||
368 |
newComposite |
|
369 |
|newComposite| |
|
370 |
||
734 | 371 |
"/ push the composite being built ... |
478 | 372 |
specStack isNil ifTrue:[ |
373 |
specStack := OrderedCollection new |
|
374 |
]. |
|
375 |
specStack addLast:(composite->compositeView). |
|
734 | 376 |
|
377 |
"/ start creating a new one ... |
|
478 | 378 |
newComposite := CompositeSpecCollection new. |
379 |
newComposite compositeSpec:(CompositeSpec new). |
|
380 |
compositeView := self add:newComposite. |
|
381 |
composite := newComposite. |
|
382 |
^ compositeView |
|
383 |
||
734 | 384 |
"Created: / 3.3.1997 / 17:15:36 / cg" |
385 |
"Modified: / 1.11.1997 / 02:48:44 / cg" |
|
100 | 386 |
! ! |
86 | 387 |
|
479 | 388 |
!UIBuilder methodsFor:'initialization'! |
389 |
||
390 |
setupWindowFor:aView |
|
391 |
|ext| |
|
392 |
||
393 |
window notNil ifTrue:[ |
|
394 |
ext := window extent. |
|
395 |
||
396 |
((window isMemberOf:View) |
|
397 |
or:[window isMemberOf:SimpleView]) ifTrue:[ |
|
398 |
aView addSubView:window. |
|
399 |
]. |
|
400 |
]. |
|
401 |
||
402 |
window := aView. |
|
403 |
||
404 |
aView container isNil ifTrue:[ |
|
405 |
spec notNil ifTrue:[ |
|
406 |
spec window setupView:window for:self |
|
407 |
] |
|
408 |
]. |
|
409 |
||
775 | 410 |
"Modified: / 27.1.1998 / 12:27:45 / cg" |
479 | 411 |
! ! |
412 |
||
132 | 413 |
!UIBuilder class methodsFor:'documentation'! |
414 |
||
415 |
version |
|
2083 | 416 |
^ '$Header: /cvs/stx/stx/libview2/UIBuilder.st,v 1.56 2006-01-17 12:12:39 cg Exp $' |
132 | 417 |
! ! |
1763 | 418 |
|
100 | 419 |
UIBuilder initialize! |