UIBuilder.st
changeset 372 6d7718f3d298
parent 367 7316abe03075
child 373 66283cb455bf
equal deleted inserted replaced
371:ce94ec6a38ee 372:6d7718f3d298
    59 
    59 
    60 menuAspect
    60 menuAspect
    61     ^ menuAspect
    61     ^ menuAspect
    62 ! !
    62 ! !
    63 
    63 
    64 !UIBuilder methodsFor:'operation'!
    64 !UIBuilder methodsFor:'building'!
    65 
    65 
    66 add:aSpec
    66 add:aSpec
    67     view := aSpec buildViewFor:self.
    67     view := aSpec buildViewFor:self.
    68     ^ view
    68     ^ view
    69 
    69 
    75 
    75 
    76 "/ old:
    76 "/ old:
    77 "/    self readSpec:aSpecArray.
    77 "/    self readSpec:aSpecArray.
    78 
    78 
    79     spec := UISpecification from:aSpecArray.
    79     spec := UISpecification from:aSpecArray.
    80     topView := view := spec buildViewFor:self.
    80     window := view := spec buildViewFor:self.
    81 
    81 
    82     menuAspect notNil ifTrue:[
    82 "/    menuAspect notNil ifTrue:[
    83 	m := self componentAt:menuAspect.
    83 "/        m := self componentAt:menuAspect.
    84 	m notNil ifTrue:[
    84 "/        m notNil ifTrue:[
    85 	    m := m value.
    85 "/            m := m value.
    86 	    m notNil ifTrue:[
    86 "/            m notNil ifTrue:[
    87 		m receiver:application.
    87 "/                m receiver:application.
    88 		topView add:m.
    88 "/                window add:m.
    89 		view topInset:(m heightIncludingBorder).
    89 "/                view topInset:(m heightIncludingBorder).
    90 	    ]
    90 "/            ]
    91 	]
    91 "/        ]
    92     ].
    92 "/    ].
    93 
    93 
    94     ^ topView
    94     ^ window
    95 
    95 
    96     "Modified: 5.9.1995 / 21:43:29 / claus"
    96     "Modified: 5.9.1995 / 21:43:29 / claus"
       
    97     "Modified: 17.1.1997 / 19:33:05 / cg"
    97 !
    98 !
    98 
    99 
    99 buildFromSpec:aSpecArray in:aView
   100 buildFromSpec:aSpecArray in:aView
   100     |m spec|
   101     |m spec|
   101 
   102 
   102     spec := UISpecification from:aSpecArray.
   103     spec := UISpecification from:aSpecArray.
   103 
   104 
   104     view := spec buildViewFor:self in:aView.
   105     view := spec buildViewFor:self in:aView.
   105 
   106 
   106     menuAspect notNil ifTrue:[
   107 "/    menuAspect notNil ifTrue:[
   107 	m := self componentAt:menuAspect.
   108 "/        m := self componentAt:menuAspect.
   108 	m notNil ifTrue:[
   109 "/        m notNil ifTrue:[
   109 	    m := m value.
   110 "/            m := m value.
   110 	    m notNil ifTrue:[
   111 "/            m notNil ifTrue:[
   111 		m receiver:application.
   112 "/                m receiver:application.
   112 		topView add:m.
   113 "/                window add:m.
   113 		view topInset:(m heightIncludingBorder).
   114 "/                view topInset:(m heightIncludingBorder).
   114 	    ]
   115 "/            ]
   115 	]
   116 "/        ]
   116     ].
   117 "/    ].
   117 
   118 
   118     ^ topView
   119     ^ view
   119 
   120 
   120     "Modified: 5.9.1995 / 21:48:09 / claus"
   121     "Modified: 5.9.1995 / 21:48:09 / claus"
       
   122     "Modified: 17.1.1997 / 19:33:48 / cg"
   121 !
   123 !
   122 
   124 
   123 doFinalHookup
   125 doFinalHookup
   124 
   126 
   125     "Created: 14.2.1997 / 14:52:27 / cg"
   127     "Created: 14.2.1997 / 14:52:27 / cg"
   126 ! !
   128 ! !
   127 
   129 
   128 !UIBuilder ignoredMethodsFor:'private arg parsing'!
       
   129 
       
   130 getAlignmentOrigin:spec
       
   131     "called for #(AlignmentOrigin ?x ?relX ?x ?y ?relY ?y)"
       
   132 
       
   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 ?
       
   138 !
       
   139 
       
   140 getArg:spec
       
   141     "take something like #(Point 50 100) and return the value"
       
   142 
       
   143     |what|
       
   144 
       
   145     what := spec at:1.
       
   146     ^ self perform:('get' , what , ':') asSymbol with:spec
       
   147 !
       
   148 
       
   149 getColorValue:spec
       
   150     "called for #(ColorValue #sym)
       
   151 	     or #(ColorValue red green blue)"
       
   152 
       
   153     |arg|
       
   154 
       
   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)
       
   169 
       
   170 
       
   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)))
       
   238 ! !
       
   239 
       
   240 !UIBuilder ignoredMethodsFor:'private spec attribute parsing'!
       
   241 
       
   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 
       
   275 yCollection:args view:aView frame:frameView
       
   276     args do:[:aSpec |
       
   277 	self readSpec:aSpec view:aView frame:frameView.
       
   278     ].
       
   279 !
       
   280 
       
   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.
       
   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.
       
   315 
       
   316 !
       
   317 
       
   318 yDefaultable:args view:aView frame:frameView
       
   319     'defaultable ignored' printCR
       
   320 
       
   321     "Modified: 20.5.1996 / 10:29:24 / cg"
       
   322 !
       
   323 
       
   324 yFlags:args view:aView frame:frameView
       
   325     'flags: ' print. args print. ' for ' print. aView print. ' ignored' printCR
       
   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"
       
   336     "Modified: 20.5.1996 / 10:29:26 / cg"
       
   337 !
       
   338 
       
   339 yIsDefault:args view:aView frame:frameView
       
   340     aView isReturnButton:args
       
   341 !
       
   342 
       
   343 yIsOpaque:args view:aView frame:frameView
       
   344     'isOpaque ignored' printCR.
       
   345 
       
   346     "Modified: 20.5.1996 / 10:29:29 / cg"
       
   347 !
       
   348 
       
   349 yIsReadOnly:args view:aView frame:frameView
       
   350     args ifTrue:[
       
   351 	aView readOnly
       
   352     ]
       
   353 !
       
   354 
       
   355 yLayout:args view:aView frame:frameView
       
   356     |value r org corn orgInset cornInset what|
       
   357 
       
   358     value := self getArg:args.
       
   359     value isLayout ifTrue:[
       
   360         frameView geometryLayout:value.
       
   361         ^ self
       
   362     ].
       
   363 
       
   364     what := value at:1.
       
   365     what == #point ifTrue:[
       
   366         Verbose ifTrue:[frameView print. ' ' print. 'origin: ' print. (value at:2) printCR].
       
   367         frameView origin:(value at:2).
       
   368         ^ self
       
   369     ].
       
   370     what == #rectangle ifTrue:[
       
   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
       
   378     ].
       
   379     what == #layoutOrigin ifTrue:[
       
   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
       
   392     ].
       
   393     what == #layoutFrame ifTrue:[
       
   394         "/ #layoutFrame orgInset cornInset relOrg relCorner
       
   395 
       
   396         org := value at:4.       "/ relative origin
       
   397         orgInset := self fixExtentFor:(value at:2).
       
   398 
       
   399         org := org x asFloat @ org y asFloat.
       
   400 "/        org = (0@0) ifTrue:[
       
   401 "/            org := value at:2    "/ absolute origin
       
   402 "/        ].
       
   403 
       
   404         corn := value at:5.      "/ relative corner
       
   405         cornInset := self fixExtentFor:(value at:3).
       
   406         corn := corn x asFloat @ corn y asFloat.
       
   407 "/        corn = (0@0) ifTrue:[
       
   408 "/            corn := value at:3   "/ absolute corner
       
   409 "/        ].
       
   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
       
   421     ].
       
   422     what == #alignmentOrigin ifTrue:[
       
   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
       
   430     ].
       
   431 
       
   432     self halt:'unimplemented'.
       
   433 
       
   434     "Modified: 20.5.1996 / 10:29:35 / cg"
       
   435 !
       
   436 
       
   437 yMax:args view:aView frame:frameView
       
   438     |value|
       
   439 
       
   440     value := self getArg:args.
       
   441     (value at:1) == #point ifTrue:[
       
   442 	aView maxExtent:(value at:2).
       
   443 	^ self
       
   444     ].
       
   445     self halt:'unimplemented'.
       
   446 !
       
   447 
       
   448 yMenu:args view:aView frame:frameView
       
   449     menuAspect := args
       
   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:[
       
   469 	(aView isMemberOf:Button) ifTrue:[
       
   470 	    model := application.
       
   471 	    aView aspect:nil.
       
   472 	    aView changeMessage:args.
       
   473 	] ifFalse:[
       
   474 	    model := application perform:args.
       
   475 	].
       
   476     ].
       
   477     aView model:model.
       
   478 !
       
   479 
       
   480 yMultipleSelections:args view:aView frame:frameView
       
   481     args == true ifTrue:[
       
   482 	aView multipleSelectOk:true
       
   483     ]
       
   484 !
       
   485 
       
   486 yName:args view:aView frame:frameView
       
   487     self componentAt:args put:aView
       
   488 !
       
   489 
       
   490 yOrientation:args view:aView frame:frameView
       
   491     'orientation ignored' printCR.
       
   492 
       
   493     "Modified: 20.5.1996 / 10:29:37 / cg"
       
   494 !
       
   495 
       
   496 ySelectionStyle:args view:aView frame:frameView
       
   497     'selectionStyle ignored' printCR.
       
   498 
       
   499     "Modified: 20.5.1996 / 10:29:41 / cg"
       
   500 !
       
   501 
       
   502 yStart:args view:aView frame:frameView
       
   503     (aView isKindOf:Scroller) ifTrue:[
       
   504         aView start:args.
       
   505         ^ self
       
   506     ].
       
   507     'start ignored' printCR.
       
   508 
       
   509     "Modified: 20.5.1996 / 10:29:42 / cg"
       
   510 !
       
   511 
       
   512 yStep:args view:aView frame:frameView
       
   513     'step ignored' printCR.
       
   514 
       
   515     "Modified: 20.5.1996 / 10:29:44 / cg"
       
   516 !
       
   517 
       
   518 yStop:args view:aView frame:frameView
       
   519     (aView isKindOf:Scroller) ifTrue:[
       
   520         aView stop:args.
       
   521         ^ self
       
   522     ].
       
   523     'stop ignored' printCR.
       
   524 
       
   525     "Modified: 20.5.1996 / 10:29:46 / cg"
       
   526 !
       
   527 
       
   528 yStyle:args view:aView frame:frameView
       
   529     'name ignored' printCR.
       
   530 
       
   531     "Modified: 20.5.1996 / 10:29:48 / cg"
       
   532 !
       
   533 
       
   534 ySubmenu:aSpec view:menu frame:frameView
       
   535     |items lines selectors labels|
       
   536 
       
   537     aSpec first ~~ #Menu ifTrue:[
       
   538         self halt:'unexpected'.
       
   539     ].
       
   540     items := (aSpec at:2).
       
   541     lines := aSpec at:3.
       
   542     selectors := aSpec at:4.
       
   543 
       
   544     "collect labels & selectors"
       
   545     labels := OrderedCollection new.
       
   546     items do:[:item |
       
   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).
       
   554     ].
       
   555 
       
   556     menu at:currentMenuSelector
       
   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"
       
   563 !
       
   564 
       
   565 yTabable:args view:aView frame:frameView
       
   566     args == true ifTrue:[
       
   567         focusSequence isNil ifTrue:[
       
   568             focusSequence := OrderedCollection new.
       
   569         ].
       
   570         focusSequence add:aView.
       
   571         'tabable element added' printCR.
       
   572     ]
       
   573 
       
   574     "Modified: 20.5.1996 / 10:29:53 / cg"
       
   575 !
       
   576 
       
   577 yType:args view:aView frame:frameView
       
   578     (aView isMemberOf:EditField) ifTrue:[
       
   579         args == #number ifTrue:[
       
   580             aView converter:(PrintConverter new initForNumber).
       
   581             ^ self
       
   582         ]
       
   583     ].
       
   584 
       
   585     'type ignored' printCR.
       
   586 
       
   587     "Modified: 20.5.1996 / 10:29:55 / cg"
       
   588 !
       
   589 
       
   590 yWindow:args view:aView frame:frameView
       
   591     self readSpec:args view:aView frame:frameView.
       
   592 ! !
       
   593 
       
   594 !UIBuilder ignoredMethodsFor:'private spec component parsing'!
       
   595 
       
   596 xActionButtonSpec:aSpec view:aView
       
   597     |b|
       
   598 
       
   599     b := Button in:aView.
       
   600     self fixFontFor:b.
       
   601     self doSpec:aSpec for:b 
       
   602 !
       
   603 
       
   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 
       
   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 
       
   668 xGroupBoxSpec:aSpec view:aView
       
   669     |l|
       
   670 
       
   671     l := FramedBox in:aView.
       
   672     self doSpec:aSpec for:l 
       
   673 !
       
   674 
       
   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"
       
   682 !
       
   683 
       
   684 xInputFieldSpec:aSpec view:aView
       
   685     |l|
       
   686 
       
   687     l := EditField in:aView.
       
   688     self fixFontFor:l.
       
   689     l aspect:#value; change:#value:.
       
   690     self doSpec:aSpec for:l 
       
   691 !
       
   692 
       
   693 xLabelSpec:aSpec view:aView
       
   694     |l|
       
   695 
       
   696     l := Label in:aView.
       
   697     self fixFontFor:l.
       
   698     self doSpec:aSpec for:l 
       
   699 
       
   700 !
       
   701 
       
   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.
       
   712 
       
   713     "precollect labels ..."
       
   714     labels := OrderedCollection new.
       
   715     items do:[:item |
       
   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)
       
   723     ].
       
   724 
       
   725     topView labels:labels.
       
   726 
       
   727     items with:(1 to:numItems) do:[:item :index |
       
   728         currentMenuSelector := index.
       
   729         self doSpec:item for:topView.
       
   730     ].
       
   731 
       
   732     currentMenuSelector := prevCurrent.
       
   733     ^ topView
       
   734 
       
   735     "Created: 9.12.1995 / 23:06:31 / cg"
       
   736     "Modified: 9.12.1995 / 23:08:11 / cg"
       
   737 !
       
   738 
       
   739 xPopUpMenu:aSpec
       
   740     |menu values|
       
   741 
       
   742     menu := PopUpMenu 
       
   743 		labels:(aSpec at:2).
       
   744     values := Array new:((aSpec at:2) size).
       
   745 
       
   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 	]
       
   753     ].
       
   754 
       
   755     menu values:values.
       
   756     ^ menu
       
   757 !
       
   758 
       
   759 xProgressIndicatorSpec:aSpec view:aView
       
   760     |s|
       
   761 
       
   762     s := ProgressIndicator in:aView.
       
   763     self doSpec:aSpec for:s 
       
   764 !
       
   765 
       
   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 
       
   783 xSequenceViewSpec:aSpec view:aView
       
   784     |f s|
       
   785 
       
   786     f := ScrollableView for:SelectionInListView in:aView.
       
   787     s := f scrolledView.
       
   788     self doSpec:aSpec for:s frame:f.
       
   789 !
       
   790 
       
   791 xSliderSpec:aSpec view:aView
       
   792     |s idx orientation|
       
   793 
       
   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 
       
   808 xSpecCollection:aSpec view:aView
       
   809     self doSpec:aSpec for:aView
       
   810 
       
   811 !
       
   812 
       
   813 xSubCanvasSpec:aSpec view:aView
       
   814     |v|
       
   815 
       
   816     v := SubCanvas in:aView.
       
   817     v origin:0.0@0.0 corner:1.0@1.0.
       
   818     self doSpec:aSpec for:v
       
   819 
       
   820     "Modified: 2.9.1995 / 15:26:15 / claus"
       
   821 !
       
   822 
       
   823 xTableViewSpec:aSpec view:aView
       
   824     |l|
       
   825 
       
   826     'tableView ignored' printCR.
       
   827     l := Label label:'TableView' in:aView.
       
   828     l level:-1.
       
   829     self doSpec:aSpec for:l
       
   830 
       
   831     "Modified: 20.5.1996 / 10:29:20 / cg"
       
   832 !
       
   833 
       
   834 xVerticalPanelViewSpec:aSpec view:aView
       
   835     |v|
       
   836 
       
   837     v := VerticalPanelView in:aView.
       
   838     self doSpec:aSpec for:v
       
   839 
       
   840     "Modified: 5.9.1995 / 21:06:19 / claus"
       
   841 !
       
   842 
       
   843 xWindowSpec:aSpec view:aView
       
   844     self doSpec:aSpec for:aView
       
   845 
       
   846 ! !
       
   847 
       
   848 !UIBuilder ignoredMethodsFor:'private spec parsing'!
       
   849 
       
   850 doSingleSpec:selector args:args for:aView frame:frame
       
   851     Verbose ifTrue:[
       
   852         'doSingle (' print. aView print. ' -> ' print. selector print.
       
   853         ' ' print. args printString printCR.
       
   854     ].
       
   855 
       
   856     self perform:('y' , selector asString asUppercaseFirst , 'view:frame:') asSymbol 
       
   857             with:args
       
   858             with:aView
       
   859             with:frame.
       
   860 
       
   861     "Modified: 20.5.1996 / 10:29:17 / cg"
       
   862 !
       
   863 
       
   864 doSpec:aSpec for:aView
       
   865     ^ self doSpec:aSpec for:aView frame:aView
       
   866 !
       
   867 
       
   868 doSpec:aSpec for:aView frame:frame 
       
   869     |selector args argsToRead|
       
   870 
       
   871     argsToRead := 0.
       
   872     args := #().
       
   873     aSpec from:2 to:(aSpec size) do:[:element |
       
   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         ]
       
   888     ]
       
   889 
       
   890     "Created: 9.12.1995 / 23:06:18 / cg"
       
   891 !
       
   892 
       
   893 readSpec:aSpec
       
   894     |what|
       
   895 
       
   896     what := aSpec first.
       
   897     ^ self perform:('x' , what , ':') asSymbol with:aSpec
       
   898 !
       
   899 
       
   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 
       
   907 !UIBuilder ignoredMethodsFor:'private special kludges'!
       
   908 
       
   909 fixExtentFor:aPoint
       
   910     ^ aPoint "/ (aPoint * (1 @ 1.5)) truncated
       
   911 !
       
   912 
       
   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,
       
   916      make the font smaller for less ugly looking elements."
       
   917 
       
   918 "/   aComponent font:(aComponent font size:8)
       
   919 ! !
       
   920 
       
   921 !UIBuilder class methodsFor:'documentation'!
   130 !UIBuilder class methodsFor:'documentation'!
   922 
   131 
   923 version
   132 version
   924     ^ '$Header: /cvs/stx/stx/libview2/UIBuilder.st,v 1.17 1997-01-16 10:11:49 cg Exp $'
   133     ^ '$Header: /cvs/stx/stx/libview2/UIBuilder.st,v 1.18 1997-01-17 19:53:59 cg Exp $'
   925 ! !
   134 ! !
   926 UIBuilder initialize!
   135 UIBuilder initialize!