/** * @brief Main menu * @param None * @retval None */ void MainMenu(void) { ICONVIEW_Handle hIcon; WM_HWIN hStatusWin; int i = 0; WM_SetCallback(WM_GetDesktopWindowEx(1), _cbBk); /* create header window for status display e.g. CPU load, Bluetooth status , GPS status */ hStatusWin = WM_CreateWindowAsChild(0, 0, LCD_GetXSize(), 20, WM_GetDesktopWindowEx(1), WM_CF_SHOW | WM_CF_HASTRANS , _cbStatus, 0); hIcon = ICONVIEW_CreateEx(0, 20, LCD_GetXSize(), LCD_GetYSize()- 26, WM_GetDesktopWindowEx(1), WM_CF_SHOW | WM_CF_HASTRANS, 0 ,'0', 115, 95); ICONVIEW_SetFont(hIcon, &GUI_Font13B_ASCII); ICONVIEW_SetBkColor(hIcon, ICONVIEW_CI_SEL, 0x941000 | 0x80404040); ICONVIEW_SetSpace(hIcon, GUI_COORD_Y, 3); ICONVIEW_SetFrame(hIcon, GUI_COORD_Y, 1); /* fill Icon view with available bitmaps */ for (i = 0; i < GUI_COUNTOF(_aBitmapItem); i++) { ICONVIEW_AddBitmapItem(hIcon,_aBitmapItem[i].pBitmap, _aBitmapItem[i].pText); } /*select layer with index 1*/ GUI_SelectLayer(1); }
/** * @brief Initializes the menu. * @param None. * @retval None. */ void k_InitMenu(void) { uint8_t i = 0; WM_HWIN hItem; ICONVIEW_Handle hIcon ; WM_SetCallback(WM_GetDesktopWindowEx(0), _cbBk); hIcon = ST_AnimatedIconView_CreateEx(0, 0, LCD_GetXSize() - 0, LCD_GetYSize() - 0, WM_GetDesktopWindowEx(0), WM_CF_SHOW | WM_CF_HASTRANS , 0, ID_ICONVIEW_MENU, 150, 180, 5, 5); ST_AnimatedIconView_SetDualFont(hIcon, &GUI_FontLubalGraphXLtBT20, &GUI_FontITCAvantGardeStdBk20); ST_AnimatedIconView_SetSpace(hIcon, GUI_COORD_Y, 5); ST_AnimatedIconView_SetSpace(hIcon, GUI_COORD_X, 5); ST_AnimatedIconView_SetFrame(hIcon, GUI_COORD_Y, 10); ST_AnimatedIconView_SetFrame(hIcon, GUI_COORD_X, 5); ST_AnimatedIconView_SetTextColor(hIcon, ICONVIEW_CI_UNSEL, 0x00DCA939); ST_AnimatedIconView_SetBkColor(hIcon, ICONVIEW_CI_UNSEL, GUI_WHITE); ST_AnimatedIconView_SetBkColor(hIcon, ICONVIEW_CI_SEL, GUI_WHITE); ST_AnimatedIconView_SetSel(hIcon, -1); ST_AnimatedIconView_SetDualTextColor(hIcon, ICONVIEW_CI_SEL, 0x00DCA939, 0x00522000); for (i = 0; i < k_ModuleGetNumber(); i++) { ST_AnimatedIconView_AddIcon(hIcon, module_prop[i].module->open_icon, module_prop[i].module->close_icon, (char *)module_prop[i].module->name); } hItem = TEXT_CreateEx(548, 360, 260, 20, WM_GetDesktopWindowEx(0), WM_CF_SHOW, TEXT_CF_LEFT, ID_FEATURES_FPU, "FPU : ON"); TEXT_SetFont(hItem, GUI_FONT_13B_1); TEXT_SetTextColor(hItem, GUI_WHITE); hItem = TEXT_CreateEx(548, 380, 260, 20, WM_GetDesktopWindowEx(0), WM_CF_SHOW, TEXT_CF_LEFT, ID_FEATURES_IC, "I-Cache : ON"); TEXT_SetFont(hItem, GUI_FONT_13B_1); TEXT_SetTextColor(hItem, GUI_WHITE); hItem = TEXT_CreateEx(548, 400, 260, 20, WM_GetDesktopWindowEx(0), WM_CF_SHOW, TEXT_CF_LEFT, ID_FEATURES_DC, "D-Cache : ON"); TEXT_SetFont(hItem, GUI_FONT_13B_1); TEXT_SetTextColor(hItem, GUI_WHITE); hItem = TEXT_CreateEx(548, 420, 260, 20, WM_GetDesktopWindowEx(0), WM_CF_SHOW, TEXT_CF_LEFT, ID_FEATURES_CPU, "MCU Load < 1%"); TEXT_SetFont(hItem, GUI_FONT_13B_1); TEXT_SetTextColor(hItem, GUI_WHITE); hItem = TEXT_CreateEx(548, 440, 260, 20, WM_GetDesktopWindowEx(0), WM_CF_SHOW, TEXT_CF_LEFT, ID_FEATURES_FREQ, "Clk : 200 MHz"); TEXT_SetFont(hItem, GUI_FONT_13B_1); TEXT_SetTextColor(hItem, GUI_WHITE); }
/** * @brief Initializes the menu. * @param None. * @retval None */ void k_InitMenu(void) { WM_HWIN hItem; uint8_t i = 0; settings.d32 = k_BkupRestoreParameter(CALIBRATION_GENERAL_SETTINGS_BKP); WM_SetCallback(WM_HBKWIN, _cbBk); hStatusWin = WM_CreateWindowAsChild(0, 0, LCD_GetXSize(), 25, WM_HBKWIN, WM_CF_SHOW | WM_CF_LATE_CLIP , _cbStatus, 0); hIcon = ICONVIEW_CreateEx(0, 26, LCD_GetXSize(), LCD_GetYSize()- 26, WM_HBKWIN, WM_CF_SHOW | WM_CF_HASTRANS, ICONVIEW_CF_AUTOSCROLLBAR_V, ID_ICONVIEW_MENU, 92, 90); ICONVIEW_SetFont(hIcon, &GUI_Font13B_ASCII); ICONVIEW_SetTextColor(hIcon, ICONVIEW_CI_UNSEL, GUI_BLUE); ICONVIEW_SetTextColor(hIcon, ICONVIEW_CI_SEL, GUI_BLUE); ICONVIEW_SetBkColor(hIcon, ICONVIEW_CI_SEL, GUI_LIGHTBLUE |GUI_TRANSPARENT); ICONVIEW_SetSpace(hIcon, GUI_COORD_Y, 10); ICONVIEW_SetFrame(hIcon, GUI_COORD_Y, 10); for (i = 0; i < k_ModuleGetNumber(); i++) { ICONVIEW_AddBitmapItem(hIcon,module_prop[i].module->icon, (char *)module_prop[i].module->name); } hItem = BUTTON_CreateEx(0, 0, 40, 23, WM_GetDesktopWindowEx(0), WM_CF_SHOW, 0, ID_BUTTON_BKGND); WM_SetCallback(hItem, _cbButton); }
/********************************************************************* * * GUIDEMO_main(): Small version of the demo * ********************************************************************** */ void GUIDEMO_main(void) { #if GUI_WINSUPPORT int i; #endif #if GUI_WINSUPPORT #if LCD_NUM_DISPLAYS > 1 FRAMEWIN_CreateAsChild(10, 10, 100, 100, WM_GetDesktopWindowEx(1), "Display 1", NULL, WM_CF_SHOW); GUI_Delay(1000); #endif WM_SetCreateFlags(WM_CF_MEMDEV); /* Automatically use memory devices on all windows */ _ButtonSizeX = 27; _ButtonSizeY = 14; _ahButton[0] = BUTTON_Create(LCD_GetXSize() - _ButtonSizeX * 2 - 5, LCD_GetYSize() - _ButtonSizeY - 3, _ButtonSizeX, _ButtonSizeY, 'H' , WM_CF_SHOW | WM_CF_STAYONTOP | WM_CF_MEMDEV); _ahButton[1] = BUTTON_Create(LCD_GetXSize() - _ButtonSizeX - 3, LCD_GetYSize() - _ButtonSizeY - 3, _ButtonSizeX, _ButtonSizeY, 'N' , WM_CF_SHOW | WM_CF_STAYONTOP | WM_CF_MEMDEV); BUTTON_SetFont(_ahButton[0], &GUI_Font8_ASCII); BUTTON_SetFont(_ahButton[1], &GUI_Font8_ASCII); BUTTON_SetText(_ahButton[0], "Stop"); BUTTON_SetText(_ahButton[1], "Next"); _UpdateCmdWin(); WM_ExecIdle(); #endif /* Show Intro */ GUIDEMO_Intro(); /* Run the individual demos ! */ for (_iTest = 0; _apfTest[_iTest]; _iTest++) { GUI_CONTEXT ContextOld; GUI_SaveContext(&ContextOld); _iTestMinor = 0; _UpdateCmdWin(); (*_apfTest[_iTest])(); _CmdNext = 0; GUI_RestoreContext(&ContextOld); } /* Cleanup */ #if GUI_WINSUPPORT for (i = 0; i < countof(_ahButton); i++) { BUTTON_Delete(_ahButton[i]); } #endif }
/** * @brief Video direct open * @param filename: video file name * @retval None */ static void VideoDirectOpen(char *filename) { WM_HWIN hItem; int ItemNbr; static char tmp[FILEMGR_FILE_NAME_SIZE]; VIDEOPLAYER_hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_GetDesktopWindowEx(1), 0, 26); if(VIDEOPLAYER_hWin != 0) { pVideoList->ptr = 0; FILEMGR_GetFileOnly (tmp, filename); hItem = WM_GetDialogItem(VIDEOPLAYER_hWin, ID_VIDEO_LIST); /* Update Playlist */ strcpy((char *)pVideoList->file[pVideoList->ptr].name, filename); ItemNbr = LISTVIEW_GetNumRows(hItem); while(ItemNbr--) { LISTVIEW_DeleteRow(hItem, ItemNbr); } LISTVIEW_AddRow(hItem, NULL); LISTVIEW_SetItemText(hItem, 0, pVideoList->ptr, tmp); pVideoList->ptr++; file_pos = 0; LISTVIEW_SetSel(hItem, 0); _StartPlay((char *)pVideoList->file[file_pos].name); WM_InvalidateWindow(hFrame); } }
/** * @brief Image direct open * @param filename: Image file name * @retval None */ static void ImageDirectOpen(char *filename) { WM_HWIN hItem; static char tmp[FILEMGR_FILE_NAME_SIZE]; IMAGE_hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_GetDesktopWindowEx(1), 0, 26); strcpy((char *)pImageList->file[pImageList->ptr].name, filename); FILEMGR_GetFileOnly(tmp, (char *)filename); hItem = WM_GetDialogItem(IMAGE_hWin, ID_IMAGE_LIST); LISTBOX_AddString(hItem, tmp); LISTBOX_SetSel(hItem, pImageList->ptr); pImageList->ptr++; file_pos = pImageList->ptr - 1; f_close(&Image_File); if((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP"))) { IMAGE_Type = IMAGE_TYPE_BMP; } else if((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG"))) { IMAGE_Type = IMAGE_TYPE_JPG; } f_open(&Image_File, (char *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ); WM_InvalidateWindow(imFrame); }
/** * @brief Audio direct open * @param filename: audio file name * @retval None */ static void AudioDirectOpen(char *filename) { WM_HWIN hItem; static char tmp[FILEMGR_FILE_NAME_SIZE]; pWavList->ptr = 0; uint32_t duration; AUDIOPLAYER_Init(); AUDIOPLAYER_hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_GetDesktopWindowEx(1), 0, 26); if(AUDIOPLAYER_hWin != 0) { if(AUDIOPLAYER_GetFileInfo(filename, &WavInfo) == 0) { /* Update Play list */ pWavList->ptr = 0; file_pos = 0; FILEMGR_GetFileOnly (tmp, filename); hItem = WM_GetDialogItem(AUDIOPLAYER_hWin, ID_WAVFILE_LIST); strcpy((char *)pWavList->file[pWavList->ptr].name, filename); LISTVIEW_AddRow(hItem, NULL); LISTVIEW_SetItemText(hItem, 0, pWavList->ptr, tmp); duration = WavInfo.FileSize / WavInfo.ByteRate; sprintf((char *)tmp , "%02lu:%02lu", duration/60, duration%60 ); LISTVIEW_SetItemText(hItem, 1, pWavList->ptr, tmp); pWavList->ptr++; LISTVIEW_SetSel(hItem, 0); _PlayFile(filename); } } }
/** * @brief Callback function of the MJPEG frame * @param pMsg: pointer to a data structure of type WM_MESSAGE * @retval None */ static void _cbVideoWindow(WM_MESSAGE * pMsg) { char temp[20]; static WM_HTIMER hTimerTime; WM_HWIN hItem; const GUI_PID_STATE * pState; GUI_RECT r; WM_GetInsideRect(&r); switch (pMsg->MsgId) { case WM_TOUCH: if(VideoPlayer_State == VIDEO_PLAY) { pState = (const GUI_PID_STATE *)pMsg->Data.p; if (pState) { if (pState->Pressed == 1) { VIDEO_Enlarge ^= 1; if(VIDEO_Enlarge) { GUI_SetOrientation(GUI_SWAP_XY | GUI_MIRROR_Y); TS_Orientation = 1; WM_AttachWindowAt(pMsg->hWin, WM_GetDesktopWindowEx(1), 0, 0); WM_SetSize(pMsg->hWin, LCD_GetXSize(), LCD_GetYSize()); } else { WM_AttachWindow(pMsg->hWin, bkparent); GUI_SetOrientation(0); TS_Orientation = 0; WM_InvalidateWindow(bkparent); WM_AttachWindowAt(pMsg->hWin, VIDEO_hWin, 5, 16); WM_SetSize(pMsg->hWin,230, 170); do_clear = 1; } } } } break; case WM_CREATE: /* Create timer */ hTimerTime = WM_CreateTimer(pMsg->hWin, 0, 50, 0); break; case WM_TIMER: WM_InvalidateWindow(pMsg->hWin); WM_RestartTimer(pMsg->Data.v, 0); break; case WM_DELETE: WM_DeleteTimer(hTimerTime); break; case WM_PAINT: if(do_clear) { GUI_ClearRectEx(&r); do_clear = 0; } if(VideoPlayer_State == VIDEO_PLAY) { if(_PlayMJPEG(&Video_File) < 0) { VideoPlayer_State = VIDEO_PLAY; ImageOffset = 0; time_start = GUI_GetTime(); f_close(&Video_File); goto_next_file(); hItem = WM_GetDialogItem(WM_GetParent(pMsg->hWin), ID_VIDEO_FILE); TEXT_SetText(hItem, (char *)FILEMGR_FileList.file[FILEMGR_FileList.idx].line); } hItem = WM_GetDialogItem(WM_GetParent(pMsg->hWin), ID_VIDEO_PROGRESS); if (progress_bar == 0) { SLIDER_SetValue(hItem, (ImageOffset * 100 )/ Video_File.fsize); } hItem = WM_GetDialogItem(WM_GetParent(pMsg->hWin), ID_VIDEO_DURATION); duration = (GUI_GetTime() - time_start )/1000; if(duration < 0) duration = 0; sprintf(temp,"%02d:%02d", duration/60, duration%60); TEXT_SetText(hItem, temp); } else if(VideoPlayer_State == VIDEO_IDLE) { GUI_ClearRectEx(&r); } break; default: WM_DefaultProc(pMsg); } }
/** * @brief Callback routine of the dialog * @param pMsg: pointer to a data structure of type WM_MESSAGE * @retval None */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; int Id, NCode; static uint8_t sel = 0; switch (pMsg->MsgId) { case WM_INIT_DIALOG: memset(Video_Path, 0, 256); hItem = BUTTON_CreateEx(574, 0, 65, 65, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_EXIT); WM_SetCallback(hItem, _cbButton_exit); hItem = ST_AnimatedIconView_CreateEx(100, 70, LCD_GetXSize() - 0, LCD_GetYSize() - 30, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS , 0, ID_ICONVIEW_SUBMENU, 200, 250, 5, 5); ST_AnimatedIconView_SetDualFont(hItem, GUI_FONT_20_1, GUI_FONT_20_1); ST_AnimatedIconView_SetSpace(hItem, GUI_COORD_Y, 5); ST_AnimatedIconView_SetSpace(hItem, GUI_COORD_X, 25); ST_AnimatedIconView_SetFrame(hItem, GUI_COORD_Y, 10); ST_AnimatedIconView_SetFrame(hItem, GUI_COORD_X, 5); ST_AnimatedIconView_SetSel(hItem, -1); ST_AnimatedIconView_SetTextColor(hItem, ICONVIEW_CI_UNSEL, 0x00DCA939); ST_AnimatedIconView_SetBkColor(hItem, ICONVIEW_CI_UNSEL, GUI_WHITE); ST_AnimatedIconView_SetBkColor(hItem, ICONVIEW_CI_SEL, GUI_WHITE); ST_AnimatedIconView_SetDualTextColor(hItem, ICONVIEW_CI_SEL, 0x00DCA939, 0x00522000); ST_AnimatedIconView_AddIcon(hItem, open_file, 0, "Play video"); ST_AnimatedIconView_AddIcon(hItem, add_video, 0, "Add to playlist"); break; case WM_PAINT: GUI_SetColor(GUI_BLACK); GUI_DrawLine(639, 0, 639, 480); break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); /* Id of widget */ NCode = pMsg->Data.v; /* Notification code */ switch(Id) { case ID_BUTTON_EXIT: switch(NCode) { case WM_NOTIFICATION_RELEASED: GUI_EndDialog(pMsg->hWin, 0); break; } break; case ID_ICONVIEW_SUBMENU: switch(NCode) { case WM_NOTIFICATION_RELEASED: sel = ST_AnimatedIconView_GetSel(pMsg->hWinSrc); if(sel == 0) { osDelay(100); /* Playlist not empty, so start play first item */ if(VideoList.ptr > 0) { GUI_SetLayerVisEx (1, 1); GUI_SelectLayer(1); playbackwin = WM_CreateWindowAsChild(-1, 0, 640, 480, WM_GetDesktopWindowEx(1), WM_CF_SHOW, _cbplaybackwin , 0); WM_CreateWindowAsChild(0, 70, 640, 300, WM_GetDesktopWindowEx(1), WM_CF_SHOW | WM_CF_HASTRANS, _cbTouch , 0); GUI_SelectLayer(0); _StartPlay(&hvideo, (char *)VideoList.file[0].name, &Video_File, 0, 0); VideoPlayer_State = VIDEO_PLAY; hFrame = WM_CreateWindowAsChild(-1, 0, 640, 480,pMsg->hWin, WM_CF_SHOW, _cbVideoWindow , 0); GUI_SelectLayer(1); } else {/* There is no item yet in the playlist: Show hint message */ hItem = GUI_CreateDialogBox(_aFileInfoDialogCreate, GUI_COUNTOF(_aFileInfoDialogCreate), _cbFileInfoDialog, pMsg->hWin, 100, 80); WM_MakeModal(hItem); } } else /* Add file to playlist icon item action */ { hItem = GUI_CreateDialogBox(_aPlaylistDialogCreate, GUI_COUNTOF(_aPlaylistDialogCreate), _cbPlaylistDialog, pMsg->hWin, 100, 80); WM_MakeModal(hItem); } break; } break; } break; default: WM_DefaultProc(pMsg); break; } }
/** * @brief Callback routine of the video main dialog * @param pMsg: pointer to a data structure of type WM_MESSAGE * @retval None */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; int Id, NCode; static uint8_t sel = 0; switch (pMsg->MsgId) { case WM_INIT_DIALOG: memset(Video_Path, 0, 256); hItem = BUTTON_CreateEx(700, 0, 100, 100, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_EXIT); WM_SetCallback(hItem, _cbButton_exit); hItem = ST_AnimatedIconView_CreateEx(120, 50, LCD_GetXSize() - 220, LCD_GetYSize() - 150, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS , 0, ID_ICONVIEW_SUBMENU, 240, 300, 100, 5); ST_AnimatedIconView_SetDualFont(hItem, &GUI_FontLubalGraph24, &GUI_FontLubalGraph24); ST_AnimatedIconView_SetSpace(hItem, GUI_COORD_Y, 5); ST_AnimatedIconView_SetSpace(hItem, GUI_COORD_X, 25); ST_AnimatedIconView_SetFrame(hItem, GUI_COORD_Y, 10); ST_AnimatedIconView_SetFrame(hItem, GUI_COORD_X, 5); ST_AnimatedIconView_SetSel(hItem, -1); ST_AnimatedIconView_SetTextColor(hItem, ICONVIEW_CI_UNSEL, GUI_STCOLOR_LIGHTBLUE); ST_AnimatedIconView_SetBkColor(hItem, ICONVIEW_CI_UNSEL, GUI_WHITE); ST_AnimatedIconView_SetBkColor(hItem, ICONVIEW_CI_SEL, GUI_WHITE); ST_AnimatedIconView_SetDualTextColor(hItem, ICONVIEW_CI_SEL, GUI_STCOLOR_LIGHTBLUE, GUI_STCOLOR_DARKBLUE); ST_AnimatedIconView_AddIcon(hItem, open_file, 0, "Play video"); ST_AnimatedIconView_AddIcon(hItem, add_video, 0, "Open playlist"); break; case WM_PAINT: GUI_SetColor(GUI_BLACK); GUI_DrawLine(799, 0, 799, 480); break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); /* Id of widget */ NCode = pMsg->Data.v; /* Notification code */ switch(Id) { case ID_BUTTON_EXIT: switch(NCode) { case WM_NOTIFICATION_CLICKED: /* avoid icon view animation */ hItem = WM_GetDialogItem(pMsg->hWin, ID_ICONVIEW_SUBMENU); WM_HideWindow(hItem); break; case WM_NOTIFICATION_MOVED_OUT: hItem = WM_GetDialogItem(pMsg->hWin, ID_ICONVIEW_SUBMENU); WM_ShowWindow(hItem); break; case WM_NOTIFICATION_RELEASED: GUI_EndDialog(pMsg->hWin, 0); break; } break; case ID_ICONVIEW_SUBMENU: switch(NCode) { case WM_NOTIFICATION_RELEASED: sel = ST_AnimatedIconView_GetSel(pMsg->hWinSrc); if(sel == 0) { if(VNC_IsRunning() == 0) { /* Playlist not empty, so start play first item */ if(VideoList.ptr > 0) { GUI_SetLayerVisEx (1, 1); GUI_SelectLayer(1); playbackwin = WM_CreateWindowAsChild(0, 0, 800, 480, WM_GetDesktopWindowEx(1), WM_CF_SHOW, _cbplaybackwin , 0); WM_CreateWindowAsChild(100, 100, 600, 280, WM_GetDesktopWindowEx(1), WM_CF_SHOW | WM_CF_HASTRANS, _cbTouch , 0); GUI_SelectLayer(0); _StartPlay(&hvideo, (char *)VideoList.file[0].name, &Video_File, 0, 0); VideoPlayer_State = VIDEO_PLAY; hFrame = WM_CreateWindowAsChild(0, 0, 800, 480,pMsg->hWin, WM_CF_SHOW, _cbVideoWindow , 0); GUI_SelectLayer(1); } else {/* There is no item yet in the playlist: Show hint message */ hItem = GUI_CreateDialogBox(_aFileInfoDialogCreate, GUI_COUNTOF(_aFileInfoDialogCreate), _cbFileInfoDialog, pMsg->hWin, 100, 50); WM_MakeModal(hItem); } } else { hItem = GUI_CreateDialogBox(_aFileErrorDialogCreate, GUI_COUNTOF(_aFileErrorDialogCreate), _cbFileInfoDialog, pMsg->hWin, 100, 50); WM_MakeModal(hItem); } } else if(sel == 1) { hPlaylistWin = GUI_CreateDialogBox(_aPlaylistDialogCreate, GUI_COUNTOF(_aPlaylistDialogCreate), _cbPlaylistDialog, pMsg->hWin, 100, 50); WM_MakeModal(hPlaylistWin); } break; } break; } break; default: WM_DefaultProc(pMsg); break; } }
void Task_0(void) { WM_HWIN hWin; _Auto = 1; GUI_SelectLayer(LAYER); WM_SetCreateFlags(WM_CF_MEMDEV); // Use memory devices on all windows to avoid flicker WM_EnableMemdev(WM_HBKWIN); WM_SetCallback(WM_HBKWIN, _cbBkWindow); GUI_Exec(); GUI_CURSOR_ShowEx(LAYER); GUI_SelectLayer(LAYER); hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbCallback, 0, 0, 0); while (1) { if (_Auto) { _PlayNextEvent(hWin); } else { SIM_Delay(100); } if (WM_IsWindow(hWin) == 0) { SIM_Delay(1000); hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbCallback, WM_GetDesktopWindowEx(LAYER), 0, 0); } } }
/** * @brief ALARM_BackgroundProcess * @param None * @retval None */ void ALARM_BackgroundProcess (void) { if (alarm_now == 0) { if (TS_Orientation == 1) { ALARM_hWin = GUI_CreateDialogBox(_aDialogAlarm_H, GUI_COUNTOF(_aDialogAlarm_H), _cbAlarmDialog, WM_GetDesktopWindowEx(1), 0, 0); } else { ALARM_hWin = GUI_CreateDialogBox(_aDialogAlarm_V, GUI_COUNTOF(_aDialogAlarm_V), _cbAlarmDialog, WM_GetDesktopWindowEx(1), 0, 0); } WM_SetStayOnTop(ALARM_hWin, 1); alarm_now = 1; } }
/** * @brief Callback routine of the dialog * @param pMsg: pointer to a data structure of type WM_MESSAGE * @retval None */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; int Id, NCode; RTC_TimeTypeDef RTC_TimeStructure; RTC_DateTypeDef RTC_DateStructure; uint8_t sec, min, hour, day, month; uint16_t year; uint8_t offset, max; static uint8_t TempStr[50]; switch (pMsg->MsgId) { case WM_PAINT: break; case WM_INIT_DIALOG: RTC_GetTime(RTC_Format_BIN, &RTC_TimeStructure); sec = RTC_TimeStructure.RTC_Seconds; min = RTC_TimeStructure.RTC_Minutes; hour = RTC_TimeStructure.RTC_Hours; RTC_GetDate(RTC_Format_BIN, &RTC_DateStructure); year = RTC_DateStructure.RTC_Year + 2000; month = RTC_DateStructure.RTC_Month; day = RTC_DateStructure.RTC_Date; /* Initialization of 'System Information' */ hItem = pMsg->hWin; FRAMEWIN_SetFont(hItem, GUI_FONT_13B_ASCII); /* Initialization of 'Close' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_CLOSE_CLOCK); BUTTON_SetFont(hItem, GUI_FONT_13B_ASCII); /* Set date in text mode */ hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_DATE); TEXT_SetFont(hItem, GUI_FONT_13B_1); TEXT_SetTextColor(hItem, 0x00804000); WM_CreateWindowAsChild(80, 45, 354, 23, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS, _cbClockWindow , 0); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_CLOCK); TEXT_SetFont(hItem, &GUI_FontBauhaus9332); TEXT_SetTextColor(hItem, 0x00804000); /* Set Init values */ hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_DATE); /* Write date and clock */ sprintf((char *)TempStr, "%02d, %s, %04d",day , strMonth[month-1], year); TEXT_SetText(hItem, (char *)TempStr); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_CLOCK); sprintf((char *)TempStr, "%02d:%02d:%02d",hour , min, sec); TEXT_SetText(hItem, (char *)TempStr); GetDateOffset (year, month, &offset , &max); CALENDAR_SetDefaultSize(CALENDAR_SI_HEADER, 25 ); CALENDAR_SetDefaultSize(CALENDAR_SI_CELL_X, 30 ); CALENDAR_SetDefaultSize(CALENDAR_SI_CELL_Y, 20 ); CALENDAR_SetDefaultFont(CALENDAR_FI_CONTENT,GUI_FONT_16B_1 ); CALENDAR_SetDefaultFont(CALENDAR_FI_HEADER, GUI_FONT_16B_1) ; CALENDAR_Create(pMsg->hWin, 15, 70, year, month, day, 2, ID_CALENDAR, WM_CF_SHOW); WM_InvalidateWindow(pMsg->hWin); 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 ID_BUTTON_CLOSE_CLOCK: GUI_EndDialog(pMsg->hWin, 0); break; case ID_BUTTON_SETTINGS_CLOCK: GUI_CreateDialogBox(_aDialogSettingsCreate, GUI_COUNTOF(_aDialogSettingsCreate), &_cbDialogSettings, pMsg->hWin, 0, 0); hNumPad = GUI_CreateDialogBox(_aDialogNumPad, GUI_COUNTOF(_aDialogNumPad), _cbDialogNumPad, WM_GetDesktopWindowEx(1), 0, 0); /* Create the numpad dialog */ WM_SetStayOnTop(hNumPad, 1); break; } break; case WM_NOTIFICATION_CHILD_DELETED: WM_NotifyParent(WM_GetParent(pMsg->hWin), 0x500); break; } break; default: WM_DefaultProc(pMsg); break; } }
void GUIDEMO_main(void) { #if GUI_WINSUPPORT int i; int xSize, ySize, xPos, yPos; #endif #if (GUI_SUPPORT_CURSOR|GUI_SUPPORT_TOUCH) GUI_CURSOR_Show(); #endif GUI_Clear(); #if GUI_WINSUPPORT #if LCD_NUM_DISPLAYS > 1 FRAMEWIN_CreateAsChild(10, 10, 100, 100, WM_GetDesktopWindowEx(1), "Display 1", NULL, WM_CF_SHOW); WM_SetDesktopColorEx(GUI_RED, 1); GUI_Delay(1000); #endif WM_SetCreateFlags(WM_CF_MEMDEV); /* Automatically use memory devices on all windows */ /* Calculate position and size of FrameWin[1] */ _ButtonSizeX = 30; _ButtonSizeY = 20; /* Create the control window incl. buttons */ _ahFrameWin[1] = FRAMEWIN_Create("Control", NULL, WM_CF_SHOW | WM_CF_STAYONTOP, LCD_GetXSize() - 80, LCD_GetYSize() - 60, 80, 60); _ahInfoWin[1] = WM_CreateWindowAsChild( 0, 0, 0, 0, WM_GetFirstChild(_ahFrameWin[1]), WM_CF_SHOW | WM_CF_STAYONTOP, &_cbCmdWin, 0); _ahButton[0] = BUTTON_CreateAsChild(4, 20, _ButtonSizeX, _ButtonSizeY, _ahInfoWin[1], 'S' , WM_CF_SHOW | WM_CF_STAYONTOP | WM_CF_MEMDEV); _ahButton[1] = BUTTON_CreateAsChild(40, 20, _ButtonSizeX, _ButtonSizeY, _ahInfoWin[1], 'N' , WM_CF_SHOW | WM_CF_STAYONTOP | WM_CF_MEMDEV); BUTTON_SetText(_ahButton[0], "Stop"); BUTTON_SetText(_ahButton[1], "Next"); _UpdateCmdWin(); WM_ExecIdle(); #endif /* Show Intro */ GUIDEMO_Intro(); #if GUI_WINSUPPORT /* Calculate position and size of FrameWin[0] */ xSize = LCD_GetXSize() / 2; ySize = 65; xPos = LCD_GetXSize() - xSize; yPos = 0; /* Create info window and run the individual demos */ _ahFrameWin[0] = FRAMEWIN_Create("µC/GUI Demo", NULL, WM_CF_STAYONTOP, xPos, yPos, xSize, ySize); // _ahInfoWin[0] = WM_GetFirstChild(_ahFrameWin[0]); _ahInfoWin[0] = WM_CreateWindowAsChild(0, 0, 0, 0, WM_GetFirstChild(_ahFrameWin[0]), WM_CF_SHOW | WM_CF_STAYONTOP, 0, 0); WM_ExecIdle(); #endif /* Run the individual demos ! */ for (_iTest = 0; _apfTest[_iTest]; _iTest++) { GUI_CONTEXT ContextOld; GUI_SaveContext(&ContextOld); _iTestMinor = 0; _UpdateCmdWin(); (*_apfTest[_iTest])(); _CmdNext = 0; GUI_RestoreContext(&ContextOld); } /* Cleanup */ #if GUI_WINSUPPORT for (i = 0; i < countof(_ahFrameWin); i++) { WM_DeleteWindow(_ahFrameWin[i]); } for (i = 0; i < countof(_ahInfoWin); i++) { WM_DeleteWindow(_ahInfoWin[i]); } #endif }