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