Problems with aligning Morphs

Ned Konz ned at bike-nomad.com
Tue Sep 11 16:00:22 UTC 2001


On Monday 10 September 2001 10:15 pm, Tim Rowledge wrote:

> Attempting to make the
> label: [text field]
> bits has been impossible as well. Using an AlignmentMorph newRow seemed
> an obvious start, but that makes a morph that is very high and no matter
> what I tried I couldn't get the text field to be similar height to
> the label, nor to spread out (using #spaceFill) to fill the width of the
> parent.

a _ Morph new
	color: Color white;
	layoutPolicy: TableLayout new;
	listDirection: #leftToRight;
	cellPositioning: #leftCenter;
	hResizing: #spaceFill;
	vResizing: #shrinkWrap.
label _ StringMorph contents: 'label: '.
textField _ TextMorph new contents: 'text field'.
a addMorph: textField; addMorph: label.
a openInWorld.

Why the fondness for AlignmentMorphs? They're more or less obsolete, you 
know, since all the layout stuff got moved to Morph.

> |a b|
>
> a _ AlignmentMorph newRow.
> b _ AlignmentMorph newColumn.
> b addMorph: PluggableListMorph new.
> b addMorph: PluggableListMorph new.
> a addMorph: b.
> a openInWindowLabeled: 'foo'

Looks fine to me. I get two PluggableListMorphs, one above the other. Of 
course, the "a" morph isn't doing anything useful there.

> or how about:-
>
> |a b|
>
> a _ AlignmentMorph newRow.
> b _ AlignmentMorph newColumn.
> b addMorph: PluggableListMorph new.
> a addMorph: PluggableListMorph new.
> a addMorph: b.
> a openInWindowLabeled: 'foo'

Looks like what you'd expect. What did you think would happen?

> then what about:-
>
> |a b|
>
> a _ AlignmentMorph newRow.
> b _ AlignmentMorph newColumn.
> b addMorph: (PluggableListMorph new hResizing: #spaceFill; vResizing:
> #spaceFill).
> a addMorph: (PluggableListMorph new hResizing: #spaceFill; vResizing:
> #spaceFill).
> a addMorph: b.
> a openInWindowLabeled: 'foo'

Again, just what you'd expect, though you want to set the window to a 
particular size so that the spaceFill will have something to fill. If you 
stretch out the window, though, it looks fine.

> or even the simple:-
>
> |a |
>
> a _ AlignmentMorph newRow.
> a addMorph: PluggableListMorph new.
> a addMorph: PluggableListMorph new.
> a openInWindowLabeled: 'foo'
>
> Eek. I thought this was simple...

Ah. I see the problem with the flop-out scrollbars (which I don't use). Your 
best bet is to use the SystemWindow proportional pane support to hold 
pane-like things (specifically, anything with a scrollbar), rather than 
letting the Morph table layout handle them.

-- 
Ned Konz
currently: Stanwood, WA
email:     ned at bike-nomad.com
homepage:  http://bike-nomad.com




More information about the Squeak-dev mailing list