Beispiel #1
0
/*********************************************************************
* Function: uint16_t PictTranslateMsg(void *pObj, GFX_OBJ_MESSAGE *pMsg)
*
* Overview: translates the GOL message for the picture control
*
********************************************************************/
GFX_GOL_TRANSLATED_ACTION GFX_GOL_PictureControlActionGet(void *pObj, GFX_GOL_MESSAGE *pMsg)
{
    GFX_GOL_PICTURECONTROL *pPict;

    pPict = (GFX_GOL_PICTURECONTROL *)pObj;

    // Evaluate if the message is for the picture
    // Check if disabled first
    if(GFX_GOL_ObjectStateGet(pPict, GFX_GOL_PICTURECONTROL_DISABLED_STATE))
        return (GFX_GOL_OBJECT_ACTION_INVALID);

        #ifdef USE_TOUCHSCREEN
    if(pMsg->type == TYPE_TOUCHSCREEN)
    {

        // Check if it falls in the picture area
        if
        (
            (pPict->hdr.left < pMsg->param1) &&
            (pPict->hdr.right > pMsg->param1) &&
            (pPict->hdr.top < pMsg->param2) &&
            (pPict->hdr.bottom > pMsg->param2)
        )
        {
            return (GFX_GOL_PICTURECONTROL_ACTION_SELECTED);
        }
    }

        #endif
    return (GFX_GOL_OBJECT_ACTION_INVALID);
}
Beispiel #2
0
/*********************************************************************
 * Function: uint16_t StTranslateMsg(void *pObj, GFX_GOL_MESSAGE *pMsg)
 *
 * Notes: Evaluates the message if the object will be affected by the
 *		 message or not.
 *
 ********************************************************************/
GFX_GOL_TRANSLATED_ACTION GFX_GOL_StaticTextActionGet(void *pObj, GFX_GOL_MESSAGE *pMsg)
{

    GFX_GOL_STATICTEXT *pSt;

    pSt = (GFX_GOL_STATICTEXT *) pObj;


    // Evaluate if the message is for the static text
    // Check if disabled first
    if (GFX_GOL_ObjectStateGet(pSt, GFX_GOL_STATICTEXT_DISABLED_STATE))
        return (GFX_GOL_OBJECT_ACTION_INVALID);

#ifdef USE_TOUCHSCREEN
    if (pMsg->type == TYPE_TOUCHSCREEN)
    {

        // Check if it falls in static text control borders
        if
            (
                (pSt->hdr.left < pMsg->param1) &&
                (pSt->hdr.right > pMsg->param1) &&
                (pSt->hdr.top < pMsg->param2) &&
                (pSt->hdr.bottom > pMsg->param2)
                )
        {
            return (GFX_GOL_STATICTEXT_ACTION_SELECTED);
        }
    }

#endif
    return (GFX_GOL_OBJECT_ACTION_INVALID);
}
Beispiel #3
0
/*********************************************************************
 * Function: uint16_t SldGetHeight(GFX_GOL_SCROLLBAR *pSld)
 *
 * Notes: An INTERNAL function that computes for the height
 *        of the thumb. This function is created to save
 *        code size. This function is called only to dynamically
 *        compute for the thumb size.
 *
 ********************************************************************/
uint16_t SldGetHeight(GFX_GOL_SCROLLBAR *pSld)
{
    uint16_t temp;

    /*
                Calculating the height is dependent on the mode type.
                If type Scrollbar, width is dependent on the ratio of the
                page/range = width/max-min (see SetThumbSize())
                if type is Slider, width is dependent on width*3/8
	
                When vertical height is dynamic, width is contant.
     */
    if (GFX_GOL_ObjectStateGet(pSld, GFX_GOL_SCROLLBAR_VERTICAL_STATE))
    {
        if (GFX_GOL_ObjectStateGet(pSld, GFX_GOL_SCROLLBAR_SLIDER_MODE_STATE))
        {
            temp = SldSetThumbSize(pSld, pSld->hdr.bottom, pSld->hdr.top);
        }
        else
        {
            temp = (((pSld->hdr.right - pSld->hdr.left) - (GFX_GOL_EMBOSS_SIZE << 1) - 2) * 3) >> 3;
        }
    }
    else
    {
Beispiel #4
0
/*********************************************************************
 * Function: uint16_t SldGetWidth(GFX_GOL_SCROLLBAR *pSld)
 *
 * Notes: An INTERNAL function that computes for the width
 *        of the thumb. This function is created to save
 *        code size. This function is called only to dynamically
 *        compute for the thumb size.
 *
 ********************************************************************/
uint16_t SldGetWidth(GFX_GOL_SCROLLBAR *pSld)
{
    uint16_t temp;

    /*
                Calculating the width is dependent on the mode type.
                If type Scrollbar, width is dependent on the ratio of the
                page/range = width/max-min (see SetThumbSize())
                if type is Slider, width is dependent on height*3/8
		
                When horizontal width is dynamic, height is contant.
	
     */
    if (GFX_GOL_ObjectStateGet(pSld, GFX_GOL_SCROLLBAR_VERTICAL_STATE))
    {
        temp = pSld->hdr.right - pSld->hdr.left;
        if (GFX_GOL_ObjectStateGet(pSld, GFX_GOL_SCROLLBAR_SLIDER_MODE_STATE))
        {
            temp = temp - (GFX_GOL_EMBOSS_SIZE << 1);
        }
        else
        {
            temp = temp - (GFX_GOL_EMBOSS_SIZE << 1) - 2;
        }
    }
    else
    {
        if (GFX_GOL_ObjectStateGet(pSld, GFX_GOL_SCROLLBAR_SLIDER_MODE_STATE))
        {
            temp = SldSetThumbSize(pSld, pSld->hdr.right, pSld->hdr.left);
        }
        else
        {
            temp = (((pSld->hdr.bottom - pSld->hdr.top) - (GFX_GOL_EMBOSS_SIZE << 1) - 2) * 3) >> 3;
        }
    }

    // to avoid calculations of dividing by two, we store half the width value
    return (temp >> 1);
}
// *****************************************************************************
GFX_GOL_TRANSLATED_ACTION GFX_GOL_EditBoxActionGet(
                                void *pObject,
                                GFX_GOL_MESSAGE *pMessage)
{
    GFX_GOL_EDITBOX *pEb;

    pEb = (GFX_GOL_EDITBOX *)pObject;

    // Evaluate if the message is for the edit box
    // Check if disabled first
    if (GFX_GOL_ObjectStateGet(pEb, GFX_GOL_EDITBOX_DISABLED_STATE))
        return (GFX_GOL_OBJECT_ACTION_INVALID);

#ifndef  GFX_CONFIG_USE_TOUCHSCREEN_DISABLE
    if(pMessage->type == TYPE_TOUCHSCREEN)
    {
        // Check if it falls in edit box borders
        if( (pEb->hdr.left     < pMessage->param1) &&
            (pEb->hdr.right    > pMessage->param1) &&
            (pEb->hdr.top      < pMessage->param2) &&
            (pEb->hdr.bottom   > pMessage->param2))
        {
            return GFX_GOL_EDITBOX_ACTION_TOUCHSCREEN;
        }

        return GFX_GOL_OBJECT_ACTION_INVALID;
	}
#endif

#ifndef GFX_CONFIG_USE_KEYBOARD_DISABLE
    if(pMessage->type == TYPE_KEYBOARD) {

        if(pMessage->uiEvent == EVENT_CHARCODE)
            return GFX_GOL_EDITBOX_ACTION_ADD_CHAR;

        if(pMessage->uiEvent == EVENT_KEYSCAN)
            if(pMessage->param2 == SCAN_BS_PRESSED)
                return GFX_GOL_EDITBOX_ACTION_DEL_CHAR;

	    return GFX_GOL_OBJECT_ACTION_INVALID;
	}
#endif


	return GFX_GOL_OBJECT_ACTION_INVALID;
}
// *****************************************************************************
void GFX_GOL_CheckBoxActionSet(
                                GFX_GOL_TRANSLATED_ACTION translatedMsg,
                                void *pObject,
                                GFX_GOL_MESSAGE *pMessage)
{
    GFX_GOL_CHECKBOX *pCb;

    pCb = (GFX_GOL_CHECKBOX *)pObject;

#ifndef GFX_CONFIG_FOCUS_DISABLE
#ifndef GFX_CONFIG_USE_TOUCHSCREEN_DISABLE
    if(pMsg->type == TYPE_TOUCHSCREEN)
    {
        if(!GFX_GOL_ObjectStateGet(pCb, GFX_GOL_CHECKBOX_FOCUSED_STATE))
        {
            GFX_GOL_ObjectFocusSet((OBJ_HEADER *)pCb);
        }
    }

#endif
#endif

    switch(translatedMsg)
    {
        case GFX_GOL_CHECKBOX_ACTION_CHECKED:
            // Set checked and redraw
            GFX_GOL_ObjectStateSet( pCb, GFX_GOL_CHECKBOX_CHECKED_STATE |
                                    GFX_GOL_CHECKBOX_DRAW_CHECK_STATE);
            break;

        case GFX_GOL_CHECKBOX_ACTION_UNCHECKED:
            // Reset check
            GFX_GOL_ObjectStateClear(pCb, GFX_GOL_CHECKBOX_CHECKED_STATE);
            // Redraw
            GFX_GOL_ObjectStateSet(pCb, GFX_GOL_CHECKBOX_DRAW_CHECK_STATE);
            break;
        default:
            // do nothing
            return;
    }
}
// *****************************************************************************
void GFX_GOL_EditBoxActionSet(
                                GFX_GOL_TRANSLATED_ACTION translatedMsg,
                                void *pObject,
                                GFX_GOL_MESSAGE *pMessage)
{

    GFX_GOL_EDITBOX *pEb;

    pEb = (GFX_GOL_EDITBOX *)pObject;

#if defined(GFX_LIB_CFG_USE_FOCUS)
#ifndef  GFX_CONFIG_USE_TOUCHSCREEN_DISABLE
    if(pMessage->type == TYPE_TOUCHSCREEN)
    {
        if(!GFX_GOL_ObjectStateGet(pEb,GFX_GOL_EDITBOX_FOCUSED_STATE)){
                GFX_GOL_ObjectFocusSet((OBJ_HEADER*)pEb);
        }
    }
#endif
#endif

    switch(translatedMsg)
    {

        case GFX_GOL_EDITBOX_ACTION_ADD_CHAR:
            GFX_GOL_EditBoxCharAdd(pEb,(GFX_XCHAR)pMessage->param2);
            GFX_GOL_ObjectStateSet(pEb, GFX_GOL_EDITBOX_DRAW_STATE);
            break;

        case GFX_GOL_EDITBOX_ACTION_DEL_CHAR:
            GFX_GOL_EditBoxCharRemove(pEb);
            GFX_GOL_ObjectStateSet(pEb, GFX_GOL_EDITBOX_DRAW_STATE);
            break;

        default:
            // do nothing
            break;

    }
}
Beispiel #8
0
/*********************************************************************
* 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);
}
Beispiel #9
0
/*********************************************************************
 * Function: uint16_t GFX_GOL_StaticTextDraw(void *pObj)
 *
 * Notes: This is the state machine to draw the static text.
 *
 ********************************************************************/
GFX_STATUS GFX_GOL_StaticTextDraw(void *pObject)
{

    typedef enum
    {
        GFX_GOL_STATICTEXT_STATE_IDLE,
        GFX_GOL_STATICTEXT_STATE_CLEANAREA,
        GFX_GOL_STATICTEXT_STATE_INIT,
        WAIT
    } GFX_GOL_STATICTEXT_DRAW_STATES;

    static GFX_GOL_STATICTEXT_DRAW_STATES state = GFX_GOL_STATICTEXT_STATE_IDLE;
    static GFX_STATUS index;
    GFX_GOL_STATICTEXT *pSt;

    pSt = (GFX_GOL_STATICTEXT *) pObject;

    while (1)
    {
        switch (state)
        {
            case GFX_GOL_STATICTEXT_STATE_IDLE:
                if (GFX_GOL_ObjectStateGet(pSt, GFX_GOL_STATICTEXT_HIDE_STATE))
                {
                    GFX_ColorSet(pSt->hdr.pGolScheme->CommonBkColor);
                    if (GFX_RectangleFillDraw(pSt->hdr.left, pSt->hdr.top, pSt->hdr.right, pSt->hdr.bottom) == GFX_STATUS_FAILURE)
                        return (GFX_STATUS_FAILURE);

                    // State is still IDLE STATE so no need to set state
                    return (GFX_STATUS_SUCCESS);
                }

                if (GFX_GOL_ObjectStateGet(pSt, GFX_GOL_STATICTEXT_DRAW_STATE))
                {

                    if (GFX_GOL_ObjectStateGet(pSt, GFX_GOL_STATICTEXT_FRAME_STATE))
                    {

                    // show frame if specified to be shown
                    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);
                    }
                    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_FAILURE)
                            return (GFX_STATUS_FAILURE);
                    }
                }

                state = GFX_GOL_STATICTEXT_STATE_CLEANAREA;

            case GFX_GOL_STATICTEXT_STATE_CLEANAREA:

            #ifdef USE_ALPHABLEND                //Draw the background image
            if (pSt->hdr.pGolScheme->AlphaValue != 100)
            {

                GFX_AlphaParamsSet(GFX_Primitive_instance.backgroundPage,pSt->hdr.left, pSt->hdr.top,
                                 GFX_Primitive_instance.backgroundPage,pSt->hdr.left, pSt->hdr.top,
                                 GFX_Primitive_instance.activePage,pSt->hdr.left, pSt->hdr.top);

                if(CopyPageWindow(
                        &GFX_Primitive_instance.alphaArea,
                        pSt->hdr.right - pSt->hdr.left, pSt->hdr.bottom - pSt->hdr.top) == GFX_STATUS_FAILURE)
                        return(GFX_STATUS_FAILURE);
            }
            else
            #endif
            {
                // clean area where text will be placed.
                GFX_ColorSet(pSt->hdr.pGolScheme->CommonBkColor);
                if (GFX_RectangleFillDraw(pSt->hdr.left, pSt->hdr.top, pSt->hdr.right, pSt->hdr.bottom) == GFX_STATUS_FAILURE)
                    return (GFX_STATUS_FAILURE);
            }
            state = GFX_GOL_STATICTEXT_STATE_INIT;

            case GFX_GOL_STATICTEXT_STATE_INIT:
                // 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);

                index = GFX_TextStringBoxDraw(
                        
                        pSt->hdr.left,
                        pSt->hdr.top,
                        pSt->hdr.right - pSt->hdr.left,
                        pSt->hdr.bottom - pSt->hdr.top,
                        pSt->pText, pSt->alignment);

                if(index == GFX_STATUS_FAILURE)
                {
                    return (GFX_STATUS_FAILURE);
                }
		state = WAIT;
            case WAIT:
                state = GFX_GOL_STATICTEXT_STATE_IDLE; // go back to IDLE state
                return (GFX_STATUS_SUCCESS);
        }
    } // end of switch()
} // end of while(1)    
// *****************************************************************************
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;

    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:

                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
                    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))
                    {

                        // 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);
                            }
                        }
                    }
                }

                // 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:
    
                // 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
                return (GFX_STATUS_SUCCESS);

        } // end of switch()
    } // end of while(1)    
}
// *****************************************************************************
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)    
}
// *****************************************************************************
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)
// *****************************************************************************
GFX_GOL_TRANSLATED_ACTION GFX_GOL_CheckBoxActionGet(
                                void *pObject,
                                GFX_GOL_MESSAGE *pMessage)
{
    GFX_GOL_CHECKBOX *pCb;

    pCb = (GFX_GOL_CHECKBOX *)pObject;

    // Evaluate if the message is for the check box
    // Check if disabled first
    if(GFX_GOL_ObjectStateGet(pCb, GFX_GOL_CHECKBOX_DISABLED_STATE))
        return (GFX_GOL_OBJECT_ACTION_INVALID);


#ifndef GFX_CONFIG_USE_TOUCHSCREEN_DISABLE
    if(pMessage->type == TYPE_TOUCHSCREEN)
    {

        // Check if it falls in the check box borders
        if
        (
            (pCb->hdr.left   < pMessage->param1) &&
            (pCb->hdr.right  > pMessage->param1) &&
            (pCb->hdr.top    < pMessage->param2) &&
            (pCb->hdr.bottom > pMessage->param2)
        )
        {
            if(pMessage->uiEvent == EVENT_RELEASE)
            {
                if(GFX_GOL_ObjectStateGet(pCb, GFX_GOL_CHECKBOX_CHECKED_STATE))
                    return (GFX_GOL_CHECKBOX_ACTION_UNCHECKED);
                else
                    return (GFX_GOL_CHECKBOX_ACTION_CHECKED);
            }
        }

        return (GFX_GOL_OBJECT_ACTION_INVALID);
    }

#endif
#ifndef GFX_CONFIG_USE_KEYBOARD_DISABLE
    if(pMessage->type == TYPE_KEYBOARD)
    {
        if((uint16_t)pMessage->param1 == pCb->hdr.ID)
        {
            if(pMessage->uiEvent == EVENT_KEYSCAN)
            {
                if( (pMessage->param2 == SCAN_SPACE_PRESSED) ||
                    (pMessage->param2 == SCAN_CR_PRESSED))
                {
                    if(GFX_GOL_ObjectStateGet(
                            pCb,
                            GFX_GOL_CHECKBOX_CHECKED_STATE))
                    {
                        return (GFX_GOL_CHECKBOX_ACTION_UNCHECKED);
                    }
                    else
                    {
                        return (GFX_GOL_CHECKBOX_ACTION_CHECKED);
                    }
                }
            }
        }

        return (GFX_GOL_OBJECT_ACTION_INVALID);
    }

#endif
    return (GFX_GOL_OBJECT_ACTION_INVALID);
}
// *****************************************************************************
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)

}
Beispiel #15
0
/////////////////////////////////////////////////////////////////////////////
// Function: WORD GOLMsgCallback(WORD objMsg, OBJ_HEADER* pObj, GOL_MSG* pMsg)
// Input: objMsg - translated message for the object,
//        pObj - pointer to the object,
//        pMsg - pointer to the non-translated, raw GOL message
// Output: if the function returns non-zero the message will be processed by default
// Overview: it's a user defined function. GOLMsg() function calls it each
//           time the valid message for the object received
/////////////////////////////////////////////////////////////////////////////
bool GFX_GOL_MessageCallback(GFX_GOL_TRANSLATED_ACTION objMsg, GFX_GOL_OBJ_HEADER *pObj, GFX_GOL_MESSAGE *pMsg)
{
    uint16_t objID;

    // check first if we need to exit the selected demo (if applicable)
    if ((objMsg == GFX_GOL_BUTTON_ACTION_RELEASED) && (pObj->ID == ID_BACK))
    {   
        // check if the button is indeed pressed
        if (GFX_GOL_ObjectStateGet(pObj, GFX_GOL_BUTTON_PRESSED_STATE))
        {
            screenState = CREATE_MAINMENU;
            return 1;
        }    
    }
    // process messages for demo screens
    switch(screenState)
    {
        case DISPLAY_MAINMENU:

            // In this portion, all management of the Button states are 
            // done here. This portion will always return 0 to inhibit
            // the button default message processing to take place.
                        
            objID = GFX_GOL_ObjectIDGet(pObj);
            if ((objID == ID_ICON1) || (objID == ID_ICON2) ||
                (objID == ID_ICON3) || (objID == ID_ICON4))
            {    
                if(objMsg == GFX_GOL_BUTTON_ACTION_PRESSED)
                {    
                    // check if button is pressed and show pressed icon
                    GFX_GOL_ObjectStateSet(pObj, GFX_GOL_BUTTON_PRESSED_STATE);
                }
                else if(objMsg == GFX_GOL_BUTTON_ACTION_RELEASED)
                {
                    // check if button is released and show release icon
                    GFX_GOL_ObjectStateClear(pObj, GFX_GOL_BUTTON_PRESSED_STATE);
                    if (objID == ID_ICON1)
                        {
                         while(GFX_DoubleBufferDisable() == GFX_STATUS_FAILURE);
                         PIPDemo();
                         screenState = CREATE_MAINMENU;
                         }
                        else if (objID == ID_ICON2)
                        {
                         while(GFX_DoubleBufferDisable() == GFX_STATUS_FAILURE);
                         SpeedDemo();
                         screenState = CREATE_MAINMENU;
                        }  
                        
                    else if (objID == ID_ICON3)
                        {
                        screenState = CREATE_ALPHABLEND;
                        } 
                   else if (objID == ID_ICON4)
                        {
                        while(GFX_DoubleBufferDisable() == GFX_STATUS_FAILURE);
                        PagingDemo();
                        screenState = CREATE_MAINMENU;
                        }
                    else
                        // this should not happen 
                        screenState = DISPLAY_MAINMENU;    
                }
                else if(objMsg == GFX_GOL_BUTTON_ACTION_STILLPRESSED)
                {
                    // do not do anything since it is already pressed
                    return 0;     
                }    
                else
                {
                    // check if button is released and show release icon
                    GFX_GOL_ObjectStateClear(pObj, GFX_GOL_BUTTON_PRESSED_STATE);              // reset pressed
                }            
                
                GFX_GOL_ObjectStateSet(pObj, GFX_GOL_BUTTON_DRAW_STATE);
                return 0;
            }
            if ((objID == ID_SCROLL1) || (objID == ID_SCROLL2) ||
                (objID == ID_SCROLL3) || (objID == ID_SCROLL4))
            {    
                if(objMsg == GFX_GOL_BUTTON_ACTION_RELEASED)
                {
                 switch(objID) //Up = 1, Down = 2, Left = 3, Right = 4 
                 {
                    case ID_SCROLL1:
                    ScrollScreen(3,10);
                    break;
                    case ID_SCROLL2:
                    ScrollScreen(1,10);
                    break;
                    case ID_SCROLL3:
                    ScrollScreen(4,10);
                    break;
                    case ID_SCROLL4:
                    ScrollScreen(2,10);
                    break;
                 }

                }
            }
            break;

        case DISPLAY_ALPHABLEND:
            return (MsgAlphaBlendScreenCallback(objMsg, pObj, pMsg));

        default:
            break;
    }        

    return (1);
}