/** * @brief Callback function of the numpad. * @param pMsg: pointer to a data structure of type WM_MESSAGE * @retval None */ static void _cbDialogNumPad(WM_MESSAGE * pMsg) { GUI_RECT r; int i, NCode, Id, Pressed = 0; WM_HWIN hDlg, hItem; hDlg = pMsg->hWin; switch (pMsg->MsgId) { case WM_PAINT: WM_GetClientRect(&r); GUI_SetColor(0x000000); GUI_DrawRect(r.x0, r.y0, r.x1, r.y1); /* Draw rectangle around it */ /* Draw the bright sides */ GUI_SetColor(0xffffff); GUI_DrawHLine(r.y0 + 1, r.x0 + 1, r.x1 - 2); /* Draw top line */ GUI_DrawVLine(r.x0 + 1, r.y0 + 1, r.y1 - 2); /* Draw the dark sides */ GUI_SetColor(0x555555); GUI_DrawHLine(r.y1-1, r.x0 + 1, r.x1 - 1); GUI_DrawVLine(r.x1-1, r.y0 + 1, r.y1 - 2); break; case WM_INIT_DIALOG: for (i = 0; i < GUI_COUNTOF(_aDialogNumPad) - 1; i++) { hItem = WM_GetDialogItem(hDlg, GUI_ID_USER + i); BUTTON_SetFocussable(hItem, 0); /* Set all buttons non focussable */ switch (i) { case 13: BUTTON_SetBitmapEx(hItem, 0, &_bmArrowLeft, 7, 7); /* Set bitmap for arrow left button (unpressed) */ BUTTON_SetBitmapEx(hItem, 1, &_bmArrowLeft, 7, 7); /* Set bitmap for arrow left button (pressed) */ break; case 14: BUTTON_SetBitmapEx(hItem, 0, &_bmArrowRight, 7, 7); /* Set bitmap for arrow right button (unpressed) */ BUTTON_SetBitmapEx(hItem, 1, &_bmArrowRight, 7, 7); /* Set bitmap for arrow right button (pressed) */ break; } } hItem = WM_GetDialogItem(hDlg, GUI_ID_USER + 12); break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); /* Id of widget */ NCode = pMsg->Data.v; /* Notification code */ switch (NCode) { case WM_NOTIFICATION_CLICKED: Pressed = 1; case WM_NOTIFICATION_RELEASED: if ((Id >= GUI_ID_USER) && (Id <= (GUI_ID_USER + GUI_COUNTOF(_aDialogNumPad) - 1))) { int Key; if (Id < GUI_ID_USER + 11) { char acBuffer[10]; BUTTON_GetText(pMsg->hWinSrc, acBuffer, sizeof(acBuffer)); /* Get the text of the button */ Key = acBuffer[0]; } else { Key = _aKey[Id - GUI_ID_USER - 11]; /* Get the text from the array */ } GUI_SendKeyMsg(Key, Pressed); /* Send a key message to the focussed window */ } break; } default: WM_DefaultProc(pMsg); } }
/******************************************************************* * * _DrawGraph */ static void _DrawGraph(void) { GUI_RECT Rect; int xSize; int ySize; int x; int y; WM_GetClientRect(&Rect); xSize = Rect.x1; ySize = Rect.y1; GUI_SetBkColor(GUI_BLACK); GUI_ClearRect(26, 1, 302, ySize - 21); GUI_SetColor(_ColorGrid); for (y = 20; y < (ySize - 21); y += 20) { int yPos = ySize - 20 - y; GUI_DrawHLine(yPos, 26, 302); } for (x = 40; x < (xSize - 25); x += 40) { int xPos = x + 25; GUI_DrawVLine(xPos, 1, ySize - 21); } GUI_SetColor(_ColorTemp1); GUI_DrawGraph(_aTemp1, GUI_COUNTOF(_aTemp1), 26, ySize - 121); GUI_SetColor(_ColorTemp2); GUI_DrawGraph(_aTemp2, GUI_COUNTOF(_aTemp2), 26, ySize - 121); }
/********************************************************************* * * _LabelGraph */ static void _LabelGraph(void) { GUI_RECT Rect; int x; int y; int xSize; int ySize; WM_GetClientRect(&Rect); xSize = Rect.x1; ySize = Rect.y1; GUI_SetBkColor(_ColorBackGround); GUI_Clear(); GUI_SetColor(_ColorLabel); GUI_SetPenSize(1); GUI_ClearRect(0, (ySize - 21) - ySize, (xSize - 1), (ySize - 1)); GUI_DrawRect(25, 0, xSize, ySize - 20); GUI_SetFont(&GUI_Font6x8); for (x = 0; x < (xSize - 20); x += 40) { int xPos = x + 25; GUI_DrawVLine(xPos, (ySize - 20), (ySize - 14)); GUI_DispDecAt(x / 40, xPos - 2, (ySize - 9), 1); } for (y = 0; y < ySize - 20; y += 20) { int yPos = ySize - 20 - y; GUI_DrawHLine(yPos, 20, 25); GUI_GotoXY(1, yPos - 4); GUI_DispDecSpace(_TempMin + y, 3); } }
/** * @brief Paints of the owner drawn button. * @param hObj: pointer to button handle * @retval None */ static void _OnPaint(BUTTON_Handle hObj) { int Index; GUI_RECT Rect; Index = (WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED) ? 1 : 0; GUI_SetBkColor(FRAMEWIN_GetDefaultClientColor()); GUI_Clear(); WM_GetClientRect(&Rect); /* Draw button background */ if(Index) { GUI_SetColor(0x40000000 | GUI_GRAY); } else { GUI_SetColor(0x40000000 | GUI_DARKGRAY); } GUI_FillRectEx(&Rect); /* Draw black shape */ GUI_SetColor(GUI_DARKGRAY); GUI_DrawRectEx(&Rect); GUI_DrawBitmap(&bmSTLogo40x20, 0, 0); }
void WIDGET__EFFECT_DrawDownRect(WIDGET* pWidget, GUI_RECT* pRect) { GUI_RECT Rect; if (pRect == NULL) { WM_GetClientRect(&Rect); pRect = &Rect; } if (pWidget->State & WIDGET_STATE_VERTICAL) { _RotateRect90(pWidget, &Rect, pRect); pRect = &Rect; } pWidget->pEffect->pfDrawDownRect(pRect); }
void GUI_GetClientRect (GUI_RECT* pRect) { if (!pRect) return; #if GUI_WINSUPPORT WM_GetClientRect(pRect); #else pRect->x0 = 0; pRect->y0 = 0; pRect->x1 = LCD_GET_XSIZE(); pRect->y1 = LCD_GET_YSIZE(); #endif }
/** * @brief Callback function of the performance dialog * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None */ static void _cbPerformanceDialog(WM_MESSAGE * pMsg) { int NCode; int Id; WM_HWIN hGraph; GUI_RECT Rect; switch (pMsg->MsgId) { case WM_INIT_DIALOG: FRAMEWIN_SetTitleVis(pMsg->hWin, 0); hGraph = WM_GetDialogItem(pMsg->hWin, ID_GRAPH_CPU); hData = GRAPH_DATA_YT_Create(GUI_LIGHTGREEN, 500, 0, 20); GRAPH_SetGridVis(hGraph, 1); GRAPH_SetBorder(hGraph, 30, 2, 2, 2); GRAPH_AttachData(hGraph, hData); hScale = GRAPH_SCALE_Create(20, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 25); GRAPH_AttachScale(hGraph, hScale); GRAPH_SCALE_SetTextColor(hScale, GUI_YELLOW); GRAPH_SetGridDistX(hGraph, 25); GRAPH_SetGridDistY(hGraph, 25); WM_GetClientRect(&Rect); WM_CreateWindowAsChild(470, 0, 10, 10, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS, _cbCpuWindow , 0); break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch(Id) { case ID_BUTTON_HIDE: /* Notifications sent by Hide Button */ switch(NCode) { case WM_NOTIFICATION_RELEASED: if(hPerformance != 0) { WM_HideWindow(hPerformance); } break; } break; } break; default: WM_DefaultProc(pMsg); break; } }
/********************************************************************* * * _Paint */ static void _Paint(DROPDOWN_Handle hObj) { int Border; GUI_RECT r; const char* s; int InnerSize, ColorIndex; DROPDOWN_Obj* pObj; int TextBorderSize; /* Do some initial calculations */ pObj = DROPDOWN_H2P(hObj); Border = pObj->Widget.pEffect->EffectSize; TextBorderSize = pObj->Props.TextBorderSize; GUI_SetFont(pObj->Props.pFont); ColorIndex = (pObj->Widget.State & WIDGET_STATE_FOCUS) ? 2 : 1; s = _GetpItem(pObj, pObj->Sel); WM_GetClientRect(&r); GUI__ReduceRect(&r, &r, Border); InnerSize = r.y1 - r.y0 + 1; /* Draw the 3D effect (if configured) */ WIDGET__EFFECT_DrawDown(&pObj->Widget); /* Draw the outer text frames */ r.x1 -= InnerSize; /* Spare square area to the right */ LCD_SetColor(pObj->Props.aBackColor[ColorIndex]); /* Draw the text */ LCD_SetBkColor(pObj->Props.aBackColor[ColorIndex]); GUI_FillRectEx(&r); r.x0 += TextBorderSize; r.x1 -= TextBorderSize; LCD_SetColor (pObj->Props.aTextColor[ColorIndex]); GUI_DispStringInRect(s, &r, pObj->Props.Align);/**/ /* Draw arrow */ WM_GetClientRect(&r); GUI__ReduceRect(&r, &r, Border); r.x0 = r.x1 + 1 - InnerSize; LCD_SetColor(0xc0c0c0); GUI_FillRectEx(&r); LCD_SetColor(GUI_BLACK); _DrawTriangleDown((r.x1 + r.x0) / 2, r.y0 + 5, (r.y1 - r.y0 - 8) / 2); WIDGET__EFFECT_DrawUpRect(&pObj->Widget, &r); }
/********************************************************************* * * _Paint */ static void _Paint_PopupWin(WM_HWIN hWin) { GUI_RECT WinRect; xIconSelBtn_OBJ *pWidget; xICON *pIcon; xICON_CHECK_XY *pIconChkXY; int i; if(!hWin) return; DEBUGOUT("xIconSelBtn::PopupWin hWin = 0x%08x\r\n", hWin); WM_GetClientRect(&WinRect); DEBUGOUT("xIconSelBtn::PopupWin Paint(%d,%d,%d,%d)\r\n",WinRect.x0, WinRect.y0, WinRect.x1, WinRect.y1); WM_GetUserData(hWin, &pWidget, sizeof(xIconSelBtn_OBJ*)); //Draw Window Background area GUI_SetColor(pWidget->PopupWinBkColor[1]); //Base Color GUI_FillRoundedRect(WinRect.x0+1,WinRect.y0+1,WinRect.x1-1,WinRect.y1-1, 2); GUI_SetColor(pWidget->PopupWinBkColor[0]); //OutLine Color GUI_DrawRoundedRect(WinRect.x0,WinRect.y0,WinRect.x1,WinRect.y1, 2); //Draw icons BMP for(i=0; i<pWidget->NumItems; i++) { pIcon= &pWidget->xIconArray[i]; pIconChkXY = &pWidget->xIconCheckXyArray[i]; if(pIcon->pBMP) { if(i == pWidget->MovingIndex) { //Draw Forcus Frame on Icon BMP outside int x0 = pIcon->x0 - pWidget->IconFocusFrameHWidth; int y0 = pIcon->y0 - pWidget->IconFocusFrameVWidth; int x1, y1; x1 = x0 + pIcon->pBMP->XSize + (pWidget->IconFocusFrameHWidth*2); y1 = y0 + pIcon->pBMP->YSize + (pWidget->IconFocusFrameVWidth*2); GUI_SetColor(pWidget->PopupWinIconFocusColor); GUI_FillRect(x0, y0, x1, y1); } GUI_DrawBitmap(pIcon->pBMP, pIcon->x0, pIcon->y0); } if( (pWidget->pCheckedBMP) && (i == pWidget->SelectedIndex) ) { GUI_DrawBitmap(pWidget->pCheckedBMP, pIconChkXY->x0, pIconChkXY->y0); } } }
/********************************************************************* * * _OnPaint */ static void _OnPaint(void) { int xPos = 0; GUI_RECT Rect; GUI_SetBkColor(GUI_GRAY); GUI_Clear(); WM_GetClientRect(&Rect); Rect.x1 = HEADER_GetItemWidth(_hHeader, 0); GUI_SetColor(GUI_RED); GUI_FillRect(Rect.x0, Rect.y0, Rect.x1, Rect.y1); Rect.x0 = Rect.x1; Rect.x1 += HEADER_GetItemWidth(_hHeader, 1); GUI_SetColor(GUI_GREEN); GUI_FillRect(Rect.x0, Rect.y0, Rect.x1, Rect.y1); Rect.x0 = Rect.x1; Rect.x1 += HEADER_GetItemWidth(_hHeader, 2); GUI_SetColor(GUI_BLUE); GUI_FillRect(Rect.x0, Rect.y0, Rect.x1, Rect.y1); }
/********************************************************************* * * _cbDialogIntro * * Function description * Callback routine of DialogIntro */ static void _cbDialogIntro(WM_MESSAGE * pMsg) { GUI_RECT Rect; WM_HWIN hDlg; int Id; unsigned i; int ySizeText; int yPos; yPos = 40; hDlg = pMsg->hWin; switch (pMsg->MsgId) { case WM_PAINT: WM_GetClientRect(&Rect); GUI_SetBkColor(GUI_WHITE); GUI_SetColor(GUI_BLACK); GUI_Clear(); GUI_SetFont(&GUI_Font24_ASCII); GUI_DispStringHCenterAt("Virtual screens", 160, 5); GUI_SetFont(&GUI_Font13B_ASCII); GUI_DrawBitmap(&_bmLogoBitmap, (Rect.x1 - _bmLogoBitmap.XSize) / 2, yPos); ySizeText = GUI_GetFontSizeY(); yPos += _bmLogoBitmap.YSize + 15; for (i = 0; i < GUI_COUNTOF(_apDialogIntro); i++) { GUI_DispStringHCenterAt(_apDialogIntro[i], Rect.x1 / 2, yPos); yPos += ySizeText; } break; case WM_NOTIFY_PARENT: if (pMsg->Data.v == WM_NOTIFICATION_RELEASED) { Id = WM_GetId(pMsg->hWinSrc); // Id of widget if (Id == GUI_ID_BUTTON0) { GUI_EndDialog(hDlg, 0); } } break; default: WM_DefaultProc(pMsg); } }
/********************************************************************* * * _Paint */ static void _Paint(LISTBOX_Handle hObj) { int i; int Border; GUI_RECT r; int FontDistY; LISTBOX_Obj* pObj = LISTBOX_H2P(hObj); int NumItems = _GetNumItems(pObj); const GUI_ConstString* ppText = pObj->ppText; Border = pObj->Widget.pEffect->EffectSize; GUI_SetFont(pObj->pFont); FontDistY = GUI_GetFontDistY(); if (Border) { GUI_SetBkColor(pObj->aBackColor[0]); GUI_Clear(); } /* Calculate rect used for painting (subtract border) */ WM_GetClientRect(&r); r.x1 -= Border; r.y1 -= Border; r.y0 -= Border; WM_SetUserClipArea(&r); for (i = pObj->ScrollState.v; i < NumItems; i++) { int y, ColorIndex; y = Border + (i - pObj->ScrollState.v) * FontDistY; if (i == pObj->Sel) { ColorIndex = (pObj->Widget.State & WIDGET_STATE_FOCUS) ? 2 : 1; } else { ColorIndex = 0; } GUI_SetBkColor(pObj->aBackColor[ColorIndex]); GUI_SetColor (pObj->aTextColor[ColorIndex]); GUI_ClearRect(Border, y, Border, y + FontDistY -1); GUI_DispStringAt(*(ppText+i), Border+1, y); GUI_DispCEOL(); } WM_SetUserClipArea(NULL); /* Draw the 3D effect (if configured) */ WIDGET__EFFECT_DrawDown(&pObj->Widget); }
/** * @brief Callback routine for informing user about exploring disk * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None */ static void _cbHint(WM_MESSAGE * pMsg) { GUI_RECT Rect; switch (pMsg->MsgId) { case WM_PAINT: GUI_SetBkColor(GUI_LIGHTBLUE); GUI_Clear(); GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_Font16_1HK); GUI_DispStringHCenterAt("Populating Tree view...", 90 , 10); GUI_SetFont(GUI_DEFAULT_FONT); WM_GetClientRect(&Rect); GUI_SetColor(GUI_DARKGRAY); GUI_DrawRectEx(&Rect); break; default: WM_DefaultProc(pMsg); break; } }
/********************************************************************* * * _OnPaint * * Purpose: Paints the owner drawn button */ static void _OnPaint(BUTTON_Handle hObj) { int Index; char ac[50]; GUI_RECT Rect; BUTTON_Obj * pObj; pObj = BUTTON_H2P(hObj); Index = (WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED) ? 1 : 0; WM_GetClientRect(&Rect); /* Draw filled ellipse with button background color */ GUI_SetColor(BUTTON_GetBkColor(hObj, Index)); GUI_FillEllipse(Rect.x1 / 2, Rect.y1 / 2, Rect.x1 / 2, Rect.y1 / 2); /* Draw black shape */ GUI_SetColor(GUI_BLACK); GUI_DrawEllipse(Rect.x1 / 2, Rect.y1 / 2, Rect.x1 / 2, Rect.y1 / 2); /* Draw button text with widget attributes */ GUI_SetColor(BUTTON_GetTextColor(hObj, Index)); GUI_SetBkColor(BUTTON_GetBkColor(hObj, Index)); GUI_SetFont(BUTTON_GetFont(hObj)); BUTTON_GetText(hObj, ac, sizeof(ac)); if (_Pressed) { strcpy(ac + strlen(ac), "\npressed"); } GUI_DispStringInRect(ac, &Rect, GUI_TA_HCENTER | GUI_TA_VCENTER); }
/********************************************************************* * * WIDGET_EFFECT_Simple_GetRect */ void WIDGET_EFFECT_Simple_GetRect(GUI_RECT* pRect) { WM_GetClientRect(pRect); GUI__ReduceRect(pRect, pRect, 1); }
/********************************************************************* * * _Paint */ static void _Paint(CHECKBOX_Obj* pObj, CHECKBOX_Handle hObj) { GUI_RECT RectBox = {0}; int ColorIndex, EffectSize, Index; EffectSize = pObj->Widget.pEffect->EffectSize; ColorIndex = WM__IsEnabled(hObj); /* Clear inside ... Just in case */ /* Fill with parents background color */ #if WM_SUPPORT_TRANSPARENCY if (!WM_GetHasTrans(hObj)) #endif { if (pObj->Props.BkColor == GUI_INVALID_COLOR) { LCD_SetBkColor(WIDGET__GetBkColor(hObj)); } else { LCD_SetBkColor(pObj->Props.BkColor); } GUI_Clear(); } /* Get size from bitmap */ RectBox.x1 = pObj->Props.apBm[CHECKBOX_BI_ACTIV]->XSize - 1 + 2 * EffectSize; RectBox.y1 = pObj->Props.apBm[CHECKBOX_BI_ACTIV]->YSize - 1 + 2 * EffectSize; WM_SetUserClipRect(&RectBox); /* Clear inside ... Just in case */ LCD_SetBkColor(pObj->Props.aBkColorBox[ColorIndex]); GUI_Clear(); Index = pObj->CurrentState * 2 + ColorIndex; if (pObj->Props.apBm[Index]) { GUI_DrawBitmap(pObj->Props.apBm[Index], EffectSize, EffectSize); } /* Draw the effect arround the box */ WIDGET__EFFECT_DrawDownRect(&pObj->Widget, &RectBox); WM_SetUserClipRect(NULL); /* Draw text if needed */ if (pObj->hpText) { const char * s; GUI_RECT RectText; /* Draw the text */ s = (const char *) GUI_ALLOC_h2p(pObj->hpText); WM_GetClientRect(&RectText); RectText.x0 += RectBox.x1 + 1 + pObj->Props.Spacing; GUI_SetTextMode(GUI_TM_TRANS); LCD_SetColor(pObj->Props.TextColor); GUI_SetFont(pObj->Props.pFont); GUI_DispStringInRect(s, &RectText, pObj->Props.Align); /* Draw focus rectangle */ if (pObj->Widget.State & WIDGET_STATE_FOCUS) { int xSizeText = GUI_GetStringDistX(s); int ySizeText = GUI_GetFontSizeY(); GUI_RECT RectFocus = RectText; switch (pObj->Props.Align & ~(GUI_TA_HORIZONTAL)) { case GUI_TA_VCENTER: RectFocus.y0 = (RectText.y1 - ySizeText + 1) / 2; break; case GUI_TA_BOTTOM: RectFocus.y0 = RectText.y1 - ySizeText; break; } switch (pObj->Props.Align & ~(GUI_TA_VERTICAL)) { case GUI_TA_HCENTER: RectFocus.x0 += ((RectText.x1 - RectText.x0) - xSizeText) / 2; break; case GUI_TA_RIGHT: RectFocus.x0 += (RectText.x1 - RectText.x0) - xSizeText; break; } RectFocus.x1 = RectFocus.x0 + xSizeText - 1; RectFocus.y1 = RectFocus.y0 + ySizeText - 1; LCD_SetColor(pObj->Props.FocusColor); GUI_DrawFocusRect(&RectFocus, -1); } } }
/********************************************************************* * * _WIDGET_EFFECT_Simple_DrawUp */ static void _WIDGET_EFFECT_Simple_DrawUp(void) { GUI_RECT r; WM_GetClientRect(&r); _WIDGET_EFFECT_Simple_DrawUpRect(&r); }
/********************************************************************* * * WIDGET_EFFECT_3D_GetRect */ void WIDGET_EFFECT_3D_GetRect(GUI_RECT* pRect) { WM_GetClientRect(pRect); GUI__ReduceRect(pRect, pRect, 2); }
void WIDGET_EFFECT_3D_DrawDown(void) { GUI_RECT r; WM_GetClientRect(&r); WIDGET_EFFECT_3D_DrawDownRect(&r); }
/********************************************************************* * * _WIDGET_EFFECT_3D1L_DrawDown */ static void _WIDGET_EFFECT_3D1L_DrawDown(void) { GUI_RECT r; WM_GetClientRect(&r); _WIDGET_EFFECT_3D1L_DrawDownRect(&r); }
/********************************************************************* * * _WIDGET_EFFECT_3D1L_GetRect */ static void _WIDGET_EFFECT_3D1L_GetRect(GUI_RECT* pRect) { WM_GetClientRect(pRect); GUI__ReduceRect(pRect, pRect, 1); }
/********************************************************************* * * _WIDGET_EFFECT_None_GetRect */ static void _WIDGET_EFFECT_None_GetRect(GUI_RECT * pRect) { WM_GetClientRect(pRect); }