MiniGUI API Reference (MiniGUI-Threads)  v3.2.0
A mature and proven cross-platform GUI system for embedded and smart IoT devices
Macros | Functions
Rectangle operations

Macros

#define RECTWP(prc)   ((prc)->right - (prc)->left)
 Gets the width of a RECT object by using the pointer to it. More...
 
#define RECTHP(prc)   ((prc)->bottom - (prc)->top)
 Gets the height of a RECT object by using the pointer to it. More...
 
#define RECTW(rc)   ((rc).right - (rc).left)
 Gets the width of a RECT object. More...
 
#define RECTH(rc)   ((rc).bottom - (rc).top)
 Gets the height of a RECT object. More...
 

Functions

static void SetRect (RECT *prc, int left, int top, int right, int bottom)
 Sets a rectangle. More...
 
static void SetRectEmpty (RECT *prc)
 Empties a rectangle. More...
 
static void CopyRect (RECT *pdrc, const RECT *psrc)
 Copies one rectangle to another. More...
 
static void OffsetRect (RECT *prc, int x, int y)
 Moves a rectangle by offsets. More...
 
static void InflateRect (RECT *prc, int cx, int cy)
 Increases or decreases the width and height of an rectangle. More...
 
static void InflateRectToPt (RECT *prc, int x, int y)
 Inflates a rectangle to contain a point. More...
 
static BOOL PtInRect (const RECT *prc, int x, int y)
 Determines whether a point lies within an rectangle. More...
 
MG_EXPORT BOOL GUIAPI IsRectEmpty (const RECT *prc)
 Determines whether an rectangle is empty. More...
 
MG_EXPORT BOOL GUIAPI EqualRect (const RECT *prc1, const RECT *prc2)
 Determines whether two rectangles are equal. More...
 
MG_EXPORT void GUIAPI NormalizeRect (RECT *pRect)
 Normalizes a rectangle. More...
 
MG_EXPORT BOOL GUIAPI IntersectRect (RECT *pdrc, const RECT *psrc1, const RECT *psrc2)
 Calculates the intersection of two rectangles. More...
 
MG_EXPORT BOOL GUIAPI IsCovered (const RECT *prc1, const RECT *prc2)
 Determines whether one rectangle is covered by another. More...
 
MG_EXPORT BOOL GUIAPI DoesIntersect (const RECT *psrc1, const RECT *psrc2)
 Determines whether two rectangles intersect. More...
 
MG_EXPORT BOOL GUIAPI UnionRect (RECT *pdrc, const RECT *psrc1, const RECT *psrc2)
 Unions two source rectangles. More...
 
MG_EXPORT void GUIAPI GetBoundRect (PRECT pdrc, const RECT *psrc1, const RECT *psrc2)
 Gets the bound rectangle of two source rectangles. More...
 
MG_EXPORT int GUIAPI SubtractRect (RECT *rc, const RECT *psrc1, const RECT *psrc2)
 Obtains the rectangles when substracting one rectangle from another. More...
 

Detailed Description

Macro Definition Documentation

#define RECTH (   rc)    ((rc).bottom - (rc).top)

Gets the height of a RECT object.

Definition at line 5424 of file gdi.h.

#define RECTHP (   prc)    ((prc)->bottom - (prc)->top)

Gets the height of a RECT object by using the pointer to it.

Definition at line 5414 of file gdi.h.

#define RECTW (   rc)    ((rc).right - (rc).left)

Gets the width of a RECT object.

Definition at line 5419 of file gdi.h.

#define RECTWP (   prc)    ((prc)->right - (prc)->left)

Gets the width of a RECT object by using the pointer to it.

Definition at line 5409 of file gdi.h.

Function Documentation

void CopyRect ( RECT pdrc,
const RECT psrc 
)
inlinestatic

Copies one rectangle to another.

This function copies the coordinates of the source rectangle pointed to by psrc to the destination rectangle pointed to by pdrc.

Parameters
pdrcThe pointer to the destination rectangle.
psrcThe pointer to the source rectangle.
See also
SetRect

Definition at line 5164 of file gdi.h.

BOOL GUIAPI DoesIntersect ( const RECT psrc1,
const RECT psrc2 
)

Determines whether two rectangles intersect.

This function determines whether two rectangles (psrc1 and psrc2) intersect.

Parameters
psrc1The first source rectangles.
psrc2The second source rectangles.
Returns
TRUE if the source rectangles intersect, otherwise FALSE.
See also
IntersectRect

Referenced by PtInRect().

BOOL GUIAPI EqualRect ( const RECT prc1,
const RECT prc2 
)

Determines whether two rectangles are equal.

This function determines whether the two specified rectangles (prc1 and prc2) are equal by comparing the coordinates of the upper-left and lower-right corners.

Parameters
prc1The pointers to the first rectangles.
prc2The pointers to the second rectangles.
Returns
TRUE for equal, otherwise FALSE.

Referenced by PtInRect().

void GUIAPI GetBoundRect ( PRECT  pdrc,
const RECT psrc1,
const RECT psrc2 
)

Gets the bound rectangle of two source rectangles.

This function creates the bound rect (pdrc) of two rectangles (psrc1 and prsrc2). The bound rect is the smallest rectangle that contains both source rectangles.

Parameters
pdrcThe destination rectangle.
psrc1The first source rectangle.
psrc2The second source rectangle.
See also
UnionRect

Referenced by PtInRect().

void InflateRect ( RECT prc,
int  cx,
int  cy 
)
inlinestatic

Increases or decreases the width and height of an rectangle.

This function increases or decreases the width and height of the specified rectangle prc. This function adds cx units to the left and right ends of the rectangle and cy units to the top and bottom. the cx and cy are signed values; positive values increases the width and height, and negative values decreases them.

Parameters
prcThe pointer to the rectangle.
cxThe inflating x value.
cyThe inflating y value.
See also
InflateRectToPt

Definition at line 5206 of file gdi.h.

void InflateRectToPt ( RECT prc,
int  x,
int  y 
)
inlinestatic

Inflates a rectangle to contain a point.

This function inflates the rectangle prc to contain the specified point (x,y).

Parameters
prcThe pointer to the rectangle.
xx,y: The point.
yx,y: The point.
See also
InflateRect

Definition at line 5225 of file gdi.h.

BOOL GUIAPI IntersectRect ( RECT pdrc,
const RECT psrc1,
const RECT psrc2 
)

Calculates the intersection of two rectangles.

This function calculates the intersection of two source rectangles (psrc1 and psrc2) and places the coordinates of the intersection rectangle into the destination rectangle pointed to by pdrc. If the source rectangles do not intersect, and empty rectangle (in which all coordinates are set to zero) is placed into the destination rectangle.

Parameters
pdrcThe pointer to the destination rectangle.
psrc1The first source rectangles.
psrc2The second source rectangles.
Returns
TRUE if the source rectangles intersect, otherwise FALSE.
See also
DoesIntersect, IsCovered

Referenced by PtInRect().

BOOL GUIAPI IsCovered ( const RECT prc1,
const RECT prc2 
)

Determines whether one rectangle is covered by another.

This function determines whether one rectangle (prc1) is covered by another rectangle (prc2).

Parameters
prc1The first rectangles.
prc2The second rectangles.
Returns
TRUE if the first rectangle is covered by the second, otherwise FALSE.
See also
DoesIntersect

Referenced by PtInRect().

BOOL GUIAPI IsRectEmpty ( const RECT prc)

Determines whether an rectangle is empty.

This function determines whether the specified rectangle prc is empty. An empty rectangle is one that has no area; that is, the coordinates of the right side is equal to the coordinate of the left side, or the coordinates of the bottom side is equal to the coordinate of the top side.

Parameters
prcThe pointer to the rectangle.
Returns
TRUE for empty, otherwise FALSE.

Referenced by PtInRect().

void GUIAPI NormalizeRect ( RECT pRect)

Normalizes a rectangle.

This function normalizes the rectangle pointed to by prc so that both the height and width are positive.

Parameters
pRectThe pointer to the rectangle.

Referenced by PtInRect().

void OffsetRect ( RECT prc,
int  x,
int  y 
)
inlinestatic

Moves a rectangle by offsets.

This function moves the specified rectangle by the specified offsets. x and y specify the amount to move the rectangle left/right or up/down respectively. x must be a negative value to move the rectangle to the left, and y must be a negative value to move the rectangle up.

Parameters
prcThe pointer to the rectangle.
xThe x offset.
yThe y offset.
See also
InflateRect

Definition at line 5185 of file gdi.h.

BOOL PtInRect ( const RECT prc,
int  x,
int  y 
)
inlinestatic

Determines whether a point lies within an rectangle.

This function determines whether the specified point (x,y) lies within the specified rectangle prc.

A point is within a rectangle if it lies on the left or top side or is within all four sides. A point on the right or bottom side is considered outside the rectangle.

Parameters
prcThe pointer to the rectangle.
xx,y: The point.
yx,y: The point.

Definition at line 5248 of file gdi.h.

References DoesIntersect(), EqualRect(), FALSE, GetBoundRect(), IntersectRect(), IsCovered(), IsRectEmpty(), _RECT::left, NormalizeRect(), SubtractRect(), _RECT::top, TRUE, and UnionRect().

void SetRect ( RECT prc,
int  left,
int  top,
int  right,
int  bottom 
)
inlinestatic

Sets a rectangle.

This function sets the rectangle with specified values.

Parameters
prcThe pointer to the rectangle.
leftThe x coordinate of the upper-left corner of the rectangle.
topThe y coordinate of the upper-left corner of the rectangle.
rightThe x coordinate of the lower-right corner of the rectangle.
bottomThe y coordinate of the lower-right corner of the rectangle.
See also
SetRectEmpty

Definition at line 5128 of file gdi.h.

void SetRectEmpty ( RECT prc)
inlinestatic

Empties a rectangle.

This function empties the rectangle pointed to by prc. An empty rectangle in MiniGUI is a rectangle whose width and height both are zero. This function will sets all coordinates of the rectangle to be zero.

Parameters
prcThe pointer to the rectangle.
See also
SetRect

Definition at line 5147 of file gdi.h.

int GUIAPI SubtractRect ( RECT rc,
const RECT psrc1,
const RECT psrc2 
)

Obtains the rectangles when substracting one rectangle from another.

This function obtains the rectangles substracting the rectangle psrc1 from the other psrc2. rc should be an array of RECT struct, and may contain at most four rectangles. This function returns the number of result rectangles.

Parameters
rcThe pointer to the resule rectangle array.
psrc1The pointer to the minuend rectangle.
psrc2The pointer to the subtrahend rectangle.
Returns
The number of result rectangles.
See also
UnionRect

Referenced by PtInRect().

BOOL GUIAPI UnionRect ( RECT pdrc,
const RECT psrc1,
const RECT psrc2 
)

Unions two source rectangles.

This function creates the union (pdrc) of two rectangles (psrc1 and psrc2), if the source rectangles are border upon and not stagger.

Parameters
pdrcThe unioned rectangle.
psrc1The first source rectangles.
psrc2The second source rectangles.
Returns
TRUE if the source rectangles are border upon and not stagger, otherwise FALSE.
See also
GetBoundRect

Referenced by PtInRect().