Ejemplo n.º 1
0
/*********************************************************************
* Function: WORD DmDraw(void *pObj)
*
* Notes: This is the state machine to display the changing numbers.
*
**********************************************************************/
WORD DmDraw(void *pObj)
{
    typedef enum
    {
        DM_STATE_IDLE,
        DM_STATE_FRAME,
        DM_STATE_DRAW_FRAME,
        DM_STATE_INIT,
        DM_STATE_SETALIGN,
        DM_STATE_SETTEXT,
        DM_STATE_ERASETEXT,
        DM_STATE_DRAWTEXT,
        DM_STATE_WRAPUP
    } DM_DRAW_STATES;

    DIGITALMETER *pDm = NULL;
    static DM_DRAW_STATES state = DM_STATE_IDLE;
    static SHORT charCtr = 0, lineCtr = 0;
    static XCHAR CurValue[DM_WIDTH], PreValue[DM_WIDTH];
    static SHORT textWidth = 0;
    static XCHAR ch = 0, pch = 0;

    pDm = (DIGITALMETER *)pObj;

    while(1)
    {

    if(IsDeviceBusy())
        return (0);
    
        switch(state)
        {
            case DM_STATE_DRAW_FRAME:
                if(Rectangle(pDm->hdr.left, pDm->hdr.top, pDm->hdr.right, pDm->hdr.bottom) == 0)
                    return (0);
                state = DM_STATE_INIT;
                break;

            case DM_STATE_IDLE:
                SetClip(CLIP_DISABLE);
    
#ifdef USE_BISTABLE_DISPLAY_GOL_AUTO_REFRESH
                GFX_DRIVER_SetupDrawUpdate( pDm->hdr.left,
                                            pDm->hdr.top,
                                            pDm->hdr.right,
                                            pDm->hdr.bottom);
#endif
                if(GetState(pDm, DM_HIDE) || GetState(pDm, DM_DRAW))
                {
    	            SetColor(pDm->hdr.pGolScheme->CommonBkColor);
    	            if(Bar(pDm->hdr.left, pDm->hdr.top, pDm->hdr.right, pDm->hdr.bottom) == 0)
    	            	return (0);
    			}
                // if the draw state was to hide then state is still IDLE STATE so no need to change state
                if (GetState(pDm, DM_HIDE))
                {
#ifdef USE_BISTABLE_DISPLAY_GOL_AUTO_REFRESH
                    GFX_DRIVER_CompleteDrawUpdate(   pDm->hdr.left,
                                                    pDm->hdr.top,
                                                    pDm->hdr.right,
                                                    pDm->hdr.bottom);
#endif
                	return (1);
                }
                state = DM_STATE_FRAME;	
    
            case DM_STATE_FRAME:
    
    			if(GetState(pDm, DM_DRAW | DM_FRAME) == (DM_DRAW | DM_FRAME))
                {
                    // show frame if specified to be shown
                    SetLineType(SOLID_LINE);
                    SetLineThickness(NORMAL_LINE);
                    if(!GetState(pDm, DM_DISABLED))
                    {
    
                        // show enabled color
                        SetColor(pDm->hdr.pGolScheme->Color1);
                    }
                    else
                    {
    
                        // show disabled color
                        SetColor(pDm->hdr.pGolScheme->ColorDisabled);
                    }
                    state = DM_STATE_DRAW_FRAME;
                    break;
                }
                else 
                {
                    state = DM_STATE_INIT;
                }
    
            case DM_STATE_INIT:
                if(IsDeviceBusy())
                    return (0);
    
                // set clipping area, text will only appear inside the static text area.
                SetClip(CLIP_ENABLE);
                SetClipRgn(pDm->hdr.left + DM_INDENT, pDm->hdr.top, pDm->hdr.right - DM_INDENT, pDm->hdr.bottom);
    
                // set the text color
                if(!GetState(pDm, DM_DISABLED))
                {
                    SetColor(pDm->hdr.pGolScheme->TextColor0);
                }
                else
                {
                    SetColor(pDm->hdr.pGolScheme->TextColorDisabled);
                }
    
                // convert the values to be displayed in string format
                NumberToString(pDm->Pvalue, PreValue, pDm->NoOfDigits, pDm->DotPos);
                NumberToString(pDm->Cvalue, CurValue, pDm->NoOfDigits, pDm->DotPos);
    
                // use the font specified in the object
                SetFont(pDm->hdr.pGolScheme->pFont);
    
                state = DM_STATE_SETALIGN;  // go to drawing of text
    
            case DM_STATE_SETALIGN:
                if(!charCtr)
                {
    
                    // set position of the next character (based on alignment and next character)
                    textWidth = GetTextWidth(CurValue, pDm->hdr.pGolScheme->pFont);
    
                    // Display text with center alignment
                    if(GetState(pDm, (DM_CENTER_ALIGN)))
                    {
                        MoveTo((pDm->hdr.left + pDm->hdr.right - textWidth) >> 1, pDm->hdr.top + (lineCtr * pDm->textHeight));
                    }
    
                    // Display text with right alignment
                    else if(GetState(pDm, (DM_RIGHT_ALIGN)))
                    {
                        MoveTo((pDm->hdr.right - textWidth - DM_INDENT), pDm->hdr.top + (lineCtr * pDm->textHeight));
                    }
    
                    // Display text with left alignment
                    else
                    {
                        MoveTo(pDm->hdr.left + DM_INDENT, pDm->hdr.top + (lineCtr * pDm->textHeight));
                    }
                }
Ejemplo n.º 2
0
// *****************************************************************************
GFX_STATUS GFX_GOL_CheckBoxDraw(void *pObject)
{
    typedef enum
    {
        DRAW_CHECKBOX_START,
        DRAW_CHECKBOX_BOX_DRAW,
        DRAW_CHECKBOX_RUN_DRAW,
        DRAW_CHECKBOX_TEXT_DRAW,
        DRAW_CHECKBOX_TEXT_DRAW_RUN,
        DRAW_CHECKBOX_CHECK_SET_DRAW,
        DRAW_CHECKBOX_CHECK_DRAW,
        DRAW_CHECKBOX_FOCUS_DRAW
    } CB_DRAW_STATES;

    static CB_DRAW_STATES   state = DRAW_CHECKBOX_START;
    static int16_t          checkIndent;
    static uint16_t         width;
    GFX_GOL_CHECKBOX        *pCb;

    pCb = (GFX_GOL_CHECKBOX *)pObject;

    while(1)
    {
        if (GFX_RenderStatusGet() == GFX_STATUS_BUSY_BIT)
            return (GFX_STATUS_FAILURE);
    
        switch(state)
        {
            case DRAW_CHECKBOX_RUN_DRAW:

                if(GFX_GOL_PanelDraw() != GFX_STATUS_SUCCESS)
                {
                    return (GFX_STATUS_FAILURE);
                }
                state = DRAW_CHECKBOX_TEXT_DRAW;

            case DRAW_CHECKBOX_TEXT_DRAW:
                if(pCb->pText != NULL)
                {
                    GFX_FontSet(pCb->hdr.pGolScheme->pFont);
    
                    if(!GFX_GOL_ObjectStateGet(
                            pCb,
                            GFX_GOL_CHECKBOX_DISABLED_STATE))
                    {
                        GFX_ColorSet(pCb->hdr.pGolScheme->TextColor0);
                    }
                    else
                    {
                        GFX_ColorSet(pCb->hdr.pGolScheme->TextColorDisabled);
                    }
                    width = pCb->hdr.bottom - pCb->hdr.top;
                    state = DRAW_CHECKBOX_TEXT_DRAW_RUN;
                }
                else
                {
                    state = DRAW_CHECKBOX_CHECK_SET_DRAW;
                    break;
                }
    
            case DRAW_CHECKBOX_TEXT_DRAW_RUN:
                if (GFX_TextStringBoxDraw(
                        pCb->hdr.left + width + CB_INDENT,
                        pCb->hdr.top + pCb->hdr.pGolScheme->EmbossSize,
                        pCb->hdr.right -
                            pCb->hdr.left -
                            (pCb->hdr.pGolScheme->EmbossSize << 1) -
                            width,
                        width -
                            (pCb->hdr.pGolScheme->EmbossSize << 1),
                        pCb->pText,
                        0,
                        pCb->alignment) != GFX_STATUS_SUCCESS)
                {
                    return (GFX_STATUS_FAILURE);
                }

                state = DRAW_CHECKBOX_CHECK_SET_DRAW;
                break;

            case DRAW_CHECKBOX_START:
#ifdef GFX_CONFIG_BISTABLE_DISPLAY_AUTO_REFRESH_ENABLE
	        GFX_DRIVER_SetupDrawUpdate( pCb->hdr.left,
	                                    pCb->hdr.top,
	                                    pCb->hdr.right,
	                                    pCb->hdr.bottom);
#endif
                if(GFX_GOL_ObjectStateGet(pCb, GFX_GOL_CHECKBOX_HIDE_STATE))
                {
                    if (GFX_GOL_ObjectHideDraw(&(pCb->hdr)) != GFX_STATUS_SUCCESS)
                        return (GFX_STATUS_FAILURE);

#ifdef GFX_CONFIG_BISTABLE_DISPLAY_AUTO_REFRESH_ENABLE
                    GFX_DRIVER_CompleteDrawUpdate(   pCb->hdr.left,
	                                             pCb->hdr.top,
	                                             pCb->hdr.right,
	                                             pCb->hdr.bottom);
#endif
                    return (GFX_STATUS_SUCCESS);
                }
                else if(GFX_GOL_ObjectStateGet(
                        pCb,
                        GFX_GOL_CHECKBOX_DRAW_STATE))
                {

                    GFX_ColorSet(pCb->hdr.pGolScheme->CommonBkColor);
                    GFX_GOL_ObjectBackGroundSet(&pCb->hdr);

                    if(GFX_RectangleFillDraw(
                            pCb->hdr.left,
                            pCb->hdr.top,
                            pCb->hdr.right,
                            pCb->hdr.bottom) != GFX_STATUS_SUCCESS)
                    {
                        return (GFX_STATUS_FAILURE);
                    }
                }
    
                state = DRAW_CHECKBOX_BOX_DRAW;
    
            case DRAW_CHECKBOX_BOX_DRAW:

                GFX_LineStyleSet(GFX_LINE_STYLE_THIN_SOLID);

                if(GFX_GOL_ObjectStateGet(
                        pCb,
                        GFX_GOL_CHECKBOX_DRAW_STATE))
                {
                    if(GFX_GOL_ObjectStateGet(
                            pCb,
                            GFX_GOL_CHECKBOX_DISABLED_STATE))
                    {
                        GFX_GOL_PanelParameterSet(
                            pCb->hdr.left + CB_INDENT,
                            pCb->hdr.top + CB_INDENT,
                            pCb->hdr.left + \
                                (pCb->hdr.bottom - pCb->hdr.top) - CB_INDENT,
                            pCb->hdr.bottom - CB_INDENT,
                            0,
                            pCb->hdr.pGolScheme->ColorDisabled,
                            pCb->hdr.pGolScheme->EmbossDkColor,
                            pCb->hdr.pGolScheme->EmbossLtColor,
                            NULL,
                            pCb->hdr.pGolScheme->fillStyle,
                            pCb->hdr.pGolScheme->EmbossSize);
                    }
                    else
                    {
                        GFX_GOL_PanelParameterSet(
                            pCb->hdr.left + CB_INDENT,
                            pCb->hdr.top + CB_INDENT,
                            pCb->hdr.left + \
                                (pCb->hdr.bottom - pCb->hdr.top) - CB_INDENT,
                            pCb->hdr.bottom - CB_INDENT,
                            0,
                            pCb->hdr.pGolScheme->Color0,
                            pCb->hdr.pGolScheme->EmbossDkColor,
                            pCb->hdr.pGolScheme->EmbossLtColor,
                            NULL,
                            pCb->hdr.pGolScheme->fillStyle,
                            pCb->hdr.pGolScheme->EmbossSize);
                    }
                    // set the background information
                    GFX_GOL_PanelBackgroundSet(&pCb->hdr);
                    state = DRAW_CHECKBOX_RUN_DRAW;
                    break;
                }
                else
                {
                    state = DRAW_CHECKBOX_CHECK_SET_DRAW;
                }
   
            case DRAW_CHECKBOX_CHECK_SET_DRAW:
                if(GFX_GOL_ObjectStateGet(
                        pCb,
                        (GFX_GOL_CHECKBOX_DRAW_STATE | GFX_GOL_CHECKBOX_DRAW_CHECK_STATE)))
                {
                    if(!GFX_GOL_ObjectStateGet(
                            pCb,
                            GFX_GOL_CHECKBOX_DISABLED_STATE))
                    {
                        if(GFX_GOL_ObjectStateGet(
                                pCb,
                                GFX_GOL_CHECKBOX_CHECKED_STATE))
                        {
                            GFX_ColorSet(pCb->hdr.pGolScheme->TextColor0);
                            GFX_FillStyleSet(GFX_FILL_STYLE_COLOR);
                        }
                        else
                        {
                            GFX_GOL_ObjectBackGroundSet(&pCb->hdr);
                            GFX_ColorSet(pCb->hdr.pGolScheme->Color0);
                        }
                    }
                    else
                    {
                        if(GFX_GOL_ObjectStateGet(
                                pCb,
                                GFX_GOL_CHECKBOX_CHECKED_STATE))
                        {
                            GFX_ColorSet(pCb->hdr.pGolScheme->TextColorDisabled);
                            GFX_FillStyleSet(GFX_FILL_STYLE_COLOR);
                        }
                        else
                        {
                            GFX_GOL_ObjectBackGroundSet(&pCb->hdr);
                            GFX_ColorSet(pCb->hdr.pGolScheme->ColorDisabled);
                        }
                    }
    
                    checkIndent = (pCb->hdr.bottom - pCb->hdr.top) >> 2;
                    state = DRAW_CHECKBOX_CHECK_DRAW;
                }   
                else
                {
                    state = DRAW_CHECKBOX_FOCUS_DRAW;
                    break;
                }
    
            case DRAW_CHECKBOX_CHECK_DRAW:
                if (    GFX_RectangleFillDraw(
                            pCb->hdr.left +
                                checkIndent + pCb->hdr.pGolScheme->EmbossSize,
                            pCb->hdr.top +
                                checkIndent + pCb->hdr.pGolScheme->EmbossSize,
                            pCb->hdr.left +
                                (pCb->hdr.bottom - pCb->hdr.top) -
                                checkIndent - pCb->hdr.pGolScheme->EmbossSize,
                            pCb->hdr.bottom -
                                checkIndent - pCb->hdr.pGolScheme->EmbossSize)
                    != GFX_STATUS_SUCCESS)
                {
                    return (GFX_STATUS_FAILURE);
                }
    
                state = DRAW_CHECKBOX_FOCUS_DRAW;
    
            case DRAW_CHECKBOX_FOCUS_DRAW:
                if(GFX_GOL_ObjectStateGet(
                        pCb,
                        (GFX_GOL_CHECKBOX_DRAW_STATE |
                        GFX_GOL_CHECKBOX_DRAW_FOCUS_STATE)))
                {
                    if(GFX_GOL_ObjectStateGet(
                            pCb,
                            GFX_GOL_CHECKBOX_FOCUSED_STATE))
                    {
                        GFX_ColorSet(pCb->hdr.pGolScheme->TextColor0);
                    }
                    else
                    {
                        GFX_ColorSet(pCb->hdr.pGolScheme->CommonBkColor);
                    }
    
                    GFX_LineStyleSet(GFX_LINE_STYLE_THIN_DASHED);
                    if(GFX_RectangleDraw(
                            pCb->hdr.left,
                            pCb->hdr.top,
                            pCb->hdr.right,
                            pCb->hdr.bottom) != GFX_STATUS_SUCCESS)
                    {
                        return (GFX_STATUS_FAILURE);
                    }
    
                    GFX_LineStyleSet(GFX_LINE_STYLE_THIN_SOLID);
                }
    
                state = DRAW_CHECKBOX_START;
#ifdef GFX_CONFIG_BISTABLE_DISPLAY_AUTO_REFRESH_ENABLE
            	GFX_DRIVER_CompleteDrawUpdate(  pCb->hdr.left,
                                                pCb->hdr.top,
                                                pCb->hdr.right,
                                                pCb->hdr.bottom);
#endif
                return (GFX_STATUS_SUCCESS);
        } // end of switch()   
    } // end of while(1)
Ejemplo n.º 3
0
// *****************************************************************************
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)    
}
Ejemplo n.º 4
0
// *****************************************************************************
GFX_STATUS GFX_GOL_EditBoxDraw(void *pObject)
{
    typedef enum
    {
        DRAW_EDITBOX_START, 
        DRAW_EDITBOX_PANEL, 
        DRAW_EDITBOX_PREPARE_TEXT, 
        DRAW_EDITBOX_TEXT, 
        DRAW_EDITBOX_CARET, 
    } DRAW_EDITBOX_STATES;

    static DRAW_EDITBOX_STATES  state = DRAW_EDITBOX_START;
    static GFX_COLOR            tempColor;
    GFX_GOL_EDITBOX             *pEb;

    pEb = (GFX_GOL_EDITBOX *)pObject;

    while(1)
    {
        if (GFX_RenderStatusGet() == GFX_STATUS_BUSY_BIT)
            return (GFX_STATUS_FAILURE);

        switch(state)
        {
    
            case DRAW_EDITBOX_START:
#ifdef GFX_LIB_CFG_USE_BISTABLE_DISPLAY_GOL_AUTO_REFRESH
                GFX_DRIVER_SetupDrawUpdate( pEb->hdr.left,
                                            pEb->hdr.top,
                                            pEb->hdr.right,
                                            pEb->hdr.bottom);
#endif
    
              	if(GFX_GOL_ObjectStateGet(pEb, GFX_GOL_EDITBOX_HIDE_STATE))
                {

                    // Hide the object (remove from screen)
                    if (GFX_GOL_ObjectHideDraw(&(pEb->hdr)) != GFX_STATUS_SUCCESS)
                        return (GFX_STATUS_FAILURE);

#ifdef GFX_LIB_CFG_USE_BISTABLE_DISPLAY_GOL_AUTO_REFRESH
                    GFX_DRIVER_CompleteDrawUpdate(  pEb->hdr.left,
                                                    pEb->hdr.top,
                                                    pEb->hdr.right,
                                                    pEb->hdr.bottom);
#endif
                    return (GFX_STATUS_SUCCESS);
                }
    
                if(GFX_GOL_ObjectStateGet(pEb,GFX_GOL_EDITBOX_DISABLED_STATE))
                {
                    tempColor = pEb->hdr.pGolScheme->ColorDisabled;
    	        }
                else
                {
                    tempColor = pEb->hdr.pGolScheme->Color0;
                }
    
                if(GFX_GOL_ObjectStateGet(pEb,GFX_GOL_EDITBOX_DRAW_STATE))
                {
                    // set up the background
                    GFX_GOL_PanelBackgroundSet(&pEb->hdr);

                    // set panel parameters
                    GFX_GOL_PanelParameterSet
                    (
                        pEb->hdr.left,
                        pEb->hdr.top,
                        pEb->hdr.right,
                        pEb->hdr.bottom,
                        0,
                        tempColor,
                        pEb->hdr.pGolScheme->EmbossDkColor,
                        pEb->hdr.pGolScheme->EmbossLtColor,
                        NULL,
                        pEb->hdr.pGolScheme->fillStyle,
                        pEb->hdr.pGolScheme->EmbossSize
                    );
    
                    state = DRAW_EDITBOX_PANEL;
                    // no break here since it will always go
                    // to the DRAW_EDITBOX_PANEL state
                }
                else
                {
                    state = DRAW_EDITBOX_PREPARE_TEXT;
                    break;
                }    
                
            case DRAW_EDITBOX_PANEL:

                if(GFX_GOL_PanelDraw() != GFX_STATUS_SUCCESS)
		{
                    return (GFX_STATUS_FAILURE);
                }
                state = DRAW_EDITBOX_PREPARE_TEXT;
                // no break here since it will always go to
                // the DRAW_EDITBOX_PREPARE_TEXT state
    
            case DRAW_EDITBOX_PREPARE_TEXT:
    
    	        GFX_FontSet(pEb->hdr.pGolScheme->pFont);
    
                if(GFX_GOL_ObjectStateGet(pEb,GFX_GOL_EDITBOX_DISABLED_STATE))
                {
                    GFX_ColorSet(pEb->hdr.pGolScheme->TextColorDisabled);
                }
                else
                {
                    GFX_ColorSet(pEb->hdr.pGolScheme->TextColor0);
                }
  
                state = DRAW_EDITBOX_TEXT;
    		    
    		// no break here since it will always go to
                // the DRAW_EDITBOX_TEXT state
    
            case DRAW_EDITBOX_TEXT:

                // render the text
                if (GFX_TextStringBoxDraw(
                    pEb->hdr.left + pEb->hdr.pGolScheme->EmbossSize,
                    pEb->hdr.top  + pEb->hdr.pGolScheme->EmbossSize,
                    pEb->hdr.right - pEb->hdr.left -
                        (pEb->hdr.pGolScheme->EmbossSize << 1),
                    pEb->hdr.bottom - pEb->hdr.top -
                        (pEb->hdr.pGolScheme->EmbossSize << 1),
                    pEb->pText,
                    0,
                    pEb->alignment) != GFX_STATUS_SUCCESS)
                {
                  return (GFX_STATUS_FAILURE);
                };
       			
                // draw the caret if required
                if(!GFX_GOL_ObjectStateGet(
                        pEb,
                        GFX_GOL_EDITBOX_DISABLED_STATE))
                {
    	            if(    (GFX_GOL_ObjectStateGet(
                                pEb,
                                GFX_GOL_EDITBOX_FOCUSED_STATE) &&
                            GFX_GOL_ObjectStateGet(
                                pEb,
                                GFX_GOL_EDITBOX_DRAW_CARET_STATE)
                           ) ||
                           (GFX_GOL_ObjectStateGet(
                                pEb,
                                GFX_GOL_EDITBOX_ENABLE_CARET_STATE)
                            )
                      )
                    {
                        GFX_ColorSet(pEb->hdr.pGolScheme->TextColor0);
                    }
                    else
                    {
                        GFX_ColorSet(pEb->hdr.pGolScheme->Color0);
                    }
                    state = DRAW_EDITBOX_CARET;

                    // no break here since it will always go to
                    // the DRAW_EDITBOX_CARET state
                }
                else
                {
                    state = DRAW_EDITBOX_START;
#ifdef GFX_LIB_CFG_USE_BISTABLE_DISPLAY_GOL_AUTO_REFRESH
                    GFX_DRIVER_CompleteDrawUpdate(  pEb->hdr.left,
                                                    pEb->hdr.top,
                                                    pEb->hdr.right,
                                                    pEb->hdr.bottom);
#endif
                    return (GFX_STATUS_SUCCESS);
                }
   
            case DRAW_EDITBOX_CARET:
            
                // draw the caret if required
                if(!GFX_BarDraw(
                        GFX_TextCursorPositionXGet(),
                        GFX_TextCursorPositionYGet(),
                        GFX_TextCursorPositionXGet() +
                            GFX_GOL_EDITBOX_CARET_WIDTH,
                        GFX_TextCursorPositionYGet() +
                            pEb->textHeight)
                  )
                {
                    return (GFX_STATUS_FAILURE);
                }
    
                state = DRAW_EDITBOX_START;

#ifdef GFX_LIB_CFG_USE_BISTABLE_DISPLAY_GOL_AUTO_REFRESH
                GFX_DRIVER_CompleteDrawUpdate(  pEb->hdr.left,
                                                pEb->hdr.top,
                                                pEb->hdr.right,
                                                pEb->hdr.bottom);
#endif
                return (GFX_STATUS_SUCCESS);
        } // switch()
        
    }//  while(1)

}