/** @file * Header file for some utility functions. * * @author mandy.wu 2010/12/06 (Add duplicate controls' core struct) * @author tzungming.lin 2009/09/28 (Control/Child scaling) * @version 0.1 */ #ifndef _GUIENG_UTIL #define _GUIENG_UTIL #include "gl_types.h" #include "stddefs.h" #include "datatypes.h" #include "gui_engine.h" #define GENG_SET_ALIGN(oriAlign, hAlign) oriAlign = ((oriAlign & ~FONT_ALIGN_MASK) | hAlign) #define GENG_SET_V_ALIGN(oriAlign, vAlign) oriAlign = ((oriAlign & ~FONT_V_ALIGN_MASK) | vAlign) #define CHECK_DISLIST(list,total) \ if( (list) == NULL && (total) > 0 ) \ { \ ERROR(PRINT("%s: Disabled list is NULL\n", __FUNCTION__)); \ return; \ } \ else if( (total) == 0 ) \ return; #define BAK_REGION_INFO(sdHandle, stOriArea) \ { \ stOriArea = gRegionDetails[sdHandle].rect; \ } #define RESTORE_REGION_INFO(sdHandle, stOriArea) \ { \ gRegionDetails[sdHandle].rect = stOriArea; \ } /** Transparent color. */ extern const Color_t gTransColor; /** icon_info_t with ICON_ID_INVALID of each state. */ extern const icon_info_t gInvalidIcon; /** color_info_t with transparent color of each state. */ extern const color_info_t gTransColorInfo; /** text_color_info_t with transparent color of each state. */ extern const text_color_info_t gTransTextColorInfo; /**************************************************************************/ /* Accessors. */ /**************************************************************************/ /** * Get a 4-byte-aligned width from the input image data. * * @param pstImgData Pointer to the target image data. * @return A 4 bytes aligned width for a bitmap. */ UINT16 GUIENG_GetBmpAlignedWidth(const PIMAGEHDR pstImgData); /** * Get parent with type of CLASS_WINDOW or CLASS_POPUP. * * @param handle Handle of a control. * @return Pointer to the handle of parent menu/popup. */ HWND GUIENG_GetParentMenu(HWND handle); /** * Get font style enum value according to the state of widget * * @param pstCtrl Control of target widget. * @param dState Specific state. * @return Font style enumeration value. */ FontStyle_e GUIENG_GetFontStyle(WinControl_t *pstCtrl, UINT32 dState); /** * Get font size according to the state of widget * * @param pstCtrl Control of target widget. * @param dState Specific state. * @return Font size in pt(or pixel). */ FONTSize_t GUIENG_GetFontSize(WinControl_t *pstCtrl, UINT32 dState); #define GUIENG_GetEndStyle(control) ((GET_WIDGET_STYLE(control) & S_TXT_END_MASK) >> 4) /** * Get text style. * @param pstCtrl Control of target control. * @return Text style enum value. */ GEL_TextStyle_e GUIENG_GetTextStyle(WinControl_t *pstCtrl); /** * Get text style of button group or listview. * @param pstCtrl Control of target control. * @param dState Desired state of the control. * @return Text style enum value. */ GEL_TextStyle_e GUIENG_GetGroupTextStyle(WinControl_t *pstCtrl, UINT32 dState); /** * Get AA information from the style of parent control. * * @param handle Handle to a control. * @param pstTextInfo Text information structure. * @return GUI_SUCCESS if succeed, error code otherwise. */ GUIResult_e GUIENG_GetAAInfo(HWND handle, GENG_TextInfo_t *pstTextInfo); /** * Get font alignment(horizontal and vertical) according to the style of a widget. * * @param dStyle Common style of a widget. * @return Result alignment flag. */ UINT8 GUIENG_GetFontAlign(UINT32 dCommStyle); /**************************************************************************/ /* Basic drawing functions. */ /**************************************************************************/ /** * Draw child controls to be background extension. * * @param hdc Handle of device context. * @param handle Handle of parent control. * @param dParentState State of the parent control. */ void GUIENG_DrawChildBg(HDC hdc, HWND handle, UINT32 dParentState, UINT32 parentParam); /** * Draw child controls to be the border. * * @param hdc Handle of device context. * @param handle Handle of parent control. * @param dParentState State of the parent control. */ void GUIENG_DrawChildBorder(HDC hdc, HWND handle, UINT32 dParentState, UINT32 parentParam); /** * Draw the background color of the parent, not the whole widget. * * @param hdc Handle to the device context. * @param stTargetRect Rectangle of the parent. * @param stColor Color of background. */ void GUIENG_FillDesignateColor(HDC hdc, RECT stTargetRect, Color_t stColor, INT32 *pBlockId); /** * Draw background icon of a widget. * * @param hdc Handle to a device context. * @param pstTargetRect Target rectangle area. * @param swIconId Icon id of background icon. * @param wSideSize Side size of background icon. * @param pDynPal Dynamic set source palette. * @param dStyle Style of this widget. */ void GUIENG_DrawBgIcon(HDC hdc, PRECT pstTargetRect , INT16 swIconId, UINT16 wSideSize, PALENTRY *pDynPal, UINT32 dStyle, INT32 *pBlockId); /**************************************************************************/ /* Marquee Related APIs. */ /**************************************************************************/ /** * Create a temp buffer to draw the prepared foreground for marquee style. * * @param hdc Handle to a device context. * @param pstControl Pointer to a WinControl_t of the control. * @return GUI_SUCCESS if succeed, error codes otherwise. */ GUIResult_e GUIENG_CreateMarqueeFgBuf(HDC hdc, WinControl_t *pstControl); /** * Create a buffer to backup the background of a marquee. * * @param hdc Handle to a device context. * @param pstControl Pointer to a WinControl_t of the control. * @param pstMarqInfo Pointer to a marquee information of target control. * @param pstBgRect The background rect to be backup. * @param dControlFlags To indecate if its a region buffer rendering. * @return GUI_SUCCESS if succeed, error codes otherwise. */ GUIResult_e GUIENG_CreateMarqueeBgBuf(HDC hdc, WinControl_t *pstControl, marquee_info_t *pstMarqInfo, PRECT pstBgRect, UINT32 dControlFlags); /** * Destroy the foreground buffer of animation. * * @param hdc Handle to a device context. * @param pstMarqInfo Pointer to a marquee information of target control. */ void GUIENG_DestroyMarqueeFgBuf(HDC hdc, marquee_info_t *pstMarqInfo); /** * Destroy the bakcground of an animation/marquee. * * @param hdc Handle to a device context. * @param pstControl Pointer to a WinControl_t of the control. * @param pstMarqInfo Pointer to a marquee information of target control. */ void GUIENG_DestroyMarqueeBgBuf(HDC hdc, WinControl_t *pstControl, marquee_info_t *pstMarqInfo); /** * Draw foreground text to perform marquee effect. * * @param hdc Handle to the device context. * @param handle Handle to the control. * @param marquee Pointer to a marquee information. * @param wTextWidth Width of area of foreground text. * @param pstBgColor Background color of the specific text position. */ void GUIENG_DrawMarquee(HDC hdc, HWND handle, marquee_info_t *marquee, UINT16 wTextWidth, color_info_t *pstBgColor, INT32 *pBlockId); /**************************************************************************/ /* Boolean functions. */ /**************************************************************************/ /** * Check if there exists transparent color in all states of the input color info * * @param eRgnFormat Region format. * @param pstColor Colors of each state. * @return TRUE if it contains transparent color, FALSE otherwise. */ BOOLEAN GUIENG_ContainTransparentBg(PixelFormat_e eRgnFormat, color_info_t *pstColor); /** * Check if there exists transparent color in a prog_color_t. * * @param eRgnFormat Region format. * @param pstProgColor Colors of each state of progress bar/scroll bar. * @return TRUE if it contains transparent color, FALSE otherwise. */ BOOLEAN GUIENG_ContainTransparentBarBg(PixelFormat_e eRgnFormat, prog_color_t *pstProgColor); /** * Check if input parent control has child icon or not. * * @param parent Handle of parent control * @return TRUE if it has at least one child icon, FALSE otherwise. */ BOOLEAN GUIENG_HasChildIcon(HWND parent); /** * Perform height scaling only. * * @param stArea Given area that needs to be scaling. * @param control Control of a widget. * @return GUI_SUCCESS if succeed, error codes otherwise. */ GUIResult_e GUIENG_HeightScaling(PRECT stArea, WinControl_t *control); /** * Perform width scaling only. * * @param stArea Given area that needs to be scaling. * @param control Control of a widget. * @return GUI_SUCCESS if succeed, error codes otherwise. */ GUIResult_e GUIENG_WidthScaling(PRECT stArea, WinControl_t *control); /** * Perform area scaling. * * @param stArea Given area that needs to be scaling. * @param control Control of a widget. * @return GUI_SUCCESS if succeed, error codes otherwise. */ GUIResult_e GUIENG_AreaScaling(PRECT stArea, WinControl_t *control); void gel_WaitForMsgDone(void); void gel_WaitForSelfDone(HWND pHandle); /**************************************************************************/ /* Move control related functions. */ /**************************************************************************/ INT32 GUIENG_4Bpp_FillBmp(RECT stSrcRect, RECT stDstRect, PIMAGEHDR pstImgData, UINT8* u8OutBuffer, UINT32 u32OutBufferLen); INT32 GUIENG_4Bpp_HasSideSize_Hrepeate(RECT stSrcRect, RECT stDstRect, PIMAGEHDR pstImgData, UINT32 side, UINT8* u8OutBuffer, UINT32 u32OutBufferLen); void GUIENG_ChildScaling(HWND parent, RECT stChildPos[3]); void GUIENG_ChildRestorePos(HWND handle, RECT stChildPos[3]); INT32 text_GetHdc(HWND handle, HDC *hdc); void GUIENG_DrawFocusedStrBorder(HWND handle, TextInfo_t *pstTextInfo); void GUIENG_DrawFocusedBorder(HWND handle, RECT rect); INT32 GUIENG_SateToIndex(INT32 state); IMAGEHDR GUIENG_GetRepeatImageByID(HDC hdc, INT16 swIconId, UINT16 wSideSize, UINT32 dStyle, RECT destRect, PIMAGEHDR pTargetImage); IMAGEHDR GUIENG_GetRepeatImage(PIMAGEHDR pSrcImage, UINT16 sideSize, UINT32 dStyle, RECT destRect, PIMAGEHDR pTargetImage); #endif //#ifndef _GUIENG_UTIL