How to lay out submorphs - example 1
Last updated at 6:18 pm UTC on 14 January 2006
m := RectangleMorph new.
m layoutPolicy: TableLayout new.
m listDirection: #leftToRight.
m hResizing: #shrinkWrap; vResizing: #shrinkWrap.
m layoutInset: 20; cellInset: 10.
4 timesRepeat:[ m addMorph: (RectangleMorph new color: (Color red)) ].
m openInWorld.
Eddie Cottongim
The same example enlarged a bit and modeled after the example on the page AlignmentMorph.
m := RectangleMorph new.
m layoutPolicy: TableLayout new.
m listDirection: #leftToRight. "If you omit this expression you get the default "
"m listDirection: #topToBottom."
m hResizing: #shrinkWrap.
m vResizing: #shrinkWrap.
m addMorph: (EllipseMorph new extent: 40@40; color: Color red).
m addMorph: (EllipseMorph new extent: 50@50; color: Color yellow).
m addMorph: (EllipseMorph new extent: 60@60; color: Color green).
m addMorph: (EllipseMorph new extent: 70@70; color: Color blue).
m openInWorld.
You can change anytime between:
m listDirection: #leftToRight.
and
m listDirection: #topToBottom.
Just evaluate the expressions with do-it.
You may as well change attributes:
m borderWidth: 0
m color: Color transparent.
m layoutInset: 20; cellInset: 10.
Hannes Hirzel, January 2005