// ***************************************************************************** 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; }
/********************************************************************* * Function: SLIDER *SldCreate(WORD ID, SHORT left, SHORT top, SHORT right, * SHORT bottom, WORD state, SHORT range, * SHORT page, SHORT pos, GOL_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. * ********************************************************************/ SLIDER *SldCreate ( WORD ID, SHORT left, SHORT top, SHORT right, SHORT bottom, WORD state, WORD range, WORD page, WORD pos, GOL_SCHEME *pScheme ) { SLIDER *pSld = NULL; pSld = (SLIDER *)GFX_malloc(sizeof(SLIDER)); if(pSld == NULL) return (pSld); pSld->hdr.ID = ID; // unique id assigned for referencing pSld->hdr.pNxtObj = NULL; pSld->hdr.type = OBJ_SLIDER; // 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 = SldDraw; // draw function pSld->hdr.MsgObj = SldTranslateMsg; // message function pSld->hdr.MsgDefaultObj = SldMsgDefault; // 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 if(pScheme == NULL) pSld->hdr.pGolScheme = _pDefaultGolScheme; // use default scheme else pSld->hdr.pGolScheme = (GOL_SCHEME *)pScheme; // user defined scheme GOLAddObject((OBJ_HEADER *)pSld); // add the new object to the current list return (pSld); }
/********************************************************************* * Function: ANALOGCLOCK *AcCreate(WORD ID, SHORT left,SHORT top, * SHORT right,SHORT bottom,SHORT hour,SHORT minute, * SHORT radius,BOOL sechand,WORD state,void *pBitmap, * GOL_SCHEME *pScheme) * * * Notes: Creates an ANALOGCLOCK 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. * ********************************************************************/ ANALOGCLOCK *AcCreate ( WORD ID, SHORT left, SHORT top, SHORT right, SHORT bottom, SHORT hour, SHORT minute, SHORT radius, BOOL sechand, WORD state, void *pBitmap, GOL_SCHEME *pScheme ) { ANALOGCLOCK *pAc = NULL; pAc = (ANALOGCLOCK *)GFX_malloc(sizeof(ANALOGCLOCK)); if(pAc == NULL) return (NULL); pAc->hdr.ID = ID; // unique id assigned for referencing pAc->hdr.pNxtObj = NULL; // initialize pointer to NULL pAc->hdr.type = OBJ_ANALOGCLOCK; // set object type pAc->hdr.left = left; // left position pAc->hdr.top = top; // top position pAc->hdr.right = left; // left position pAc->hdr.bottom = top; // top position pAc->radius = radius; pAc->valueS = 0; pAc->prev_valueS = pAc->valueS; pAc->valueM = minute; pAc->prev_valueM = pAc->valueM-1; pAc->valueH = (hour*5) + (minute/12); pAc->prev_valueH = pAc->valueH-1; pAc->centerx = (left + ((right-left)>>1)); pAc->centery = (top + ((bottom-top)>>1)); pAc->pBitmap = pBitmap; // location of bitmap pAc->hdr.state = state; // state pAc->hdr.DrawObj = AcDraw; // draw function pAc->hdr.MsgObj = NULL; // no message function pAc->hdr.MsgDefaultObj = NULL; // no default message function pAc->hdr.FreeObj = NULL; // Set the color scheme to be used if(pScheme == NULL) pAc->hdr.pGolScheme = _pDefaultGolScheme; else pAc->hdr.pGolScheme = (GOL_SCHEME *)pScheme; GOLAddObject((OBJ_HEADER *)pAc); return (pAc); }
/********************************************************************************************************* * Function: DIGITALMETER *DmCreate(WORD ID, SHORT left, SHORT top, SHORT right, SHORT bottom, WORD state, * DWORD Value, BYTE NoOfDigits, BYTE DotPos, GOL_SCHEME *pScheme) * * Notes: Creates a DIGITALMETER 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. * **********************************************************************************************************/ DIGITALMETER *DmCreate ( WORD ID, SHORT left, SHORT top, SHORT right, SHORT bottom, WORD state, DWORD Value, BYTE NoOfDigits, BYTE DotPos, GOL_SCHEME *pScheme ) { DIGITALMETER *pDm = NULL; pDm = GFX_malloc(sizeof(DIGITALMETER)); if(pDm == NULL) return (pDm); pDm->hdr.ID = ID; // unique id assigned for referencing pDm->hdr.pNxtObj = NULL; // initialize pointer to NULL pDm->hdr.type = OBJ_DIGITALMETER; // set object type pDm->hdr.left = left; // left,top corner pDm->hdr.top = top; pDm->hdr.right = right; // right buttom corner pDm->hdr.bottom = bottom; pDm->Cvalue = Value; // initial value to be displayed pDm->hdr.state = state; pDm->NoOfDigits = NoOfDigits; // number of digits to be displayed pDm->DotPos = DotPos; // position of decimal point pDm->hdr.DrawObj = DmDraw; // draw function pDm->hdr.MsgObj = DmTranslateMsg; // message function pDm->hdr.MsgDefaultObj = NULL; // default message function pDm->hdr.FreeObj = NULL; // free function // Set the color scheme to be used if(pScheme == NULL) pDm->hdr.pGolScheme = _pDefaultGolScheme; else pDm->hdr.pGolScheme = (GOL_SCHEME *)pScheme; pDm->textHeight = 0; if(pDm->Cvalue != 0) { // Set the text height pDm->textHeight = GetTextHeight(pDm->hdr.pGolScheme->pFont); } GOLAddObject((OBJ_HEADER *)pDm); return (pDm); }
/********************************************************************* * 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); }
/********************************************************************* * Function: GOL_SCHEME *GOLCreateScheme(void) * * PreCondition: none * * Input: none * * Output: pointer to scheme object * * Side Effects: none * * Overview: creates a color scheme object and assign default colors * * Note: none * ********************************************************************/ GOL_SCHEME *GOLCreateScheme(void) { GOL_SCHEME *pTemp; pTemp = (GOL_SCHEME *)GFX_malloc(sizeof(GOL_SCHEME)); if(pTemp != NULL) { memcpy(pTemp, &GFX_SCHEMEDEFAULT, sizeof(GOL_SCHEME)); } return (pTemp); }
GFX_GOL_OBJ_SCHEME *GFX_GOL_SchemeCreate(void) { GFX_GOL_OBJ_SCHEME *pTemp; pTemp = (GFX_GOL_OBJ_SCHEME *)GFX_malloc(sizeof(GFX_GOL_OBJ_SCHEME)); if(pTemp != NULL) { memcpy(pTemp, &GOLSchemeDefault, sizeof(GFX_GOL_OBJ_SCHEME)); } return (pTemp); }
// ***************************************************************************** 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); }
/********************************************************************* * 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); }
/********************************************************************* * Function: PICTURE *PictCreate(WORD ID, SHORT left, SHORT top, SHORT right, * SHORT bottom, WORD state, char scale, void *pBitmap, * GOL_SCHEME *pScheme) * * Overview: creates the picture control * ********************************************************************/ PICTURE *PictCreate ( WORD ID, SHORT left, SHORT top, SHORT right, SHORT bottom, WORD state, char scale, void *pBitmap, GOL_SCHEME *pScheme ) { PICTURE *pPict = NULL; pPict = (PICTURE *)GFX_malloc(sizeof(PICTURE)); if(pPict == NULL) return (pPict); pPict->hdr.ID = ID; pPict->hdr.pNxtObj = NULL; pPict->hdr.type = OBJ_PICTURE; pPict->hdr.left = left; pPict->hdr.top = top; pPict->hdr.right = right; pPict->hdr.bottom = bottom; pPict->pBitmap = pBitmap; pPict->hdr.state = state; pPict->scale = scale; pPict->hdr.DrawObj = PictDraw; // draw function pPict->hdr.MsgObj = PictTranslateMsg; // message function pPict->hdr.MsgDefaultObj = NULL; // default message function pPict->hdr.FreeObj = NULL; // free function // Set the style scheme to be used if(pScheme == NULL) pPict->hdr.pGolScheme = _pDefaultGolScheme; else pPict->hdr.pGolScheme = (GOL_SCHEME *)pScheme; GOLAddObject((OBJ_HEADER *)pPict); return (pPict); }
/********************************************************************* * Function: GFX_GOL_ROUNDDIAL *GFX_GOL_RoundDialCreate(uint16_t ID, uint16_t x, uint16_t y, uint16_t radius, * uint16_t state, uint16_t res, uint16_t value, uint16_t max, * GFX_GOL_SCHEME *pScheme) * * * Notes: Creates a ROUNDDIAL 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_ROUNDDIAL *GFX_GOL_RoundDialCreate ( uint16_t ID, int16_t left, int16_t top, int16_t right, int16_t bottom, uint8_t rad, uint16_t state, const ROUNDDIALITEM* pItems, uint16_t nItems, uint16_t startPos, GFX_ALIGNMENT alignment, GFX_GOL_OBJ_SCHEME *pScheme ) { int16_t txtHeight, txtWidth; GFX_GOL_ROUNDDIAL *pDia = NULL; // sanity check if ((pItems == NULL) || (nItems == 0)) return NULL; // allocate memory for the control pDia = (GFX_GOL_ROUNDDIAL*) GFX_malloc(sizeof (GFX_GOL_ROUNDDIAL)); if (pDia == NULL) return (pDia); pDia->hdr.imageStored = false; if (startPos >= nItems) startPos = nItems - 1; pDia->hdr.ID = ID; pDia->hdr.pNxtObj = NULL; pDia->hdr.type = GFX_GOL_ROUNDDIAL_TYPE; pDia->hdr.state = state; // set state pDia->hdr.left = left; pDia->hdr.top = top; pDia->hdr.right = right; pDia->hdr.bottom = bottom; pDia->hdr.DrawObj = GFX_GOL_RoundDialDraw; // draw function pDia->hdr.actionGet = GFX_GOL_RoundDailActionGet; // message function pDia->hdr.actionSet = GFX_GOL_RoundDailActionSet; // default message function pDia->alignment = alignment; pDia->radius = rad; // record the data items pDia->pItems = pItems; pDia->nItems = nItems; // current position bit shifted to allow rotational steps pDia->pos = startPos; pDia->posOffset = startPos; // Set the style scheme to be used pDia->hdr.pGolScheme = (GFX_GOL_OBJ_SCHEME *) pScheme; // calculate the range of values either side of the current one that will be visible if (pDia->alignment == GFX_ALIGN_VCENTER) { txtHeight = GFX_TextStringHeightGet(pDia->hdr.pGolScheme->pFont) + ROUNDDIAL_VALUE_GAP; pDia->bandHeight = txtHeight; pDia->numericRange = (bottom - top) / txtHeight; pDia->center = (top + bottom) >> 1; } else {