/********************************************************************* * * _ShowDemo */ static void _ShowDemo(void) { WM_HWIN hWin0; WM_HWIN hWin1; WM_HWIN hWin2; WM_HWIN hFrame1; WM_HWIN hFrame2; WM_HWIN hClient1; WM_HWIN hClient2; WM_SetCallback(WM_HBKWIN, _cbBkWin); hFrame1 = FRAMEWIN_CreateEx( 10, 30, 140, 140, 0, WM_CF_SHOW, FRAMEWIN_CF_MOVEABLE, 0, "Early Clipping", _cbFrameWin1); hFrame2 = FRAMEWIN_CreateEx(170, 30, 140, 140, 0, WM_CF_SHOW, FRAMEWIN_CF_MOVEABLE, 0, "Late Clipping", _cbFrameWin2); hClient1 = WM_GetClientWindow(hFrame1); hClient2 = WM_GetClientWindow(hFrame2); _hWin1 = WM_CreateWindowAsChild(0, 0, WM_GetWindowSizeX(hClient1), WM_GetWindowSizeY(hClient1), hClient1, WM_CF_SHOW, _cbFrameWin1, 0); _hWin2 = WM_CreateWindowAsChild(0, 0, WM_GetWindowSizeX(hClient2), WM_GetWindowSizeY(hClient2), hClient2, WM_CF_SHOW | WM_CF_LATE_CLIP, _cbFrameWin2, 0); _hBut1 = BUTTON_CreateEx( 10, 210, 140, 20, 0, WM_CF_SHOW, 0, 1); _hBut2 = BUTTON_CreateEx(170, 210, 140, 20, 0, WM_CF_SHOW, 0, 2); hWin0 = FRAMEWIN_CreateEx( 60, 80, 40, 40, 0, WM_CF_SHOW | WM_CF_STAYONTOP, FRAMEWIN_CF_MOVEABLE, 0, "Top 0", _cbTop); hWin1 = FRAMEWIN_CreateEx(220, 80, 40, 40, 0, WM_CF_SHOW | WM_CF_STAYONTOP, FRAMEWIN_CF_MOVEABLE, 0, "Top 1", _cbTop); hWin2 = FRAMEWIN_CreateEx(140, 170, 40, 40, 0, WM_CF_SHOW | WM_CF_STAYONTOP, FRAMEWIN_CF_MOVEABLE, 0, "Top 2", _cbTop); FRAMEWIN_SetResizeable(hWin0, 1); FRAMEWIN_SetResizeable(hWin1, 1); FRAMEWIN_SetResizeable(hWin2, 1); BUTTON_SetText(_hBut1, "Invalidate"); BUTTON_SetText(_hBut2, "Reset counters"); while(1) { GUI_Delay(50); } }
static void CalcPositions( FRAMEWIN_Handle hObj) { if (hObj) { FRAMEWIN_Obj * pObj = FRAMEWIN_H2P(hObj); int TitleHeight; int FontSize = GUI_GetYSizeOfFont(pObj->pFont); int xsize = WM_GetWindowSizeX(hObj); int ysize = WM_GetWindowSizeY(hObj); TitleHeight = _DefaultCaptionSize; /* Make sure defaults are o.k. for us */ if (FontSize + 2 >= TitleHeight) TitleHeight = FontSize + 2; /* Set object properties accordingly */ pObj->rClient.x0 = _DefaultBorderSize; pObj->rClient.x1 = xsize - _DefaultBorderSize - 1; pObj->rClient.y0 = _DefaultBorderSize + FRAMEWIN_IBORDER_DEFAULT + TitleHeight; pObj->rClient.y1 = ysize - _DefaultBorderSize - 1; pObj->FrameSize = _DefaultBorderSize; pObj->TitleHeight = TitleHeight; if (pObj->hClient) { WM_MoveTo (pObj->hClient, pObj->rClient.x0 + pObj->Widget.Win.Rect.x0, pObj->rClient.y0 + pObj->Widget.Win.Rect.y0); WM_SetSize(pObj->hClient, pObj->rClient.x1 - pObj->rClient.x0 + 1, pObj->rClient.y1 - pObj->rClient.y0 + 1); } } }
/********************************************************************* * * _cbWin * * Purpose: * Callback routine of window which draws the content of the memory device */ static void _cbWin(WM_MESSAGE * pMsg) { WM_HWIN hWin; int xPos, yPos, xSize, ySize; GUI_MEMDEV_Handle hMem; hWin = pMsg->hWin; switch (pMsg->MsgId) { case WM_PAINT: // // Get window position // xPos = WM_GetWindowOrgX(hWin); yPos = WM_GetWindowOrgY(hWin); xSize = WM_GetWindowSizeX(hWin); ySize = WM_GetWindowSizeY(hWin); // // Draw memory device // WINDOW_GetUserData(hWin, &hMem, sizeof(hMem)); GUI_MEMDEV_WriteAt(hMem, xPos, yPos); // // Draw surrounding frame // GUI_DrawRect(0, 0, xSize - 1, ySize - 1); break; } }
static void _Paint(FRAMEWIN_Obj* pObj) { WM_HWIN hWin = WM_GetActiveWindow(); int xsize = WM_GetWindowSizeX(hWin); int ysize = WM_GetWindowSizeY(hWin); int FrameSize = pObj->FrameSize; GUI_RECT rClient; GUI_GetClientRect(&rClient); GUI_SetFont(pObj->pFont); /* Draw Title */ GUI_SetBkColor((pObj->Widget.State & WIDGET_STATE_CHILD_HAS_FOCUS) ? pObj->BarColor[1] : pObj->BarColor[0]); GUI_SetColor (pObj->TextColor); GUI_SetTextAlign(pObj->TextAlign); GUI_ClearRect(FrameSize,FrameSize, xsize-1-FrameSize, FrameSize+pObj->rClient.y0-1); GUI_DispStringAt( pObj->pText, FrameSize+pObj->XOff, FrameSize+pObj->YOff); /* Draw Frame */ GUI_SetColor (FRAMEWIN_FRAMECOLOR_DEFAULT); /* pObj->BarColor[1]*/ GUI_FillRect (0, 0, xsize-1, FrameSize-1); GUI_FillRect (0, 0, pObj->rClient.x0-1, ysize-1); GUI_FillRect (pObj->rClient.x1+1, 0, xsize-1, ysize-1); GUI_FillRect (0, pObj->rClient.y1+1, xsize-1, ysize-1); GUI_FillRect (0, pObj->TitleHeight+FrameSize, xsize-1, pObj->TitleHeight+2*FrameSize-1); /* Draw Client area */ WM_SetUserClipArea(&pObj->rClient); /*GUI_SetBkColor(pObj->ClientColor); GUI_Clear();*/ WM_SetUserClipArea(NULL); /* Draw the 3D effect (if configured) */ #if FRAMEWIN_USE_3D WIDGET_EFFECT_3D_DrawUp(); #endif }
/******************************************************************* * * WIDGET__GetWindowSizeX Return width (or height in case of rotation) of window in pixels */ int WIDGET__GetWindowSizeX(WM_HWIN hWin) { WIDGET* pWidget = WIDGET_H2P(hWin); if (pWidget->State & WIDGET_STATE_VERTICAL) { return WM_GetWindowSizeY(hWin); } else { return WM_GetWindowSizeX(hWin); } }
static void _cbWindow1(WM_MESSAGE* pMsg) { int x, y,d; switch (pMsg->MsgId) { case WM_PAINT: // GUI_SetBkColor(_WindowColor1); // GUI_SetColor(GUI_WHITE); // GUI_SetFont(&GUI_Font24_ASCII); if(curbuttonid != -1) { GUI_SetColor(GUI_WHITE); GUI_SetBkColor(GUI_BLUE); GUI_SetFont(&GUI_FontHZ12); GUI_Clear(); x = WM_GetWindowSizeX(pMsg->hWin); y = WM_GetWindowSizeY(pMsg->hWin); GUI_DispStringHCenterAt(pButton[curbuttonid].desc, x / 2, (y / 2) + 30); } break; case WM_NOTIFY_PARENT: //#define WM_NOTIFICATION_CLICKED 1 //#define WM_NOTIFICATION_RELEASED 2 if(pMsg->Data.v == WM_NOTIFICATION_RELEASED) { x = WM_GetWindowSizeX(pMsg->hWin); y = WM_GetWindowSizeY(pMsg->hWin); d = GetButtonID(pMsg->hWinSrc); GUI_Clear(); GUI_DispStringHCenterAt(pButton[d].desc, x / 2, (y / 2) + 30); curbuttonid = d; if(pButton[d].ExeProg) { //OSTaskCreate (pButton[d].ExeProg,pMsg->hWin, &TaskStk[TASK_STK_SIZE-1],20); printf("new 1 task\n"); pButton[d].ExeProg(pMsg->hWin,0,0); // CREATE_TASK(&aTCB[0],pButton[d].title,pButton[d].ExeProg,80,Stack_0); } } break; default: WM_DefaultProc(pMsg); } }
/********************************************************************* * * _cbFrameWinControl */ static void _cbFrameWinControl(WM_MESSAGE * pMsg) { WM_HWIN hItem; int xSize; int ySize; int NCode; int Id; switch (pMsg->MsgId) { case WM_KEY: WM_SendMessage(WM_HBKWIN, pMsg); break; case WM_INIT_DIALOG: hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_PROGBAR0); PROGBAR_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); PROGBAR_SetFont(hItem, &GUI_FontD6x8); hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_HALT); BUTTON_SetFocussable(hItem, 0); hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_NEXT); BUTTON_SetFocussable(hItem, 0); hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_TEXT0); TEXT_SetText(hItem, "Intro"); TEXT_SetFont(hItem, &GUI_Font8_ASCII); break; case WM_PAINT: xSize = WM_GetWindowSizeX(pMsg->hWin); ySize = WM_GetWindowSizeY(pMsg->hWin); GUI_DrawGradientV(0, 0, xSize - 1, ySize - 1, 0xFFFFFF, 0xDCCEC0); break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch (NCode) { case WM_NOTIFICATION_RELEASED: switch (Id) { case GUI_ID_HALT: if (_Halt) { _Halt = 0; _HaltTime = GUI_GetTime() - _HaltTimeStart; WM_MakeModal(0); } else { _Halt = 1; _HaltTimeStart = GUI_GetTime() - _HaltTime; WM_MakeModal(pMsg->hWin); } break; case GUI_ID_NEXT: _Next = 1; // Will be set to 0 by GUIDEMO_GetNextState() _ClearHalt(); // Clear _Halt, so the next sample demonstrates immediately break; } break; } break; default: WM_DefaultProc(pMsg); } }
/********************************************************************* * * _MakeNumberText * * Purpose: * Create text widgets for showing the result */ static void _MakeNumberText(WM_HWIN hParent, int xPos, int * pyPos, int xSize, int ySize, char * pText, U32 Value) { WM_HWIN hText; int Len; Len = _GetLen(pText); _MakeNumberString(pText + Len, Value); hText = TEXT_CreateEx(xPos, *pyPos, xSize, ySize, hParent, WM_CF_SHOW, 0, GUI_ID_TEXT0, pText); *pyPos += WM_GetWindowSizeY(hText); }
/********************************************************************* * * _Paint */ static void _Paint(PROGBAR_Handle hObj) { PROGBAR_Obj* pObj = PROGBAR_H2P(hObj); WM_HWIN hWin = hObj; int xsize = WM_GetWindowSizeX(hWin); int ysize = WM_GetWindowSizeY(hWin); int tm; GUI_SetFont(pObj->pFont); { int x1; int FontSizeY = GUI_GetFontSizeY(); int xText = 0; int yText = (ysize-FontSizeY)/2; GUI_RECT r; int XSizeChar; char ac[5]; /* Just enough for the percentage */ char*s = ac; const char* pText; if (pObj->hpText != WM_HMEM_NULL) { pText = (const char*) WM_HMEM2Ptr(pObj->hpText); } else { GUI_AddDecMin((100*(I32)(pObj->v-pObj->Min))/(pObj->Max-pObj->Min), &s); *s = '%'; *(s+1) =0; pText = &ac[0]; } /* Calculate text positions */ XSizeChar = GUI_GetStringDistX(pText); x1 = _Value2X(hObj, pObj->v); switch (pObj->TextAlign &GUI_TA_HORIZONTAL) { case GUI_TA_CENTER: xText = (xsize-XSizeChar)/2; break; case GUI_TA_LEFT: xText = 0; break; case GUI_TA_RIGHT: xText = xsize-XSizeChar-1; break; } xText += pObj->XOff; yText += pObj->YOff; tm = GUI_SetTextMode(GUI_TM_TRANS); /* Draw left bar */ r.x0=0; r.x1=x1-1; r.y0=0; r.y1 = GUI_YMAX; WM_SetUserClipArea(&r); _DrawPart(pObj, 0, xText, yText, pText); /* Draw right bar */ r.x0=r.x1+1; r.x1=GUI_XMAX; WM_SetUserClipArea(&r); _DrawPart(pObj, 1, xText, yText, pText); } WM_SetUserClipArea(NULL); GUI_SetTextMode(tm); }
/** * @brief Callback routine of the status bar * @param pMsg: pointer to a data structure of type WM_MESSAGE * @retval None */ static void _cbStatus(WM_MESSAGE* pMsg) { int xSize, ySize; static uint8_t TempStr[50]; static WM_HTIMER hTimerTime; WM_HWIN hWin; hWin = pMsg->hWin; switch (pMsg->MsgId) { case WM_CREATE: hTimerTime = WM_CreateTimer(hWin, ID_TIMER_TIME, 1000, 0); break; case WM_DELETE: WM_DeleteTimer(hTimerTime); break; case WM_TIMER: WM_InvalidateWindow(hWin); WM_RestartTimer(pMsg->Data.v, 0); break; case WM_PAINT: xSize = WM_GetWindowSizeX(hWin); ySize = WM_GetWindowSizeY(hWin); /* Draw background */ GUI_SetColor(0x303030); GUI_FillRect(0, 0, xSize, ySize - 3); GUI_SetColor(0x808080); GUI_DrawHLine(ySize - 2, 0, xSize); GUI_SetColor(0x404040); GUI_DrawHLine(ySize - 1, 0, xSize); GUI_SetTextMode(GUI_TM_TRANS); GUI_SetColor(GUI_WHITE); GUI_SetFont(GUI_FONT_13B_ASCII); /* Serial port*/ if (pdTRUE == BluetoothReady) { GUI_DrawBitmap(&bmICON_BluetoothStatus, xSize - 155, 0); } if (pdTRUE == GPSReady) { GUI_DrawBitmap(&bmICON_GPS_Status, xSize - 125, 0); } sprintf((char *)TempStr, "CPU : %d %%", FreeRTOS_GetCPUUsage()); if (75 > FreeRTOS_GetCPUUsage()) { GUI_SetColor(GUI_WHITE); } else { GUI_SetColor(GUI_RED); } GUI_DispStringAt((char *)TempStr, 4, 4); GUI_SetColor(GUI_WHITE); break; default: WM_DefaultProc(pMsg); break; } }
/******************************************************************* * * _cbDemoCallback2 */ static void _cbDemoCallback2(WM_MESSAGE* pMsg) { int x, y; switch (pMsg->MsgId) { case WM_PAINT: GUI_SetBkColor(GUI_MAGENTA); GUI_Clear(); GUI_SetColor(GUI_YELLOW); GUI_SetFont(&GUI_FontComic18B_1); x = WM_GetWindowSizeX(pMsg->hWin); y = WM_GetWindowSizeY(pMsg->hWin); GUI_DispStringHCenterAt("Window 2\nanother Callback", x / 2, (y / 4) - 18); break; default: WM_DefaultProc(pMsg); } }
/******************************************************************* * * _cbChild */ static void _cbChild(WM_MESSAGE* pMsg) { int x, y; switch (pMsg->MsgId) { case WM_PAINT: GUI_SetBkColor(_ChildColor); GUI_Clear(); GUI_SetColor(GUI_RED); GUI_SetFont(&GUI_Font24_ASCII); x = WM_GetWindowSizeX(pMsg->hWin); y = WM_GetWindowSizeY(pMsg->hWin); GUI_DispStringHCenterAt("Child window", x / 2, (y / 2) - 12); break; default: WM_DefaultProc(pMsg); } }
/******************************************************************* * * _cbWindow2 */ static void _cbWindow2(WM_MESSAGE* pMsg) { int x, y; switch (pMsg->MsgId) { case WM_PAINT: GUI_SetBkColor(_WindowColor2); GUI_Clear(); GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_Font24_ASCII); x = WM_GetWindowSizeX(pMsg->hWin); y = WM_GetWindowSizeY(pMsg->hWin); GUI_DispStringHCenterAt("Window 2", x / 2, (y / 4) - 12); break; case WM_SIZE: WM_InvalidateWindow(_hChild); break; default: WM_DefaultProc(pMsg); } }
/******************************************************************* * * _cbWindow2 */ static void _cbWindow2(WM_MESSAGE* pMsg) { GUI_RECT Rect; int x, y; switch (pMsg->MsgId) { case WM_PAINT: WM_GetInsideRect(&Rect); GUI_SetBkColor(_WindowColor2); GUI_SetColor(_FrameColor2); GUI_ClearRectEx(&Rect); GUI_DrawRectEx(&Rect); GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_Font24_ASCII); x = WM_GetWindowSizeX(pMsg->hWin); y = WM_GetWindowSizeY(pMsg->hWin); GUI_DispStringHCenterAt("Window 2", x / 2, (y / 4) - 12); break; default: WM_DefaultProc(pMsg); } }
/********************************************************************* * * _cbFrameWinInfo */ static void _cbFrameWinInfo(WM_MESSAGE * pMsg) { int xSize, ySize; switch (pMsg->MsgId) { case WM_KEY: WM_SendMessage(WM_HBKWIN, pMsg); break; case WM_CREATE: xSize = LCD_GetXSize(); WM_SetWindowPos(pMsg->hWin, xSize >> 1, 0, xSize >> 1, INFO_SIZE_Y); break; case WM_PAINT: xSize = WM_GetWindowSizeX(pMsg->hWin); ySize = WM_GetWindowSizeY(pMsg->hWin); GUI_DrawGradientV(0, 0, xSize - 1, ySize - 1, 0xFFFFFF, 0xDCCEC0); break; default: WM_DefaultProc(pMsg); } }
/******************************************************************* * * _cbChild */ static void _cbChild(WM_MESSAGE * pMsg) { GUI_RECT Rect; int x; int y; switch (pMsg->MsgId) { case WM_PAINT: WM_GetInsideRect(&Rect); GUI_SetBkColor(_ChildColor); GUI_SetColor(_ChildFrame); GUI_ClearRectEx(&Rect); GUI_DrawRectEx(&Rect); GUI_SetColor(GUI_RED); GUI_SetFont(&GUI_Font24_ASCII); x = WM_GetWindowSizeX(pMsg->hWin); y = WM_GetWindowSizeY(pMsg->hWin); GUI_DispStringHCenterAt("Child window", x / 2, (y / 2) - 12); break; default: WM_DefaultProc(pMsg); } }
/** * @brief Callback routine of desktop window status. * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None */ static void _cbStatus(WM_MESSAGE * pMsg) { int xSize, ySize; static uint8_t TempStr[50]; static WM_HTIMER hTimerTime; static WM_HTIMER hSpriteTime; RTC_TimeTypeDef RTC_Time; RTC_DateTypeDef RTC_DateStructure; uint8_t sec, min, hour, day, month; uint16_t year; WM_HWIN hWin; hWin = pMsg->hWin; switch (pMsg->MsgId) { case WM_CREATE: hTimerTime = WM_CreateTimer(hWin, ID_TIMER_TIME, 1000, 0); if(settings.b.enable_sprite) { hSpriteTime = WM_CreateTimer(hWin, ID_SPRITE_TIME, 50, 0); } break; case WM_DELETE: WM_DeleteTimer(hTimerTime); if(settings.b.enable_sprite) { WM_DeleteTimer(hSpriteTime); } break; case WM_TIMER: if( WM_GetTimerId(pMsg->Data.v) == ID_TIMER_TIME) { WM_InvalidateWindow(hWin); WM_RestartTimer(pMsg->Data.v, 1000); } else if( WM_GetTimerId(pMsg->Data.v) == ID_SPRITE_TIME) { if(settings.b.enable_sprite) { if(SpriteDisabled == 0) { _MoveSprite(&_aSprite[0]); } } WM_RestartTimer(pMsg->Data.v, 100); } break; case WM_PAINT: xSize = WM_GetWindowSizeX(hWin); ySize = WM_GetWindowSizeY(hWin); /* Draw background */ GUI_SetColor(0x40303030); GUI_FillRect(0, 0, xSize , ySize - 3); GUI_SetColor(0x808080); GUI_DrawHLine(ySize - 2, 0, xSize ); GUI_SetColor(0x404040); GUI_DrawHLine(ySize - 1, 0, xSize ); /* Draw time & Date */ GUI_SetTextMode(GUI_TM_TRANS); GUI_SetColor(GUI_WHITE); GUI_SetFont(GUI_FONT_13B_ASCII); k_GetTime(&RTC_Time); sec = RTC_Time.Seconds; min = RTC_Time.Minutes; hour = RTC_Time.Hours; k_GetDate(&RTC_DateStructure); sprintf((char *)TempStr, "%02d:%02d:%02d", hour , min, sec); GUI_DispStringAt((char *)TempStr, xSize - 50, 4); year = RTC_DateStructure.Year + 2014; month = RTC_DateStructure.Month; day = RTC_DateStructure.Date; if((day > 0) && (day <= 31) && (month > 0)&& (month <= 12) && (year >= 1900)) { sprintf((char *)TempStr, "%02d, %s, %04d", day , strMonth[month-1], year); } else { sprintf((char *)TempStr, "01, January, 2014"); } GUI_DispStringHCenterAt((char *)TempStr, xSize / 2, 4); /* USB */ if(k_StorageGetStatus(USB_DISK_UNIT)) { GUI_DrawBitmap(&bmusbdisk, xSize - 80, 0); } /* MSD */ if(k_StorageGetStatus(MSD_DISK_UNIT)) { GUI_DrawBitmap(&bmmicrosd, xSize - 80 - 35 * k_StorageGetStatus(USB_DISK_UNIT) , 0); } sprintf((char *)TempStr, "CPU : %d %%", osGetCPUUsage()); if(osGetCPUUsage() > 95 ) { /* waiting for user input when using dialog box*/ sprintf((char *)TempStr, "CPU : 95 %%"); } GUI_DispStringAt( (char *)TempStr, 50, 4); break; default: WM_DefaultProc(pMsg); } }
/** * @brief Callback routine of desktop window status. * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None */ static void _cbStatus(WM_MESSAGE * pMsg) { int xSize, ySize; static uint8_t TempStr[50]; static WM_HTIMER hTimerTime; uint8_t res = 0; //static WM_HTIMER hSpriteTime; RTC_TimeTypeDef RTC_Time; RTC_DateTypeDef RTC_DateStructure; uint8_t sec, min, hour, day, month; uint16_t year; WM_HWIN hWin; uint16_t PosDisplay; hWin = pMsg->hWin; switch (pMsg->MsgId) { case WM_CREATE: hTimerTime = WM_CreateTimer(hWin, ID_TIMER_TIME, 1000, 0); break; case WM_DELETE: WM_DeleteTimer(hTimerTime); break; case WM_TIMER: if( WM_GetTimerId(pMsg->Data.v) == ID_TIMER_TIME) { WM_InvalidateWindow(hWin); WM_RestartTimer(pMsg->Data.v, 1000); } break; case WM_PAINT: xSize = WM_GetWindowSizeX(hWin); ySize = WM_GetWindowSizeY(hWin); PosDisplay = xSize; /* Draw background */ //GUI_SetColor(0x808080); //GUI_SetColor(0x742E1B); GUI_SetColor(0x000000); GUI_FillRect(0, 0, xSize - 1, ySize - 1); // status GUI_SetTextMode(GUI_TM_TRANS); GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_FontHZ_Song_16); GUI_DispStringAt( (char *)StatusText, 4, 4); /* Draw time & Date */ GUI_SetTextMode(GUI_TM_TRANS); GUI_SetColor(GUI_WHITE); GUI_SetFont(GUI_FONT_13B_ASCII); //time k_GetTime(&RTC_Time); sec = RTC_Time.Seconds; min = RTC_Time.Minutes; hour = RTC_Time.Hours; sprintf((char *)TempStr, "%02d:%02d:%02d", hour , min, sec); //sprintf((char *)TempStr, "%02d:%02d", hour , min); PosDisplay-=60; GUI_DispStringAt((char *)TempStr, PosDisplay, 0); //date k_GetDate(&RTC_DateStructure); year = RTC_DateStructure.Year + 2014; month = RTC_DateStructure.Month; day = RTC_DateStructure.Date; if((day > 0) && (day <= 31) && (month > 0)&& (month <= 12) && (year >= 1900)) { sprintf((char *)TempStr, "%04d/%s/%02d", year, strMonth[month-1], day); } else { sprintf((char *)TempStr, "2014/01/01"); } PosDisplay-=10; GUI_DispStringAt((char *)TempStr, PosDisplay, 11); /* USB */ if(k_StorageGetStatus(USB_DISK_UNIT)) { PosDisplay-=35; GUI_DrawBitmap(&bmusbdisk, PosDisplay, 3); } /* MSD */ if(k_StorageGetStatus(MSD_DISK_UNIT)) { PosDisplay-=35; GUI_DrawBitmap(&bmmicrosd, PosDisplay, 3); } /* CPU */ sprintf((char *)TempStr, "%d %%", osGetCPUUsage()); if(osGetCPUUsage() > 95 ) { /* waiting for user input when using dialog box*/ sprintf((char *)TempStr, "95 %%"); } PosDisplay-=35; GUI_DispStringAt( (char *)TempStr, PosDisplay, 6); if(WT_Config.Print == 1 && PrintFile.print_status == 4)//本地打印Yes //print_status 0-stop 1-wait, 2-print ok, 3-print run, 4-print error { // WT_PrintFolder_Init(); // res=WT_PrintFiles_Init((char *)PrintFolder.FilesName[WT_Config.Print_ID]);//0-not init, 1-inited, 2-no files, 3-hardware error, 4-no folder // if(res != 1) wt_SetText_Status("打印文件错误"); wt_SetText_Status("打印文件错误"); } break; default: WM_DefaultProc(pMsg); } }
static void _cbWindow(WM_MESSAGE * pMsg) { const WM_KEY_INFO* pInfo; WM_HWIN thisFrame = pMsg->hWin; int NCode; int Id; int xSize; int ySize; switch (pMsg->MsgId) { case WM_SET_FOCUS: if(pMsg->Data.v) { // WM_GetUserData(pMsg->hWin,&UserData,4); if(UserData==MONITMMSI_FULL || UserData == MONITMMSI_FIRST) { WM_SetFocus(buttons[2]); } else { UserData = 0; WM_SetFocus(buttons[0]); } } break; case WM_PAINT: xSize = WM_GetWindowSizeX(pMsg->hWin); ySize = WM_GetWindowSizeY(pMsg->hWin); // hMem0 = GUI_MEMDEV_Create(0, 0, xSize, ySize); // GUI_MEMDEV_Select(hMem0); GUI_DrawGradientRoundedV(0, 0, xSize - 1, ySize - 1, 20, pColors->bkTopColor,pColors->bkBottomColor); // GUI_MEMDEV_Select(0); // GUI_MEMDEV_CopyToLCD(hMem0); // GUI_MEMDEV_Delete(hMem0); break; case USER_MSG_SKIN: pColors = &(confirmWinColors[pMsg->Data.v]); BUTTON_SetBkColor(buttons[0], BUTTON_BI_UNPRESSED, pColors->btBkColor); BUTTON_SetBkColor(buttons[1], BUTTON_BI_UNPRESSED, pColors->btBkColor); BUTTON_SetBkColor(buttons[2], BUTTON_BI_UNPRESSED, pColors->btBkColor); BUTTON_SetFocusColor(buttons[0], pColors->btFocusBkColor); BUTTON_SetFocusColor(buttons[1], pColors->btFocusBkColor); BUTTON_SetFocusColor(buttons[2], pColors->btFocusBkColor); TEXT_SetTextColor(dlgTextContent, pColors->textColor); break; case WM_CREATE: pColors = &confirmWinColors[t90_set.sys.nightmode]; BUTTON_CreateEx (60,110,80,40,thisFrame, WM_CF_HASTRANS ,0,GUI_ID_BUTTON0); buttons[0] = WM_GetDialogItem(pMsg->hWin, GUI_ID_BUTTON0); BUTTON_SetFocusColor(buttons[0],pColors->btFocusBkColor); WM_ShowWindow (buttons[0]); BUTTON_SetText(buttons[0], "确定"); BUTTON_SetFont(buttons[0], &GUI_Font_T90_30); WM_SetCallback(buttons[0], &myButton); BUTTON_SetBkColor(buttons[0],BUTTON_BI_UNPRESSED,pColors->btBkColor); BUTTON_SetTextColor(buttons[0],BUTTON_BI_UNPRESSED,pColors->btTextColor); BUTTON_CreateEx(260, 110, 80, 40,thisFrame,WM_CF_HASTRANS,0,GUI_ID_BUTTON1); buttons[1] = WM_GetDialogItem(pMsg->hWin, GUI_ID_BUTTON1); BUTTON_SetFocusColor(buttons[1],pColors->btFocusBkColor); WM_ShowWindow (buttons[1]); BUTTON_SetText(buttons[1], "取消"); BUTTON_SetFont(buttons[1], &GUI_Font_T90_30); WM_SetCallback(buttons[1], &myButton); BUTTON_SetBkColor(buttons[1],BUTTON_BI_UNPRESSED,pColors->btBkColor); BUTTON_SetTextColor(buttons[1],BUTTON_BI_UNPRESSED,pColors->btTextColor); buttons[2] = BUTTON_CreateEx (160,110,80,40,thisFrame, WM_CF_HASTRANS ,0,GUI_ID_BUTTON2); WM_HideWin(buttons[2]); BUTTON_SetText(buttons[2], "确定"); BUTTON_SetFont(buttons[2], &GUI_Font_T90_30); WM_SetCallback(buttons[2], &myButton); BUTTON_SetFocusColor(buttons[2],pColors->btFocusBkColor); BUTTON_SetBkColor(buttons[2],BUTTON_BI_UNPRESSED,pColors->btBkColor); BUTTON_SetTextColor(buttons[2],BUTTON_BI_UNPRESSED,pColors->btTextColor); TEXT_CreateEx (0, 35, 400, 80, thisFrame,WM_CF_SHOW,0,ID_TEXT_CONTENT,NULL); dlgTextContent = WM_GetDialogItem(pMsg->hWin, ID_TEXT_CONTENT); TEXT_SetTextAlign(dlgTextContent,TEXT_CF_HCENTER); TEXT_SetFont(dlgTextContent, &GUI_Font_T90_30); TEXT_SetTextColor (dlgTextContent,pColors->textColor); break; case WM_KEY: pInfo = (WM_KEY_INFO*)pMsg->Data.p; switch(pInfo->Key) { case GUI_KEY_LEFT: case GUI_KEY_RIGHT: // WM_GetUserData(pMsg->hWin,&UserData,4); if(UserData==MONITMMSI_FULL || UserData == MONITMMSI_FIRST) { WM_SetFocus(buttons[2]); } else { if(WM_HasFocus(buttons[0])) { WM_SetFocus(buttons[1]); } else { WM_SetFocus(buttons[0]); } } break; default: break; } break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); // Id of widget NCode = pMsg->Data.v; // Notification code switch (NCode) { case WM_NOTIFICATION_RELEASED: // React only if released switch (Id) { case GUI_ID_BUTTON0: // if(myMsg.Data.v == UPDATA) // { // updata[2] = 0x01; // if(UART_Send(UART_1, updata, 18, BLOCKING) == 18) // { // GUI_Delay(100); // NVIC_SystemReset(); // } // break; // } myMsg.hWin = myMsg.hWinSrc; myMsg.hWinSrc = pMsg->hWin; myMsg.MsgId = USER_MSG_REPLY; myMsg.Data.v = REPLY_OK; WM_SendMessage(myMsg.hWin, &myMsg); break; case GUI_ID_BUTTON1: // if(myMsg.Data.v == UPDATA) // { // UART_Send(UART_1, updata, 18, BLOCKING); // WM_SetFocus(myMsg.hWinSrc); // break; // } WM_SetFocusOnPrevChild(confirmWin); myMsg.hWin = myMsg.hWinSrc; myMsg.hWinSrc = pMsg->hWin; myMsg.MsgId = USER_MSG_REPLY; myMsg.Data.v = REPLY_CANCEL; WM_SendMessage(myMsg.hWin, &myMsg); break; case GUI_ID_BUTTON2: myMsg.hWin = myMsg.hWinSrc; myMsg.hWinSrc = pMsg->hWin; myMsg.MsgId = USER_MSG_REPLY; myMsg.Data.v = REPLY_OK; WM_SendMessage(myMsg.hWin, &myMsg); { WM_ShowWin(buttons[0]); WM_ShowWin(buttons[1]); WM_HideWin(buttons[2]); } break; } WM_BringToBottom(confirmWin); break; } break; case USER_MSG_CHOOSE: Option = pMsg->Data.v; myMsg.hWinSrc = pMsg->hWinSrc; myMsg.Data.v = Option; switch(Option) { case CANCEL_MONITED: TEXT_SetText(dlgTextContent, "??????????"); break; case STORE_SETTING: TEXT_SetText(dlgTextContent, "??????????"); break; case ADD_MONITED: TEXT_SetText(dlgTextContent, "????????????"); break; case SYS_SETTING: TEXT_SetText(dlgTextContent, "是否更改设置内容?"); UserData = SYS_SETTING; // WM_SetUserData(pMsg->hWin,&UserData,4); break; case SYS_RESET: TEXT_SetText(dlgTextContent, "是否恢复出厂设置?"); UserData = SYS_RESET; // WM_SetUserData(pMsg->hWin,&UserData,4); break; case MONITMMSI_SET: MMSI = getMMSItmp(); sprintf(pstring,"您输入的辅船九位码为: \n%09ld,是否确定?",MMSI); TEXT_SetText(dlgTextContent, pstring); UserData = MONITMMSI_SET; // WM_SetUserData(pMsg->hWin,&UserData,4); break; case MONITMMSI_ADD: MMSI = getMMSItmp(); sprintf(pstring, "确定将船只 %09ld \n加入船队?",MMSI); TEXT_SetText(dlgTextContent, pstring); UserData = MONITMMSI_ADD; // WM_SetUserData(pMsg->hWin,&UserData,4); break; case MONITMMSI_DEL: TEXT_SetText(dlgTextContent, "删除后,对该船只报警功能\n恢复正常,是否确认删除?"); UserData = MONITMMSI_DEL; WM_SetUserData(pMsg->hWin,&UserData,4); break; case MONITMMSI_FULL: TEXT_SetText(dlgTextContent, "已经达到设置上限,请删\n除后再进行添加!"); WM_HideWin(buttons[0]); WM_HideWin(buttons[1]); WM_ShowWin(buttons[2]); UserData = MONITMMSI_FULL; // WM_SetUserData(pMsg->hWin,&UserData,4); break; case MONITMMSI_NINE: TEXT_SetText(dlgTextContent, "你输入的九位码不足九位, \n确定继续修改?"); break; case MONITMMSI_FIRST: TEXT_SetText(dlgTextContent, "你输入的九位码不足九位, \n请继续输入!"); WM_HideWin(buttons[0]); WM_HideWin(buttons[1]); WM_ShowWin(buttons[2]); UserData = MONITMMSI_FIRST; // WM_SetUserData(pMsg->hWin,&UserData,4); break; // case UPDATA: // TEXT_SetText(dlgTextContent,"是否进行更新?"); default: break; } break; default: WM_DefaultProc(pMsg); break; } }