| Framework | Carbon/Carbon.h |
| Declared in | HIShape.h |
HIShape is an abstract shape object that replaces the old QuickDraw region handle. HIShape objects are the preferred way to describe regions in HIView views that use Quartz.
One advantage of HIShape objects is that they can be mutable or immutable. Using immutable (that is, fixed) shapes improves performance because copying it simply requires incrementing the reference count, avoiding the handle-to-handle copies required with the older region handles.
Currently, HIShape objects cannot handle floating pointâÂÂbased shape descriptions. Therefore, any coordinates you specify when defining shapes must end on integer boundaries. The purpose of the shape often dictates whether rounding fractional values up or down will give you the best results. For example, shapes that describe a maximum alllowable area, such as the structure region of a window, should be rounded up (or outward) to the nearest integer. Shapes describing a minimum allowable area, such as the opaque region, should be rounded down (or inward). By default, any fractional coordinate values are truncated.
Typical shapes are rectangular, but you can build more complex shapes by combining them with other shapes using the union, intersection, or difference functions. The Quartz-savvy HITheme APIs also let you obtain shapes for various standard control elements.
In most cases, applications will obtain or set shapes in response to a Carbon event using GetEventParameter or SetEventParameter with the typeHIShapeRef parameter type.
The following functions also take HIShape references as parameters:
HIViewNewTrackingArea and HIViewChangeTrackingArea, which let you set or change an HIShape-based tracking area in a view (comparable to window tracking regions).
HIViewSetNeedsDisplayInShape, which is the HIShape-compatible version of HIViewSetNeedsDisplayInRegion.
Except where noted, HIShape functions return only the result codes noErr or paramErr.
HIShape objects are available in Mac OS X version 10.2 and later. However, many of the functions that take HIShape parameters are available only in Mac OS X version 10.4 and later.
HIShapeCreateWithQDRgn
HIShapeCreateWithRect
HIShapeCreateEmpty
HIShapeCreateCopy
HIShapeCreateIntersection
HIShapeCreateDifference
HIShapeCreateUnion
HIShapeCreateMutable
HIShapeCreateMutableCopy
HIShapeSetEmpty
HIShapeIntersect
HIShapeDifference
HIShapeUnion
HIShapeOffset
HIShapeGetTypeID
HIShapeGetBounds
HIShapeIntersectsRect
HIShapeGetAsQDRgn
HIShapeReplacePathInCGContext
HIShapeSetQDClip
Determines whether a shape contains the given point.
Boolean HIShapeContainsPoint ( HIShapeRef inShape, const CGPoint *inPoint );
The shape to test.
The point to test.
True if
the shape contains the point, False otherwise.
This function is comparable to the old QuickDraw function PtInRgn.
HIShape.hCreates an immutable copy of a mutable or immutable shape.
HIShapeRef HIShapeCreateCopy ( HIShapeRef inShape );
The shape you want to copy.
The newly-created copy.
Copying an immutable shape simply increments its reference count. Copying a mutable shape actually duplicates it in memory.
HIShape.hCreates an immutable shape that is the difference of two shapes.
HIShapeRef HIShapeCreateDifference ( HIShapeRef inShape1, HIShapeRef inShape2 );
The first shape.
The shape to subtract from the first shape.
The newly-created difference shape.
HIShape.hCreates an empty immutable shape.
HIShapeRef HIShapeCreateEmpty ( void );
The newly-created empty shape.
HIShape.hCreates an immutable shape that is the intersection of two shapes.
HIShapeRef HIShapeCreateIntersection ( HIShapeRef inShape1, HIShapeRef inShape2 );
An existing shape.
Another existing shape.
The newly-created intersection shape.
If the two shapes do not intersect, the shape returned is empty.
HIShape.hCreates an empty mutable shape.
HIMutableShapeRef HIShapeCreateMutable ( void );
An empty, mutable shape.
HIShape.hCreates a mutable copy of an existing shape.
HIMutableShapeRef HIShapeCreateMutableCopy ( HIShapeRef inOrig );
The shape to copy.
The newly-created copy.
HIShape.hCreates an immutable shape that is the union of two shapes.
HIShapeRef HIShapeCreateUnion ( HIShapeRef inShape1, HIShapeRef inShape2 );
An existing shape.
Another existing shape.
The newly-created union shape.
HIShape.hCreates an immutable shape from a QuickDraw region.
HIShapeRef HIShapeCreateWithQDRgn ( RgnHandle inRgn );
The region to convert to an immutable shape.
The newly created shape.
You can use this function to convert handle-based regions to HIShape objects. However, you should be judicious about how often you convert, as this function does require memory allocation.
HIShape.hCreates an immutable shape from a Quartz rectangle.
HIShapeRef HIShapeCreateWithRect ( const CGRect *inRect );
The Quartz-based rectangle to convert.
The newly-created shape.
This function is comparable to the old QuickDraw function RectRgn.
HIShape.hSets a shape to be the difference of two other shapes.
OSStatus HIShapeDifference ( HIShapeRef inShape1, HIShapeRef inShape2, HIMutableShapeRef outResult );
The first shape.
The shape to subtract from the first.
The shape to hold the difference of the two shapes. This parameter can be one of the source shapes.
A result code.
This function is comparable to the old QuickDraw function DiffRgn.
HIShape.hCreates a QuickDraw region with the same shape as the
specified HIShape.
OSStatus HIShapeGetAsQDRgn ( HIShapeRef inShape, RgnHandle outRgn );
The shape to convert.
A valid region handle. You must obtain this
handle by calling NewRgn before calling
this function.
A result code.
You can use this function to create a handle-based region from an HIShape object. This conversion requires memory allocation, so you should convert only when necessary.
HIShape.hObtains the bounding rectangle for the given shape.
CGRect * HIShapeGetBounds ( HIShapeRef inShape, CGRect *outRect );
The shape whose bounds you want to obtain.
A pointer to the HIRect structure
you want filled with the shape bounds.
A pointer to the rectangle
you passed in the inRect parameter,
now set to the shape’s bounding rectangle.
The function result is a pointer to the HIRect structure
you passed in the inRect parameter.
HIShape.hObtains the Core Foundation type ID for the HIShape class.
CFTypeID HIShapeGetTypeID ( void );
The type ID for the HIShape class.
HIShape.hSets a shape to be the intersection of two other shapes.
OSStatus HIShapeIntersect ( HIShapeRef inShape1, HIShapeRef inShape2, HIMutableShapeRef outResult );
The first shape.
The second shape.
The shape to hold the intersection of the two shapes. This parameter can be one of the source shapes.
A result code.
This function is comparable to the old QuickDraw function SectRgn.
HIShape.hDetermines whether a given shape intersects a given rectangle.
Boolean HIShapeIntersectsRect ( HIShapeRef inShape, const CGRect *inRect );
The shape to test.
The rectangle to test against.
Returns True if
the area of the shape intersects the rectangle, False otherwise.
HIShape.hDetermines whether a given shape is empty.
Boolean HIShapeIsEmpty ( HIShapeRef inShape );
The shape to test.
True if
the shape’s area is empty, False otherwise.
This function is comparable to the old QuickDraw function EmptyRgn.
HIShape.hDetermines whether a given shape is rectangular.
Boolean HIShapeIsRectangular ( HIShapeRef inShape );
The shape to test.
True if
the shape’s area is rectangular, False otherwise.
HIShape.hMoves a shape by a specified offset.
OSStatus HIShapeOffset ( HIMutableShapeRef inShape, CGFloat inDX, CGFloat inDY );
The shape to offset.
The desired x-coordinate offset.
The desired y-coordinate offset.
A result code.
This function is comparable to the old QuickDraw function OffsetRgn.
HIShape.hMake the current path in a graphics context match a shape.
OSStatus HIShapeReplacePathInCGContext ( HIShapeRef inShape, CGContextRef inContext );
The shape to apply to the path.
The context to apply the shape to.
A result code.
HIShape.hSets the specified mutable shape to be empty.
OSStatus HIShapeSetEmpty ( HIMutableShapeRef inShape );
The shape to empty.
A result code.
This function is comparable to the old QuickDraw function SetEmptyRgn.
HIShape.hSets the clip region in the current QuickDraw port to be the specified shape.
OSStatus HIShapeSetQDClip ( HIShapeRef inShape, CGrafPtr inPort );
The shape to apply to the clip region.
The clip region to apply the shape to.
A result code. If HIShapeSetQDClip cannot
allocate a QuickDraw region, it returns memFullErr.
HIShape.hSets a shape to be the union of two other shapes.
OSStatus HIShapeUnion ( HIShapeRef inShape1, HIShapeRef inShape2, HIMutableShapeRef outResult );
An existing shape.
Another existing shape.
The shape to hold the union of the two shapes. This parameter can be one of the source shapes.
A result code.
This function is comparable to the old QuickDraw function UnionRgn.
HIShape.hDefines a shape object.
typedef const struct __HIShape *HIShapeRef;
The structure pointed to by this reference is opaque.
HIShape.h
Defines a mutable shape object.
typedef struct __HIShape *HIMutableShapeRef;
The structure pointed to by this reference is opaque.
HIShape.h
© 2004 Apple Computer, Inc. All Rights Reserved. (Last updated: 2004-06-28)