23077
|
1 /*
|
23078
|
2 MPlayer GUI for Win32
|
23077
|
3 Copyright (c) 2003 Sascha Sommer <saschasommer@freenet.de>
|
|
4 Copyright (c) 2006 Erik Augustson <erik_27can@yahoo.com>
|
|
5 Copyright (c) 2006 Gianluigi Tiesi <sherpya@netfarm.it>
|
|
6
|
|
7 This program is free software; you can redistribute it and/or modify
|
|
8 it under the terms of the GNU General Public License as published by
|
|
9 the Free Software Foundation; either version 2 of the License, or
|
|
10 (at your option) any later version.
|
|
11
|
|
12 This program is distributed in the hope that it will be useful,
|
|
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15 GNU General Public License for more details.
|
|
16
|
|
17 You should have received a copy of the GNU General Public License
|
|
18 along with this program; if not, write to the Free Software
|
|
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA
|
|
20 */
|
|
21
|
|
22 #include <windows.h>
|
|
23 #include <commctrl.h>
|
|
24 #include <interface.h>
|
|
25 #include <mp_msg.h>
|
|
26 #include <help_mp.h>
|
|
27 #include <stream/stream.h>
|
|
28 #include <libmpdemux/demuxer.h>
|
|
29 #include <libmpdemux/stheader.h>
|
|
30 #include "gui.h"
|
|
31 #include "wincfg.h"
|
|
32 #include "dialogs.h"
|
|
33 #include "libvo/sub.h"
|
|
34
|
|
35 WNDPROC OldUrlWndProc;
|
|
36 LRESULT CALLBACK SubUrlWndProc(HWND, UINT, WPARAM, LPARAM);
|
|
37 extern int vo_gamma_brightness;
|
|
38 extern int vo_gamma_saturation;
|
|
39 extern int vo_gamma_contrast;
|
|
40 extern int vo_gamma_hue;
|
|
41 extern int set_video_colors(sh_video_t *sh_video, char *item, int value);
|
|
42 extern int get_video_colors(sh_video_t *sh_video, char *item, int *value);
|
|
43
|
|
44 guiInterface_t guiIntfStruct;
|
|
45 int addurl = 0;
|
|
46
|
|
47 extern mp_osd_obj_t* vo_osd_list;
|
|
48 extern char **sub_name;
|
|
49
|
|
50 void guiLoadSubtitle(char *name)
|
|
51 {
|
|
52 if (!guiIntfStruct.Playing)
|
|
53 {
|
|
54 guiIntfStruct.SubtitleChanged = 1;
|
|
55 return;
|
|
56 }
|
|
57 if (subdata)
|
|
58 {
|
|
59 mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_DeletingSubtitles);
|
|
60 sub_free(subdata);
|
|
61 subdata = NULL;
|
|
62 vo_sub = NULL;
|
|
63 if (vo_osd_list)
|
|
64 {
|
|
65 int len;
|
|
66 mp_osd_obj_t *osd = vo_osd_list;
|
|
67 while (osd)
|
|
68 {
|
|
69 if (osd->type == OSDTYPE_SUBTITLE) break;
|
|
70 osd = osd->next;
|
|
71 }
|
|
72 if (osd && osd->flags & OSDFLAG_VISIBLE)
|
|
73 {
|
|
74 len = osd->stride * (osd->bbox.y2 - osd->bbox.y1);
|
|
75 memset(osd->bitmap_buffer, 0, len);
|
|
76 memset(osd->alpha_buffer, 0, len);
|
|
77 }
|
|
78 }
|
|
79 }
|
|
80
|
|
81 if (name)
|
|
82 {
|
|
83 mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_LoadingSubtitles, name);
|
|
84 subdata = sub_read_file(strdup(name), guiIntfStruct.FPS);
|
|
85 if (!subdata) mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_CantLoadSub,name);
|
|
86 sub_name = (malloc(2 * sizeof(char*))); /* when mplayer will be restarted */
|
|
87 sub_name[0] = strdup(name); /* sub_name[0] will be read */
|
|
88 sub_name[1] = NULL;
|
|
89 }
|
|
90 update_set_of_subtitles();
|
|
91 }
|
|
92
|
|
93 int display_openfilewindow(gui_t *gui, int add)
|
|
94 {
|
|
95 OPENFILENAME fileopen;
|
|
96 int result = 0;
|
|
97 char filelist[MAXFILE];
|
|
98 char filename[MAX_PATH];
|
|
99 char directory[MAX_PATH];
|
|
100 char *filespec = NULL;
|
|
101 char *filepart = NULL;
|
|
102
|
|
103 memset(&fileopen, 0, sizeof(OPENFILENAME));
|
|
104 memset(filelist, 0, sizeof(filelist));
|
|
105
|
|
106 fileopen.lStructSize = sizeof(OPENFILENAME);
|
|
107 fileopen.hwndOwner = gui->mainwindow;
|
|
108 fileopen.hInstance = GetModuleHandle(NULL);
|
|
109 fileopen.lpstrFilter = "All Files (*.*)\0*.*\0"
|
|
110 "Media Files (*.avi;*.asf;*.wmv;*.mpg;*.mpeg;*.m2v;*.mov;\
|
|
111 *.rmvb;*.rm;*.ogm;*.mp3;*.wav;*.wma;*.ra;*.ogg)\0\
|
|
112 *.avi;*.asf;*.wmv;*.mpg;*.mpeg;*.m2v;*.mov;\
|
|
113 *.rmvb;*.rm;*.ogm;*.mp3;*.wav;*.wma;*.ra;*.ogg\0"
|
|
114 "Video Files (*.avi;*.mpg;*.mpeg;*.mov)\0*.avi;*.mpg;*.mpeg;*.mov\0"
|
|
115 "Avisynth Scripts (*.avs)\0*.avs\0"
|
|
116 "Audio Files (*.mp3;*.wav;*.ra)\0*.mp3;*.wav;*.ra\000";
|
|
117 fileopen.nFilterIndex = 0;
|
|
118 fileopen.lpstrTitle = "Add file(s)...";
|
|
119 fileopen.Flags = OFN_ALLOWMULTISELECT | OFN_FILEMUSTEXIST| OFN_LONGNAMES | OFN_EXPLORER| OFN_READONLY | OFN_HIDEREADONLY;
|
|
120 fileopen.lpstrFile = filelist;
|
|
121 fileopen.lpstrCustomFilter = NULL;
|
|
122 fileopen.nMaxFile = MAXFILE;
|
|
123
|
|
124 if(GetOpenFileName(&fileopen))
|
|
125 {
|
|
126 /* clear playlist */
|
|
127 if(!add) gui->playlist->clear_playlist(gui->playlist);
|
|
128
|
|
129 memcpy(directory, fileopen.lpstrFile, fileopen.nFileOffset - 1);
|
|
130 directory[fileopen.nFileOffset - 1] = 0;
|
|
131
|
|
132 do
|
|
133 {
|
|
134 filespec = &fileopen.lpstrFile[fileopen.nFileOffset];
|
|
135 filename[0] = 0;
|
|
136 strcat(filename, directory);
|
|
137 strcat(filename, "\\");
|
|
138 strcat(filename, filespec);
|
|
139
|
|
140 if (GetFileAttributes(filename) & FILE_ATTRIBUTE_DIRECTORY)
|
|
141 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] %s is a directory, skipping...\n", filename);
|
|
142 else
|
|
143 {
|
|
144 if (GetFullPathName(filename, MAX_PATH, filename, &filepart))
|
|
145 {
|
|
146 mplSetFileName(NULL, filename, STREAMTYPE_FILE);
|
|
147 if(!parse_filename(filename, playtree, mconfig, 0))
|
|
148 gui->playlist->add_track(gui->playlist, filename, NULL, filepart, 0);
|
|
149 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Adding file: %s - path %s\n", filespec, filename);
|
|
150 result++;
|
|
151 }
|
|
152 }
|
|
153 fileopen.nFileOffset += strlen(filespec) + 1;
|
|
154 } while (*filespec);
|
|
155 }
|
|
156 return result;
|
|
157 }
|
|
158
|
|
159 void display_opensubtitlewindow(gui_t *gui)
|
|
160 {
|
|
161 OPENFILENAME subtitleopen;
|
|
162 char subtitlefile[MAX_PATH];
|
|
163
|
|
164 /* Safety check */
|
|
165 if (guiIntfStruct.Playing == 0 || !guiIntfStruct.sh_video) return;
|
|
166
|
|
167 memset(&subtitleopen, 0, sizeof(OPENFILENAME));
|
|
168 memset(subtitlefile, 0, sizeof(subtitlefile));
|
|
169
|
|
170 subtitleopen.lStructSize = sizeof(OPENFILENAME);
|
|
171 subtitleopen.hwndOwner = gui->mainwindow;
|
|
172 subtitleopen.hInstance = GetModuleHandle(NULL);
|
|
173 subtitleopen.lpstrFilter = "All Files (*.*)\0*.*\0"
|
|
174 "Subtitle Files (*.srt;*.txt;*.vob)\0*.srt;*.txt;*.vob\0";
|
|
175 subtitleopen.nFilterIndex = 0;
|
|
176 subtitleopen.lpstrTitle = "Add Subtitle...";
|
|
177 subtitleopen.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_EXPLORER | OFN_READONLY | OFN_HIDEREADONLY;
|
|
178 subtitleopen.lpstrFile = subtitlefile;
|
|
179 subtitleopen.lpstrCustomFilter = NULL;
|
|
180 subtitleopen.nMaxFile = MAXFILE;
|
|
181
|
|
182 if(GetOpenFileName(&subtitleopen))
|
|
183 guiLoadSubtitle(subtitlefile);
|
|
184 }
|
|
185
|
|
186 void display_loadplaylistwindow(gui_t *gui)
|
|
187 {
|
|
188 OPENFILENAME playlistopen;
|
|
189 char playlistfile[MAX_PATH];
|
|
190
|
|
191 memset(&playlistopen, 0, sizeof(OPENFILENAME));
|
|
192 memset(playlistfile, 0, sizeof(playlistfile));
|
|
193
|
|
194 playlistopen.lStructSize = sizeof(OPENFILENAME);
|
|
195 playlistopen.hwndOwner = gui->mainwindow;
|
|
196 playlistopen.hInstance = GetModuleHandle(NULL);
|
|
197 playlistopen.lpstrFilter = "All Files (*.*)\0*.*\0"
|
|
198 "Playlist Files (*.m3u;*.pls;*.txt)\0*.m3u;*.pls;*.txt\0";
|
|
199 playlistopen.nFilterIndex = 0;
|
|
200 playlistopen.lpstrTitle = "Load Playlist...";
|
|
201 playlistopen.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_EXPLORER | OFN_READONLY | OFN_HIDEREADONLY;
|
|
202 playlistopen.lpstrFile = playlistfile;
|
|
203 playlistopen.lpstrCustomFilter = NULL;
|
|
204 playlistopen.nMaxFile = MAXFILE;
|
|
205
|
|
206 if(GetOpenFileName(&playlistopen))
|
|
207 {
|
|
208 if(parse_filename(playlistfile, playtree, mconfig, 1))
|
|
209 gui->startplay(gui);
|
|
210 }
|
|
211 }
|
|
212
|
|
213 void display_saveplaylistwindow(gui_t* gui)
|
|
214 {
|
|
215 OPENFILENAME playlistsave;
|
|
216 static FILE *playlist_file = NULL;
|
|
217 char playlistname[MAX_PATH];
|
|
218
|
|
219 memset(&playlistsave, 0, sizeof(OPENFILENAME));
|
|
220 memset(playlistname, 0, sizeof(playlistname));
|
|
221
|
|
222 playlistsave.lStructSize = sizeof(OPENFILENAME);
|
|
223 playlistsave.hwndOwner = gui->mainwindow;
|
|
224 playlistsave.hInstance = GetModuleHandle(NULL);
|
|
225 playlistsave.lpstrFilter = "Playlist Files (*.pls)\0*.pls\0";
|
|
226 playlistsave.nFilterIndex = 0;
|
|
227 playlistsave.lpstrTitle = "Save Playlist...";
|
|
228 playlistsave.Flags = OFN_LONGNAMES | OFN_EXPLORER | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
|
|
229 playlistsave.lpstrFile = playlistname;
|
|
230 playlistsave.lpstrCustomFilter = NULL;
|
|
231 playlistsave.nMaxFile = MAXFILE;
|
|
232
|
|
233 if(GetSaveFileName(&playlistsave))
|
|
234 {
|
|
235 int i=0;
|
|
236 HANDLE my_playlist;
|
|
237
|
|
238 if(!strstr(playlistname, ".pls")) strcat(playlistname, ".pls");
|
|
239
|
|
240 my_playlist = CreateFile(playlistname,
|
|
241 GENERIC_WRITE,
|
|
242 0,
|
|
243 NULL,
|
|
244 CREATE_ALWAYS,
|
|
245 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
|
|
246 NULL);
|
|
247
|
|
248 if(my_playlist != INVALID_HANDLE_VALUE)
|
|
249 {
|
|
250 CloseHandle(my_playlist); /* close the file first so we can write to it */
|
|
251 playlist_file = fopen(playlistsave.lpstrFile, "w");
|
|
252 fprintf(playlist_file, "[playlist]\n");
|
|
253 fprintf(playlist_file, "numberofentries=%d\n", gui->playlist->trackcount);
|
|
254
|
|
255 for(i=0; i<(gui->playlist->trackcount); i++)
|
|
256 {
|
|
257 fprintf(playlist_file, "File%i=%s\n", i + 1, gui->playlist->tracks[i]->filename);
|
|
258 fprintf(playlist_file, "Length%i=-1\n", i + 1);
|
|
259 }
|
|
260 fclose(playlist_file);
|
|
261 }
|
|
262 }
|
|
263 }
|
|
264
|
|
265 static LRESULT CALLBACK OpenUrlWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
|
|
266 {
|
|
267 static HWND url;
|
|
268 HWND wdg;
|
|
269 FILE *f;
|
|
270 char *history = get_path("gui.url");
|
|
271 gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
|
272 switch (iMsg)
|
|
273 {
|
|
274 case WM_CREATE:
|
|
275 wdg = CreateWindow("button", "Ok",
|
|
276 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
|
|
277 4, 43, 80, 25, hwnd,
|
|
278 (HMENU) ID_OK,
|
|
279 ((LPCREATESTRUCT) lParam) -> hInstance,
|
|
280 NULL);
|
|
281 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
|
|
282
|
|
283 wdg = CreateWindow("button", "Cancel",
|
|
284 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
|
|
285 90, 43, 80, 25, hwnd,
|
|
286 (HMENU) ID_CANCEL,
|
|
287 ((LPCREATESTRUCT) lParam) -> hInstance,
|
|
288 NULL);
|
|
289 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
|
|
290
|
|
291 url = wdg = CreateWindowEx(WS_EX_CLIENTEDGE,
|
|
292 "edit", NULL,
|
|
293 WS_CHILD | WS_VISIBLE | ES_LEFT | ES_AUTOHSCROLL,
|
|
294 4, 10, 300, 25, hwnd,
|
|
295 (HMENU) ID_URL,
|
|
296 ((LPCREATESTRUCT) lParam) -> hInstance,
|
|
297 NULL);
|
|
298 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
|
|
299 SendMessage(wdg, EM_SETLIMITTEXT, MAX_PATH, 0);
|
|
300
|
|
301 /*subclass the edit box to capture the VK_RETURN key*/
|
|
302 OldUrlWndProc = (WNDPROC)SetWindowLongPtr(url, GWLP_WNDPROC, (LONG_PTR)SubUrlWndProc);
|
|
303
|
|
304 if((f = fopen(history, "r")))
|
|
305 {
|
|
306 char lasturl[MAX_PATH];
|
|
307 fgets(lasturl, MAX_PATH, f);
|
|
308 SendMessage(url, WM_SETTEXT, 0, (LPARAM) lasturl);
|
|
309 SendMessage(url, EM_SETSEL, 0, -1);
|
|
310 fclose(f);
|
|
311 }
|
|
312 break;
|
|
313 case WM_KEYDOWN:
|
|
314 switch (LOWORD(wParam))
|
|
315 {
|
|
316 case VK_RETURN:
|
|
317 SendMessage(hwnd, WM_COMMAND, (WPARAM) ID_OK, 0);
|
|
318 break;
|
|
319 }
|
|
320 case WM_COMMAND:
|
|
321 {
|
|
322 switch (LOWORD(wParam))
|
|
323 {
|
|
324 case ID_CANCEL:
|
|
325 DestroyWindow(hwnd);
|
|
326 return 0;
|
|
327 case ID_OK:
|
|
328 {
|
|
329 char file[MAX_PATH];
|
|
330 SendMessage(url, WM_GETTEXT, MAX_PATH, (LPARAM) file);
|
|
331 mplSetFileName(NULL, file, STREAMTYPE_STREAM);
|
|
332 if((f = fopen(history, "wt+")))
|
|
333 {
|
|
334 fprintf(f, file);
|
|
335 fclose(f);
|
|
336 }
|
|
337 if(!parse_filename(file, playtree, mconfig, addurl? 0 : 1))
|
|
338 gui->playlist->add_track(gui->playlist, file, NULL, NULL, 0);
|
|
339 if(!addurl)
|
|
340 gui->startplay(gui);
|
|
341 else update_playlistwindow();
|
|
342 DestroyWindow(hwnd);
|
|
343 }
|
|
344 break;
|
|
345 }
|
|
346 }
|
|
347 return 0;
|
|
348 case WM_DESTROY:
|
|
349 {
|
|
350 PostQuitMessage (0);
|
|
351 addurl = 0;
|
|
352 return 0;
|
|
353 }
|
|
354 }
|
|
355 return DefWindowProc(hwnd, iMsg, wParam, lParam);
|
|
356 }
|
|
357
|
|
358 LRESULT CALLBACK SubUrlWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
|
|
359 {
|
|
360 switch(iMsg)
|
|
361 {
|
|
362 case WM_KEYDOWN:
|
|
363 switch (LOWORD(wParam))
|
|
364 {
|
|
365 case VK_RETURN:
|
|
366 SendMessage(FindWindow(NULL, "MPlayer - Open URL..."), WM_COMMAND, (WPARAM) ID_OK, 0);
|
|
367 break;
|
|
368 }
|
|
369 }
|
|
370 return CallWindowProc(OldUrlWndProc, hwnd, iMsg, wParam, lParam);
|
|
371 }
|
|
372
|
|
373 void display_openurlwindow(gui_t *gui, int add)
|
|
374 {
|
|
375 HWND hWnd;
|
|
376 HINSTANCE hInstance = GetModuleHandle(NULL);
|
|
377 WNDCLASS wc;
|
|
378 int x, y;
|
|
379
|
|
380 if(add) addurl = 1;
|
|
381 if(FindWindow(NULL, "MPlayer - Open URL...")) return;
|
|
382 wc.style = CS_HREDRAW | CS_VREDRAW;
|
|
383 wc.lpfnWndProc = OpenUrlWndProc;
|
|
384 wc.cbClsExtra = 0;
|
|
385 wc.cbWndExtra = 0;
|
|
386 wc.hInstance = hInstance;
|
|
387 wc.hCursor = LoadCursor(NULL,IDC_ARROW);
|
|
388 wc.hIcon = gui->icon;
|
|
389 wc.hbrBackground = SOLID_GREY2;
|
|
390 wc.lpszClassName = "MPlayer - URL";
|
|
391 wc.lpszMenuName = NULL;
|
|
392 RegisterClass(&wc);
|
|
393 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (320 / 2);
|
|
394 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (100 / 2);
|
|
395 hWnd = CreateWindow("MPlayer - URL",
|
|
396 "MPlayer - Open URL...",
|
|
397 WS_POPUPWINDOW | WS_CAPTION,
|
|
398 x,
|
|
399 y,
|
|
400 320,
|
|
401 100,
|
|
402 NULL,
|
|
403 NULL,
|
|
404 hInstance,
|
|
405 NULL);
|
|
406 SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD) gui);
|
|
407 ShowWindow(hWnd, SW_SHOW);
|
|
408 UpdateWindow(hWnd);
|
|
409 }
|
|
410
|
|
411 static void create_playlistmenu(gui_t *gui)
|
|
412 {
|
|
413 gui->playlistmenu = CreatePopupMenu();
|
|
414 AppendMenu(gui->playlistmenu, MF_STRING, ID_ADDFILE, "Add File...");
|
|
415 AppendMenu(gui->playlistmenu, MF_STRING, ID_ADDURL, "Add Url...");
|
|
416 AppendMenu(gui->playlistmenu, MF_SEPARATOR, 0, 0);
|
|
417 AppendMenu(gui->playlistmenu, MF_STRING, ID_REMOVE, "Remove Selected");
|
|
418 AppendMenu(gui->playlistmenu, MF_STRING, ID_CLEAR, "Clear Playlist");
|
|
419 AppendMenu(gui->playlistmenu, MF_SEPARATOR, 0, 0);
|
|
420 AppendMenu(gui->playlistmenu, MF_STRING, ID_CLOSE, "Close");
|
|
421 }
|
|
422
|
|
423 static void updatetracklist(HWND hwnd)
|
|
424 {
|
|
425 int i=0;
|
|
426 gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
|
427 /* clear listbox */
|
|
428 SendDlgItemMessage(hwnd, ID_TRACKLIST, LB_RESETCONTENT, 0, 0);
|
|
429 for (i=0; i < gui->playlist->trackcount; i++)
|
|
430 if (gui->playlist->tracks[i]->title)
|
|
431 SendDlgItemMessage(hwnd, ID_TRACKLIST, LB_ADDSTRING, 0, (LPARAM)gui->playlist->tracks[i]->title);
|
|
432 else
|
|
433 SendDlgItemMessage(hwnd, ID_TRACKLIST, LB_ADDSTRING, 0, (LPARAM)gui->playlist->tracks[i]->filename);
|
|
434 }
|
|
435
|
|
436 static LRESULT CALLBACK PlayListWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
|
|
437 {
|
|
438 HWND wdg;
|
|
439 POINT cursor;
|
|
440 gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
|
441 playlist_t *pl = gui ? gui->playlist : NULL;
|
|
442 switch (iMsg)
|
|
443 {
|
|
444 case WM_CREATE:
|
|
445 {
|
|
446 wdg = CreateWindow("button", "Play",
|
|
447 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
|
|
448 4, 10, 80, 25, hwnd,
|
|
449 (HMENU) ID_PLAY,
|
|
450 ((LPCREATESTRUCT) lParam) -> hInstance,
|
|
451 NULL);
|
|
452 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
|
|
453
|
|
454 wdg = CreateWindow ("button", "Up",
|
|
455 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
|
|
456 4, 37, 80, 25, hwnd,
|
|
457 (HMENU) ID_UP,
|
|
458 ((LPCREATESTRUCT) lParam) -> hInstance,
|
|
459 NULL);
|
|
460 SendMessage(wdg, WM_SETFONT,(WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
|
|
461
|
|
462 wdg = CreateWindow ("button", "Down",
|
|
463 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
|
|
464 4, 64, 80, 25, hwnd,
|
|
465 (HMENU) ID_DOWN,
|
|
466 ((LPCREATESTRUCT) lParam) -> hInstance,
|
|
467 NULL);
|
|
468 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0);
|
|
469
|
|
470 wdg = CreateWindow ("button", "Remove",
|
|
471 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
|
|
472 4, 91, 80, 25, hwnd,
|
|
473 (HMENU) ID_REMOVE,
|
|
474 ((LPCREATESTRUCT) lParam) -> hInstance,
|
|
475 NULL);
|
|
476 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0);
|
|
477
|
|
478 wdg = CreateWindow ("button", "Load",
|
|
479 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
|
|
480 4, 118, 80, 25, hwnd,
|
|
481 (HMENU) ID_PLAYLISTLOAD,
|
|
482 ((LPCREATESTRUCT) lParam) -> hInstance,
|
|
483 NULL);
|
|
484 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0);
|
|
485
|
|
486 wdg = CreateWindow ("button", "Save",
|
|
487 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
|
|
488 4, 145, 80, 25, hwnd,
|
|
489 (HMENU) ID_PLAYLISTSAVE,
|
|
490 ((LPCREATESTRUCT) lParam) -> hInstance,
|
|
491 NULL);
|
|
492 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0);
|
|
493
|
|
494 wdg = CreateWindow ("button", "Close",
|
|
495 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
|
|
496 4, 193, 80, 25, hwnd,
|
|
497 (HMENU) ID_CLOSE,
|
|
498 ((LPCREATESTRUCT) lParam) -> hInstance,
|
|
499 NULL);
|
|
500 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0);
|
|
501
|
|
502 wdg = CreateWindow ("listbox", "tracklist", WS_CHILD | WS_VISIBLE | LBS_NOTIFY | WS_VSCROLL |
|
|
503 WS_HSCROLL | LBS_DISABLENOSCROLL, 92, 10, 300, 208, hwnd, (HMENU) ID_TRACKLIST,
|
|
504 ((LPCREATESTRUCT) lParam) -> hInstance, NULL);
|
|
505 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
|
|
506 SendMessage(wdg, LB_SETHORIZONTALEXTENT, MAX_PATH*4, 0);
|
|
507 break;
|
|
508 }
|
|
509 case WM_CONTEXTMENU:
|
|
510 {
|
|
511 GetCursorPos(&cursor);
|
|
512 SetForegroundWindow(hwnd);
|
|
513 TrackPopupMenu(gui->playlistmenu, 0, cursor.x, cursor.y, 0, hwnd, NULL);
|
|
514 break;
|
|
515 }
|
|
516 case WM_COMMAND:
|
|
517 {
|
|
518 int selected = 0;
|
|
519 int i;
|
|
520 for (i=0; i<pl->trackcount; i++)
|
|
521 if(0 < SendDlgItemMessage(hwnd, ID_TRACKLIST, LB_GETSEL, i, 0)) selected = i + 1;
|
|
522 switch (LOWORD(wParam))
|
|
523 {
|
|
524 case ID_CLOSE:
|
|
525 DestroyWindow(hwnd);
|
|
526 return 0;
|
|
527 case ID_TRACKLIST:
|
|
528 if(HIWORD(wParam) == LBN_DBLCLK)
|
|
529 {
|
|
530 case ID_PLAY:
|
|
531 if(selected) pl->current = selected - 1;
|
|
532 mplSetFileName(NULL, pl->tracks[pl->current]->filename, STREAMTYPE_STREAM);
|
|
533 gui->startplay(gui);
|
|
534 }
|
|
535 return 0;
|
|
536 case ID_UP:
|
|
537 {
|
|
538 if(selected) pl->moveup_track(pl, selected);
|
|
539 selected--;
|
|
540 break;
|
|
541 }
|
|
542 case ID_DOWN:
|
|
543 {
|
|
544 if(selected) pl->movedown_track(pl, selected);
|
|
545 selected++;
|
|
546 break;
|
|
547 }
|
|
548 case ID_REMOVE:
|
|
549 if(selected) pl->remove_track(pl, selected);
|
|
550 break;
|
|
551 case ID_ADDFILE:
|
|
552 {
|
|
553 if(guiIntfStruct.StreamType == STREAMTYPE_DVD ||
|
|
554 guiIntfStruct.StreamType == STREAMTYPE_DVDNAV) return 0;
|
|
555 display_openfilewindow(gui, 1);
|
|
556 break;
|
|
557 }
|
|
558 case ID_ADDURL:
|
|
559 {
|
|
560 if(guiIntfStruct.StreamType == STREAMTYPE_DVD ||
|
|
561 guiIntfStruct.StreamType == STREAMTYPE_DVDNAV) return 0;
|
|
562 display_openurlwindow(gui, 1);
|
|
563 break;
|
|
564 }
|
|
565 case ID_CLEAR:
|
|
566 {
|
|
567 if(!gui->playlist->trackcount) return 0;
|
|
568 gui->playlist->clear_playlist(gui->playlist);
|
|
569 break;
|
|
570 }
|
|
571 case ID_PLAYLISTLOAD:
|
|
572 {
|
|
573 if(guiIntfStruct.StreamType == STREAMTYPE_DVD ||
|
|
574 guiIntfStruct.StreamType == STREAMTYPE_DVDNAV) return 0;
|
|
575 display_loadplaylistwindow(gui);
|
|
576 break;
|
|
577 }
|
|
578 case ID_PLAYLISTSAVE:
|
|
579 {
|
|
580 /* no point saving an empty playlist */
|
|
581 if(!gui->playlist->trackcount ||
|
|
582 guiIntfStruct.StreamType == STREAMTYPE_DVD ||
|
|
583 guiIntfStruct.StreamType == STREAMTYPE_DVDNAV)
|
|
584 return 0;
|
|
585 display_saveplaylistwindow(gui);
|
|
586 break;
|
|
587 }
|
|
588 }
|
|
589 updatetracklist(hwnd);
|
|
590 if(selected < 1) selected = 1;
|
|
591 else if(selected>pl->trackcount) selected = pl->trackcount;
|
|
592 SendDlgItemMessage(hwnd, ID_TRACKLIST, LB_SETCURSEL, selected - 1, 0);
|
|
593 return 0;
|
|
594 }
|
|
595 case WM_DROPFILES:
|
|
596 {
|
|
597 char file[MAX_PATH];
|
|
598 int filecount = DragQueryFile((HDROP) wParam, -1, file, MAX_PATH);
|
|
599 int i;
|
|
600 for (i=0; i<filecount; i++)
|
|
601 {
|
|
602 DragQueryFile((HDROP) wParam, i, file, MAX_PATH);
|
|
603 if(!parse_filename(file, playtree, mconfig, 0))
|
|
604 pl->add_track(pl, file, NULL, NULL, 0);
|
|
605 }
|
|
606 DragFinish((HDROP) wParam);
|
|
607 updatetracklist(hwnd);
|
|
608 }
|
|
609 break;
|
|
610 case WM_DESTROY:
|
|
611 PostQuitMessage(0);
|
|
612 return 0;
|
|
613 }
|
|
614 return DefWindowProc(hwnd, iMsg, wParam, lParam);
|
|
615 }
|
|
616
|
|
617 void update_playlistwindow(void)
|
|
618 {
|
|
619 HWND hWnd = FindWindow(NULL, "MPlayer Playlist");
|
|
620 if (hWnd) updatetracklist(hWnd);
|
|
621 }
|
|
622
|
|
623 void display_playlistwindow(gui_t *gui)
|
|
624 {
|
|
625 HWND hWnd = FindWindow(NULL, "MPlayer Playlist");
|
|
626 HINSTANCE hInstance = GetModuleHandle(NULL);
|
|
627 WNDCLASS wc;
|
|
628 int x, y;
|
|
629
|
|
630 if (hWnd)
|
|
631 {
|
|
632 SendMessage(hWnd, WM_CLOSE, 0, 0);
|
|
633 return;
|
|
634 }
|
|
635
|
|
636 wc.style = CS_HREDRAW | CS_VREDRAW;
|
|
637 wc.lpfnWndProc = PlayListWndProc;
|
|
638 wc.cbClsExtra = 0;
|
|
639 wc.cbWndExtra = 0;
|
|
640 wc.hInstance = hInstance;
|
|
641 wc.hCursor = LoadCursor(NULL,IDC_ARROW);
|
|
642 wc.hIcon = gui->icon;
|
|
643 wc.hbrBackground = SOLID_GREY2;
|
|
644 wc.lpszClassName = "MPlayer - Playlist";
|
|
645 wc.lpszMenuName = NULL;
|
|
646 RegisterClass(&wc);
|
|
647 create_playlistmenu(gui);
|
|
648 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (400 / 2); /* Erik: center popup window on screen */
|
|
649 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (254 / 2);
|
|
650 hWnd = CreateWindow("MPlayer - Playlist",
|
|
651 "MPlayer Playlist",
|
|
652 WS_POPUPWINDOW | WS_CAPTION | WS_MINIMIZEBOX,
|
|
653 x,
|
|
654 y,
|
|
655 400,
|
|
656 254,
|
|
657 NULL,
|
|
658 NULL,
|
|
659 hInstance,
|
|
660 NULL);
|
|
661 SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD)gui);
|
|
662 updatetracklist(hWnd);
|
|
663 DragAcceptFiles(hWnd,TRUE);
|
|
664 ShowWindow(hWnd, SW_SHOW);
|
|
665 UpdateWindow(hWnd);
|
|
666 }
|
|
667
|
|
668 static LRESULT CALLBACK SkinBrowserWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
|
|
669 {
|
|
670 static HWND listbox;
|
|
671 static char skinspath[MAX_PATH];
|
|
672 gui_t* gui = (gui_t*) GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
|
673 switch (iMsg)
|
|
674 {
|
|
675 case WM_CREATE:
|
|
676 {
|
|
677 HANDLE skinHandle = INVALID_HANDLE_VALUE;
|
|
678 WIN32_FIND_DATA finddata;
|
|
679
|
|
680 listbox = CreateWindow("listbox", NULL,
|
|
681 WS_CHILD | WS_VISIBLE | LBS_NOTIFY | LBS_NOINTEGRALHEIGHT |
|
|
682 LBS_DISABLENOSCROLL | WS_VSCROLL | WS_TABSTOP,
|
|
683 4, 5, 166, 60, hwnd,
|
|
684 (HMENU) ID_DIR,
|
|
685 ((LPCREATESTRUCT) lParam) -> hInstance,
|
|
686 NULL);
|
|
687 SendMessage(listbox, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
|
|
688
|
|
689 /* This opens the skins directory, lists the directory names, and adds them to the listbox */
|
|
690 sprintf(skinspath, "%s/*.", get_path("skins"));
|
|
691
|
|
692 skinHandle = FindFirstFile(skinspath, &finddata);
|
|
693 if (skinHandle != INVALID_HANDLE_VALUE)
|
|
694 {
|
|
695 do
|
|
696 {
|
|
697 if (finddata.cFileName[0] == '.') continue;
|
|
698 /* populate the listbox */
|
|
699 capitalize(finddata.cFileName);
|
|
700 SendDlgItemMessage(hwnd, ID_DIR, LB_ADDSTRING, 0, (LPARAM) finddata.cFileName);
|
|
701 } while (FindNextFile(skinHandle, &finddata));
|
|
702 FindClose(skinHandle);
|
|
703 }
|
|
704 else
|
|
705 mp_msg(MSGT_GPLAYER, MSGL_FATAL, "Error opening %s\n", get_path("skins"));
|
|
706 break;
|
|
707 }
|
|
708 case WM_COMMAND:
|
|
709 {
|
|
710 if ((HWND) lParam == listbox)
|
|
711 {
|
|
712 if(HIWORD(wParam) == LBN_DBLCLK)
|
|
713 {
|
|
714 int index = SendMessage(listbox, LB_GETCURSEL, 0, 0);
|
|
715 int len = SendMessage(listbox, LB_GETTEXTLEN, index, 0);
|
|
716 if (len)
|
|
717 {
|
|
718 if (guiIntfStruct.Playing) guiGetEvent(guiCEvent, (void *) guiSetStop);
|
|
719 if (skinName) free(skinName);
|
|
720 skinName = (char *) malloc(len+1);
|
|
721 SendMessage(listbox, LB_GETTEXT, (WPARAM) index, (LPARAM) skinName);
|
|
722 /* fill out the full pathname to the skin */
|
|
723 strcpy(skinspath, get_path("skins"));
|
|
724 strcat(skinspath, "\\");
|
|
725 strcat(skinspath, skinName);
|
|
726 ShowWindow(hwnd, SW_HIDE);
|
|
727 Shell_NotifyIcon(NIM_DELETE, &nid);
|
|
728 destroy_window(gui);
|
|
729 create_window(gui, skinspath);
|
|
730 create_subwindow(gui, skinspath);
|
|
731 SendMessage(hwnd, WM_CLOSE, 0, 0); /* Avoid crashing when switching skin */
|
|
732 }
|
|
733 }
|
|
734 }
|
|
735 }
|
|
736 return 0;
|
|
737 case WM_DESTROY:
|
|
738 PostQuitMessage(0);
|
|
739 return 0;
|
|
740 }
|
|
741 return DefWindowProc(hwnd, iMsg, wParam, lParam);
|
|
742 }
|
|
743
|
|
744 void display_skinbrowser(gui_t* gui)
|
|
745 {
|
|
746 HWND hWnd = FindWindow(NULL, "Skin Browser");
|
|
747 HINSTANCE hInstance = GetModuleHandle(NULL);
|
|
748 WNDCLASS wc;
|
|
749 int x, y;
|
|
750
|
|
751 if (hWnd)
|
|
752 {
|
|
753 SendMessage(hWnd, WM_CLOSE, 0, 0);
|
|
754 return;
|
|
755 }
|
|
756
|
|
757 wc.style = CS_HREDRAW | CS_VREDRAW;
|
|
758 wc.lpfnWndProc = SkinBrowserWndProc;
|
|
759 wc.cbClsExtra = 0;
|
|
760 wc.cbWndExtra = 0;
|
|
761 wc.hInstance = hInstance;
|
|
762 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
|
763 wc.hIcon = gui->icon;
|
|
764 wc.hbrBackground = SOLID_GREY2;
|
|
765 wc.lpszClassName = "Skin Browser";
|
|
766 wc.lpszMenuName = NULL;
|
|
767 RegisterClass(&wc);
|
|
768 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (180 / 2);
|
|
769 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (102 / 2);
|
|
770 hWnd = CreateWindow("Skin Browser",
|
|
771 "Skin Browser",
|
|
772 WS_POPUPWINDOW |WS_CAPTION,
|
|
773 x,
|
|
774 y,
|
|
775 180,
|
|
776 102,
|
|
777 NULL,
|
|
778 NULL,
|
|
779 hInstance,
|
|
780 NULL);
|
|
781 SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD) gui);
|
|
782 ShowWindow(hWnd, SW_SHOW);
|
|
783 UpdateWindow(hWnd);
|
|
784 }
|
|
785
|
|
786 #ifdef USE_DVDREAD
|
|
787 static LRESULT CALLBACK TitleChapterWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
|
|
788 {
|
|
789 static HWND title;
|
|
790 static HWND chapter;
|
|
791 HWND wdg;
|
|
792 int i=0, j=0;
|
|
793 char titles[MAX_PATH] = "";
|
|
794 char chapters[MAX_PATH] = "";
|
|
795 gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
|
796 switch (iMsg)
|
|
797 {
|
|
798 case WM_CREATE:
|
|
799 wdg = CreateWindow("button", "Ok",
|
|
800 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
|
|
801 4, 43, 80, 25, hwnd,
|
|
802 (HMENU) ID_OK,
|
|
803 ((LPCREATESTRUCT) lParam) -> hInstance,
|
|
804 NULL);
|
|
805 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
|
|
806
|
|
807 wdg = CreateWindow("button", "Cancel",
|
|
808 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
|
|
809 90, 43, 80, 25, hwnd,
|
|
810 (HMENU) ID_CANCEL,
|
|
811 ((LPCREATESTRUCT) lParam) -> hInstance,
|
|
812 NULL);
|
|
813 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
|
|
814
|
|
815 title = CreateWindow("combobox", NULL,
|
|
816 CBS_DROPDOWNLIST | CB_SHOWDROPDOWN | CBS_NOINTEGRALHEIGHT | CBS_HASSTRINGS |
|
|
817 WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP,
|
|
818 4, 10, 80, 160, hwnd,
|
|
819 (HMENU) ID_TITLESEL,
|
|
820 ((LPCREATESTRUCT) lParam) -> hInstance,
|
|
821 NULL);
|
|
822
|
|
823 SendMessage(title, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
|
|
824
|
|
825 chapter = CreateWindow("combobox", NULL,
|
|
826 CBS_DROPDOWNLIST | CB_SHOWDROPDOWN | CBS_NOINTEGRALHEIGHT | CBS_HASSTRINGS |
|
|
827 WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP,
|
|
828 90, 10, 80, 160, hwnd,
|
|
829 (HMENU) ID_CHAPTERSEL,
|
|
830 ((LPCREATESTRUCT) lParam) -> hInstance,
|
|
831 NULL);
|
|
832 SendMessage(chapter, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
|
|
833
|
|
834 for (i=0; i<guiIntfStruct.DVD.titles; i++)
|
|
835 {
|
|
836 /* we have to reverse the order here because of the way CB_INSERTSTRING adds items */
|
|
837 sprintf(&titles[i], "%d", guiIntfStruct.DVD.titles - i);
|
|
838 SendDlgItemMessage(hwnd, ID_TITLESEL, CB_INSERTSTRING, 0, (LPARAM) &titles[i]);
|
|
839 }
|
|
840 SendDlgItemMessage(hwnd, ID_TITLESEL, CB_SETCURSEL, dvd_title, 0);
|
|
841
|
|
842 for (j=0; j<guiIntfStruct.DVD.chapters; j++)
|
|
843 {
|
|
844 sprintf(&chapters[j], "%d", guiIntfStruct.DVD.chapters - j);
|
|
845 SendDlgItemMessage(hwnd, ID_CHAPTERSEL, CB_INSERTSTRING, 0, (LPARAM) &chapters[j]);
|
|
846 }
|
|
847 SendDlgItemMessage(hwnd, ID_CHAPTERSEL, CB_SETCURSEL, dvd_chapter, 0);
|
|
848
|
|
849 break;
|
|
850 case WM_COMMAND:
|
|
851 {
|
|
852 switch (LOWORD(wParam))
|
|
853 {
|
|
854 case ID_CANCEL:
|
|
855 DestroyWindow(hwnd);
|
|
856 return 0;
|
|
857 case ID_OK:
|
|
858 {
|
|
859 guiIntfStruct.DVD.current_title = SendMessage(title, CB_GETCURSEL, 0, 0) + 1;
|
|
860 guiIntfStruct.DVD.current_chapter = SendMessage(chapter, CB_GETCURSEL, 0, 0) + 1;
|
|
861
|
|
862 if((guiIntfStruct.DVD.current_title != 0 || guiIntfStruct.DVD.current_chapter != 0))
|
|
863 {
|
|
864 gui->startplay(gui);
|
|
865 DestroyWindow(hwnd);
|
|
866 }
|
|
867 }
|
|
868 break;
|
|
869 }
|
|
870 }
|
|
871 return 0;
|
|
872 case WM_DESTROY:
|
|
873 PostQuitMessage (0);
|
|
874 return 0;
|
|
875 }
|
|
876 return DefWindowProc(hwnd, iMsg, wParam, lParam);
|
|
877 }
|
|
878
|
|
879 void display_chapterselwindow(gui_t *gui)
|
|
880 {
|
|
881 HWND hWnd;
|
|
882 HINSTANCE hInstance = GetModuleHandle(NULL);
|
|
883 WNDCLASS wc;
|
|
884 int x, y;
|
|
885
|
|
886 if (guiIntfStruct.StreamType != STREAMTYPE_DVD) return;
|
|
887 if (FindWindow(NULL, "Select Title/Chapter...")) return;
|
|
888
|
|
889 wc.style = CS_HREDRAW | CS_VREDRAW;
|
|
890 wc.lpfnWndProc = TitleChapterWndProc;
|
|
891 wc.cbClsExtra = 0;
|
|
892 wc.cbWndExtra = 0;
|
|
893 wc.hInstance = hInstance;
|
|
894 wc.hCursor = LoadCursor(NULL,IDC_ARROW);
|
|
895 wc.hIcon = gui->icon;
|
|
896 wc.hbrBackground = SOLID_GREY2;
|
|
897 wc.lpszClassName = "Select Title/Chapter...";
|
|
898 wc.lpszMenuName = NULL;
|
|
899 RegisterClass(&wc);
|
|
900 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (180 / 2);
|
|
901 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (100 / 2);
|
|
902 hWnd = CreateWindow("Select Title/Chapter...",
|
|
903 "Select Title/Chapter...",
|
|
904 WS_POPUPWINDOW | WS_CAPTION,
|
|
905 x,
|
|
906 y,
|
|
907 180,
|
|
908 100,
|
|
909 NULL,
|
|
910 NULL,
|
|
911 hInstance,
|
|
912 NULL);
|
|
913 SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD) gui);
|
|
914 ShowWindow(hWnd, SW_SHOW);
|
|
915 UpdateWindow(hWnd);
|
|
916 }
|
|
917 #endif
|
|
918
|
|
919 static LRESULT CALLBACK EqWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
|
|
920 {
|
|
921 HWND btn, label, eq0, eq1, eq2, eq3;
|
|
922
|
|
923 switch (iMsg)
|
|
924 {
|
|
925 case WM_CREATE:
|
|
926 {
|
|
927 btn = CreateWindow("button", "Reset",
|
|
928 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
|
|
929 157, 143, 80, 25, hwnd,
|
|
930 (HMENU) ID_DEFAULTS,
|
|
931 ((LPCREATESTRUCT) lParam) -> hInstance,
|
|
932 NULL);
|
|
933 SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
|
|
934
|
|
935 btn = CreateWindow("button", "Close",
|
|
936 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
|
|
937 243, 143, 80, 25, hwnd,
|
|
938 (HMENU) ID_CLOSE,
|
|
939 ((LPCREATESTRUCT) lParam) -> hInstance,
|
|
940 NULL);
|
|
941 SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
|
|
942
|
|
943 label = CreateWindow("static", "Brightness",
|
|
944 WS_CHILD | WS_VISIBLE,
|
|
945 12, 122, 70, 15, hwnd,
|
|
946 NULL,
|
|
947 ((LPCREATESTRUCT) lParam) -> hInstance,
|
|
948 NULL);
|
|
949 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
|
|
950
|
|
951 label = CreateWindow("static", "Contrast",
|
|
952 WS_CHILD | WS_VISIBLE,
|
|
953 99, 122, 70, 15, hwnd,
|
|
954 NULL,
|
|
955 ((LPCREATESTRUCT) lParam) -> hInstance,
|
|
956 NULL);
|
|
957 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
|
|
958
|
|
959 label = CreateWindow("static", "Hue",
|
|
960 WS_CHILD | WS_VISIBLE,
|
|
961 191, 122, 70, 15, hwnd,
|
|
962 NULL,
|
|
963 ((LPCREATESTRUCT) lParam) -> hInstance, NULL);
|
|
964 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
|
|
965
|
|
966 label = CreateWindow("static", "Saturation",
|
|
967 WS_CHILD | WS_VISIBLE,
|
|
968 260, 122, 70, 15, hwnd,
|
|
969 NULL,
|
|
970 ((LPCREATESTRUCT) lParam) -> hInstance,
|
|
971 NULL);
|
|
972 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
|
|
973
|
|
974 eq0 = CreateWindow(TRACKBAR_CLASS, "brightness",
|
|
975 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED |
|
|
976 TBS_VERT | TBS_NOTICKS,
|
|
977 30, 0, 20, 120, hwnd,
|
|
978 (HMENU) ID_EQ0,
|
|
979 ((LPCREATESTRUCT) lParam) -> hInstance,
|
|
980 NULL);
|
|
981 SendDlgItemMessage(hwnd, ID_EQ0, TBM_SETRANGE, 1, MAKELONG(0, 200));
|
|
982
|
|
983 eq1 = CreateWindow(TRACKBAR_CLASS, "contrast",
|
|
984 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED |
|
|
985 TBS_VERT | TBS_NOTICKS,
|
|
986 112, 0, 20, 120, hwnd,
|
|
987 (HMENU) ID_EQ1,
|
|
988 ((LPCREATESTRUCT) lParam) -> hInstance,
|
|
989 NULL);
|
|
990 SendDlgItemMessage(hwnd, ID_EQ1, TBM_SETRANGE, 1, MAKELONG(0, 200));
|
|
991
|
|
992 eq2 = CreateWindow(TRACKBAR_CLASS, "hue",
|
|
993 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED |
|
|
994 TBS_VERT | TBS_NOTICKS,
|
|
995 194, 0, 20, 120, hwnd,
|
|
996 (HMENU) ID_EQ2,
|
|
997 ((LPCREATESTRUCT) lParam) -> hInstance,
|
|
998 NULL);
|
|
999 SendDlgItemMessage(hwnd, ID_EQ2, TBM_SETRANGE, 1, MAKELONG(0, 200));
|
|
1000
|
|
1001 eq3 = CreateWindow(TRACKBAR_CLASS, "saturation",
|
|
1002 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED |
|
|
1003 TBS_VERT | TBS_NOTICKS,
|
|
1004 276, 0, 20, 120, hwnd,
|
|
1005 (HMENU) ID_EQ3,
|
|
1006 ((LPCREATESTRUCT) lParam) -> hInstance, NULL);
|
|
1007 SendDlgItemMessage(hwnd, ID_EQ3, TBM_SETRANGE, 1, MAKELONG(0, 200));
|
|
1008
|
|
1009 if(guiIntfStruct.sh_video && guiIntfStruct.Playing)
|
|
1010 {
|
|
1011 EnableWindow(eq0, 1); EnableWindow(eq1, 1); EnableWindow(eq2, 1); EnableWindow(eq3, 1);
|
|
1012 get_video_colors(guiIntfStruct.sh_video, "brightness", &vo_gamma_brightness);
|
|
1013 get_video_colors(guiIntfStruct.sh_video, "contrast", &vo_gamma_contrast);
|
|
1014 get_video_colors(guiIntfStruct.sh_video, "hue", &vo_gamma_hue);
|
|
1015 get_video_colors(guiIntfStruct.sh_video, "saturation", &vo_gamma_saturation);
|
|
1016 }
|
|
1017 SendDlgItemMessage(hwnd, ID_EQ0, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_brightness);
|
|
1018 SendDlgItemMessage(hwnd, ID_EQ1, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_contrast);
|
|
1019 SendDlgItemMessage(hwnd, ID_EQ2, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_hue);
|
|
1020 SendDlgItemMessage(hwnd, ID_EQ3, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_saturation);
|
|
1021 break;
|
|
1022 }
|
|
1023 case WM_VSCROLL:
|
|
1024 {
|
|
1025 switch (LOWORD(wParam))
|
|
1026 {
|
|
1027 case TB_THUMBTRACK:
|
|
1028 if(guiIntfStruct.sh_video && guiIntfStruct.Playing)
|
|
1029 {
|
|
1030 vo_gamma_brightness = 100 - SendDlgItemMessage(hwnd, ID_EQ0, TBM_GETPOS, 0, 0);
|
|
1031 set_video_colors(guiIntfStruct.sh_video, "brightness", vo_gamma_brightness);
|
|
1032
|
|
1033 vo_gamma_contrast = 100 - SendDlgItemMessage(hwnd, ID_EQ1, TBM_GETPOS, 0, 0);
|
|
1034 set_video_colors(guiIntfStruct.sh_video, "contrast", vo_gamma_contrast);
|
|
1035
|
|
1036 vo_gamma_hue = 100 - SendDlgItemMessage(hwnd, ID_EQ2, TBM_GETPOS, 0, 0);
|
|
1037 set_video_colors(guiIntfStruct.sh_video, "hue", vo_gamma_hue);
|
|
1038
|
|
1039 vo_gamma_saturation = 100 - SendDlgItemMessage(hwnd, ID_EQ3, TBM_GETPOS, 0, 0);
|
|
1040 set_video_colors(guiIntfStruct.sh_video, "saturation", vo_gamma_saturation);
|
|
1041 }
|
|
1042 else
|
|
1043 {
|
|
1044 EnableWindow(GetDlgItem(hwnd, ID_EQ0), 0);
|
|
1045 EnableWindow(GetDlgItem(hwnd, ID_EQ1), 0);
|
|
1046 EnableWindow(GetDlgItem(hwnd, ID_EQ2), 0);
|
|
1047 EnableWindow(GetDlgItem(hwnd, ID_EQ3), 0);
|
|
1048 }
|
|
1049 break;
|
|
1050 }
|
|
1051 }
|
|
1052 case WM_CTLCOLORDLG:
|
|
1053 case WM_CTLCOLORSTATIC:
|
|
1054 {
|
|
1055 HDC hdc = (HDC)wParam;
|
|
1056 SetBkMode(hdc, TRANSPARENT);
|
|
1057 return (INT_PTR)SOLID_GREY2;
|
|
1058 }
|
|
1059 break;
|
|
1060 case WM_COMMAND:
|
|
1061 {
|
|
1062 switch (LOWORD(wParam))
|
|
1063 {
|
|
1064 case ID_CLOSE:
|
|
1065 DestroyWindow(hwnd);
|
|
1066 return 0;
|
|
1067 case ID_DEFAULTS:
|
|
1068 if(guiIntfStruct.sh_video && guiIntfStruct.Playing)
|
|
1069 {
|
|
1070 vo_gamma_brightness=0;
|
|
1071 SendDlgItemMessage(hwnd, ID_EQ0, TBM_SETPOS, 1, (LPARAM)100);
|
|
1072 set_video_colors(guiIntfStruct.sh_video, "brightness", vo_gamma_brightness);
|
|
1073
|
|
1074 vo_gamma_contrast=0;
|
|
1075 SendDlgItemMessage(hwnd, ID_EQ1, TBM_SETPOS, 1, (LPARAM)100);
|
|
1076 set_video_colors(guiIntfStruct.sh_video, "contrast", vo_gamma_contrast);
|
|
1077
|
|
1078 vo_gamma_hue=0;
|
|
1079 SendDlgItemMessage(hwnd, ID_EQ2, TBM_SETPOS, 1, (LPARAM)100);
|
|
1080 set_video_colors(guiIntfStruct.sh_video, "hue", vo_gamma_hue);
|
|
1081
|
|
1082 vo_gamma_saturation=0;
|
|
1083 SendDlgItemMessage(hwnd, ID_EQ3, TBM_SETPOS, 1, (LPARAM)100);
|
|
1084 set_video_colors(guiIntfStruct.sh_video, "saturation", vo_gamma_saturation);
|
|
1085 }
|
|
1086 break;
|
|
1087 }
|
|
1088 }
|
|
1089 return 0;
|
|
1090 case WM_DESTROY:
|
|
1091 PostQuitMessage (0);
|
|
1092 return 0;
|
|
1093 }
|
|
1094 return DefWindowProc(hwnd, iMsg, wParam, lParam);
|
|
1095 }
|
|
1096
|
|
1097 void display_eqwindow(gui_t *gui)
|
|
1098 {
|
|
1099 HWND hWnd;
|
|
1100 HINSTANCE hInstance = GetModuleHandle(NULL);
|
|
1101 WNDCLASS wc;
|
|
1102 int x, y;
|
|
1103
|
|
1104 if(!guiIntfStruct.sh_video) return;
|
|
1105 if(FindWindow(NULL, "MPlayer - Equalizer")) return;
|
|
1106 wc.style = CS_HREDRAW | CS_VREDRAW;
|
|
1107 wc.lpfnWndProc = EqWndProc;
|
|
1108 wc.cbClsExtra = 0;
|
|
1109 wc.cbWndExtra = 0;
|
|
1110 wc.hInstance = hInstance;
|
|
1111 wc.hCursor = LoadCursor(NULL,IDC_ARROW);
|
|
1112 wc.hIcon = gui->icon;
|
|
1113 wc.hbrBackground = SOLID_GREY2;
|
|
1114 wc.lpszClassName = "MPlayer - Equalizer";
|
|
1115 wc.lpszMenuName = NULL;
|
|
1116 RegisterClass(&wc);
|
|
1117 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (332 / 2);
|
|
1118 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (200 / 2);
|
|
1119 hWnd = CreateWindow("MPlayer - Equalizer",
|
|
1120 "MPlayer - Equalizer",
|
|
1121 WS_POPUPWINDOW | WS_CAPTION,
|
|
1122 x,
|
|
1123 y,
|
|
1124 332,
|
|
1125 200,
|
|
1126 NULL,
|
|
1127 NULL,
|
|
1128 hInstance,
|
|
1129 NULL);
|
|
1130 SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD) gui);
|
|
1131 ShowWindow(hWnd, SW_SHOW);
|
|
1132 UpdateWindow(hWnd);
|
|
1133 }
|