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