void MainTask_2D_text_bmp(void) { int i; horPos = ICONS_HOR_POS; verPos = ICONS_VER_POS; iconTouched = 0xFF; SetemWinRunning(1); GUI_SelectLayer(1); // select foregroung layer GUI_SetBkColor(GUI_TRANSPARENT); // select background as transparent color GUI_Clear(); // fill with the background color // get the number of icons iconNumber = GUI_COUNTOF(iconDrawFunctions); // compute padding to fit to whole display iconPadding = ((GUI_GetScreenSizeY() - (iconNumber * ICON_SIZE) - 2*ICONS_VER_POS) / iconNumber); // start time measurement timeMeasureStart(); // draw a background bitmap to the bottom LCD layer GUI_SelectLayer(0); // select the background layer // !! TO BE MODIFIED !! GUI_DrawBitmap(&bmbackground, 0, 0); GUI_SelectLayer(1); // set back the foregroung layer // now draw our icons one by one for (i = 0; i < iconNumber; i++) { iconDrawFunctions[i](horPos, verPos, ICON_SIZE); verPos += ICON_SIZE + iconPadding; } // add a title text GUI_SetTextMode(GUI_TM_TRANS); GUI_SetFont(&GUI_FontTimesNewRoman31); LCD_AA_SetAndMask(0xFFFFFFFF); GUI_DispStringInRect("STM32 Player", &rect, GUI_TA_CENTER); LCD_AA_SetAndMask(0x00FFFFFF); // end measurement time = timeMeasureEnd(); GUI_SetFont(&GUI_Font8_1); sprintf (timeString, "time to render: %d,%dms", time/10, time%10); GUI_DispStringAt(timeString, 10, 320 - 10); // optionally we can use cursor GUI_CURSOR_Show(); // the GUI is now rendered // in never ending loop just check if an incon is touched while(!tamperPushed) { GUI_TOUCH_GetState(&TouchState); // Get the touch position in pixel if (TouchState.Pressed) { if (iconTouched == 0xFF) // no icon was touched previously { GUI_CURSOR_SetPosition(TouchState.x, TouchState.y); // move the cursor to current touch position // check if the touch is in icons area if (TouchState.x > ICONS_HOR_POS && TouchState.x < ICONS_HOR_POS + ICON_SIZE) { if(TouchState.y > ICONS_VER_POS && TouchState.y < ICONS_VER_POS + iconNumber*(ICON_SIZE + iconPadding)) { // get he number of touched icon iconTouched = (TouchState.y - ICONS_VER_POS) / (ICON_SIZE + iconPadding); ReDrawIcon(GUI_RED, iconTouched); // draw again with hihghlight color } } } } else { ReDrawIcon(GUI_WHITE, iconTouched); iconTouched = 0xFF; } } SetemWinRunning(0); GUI_CURSOR_Hide(); }
/** * @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; } }
/** * @brief Benchmark window startup * @param hWin: pointer to the parent handle. * @param xpos: X position * @param ypos: Y position * @retval None */ static void Startup(WM_HWIN hWin, uint16_t xpos, uint16_t ypos) { GUI_CreateDialogBox(_aDialog, GUI_COUNTOF(_aDialog), _cbDialog, hWin, xpos, ypos); }
/** * @brief Callback routine of the dialog * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; GUI_RECT r; int result; int Id, NCode, Index; char tmp[FILEMGR_FILE_NAME_SIZE]; switch (pMsg->MsgId) { case WM_INIT_DIALOG: pImageList = (FILELIST_FileTypeDef *)k_malloc(sizeof(FILELIST_FileTypeDef)); pFileInfo = (CHOOSEFILE_INFO *)k_malloc(sizeof(CHOOSEFILE_INFO)); pImageList->ptr = 0; file_pos = 0; effects = 0; ImSettings.d32 = k_BkupRestoreParameter(CALIBRATION_IMAGE_SETTINGS_BKP); if(ImSettings.b.ss_timer == 0) { ImSettings.b.ss_timer = 1; } /* Image frame initialization */ IMAGE_Enlarge = 0; hItem = WM_GetClientWindow(pMsg->hWin); WM_GetClientRectEx(hItem, &r); imFrame = WM_CreateWindowAsChild(r.x0 + 6, r.y0 + 6, r.x1 - 98, r.y1 - 78, hItem, WM_CF_SHOW, _cbImageWindow, 0); /* Buttons initialization */ hItem = BUTTON_CreateEx(47, 155, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_PREVIOUS_BUTTON); WM_SetCallback(hItem, _cbButton_previous); hItem = BUTTON_CreateEx(94, 148, 50, 50, pMsg->hWin, WM_CF_SHOW, 0, ID_SLIDE_BUTTON); WM_SetCallback(hItem, _cbButton_play); slideshow_state = OFF; hItem = BUTTON_CreateEx(154, 155, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_NEXT_BUTTON); WM_SetCallback(hItem, _cbButton_next); hItem = BUTTON_CreateEx(242, 145, 70, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_ADD_BUTTON); WM_SetCallback(hItem, _cbButton_add); hItem = BUTTON_CreateEx(242, 175, 70, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_OPEN_BUTTON); WM_SetCallback(hItem, _cbButton_open); hItem = BUTTON_CreateEx(196, 174, 30, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_SETTINGS_BUTTON); WM_SetCallback(hItem, _cbButton_settings); hItem = BUTTON_CreateEx(10, 174, 30, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_CLOSE_BUTTON); WM_SetCallback(hItem, _cbButton_close); hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_LIST); LISTBOX_SetBkColor(hItem, LISTBOX_CI_SEL, GUI_BLUE); LISTBOX_SetTextColor(hItem, LISTBOX_CI_SEL, GUI_WHITE); LISTBOX_SetBkColor(hItem, LISTBOX_CI_UNSEL, GUI_BLACK); LISTBOX_SetTextColor(hItem, LISTBOX_CI_UNSEL, GUI_CYAN); LISTBOX_SetAutoScrollV(hItem, 1); break; case WM_TIMER: playlist_select = 0; break; case WM_PAINT: DrawRect3D(5, 140, 222, 67); DrawRect3D(230, 140, 83, 67); break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch (Id) { /* Notification sent by "Button_Settings" */ case ID_SETTINGS_BUTTON: switch (NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: GUI_CreateDialogBox(_aSettingsDialogCreate, GUI_COUNTOF(_aSettingsDialogCreate), _cbSettingsDialog, IMAGE_hWin, 0, 0); break; } break; /* Notifications sent by 'ListView' Slider */ case ID_IMAGE_LIST: if(NCode == WM_NOTIFICATION_CLICKED) { hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_LIST); Index = LISTBOX_GetSel(hItem); if(Index < pImageList->ptr) { if(playlist_select == 0) { hPlaylistTimer = WM_CreateTimer(pMsg->hWin, ID_PLAYLIST_TIMER, 500, 0); playlist_select = (Index + 1); } else if(playlist_select == (Index + 1)) { WM_DeleteTimer(hPlaylistTimer); hPlaylistTimer = 0; playlist_select = 0; if(Index < pImageList->ptr) { file_pos = Index; 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_close(&Image_File); f_open(&Image_File, (char const *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ); WM_InvalidateWindow(imFrame); } } } } break; /* Notification sent by "Button_Close" */ case ID_CLOSE_BUTTON: switch (NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: f_close(&Image_File); k_free(pImageList); k_free(pFileInfo); GUI_EndDialog(pMsg->hWin, 0); break; } break; /* Notification sent by "Button_Open" */ case ID_OPEN_BUTTON: switch (NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: pFileInfo->pfGetData = k_GetData; pFileInfo->pMask = acMask_dir; hItem = CHOOSEFILE_Create(pMsg->hWin, 20, 20, 200, 150, apDrives, GUI_COUNTOF(apDrives), 0, "add a folder", 0, pFileInfo); WM_MakeModal(hItem); result = GUI_ExecCreatedDialog(hItem); if (result == 0) { if(pImageList->ptr == 0) { _AddEntireFolder(pFileInfo->pRoot); file_pos = 0; 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); } else { _AddEntireFolder(pFileInfo->pRoot); } } break; } break; /* Notification sent by "Button_Open" */ case ID_ADD_BUTTON: switch (NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: pFileInfo->pfGetData = k_GetData; pFileInfo->pMask = acMask_img; hItem = CHOOSEFILE_Create(pMsg->hWin, 20, 20, 200, 150, apDrives, GUI_COUNTOF(apDrives), 0, "Add an image to playlist", 0, pFileInfo); WM_MakeModal(hItem); result = GUI_ExecCreatedDialog(hItem); if (result == 0) { if((strstr(pFileInfo->pRoot, ".jpg")) || (strstr(pFileInfo->pRoot, ".bmp")) || (strstr(pFileInfo->pRoot, ".JPG")) || (strstr(pFileInfo->pRoot, ".BMP"))) { strcpy((char *)pImageList->file[pImageList->ptr].name, pFileInfo->pRoot); FILEMGR_GetFileOnly(tmp, (char *)pFileInfo->pRoot); 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); } } break; } break; /* Notification sent by "Button_SlideShow" */ case ID_SLIDE_BUTTON: switch (NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: if(pImageList->ptr > 1) { f_close(&Image_File); f_open(&Image_File, (char const *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ); 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; } WM_InvalidateWindow(imFrame); if (slideshow_state == OFF) { hTimerTime = WM_CreateTimer(imFrame, ID_SLIDER_TIMER, (ImSettings.b.ss_timer * 1000) , 0); } else if(hTimerTime != 0) { WM_DeleteTimer(hTimerTime); hTimerTime = 0; } slideshow_state = (slideshow_state == OFF ? ON : OFF); } break; } break; /* Notification sent by "Button_Next" */ case ID_NEXT_BUTTON: switch (NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: if(pImageList->ptr > 0) { if (file_pos < (pImageList->ptr - 1)) { file_pos++; f_close(&Image_File); } else { file_pos = 0; 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 const *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ); WM_InvalidateWindow(imFrame); hItem = WM_GetDialogItem(IMAGE_hWin, ID_IMAGE_LIST); LISTBOX_SetSel(hItem, file_pos); } break; } break; /* Notification sent by "Button_Previous" */ case ID_PREVIOUS_BUTTON: switch (NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: if(pImageList->ptr > 0) { if (file_pos > 0 ) { file_pos--; f_close(&Image_File); } else { 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 const *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ); WM_InvalidateWindow(imFrame); hItem = WM_GetDialogItem(IMAGE_hWin, ID_IMAGE_LIST); LISTBOX_SetSel(hItem, file_pos); } break; } break; } break; default: WM_DefaultProc(pMsg); break; } }
/** * @brief Callback routine of Info dialog * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None */ static void _cbPlaylistDialog(WM_MESSAGE * pMsg) { int NCode; int Id; int r; WM_HWIN hItem; static char tmp[64]; uint32_t i = 0; switch (pMsg->MsgId) { case WM_INIT_DIALOG: hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_OKPL); WM_SetCallback(hItem, _cbButton_okPL); hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_ADDPL); WM_SetCallback(hItem, _cbButton_add2PL); hItem = LISTVIEW_CreateEx(35, 30, 250, 155, pMsg->hWin, WM_CF_SHOW, 0, ID_VIDEO_LIST); LISTVIEW_SetFont(hItem, &GUI_FontLubalGraph16); LISTVIEW_SetTextColor(hItem, LISTVIEW_CI_UNSEL, GUI_STCOLOR_LIGHTBLUE); LISTVIEW_SetTextColor(hItem, LISTVIEW_CI_SEL, GUI_WHITE); LISTVIEW_SetHeaderHeight(hItem, 0); LISTVIEW_AddColumn(hItem, 250, "", GUI_TA_VCENTER | GUI_TA_LEFT); LISTVIEW_SetGridVis(hItem, 0); LISTVIEW_SetAutoScrollV(hItem, 1); WIDGET_SetEffect(hItem, &WIDGET_Effect_None); LISTVIEW_SetTextAlign(hItem, 0, GUI_TA_HCENTER); if(VideoList.ptr > 0) { for(i=0; i<VideoList.ptr; i++) { strcpy(FileInfo.pRoot, (char *)VideoList.file[i].name); FILEMGR_GetFileOnly ((char *)tmp, (char *)FileInfo.pRoot); LISTVIEW_AddRow(hItem, NULL); LISTVIEW_SetItemText(hItem, 0, i, (char *)tmp); } sprintf(tmp, "PlayList [%d Item(s)]", VideoList.ptr); FRAMEWIN_SetText(pMsg->hWin, tmp); } else { FRAMEWIN_SetText(pMsg->hWin, "PlayList [no Item]"); FileInfo.pfGetData = k_GetData; FileInfo.pMask = acMask_video; hItem = CHOOSEFILE_Create(WM_GetParent(pMsg->hWin), 100, 60, 240, 170, apDrives, GUI_COUNTOF(apDrives), 0, "Video files", 0, &FileInfo); WM_MakeModal(hItem); r = GUI_WaitForDialogExec(hItem); if (r == 0) { if((strstr(FileInfo.pRoot, ".emf")) || (strstr(FileInfo.pRoot, ".EMF"))) { if(VideoList.ptr < FILEMGR_LIST_DEPDTH) { strcpy((char *)VideoList.file[VideoList.ptr].name, FileInfo.pRoot); FILEMGR_GetFileOnly ((char *)tmp, (char *)FileInfo.pRoot); hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_LIST); LISTVIEW_AddRow(hItem, NULL); LISTVIEW_SetItemText(hItem, 0, VideoList.ptr, (char *)tmp); VideoList.ptr++; } } sprintf(tmp, "PlayList [%d Item(s)]", VideoList.ptr); FRAMEWIN_SetText(pMsg->hWin, tmp); } WM_InvalidateWindow(pMsg->hWin); } break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch(Id) { case ID_BUTTON_OKPL: /* Notifications sent by 'OK' */ switch(NCode) { case WM_NOTIFICATION_RELEASED: GUI_EndDialog(pMsg->hWin, 0); Video_FilePos = 0; hPlaylistWin = 0; break; } break; case ID_BUTTON_ADDPL: switch(NCode) { case WM_NOTIFICATION_RELEASED: FileInfo.pfGetData = k_GetData; FileInfo.pMask = acMask_video; hItem = CHOOSEFILE_Create(pMsg->hWin, 40, 20, 240, 170, apDrives, GUI_COUNTOF(apDrives), 0, "Video files", 0, &FileInfo); WM_MakeModal(hItem); r = GUI_WaitForDialogExec(hItem); if (r == 0) { if((strstr(FileInfo.pRoot, ".emf")) || (strstr(FileInfo.pRoot, ".EMF"))) { if(VideoList.ptr < FILEMGR_LIST_DEPDTH) { strcpy((char *)VideoList.file[VideoList.ptr].name, FileInfo.pRoot); FILEMGR_GetFileOnly ((char *)tmp, (char *)FileInfo.pRoot); hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_LIST); LISTVIEW_AddRow(hItem, NULL); LISTVIEW_SetItemText(hItem, 0, VideoList.ptr, (char *)tmp); VideoList.ptr++; } } sprintf(tmp, "PlayList [%d Item(s)]", VideoList.ptr); FRAMEWIN_SetText(pMsg->hWin, tmp); WM_InvalidateWindow(pMsg->hWin); } break; } break; } break; default: WM_DefaultProc(pMsg); break; } }
/** * @brief Camera window Startup * @param hWin: pointer to the parent handle. * @param xpos: X position * @param ypos: Y position * @retval None */ static void Startup(WM_HWIN hWin, uint16_t xpos, uint16_t ypos) { camera_disabled = 0; CAMERA_hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, hWin, xpos, ypos); }
/** * @brief Callback routine of dialog * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; int Id, NCode; TREEVIEW_ITEM_Handle hTreeView; TREEVIEW_ITEM_INFO Info; GUI_PID_STATE State; switch (pMsg->MsgId) { case WM_INIT_DIALOG: pFileList = (FILELIST_FileTypeDef *)k_malloc(sizeof(FILELIST_FileTypeDef)); pFileList->ptr = 0; hPopUp = WM_CreateWindowAsChild(0, 26, LCD_GetXSize(), LCD_GetYSize()-26, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS , _cbPopup, 0); WM_BringToBottom(hPopUp); hItem = pMsg->hWin; FRAMEWIN_AddCloseButton(hItem, FRAMEWIN_BUTTON_RIGHT, 0); WM_CreateWindowAsChild(240, 320, 1, 1, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS, _cbMediaConnection , 0); _RefreshBrowser(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_CHILD_DELETED: k_free(pFileList); if(hFileInfo != 0) { hFileInfo = 0; } break; case WM_NOTIFICATION_CLICKED: /* React only if released */ switch (Id) { case ID_TREEVIEW: hTreeView = TREEVIEW_GetSel(pMsg->hWinSrc); TREEVIEW_ITEM_GetInfo(hTreeView, &Info); if(Info.IsNode == 0) { GUI_TOUCH_GetState(&State); State.x += 20; if(State.x > 175) { State.x = 175; } State.y-= 50; if(State.y > 150) { State.y -= 70; } _FindFullPath(pMsg->hWinSrc, hTreeView, SelectedFileName); /* Create popup menu after touching the display */ _OpenPopup(hPopUp, _aMenuItems, GUI_COUNTOF(_aMenuItems), State.x, State.y); } break; case ID_BUTTON_REFRESH: _RefreshBrowser (pMsg->hWin); break; } break; } break; default: WM_DefaultProc(pMsg); break; } }
/********************************************************************* * * GUIDEMO_Config */ void GUIDEMO_Config(GUIDEMO_CONFIG * pConfig) { pConfig->apFunc = _apfTest; pConfig->NumDemos = GUI_COUNTOF(_apfTest); pConfig->Flags = GUIDEMO_CF_SHOW_SPRITES | GUIDEMO_CF_USE_AUTO_BK; }
int num_dialog(WM_HWIN hWin) { int set_num; set_num = GUI_ExecDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &_cbCallback, hWin, 320, 80);// GUI_ExecDialogBox return set_num; }
WM_HWIN _TaskerAddPage2(WM_HWIN hWin) { hParent = hWin; return GUI_CreateDialogBox(_aDialogCreate2, GUI_COUNTOF(_aDialogCreate2), _cbDialog, WM_UNATTACHED, 0, 0); }
/** * @brief Callback routine of the VNC dialog * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None */ static void _cbDialog_VNC(WM_MESSAGE * pMsg) { WM_HWIN hItem; int Id, NCode; switch (pMsg->MsgId) { case WM_INIT_DIALOG: /* Initialization of 'Multi Edit' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_MULTIEDIT_VNC); MULTIEDIT_SetReadOnly(hItem, 1); MULTIEDIT_SetBkColor(hItem, 1, 0); MULTIEDIT_SetTextColor(hItem, 1, 0xFFFFFF); /* Initialization of 'Image 1' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_PCNETWORK); IMAGE_SetBitmap(hItem, &bmpc_network64); /* Initialization of 'Image 2' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_STATE); IMAGE_SetBitmap(hItem, &bmDelete32); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_DHCP); TEXT_SetFont(hItem, GUI_FONT_13B_1); TEXT_SetTextColor(hItem, GUI_BLACK); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_DHCP_STATE); TEXT_SetFont(hItem, GUI_FONT_8_ASCII); TEXT_SetTextColor(hItem, GUI_BLACK); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_IPADDR); TEXT_SetFont(hItem, GUI_FONT_13B_1); TEXT_SetTextColor(hItem, GUI_BLACK); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_IPADDR_VALUE); TEXT_SetFont(hItem, GUI_FONT_8_ASCII); TEXT_SetTextColor(hItem, GUI_BLACK); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_SUBNETMASK); TEXT_SetFont(hItem, GUI_FONT_13B_1); TEXT_SetTextColor(hItem, GUI_BLACK); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_SUBNETMASK_VALUE); TEXT_SetFont(hItem, GUI_FONT_8_ASCII); TEXT_SetTextColor(hItem, GUI_BLACK); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_GWADDR); TEXT_SetFont(hItem, GUI_FONT_13B_1); TEXT_SetTextColor(hItem, GUI_BLACK); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_GWADDR_VALUE); TEXT_SetFont(hItem, GUI_FONT_8_ASCII); TEXT_SetTextColor(hItem, GUI_BLACK); /* Restore VNC settings */ _VNCServer_RestoreSettings(); if (VNCSettings.maskaddr.b.addr3 != 255) { VNCSettings.dhcp_use.b.dhcp = 1; VNCSettings.ipaddr.b.addr0 = 0; VNCSettings.ipaddr.b.addr1 = 0; VNCSettings.ipaddr.b.addr2 = 0; VNCSettings.ipaddr.b.addr3 = 0; VNCSettings.maskaddr.b.addr0 = 0; VNCSettings.maskaddr.b.addr1 = 0; VNCSettings.maskaddr.b.addr2 = 0; VNCSettings.maskaddr.b.addr3 = 0; VNCSettings.gwaddr.b.addr0 = 0; VNCSettings.gwaddr.b.addr1 = 0; VNCSettings.gwaddr.b.addr2 = 0; VNCSettings.gwaddr.b.addr3 = 0; /* Save VNC settings */ _VNCServer_SaveSettings(); } else { _VNCApp_GetIPAddress(IP_ADDRESS, VNCSettings.ipaddr.b.addr3, VNCSettings.ipaddr.b.addr2, VNCSettings.ipaddr.b.addr1, VNCSettings.ipaddr.b.addr0); _VNCApp_GetIPAddress(SUBNET_MASK, VNCSettings.maskaddr.b.addr3, VNCSettings.maskaddr.b.addr2, VNCSettings.maskaddr.b.addr1, VNCSettings.maskaddr.b.addr0); _VNCApp_GetIPAddress(GW_ADDRESS, VNCSettings.gwaddr.b.addr3, VNCSettings.gwaddr.b.addr2, VNCSettings.gwaddr.b.addr1, VNCSettings.gwaddr.b.addr0); } if (VNCSettings.dhcp_use.b.dhcp == 0) { _VNCServer_DisplayIPAddress(); } break; case WM_PAINT: DrawRect3D(230, 5, 87, 120); DrawRect3D(2, 130, 225, 80); DrawRect3D(230, 130, 87, 80); 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_SETTINGS: /* Settings */ if(hWinVNC_Settings == 0) { hWinVNC_Settings = GUI_CreateDialogBox(_aDialog_VNC_SETTINGS, GUI_COUNTOF(_aDialog_VNC_SETTINGS), _cbDialog_VNC_SETTINGS, hWinVNC, 0, 10); hNumPad = GUI_CreateDialogBox(_aDialogNumPad, GUI_COUNTOF(_aDialogNumPad), _cbDialogNumPad, pMsg->hWin, 0, 0); } break; case ID_BUTTON_START: /* Start */ if(hWinVNC_Settings == 0) { if (start_button == VNC_START) { /* change start button to hide */ start_button = VNC_HIDE; hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_START); BUTTON_SetText(hItem, (const char*) "Hide"); /* Cange connection png pic from disconnected to connecting */ hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_STATE); IMAGE_SetBitmap(hItem, &bmhourglass32); hItem = WM_GetDialogItem(pMsg->hWin, ID_MULTIEDIT_VNC); MULTIEDIT_AddText(hItem, (const char *) "TCP/IP stack initialization ... \n\r"); TCPIP_Initialized = 1; /* Initilaize the LwIP stack */ NetworkInit(VNCSettings.dhcp_use.b.dhcp); } else /* start_button == VNC_HIDE */ { if(hWinVNC_Settings == 0) { WM_HideWindow(pMsg->hWin); } } } break; } break; } break; default: WM_DefaultProc(pMsg); break; } }
"December"}; /* Array of menu items */ static MENU_ITEM _aMenuItems[] = { {"Kernel Log" , ID_MENU_LOG, 0}, {"Process Viewer" , ID_MENU_PMGR, 0}, {"CPU Usage", ID_MENU_PERF, 0}, {0 , 0 , MENU_IF_SEPARATOR}, {"Cancel" , ID_MENU_EXIT, 0}, }; /* Sprite array */ static SPRITE _aSprite[] = { { 640, 150, -8, -2, GUI_COUNTOF(apbmbutterfly), apbmbutterfly}, }; /* Dialog Create */ static const GUI_WIDGET_CREATE_INFO _aPerformanceDialogCreate[] = { { FRAMEWIN_CreateIndirect, "CPU Usage", ID_FRAMEWIN_PERFORMANCE, 100, 100, 405, 240, 0, 0x0, 0 }, { GRAPH_CreateIndirect, "", ID_GRAPH_CPU, 6, 9, 380, 190, 0, 0x0, 0 }, { BUTTON_CreateIndirect, "Hide", ID_BUTTON_HIDE, 166, 200, 80, 30, 0, 0x0, 0 }, }; static const GUI_WIDGET_CREATE_INFO _aKernelLogDialogCreate[] = { { FRAMEWIN_CreateIndirect, "Kernel Log", ID_FRAMEWIN_KERNELLOG, 100, 100, 405, 240, 0, 0x0, 0 }, { BUTTON_CreateIndirect, "Cancel", ID_BUTTON_CANCEL_KERNELLOG, 166, 200, 80, 30, 0, 0x0, 0 }, { MULTIEDIT_CreateIndirect, "Multiedit", ID_MULTIEDIT_KERNELLOG, 6, 9, 380, 190, 0, 0x0, 0 }, };
WM_HWIN Create_wSaveDlg(void) { WM_HWIN hWin; hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &_cbDialog, WM_HBKWIN, 0, 0); return hWin; }
/********************************************************************* * * MULTIPAGE_SetDefaultTextColor */ void MULTIPAGE_SetDefaultTextColor(GUI_COLOR Color, unsigned Index) { if (Index < GUI_COUNTOF(MULTIPAGE__DefaultTextColor)) { MULTIPAGE__DefaultTextColor[Index] = Color; } }
/** * @brief Callback function of the Settings frame * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None */ static void _cbSettingsDialog(WM_MESSAGE * pMsg) { int Id, NCode; WM_HWIN hItem; switch (pMsg->MsgId) { case WM_INIT_DIALOG: /* Settings frame initialization */ hItem = pMsg->hWin; FRAMEWIN_AddCloseButton(hItem, FRAMEWIN_BUTTON_RIGHT, 0); /* Create and attache the MULTIPAGE dialog windows */ hItem = WM_GetDialogItem(pMsg->hWin, ID_MULTIPAGE); hDialogCameraSettings = GUI_CreateDialogBox(_aDialogCameraSettings, GUI_COUNTOF(_aDialogCameraSettings), &_cbCameraSettings, WM_UNATTACHED, 0, 0); MULTIPAGE_AddPage(hItem, hDialogCameraSettings, "Camera Settings"); hDialogFileControl = GUI_CreateDialogBox(_aDialogFileControl, GUI_COUNTOF(_aDialogFileControl), &_cbFileControl, WM_UNATTACHED, 0, 0); MULTIPAGE_AddPage(hItem, hDialogFileControl, "File Settings"); MULTIPAGE_SelectPage(hItem, 0); /* 'OK' button initialization */ hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_OK); BUTTON_SetFont(hItem, GUI_FONT_13B_1); /* 'Cancel' button initialization */ hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_CANCEL); BUTTON_SetFont(hItem, GUI_FONT_13B_1); break; case WM_DELETE: camera_disabled = 0; hSettings = 0; if(SD_Configured == 1) { BSP_CAMERA_Init(RESOLUTION_R160x120); CAMERA_Configured = 1; /* Apply new settings*/ SD_Configured = 0; } /* Delete choosfile window */ WM_DeleteWindow(chooser_select_folder); break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch (Id) { case ID_BUTTON_OK: /* Notification sent by "OK" button */ switch (NCode) { case WM_NOTIFICATION_RELEASED: /* Save camera settings before delete settings frame */ hItem = WM_GetDialogItem(hDialogCameraSettings, ID_SLIDER_0); CameraSettings.b.brightness = SLIDER_GetValue(hItem); hItem = WM_GetDialogItem(hDialogCameraSettings, ID_SLIDER_1); CameraSettings.b.contrast = SLIDER_GetValue(hItem); /* Back to normal mode (no effects) */ hItem = WM_GetDialogItem(CAMERA_hWin, ID_RADIO); RADIO_SetValue(hItem, 0); if(CAMERA_GetState() != CAMERA_ERROR) { /* Apply new settings*/ CAMERA_Set_ContrastBrightness(CameraSettings.b.contrast, CameraSettings.b.brightness); BSP_CAMERA_BlackWhiteConfig(CAMERA_BLACK_WHITE_NORMAL); } GUI_EndDialog(pMsg->hWin, 0); break; } break; case ID_BUTTON_CANCEL: /* Notification sent by "Cancel" button */ switch (NCode) { case WM_NOTIFICATION_RELEASED: GUI_EndDialog(pMsg->hWin, 0); break; } break; } break; } }
/** * @brief Game window Startup * @param hWin: pointer to the parent handle. * @param xpos: X position * @param ypos: Y position * @retval None */ static void Startup(WM_HWIN hWin, uint16_t xpos, uint16_t ypos) { frame = 0; SystemWin = GUI_CreateDialogBox(_aDialog, GUI_COUNTOF(_aDialog), _cbDialog, hWin, xpos, ypos); hTimer = WM_CreateTimer(SystemWin, 0, 100, 0); }
/** * @brief Callback routine of the dialog * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem, Hint; GUI_RECT r; int NCode, Id; uint32_t tmp_param = 0; switch (pMsg->MsgId) { case WM_INIT_DIALOG: pFileInfo = (CHOOSEFILE_INFO *)k_malloc(sizeof(CHOOSEFILE_INFO)); CameraSettings.d32 = k_BkupRestoreParameter(CALIBRATION_CAMERA_SETTING_BKP); /* Initialization of 'Image' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE); IMAGE_SetBitmap(hItem, &bmwizard); /* Initialization of 'Effects' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT); TEXT_SetFont(hItem, GUI_FONT_16B_1); /* Initialization of 'Radio' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_RADIO); RADIO_SetText(hItem, "None", 0); RADIO_SetText(hItem, "B&W", 1); RADIO_SetText(hItem, "Negative", 2); RADIO_SetText(hItem, "Antique", 3); RADIO_SetText(hItem, "Blue", 4); RADIO_SetText(hItem, "Green", 5); RADIO_SetText(hItem, "Red", 6); /* Camera frame initialization */ hItem = WM_GetClientWindow(pMsg->hWin); WM_GetClientRectEx(hItem, &r); hCameraFrame = WM_CreateWindowAsChild(r.x0 + 79, r.y0 + 49, r.x1 - 159, r.y1 - 93, hItem, WM_CF_SHOW | WM_CF_LATE_CLIP, _cbCameraWindow, 0); /* Buttons initialization */ hItem = BUTTON_CreateEx(266, 175, 30, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_CLOSE); WM_SetCallback(hItem, _cbButton_close); hItem = BUTTON_CreateEx(256, 79, 50, 50, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_CAPTURE); WM_SetCallback(hItem, _cbButton_capture); hItem = BUTTON_CreateEx(266, 14, 30, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_SETTINGS); WM_SetCallback(hItem, _cbButton_settings); _Check_DefaultPath (capture_folder); FrameAvailable = 0; break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; if(hSettings == 0) { switch(Id) { case ID_RADIO: if(NCode == WM_NOTIFICATION_VALUE_CHANGED) { hItem = WM_GetDialogItem(pMsg->hWin, ID_RADIO); if(CAMERA_GetState() != CAMERA_ERROR) { CAMERA_SelectEffect(RADIO_GetValue(hItem)); } } break; case ID_BUTTON_CLOSE: /* Notifications sent by 'Close' */ switch(NCode) { case WM_NOTIFICATION_RELEASED: k_free(pFileInfo); CAMERA_Stop(); GUI_EndDialog(pMsg->hWin, 0); break; } break; case ID_BUTTON_CAPTURE: /* Notifications sent by 'OK' */ switch(NCode) { case WM_NOTIFICATION_RELEASED: /* Show Hint */ if(CAMERA_GetState() == CAMERA_OK) { Hint = WM_CreateWindowAsChild(100, 90, 120, 32, pMsg->hWin, WM_CF_SHOW , _cbHint, 0); GUI_Exec(); if(CAMERA_GetState() == CAMERA_OK) { CAMERA_SaveToFile(capture_folder); } WM_DeleteWindow(Hint); } break; } break; case ID_BUTTON_SETTINGS: /* Notifications sent by 'Settings' */ switch(NCode) { case WM_NOTIFICATION_RELEASED: camera_disabled = 1; hSettings = GUI_CreateDialogBox(_aSettingsDialogCreate, GUI_COUNTOF(_aSettingsDialogCreate), _cbSettingsDialog, CAMERA_hWin, 0, 0); break; } break; } } break; case WM_DELETE: tmp_param = k_BkupRestoreParameter(CALIBRATION_CAMERA_SETTING_BKP); /* check if new settings have to be saved */ if(CameraSettings.d32 != tmp_param) { k_BkupSaveParameter(CALIBRATION_CAMERA_SETTING_BKP, CameraSettings.d32); } break; default: WM_DefaultProc(pMsg); break; } }
/********************************************************************* * * CreateWindow */ WM_HWIN mainWinCreate(void) { WM_HWIN hWin; hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0); return hWin; }
/** * @brief Callback routine of popup menu. * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None */ static void _cbPopup(WM_MESSAGE * pMsg) { K_GET_DIRECT_OPEN_FUNC * pfOpen; MENU_MSG_DATA* pData; TREEVIEW_ITEM_Handle hTreeView; TREEVIEW_ITEM_INFO Info; WM_HWIN hItem; char ext[4]; switch (pMsg->MsgId) { case WM_INIT_DIALOG: break; case WM_MENU: /* Process the menu message */ pData = (MENU_MSG_DATA*)pMsg->Data.p; switch (pData->MsgType) { case MENU_ON_ITEMSELECT: /* Menu item has been selected */ switch (pData->ItemId) { case ID_MENU_OPENFILE: k_GetExtOnly(SelectedFileName, ext); pfOpen = k_ModuleCheckLink(ext); if(pfOpen != NULL) { pfOpen(SelectedFileName); } else { _ShowMessageBox(hExplorerWin, "File Browser", "No external module is linked to\n this extension!", 0); } break; case ID_MENU_DELETE: if (_ShowMessageBox(hExplorerWin, "File Browser", "Are you sure you want to\ndelete selected file?", 1)) { f_unlink (SelectedFileName); _RefreshBrowser(hExplorerWin); } break; case ID_MENU_PROPRIETIES: if(hFileInfo == 0) { hFileInfo = GUI_CreateDialogBox(_aFileInfoDialogCreate, GUI_COUNTOF(_aFileInfoDialogCreate), _cbFileInfoDialog, hExplorerWin, 5, 75); } break; case ID_MENU_EXIT: break; } hItem = WM_GetDialogItem(hExplorerWin, ID_TREEVIEW); hTreeView = TREEVIEW_GetSel(hItem); TREEVIEW_ITEM_GetInfo(hTreeView, &Info); if(Info.IsNode == 0) { /*Force Deselect item */ hTreeView = TREEVIEW_GetItem(hItem, hTreeView, TREEVIEW_GET_PARENT); TREEVIEW_SetSel(hItem, hTreeView); } } break; default: WM_DefaultProc(pMsg); break; } }
/** * @brief Callback routine of desktop window. * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None */ static void _cbBk(WM_MESSAGE * pMsg) { MENU_MSG_DATA* pData; uint32_t NCode, Id; static uint8_t sel = 0; switch (pMsg->MsgId) { case WM_MENU: /* Process the menu message */ pData = (MENU_MSG_DATA*)pMsg->Data.p; switch (pData->MsgType) { case MENU_ON_ITEMSELECT: /* A menu item has been selected */ switch (pData->ItemId) { case ID_MENU_LOG: if (hLog == 0) { hLog = GUI_CreateDialogBox(_aKernelLogDialogCreate, GUI_COUNTOF(_aProcessManagerDialogCreate), _cbKernelLogDialog, pMsg->hWin, FRAMEWIN_CF_MOVEABLE | WM_CF_FGND | WM_CF_STAYONTOP, 50); } else { WM_ShowWindow(hLog); WM_BringToTop(hLog); } break; case ID_MENU_PMGR: if(hProcess == 0) { hProcess = GUI_CreateDialogBox(_aProcessManagerDialogCreate, GUI_COUNTOF(_aProcessManagerDialogCreate), _cbProcessManagerDialog, pMsg->hWin, FRAMEWIN_CF_MOVEABLE | WM_CF_FGND | WM_CF_STAYONTOP, 50); } else { WM_ShowWindow(hProcess); WM_BringToTop(hProcess); } break; case ID_MENU_PERF: if(hPerformance == 0) { hPerformance = GUI_CreateDialogBox(_aPerformanceDialogCreate, GUI_COUNTOF(_aPerformanceDialogCreate), _cbPerformanceDialog, pMsg->hWin, FRAMEWIN_CF_MOVEABLE | WM_CF_FGND | WM_CF_STAYONTOP, 50); } else { WM_ShowWindow(hPerformance); WM_BringToTop(hPerformance); } break; case ID_MENU_EXIT: break; } } break; case WM_PAINT: GUI_SetBkColor(GUI_WHITE); GUI_Clear(); if(hIcon) { WM_BringToBottom(hIcon); } break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch (NCode) { case WM_NOTIFICATION_CLICKED: if (Id == ID_ICONVIEW_MENU) { sel = ICONVIEW_GetSel(pMsg->hWinSrc); if(hPerformance != 0) { WM_HideWindow(hPerformance); } if(sel < k_ModuleGetNumber()) { if(sel < 8) { ICONVIEW_SetSel(pMsg->hWinSrc, -1); } else { ICONVIEW_SetSel(pMsg->hWinSrc, k_ModuleGetNumber() + 1); } } } break; case WM_NOTIFICATION_RELEASED: if (Id == ID_ICONVIEW_MENU) { if(sel < k_ModuleGetNumber()) { module_prop[sel].module->startup(pMsg->hWin, 0, 25); sel = 0; } } else if (Id == ID_BUTTON_BKGND) { /* Create popup menu after touching the display */ _OpenPopup(WM_HBKWIN, _aMenuItems, GUI_COUNTOF(_aMenuItems),0 , 25); } break; default: break; } break; default: WM_DefaultProc(pMsg); } }
/********************************************************************* * * MainTask * ********************************************************************** */ WM_HWIN MeasureData_CreateWindow (void) { WM_HWIN hWin; hWin = GUI_CreateDialogBox(MeasureData_aDialog, GUI_COUNTOF (MeasureData_aDialog), &MeasureData_cbCallback, 0, 0, 0); return hWin; }
/** * @brief Audio player window Startup * @param hWin: pointer to the parent handle. * @param xpos: X position * @param ypos: Y position * @retval None */ static void Startup(WM_HWIN hWin, uint16_t xpos, uint16_t ypos) { AUDIOPLAYER_Init(); AUDIOPLAYER_hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, hWin, xpos, ypos); }
/** * @brief This function is responsible to pass information about the requested file * @param pInfo: Pointer to structure which contains all details of the requested file. * @retval None */ int k_GetData(CHOOSEFILE_INFO * pInfo) { char c; int i; char tmp[CHOOSEFILE_MAXLEN]; FRESULT res = FR_INT_ERR; char *fn; FILINFO fno; #if _USE_LFN fno.lfname = lfn; fno.lfsize = sizeof(lfn); #endif switch (pInfo->Cmd) { case CHOOSEFILE_FINDFIRST: f_closedir(&dir); /* reformat path */ memset(tmp, 0, CHOOSEFILE_MAXLEN); strcpy(tmp, pInfo->pRoot); for(i= CHOOSEFILE_MAXLEN; i > 0 ; i--) { if(tmp[i] == '/') { tmp[i] = 0 ; break; } } res = f_opendir(&dir, tmp); if (res == FR_OK) { res = f_readdir(&dir, &fno); } break; case CHOOSEFILE_FINDNEXT: res = f_readdir(&dir, &fno); break; } if (res == FR_OK) { #if _USE_LFN if(*fno.lfname == 0) { strcpy(fno.lfname, fno.fname); } fn = fno.lfname; #else fn = fno.fname; #endif while (((fno.fattrib & AM_DIR) == 0) && (res == FR_OK)) { if((strstr(pInfo->pMask, ".img"))) { if((strstr(fn, ".bmp")) || (strstr(fn, ".jpg")) || (strstr(fn, ".BMP")) || (strstr(fn, ".JPG"))) { break; } else { res = f_readdir(&dir, &fno); if (res != FR_OK || fno.fname[0] == 0) { f_closedir(&dir); return 1; } else { #if _USE_LFN if(*fno.lfname == 0) { strcpy(fno.lfname, fno.fname); } fn = fno.lfname; #else fn = fno.fname; #endif } } } else if((strstr(pInfo->pMask, ".audio"))) { if((strstr(fn, ".wav")) || (strstr(fn, ".WAV"))) { break; } else { res = f_readdir(&dir, &fno); if (res != FR_OK || fno.fname[0] == 0) { f_closedir(&dir); return 1; } else { #if _USE_LFN if(*fno.lfname == 0) { strcpy(fno.lfname, fno.fname); } fn = fno.lfname; #else fn = fno.fname; #endif } } } else if((strstr(pInfo->pMask, ".video"))) { if((strstr(fn, ".emf")) || (strstr(fn, ".EMF"))) { break; } else { res = f_readdir(&dir, &fno); if (res != FR_OK || fno.fname[0] == 0) { f_closedir(&dir); return 1; } else { #if _USE_LFN if(*fno.lfname == 0) { strcpy(fno.lfname, fno.fname); } fn = fno.lfname; #else fn = fno.fname; #endif } } } else if(strstr(fn, pInfo->pMask) == NULL) { res = f_readdir(&dir, &fno); if (res != FR_OK || fno.fname[0] == 0) { f_closedir(&dir); return 1; } else { #if _USE_LFN if(*fno.lfname == 0) { strcpy(fno.lfname, fno.fname); } fn = fno.lfname; #else fn = fno.fname; #endif } } else { break; } } if(fn[0] == 0) { f_closedir(&dir); return 1; } pInfo->Flags = ((fno.fattrib & AM_DIR) == AM_DIR) ? CHOOSEFILE_FLAG_DIRECTORY : 0; for (i = 0; i < GUI_COUNTOF(_aAttrib); i++) { if (fno.fattrib & _aAttrib[i].Mask) { c = _aAttrib[i].c; } else { c = '-'; } acAttrib[i] = c; } if((fno.fattrib & AM_DIR) == AM_DIR) { acExt[0] = 0; } else { GetExt(fn, acExt); } pInfo->pAttrib = acAttrib; pInfo->pName = fn; pInfo->pExt = acExt; pInfo->SizeL = fno.fsize; pInfo->SizeH = 0; } return res; }
/** * @brief Callback routine of the dialog * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; int NCode; int Id, ItemNbr; int result; int duration, volume, index; static char tmp[FILEMGR_FILE_NAME_SIZE]; switch (pMsg->MsgId) { case WM_INIT_DIALOG: pWavList = (FILELIST_FileTypeDef *)k_malloc(sizeof(FILELIST_FileTypeDef)); pFileInfo = (CHOOSEFILE_INFO *)k_malloc(sizeof(CHOOSEFILE_INFO)); pWavList->ptr = 0; /* Initialization of 'Listview' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_WAVFILE_LIST); LISTVIEW_AddColumn(hItem, 120, "Track", GUI_TA_VCENTER | GUI_TA_LEFT); LISTVIEW_AddColumn(hItem, 60, "Duration", GUI_TA_VCENTER | GUI_TA_RIGHT); LISTVIEW_SetGridVis(hItem, 0); LISTVIEW_SetAutoScrollV(hItem, 1); LISTVIEW_SetBkColor(hItem, LISTVIEW_CI_UNSEL, GUI_BLACK); LISTVIEW_SetTextColor(hItem, LISTVIEW_CI_UNSEL, GUI_CYAN); /* Title Initialization in play list */ hItem = WM_GetDialogItem(pMsg->hWin, ID_TITLE_CAPTION); TEXT_SetText(hItem, "TITLE:"); TEXT_SetTextColor(hItem, GUI_CYAN); /* Title Initialization in play list */ hItem = WM_GetDialogItem(pMsg->hWin, ID_TITLE); TEXT_SetTextColor(hItem, GUI_CYAN); /* Duration */ hItem = WM_GetDialogItem(pMsg->hWin, ID_ELAPSED_TIME); TEXT_SetText(hItem, "00:00"); TEXT_SetFont(hItem, GUI_FONT_20B_1); TEXT_SetTextColor(hItem, GUI_LIGHTGRAY); /* Author initialization */ hItem = WM_GetDialogItem(pMsg->hWin, ID_AUTHOR_CAPTION); TEXT_SetText(hItem, "AUTHOR:"); TEXT_SetTextColor(hItem, GUI_CYAN); /* Author */ hItem = WM_GetDialogItem(pMsg->hWin, ID_AUTHOR); TEXT_SetText(hItem, ""); TEXT_SetTextColor(hItem, GUI_CYAN); /* Sampling Rate */ hItem = WM_GetDialogItem(pMsg->hWin, ID_SAMPLING_CAPTION); TEXT_SetText(hItem, "SAMPLING:"); TEXT_SetTextColor(hItem, GUI_CYAN); /* Sampling Rate Value */ hItem = WM_GetDialogItem(pMsg->hWin, ID_SAMPLING_VALUE); TEXT_SetText(hItem, ""); TEXT_SetTextColor(hItem, GUI_CYAN); /* Duration */ hItem = WM_GetDialogItem(pMsg->hWin, ID_TOTAL_TIME); TEXT_SetText(hItem, "00:00"); TEXT_SetTextColor(hItem, GUI_CYAN); /* Initialization of 'OPEN' Button */ hItem = WM_GetDialogItem(pMsg->hWin, ID_OPEN_BUTTON); BUTTON_SetFont(hItem, GUI_FONT_24_1); /* Initialization of 'Play List' Button */ hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_LIST_BUTTON); BUTTON_SetFont(hItem, GUI_FONT_24_1); /* Initialization of 'Add' Button */ hItem = WM_GetDialogItem(pMsg->hWin, ID_ADD_BUTTON); BUTTON_SetFont(hItem, GUI_FONT_24_1); volume = AUDIOPLAYER_GetVolume(); hItem = WM_GetDialogItem(pMsg->hWin, ID_VOLUME_SLIDER); SLIDER_SetValue(hItem, volume); hItem = WM_GetDialogItem(pMsg->hWin, ID_DURATION_SLIDER); SLIDER_SetNumTicks(hItem, 25); PlayerSettings.d32 = k_BkupRestoreParameter(CALIBRATION_AUDIOPLAYER_SETTING_BKP); PlayerSettings.b.mute = MUTE_OFF; PlayerSettings.b.pause = PLAY_ACTIVE; hItem = WM_GetClientWindow(pMsg->hWin); hItem = BUTTON_CreateEx(17, 96, 30, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_REPEAT_BUTTON); WM_SetCallback(hItem, _cbButton_repeat); hItem = WM_GetClientWindow(pMsg->hWin); hItem = BUTTON_CreateEx(58, 91, 40, 40, pMsg->hWin, WM_CF_SHOW, 0, ID_MUTE_BUTTON); WM_SetCallback(hItem, _cbButton_speaker); hItem = WM_GetClientWindow(pMsg->hWin); hItem = BUTTON_CreateEx(239, 70, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_STOP_BUTTON); WM_SetCallback(hItem, _cbButton_stop); hItem = WM_GetClientWindow(pMsg->hWin); hItem = BUTTON_CreateEx(198, 45, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_PREVIOUS_BUTTON); WM_SetCallback(hItem, _cbButton_previous); hItem = WM_GetClientWindow(pMsg->hWin); hItem = BUTTON_CreateEx(231, 10, 50, 50, pMsg->hWin, WM_CF_SHOW, 0, ID_PLAY_BUTTON); WM_SetCallback(hItem, _cbButton_play); hItem = WM_GetClientWindow(pMsg->hWin); hItem = BUTTON_CreateEx(276, 45, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_NEXT_BUTTON); WM_SetCallback(hItem, _cbButton_next); hItem = WM_GetClientWindow(pMsg->hWin); hItem = BUTTON_CreateEx(197, 135, 70, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_OPEN_BUTTON); WM_SetCallback(hItem, _cbButton_open); hItem = WM_GetClientWindow(pMsg->hWin); hItem = BUTTON_CreateEx(197, 172, 70, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_ADD_BUTTON); WM_SetCallback(hItem, _cbButton_add); hItem = WM_GetClientWindow(pMsg->hWin); hItem = BUTTON_CreateEx(280, 170, 30, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_CLOSE_BUTTON); WM_SetCallback(hItem, _cbButton_close); hTimerWin = WM_CreateWindowAsChild(0, 100, 10, 10, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS, _cbAudioProcess, 0); WM_CreateWindowAsChild(319, 220, 1, 1, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS, _cbMediaConnection , 0); break; case WM_PAINT: GUI_SetBkColor(GUI_BLACK); GUI_ClearRect(8, 3, 190, 70); DrawRect3D(195, 3, 118, 127); DrawRect3D(195, 131, 118, 77); DrawRect3D(8, 70, 182, 62); break; case WM_DELETE: AUDIOPLAYER_DeInit(); k_free(pWavList); k_free(pFileInfo); pWavList->ptr = 0; PlayerSettings.b.mute = MUTE_OFF; PlayerSettings.b.pause = PLAY_ACTIVE; k_BkupSaveParameter(CALIBRATION_AUDIOPLAYER_SETTING_BKP, PlayerSettings.d32); break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch(Id) { /* Notification sent by "Button_Close" */ case ID_CLOSE_BUTTON: switch (NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: GUI_EndDialog(pMsg->hWin, 0); break; } break; /* Notifications sent by 'Repeat' Button */ case ID_REPEAT_BUTTON: if(NCode == WM_NOTIFICATION_RELEASED) { hItem = WM_GetDialogItem(pMsg->hWin, ID_REPEAT_BUTTON); if(PlayerSettings.b.repeat == REPEAT_NONE) { PlayerSettings.b.repeat = REPEAT_ONCE; } else if(PlayerSettings.b.repeat == REPEAT_ONCE) { PlayerSettings.b.repeat = REPEAT_ALL; } else if(PlayerSettings.b.repeat == REPEAT_ALL) { PlayerSettings.b.repeat = REPEAT_NONE; } } break; /* Notifications sent by 'Mute' Button */ case ID_MUTE_BUTTON: if(NCode == WM_NOTIFICATION_RELEASED) { hItem = WM_GetDialogItem(pMsg->hWin, ID_MUTE_BUTTON); if(PlayerSettings.b.mute == MUTE_OFF) { AUDIOPLAYER_Mute(MUTE_ON); PlayerSettings.b.mute = MUTE_ON; } else { AUDIOPLAYER_Mute(MUTE_OFF); PlayerSettings.b.mute = MUTE_OFF; } } break; /* Notifications sent by 'Volume' Slider */ case ID_VOLUME_SLIDER: if(NCode == WM_NOTIFICATION_VALUE_CHANGED) { hItem = WM_GetDialogItem(pMsg->hWin, ID_VOLUME_SLIDER); AUDIOPLAYER_SetVolume(SLIDER_GetValue(hItem)); if(PlayerSettings.b.mute == MUTE_ON) { AUDIOPLAYER_Mute(MUTE_OFF); PlayerSettings.b.mute = MUTE_OFF; } } break; /* Notifications sent by 'progress' Slider */ case ID_DURATION_SLIDER: if(NCode == WM_NOTIFICATION_CLICKED) { hItem = WM_GetDialogItem(pMsg->hWin, ID_DURATION_SLIDER); AUDIOPLAYER_SetPosition(SLIDER_GetValue(hItem)); if(PlayerSettings.b.mute == MUTE_ON) { AUDIOPLAYER_Mute(MUTE_ON); } } break; /* Notifications sent by 'ListView' Slider */ case ID_WAVFILE_LIST: if(NCode == WM_NOTIFICATION_CLICKED) { hItem = WM_GetDialogItem(pMsg->hWin, ID_WAVFILE_LIST); index = LISTVIEW_GetSel(hItem); if(index < pWavList->ptr) { if(playlist_select == 0) { hPlaylistTimer = WM_CreateTimer(hTimerWin, ID_PLAYLIST_TIMER, 500, 0); playlist_select = (index + 1); } else if(playlist_select == (index + 1)) { WM_DeleteTimer(hPlaylistTimer); hPlaylistTimer = 0; playlist_select = 0; if(index < pWavList->ptr) { if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { AUDIOPLAYER_Stop(); } PlayerSettings.b.pause = PLAY_ACTIVE; hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON); WM_InvalidateWindow(hItem); WM_Update(hItem); file_pos = index; _PlayFile((char *)pWavList->file[index].name); } } } } break; /* Notifications sent by 'Play' Button */ case ID_PLAY_BUTTON: if(NCode == WM_NOTIFICATION_RELEASED) { if(AUDIOPLAYER_GetState() == AUDIOPLAYER_STOP) { if(pWavList->ptr > 0) { _PlayFile((char *)pWavList->file[file_pos].name); LISTVIEW_SetSel(WM_GetDialogItem(AUDIOPLAYER_hWin, ID_WAVFILE_LIST), file_pos); } else { pFileInfo->pfGetData = k_GetData; pFileInfo->pMask = acMask_audio; hItem = CHOOSEFILE_Create(pMsg->hWin, 20, 20, 200, 150, apDrives, GUI_COUNTOF(apDrives), 0, "Open an audio file", 0, pFileInfo); result = GUI_ExecCreatedDialog(hItem); if (result == 0) { if((strstr(pFileInfo->pRoot, ".wav")) || (strstr(pFileInfo->pRoot, ".WAV"))) { if(AUDIOPLAYER_GetFileInfo(pFileInfo->pRoot, &WavInfo) == 0) { if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { /* Stop current audio sample */ AUDIOPLAYER_Stop(); } pWavList->ptr = 0; file_pos = 0; strcpy((char *)pWavList->file[pWavList->ptr].name, pFileInfo->pRoot); FILEMGR_GetFileOnly (tmp, pFileInfo->pRoot); hItem = WM_GetDialogItem(pMsg->hWin, ID_WAVFILE_LIST); /* Update Play list */ strcpy((char *)pWavList->file[pWavList->ptr].name, pFileInfo->pRoot); ItemNbr = LISTVIEW_GetNumRows(hItem); while(ItemNbr--) { LISTVIEW_DeleteRow(hItem, ItemNbr); } LISTVIEW_AddRow(hItem, NULL); LISTVIEW_SetItemText(hItem, 0, pWavList->ptr, tmp); duration = WavInfo.FileSize / WavInfo.ByteRate; sprintf((char *)tmp , "%02d:%02d", duration/60, duration%60 ); LISTVIEW_SetItemText(hItem, 1, pWavList->ptr, tmp); pWavList->ptr++; LISTVIEW_SetSel(hItem, 0); _PlayFile(pFileInfo->pRoot); WM_InvalidateWindow(pMsg->hWin); } } } } } else if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { PlayerSettings.b.pause = (PlayerSettings.b.pause == PLAY_ACTIVE ? PAUSE_ACTIVE : PLAY_ACTIVE); if(PlayerSettings.b.pause == PAUSE_ACTIVE) { AUDIOPLAYER_Pause(); } else if(PlayerSettings.b.pause == PLAY_ACTIVE) { AUDIOPLAYER_Resume(); } } } break; /* Notifications sent by 'STOP' Button */ case ID_STOP_BUTTON: if(NCode == WM_NOTIFICATION_RELEASED) { if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { if(PlayerSettings.b.pause == PAUSE_ACTIVE) { PlayerSettings.b.pause = PLAY_ACTIVE; } hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON); WM_InvalidateWindow(hItem); WM_Update(hItem); AUDIOPLAYER_Stop(); hItem = WM_GetDialogItem(AUDIOPLAYER_hWin, ID_ELAPSED_TIME); TEXT_SetText(hItem, "00:00"); } } break; /* Notifications sent by 'Next' Button */ case ID_NEXT_BUTTON: if(NCode == WM_NOTIFICATION_RELEASED) { if( pWavList->ptr > 0) { if(file_pos < (pWavList->ptr - 1)) { file_pos++; LISTVIEW_IncSel(WM_GetDialogItem(AUDIOPLAYER_hWin, ID_WAVFILE_LIST)); } else if(PlayerSettings.b.repeat == REPEAT_ALL) { file_pos = 0; LISTVIEW_SetSel(WM_GetDialogItem(AUDIOPLAYER_hWin, ID_WAVFILE_LIST), file_pos); } if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { if(PlayerSettings.b.pause == PAUSE_ACTIVE) { PlayerSettings.b.pause = PLAY_ACTIVE; hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON); WM_InvalidateWindow(hItem); WM_Update(hItem); } AUDIOPLAYER_Stop(); _PlayFile((char *)pWavList->file[file_pos].name); } } } break; /* Notifications sent by 'Previous' Button */ case ID_PREVIOUS_BUTTON: if(NCode == WM_NOTIFICATION_RELEASED) { if( pWavList->ptr > 0) { if(file_pos > 0) { file_pos--; LISTVIEW_DecSel(WM_GetDialogItem(AUDIOPLAYER_hWin, ID_WAVFILE_LIST)); } else if(PlayerSettings.b.repeat == REPEAT_ALL) { file_pos = (pWavList->ptr - 1); LISTVIEW_SetSel(WM_GetDialogItem(AUDIOPLAYER_hWin, ID_WAVFILE_LIST), file_pos); } if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { if(PlayerSettings.b.pause == PAUSE_ACTIVE) { PlayerSettings.b.pause = PLAY_ACTIVE; hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON); WM_InvalidateWindow(hItem); WM_Update(hItem); } AUDIOPLAYER_Stop(); _PlayFile((char *)pWavList->file[file_pos].name); } } } break; /* Notifications sent by 'Open' Button */ case ID_OPEN_BUTTON: switch(NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: pFileInfo->pfGetData = k_GetData; pFileInfo->pMask = acMask_dir; hItem = CHOOSEFILE_Create(pMsg->hWin, 20, 20, 200, 150, apDrives, GUI_COUNTOF(apDrives), 0, "Add a folder", 0, pFileInfo); WM_MakeModal(hItem); result = GUI_ExecCreatedDialog(hItem); if (result == 0) { _AddEntireFolder(pFileInfo->pRoot); } break; } break; /* Notifications sent by 'Add' Button */ case ID_ADD_BUTTON: switch(NCode) { case WM_NOTIFICATION_RELEASED: pFileInfo->pfGetData = k_GetData; pFileInfo->pMask = acMask_audio; hItem = CHOOSEFILE_Create(pMsg->hWin, 20, 20, 200, 150, apDrives, GUI_COUNTOF(apDrives), 0, "Add to playlist", 0, pFileInfo); WM_MakeModal(hItem); result = GUI_ExecCreatedDialog(hItem); if (result == 0) { if((strstr(pFileInfo->pRoot, ".wav")) || (strstr(pFileInfo->pRoot, ".WAV"))) { if(pWavList->ptr < FILEMGR_LIST_DEPDTH) { strcpy((char *)pWavList->file[pWavList->ptr].name, pFileInfo->pRoot); FILEMGR_GetFileOnly (tmp, pFileInfo->pRoot); hItem = WM_GetDialogItem(pMsg->hWin, ID_WAVFILE_LIST); if(AUDIOPLAYER_GetFileInfo(pFileInfo->pRoot, &WavInfo) == 0) { LISTVIEW_AddRow(hItem, NULL); LISTVIEW_SetItemText(hItem, 0, pWavList->ptr, tmp); duration = WavInfo.FileSize / WavInfo.ByteRate; sprintf((char *)tmp , "%02d:%02d", duration/60, duration%60 ); LISTVIEW_SetItemText(hItem, 1, pWavList->ptr, tmp); pWavList->ptr++; } } } } break; } break; } break; default: WM_DefaultProc(pMsg); break; } }
/** * @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(419, 0, 60, 60, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_EXIT); WM_SetCallback(hItem, _cbButton_exit); hItem = ST_AnimatedIconView_CreateEx(30, 20, LCD_GetXSize() - 90, LCD_GetYSize() - 60, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS , 0, ID_ICONVIEW_SUBMENU, 170, 180, 40, 5); ST_AnimatedIconView_SetDualFont(hItem, &GUI_FontLubalGraph20, &GUI_FontLubalGraph20); ST_AnimatedIconView_SetSpace(hItem, GUI_COORD_Y, 5); ST_AnimatedIconView_SetSpace(hItem, GUI_COORD_X, 20); ST_AnimatedIconView_SetFrame(hItem, GUI_COORD_Y, 20); 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(479, 0, 479, 272); 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(-1, 0, 480, 272, WM_GetDesktopWindowEx(1), WM_CF_SHOW, _cbplaybackwin , 0); WM_CreateWindowAsChild(0, 70, 480, 140, 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, 480, 272,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, 75, 30); WM_MakeModal(hItem); } } else { hItem = GUI_CreateDialogBox(_aFileErrorDialogCreate, GUI_COUNTOF(_aFileErrorDialogCreate), _cbFileInfoDialog, pMsg->hWin, 75, 30); WM_MakeModal(hItem); } } else if(sel == 1) { hPlaylistWin = GUI_CreateDialogBox(_aPlaylistDialogCreate, GUI_COUNTOF(_aPlaylistDialogCreate), _cbPlaylistDialog, pMsg->hWin, 60, 40); WM_MakeModal(hPlaylistWin); } break; } break; } break; default: WM_DefaultProc(pMsg); break; } }
WM_HWIN Create_EditDlgWindow( WM_HWIN hWin_para) { WM_HWIN hWin; hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, hWin_para, 0, 0); return hWin; }
/** * @brief DEMO_Clock * @param hWin: Window handle * @retval None */ void DEMO_Clock(WM_HWIN hWin) { GUI_CreateDialogBox(_aDialog, GUI_COUNTOF(_aDialog), _cbDialog, hWin, 0, 0); }
/** * @brief Callback function of the File Control page * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None */ static void _cbFileControl(WM_MESSAGE * pMsg) { WM_HWIN hItem; int NCode; int Id; int result; switch (pMsg->MsgId) { case WM_INIT_DIALOG: /* Initialization of 'Brightness' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_FOLDER_CAPTION); TEXT_SetFont(hItem, GUI_FONT_13B_1); hItem = WM_GetDialogItem(pMsg->hWin, ID_FOLDER); EDIT_SetText(hItem, (char *)capture_folder); break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch(Id) { case ID_BROWSE: /* Notifications sent by 'Radio' */ switch(NCode) { case WM_NOTIFICATION_RELEASED: pFileInfo->pfGetData = k_GetData; pFileInfo->pMask = acMask_folder; BSP_SD_Init(); SD_Configured = 1; chooser_select_folder = CHOOSEFILE_Create(CAMERA_hWin, 20, 20, 200, 150, apDrives, GUI_COUNTOF(apDrives), 0, "Select a folder", 0, pFileInfo); result = GUI_ExecCreatedDialog(chooser_select_folder); if (result == 0) { if(((pFileInfo->pRoot[0] == '0' ) || (pFileInfo->pRoot[0] == '1' ))) { hItem = WM_GetDialogItem(hDialogFileControl, ID_FOLDER); EDIT_SetText(hItem, (char *)pFileInfo->pRoot); chooser_select_folder = 0; WM_InvalidateWindow(hDialogFileControl); WM_Paint(hDialogFileControl); strncpy((char *)(CAMERA_SAVE_PATH),pFileInfo->pRoot , FILEMGR_FULL_PATH_SIZE); strncpy((char *)capture_folder,pFileInfo->pRoot , FILEMGR_FULL_PATH_SIZE); } } break; } break; } break; default: WM_DefaultProc(pMsg); break; } }
/********************************************************************* * * _Action * * Purpose: * Does some action with the widget */ static void _Action(WM_HWIN hList) { unsigned ColoredCol = 0; unsigned ColoredRow = 0; unsigned NumRows; unsigned Index; unsigned i; int SortedColumn = -1; int ColorIndex = 0; int Reverse = 0; Index = 0; do { if (_aAction[Index].pDescription) { GUIDEMO_ShowInfo(_aAction[Index].pDescription); } switch (_aAction[Index].Job) { case JOB_COLOR: NumRows = LISTVIEW_GetNumRows(hList); for (i = 0; i < NumRows; i++) { LISTVIEW_SetItemBkColor(hList, ColoredCol, ColoredRow, LISTVIEW_CI_UNSEL, _aColor[ColorIndex]); if (++ColorIndex == GUI_COUNTOF(_aColor)) { ColorIndex = 0; } if (++ColoredCol == LISTVIEW_GetNumColumns(hList)) { ColoredCol = 0; } if (++ColoredRow == NumRows) { ColoredRow = 0; } } break; case JOB_INCSEL: LISTVIEW_IncSel(hList); break; case JOB_DECSEL: LISTVIEW_DecSel(hList); break; case JOB_REVERSE: Reverse ^= 1; LISTVIEW_SetSort(hList, SortedColumn, Reverse); break; case JOB_ADDROWS: for (i = 0; i < 40; i++) { _AddRow(hList, 0); } break; case JOB_SETSORT: if (SortedColumn == -1) { SortedColumn = 0; } else { SortedColumn++; if (SortedColumn == (int)LISTVIEW_GetNumColumns(hList)) { SortedColumn = 0; } } LISTVIEW_SetSort(hList, SortedColumn, Reverse); break; } GUI_Delay(_aAction[Index].Delay); } while ((++Index < GUI_COUNTOF(_aAction)) && (GUIDEMO_CheckCancel() == 0)); }
WM_HWIN CreateWindow_1(void) { hWin_1 = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0); return hWin_1; }