Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Layout of a simple table (cellInset)
Last updated at 3:50 am UTC on 26 July 2020
 | parent1Side cellSide cell |
 
  parent1Side := 320.
  cellSide := 50.
 
  parent1 := Morph new.
  parent1 width: parent1Side.
  parent1 height: parent1Side.
  parent1 color: Color white.
 
  parent1 layoutPolicy: TableLayout new.
  parent1 listDirection: #leftToRight.
  parent1 wrapCentering: #topLeft.
  parent1 wrapDirection: #topToBottom.
 
  parent1 layoutInset: 18@18.
  parent1 cellInset: 8@8.
  
  1 to: 25 do:  [:i |  cell := EllipseMorph new. 
                    cell height: cellSide. cell width: cellSide.
                    cell color: Color random twiceLighter twiceLighter twiceLighter. 
                    cell borderWidth: 0.
                    parent1 addMorphBack: cell
                  ].
 
  parent1 openInWorld.

TableLayout_simple.png


The code above (with background color slightly changed) executed in Squeak 5.3 produces the following result.
Morph_TableLayout_Demo_cellInset_in_Squeak5.png
This is because #cellInset: is has been changed (see release notes).


Using #cellGap: instead brings back:

Morph_TableLayout_Demo_with_cellInset.png


Adapted from MorphLayoutArticle, first exercise.
MorphLayoutArticle_a_simple_table.png