Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
The AlignmentMorph may be replaced by any Morph class
Last updated at 10:05 am UTC on 29 July 2020
The AlignmentMorph class has been reduced to only 13 instance methods in 2000. It it kept in the image for compatibility reasons.
However in a recent Squeak image many morph classes are still based on the AlignmentMorph

The functionality is now available directly inside each Morph and thus it is no longer necessary to subclass AlignmentMorph for your own Morph class in order to have the layout capability on that morph.

Any morph type can do alignment (or more generally 'Layout') if it has been given a LayoutPolicy.

AlingmentMorph the two construction methods: construction of a newColumn and of a newRow.


You may copy the content the newRow method of AlignmentMorph
 newRow

	^ self new
		listDirection: #leftToRight;
		hResizing: #spaceFill;
		vResizing: #spaceFill;
		extent: 1@1;
		borderWidth: 0

to your own subclass of Morph 'MyLayoutMorph' and combine it with some code from AlignmentMorph>>basicInitialize

 newRow

	^ self new layoutPolicy: TableLayout new;
		listDirection: #leftToRight;
		wrapCentering: #topLeft;
		hResizing: #spaceFill;
		vResizing: #spaceFill;
		layoutInset: 2;
		extent: 1@1;
		borderWidth: 0

So
 MyLayoutMorph newRow

gives you a morph configured to do a row layout.

 newColumn

	^ self new layoutPolicy: TableLayout new;
		listDirection: #topToBottom;
		hResizing: #spaceFill;
		vResizing: #spaceFill;
		extent: 1@1;
		layoutInset: 2;
		borderWidth: 0

More see: How to lay out submorphs.