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