Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Imaging With QuickDraw /
Chapter 2 - Basic QuickDraw / Basic QuickDraw Reference
Routines / Managing Bitmaps, Port Rectangles, and Clipping Regions


SetOrigin

To change the coordinates of the window origin of the port rectangle of the current graphics port (basic or color), use the SetOrigin procedure.

PROCEDURE SetOrigin (h,v: Integer);
h
The horizontal coordinate of the upper-left corner of the port rectangle.
v
The vertical coordinate of the upper-left corner of the port rectangle.
DESCRIPTION
The SetOrigin procedure changes the coordinates of the upper-left corner of the current graphics port's port rectangle to the values supplied by the h and v parameters. All other points in the current graphics port's local coordinate system are calculated from this point. All subsequent drawing and calculation routines use the new coordinate system.

The SetOrigin procedure does not affect the screen; it does, however, affect where subsequent drawing inside the graphics port appears. The SetOrigin procedure does not offset the coordinates of the clipping region or the graphics pen, which therefore change position on the screen (unlike the boundary rectangle, port rectangle, and visible region, which don't change position onscreen).

Because SetOrigin does not move the window's clipping region, use the GetClip procedure to store your clipping region immediately after your first call to SetOrigin--if you use clipping regions in your windows. Before calling your own window-drawing routine, use the ClipRect procedure to define a new clipping region--to avoid drawing over your scroll bars, for example. After calling your own window-drawing routine, use the SetClip procedure to restore the original clipping region. You can then call SetOrigin again to restore the window origin to a horizontal coordinate of 0 and a vertical coordinate of 0 with your original clipping region intact.

All other routines in the Macintosh Toolbox and Operating System preserve the local coordinate system of the current graphics port. The SetOrigin procedure is useful for readjusting the coordinate system after a scrolling operation.

Note
The Window Manager and Control Manager always assume the window's upper-left point has a horizontal coordinate of 0 and a vertical coordinate of 0 when they draw in a window. Therefore, if you use SetOrigin to change the window origin, be sure to use SetOrigin again to return the window origin to a horizontal coordinate of 0 and a vertical coordinate of 0 before using any Window Manager or Control Manager routines.
SEE ALSO
"Scrolling the Pixels in the Port Rectangle" beginning on page 2-18 provides a general discussion of the use of SetOrigin, and Listing 2-5 on page 2-19 illustrates how to use SetOrigin when scrolling through a document in a window.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996