Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
How to lay out submorphs - example 0
Last updated at 12:16 am UTC on 31 July 2020
A RectangleMorph object is made a layout morph by assigning to it a LayoutPolicy, a TableLayout policy object.

 myLayoutMorph := RectangleMorph new.
 myLayoutMorph layoutPolicy: TableLayout new.
 
 "center submorphs"
 myLayoutMorph listCentering: #center.
 myLayoutMorph wrapCentering: #center.
 
 myLayoutMorph width: 320.
 myLayoutMorph height: 240.
 myLayoutMorph color: Color white darker.

 m := RectangleMorph new color: (Color red).
 m width: (myLayoutMorph width - 40).
 m height: (myLayoutMorph height - 40).

 myLayoutMorph addMorph: m.
 myLayoutMorph openInWorld.
Rectangle_Morph_with_a_TableLayout_policy_and_centered_submorph.png


 myLayoutMorph := RectangleMorph new.
 myLayoutMorph layoutPolicy: TableLayout new.
 myLayoutMorph color: Color gray.
 
 myLayoutMorph listDirection: #leftToRight.
 myLayoutMorph hResizing: #shrinkWrap; vResizing: #shrinkWrap.
 myLayoutMorph layoutInset: 20.
 
 m:= RectangleMorph new color: (Color green darker).
 m width: 300.
 m height: 200.
 
 myLayoutMorph addMorph: m.
 myLayoutMorph openInHand
Rectangle_Morph_with_a_TableLayout_policy_and_centered_submorph_shrinkWrap.png