// *****************************************************************************
GFX_GOL_EDITBOX  *GFX_GOL_EditBoxCreate(
                                uint16_t            ID,
                                uint16_t            left,
                                uint16_t            top,
                                uint16_t            right,
                                uint16_t            bottom,
                                uint16_t            state,
                                GFX_XCHAR           *pText,
                                uint16_t            charMax,
                                GFX_ALIGNMENT       alignment,
                                GFX_GOL_OBJ_SCHEME  *pScheme)
{
    GFX_GOL_EDITBOX *pEb = NULL;
    
    // ending zero is not included into charMax
    pEb = (GFX_GOL_EDITBOX*) GFX_malloc(sizeof(GFX_GOL_EDITBOX) + (charMax + 1)*sizeof(GFX_XCHAR));

    if (pEb == NULL)
        return pEb;

    // allocate space for the text buffer
    pEb->pText    = (GFX_XCHAR*)((uint8_t*)pEb + sizeof(GFX_GOL_EDITBOX));
    // initialize to contain nothing
    *pEb->pText             = 0;
    pEb->length             = 0;
    pEb->charMax            = charMax;

    pEb->hdr.ID      	    = ID;
    pEb->hdr.pNxtObj 	    = NULL;
    pEb->hdr.type    	    = GFX_GOL_EDITBOX_TYPE;
    pEb->hdr.left    	    = left;
    pEb->hdr.top     	    = top;
    pEb->hdr.right   	    = right;
    pEb->hdr.bottom  	    = bottom;
    pEb->hdr.state   	    = state;

    pEb->hdr.DrawObj        = GFX_GOL_EditBoxDraw;      // draw function
    pEb->hdr.FreeObj        = NULL;                     // free function
    pEb->hdr.actionGet      = GFX_GOL_EditBoxActionGet; // action get function
    pEb->hdr.actionSet      = GFX_GOL_EditBoxActionSet; // default action function

    // copy the text to the buffer
    if(pText != NULL)
        GFX_GOL_EditBoxTextSet(pEb, pText);

    // set the alignment
    GFX_GOL_EditBoxTextAlignmentSet(pEb, alignment);

    // Set the style scheme to be used
    pEb->hdr.pGolScheme = (GFX_GOL_OBJ_SCHEME *)pScheme;

    pEb->textHeight = GFX_TextStringHeightGet(pEb->hdr.pGolScheme->pFont);

    GFX_GOL_ObjectAdd((GFX_GOL_OBJ_HEADER *)pEb);

    return pEb;
}
Beispiel #2
0
/*********************************************************************
 * Function: GFX_GOL_SCROLLBAR *GFX_GOL_Slider_Create(uint16_t ID, uint16_t left, uint16_t top, uint16_t right,
 *							  uint16_t bottom, uint16_t state, uint16_t range,
 *							  uint16_t page, uint16_t pos, GFX_GOL_OBJ_SCHEME *pScheme)
 *
 * Notes: Creates a SLIDER object and adds it to the current active list.
 *        If the creation is successful, the pointer to the created Object
 *        is returned. If not successful, NULL is returned.
 *
 ********************************************************************/
GFX_GOL_SCROLLBAR *GFX_GOL_ScrollBarCreate
(
        uint16_t ID,
        uint16_t left,
        uint16_t top,
        uint16_t right,
        uint16_t bottom,
        uint16_t state,
        uint16_t range,
        uint16_t page,
        uint16_t pos,
        GFX_GOL_OBJ_SCHEME *pScheme
        )
{
    GFX_GOL_SCROLLBAR *pSld = NULL;

    pSld = (GFX_GOL_SCROLLBAR *) GFX_malloc(sizeof (GFX_GOL_SCROLLBAR));
    if (pSld == NULL)
        return (pSld);

    //pSld->hdr.instance = instance; //Device Instance set
    pSld->hdr.ID = ID; // unique id assigned for referencing
    pSld->hdr.pNxtObj = NULL;
    pSld->hdr.type = GFX_GOL_SCROLLBAR_TYPE; // set object type
    pSld->hdr.left = left; // left and right should be equal when oriented vertically
    pSld->hdr.top = top; // top and bottom should be equal when oriented horizontally
    pSld->hdr.right = right;
    pSld->hdr.bottom = bottom;
    pSld->hdr.state = state;
    pSld->hdr.DrawObj = GFX_GOL_ScrollBarDraw; // draw function
    pSld->hdr.actionGet = GFX_GOL_ScrollBarActionGet; // message function
    pSld->hdr.actionSet = GFX_GOL_ScrollBarActionSet; // default message function
    pSld->hdr.FreeObj = NULL; // default free function

    // Parameters in the user defined range system (pos, page and range)
    pSld->range = range; // range of the slider movement (always measured from 0 to range)

    // 0 refers to pSld->minPos and
    // range refers to pSld->maxpos where: minPos and maxPos are
    // the coordinate equivalent of 0 and range value
    pSld->page = page; // set the resolution
    pSld->pos = pos; // set the initial position

    // calculate the thumb width and height
    pSld->thWidth = SldGetWidth(pSld);
    pSld->thHeight = SldGetHeight(pSld);

    // Set the color scheme to be used
    pSld->hdr.pGolScheme = (GFX_GOL_OBJ_SCHEME *) pScheme; // user defined scheme

    GFX_GOL_ObjectAdd((GFX_GOL_OBJ_HEADER *) pSld); // add the new object to the current list
    return (pSld);
}
// *****************************************************************************
GFX_GOL_STATICTEXT  *GFX_GOL_StaticTextCreate(
                                uint16_t            ID,
                                uint16_t            left,
                                uint16_t            top,
                                uint16_t            right,
                                uint16_t            bottom,
                                uint16_t            state,
                                GFX_XCHAR           *pText,
                                GFX_ALIGNMENT       alignment,
                                GFX_GOL_OBJ_SCHEME  *pScheme)
{
    GFX_GOL_STATICTEXT  *pSt = NULL;

    pSt = (GFX_GOL_STATICTEXT *)GFX_malloc(sizeof(GFX_GOL_STATICTEXT));
    if(pSt == NULL)
        return (pSt);

    pSt->hdr.ID        = ID;                        // unique id assigned for referencing
    pSt->hdr.pNxtObj   = NULL;                      // initialize pointer to NULL
    pSt->hdr.type      = GFX_GOL_STATICTEXT_TYPE;   // set object type
    pSt->hdr.left      = left;                      // left,top corner
    pSt->hdr.top       = top;
    pSt->hdr.right     = right;                     // right buttom corner
    pSt->hdr.bottom    = bottom;
    pSt->hdr.state     = state;
    pSt->hdr.DrawObj   = GFX_GOL_StaticTextDraw;    // draw function
    pSt->hdr.actionGet = GFX_GOL_StaticTextActionGet; // action get function
    pSt->hdr.actionSet = NULL;                      // default action function
    pSt->hdr.FreeObj   = NULL;                      // free function

    // set the text if it exists
    if(pText != NULL)
    {
        GFX_GOL_StaticTextSet(pSt, pText);
    }
    else
    {
        pSt->pText = NULL;
    }
    GFX_GOL_StaticTextAlignmentSet(pSt, alignment);

    // Set the color scheme to be used
    pSt->hdr.pGolScheme = (GFX_GOL_OBJ_SCHEME *)pScheme;

    GFX_GOL_ObjectAdd((GFX_GOL_OBJ_HEADER *)pSt);
    return (pSt);
}
Beispiel #4
0
/*********************************************************************
* Function: PICTURE  *PictCreate(uint16_t ID, uint16_t left, uint16_t top, uint16_t right,
*                              uint16_t bottom, uint16_t state, char scale, void *pImage,
*                              GFX_GOL_OBJ_SCHEME *pScheme)
*
* Overview: creates the picture control
*
********************************************************************/
GFX_GOL_PICTURECONTROL *GFX_GOL_PictureControlCreate
(
    uint16_t        ID,
    uint16_t       left,
    uint16_t       top,
    uint16_t       right,
    uint16_t       bottom,
    uint16_t        state,
    int8_t        scale,
    GFX_RESOURCE_HDR        *pBitmap,
    GFX_GOL_OBJ_SCHEME  *pScheme
)
{
    GFX_GOL_PICTURECONTROL *pPict = NULL;

    pPict = (GFX_GOL_PICTURECONTROL *)GFX_malloc(sizeof(GFX_GOL_PICTURECONTROL));
    if(pPict == NULL)
        return (pPict);

    //pPict->hdr.instance = instance;
    pPict->hdr.ID = ID;
    pPict->hdr.pNxtObj = NULL;
    pPict->hdr.type = GFX_GOL_PICTURECONTROL_TYPE;
    pPict->hdr.left = left;
    pPict->hdr.top = top;
    pPict->hdr.right = right;
    pPict->hdr.bottom = bottom;
    pPict->pImage = pBitmap;
    pPict->hdr.state = state;
    pPict->scaleFactor = scale;
    pPict->count = 0;                             //Hard coded for now
    pPict->hdr.DrawObj = GFX_GOL_PictureControlDraw;	          // draw function
    pPict->hdr.actionGet = GFX_GOL_PictureControlActionGet;         // message function
    pPict->hdr.actionSet = NULL;		  // default message function
    pPict->hdr.FreeObj = NULL;		          // free function
    pPict->delay = 0;

    pPict->partial.width=0;                       //This voids the partial image

    // Set the style scheme to be used
    pPict->hdr.pGolScheme = (GFX_GOL_OBJ_SCHEME *)pScheme;

    GFX_GOL_ObjectAdd((GFX_GOL_OBJ_HEADER *)pPict);

    return (pPict);
}
// *****************************************************************************
GFX_GOL_CHECKBOX *GFX_GOL_CheckBoxCreate(
                                uint16_t            ID,
                                uint16_t            left,
                                uint16_t            top,
                                uint16_t            right,
                                uint16_t            bottom,
                                uint16_t            state,
                                GFX_XCHAR           *pText,
                                GFX_ALIGNMENT       alignment,
                                GFX_GOL_OBJ_SCHEME  *pScheme)
{
    GFX_GOL_CHECKBOX *pObject = NULL;

    pObject = (GFX_GOL_CHECKBOX *)GFX_malloc(sizeof(GFX_GOL_CHECKBOX));
    if(pObject == NULL)
        return (pObject);

    pObject->hdr.ID         = ID;
    pObject->hdr.pNxtObj    = NULL;
    pObject->hdr.type       = GFX_GOL_CHECKBOX_TYPE;
    pObject->hdr.left       = left;
    pObject->hdr.top        = top;
    pObject->hdr.right      = right;
    pObject->hdr.bottom     = bottom;
    pObject->pText          = pText;
    pObject->alignment      = alignment;
    pObject->hdr.state      = state;

    pObject->hdr.DrawObj    = GFX_GOL_CheckBoxDraw;      // draw function
    pObject->hdr.FreeObj    = NULL;                      // free function
    pObject->hdr.actionGet  = GFX_GOL_CheckBoxActionGet; // action get function
    pObject->hdr.actionSet  = GFX_GOL_CheckBoxActionSet; // default action function

    // Set the style scheme
    pObject->hdr.pGolScheme = pScheme;

    // Set the text height
    // Set the text and the alignment
    GFX_GOL_CheckBoxTextSet(pObject, pText);
    GFX_GOL_CheckBoxTextAlignmentSet(pObject, alignment);


    GFX_GOL_ObjectAdd((GFX_GOL_OBJ_HEADER *)pObject);

    return (pObject);
}