예제 #1
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)
예제 #2
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)

}