MiniGUI API Reference (MiniGUI-Threads)
v3.2.0
A mature and proven cross-platform GUI system for embedded and smart IoT devices
|
Data Structures | |
struct | _CLIPRECT |
struct | _CLIPRGN |
Macros | |
#define | InitFreeClipRectList(heap, size) InitBlockDataHeap (heap, sizeof (CLIPRECT), size) |
Initializes the private block data heap used to allocate clipping rectangles. More... | |
#define | ClipRectAlloc(heap) BlockDataAlloc (heap) |
Allocates a clipping rectangles from the private block data heap. More... | |
#define | FreeClipRect(heap, cr) BlockDataFree (heap, cr); |
Frees a clipping rectangle which is allocated from the private block data heap. More... | |
#define | DestroyFreeClipRectList(heap) DestroyBlockDataHeap (heap); |
Destroys the private block data heap used to allocate clipping rectangles. More... | |
#define | UnionRectWithRegion AddClipRect |
Is an alias of AddClipRect. More... | |
#define | CopyRegion ClipRgnCopy |
Is an alias of ClipRgnCopy. More... | |
#define | IntersectRegion ClipRgnIntersect |
Is an alias of ClipRgnIntersect. More... | |
Typedefs | |
typedef struct _CLIPRECT | CLIPRECT |
typedef struct _CLIPRGN | CLIPRGN |
typedef CLIPRGN * | PCLIPRGN |
Data type of the pointer to a CLIPRGN. More... | |
Functions | |
MG_EXPORT void GUIAPI | InitClipRgn (PCLIPRGN pRgn, PBLOCKHEAP pFreeList) |
Initializes a clipping region. More... | |
MG_EXPORT void GUIAPI | EmptyClipRgn (PCLIPRGN pRgn) |
Empties a clipping region. More... | |
MG_EXPORT PCLIPRGN GUIAPI | CreateClipRgn (void) |
Creates a clipping region. More... | |
MG_EXPORT void GUIAPI | DestroyClipRgn (PCLIPRGN pRgn) |
Empties and destroys a clipping region. More... | |
MG_EXPORT BOOL GUIAPI | ClipRgnCopy (PCLIPRGN pDstRgn, const CLIPRGN *pSrcRgn) |
Copies one region to another. More... | |
MG_EXPORT BOOL GUIAPI | ClipRgnIntersect (PCLIPRGN pRstRgn, const CLIPRGN *pRgn1, const CLIPRGN *pRgn2) |
Intersects two region. More... | |
MG_EXPORT void GUIAPI | GetClipRgnBoundRect (PCLIPRGN pRgn, PRECT pRect) |
Gets the bounding rectangle of a region. More... | |
MG_EXPORT BOOL GUIAPI | SetClipRgn (PCLIPRGN pRgn, const RECT *pRect) |
Sets a region to contain only one rect. More... | |
MG_EXPORT BOOL GUIAPI | IsEmptyClipRgn (const CLIPRGN *pRgn) |
Determines whether a region is an empty region. More... | |
MG_EXPORT BOOL GUIAPI | AddClipRect (PCLIPRGN pRgn, const RECT *pRect) |
Unions one rectangle to a region. More... | |
MG_EXPORT BOOL GUIAPI | IntersectClipRect (PCLIPRGN pRgn, const RECT *pRect) |
Intersects a rectangle with a region. More... | |
MG_EXPORT BOOL GUIAPI | SubtractClipRect (PCLIPRGN pRgn, const RECT *pRect) |
Subtracts a rectangle from a region. More... | |
MG_EXPORT BOOL GUIAPI | PtInRegion (PCLIPRGN region, int x, int y) |
Determines whether a point is in a region. More... | |
MG_EXPORT BOOL GUIAPI | RectInRegion (PCLIPRGN region, const RECT *rect) |
Determines whether a rectangle is intersected with a region. More... | |
MG_EXPORT void GUIAPI | OffsetRegionEx (PCLIPRGN region, const RECT *rcClient, const RECT *rcScroll, int x, int y) |
Offsets the region in the specified window's scroll area. More... | |
MG_EXPORT void GUIAPI | OffsetRegion (PCLIPRGN region, int x, int y) |
Offsets the region. More... | |
MG_EXPORT BOOL GUIAPI | UnionRegion (PCLIPRGN dst, const CLIPRGN *src1, const CLIPRGN *src2) |
Unions two regions. More... | |
MG_EXPORT BOOL GUIAPI | SubtractRegion (CLIPRGN *rgnD, const CLIPRGN *rgnM, const CLIPRGN *rgnS) |
Substrcts a region from another. More... | |
MG_EXPORT BOOL GUIAPI | XorRegion (CLIPRGN *dst, const CLIPRGN *src1, const CLIPRGN *src2) |
Does the XOR operation between two regions. More... | |
MG_EXPORT BOOL GUIAPI | InitCircleRegion (PCLIPRGN dst, int x, int y, int r) |
Initializes a region to be an enclosed circle. More... | |
MG_EXPORT BOOL GUIAPI | InitEllipseRegion (PCLIPRGN dst, int x, int y, int rx, int ry) |
Initializes a region to be an enclosed ellipse. More... | |
MG_EXPORT BOOL GUIAPI | InitPolygonRegion (PCLIPRGN dst, const POINT *pts, int vertices) |
Initializes a region to be an enclosed polygon. More... | |
A Region is simply an area, as the name implies, and is implemented as a "y-x-banded" array of rectangles. To explain: Each Region is made up of a certain number of rectangles sorted by y coordinate first, and then by x coordinate.
Furthermore, the rectangles are banded such that every rectangle with a given upper-left y coordinate (y1) will have the same lower-right y coordinate (y2) and vice versa. If a rectangle has scanlines in a band, it will span the entire vertical distance of the band. This means that some areas that could be merged into a taller rectangle will be represented as several shorter rectangles to account for shorter rectangles to its left or right but within its "vertical scope".
An added constraint on the rectangles is that they must cover as much horizontal area as possible. E.g. no two rectangles in a band are allowed to touch.
Whenever possible, bands will be merged together to cover a greater vertical distance (and thus reduce the number of rectangles). Two bands can be merged only if the bottom of one touches the top of the other and they have rectangles in the same places (of the same width, of course). This maintains the y-x-banding that's so nice to have...
Example:
#define ClipRectAlloc | ( | heap | ) | BlockDataAlloc (heap) |
Allocates a clipping rectangles from the private block data heap.
heap | The pointer to the initialized BLOCKHEAP structure. |
#define CopyRegion ClipRgnCopy |
#define DestroyFreeClipRectList | ( | heap | ) | DestroyBlockDataHeap (heap); |
Destroys the private block data heap used to allocate clipping rectangles.
heap | The pointer to the BLOCKHEAP structure. |
#define FreeClipRect | ( | heap, | |
cr | |||
) | BlockDataFree (heap, cr); |
Frees a clipping rectangle which is allocated from the private block data heap.
heap | The pointer to the initialized BLOCKHEAP structure. |
cr | The pointer to the clipping rectangle to be freed. |
#define InitFreeClipRectList | ( | heap, | |
size | |||
) | InitBlockDataHeap (heap, sizeof (CLIPRECT), size) |
Initializes the private block data heap used to allocate clipping rectangles.
heap | The pointer to a BLOCKHEAP structure. |
size | The size of the heap. |
#define IntersectRegion ClipRgnIntersect |
#define UnionRectWithRegion AddClipRect |
Unions one rectangle to a region.
This function unions a rectangle to the region pointed to by pRgn.
pRgn | The pointer to the region. |
pRect | The pointer to the rectangle. |
Copies one region to another.
This function copies the region pointed to by pSrcRgn to the region pointed to by pDstRgn.
pDstRgn | The destination region. |
pSrcRgn | The source region. |
Intersects two region.
This function gets the intersection of two regions pointed to by pRgn1 and pRgn2 respectively and puts the result to the region pointed to by pRstRgn.
pRstRgn | The intersected result region. |
pRgn1 | The first region. |
pRgn2 | The second region. |
PCLIPRGN GUIAPI CreateClipRgn | ( | void | ) |
Creates a clipping region.
void GUIAPI DestroyClipRgn | ( | PCLIPRGN | pRgn | ) |
Empties and destroys a clipping region.
This function empties and destroys a clipping region pointed to by pRgn.
pRgn | The pointer to the region. |
void GUIAPI EmptyClipRgn | ( | PCLIPRGN | pRgn | ) |
Empties a clipping region.
This function empties a clipping region pointed to by pRgn.
pRgn | The pointer to the region. |
Gets the bounding rectangle of a region.
This function gets the bounding rect of the region pointed to by pRgn, and returns the rect in the rect pointed to by pRect.
pRgn | The pointer to the region. |
pRect | The pointer to the result rect. |
Initializes a region to be an enclosed circle.
dst | The pointer to the region to be initialized. |
x | x,y: The center of the circle. |
y | x,y: The center of the circle. |
r | The radius of the circle. |
void GUIAPI InitClipRgn | ( | PCLIPRGN | pRgn, |
PBLOCKHEAP | pFreeList | ||
) |
Initializes a clipping region.
Before intializing a clipping region, you should initialize a private block data heap first. The region operations, such as UnionRegion function, will allocate/free the clipping rectangles from/to the heap. This function will set the heap field of pRgn to be pFreeList, and empty the region.
pRgn | The pointer to the CLIPRGN structure to be initialized. |
pFreeList | The pointer to the initialized private block data heap. |
Example:
Initializes a region to be an enclosed ellipse.
dst | The pointer to the region to be initialized. |
x | x,y: The center of the ellipse. |
y | x,y: The center of the ellipse. |
rx | The x-radius of the ellipse. |
ry | The y-radius of the ellipse. |
Initializes a region to be an enclosed polygon.
dst | The pointer to the region to be initialized. |
pts | The vertex array of the polygon. |
vertices | The number of the vertices. |
Intersects a rectangle with a region.
This function intersects the region pointed to by pRgn with a rect pointed to by pRect.
pRgn | The pointer to the region. |
pRect | The pointer to the rectangle. |
Determines whether a region is an empty region.
This function determines whether the region pointed to by pRgn is an empty region.
pRgn | The pointer to the region. |
void GUIAPI OffsetRegion | ( | PCLIPRGN | region, |
int | x, | ||
int | y | ||
) |
Offsets the region.
This function offsets a given region pointed to by region.
region | The pointer to the region. |
x | x,y: Offsets on x and y coodinates. |
y | x,y: Offsets on x and y coodinates. |
void GUIAPI OffsetRegionEx | ( | PCLIPRGN | region, |
const RECT * | rcClient, | ||
const RECT * | rcScroll, | ||
int | x, | ||
int | y | ||
) |
Offsets the region in the specified window's scroll area.
This function offsets a given region pointed to by region in the specified window's scroll area.
region | The pointer to the region. |
rcClient | The client area which the region belongs to. |
rcScroll | The rectangle of the area in which the region will be offset. |
x | x,y: Offsets on x and y coodinates. |
y | x,y: Offsets on x and y coodinates. |
Determines whether a point is in a region.
This function determines whether a point (x,y) is in the region pointed to by region.
region | The pointer to the region. |
x | x,y: The point. |
y | x,y: The point. |
Determines whether a rectangle is intersected with a region.
This function determines whether the rect rect is intersected with the region pointed to by region.
region | The pointer to the region. |
rect | The pointer to the rect. |
Sets a region to contain only one rect.
This function sets the region pRgn to contain only a rect pointed to by pRect.
pRgn | The pointer to the region. |
pRect | The pointer to the rect. |
Subtracts a rectangle from a region.
This function subtracts a rect pointed to by pRect from the region pointed to by pRgn.
pRgn | The pointer to the region. |
pRect | The pointer to the rect. |
Substrcts a region from another.
This function subtracts rgnS from rgnM and leave the result in rgnD.
rgnD | The pointer to the difference region. |
rgnM | The pointer to the minuend region. |
rgnS | The pointer to the subtrahend region. |
Unions two regions.
This function unions two regions pointed to by src1 and src2 respectively and puts the result to the region pointed to by dst.
dst | The pointer to the result region. |
src1 | src1,src2: Two regions will be unioned. |
src2 | src1,src2: Two regions will be unioned. |
Does the XOR operation between two regions.
This function does the XOR operation between two regions pointed to by src1 and src2 and puts the result to the region pointed to by dst.
dst | The pointer to the result region. |
src1 | src1,src2: Two regions will be xor'ed. |
src2 | src1,src2: Two regions will be xor'ed. |