No class LayoutManager but LayoutPolicy
Last updated at 11:25 am UTC on 24 April 2022
There is no class called 'LayoutManager' in Squeak. Layout management is done by assigning a LayoutPolicy to a Morph object.
Example:
A morph to which a
TableLayout new
object is assigned as layoutPolicy makes the submorphs to appear in a row if in addition the listDirection is set to 'leftToRight'.
row := Morph new.
row layoutPolicy: TableLayout new.
row listDirection: #leftToRight.
row hResizing: #shrinkWrap.
row vResizing: #shrinkWrap.
"The row morph object is now doing layout management of its submorphs"
width:= 100. height := 50.
row addMorphBack: (Morph new color: Color red; extent: width@height).
row addMorphBack: (Morph new color: Color green; extent: (width * 1.5)@height).
row addMorphBack: (Morph new color: Color blue; extent: (width * 2)@height).
row openInHand.
row extent 450@50
For an example which makes use of the code above repeatedly:
Multiplication table (TableLayout example)
More info about assigning LayoutPolicy objects: see LayoutPolicy.
tagBeginner