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