1 'From Smalltalk/X, Version:2.10.5 on 11-apr-1995 at 9:42:52 am'! |
1 'From Smalltalk/X, Version:2.10.5 on 11-apr-1995 at 9:42:52 am'! |
2 |
2 |
3 WindowBuilder subclass:#UIBuilder |
3 WindowBuilder subclass:#UIBuilder |
4 instanceVariableNames:'' |
4 instanceVariableNames:'view currentMenuSelector menuAspect' |
5 classVariableNames:'Verbose' |
5 classVariableNames:'Verbose' |
6 poolDictionaries:'' |
6 poolDictionaries:'' |
7 category:'Interface-Support-UI' |
7 category:'Interface-Support-UI' |
8 ! |
8 ! |
9 |
9 |
26 |
26 |
27 initialize |
27 initialize |
28 Verbose := false "/ debugging flag |
28 Verbose := false "/ debugging flag |
29 ! ! |
29 ! ! |
30 |
30 |
|
31 !UIBuilder methodsFor:'accessing'! |
|
32 |
|
33 menuAspect |
|
34 ^ menuAspect |
|
35 ! ! |
|
36 |
31 !UIBuilder methodsFor:'operation'! |
37 !UIBuilder methodsFor:'operation'! |
32 |
38 |
33 buildFromSpec:aSpec |
39 buildFromSpec:aSpec |
|
40 |m| |
|
41 |
34 self readSpec:aSpec. |
42 self readSpec:aSpec. |
|
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 |
35 ^ topView |
56 ^ topView |
36 ! ! |
57 ! ! |
37 |
58 |
38 !UIBuilder methodsFor:'private spec component parsing'! |
59 !UIBuilder methodsFor:'private spec component parsing'! |
39 |
60 |
45 self doSpec:aSpec for:l |
66 self doSpec:aSpec for:l |
46 |
67 |
47 ! |
68 ! |
48 |
69 |
49 xFullSpec:aSpec |
70 xFullSpec:aSpec |
50 topView := StandardSystemView new. |
71 topView isNil ifTrue:[ |
51 topView controller:(ApplicationController new). |
72 topView := StandardSystemView new. |
52 topView application:application. |
73 topView controller:(ApplicationController new). |
53 |
74 topView application:application. |
54 self doSpec:aSpec for:topView. |
75 ]. |
|
76 |
|
77 view := View new. |
|
78 self doSpec:aSpec for:view. |
|
79 |
|
80 topView extent:(view extent). |
|
81 view origin:0.0@0.0 corner:1.0@1.0. |
|
82 topView add:view. |
|
83 |
55 ^ topView |
84 ^ topView |
|
85 ! |
|
86 |
|
87 xSubCanvasSpec:aSpec view:aView |
|
88 |v| |
|
89 |
|
90 v := SubCanvas in:aView. |
|
91 self doSpec:aSpec for:v |
56 ! |
92 ! |
57 |
93 |
58 xSpecCollection:aSpec view:aView |
94 xSpecCollection:aSpec view:aView |
59 self doSpec:aSpec for:aView |
95 self doSpec:aSpec for:aView |
60 |
96 |
61 ! |
97 ! |
62 |
98 |
63 xWindowSpec:aSpec view:aView |
99 xWindowSpec:aSpec view:aView |
64 self doSpec:aSpec for:aView |
100 self doSpec:aSpec for:aView |
65 |
101 |
|
102 ! |
|
103 |
|
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 |
66 ! |
156 ! |
67 |
157 |
68 xInputFieldSpec:aSpec view:aView |
158 xInputFieldSpec:aSpec view:aView |
69 |l| |
159 |l| |
70 |
160 |
132 ! |
222 ! |
133 |
223 |
134 xCompositeSpecCollection:aSpec view:aView |
224 xCompositeSpecCollection:aSpec view:aView |
135 |v| |
225 |v| |
136 |
226 |
137 "/ 'compositeSpecCollection ignoed' printNL. |
227 "/ 'compositeSpecCollection ignored' printNL. |
138 "/ ^ self. |
228 "/ ^ self. |
139 v := View in:aView. |
229 v := View in:aView. |
140 self doSpec:aSpec for:v |
230 self doSpec:aSpec for:v |
141 |
231 |
142 ! |
232 ! |
143 |
233 |
144 xArbitraryComponentSpec:aSpec view:aView |
234 xArbitraryComponentSpec:aSpec view:aView |
145 |v| |
235 |v| |
146 |
236 |
147 "/ v := View in:aView. |
237 v := View in:aView. |
148 v := Label label:'ArbitraryView' in:aView. |
238 "/ v := Label label:'ArbitraryView' in:aView. |
149 v level:-1. |
239 v level:-1. |
150 self doSpec:aSpec for:v |
240 self doSpec:aSpec for:v |
151 ! |
241 ! |
152 |
242 |
153 xCheckBoxSpec:aSpec view:aView |
243 xCheckBoxSpec:aSpec view:aView |
182 self doSpec:aSpec for:l |
272 self doSpec:aSpec for:l |
183 ! ! |
273 ! ! |
184 |
274 |
185 !UIBuilder methodsFor:'private spec attribute parsing'! |
275 !UIBuilder methodsFor:'private spec attribute parsing'! |
186 |
276 |
187 yMultipleSelections:args view:aView |
277 yMultipleSelections:args view:aView frame:frameView |
|
278 args == true ifTrue:[ |
|
279 aView multipleSelectOk:true |
|
280 ] |
|
281 ! |
|
282 |
|
283 XXyMultipleSelections:args view:aView |
188 aView multipleSelectOk:args |
284 aView multipleSelectOk:args |
189 ! |
285 ! |
190 |
286 |
191 yBounds:args view:aView frame:frameView |
287 yBounds:args view:aView frame:frameView |
192 |value r| |
288 |value r| |
209 yComponent:args view:aView frame:frameView |
305 yComponent:args view:aView frame:frameView |
210 |v| |
306 |v| |
211 |
307 |
212 args isSymbol ifTrue:[ |
308 args isSymbol ifTrue:[ |
213 v := application perform:args. |
309 v := application perform:args. |
|
310 v origin:0.0@0.0 corner:1.0@1.0. |
214 aView addSubView:v |
311 aView addSubView:v |
215 ] ifFalse:[ |
312 ] ifFalse:[ |
216 v := View origin:0.0@0.0 corner:1.0@1.0 in:aView. |
313 "/ v := View origin:0.0@0.0 corner:1.0@1.0 in:aView. |
217 self readSpec:args view:v frame:frameView. |
314 "/ self readSpec:args view:v frame:frameView. |
|
315 self readSpec:args view:aView frame:frameView. |
218 ] |
316 ] |
219 ! |
317 ! |
220 |
318 |
221 yColors:args view:aView frame:frameView |
319 yColors:args view:aView frame:frameView |
222 |value| |
320 |value| |
349 |model| |
447 |model| |
350 |
448 |
351 (aspects notNil and:[aspects includesKey:args]) ifTrue:[ |
449 (aspects notNil and:[aspects includesKey:args]) ifTrue:[ |
352 model := aspects at:args |
450 model := aspects at:args |
353 ] ifFalse:[ |
451 ] ifFalse:[ |
354 model := application perform:args |
452 (aView isMemberOf:Button) ifTrue:[ |
|
453 model := application. |
|
454 aView aspect:nil. |
|
455 aView changeMessage:args. |
|
456 ] ifFalse:[ |
|
457 model := application perform:args. |
|
458 ]. |
355 ]. |
459 ]. |
356 aView model:model. |
460 aView model:model. |
357 ! |
461 ! |
358 |
462 |
359 yIsOpaque:args view:aView frame:frameView |
463 yIsOpaque:args view:aView frame:frameView |
376 ]. |
480 ]. |
377 self halt:'unimplemented'. |
481 self halt:'unimplemented'. |
378 ! |
482 ! |
379 |
483 |
380 yMenu:args view:aView frame:frameView |
484 yMenu:args view:aView frame:frameView |
381 'menu ignored' printNL |
485 menuAspect := args |
382 ! |
486 ! |
383 |
487 |
384 yName:args view:aView frame:frameView |
488 yName:args view:aView frame:frameView |
385 bindings isNil ifTrue:[ |
489 self componentAt:args put:aView |
386 bindings := IdentityDictionary new. |
|
387 ]. |
|
388 bindings at:args put:aView |
|
389 ! |
490 ! |
390 |
491 |
391 yOrientation:args view:aView frame:frameView |
492 yOrientation:args view:aView frame:frameView |
392 'orientation ignored' printNL. |
493 'orientation ignored' printNL. |
393 ! |
494 ! |
406 'tabable element added' printNL. |
507 'tabable element added' printNL. |
407 ] |
508 ] |
408 ! |
509 ! |
409 |
510 |
410 yStart:args view:aView frame:frameView |
511 yStart:args view:aView frame:frameView |
|
512 (aView isKindOf:Scroller) ifTrue:[ |
|
513 aView start:args. |
|
514 ^ self |
|
515 ]. |
411 'start ignored' printNL. |
516 'start ignored' printNL. |
412 |
|
413 ! |
517 ! |
414 |
518 |
415 yStep:args view:aView frame:frameView |
519 yStep:args view:aView frame:frameView |
416 'step ignored' printNL. |
520 'step ignored' printNL. |
417 |
521 |
418 ! |
522 ! |
419 |
523 |
|
524 yStop:args view:aView frame:frameView |
|
525 (aView isKindOf:Scroller) ifTrue:[ |
|
526 aView stop:args. |
|
527 ^ self |
|
528 ]. |
|
529 'stop ignored' printNL. |
|
530 ! |
|
531 |
|
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. |
|
541 |
|
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 |
420 yWindow:args view:aView frame:frameView |
560 yWindow:args view:aView frame:frameView |
421 self readSpec:args view:aView frame:frameView. |
561 self readSpec:args view:aView frame:frameView. |
422 ! |
562 ! |
423 |
563 |
424 yStop:args view:aView frame:frameView |
|
425 'stop ignored' printNL. |
|
426 |
|
427 ! |
|
428 |
|
429 yStyle:args view:aView frame:frameView |
564 yStyle:args view:aView frame:frameView |
430 'name ignored' printNL. |
565 'name ignored' printNL. |
431 |
566 |
432 ! |
567 ! |
433 |
568 |
434 yType:args view:aView frame:frameView |
569 yType:args view:aView frame:frameView |
|
570 (aView isMemberOf:EditField) ifTrue:[ |
|
571 args == #number ifTrue:[ |
|
572 aView converter:(PrintConverter new initForNumber). |
|
573 ^ self |
|
574 ] |
|
575 ]. |
|
576 |
435 'type ignored' printNL. |
577 'type ignored' printNL. |
436 ! ! |
578 ! ! |
437 |
579 |
438 !UIBuilder methodsFor:'private arg parsing'! |
580 !UIBuilder methodsFor:'private arg parsing'! |
439 |
581 |