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