Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
LayoutPolicy
Last updated at 12:04 am UTC on 1 August 2020
Objects of class LayoutPolicy are used to control how the submorphs of a Morph are laid out.

The default for a morph is not to have a LayoutPolicy object.

 m := Morph new.
 m layoutPolicy 
 nil

The same applies for the LayoutProperties object:
 m layoutProperties 
 nil

That means the Morph does not do any layout of its submorphs at all. The following illustrates this effect:

 redMorph := Morph new color: Color red.
 slide := Morph new color: Color white darker; width: 300; height: 200; position: 50@20.
 slide addMorph: redMorph.  
 slide openInWorld. 

Morph_with_no_LayoutPolicy.png

 redMorph := Morph new color: Color red.
 slide := Morph new color: Color white darker; 
             width: 300; height: 200; position: 50@20.
 "set a default TableLayout object"
 slide layoutPolicy: TableLayout new.
 slide addMorph: redMorph.  
 slide openInWorld.
Morph_with_default_TableLayout_object.png
For a more elaborate example showing this see point 2 of: Example - aMorph addMorph: anotherMorph (no layout and TableLayout)

There are two subclasses of LayoutPolicy.

For examples how these subclasses are used see: How to lay out submorphs

If you would like to write your own subclass of LayoutPolicy, you may be interested in LayoutPolicy.

Also useful is to subclass TableLayout and TableLayoutProperties, e.g. TableLayout1 and TableLayoutProperties1 and configure them for a specialized case.