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