author | Claus Gittinger <cg@exept.de> |
Mon, 12 Apr 1999 13:19:11 +0200 | |
changeset 1157 | feeae3138d3d |
parent 1145 | 93aade1b7265 |
child 1204 | a043422d0565 |
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 |
1121 | 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 |
|
1145 | 179 |
! |
180 |
||
181 |
spec |
|
182 |
"return the current spec" |
|
183 |
||
184 |
^ spec |
|
86 | 185 |
! ! |
186 |
||
372
6d7718f3d298
more ST-80 compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
367
diff
changeset
|
187 |
!UIBuilder methodsFor:'building'! |
66 | 188 |
|
734 | 189 |
buildFromSpec:aSpecOrSpecArray |
190 |
window notNil ifTrue:[ |
|
191 |
^ self buildFromSpec:aSpecOrSpecArray in:window |
|
192 |
]. |
|
193 |
||
194 |
spec := UISpecification from:aSpecOrSpecArray. |
|
195 |
window := spec buildViewFor:self. |
|
196 |
||
197 |
^ window |
|
198 |
||
199 |
"Modified: / 5.9.1995 / 21:43:29 / claus" |
|
200 |
"Modified: / 31.10.1997 / 18:41:14 / cg" |
|
201 |
! |
|
202 |
||
203 |
buildFromSpec:aSpecArray in:aView |
|
204 |
spec := UISpecification from:aSpecArray. |
|
205 |
^ spec buildViewFor:self in:aView. |
|
206 |
||
207 |
"Modified: 3.3.1997 / 18:44:02 / cg" |
|
208 |
! |
|
209 |
||
210 |
doFinalHookup |
|
211 |
||
212 |
"Created: 14.2.1997 / 14:52:27 / cg" |
|
213 |
! |
|
214 |
||
215 |
newSubBuilder |
|
216 |
|builder| |
|
217 |
||
218 |
builder := UIBuilder new. |
|
751 | 219 |
|
220 |
builder isEditing:isEditing. |
|
863 | 221 |
builder showDefaults:showDefaults. |
734 | 222 |
builder bindings:(self bindings). |
223 |
builder application:(self application). |
|
854 | 224 |
"/ builder applicationClass:applicationClass. |
751 | 225 |
^ builder |
734 | 226 |
! ! |
227 |
||
228 |
!UIBuilder methodsFor:'building - programatically'! |
|
229 |
||
367 | 230 |
add:aSpec |
478 | 231 |
|collectedComponents| |
232 |
||
233 |
composite notNil ifTrue:[ |
|
234 |
(collectedComponents := composite collection) isNil ifTrue:[ |
|
235 |
composite collection:(collectedComponents := OrderedCollection new). |
|
236 |
]. |
|
237 |
collectedComponents add:aSpec. |
|
238 |
view := aSpec buildViewWithLayoutFor:self in:compositeView. |
|
239 |
] ifFalse:[ |
|
240 |
spec isNil ifTrue:[ |
|
241 |
spec := FullSpec new. |
|
242 |
]. |
|
243 |
||
244 |
(aSpec isMemberOf:WindowSpec) ifTrue:[ |
|
245 |
spec window:aSpec |
|
246 |
] ifFalse:[ |
|
247 |
((aSpec isMemberOf:ComponentSpec) |
|
248 |
or:[(aSpec isMemberOf:SpecCollection)]) ifTrue:[ |
|
249 |
spec component:aSpec. |
|
250 |
||
251 |
window isNil ifTrue:[ |
|
965
04cadbd21aac
use new ApplicationWindow (instead of StandardSystemView)
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
252 |
window := ApplicationWindow new. |
734 | 253 |
window extent:300@300. |
478 | 254 |
]. |
255 |
aSpec buildViewWithLayoutFor:self in:window. |
|
256 |
"/ builder window displayBox |
|
257 |
composite := aSpec. |
|
258 |
compositeView := window. |
|
259 |
] ifFalse:[ |
|
260 |
spec component isNil ifTrue:[ |
|
261 |
spec component:SpecCollection new. |
|
262 |
spec component collection:OrderedCollection new. |
|
263 |
]. |
|
734 | 264 |
composite := spec component. |
265 |
window isNil ifTrue:[ |
|
965
04cadbd21aac
use new ApplicationWindow (instead of StandardSystemView)
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
266 |
window := ApplicationWindow new. |
734 | 267 |
window extent:300@300. |
268 |
]. |
|
269 |
compositeView := window. |
|
478 | 270 |
spec component collection add:aSpec. |
271 |
view := aSpec buildViewWithLayoutFor:self in:compositeView. |
|
272 |
]. |
|
273 |
] |
|
274 |
]. |
|
275 |
||
276 |
lastComponent := view. |
|
367 | 277 |
^ view |
278 |
||
965
04cadbd21aac
use new ApplicationWindow (instead of StandardSystemView)
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
279 |
"Modified: / 18.6.1998 / 19:09:38 / cg" |
478 | 280 |
! |
281 |
||
282 |
endComposite |
|
734 | 283 |
|entry finishedComposite finishedView| |
478 | 284 |
|
497 | 285 |
(specStack notNil and:[specStack notEmpty]) ifTrue:[ |
734 | 286 |
finishedComposite := composite. |
287 |
finishedView := compositeView. |
|
288 |
||
289 |
"/ pop |
|
478 | 290 |
entry := specStack removeLast. |
291 |
composite := entry key. |
|
292 |
compositeView := entry value. |
|
734 | 293 |
|
294 |
lastComponent := finishedView. |
|
295 |
^ finishedComposite |
|
478 | 296 |
]. |
734 | 297 |
self halt. |
478 | 298 |
^ composite |
299 |
||
734 | 300 |
"Created: / 3.3.1997 / 17:17:43 / cg" |
301 |
"Modified: / 30.10.1997 / 23:28:04 / cg" |
|
478 | 302 |
! |
303 |
||
304 |
endCompositeLayout:layout |
|
734 | 305 |
composite compositeSpec isNil ifTrue:[ |
306 |
composite compositeSpec:(CompositeSpec new). |
|
307 |
]. |
|
308 |
composite compositeSpec layout:layout. |
|
479 | 309 |
compositeView layout:layout. |
478 | 310 |
self endComposite |
311 |
||
734 | 312 |
"Modified: / 30.10.1997 / 23:10:10 / cg" |
479 | 313 |
! |
314 |
||
315 |
endCompositeLayout:layout properties:props |
|
316 |
self endCompositeLayout:layout |
|
317 |
||
318 |
"Created: 3.3.1997 / 22:15:17 / cg" |
|
478 | 319 |
! |
320 |
||
321 |
newComposite |
|
322 |
|newComposite| |
|
323 |
||
734 | 324 |
"/ push the composite being built ... |
478 | 325 |
specStack isNil ifTrue:[ |
326 |
specStack := OrderedCollection new |
|
327 |
]. |
|
328 |
specStack addLast:(composite->compositeView). |
|
734 | 329 |
|
330 |
"/ start creating a new one ... |
|
478 | 331 |
newComposite := CompositeSpecCollection new. |
332 |
newComposite compositeSpec:(CompositeSpec new). |
|
333 |
compositeView := self add:newComposite. |
|
334 |
composite := newComposite. |
|
335 |
^ compositeView |
|
336 |
||
734 | 337 |
"Created: / 3.3.1997 / 17:15:36 / cg" |
338 |
"Modified: / 1.11.1997 / 02:48:44 / cg" |
|
100 | 339 |
! ! |
86 | 340 |
|
479 | 341 |
!UIBuilder methodsFor:'initialization'! |
342 |
||
343 |
setupWindowFor:aView |
|
344 |
|ext| |
|
345 |
||
346 |
window notNil ifTrue:[ |
|
347 |
ext := window extent. |
|
348 |
||
349 |
((window isMemberOf:View) |
|
350 |
or:[window isMemberOf:SimpleView]) ifTrue:[ |
|
351 |
aView addSubView:window. |
|
352 |
]. |
|
353 |
]. |
|
354 |
||
355 |
window := aView. |
|
356 |
||
357 |
aView container isNil ifTrue:[ |
|
358 |
spec notNil ifTrue:[ |
|
359 |
spec window setupView:window for:self |
|
360 |
] |
|
361 |
]. |
|
362 |
||
775 | 363 |
"Modified: / 27.1.1998 / 12:27:45 / cg" |
479 | 364 |
! ! |
365 |
||
132 | 366 |
!UIBuilder class methodsFor:'documentation'! |
367 |
||
368 |
version |
|
1145 | 369 |
^ '$Header: /cvs/stx/stx/libview2/UIBuilder.st,v 1.41 1999-03-18 14:46:19 tm Exp $' |
132 | 370 |
! ! |
100 | 371 |
UIBuilder initialize! |