Labels

algorithms (22) Design Patterns (20) java (19) linux (14) Snippet (13) service mix (6) soa (4)

MORPHIC

Morphic is the name given to Pharo’s graphical interface.it does not have separate modes for “composing” and “running” the interface: all the graphical elements can be assembled and disassembled by the user, at any time.
You can create a morph to represent any object, although how good a representation you get depends
on the object!
To create a morph to represent a string object, execute the following code in aworkspace.

                              'Morph' asMorph openInWorld

This creates a Morph to represent the string 'Morph', and then opens it (that is, displays it) in the “world”, which is the name that Pharo gives to the screen. You should obtain a graphical element—a Morph—which you can manipulate by meta-clicking.




MANIPULATING MORPHS:
Morphs are objects, so we can manipulate them like any other object in
Smalltalk: by sending messages, we can change their properties, create new
subclasses of Morph
  • Every morph, even if it is not currently open on the screen, has a position
    and a size.
  • All morphs are considered to occupy a rectangular region of the screen; if they are irregularly shaped, their position and size are those of the smallest rectangular “box” that surrounds them, which is
    known as the morph’s bounding box, or just its “bounds”.
  • The position method returns a Point that describes the location of the morph’s upper left corner (or the upper left corner of its bounding box).
  • The origin of the coordinate system is the screen’s upper left corner, with y coordinates increasing down the screen and x coordinates increasing to the right.
  • The extent method also returns a point, but this point specifies the width and height of the morph
    rather than a location.
    "Type the following code into a workspace and do it :"
                  joe := Morph new color: Color blue.
                  joe openInWorld.
                  bill := Morph new color: Color red .
                  bill openInWorld.
    Then type joe position and print it . To move joe, execute joe position: (joe position +(10@3)) repeatedly.

No comments:

Post a Comment

Search 24 Bytes