author | Claus Gittinger <cg@exept.de> |
Tue, 14 Jan 1997 15:17:37 +0100 | |
changeset 363 | c7a26a5ebaba |
parent 344 | 42ae71c13eef |
child 367 | 7316abe03075 |
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 |
223 | 14 |
instanceVariableNames:'view currentMenuSelector menuAspect spec' |
15 |
classVariableNames:'Verbose' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'Interface-Support-UI' |
|
66 | 18 |
! |
19 |
||
20 |
!UIBuilder class methodsFor:'documentation'! |
|
21 |
||
125 | 22 |
copyright |
23 |
" |
|
24 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
25 |
All Rights Reserved |
|
26 |
||
27 |
This software is furnished under a license and may be used |
|
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
88 | 34 |
! |
35 |
||
66 | 36 |
documentation |
37 |
" |
|
38 |
this class will (eventually) allow parsing windowSpecs as |
|
39 |
created by ST-80's UIPainter, and thereby allow to run applications |
|
40 |
built with this tool. |
|
41 |
It was created to allow execution of PD applications which were |
|
42 |
written using that tool (and more and more are appearing ...). |
|
43 |
||
44 |
The class is not completed yet and certainly not bug free. |
|
45 |
Also, it is not quaranteed that all winSpecs are understood. |
|
223 | 46 |
|
47 |
[author:] |
|
48 |
Claus Gittinger |
|
66 | 49 |
" |
50 |
! ! |
|
51 |
||
52 |
!UIBuilder class methodsFor:'initialization'! |
|
53 |
||
54 |
initialize |
|
55 |
Verbose := false "/ debugging flag |
|
56 |
! ! |
|
57 |
||
86 | 58 |
!UIBuilder methodsFor:'accessing'! |
59 |
||
60 |
menuAspect |
|
61 |
^ menuAspect |
|
62 |
! ! |
|
63 |
||
66 | 64 |
!UIBuilder methodsFor:'operation'! |
65 |
||
100 | 66 |
buildFromSpec:aSpecArray |
67 |
|m spec| |
|
68 |
||
69 |
"/ old: |
|
70 |
"/ self readSpec:aSpecArray. |
|
71 |
||
72 |
spec := UISpecification from:aSpecArray. |
|
73 |
topView := view := spec buildViewFor:self. |
|
74 |
||
75 |
menuAspect notNil ifTrue:[ |
|
114
e577a2f332d0
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
76 |
m := self componentAt:menuAspect. |
e577a2f332d0
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
77 |
m notNil ifTrue:[ |
e577a2f332d0
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
78 |
m := m value. |
e577a2f332d0
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
79 |
m notNil ifTrue:[ |
e577a2f332d0
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
80 |
m receiver:application. |
e577a2f332d0
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
81 |
topView add:m. |
e577a2f332d0
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
82 |
view topInset:(m heightIncludingBorder). |
e577a2f332d0
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
83 |
] |
e577a2f332d0
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
100
diff
changeset
|
84 |
] |
86 | 85 |
]. |
86 |
||
100 | 87 |
^ topView |
66 | 88 |
|
100 | 89 |
"Modified: 5.9.1995 / 21:43:29 / claus" |
125 | 90 |
! |
91 |
||
92 |
buildFromSpec:aSpecArray in:aView |
|
93 |
|m spec| |
|
94 |
||
95 |
spec := UISpecification from:aSpecArray. |
|
96 |
||
97 |
view := spec buildViewFor:self in:aView. |
|
98 |
||
99 |
menuAspect notNil ifTrue:[ |
|
100 |
m := self componentAt:menuAspect. |
|
101 |
m notNil ifTrue:[ |
|
102 |
m := m value. |
|
103 |
m notNil ifTrue:[ |
|
104 |
m receiver:application. |
|
105 |
topView add:m. |
|
106 |
view topInset:(m heightIncludingBorder). |
|
107 |
] |
|
108 |
] |
|
109 |
]. |
|
110 |
||
111 |
^ topView |
|
112 |
||
113 |
"Modified: 5.9.1995 / 21:48:09 / claus" |
|
363
c7a26a5ebaba
doFinalHookup (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
344
diff
changeset
|
114 |
! |
c7a26a5ebaba
doFinalHookup (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
344
diff
changeset
|
115 |
|
c7a26a5ebaba
doFinalHookup (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
344
diff
changeset
|
116 |
doFinalHookup |
c7a26a5ebaba
doFinalHookup (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
344
diff
changeset
|
117 |
|
c7a26a5ebaba
doFinalHookup (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
344
diff
changeset
|
118 |
"Created: 14.2.1997 / 14:52:27 / cg" |
100 | 119 |
! ! |
86 | 120 |
|
100 | 121 |
!UIBuilder methodsFor:'private arg parsing'! |
66 | 122 |
|
100 | 123 |
getAlignmentOrigin:spec |
124 |
"called for #(AlignmentOrigin ?x ?relX ?x ?y ?relY ?y)" |
|
66 | 125 |
|
100 | 126 |
^ AlignmentOrigin new fromLiteralArrayEncoding:spec. |
127 |
"/ ^ Array with:#alignmentOrigin |
|
128 |
"/ with:((spec at:2) @ (spec at:5)) "/ ? |
|
129 |
"/ with:((spec at:3) @ (spec at:6)) "/ rels ? |
|
130 |
"/ with:((spec at:4) @ (spec at:7)) "/ insets ? |
|
66 | 131 |
! |
132 |
||
125 | 133 |
getArg:spec |
134 |
"take something like #(Point 50 100) and return the value" |
|
66 | 135 |
|
125 | 136 |
|what| |
137 |
||
138 |
what := spec at:1. |
|
139 |
^ self perform:('get' , what , ':') asSymbol with:spec |
|
66 | 140 |
! |
141 |
||
100 | 142 |
getColorValue:spec |
143 |
"called for #(ColorValue #sym) |
|
144 |
or #(ColorValue red green blue)" |
|
66 | 145 |
|
344 | 146 |
|arg| |
66 | 147 |
|
100 | 148 |
(arg := spec at:2) isSymbol ifTrue:[ |
149 |
(Color respondsTo:arg) ifTrue:[ |
|
150 |
^ Color perform:arg |
|
151 |
]. |
|
152 |
^ Color name:arg asString ifIllegal:[Color black] |
|
153 |
]. |
|
154 |
arg isInteger ifTrue:[ |
|
155 |
^ ColorValue scaledRed:arg |
|
156 |
scaledGreen:(spec at:3) |
|
157 |
scaledBlue:(spec at:4) |
|
158 |
]. |
|
159 |
^ ColorValue red:arg |
|
160 |
green:(spec at:3) |
|
161 |
blue:(spec at:4) |
|
66 | 162 |
|
163 |
||
125 | 164 |
! |
165 |
||
166 |
getCompositeSpec:spec |
|
167 |
"called for #(CompositeSpec layout: #(orgx orgy cornx corny)" |
|
168 |
||
169 |
|layout| |
|
170 |
||
171 |
(spec at:2) == #layout: ifTrue:[ |
|
172 |
layout := spec at:3. |
|
173 |
(layout at:1) == #Rectangle ifTrue:[ |
|
174 |
^ Rectangle |
|
175 |
origin:(layout at:2) @ (layout at:3) |
|
176 |
corner:(layout at:4) @ (layout at:5) |
|
177 |
]. |
|
178 |
]. |
|
179 |
self halt:'unimplemented'. |
|
180 |
! |
|
181 |
||
182 |
getLayoutFrame:spec |
|
183 |
"called for #(LayoutFrame absOrgX relOrgX absOrgY relOrgY absCornX relCornX absCornY relCornY)" |
|
184 |
" 1 2 3 4 5 6 7 8 9" |
|
185 |
||
186 |
^ LayoutFrame new fromLiteralArrayEncoding:spec. |
|
187 |
||
188 |
"/ ^ Array with:#layoutFrame |
|
189 |
"/ with:((spec at:2) @ (spec at:4)) "/ org inset |
|
190 |
"/ with:((spec at:6) @ (spec at:8)) "/ corner inset |
|
191 |
"/ with:((spec at:3) @ (spec at:5)) "/ rel org |
|
192 |
"/ with:((spec at:7) @ (spec at:9)) "/ rel corn |
|
193 |
||
194 |
! |
|
195 |
||
196 |
getLayoutOrigin:spec |
|
197 |
"called for #(LayoutOrigin xInset relX yInset relY)" |
|
198 |
||
199 |
^ LayoutOrigin new fromLiteralArrayEncoding:spec. |
|
200 |
"/ ^ Array with:#layoutOrigin |
|
201 |
"/ with:((spec at:3) @ (spec at:5)) "/ rels |
|
202 |
"/ with:((spec at:2) @ (spec at:4)) "/ insets |
|
203 |
! |
|
204 |
||
205 |
getLookPreferences:spec |
|
206 |
"called for #(LookPreferences setForegroundColor: (...) setBackgroundColor: (...) ...)" |
|
207 |
||
208 |
|coll| |
|
209 |
||
210 |
coll := OrderedCollection new. |
|
211 |
2 to:spec size by:2 do:[:index | |
|
212 |
coll add: |
|
213 |
(Array with:(spec at:index) |
|
214 |
with:(self getArg:(spec at:index+1))) |
|
215 |
]. |
|
216 |
^ coll. |
|
217 |
! |
|
218 |
||
219 |
getPoint:spec |
|
220 |
"called for #(Point x y)" |
|
221 |
||
222 |
^ Array with:#point |
|
223 |
with:((spec at:2) @ (spec at:3)) |
|
224 |
! |
|
225 |
||
226 |
getRectangle:spec |
|
227 |
"called for #(Rectangle x y)" |
|
228 |
||
229 |
^ Array with:#rectangle |
|
230 |
with:(((spec at:2) @ (spec at:3)) corner:((spec at:4) @ (spec at:5))) |
|
66 | 231 |
! ! |
232 |
||
233 |
!UIBuilder methodsFor:'private spec attribute parsing'! |
|
234 |
||
125 | 235 |
XXyMultipleSelections:args view:aView |
236 |
aView multipleSelectOk:args |
|
237 |
! |
|
238 |
||
239 |
doesNotUnderstand:aMessage |
|
240 |
|rest sel| |
|
241 |
||
242 |
((sel := aMessage selector) startsWith:'y') ifTrue:[ |
|
243 |
rest := sel copyFrom:2 to:(sel indexOf:$:). |
|
244 |
rest at:1 put:(rest at:1) asLowercase. |
|
245 |
rest := rest asSymbolIfInterned. |
|
246 |
rest notNil ifTrue:[ |
|
247 |
(aMessage arguments at:2) perform:rest with:(aMessage arguments at:1). |
|
248 |
^ self. |
|
249 |
] |
|
250 |
]. |
|
251 |
super doesNotUnderstand:aMessage |
|
252 |
||
253 |
"Modified: 5.9.1995 / 21:13:16 / claus" |
|
254 |
! |
|
255 |
||
256 |
yBounds:args view:aView frame:frameView |
|
257 |
|value r| |
|
258 |
||
259 |
value := self getArg:args. |
|
260 |
(value at:1) == #rectangle ifTrue:[ |
|
261 |
r := value at:2. |
|
262 |
aView origin:r origin corner:r corner. |
|
263 |
^ self |
|
264 |
]. |
|
265 |
self halt:'unimplemented'. |
|
266 |
! |
|
267 |
||
66 | 268 |
yCollection:args view:aView frame:frameView |
269 |
args do:[:aSpec | |
|
270 |
self readSpec:aSpec view:aView frame:frameView. |
|
271 |
]. |
|
272 |
! |
|
273 |
||
125 | 274 |
yColors:args view:aView frame:frameView |
275 |
|value| |
|
276 |
||
277 |
value := self getArg:args. |
|
278 |
self halt:'unimplemented'. |
|
279 |
! |
|
280 |
||
281 |
yComponent:args view:aView frame:frameView |
|
282 |
|v| |
|
283 |
||
284 |
args isSymbol ifTrue:[ |
|
285 |
v := application perform:args. |
|
286 |
v origin:0.0@0.0 corner:1.0@1.0. |
|
287 |
aView addSubView:v |
|
288 |
] ifFalse:[ |
|
289 |
"/ v := View origin:0.0@0.0 corner:1.0@1.0 in:aView. |
|
290 |
"/ self readSpec:args view:v frame:frameView. |
|
291 |
self readSpec:args view:aView frame:frameView. |
|
292 |
] |
|
293 |
! |
|
294 |
||
295 |
yCompositeSpec:args view:aView frame:frameView |
|
296 |
|value r| |
|
297 |
||
298 |
self doSpec:args for:aView. |
|
344 | 299 |
"/ |
300 |
"/ value := self getArg:args. |
|
301 |
"/ (value at:1) == #rectangle ifTrue:[ |
|
302 |
"/ r := value at:2. |
|
303 |
"/ aView origin:r origin corner:r corner. |
|
304 |
"/ ^ self |
|
305 |
"/ ]. |
|
306 |
"/ |
|
307 |
"/self halt. |
|
125 | 308 |
|
309 |
! |
|
310 |
||
311 |
yDefaultable:args view:aView frame:frameView |
|
270 | 312 |
'defaultable ignored' printCR |
313 |
||
314 |
"Modified: 20.5.1996 / 10:29:24 / cg" |
|
125 | 315 |
! |
316 |
||
317 |
yFlags:args view:aView frame:frameView |
|
270 | 318 |
'flags: ' print. args print. ' for ' print. aView print. ' ignored' printCR |
125 | 319 |
" |
320 |
32 : initially disabled |
|
321 |
16 : initially invisible |
|
322 |
8 : border |
|
323 |
4 : menuBar |
|
324 |
2 : hScroll |
|
325 |
1 : vScroll |
|
326 |
" |
|
327 |
||
328 |
"Modified: 2.9.1995 / 15:44:15 / claus" |
|
270 | 329 |
"Modified: 20.5.1996 / 10:29:26 / cg" |
125 | 330 |
! |
331 |
||
332 |
yIsDefault:args view:aView frame:frameView |
|
333 |
aView isReturnButton:args |
|
334 |
! |
|
335 |
||
336 |
yIsOpaque:args view:aView frame:frameView |
|
270 | 337 |
'isOpaque ignored' printCR. |
338 |
||
339 |
"Modified: 20.5.1996 / 10:29:29 / cg" |
|
125 | 340 |
! |
341 |
||
342 |
yIsReadOnly:args view:aView frame:frameView |
|
343 |
args ifTrue:[ |
|
344 |
aView readOnly |
|
345 |
] |
|
346 |
! |
|
347 |
||
66 | 348 |
yLayout:args view:aView frame:frameView |
349 |
|value r org corn orgInset cornInset what| |
|
350 |
||
351 |
value := self getArg:args. |
|
100 | 352 |
value isLayout ifTrue:[ |
270 | 353 |
frameView geometryLayout:value. |
354 |
^ self |
|
100 | 355 |
]. |
66 | 356 |
|
357 |
what := value at:1. |
|
358 |
what == #point ifTrue:[ |
|
270 | 359 |
Verbose ifTrue:[frameView print. ' ' print. 'origin: ' print. (value at:2) printCR]. |
360 |
frameView origin:(value at:2). |
|
361 |
^ self |
|
66 | 362 |
]. |
363 |
what == #rectangle ifTrue:[ |
|
270 | 364 |
r := value at:2. |
365 |
Verbose ifTrue:[ |
|
366 |
frameView print. ' ' print. 'origin: ' print. r origin print. |
|
367 |
' corner: ' print. r corner printCR. |
|
368 |
]. |
|
369 |
frameView origin:r origin corner:r corner. |
|
370 |
^ self |
|
66 | 371 |
]. |
372 |
what == #layoutOrigin ifTrue:[ |
|
270 | 373 |
"/ #layoutOrigin relOrg orgInset |
374 |
org := value at:2. "/ relative origin |
|
375 |
org := org x asFloat @ org y asFloat. |
|
376 |
orgInset := self fixExtentFor:(value at:3). |
|
377 |
Verbose ifTrue:[ |
|
378 |
frameView print. ' ' print. 'origin: ' print. org printCR |
|
379 |
]. |
|
380 |
frameView origin:org. |
|
381 |
frameView |
|
382 |
leftInset:orgInset x; |
|
383 |
topInset:orgInset y. |
|
384 |
^ self |
|
66 | 385 |
]. |
386 |
what == #layoutFrame ifTrue:[ |
|
270 | 387 |
"/ #layoutFrame orgInset cornInset relOrg relCorner |
66 | 388 |
|
270 | 389 |
org := value at:4. "/ relative origin |
390 |
orgInset := self fixExtentFor:(value at:2). |
|
66 | 391 |
|
270 | 392 |
org := org x asFloat @ org y asFloat. |
66 | 393 |
"/ org = (0@0) ifTrue:[ |
394 |
"/ org := value at:2 "/ absolute origin |
|
395 |
"/ ]. |
|
396 |
||
270 | 397 |
corn := value at:5. "/ relative corner |
398 |
cornInset := self fixExtentFor:(value at:3). |
|
399 |
corn := corn x asFloat @ corn y asFloat. |
|
66 | 400 |
"/ corn = (0@0) ifTrue:[ |
401 |
"/ corn := value at:3 "/ absolute corner |
|
402 |
"/ ]. |
|
270 | 403 |
Verbose ifTrue:[ |
404 |
frameView print. ' ' print. 'origin: ' print. org print. |
|
405 |
' corner: ' print. corn printCR. |
|
406 |
]. |
|
407 |
frameView origin:org corner:corn. |
|
408 |
frameView leftInset:orgInset x; |
|
409 |
topInset:orgInset y; |
|
410 |
rightInset:cornInset x negated; |
|
411 |
bottomInset:cornInset y negated. |
|
412 |
frameView sizeFixed:true. |
|
413 |
^ self |
|
66 | 414 |
]. |
415 |
what == #alignmentOrigin ifTrue:[ |
|
270 | 416 |
org := value at:3. "/ relative origin |
417 |
org = (0@0) ifTrue:[ |
|
418 |
org := value at:2 "/ absolute origin |
|
419 |
]. |
|
420 |
Verbose ifTrue:[frameView print. ' ' print. 'origin: ' print. org printCR]. |
|
421 |
frameView origin:org. |
|
422 |
^ self |
|
66 | 423 |
]. |
424 |
||
425 |
self halt:'unimplemented'. |
|
270 | 426 |
|
427 |
"Modified: 20.5.1996 / 10:29:35 / cg" |
|
66 | 428 |
! |
429 |
||
125 | 430 |
yMax:args view:aView frame:frameView |
431 |
|value| |
|
100 | 432 |
|
433 |
value := self getArg:args. |
|
125 | 434 |
(value at:1) == #point ifTrue:[ |
435 |
aView maxExtent:(value at:2). |
|
100 | 436 |
^ self |
437 |
]. |
|
438 |
self halt:'unimplemented'. |
|
439 |
! |
|
440 |
||
125 | 441 |
yMenu:args view:aView frame:frameView |
442 |
menuAspect := args |
|
66 | 443 |
! |
444 |
||
445 |
yMin:args view:aView frame:frameView |
|
446 |
|value| |
|
447 |
||
448 |
value := self getArg:args. |
|
449 |
(value at:1) == #point ifTrue:[ |
|
450 |
aView minExtent:(value at:2). |
|
451 |
^ self |
|
452 |
]. |
|
453 |
self halt:'unimplemented'. |
|
454 |
! |
|
455 |
||
456 |
yModel:args view:aView frame:frameView |
|
457 |
|model| |
|
458 |
||
459 |
(aspects notNil and:[aspects includesKey:args]) ifTrue:[ |
|
460 |
model := aspects at:args |
|
461 |
] ifFalse:[ |
|
86 | 462 |
(aView isMemberOf:Button) ifTrue:[ |
463 |
model := application. |
|
464 |
aView aspect:nil. |
|
465 |
aView changeMessage:args. |
|
466 |
] ifFalse:[ |
|
467 |
model := application perform:args. |
|
468 |
]. |
|
66 | 469 |
]. |
470 |
aView model:model. |
|
471 |
! |
|
472 |
||
125 | 473 |
yMultipleSelections:args view:aView frame:frameView |
474 |
args == true ifTrue:[ |
|
475 |
aView multipleSelectOk:true |
|
66 | 476 |
] |
477 |
! |
|
478 |
||
125 | 479 |
yName:args view:aView frame:frameView |
480 |
self componentAt:args put:aView |
|
66 | 481 |
! |
482 |
||
483 |
yOrientation:args view:aView frame:frameView |
|
270 | 484 |
'orientation ignored' printCR. |
485 |
||
486 |
"Modified: 20.5.1996 / 10:29:37 / cg" |
|
66 | 487 |
! |
488 |
||
489 |
ySelectionStyle:args view:aView frame:frameView |
|
270 | 490 |
'selectionStyle ignored' printCR. |
66 | 491 |
|
270 | 492 |
"Modified: 20.5.1996 / 10:29:41 / cg" |
66 | 493 |
! |
494 |
||
495 |
yStart:args view:aView frame:frameView |
|
86 | 496 |
(aView isKindOf:Scroller) ifTrue:[ |
270 | 497 |
aView start:args. |
498 |
^ self |
|
86 | 499 |
]. |
270 | 500 |
'start ignored' printCR. |
501 |
||
502 |
"Modified: 20.5.1996 / 10:29:42 / cg" |
|
66 | 503 |
! |
504 |
||
505 |
yStep:args view:aView frame:frameView |
|
270 | 506 |
'step ignored' printCR. |
66 | 507 |
|
270 | 508 |
"Modified: 20.5.1996 / 10:29:44 / cg" |
66 | 509 |
! |
510 |
||
86 | 511 |
yStop:args view:aView frame:frameView |
512 |
(aView isKindOf:Scroller) ifTrue:[ |
|
270 | 513 |
aView stop:args. |
514 |
^ self |
|
86 | 515 |
]. |
270 | 516 |
'stop ignored' printCR. |
517 |
||
518 |
"Modified: 20.5.1996 / 10:29:46 / cg" |
|
66 | 519 |
! |
520 |
||
125 | 521 |
yStyle:args view:aView frame:frameView |
270 | 522 |
'name ignored' printCR. |
125 | 523 |
|
270 | 524 |
"Modified: 20.5.1996 / 10:29:48 / cg" |
125 | 525 |
! |
526 |
||
86 | 527 |
ySubmenu:aSpec view:menu frame:frameView |
528 |
|items lines selectors labels| |
|
529 |
||
530 |
aSpec first ~~ #Menu ifTrue:[ |
|
139 | 531 |
self halt:'unexpected'. |
86 | 532 |
]. |
533 |
items := (aSpec at:2). |
|
534 |
lines := aSpec at:3. |
|
535 |
selectors := aSpec at:4. |
|
66 | 536 |
|
86 | 537 |
"collect labels & selectors" |
538 |
labels := OrderedCollection new. |
|
539 |
items do:[:item | |
|
139 | 540 |
item first ~~ #MenuItem ifTrue:[ |
541 |
self halt:'unexpected' |
|
542 |
]. |
|
543 |
(item at:2) ~~ #'label:' ifTrue:[ |
|
544 |
self halt:'unexpected' |
|
545 |
]. |
|
546 |
labels add:(item at:3). |
|
86 | 547 |
]. |
548 |
||
549 |
menu at:currentMenuSelector |
|
139 | 550 |
putLabels:labels |
551 |
selectors:selectors |
|
552 |
receiver:nil. |
|
553 |
||
554 |
"Created: 9.12.1995 / 23:06:39 / cg" |
|
555 |
"Modified: 9.12.1995 / 23:08:15 / cg" |
|
86 | 556 |
! |
557 |
||
125 | 558 |
yTabable:args view:aView frame:frameView |
559 |
args == true ifTrue:[ |
|
270 | 560 |
focusSequence isNil ifTrue:[ |
561 |
focusSequence := OrderedCollection new. |
|
562 |
]. |
|
563 |
focusSequence add:aView. |
|
564 |
'tabable element added' printCR. |
|
125 | 565 |
] |
270 | 566 |
|
567 |
"Modified: 20.5.1996 / 10:29:53 / cg" |
|
66 | 568 |
! |
569 |
||
570 |
yType:args view:aView frame:frameView |
|
86 | 571 |
(aView isMemberOf:EditField) ifTrue:[ |
270 | 572 |
args == #number ifTrue:[ |
573 |
aView converter:(PrintConverter new initForNumber). |
|
574 |
^ self |
|
575 |
] |
|
86 | 576 |
]. |
577 |
||
270 | 578 |
'type ignored' printCR. |
579 |
||
580 |
"Modified: 20.5.1996 / 10:29:55 / cg" |
|
100 | 581 |
! |
582 |
||
125 | 583 |
yWindow:args view:aView frame:frameView |
584 |
self readSpec:args view:aView frame:frameView. |
|
66 | 585 |
! ! |
586 |
||
100 | 587 |
!UIBuilder methodsFor:'private spec component parsing'! |
66 | 588 |
|
100 | 589 |
xActionButtonSpec:aSpec view:aView |
590 |
|b| |
|
591 |
||
592 |
b := Button in:aView. |
|
593 |
self fixFontFor:b. |
|
594 |
self doSpec:aSpec for:b |
|
66 | 595 |
! |
596 |
||
125 | 597 |
xArbitraryComponentSpec:aSpec view:aView |
598 |
|v| |
|
599 |
||
600 |
v := View in:aView. |
|
601 |
"/ v := Label label:'ArbitraryView' in:aView. |
|
602 |
v origin:0.0@0.0 corner:1.0@1.0. |
|
603 |
v level:-1. |
|
604 |
self doSpec:aSpec for:v |
|
605 |
||
606 |
"Modified: 2.9.1995 / 15:26:03 / claus" |
|
607 |
! |
|
608 |
||
609 |
xCheckBoxSpec:aSpec view:aView |
|
610 |
|b| |
|
611 |
||
612 |
b := CheckBox in:aView. |
|
613 |
self fixFontFor:b. |
|
614 |
self doSpec:aSpec for:b |
|
615 |
||
616 |
! |
|
617 |
||
618 |
xCompositeSpecCollection:aSpec view:aView |
|
619 |
|v| |
|
620 |
||
621 |
"/ 'compositeSpecCollection ignored' printNL. |
|
622 |
"/ ^ self. |
|
623 |
v := View in:aView. |
|
624 |
self doSpec:aSpec for:v |
|
625 |
||
626 |
! |
|
627 |
||
628 |
xDividerSpec:aSpec view:aView |
|
629 |
|l| |
|
630 |
||
631 |
l := View in:aView. |
|
632 |
self doSpec:aSpec for:l |
|
633 |
! |
|
634 |
||
635 |
xFramedBoxSpec:aSpec view:aView |
|
636 |
|v| |
|
637 |
||
638 |
v := FramedBox in:aView. |
|
639 |
self doSpec:aSpec for:v |
|
640 |
||
641 |
"Modified: 5.9.1995 / 21:05:38 / claus" |
|
642 |
! |
|
643 |
||
100 | 644 |
xFullSpec:aSpec |
645 |
topView isNil ifTrue:[ |
|
646 |
topView := StandardSystemView new. |
|
647 |
topView controller:(ApplicationController new). |
|
648 |
topView application:application. |
|
649 |
]. |
|
650 |
||
651 |
view := View new. |
|
652 |
self doSpec:aSpec for:view. |
|
653 |
||
654 |
topView extent:(view extent). |
|
655 |
view origin:0.0@0.0 corner:1.0@1.0. |
|
656 |
topView add:view. |
|
657 |
||
658 |
^ topView |
|
659 |
! |
|
660 |
||
125 | 661 |
xGroupBoxSpec:aSpec view:aView |
662 |
|l| |
|
663 |
||
664 |
l := FramedBox in:aView. |
|
665 |
self doSpec:aSpec for:l |
|
666 |
! |
|
66 | 667 |
|
125 | 668 |
xHorizontalPanelViewSpec:aSpec view:aView |
669 |
|v| |
|
670 |
||
671 |
v := HorizontalPanelView in:aView. |
|
672 |
self doSpec:aSpec for:v |
|
673 |
||
674 |
"Modified: 5.9.1995 / 21:06:25 / claus" |
|
66 | 675 |
! |
676 |
||
125 | 677 |
xInputFieldSpec:aSpec view:aView |
678 |
|l| |
|
66 | 679 |
|
125 | 680 |
l := EditField in:aView. |
681 |
self fixFontFor:l. |
|
682 |
l aspect:#value; change:#value:. |
|
683 |
self doSpec:aSpec for:l |
|
684 |
! |
|
100 | 685 |
|
125 | 686 |
xLabelSpec:aSpec view:aView |
687 |
|l| |
|
688 |
||
689 |
l := Label in:aView. |
|
690 |
self fixFontFor:l. |
|
691 |
self doSpec:aSpec for:l |
|
692 |
||
66 | 693 |
! |
694 |
||
100 | 695 |
xMenu:aSpec |
696 |
|items numItems unknown prevCurrent labels| |
|
697 |
||
698 |
topView := PullDownMenu new. |
|
699 |
||
700 |
items := aSpec at:2. |
|
701 |
numItems := (aSpec at:3) at:1. |
|
702 |
unknown := (aSpec at:4). |
|
703 |
||
704 |
prevCurrent := currentMenuSelector. |
|
66 | 705 |
|
100 | 706 |
"precollect labels ..." |
707 |
labels := OrderedCollection new. |
|
708 |
items do:[:item | |
|
139 | 709 |
(item at:1) ~~ #MenuItem ifTrue:[ |
710 |
self halt:'unexpected' |
|
711 |
]. |
|
712 |
(item at:2) ~~ #'label:' ifTrue:[ |
|
713 |
self halt:'unexpected' |
|
714 |
]. |
|
715 |
labels add:(item at:3) |
|
100 | 716 |
]. |
717 |
||
718 |
topView labels:labels. |
|
719 |
||
720 |
items with:(1 to:numItems) do:[:item :index | |
|
139 | 721 |
currentMenuSelector := index. |
722 |
self doSpec:item for:topView. |
|
100 | 723 |
]. |
724 |
||
725 |
currentMenuSelector := prevCurrent. |
|
726 |
^ topView |
|
139 | 727 |
|
728 |
"Created: 9.12.1995 / 23:06:31 / cg" |
|
729 |
"Modified: 9.12.1995 / 23:08:11 / cg" |
|
66 | 730 |
! |
731 |
||
100 | 732 |
xPopUpMenu:aSpec |
733 |
|menu values| |
|
66 | 734 |
|
100 | 735 |
menu := PopUpMenu |
736 |
labels:(aSpec at:2). |
|
737 |
values := Array new:((aSpec at:2) size). |
|
66 | 738 |
|
100 | 739 |
(aSpec at:4) keysAndValuesDo:[:index :item | |
740 |
((item size > 0) |
|
741 |
and:[(item at:1) == #PopUpMenu]) ifTrue:[ |
|
742 |
menu subMenuAt:index put:(self xPopUpMenu:item) |
|
743 |
] ifFalse:[ |
|
744 |
values at:index put:item |
|
745 |
] |
|
66 | 746 |
]. |
100 | 747 |
|
748 |
menu values:values. |
|
749 |
^ menu |
|
750 |
! |
|
751 |
||
125 | 752 |
xProgressIndicatorSpec:aSpec view:aView |
753 |
|s| |
|
100 | 754 |
|
125 | 755 |
s := ProgressIndicator in:aView. |
756 |
self doSpec:aSpec for:s |
|
66 | 757 |
! |
758 |
||
100 | 759 |
xScrollerSpec:aSpec view:aView |
760 |
|s idx orientation| |
|
761 |
||
762 |
idx := aSpec indexOf:#orientation:. |
|
763 |
idx == 0 ifTrue:[ |
|
764 |
orientation := #vertical |
|
765 |
] ifFalse:[ |
|
766 |
orientation := aSpec at:(idx + 1) |
|
767 |
]. |
|
768 |
orientation == #horizontal ifTrue:[ |
|
769 |
s := HorizontalScroller in:aView |
|
770 |
] ifFalse:[ |
|
771 |
s := Scroller in:aView |
|
772 |
]. |
|
773 |
self doSpec:aSpec for:s |
|
774 |
! |
|
775 |
||
125 | 776 |
xSequenceViewSpec:aSpec view:aView |
777 |
|f s| |
|
100 | 778 |
|
125 | 779 |
f := ScrollableView for:SelectionInListView in:aView. |
780 |
s := f scrolledView. |
|
781 |
self doSpec:aSpec for:s frame:f. |
|
100 | 782 |
! |
66 | 783 |
|
100 | 784 |
xSliderSpec:aSpec view:aView |
785 |
|s idx orientation| |
|
66 | 786 |
|
100 | 787 |
idx := aSpec indexOf:#orientation:. |
788 |
idx == 0 ifTrue:[ |
|
789 |
orientation := #vertical |
|
790 |
] ifFalse:[ |
|
791 |
orientation := aSpec at:(idx + 1) |
|
792 |
]. |
|
793 |
orientation == #horizontal ifTrue:[ |
|
794 |
s := HorizontalSlider in:aView |
|
795 |
] ifFalse:[ |
|
796 |
s := Slider in:aView |
|
797 |
]. |
|
798 |
self doSpec:aSpec for:s |
|
799 |
! |
|
800 |
||
125 | 801 |
xSpecCollection:aSpec view:aView |
802 |
self doSpec:aSpec for:aView |
|
66 | 803 |
|
804 |
! |
|
805 |
||
125 | 806 |
xSubCanvasSpec:aSpec view:aView |
100 | 807 |
|v| |
66 | 808 |
|
125 | 809 |
v := SubCanvas in:aView. |
100 | 810 |
v origin:0.0@0.0 corner:1.0@1.0. |
811 |
self doSpec:aSpec for:v |
|
812 |
||
125 | 813 |
"Modified: 2.9.1995 / 15:26:15 / claus" |
100 | 814 |
! |
815 |
||
816 |
xTableViewSpec:aSpec view:aView |
|
817 |
|l| |
|
818 |
||
270 | 819 |
'tableView ignored' printCR. |
100 | 820 |
l := Label label:'TableView' in:aView. |
821 |
l level:-1. |
|
270 | 822 |
self doSpec:aSpec for:l |
823 |
||
824 |
"Modified: 20.5.1996 / 10:29:20 / cg" |
|
66 | 825 |
! |
826 |
||
100 | 827 |
xVerticalPanelViewSpec:aSpec view:aView |
828 |
|v| |
|
829 |
||
830 |
v := VerticalPanelView in:aView. |
|
831 |
self doSpec:aSpec for:v |
|
66 | 832 |
|
100 | 833 |
"Modified: 5.9.1995 / 21:06:19 / claus" |
834 |
! |
|
66 | 835 |
|
125 | 836 |
xWindowSpec:aSpec view:aView |
837 |
self doSpec:aSpec for:aView |
|
100 | 838 |
|
66 | 839 |
! ! |
840 |
||
841 |
!UIBuilder methodsFor:'private spec parsing'! |
|
842 |
||
125 | 843 |
add:aSpec |
844 |
self readSpec:aSpec |
|
66 | 845 |
! |
846 |
||
125 | 847 |
doSingleSpec:selector args:args for:aView frame:frame |
848 |
Verbose ifTrue:[ |
|
270 | 849 |
'doSingle (' print. aView print. ' -> ' print. selector print. |
850 |
' ' print. args printString printCR. |
|
125 | 851 |
]. |
66 | 852 |
|
125 | 853 |
self perform:('y' , selector asString asUppercaseFirst , 'view:frame:') asSymbol |
270 | 854 |
with:args |
855 |
with:aView |
|
856 |
with:frame. |
|
125 | 857 |
|
270 | 858 |
"Modified: 20.5.1996 / 10:29:17 / cg" |
125 | 859 |
! |
860 |
||
861 |
doSpec:aSpec for:aView |
|
862 |
^ self doSpec:aSpec for:aView frame:aView |
|
66 | 863 |
! |
864 |
||
865 |
doSpec:aSpec for:aView frame:frame |
|
344 | 866 |
|selector args argsToRead| |
66 | 867 |
|
868 |
argsToRead := 0. |
|
869 |
args := #(). |
|
870 |
aSpec from:2 to:(aSpec size) do:[:element | |
|
139 | 871 |
argsToRead > 1 ifTrue:[ |
872 |
self halt:'invalid spec'. |
|
873 |
] ifFalse:[ |
|
874 |
argsToRead == 1 ifTrue:[ |
|
875 |
args := element. |
|
876 |
argsToRead := argsToRead - 1 |
|
877 |
] ifFalse:[ |
|
878 |
selector := element. |
|
879 |
argsToRead := selector numArgs. |
|
880 |
]. |
|
881 |
]. |
|
882 |
argsToRead == 0 ifTrue:[ |
|
883 |
self doSingleSpec:selector args:args for:aView frame:frame |
|
884 |
] |
|
66 | 885 |
] |
139 | 886 |
|
887 |
"Created: 9.12.1995 / 23:06:18 / cg" |
|
66 | 888 |
! |
889 |
||
125 | 890 |
readSpec:aSpec |
891 |
|what| |
|
892 |
||
893 |
what := aSpec first. |
|
894 |
^ self perform:('x' , what , ':') asSymbol with:aSpec |
|
895 |
! |
|
896 |
||
66 | 897 |
readSpec:aSpec view:aView frame:frameView |
898 |
|what| |
|
899 |
||
900 |
what := aSpec first. |
|
901 |
self perform:('x' , what , ':view:') asSymbol with:aSpec with:aView |
|
902 |
! ! |
|
903 |
||
904 |
!UIBuilder methodsFor:'private special kludges'! |
|
905 |
||
125 | 906 |
fixExtentFor:aPoint |
907 |
^ aPoint "/ (aPoint * (1 @ 1.5)) truncated |
|
908 |
! |
|
909 |
||
66 | 910 |
fixFontFor:aComponent |
911 |
"since ST-80 seems to use a smaller default font, |
|
912 |
and component sizes are often given in pixels in winSpecs, |
|
75 | 913 |
make the font smaller for less ugly looking elements." |
66 | 914 |
|
915 |
"/ aComponent font:(aComponent font size:8) |
|
916 |
! ! |
|
917 |
||
132 | 918 |
!UIBuilder class methodsFor:'documentation'! |
919 |
||
920 |
version |
|
363
c7a26a5ebaba
doFinalHookup (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
344
diff
changeset
|
921 |
^ '$Header: /cvs/stx/stx/libview2/UIBuilder.st,v 1.16 1997-01-14 14:17:37 cg Exp $' |
132 | 922 |
! ! |
100 | 923 |
UIBuilder initialize! |