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