'From Squeak3.6alpha of ''17 March 2003'' [latest update: #5240] on 1 June 2003 at 3:51:13 pm'! "Change Set: MorphicClassComments-efc Date: 7 March 2003 Author: Eddie Cottongim Class Comments for Morph, ImageMorph, SimpleButtonMorph and StringMorph. These were subject to review and editing on the swiki, and thus should be fairly comprehensive."! !Morph commentStamp: 'efc 2/26/2003 20:01' prior: 0! A Morph (from the Greek "shape" or "form") is an interactive graphical object. General information on the Morphic system can be found at http://minnow.cc.gatech.edu/squeak/30. 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 My parent Morph, or nil for the top-level Morph, which is a or nil world, typically a PasteUpMorph. submorphs Array My child Morphs. fullBounds Rectangle A Rectangle minimally enclosing me and my submorphs. color Color My primary color. Subclasses can use this in different ways. extension MorphExtension Allows extra properties to be stored without adding a or nil 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 BorderStyle, most users should use BorderedMorph if they want borders.! ]style[(2 5 130 37 59 12 325 14 209 12 2 4 4 11 1 11 9 90 5 123 5 35 9 66 5 78 14 209 12 91 11 24 13 22)f1,f1LMorph Hierarchy;,f1,f1Rhttp://minnow.cc.gatech.edu/squeak/30;,f1,f1LPasteUpMorph Comment;,f1,f1LTransformMorph Comment;,f1,f1u,f1,f1u,f1,f1u,f1i,f1,f1LRectangle Comment;,f1,f1LMorph Comment;,f1,f1LArray Comment;,f1,f1LRectangle Comment;,f1,f1LColor Comment;,f1,f1LMorphExtension Comment;,f1,f1LLayoutPolicy Comment;,f1,f1LBorderStyle Comment;,f1,f1LBorderedMorph Comment;,f1! !ImageMorph commentStamp: 'efc 3/7/2003 17:48' prior: 0! ImageMorph is a morph that displays a picture (Form). My extent is determined by the extent of my form. Use #image: to set my picture. Structure: instance var Type Description image Form The Form to use when drawing Code examples: ImageMorph new openInWorld; grabFromScreen (Form fromFileNamed: 'myGraphicsFileName') asMorph openInWorld Relationship to SketchMorph: ImageMorph should be favored over SketchMorph, a parallel, legacy class -- see the Swiki FAQ for details ( http://minnow.cc.gatech.edu/squeak/1372 ). ! ]style[(10 37 4 97 33 11 5 47 42 3 62 18 11 109 39 5)f1LImageMorph Hierarchy;,f1,f1LForm Comment;,f1,f1i,f1,f1LForm Comment;,f1,f1dImageMorph new openInWorld; grabFromScreen;;,f1,f1d(Form fromFileNamed: 'myGraphicsFileName') asMorph openInWorld;;,f1,f1LSketchMorph Comment;,f1,f1Rhttp://minnow.cc.gatech.edu/squeak/1372;,f1! !SimpleButtonMorph commentStamp: 'efc 3/7/2003 17:46' prior: 0! I am labeled, rectangular morph which allows the user to click me. I can be configured to send my "target" the message "actionSelector" with "arguments" when I am clicked. I may have a label, implemented as a StringMorph. Example: SimpleButtonMorph new target: Smalltalk; label: 'Beep!!'; actionSelector: #beep; openInWorld Structure: instance var Type Description target Object The Object to notify upon a click actionSelector Symbol The message to send to Target (#messageName) arguments Array Arguments to send with #actionSelection (optional) actWhen Symbol When to take action: may be #buttonUp (default), #buttonDown, #whilePressed, or #startDrag oldColor Color Used to restore color after click Another example: a button which quits the image without saving it. SimpleButtonMorph new target: Smalltalk; label: 'quit'; actionSelector: #snapshot:andQuit:; arguments: (Array with: false with: true); openInWorld ! ]style[(209 11 13 101 13 31 12 6 54 6 61 5 65 6 114 5 107 158 2)f1,f1LStringMorph Comment;,f1,f1d SimpleButtonMorph new target: Smalltalk; label: 'Beep!!'; actionSelector: #beep; openInWorld;;,f1,f1i,f1,f1LObject Comment;,f1,f1LSymbol Comment;,f1,f1LArray Comment;,f1,f1LSymbol Comment;,f1,f1LColor Comment;,f1,f1d SimpleButtonMorph new target: Smalltalk; label: 'quit'; actionSelector: #snapshot:andQuit:; arguments: (Array with: false with: true); openInWorld;;,f1! !StringMorph commentStamp: 'efc 3/7/2003 17:34' prior: 0! StringMorph is a "lightweight" Morph to display a String. It supports only a single font, color, and emphasis combination. For multiple text styles, use TextMorph. Structure: instance var Type Description font StrikeFont (normally nil; then the accessor #font gives back TextStyle or nil defaultFont) emphasis SmallInteger bitmask determining character attributes (underline, bold, italics, narrow, struckout) contents String The text that will be displayed. hasFocus Boolean Do I have the keyboard focus or not? If you shift-click on a StringMorph you can edit its string. This is accomplished the following way: StringMorph can launch a StringMorphEditor if it receives a #mouseDown event. A StringMorph may also be used like a SimpleButtonMorph to do an action when clicked. Use the menu 'extras' / 'add mouseUpAction'. The following propery will be defined: aStringMorph valueOfProperty: #mouseUpCodeToRun! ]style[(11 20 5 14 6 97 9 14 47 9 10 53 9 40 12 108 6 49 7 168 17 75 17 163)f1LStringMorph Hierarchy;,f1,f1LMorph Comment;,f1,f1LString Comment;,f1,f1LTextMorph Comment;,f1,f1i,f1,f1LStrikeFont Comment;,f1,f1LTextStyle Comment;,f1,f1LSmallInteger Comment;,f1,f1LString Comment;,f1,f1LBoolean Comment;,f1,f1LStringMorphEditor Comment;,f1,f1LSimpleButtonMorph Comment;,f1!