uLib  User mode C/C++ extended API library for Win32 programmers.

Module Description

Additional region APIs...

Groups

 Region Numbers
 

Classes

struct  GdiPathData
 

Typedefs

typedef struct _gdiPathData * PGdiPathData
 

Functions

int WINAPI MapRegionToWindow (HRGN hRgn, HWND hWnd)
 
RGNDATA *WINAPI AllocAndGetRegionData (IN HRGN hRgn, OPTOUT PRECT *ppRc)
 
RGNDATA *WINAPI FreeRegionData (RGNDATA *pRgn)
 
void WINAPI DumpRegionData (CSTR Title, HRGN hRgn)
 
bool WINAPI GetGdiPathData (HDC hdc, OUT PGdiPathData pData)
 
void WINAPI FreeGdiPathData (PGdiPathData pData)
 
bool WINAPI GetGdiPathBounds (HDC hdc, PRECT pBounds)
 
HRGN WINAPI GetGdiPathRgn (HDC hdc, OUT RGNDATA **ppRgnData, OPTOUT RECT **ppRgnRects)
 
void OffsetPoints (POINT *Pts, UINT nPts, int dx, int dy)
 
void OffsetRgnData (PRGNDATA prd, int dx, int dy)
 
void SetIdentityMat2 (MAT2 *pm)
 

Class Documentation

◆ GdiPathData

struct GdiPathData

Data structure to use with GetGdiPathData().

Definition at line 2131 of file UtilFunc.h.

Class Members
LPPOINT pPoint Array of points.
LPBYTE pType Array of type specs for each point.
RECT Bounds Bounding rect for the whole path.
int nPoints Nr of elements in the pPoint and pType arrays.

Typedef Documentation

◆ PGdiPathData

typedef struct _gdiPathData * PGdiPathData

Data structure to use with GetGdiPathData().

Function Documentation

◆ MapRegionToWindow()

int WINAPI MapRegionToWindow ( HRGN  hRgn,
HWND  hWnd 
)

Offset the hRgn to hWnd.
The return value specifies the region's complexity. (See OffsetRgn().)
This function is primarily for use with GetRandomRgn().

Definition at line 610 of file GdiUtil.cpp.

◆ AllocAndGetRegionData()

RGNDATA* WINAPI AllocAndGetRegionData ( IN HRGN  hRgn,
OPTOUT PRECT *  ppRc 
)

Allocate a region data block and retrieve it with GetRegionData().
If provided, ppRc receives a pointer to the region's constituent RECTs.

Note:: Don't forget to FreeRegionData() when you're done.

◆ FreeRegionData()

RGNDATA* WINAPI FreeRegionData ( RGNDATA *  pRgn)

Free an AllocAndGetRegionData() block.

Definition at line 629 of file GdiUtil.cpp.

◆ DumpRegionData()

void WINAPI DumpRegionData ( CSTR  Title,
HRGN  hRgn 
)

Dump region data to the debugger. (Only in uLib _DEBUG builds)

Definition at line 635 of file GdiUtil.cpp.

◆ GetGdiPathData()

bool WINAPI GetGdiPathData ( HDC  hdc,
OUT PGdiPathData  pData 
)

GetGdiPathData() retrieves the current path data from a display context.
The path data is returned in a form suitable for use with PolyDraw().
The caller must supply a GdiPathData struct, which is filled by the function.
Dispose the data with FreeGdiPathData() when done.

Note
GetPath() sometimes fails, with no error code, even when there is a valid path.
I.e: GetPath( hdc, 0,0,0 ) == -1, and GetLastError() == 0.
Converting the path to a region with PathToRegion() appears more reliable.
You might use GetGdiPathRgn() for that purpose.

Definition at line 660 of file GdiUtil.cpp.

◆ FreeGdiPathData()

void WINAPI FreeGdiPathData ( PGdiPathData  pData)

FreeGdiPathData() disposes path data retrieved by GetGdiPathData().

Definition at line 707 of file GdiUtil.cpp.

◆ GetGdiPathBounds()

bool WINAPI GetGdiPathBounds ( HDC  hdc,
PRECT  pBounds 
)

GetGdiPathBounds() computes the bounding rect for the current HDC path.

Definition at line 714 of file GdiUtil.cpp.

◆ GetGdiPathRgn()

HRGN WINAPI GetGdiPathRgn ( HDC  hdc,
OUT RGNDATA **  ppRgnData,
OPTOUT RECT **  ppRgnRects 
)

GetGdiPathRgn() converts the current HDC path to a region and retrieves the region data.
After conversion, GDI clears the path from the display context.
The region can be used to perform operations not available for paths.
Call FreeRegionData() when done.

Parameters
hdcDisplay context containing a closed path.
ppRgnDataPointer to a RGNDATA pointer that recieves the region data.
ppRgnRectsPointer to a RECT pointer that recieves the array of rects.
Transforming a path with ExtCreateRegion.
RGNDATA* rgnData;
HRGN pathRgn = GetGdiPathRgn( hdc, &rgnData, NULL );
XFORM xfm; memset( &xfm, 0, sizeof(XFORM) );
xfm.eM11 = 1.0f; // Horz scale
xfm.eM21 = -1.0f; // Horz shear
xfm.eM22 = 0.9f; // Vert scale
DWORD cbRgnData = rgnData->rdh.dwSize + rgnData->rdh.nRgnSize;
HRGN xfmRgn = ExtCreateRegion( &xfm, cbRgnData, rgnData );

Definition at line 728 of file GdiUtil.cpp.

◆ OffsetPoints()

void OffsetPoints ( POINT *  Pts,
UINT  nPts,
int  dx,
int  dy 
)

OffsetPoints() offsets an array of points by dx/dy.
Useful e.g to modify data from GetGdiPathData().

Definition at line 758 of file GdiUtil.cpp.

◆ OffsetRgnData()

void OffsetRgnData ( PRGNDATA  prd,
int  dx,
int  dy 
)

OffsetRgnData() offsets the retrieved region data by dx/dy.
Useful e.g to modify data from GetGdiPathRgn() in lieu of ExtCreateRegion().

Definition at line 770 of file GdiUtil.cpp.

◆ SetIdentityMat2()

void SetIdentityMat2 ( MAT2 *  pm)

SetIdentityMat2() initializes a MAT2 to the identity matrix (i.e. no transform).
An initialized MAT2 is a mandatory parameter for GetGlyphOutline(),
but is somewhat of a PITA to initialize as there's no FIXED support.
(If you need to manipulate FIXED, have a look ar Fixed.hpp.)

Definition at line 782 of file GdiUtil.cpp.