[Q] Morphic strategies

Brian Brown rbb at techgame.net
Tue May 20 21:20:54 UTC 2003


On Tuesday 20 May 2003 02:42 pm, Ned Konz wrote:
> On Tuesday 20 May 2003 01:08 pm, Brian Brown wrote:
> >    My question relates to the ways of laying out groupings of
> > morphs within an "application". Simplistically I would create a
> > RectangleMorph or PasteUpMorph, give it a TableLayout (#leftToRight
> > for example) and then add Morphs with I would intend to be
> > containers for text, buttons etc.... so this strategy is to use
> > multiply nested Morphs with appropriate Layouts in order to arrange
> > the elements in the way I want them.
>
> That's one way to do it.
>
> > Is the how people do this in Morphic? If so, how would I deal with
> > dynamically sizing those element?
>
> By combinations of hResizing and vResizing settings (#spaceFill,
> #shrinkWrap, or #rigid).
>
> > I've see a couple of examples
> > using proportional layout, but when I start from scratch I can't
> > seem to lay things out as I wish, it seems that I am missing
> > something fundamental as to the logic.
>
> Proportional layout is also easy to do.
>
> Can you show us what you've tried to do?

Sure, here is some code....

        window _ PasteUpMorph newBounds: ((0 at 460) extent: (640 at 480)).
        window color: Color blue. 
        window layoutPolicy: TableLayout new.
        window listDirection: #leftToRight; wrapDirection: #topToBottom.
        leftFrame _ RectangleMorph newBounds: ((window bounds topLeft) extent: (320 at 480)).
        leftFrame layoutPolicy: TableLayout new.
        leftFrame listDirection: #leftToRight; wrapDirection: #topToBottom.             
	leftTop _ RectangleMorph newBounds: ((leftFrame bounds topLeft) 
                                                                extent: ((leftFrame width)@(leftFrame height//2))) color: Color green.  
        leftBottom _ RectangleMorph newBounds: ((leftTop bounds bottomLeft)
                                                                        extent: ((leftFrame width)@(leftFrame height//2))) color: Color red.
        leftFrame addMorphBack: leftTop.
        leftFrame addMorphBack: leftBottom.     
        window addMorphBack: leftFrame.

        window addMorphBack: (RectangleMorph new).

-----------------
This produces two colored boxes (topToBottom on the left) and one on the right. I would be putting 
various controls in the top and bottom boxes as well as in the right "frame". With this I have 
created a PasteUpMorph and 3 other RectangleMorphs just as containers... are there better ways
to do it, or is this fine? (this will do no dynamic resizing though... I assume I need ProportionalLayout 
for that)

thanks Ned,

Brian



More information about the Squeak-dev mailing list