author | Claus Gittinger <cg@exept.de> |
Sat, 09 Dec 1995 23:11:21 +0100 | |
changeset 139 | 779ae6adb925 |
parent 132 | 0a8fe342ed91 |
child 223 | b65dc250db8d |
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:[ |
|
139 | 507 |
self halt:'unexpected'. |
86 | 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 | |
|
139 | 516 |
item first ~~ #MenuItem ifTrue:[ |
517 |
self halt:'unexpected' |
|
518 |
]. |
|
519 |
(item at:2) ~~ #'label:' ifTrue:[ |
|
520 |
self halt:'unexpected' |
|
521 |
]. |
|
522 |
labels add:(item at:3). |
|
86 | 523 |
]. |
524 |
||
525 |
menu at:currentMenuSelector |
|
139 | 526 |
putLabels:labels |
527 |
selectors:selectors |
|
528 |
receiver:nil. |
|
529 |
||
530 |
"Created: 9.12.1995 / 23:06:39 / cg" |
|
531 |
"Modified: 9.12.1995 / 23:08:15 / cg" |
|
86 | 532 |
! |
533 |
||
125 | 534 |
yTabable:args view:aView frame:frameView |
535 |
args == true ifTrue:[ |
|
536 |
focusSequence isNil ifTrue:[ |
|
537 |
focusSequence := OrderedCollection new. |
|
538 |
]. |
|
539 |
focusSequence add:aView. |
|
540 |
'tabable element added' printNL. |
|
541 |
] |
|
66 | 542 |
! |
543 |
||
544 |
yType:args view:aView frame:frameView |
|
86 | 545 |
(aView isMemberOf:EditField) ifTrue:[ |
546 |
args == #number ifTrue:[ |
|
547 |
aView converter:(PrintConverter new initForNumber). |
|
548 |
^ self |
|
549 |
] |
|
550 |
]. |
|
551 |
||
66 | 552 |
'type ignored' printNL. |
100 | 553 |
! |
554 |
||
125 | 555 |
yWindow:args view:aView frame:frameView |
556 |
self readSpec:args view:aView frame:frameView. |
|
66 | 557 |
! ! |
558 |
||
100 | 559 |
!UIBuilder methodsFor:'private spec component parsing'! |
66 | 560 |
|
100 | 561 |
xActionButtonSpec:aSpec view:aView |
562 |
|b| |
|
563 |
||
564 |
b := Button in:aView. |
|
565 |
self fixFontFor:b. |
|
566 |
self doSpec:aSpec for:b |
|
66 | 567 |
! |
568 |
||
125 | 569 |
xArbitraryComponentSpec:aSpec view:aView |
570 |
|v| |
|
571 |
||
572 |
v := View in:aView. |
|
573 |
"/ v := Label label:'ArbitraryView' in:aView. |
|
574 |
v origin:0.0@0.0 corner:1.0@1.0. |
|
575 |
v level:-1. |
|
576 |
self doSpec:aSpec for:v |
|
577 |
||
578 |
"Modified: 2.9.1995 / 15:26:03 / claus" |
|
579 |
! |
|
580 |
||
581 |
xCheckBoxSpec:aSpec view:aView |
|
582 |
|b| |
|
583 |
||
584 |
b := CheckBox in:aView. |
|
585 |
self fixFontFor:b. |
|
586 |
self doSpec:aSpec for:b |
|
587 |
||
588 |
! |
|
589 |
||
590 |
xCompositeSpecCollection:aSpec view:aView |
|
591 |
|v| |
|
592 |
||
593 |
"/ 'compositeSpecCollection ignored' printNL. |
|
594 |
"/ ^ self. |
|
595 |
v := View in:aView. |
|
596 |
self doSpec:aSpec for:v |
|
597 |
||
598 |
! |
|
599 |
||
600 |
xDividerSpec:aSpec view:aView |
|
601 |
|l| |
|
602 |
||
603 |
l := View in:aView. |
|
604 |
self doSpec:aSpec for:l |
|
605 |
! |
|
606 |
||
607 |
xFramedBoxSpec:aSpec view:aView |
|
608 |
|v| |
|
609 |
||
610 |
v := FramedBox in:aView. |
|
611 |
self doSpec:aSpec for:v |
|
612 |
||
613 |
"Modified: 5.9.1995 / 21:05:38 / claus" |
|
614 |
! |
|
615 |
||
100 | 616 |
xFullSpec:aSpec |
617 |
topView isNil ifTrue:[ |
|
618 |
topView := StandardSystemView new. |
|
619 |
topView controller:(ApplicationController new). |
|
620 |
topView application:application. |
|
621 |
]. |
|
622 |
||
623 |
view := View new. |
|
624 |
self doSpec:aSpec for:view. |
|
625 |
||
626 |
topView extent:(view extent). |
|
627 |
view origin:0.0@0.0 corner:1.0@1.0. |
|
628 |
topView add:view. |
|
629 |
||
630 |
^ topView |
|
631 |
! |
|
632 |
||
125 | 633 |
xGroupBoxSpec:aSpec view:aView |
634 |
|l| |
|
635 |
||
636 |
l := FramedBox in:aView. |
|
637 |
self doSpec:aSpec for:l |
|
638 |
! |
|
66 | 639 |
|
125 | 640 |
xHorizontalPanelViewSpec:aSpec view:aView |
641 |
|v| |
|
642 |
||
643 |
v := HorizontalPanelView in:aView. |
|
644 |
self doSpec:aSpec for:v |
|
645 |
||
646 |
"Modified: 5.9.1995 / 21:06:25 / claus" |
|
66 | 647 |
! |
648 |
||
125 | 649 |
xInputFieldSpec:aSpec view:aView |
650 |
|l| |
|
66 | 651 |
|
125 | 652 |
l := EditField in:aView. |
653 |
self fixFontFor:l. |
|
654 |
l aspect:#value; change:#value:. |
|
655 |
self doSpec:aSpec for:l |
|
656 |
! |
|
100 | 657 |
|
125 | 658 |
xLabelSpec:aSpec view:aView |
659 |
|l| |
|
660 |
||
661 |
l := Label in:aView. |
|
662 |
self fixFontFor:l. |
|
663 |
self doSpec:aSpec for:l |
|
664 |
||
66 | 665 |
! |
666 |
||
100 | 667 |
xMenu:aSpec |
668 |
|items numItems unknown prevCurrent labels| |
|
669 |
||
670 |
topView := PullDownMenu new. |
|
671 |
||
672 |
items := aSpec at:2. |
|
673 |
numItems := (aSpec at:3) at:1. |
|
674 |
unknown := (aSpec at:4). |
|
675 |
||
676 |
prevCurrent := currentMenuSelector. |
|
66 | 677 |
|
100 | 678 |
"precollect labels ..." |
679 |
labels := OrderedCollection new. |
|
680 |
items do:[:item | |
|
139 | 681 |
(item at:1) ~~ #MenuItem ifTrue:[ |
682 |
self halt:'unexpected' |
|
683 |
]. |
|
684 |
(item at:2) ~~ #'label:' ifTrue:[ |
|
685 |
self halt:'unexpected' |
|
686 |
]. |
|
687 |
labels add:(item at:3) |
|
100 | 688 |
]. |
689 |
||
690 |
topView labels:labels. |
|
691 |
||
692 |
items with:(1 to:numItems) do:[:item :index | |
|
139 | 693 |
currentMenuSelector := index. |
694 |
self doSpec:item for:topView. |
|
100 | 695 |
]. |
696 |
||
697 |
currentMenuSelector := prevCurrent. |
|
698 |
^ topView |
|
139 | 699 |
|
700 |
"Created: 9.12.1995 / 23:06:31 / cg" |
|
701 |
"Modified: 9.12.1995 / 23:08:11 / cg" |
|
66 | 702 |
! |
703 |
||
100 | 704 |
xPopUpMenu:aSpec |
705 |
|menu values| |
|
66 | 706 |
|
100 | 707 |
menu := PopUpMenu |
708 |
labels:(aSpec at:2). |
|
709 |
values := Array new:((aSpec at:2) size). |
|
66 | 710 |
|
100 | 711 |
(aSpec at:4) keysAndValuesDo:[:index :item | |
712 |
((item size > 0) |
|
713 |
and:[(item at:1) == #PopUpMenu]) ifTrue:[ |
|
714 |
menu subMenuAt:index put:(self xPopUpMenu:item) |
|
715 |
] ifFalse:[ |
|
716 |
values at:index put:item |
|
717 |
] |
|
66 | 718 |
]. |
100 | 719 |
|
720 |
menu values:values. |
|
721 |
^ menu |
|
722 |
! |
|
723 |
||
125 | 724 |
xProgressIndicatorSpec:aSpec view:aView |
725 |
|s| |
|
100 | 726 |
|
125 | 727 |
s := ProgressIndicator in:aView. |
728 |
self doSpec:aSpec for:s |
|
66 | 729 |
! |
730 |
||
100 | 731 |
xScrollerSpec:aSpec view:aView |
732 |
|s idx orientation| |
|
733 |
||
734 |
idx := aSpec indexOf:#orientation:. |
|
735 |
idx == 0 ifTrue:[ |
|
736 |
orientation := #vertical |
|
737 |
] ifFalse:[ |
|
738 |
orientation := aSpec at:(idx + 1) |
|
739 |
]. |
|
740 |
orientation == #horizontal ifTrue:[ |
|
741 |
s := HorizontalScroller in:aView |
|
742 |
] ifFalse:[ |
|
743 |
s := Scroller in:aView |
|
744 |
]. |
|
745 |
self doSpec:aSpec for:s |
|
746 |
! |
|
747 |
||
125 | 748 |
xSequenceViewSpec:aSpec view:aView |
749 |
|f s| |
|
100 | 750 |
|
125 | 751 |
f := ScrollableView for:SelectionInListView in:aView. |
752 |
s := f scrolledView. |
|
753 |
self doSpec:aSpec for:s frame:f. |
|
100 | 754 |
! |
66 | 755 |
|
100 | 756 |
xSliderSpec:aSpec view:aView |
757 |
|s idx orientation| |
|
66 | 758 |
|
100 | 759 |
idx := aSpec indexOf:#orientation:. |
760 |
idx == 0 ifTrue:[ |
|
761 |
orientation := #vertical |
|
762 |
] ifFalse:[ |
|
763 |
orientation := aSpec at:(idx + 1) |
|
764 |
]. |
|
765 |
orientation == #horizontal ifTrue:[ |
|
766 |
s := HorizontalSlider in:aView |
|
767 |
] ifFalse:[ |
|
768 |
s := Slider in:aView |
|
769 |
]. |
|
770 |
self doSpec:aSpec for:s |
|
771 |
! |
|
772 |
||
125 | 773 |
xSpecCollection:aSpec view:aView |
774 |
self doSpec:aSpec for:aView |
|
66 | 775 |
|
776 |
! |
|
777 |
||
125 | 778 |
xSubCanvasSpec:aSpec view:aView |
100 | 779 |
|v| |
66 | 780 |
|
125 | 781 |
v := SubCanvas in:aView. |
100 | 782 |
v origin:0.0@0.0 corner:1.0@1.0. |
783 |
self doSpec:aSpec for:v |
|
784 |
||
125 | 785 |
"Modified: 2.9.1995 / 15:26:15 / claus" |
100 | 786 |
! |
787 |
||
788 |
xTableViewSpec:aSpec view:aView |
|
789 |
|l| |
|
790 |
||
791 |
'tableView ignored' printNL. |
|
792 |
l := Label label:'TableView' in:aView. |
|
793 |
l level:-1. |
|
794 |
self doSpec:aSpec for:l |
|
66 | 795 |
! |
796 |
||
100 | 797 |
xVerticalPanelViewSpec:aSpec view:aView |
798 |
|v| |
|
799 |
||
800 |
v := VerticalPanelView in:aView. |
|
801 |
self doSpec:aSpec for:v |
|
66 | 802 |
|
100 | 803 |
"Modified: 5.9.1995 / 21:06:19 / claus" |
804 |
! |
|
66 | 805 |
|
125 | 806 |
xWindowSpec:aSpec view:aView |
807 |
self doSpec:aSpec for:aView |
|
100 | 808 |
|
66 | 809 |
! ! |
810 |
||
811 |
!UIBuilder methodsFor:'private spec parsing'! |
|
812 |
||
125 | 813 |
add:aSpec |
814 |
self readSpec:aSpec |
|
66 | 815 |
! |
816 |
||
125 | 817 |
doSingleSpec:selector args:args for:aView frame:frame |
818 |
Verbose ifTrue:[ |
|
819 |
'doSingle (' print. aView print. ' -> ' print. selector print. |
|
820 |
' ' print. args printString printNL. |
|
821 |
]. |
|
66 | 822 |
|
125 | 823 |
self perform:('y' , selector asString asUppercaseFirst , 'view:frame:') asSymbol |
824 |
with:args |
|
825 |
with:aView |
|
826 |
with:frame. |
|
827 |
||
828 |
! |
|
829 |
||
830 |
doSpec:aSpec for:aView |
|
831 |
^ self doSpec:aSpec for:aView frame:aView |
|
66 | 832 |
! |
833 |
||
834 |
doSpec:aSpec for:aView frame:frame |
|
835 |
|state selector args argsToRead| |
|
836 |
||
837 |
argsToRead := 0. |
|
838 |
args := #(). |
|
839 |
aSpec from:2 to:(aSpec size) do:[:element | |
|
139 | 840 |
argsToRead > 1 ifTrue:[ |
841 |
self halt:'invalid spec'. |
|
842 |
] ifFalse:[ |
|
843 |
argsToRead == 1 ifTrue:[ |
|
844 |
args := element. |
|
845 |
argsToRead := argsToRead - 1 |
|
846 |
] ifFalse:[ |
|
847 |
selector := element. |
|
848 |
argsToRead := selector numArgs. |
|
849 |
]. |
|
850 |
]. |
|
851 |
argsToRead == 0 ifTrue:[ |
|
852 |
self doSingleSpec:selector args:args for:aView frame:frame |
|
853 |
] |
|
66 | 854 |
] |
139 | 855 |
|
856 |
"Created: 9.12.1995 / 23:06:18 / cg" |
|
66 | 857 |
! |
858 |
||
125 | 859 |
readSpec:aSpec |
860 |
|what| |
|
861 |
||
862 |
what := aSpec first. |
|
863 |
^ self perform:('x' , what , ':') asSymbol with:aSpec |
|
864 |
! |
|
865 |
||
66 | 866 |
readSpec:aSpec view:aView frame:frameView |
867 |
|what| |
|
868 |
||
869 |
what := aSpec first. |
|
870 |
self perform:('x' , what , ':view:') asSymbol with:aSpec with:aView |
|
871 |
! ! |
|
872 |
||
873 |
!UIBuilder methodsFor:'private special kludges'! |
|
874 |
||
125 | 875 |
fixExtentFor:aPoint |
876 |
^ aPoint "/ (aPoint * (1 @ 1.5)) truncated |
|
877 |
! |
|
878 |
||
66 | 879 |
fixFontFor:aComponent |
880 |
"since ST-80 seems to use a smaller default font, |
|
881 |
and component sizes are often given in pixels in winSpecs, |
|
75 | 882 |
make the font smaller for less ugly looking elements." |
66 | 883 |
|
884 |
"/ aComponent font:(aComponent font size:8) |
|
885 |
! ! |
|
886 |
||
132 | 887 |
!UIBuilder class methodsFor:'documentation'! |
888 |
||
889 |
version |
|
139 | 890 |
^ '$Header: /cvs/stx/stx/libview2/UIBuilder.st,v 1.12 1995-12-09 22:11:21 cg Exp $' |
132 | 891 |
! ! |
100 | 892 |
UIBuilder initialize! |