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