/********************************************************************* * * _cbDialogOrder */ static void _cbDialogOrder(WM_MESSAGE* pMsg) { WM_HWIN hDlg, hWin = pMsg->hWin; switch (pMsg->MsgId) { case WM_INIT_DIALOG: _InitDialogOrder(hWin); WM_SetFocus(WM_GetDialogItem(hWin, GUI_ID_OK)); break; case WM_NOTIFY_PARENT: if (pMsg->Data.v == WM_NOTIFICATION_RELEASED) { int Id = WM_GetId(pMsg->hWinSrc); switch (Id) { case GUI_ID_BUTTON0: hDlg = GUI_CreateDialogBox(_aDialogSelect, GUI_COUNTOF(_aDialogSelect), &_cbDialogSelect, WM_HBKWIN, 0, 0); WM_MakeModal(hDlg); GUI_ExecCreatedDialog(hDlg); WM_MakeModal(hWin); WM_SetFocus(hWin); hDlg = WM_GetDialogItem(hWin, GUI_ID_EDIT0); EDIT_SetText(hDlg, _acVehicle); break; case GUI_ID_OK: case GUI_ID_CANCEL: GUI_EndDialog(hWin, 0); break; } } 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); } }
/** * @brief Show Message Box * @param hWin: pointer to the parent handle * @param pTitle: pointer to the title * @param pText: pointer to the text * @retval int */ static int _ShowMessageBox(WM_HWIN hWin, const char* pTitle, const char* pText, int YesNo) { WM_HWIN hFrame, hClient, hBut; int r = 0; /* Create frame win */ hFrame = FRAMEWIN_CreateEx(25, 82, 190, 90, hWin, WM_CF_SHOW, FRAMEWIN_CF_MOVEABLE, 0, pTitle, &_cbMessageBox); FRAMEWIN_SetClientColor (hFrame, GUI_WHITE); FRAMEWIN_SetFont (hFrame, &GUI_Font16B_ASCII); FRAMEWIN_SetTextAlign (hFrame, GUI_TA_HCENTER); /* Create dialog items */ hClient = WM_GetClientWindow(hFrame); TEXT_CreateEx(10, 7, 170, 30, hClient, WM_CF_SHOW, GUI_TA_HCENTER, 0, pText); if (YesNo) { hBut = BUTTON_CreateEx(97, 45, 55, 18, hClient, WM_CF_SHOW, 0, GUI_ID_CANCEL); BUTTON_SetText (hBut, "No"); hBut = BUTTON_CreateEx(32, 45, 55, 18, hClient, WM_CF_SHOW, 0, GUI_ID_OK); BUTTON_SetText (hBut, "Yes"); } else { hBut = BUTTON_CreateEx(64, 45, 55, 18, hClient, WM_CF_SHOW, 0, GUI_ID_OK); BUTTON_SetText (hBut, "Ok"); } WM_SetFocus(hFrame); WM_MakeModal(hFrame); r = GUI_ExecCreatedDialog(hFrame); return r; }
/********************************************************************* * * _MessageBox */ static void _MessageBox(const char* pText, const char* pCaption) { WM_HWIN hWin; hWin = MESSAGEBOX_Create(pText, pCaption, 0); WM_MakeModal(hWin); GUI_ExecCreatedDialog(hWin); }
/********************************************************************* * * _cbDialogSelect */ static void _cbDialogSelect(WM_MESSAGE* pMsg) { WM_HWIN hWin = pMsg->hWin; switch (pMsg->MsgId) { case WM_INIT_DIALOG: _InitDialogSelect(hWin); WM_SetFocus(WM_GetDialogItem(hWin, GUI_ID_OK)); break; case WM_NOTIFY_PARENT: if (pMsg->Data.v == WM_NOTIFICATION_RELEASED) { int Id = WM_GetId(pMsg->hWinSrc); switch (Id) { case GUI_ID_OK: if (_GetVehicle(hWin) == 0) { _MessageBox("You have to select a vehicle!", "ERROR"); WM_MakeModal(hWin); WM_SetFocus(hWin); break; } case GUI_ID_CANCEL: GUI_EndDialog(pMsg->hWin, 0); break; } } break; default: WM_DefaultProc(pMsg); } }
/*---------------------------------------------------------------------------* * Routine: _cbDialog *---------------------------------------------------------------------------* * Description: * Callback function used by emWin to process events for the active window. * Inputs: * WM_MESSAGE *pMsg -- message structure for current dialog. *---------------------------------------------------------------------------*/ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; int Id, NCode; T_keyboardMapping *p = G_keypadCurrentMapping; switch (pMsg->MsgId) { case WM_INIT_DIALOG: // // Initialization of 'Window' // hItem = pMsg->hWin; G_window = hItem; WINDOW_SetBkColor(hItem, KEYBOARD_BACKGROUND_COLOR); //BUTTON_SetDefaultBkColor(KEY_BACKGROUND_COLOR, BUTTON_CI_UNPRESSED); EDIT_SetDefaultFont(&KEYBOARD_DEFAULT_FONT); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_BOX); EDIT_SetMaxLen(hItem, MAX_NUMBER_OF_CHARS); EDIT_SetText(hItem, G_textBox); EDIT_SetFont(hItem, &KEYBOARD_DEFAULT_FONT); G_textBoxIndex = EDIT_GetNumChars(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_MESSAGE); TEXT_SetFont(hItem, &KEYBOARD_DEFAULT_FONT); TEXT_SetTextColor(hItem, GUI_BLACK); TEXT_SetBkColor(hItem, KEYBOARD_BACKGROUND_COLOR); TEXT_SetText(hItem, G_message); TEXT_SetTextAlign(hItem, GUI_TA_TOP); while (p->iID) { hItem = WM_GetDialogItem(pMsg->hWin, p->iID); BUTTON_SetFont(hItem, &KEYBOARD_DEFAULT_FONT); BUTTON_SetTextColor(hItem, BUTTON_CI_UNPRESSED, GUI_BLACK); BUTTON_SetTextColor(hItem, BUTTON_CI_PRESSED, GUI_BLACK); BUTTON_SetBkColor(hItem, BUTTON_CI_UNPRESSED, KEY_BACKGROUND_COLOR); BUTTON_SetBkColor(hItem, BUTTON_CI_PRESSED, GUI_LIGHTGRAY); //BUTTON_SetSkin(hItem, BUTTON_SKIN_FLEX); p++; } WM_MakeModal(pMsg->hWin); setNewButtonText(pMsg, 0, 0); break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; if (!IKeyboardHandleEvent(pMsg, NCode, Id)) { // Special cases go here // Nothing happens otherwise } case WM_POST_PAINT: // Make sure the all presses up til now are gone TouchscreenClearPresses(); break; default: WM_DefaultProc(pMsg); break; } }
void MainTask(void) { WM_HWIN hWin; GUI_Init(); GUI_CURSOR_Show(); WM_SetCreateFlags(WM_CF_MEMDEV); WM_EnableMemdev(WM_HBKWIN); WM_SetCallback(WM_HBKWIN, &_cbBkWindow); while (1) { hWin = GUI_CreateDialogBox(_aDialogOrder, GUI_COUNTOF(_aDialogOrder), &_cbDialogOrder, WM_HBKWIN, 0, 0); WM_MakeModal(hWin); GUI_ExecCreatedDialog(hWin); GUI_Delay(1500); } }
static void OpenFileProcess(int sel_num,char* record_file) { result = f_open (&listfile, FILE_LIST_PATH, FA_READ|FA_OPEN_EXISTING); //打开索引文件 if(result != FR_OK) return ; result = f_lseek (&listfile, sel_num*BROWSER_FILE_NAME_LEN); if(result != FR_OK) return ; result = f_read (&listfile, curentopenfile, BROWSER_FILE_NAME_LEN, &bw); if(result != FR_OK) return ; //printf("\nfileItem=:%s",openfile); f_close (&listfile); if(strstr(curentopenfile,".gcode")||strstr(curentopenfile,".GCODE") ||strstr(curentopenfile,".g")||strstr(curentopenfile,".G")) //判断是否是gcode文件,可以执行打印指令 { //对话框显示是否打印该文件 _ChooseFrame = CreatePrintFileWaring(); WM_MakeModal(_ChooseFrame); } #if 0 else if(strstr(openfile,".txt")||strstr(openfile,".TXT") ||strstr(openfile,".c")||strstr(openfile,".c") ||strstr(openfile,".cpp")||strstr(openfile,".CPP") ||strstr(openfile,".h")||strstr(openfile,".h"))//判断是否可以使用txt格式打开 { //printf("\ntxt file"); WM_HideWindow(hDialog); hOpenfile=FRAMEWIN_CreateEx(0,0,320,240,WM_HBKWIN,WM_CF_SHOW,0,0,0,_cbOpenfile); FRAMEWIN_SetTextColor(hOpenfile,GUI_DARKGRAY); FRAMEWIN_SetTitleHeight(hOpenfile, 20); FRAMEWIN_SetText(hOpenfile,framename); FRAMEWIN_SetTextAlign(hOpenfile, GUI_TA_LEFT | GUI_TA_VCENTER); FRAMEWIN_AddCloseButton(hOpenfile,FRAMEWIN_BUTTON_RIGHT,0); hWin=MULTIEDIT_CreateEx(5,22,295,230,hOpenfile, WM_CF_SHOW,MULTIEDIT_CF_AUTOSCROLLBAR_V|MULTIEDIT_CF_READONLY,0,0,0); MULTIEDIT_SetBkColor(hWin,MULTIEDIT_CI_READONLY,GUI_WHITE); MULTIEDIT_SetWrapWord(hWin); MULTIEDIT_AddText(hWin,txtBuffer); } #endif else { GUI_MessageBox("Sorry,do not support open the file!","Sorry",GUI_MESSAGEBOX_CF_MODAL); } }
void MainTask(void) { WM_HWIN hWin; GUI_Init(); // // Check if recommended memory for the sample is available // if (GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY) { GUI_ErrorOut("Not enough memory available."); return; } GUI_CURSOR_Show(); WM_SetCreateFlags(WM_CF_MEMDEV); WM_EnableMemdev(WM_HBKWIN); WM_SetCallback(WM_HBKWIN, &_cbBkWindow); while (1) { hWin = GUI_CreateDialogBox(_aDialogOrder, GUI_COUNTOF(_aDialogOrder), &_cbDialogOrder, WM_HBKWIN, 0, 0); WM_MakeModal(hWin); GUI_ExecCreatedDialog(hWin); GUI_Delay(1500); } }
/********************************************************************* * * _cbCallback */ static void _cbCallback(WM_MESSAGE * pMsg) { WM_HWIN hDlg, hWinSrc, hItem; int Id, NCode, i; hWinSrc = pMsg->hWinSrc; hDlg = pMsg->hWin; switch (pMsg->MsgId) { case WM_INIT_DIALOG: WM_MakeModal(hDlg); FRAMEWIN_SetFont(hDlg, &GUI_Font24B_ASCII); FRAMEWIN_SetTextAlign(hDlg, GUI_TA_HCENTER); FRAMEWIN_SetClientColor(hDlg, GUI_YELLOW); for (i = 0; i < 4; i++) { hItem = WM_GetDialogItem(hDlg, GUI_ID_SLIDER0 + i); SLIDER_SetRange(hItem, 0, 999); SLIDER_SetValue(hItem, _aSlider[i]); hItem = WM_GetDialogItem(hDlg, GUI_ID_EDIT0 + i); EDIT_SetDecMode(hItem, _aSlider[i], 0, 999, 0, 0); WM_DisableWindow(hItem); } break; case WM_NOTIFY_PARENT: Id = WM_GetId(hWinSrc); /* Id of widget */ NCode = pMsg->Data.v; /* Notification code */ if (NCode == WM_NOTIFICATION_RELEASED) { /* React only if released */ if (Id == GUI_ID_OK) { /* OK Button */ GUI_EndDialog(hDlg, 0); WM_SetFocus(_hPrevWin); } } if (NCode == WM_NOTIFICATION_VALUE_CHANGED) { _OnValueChanged(hDlg, Id); } break; default: WM_DefaultProc(pMsg); } }
/********************************************************************* * * _cbCallback */ static void _cbCallback(WM_MESSAGE * pMsg) { WM_HWIN hDlg, hWinSrc; int Id, NCode; GUI_RECT Rect; Rect.x0 = 10; Rect.y0 = 10; Rect.x1 = 300; Rect.y1 = 200; hWinSrc = pMsg->hWinSrc; hDlg = pMsg->hWin; switch (pMsg->MsgId) { case WM_INIT_DIALOG: WM_MakeModal(hDlg); FRAMEWIN_SetFont(hDlg, &GUI_Font24B_ASCII); FRAMEWIN_SetTextAlign(hDlg, GUI_TA_HCENTER); FRAMEWIN_SetClientColor(hDlg, GUI_GREEN); break; case WM_PAINT: GUI_SetColor(GUI_BLACK); GUI_SetFont(&GUI_Font16_ASCII); GUI_DispStringInRect(&_aExplain[0], &Rect, GUI_TA_LEFT); break; case WM_NOTIFY_PARENT: Id = WM_GetId(hWinSrc); /* Id of widget */ NCode = pMsg->Data.v; /* Notification code */ if (NCode == WM_NOTIFICATION_RELEASED) { /* React only if released */ if (Id == GUI_ID_OK) { /* OK Button */ GUI_EndDialog(hDlg, 0); WM_SetFocus(_hPrevWin); } } break; default: WM_DefaultProc(pMsg); } }
/********************************************************************* * * _cbDialog */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; int NCode; int Id; switch (pMsg->MsgId) { case WM_INIT_DIALOG: // // Initialization of 'Dropdown' // hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_LIGHTS); DROPDOWN_AddString(hItem, "Light 2"); DROPDOWN_AddString(hItem, "Light 1"); DROPDOWN_AddString(hItem, "Item"); DROPDOWN_IncSel(hItem); // // Initialization of 'Address' Text // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_ADDRESS); TEXT_SetText(hItem, "Address: <address>"); // // Initialization of 'Status' Text // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_ONOFF); TEXT_SetText(hItem, "Status: ON"); // // Initialization of 'On/Off' Button // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_ONOFF); BUTTON_SetText(hItem, "Toggle On/Off"); // // Initialization of 'Mode' Text // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_MODE); TEXT_SetText(hItem, "Mode: Auto"); // // Initialization of 'Mode' Button // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_MODE); BUTTON_SetText(hItem, "Trigger SOS"); // // Initialization of 'Add' Button // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_ADD); BUTTON_SetText(hItem, "Add new..."); // // Initialization of 'Reconfigure' Button // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_RECONFIGURE); BUTTON_SetText(hItem, "Reconfigure..."); // // Initialization of 'Remove' Button // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_REMOVE); BUTTON_SetText(hItem, "Remove..."); WM_MakeModal(pMsg->hWin); break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch (Id) { case ID_DROPDOWN_LIGHTS: // Notifications sent by 'Dropdown' switch (NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: break; case WM_NOTIFICATION_SEL_CHANGED: break; } break; case ID_BUTTON_ONOFF: switch (NCode) { case WM_NOTIFICATION_CLICKED: ToggleLightN(1, WM_GetDialogItem(pMsg->hWin, ID_TEXT_ONOFF)); break; case WM_NOTIFICATION_RELEASED: break; } break; case ID_BUTTON_MODE: switch (NCode) { case WM_NOTIFICATION_CLICKED: TriggerSOS(1, WM_GetDialogItem(pMsg->hWin, ID_TEXT_MODE)); break; case WM_NOTIFICATION_RELEASED: break; } break; case ID_BUTTON_ADD: switch (NCode) { case WM_NOTIFICATION_CLICKED: AddNewLight(0); break; case WM_NOTIFICATION_RELEASED: break; } break; case ID_BUTTON_RECONFIGURE: switch (NCode) { case WM_NOTIFICATION_CLICKED: ReconfigureLight(0); break; case WM_NOTIFICATION_RELEASED: break; } break; case ID_BUTTON_REMOVE: switch (NCode) { case WM_NOTIFICATION_CLICKED: RemoveLight(0); break; case WM_NOTIFICATION_RELEASED: break; } break; case ID_BUTTON_OK: switch (NCode) { case WM_NOTIFICATION_CLICKED: GUI_EndDialog(pMsg->hWin, 0); break; case WM_NOTIFICATION_RELEASED: break; } break; } break; default: WM_DefaultProc(pMsg); break; } }
/********************************************************************* * * _cbDialog */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; int NCode; int Id; WM_HWIN hNumPad; u8 Mb_Val; switch (pMsg->MsgId) { case WM_INIT_DIALOG: // //Initialization of Window // hItem = pMsg->hWin; WINDOW_SetBkColor(hItem, GUI_LIGHTBLUE); // // Initialization of 'Button' // GUI_UC_SetEncodeUTF8(); GUI_SetFont(&GUI_FontSongTi16); hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_BACK); BUTTON_SetFont(hItem,&GUI_FontSongTi12); BUTTON_SetText(hItem, _StringHZ[2]); hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_ENTER); BUTTON_SetFont(hItem,&GUI_FontSongTi12); BUTTON_SetText(hItem, _StringHZ[3]); hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_NEW); BUTTON_SetFont(hItem,&GUI_FontSongTi16); BUTTON_SetText(hItem, _StringHZ[0]); hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_OPEN); BUTTON_SetFont(hItem,&GUI_FontSongTi16); BUTTON_SetText(hItem, _StringHZ[1]); // // Initialization of 'Header' // hItem = WM_GetDialogItem(pMsg->hWin, ID_HEADER_1); HEADER_AddItem(hItem, 80, "LeCoder", 14); // //Initialize EDIT0 // hItem = WM_GetDialogItem(pMsg->hWin, ID_MULTIEDIT_0); MULTIEDIT_SetText(hItem, ""); //清空EDIT内容 MULTIEDIT_SetFocussable(hItem,1); //设为捕捉光标焦点 MULTIEDIT_SetAutoScrollV(hItem,1);//自动竖直滑块 MULTIEDIT_SetAutoScrollH(hItem,1);//自动水平滑块 MULTIEDIT_SetWrapWord(hItem); //自动换行 MULTIEDIT_SetFocussable(hItem, 1); WM_SetFocus(hItem); break; case WM_PAINT: GUI_SetColor(GUI_RED); GUI_SetFont(&GUI_FontSongTi12); GUI_DispStringAt(_StringHZ[4], 100, 25); break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch(Id) { case ID_BUTTON_BACK: // Notifications sent by 'Button' switch(NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: Key_Value = WINDOW_TOP; break; } break; case ID_BUTTON_ENTER: // Notifications sent by 'ENTER' case ID_BUTTON_NEW: // Notifications sent by 'New' switch(NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: //get the program name in the edit hItem = WM_GetDialogItem(pMsg->hWin, ID_MULTIEDIT_0); MULTIEDIT_GetText(hItem,program_name,sizeof(program_name)); //warning the situation of empty program name if(strcmp(program_name, "") == 0) { _MessageBox(_StringHZ[4],_StringHZ[5], &Mb_Val); } else { CreateWindow_1_1(); } break; } break; case ID_BUTTON_OPEN: // Notifications sent by 'Open' switch(NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: CreateWindow_TreeView(); break; } break; case ID_HEADER_1: // Notifications sent by 'Header' switch(NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: break; case WM_NOTIFICATION_MOVED_OUT: break; } break; case ID_MULTIEDIT_0: // Notifications sent by 'Edit1' switch(NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: hNumPad = Create_NumPad(pMsg->hWin); WM_MakeModal(hNumPad); GUI_ExecCreatedDialog(hNumPad); break; case WM_NOTIFICATION_VALUE_CHANGED: break; } break; } break; default: WM_DefaultProc(pMsg); break; } }
/** * @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 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; uint32_t tmp_param = 0; switch (pMsg->MsgId) { case WM_INIT_DIALOG: WM_MakeModal(pMsg->hWin); /* 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); /* '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); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1); TEXT_SetFont(hItem, GUI_FONT_13B_1); hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_0); SPINBOX_SetRange(hItem, 1, 10); if(ImSettings.b.ss_timer > 0) { SPINBOX_SetValue(hItem, ImSettings.b.ss_timer); } else { ImSettings.b.ss_timer = 1; SPINBOX_SetValue(hItem, 1); } break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch (Id) { /* Notification sent by "OK" button */ case ID_BUTTON_OK: switch (NCode) { case WM_NOTIFICATION_RELEASED: /* Save image settings before delete settings frame */ hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_0); ImSettings.b.ss_timer = SPINBOX_GetValue(hItem); WM_RestartTimer(hTimerTime, (ImSettings.b.ss_timer * 1000)); tmp_param = k_BkupRestoreParameter(CALIBRATION_IMAGE_SETTINGS_BKP); /* check if new settings have to be saved */ if(ImSettings.d32 != tmp_param) { k_BkupSaveParameter(CALIBRATION_IMAGE_SETTINGS_BKP, ImSettings.d32); } GUI_EndDialog(pMsg->hWin, 0); break; } break; /* Notification sent by "Cancel" button */ case ID_BUTTON_CANCEL: switch (NCode) { case WM_NOTIFICATION_RELEASED: GUI_EndDialog(pMsg->hWin, 0); break; } break; } break; } }
/** * @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, 132, "Track", GUI_TA_VCENTER | GUI_TA_LEFT); LISTVIEW_AddColumn(hItem, 55, "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 'WAV' Button */ hItem = WM_GetDialogItem(pMsg->hWin, ID_WAV_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 = BUTTON_CreateEx(25, 100, 30, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_REPEAT_BUTTON); WM_SetCallback(hItem, _cbButton_repeat); hItem = BUTTON_CreateEx(100, 95, 40, 40, pMsg->hWin, WM_CF_SHOW, 0, ID_MUTE_BUTTON); WM_SetCallback(hItem, _cbButton_speaker); hItem = BUTTON_CreateEx(22, 147, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_STOP_BUTTON); WM_SetCallback(hItem, _cbButton_stop); hItem = BUTTON_CreateEx(89, 147, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_PREVIOUS_BUTTON); WM_SetCallback(hItem, _cbButton_previous); hItem = BUTTON_CreateEx(148, 140, 50, 50, pMsg->hWin, WM_CF_SHOW, 0, ID_PLAY_BUTTON); WM_SetCallback(hItem, _cbButton_play); hItem = BUTTON_CreateEx(222, 147, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_NEXT_BUTTON); WM_SetCallback(hItem, _cbButton_next); hItem = WM_GetClientWindow(pMsg->hWin); hItem = BUTTON_CreateEx(20, 205, 50, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_WAV_BUTTON); WM_SetCallback(hItem, _cbButton_open); hItem = BUTTON_CreateEx(80, 205, 50, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_ADD_BUTTON); WM_SetCallback(hItem, _cbButton_add); hItem = BUTTON_CreateEx(235, 205, 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); hItem = WM_CreateWindowAsChild(15, 75, 255, 20, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS | WM_CF_BGND, _cbDrawProgressSlider, 0); hItem = WM_CreateWindowAsChild(145, 105, 125, 20, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS | WM_CF_BGND, _cbDrawVolumeSlider, 0); WM_CreateWindowAsChild(479, 250, 1, 1, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS, _cbMediaConnection , 0); break; case WM_PAINT: GUI_SetBkColor(GUI_BLACK); GUI_ClearRect(15, 6, 270, 70); DrawRect3D(15, 135, 255, 60); DrawRect3D(15, 200, 255, 40); 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, 47, 10, 385, 215, apDrives, GUI_COUNTOF(apDrives), 0, "Open an audio file", 0, pFileInfo); WM_MakeModal(hItem); 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); } } } } } 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; } AUDIOPLAYER_Stop(); hItem = WM_GetDialogItem(pMsg->hWin, ID_ELAPSED_TIME); TEXT_SetText(hItem, "00:00"); hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON); WM_InvalidateWindow(hItem); WM_Update(hItem); } } 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++; } 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--; } 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_WAV_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, 47, 10, 385, 215, 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, 47, 10, 385, 215, 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; default: WM_DefaultProc(pMsg); break; } }
/********************************************************************* * * MESSAGEBOX_Create */ WM_HWIN MESSAGEBOX_Create(const char * sMessage, const char * sCaption, int Flags) { GUI_WIDGET_CREATE_INFO _aDialogCreate[3]; /* 0: FrameWin, 1: Text, 2: Button */ int BorderSize = FRAMEWIN_GetDefaultBorderSize(); /* Default border size of frame window */ int xSizeFrame = MESSAGEBOX_XSIZEOK + 2 * BorderSize + MESSAGEBOX_BORDER * 2; /* XSize of frame window */ int ySizeFrame; /* YSize of frame window */ int x0, y0; /* Position of frame window */ int xSizeMessage; /* Length in pixels of message */ int xSizeCaption; /* Length in pixels of caption */ int ySizeCaption; /* YSize of caption */ int ySizeMessage; /* YSize of message */ WM_HWIN hBox; GUI_RECT Rect; const GUI_FONT GUI_UNI_PTR * pOldFont; /* Zeroinit variables */ memset(_aDialogCreate, 0, sizeof(_aDialogCreate)); /* Get dimension of message */ pOldFont = GUI_SetFont(TEXT_GetDefaultFont()); GUI_GetTextExtend(&Rect, sMessage, 255); xSizeMessage = Rect.x1 - Rect.x0 + MESSAGEBOX_BORDER * 2; ySizeMessage = Rect.y1 - Rect.y0 + 1; if (xSizeFrame < (xSizeMessage + 4 + MESSAGEBOX_BORDER * 2)) { xSizeFrame = xSizeMessage + 4 + MESSAGEBOX_BORDER * 2; } ySizeCaption = GUI_GetYSizeOfFont(FRAMEWIN_GetDefaultFont()); ySizeFrame = ySizeMessage + /* size of message */ MESSAGEBOX_YSIZEOK + /* size of button */ ySizeCaption + /* caption size */ MESSAGEBOX_BORDER * 3 + /* inner border - text, text - button, button - bottom */ BorderSize * 2 + /* top & bottom border */ 1; /* inner border */ /* Get xsize of caption */ xSizeCaption = GUI_GetStringDistX(sCaption); if (xSizeFrame < xSizeCaption + BorderSize * 2) { xSizeFrame = xSizeCaption + BorderSize * 2; } /* Check maximum */ if (xSizeFrame > LCD_GET_XSIZE()) { xSizeFrame = LCD_GET_XSIZE(); } if (ySizeFrame > LCD_GET_YSIZE()) { ySizeFrame = LCD_GET_YSIZE(); } /* Calculate position of framewin */ x0 = GUI_OrgX + (LCD_GET_XSIZE() - xSizeFrame) / 2; y0 = GUI_OrgY + (LCD_GET_YSIZE() - ySizeFrame) / 2; /* restore modified Context */ GUI_SetFont(pOldFont); /* Fill frame win resource */ _aDialogCreate[0].pfCreateIndirect = FRAMEWIN_CreateIndirect; _aDialogCreate[0].pName = sCaption; _aDialogCreate[0].x0 = x0; _aDialogCreate[0].y0 = y0; _aDialogCreate[0].xSize = xSizeFrame; _aDialogCreate[0].ySize = ySizeFrame; if (Flags & GUI_MESSAGEBOX_CF_MOVEABLE) { _aDialogCreate[0].Flags = FRAMEWIN_CF_MOVEABLE; } /* Fill text resource */ _aDialogCreate[1].pfCreateIndirect = TEXT_CreateIndirect; _aDialogCreate[1].pName = sMessage; _aDialogCreate[1].x0 = (xSizeFrame - xSizeMessage - BorderSize * 2) / 2; _aDialogCreate[1].y0 = MESSAGEBOX_BORDER; _aDialogCreate[1].xSize = xSizeMessage; _aDialogCreate[1].ySize = ySizeMessage; _aDialogCreate[1].Para = GUI_TA_TOP | GUI_TA_HCENTER; /* Fill button resource */ _aDialogCreate[2].pfCreateIndirect = BUTTON_CreateIndirect; _aDialogCreate[2].pName = "OK"; _aDialogCreate[2].Id = GUI_ID_OK; _aDialogCreate[2].x0 = (xSizeFrame - MESSAGEBOX_XSIZEOK - BorderSize * 2) / 2; _aDialogCreate[2].y0 = MESSAGEBOX_BORDER * 2 + ySizeMessage; _aDialogCreate[2].xSize = MESSAGEBOX_XSIZEOK; _aDialogCreate[2].ySize = MESSAGEBOX_YSIZEOK; /* Create dialog */ hBox = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), MESSAGEBOX_Callback, 0, 0, 0); if (Flags & GUI_MESSAGEBOX_CF_MODAL) { WM_MakeModal(hBox); } return hBox; }
/** * @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; } }
/** * @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 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(60, 30, 300, 250, pMsg->hWin, WM_CF_SHOW, 0, ID_VIDEO_LIST); LISTVIEW_SetFont(hItem, &GUI_Font16_1); LISTVIEW_SetTextColor(hItem, LISTVIEW_CI_UNSEL, 0x00DCA939); LISTVIEW_SetTextColor(hItem, LISTVIEW_CI_SEL, GUI_WHITE); LISTVIEW_SetHeaderHeight(hItem, 0); LISTVIEW_AddColumn(hItem, 300, "", 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); hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_LIST); LISTVIEW_AddRow(hItem, NULL); LISTVIEW_SetItemText(hItem, 0, i, (char *)tmp); } } 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); 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, 48, 30, 330, 240, apDrives, GUI_COUNTOF(apDrives), 0, "Video files", 0, &FileInfo); WM_MakeModal(hItem); r = GUI_ExecCreatedDialog(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++; } } WM_InvalidateWindow(pMsg->hWin); } 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, hClient; int NCode; int Id, Index, newpos; GUI_RECT r; int ItemNbr; int result; static char tmp[FILEMGR_FILE_NAME_SIZE]; switch (pMsg->MsgId) { case WM_INIT_DIALOG: pVideoList = (FILELIST_FileTypeDef *)k_malloc(sizeof(FILELIST_FileTypeDef)); pFileInfo = (CHOOSEFILE_INFO *)k_malloc(sizeof(CHOOSEFILE_INFO)); pVideoList->ptr = 0; PlayerSettings.d32 = k_BkupRestoreParameter(CALIBRATION_VIDEOPLAYER_SETTING_BKP); /* Initialization of 'Listview' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_LIST); LISTVIEW_AddColumn(hItem, 165, "Video", GUI_TA_VCENTER | GUI_TA_LEFT); LISTVIEW_SetGridVis(hItem, 0); LISTVIEW_SetAutoScrollV(hItem, 1); LISTVIEW_SetBkColor(hItem, LISTVIEW_CI_UNSEL, GUI_BLACK); LISTVIEW_SetTextColor(hItem, LISTVIEW_CI_UNSEL, GUI_CYAN); hItem = BUTTON_CreateEx( 240, 202, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_STOP_BUTTON); WM_SetCallback(hItem, _cbButton_stop); hItem = BUTTON_CreateEx(92, 202, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_PREVIOUS_BUTTON); WM_SetCallback(hItem, _cbButton_previous); hItem = BUTTON_CreateEx(137, 195, 50, 45, pMsg->hWin, WM_CF_SHOW, 0, ID_PLAY_BUTTON); WM_SetCallback(hItem, _cbButton_play); hItem = BUTTON_CreateEx(195, 202, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_NEXT_BUTTON); WM_SetCallback(hItem, _cbButton_next); hItem = BUTTON_CreateEx(47, 205, 30, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_REPEAT_BUTTON); WM_SetCallback(hItem, _cbButton_repeat); hItem = BUTTON_CreateEx(315, 205, 70, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_OPEN_BUTTON); WM_SetCallback(hItem, _cbButton_open); hItem = BUTTON_CreateEx(375, 205, 70, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_ADD_BUTTON); WM_SetCallback(hItem, _cbButton_add); hItem = BUTTON_CreateEx(440, 202, 30, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_CLOSE_BUTTON); WM_SetCallback(hItem, _cbButton_close); hItem = BUTTON_CreateEx(281, 172, 25, 25, pMsg->hWin, WM_CF_SHOW, 0, ID_FULL_SCREEN_BUTTON); WM_SetCallback(hItem, _cbButton_fullscreen); hClient = WM_GetClientWindow(pMsg->hWin); WM_GetClientRectEx(hClient, &r); hFrame = WM_CreateWindowAsChild(r.x0 + 5, r.y0 + 5, r.x1 - 179, r.y1 - 75, hClient, WM_CF_SHOW, _cbVideoWindow , 0); hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON); hItem = WM_GetDialogItem(pMsg->hWin, ID_PROGRESS_SLIDER); SLIDER_SetNumTicks(hItem, 25); hItem = WM_CreateWindowAsChild(05, 163, 275, 20, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS | WM_CF_BGND, _cbDrawProgressSlider, 0); WM_CreateWindowAsChild(479, 250, 1, 1, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS, _cbMediaConnection , 0); break; case WM_PAINT: DrawRect3D(05, 193, 300, 50); DrawRect3D(310, 193, 165, 50); break; case WM_TIMER: Id = WM_GetTimerId(pMsg->Data.v); if (Id == ID_PLAYLIST_TIMER) { playlist_select = 0; } break; case WM_DELETE: k_BkupSaveParameter(CALIBRATION_VIDEOPLAYER_SETTING_BKP, PlayerSettings.d32); WM_DeleteTimer(hPlaylistTimer); break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch(Id) { /* Notification sent by "Close Button" */ case ID_FULL_SCREEN_BUTTON: switch (NCode) { case WM_NOTIFICATION_RELEASED: if( VideoPlayer_State != VIDEO_IDLE) { _ShowFullScreen(); } break; } break; /* Notifications sent by 'Add' Button */ case ID_ADD_BUTTON: switch(NCode) { case WM_NOTIFICATION_RELEASED: pFileInfo->pfGetData = k_GetData; pFileInfo->pMask = acMask_video; hItem = CHOOSEFILE_Create(pMsg->hWin, 47, 10, 385, 215, apDrives, GUI_COUNTOF(apDrives), 0, "Add video file to playlist", 0, pFileInfo); if(VideoPlayer_State == VIDEO_PLAY) { GUI_MOVIE_Pause(hMovie); } WM_MakeModal(hItem); result = GUI_ExecCreatedDialog(hItem); if (result == 0) { if((strstr(pFileInfo->pRoot, ".emf")) || (strstr(pFileInfo->pRoot, ".EMF"))) { if(pVideoList->ptr < FILEMGR_LIST_DEPDTH) { strcpy((char *)pVideoList->file[pVideoList->ptr].name, pFileInfo->pRoot); FILEMGR_GetFileOnly ((char *)tmp, (char *)pFileInfo->pRoot); hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_LIST); LISTVIEW_AddRow(hItem, NULL); LISTVIEW_SetItemText(hItem, 0, pVideoList->ptr, tmp); pVideoList->ptr++; } } WM_InvalidateWindow(hFrame); } if(VideoPlayer_State == VIDEO_PLAY) { GUI_MOVIE_Play(hMovie); } break; } break; /* Notifications sent by 'Open' Button */ case ID_OPEN_BUTTON: switch(NCode) { case WM_NOTIFICATION_RELEASED: pFileInfo->pfGetData = k_GetData; pFileInfo->pMask = acMask_dir; hItem = CHOOSEFILE_Create(pMsg->hWin, 47, 10, 385, 215, apDrives, GUI_COUNTOF(apDrives), 0, "Add a folder", 0, pFileInfo); if(VideoPlayer_State == VIDEO_PLAY) { GUI_MOVIE_Pause(hMovie); } WM_MakeModal(hItem); result = GUI_ExecCreatedDialog(hItem); if (result == 0) { _AddEntireFolder(pFileInfo->pRoot); WM_InvalidateWindow(hFrame); } if(VideoPlayer_State == VIDEO_PLAY) { GUI_MOVIE_Play(hMovie); } break; } break; /* Notification sent by "Full Screen button" */ case ID_CLOSE_BUTTON: switch (NCode) { case WM_NOTIFICATION_RELEASED: k_free(pVideoList); k_free(pFileInfo); _StopPlay(); GUI_EndDialog(pMsg->hWin, 0); break; } break; /* Notification sent by "Play Button" */ case ID_PLAY_BUTTON: switch(NCode) { case WM_NOTIFICATION_RELEASED: if(VideoPlayer_State == VIDEO_IDLE) { if (pVideoList->ptr > 0) { _StartPlay((char *)pVideoList->file[file_pos].name); LISTVIEW_SetSel(WM_GetDialogItem(VIDEOPLAYER_hWin, ID_VIDEO_LIST), file_pos); } else { pFileInfo->pfGetData = k_GetData; pFileInfo->pMask = acMask_video; hItem = CHOOSEFILE_Create(pMsg->hWin, 47, 10, 385, 215, apDrives, GUI_COUNTOF(apDrives), 0, "Open a video file", 0, pFileInfo); WM_MakeModal(hItem); result = GUI_ExecCreatedDialog(hItem); if (result == 0) { if((strstr(pFileInfo->pRoot, ".emf")) || (strstr(pFileInfo->pRoot, ".EMF"))) { pVideoList->ptr = 0; strcpy((char *)pVideoList->file[pVideoList->ptr].name, pFileInfo->pRoot); FILEMGR_GetFileOnly (tmp, pFileInfo->pRoot); hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_LIST); /* Update Play list */ strcpy((char *)pVideoList->file[pVideoList->ptr].name, pFileInfo->pRoot); 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); } } } } else if(VideoPlayer_State == VIDEO_PLAY) { _PausePlay(); } else if(VideoPlayer_State == VIDEO_PAUSE) { _ResumePlay(); } break; } break; 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; case ID_STOP_BUTTON: _StopPlay(); hItem = WM_GetDialogItem(VIDEOPLAYER_hWin, ID_PROGRESS_SLIDER); SLIDER_SetValue(hItem, 0); WM_InvalidateWindow(hFrame); break; case ID_NEXT_BUTTON: switch(NCode) { case WM_NOTIFICATION_RELEASED: if(file_pos < (pVideoList->ptr - 1)) { /* Play Next */ file_pos++; LISTVIEW_IncSel(WM_GetDialogItem(VIDEOPLAYER_hWin, ID_VIDEO_LIST)); } else if(PlayerSettings.b.repeat == REPEAT_ALL) { file_pos = 0; LISTVIEW_SetSel(WM_GetDialogItem(VIDEOPLAYER_hWin, ID_VIDEO_LIST), file_pos); } if(VideoPlayer_State == VIDEO_PLAY) { _StopPlay(); _StartPlay((char *)pVideoList->file[file_pos].name); WM_InvalidateWindow(hFrame); } break; } break; case ID_PREVIOUS_BUTTON: switch(NCode) { case WM_NOTIFICATION_RELEASED: if( pVideoList->ptr > 0) { if(file_pos > 0) { file_pos--; LISTVIEW_DecSel(WM_GetDialogItem(VIDEOPLAYER_hWin, ID_VIDEO_LIST)); } else if(PlayerSettings.b.repeat == REPEAT_ALL) { file_pos = (pVideoList->ptr - 1); LISTVIEW_SetSel(WM_GetDialogItem(VIDEOPLAYER_hWin, ID_VIDEO_LIST), file_pos); } if(VideoPlayer_State == VIDEO_PLAY) { _StopPlay(); _StartPlay((char *)pVideoList->file[file_pos].name); WM_InvalidateWindow(hFrame); } } break; } break; /* Notifications sent by 'progress' Slider */ case ID_PROGRESS_SLIDER: if(NCode == WM_NOTIFICATION_CLICKED) { if(VideoPlayer_State != VIDEO_IDLE) { GUI_MOVIE_Pause(hMovie); hItem = WM_GetDialogItem(pMsg->hWin, ID_PROGRESS_SLIDER); newpos = (SLIDER_GetValue(hItem) * Video_Info.NumFrames)/100; GUI_MOVIE_GotoFrame(hMovie, newpos); if(VideoPlayer_State == VIDEO_PLAY) { GUI_MOVIE_Play(hMovie); } } } break; /* Notifications sent by 'ListView' Slider */ case ID_VIDEO_LIST: if(NCode == WM_NOTIFICATION_CLICKED) { hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_LIST); Index = LISTVIEW_GetSel(hItem); if(Index < pVideoList->ptr) { file_pos = Index; 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 < pVideoList->ptr) { if(VideoPlayer_State != VIDEO_IDLE) { _StopPlay(); } _StartPlay((char *)pVideoList->file[Index].name); hItem = WM_GetDialogItem(VIDEOPLAYER_hWin, ID_PLAY_BUTTON); WM_InvalidateWindow(hItem); WM_Update(hItem); WM_InvalidateWindow(hFrame); } } } } break; } break; default: WM_DefaultProc(pMsg); break; } }
/******************************************************************************************************* * * 函数名称: * * 函数功能: * * 入口参数: * * 出口参数: 无 * * 说明: * *******************************************************************************************************/ int SoftKBDlg(WM_HWIN hParenWin,int x0,int y0, void *para) { int x; int y; int j; int i; int k; int result; y = BTN_TOP_SPACE; k = 2; //按钮索引从2开始 for (i = 0; i < 3; i++) //3行3列 { for (x = BTN_LEFT_SPACE,j = 0; j < 3; j++) { _aTextDialogCreate[k].x0 = x; _aTextDialogCreate[k].y0 = y; _aTextDialogCreate[k].xSize = NUM_BUTTON_W; _aTextDialogCreate[k].ySize = NUM_BUTTON_H; x += NUM_BUTTON_W + BTN_H_SPACE; k++; } y += NUM_BUTTON_H + BTN_V_SPACE; } //数字0 x = BTN_LEFT_SPACE; _aTextDialogCreate[k].x0 = x; _aTextDialogCreate[k].y0 = y; _aTextDialogCreate[k].xSize = NUM_BUTTON_W * 2 + BTN_H_SPACE; _aTextDialogCreate[k].ySize = NUM_BUTTON_H; k++; //退格 x += NUM_BUTTON_W * 2 + BTN_H_SPACE + BTN_H_SPACE; _aTextDialogCreate[k].x0 = x; _aTextDialogCreate[k].y0 = y; _aTextDialogCreate[k].xSize = NUM_BUTTON_W; _aTextDialogCreate[k].ySize = NUM_BUTTON_H; k++; //最后1行 x = BTN_LEFT_SPACE; y += NUM_BUTTON_H + BTN_V_SPACE; for (i = 0; i < 3; i++) { _aTextDialogCreate[k].x0 = x; _aTextDialogCreate[k].y0 = y; _aTextDialogCreate[k].xSize = NUM_BUTTON_W; _aTextDialogCreate[k].ySize = NUM_BUTTON_H; x += NUM_BUTTON_W + BTN_H_SPACE; k++; } y += NUM_BUTTON_H + BTN_V_SPACE; //文本输入框 _aTextDialogCreate[1].x0 = EDIT_LEFT_SPACE; _aTextDialogCreate[1].y0 = EDIT_TOP_SPACE; _aTextDialogCreate[1].xSize = EDIT_XSIZE; _aTextDialogCreate[1].ySize = EDIT_YSIZE; //窗体本身 _aTextDialogCreate[0].xSize = NUM_BUTTON_W * 3 + BTN_H_SPACE * 2 + BTN_LEFT_SPACE * 2; _aTextDialogCreate[0].ySize = y + EDIT_TOP_SPACE; x0 -= _aTextDialogCreate[0].xSize; // if (y0 + _aTextDialogCreate[0].ySize > 479) //479 = LCD_H { y0 = 479 - _aTextDialogCreate[0].ySize - 50; //50--debug } ParentParam = (int)para; //注意这里保存的是要返回值的指针 #if 1 //WM_DisableWindow(hParenWin); hWindKB = GUI_CreateDialogBox(_aTextDialogCreate, GUI_COUNTOF(_aTextDialogCreate), &_cbKBDlgCallback,hParenWin, x0, y0); WM_MakeModal(hWindKB); #else //WM_DisableWindow(hParenWin); hWindKB = GUI_CreateDialogBox(_aTextDialogCreate, GUI_COUNTOF(_aTextDialogCreate), &_cbKBDlgCallback,WM_HBKWIN, x0, y0); ///WM_SetCallback(hWindKB, &_cbKBDlgCallback); WM_MakeModal(hWindKB); //WM_SetFocus(hWindKB); result = GUI_ExecCreatedDialog(hWindKB); // 焦点返回给主对话框 /// WM_EnableWindow(hParenWin); WM_MakeModal(hMain); #endif //WM_SetFocus(hMain); //SetMainCallback(); //GUI_ExecCreatedDialog(hMain); return result; }