Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
AlignmentMorph
Last updated at 12:35 pm UTC on 28 December 2004
The mechanism for arranging submorphs has changed in Squeak 3.x. Every Morph has now the capability to layout its submorphs (for details see class category 'Morphic-Layout' in the image), so you will generally not need to use AlignmentMorph anymore. (Although it isn't quite deprecated.)

Bob's SuperSwiki contains a project 'TableLayouts' which includes a good documentation how layouts are done. Classes TableLayout and ProportionalLayout are subclasses of the abstract class LayoutPolicy.
The class AlignmentMorph uses the TableLayout policy.

The AlignmentMorph class is still in place.

March 2001 / Hannes Hirzel

Andreas Raab pointed out earlier that AlignmentMorph can indeed still be used for the simple reason that it is a bit more explicit in intention, but it isn't necessary to use anymore though since any Morph can do what it can. (from the Squeak Mailing Lists, September 2002)

Sep - 2003
The following links to Yahoo groups are longer valid.
It appears that Yahoo groups are only archived for three months.
If anyone has a copy of these dicussions please put them on the
swiki so they can be integrated into the Morphic documentation.

The original announcement of these changes is in http://groups.yahoo.com/group/squeak/message/21981

A useful discussion of converting to the new alignment can be found in the mail thread http://groups.yahoo.com/group/squeak/message/27785

Jan 2002 - Jeff Sparkes

Another useful discussion of when to use a parent morph to align submorphs: http://groups.yahoo.com/group/squeak/message/46601

And here is: How to lay out submorphs.

Old AlignmentMorph Examples


They are still working and probably will be for a long time; there are even two AlignmentMorphs in the new ObjectTool.

  1. Two examples with direct manipulation from Torsten Bergmann:
    http://www.phaidros.com/DIGITALIS/englisch/sqk/sqk00053.htm


  2. Similar examples done with Smalltalk code:


    AlignmentMorph newRow
    addMorph: (EllipseMorph new extent: 40@40; color: Color red);
    addMorph: (EllipseMorph new extent: 50@50; color: Color yellow);
    addMorph: (EllipseMorph new extent: 60@60; color: Color green);
    addMorph: (EllipseMorph new extent: 70@70; color: Color blue);
    position: 20@20;
    openInWorld

    Try also newColumn instead of newRow.
    Try using addMorphBack: instead of addMorph.


  3. StringMorph test openInWorld
    StringMorph test2 openInWorld

  4. PluggableButtonMorph example openInWorld


  5. Add the following two methods to the class side of AlignmentMorph:

    createClassNameMorph: aClass

    | d |
    d := AlignmentMorph newRow.
    d centering: #center.
    d color: Color yellow.
    d borderColor: Color blue.
    d vResizing: #shrinkWrap.
    d hResizing: #shrinkWrap.
    d addMorph: (StringMorph contents: aClass name).
    d openToDragNDrop: true.
    ^d
    

    createClassHierarchyMorph: aClass | col d subCls | d := self createClassNameMorph: aClass. (subCls := aClass subclasses) isNil ifTrue: [^d] . col := AlignmentMorph newColumn. subCls do: [ :aSubclass | col addMorph: (self createClassHierarchyMorph: aSubclass)]. d addMorphBack: col. ^d


    And evaluate:
    (AlignmentMorph createClassHierarchyMorph: AlignmentMorph) openInWorld.

    Or

    (AlignmentMorph createClassHierarchyMorph: BorderedMorph) openInWorld

  6. Squeak contains a nice game which may serve as an example of using AlignmentMorphs. See SameGame initialize and SameGame makeControls