| Graphics | Chapter 8 | Contents |
|---|
| Inside Macintosh |
QuickDraw Window Manager Toolbox Utilities |
Class Rect is the most widely used QuickDraw class, describing an extensive set of behaviors appropriate to basic rectangles. Rectangles are used for a variety of operations in the Toolbox, such as sizing windows, controls and dialogs, drawing rectangular frames, filling with a pattern, and clipping. Class GrafPort is the superclass of window, and describes the graphics structure that QuickDraw uses as its foundation for windowed behavior.
The Mops word Cursor serves as a defining word to associate names with cursor resource definitions. For instance:
1 cursor IBeamCurs
associates the name IBeamCurs with the cursor data whose resource ID in the system is 1. This happens to be the cursor used for editing text. After this declaration, you can change the current cursor to this image by simply executing the word IBeamCurs. Mops predefines four cursor images for you: IBeamCurs, crossCurs, plusCurs, and watchCurs.
Mops provides access to the system pattern list via the word sysPat. For instance, the phrase:
3 SysPat get: **
leaves a pointer to the system pattern with ID 3. This can be used to send a Fill: message to various graphics objects, or set the pattern for the current pen, for example.
| Point |
Point provides a building block for Rect. A Rect is composed of two Points, each consisting of two Ints, Y and X. Point's methods are useful in providing more advantageous access to a rectangle's data. QuickDraw stores Y before X in Rectangles, but Mops always represents Points on the stack as ( X Y -- ).
| Superclass | Object | |||||||
| Source file | QD | |||||||
| Status | Core | |||||||
| Instance variables |
| |||||||
| Indexed data | None | |||||||
| System objects | None |
Object
| accessing | ||
| get: | ( -- x y ) | Returns the values in Y and X |
|---|---|---|
| getX: | ( -- x ) | Returns the value in X |
| getY: | ( -- y ) | Returns the value in Y |
| int: | ( -- x:y ) | Returns a single longword with x and y packed into the high and low words, as was required for a number of Toolbox calls before SYSCALL |
| put: | ( x y -- ) | Stores new values in Y and X |
| putX: | ( x -- ) | Stores a new value in X |
| putY: | ( y -- ) | Stores a new value in Y. |
| Rect |
Rect is a widely used class that describes various properties of Rectangles.
| Superclass | Object | |||||||
| Source file | QD | |||||||
| Status | Core |
| ||||||
| Instance variables | ||||||||
| Indexed data | None | |||||||
| System objects |
| |||||||
Object
| accessing | ||
| get: | ( -- l t r b ) | Returns the values in the Rect's two Points in (X Y X Y) format. The first pair is the topLeft Point, and the pair on top of the stack is the bottomRight Point |
|---|---|---|
| getTop: | ( -- x y ) | |
| topInt: | ( -- x:y ) | Returns the point TopL with x and y packed into a longword |
| getTopX: | ( -- x ) | |
| getTopY: | ( -- y ) | |
| getBot: | ( -- x y ) | |
| botInt: | ( -- x:y ) | |
| getBotX: | ( -- x ) | |
| getBotY: | ( -- y ) | |
| put: | ( l t r b -- ) | Stores new coordinates in the Rectangle |
| putTop: | ( x y -- ) | |
| putTopX: | ( x -- ) | |
| putTopY: | ( y -- ) | |
| putBot: | ( x y -- ) | |
| putBotX: | ( x -- ) | |
| putBotY: | ( y -- ) | |
| size: | ( -- w h ) | Returns the size of the rectangle in pixels as width and height |
| setSize: | ( w h -- ) | Sets the width and height of the rectangle according to w and h, by setting the BotR point |
| getCenter: | ( -- x y ) | Returns the center point of the rectangle in the local coordinates of the current GrafPort |
| inset: | ( dx dy -- ) | Causes the rectangle to be grown or shrunk around the center point. The left and right sides are moved in by the amount specified by dx; the top and bottom are moved towards the center by the amount specified by dy. If dh or dv is negative, the appropriate pair of sides is moved outwards instead of inwards. Does not redraw the Rect. If either the width or height would become negative, the rectangle is reset to the empty rectangle (0 0 0 0) |
| shift: | ( dx dy -- ) | Moves the rectangle the given distance. Does not redraw the Rect |
| offset: | ( dx dy -- ) | A synonym for shift: |
| stretch: | ( dx dy -- ) | Shifts the BotR point by the given distance |
| ->: | ( ^rect -- ) | Copies the Rect whose address is passed in to this Rect. |
| drawing | ||
| draw: | ( -- ) | Draws the rectangle's frame |
| dropShadow: | ( -- ) | As for draw:, but adds a standard Mac drop shadow |
| disp: | ( l t r b -- ) | Combines the actions of put: and draw: |
| clear: | ( -- ) | Fills the rectangle's frame with the current GrafPort's background pattern and color |
| paint: | ( -- ) | Fills the rectangle's frame with the current GrafPort's foreground pattern and colour |
| fill: | ( pattern -- ) | Given a pointer to a QuickDraw Pattern, fills the Rect's frame with the Pattern. For example, 3 sysPat get: ** fill: myRect would fill the rectangle with the system pattern #3 |
| invert: | ( -- ) | Inverts the pixels bounded by the rectangle |
| clip: | ( -- ) | Clips all subsequent drawing to the area bounded by the rectangle |
| update: | ( -- ) | Causes an update event to occur for the current window that will redraw everything inside the rectangle |
| GrafPort |
This class maps the record structure for a GrafPort. A QuickDraw GrafPort defines a local drawing environ-ment with its own coordinate system and pen characteristics, and provides the basic functionality necessary for windowing. A Window record incorporates a GrafPort as the first part of its data. Note that although a basic (B&W) GrafPort and a (color) CGrafPort are the same length, the allocation of individual bytes to different functions is not identical; this is one reason why we do not assign names to each field in the GrafPort record.
| Superclass | Object | |||||||||||||||||||
| Source file | QD |
| ||||||||||||||||||
| Status | Core | |||||||||||||||||||
| Instance variables | ||||||||||||||||||||
| Indexed data | None | |||||||||||||||||||
| System objects | None |
Object
| accessing | ||
| getRect: | ( -- l t r b ) | Returns the coordinates of the GrafPort's PortRect |
|---|---|---|
| putRect: | ( l t r b -- ) | Sets the coordinates of the GrafPort's PortRect |
| drawing | ||
| set: | ( -- ) | Causes this to be the current GrafPort for subsequent drawing. |
| Previous Chapter | Contents | Next Chapter |
|---|---|---|
| ⇧ | ||
| This page online: http://PowerMops.com/MopsManual/Classes/Chapter8.html | ||