Previous Page Table of Contents Index Next Page

Palm OS SDK Reference


Palm Logo 41 Rectangles

This chapter provides reference material for the rectangles API, declared in the header file Rect.h.

Rectangle Functions




RctCopyRectangle

Purpose

Copy the source rectangle to the destination rectangle.

Prototype

void RctCopyRectangle (const RectangleType* srcRectP, RectangleType* dstRectP)

Parameters

  srcRectP
A pointer to the rectangle to be copied.
  dstRectP
A pointer to the destination rectangle.

See Also

RctSetRectangle



RctGetIntersection

Purpose

Determine the intersection of two rectangles.

Prototype

void RctGetIntersection (const RectangleType* r1P, const RectangleType* r2P, RectangleType* r3P)

Parameters

  r1P
A pointer to a source rectangle.
  r2P
A pointer to the other source rectangle.
  r3P
Upon return, points to a rectangle representing the intersection of r1 and r2.

Comments

The rectangle type RectangleType, which is pointed to by RectanglePtr, stores the coordinates for the top-left corner of the rectangle plus the rectangle's width and height. This function returns in the r3 parameter a pointer to the rectangle that represents the intersection of the first two rectangles.

If rectangles r1 and r2 do not intersect, r3 contains a rectangle that begins at coordinates (0, 0) and has 0 width and 0 height.



RctInsetRectangle

Purpose

Move all of the boundaries of a rectangle by a specified offset.

Prototype

void RctInsetRectangle (RectangleType* rP, Coord insetAmt)

Parameters

  rP
A pointer to the rectangle.
  insetAmt
Number of pixels to move the boundaries. This can be a negative number.

Comments

The rectangle type RectangleType, which is pointed to by RectanglePtr, stores the coordinates for the top-left corner of the rectangle plus the rectangle's width and height. This function adds insetAmt to the x and y values of the top-left coordinate and then adjusts the width and the height accordingly so that all of the sides of the rectangle are contracted or expanded by the same amount.

A positive insetAmt creates a smaller rectangle that is contained inside the old rectangle's boundaries. A negative insetAmt creates a larger rectangle that surrounds the old rectangle.

See Also

RctOffsetRectangle



RctOffsetRectangle

Purpose

Move the top and left boundaries of a rectangle by the specified values.

Prototype

void RctOffsetRectangle (RectangleType* rP, Coord deltaX, Coord deltaY)

Parameters

  rP
A pointer to the rectangle.
  deltaX
Number of pixels to move the left boundary. This can be a negative number.
  deltaY
Number of pixels to move the top boundary. This can be a negative number.

Comments

The rectangle type RectangleType, which is pointed to by RectanglePtr, stores the coordinates for the top-left corner of the rectangle plus the rectangle's width and height. This function adds deltaX to the x value of the top-left coordinate and deltaY to the y value. The width and height are unchanged. Thus, this function shifts the position of the rectangle by the deltaX and deltaY amounts.

See Also

RctInsetRectangle



RctPtInRectangle

Purpose

Determine if a point lies within a rectangle's boundaries.

Prototype

Boolean RctPtInRectangle (Coord x, Coord y, const RectangleType* rP)

Parameters

  x
The x coordinate of the point.
  y
The y coordinate of the point.
  rP
The rectangle.

Result

Returns true if the point (x, y) lies within the boundaries of rectangle r, false otherwise.



RctSetRectangle

Purpose

Sets a rectangle's values.

Prototype

void RctSetRectangle (RectangleType* rP, Coord left, Coord top, Coord width, Coord height)

Parameters

  rP
A pointer to the rectangle to be set.
  left
The x value for the top-left coordinate of the rectangle.
  top
The y value for the top-left coordinate of the rectangle.
  width
The rectangle's width.
  height
The rectangle's height.

See Also

RctCopyRectangle



Palm OS SDK Reference

  Previous Page Table of Contents Index Next Page  

This is page 43 of 85 in this book

Palm Computing Platform Development Zone
Copyright © 2000, Palm, Inc. All rights reserved.