author | Claus Gittinger <cg@exept.de> |
Tue, 28 Oct 1997 20:14:37 +0100 | |
changeset 721 | 1889d708a951 |
parent 667 | fe63e8ecb0d3 |
child 734 | f1079f443a75 |
permissions | -rw-r--r-- |
88 | 1 |
" |
2 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
100 | 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 |
478 | 14 |
instanceVariableNames:'view currentMenuSelector menuAspect spec specStack composite |
721
1889d708a951
provide a handle to the applications menuBar
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
15 |
lastComponent compositeView menuBar' |
223 | 16 |
classVariableNames:'Verbose' |
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 |
|
26 |
All Rights Reserved |
|
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 |
" |
|
39 |
this class will (eventually) allow parsing windowSpecs as |
|
40 |
created by ST-80's UIPainter, and thereby allow to run applications |
|
41 |
built with this tool. |
|
42 |
It was created to allow execution of PD applications which were |
|
43 |
written using that tool (and more and more are appearing ...). |
|
44 |
||
45 |
The class is not completed yet and certainly not bug free. |
|
46 |
Also, it is not quaranteed that all winSpecs are understood. |
|
223 | 47 |
|
373 | 48 |
Notice: |
49 |
this class was implemented using protocol information |
|
50 |
from alpha testers, literature and by read public domain code |
|
51 |
- it may not be complete or compatible to |
|
52 |
the corresponding ST-80 class. |
|
53 |
If you encounter any incompatibilities, please forward a note |
|
54 |
describing the incompatibility verbal (i.e. no code) to the ST/X team. |
|
55 |
||
223 | 56 |
[author:] |
57 |
Claus Gittinger |
|
66 | 58 |
" |
478 | 59 |
! |
60 |
||
61 |
examples |
|
62 |
" |
|
63 |
examples to be added. |
|
64 |
" |
|
65 |
! |
|
66 |
||
67 |
history |
|
68 |
"Created: 3.3.1997 / 19:33:13 / cg" |
|
66 | 69 |
! ! |
70 |
||
71 |
!UIBuilder class methodsFor:'initialization'! |
|
72 |
||
73 |
initialize |
|
74 |
Verbose := false "/ debugging flag |
|
75 |
! ! |
|
76 |
||
86 | 77 |
!UIBuilder methodsFor:'accessing'! |
78 |
||
79 |
menuAspect |
|
80 |
^ menuAspect |
|
721
1889d708a951
provide a handle to the applications menuBar
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
81 |
! |
1889d708a951
provide a handle to the applications menuBar
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
82 |
|
1889d708a951
provide a handle to the applications menuBar
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
83 |
menuBar |
1889d708a951
provide a handle to the applications menuBar
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
84 |
"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
|
85 |
|
1889d708a951
provide a handle to the applications menuBar
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
86 |
^ menuBar |
1889d708a951
provide a handle to the applications menuBar
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
87 |
|
1889d708a951
provide a handle to the applications menuBar
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
88 |
"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
|
89 |
! |
1889d708a951
provide a handle to the applications menuBar
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
90 |
|
1889d708a951
provide a handle to the applications menuBar
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
91 |
menuBar:something |
1889d708a951
provide a handle to the applications menuBar
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
92 |
"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
|
93 |
|
1889d708a951
provide a handle to the applications menuBar
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
94 |
menuBar := something. |
1889d708a951
provide a handle to the applications menuBar
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
95 |
|
1889d708a951
provide a handle to the applications menuBar
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
96 |
"Created: / 27.10.1997 / 16:30:13 / cg" |
86 | 97 |
! ! |
98 |
||
372
6d7718f3d298
more ST-80 compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
367
diff
changeset
|
99 |
!UIBuilder methodsFor:'building'! |
66 | 100 |
|
367 | 101 |
add:aSpec |
478 | 102 |
|collectedComponents| |
103 |
||
104 |
composite notNil ifTrue:[ |
|
105 |
(collectedComponents := composite collection) isNil ifTrue:[ |
|
106 |
composite collection:(collectedComponents := OrderedCollection new). |
|
107 |
]. |
|
108 |
collectedComponents add:aSpec. |
|
109 |
view := aSpec buildViewWithLayoutFor:self in:compositeView. |
|
110 |
] ifFalse:[ |
|
111 |
spec isNil ifTrue:[ |
|
112 |
spec := FullSpec new. |
|
113 |
]. |
|
114 |
||
115 |
(aSpec isMemberOf:WindowSpec) ifTrue:[ |
|
116 |
spec window:aSpec |
|
117 |
] ifFalse:[ |
|
118 |
((aSpec isMemberOf:ComponentSpec) |
|
119 |
or:[(aSpec isMemberOf:SpecCollection)]) ifTrue:[ |
|
120 |
spec component:aSpec. |
|
121 |
||
122 |
window isNil ifTrue:[ |
|
479 | 123 |
window := windowView := View new. |
478 | 124 |
]. |
125 |
aSpec buildViewWithLayoutFor:self in:window. |
|
126 |
"/ builder window displayBox |
|
127 |
composite := aSpec. |
|
128 |
compositeView := window. |
|
129 |
] ifFalse:[ |
|
130 |
spec component isNil ifTrue:[ |
|
131 |
spec component:SpecCollection new. |
|
132 |
spec component collection:OrderedCollection new. |
|
133 |
composite := spec component. |
|
134 |
window isNil ifTrue:[ |
|
479 | 135 |
window := windowView := View new. |
478 | 136 |
]. |
137 |
compositeView := window. |
|
138 |
]. |
|
139 |
spec component collection add:aSpec. |
|
140 |
view := aSpec buildViewWithLayoutFor:self in:compositeView. |
|
141 |
]. |
|
142 |
] |
|
143 |
]. |
|
144 |
||
145 |
lastComponent := view. |
|
367 | 146 |
^ view |
147 |
||
479 | 148 |
"Modified: 3.3.1997 / 22:03:02 / cg" |
367 | 149 |
! |
150 |
||
474 | 151 |
buildFromSpec:aSpecOrSpecArray |
100 | 152 |
|m spec| |
153 |
||
474 | 154 |
window notNil ifTrue:[ |
155 |
^ self buildFromSpec:aSpecOrSpecArray in:window |
|
156 |
]. |
|
100 | 157 |
|
474 | 158 |
spec := UISpecification from:aSpecOrSpecArray. |
478 | 159 |
window := spec buildViewFor:self. |
100 | 160 |
|
372
6d7718f3d298
more ST-80 compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
367
diff
changeset
|
161 |
"/ menuAspect notNil ifTrue:[ |
6d7718f3d298
more ST-80 compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
367
diff
changeset
|
162 |
"/ m := self componentAt:menuAspect. |
6d7718f3d298
more ST-80 compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
367
diff
changeset
|
163 |
"/ m notNil ifTrue:[ |
6d7718f3d298
more ST-80 compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
367
diff
changeset
|
164 |
"/ m := m value. |
6d7718f3d298
more ST-80 compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
367
diff
changeset
|
165 |
"/ m notNil ifTrue:[ |
6d7718f3d298
more ST-80 compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
367
diff
changeset
|
166 |
"/ m receiver:application. |
6d7718f3d298
more ST-80 compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
367
diff
changeset
|
167 |
"/ window add:m. |
6d7718f3d298
more ST-80 compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
367
diff
changeset
|
168 |
"/ view topInset:(m heightIncludingBorder). |
6d7718f3d298
more ST-80 compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
367
diff
changeset
|
169 |
"/ ] |
6d7718f3d298
more ST-80 compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
367
diff
changeset
|
170 |
"/ ] |
6d7718f3d298
more ST-80 compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
367
diff
changeset
|
171 |
"/ ]. |
86 | 172 |
|
372
6d7718f3d298
more ST-80 compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
367
diff
changeset
|
173 |
^ window |
66 | 174 |
|
100 | 175 |
"Modified: 5.9.1995 / 21:43:29 / claus" |
478 | 176 |
"Modified: 3.3.1997 / 18:43:50 / cg" |
125 | 177 |
! |
178 |
||
179 |
buildFromSpec:aSpecArray in:aView |
|
180 |
|m spec| |
|
181 |
||
182 |
spec := UISpecification from:aSpecArray. |
|
478 | 183 |
^ spec buildViewFor:self in:aView. |
125 | 184 |
|
478 | 185 |
"Modified: 3.3.1997 / 18:44:02 / cg" |
363
c7a26a5ebaba
doFinalHookup (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
344
diff
changeset
|
186 |
! |
c7a26a5ebaba
doFinalHookup (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
344
diff
changeset
|
187 |
|
c7a26a5ebaba
doFinalHookup (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
344
diff
changeset
|
188 |
doFinalHookup |
c7a26a5ebaba
doFinalHookup (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
344
diff
changeset
|
189 |
|
c7a26a5ebaba
doFinalHookup (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
344
diff
changeset
|
190 |
"Created: 14.2.1997 / 14:52:27 / cg" |
478 | 191 |
! |
192 |
||
193 |
endComposite |
|
194 |
|entry| |
|
195 |
||
497 | 196 |
(specStack notNil and:[specStack notEmpty]) ifTrue:[ |
478 | 197 |
entry := specStack removeLast. |
198 |
composite := entry key. |
|
199 |
compositeView := entry value. |
|
200 |
]. |
|
201 |
^ composite |
|
202 |
||
203 |
"Created: 3.3.1997 / 17:17:43 / cg" |
|
497 | 204 |
"Modified: 6.3.1997 / 16:18:05 / cg" |
478 | 205 |
! |
206 |
||
207 |
endCompositeLayout:layout |
|
208 |
composite compositeSpec:(CompositeSpec new layout:layout). |
|
479 | 209 |
compositeView layout:layout. |
478 | 210 |
self endComposite |
211 |
||
479 | 212 |
"Modified: 3.3.1997 / 20:54:35 / cg" |
213 |
! |
|
214 |
||
215 |
endCompositeLayout:layout properties:props |
|
216 |
self endCompositeLayout:layout |
|
217 |
||
218 |
"Created: 3.3.1997 / 22:15:17 / cg" |
|
478 | 219 |
! |
220 |
||
585 | 221 |
menuAt:aKey |
222 |
"Find a binding for the menu named aKey, either in the bindings |
|
223 |
cache, or from the source |
|
224 |
" |
|
225 |
| menu | |
|
226 |
||
227 |
menu := self bindingAt:aKey. |
|
228 |
menu isNil ifTrue:[ |
|
229 |
menu := self safelyPerform:#menuFor: with:aKey. |
|
230 |
menu isNil ifTrue:[ |
|
231 |
menu := self safelyPerform:aKey |
|
232 |
]. |
|
233 |
menu := menu value. |
|
234 |
||
235 |
(application notNil and:[menu notNil]) ifTrue:[ |
|
667 | 236 |
menu isArray ifTrue:[ |
237 |
menu := Menu new fromLiteralArrayEncoding:menu. |
|
238 |
menu receiver:application. |
|
239 |
^ menu |
|
240 |
]. |
|
585 | 241 |
menu findGuiResourcesIn:application |
242 |
] |
|
243 |
]. |
|
244 |
^ menu |
|
245 |
||
246 |
! |
|
247 |
||
248 |
menuAt:aSymbol put:aModel |
|
249 |
"Install value as the binding for the menu named aKey in the |
|
250 |
bindings cache |
|
251 |
" |
|
252 |
^ self aspectAt:aSymbol put:aModel |
|
253 |
! |
|
254 |
||
478 | 255 |
newComposite |
256 |
|newComposite| |
|
257 |
||
258 |
specStack isNil ifTrue:[ |
|
259 |
specStack := OrderedCollection new |
|
260 |
]. |
|
261 |
specStack addLast:(composite->compositeView). |
|
262 |
newComposite := CompositeSpecCollection new. |
|
263 |
newComposite compositeSpec:(CompositeSpec new). |
|
264 |
compositeView := self add:newComposite. |
|
265 |
composite := newComposite. |
|
266 |
^ compositeView |
|
267 |
||
268 |
"Created: 3.3.1997 / 17:15:36 / cg" |
|
269 |
"Modified: 3.3.1997 / 18:55:13 / cg" |
|
270 |
! |
|
271 |
||
272 |
wrapper |
|
273 |
^ view |
|
274 |
||
275 |
"Created: 3.3.1997 / 18:28:31 / cg" |
|
276 |
"Modified: 3.3.1997 / 18:44:12 / cg" |
|
100 | 277 |
! ! |
86 | 278 |
|
479 | 279 |
!UIBuilder methodsFor:'initialization'! |
280 |
||
281 |
setupWindowFor:aView |
|
282 |
|ext| |
|
283 |
||
284 |
window notNil ifTrue:[ |
|
285 |
ext := window extent. |
|
286 |
||
287 |
((window isMemberOf:View) |
|
288 |
or:[window isMemberOf:SimpleView]) ifTrue:[ |
|
607 | 289 |
|
479 | 290 |
windowView ~~ window ifTrue:[ |
291 |
windowView isNil ifTrue:[ |
|
607 | 292 |
self halt:'debug halt - should not happen' |
479 | 293 |
] |
294 |
]. |
|
295 |
aView addSubView:window. |
|
296 |
]. |
|
297 |
]. |
|
298 |
||
299 |
window := aView. |
|
300 |
||
301 |
aView container isNil ifTrue:[ |
|
302 |
spec notNil ifTrue:[ |
|
303 |
spec window setupView:window for:self |
|
304 |
] |
|
305 |
]. |
|
306 |
||
607 | 307 |
"Modified: 17.6.1997 / 18:03:54 / cg" |
479 | 308 |
! ! |
309 |
||
503 | 310 |
!UIBuilder methodsFor:'misc'! |
311 |
||
312 |
newSubBuilder |
|
313 |
|builder| |
|
314 |
||
315 |
builder := UIBuilder new. |
|
316 |
builder bindings:(self bindings). |
|
317 |
builder application:(self application). |
|
318 |
^ builder |
|
319 |
! ! |
|
320 |
||
132 | 321 |
!UIBuilder class methodsFor:'documentation'! |
322 |
||
323 |
version |
|
721
1889d708a951
provide a handle to the applications menuBar
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
324 |
^ '$Header: /cvs/stx/stx/libview2/UIBuilder.st,v 1.28 1997-10-28 19:14:37 cg Exp $' |
132 | 325 |
! ! |
100 | 326 |
UIBuilder initialize! |