Morphic class comment
Last updated at 8:03 am UTC on 8 November 2019
I thought it might be good to add a thorough class comment for Morph. Please make any changes you think will be helpful, and in a few days I'll post this as a changeset to the list. (efc)
This comment is not intended to be a full tutorial on the Morphic system, only to cover the essentials of class Morph and perhaps provide pointers to other important parts of the system.
The comment will have links to other class comments in most cases. Since it's such an important class, it should make full use of our hypertext abilities. I've had to mess with the formatting some to make it look ok on the swiki; I will adhere to the standard comment format when it goes back into Squeak.
This comment has now been harvested; feel free to make any additions, but please mark them [orange cause blue already taken for links] as such so we can tell the differences. If additions warrant, the comment can go out again.
A Morph (from the Greek "shape" or "form") is an interactive graphical object. General information on the Morphic system can be found at Morphic.
Morphs exist in a tree, rooted at a World (generally a PasteUpMorph). A morph becomes owner of another morph by #addMorph: method. Morphs are drawn recursively; if a Morph has no owner it never gets drawn. To hide a Morph and its submorphs, set its #visible property to false using the #visible: method.
The World (screen) coordinate system is used for most coordinates, but can be changed if there is a TransformMorph somewhere in the owner chain.
My instance variables have accessor methods (e.g., #bounds, #bounds:). Most users should use the accessor methods instead of using the instance variables directly.
- A Rectangle indicating my position and a size that will enclose me.
- Morph or nil
- My parent Morph, or nil for the top-level Morph, which is a world, typically a PasteUpMorph.
- A Rectangle minimally enclosing me and my submorphs.
- My primary color. Subclasses can use this in different ways.
- MorphExtension or nil
- Allows extra properties to be stored without adding a storage burden to all morphs.
By default, Morphs do not position their submorphs, see example . Morphs may position their submorphs directly or use a LayoutPolicy to automatically control their submorph positioning.
Although Morph has some support for BorderStyles, most users should use BorderedMorphs if they want borders.