Important: The information in this document is obsolete and should not be used for new development.
OpenRgn
To begin defining a region, use theOpenRgnprocedure.
PROCEDURE OpenRgn;DESCRIPTION
TheOpenRgnprocedure allocates temporary memory to start saving lines and framed shapes for processing as a region definition. CallOpenRgnonly after initializing a region with theNewRgnfunction.The
NewRgnfunction stores the definition for a region in aRegionrecord.While a region is open, all calls to
Line,LineTo, and the procedures that draw framed shapes (except arcs) affect the outline of the region. Only the line endpoints and shape boundaries affect the region definition--the pattern mode, pattern, and size do not affect it.When you are finished defining the region, call the
CloseRgnprocedure.The
OpenRgnprocedure callsHidePen, so no drawing occurs on the screen while the region is open (unless you callShowPenjust afterOpenRgn, or you calledShowPenpreviously without balancing it by a call toHidePen). Since the pen hangs below and
to the right of the pen location, drawing lines with even the smallest pen changes pixels that lie outside the region you define.The outline of a region is mathematically defined and infinitely thin, and it separates the bit or pixel image into two groups of pixels: those within the region and those outside it.
A region should consist of one or more closed loops. Each framed shape itself constitutes a loop. Any lines drawn with the
LineorLineToprocedure should connect with each other or with a framed shape. Even if the onscreen presentation of a region is clipped, the definition of a region is not; you can define a region anywhere on the coordinate plane with complete disregard for the location of various graphics port entities on that plane.When a region is open, the current graphics port's
rgnSavefield contains a handle to information related to the region definition. If you want to temporarily disable the collection of lines and shapes, you can save the current value of this field, set the field toNIL, and later restore the saved value to resume the region definition. Also, callingSetPortwhile a region is being formed discontinues formation of the region until another call toSetPortresets the region's original graphics port.SPECIAL CONSIDERATIONS
Regions are limited to 32 KB in size in basic QuickDraw and 64 KB in Color QuickDraw. You can determine the current size of an existing region by calling the Memory Manager functionGetHandleSize(described in Inside Macintosh: Memory). When you record drawing operations in an open region, the resulting region description may overflow the 32 KB or 64 KB limit. Should this happen in Color QuickDraw, theQDErrorfunction (described in the chapter "Color QuickDraw" in this book) returns the result coderegionTooBigError.Do not call
OpenRgnwhile another region or a polygon is already open. When you are finished constructing the region, use theCloseRgnprocedure, which is described next.The
OpenRgnprocedure may move or purge memory blocks in the application heap. Your application should not call this procedure at interrupt time.SEE ALSO
Listing 3-8 on page 3-24 illustrates how to use this procedure. TheRegionrecord is described in the chapter "Basic QuickDraw."