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