static void drawHandler(GL_PageControls_TypeDef* pThis, _Bool force) { LabelData *pInstData = getInstDataFromPageCtrl(pThis); // Check if a call to Widget_ChangeLabelText() has happened: _Bool change = 0; // Allow code to update itself (via an update handler, if any). if (pInstData->pUpdateHandler != 0) { change |= pInstData->pUpdateHandler(pThis, force); } change |= pInstData->isRedrawRequired; int x = pThis->objCoordinates.MinX; int y = pThis->objCoordinates.MinY; // Redraw? if (force || change) { GL_SetTextColor(pInstData->textColor); GL_SetBackColor(pInstData->backColor); GL_SetFont(pInstData->font); GL_PrintString(x, y, pInstData->strText, pInstData->isTransparent); } pInstData->isRedrawRequired = 0; }
void Widget_ChangeLabelText(GL_PageControls_TypeDef *pThis, const char* strText) { LabelData *pInstData = getInstDataFromPageCtrl(pThis); // Store Text // Note: Buffer is 1 bigger than WIDGET_LABEL_TEXT_MAXLENGTH strncpy(pInstData->strText, strText, WIDGET_LABEL_TEXT_MAXLENGTH); pInstData->strText[WIDGET_LABEL_TEXT_MAXLENGTH] = 0; pInstData->isRedrawRequired = 1; }
void Widget_ChangeLabelText(GL_PageControls_TypeDef *pThis, const char* strText) { LabelData *pInstData = getInstDataFromPageCtrl(pThis); // Check if the new text is different than the old text: if (strncmp(pInstData->strText, strText, WIDGET_LABEL_TEXT_MAXLENGTH) == 0) { // Text is unchanged; don't copy and don't redraw. return; } // Store Text // Note: Buffer is 1 bigger than WIDGET_LABEL_TEXT_MAXLENGTH strncpy(pInstData->strText, strText, WIDGET_LABEL_TEXT_MAXLENGTH); pInstData->strText[WIDGET_LABEL_TEXT_MAXLENGTH] = 0; pInstData->isRedrawRequired = 1; }
static uint16_t getHeight(GL_PageControls_TypeDef* pThis) { LabelData *pInstData = getInstDataFromPageCtrl(pThis); return GL_GetFontLetterHeight(pInstData->font); }
/* * Private interface */ static uint16_t getWidth(GL_PageControls_TypeDef* pThis) { LabelData *pInstData = getInstDataFromPageCtrl(pThis); return strlen(pInstData->strText) * GL_GetFontLetterWidth(pInstData->font); }
void Widget_ChangeLabelColour(GL_PageControls_TypeDef *pThis, uint16_t newTextColour) { LabelData *pInstData = getInstDataFromPageCtrl(pThis); pInstData->textColor = newTextColour; pInstData->isRedrawRequired = 1; }