?? gui.c
字號:
break; } case WM_CAPTURECHANGED: { if(gui->activewidget) { gui->activewidget->pressed = 0; renderwidget(gui->skin, get_drawground(hWnd), gui->activewidget, 1); RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE); gui->activewidget = NULL; } break; } case WM_LBUTTONUP: { ReleaseCapture(); if(gui->activewidget) { gui->activewidget->pressed = 0; renderwidget(gui->skin, get_drawground(hWnd), gui->activewidget, 1); RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE); gui->activewidget = NULL; } break; } case WM_RBUTTONDOWN: { POINT point; char device[MAX_PATH]; char searchpath[MAX_PATH]; char searchpath2[MAX_PATH];#ifdef HAVE_LIBCDIO char searchpath3[MAX_PATH];#endif int len, pos = 0, cdromdrive = 0; UINT errmode; point.x = GET_X_LPARAM(lParam); point.y = GET_Y_LPARAM(lParam); ClientToScreen(hWnd, &point); errmode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); while (GetMenuItemCount(gui->diskmenu) > 0) DeleteMenu(gui->diskmenu, 0, MF_BYPOSITION); len = GetLogicalDriveStrings(MAX_PATH, device); while(pos < len) { if(GetDriveType(device + pos) == DRIVE_CDROM) { char volname[MAX_PATH]; char menuitem[MAX_PATH]; int flags = MF_STRING; mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] checking %s for CD/VCD/SVCD/DVDs\n", device + pos); sprintf(searchpath, "%sVIDEO_TS", device + pos); sprintf(searchpath2, "%sMpegav", device + pos);#ifdef HAVE_LIBCDIO sprintf(searchpath3, "%sTrack01.cda", device + pos);#endif if(GetFileAttributes(searchpath) != INVALID_FILE_ATTRIBUTES) flags |= MF_ENABLED; else if(GetFileAttributes(searchpath2) != INVALID_FILE_ATTRIBUTES) flags |= MF_ENABLED;#ifdef HAVE_LIBCDIO else if(GetFileAttributes(searchpath3) != INVALID_FILE_ATTRIBUTES) flags |= MF_ENABLED;#endif else flags |= MF_GRAYED; volname[0] = 0; strcpy(menuitem, device + pos); menuitem[strlen(menuitem) - 1]=0; GetVolumeInformation(device + pos, volname, MAX_PATH, NULL, NULL, NULL, NULL, 0); if (strlen(volname)) { capitalize(volname); strcat(menuitem, " - "); strcat(menuitem, volname); } AppendMenu(gui->diskmenu, flags, IDPLAYDISK + cdromdrive, menuitem); cdromdrive++; } pos += strlen(device + pos) + 1; } SetErrorMode(errmode); TrackPopupMenu(gui->menu, 0, point.x, point.y, 0, hWnd, NULL); return 0; } case WM_MOUSEMOVE: { if(wParam & MK_LBUTTON) { POINT point; RECT rect; if(gui->activewidget) { widget *item = gui->activewidget; if(item->type == tyHpotmeter) { item->x = GET_X_LPARAM(lParam) - gui->mousewx; item->value = (float)((float)((item->x - item->wx) * 100.0f) / (float)(item->wwidth - item->width)); } if(item->type == tyPotmeter) { gui->mousewx = GET_X_LPARAM(lParam) - gui->activewidget->x; item->value = (float) (gui->mousewx * 100.0f) / (float) item->wwidth; } if((item->type == tyPotmeter) || (item->type == tyHpotmeter) || (item->type == tyVpotmeter)) { /* Bound checks */ if(item->value > 100.0f) item->value = 100.0f; else if(item->value < 0.0f) item->value = 0.0f; if(item->msg == evSetVolume) guiIntfStruct.Volume = (float) item->value; else if(item->msg == evSetMoviePosition) guiIntfStruct.Position = (float) item->value; else if(item->msg == evSetBalance) { /* make the range for 50% a bit bigger, because the sliders for balance usually suck */ if((item->value - 50.0f < 1.5f) && (item->value - 50.0f > -1.5f)) item->value = 50.0f; guiIntfStruct.Balance = (float) item->value; } updatedisplay(gui, hWnd); handlemsg(hWnd, item->msg); } break; } point.x = GET_X_LPARAM(lParam); point.y = GET_Y_LPARAM(lParam); ClientToScreen(hWnd, &point); GetWindowRect(hWnd, &rect); MoveWindow(hWnd, point.x - gui->mousex, point.y - gui->mousey, rect.right-rect.left,rect.bottom-rect.top,TRUE); break; } break; } case WM_COMMAND: { switch(LOWORD(wParam)) { case IDEXIT: PostQuitMessage(0); handlemsg(hWnd, evExit); break; case IDFILE_OPEN: handlemsg(hWnd, evLoadPlay); break; case IDDIR_OPEN: { static char path[MAX_PATH]; BROWSEINFO bi; LPITEMIDLIST pidl; memset(&bi, 0, sizeof(BROWSEINFO)); bi.lpszTitle = "Choose a Directory..."; pidl = SHBrowseForFolder(&bi); if (SHGetPathFromIDList(pidl, path)) { gui->playlist->clear_playlist(gui->playlist); adddirtoplaylist(gui->playlist, path, TRUE); gui->startplay(gui); } break; } case ID_SKINBROWSER: handlemsg(hWnd, evSkinBrowser); break; case IDURL_OPEN: display_openurlwindow(gui, 0); break; case ID_MUTE: mp_input_queue_cmd(mp_input_parse_cmd("mute")); break; case IDSUBTITLE_OPEN: display_opensubtitlewindow(gui); break; case ID_PTRACK: handlemsg(hWnd, evPrev); break; case ID_SEEKB: handlemsg(hWnd, evBackward10sec); break; case ID_PLAY: handlemsg(hWnd, evPlaySwitchToPause); break; case ID_STOP: handlemsg(hWnd, evStop); break; case ID_SEEKF: handlemsg(hWnd, evForward10sec); break; case ID_NTRACK: handlemsg(hWnd, evNext); break; case ID_SHOWHIDE: { if(IsWindowVisible(hWnd)) ShowWindow(hWnd, SW_HIDE); else ShowWindow(hWnd, SW_SHOW); break; } case ID_PLAYLIST: handlemsg(hWnd, evPlayList); break; case ID_PREFS: handlemsg(hWnd, evPreferences); break; case ID_CONSOLE: console_toggle(); break; case ID_ONLINEHELP: ShellExecute(NULL, "open", ONLINE_HELP_URL, NULL, NULL, SW_SHOWNORMAL); break; } if((IDPLAYDISK <= LOWORD(wParam)) && (LOWORD(wParam) < (IDPLAYDISK + 100))) { char device[MAX_PATH]; char searchpath[MAX_PATH]; char filename[MAX_PATH]; int len, pos = 0, cdromdrive = 0; len = GetLogicalDriveStrings(MAX_PATH, device); while(pos < len) { if(GetDriveType(device + pos)==DRIVE_CDROM) { if(LOWORD(wParam) - IDPLAYDISK == cdromdrive) { sprintf(searchpath, "%sVIDEO_TS", device + pos); if(GetFileAttributes(searchpath) != INVALID_FILE_ATTRIBUTES) {#ifdef USE_DVDREAD if (dvd_device) free(dvd_device); dvd_device = strdup(device + pos); dvd_title = dvd_chapter = dvd_angle = 1; handlemsg(hWnd, evPlayDVD);#endif } sprintf(searchpath, "%sTrack01.cda", device + pos); if(GetFileAttributes(searchpath) != INVALID_FILE_ATTRIBUTES) {#ifdef HAVE_LIBCDIO if (cdrom_device) free(cdrom_device); cdrom_device = strdup(device + pos); /* mplayer doesn't seem to like the trailing \ after the device name */ cdrom_device[2]=0; handlemsg(hWnd, evPlayCD);#endif } else { HANDLE searchhndl; WIN32_FIND_DATA finddata; sprintf(searchpath, "%smpegav\\*.dat", device + pos); if((searchhndl=FindFirstFile(searchpath, &finddata)) != INVALID_HANDLE_VALUE) { mp_msg(MSGT_GPLAYER,MSGL_V, "Opening VCD/SVCD\n"); gui->playlist->clear_playlist(gui->playlist); do { sprintf(filename, "%smpegav\\%s", device + pos, finddata.cFileName); gui->playlist->add_track(gui->playlist, filename, NULL, NULL, 0); } while(FindNextFile(searchhndl, &finddata)); FindClose(searchhndl); } gui->startplay(gui); } } cdromdrive++; } pos += strlen(device + pos) + 1; } } break; } case WM_PAINT: { PAINTSTRUCT ps; RECT rd; HDC hdc = BeginPaint(hWnd, &ps); HDC hMemDC = CreateCompatibleDC(hdc); int width, height; GetClientRect(hWnd, &rd); width = rd.right - rd.left; height = rd.bottom - rd.top; SelectObject(hMemDC, get_bitmap(hWnd)); BitBlt(hdc, 0, 0, width, height, hMemDC, 0, 0, SRCCOPY); DeleteDC(hMemDC); EndPaint(hWnd, &ps); return 0; } return 0; } return DefWindowProc(hWnd, message, wParam, lParam);}inline void startplay(gui_t *gui){ handlemsg(gui->mainwindow, evDropFile);}/* returns the bits per pixel of the desktop *//* the format is always in BGR byte order */static int GetDesktopBitsPerPixel(void){ HWND desktop=GetDesktopWindow(); HDC dc=GetDC(desktop); int bpp=GetDeviceCaps(dc, BITSPIXEL); ReleaseDC(desktop, dc); return bpp;}/* unloads a skin and destroys its windows */extern int destroy_window(gui_t *gui){ RECT rd; unsigned int i; /* Save position: MSDN says don't pass workspace coordinates * to CreateWindow() or SetWindowPos(), as both of which expect * screen coordinates; resulting in the window appearing in the * wrong location. * -Erik */ /* main window position */ if(IsIconic(gui->mainwindow)) ShowWindow(gui->mainwindow, SW_SHOWNORMAL); GetWindowRect(gui->mainwindow, &rd); gui_main_pos_x = rd.left; gui_main_pos_y = rd.top; /* sub window position */ if(IsIconic(gui->subwindow)) ShowWindow(gui->subwindow, SW_SHOWNORMAL); GetWindowRect(gui->subwindow, &rd); gui_sub_pos_x = rd.left; gui_sub_pos_y = rd.top; for(i=0; i<gui->window_priv_count; i++) { if(gui->window_priv[i]->bitmap) DeleteObject(gui->window_priv[i]->bitmap); free(gui->window_priv[i]); } free(gui->window_priv); gui->window_priv = NULL; gui->window_priv_count = 0; /* destroy the main window */ if(gui->mainwindow) DestroyWindow(gui->mainwindow); gui->mainwindow = NULL; /* destroy the sub window */ if(gui->subwindow) DestroyWindow(gui->subwindow); gui->subwindow = NULL; UnregisterClass(gui->classname, 0); DestroyIcon(gui->icon); gui->skin->freeskin(gui->skin); gui->skin = NULL; return 0;}static void create_menu(gui_t *gui){ gui->diskmenu = CreatePopupMenu(); gui->menu=CreatePopupMenu(); gui->trayplaymenu = CreatePopupMenu(); AppendMenu(gui->menu, MF_STRING | MF_POPUP, (UINT) gui->trayplaymenu, "Open..."); AppendMenu(gui->trayplaymenu, MF_STRING, IDFILE_OPEN, "File..."); AppendMenu(gui->trayplaymenu, MF_STRING, IDURL_OPEN, "Url..."); AppendMenu(gui->trayplaymenu, MF_STRING, IDDIR_OPEN, "Directory..."); AppendMenu(gui->menu, MF_SEPARATOR, 0, 0); AppendMenu(gui->menu, MF_STRING | MF_POPUP, (UINT) gui->diskmenu, "Play &CD/DVD/VCD/SVCD"); AppendMenu(gui->menu, MF_SEPARATOR, 0, 0); AppendMenu(gui->menu, MF_STRING, IDSUBTITLE_OPEN, "Open Subtitle"); AppendMenu(gui->menu, MF_STRING, ID_SKINBROWSER, "Skin Browser"); AppendMenu(gui->menu, MF_SEPARATOR, 0, 0); AppendMenu(gui->menu, MF_STRING, ID_PREFS, "Preferences"); AppendMenu(gui->menu, MF_STRING, ID_CONSOLE, "Debug Console"); AppendMenu(gui->menu, MF_STRING, ID_ONLINEHELP, "Online Help"); AppendMenu(gui->menu, MF_SEPARATOR, 0, 0); AppendMenu(gui->menu, MF_STRING, IDEXIT, "&Exit");}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -