/********************************************************************* * Function: uint16_t GFX_GOL_PictureDraw(void *pObj) * * Output: returns the status of the drawing * 0 - not completed * 1 - done * * Overview: draws picture * ********************************************************************/ GFX_STATUS GFX_GOL_PictureControlDraw(void *pObj) { typedef enum { REMOVE, DRAW_IMAGE, DRAW_BACKGROUND1, DRAW_BACKGROUND2, DRAW_BACKGROUND3, DRAW_BACKGROUND4, DRAW_FRAME, } GFX_GOL_PICTURE_DRAW_STATES; static GFX_GOL_PICTURE_DRAW_STATES state = REMOVE; static uint16_t posleft; static uint16_t postop; static uint16_t posright; static uint16_t posbottom; static GFX_STATUS index = GFX_STATUS_FAILURE; GFX_GOL_PICTURECONTROL *pPict; pPict = (GFX_GOL_PICTURECONTROL *)pObj; switch(state) { case REMOVE: if(GFX_GOL_ObjectStateGet(pPict, GFX_GOL_PICTURECONTROL_HIDE_STATE)) { GFX_ColorSet(pPict->hdr.pGolScheme->CommonBkColor); if(GFX_RectangleFillDraw(pPict->hdr.left, pPict->hdr.top, pPict->hdr.right, pPict->hdr.bottom) == GFX_STATUS_FAILURE) return (GFX_STATUS_FAILURE); return (GFX_STATUS_SUCCESS); } posleft = (pPict->hdr.left + 1 + pPict->hdr.right - pPict->scaleFactor * GFX_ImageWidthGet(pPict->pImage)) >> 1; postop = (pPict->hdr.top + 1 + pPict->hdr.bottom - pPict->scaleFactor * GFX_ImageHeightGet(pPict->pImage)) >> 1; posright = (pPict->hdr.right + pPict->hdr.left + pPict->scaleFactor * GFX_ImageWidthGet(pPict->pImage)) >> 1; posbottom = (pPict->hdr.bottom + pPict->hdr.top + pPict->scaleFactor * GFX_ImageHeightGet(pPict->pImage)) >> 1; GFX_ImageStretchSet(pPict->scaleFactor); state = DRAW_IMAGE; case DRAW_IMAGE: if(pPict->pImage != NULL) { if(GFX_ImagePartialDraw(posleft, postop, pPict->partial.xoffset,pPict->partial.yoffset,pPict->partial.width,pPict->partial.height, pPict->pImage)==GFX_STATUS_FAILURE) return (GFX_STATUS_FAILURE); } if(GFX_GOL_ObjectStateGet(pPict, GFX_GOL_PICTURECONTROL_STREAM_STATE)) { if(pPict->count > 0) { SYS_TMR_DelayMS(pPict->delay); pPict->count -= 1; pPict->pImage = (GFX_RESOURCE_HDR*)*pPict->stream++; //Index to next bitmap in stream return(GFX_STATUS_FAILURE); } } state = DRAW_BACKGROUND1; case DRAW_BACKGROUND1: GFX_ColorSet(pPict->hdr.pGolScheme->CommonBkColor); if(GFX_RectangleFillDraw(pPict->hdr.left + 1, pPict->hdr.top + 1, pPict->hdr.right - 1, postop - 1) == GFX_STATUS_FAILURE) return (GFX_STATUS_FAILURE); state = DRAW_BACKGROUND2; case DRAW_BACKGROUND2: if(GFX_RectangleFillDraw(pPict->hdr.left + 1, posbottom, pPict->hdr.right - 1, pPict->hdr.bottom - 1) == GFX_STATUS_FAILURE) return (GFX_STATUS_FAILURE); state = DRAW_BACKGROUND3; case DRAW_BACKGROUND3: if(GFX_RectangleFillDraw(pPict->hdr.left + 1, postop, posleft - 1, posbottom) == GFX_STATUS_FAILURE) return (GFX_STATUS_FAILURE); state = DRAW_BACKGROUND4; case DRAW_BACKGROUND4: index = GFX_RectangleFillDraw(posright, postop, pPict->hdr.right - 1, posbottom); if(index == GFX_STATUS_FAILURE) { return (GFX_STATUS_FAILURE); } state = DRAW_FRAME; case DRAW_FRAME: if(GFX_GOL_ObjectStateGet(pPict, GFX_GOL_PICTURECONTROL_FRAME_STATE)) { GFX_LineStyleSet(GFX_LINE_STYLE_THIN_SOLID); GFX_ColorSet(pPict->hdr.pGolScheme->TextColor0); index = GFX_RectangleDraw(pPict->hdr.left, pPict->hdr.top, pPict->hdr.right, pPict->hdr.bottom); if(index == GFX_STATUS_FAILURE) { return (GFX_STATUS_FAILURE); } } state = REMOVE; return (GFX_STATUS_SUCCESS); } return (GFX_STATUS_SUCCESS); }
// ***************************************************************************** GFX_STATUS GFX_GOL_StaticTextDraw(void *pObject) { typedef enum { DRAW_STATIC_TEXT_IDLE, DRAW_STATIC_TEXT_CLEANAREA, DRAW_STATIC_TEXT_INIT, DRAW_STATIC_TEXT_DRAWTEXT, } ST_DRAW_STATES; static ST_DRAW_STATES state = DRAW_STATIC_TEXT_IDLE; GFX_GOL_STATICTEXT *pSt; static uint16_t adjustBackground = 0; #ifdef GFX_CONFIG_ALPHABLEND_DISABLE #ifndef GFX_CONFIG_TRANSPARENT_COLOR_DISABLE uint16_t transparentColorStatus; GFX_COLOR transparentColorSet = 0; #endif #endif pSt = (GFX_GOL_STATICTEXT *)pObject; while(1) { if (GFX_RenderStatusGet() == GFX_STATUS_BUSY_BIT) return (GFX_STATUS_FAILURE); switch(state) { case DRAW_STATIC_TEXT_IDLE: #ifdef GFX_CONFIG_BISTABLE_DISPLAY_AUTO_REFRESH_ENABLE GFX_DRIVER_SetupDrawUpdate( \ pSt->hdr.left, \ pSt->hdr.top, \ pSt->hdr.right, \ pSt->hdr.bottom); #endif if (GFX_GOL_ObjectStateGet(pSt, GFX_GOL_STATICTEXT_HIDE_STATE)) { // Hide the GFX_GOL_STATICTEXT (remove from screen) if (GFX_GOL_ObjectHideDraw(&(pSt->hdr)) != GFX_STATUS_SUCCESS) return (GFX_STATUS_FAILURE); // State is still IDLE STATE so no need to set state #ifdef GFX_CONFIG_BISTABLE_DISPLAY_AUTO_REFRESH_ENABLE GFX_DRIVER_CompleteDrawUpdate( \ pSt->hdr.left, \ pSt->hdr.top, \ pSt->hdr.right, \ pSt->hdr.bottom); #endif return (GFX_STATUS_SUCCESS); } if(GFX_GOL_ObjectStateGet(pSt, GFX_GOL_STATICTEXT_DRAW_STATE)) { // show frame if specified to be shown GFX_LineStyleSet(GFX_LINE_STYLE_THIN_SOLID); if(GFX_GOL_ObjectStateGet(pSt, GFX_GOL_STATICTEXT_FRAME_STATE)) { adjustBackground = 1; // set the line style to solid thin line GFX_LineStyleSet(GFX_LINE_STYLE_THIN_SOLID); if(!GFX_GOL_ObjectStateGet(pSt, GFX_GOL_STATICTEXT_DISABLED_STATE)) { // show enabled color GFX_ColorSet(pSt->hdr.pGolScheme->Color1); if(GFX_RectangleDraw( pSt->hdr.left, pSt->hdr.top, pSt->hdr.right, pSt->hdr.bottom) != GFX_STATUS_SUCCESS) { return (GFX_STATUS_FAILURE); } } else { // show disabled color GFX_ColorSet(pSt->hdr.pGolScheme->ColorDisabled); if(GFX_RectangleDraw( pSt->hdr.left, pSt->hdr.top, pSt->hdr.right, pSt->hdr.bottom) != GFX_STATUS_SUCCESS) { return (GFX_STATUS_FAILURE); } } } else { adjustBackground = 0; } } // check if there is no background if(GFX_GOL_ObjectStateGet(pSt, GFX_GOL_STATICTEXT_NOBACKGROUNDCOLORFILL_STATE)) { state = DRAW_STATIC_TEXT_INIT; break; } else { state = DRAW_STATIC_TEXT_CLEANAREA; } case DRAW_STATIC_TEXT_CLEANAREA: /* The refreshing of the static area is dependent on the features set. Case 1: When fill style is GFX_FILL_STYLE_NONE, text cannot be changed and refreshed. If text changes then use one of the following fill styles: GFX_FILL_STYLE_COLOR GFX_FILL_STYLE_ALPHA_COLOR GFX_FILL_STYLE_GRADIENT_DOWN, GFX_FILL_STYLE_GRADIENT_UP, GFX_FILL_STYLE_GRADIENT_RIGHT, GFX_FILL_STYLE_GRADIENT_LEFT, GFX_FILL_STYLE_GRADIENT_DOUBLE_VER, GFX_FILL_STYLE_GRADIENT_DOUBLE_HOR, or use (or enable) the common background image if available in the application (see case 2). Case 2: When common background image is set, then GFX_FILL_STYLE_NONE can be used. Redrawing the static text will redraw the background which in turn refreshes the text. Therefore, in this case the text can be modified. Case 3: Alpha blending cannot be used with gradient fills. Therefore, do use gradient fills when alpha blending of panels are enabled. */ // check if fill style is GFX_FILL_STYLE_NONE and common // background is present if ((pSt->hdr.pGolScheme->pCommonBkImage != NULL) && (pSt->hdr.pGolScheme->fillStyle == GFX_FILL_STYLE_NONE)) { #ifdef GFX_CONFIG_ALPHABLEND_DISABLE #ifndef GFX_CONFIG_TRANSPARENT_COLOR_DISABLE if (GFX_TransparentColorStatusGet() == GFX_FEATURE_ENABLED) { // disable the transparent color since we want the // background to refresh with all pixels being drawn GFX_TransparentColorDisable(); transparentColorStatus = 1; transparentColorSet = GFX_TransparentColorGet(); } #endif #endif if (GFX_ImagePartialDraw( pSt->hdr.left + adjustBackground, pSt->hdr.top + adjustBackground, pSt->hdr.left - pSt->hdr.pGolScheme->CommonBkLeft + adjustBackground, pSt->hdr.top - pSt->hdr.pGolScheme->CommonBkTop + adjustBackground, pSt->hdr.right - pSt->hdr.left + 1 - (adjustBackground << 1), pSt->hdr.bottom - pSt->hdr.top + 1 - (adjustBackground << 1), pSt->hdr.pGolScheme->pCommonBkImage ) != GFX_STATUS_SUCCESS) { return (GFX_STATUS_FAILURE); } #ifdef GFX_CONFIG_ALPHABLEND_DISABLE #ifndef GFX_CONFIG_TRANSPARENT_COLOR_DISABLE // after rendering the background, we need to restore the // transparent color if previously enabled. if (transparentColorStatus) { GFX_TransparentColorEnable(transparentColorSet); } #endif #endif } else { if (pSt->hdr.pGolScheme->fillStyle != GFX_FILL_STYLE_NONE) { // clean area where text will be placed. GFX_ColorSet(pSt->hdr.pGolScheme->CommonBkColor); GFX_GOL_ObjectBackGroundSet(&pSt->hdr); if(GFX_RectangleFillDraw( pSt->hdr.left + 1, pSt->hdr.top + 1, pSt->hdr.right - 1, pSt->hdr.bottom - 1) != GFX_STATUS_SUCCESS) { return (GFX_STATUS_FAILURE); } } } state = DRAW_STATIC_TEXT_INIT; case DRAW_STATIC_TEXT_INIT: if (GFX_RenderStatusGet() == GFX_STATUS_BUSY_BIT) return (GFX_STATUS_FAILURE); // set the text color if(!GFX_GOL_ObjectStateGet(pSt, GFX_GOL_STATICTEXT_DISABLED_STATE)) { GFX_ColorSet(pSt->hdr.pGolScheme->TextColor0); } else { GFX_ColorSet(pSt->hdr.pGolScheme->TextColorDisabled); } // use the font specified in the object GFX_FontSet(pSt->hdr.pGolScheme->pFont); state = DRAW_STATIC_TEXT_DRAWTEXT; case DRAW_STATIC_TEXT_DRAWTEXT: if (GFX_TextStringBoxDraw( \ pSt->hdr.left + 1, \ pSt->hdr.top + 1, \ pSt->hdr.right - pSt->hdr.left - 1, \ pSt->hdr.bottom - pSt->hdr.top - 1, \ pSt->pText, \ 0, \ pSt->alignment) != GFX_STATUS_SUCCESS) return (GFX_STATUS_FAILURE); state = DRAW_STATIC_TEXT_IDLE; // go back to IDLE state #ifdef GFX_CONFIG_BISTABLE_DISPLAY_AUTO_REFRESH_ENABLE GFX_DRIVER_CompleteDrawUpdate( \ pSt->hdr.left, \ pSt->hdr.top, \ pSt->hdr.right, \ pSt->hdr.bottom); #endif return (GFX_STATUS_SUCCESS); } // end of switch() } // end of while(1) }