/*************************************************** * Function : CreatePrimitivesForcurrentlyRecordingScreen * Parameters : none * Return : none * Description : Creates GPL widgets used in screen - currentlyRecordingScreen ***************************************************/ void CreatePrimitivesForcurrentlyRecordingScreen(void) { SetLineType(0); SetLineThickness(0); SetColor(12678); SetFont((void*)&Gentium_Plain_0_0_22); while(!OutTextXY(57,84,(XCHAR*)currentlyRecordingScreen_OTE_4text)); }
/*************************************************** * Function : CreatePrimitivesForlistTracesScreen * Parameters : none * Return : none * Description : Creates GPL widgets used in screen - listTracesScreen ***************************************************/ void CreatePrimitivesForlistTracesScreen(void) { SetLineType(0); SetLineThickness(0); SetColor(12678); SetFont((void*)&Gentium_Plain_0_0_22); while(!OutTextXY(17,54,(XCHAR*)listTracesScreen_OTE_18text)); }
/*************************************************** * Function : CreatePrimitivesForhomeScreen * Parameters : none * Return : none * Description : Creates GPL widgets used in screen - homeScreen ***************************************************/ void CreatePrimitivesForhomeScreen(void) { SetLineType(0); SetLineThickness(0); SetColor(12678); SetFont((void*)&Gentium_Plain_0_0_22); while(!OutTextXY(130,127,(XCHAR*)homeScreen_OTE_4text)); }
static WORD DrawOrHideDecoration(void) { static int drawState; OBJ_HEADER *pObj; SHORT l, t, r, b; if (showDecoration != showDecorationPrev) { showDecorationPrev = showDecoration; drawState = 0; } switch (drawState) { case 0: // prepare style SetLineThickness(THICK_LINE); SetLineType(DASHED_LINE); if (showDecoration) SetColor(GFX_SCHEMEDEFAULT.Color1); else SetColor(GFX_SCHEMEDEFAULT.CommonBkColor); drawState++; /* fall through */ case 1: // draw/hide decoration pObj = GOLFindObject(ID_BUTTON); if (pObj == NULL) break; l = pObj->left - 5; t = pObj->top - 5; r = pObj->right + 5; b = pObj->bottom + 5; if (!Rectangle(l, t, r, b)) return 0; drawState++; /* fall through */ default: break; } return 1; }
WORD GridDraw( GRID *pGrid ) { SHORT i; SHORT j; if ((pGrid->hdr.state & GRID_DRAW_ITEMS) || (pGrid->hdr.state & GRID_DRAW_ALL) || (pGrid->hdr.state & GRID_SHOW_FOCUS)) { if (pGrid->hdr.state & GRID_DRAW_ALL) { // Clear the entire region. SetColor( pGrid->hdr.pGolScheme->CommonBkColor ); Bar( pGrid->hdr.left, pGrid->hdr.top, pGrid->hdr.right, pGrid->hdr.bottom ); // Draw the grid lines if (pGrid->hdr.state & (GRID_SHOW_LINES | GRID_SHOW_BORDER_ONLY | GRID_SHOW_SEPARATORS_ONLY)) { SetLineType( SOLID_LINE ); SetColor( pGrid->hdr.pGolScheme->EmbossLtColor ); // Draw the outside of the box // TODO This should have some 3D effects added with GOL_EMBOSS_SIZE if (pGrid->hdr.state & (GRID_SHOW_LINES | GRID_SHOW_BORDER_ONLY)) { Line( pGrid->hdr.left, pGrid->hdr.top, pGrid->hdr.right, pGrid->hdr.top ); LineTo( _cursorX, pGrid->hdr.bottom ); LineTo( pGrid->hdr.left, _cursorY ); LineTo( pGrid->hdr.left, pGrid->hdr.top ); } // Draw the lines between each cell if (pGrid->hdr.state & (GRID_SHOW_LINES | GRID_SHOW_SEPARATORS_ONLY)) { for (i=1; i< pGrid->numColumns; i++) { Line( pGrid->hdr.left + i * (pGrid->cellWidth+1), pGrid->hdr.top, pGrid->hdr.left + i * (pGrid->cellWidth+1), pGrid->hdr.top + pGrid->numRows * (pGrid->cellHeight+1) ); } for (i=1; i<pGrid->numRows; i++) { Line( pGrid->hdr.left, pGrid->hdr.top + i * (pGrid->cellHeight+1), pGrid->hdr.right, pGrid->hdr.top + i * (pGrid->cellHeight+1) ); } } } } for (i = 0; i < pGrid->numColumns; i++) { for (j = 0; j < pGrid->numRows; j++) { if ((pGrid->hdr.state & GRID_DRAW_ALL) || ((pGrid->hdr.state & GRID_DRAW_ITEMS) && (pGrid->gridObjects[CELL_AT(i,j)].status & GRIDITEM_DRAW)) || ((pGrid->hdr.state & GRID_SHOW_FOCUS) && (i == pGrid->focusX) && (j == pGrid->focusY))) { // Clear the cell SetColor( pGrid->hdr.pGolScheme->CommonBkColor ); Bar( CELL_LEFT, CELL_TOP, CELL_RIGHT, CELL_BOTTOM ); // Draw the cell if ((pGrid->gridObjects[CELL_AT(i,j)].status & GRID_TYPE_MASK) == GRIDITEM_IS_BITMAP) { // Draw the bitmap if (pGrid->gridObjects[CELL_AT(i,j)].data) { PutImage( CELL_LEFT, CELL_TOP, pGrid->gridObjects[CELL_AT(i,j)].data, BITMAP_SCALE ); } } else { // Draw the text } // Draw the focus if applicable. if ((pGrid->hdr.state & GRID_SHOW_FOCUS) && (i == pGrid->focusX) && (j == pGrid->focusY)) { SetColor( pGrid->hdr.pGolScheme->EmbossLtColor ); SetLineType( DOTTED_LINE ); SetLineThickness( NORMAL_LINE ); Rectangle( CELL_LEFT, CELL_TOP, CELL_RIGHT, CELL_BOTTOM ); } // If the cell is selected, indicate it. if (pGrid->gridObjects[CELL_AT(pGrid->focusX,pGrid->focusY)].status & GRIDITEM_SELECTED) { SetColor( pGrid->hdr.pGolScheme->EmbossLtColor ); SetLineType( SOLID_LINE ); if (pGrid->hdr.state & GRID_SHOW_LINES) { SetLineThickness( THICK_LINE ); } else { SetLineThickness( NORMAL_LINE ); } Rectangle( CELL_LEFT-1, CELL_TOP-1, CELL_RIGHT+1, CELL_BOTTOM+1 ); } GridClearCellState( pGrid, i, j, GRIDITEM_DRAW ); } } } //pGrid->state &= ~(GRID_DRAW_ITEMS || GRID_DRAW_ALL || GRID_SHOW_FOCUS); pGrid->hdr.state &= ~(GRID_DRAW_ITEMS || GRID_DRAW_ALL ); // Set line state SetLineType( SOLID_LINE ); } return 1; }
/********************************************************************* * Function: WORD DmDraw(void *pObj) * * Notes: This is the state machine to display the changing numbers. * **********************************************************************/ WORD DmDraw(void *pObj) { typedef enum { DM_STATE_IDLE, DM_STATE_FRAME, DM_STATE_DRAW_FRAME, DM_STATE_INIT, DM_STATE_SETALIGN, DM_STATE_SETTEXT, DM_STATE_ERASETEXT, DM_STATE_DRAWTEXT, DM_STATE_WRAPUP } DM_DRAW_STATES; DIGITALMETER *pDm = NULL; static DM_DRAW_STATES state = DM_STATE_IDLE; static SHORT charCtr = 0, lineCtr = 0; static XCHAR CurValue[DM_WIDTH], PreValue[DM_WIDTH]; static SHORT textWidth = 0; static XCHAR ch = 0, pch = 0; pDm = (DIGITALMETER *)pObj; while(1) { if(IsDeviceBusy()) return (0); switch(state) { case DM_STATE_DRAW_FRAME: if(Rectangle(pDm->hdr.left, pDm->hdr.top, pDm->hdr.right, pDm->hdr.bottom) == 0) return (0); state = DM_STATE_INIT; break; case DM_STATE_IDLE: SetClip(CLIP_DISABLE); #ifdef USE_BISTABLE_DISPLAY_GOL_AUTO_REFRESH GFX_DRIVER_SetupDrawUpdate( pDm->hdr.left, pDm->hdr.top, pDm->hdr.right, pDm->hdr.bottom); #endif if(GetState(pDm, DM_HIDE) || GetState(pDm, DM_DRAW)) { SetColor(pDm->hdr.pGolScheme->CommonBkColor); if(Bar(pDm->hdr.left, pDm->hdr.top, pDm->hdr.right, pDm->hdr.bottom) == 0) return (0); } // if the draw state was to hide then state is still IDLE STATE so no need to change state if (GetState(pDm, DM_HIDE)) { #ifdef USE_BISTABLE_DISPLAY_GOL_AUTO_REFRESH GFX_DRIVER_CompleteDrawUpdate( pDm->hdr.left, pDm->hdr.top, pDm->hdr.right, pDm->hdr.bottom); #endif return (1); } state = DM_STATE_FRAME; case DM_STATE_FRAME: if(GetState(pDm, DM_DRAW | DM_FRAME) == (DM_DRAW | DM_FRAME)) { // show frame if specified to be shown SetLineType(SOLID_LINE); SetLineThickness(NORMAL_LINE); if(!GetState(pDm, DM_DISABLED)) { // show enabled color SetColor(pDm->hdr.pGolScheme->Color1); } else { // show disabled color SetColor(pDm->hdr.pGolScheme->ColorDisabled); } state = DM_STATE_DRAW_FRAME; break; } else { state = DM_STATE_INIT; } case DM_STATE_INIT: if(IsDeviceBusy()) return (0); // set clipping area, text will only appear inside the static text area. SetClip(CLIP_ENABLE); SetClipRgn(pDm->hdr.left + DM_INDENT, pDm->hdr.top, pDm->hdr.right - DM_INDENT, pDm->hdr.bottom); // set the text color if(!GetState(pDm, DM_DISABLED)) { SetColor(pDm->hdr.pGolScheme->TextColor0); } else { SetColor(pDm->hdr.pGolScheme->TextColorDisabled); } // convert the values to be displayed in string format NumberToString(pDm->Pvalue, PreValue, pDm->NoOfDigits, pDm->DotPos); NumberToString(pDm->Cvalue, CurValue, pDm->NoOfDigits, pDm->DotPos); // use the font specified in the object SetFont(pDm->hdr.pGolScheme->pFont); state = DM_STATE_SETALIGN; // go to drawing of text case DM_STATE_SETALIGN: if(!charCtr) { // set position of the next character (based on alignment and next character) textWidth = GetTextWidth(CurValue, pDm->hdr.pGolScheme->pFont); // Display text with center alignment if(GetState(pDm, (DM_CENTER_ALIGN))) { MoveTo((pDm->hdr.left + pDm->hdr.right - textWidth) >> 1, pDm->hdr.top + (lineCtr * pDm->textHeight)); } // Display text with right alignment else if(GetState(pDm, (DM_RIGHT_ALIGN))) { MoveTo((pDm->hdr.right - textWidth - DM_INDENT), pDm->hdr.top + (lineCtr * pDm->textHeight)); } // Display text with left alignment else { MoveTo(pDm->hdr.left + DM_INDENT, pDm->hdr.top + (lineCtr * pDm->textHeight)); } }
/********************************************************************* * Function: WORD BtnDraw(BUTTON *pB) * * * Notes: This is the state machine to draw the button. * ********************************************************************/ WORD BtnDraw(BUTTON *pB) { typedef enum { REMOVE, BEVEL_DRAW, RNDBUTTON_DRAW, TEXT_DRAW, TEXT_DRAW_RUN, FOCUS_DRAW, } BTN_DRAW_STATES; static BTN_DRAW_STATES state = REMOVE; static SHORT width, height, radius; WORD faceClr, embossLtClr, embossDkClr, xText, yText; if(IsDeviceBusy()) return 0; switch(state){ case REMOVE: if(IsDeviceBusy()) return 0; if (GetState(pB,BTN_HIDE)) { // Hide the button (remove from screen) SetColor(pB->hdr.pGolScheme->CommonBkColor); Bar(pB->hdr.left, pB->hdr.top, pB->hdr.right, pB->hdr.bottom); return 1; } /* Note: that width and height adjustment considers the following assumptions: 1. if circular width = height = radius*2 2. if vertical capsule width = radius*2 3. if horizontal capsule height = radius*2 4. radius must be less than or equal to width if height is greater than width 5. radius must be less than or equal to height if width is greater than height 6. if button is cornered, radius must be zero */ radius = pB->radius; // get radius width = (pB->hdr.right - pB->hdr.left) - (radius*2); // get width height = (pB->hdr.bottom - pB->hdr.top) - (radius*2); // get height state = BEVEL_DRAW; case BEVEL_DRAW: if(!GetState(pB,BTN_DISABLED)){ if(GetState(pB,BTN_PRESSED)){ embossDkClr = pB->hdr.pGolScheme->EmbossLtColor; embossLtClr = pB->hdr.pGolScheme->EmbossDkColor; faceClr = pB->hdr.pGolScheme->Color1; } else { embossLtClr = pB->hdr.pGolScheme->EmbossLtColor; embossDkClr = pB->hdr.pGolScheme->EmbossDkColor; faceClr = pB->hdr.pGolScheme->Color0; } }else{ embossLtClr = pB->hdr.pGolScheme->EmbossLtColor; embossDkClr = pB->hdr.pGolScheme->EmbossDkColor; faceClr = pB->hdr.pGolScheme->ColorDisabled; } SetLineThickness(NORMAL_LINE); SetLineType(SOLID_LINE); GOLPanelDraw(pB->hdr.left+radius, pB->hdr.top+radius, pB->hdr.right-radius, pB->hdr.bottom-radius, radius, faceClr, embossLtClr, embossDkClr, pB->pBitmap, GOL_EMBOSS_SIZE); state = RNDBUTTON_DRAW; case RNDBUTTON_DRAW: if(!GOLPanelDrawTsk()){ return 0; } state = TEXT_DRAW; case TEXT_DRAW: if (pB->pText != NULL){ if (!GetState(pB,BTN_DISABLED)){ if (GetState(pB,BTN_PRESSED)){ SetColor(pB->hdr.pGolScheme->TextColor1); }else{ SetColor(pB->hdr.pGolScheme->TextColor0); } } else{ SetColor(pB->hdr.pGolScheme->TextColorDisabled); } SetFont(pB->hdr.pGolScheme->pFont); // check text alignment if (GetState(pB, BTN_TEXTRIGHT)) xText = pB->hdr.right-(pB->textWidth+GOL_EMBOSS_SIZE+2); else if (GetState(pB, BTN_TEXTLEFT)) xText = pB->hdr.left+GOL_EMBOSS_SIZE+2; else xText = (pB->hdr.left+pB->hdr.right-pB->textWidth)>>1; if (GetState(pB, BTN_TEXTTOP)) yText = pB->hdr.top+GOL_EMBOSS_SIZE+2; else if (GetState(pB, BTN_TEXTBOTTOM)) yText = pB->hdr.bottom-(pB->textHeight+GOL_EMBOSS_SIZE); else yText = (pB->hdr.bottom+pB->hdr.top-pB->textHeight)>>1; MoveTo(xText, yText); state = TEXT_DRAW_RUN; }else { state = FOCUS_DRAW; goto rnd_button_draw_focus; } case TEXT_DRAW_RUN: if(!OutText(pB->pText)) return 0; state = FOCUS_DRAW; case FOCUS_DRAW: rnd_button_draw_focus: if(IsDeviceBusy()) return 0; if(GetState(pB,BTN_FOCUSED)){ SetLineType(FOCUS_LINE); if(GetState(pB,BTN_PRESSED)) { SetColor(pB->hdr.pGolScheme->TextColor1); } else { SetColor(pB->hdr.pGolScheme->TextColor0); } // check if the object has rounded corners or not if (!pB->radius) { Rectangle( pB->hdr.left+GOL_EMBOSS_SIZE+2 , pB->hdr.top+GOL_EMBOSS_SIZE+2, pB->hdr.right-GOL_EMBOSS_SIZE-2, pB->hdr.bottom-GOL_EMBOSS_SIZE-2); } else { // original center is still the same, but radius is reduced Bevel( pB->hdr.left+radius, pB->hdr.top+radius, \ pB->hdr.right-radius, pB->hdr.bottom-radius, \ radius - 2 - GOL_EMBOSS_SIZE); } SetLineType(SOLID_LINE); } state = REMOVE; return 1; }
/********************************************************************* * Function: WORD StDraw(STATICTEXT *pSt) * * Notes: This is the state machine to draw the static text. * ********************************************************************/ WORD StDraw(STATICTEXT *pSt) { typedef enum { ST_STATE_IDLE, ST_STATE_CLEANAREA, ST_STATE_INIT, ST_STATE_SETALIGN, ST_STATE_DRAWTEXT } ST_DRAW_STATES; static ST_DRAW_STATES state = ST_STATE_IDLE; static SHORT charCtr = 0, lineCtr = 0; static XCHAR *pCurLine = NULL; SHORT textWidth; XCHAR ch = 0; if(IsDeviceBusy()) return 0; switch(state){ case ST_STATE_IDLE: SetClip(CLIP_DISABLE); if (GetState(pSt, ST_HIDE)) { SetColor(pSt->hdr.pGolScheme->CommonBkColor); if(!Bar(pSt->hdr.left,pSt->hdr.top,pSt->hdr.right,pSt->hdr.bottom)) return 0; // State is still IDLE STATE so no need to set return 1; } if (GetState(pSt, ST_DRAW)) { if (GetState(pSt, ST_FRAME)) { // show frame if specified to be shown SetLineType(SOLID_LINE); SetLineThickness(NORMAL_LINE); if(!GetState(pSt,ST_DISABLED)){ // show enabled color SetColor(pSt->hdr.pGolScheme->Color1); if(!Rectangle(pSt->hdr.left,pSt->hdr.top,pSt->hdr.right,pSt->hdr.bottom)) return 0; } else { // show disabled color SetColor(pSt->hdr.pGolScheme->ColorDisabled); if(!Rectangle(pSt->hdr.left,pSt->hdr.top,pSt->hdr.right,pSt->hdr.bottom)) return 0; } } } // set clipping area, text will only appear inside the static text area. SetClip(CLIP_ENABLE); SetClipRgn(pSt->hdr.left+ST_INDENT, pSt->hdr.top, \ pSt->hdr.right-ST_INDENT, pSt->hdr.bottom); state = ST_STATE_CLEANAREA; case ST_STATE_CLEANAREA: // clean area where text will be placed. SetColor(pSt->hdr.pGolScheme->CommonBkColor); if(!Bar(pSt->hdr.left+1,pSt->hdr.top + 1,pSt->hdr.right-1,pSt->hdr.bottom-1)) return 0; state = ST_STATE_INIT; case ST_STATE_INIT: if(IsDeviceBusy()) return 0; // set the text color if(!GetState(pSt,ST_DISABLED)){ SetColor(pSt->hdr.pGolScheme->TextColor0); } else { SetColor(pSt->hdr.pGolScheme->TextColorDisabled); } // use the font specified in the object SetFont(pSt->hdr.pGolScheme->pFont); pCurLine = pSt->pText; // get first line of text state = ST_STATE_SETALIGN; // go to drawing of text case ST_STATE_SETALIGN: st_state_alignment: if (!charCtr) { // set position of the next character (based on alignment and next character) textWidth = GetTextWidth(pCurLine, pSt->hdr.pGolScheme->pFont); // Display text with center alignment if (GetState(pSt, (ST_CENTER_ALIGN))) { MoveTo((pSt->hdr.left+pSt->hdr.right-textWidth) >> 1, \ pSt->hdr.top+(lineCtr * pSt->textHeight)); } // Display text with right alignment
/********************************************************************* * Function: WORD AcDraw(ANALOGCLOCK *pAc) * * * Notes: This is the state machine to draw the clock. * ********************************************************************/ WORD AcDraw(void *pObj) { typedef enum { REMOVE, BEVEL_DRAW, TICK } AC_DRAW_STATES; static AC_DRAW_STATES state = REMOVE; static SHORT width, height, radius; static GFX_COLOR faceClr, handClr; ANALOGCLOCK *pAc; pAc = (ANALOGCLOCK *)pObj; if(IsDeviceBusy()) return (0); switch(state) { case REMOVE: if(IsDeviceBusy()) return (0); if(GetState(pAc, AC_HIDE)) // Hide the button (remove from screen) { SetColor(pAc->hdr.pGolScheme->CommonBkColor); if(!Bar(pAc->hdr.left, pAc->hdr.top, pAc->hdr.right, pAc->hdr.bottom)) { return (0); } } if(GetState(pAc, AC_TICK)) { state = TICK; return(1); //buthave to do goto erase //goto erase_current_pos; } if(GetState(pAc, UPDATE_HOUR)) { AcHandsDraw(pAc, HOUR, THICKNESS_SECOND+4, handClr, pAc->pBitmap); state = TICK; return(1); //buthave to do goto erase //goto erase_current_pos; } if(GetState(pAc, UPDATE_MINUTE)) { AcHandsDraw(pAc, MINUTE, THICKNESS_SECOND+4, handClr, pAc->pBitmap); state = TICK; return(1); //buthave to do goto erase //goto erase_current_pos; } if(GetState(pAc, UPDATE_SECOND)) { AcHandsDraw(pAc, SECOND, THICKNESS_SECOND+4, handClr, pAc->pBitmap); state = TICK; return(1); //buthave to do goto erase //goto erase_current_pos; } radius = pAc->radius; // get radius width = (pAc->hdr.right - pAc->hdr.left) - (radius * 2); // get width height = (pAc->hdr.bottom - pAc->hdr.top) - (radius * 2); // get height state = BEVEL_DRAW; case BEVEL_DRAW: faceClr = pAc->hdr.pGolScheme->Color0; handClr = pAc->hdr.pGolScheme->Color1; SetLineThickness(NORMAL_LINE); SetLineType(SOLID_LINE); SetColor(faceClr); FillCircle(pAc->centerx,pAc->centery, radius); //Draw Face of Analog Clock SetColor(handClr); FillCircle(pAc->centerx,pAc->centery, 8); //Draw Middle of Analog Clock AcHandsDraw(pAc, SECOND, THICKNESS_SECOND, handClr, pAc->pBitmap); AcHandsDraw(pAc, HOUR, THICKNESS_SECOND+4, handClr, pAc->pBitmap); AcHandsDraw(pAc, MINUTE, THICKNESS_SECOND+4, handClr, pAc->pBitmap); state = REMOVE; break; case TICK: AcHandsDraw(pAc, SECOND, THICKNESS_SECOND, handClr, pAc->pBitmap); if(pAc->valueS++ == 60) { pAc->valueS = 1; if(pAc->valueM++ == 60) { pAc->valueM = 1; } if(pAc->valueM%12 == 0) { pAc->valueH++; if(pAc->valueH == 60) pAc->valueH = 0; AcHandsDraw(pAc, HOUR, THICKNESS_SECOND+4, handClr, pAc->pBitmap); } AcHandsDraw(pAc, MINUTE, THICKNESS_SECOND+4, handClr, pAc->pBitmap); } if( ((pAc->valueS - pAc->valueM)<4 && (pAc->valueS - pAc->valueM)>=0) || ((pAc->valueS - pAc->valueM)<-56 && (pAc->valueS - pAc->valueM)>-59) ) AcHandsDraw(pAc, MINUTE, THICKNESS_SECOND+4, handClr, pAc->pBitmap); if( ((pAc->valueS - pAc->valueH)<4 && (pAc->valueS - pAc->valueH)>=0) || ((pAc->valueS - pAc->valueH)<-56 && (pAc->valueS - pAc->valueH)>-59) ) AcHandsDraw(pAc, HOUR, THICKNESS_SECOND+4, handClr, pAc->pBitmap); if(pAc->valueS-1 == pAc->valueM) AcHandsDraw(pAc, MINUTE, THICKNESS_SECOND+4, handClr, pAc->pBitmap); if(pAc->valueS-1 == pAc->valueH) AcHandsDraw(pAc, HOUR, THICKNESS_SECOND+4, handClr, pAc->pBitmap); state = REMOVE; return (1); } return (1); }