/** @file * GDI structures and API * * @author anlzhao * @author mandy.wu 2010/01/11 (Add KOK caption support) * @author tzungming.lin 2010/01/08 (FixCharWidth/FixLineHeight) * @version 0.1 */ #ifndef _WINGDI_H #define _WINGDI_H #include "gui_eng/gel_private.h" #include "gui_eng/stddefs.h" #include "gui_eng/device_font.h" #include "gui_eng/region.h" #define GDL_SUCCESS (0) #define GDL_FAILURE (-1) /* Internal style tranform - use individual style bits 21~31 */ #define GDI_FLAG_PIC_90 (0x100000 << 1) #define GDI_FLAG_PIC_180 (0x100000 << 2) #define GDI_FLAG_PIC_270 (0x100000 << 3) /** * Get handle to device context. * * @param hwnd Handle to the control. * @param sdRegionHandle Region handle index. * @return Handle to the device context. */ HDC GDI_GetDc(HWND hwnd, INT32 sdRegionHandle); /** * Free the handle of a device context which was allocated by GDI_get_dc. * * @param hdc Handle to the device context. * @return GUI_SUCCESS if succeed, error codes otherwise. */ GUIResult_e GDI_ReleaseDc(HDC hdc); #if 0 /** * Set a background color to a DC. * * @param hdc Handle to the device context. * @param stBgColor A new background color. * @return The previous background color. */ Color_t GDI_SetBgColor(HDC hdc, Color_t stBgColor); /** * Set a background mode to a DC. * * @param hdc Handle to the device context. * @param sdBgMode New background mode. * @return The previous background mode. */ INT32 GDI_SetBgMode(HDC hdc, INT32 sdBgMode); #endif /** * Set a foreground color to a DC. * * @param hdc Handle to the device context. * @param stFgColor A new foreground color. * @return The previous foreground color. */ Color_t GDI_SetFgColor(HDC hdc, Color_t stFgColor); /** * Set a pixel value from a DC. * * @param hdc Handle to the device context. * @param sdX X coordinate of a DC. * @param sdY Y coordinate of a DC. * @param stColor The pixel value to be set. * @return GUI_SUCCESS if succeed, error codes otherwise. */ GUIResult_e GDI_SetPixel(HDC hdc, INT32 sdX, INT32 sdY, Color_t stColor, INT32 *pBlockId); /** * Draw a filled rectangle. * * @param hdc Handle to the device context. * @param pRect Pointer to a rectangle. * @param stColor The color to be filled. * @return GUI_SUCCESS if succeed, error codes otherwise. */ GUIResult_e GDI_FastFillRect(HDC hdc, LPRECT pRect, Color_t stColor, INT32 *pBlockId); /** * Draw a line. * * @param hdc Handle to the device context. * @param swX1 Start x coordinate. * @param swY1 Start y coordinate. * @param swX2 End x coordinate. * @param swY2 End y coordinate. * @param wThickness The width of the pen to draw a line. * @return GUI_SUCCESS if succeed, error codes otherwise. */ GUIResult_e GDI_DrawLine(HDC hdc, INT16 swX1, INT16 swY1, INT16 swX2, INT16 swY2, UINT16 wThickness, INT32 *pBlockId); /** * Draw a rectangle. * * @param hdc Handle to the device context. * @param pRect Rectangle to be drawn. * @param wThickness The width of the pen to draw a line. * @return GUI_SUCCESS if succeed, error codes otherwise. */ GUIResult_e GDI_DrawRect(HDC hdc, PRECT pRect, UINT16 wThickness, INT32 *pBlockId); /** * Fill a rectangle. * * @param hdc Handle to the device context. * @param pRect Pointer to a rectangular area to be filled. * @return GUI_SUCCESS if succeed, error codes otherwise. */ GUIResult_e GDI_FillRect(HDC hdc, PRECT pRect, INT32 *pBlockId); /** * Interface to fill color and do not ignore transparent color. * * @param hdc Handle to device context. * @param pRect Pointer to Rect Struct. * @return GUI_SUCCESS if succeed, error codes otherwise. */ GUIResult_e GDI_FillRectWithTransparent(HDC hdc, PRECT pRect, INT32 *pBlockId); /** * Interface to draw Icon/bitmap. * * @param hdc Handle to device context. * @param pSrcRect Source area. * @param pDstRect Destination area. * @param pImage Pointer to image structure. * @param pDynSrcPal The pointer of dynamic source palette. * @param dFlags Flags indicating different draw styles. * @param bDrawFlag Refer to GDL_XXX definitions in device_gdi.h * @return GUI_SUCCESS if succeed, error codes otherwise. */ GUIResult_e GDI_DrawBitmap(HDC hdc, PRECT pSrcRect, PRECT pDstRect, PIMAGEHDR pImage, PALENTRY *pDynSrcPal, UINT32 dFlags, UINT8 bDrawFlag, INT32 *pBlockId); /** * Apply a constant alpha value to draw a bitmap. * * @param hdc Handle to device context. * @param pDstRect Pointer to the dest rectantgle to be drawn. * @param pImage Pointer to an image structure. * @param pDynSrcPal Dynamic assigned source palette at runtime. * @param bAlphaValue The constant alpha value to be applied. * @return GUI_SUCCESS if succeed, error codes otherwise. */ GUIResult_e GDI_BlendBitmap(HDC hdc, PRECT pDstRect, PIMAGEHDR pImage, PALENTRY *pDynSrcPal, UINT8 bAlphaValue, INT32 *pBlockId); /** * Interface to stretch blit a bitmap. * * @param hdc Handle to device context. * @param pDstRect Pointer to the target rectangle to be drawn. * @param pImage Pointer to the handle of a bitmap. * @param pDynSrcPal Dynamic assigned source palette at runtime. * @param dFlags Flags indicating different draw styles * @return GUI_SUCCESS if succeed, error codes otherwise. */ GUIResult_e GDI_StretchBlit(HDC hdc, PRECT pDstRect, PIMAGEHDR pImage, PALENTRY *pDynSrcPal, UINT32 dFlags, INT32 *pBlockId); #if 0 /** * Interface to set new object and get previous object. * * @param hdc Handle to device context. * @param newobj Pointer to Object to set like pen, brush. * @return Poiner to old object if type is found else NULL. */ obj_ptr GDI_SelectObject(HDC hdc, obj_ptr newobj); #endif /** * Interface to delete the object created using CreateXXX(). * * @param stObject Pointer to Object to delete like pen, brush. * @return GUI_SUCCESS if object is valid, error codes otherwise. */ GUIResult_e GDI_DeleteObject(obj_ptr stObject); #if 0 /** * Interface to set the color of the object. * * @param object Pointer to Object to be deleted. * @param stColor Color to be set. * @return Old color of the object. */ Color_t GDI_SetObjectColor(obj_ptr object, Color_t stColor); #endif /** * Interface to create solid brush. * * @param stcolor Brush color. * @return Pointer to BRUSH if brush created successfully else NULL. */ brush_ptr GDI_CreateSolidBrush(Color_t stColor); /** * Interface to create pen. * * @param stStyle Style of the Pen. * @param swWidth Width of the pen. * @param stColor Color of the pen. * @return Pointer to HPEN if pen created successfully else NULL. */ pen_ptr GDI_CreatePen(pen_style_t stStyle, INT32 swWidth, Color_t stColor); /** * Get the bitmap data from an icon id. * * @param hdc Handle to a device context. * @param swIconId An icon id. * @param pImgData Return the image data. * @return GUI_SUCCESS if succeed, error codes otherwise. */ GUIResult_e GDI_GetBmpData(HDC hdc, INT16 swIconId, IMAGEHDR *pImgData); /** * Convert native code string to unicode string depond on Designate or Default Codepage. * * @param pNative Native code string * @param pDest Converted Unicode string * @param i32DestLen Length limitation of Unicode string, if < 0, ignore dest buffer size * @return Length of converted unicode string */ INT32 GDI_Native2UniConvert (HDC hdc, UINT8 *pNative, UINT16 *pDest, INT32 i32DestLen); /** * Convert native code string to UTF-8 string depond on Designate or Default Codepage. * * @param pNative Native code string * @param pDest Converted Unicode string * @param i32DestLen Length limitation of Unicode string, if < 0, ignore dest buffer size * @return Length of converted unicode string */ INT32 GDI_Native2Utf8Convert (HDC hdc, UINT8 *pNative, UINT8 *pDest, INT32 i32DestLen); INT32 GDI_ReleaseBlock(RegionHandle_t sdRegionHandle, INT32 * pBlockId); INT32 GDI_ReleaseBlockItems(RegionHandle_t sdRegionHandle, INT32 * pBlockId, UINT32 uiItems); #endif //#ifndef _WINGDI_H