From 4aa477ef2cfb2973e87e9d0662fe1c4e6946f120 Mon Sep 17 00:00:00 2001 From: vayne Date: Thu, 6 Jul 2006 02:07:03 +0000 Subject: Initial win32 gui release. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@18919 b3059339-0415-0410-9bf9-f77b7e298cf2 --- Gui/win32/Changelog | 317 ++++++++++ Gui/win32/README | 17 + Gui/win32/dialogs.c | 1142 ++++++++++++++++++++++++++++++++++ Gui/win32/dialogs.h | 129 ++++ Gui/win32/gui.c | 1555 ++++++++++++++++++++++++++++++++++++++++++++++ Gui/win32/gui.h | 118 ++++ Gui/win32/interface.c | 975 +++++++++++++++++++++++++++++ Gui/win32/playlist.c | 154 +++++ Gui/win32/playlist.h | 57 ++ Gui/win32/preferences.c | 714 +++++++++++++++++++++ Gui/win32/skinload.c | 809 ++++++++++++++++++++++++ Gui/win32/skinload.h | 213 +++++++ Gui/win32/widgetrender.c | 350 +++++++++++ Gui/win32/wincfg.c | 143 +++++ Gui/win32/wincfg.h | 38 ++ 15 files changed, 6731 insertions(+) create mode 100644 Gui/win32/Changelog create mode 100644 Gui/win32/README create mode 100644 Gui/win32/dialogs.c create mode 100644 Gui/win32/dialogs.h create mode 100644 Gui/win32/gui.c create mode 100644 Gui/win32/gui.h create mode 100644 Gui/win32/interface.c create mode 100644 Gui/win32/playlist.c create mode 100644 Gui/win32/playlist.h create mode 100644 Gui/win32/preferences.c create mode 100644 Gui/win32/skinload.c create mode 100644 Gui/win32/skinload.h create mode 100644 Gui/win32/widgetrender.c create mode 100644 Gui/win32/wincfg.c create mode 100644 Gui/win32/wincfg.h (limited to 'Gui') diff --git a/Gui/win32/Changelog b/Gui/win32/Changelog new file mode 100644 index 0000000000..d439fa9dcd --- /dev/null +++ b/Gui/win32/Changelog @@ -0,0 +1,317 @@ +HISTORY +2006/06/30 - Erik Augustson +- Fixed display of wrong aspect ratios. + +2006/06/13 - Erik Augustson +- Minor bugfixes. +- Updated to current SVN + +2006/04/14 - Erik Augustson +- Fixed a crash bug. +- Fixed a major fullscreen bug (WinID wasn't getting + reset when FS switching). + +2006/04/13 - Erik Augustson +- More minor fixups + +2006/04/07 - Erik Augustson +- Minor fixups to openurl and openfile from dialogs.c + +2006/04/06 - Erik Augustson +- Fixed IPC and drag&drop appending files to the + playlist instead of opening them right away. +- Updated dvdnav patch. + +2006/04/03 - Erik Augustson +- Fixed a long pathnames issue with WM_COPYDATA. +- Fixed a minor crash happening when rendering the + codec name. +- Some code cleanup. + +2006/04/01 - Erik Augustson +- Added ability to enable/disable videos displaying + in the sub window in preferences. +- Small fix in update_subwindow() for coming out + of fullscreen when the sub window was minimized. + +2006/03/27 - Erik Augustson +- Updated to current CVS. +- Debug console now shows the extensions mplayer + was compiled with. + +2006/03/23 - Erik Augustson +- Fixed using -playlist and -shuffle. + +2006/03/22 - Erik Augustson +- Fixed a small bug with input events for dialogs. + +2006/03/16 - Erik Augustson +- Fixed left button mouse event in dvdnav patch. +- More aspect fixes. +- Fixed double-click in the playlist. +- Fixed some drag&drop functionality. + +2006/03/14 - Erik Augustson +- Simplified title/chapter selection dialog. +- Code cleanup. + +2006/03/14 - Erik Augustson + +- Fixed resetting aspect on file ending in mplEnd() + +2006/03/13 - Erik Augustson +- Fixed double click events, forgot to add CS_DBLCLKS + to sub window's window style. +- Fixed window focusing with drag&drop files. +- Re-arranged some menu items, and added support for + runtime aspect switching. This adds 3 lines to + mplayer.c but is well worth it IMO. + +2006/03/12 - Erik Augustson +- Fixed window positioning for both windows. +- Added more mouse button events. + +2006/03/10 - Erik Augustson +- Fixed mouse and sub window vanishing after coming + out of fullscreen by end of file. +- Fixed sub window popping up when switching to + fullscreen and *not* using directx. +- Added codec name to widgets to properly render + in some skins. +- Middle and scroll wheel mouse event should work + now on the sub window. +- #ifdef'd USE_DVDREAD to allow for compilation + when disabling mpdvdkit. +- Updated license information. + +2006/03/08 - Erik Augustson +- Removed unnecessary playerinfo struct +- Fixed movies playing at wrong aspects +- Minor bugfixes all around + +2006/03/07 - Erik Augustson +- Fixed some skin labels not displaying properly + +2006/03/06 - Gianluigi Tiesi +- Temporaly fix crash if no vo_driver is specified + (interface.c:877) + +2006/02/28 - Erik Augustson +- Added sub window. The sub window is the WinID + (-wid) when using the directx vo. The sub window + hides when the file is audio only, and as well + when the vo is not directx, and automatically + adjusts and maintains video aspect ratios +- Minor fixups +- TODO: Get WinID working when using gl2, and add + fix for both windows if going out of bounds on + right and bottom of screen. + +2006/01/30 - Erik Augustson +- Fixed playing movies from network drives. + +2006/01/27 - Erik Augustson +- Fixed a small annoyance when playing a network file + with file associations when mplayer wasn't running, + using GetLongPathNameA() + +2006/01/15 - Erik Augustson +- Added some CD functionality if using libcdio. + +2005/12/02 - Erik Augustson +- Fix to disable gui if running in slave mode. + +2005/11/14 - Erik Augustson +- Implemented IPC with WM_COPYDATA to open new + files/playlists in the current running mplayer, + rather than having a new mplayer process spawn. + +2005/11/12 - Erik Augustson +- Modified evMute to mute/unmute +- Mute button should show as pressed when muted +- Added evDecVolume and evIncVolume + +2005/11/09 - Erik Augustson +- Fixed screensaver issues + +2005/11/06 - Erik Augustson +- Display fixes + +2005/09/18 - Erik Augustson +- Playlist additions +- Minor playlist bugfixes + +2005/09/16 - Gianluigi Tiesi +- Code cleanup + +2005/09/05 - Erik Augustson +- Updated to apply to current CVS + +2005/07/27 - Erik Augustson +- Added initial evEqualizer for brightness, contrast, + hue and saturation of videos. + +2005/07/26 - Erik Augustson +- Fixed double click on playlist +- Added support for screenshot video filter, vf_screenshot patch + is also needed + +2005/06/19 - Gianluigi Tiesi +- Removed -console switch, moved console stuff out of mplayer main, + console option is handled in wincfg, it's switchable at runtime + from the gui and the state is saved + +2005/06/15 - Erik Augustson +- Fixed bugs with DVD chapter skipping +- Title/chapter switching dialog works again :) +- Fixed a bug with url's not working after playing a DVD +- Removed fullscreen handling from mplayer.c. It's now + handled in interface.c +- Disabled loading/saving playlists, and adding files/urls + while playing a DVD + +2005/06/12 - Gianluigi Tiesi +- Added -console cmd line option to bring up a dos console + that displays mplayer messages + +2005/06/10 - Erik Augustson +- Fixed a bug with the audio filters not loading +- Fixed bugs with the audio delay and stereo sliders +- Added a few safety checks + +2005/06/08 - Erik Augustson +- Added initial evPreferences +- Fixed a bug with the load subtitle dialog +- Some code cleanup and minor fixes here and there + +2005/06/02 - Erik Augustson +- Fixed a bug with pathnames in the open url dialog + +2005/05/26 - Erik Augustson +- Added "Add file" and "Add url" menu to the playlist +- Fixed file skipping when double-clicking playlist entries + +2005/05/19 - Erik Augustson +- added simple url history + +2005/05/12 - Erik Augustson +- added load and save playlists options +- fixed opening remote m3u and pls files in open url +- no problems so far with evprev and evnext :) + +2005/05/10 - Erik Augustson +- more evNext and evPrev fixes + +2005/05/06 - Erik Augustson +- implemented mplEnd() for proper looping fix +- fixed bugs in evNext and evPrev +- re-organized the menus + +2005/03/02 - Gianluigi Tiesi +- adapted subtitle patch from Raul +- readapted endless loop fix to not touch mp_msg.c +Erik Augustson +- small fixes, orginal endless loop fix + +2005/02/25 - Gianluigi Tiesi +- Fixed exit stuff (I hope ;P) +- Fixes to Erik's title/chapter selector +Erik Augustson +- Added additional gui events +- Added evPrev and evNext dvd chapter switching + +2005/02/23 - Erik Augustson +- added dvd title/chapter switching + +2005/02/20 - Gianluigi Tiesi +- fixed dvd stop and play +Erik Augustson +- imported some stuff from unix gui +- fixed file play after dvd + +2005/02/18 - Erik Augustson +- addons for dvd playing + +2005/02/16 - Gianluigi Tiesi +- renamed README to README.txt +- retain window position even when switching the skin +- converted all opendir calls to native win32 calls +- adding filename as title without directory for all calls +- more cleanups in skinloader/unloader +- removed a lot of warnings +- removed unused includes +Erik Augustson +- added online help menu + +2005/02/15 - Gianluigi Tiesi +- Disabled access to gui when gui->mainwindow doesn't match hwnd passed to windproc +- Fixed save position for main window gui +- Cleanups in skinloader/unloader +Erik Augustson erik_27can@yahoo.com +- Added saving main window position to gui config +- Fixes on playlist for vcd + +2005/02/13 - Gianluigi Tiesi +- Fixed multithreaded (I hope ;P) +- Skinbrowser window is closed when a skin is changed, this prevents crashes if multiple clicks +- Playlist window is updated if files are added while playlist is visible +- Removed patch on mplayer.rc, take icon using the included routine +- SkinBrowser and Playlist dialogs can be opened/closed by clicking multiple times gui buttons +- Added support for DVD, stop dvd + play is broken ;( +- ifdef-ed a lot of debug stuff +- Fixed systray icon removing +- Added Erik and me to about dialog ;) +Erik Augustson +- Added key handling for the gui window +- Small fixes on tray icon stuff + +2005/02/11 - Gianluigi Tiesi +- fixed sliders, balance is not 100% working, anyway dsound output driver doesn't support balanced audio +- remade threaded +- removed demuxer/avi patches, really needed ?? +- added a fake vo_init if opengl is not enabled +Erik Augustson +- fixes on traymenu play +- added a base configuration reader/writer - only support for skin selection for now + +2005/02/10 - Gianluigi Tiesi +- fixed (workarounded) the NULL filename bug +- moved add directory directly into gui.c +- it starts to be usable :) +Erik Augustson +- Added systray support +- Added skin browser option to menu (some skins don't show a skin browser button) + +2005/02/09 - Gianluigi Tiesi +- Fixed window disappearing bug +- Made a patch compatible with current tree +- Fixed icons in minor dialogs +- Major cleanup and code reorganization + +2005/02/08 - Erik Augustson +- Removed multi-threading, mplayer now runs in a single thread +- Play directory now works as intended +- Added a Skin browser, double-click skin names to switch skins +- Still more things todo + +pre4 +- URL open +- use windows native menus +- Gui runs in a seperate thread now because some controls interupt playback :( + +pre 3 +- some of the previous features broken again +- full font loading/display support +- better integration into mplayer +- seek bar, balance, volume control work + +pre 2 +- playlist +- Drag 'N Drop support +- fixed segfault when no skinfile found + +pre 1 +- initial revision +- play/pause works +- loads "blue" skin +- still lot of things todo diff --git a/Gui/win32/README b/Gui/win32/README new file mode 100644 index 0000000000..f0a7123be7 --- /dev/null +++ b/Gui/win32/README @@ -0,0 +1,17 @@ +MPlayer Windows GUI (c) +2003 Sascha Sommer - +2006 Erik Augustson - +2006 Gianluigi Tiesi - + +This beta gui for win32 was originally written by Sascha Sommer and +has since been heavily modified by myself (Erik Augustson) and Gianluigi +Tiesi. It follows the same concept for the linux gui, and should be +able to load all(most) of the current skins available for the linux gui. + +To compile, quite simply pass --enable-gui to configure, and it is highly +recommended to also pass --enable-static="-mwindows" to link mplayer as +a windows binary. NOTE: this will also link mencoder with -mwindows +and thus link mencoder as a windows binary as well. + +Please send all bug reports/comments/requests/gripes to: + diff --git a/Gui/win32/dialogs.c b/Gui/win32/dialogs.c new file mode 100644 index 0000000000..815aab0cc1 --- /dev/null +++ b/Gui/win32/dialogs.c @@ -0,0 +1,1142 @@ +/* + MPlayer Gui for win32 + Copyright (c) 2003 Sascha Sommer + Copyright (c) 2006 Erik Augustson + Copyright (c) 2006 Gianluigi Tiesi + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "gui.h" +#include "wincfg.h" +#include "dialogs.h" + +WNDPROC OldUrlWndProc; +LRESULT CALLBACK SubUrlWndProc(HWND, UINT, WPARAM, LPARAM); +extern int vo_gamma_brightness; +extern int vo_gamma_saturation; +extern int vo_gamma_contrast; +extern int vo_gamma_hue; +extern int set_video_colors(sh_video_t *sh_video, char *item, int value); +extern int get_video_colors(sh_video_t *sh_video, char *item, int *value); + +guiInterface_t guiIntfStruct; +int addurl = 0; + +#ifdef USE_SUB +extern mp_osd_obj_t* vo_osd_list; +extern char **sub_name; + +void guiLoadSubtitle(char *name) +{ + if (!guiIntfStruct.Playing) + { + guiIntfStruct.SubtitleChanged = 1; + return; + } + if (subdata) + { + mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_DeletingSubtitles); + sub_free(subdata); + subdata = NULL; + vo_sub = NULL; + if (vo_osd_list) + { + int len; + mp_osd_obj_t *osd = vo_osd_list; + while (osd) + { + if (osd->type == OSDTYPE_SUBTITLE) break; + osd = osd->next; + } + if (osd && osd->flags & OSDFLAG_VISIBLE) + { + len = osd->stride * (osd->bbox.y2 - osd->bbox.y1); + memset(osd->bitmap_buffer, 0, len); + memset(osd->alpha_buffer, 0, len); + } + } + } + + if (name) + { + mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_LoadingSubtitles, name); + subdata = sub_read_file(strdup(name), guiIntfStruct.FPS); + if (!subdata) mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_CantLoadSub,name); + sub_name = (malloc(2 * sizeof(char*))); /* when mplayer will be restarted */ + sub_name[0] = strdup(name); /* sub_name[0] will be read */ + sub_name[1] = NULL; + } + update_set_of_subtitles(); +} +#endif + +int display_openfilewindow(gui_t *gui, int add) +{ + OPENFILENAME fileopen; + int result = 0; + char filelist[MAXFILE]; + char filename[MAX_PATH]; + char directory[MAX_PATH]; + char *filespec = NULL; + char *filepart = NULL; + + memset(&fileopen, 0, sizeof(OPENFILENAME)); + memset(filelist, 0, sizeof(filelist)); + + fileopen.lStructSize = sizeof(OPENFILENAME); + fileopen.hwndOwner = gui->mainwindow; + fileopen.hInstance = GetModuleHandle(NULL); + fileopen.lpstrFilter = "All Files (*.*)\0*.*\0" + "Media Files (*.avi;*.asf;*.wmv;*.mpg;*.mpeg;*.m2v;*.mov;\ + *.rmvb;*.rm;*.ogm;*.mp3;*.wav;*.wma;*.ra;*.ogg)\0\ + *.avi;*.asf;*.wmv;*.mpg;*.mpeg;*.m2v;*.mov;\ + *.rmvb;*.rm;*.ogm;*.mp3;*.wav;*.wma;*.ra;*.ogg\0" + "Video Files (*.avi;*.mpg;*.mpeg;*.mov)\0*.avi;*.mpg;*.mpeg;*.mov\0" + "Avisynth Scripts (*.avs)\0*.avs\0" + "Audio Files (*.mp3;*.wav;*.ra)\0*.mp3;*.wav;*.ra\000"; + fileopen.nFilterIndex = 0; + fileopen.lpstrTitle = "Add file(s)..."; + fileopen.Flags = OFN_ALLOWMULTISELECT | OFN_FILEMUSTEXIST| OFN_LONGNAMES | OFN_EXPLORER| OFN_READONLY | OFN_HIDEREADONLY; + fileopen.lpstrFile = filelist; + fileopen.lpstrCustomFilter = NULL; + fileopen.nMaxFile = MAXFILE; + + if(GetOpenFileName(&fileopen)) + { + /* clear playlist */ + if(!add) gui->playlist->clear_playlist(gui->playlist); + + memcpy(directory, fileopen.lpstrFile, fileopen.nFileOffset - 1); + directory[fileopen.nFileOffset - 1] = 0; + + do + { + filespec = &fileopen.lpstrFile[fileopen.nFileOffset]; + filename[0] = 0; + strcat(filename, directory); + strcat(filename, "\\"); + strcat(filename, filespec); + + if (GetFileAttributes(filename) & FILE_ATTRIBUTE_DIRECTORY) + mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] %s is a directory, skipping...\n", filename); + else + { + if (GetFullPathName(filename, MAX_PATH, filename, &filepart)) + { + if(!parse_filename(filename, playtree, mconfig, add? 0 : 1)) + gui->playlist->add_track(gui->playlist, filename, NULL, filepart, 0); + mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Adding file: %s - path %s\n", filespec, filename); + result++; + } + } + fileopen.nFileOffset += strlen(filespec) + 1; + } while (*filespec); + } + return result; +} + +#ifdef USE_SUB +void display_opensubtitlewindow(gui_t *gui) +{ + OPENFILENAME subtitleopen; + char subtitlefile[MAX_PATH]; + + /* Safety check */ + if (guiIntfStruct.Playing == 0 || !guiIntfStruct.sh_video) return; + + memset(&subtitleopen, 0, sizeof(OPENFILENAME)); + memset(subtitlefile, 0, sizeof(subtitlefile)); + + subtitleopen.lStructSize = sizeof(OPENFILENAME); + subtitleopen.hwndOwner = gui->mainwindow; + subtitleopen.hInstance = GetModuleHandle(NULL); + subtitleopen.lpstrFilter = "All Files (*.*)\0*.*\0" + "Subtitle Files (*.srt;*.txt;*.vob)\0*.srt;*.txt;*.vob\0"; + subtitleopen.nFilterIndex = 0; + subtitleopen.lpstrTitle = "Add Subtitle..."; + subtitleopen.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_EXPLORER | OFN_READONLY | OFN_HIDEREADONLY; + subtitleopen.lpstrFile = subtitlefile; + subtitleopen.lpstrCustomFilter = NULL; + subtitleopen.nMaxFile = MAXFILE; + + if(GetOpenFileName(&subtitleopen)) + guiLoadSubtitle(subtitlefile); +} +#endif + +void display_loadplaylistwindow(gui_t *gui) +{ + OPENFILENAME playlistopen; + char playlistfile[MAX_PATH]; + + memset(&playlistopen, 0, sizeof(OPENFILENAME)); + memset(playlistfile, 0, sizeof(playlistfile)); + + playlistopen.lStructSize = sizeof(OPENFILENAME); + playlistopen.hwndOwner = gui->mainwindow; + playlistopen.hInstance = GetModuleHandle(NULL); + playlistopen.lpstrFilter = "All Files (*.*)\0*.*\0" + "Playlist Files (*.m3u;*.pls;*.txt)\0*.m3u;*.pls;*.txt\0"; + playlistopen.nFilterIndex = 0; + playlistopen.lpstrTitle = "Load Playlist..."; + playlistopen.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_EXPLORER | OFN_READONLY | OFN_HIDEREADONLY; + playlistopen.lpstrFile = playlistfile; + playlistopen.lpstrCustomFilter = NULL; + playlistopen.nMaxFile = MAXFILE; + + if(GetOpenFileName(&playlistopen)) + { + if(parse_filename(playlistfile, playtree, mconfig, 1)) + gui->startplay(gui); + } +} + +void display_saveplaylistwindow(gui_t* gui) +{ + OPENFILENAME playlistsave; + static FILE *playlist_file = NULL; + char playlistname[MAX_PATH]; + + memset(&playlistsave, 0, sizeof(OPENFILENAME)); + memset(playlistname, 0, sizeof(playlistname)); + + playlistsave.lStructSize = sizeof(OPENFILENAME); + playlistsave.hwndOwner = gui->mainwindow; + playlistsave.hInstance = GetModuleHandle(NULL); + playlistsave.lpstrFilter = "Playlist Files (*.pls)\0*.pls\0"; + playlistsave.nFilterIndex = 0; + playlistsave.lpstrTitle = "Save Playlist..."; + playlistsave.Flags = OFN_LONGNAMES | OFN_EXPLORER | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY; + playlistsave.lpstrFile = playlistname; + playlistsave.lpstrCustomFilter = NULL; + playlistsave.nMaxFile = MAXFILE; + + if(GetSaveFileName(&playlistsave)) + { + int i=0; + HANDLE my_playlist; + + if(!strstr(playlistname, ".pls")) strcat(playlistname, ".pls"); + + my_playlist = CreateFile(playlistname, + GENERIC_WRITE, + 0, + NULL, + CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, + NULL); + + if(my_playlist != INVALID_HANDLE_VALUE) + { + CloseHandle(my_playlist); /* close the file first so we can write to it */ + playlist_file = fopen(playlistsave.lpstrFile, "w"); + fprintf(playlist_file, "[playlist]\n"); + fprintf(playlist_file, "numberofentries=%d\n", gui->playlist->trackcount); + + for(i=0; i<(gui->playlist->trackcount); i++) + { + fprintf(playlist_file, "File%i=%s\n", i + 1, gui->playlist->tracks[i]->filename); + fprintf(playlist_file, "Length%i=-1\n", i + 1); + } + fclose(playlist_file); + } + } +} + +static LRESULT CALLBACK OpenUrlWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) +{ + static HWND url; + HWND wdg; + FILE *f; + char *history = get_path("gui.url"); + gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA); + switch (iMsg) + { + case WM_CREATE: + wdg = CreateWindow("button", "Ok", + WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, + 4, 43, 80, 25, hwnd, + (HMENU) ID_OK, + ((LPCREATESTRUCT) lParam) -> hInstance, + NULL); + SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); + + wdg = CreateWindow("button", "Cancel", + WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, + 90, 43, 80, 25, hwnd, + (HMENU) ID_CANCEL, + ((LPCREATESTRUCT) lParam) -> hInstance, + NULL); + SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); + + url = wdg = CreateWindowEx(WS_EX_CLIENTEDGE, + "edit", NULL, + WS_CHILD | WS_VISIBLE | ES_LEFT | ES_AUTOHSCROLL, + 4, 10, 300, 25, hwnd, + (HMENU) ID_URL, + ((LPCREATESTRUCT) lParam) -> hInstance, + NULL); + SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); + SendMessage(wdg, EM_SETLIMITTEXT, MAX_PATH, 0); + + /*subclass the edit box to capture the VK_RETURN key*/ + OldUrlWndProc = (WNDPROC)SetWindowLongPtr(url, GWLP_WNDPROC, (LONG_PTR)SubUrlWndProc); + + if((f = fopen(history, "r"))) + { + char lasturl[MAX_PATH]; + fgets(lasturl, MAX_PATH, f); + SendMessage(url, WM_SETTEXT, 0, (LPARAM) lasturl); + SendMessage(url, EM_SETSEL, 0, -1); + fclose(f); + } + break; + case WM_KEYDOWN: + switch (LOWORD(wParam)) + { + case VK_RETURN: + SendMessage(hwnd, WM_COMMAND, (WPARAM) ID_OK, 0); + break; + } + case WM_COMMAND: + { + switch (LOWORD(wParam)) + { + case ID_CANCEL: + DestroyWindow(hwnd); + return 0; + case ID_OK: + { + char file[MAX_PATH]; + SendMessage(url, WM_GETTEXT, MAX_PATH, (LPARAM) file); + mplSetFileName(NULL, file, STREAMTYPE_STREAM); + if((f = fopen(history, "wt+"))) + { + fprintf(f, file); + fclose(f); + } + if(!parse_filename(file, playtree, mconfig, addurl? 0 : 1)) + gui->playlist->add_track(gui->playlist, file, NULL, NULL, 0); + if(!addurl) + gui->startplay(gui); + else update_playlistwindow(); + DestroyWindow(hwnd); + } + break; + } + } + return 0; + case WM_DESTROY: + { + PostQuitMessage (0); + addurl = 0; + return 0; + } + } + return DefWindowProc(hwnd, iMsg, wParam, lParam); +} + +LRESULT CALLBACK SubUrlWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) +{ + switch(iMsg) + { + case WM_KEYDOWN: + switch (LOWORD(wParam)) + { + case VK_RETURN: + SendMessage(FindWindow(NULL, "MPlayer - Open URL..."), WM_COMMAND, (WPARAM) ID_OK, 0); + break; + } + } + return CallWindowProc(OldUrlWndProc, hwnd, iMsg, wParam, lParam); +} + +void display_openurlwindow(gui_t *gui, int add) +{ + if(add) addurl = 1; + HWND hWnd; + HINSTANCE hInstance = GetModuleHandle(NULL); + WNDCLASS wc; + int x, y; + if(FindWindow(NULL, "MPlayer - Open URL...")) return; + wc.style = CS_HREDRAW | CS_VREDRAW; + wc.lpfnWndProc = OpenUrlWndProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = hInstance; + wc.hCursor = LoadCursor(NULL,IDC_ARROW); + wc.hIcon = gui->icon; + wc.hbrBackground = SOLID_GREY2; + wc.lpszClassName = "MPlayer - URL"; + wc.lpszMenuName = NULL; + RegisterClass(&wc); + x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (320 / 2); + y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (100 / 2); + hWnd = CreateWindow("MPlayer - URL", + "MPlayer - Open URL...", + WS_POPUPWINDOW | WS_CAPTION, + x, + y, + 320, + 100, + NULL, + NULL, + hInstance, + NULL); + SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD) gui); + ShowWindow(hWnd, SW_SHOW); + UpdateWindow(hWnd); +} + +static void create_playlistmenu(gui_t *gui) +{ + gui->playlistmenu = CreatePopupMenu(); + AppendMenu(gui->playlistmenu, MF_STRING, ID_ADDFILE, "Add File..."); + AppendMenu(gui->playlistmenu, MF_STRING, ID_ADDURL, "Add Url..."); + AppendMenu(gui->playlistmenu, MF_SEPARATOR, 0, 0); + AppendMenu(gui->playlistmenu, MF_STRING, ID_REMOVE, "Remove Selected"); + AppendMenu(gui->playlistmenu, MF_STRING, ID_CLEAR, "Clear Playlist"); + AppendMenu(gui->playlistmenu, MF_SEPARATOR, 0, 0); + AppendMenu(gui->playlistmenu, MF_STRING, ID_CLOSE, "Close"); +} + +static void updatetracklist(HWND hwnd) +{ + int i=0; + gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA); + HWND tracklist = GetDlgItem(hwnd, ID_TRACKLIST); + /* clear listbox */ + SendMessage(tracklist, LB_RESETCONTENT, 0, 0); + for (i=0; i < gui->playlist->trackcount; i++) + if (gui->playlist->tracks[i]->title) + SendMessage(tracklist, LB_ADDSTRING, 0, (LPARAM)gui->playlist->tracks[i]->title); + else + SendMessage(tracklist, LB_ADDSTRING, 0, (LPARAM)gui->playlist->tracks[i]->filename); +} + +static LRESULT CALLBACK PlayListWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) +{ + HWND wdg; + POINT cursor; + gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA); + playlist_t *pl = gui ? gui->playlist : NULL; + switch (iMsg) + { + case WM_CREATE: + { + wdg = CreateWindow("button", "Play", + WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, + 4, 10, 80, 25, hwnd, + (HMENU) ID_PLAY, + ((LPCREATESTRUCT) lParam) -> hInstance, + NULL); + SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); + + wdg = CreateWindow ("button", "Up", + WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, + 4, 37, 80, 25, hwnd, + (HMENU) ID_UP, + ((LPCREATESTRUCT) lParam) -> hInstance, + NULL); + SendMessage(wdg, WM_SETFONT,(WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); + + wdg = CreateWindow ("button", "Down", + WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, + 4, 64, 80, 25, hwnd, + (HMENU) ID_DOWN, + ((LPCREATESTRUCT) lParam) -> hInstance, + NULL); + SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0); + + wdg = CreateWindow ("button", "Remove", + WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, + 4, 91, 80, 25, hwnd, + (HMENU) ID_REMOVE, + ((LPCREATESTRUCT) lParam) -> hInstance, + NULL); + SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0); + + wdg = CreateWindow ("button", "Load", + WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, + 4, 118, 80, 25, hwnd, + (HMENU) ID_PLAYLISTLOAD, + ((LPCREATESTRUCT) lParam) -> hInstance, + NULL); + SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0); + + wdg = CreateWindow ("button", "Save", + WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, + 4, 145, 80, 25, hwnd, + (HMENU) ID_PLAYLISTSAVE, + ((LPCREATESTRUCT) lParam) -> hInstance, + NULL); + SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0); + + wdg = CreateWindow ("button", "Close", + WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, + 4, 193, 80, 25, hwnd, + (HMENU) ID_CLOSE, + ((LPCREATESTRUCT) lParam) -> hInstance, + NULL); + SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0); + + wdg = CreateWindow ("listbox", "tracklist", WS_CHILD | WS_VISIBLE | LBS_NOTIFY | WS_VSCROLL | + WS_HSCROLL | LBS_DISABLENOSCROLL, 92, 10, 300, 208, hwnd, (HMENU) ID_TRACKLIST, + ((LPCREATESTRUCT) lParam) -> hInstance, NULL); + SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); + SendMessage(wdg, LB_SETHORIZONTALEXTENT, MAX_PATH*4, 0); + break; + } + case WM_CONTEXTMENU: + { + GetCursorPos(&cursor); + SetForegroundWindow(hwnd); + TrackPopupMenu(gui->playlistmenu, 0, cursor.x, cursor.y, 0, hwnd, NULL); + break; + } + case WM_COMMAND: + { + HWND tracklist = GetDlgItem(hwnd, ID_TRACKLIST); + int selected = 0; + int i; + for (i=0; itrackcount; i++) + if(0 < SendMessage(tracklist, LB_GETSEL, i, 0)) selected = i + 1; + switch (LOWORD(wParam)) + { + case ID_CLOSE: + DestroyWindow(hwnd); + return 0; + case ID_TRACKLIST: + if(HIWORD(wParam) == LBN_DBLCLK) + { + if(selected) pl->current = selected - 1; + mplGotoTheNext = 0; + gui->startplay(gui); + } + return 0; + case ID_UP: + { + if(selected) pl->moveup_track(pl, selected); + selected--; + break; + } + case ID_DOWN: + { + if(selected) pl->movedown_track(pl, selected); + selected++; + break; + } + case ID_PLAY: + { + if(selected) pl->current = selected - 1; + mplGotoTheNext = 0; + gui->startplay(gui); + break; + } + case ID_REMOVE: + if(selected) pl->remove_track(pl, selected); + break; + case ID_ADDFILE: + { + if(guiIntfStruct.StreamType == STREAMTYPE_DVD || + guiIntfStruct.StreamType == STREAMTYPE_DVDNAV) return 0; + display_openfilewindow(gui, 1); + break; + } + case ID_ADDURL: + { + if(guiIntfStruct.StreamType == STREAMTYPE_DVD || + guiIntfStruct.StreamType == STREAMTYPE_DVDNAV) return 0; + display_openurlwindow(gui, 1); + break; + } + case ID_CLEAR: + { + if(!gui->playlist->trackcount) return 0; + gui->playlist->clear_playlist(gui->playlist); + break; + } + case ID_PLAYLISTLOAD: + { + if(guiIntfStruct.StreamType == STREAMTYPE_DVD || + guiIntfStruct.StreamType == STREAMTYPE_DVDNAV) return 0; + display_loadplaylistwindow(gui); + break; + } + case ID_PLAYLISTSAVE: + { + /* no point saving an empty playlist */ + if(!gui->playlist->trackcount || + guiIntfStruct.StreamType == STREAMTYPE_DVD || + guiIntfStruct.StreamType == STREAMTYPE_DVDNAV) + return 0; + display_saveplaylistwindow(gui); + break; + } + } + updatetracklist(hwnd); + if(selected < 1) selected = 1; + else if(selected>pl->trackcount) selected = pl->trackcount; + SendMessage(tracklist, LB_SETCURSEL, selected - 1, 0); + return 0; + } + case WM_DROPFILES: + { + char file[MAX_PATH]; + int filecount = DragQueryFile((HDROP) wParam, -1, file, MAX_PATH); + int i; + for (i=0; iadd_track(pl, file, NULL, NULL, 0); + } + DragFinish((HDROP) wParam); + updatetracklist(hwnd); + } + break; + case WM_DESTROY: + PostQuitMessage(0); + return 0; + } + return DefWindowProc(hwnd, iMsg, wParam, lParam); +} + +void update_playlistwindow(void) +{ + HWND hWnd = FindWindow(NULL, "MPlayer Playlist"); + if (hWnd) updatetracklist(hWnd); +} + +void display_playlistwindow(gui_t *gui) +{ + HWND hWnd = FindWindow(NULL, "MPlayer Playlist"); + if (hWnd) + { + SendMessage(hWnd, WM_CLOSE, 0, 0); + return; + } + + HINSTANCE hInstance = GetModuleHandle(NULL); + WNDCLASS wc; + int x, y; + + wc.style = CS_HREDRAW | CS_VREDRAW; + wc.lpfnWndProc = PlayListWndProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = hInstance; + wc.hCursor = LoadCursor(NULL,IDC_ARROW); + wc.hIcon = gui->icon; + wc.hbrBackground = SOLID_GREY2; + wc.lpszClassName = "MPlayer - Playlist"; + wc.lpszMenuName = NULL; + RegisterClass(&wc); + create_playlistmenu(gui); + x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (400 / 2); /* Erik: center popup window on screen */ + y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (254 / 2); + hWnd = CreateWindow("MPlayer - Playlist", + "MPlayer Playlist", + WS_POPUPWINDOW | WS_CAPTION | WS_MINIMIZEBOX, + x, + y, + 400, + 254, + NULL, + NULL, + hInstance, + NULL); + SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD)gui); + updatetracklist(hWnd); + DragAcceptFiles(hWnd,TRUE); + ShowWindow(hWnd, SW_SHOW); + UpdateWindow(hWnd); +} + +static LRESULT CALLBACK SkinBrowserWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) +{ + static HWND listbox; + static char skinspath[MAX_PATH]; + gui_t* gui = (gui_t*) GetWindowLongPtr(hwnd, GWLP_USERDATA); + switch (iMsg) + { + case WM_CREATE: + { + listbox = CreateWindow("listbox", NULL, + WS_CHILD | WS_VISIBLE | LBS_NOTIFY | LBS_NOINTEGRALHEIGHT | + LBS_DISABLENOSCROLL | WS_VSCROLL | WS_TABSTOP, + 4, 5, 166, 60, hwnd, + (HMENU) ID_DIR, + ((LPCREATESTRUCT) lParam) -> hInstance, + NULL); + SendMessage(listbox, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); + + /* This opens the skins directory, lists the directory names, and adds them to the listbox */ + sprintf(skinspath, "%s/*.", get_path("skins")); + + HANDLE skinHandle = INVALID_HANDLE_VALUE; + WIN32_FIND_DATA finddata; + + skinHandle = FindFirstFile(skinspath, &finddata); + if (skinHandle != INVALID_HANDLE_VALUE) + { + do + { + if (finddata.cFileName[0] == '.') continue; + /* populate the listbox */ + capitalize(finddata.cFileName); + SendDlgItemMessage(hwnd, ID_DIR, LB_ADDSTRING, 0, (LPARAM) finddata.cFileName); + } while (FindNextFile(skinHandle, &finddata)); + FindClose(skinHandle); + } + else + mp_msg(MSGT_GPLAYER, MSGL_FATAL, "Error opening %s\n", get_path("skins")); + break; + } + case WM_COMMAND: + { + if ((HWND) lParam == listbox) + { + if(HIWORD(wParam) == LBN_DBLCLK) + { + int index = SendMessage(listbox, LB_GETCURSEL, 0, 0); + int len = SendMessage(listbox, LB_GETTEXTLEN, index, 0); + if (len) + { + if (skinName) free(skinName); + skinName = (char *) malloc(len+1); + SendMessage(listbox, LB_GETTEXT, (WPARAM) index, (LPARAM) skinName); + /* fill out the full pathname to the skin */ + strcpy(skinspath, get_path("skins")); + strcat(skinspath, "\\"); + strcat(skinspath, skinName); + ShowWindow(hwnd, SW_HIDE); + Shell_NotifyIcon(NIM_DELETE, &nid); + destroy_window(gui); + create_window(gui, skinspath); + create_subwindow(gui, skinspath); + SendMessage(hwnd, WM_CLOSE, 0, 0); /* Avoid crashing when switching skin */ + } + } + } + } + return 0; + case WM_DESTROY: + PostQuitMessage(0); + return 0; + } + return DefWindowProc(hwnd, iMsg, wParam, lParam); +} + +void display_skinbrowser(gui_t* gui) +{ + HWND hWnd = FindWindow(NULL, "Skin Browser"); + if (hWnd) + { + SendMessage(hWnd, WM_CLOSE, 0, 0); + return; + } + + HINSTANCE hInstance = GetModuleHandle(NULL); + WNDCLASS wc; + int x, y; + + wc.style = CS_HREDRAW | CS_VREDRAW; + wc.lpfnWndProc = SkinBrowserWndProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = hInstance; + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hIcon = gui->icon; + wc.hbrBackground = SOLID_GREY2; + wc.lpszClassName = "Skin Browser"; + wc.lpszMenuName = NULL; + RegisterClass(&wc); + x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (180 / 2); + y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (102 / 2); + hWnd = CreateWindow("Skin Browser", + "Skin Browser", + WS_POPUPWINDOW |WS_CAPTION, + x, + y, + 180, + 102, + NULL, + NULL, + hInstance, + NULL); + SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD) gui); + ShowWindow(hWnd, SW_SHOW); + UpdateWindow(hWnd); +} + +#ifdef USE_DVDREAD +static LRESULT CALLBACK TitleChapterWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) +{ + static HWND title; + static HWND chapter; + HWND wdg; + int i=0, j=0; + char titles[MAX_PATH] = ""; + char chapters[MAX_PATH] = ""; + switch (iMsg) + { + case WM_CREATE: + wdg = CreateWindow("button", "Ok", + WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, + 4, 43, 80, 25, hwnd, + (HMENU) ID_OK, + ((LPCREATESTRUCT) lParam) -> hInstance, + NULL); + SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); + + wdg = CreateWindow("button", "Cancel", + WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, + 90, 43, 80, 25, hwnd, + (HMENU) ID_CANCEL, + ((LPCREATESTRUCT) lParam) -> hInstance, + NULL); + SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); + + title = CreateWindow("combobox", NULL, + CBS_DROPDOWNLIST | CB_SHOWDROPDOWN | CBS_NOINTEGRALHEIGHT | CBS_HASSTRINGS | + WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, + 4, 10, 80, 160, hwnd, + (HMENU) ID_TITLESEL, + ((LPCREATESTRUCT) lParam) -> hInstance, + NULL); + + SendMessage(title, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); + + chapter = CreateWindow("combobox", NULL, + CBS_DROPDOWNLIST | CB_SHOWDROPDOWN | CBS_NOINTEGRALHEIGHT | CBS_HASSTRINGS | + WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, + 90, 10, 80, 160, hwnd, + (HMENU) ID_CHAPTERSEL, + ((LPCREATESTRUCT) lParam) -> hInstance, + NULL); + SendMessage(chapter, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); + + for (i=0; iicon; + wc.hbrBackground = SOLID_GREY2; + wc.lpszClassName = "Select Title/Chapter..."; + wc.lpszMenuName = NULL; + RegisterClass(&wc); + x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (180 / 2); + y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (100 / 2); + hWnd = CreateWindow("Select Title/Chapter...", + "Select Title/Chapter...", + WS_POPUPWINDOW | WS_CAPTION, + x, + y, + 180, + 100, + NULL, + NULL, + hInstance, + NULL); + SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD) gui); + ShowWindow(hWnd, SW_SHOW); + UpdateWindow(hWnd); +} +#endif + +static LRESULT CALLBACK EqWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) +{ + HWND btn, label, eq0, eq1, eq2, eq3; + + switch (iMsg) + { + case WM_CREATE: + { + btn = CreateWindow("button", "Reset", + WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, + 157, 143, 80, 25, hwnd, + (HMENU) ID_DEFAULTS, + ((LPCREATESTRUCT) lParam) -> hInstance, + NULL); + SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); + + btn = CreateWindow("button", "Close", + WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, + 243, 143, 80, 25, hwnd, + (HMENU) ID_CLOSE, + ((LPCREATESTRUCT) lParam) -> hInstance, + NULL); + SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); + + label = CreateWindow("static", "Brightness", + WS_CHILD | WS_VISIBLE, + 12, 122, 70, 15, hwnd, + NULL, + ((LPCREATESTRUCT) lParam) -> hInstance, + NULL); + SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); + + label = CreateWindow("static", "Contrast", + WS_CHILD | WS_VISIBLE, + 99, 122, 70, 15, hwnd, + NULL, + ((LPCREATESTRUCT) lParam) -> hInstance, + NULL); + SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); + + label = CreateWindow("static", "Hue", + WS_CHILD | WS_VISIBLE, + 191, 122, 70, 15, hwnd, + NULL, + ((LPCREATESTRUCT) lParam) -> hInstance, NULL); + SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); + + label = CreateWindow("static", "Saturation", + WS_CHILD | WS_VISIBLE, + 260, 122, 70, 15, hwnd, + NULL, + ((LPCREATESTRUCT) lParam) -> hInstance, + NULL); + SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); + + eq0 = CreateWindow(TRACKBAR_CLASS, "brightness", + WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED | + TBS_VERT | TBS_NOTICKS, + 30, 0, 20, 120, hwnd, + (HMENU) ID_EQ0, + ((LPCREATESTRUCT) lParam) -> hInstance, + NULL); + SendDlgItemMessage(hwnd, ID_EQ0, TBM_SETRANGE, 1, MAKELONG(0, 200)); + + eq1 = CreateWindow(TRACKBAR_CLASS, "contrast", + WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED | + TBS_VERT | TBS_NOTICKS, + 112, 0, 20, 120, hwnd, + (HMENU) ID_EQ1, + ((LPCREATESTRUCT) lParam) -> hInstance, + NULL); + SendDlgItemMessage(hwnd, ID_EQ1, TBM_SETRANGE, 1, MAKELONG(0, 200)); + + eq2 = CreateWindow(TRACKBAR_CLASS, "hue", + WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED | + TBS_VERT | TBS_NOTICKS, + 194, 0, 20, 120, hwnd, + (HMENU) ID_EQ2, + ((LPCREATESTRUCT) lParam) -> hInstance, + NULL); + SendDlgItemMessage(hwnd, ID_EQ2, TBM_SETRANGE, 1, MAKELONG(0, 200)); + + eq3 = CreateWindow(TRACKBAR_CLASS, "saturation", + WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED | + TBS_VERT | TBS_NOTICKS, + 276, 0, 20, 120, hwnd, + (HMENU) ID_EQ3, + ((LPCREATESTRUCT) lParam) -> hInstance, NULL); + SendDlgItemMessage(hwnd, ID_EQ3, TBM_SETRANGE, 1, MAKELONG(0, 200)); + + if(guiIntfStruct.sh_video && guiIntfStruct.Playing) + { + EnableWindow(eq0, 1); EnableWindow(eq1, 1); EnableWindow(eq2, 1); EnableWindow(eq3, 1); + get_video_colors(guiIntfStruct.sh_video, "brightness", &vo_gamma_brightness); + get_video_colors(guiIntfStruct.sh_video, "contrast", &vo_gamma_contrast); + get_video_colors(guiIntfStruct.sh_video, "hue", &vo_gamma_hue); + get_video_colors(guiIntfStruct.sh_video, "saturation", &vo_gamma_saturation); + } + SendDlgItemMessage(hwnd, ID_EQ0, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_brightness); + SendDlgItemMessage(hwnd, ID_EQ1, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_contrast); + SendDlgItemMessage(hwnd, ID_EQ2, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_hue); + SendDlgItemMessage(hwnd, ID_EQ3, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_saturation); + break; + } + case WM_VSCROLL: + { + switch (LOWORD(wParam)) + { + case TB_THUMBTRACK: + if(guiIntfStruct.sh_video && guiIntfStruct.Playing) + { + vo_gamma_brightness = 100 - SendDlgItemMessage(hwnd, ID_EQ0, TBM_GETPOS, 0, 0); + set_video_colors(guiIntfStruct.sh_video, "brightness", vo_gamma_brightness); + + vo_gamma_contrast = 100 - SendDlgItemMessage(hwnd, ID_EQ1, TBM_GETPOS, 0, 0); + set_video_colors(guiIntfStruct.sh_video, "contrast", vo_gamma_contrast); + + vo_gamma_hue = 100 - SendDlgItemMessage(hwnd, ID_EQ2, TBM_GETPOS, 0, 0); + set_video_colors(guiIntfStruct.sh_video, "hue", vo_gamma_hue); + + vo_gamma_saturation = 100 - SendDlgItemMessage(hwnd, ID_EQ3, TBM_GETPOS, 0, 0); + set_video_colors(guiIntfStruct.sh_video, "saturation", vo_gamma_saturation); + } + else + { + EnableWindow(GetDlgItem(hwnd, ID_EQ0), 0); + EnableWindow(GetDlgItem(hwnd, ID_EQ1), 0); + EnableWindow(GetDlgItem(hwnd, ID_EQ2), 0); + EnableWindow(GetDlgItem(hwnd, ID_EQ3), 0); + } + break; + } + } + case WM_CTLCOLORDLG: + case WM_CTLCOLORSTATIC: + { + HDC hdc = (HDC)wParam; + SetBkMode(hdc, TRANSPARENT); + return (INT_PTR)SOLID_GREY2; + } + break; + case WM_COMMAND: + { + switch (LOWORD(wParam)) + { + case ID_CLOSE: + DestroyWindow(hwnd); + return 0; + case ID_DEFAULTS: + if(guiIntfStruct.sh_video && guiIntfStruct.Playing) + { + vo_gamma_brightness=0; + SendDlgItemMessage(hwnd, ID_EQ0, TBM_SETPOS, 1, (LPARAM)100); + set_video_colors(guiIntfStruct.sh_video, "brightness", vo_gamma_brightness); + + vo_gamma_contrast=0; + SendDlgItemMessage(hwnd, ID_EQ1, TBM_SETPOS, 1, (LPARAM)100); + set_video_colors(guiIntfStruct.sh_video, "contrast", vo_gamma_contrast); + + vo_gamma_hue=0; + SendDlgItemMessage(hwnd, ID_EQ2, TBM_SETPOS, 1, (LPARAM)100); + set_video_colors(guiIntfStruct.sh_video, "hue", vo_gamma_hue); + + vo_gamma_saturation=0; + SendDlgItemMessage(hwnd, ID_EQ3, TBM_SETPOS, 1, (LPARAM)100); + set_video_colors(guiIntfStruct.sh_video, "saturation", vo_gamma_saturation); + } + break; + } + } + return 0; + case WM_DESTROY: + PostQuitMessage (0); + return 0; + } + return DefWindowProc(hwnd, iMsg, wParam, lParam); +} + +void display_eqwindow(gui_t *gui) +{ + if(!guiIntfStruct.sh_video) return; + + HWND hWnd; + HINSTANCE hInstance = GetModuleHandle(NULL); + WNDCLASS wc; + int x, y; + if(FindWindow(NULL, "MPlayer - Equalizer")) return; + wc.style = CS_HREDRAW | CS_VREDRAW; + wc.lpfnWndProc = EqWndProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = hInstance; + wc.hCursor = LoadCursor(NULL,IDC_ARROW); + wc.hIcon = gui->icon; + wc.hbrBackground = SOLID_GREY2; + wc.lpszClassName = "MPlayer - Equalizer"; + wc.lpszMenuName = NULL; + RegisterClass(&wc); + x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (332 / 2); + y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (200 / 2); + hWnd = CreateWindow("MPlayer - Equalizer", + "MPlayer - Equalizer", + WS_POPUPWINDOW | WS_CAPTION, + x, + y, + 332, + 200, + NULL, + NULL, + hInstance, + NULL); + SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD) gui); + ShowWindow(hWnd, SW_SHOW); + UpdateWindow(hWnd); +} diff --git a/Gui/win32/dialogs.h b/Gui/win32/dialogs.h new file mode 100644 index 0000000000..ac80f2c058 --- /dev/null +++ b/Gui/win32/dialogs.h @@ -0,0 +1,129 @@ +/* + MPlayer Gui for win32 + Copyright (c) 2003 Sascha Sommer + Copyright (c) 2006 Erik Augustson + Copyright (c) 2006 Gianluigi Tiesi + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA +*/ + +#ifndef _DIALOGS_H +#define _DIALOGS_H + +#define TBS_TOOLTIPS 0x0100 +#define WM_SYSTRAY (WM_USER+1) +#define UDM_SETRANGE32 (WM_USER+111) +#define UDM_GETRANGE32 (WM_USER+112) +#define UDM_SETPOS32 (WM_USER+113) +#define UDM_GETPOS32 (WM_USER+114) + +#define SOLID_GREY (HBRUSH) CreateSolidBrush(RGB(232, 232, 232)) +#define SOLID_GREY2 (HBRUSH) CreateSolidBrush(RGB(175, 175, 175)) + +#define gfree free + +#define MAXFILE 1024 + +#define COPYRIGHT " MPlayer GUI for Windows\n\n" \ + " Copyright (c) 2003 Sascha Sommer\n" \ + " Copyright (c) 2006 Erik Augustson\n" \ + " Copyright (c) 2006 Gianluigi Tiesi" + +#define ONLINE_HELP_URL "http://www.mplayerhq.hu/DOCS/HTML/en/index.html" + +#define ID_OK 12 +#define ID_APPLY 13 +#define ID_CANCEL 14 +#define ID_CLOSE 15 +#define ID_DEFAULTS 16 +#define ID_VO_DRIVER 17 +#define ID_AO_DRIVER 18 +#define ID_DOUBLE 19 +#define ID_DIRECT 20 +#define ID_FRAMEDROP 21 +#define ID_NORMALIZE 22 +#define ID_SOFTMIX 23 +#define ID_EXTRASTEREO 24 +#define ID_TRACKBAR1 25 +#define ID_TRACKBAR2 26 +#define ID_UPDOWN1 27 +#define ID_UPDOWN2 28 +#define ID_EDIT1 29 +#define ID_EDIT2 30 +#define ID_CACHE 31 +#define ID_AUTOSYNC 32 +#define ID_NONE 33 +#define ID_OSD1 34 +#define ID_OSD2 35 +#define ID_OSD3 36 +#define ID_DVDDEVICE 37 +#define ID_CDDEVICE 38 +#define ID_PRIO 39 +#define ID_URL 40 +#define ID_TITLESEL 41 +#define ID_UP 42 +#define ID_DOWN 43 +#define ID_REMOVE 44 +#define ID_ADDFILE 45 +#define ID_TRACKLIST 46 +#define ID_SUBTITLE 47 +#define ID_PLAYLISTLOAD 48 +#define ID_PLAYLISTSAVE 49 +#define ID_ADDURL 50 +#define ID_DIR 51 +#define ID_PLAY 52 +#define ID_STOP 53 +#define ID_SEEKF 54 +#define ID_SEEKB 55 +#define ID_NTRACK 56 +#define ID_PTRACK 57 +#define ID_PLAYLIST 58 +#define ID_CLEAR 59 +#define ID_SHOWHIDE 60 +#define ID_SKINBROWSER 61 +#define ID_KEYHELP 62 +#define ID_ONLINEHELP 63 +#define ID_CHAPTERSEL 64 +#define ID_PREFS 65 +#define TRAYMENU 66 +#define IDFILE_OPEN 67 +#define IDEXIT 68 +#define IDURL_OPEN 69 +#define IDDIR_OPEN 70 +#define IDFILE_NEW 71 +#define IDFILE_SAVE 72 +#define IDHELP_ABOUT 73 +#define IDSUBTITLE_OPEN 74 +#define IDPLAYDISK 75 +#define ID_CONSOLE 76 +#define ID_EQ0 77 +#define ID_EQ1 78 +#define ID_EQ2 79 +#define ID_EQ3 80 +#define IDSUB_TOGGLE 81 +#define IDSUB_CYCLE 82 +#define ID_ASPECT1 83 +#define ID_ASPECT2 84 +#define ID_ASPECT3 85 +#define ID_ASPECT4 86 +#define ID_SUBWINDOW 87 + +/* gtk emulation */ +#define GTK_MB_FATAL 0x1 +#define GTK_MB_ERROR 0x2 +#define GTK_MB_WARNING 0x4 +#define GTK_MB_SIMPLE 0x8 + +#endif diff --git a/Gui/win32/gui.c b/Gui/win32/gui.c new file mode 100644 index 0000000000..a1cbfab4ab --- /dev/null +++ b/Gui/win32/gui.c @@ -0,0 +1,1555 @@ +/* + MPlayer Gui for win32 + Copyright (c) 2003 Sascha Sommer + Copyright (c) 2006 Erik Augustson