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 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). The morphs owned by a morph are its submorphs. 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.
Structure:
instance var
Type
Description
bounds
Rectangle
A Rectangle indicating my position and a size that will enclose me.
owner
Morph or nil
My parent Morph, or nil for the top-level Morph, which is a world, typically a PasteUpMorph.
submorphs
Array
My child Morphs.
fullBounds
Rectangle
A Rectangle minimally enclosing me and my submorphs.
My primary color. Subclasses can use this in different ways.
extension
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. 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.