gdi.h
资源名称:GPRS_work.rar [点击查看]
上传用户:sdaoma
上传日期:2013-08-07
资源大小:3838k
文件大小:218k
源码类别:
GPS编程
开发平台:
C/C++
- * param x1 x1,y1: The start point of the line.
- * param y1 x1,y1: The start point of the line.
- * param x2 x2,y2: The end point of the line.
- * param y2 x2,y2: The end point of the line.
- *
- * note Only defined for _USE_NEWGAL and _ADV_2DAPI
- *
- * note This function does not change the pen position.
- *
- * sa LineTo, dc_attrs
- */
- void GUIAPI LineEx (HDC hdc, int x1, int y1, int x2, int y2);
- /**
- * fn void GUIAPI ArcEx (HDC hdc, int sx, int sy, int width, int height, int ang1, int ang2)
- * brief Draws an arc with the current pen in a DC.
- *
- * This function draws an arc with the current pen in the DC a hdc.
- * The center of the arc is at a (sx, sy), the bounding box of the arc is a width wide
- * and a height high, and the degree of start angle and end angle are a ang1 and a ang2
- * respectively.
- *
- * param hdc The device context.
- * param sx sx,sy: The center of the arc.
- * param sy sx,sy: The center of the arc.
- * param width The width of the bounding box of the arc.
- * param height The height of the bounding box of the arc.
- * param ang1 The start angle of the arc, relative to the 3 o'clock position,
- * counter-clockwise, in 1/64ths of a degree.
- * param ang2 The end angle of the arc, relative to angle1, in 1/64ths of a degree.
- *
- * note Only defined for _USE_NEWGAL
- *
- * sa CircleArc, dc_attrs
- */
- void GUIAPI ArcEx (HDC hdc, int sx, int sy, int width, int height, int ang1, int ang2);
- /**
- * fn void GUIAPI FillArcEx (HDC hdc, int x, int y, int width, int height, int ang1, int ang2)
- * brief Fills an arc with the current brush in a DC.
- *
- * This function fills an arc with the current brush in the DC a hdc.
- * The center of the arc is at a (sx, sy), the bounding box of the arc is a width wide
- * and a height high, and the degree of start angle and end angle are a ang1 and a ang2
- * respectively.
- *
- * param hdc The device context.
- * param x the x coordinate of the left edge of the bounding rectangle.
- * param y the y coordinate of the left edge of the bounding rectangle.
- * param width The width of the bounding box of the arc.
- * param height The height of the bounding box of the arc.
- * param ang1 The start angle of the arc, relative to the 3 o'clock position,
- * counter-clockwise, in 1/64ths of a degree.
- * param ang2 The end angle of the arc, relative to angle1, in 1/64ths of a degree.
- *
- * sa ArcEx, dc_attrs
- */
- void GUIAPI FillArcEx (HDC hdc, int x, int y, int width, int height, int ang1, int ang2);
- /**
- * fn void GUIAPI PolyLineEx (HDC hdc, const POINT* pts, int nr_pts)
- * brief Draws a polyline with the current pen in a DC.
- *
- * This function draws a polyline with the current pen in the DC a hdc.
- *
- * param hdc The device context.
- * param pts The pointer to the vertex array of the polyline.
- * param nr_pts The number of the vertices.
- *
- * sa LineEx
- */
- void GUIAPI PolyLineEx (HDC hdc, const POINT* pts, int nr_pts);
- /**
- * Arc structure.
- */
- typedef struct _ARC
- {
- /** the x coordinate of the left edge of the bounding rectangle. */
- int x;
- /** the y coordinate of the left edge of the bounding rectangle. */
- int y;
- /** the width of the bounding box of the arc. */
- int width;
- /** the height of the bounding box of the arc. */
- int height;
- /**
- * The start angle of the arc, relative to the 3 o'clock position,
- * counter-clockwise, in 1/64ths of a degree.
- */
- int angle1;
- /**
- * The end angle of the arc, relative to angle1, in 1/64ths of a degree.
- */
- int angle2;
- } ARC;
- /**
- * fn void GUIAPI PolyArcEx (HDC hdc, const ARC* arcs, int nr_arcs)
- * brief Draws a polyarc with the current pen in a DC.
- *
- * This function draws a polyarc with the current pen in the DC a hdc.
- *
- * param hdc The device context.
- * param arcs The pointer to an ARC array which defines the arcs.
- * param nr_arcs The number of the arcs.
- *
- * sa ArcEx
- */
- void GUIAPI PolyArcEx (HDC hdc, const ARC* arcs, int nr_arcs);
- /**
- * fn void GUIAPI PolyFillArcEx (HDC hdc, const ARC* arcs, int nr_arcs)
- * brief Fill a polyarc with the current brush in a DC.
- *
- * This function fill a polyarc with the current brush in the DC a hdc.
- *
- * param hdc The device context.
- * param arcs The pointer to an ARC array which defines the arcs.
- * param nr_arcs The number of the arcs.
- *
- * sa ArcEx
- */
- void GUIAPI PolyFillArcEx (HDC hdc, const ARC* arcs, int nr_arcs);
- /**
- * @} end of draw_adv_2d_fns
- */
- #endif
- #else
- /* Old GDI drawing functions */
- void GUIAPI MoveTo (HDC hdc, int x, int y);
- void GUIAPI LineTo (HDC hdc, int x, int y);
- void GUIAPI Rectangle (HDC hdc, int x0, int y0, int x1, int y1);
- void GUIAPI PolyLineTo (HDC hdc, const POINT* pts, int vertices);
- void GUIAPI Circle (HDC hdc, int sx, int sy, int r);
- void GUIAPI FillBox (HDC hdc, int x, int y, int w, int h);
- #endif
- /** @} end of draw_fns */
- /**
- * defgroup map_fns Mapping Operations
- *
- * The mapping mode defines the unit of measure used to transform
- * page-space units into device-space units, and also defines
- * the orientation of the device's x and y axes.
- *
- * So far, MiniGUI support only two mapping mode:
- *
- * - MM_TEXTn
- * Each logical unit is mapped to on device pixel.
- * Positive x is to the right; positive y is down.
- * - MM_ANISOTROPICn
- * Logical units are mapped to arbitrary units with arbitrarily scaled axes;
- * Use a SetWindowExt and a SetViewportExt functions to specify the units,
- * orientation, and scaling required.
- *
- * The following formula shows the math involved in converting a point
- * from page space to device space:
- *
- * code
- * Dx = ((Lx - WOx) * VEx / WEx) + VOx
- * endcode
- *
- * The following variables are involved:
- *
- * - Dx x value in device units
- * - Lx x value in logical units (also known as page space units)
- * - WO window x origin
- * - VO viewport x origin
- * - WE window x-extent
- * - VE viewport x-extent
- *
- * The same equation with y replacing x transforms the y component of a point.
- * The formula first offsets the point from its coordinate origin.
- * This value, no longer biased by the origin, is then scaled into
- * the destination coordinate system by the ratio of the extents.
- * Finally, the scaled value is offset by the destination origin to
- * its final mapping.
- *
- * @{
- */
- #define MM_TEXT 0
- #define MM_ANISOTROPIC 1
- #ifdef _USE_NEWGAL
- /**
- * def GetMapMode(hdc)
- * brief Retrives the current mapping mode of a DC.
- *
- * This function retrives the current mapping mode of the DC a hdc.
- *
- * So far, MiniGUI support two mapping modes: MM_TEXT and MM_ANISOTROPIC.
- *
- * param hdc The device context.
- * return The current mapping mode, can be either a MM_TEXT or a MM_ANISOTROPIC.
- *
- * note Defined as a macro calling a GetDCAttr for _USE_NEWGAL.
- * If _USE_NEWGAL is not defined, a GetMapMode is defined as
- * a function, and have the same semantics as this macro.
- *
- * sa SetWindowExt, SetViewportExt, SetMapMode
- */
- #define GetMapMode(hdc) (int)GetDCAttr (hdc, DC_ATTR_MAP_MODE)
- /**
- * def SetMapMode(hdc, mapmode)
- * brief Sets the mapping mode of a display context.
- *
- * This function sets the mapping mode of the specified display context a hdc.
- *
- * So far, MiniGUI support two mapping modes: MM_TEXT and MM_ANISOTROPIC.
- *
- * param hdc The device context.
- * param mapmode The new mapping mode, should be either a MM_TEXT or a MM_ANISOTROPIC.
- * return The old mapping mode, either a MM_TEXT or a MM_ANISOTROPIC.
- *
- * note Defined as a macro calling a SetDCAttr for _USE_NEWGAL.
- * If _USE_NEWGAL is not defined, a SetMapMode is defined as
- * a function, and have the same semantics as this macro.
- *
- * sa SetWindowExt, SetViewportExt, SetMapMode
- */
- #define SetMapMode(hdc, mapmode) (int)SetDCAttr (hdc, DC_ATTR_MAP_MODE, (DWORD)mapmode)
- #else
- int GUIAPI GetMapMode (HDC hdc);
- void GUIAPI SetMapMode (HDC hdc, int mapmode);
- #endif /* _USE_NEWGAL */
- #ifdef _USE_NEWGAL
- /**
- * fn void GUIAPI GetDCLCS (HDC hdc, int which, POINT* pt)
- * brief Retrives mapping parameters of a device context.
- *
- * This function retrives mapping paramters of the specified device context a hdc
- * when the mapping mode is not a MM_TEXT.
- *
- * param hdc The device context.
- * param which Which parameter you want to retrive, can be one of the following values:
- *
- * - DC_LCS_VORGn
- * Retrives the x-coordinates and y-coordinates of the viewport origin.
- * - DC_LCS_VEXTn
- * Retrives the x-extents and y-extents of the current viewport.
- * - DC_LCS_WORGn
- * Retrives the x-coordinates and y-coordinates of the window origin.
- * - DC_LCS_WEXTn
- * Retrives the x-extents and y-extents of the window.
- *
- * param pt The coordinates or extents will be returned through this buffer.
- *
- * note Only defined for _USE_NEWGAL
- *
- * sa GetMapMode, SetMapMode, SetDCLCS
- */
- void GUIAPI GetDCLCS (HDC hdc, int which, POINT* pt);
- /**
- * fn void GUIAPI SetDCLCS (HDC hdc, int which, const POINT* pt)
- * brief Sets mapping parameters of a device context.
- *
- * This function sets mapping paramters of the specified device context a hdc
- * when the mapping mode is not a MM_TEXT.
- *
- * param hdc The device context.
- * param which Which parameter you want to retrive, can be one of the following values:
- *
- * - DC_LCS_VORGn
- * Sets the x-coordinates and y-coordinates of the viewport origin.
- * - DC_LCS_VEXTn
- * Sets the x-extents and y-extents of the current viewport.
- * - DC_LCS_WORGn
- * Sets the x-coordinates and y-coordinates of the window origin.
- * - DC_LCS_WEXTn
- * Sets the x-extents and y-extents of the window.
- *
- * param pt The coordinates or extents will be set.
- *
- * note Only defined for _USE_NEWGAL
- *
- * sa GetMapMode, SetMapMode, GetDCLCS
- */
- void GUIAPI SetDCLCS (HDC hdc, int which, const POINT* pt);
- #define DC_LCS_VORG 0
- #define DC_LCS_VEXT 1
- #define DC_LCS_WORG 2
- #define DC_LCS_WEXT 3
- #define NR_DC_LCS_PTS 4
- /**
- * def GetViewportOrg(hdc, pPt)
- * brief Retrieves the x-coordinates and y-coordinates of the viewport origin for a device context.
- *
- * This function retrives the x-coordinates and y-coordinates of
- * the viewport origin of the specified device context a hdc.
- *
- * param hdc The device context.
- * param pPt The viewport origin will be returned through this buffer.
- *
- * note Defined as a macro calling a GetDCLCS for _USE_NEWGAL.
- * If _USE_NEWGAL is not defined, a GetViewportOrg is defined as
- * a function, and have the same semantics as this macro.
- *
- * sa GetMapMode, SetViewportOrg
- */
- #define GetViewportOrg(hdc, pPt) GetDCLCS(hdc, DC_LCS_VORG, pPt)
- /**
- * def GetViewportExt(hdc, pPt)
- * brief Retrieves the x-extents and y-extents of the current viewport for a device context.
- *
- * This function retrives the x-extents and y-extens of the current viewport of
- * the specified device context a hdc.
- *
- * param hdc The device context.
- * param pPt The viewport extents will be returned through this buffer.
- *
- * note Defined as a macro calling a GetDCLCS for _USE_NEWGAL.
- * If _USE_NEWGAL is not defined, a GetViewportExt is defined as
- * a function, and have the same semantics as this macro.
- *
- * sa GetMapMode, SetViewportExt
- */
- #define GetViewportExt(hdc, pPt) GetDCLCS(hdc, DC_LCS_VEXT, pPt)
- /**
- * def GetWindowOrg(hdc, pPt)
- * brief Retrieves the x-coordinates and y-coordinates of the window for a device context.
- *
- * This function retrives the x-coordinates and y-coordinates of
- * the window origin of the specified device context a hdc.
- *
- * param hdc The device context.
- * param pPt The window origin will be returned through this buffer.
- *
- * note Defined as a macro calling a GetDCLCS for _USE_NEWGAL.
- * If _USE_NEWGAL is not defined, a GetWindowOrg is defined as
- * a function, and have the same semantics as this macro.
- *
- * sa GetMapMode, SetWindowOrg
- */
- #define GetWindowOrg(hdc, pPt) GetDCLCS(hdc, DC_LCS_WORG, pPt)
- /**
- * def GetWindowExt(hdc, pPt)
- * brief Retrieves the x-extents and y-extents of the current window for a device context.
- *
- * This function retrives the x-extents and y-extens of the current window of
- * the specified device context a hdc.
- *
- * param hdc The device context.
- * param pPt The window extents will be returned through this buffer.
- *
- * note Defined as a macro calling a GetDCLCS for _USE_NEWGAL.
- * If _USE_NEWGAL is not defined, a GetWindowExt is defined as
- * a function, and have the same semantics as this macro.
- *
- * sa GetMapMode, SetWindowExt
- */
- #define GetWindowExt(hdc, pPt) GetDCLCS(hdc, DC_LCS_WEXT, pPt)
- /**
- * def SetViewportOrg(hdc, pPt)
- * brief Sets the x-coordinates and y-coordinates of the viewport origin for a device context.
- *
- * This function sets the x-coordinates and y-coordinates of
- * the viewport origin of the specified device context a hdc.
- *
- * param hdc The device context.
- * param pPt The viewport origin will be set.
- *
- * note Defined as a macro calling a GetDCLCS for _USE_NEWGAL.
- * If _USE_NEWGAL is not defined, a SetViewportOrg is defined as
- * a function, and have the same semantics as this macro.
- *
- * sa GetMapMode, GetViewportOrg
- */
- #define SetViewportOrg(hdc, pPt) SetDCLCS(hdc, DC_LCS_VORG, pPt)
- /**
- * def SetViewportExt(hdc, pPt)
- * brief Sets the x-extents and y-extents of the current viewport for a device context.
- *
- * This function sets the x-extents and y-extens of the current viewport of
- * the specified device context a hdc.
- *
- * param hdc The device context.
- * param pPt The viewport extents will be set.
- *
- * note Defined as a macro calling a GetDCLCS for _USE_NEWGAL.
- * If _USE_NEWGAL is not defined, a SetViewportExt is defined as
- * a function, and have the same semantics as this macro.
- *
- * sa GetMapMode, GetViewportExt
- */
- #define SetViewportExt(hdc, pPt) SetDCLCS(hdc, DC_LCS_VEXT, pPt)
- /**
- * def SetWindowOrg(hdc, pPt)
- * brief Sets the x-coordinates and y-coordinates of the window for a device context.
- *
- * This function sets the x-coordinates and y-coordinates of
- * the window origin of the specified device context a hdc.
- *
- * param hdc The device context.
- * param pPt The window origin will be set.
- *
- * note Defined as a macro calling a GetDCLCS for _USE_NEWGAL.
- * If _USE_NEWGAL is not defined, a SetWindowOrg is defined as
- * a function, and have the same semantics as this macro.
- *
- * sa GetMapMode, GetWindowOrg
- */
- #define SetWindowOrg(hdc, pPt) SetDCLCS(hdc, DC_LCS_WORG, pPt)
- /**
- * def SetWindowExt(hdc, pPt)
- * brief Sets the x-extents and y-extents of the current window for a device context.
- *
- * This function sets the x-extents and y-extens of the current window of
- * the specified device context a hdc.
- *
- * param hdc The device context.
- * param pPt The window extents will be set.
- *
- * note Defined as a macro calling a GetDCLCS for _USE_NEWGAL.
- * If _USE_NEWGAL is not defined, a SetWindowExt is defined as
- * a function, and have the same semantics as this macro.
- *
- * sa GetMapMode, GetWindowExt
- */
- #define SetWindowExt(hdc, pPt) SetDCLCS(hdc, DC_LCS_WEXT, pPt)
- #else
- void GUIAPI GetViewportExt (HDC hdc, POINT* pPt);
- void GUIAPI GetViewportOrg (HDC hdc, POINT* pPt);
- void GUIAPI GetWindowExt (HDC hdc, POINT* pPt);
- void GUIAPI GetWindowOrg (HDC hdc, POINT* pPt);
- void GUIAPI SetViewportExt (HDC hdc, POINT* pPt);
- void GUIAPI SetViewportOrg (HDC hdc, POINT* pPt);
- void GUIAPI SetWindowExt (HDC hdc, POINT* pPt);
- void GUIAPI SetWindowOrg (HDC hdc, POINT* pPt);
- #endif /* _USE_NEWGAL */
- /**
- * fn void GUIAPI DPtoLP (HDC hdc, POINT* pPt)
- * brief Converts device coordinates into logical coordinates.
- *
- * This function converts device coordinates into logical coordinates
- * in the device context a hdc.
- *
- * The conversion depends on the mapping mode of the display context,
- * the settings of the origins and extents for the window and viewport.
- * The x-coordinate and y-coordinate contained in struct a pPt will be
- * transformed.
- *
- * param hdc The device context.
- * param pPt The coordinates to be converted, and the transformed coordinates
- * will be contained in this buffer after the function returns.
- *
- * sa LPtoDP
- */
- void GUIAPI DPtoLP (HDC hdc, POINT* pPt);
- /**
- * fn void GUIAPI LPtoDP (HDC hdc, POINT* pPt)
- * brief Converts logical coordinates into device coordinates.
- *
- * This function converts logical coordinates into device coordinates
- * in the device context a hdc.
- *
- * The conversion depends on the mapping mode of the display context,
- * the settings of the origins and extents for the window and viewport.
- * The x-coordinate and y-coordinate contained in struct a pPt will be
- * transformed.
- *
- * param hdc The device context.
- * param pPt The coordinates to be converted, and the transformed coordinates
- * will be contained in this buffer after the function returns.
- *
- * sa DPtoLP
- */
- void GUIAPI LPtoDP (HDC hdc, POINT* pPt);
- /** @} end of map_fns */
- /**
- * defgroup clip_fns Clipping operations
- * @{
- */
- /**
- * fn void GUIAPI ExcludeClipRect (HDC hdc, const RECT* prc)
- * brief Excludes the specified rectangle from the current visible region of a DC.
- *
- * This function excludes the specified rect a prc from the current visible region
- * of the device context a hdc.
- *
- * param hdc The device context.
- * param prc The rectangle to be excluded.
- *
- * sa IncludeClipRect, region_fns
- */
- void GUIAPI ExcludeClipRect (HDC hdc, const RECT* prc);
- /**
- * fn void GUIAPI IncludeClipRect (HDC hdc, const RECT* prc)
- * brief Includes the specified rectangle to the current visible region of a DC.
- *
- * This function includes the specified rectangle a prc to the current visible region
- * of the device context a hdc.
- *
- * param hdc The device context.
- * param prc The rectangle to be included.
- *
- * sa ExcludeClipRect, region_fns
- */
- void GUIAPI IncludeClipRect (HDC hdc, const RECT* prc);
- /**
- * fn BOOL GUIAPI PtVisible (HDC hdc, int x, int y)
- * brief Checks whether a point is visible.
- *
- * This function checks whether the point specified by a (x,y) is visible, i.e.
- * it is within the current visible clipping region of the device context a hdc.
- *
- * param hdc The device context.
- * param x x,y: The coordinates of the point.
- * param y x,y: The coordinates of the point.
- * return TRUE for visible, else for not.
- *
- * sa RectVisible, region_fns
- */
- BOOL GUIAPI PtVisible (HDC hdc, int x, int y);
- /**
- * fn void GUIAPI ClipRectIntersect (HDC hdc, const RECT* prc)
- * brief Intersects the specified rectangle with the visible region of the DC.
- *
- * This function intersects the specified rectangle a prc with the visible region
- * of the device context a hdc.
- *
- * param hdc The device context.
- * param prc Pointer to the rectangle.
- *
- * sa IncludeClipRect, ExcludeClipRect, region_fns
- */
- void GUIAPI ClipRectIntersect (HDC hdc, const RECT* prc);
- /**
- * fn void GUIAPI SelectClipRect (HDC hdc, const RECT* prc)
- * brief Sets the visible region of a DC to be a rectangle.
- *
- * This function sets the visible region of the device context a hdc
- * to the rectangle pointed to by a prc.
- *
- * param hdc The device context.
- * param prc Pointer to the rectangle.
- *
- * sa SelectClipRegion, region_fns
- */
- void GUIAPI SelectClipRect (HDC hdc, const RECT* prc);
- /**
- * fn void GUIAPI SelectClipRegion (HDC hdc, const CLIPRGN* pRgn)
- * brief Sets the visible region of a DC to be a region.
- *
- * This function sets the visible region of the device context a hdc
- * to the region pointed to by a pRgn.
- *
- * param hdc The device context.
- * param pRgn Pointer to the region.
- *
- * sa SelectClipRect, region_fns
- */
- void GUIAPI SelectClipRegion (HDC hdc, const CLIPRGN* pRgn);
- /**
- * fn void GUIAPI GetBoundsRect (HDC hdc, RECT* pRect)
- * brief Retrives the bounding rectangle of the current visible region of a DC.
- *
- * This function retrives the bounding rectangle of the current visible region
- * of the specified device context a hdc, and returned through a pRect.
- *
- * param hdc The device context.
- * param pRect The bounding rectangle will be returned through this buffer.
- *
- * sa region_fns
- */
- void GUIAPI GetBoundsRect (HDC hdc, RECT* pRect);
- /**
- * fn BOOL GUIAPI RectVisible (HDC hdc, const RECT* pRect)
- * brief Checks whether the specified rectangle is visible.
- *
- * This function checks whether the rectangle pointed to by a pRect is visible, i.e.
- * it is intersected with the current visible region of the device context a hdc.
- *
- * param hdc The device context.
- * param pRect Pointer to the rectangle.
- *
- * sa PtVisible, region_fns
- *
- * Example:
- *
- * include rectvisible.c
- */
- BOOL GUIAPI RectVisible (HDC hdc, const RECT* pRect);
- /** @} end of clip_fns */
- /**
- * defgroup bmp_fns BITMAP and blitting operations
- *
- * Example:
- *
- * include blitting.c
- *
- * @{
- */
- #ifdef _USE_NEWGAL
- /**
- * fn BOOL GUIAPI GetBitmapFromDC (HDC hdc, int x, int y, int w, int h, BITMAP* bmp)
- * brief Gets image box on a DC and saves it into a BITMAP object.
- *
- * This function gets image box on the specified device context a hdc,
- * and saves the image bits into the BITMAP object pointed to by a bmp.
- * The image box begins at a (x,y), and is a w wide and a h high.
- * You must make sure that a bmp->bits is big enough to store the image.
- *
- * param hdc The device context.
- * param x The x coordinate in pixels of upper-left corner of the image box.
- * param y The y coordinate in pixels of upper-left corner of the image box.
- * param w The width of the image box.
- * param h The height of the image box.
- * param bmp The pointer to the BITMAP object.
- *
- * note Only defined for _USE_NEWGAL. If _USE_NEWGAL not defined, there is
- * will be an analogous function called a SaveScreenBox:
- *
- * code
- * void GUIAPI SaveScreenBox (int x, int y, int w, int h, void* vbuf)
- * endcode
- *
- * sa FillBoxWithBitmap, bmp_struct
- */
- BOOL GUIAPI GetBitmapFromDC (HDC hdc, int x, int y, int w, int h, BITMAP* bmp);
- #else
- void GUIAPI SaveScreenBox (int x, int y, int w, int h, void* vbuf);
- void* GUIAPI SaveCoveredScreenBox (int x, int y, int w, int h);
- void GUIAPI PutSavedBoxOnScreen (int x, int y, int w, int h, void* vbuf);
- void GUIAPI PutSavedBoxOnDC (HDC hdc, int x, int y, int w, int h, void* vbuf);
- void GUIAPI ScreenCopy (int sx, int sy, HDC hdc, int dx, int dy);
- #endif /* _USE_NEWGAL */
- /**
- * fn BOOL GUIAPI FillBoxWithBitmap (HDC hdc, int x, int y, int w, int h, const BITMAP *bmp)
- * brief Fills a box with a BITMAP object.
- *
- * This function fills a box with a BITMAP object pointed to by a bmp.
- * a (x,y) is the upper-left corner of the box, and a w, a h are
- * the width and the height of the box respectively.
- *
- * This function will scale the bitmap when necessary; that is, when
- * the width or the height of the box is not equal to the with or
- * the height of the BITMAP object.
- *
- * param hdc The device context.
- * param x The x coordinate of the upper-left corner of the box.
- * param y The y coordinate of the upper-left corner of the box.
- * param w The width of the box. Can be zero, means the width
- * or the height will be equal to the width or the height of the BITMAP object.
- * param h The height of the box. Can be zero, means the width
- * or the height will be equal to the width or the height of the BITMAP object.
- * param bmp The pointer to the BITMAP object.
- * return TRUE on success, otherwise FALSE.
- *
- * note You can specify the alpha value or the color key of the BITMAP object if
- * _USE_NEWGAL defined, and the current raster operation was set by a SetRasterOperation
- * for the DC will override the alpha value of color key if ROP is not ROP_SET.
- * If _USE_NEWGAL is not defined, this function will not return anything, and
- * you can not specify the alpha value and the color key of the BITMAP object.
- *
- * sa FillBoxWithBitmapPart, GetBitmapFromDC, bmp_load_fns
- */
- BOOL GUIAPI FillBoxWithBitmap (HDC hdc, int x, int y, int w, int h,
- const BITMAP *bmp);
- /**
- * fn BOOL GUIAPI FillBoxWithBitmapPart (HDC hdc, int x, int y, int w, int h, int bw, int bh, const BITMAP* bmp, int xo, int yo)
- * brief Fills a box with a part of a bitmap oject.
- *
- * This function fills a box with a part of a bitmap object pointed to by a bmp.
- * a (x,y) is the upper-left corner of the box, and a w, a h are the width and
- * the height of the box respectively. a (xo, yo) is the start position of the
- * part box in the bitmap relative to upper-left corner of the bitmap,
- * and a bw, a bh are the width and the height of the full bitmap expected.
- *
- * If a bw or a bh is less than or equal to zero, this function will use
- * the original width and height of the bitmap, else it will scale
- * the BITMAP object when necessary; that is, when the width or the height of
- * the box is not equal to the with or the height of the BITMAP object.
- *
- * param hdc The device context.
- * param x The x coordinate of the upper-left corner of the box.
- * param y The y coordinate of the upper-left corner of the box.
- * param w The width of the box.
- * param h The height of the box.
- * param bw The width of the full bitmap expected.
- * Can be zero, means the width or the height will be equal to
- * the width or the height of the BITMAP object.
- * param bh The height of the full bitmap expected.
- * Can be zero, means the width or the height will be equal to
- * the width or the height of the BITMAP object.
- * param xo xo,yo: The start position of the part box in the bitmap
- * relative to upper-left corner of the BITMAP object.
- * param yo xo,yo: The start position of the part box in the bitmap
- * relative to upper-left corner of the BITMAP object.
- * param bmp The pointer to the BITMAP object.
- * return TRUE on success, otherwise FALSE.
- *
- * note You can specify the alpha value or the color key of the BITMAP object if
- * _USE_NEWGAL defined, and the current raster operation was set by
- * a SetRasterOperation for the DC will override the alpha value or
- * the color key if ROP is not ROP_SET. If _USE_NEWGAL not defined,
- * this function will not return anything, and you can not specify
- * the alpha value and the color key of the BITMAP object.
- *
- * sa FillBoxWithBitmap, GetBitmapFromDC, bmp_struct
- */
- BOOL GUIAPI FillBoxWithBitmapPart (HDC hdc, int x, int y, int w, int h,
- int bw, int bh, const BITMAP* bmp, int xo, int yo);
- /**
- * fn void GUIAPI BitBlt (HDC hsdc, int sx, int sy, int sw, int sh, HDC hddc, int dx, int dy, DWORD dwRop)
- * brief Performs a bit-block transfer from a device context into another device context.
- *
- * This function performs a bit-block transfer of the color data cooresponding to
- * a rectangle of pixels from the specified source device context a hsdc into
- * a destination device context a hddc. a (sx,sy,sw,sh) specifies the rectangle
- * in the source DC, and a (dx,dy) specifies the position of the rectangle
- * in the destination DC. Note that the size of the two rectangles are identical.
- *
- * Note that all coordinates should be in the device space.
- *
- * param hsdc The source device context.
- * param sx The x coordinate of the upper-left corner of the rectangle in the source DC.
- * param sy The y coordinate of the upper-left corner of the rectangle in the source DC.
- * param sw The width of the source rectangle.
- * param sh The height of the source rectangle.
- * param hddc The destination device context a hddc.
- * param dx The x coordinate of the upper-left corner of the rectangle in the destination DC.
- * param dy The y coordinate of the upper-left corner of the rectangle in the destination DC.
- * param dwRop The raster operation, currently ignored.
- *
- * note If _USE_NEWGAL defined, the alpha and color key settings of the source DC
- * will come into play.
- *
- * sa StretchBlt, SetMemDCAlpha, SetMemDCColorKey
- */
- void GUIAPI BitBlt (HDC hsdc, int sx, int sy, int sw, int sh,
- HDC hddc, int dx, int dy, DWORD dwRop);
- /**
- * fn void GUIAPI StretchBlt (HDC hsdc, int sx, int sy, int sw, int sh, HDC hddc, int dx, int dy, int dw, int dh, DWORD dwRop)
- * brief Copies a bitmap from a source rectangle into a destination rectangle, streches the bitmap if necessary.
- *
- * This function copies a bitmap from a source rectangle into a destination rectangle,
- * streching or compressing the bitmap to fit the dimension of the destination rectangle,
- * if necessary. This function is similar with sa BitBlt function except the former scaling the bitmap.
- * a (dw,dh) specifies the size of the destination rectangle.
- *
- * param hsdc The source device context.
- * param sx The x coordinate of the upper-left corner of the rectangle in the source DC.
- * param sy The y coordinate of the upper-left corner of the rectangle in the source DC.
- * param sw The width of the source rectangle.
- * param sh The height of the source rectangle.
- * param hddc The destination device context a hddc.
- * param dx The x coordinate of the upper-left corner of the rectangle in the destination DC.
- * param dy The y coordinate of the upper-left corner of the rectangle in the destination DC.
- * param dw The width of the destination rectangle.
- * param dh The height of the destination rectangle.
- * param dwRop The raster operation, currently ignored.
- *
- * note The source rect should be contained in the device space entirely,
- * and all coordinates should be in the device space.
- *
- * note The alpha and color key settings of the source DC will not come into play.
- *
- * sa BitBlt, SetMemDCAlpha, SetMemDCColorKey
- */
- void GUIAPI StretchBlt (HDC hsdc, int sx, int sy, int sw, int sh,
- HDC hddc, int dx, int dy, int dw, int dh, DWORD dwRop);
- /**
- * fn BOOL GUIAPI ScaleBitmap (BITMAP* dst, const BITMAP* src)
- * brief Scales a BITMAP object into another BITMAP object by using DDA algorithm.
- *
- * This function scales a BITMAP object a src into another BITMAO object a dst
- * by using DDA algorithm. The source rectangle and the destination rectangle
- * both are defined in the BITMAP objects.
- *
- * param dst The destination BITMAP object.
- * param src The srouce BITMAP object.
- * return TRUE on success, otherwise FALSE.
- *
- * note Only defined for _USE_NEWGAL.
- *
- * sa FillBoxWithBitmap, StretchBlt, bmp_struct
- */
- BOOL GUIAPI ScaleBitmap (BITMAP* dst, const BITMAP* src);
- /**
- * fn gal_pixel GUIAPI GetPixelInBitmap (const BITMAP* bmp, int x, int y)
- * brief Returns the pixel value in a BITMAP object.
- *
- * This function returns the pixel value at the position a (x,y) in
- * the BITMAP object a bmp.
- *
- * param bmp The BITMAP object.
- * param x x,y: The position of the pixel in the bitmap relative to
- * the upper-left corner of the bitmap.
- * param y x,y: The position of the pixel in the bitmap relative to
- * the upper-left corner of the bitmap.
- * return The pixel value, if the position is out of the bitmap,
- * zero returned.
- *
- * note Only defined for _USE_NEWGAL.
- *
- * sa SetPixelInBitmap, bmp_struct
- */
- gal_pixel GUIAPI GetPixelInBitmap (const BITMAP* bmp, int x, int y);
- /**
- * fn BOOL GUIAPI SetPixelInBitmap (const BITMAP* bmp, int x, int y, gal_pixel pixel)
- * brief Sets pixel value in a BITMAP object.
- *
- * This function sets the pixel value at the position a (x,y) in
- * the BITMAP object a bmp.
- *
- * param bmp The BITMAP object.
- * param x x,y: The position of the pixel in the bitmap relative to
- * the upper-left corner of the bitmap.
- * param y x,y: The position of the pixel in the bitmap relative to
- * the upper-left corner of the bitmap.
- * param pixel The pixel value.
- * return TRUE on success. If the position is out of the bitmap, FALSE returned.
- *
- * note Only defined for _USE_NEWGAL.
- *
- * sa GetPixelInBitmap, bmp_struct
- */
- BOOL GUIAPI SetPixelInBitmap (const BITMAP* bmp, int x, int y, gal_pixel pixel);
- #ifdef _MISC_SAVESCREEN
- /**
- * fn BOOL GUIAPI SaveMainWindowContent (HWND hWnd, const char* filename)
- * brief Saves content of a main window to a file.
- *
- * This function saves the content of the main window a hWnd to the iamge file a filename.
- * MiniGUI uses the extension name of the file to determine the format of the image file.
- *
- * param hWnd Handle to the main window.
- * param filename The name of the iamge file.
- * return TRUE on success, otherwise FALSE.
- *
- * note Only defined for _MISC_SAVESCREEN.
- *
- * sa bmp_load_fns
- */
- BOOL GUIAPI SaveMainWindowContent (HWND hWnd, const char* filename);
- #endif
- /** @} end of bmp_fns */
- /**
- * defgroup icon_fns Icon operations
- * @{
- */
- /**
- * fn HICON GUIAPI LoadIconFromFile (HDC hdc, const char* filename, int which)
- * brief Loads an icon from a Windows ICO file.
- *
- * This function loads an icon from a Windows ICO file named a filename
- * and creates an icon object. This function can load mono- and 16-color icons.
- * Some Windows ICO file contain two icons in different sizes. You can tell
- * this function to load which icon though a which, 0 for the first icon,
- * and 1 for the second icon. Generally, the later icon is the larger icon.
- *
- * param hdc The device context.
- * param filename The file name of the ICO file.
- * param which Tell the function to load which icon.
- * return The handle to the icon object, zero means error occurred.
- *
- * sa CreateIcon
- */
- HICON GUIAPI LoadIconFromFile (HDC hdc, const char* filename, int which);
- /**
- * fn HICON GUIAPI LoadIconFromMem (HDC hdc, const void* area, int which)
- * brief Loads an icon from a memory area.
- *
- * This function loads an icon from a memroy area pointed to by a area.
- * The memory area has the same layout as the M$ Windows ICO file.
- *
- * This function can load mono- and 16-color icons.
- * Some Windows ICO file contain two icons in different sizes. You can tell
- * this function to load which icon though a which, 0 for the first icon,
- * and 1 for the second icon. Generally, the later icon is the larger icon.
- *
- * param hdc The device context.
- * param area The pointer to the memory area.
- * param which Tell the function to load which icon.
- * return The handle to the icon object, zero means error occurred.
- *
- * sa CreateIcon
- */
- HICON GUIAPI LoadIconFromMem (HDC hdc, const void* area, int which);
- /**
- * fn HICON GUIAPI CreateIcon (HDC hdc, int w, int h, const BYTE* AndBits, const BYTE* XorBits, int colornum)
- * brief Creates an icon object from the memory.
- *
- * This function creates an icon from memory data rather than icon file.
- * a w and a h are the width and the height of the icon respectively.
- * a pANDBits and a pXORBits are AND bitmask and XOR bitmask of the icon.
- * MiniGUI currently support mono-color cursor and 16-color icon, a colornum
- * specifies the cursor's color depth. For mono-color, it should be 1, and for
- * 16-color cursor, it should be 4.
- *
- * param hdc The device context.
- * param w The width of the icon.
- * param h The height of the icon.
- * param AndBits The pointer to the AND bits of the icon.
- * param XorBits The pointer to the XOR bits of the icon.
- * param colornum The bit-per-pixel of XOR bits.
- * return The handle to the icon object, zero means error occurred.
- *
- * sa LoadIconFromFile
- */
- HICON GUIAPI CreateIcon (HDC hdc, int w, int h,
- const BYTE* AndBits, const BYTE* XorBits, int colornum);
- /**
- * fn BOOL GUIAPI DestroyIcon (HICON hicon)
- * brief Destroys an icon object.
- *
- * This function destroys the icon object a hicon.
- *
- * param hicon The icon object.
- * return TRUE on success, otherwise FALSE.
- *
- * sa CreateIcon, LoadIconFromFile
- */
- BOOL GUIAPI DestroyIcon (HICON hicon);
- /**
- * fn BOOL GUIAPI GetIconSize (HICON hicon, int* w, int* h)
- * brief Gets the size of an icon object.
- *
- * This function gets the size of the icon object a hicon.
- *
- * param hicon The icon object.
- * param w The width of the icon will be returned throught this buffer.
- * param h The height of the icon will be returned throught this buffer.
- * return TRUE on success, otherwise FALSE.
- *
- * sa CreateIcon, LoadIconFromFile
- */
- BOOL GUIAPI GetIconSize (HICON hicon, int* w, int* h);
- /**
- * fn void GUIAPI DrawIcon (HDC hdc, int x, int y, int w, int h, HICON hicon)
- * brief Draws an icon into a box.
- *
- * This function draws an icon object a hicon into a box specified by a (x,y,w,h).
- *
- * param hdc The device context.
- * param x The x coordinate of the upper-left corner of the box.
- * param y The y coordinate of the upper-left corner of the box.
- * param w The width of the box.
- * param h The height of the box.
- * param hicon The icon object.
- *
- * sa CreateIcon, LoadIconFromFile
- */
- void GUIAPI DrawIcon (HDC hdc, int x, int y, int w, int h, HICON hicon);
- /** @} end of icon_fns */
- /**
- * defgroup rect_fns Rectangle operations
- * @{
- */
- #ifdef _USE_NEWGAL
- /**
- * fn void SetRect (RECT* prc, int left, int top, int right, int bottom)
- * brief Sets a rectangle.
- *
- * This function sets the rectangle with specified values.
- *
- * param prc The pointer to the rectangle.
- * param left The x coordinate of the upper-left corner of the rectangle.
- * param top The y coordinate of the upper-left corner of the rectangle.
- * param right The x coordinate of the lower-right corner of the rectangle.
- * param bottom The y coordinate of the lower-right corner of the rectangle.
- *
- * note Defined as an inline function for _USE_NEWGAL.
- *
- * sa SetRectEmpty
- */
- static inline void SetRect (RECT* prc, int left, int top, int right, int bottom)
- {
- (prc)->left = left; (prc)->top = top; (prc)->right = right; (prc)->bottom = bottom;
- }
- /**
- * fn void SetRectEmpty (RECT* prc)
- * brief Empties a rectangle.
- *
- * This function empties the rectangle pointed to by a 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.
- *
- * param prc The pointer to the rectangle.
- *
- * note Defined as an inline function for _USE_NEWGAL.
- *
- * sa SetRect
- */
- static inline void SetRectEmpty (RECT* prc)
- {
- (prc)->left = (prc)->top = (prc)->right = (prc)->bottom = 0;
- }
- /**
- * fn void CopyRect (RECT* pdrc, const RECT* psrc)
- * brief Copies one rectangle to another.
- *
- * This function copies the coordinates of the source rectangle
- * pointed to by a psrc to the destination rectangle pointed to by a pdrc.
- *
- * param pdrc The pointer to the destination rectangle.
- * param psrc The pointer to the source rectangle.
- *
- * note Defined as an inline function for _USE_NEWGAL.
- *
- * sa SetRect
- */
- static inline void CopyRect (RECT* pdrc, const RECT* psrc)
- {
- (pdrc)->left = (psrc)->left; (pdrc)->top = (psrc)->top;
- (pdrc)->right = (psrc)->right; (pdrc)->bottom = (psrc)->bottom;
- }
- /**
- * fn void OffsetRect (RECT* prc, int x, int y)
- * brief Moves a rectangle by offsets.
- *
- * This function moves the specified rectangle by the specified offsets.
- * a x and a y specify the amount to move the rectangle left/right or up/down
- * respectively. a x must be a negative value to move the rectangle to
- * the left, and a y must be a negative value to move the rectangle up.
- *
- * param prc The pointer to the rectangle.
- * param x The x offset.
- * param y The y offset.
- *
- * note Defined as an inline function for _USE_NEWGAL.
- *
- * sa InflateRect
- */
- static inline void OffsetRect (RECT* prc, int x, int y)
- {
- (prc)->left += x; (prc)->top += y; (prc)->right += x; (prc)->bottom += y;
- }
- /**
- * fn void InflateRect (RECT* prc, int cx, int cy)
- * brief Increases or decreases the width and height of an rectangle.
- *
- * This function increases or decreases the width and height of
- * the specified rectangle a prc. This function adds a cx units
- * to the left and right ends of the rectangle and a 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.
- *
- * param prc The pointer to the rectangle.
- * param cx The inflating x value.
- * param cy The inflating y value.
- *
- * note Defined as an inline function for _USE_NEWGAL.
- *
- * sa InflateRectToPt
- */
- static inline void InflateRect (RECT* prc, int cx, int cy)
- {
- (prc)->left -= cx; (prc)->top -= cy; (prc)->right += cx; (prc)->bottom += cy;
- }
- /**
- * fn void InflateRectToPt (RECT* prc, int x, int y)
- * brief Inflates a rectangle to contain a point.
- *
- * This function inflates the rectangle a prc to contain the specified point a (x,y).
- *
- * param prc The pointer to the rectangle.
- * param x x,y: The point.
- * param y x,y: The point.
- *
- * note Defined as an inline function for _USE_NEWGAL.
- *
- * sa InflateRect
- */
- static inline void InflateRectToPt (RECT* prc, int x, int y)
- {
- if ((x) < (prc)->left) (prc)->left = (x);
- if ((y) < (prc)->top) (prc)->top = (y);
- if ((x) > (prc)->right) (prc)->right = (x);
- if ((y) > (prc)->bottom) (prc)->bottom = (y);
- }
- /**
- * fn BOOL PtInRect(const RECT* prc, int x, int y)
- * brief Determines whether a point lies within an rectangle.
- *
- * This function determines whether the specified point a (x,y) lies within
- * the specified rectangle a 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.
- *
- * param prc The pointer to the rectangle.
- * param x x,y: The point.
- * param y x,y: The point.
- *
- * note Defined as an inline function for _USE_NEWGAL.
- */
- static inline BOOL PtInRect(const RECT* prc, int x, int y)
- {
- if (x >= prc->left && x < prc->right && y >= prc->top && y < prc->bottom)
- return TRUE;
- return FALSE;
- }
- #else
- void GUIAPI SetRect (RECT* prc, int left, int top, int right, int bottom);
- void GUIAPI SetRectEmpty (RECT* prc);
- void GUIAPI CopyRect (RECT* pdrc, const RECT* psrc);
- void GUIAPI OffsetRect (RECT* prc, int x, int y);
- void GUIAPI InflateRect (RECT* prc, int cx, int cy);
- void GUIAPI InflateRectToPt (RECT* prc, int x, int y);
- BOOL GUIAPI PtInRect (const RECT* prc, int x, int y);
- #endif
- /**
- * fn BOOL GUIAPI IsRectEmpty (const RECT* prc)
- * brief Determines whether an rectangle is empty.
- *
- * This function determines whether the specified rectangle a 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.
- *
- * param prc The pointer to the rectangle.
- * return TRUE for empty, otherwise FALSE.
- */
- BOOL GUIAPI IsRectEmpty (const RECT* prc);
- /**
- * fn BOOL GUIAPI EqualRect (const RECT* prc1, const RECT* prc2)
- * brief Determines whether two rectangles are equal.
- *
- * This function determines whether the two specified rectangles
- * (a prc1 and a prc2) are equal by comparing the coordinates of
- * the upper-left and lower-right corners.
- *
- * param prc1 The pointers to the first rectangles.
- * param prc2 The pointers to the second rectangles.
- * return TRUE for equal, otherwise FALSE.
- */
- BOOL GUIAPI EqualRect (const RECT* prc1, const RECT* prc2);
- /**
- * fn void GUIAPI NormalizeRect (RECT* pRect)
- * brief Normalizes a rectangle.
- *
- * This function normalizes the rectangle pointed to by a prc
- * so that both the height and width are positive.
- *
- * param pRect The pointer to the rectangle.
- */
- void GUIAPI NormalizeRect (RECT* pRect);
- /**
- * fn BOOL GUIAPI IntersectRect (RECT* pdrc, const RECT* psrc1, const RECT* psrc2)
- * brief Calculates the intersection of two rectangles.
- *
- * This function calculates the intersection of two source rectangles (a psrc1 and a psrc2)
- * and places the coordinates of the intersection rectangle into the destination rectangle
- * pointed to by a 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.
- *
- * param pdrc The pointer to the destination rectangle.
- * param psrc1 The first source rectangles.
- * param psrc2 The second source rectangles.
- * return TRUE if the source rectangles intersect, otherwise FALSE.
- *
- * sa DoesIntersect, IsCovered
- */
- BOOL GUIAPI IntersectRect (RECT* pdrc, const RECT* psrc1, const RECT* psrc2);
- /**
- * fn BOOL GUIAPI IsCovered (const RECT* prc1, const RECT* prc2)
- * brief Determines whether one rectangle is covered by another.
- *
- * This function determines whether one rectangle (a prc1)
- * is covered by another rectangle (a prc2).
- *
- * param prc1 The first rectangles.
- * param prc2 The second rectangles.
- * return TRUE if the first rectangle is covered by the second, otherwise FALSE.
- *
- * sa DoesIntersect
- */
- BOOL GUIAPI IsCovered (const RECT* prc1, const RECT* prc2);
- /**
- * fn BOOL GUIAPI DoesIntersect (const RECT* psrc1, const RECT* psrc2)
- * brief Determines whether two rectangles intersect.
- *
- * This function determines whether two rectangles (a psrc1 and a psrc2) intersect.
- *
- * param psrc1 The first source rectangles.
- * param psrc2 The second source rectangles.
- * return TRUE if the source rectangles intersect, otherwise FALSE.
- *
- * sa IntersectRect
- */
- BOOL GUIAPI DoesIntersect (const RECT* psrc1, const RECT* psrc2);
- /**
- * fn BOOL GUIAPI UnionRect (RECT* pdrc, const RECT* psrc1, const RECT* psrc2)
- * brief Unions two source rectangles.
- *
- * This function creates the union (a pdrc) of two rectangles (a psrc1 and a psrc2),
- * if the source rectangles are border upon and not stagger.
- *
- * param pdrc The unioned rectangle.
- * param psrc1 The first source rectangles.
- * param psrc2 The second source rectangles.
- * return TRUE if the source rectangles are border upon and not stagger, otherwise FALSE.
- *
- * sa GetBoundRect
- */
- BOOL GUIAPI UnionRect (RECT* pdrc, const RECT* psrc1, const RECT* psrc2);
- /**
- * fn void GUIAPI GetBoundRect (PRECT pdrc, const RECT* psrc1, const RECT* psrc2)
- * brief Gets the bound rectangle of two source rectangles.
- *
- * This function creates the bound rect (a pdrc) of two rectangles (a psrc1 and a prsrc2).
- * The bound rect is the smallest rectangle that contains both source rectangles.
- *
- * param pdrc The destination rectangle.
- * param psrc1 The first source rectangle.
- * param psrc2 The second source rectangle.
- *
- * sa UnionRect
- */
- void GUIAPI GetBoundRect (PRECT pdrc, const RECT* psrc1, const RECT* psrc2);
- /**
- * fn int GUIAPI SubtractRect (RECT* rc, const RECT* psrc1, const RECT* psrc2)
- * brief Obtains the rectangles when substracting one rectangle from another.
- *
- * This function obtains the rectangles substracting the rectangle a psrc1
- * from the other a psrc2. a rc should be an array of RECT struct, and
- * may contain at most four rectangles. This function returns
- * the number of result rectangles.
- *
- * param rc The pointer to the resule rectangle array.
- * param psrc1 The pointer to the minuend rectangle.
- * param psrc2 The pointer to the subtrahend rectangle.
- * return The number of result rectangles.
- *
- * sa UnionRect
- */
- int GUIAPI SubtractRect (RECT* rc, const RECT* psrc1, const RECT* psrc2);
- /**
- * def RECTWP(prc)
- * brief Gets the width of a RECT object by using the pointer to it.
- */
- #define RECTWP(prc) (prc->right - prc->left)
- /**
- * def RECTHP(prc)
- * brief Gets the height of a RECT object by using the pointer to it.
- */
- #define RECTHP(prc) (prc->bottom - prc->top)
- /**
- * def RECTW(rc)
- * brief Gets the width of a RECT object.
- */
- #define RECTW(rc) (rc.right - rc.left)
- /**
- * def RECTH(rc)
- * brief Gets the height of a RECT object.
- */
- #define RECTH(rc) (rc.bottom - rc.top)
- /** @} end of rect_fns */
- /**
- * defgroup font_fns Logical font operations
- *
- * MiniGUI uses logical font to render text in a DC. You can create a logical
- * font by using a CreateLogFont and select it into a DC by using a SelectFont,
- * then you can use this logical font to render text by using a TextOutLen or a DrawTextEx.
- *
- * @{
- */
- /* Font-related structures */
- #define LEN_FONT_NAME 15
- #define LEN_DEVFONT_NAME 79
- #define LEN_UNIDEVFONT_NAME 127
- #define FONT_WEIGHT_NIL ' '
- #define FONT_WEIGHT_ALL '*'
- #define FONT_WEIGHT_BLACK 'c'
- #define FONT_WEIGHT_BOLD 'b'
- #define FONT_WEIGHT_BOOK 'k'
- #define FONT_WEIGHT_DEMIBOLD 'd'
- #define FONT_WEIGHT_LIGHT 'l'
- #define FONT_WEIGHT_MEDIUM 'm'
- #define FONT_WEIGHT_REGULAR 'r'
- #define FS_WEIGHT_MASK 0x000000FF
- #define FS_WEIGHT_BLACK 0x00000001
- #define FS_WEIGHT_BOLD 0x00000002
- #define FS_WEIGHT_BOOK 0x00000004
- #define FS_WEIGHT_DEMIBOLD 0x00000006 /* BOOK | BOLD */
- #define FS_WEIGHT_LIGHT 0x00000010
- #define FS_WEIGHT_MEDIUM 0x00000020
- #define FS_WEIGHT_REGULAR 0x00000000
- #define FONT_SLANT_NIL ' '
- #define FONT_SLANT_ALL '*'
- #define FONT_SLANT_ITALIC 'i'
- #define FONT_SLANT_OBLIQUE 'o'
- #define FONT_SLANT_ROMAN 'r'
- #define FS_SLANT_MASK 0x00000F00
- #define FS_SLANT_ITALIC 0x00000100
- #define FS_SLANT_OBLIQUE 0x00000200
- #define FS_SLANT_ROMAN 0x00000000
- #define FONT_SETWIDTH_NIL ' '
- #define FONT_SETWIDTH_ALL '*'
- #define FONT_SETWIDTH_BOLD 'b'
- #define FONT_SETWIDTH_CONDENSED 'c'
- #define FONT_SETWIDTH_SEMICONDENSED 's'
- #define FONT_SETWIDTH_NORMAL 'n'
- #define FS_SETWIDTH_MASK 0x0000F000
- #define FS_SETWIDTH_BOLD 0x00001000
- #define FS_SETWIDTH_CONDENSED 0x00002000
- #define FS_SETWIDTH_SEMICONDENSED 0x00004000
- #define FS_SETWIDTH_NORMAL 0x00000000
- #define FONT_SPACING_NIL ' '
- #define FONT_SPACING_ALL '*'
- #define FONT_SPACING_MONOSPACING 'm'
- #define FONT_SPACING_PROPORTIONAL 'p'
- #define FONT_SPACING_CHARCELL 'c'
- #define FS_SPACING_MASK 0x000F0000
- #define FS_SPACING_MONOSPACING 0x00010000
- #define FS_SPACING_PROPORTIONAL 0x00020000
- #define FS_SPACING_CHARCELL 0x00000000
- #define FONT_UNDERLINE_NIL ' '
- #define FONT_UNDERLINE_ALL '*'
- #define FONT_UNDERLINE_LINE 'u'
- #define FONT_UNDERLINE_NONE 'n'
- #define FS_UNDERLINE_MASK 0x00F00000
- #define FS_UNDERLINE_LINE 0x00100000
- #define FS_UNDERLINE_NONE 0x00000000
- #define FONT_STRUCKOUT_NIL ' '
- #define FONT_STRUCKOUT_ALL '*'
- #define FONT_STRUCKOUT_LINE 's'
- #define FONT_STRUCKOUT_NONE 'n'
- #define FS_STRUCKOUT_MASK 0x0F000000
- #define FS_STRUCKOUT_LINE 0x01000000
- #define FS_STRUCKOUT_NONE 0x00000000
- #define FONT_TYPE_NAME_BITMAP_RAW "rbf"
- #define FONT_TYPE_NAME_BITMAP_VAR "vbf"
- #define FONT_TYPE_NAME_BITMAP_QPF "qpf"
- #define FONT_TYPE_NAME_SCALE_TTF "ttf"
- #define FONT_TYPE_NAME_SCALE_T1F "t1f"
- #define FONT_TYPE_NAME_ALL "*"
- #define FONT_TYPE_BITMAP_RAW 0x0001 /* "rbf" */
- #define FONT_TYPE_BITMAP_VAR 0x0002 /* "vbf" */
- #define FONT_TYPE_BITMAP_QPF 0x0003 /* "qpf" */
- #define FONT_TYPE_SCALE_TTF 0x0010 /* "ttf" */
- #define FONT_TYPE_SCALE_T1F 0x0011 /* "t1f" */
- #define FONT_TYPE_ALL 0xFFFF /* "all" */
- #define FONT_CHARSET_US_ASCII "US-ASCII"
- #define FONT_CHARSET_ISO8859_1 "ISO8859-1"
- #define FONT_CHARSET_ISO8859_2 "ISO8859-2"
- #define FONT_CHARSET_ISO8859_3 "ISO8859-3"
- #define FONT_CHARSET_ISO8859_4 "ISO8859-4"
- #define FONT_CHARSET_ISO8859_5 "ISO8859-5"
- #define FONT_CHARSET_ISO8859_6 "ISO8859-6"
- #define FONT_CHARSET_ISO8859_7 "ISO8859-7"
- #define FONT_CHARSET_ISO8859_8 "ISO8859-8"
- #define FONT_CHARSET_ISO8859_9 "ISO8859-9"
- #define FONT_CHARSET_ISO8859_10 "ISO8859-10"
- #define FONT_CHARSET_ISO8859_11 "ISO8859-11"
- #define FONT_CHARSET_ISO8859_12 "ISO8859-12"
- #define FONT_CHARSET_ISO8859_13 "ISO8859-13"
- #define FONT_CHARSET_ISO8859_14 "ISO8859-14"
- #define FONT_CHARSET_ISO8859_15 "ISO8859-15"
- #define FONT_CHARSET_ISO8859_16 "ISO8859-16"
- #define FONT_CHARSET_EUC_CN "EUC-CN"
- #define FONT_CHARSET_GB1988_0 "GB1988-0" /* EUC encoding of GB1988 charset, treat as ISO8859-1 */
- #define FONT_CHARSET_GB2312_0 "GB2312-0" /* EUC encoding of GB2312 charset */
- #define FONT_CHARSET_GBK "GBK"
- #define FONT_CHARSET_GB18030_0 "GB18030-0" /* EUC encoding of GB18030 charset */
- #define FONT_CHARSET_BIG5 "BIG5"
- #define FONT_CHARSET_EUCTW "EUC-TW" /* EUC encoding of CNS11643 charset, not supported */
- #define FONT_CHARSET_EUCKR "EUC-KR"
- #define FONT_CHARSET_KSC5636_0 "KSC5636-0" /* EUC encoding of KSC5636 charset, treat as ISO8859-1 */
- #define FONT_CHARSET_KSC5601_0 "KSC5601-0" /* EUC encoding of KSC5601 charset */
- #define FONT_CHARSET_EUCJP "EUC-JP"
- #define FONT_CHARSET_JISX0201_0 "JISX0201-0" /* EUC encoding of JISX0201 charset */
- #define FONT_CHARSET_JISX0208_0 "JISX0208-0" /* EUC encoding of JISX0208 charset */
- #define FONT_CHARSET_SHIFTJIS "SHIFT-JIS"
- #define FONT_CHARSET_JISX0201_1 "JISX0201-1" /* Shift-JIS encoding of JISX0201 charset */
- #define FONT_CHARSET_JISX0208_1 "JISX0208-1" /* Shift-JIS encoding of JISX0208 charset */
- #define FONT_CHARSET_ISO_10646_1 "ISO-10646-1" /* UCS-2 encoding of UNICODE */
- #define FONT_CHARSET_UTF8 "UTF-8"
- #define FONT_MAX_SIZE 256
- #define FONT_MIN_SIZE 4
- struct _DEVFONT;
- typedef struct _DEVFONT DEVFONT;
- /** The logical font structure. */
- typedef struct _LOGFONT {
- /** The type of the logical font. */
- char type [LEN_FONT_NAME + 1];
- /** The family name of the logical font. */
- char family [LEN_FONT_NAME + 1];
- /** The charset of the logical font. */
- char charset [LEN_FONT_NAME + 1];
- /** The styles of the logical font. */
- DWORD style;
- /** The size of the logical font. */
- int size;
- /** The rotation angle of the logical font. */
- int rotation;
- DEVFONT* sbc_devfont;
- DEVFONT* mbc_devfont;
- } LOGFONT;
- typedef LOGFONT* PLOGFONT;
- struct _WORDINFO;
- typedef struct _WORDINFO WORDINFO;
- #define MAX_LEN_MCHAR 4
- typedef struct _CHARSETOPS
- {
- int nr_chars;
- int bytes_per_char;
- int bytes_maxlen_char;
- const char* name;
- char def_char [MAX_LEN_MCHAR];
- int (*len_first_char) (const unsigned char* mstr, int mstrlen);
- unsigned int (*char_offset) (const unsigned char* mchar);
- int (*nr_chars_in_str) (const unsigned char* mstr, int mstrlen);
- int (*is_this_charset) (const unsigned char* charset);
- int (*len_first_substr) (const unsigned char* mstr, int mstrlen);
- const unsigned char* (*get_next_word) (const unsigned char* mstr,
- int strlen, WORDINFO* word_info);
- int (*pos_first_char) (const unsigned char* mstr, int mstrlen);
- #ifdef _UNICODE_SUPPORT
- unsigned short (*conv_to_uc16) (const unsigned char* mchar, int len);
- #endif /* LITE_VERSION */
- } CHARSETOPS;
- typedef struct _FONTOPS
- {
- int (*get_char_width) (LOGFONT* logfont, DEVFONT* devfont,
- const unsigned char* mchar, int len);
- int (*get_str_width) (LOGFONT* logfont, DEVFONT* devfont,
- const unsigned char* mstr, int n, int cExtra);
- int (*get_ave_width) (LOGFONT* logfont, DEVFONT* devfont);
- int (*get_max_width) (LOGFONT* logfont, DEVFONT* devfont);
- int (*get_font_height) (LOGFONT* logfont, DEVFONT* devfont);
- int (*get_font_size) (LOGFONT* logfont, DEVFONT* devfont, int expect);
- int (*get_font_ascent) (LOGFONT* logfont, DEVFONT* devfont);
- int (*get_font_descent) (LOGFONT* logfont, DEVFONT* devfont);
- /* TODO: int (*get_font_ABC) (LOGFONT* logfont); */
- size_t (*char_bitmap_size) (LOGFONT* logfont, DEVFONT* devfont,
- const unsigned char* mchar, int len);
- size_t (*max_bitmap_size) (LOGFONT* logfont, DEVFONT* devfont);
- const void* (*get_char_bitmap) (LOGFONT* logfont, DEVFONT* devfont,
- const unsigned char* mchar, int len);
- const void* (*get_char_pixmap) (LOGFONT* logfont, DEVFONT* devfont,
- const unsigned char* mchar, int len, int* pitch);
- /* Can be NULL */
- void (*start_str_output) (LOGFONT* logfont, DEVFONT* devfont);
- /* Can be NULL */
- int (*get_char_bbox) (LOGFONT* logfont, DEVFONT* devfont,
- const unsigned char* mchar, int len,
- int* px, int* py, int* pwidth, int* pheight);
- /* Can be NULL */
- void (*get_char_advance) (LOGFONT* logfont, DEVFONT* devfont,
- const unsigned char* mchar, int len, int* px, int* py);
- /* Can be NULL */
- DEVFONT* (*new_instance) (LOGFONT* logfont, DEVFONT* devfont,
- BOOL need_sbc_font);
- /* Can be NULL */
- void (*delete_instance) (DEVFONT* devfont);
- /* Can be NULL */
- } FONTOPS;
- struct _DEVFONT
- {
- char name [LEN_UNIDEVFONT_NAME + 1];
- DWORD style;
- FONTOPS* font_ops;
- CHARSETOPS* charset_ops;
- struct _DEVFONT* sbc_next;
- struct _DEVFONT* mbc_next;
- void* data;
- };
- #define SBC_DEVFONT_INFO(logfont) (logfont.sbc_devfont)
- #define MBC_DEVFONT_INFO(logfont) (logfont.mbc_devfont)
- #define SBC_DEVFONT_INFO_P(logfont) (logfont->sbc_devfont)
- #define MBC_DEVFONT_INFO_P(logfont) (logfont->mbc_devfont)
- #define INV_LOGFONT 0
- /** The font metrics structure. */
- typedef struct _FONTMETRICS
- {
- /** the height of the logical font. */
- int font_height;
- /** the ascent of the logical font. */
- int ascent;
- /** the descent of the logical font. */
- int descent;
- /** the maximal width of the logical font. */
- int max_width;
- /** the average width of the logical font. */
- int ave_width;
- } FONTMETRICS;
- /**
- * fn void GUIAPI GetFontMetrics (LOGFONT* log_font, FONTMETRICS* font_metrics)
- * brief Gets metrics information of a logical font.
- *
- * This function returns the font metrics information of the specified
- * logical font a log_font.
- *
- * param log_font The pointer to the logical font.
- * param font_metrics The buffer receives the metrics information.
- * return None.
- *
- * sa GetGlyphBitmap, FONTMETRICS
- */
- void GUIAPI GetFontMetrics (LOGFONT* log_font, FONTMETRICS* font_metrics);
- /** The glyph bitmap structure. */
- typedef struct _GLYPHBITMAP
- {
- /** The bounding box of the glyph. */
- int bbox_x, bbox_y, bbox_w, bbox_h;
- /** The advance value of the glyph. */
- int advance_x, advance_y;
- /** The size of the glyph bitmap. */
- size_t bmp_size;
- /** The pitch of the glyph bitmap. */
- int bmp_pitch;
- /** The pointer to the buffer of glyph bitmap bits. */
- const unsigned char* bits;
- } GLYPHBITMAP;
- /**
- * fn void GUIAPI GetGlyphBitmap (LOGFONT* log_font, const unsigned char* mchar, int mchar_len, GLYPHBITMAP* glyph_bitmap)
- * brief Gets the glyph bitmap information when uses a logical font to output a character.
- *
- * This function gets the glyph bitmap of one multi-byte character
- * (specified by a mchar and a mchar_len) and returns the bitmap information
- * through a font_bitmap when using a log_font to render the character.
- *
- * param log_font The logical font used to render the character.
- * param mchar The pointer to the multi-byte character.
- * param mchar_len The length of the multi-byte character.
- * param glyph_bitmap The buffer receives the glyph bitmap information.
- * return None.
- *
- * Example:
- * code
- * GLYPHBITMAP glyph_bitmap = {0};
- *
- * GetFontBitmap (log_font, "A", 1, &glyph_bitmap);
- * endcode
- *
- * sa GetFontMetrics, GLYPHBITMAP
- */
- void GUIAPI GetGlyphBitmap (LOGFONT* log_font, const unsigned char* mchar, int mchar_len,
- GLYPHBITMAP* glyph_bitmap);
- #ifdef _LITE_VERSION
- /**
- * fn BOOL GUIAPI InitVectorialFonts (void)
- * brief Initializes vectorial font renderer.
- *
- * This function initializes vectorial font renderer for MiniGUI-Lite application.
- * For the performance reason, MiniGUI-Lite does not load vetorical fonts, such as
- * TrueType or Adobe Type1, at startup. If you want to render text in vectorial fonts,
- * you must call this function to initialize TrueType and Type1 font renderer.
- *
- * return TRUE on success, FALSE on error.
- *
- * note Only defined for _LITE_VERSION. If your MiniGUI configured as MiniGUI-Threads,
- * no need to initialize TrueType and Type1 font renderer explicitly.
- *
- * sa TermVectorialFonts
- */
- BOOL GUIAPI InitVectorialFonts (void);
- /**
- * fn void GUIAPI TermVectorialFonts (void)
- * brief Terminates vectorial font renderer.
- *
- * This function terminates the vectorial font renderer.
- * When you are done with vectorial fonts, you should call this function to
- * unload the vectorial fonts to save memory.
- *
- * note Only defined for _LITE_VERSION.
- *
- * sa InitVectorialFonts
- */
- void GUIAPI TermVectorialFonts (void);
- #endif
- /**
- * fn PLOGFONT GUIAPI CreateLogFont (const char* type, const char* family, const char* charset, char weight, char slant, char set_width, char spacing, char underline, char struckout, int size, int rotation)
- * brief Creates a logical font.
- *
- * This function creates a logical font.
- *
- * param type The type of the logical font, can be one of the values:
- * - FONT_TYPE_NAME_BITMAP_RAWn
- * Creates a logical font by using raw bitmap device font, i.e. mono-space bitmap font.
- * - FONT_TYPE_NAME_BITMAP_VARn
- * Creates a logical font by using var-width bitmap device font.
- * - FONT_TYPE_NAME_SCALE_TTFn
- * Creates a logical font by using scalable TrueType device font.
- * - FONT_TYPE_NAME_SCALE_T1Fn
- * Creates a logical font by using scalable Adobe Type1 device font.
- * - FONT_TYPE_NAME_ALLn
- * Creates a logical font by using any type device font.
- * param family The family of the logical font, such as "Courier", "Helvetica", and so on.
- * param charset The charset of the logical font. You can specify a sigle-byte charset
- * like "ISO8859-1", or a multi-byte charset like "GB2312.1980-0".
- * param weight The weight of the logical font, can be one of the values:
- * - FONT_WEIGHT_ALLn
- * Any one.
- * - FONT_WEIGHT_REGULARn
- * Regular font.
- * - FONT_WEIGHT_BOLDn
- * Bold font.
- * param slant The slant of the logical font, can be one of the values:
- * - FONT_SLANT_ALLn
- * Any one.
- * - FONT_SLANT_ROMANn
- * Regular font.
- * - FONT_SLANT_ITALICn
- * Italic font.
- * param set_width Not used so far.
- * param spacing Not used so far.
- * param underline The underline of the logical font, can be one of the values:
- * - FONT_UNDERLINE_ALLn
- * Any one.
- * - FONT_UNDERLINE_LINEn
- * With underline.
- * - FONT_UNDERLINE_NONEn
- * Without underline.
- * param struckout The struckout line of the logical font, can be one of the values:
- * - FONT_STRUCKOUT_ALLn
- * Any one.
- * - FONT_STRUCKOUT_LINEn
- * With struckout line.
- * - FONT_STRUCKOUT_NONEn
- * Without struckout line.
- * param size The size, i.e. the height, of the logical font. Note that the size of
- * the created logical font may be different from the size expected.
- * param rotation The rotation of the logical font, it is in units of tenth degrees.
- * Note that you can specify rotation only for TrueType and Adobe Type1 fonts.
- * return The pointer to the logical font created, NULL on error.
- *
- * sa CreateLogFontIndirect, SelectFont
- *
- * Example:
- *
- * include createlogfont.c
- *
- */
- PLOGFONT GUIAPI CreateLogFont (const char* type, const char* family,
- const char* charset, char weight, char slant, char set_width,
- char spacing, char underline, char struckout,
- int size, int rotation);
- /**
- * fn PLOGFONT GUIAPI CreateLogFontByName (const char* font_name)
- * brief Creates a logical font by a font name.
- *
- * This function creates a logical font by a font name specified by a font_name.
- *
- * param font_name The name of the font.
- * return The pointer to the logical font created, NULL on error.
- *
- * sa CreateLogFont, SelectFont
- */
- PLOGFONT GUIAPI CreateLogFontByName (const char* font_name);
- /**
- * fn PLOGFONT GUIAPI CreateLogFontIndirect (LOGFONT* logfont)
- * brief Creates a logical font indirectly from a LOGFONT structure.
- *
- * This function creates a logical font from information in a LOGFONT object.
- *
- * param logfont The pointer to the reference logical font structure.
- * return The pointer to the logical font created, NULL on error.
- *
- * sa CreateLogFont, SelectFont
- */
- PLOGFONT GUIAPI CreateLogFontIndirect (LOGFONT* logfont);
- /**
- * fn void GUIAPI DestroyLogFont (PLOGFONT log_font)
- * brief Destroies a logical font.
- *
- * This function destroies the specified logical font a log_font.
- *
- * param log_font The logical font will be destroied.
- *
- * sa CreateLogFont, CreateLogFontIndirect
- */
- void GUIAPI DestroyLogFont (PLOGFONT log_font);
- /**
- * fn void GUIAPI GetLogFontInfo (HDC hdc, LOGFONT* log_font)
- * brief Gets logical font information of a DC.
- *
- * This function gets the logical font information of the specified DC a hdc,
- * and copies to the LOGFONT structure pointed to by a log_font.
- *
- * param hdc The device context.
- * param log_font The pointer to the LOGFONT structure to save the logical font info.
- *
- * sa GetCurFont
- */
- void GUIAPI GetLogFontInfo (HDC hdc, LOGFONT* log_font);
- /**
- * fn PLOGFONT GUIAPI GetCurFont (HDC hdc)
- * brief Gets the pointer to the current logical font of a DC.
- *
- * This function returns the pointer to the current logical font selected to the DC a hdc.
- *
- * param hdc The device context.
- * return The pointer to the current logical font.
- *
- * sa GetLogFontInfo, SelectFont
- */
- PLOGFONT GUIAPI GetCurFont (HDC hdc);
- /**
- * fn PLOGFONT GUIAPI SelectFont (HDC hdc, PLOGFONT log_font)
- * brief Selects a logical font into a DC.
- *
- * This function selects the specified logical font a log_font into the device context a hdc.
- *
- * param hdc The device context.
- * param log_font The pointer to the logical font to be selected into the DC.
- * return The old logical font of the DC.
- *
- * sa GetCurFont
- *
- * Example:
- *
- * include drawtext.c
- *
- */
- PLOGFONT GUIAPI SelectFont (HDC hdc, PLOGFONT log_font);
- /**
- * fn const DEVFONT* GUIAPI GetNextDevFont (const DEVFONT* dev_font)
- * brief Get next devfont information.
- *
- * This function can be used to enumerate all device fonts loaded by MiniGUI.
- *
- * param dev_font The pointer to the current device font, can be NULL to get
- * the first device font.
- * return The next device font.
- */
- const DEVFONT* GUIAPI GetNextDevFont (const DEVFONT* dev_font);
- /** @} end of font_fns */
- /**
- * defgroup system_font System charset and font operations
- *
- * MiniGUI creates a few system fonts to draw menu text, window caption, or
- * other general items. MiniGUI at least creates two system fonts: one mono-space
- * logical font for single-byte charset, and one mono-space logical font for
- * multi-byte charset. For the multi-byte charset,
- * the width of one multi-byte character should be equal to the width of
- * two single-byte characters.
- *
- * @{
- */
- #define SYSLOGFONT_DEFAULT 0
- #define SYSLOGFONT_WCHAR_DEF 1
- #define SYSLOGFONT_FIXED 2
- #define SYSLOGFONT_CAPTION 3
- #define SYSLOGFONT_MENU 4
- #define SYSLOGFONT_CONTROL 5
- #define NR_SYSLOGFONTS 6
- extern PLOGFONT g_SysLogFont [];
- /**
- * fn PLOGFONT GUIAPI GetSystemFont (int font_id)
- * brief Gets the system logical font through an font identifier.
- *
- * This function returns the system logical font through the font identifier a font_id.
- *
- * param font_id The identifier of a system font, can be one of the following values:
- * - SYSLOGFONT_DEFAULTn
- * The default system logical font in single-byte charset, must be rbf.
- * - SYSLOGFONT_WCHAR_DEFn
- * The default system logical font in multi-byte charset, must be rbf.
- * - SYSLOGFONT_FIXEDn
- * The fixed space system logical font.
- * - SYSLOGFONT_CAPTIONn
- * The system logical font used to draw caption text.
- * - SYSLOGFONT_MENUn
- * The system logical font used to draw menu items.
- * - SYSLOGFONT_CONTROLn
- * The system logical font used to draw controls.
- * return The pointer to the system logical font. NULL on error.
- */
- static inline PLOGFONT GUIAPI GetSystemFont (int font_id)
- {
- if (font_id >= 0 && font_id < NR_SYSLOGFONTS)
- return g_SysLogFont [font_id];
- else
- return (PLOGFONT)NULL;
- }
- /**
- * fn int GUIAPI GetSysFontMaxWidth (int font_id)
- * brief Gets the maximal width of a single-byte character of a system font.
- *
- * This function returns the maximal width of a single-byte character of one system font.
- *
- * param font_id The identifier of a system font.
- * return The maximal width of single-byte character of the default system font.
- *
- * sa GetSystemFont
- */
- int GUIAPI GetSysFontMaxWidth (int font_id);
- /**
- * fn int GUIAPI GetSysFontAveWidth (int font_id)
- * brief Gets the average width of a single-byte character of a system font.
- *
- * This function returns the average width of a single-byte character of one system font.
- *
- * param font_id The identifier of a system font.
- * return The average width of single-byte character of the default system font.
- *
- * sa GetSystemFont
- */
- int GUIAPI GetSysFontAveWidth (int font_id);
- /**
- * fn int GUIAPI GetSysFontHeight (int font_id)
- * brief Gets the height of a single-byte character of a system font.
- *
- * This function returns the height of a single-byte character of one system font.
- *
- * param font_id The identifier of a system font.
- * return The height of single-byte character of the default system font.
- *
- * sa GetSystemFont
- */
- int GUIAPI GetSysFontHeight (int font_id);
- /**
- * fn const char* GUIAPI GetSysCharset (BOOL wchar)
- * brief Gets the current system charset.
- *
- * This function gets the current system charset and returns the charset name.
- * By default, the system charset is ISO8859-1 (for single-byte charset) or
- * GB2312.1980-0 (for wide charset), but you can change it by modifying a MiniGUI.cfg.
- *
- * param wchar Whether to retrive the wide charset supported currently.
- * return The read-only buffer of charset name. If you pass a wchar TRUE,
- * This function may return NULL, if there is not any wide charset supported.
- */
- const char* GUIAPI GetSysCharset (BOOL wchar);
- /**
- * fn int GUIAPI GetSysCharHeight (void)
- * brief Gets the height of a character of the default system font.
- *
- * This function returns the height of a character of
- * the system default font. MiniGUI uses mono-space font as the default system font.
- *
- * Normally, the width of one multi-byte character is equal to
- * the width of two single-byte character when using the default system font.
- *
- * return The character height of the default system font.
- *
- * sa GetSysCharWidth, GetSysCCharWidth
- */
- int GUIAPI GetSysCharHeight (void);
- /**
- * fn int GUIAPI GetSysCharWidth (void)
- * brief Gets the width of a single-byte character of the default system font.
- *
- * This function returns the width of a single-byte character of the default system font.
- * MiniGUI uses mono-space font as the default system font, but you can specify a
- * different font to output text in windows of MiniGUI.
- *
- * return The width of single-byte character of the default system font.
- *
- * sa GetSysCharHeight, GetSysCCharWidth, SelectFont, CreateLogFont
- */
- int GUIAPI GetSysCharWidth (void);
- /**
- * fn int GUIAPI GetSysCCharWidth (void)
- * brief Gets the width of a multi-byte character of the default system font.
- *
- * This function returns the width of a multi-byte character of
- * the default system font. MiniGUI uses mono-space font as the system default font.
- *
- * return The width of multi-byte character of the default system font.
- *
- * sa GetSysCharHeight, GetSysCharWidth
- */
- int GUIAPI GetSysCCharWidth (void);
- #if 0
- /**
- * fn void GUIAPI GetSysTabbedTextExtent (const char* spText, SIZE* pSize)
- * brief Gets the output extent of a formatted string when using the system font.
- *
- * This function gets the output extent of the formatted string pointed to by a spText
- * when using the system font, nnd returns the extent in SIZE struct pointed to by a pSize.
- *
- * param spText The pointer to the formatted string.
- * param pSize The output extent will be returned through this buffer.
- *
- * note Obsolete
- *
- * sa GetSysCharWidth, GetSysCharHeight
- */
- void GUIAPI GetSysTabbedTextExtent (const char* spText, SIZE* pSize);
- /**
- * fn BOOL GUIAPI DoesSupportCharset (const char* charset)
- * brief Determines whether MiniGUI supports a system charset.
- *
- * This function determines whether MiniGUI
- * supports the specified system charset a charset.
- *
- * param charset The name of the charset.
- * return TRUE for supported charset, otherwise FALSE.
- *
- * note Obsolete
- *
- * sa GetSysCharset
- */
- BOOL GUIAPI DoesSupportCharset (const char* charset);
- /**
- * fn BOOL GUIAPI SetSysCharset (const char* charset)
- * brief Sets a charset to be the system charset.
- *
- * This function sets the specified charset a charset to be the system charset.
- *
- * param charset The name of the charset.
- * return 0 on success, -1 on error.
- *
- * note Obsolete
- *
- * sa GetSysCharset
- */
- BOOL GUIAPI SetSysCharset (const char* charset);
- #endif
- /** @} end of system_font */
- /**
- * defgroup text_parse_fns Text parsing functions
- *
- * MiniGUI uses logical font to output text, also uses
- * logical font to parsing the multi-byte characters and
- * words in the text.
- *
- * @{
- */
- /** Word information structure */
- struct _WORDINFO
- {
- /** the length of the word. */
- int len;
- /** the delimiter after the word. */
- unsigned char delimiter;
- /** the number of delimiters after the word. */
- int nr_delimiters;
- };
- /**
- * fn int GUIAPI GetTextMCharInfo (PLOGFONT log_font, const char* mstr, int len, int* pos_chars)
- * brief Retrives positions of multi-byte characters in a string.
- *
- * This function retrives position of multi-byte characters in
- * the string a mstr which is len bytes long. It returns the positions
- * of characters in the string in an integer array pointed to by a pos_chars.
- *
- * param log_font The logical font used to parse the multi-byte string.
- * param mstr The multi-byte string.
- * param len The length of the string.
- * param pos_chars The position of characters will be returned through this array if it is not NULL.
- * return The number of characters in the multi-byte string.
- *
- * sa GetTextWordInfo
- */
- int GUIAPI GetTextMCharInfo (PLOGFONT log_font, const char* mstr, int len,
- int* pos_chars);
- /**
- * fn int GUIAPI GetTextWordInfo (PLOGFONT log_font, const char* mstr, int len, int* pos_words, WORDINFO* info_words)
- * brief Retrives information of multi-byte words in a string.
- *
- * This function retrives information of multi-byte words in the string a mstr which is
- * a len bytes long. It returns the positions of words in the string in an integer
- * array pointed to by a pos_words if the pointer is not NULL. This function also
- * returns the information of words in a WORDINFO struct array pointed to by a info_words
- * when the pointer is not NULL.
- *
- * param log_font The logical font used to parse the multi-byte string.
- * param mstr The multi-byte string.
- * param len The length of the string.
- * param pos_words The position of words will be returned through this array if it is not NULL.
- * param info_words The words' information will be returned through this array if it is not NULL.
- * return The number of words in the multi-byte string.
- *
- * sa GetTextMCharInfo, WORDINFO
- */
- int GUIAPI GetTextWordInfo (PLOGFONT log_font, const char* mstr, int len,
- int* pos_words, WORDINFO* info_words);
- /**
- * fn int GUIAPI GetFirstMCharLen (PLOGFONT log_font, const char* mstr, int len)
- * brief Retrives the length of the first multi-byte character in a string.
- *
- * This function retrives and returns the length of the first multi-byte
- * character in the string a mstr which is a len bytes long.
- *
- * param log_font The logical font used to parse the multi-byte string.
- * param mstr The multi-byte string.
- * param len The length of the string.
- * return The length of the first multi-byte character.
- *
- * sa GetFirstWord
- */
- int GUIAPI GetFirstMCharLen (PLOGFONT log_font, const char* mstr, int len);
- /**
- * fn int GUIAPI GetFirstWord (PLOGFONT log_font, const char* mstr, int len, WORDINFO* word_info)
- * brief Retrives the length and info of the first multi-byte word in a string.
- *
- * This function retrives the information of the first multi-byte character in the string a mstr
- * which is a len bytes long, and returns it through a word_info.
- * It also returns the full length of the word including the delimiters after the word.
- *
- * param log_font The logical font used to parse the multi-byte string.
- * param mstr The multi-byte string.
- * param len The length of the string.
- * param word_info The pointer to a WORDINFO structure used to return the word information.
- * return The length of the first multi-byte word.
- *
- * sa GetFirstMCharLen, WORDINFO
- */
- int GUIAPI GetFirstWord (PLOGFONT log_font, const char* mstr, int len,
- WORDINFO* word_info);
- /**
- * fn int GUIAPI GetTextExtentPoint (HDC hdc, const char* text, int len, int max_extent, int* fit_chars, int* pos_chars, int* dx_chars, SIZE* size)
- * brief Computes the extent of a string when output the string in a limited space.
- *
- * This function computes the extent of the specified string of text a text which is
- * a len bytes long when output the text in a limited space (a max_extent wide).
- * If a pos_chars and a dx_chars are not NULL, this function will return the
- * positions of each character in the text, and the output position of each character.
- * This function returns the text extent in a SIZE struct pointed to by a size, and
- * the width of text as return value.
- *
- * param hdc The device context.
- * param text The multi-byte string.
- * param len The length of the string.
- * param max_extent The width of the limited space.
- * param fit_chars The number of the characters actually outputed.
- * param pos_chars The positions of each character in the text will be returned through this pointer.
- * param dx_chars The output positions of each character in the text will be returned through this pointer.
- * param size The output extent of the text in the limited space will be returned through this pointer.
- *
- * return The number of the characters which can be fit to the limited space.
- *
- * sa GetFirstMCharLen, GetFirstWord
- */
- int GUIAPI GetTextExtentPoint (HDC hdc, const char* text, int len, int max_extent,
- int* fit_chars, int* pos_chars, int* dx_chars, SIZE* size);
- /**
- * fn int GUIAPI GetTabbedTextExtentPoint (HDC hdc, const char* text, int len, int max_extent, int* fit_chars, int* pos_chars, int* dx_chars, SIZE* size)
- *
- * brief Computes the extent of a string when output the formatted string in a limited space.
- */
- int GUIAPI GetTabbedTextExtentPoint (HDC hdc, const char* text, int len, int max_extent,
- int* fit_chars, int* pos_chars, int* dx_chars, SIZE* size);
- /** @} end of text_parse_fns */
- /**
- * defgroup text_output_fns Text output functions
- * @{
- */
- /**
- * fn int GUIAPI GetFontHeight (HDC hdc)
- * brief Retrives the height of the current logical font in a DC.
- *
- * This function retrives the height of the current logical font in the DC a hdc.
- *
- * param hdc The device context.
- * return The height of the current logical font.
- *
- * sa GetMaxFontWidth
- */
- int GUIAPI GetFontHeight (HDC hdc);
- /**
- * fn int GUIAPI GetMaxFontWidth (HDC hdc)
- * brief Retrives the maximal character width of the current logical font in a DC.
- *
- * This function retrives the maximal character width of the current logical font
- * in the DC a hdc.
- *
- * param hdc The device context.
- * return The maximal character width of the current logical font.
- *
- * sa GetFontHeight
- */
- int GUIAPI GetMaxFontWidth (HDC hdc);
- /**
- * fn void GUIAPI GetTextExtent (HDC hdc, const char* spText, int len, SIZE* pSize)
- * brief Computes the output extent of a string of text.
- *
- * This function computes the output extent of the text (a spText) with length of a len.
- * This function returns the extent in a SIZE struct pointed to by a pSize and the width
- * of text as the return value.
- *
- * param hdc The device context.
- * param spText The pointer to the string of text.
- * param len The length of the text.
- * param pSize The output extent will be returned through this buffer.
- *
- * sa GetTabbedTextExtent
- */
- void GUIAPI GetTextExtent (HDC hdc, const char* spText, int len, SIZE* pSize);
- /**
- * fn void GUIAPI GetTabbedTextExtent (HDC hdc, const char* spText, int len, SIZE* pSize)
- * brief Computes the output extent of a formatted text.
- *
- * This function computes the output extent of the formatted text (a spText) with length of a len.
- * This function returns the extent in a SIZE struct pointed to by a pSize and the width of text as
- * the return value. The output extent will be affected by the default tab size if there are some
- * TAB characters in the text.
- *
- * param hdc The device context.
- * param spText The pointer to the string of text.
- * param len The length of the text.
- * param pSize The output extent will be returned through this buffer.
- *
- * sa GetTextExtent
- */
- void GUIAPI GetTabbedTextExtent (HDC hdc, const char* spText, int len, SIZE* pSize);
- #ifdef _USE_NEWGAL
- /**
- * def GetTextCharacterExtra(hdc)
- * brief Retrives the current intercharacter spacing for the DC.
- *
- * note Defined as a macro calling a GetDCAttr for _USE_NEWGAL.
- * If _USE_NEWGAL is not defined, a GetTextCharacterExtra is defined as
- * a function, and have the same semantics as this macro.
- *
- * sa SetTextCharacterExtra
- */
- #define GetTextCharacterExtra(hdc) (int)GetDCAttr (hdc, DC_ATTR_CHAR_EXTRA)
- /**
- * def GetTextAboveLineExtra(hdc)
- * brief Retrives the current spacing above line for the DC.
- *
- * note Defined as a macro calling a GetDCAttr for _USE_NEWGAL.
- * If _USE_NEWGAL is not defined, a GetTextAboveLineExtra is defined as
- * a function, and have the same semantics as this macro.
- *
- * sa SetTextAboveLineExtra
- */
- #define GetTextAboveLineExtra(hdc) (int)GetDCAttr (hdc, DC_ATTR_ALINE_EXTRA)
- /**
- * def GetTextBellowLineExtra(hdc)
- * brief Retrives the current spacing bellow line for the DC.
- *
- * note Defined as a macro calling a GetDCAttr for _USE_NEWGAL.
- * If _USE_NEWGAL is not defined, a GetTextBellowLineExtra is defined as
- * a function, and have the same semantics as this macro.
- *
- * sa SetTextBellowLineExtra
- */
- #define GetTextBellowLineExtra(hdc) (int)GetDCAttr (hdc, DC_ATTR_BLINE_EXTRA)
- /**
- * def SetTextCharacterExtra(hdc, extra)
- * brief Sets the intercharacter spacing for the DC and returns the old spacing value.
- *
- * note Defined as a macro calling a SetDCAttr for _USE_NEWGAL.
- * If _USE_NEWGAL is not defined, a SetTextCharacterExtra is defined as
- * a function, and have the same semantics as this macro.
- *
- * sa GetTextCharacterExtra
- */
- #define SetTextCharacterExtra(hdc, extra) (int)SetDCAttr (hdc, DC_ATTR_CHAR_EXTRA, (DWORD) extra)
- /**
- * def SetTextAboveLineExtra(hdc, extra)
- * brief Sets the spacing above line for the DC and returns the old value.
- *
- * note Defined as a macro calling a SetDCAttr for _USE_NEWGAL.
- * If _USE_NEWGAL is not defined, a SetTextAboveLineExtra is defined as
- * a function, and have the same semantics as this macro.
- *
- * sa GetTextAboveLineExtra
- */
- #define SetTextAboveLineExtra(hdc, extra) (int)SetDCAttr (hdc, DC_ATTR_ALINE_EXTRA, (DWORD) extra)
- /**
- * def SetTextBellowLineExtra(hdc, extra)
- * brief Sets the spacing bellow line for the DC and returns the old value.
- *
- * note Defined as a macro calling a SetDCAttr for _USE_NEWGAL.
- * If _USE_NEWGAL is not defined, a SetTextBellowLineExtra is defined as
- * a function, and have the same semantics as this macro.
- *
- * sa GetTextBellowLineExtra
- */
- #define SetTextBellowLineExtra(hdc, extra) (int)SetDCAttr (hdc, DC_ATTR_BLINE_EXTRA, (DWORD) extra)
- #else
- int GUIAPI GetTextCharacterExtra (HDC hdc);
- int GUIAPI SetTextCharacterExtra (HDC hdc, int extra);
- int GUIAPI GetTextAboveLineExtra (HDC hdc);
- int GUIAPI SetTextAboveLineExtra (HDC hdc, int extra);
- int GUIAPI GetTextBellowLineExtra (HDC hdc);
- int GUIAPI SetTextBellowLineExtra (HDC hdc, int extra);
- #endif /* _USE_NEWGAL */
- /**
- * fn int GUIAPI TextOutLen (HDC hdc, int x, int y, const char* spText, int len)
- * brief Outputs a string of text.
- *
- * This function outputs the text a spText with length of a len at a (x,y).
- * This function returns the width of text.
- *
- * param hdc The device context.
- * param x x,y: The output start position.
- * param y x,y: The output start position.
- * param spText The string of the text.
- * param len The length of the text. If it is less than 0, MiniGUI will treat it as
- * a null-terminated string.
- * return The output width of the text.
- *
- * sa TabbedTextOutLen
- */
- int GUIAPI TextOutLen (HDC hdc, int x, int y, const char* spText, int len);
- /**
- * fn int GUIAPI TabbedTextOutLen (HDC hdc, int x, int y, const char* spText, int len)
- * brief Outputs a formatted text.
- *
- * This function outputs the formatted text a spText with length of a len at a (x,y).
- * This function returns the width of text. The output will be affected by
- * the default tab size if there are some TAB characters in the text.
- *
- * param hdc The device context.
- * param x x,y: The output start position.
- * param y x,y: The output start position.
- * param spText The formatted text.
- * param len The length of the text. If it is less than 0, MiniGUI will treat it as
- * a null-terminated string.
- * return The output width of the text.
- *
- * sa TextOutLen
- */
- int GUIAPI TabbedTextOutLen (HDC hdc, int x, int y, const char* spText, int len);
- /**
- * fn int GUIAPI TabbedTextOutEx (HDC hdc, int x, int y, const char* spText, int nCount, int nTabPositions, int *pTabPositions, int nTabOrigin)
- * brief Writes a character string at a specified location, expanding tabs to the values
- * specified in an anrry of tab-stop positions.
- *
- * This function writes the string a spText with length of a nCount at a specified locations,
- * expanding tabs to the value spcified in the array a pTabPositions of tab-stop positions.
- *
- * param hdc The device context.
- * param x x,y: The output start position.
- * param y x,y: The output start position.
- * param spText The formatted text.
- * param nCount The length of the text. If it is less than 0, MiniGUI will treat it as
- * a null-terminated string.
- * param nTabPositions The length of the array of the tab-stop positions.
- * param pTabPositions The array of the tab-stop positions.
- * param nTabOrigin The origin of the tab-stops.
- * return The output width of the text.
- *
- * sa TabbedTextOutLen
- */
- int GUIAPI TabbedTextOutEx (HDC hdc, int x, int y, const char* spText, int nCount,
- int nTabPositions, int *pTabPositions, int nTabOrigin);
- /**
- * fn void GUIAPI GetLastTextOutPos (HDC hdc, POINT* pt)
- * brief Retrives the last text output position.
- *
- * param hdc The device context.
- * param pt The last text output position will be returned through this pointer.
- *
- */
- void GUIAPI GetLastTextOutPos (HDC hdc, POINT* pt);
- /**
- * def TextOut(hdc, x, y, text)
- * brief Outputs text.
- *
- * Defined as a macro calling a TextOutLen passing a len as -1.
- *
- * sa TextOutLen
- */
- #define TextOut(hdc, x, y, text) TextOutLen (hdc, x, y, text, -1)
- /**
- * def TabbedTextOut(hdc, x, y, text)
- * brief Outputs formatted text.
- *
- * Defined as a macro calling a TabbedTextOutLen passing a len as -1.
- *
- * sa TextOutLen
- */
- #define TabbedTextOut(hdc, x, y, text) TabbedTextOutLen (hdc, x, y, text, -1)
- #define DT_TOP 0x00000000
- #define DT_LEFT 0x00000000
- #define DT_CENTER 0x00000001
- #define DT_RIGHT 0x00000002
- #define DT_VCENTER 0x00000004
- #define DT_BOTTOM 0x00000008
- #define DT_WORDBREAK 0x00000010
- #define DT_SINGLELINE 0x00000020
- #define DT_EXPANDTABS 0x00000040
- #define DT_TABSTOP 0x00000080
- #define DT_NOCLIP 0x00000100
- #define DT_EXTERNALLPADING 0x00000200
- #define DT_CALCRECT 0x00000400
- #define DT_NOPREFIX 0x00000800
- #define DT_INTERNAL 0x00001000
- /**
- * First line information of DrawTextEx2
- */
- typedef struct _DTFIRSTLINE
- {
- /** The number of the characters of first line in bytes. */
- int nr_chars;
- /** The output x-coordinate of the fist line. */
- int startx;
- /** The output y-coordinate of the fist line. */
- int starty;
- /** The output width of the fist line. */
- int width;
- /** The output height of the fist line. */
- int height;
- } DTFIRSTLINE;
- /**
- * fn int GUIAPI DrawTextEx2 (HDC hdc, const char* pText, int nCount, RECT* pRect, int nIndent, UINT nFormat, DTFIRSTLINE* firstline)
- * brief Draws a formatted text in a rectangle.
- *
- * This function draws formatted text (a pText) in the specified rectangle (a pRect).
- * It formats the text according to the specified method (through a nFormat,
- * including expanding tabs, justifying characters, breaking lines, and so forth).
- *
- * param hdc The device context.
- * param pText The formatted text.
- * param nCount The length of the text. If it is less than 0, MiniGUI will treat it as
- * a null-terminated string.
- * param pRect The output rectangle.
- * param nIndent The indent value of the first line.
- * param nFormat The methods used to format the text. MiniGUI support
- * the following method to format text so far:
- *
- * - DT_TOPn
- * Top-justifies text (single line only).
- * - DT_LEFTn
- * Aligns text to the left.
- * - DT_CENTERn
- * Centers text horizontally in the rectangle.
- * - DT_RIGHTn
- * Aligns text to the right.
- * - DT_VCENTERn
- * Centers text vertically (single line only).
- * - DT_BOTTOMn
- * Justify the text to the bottom of the rectangle. This value must be combined with DT_SINGLELINE.
- * - DT_WORDBREAKn
- * Break words. Lines are automatically broken beteween words if a word would extend past
- * the edge of the rectangle specified by the the pRect parameter.
- * A carriage return or linefeed also breaks the line.
- * - DT_SINGLELINEn
- * Display text ont the single line only. Carriage returns and linefeeds do not break the line.
- * - DT_EXPANDTABSn
- * Expands tab characters. The default number of character per tab is eight.
- * - DT_TABSTOPn
- * Set tab stops. Bits 15-8 (hight-order byte of the low-order word) of the a uForma parameter specify
- * the number of characters for each tab. The default number of characters per tab is eight.
- * - DT_NOCLIPn
- * Draws without clipping. a DrawText is somewhat faster when DT_NOCLIP is used.
- * - DT_CALCRECTn
- * Determines the width and the height of the rectangle. If there are multiple lines of text,
- * a DrawText uses the width of the rectangle pointed to by the a lpRect parameter and extends
- * the base of the rectangle to bound the last line of text. If there is only one line of text,
- * a DrawText modifies the right side of the rectangle so that it bounds
- * the last character in the line. In either case, a DrawText returns the height of
- * the formatted text but does not draw the text.
- *
- * param firstline If not null, DrawTextEx2 will only calculate the first line will be output in the
- * rectangle, and return the number of the characters and the output width.
- *
- * return The output height of the formatted text.
- *
- * sa DrawText
- *
- * Example:
- *
- * include drawtext.c
- */
- int GUIAPI DrawTextEx2 (HDC hdc, const char* pText, int nCount,
- RECT* pRect, int nIndent, UINT nFormat, DTFIRSTLINE *firstline);
- /**
- * def DrawText(hdc, text, n, rc, format)
- * brief Draws a formatted text in a rectangle.
- *
- * Defined as a macro calling a DrawTextEx2 passing a nIndent as 0 and a firstline as NULL.
- *
- * sa DrawTextEx2
- */
- #define DrawText(hdc, text, n, rc, format) DrawTextEx2 (hdc, text, n, rc, 0, format, NULL)
- /**
- * def DrawTextEx(hdc, text, n, rc, indent, format)
- * brief Draws a formatted text in a rectangle.
- *
- * Defined as a macro calling a DrawTextEx2 passing a firstline as NULL.
- *
- * sa DrawTextEx2
- */
- #define DrawTextEx(hdc, text, n, rc, indent, format) DrawTextEx2 (hdc, text, n, rc, indent, format, NULL)
- /** @} end of text_output_fns */
- /**
- * defgroup bmp_struct Bitmap structure
- *
- * MiniGUI uses a MYBITMAP structure to represent a device-independent bitmap,
- * and BITMAP structure to represent a device-dependent bitmap.
- *
- * Note that if _USE_NEWGAL is not defined, the BITMAP structure
- * has a different definition:
- *
- * code
- * struct _BITMAP
- * {
- * Uint8 bmType;
- * Uint8 bmBitsPerPixel;
- * Uint8 bmBytesPerPixel;
- * Uint8 bmReserved;
- *
- * Uint32 bmColorKey;
- *
- * Uint32 bmWidth;
- * Uint32 bmHeight;
- * Uint32 bmPitch;
- *
- * void* bmBits;
- * Uint32 bmReserved1;
- * };
- * endcode
- *
- * @{
- */
- #define MYBMP_TYPE_NORMAL 0x00000000
- #define MYBMP_TYPE_RLE4 0x00000001
- #define MYBMP_TYPE_RLE8 0x00000002
- #define MYBMP_TYPE_RGB 0x00000003
- #define MYBMP_TYPE_BGR 0x00000004
- #define MYBMP_TYPE_RGBA 0x00000005
- #define MYBMP_TYPE_MASK 0x0000000F
- #define MYBMP_FLOW_DOWN 0x00000010
- #define MYBMP_FLOW_UP 0x00000020
- #define MYBMP_FLOW_MASK 0x000000F0
- #define MYBMP_TRANSPARENT 0x00000100
- #define MYBMP_ALPHACHANNEL 0x00000200
- #define MYBMP_ALPHA 0x00000400
- #define MYBMP_RGBSIZE_3 0x00001000
- #define MYBMP_RGBSIZE_4 0x00002000
- #define MYBMP_LOAD_GRAYSCALE 0x00010000
- #define MYBMP_LOAD_NONE 0x00000000
- /** Device-independent bitmap structure. */
- struct _MYBITMAP
- {
- /**
- * Flags of the bitmap, can be OR'ed by the following values:
- * - MYBMP_TYPE_NORMALn
- * A normal palette bitmap.
- * - MYBMP_TYPE_RGBn
- * A RGB bitmap.
- * - MYBMP_TYPE_BGRn
- * A BGR bitmap.
- * - MYBMP_TYPE_RGBAn
- * A RGBA bitmap.
- * - MYBMP_FLOW_DOWNn
- * The scanline flows from top to bottom.
- * - MYBMP_FLOW_UPn
- * The scanline flows from bottom to top.
- * - MYBMP_TRANSPARENTn
- * Have a trasparent value.
- * - MYBMP_ALPHACHANNELn
- * Have a alpha channel.
- * - MYBMP_ALPHAn
- * Have a per-pixel alpha value.
- * - MYBMP_RGBSIZE_3n
- * Size of each RGB triple is 3 bytes.
- * - MYBMP_RGBSIZE_4n
- * Size of each RGB triple is 4 bytes.
- * - MYBMP_LOAD_GRAYSCALEn
- * Tell bitmap loader to load a grayscale bitmap.
- */
- DWORD flags;
- /** The number of the frames. */
- int frames;
- /** The pixel depth. */
- Uint8 depth;
- /** The alpha channel value. */
- Uint8 alpha;
- Uint8 reserved [2];
- /** The transparent pixel. */
- Uint32 transparent;
- /** The width of the bitmap. */
- Uint32 w;
- /** The height of the bitmap. */
- Uint32 h;
- /** The pitch of the bitmap. */
- Uint32 pitch;
- /** The size of the bits of the bitmap. */
- Uint32 size;
- /** The pointer to the bits of the bitmap. */
- BYTE* bits;
- };
- #ifdef _USE_NEWGAL
- #define BMP_TYPE_NORMAL 0x00
- #define BMP_TYPE_RLE 0x01
- #define BMP_TYPE_ALPHA 0x02
- #define BMP_TYPE_ALPHACHANNEL 0x04
- #define BMP_TYPE_COLORKEY 0x10
- #define BMP_TYPE_PRIV_PIXEL 0x20
- #ifdef _FOR_MONOBITMAP
- #define BMP_TYPE_MONOKEY 0x40
- #endif
- /** Expanded device-dependent bitmap structure. */
- struct _BITMAP
- {
- /**
- * Bitmap types, can be OR'ed by the following values:
- * - BMP_TYPE_NORMALn
- * A nomal bitmap, without alpha and color key.
- * - BMP_TYPE_RLEn
- * A RLE encoded bitmap, not used so far.
- * - BMP_TYPE_ALPHAn
- * Per-pixel alpha in the bitmap.
- * - BMP_TYPE_ALPHACHANNELn
- * The a bmAlpha is a valid alpha channel value.
- * - BMP_TYPE_COLORKEYn
- * The a bmColorKey is a valid color key value.
- * - BMP_TYPE_PRIV_PIXELn
- * The bitmap have a private pixel format.
- */
- Uint8 bmType;
- /** The bits per piexel. */
- Uint8 bmBitsPerPixel;
- /** The bytes per piexel. */
- Uint8 bmBytesPerPixel;
- /** The alpha channel value. */
- Uint8 bmAlpha;
- /** The color key value. */
- Uint32 bmColorKey;
- #ifdef _FOR_MONOBITMAP
- Uint32 bmColorRep;
- #endif
- /** The width of the bitmap */
- Uint32 bmWidth;
- /** The height of the bitmap */
- Uint32 bmHeight;
- /** The pitch of the bitmap */
- Uint32 bmPitch;
- /** The bits of the bitmap */
- Uint8* bmBits;
- /** The private pixel format */
- void* bmAlphaPixelFormat;
- };
- #else
- #define BMP_TYPE_NORMAL 0x00
- #define BMP_TYPE_COLORKEY 0x01
- /* expanded bitmap struct */
- struct _BITMAP
- {
- Uint8 bmType;
- Uint8 bmBitsPerPixel;
- Uint8 bmBytesPerPixel;
- Uint8 bmReserved;
- Uint32 bmColorKey;
- Uint32 bmWidth;
- Uint32 bmHeight;
- Uint32 bmPitch;
- void* bmBits;
- Uint32 bmReserved1;
- };
- #endif /* _USE_NEWGAL */
- /** @} end of bmp_struct */
- /**
- * defgroup bmp_load_fns Bitmap file load/save operations
- * @{
- *
- * Example:
- *
- * include bitmap.c
- */
- #include <stdio.h>
- #include "endianrw.h"
- /**
- * fn BOOL GUIAPI RegisterBitmapFileType (const char *ext, int (*load) (MG_RWops* fp, MYBITMAP *bmp, RGB *pal), int (*save) (MG_RWops* fp, MYBITMAP *bmp, RGB *pal), BOOL (*check) (MG_RWops* fp))
- *
- * brief Registers a bitmap file loader, saver, and checker.
- *
- * This function registers a new bitmap file loader, saver, and checker.
- * You should pass the extension of the bitmap files, the function to
- * load this type of bitmap file, the function to save, and the
- * function to check the type.
- *
- * param ext The extension name of the type of bitmap file, like "jpg" or "gif".
- * param load The loader of the bitmap file.
- * param save The saver of the bitmap file, can be NULL.
- * param check The checker of the bitmap file.
- * return TRUE on success, FALSE on error.
- *
- * sa CheckBitmapType, LoadBitmapEx, general_rw_fns
- */
- BOOL GUIAPI RegisterBitmapFileType (const char *ext,
- int (*load) (MG_RWops* fp, MYBITMAP *bmp, RGB *pal),
- int (*save) (MG_RWops* fp, MYBITMAP *bmp, RGB *pal),
- BOOL (*check) (MG_RWops* fp));
- /**
- * fn const char* GUIAPI CheckBitmapType (MG_RWops* fp)
- * brief Checks the type of the bitmap in a data source.
- *
- * This function checks the type of the bitmap in the data source a fp,
- * and returns the extension of this type of bitmap file.
- *
- * param fp The pointer to the data source.
- * return The extension of the type of bitmap file. NULL for not recongnized bitmap type.
- *
- * sa RegisterBitmapFileType
- */
- const char* GUIAPI CheckBitmapType (MG_RWops* fp);
- #define ERR_BMP_OK 0
- #define ERR_BMP_IMAGE_TYPE -1
- #define ERR_BMP_UNKNOWN_TYPE -2
- #define ERR_BMP_CANT_READ -3
- #define ERR_BMP_CANT_SAVE -4
- #define ERR_BMP_NOT_SUPPORTED -5
- #define ERR_BMP_MEM -6
- #define ERR_BMP_LOAD -7
- #define ERR_BMP_FILEIO -8
- #define ERR_BMP_OTHER -9
- #define ERR_BMP_ERROR_SOURCE -10
- /**
- * fn int GUIAPI LoadBitmapEx (HDC hdc, PBITMAP pBitmap, MG_RWops* area, const char* ext)
- * brief Loads a device-dependent bitmap from a general data source.
- *
- * This function loads a device-dependent bitmap from the data source a area.
- *
- * param hdc The device context.
- * param pBitmap The pointer to the BITMAP object.
- * param area The data source.
- * param ext The extension of the type of this bitmap.
- * return 0 on success, less than 0 on error.
- *
- * retval ERR_BMP_OK Loading successfully
- * retval ERR_BMP_IMAGE_TYPE Not a valid bitmap.
- * retval ERR_BMP_UNKNOWN_TYPE Not recongnized bitmap type.
- * retval ERR_BMP_CANT_READ Read error.
- * retval ERR_BMP_CANT_SAVE Save error.
- * retval ERR_BMP_NOT_SUPPORTED Not supported bitmap type.
- * retval ERR_BMP_MEM Memory allocation error.
- * retval ERR_BMP_LOAD Loading error.
- * retval ERR_BMP_FILEIO I/O failed.
- * retval ERR_BMP_OTHER Other error.
- * retval ERR_BMP_ERROR_SOURCE A error data source.
- *
- * sa LoadBitmapFromFile, LoadBitmapFromMemory
- */
- int GUIAPI LoadBitmapEx (HDC hdc, PBITMAP pBitmap, MG_RWops* area, const char* ext);
- /**
- * fn int GUIAPI LoadBitmapFromFile (HDC hdc, PBITMAP pBitmap, const char* spFileName)
- * brief Loads a device-dependent bitmap from a file.
- *
- * sa LoadBitmapEx
- */
- int GUIAPI LoadBitmapFromFile (HDC hdc, PBITMAP pBitmap, const char* spFileName);
- /**
- * def LoadBitmap
- * brief An alias of a LoadBitmapFromFile.
- *
- * sa LoadBitmapFromFile
- */
- #define LoadBitmap LoadBitmapFromFile
- /**
- * fn int GUIAPI LoadBitmapFromMem (HDC hdc, PBITMAP pBitmap, const void* mem, int size, const char* ext)
- * brief Loads a device-dependent bitmap from memory.
- *
- * sa LoadBitmapEx
- */
- int GUIAPI LoadBitmapFromMem (HDC hdc, PBITMAP pBitmap, const void* mem, int size, const char* ext);
- #define LoadBitmapFromMemory LoadBitmapFromMem
- /**
- * fn void GUIAPI UnloadBitmap (PBITMAP pBitmap)
- * brief Unloads a bitmap.
- *
- * This function unloads the specified bitmap a pBitmap.
- * It will free the private pixel format and the bits of the bitmap.
- *
- * param pBitmap The BITMAP object.
- *
- * sa LoadBitmapEx
- */
- void GUIAPI UnloadBitmap (PBITMAP pBitmap);
- /**
- * fn void GUIAPI ReplaceBitmapColor (HDC hdc, PBITMAP pBitmap, gal_pixel iOColor, gal_pixel iNColor)
- * brief Replaces a specific pixels in a bitmap with another pixel.
- *
- * This function replaces the specific pixels with value a iOColor with the other pixel value a iNcolor
- * in the bitmap a pBitmap.
- *
- * param hdc The device context.
- * param pBitmap The BITMAP object.
- * param iOColor The pixel value of the color will be replaced.
- * param iNColor The pixel value of the new color.
- *
- */
- void GUIAPI ReplaceBitmapColor (HDC hdc, PBITMAP pBitmap, gal_pixel iOColor, gal_pixel iNColor);
- /**
- * fn int GUIAPI LoadMyBitmapEx (PMYBITMAP my_bmp, RGB* pal, MG_RWops* area, const char* ext)
- * brief Loads a MYBITMAP object from a data source.
- *
- * This function loads a MYBITMAP object from the data source a area.
- *
- * param my_bmp The pointer to the MYBITMAP object.
- * param area The data source.
- * param pal The palette will be returned.
- * param ext The extension of the type of this bitmap.
- * return 0 on success, less than 0 on error.
- *
- * sa LoadBitmapEx
- */
- int GUIAPI LoadMyBitmapEx (PMYBITMAP my_bmp, RGB* pal, MG_RWops* area, const char* ext);
- /**
- * fn int GUIAPI LoadMyBitmapFromFile (PMYBITMAP my_bmp, RGB* pal, const char* file_name)
- * brief Loads a MYBITMAP object from a file.
- *
- * sa LoadMyBitmapEx
- */
- int GUIAPI LoadMyBitmapFromFile (PMYBITMAP my_bmp, RGB* pal, const char* file_name);
- /**
- * def LoadMyBitmap
- * brief Alias of a LoadMyBitmapFromFile.
- *
- * sa LoadMyBitmapFromFile
- */
- #define LoadMyBitmap LoadMyBitmapFromFile
- /**
- * fn int GUIAPI LoadMyBitmapFromMem (PMYBITMAP my_bmp, RGB* pal, const void* mem, int size, const char* ext)
- * brief Loads a MYBITMAP object from memory.
- *
- * This function loads a MYBITMAP object from memory.
- *
- * param my_bmp The pointer to the MYBITMAP object.
- * param pal The palette will be retruned through this pointer.
- * param mem The pointer to the memory area.
- * param size The size of the memory area.
- * param ext The extension name used to determine the type of the bitmap.
- *
- * sa LoadMyBitmapEx, MYBITMAP
- */
- int GUIAPI LoadMyBitmapFromMem (PMYBITMAP my_bmp, RGB* pal, const void* mem, int size, const char* ext);
- #define LoadMyBitmapFromMemory LoadMyBitmapFromMem
- /**
- * fn void GUIAPI UnloadMyBitmap (PMYBITMAP my_bmp)
- * brief Unloads a bitmap.
- *
- * This function unloads the specified MYBITMAP object a my_bmp.
- * It will free the bits of the bitmap.
- *
- * param my_bmp The pointer to the MYBITMAP object.
- *
- * sa LoadMyBitmapEx
- */
- void GUIAPI UnloadMyBitmap (PMYBITMAP my_bmp);
- #ifdef _SAVE_BITMAP
- /**
- * fn int GUIAPI SaveMyBitmapToFile (PMYBITMAP my_bmp, RGB* pal, const char* spFileName)
- * brief Saves a MYBITMAP object to a bitmap file.
- *
- * This function saves the MYBITMAP object a my_bmp to the bitmap file named a spFileName.
- *
- * param my_bmp The MYBITMAP object.
- * param pal The palette.
- * param spFileName The file name.
- * return 0 on success, less than 0 on error.
- *
- * sa SaveBitmapToFile
- */
- int GUIAPI SaveMyBitmapToFile (PMYBITMAP my_bmp, RGB* pal, const char* spFileName);
- /**
- * fn int GUIAPI SaveBitmapToFile (HDC hdc, PBITMAP pBitmap, const char* spFileName)
- * brief Saves a BITMAP object to a bitmap file.
- *
- * This function saves the BITMAP object a pBitmap to the bitmap file named a spFileName.
- *
- * param hdc The device context.
- * param pBitmap The BITMAP object.
- * param spFileName The file name.
- * return 0 on success, less than 0 on error.
- *
- * sa SaveMyBitmapToFile
- */
- int GUIAPI SaveBitmapToFile (HDC hdc, PBITMAP pBitmap, const char* spFileName);
- #define SaveBitmap SaveBitmapToFile
- #endif
- /**
- * fn BOOL GUIAPI InitBitmap (HDC hdc, Uint32 w, Uint32 h, Uint32 pitch, BYTE* bits, PBITMAP bmp)
- * brief Initializes a BITMAP object as a normal bitmap.
- *
- * This function initializes the bitmap pointed to by a bmp as a normal bitmap.
- * It sets the bitmap structure fields, and allocates the bits if a bits is NULL.
- *
- * param hdc The device context.
- * param w The width of the bitmap.
- * param h The height of the bitmap.
- * param pitch The pitch of the bitmap.
- * param bits The bits of the bitmap.
- * param bmp The BITMAP object to be initialized.
- * return TRUE on success, FALSE on error.
- *
- * note a LoadBitmapEx will initialize the BITMAP object itself.
- *
- * sa InitBitmapPixelFormat, UnloadBitmap, bmp_struct
- */
- BOOL GUIAPI InitBitmap (HDC hdc, Uint32 w, Uint32 h, Uint32 pitch, BYTE* bits, PBITMAP bmp);
- #ifdef _USE_NEWGAL
- /**
- * fn BOOL GUIAPI InitBitmapPixelFormat (HDC hdc, PBITMAP bmp)
- * brief Initializes the bitmap pixel format information of a BITMAP object.
- *
- * This function initializes the bitmap pixel format information of the BITMAP object
- * pointed to by a bmp. This includes a bmBitsPerPixel and a bmBytesPerPixel fields,
- * and the private pixel format if the bitmap is a bitmap with alpha.
- *
- * param hdc The device context.
- * param bmp The BITMAP object to be initialized.
- * return TRUE on success, FALSE on error.
- *
- * sa InitBitmap, bmp_struct
- */
- BOOL GUIAPI InitBitmapPixelFormat (HDC hdc, PBITMAP bmp);
- /**
- * fn void GUIAPI DeleteBitmapAlphaPixel (PBITMAP bmp)
- * brief Deletes the bitmap alpha pixel format information of a BITMAP object.
- *
- * This function deletes the bitmap alpha pixel format information of the BITMAP object a bmp.
- *
- * sa InitBitmapPixelFormat
- */
- void GUIAPI DeleteBitmapAlphaPixel (PBITMAP bmp);
- /**
- * fn int GUIAPI ExpandMyBitmap (HDC hdc, PBITMAP bmp, const MYBITMAP* my_bmp, const RGB* pal, int frame)
- * brief Expands a MYBITMAP object to a BITMAP object.
- *
- * This function expands the MYBITMAP object pointed to by a my_bmp
- * to a BITMAP object (a bmp).
- *
- * param hdc The device context.
- * param bmp The expanded BITMAP object.
- * param my_bmp The MYBITMAP object to be expanded.
- * param pal The palette of the MYBITMAP object.
- * param frame The frame of the MYBITMAP object.
- * return 0 on success, non-zero on error.
- */
- int GUIAPI ExpandMyBitmap (HDC hdc, PBITMAP bmp, const MYBITMAP* my_bmp, const RGB* pal, int frame);
- void GUIAPI ExpandMonoBitmap (HDC hdc, BYTE* bits, Uint32 pitch, const BYTE* my_bits, Uint32 my_pitch,
- Uint32 w, Uint32 h, DWORD flags, Uint32 bg, Uint32 fg);
- void GUIAPI Expand16CBitmap (HDC hdc, BYTE* bits, Uint32 pitch, const BYTE* my_bits, Uint32 my_pitch,
- Uint32 w, Uint32 h, DWORD flags, const RGB* pal);
- void GUIAPI Expand256CBitmap (HDC hdc, BYTE* bits, Uint32 pitch, const BYTE* my_bits, Uint32 my_pitch,
- Uint32 w, Uint32 h, DWORD flags, const RGB* pal);
- void GUIAPI CompileRGBABitmap (HDC hdc, BYTE* bits, Uint32 pitch, const BYTE* my_bits, Uint32 my_pitch,
- Uint32 w, Uint32 h, DWORD flags, void* pixel_format);
- #define CompileRGBBitmap CompileRGBABitmap
- #else
- int GUIAPI ExpandMyBitmap (HDC hdc, const MYBITMAP* pMyBitmap, const RGB* pal, PBITMAP pBitmap);
- void GUIAPI ExpandMonoBitmap (HDC hdc, int w, int h, const BYTE* my_bits, int my_pitch, int bits_flow,
- BYTE* bitmap, int pitch, int bg, int fg);
- void GUIAPI Expand16CBitmap (HDC hdc, int w, int h, const BYTE* my_bits, int my_pitch, int bits_flow,
- BYTE* bitmap, int pitch, const RGB* pal);
- void GUIAPI Expand256CBitmap (HDC hdc, int w, int h, const BYTE* my_bits, int my_pitch, int bits_flow,
- BYTE* bitmap, int pitch, const RGB* pal);
- void GUIAPI CompileRGBBitmap (HDC hdc, int w, int h, const BYTE* my_bits, int my_pitch, int bits_flow,
- BYTE* bitmap, int pitch, int rgb_order);
- #endif /* _USE_NEWGAL */
- /** @} end of bmp_load_fns */
- /** @} end of gdi_fns */
- /** @} end of fns */
- #ifdef __cplusplus
- }
- #endif /* __cplusplus */
- #endif /* _MGUI_GDI_H */