Mercurial > mplayer.hg
annotate Gui/win32/dialogs.c @ 19219:7b6e341b72f5
10l, last commit swapped U and V planes.
author | reimar |
---|---|
date | Fri, 28 Jul 2006 17:56:38 +0000 |
parents | 42d4e99a075e |
children | 64d82a45a05d |
rev | line source |
---|---|
18914 | 1 /* |
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 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 <libmpdemux/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 | |
34 WNDPROC OldUrlWndProc; | |
35 LRESULT CALLBACK SubUrlWndProc(HWND, UINT, WPARAM, LPARAM); | |
36 extern int vo_gamma_brightness; | |
37 extern int vo_gamma_saturation; | |
38 extern int vo_gamma_contrast; | |
39 extern int vo_gamma_hue; | |
40 extern int set_video_colors(sh_video_t *sh_video, char *item, int value); | |
41 extern int get_video_colors(sh_video_t *sh_video, char *item, int *value); | |
42 | |
43 guiInterface_t guiIntfStruct; | |
44 int addurl = 0; | |
45 | |
46 #ifdef USE_SUB | |
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 #endif | |
93 | |
94 int display_openfilewindow(gui_t *gui, int add) | |
95 { | |
96 OPENFILENAME fileopen; | |
97 int result = 0; | |
98 char filelist[MAXFILE]; | |
99 char filename[MAX_PATH]; | |
100 char directory[MAX_PATH]; | |
101 char *filespec = NULL; | |
102 char *filepart = NULL; | |
103 | |
104 memset(&fileopen, 0, sizeof(OPENFILENAME)); | |
105 memset(filelist, 0, sizeof(filelist)); | |
106 | |
107 fileopen.lStructSize = sizeof(OPENFILENAME); | |
108 fileopen.hwndOwner = gui->mainwindow; | |
109 fileopen.hInstance = GetModuleHandle(NULL); | |
110 fileopen.lpstrFilter = "All Files (*.*)\0*.*\0" | |
111 "Media Files (*.avi;*.asf;*.wmv;*.mpg;*.mpeg;*.m2v;*.mov;\ | |
112 *.rmvb;*.rm;*.ogm;*.mp3;*.wav;*.wma;*.ra;*.ogg)\0\ | |
113 *.avi;*.asf;*.wmv;*.mpg;*.mpeg;*.m2v;*.mov;\ | |
114 *.rmvb;*.rm;*.ogm;*.mp3;*.wav;*.wma;*.ra;*.ogg\0" | |
115 "Video Files (*.avi;*.mpg;*.mpeg;*.mov)\0*.avi;*.mpg;*.mpeg;*.mov\0" | |
116 "Avisynth Scripts (*.avs)\0*.avs\0" | |
117 "Audio Files (*.mp3;*.wav;*.ra)\0*.mp3;*.wav;*.ra\000"; | |
118 fileopen.nFilterIndex = 0; | |
119 fileopen.lpstrTitle = "Add file(s)..."; | |
120 fileopen.Flags = OFN_ALLOWMULTISELECT | OFN_FILEMUSTEXIST| OFN_LONGNAMES | OFN_EXPLORER| OFN_READONLY | OFN_HIDEREADONLY; | |
121 fileopen.lpstrFile = filelist; | |
122 fileopen.lpstrCustomFilter = NULL; | |
123 fileopen.nMaxFile = MAXFILE; | |
124 | |
125 if(GetOpenFileName(&fileopen)) | |
126 { | |
127 /* clear playlist */ | |
128 if(!add) gui->playlist->clear_playlist(gui->playlist); | |
129 | |
130 memcpy(directory, fileopen.lpstrFile, fileopen.nFileOffset - 1); | |
131 directory[fileopen.nFileOffset - 1] = 0; | |
132 | |
133 do | |
134 { | |
135 filespec = &fileopen.lpstrFile[fileopen.nFileOffset]; | |
136 filename[0] = 0; | |
137 strcat(filename, directory); | |
138 strcat(filename, "\\"); | |
139 strcat(filename, filespec); | |
140 | |
141 if (GetFileAttributes(filename) & FILE_ATTRIBUTE_DIRECTORY) | |
142 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] %s is a directory, skipping...\n", filename); | |
143 else | |
144 { | |
145 if (GetFullPathName(filename, MAX_PATH, filename, &filepart)) | |
146 { | |
147 if(!parse_filename(filename, playtree, mconfig, add? 0 : 1)) | |
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 #ifdef USE_SUB | |
160 void display_opensubtitlewindow(gui_t *gui) | |
161 { | |
162 OPENFILENAME subtitleopen; | |
163 char subtitlefile[MAX_PATH]; | |
164 | |
165 /* Safety check */ | |
166 if (guiIntfStruct.Playing == 0 || !guiIntfStruct.sh_video) return; | |
167 | |
168 memset(&subtitleopen, 0, sizeof(OPENFILENAME)); | |
169 memset(subtitlefile, 0, sizeof(subtitlefile)); | |
170 | |
171 subtitleopen.lStructSize = sizeof(OPENFILENAME); | |
172 subtitleopen.hwndOwner = gui->mainwindow; | |
173 subtitleopen.hInstance = GetModuleHandle(NULL); | |
174 subtitleopen.lpstrFilter = "All Files (*.*)\0*.*\0" | |
175 "Subtitle Files (*.srt;*.txt;*.vob)\0*.srt;*.txt;*.vob\0"; | |
176 subtitleopen.nFilterIndex = 0; | |
177 subtitleopen.lpstrTitle = "Add Subtitle..."; | |
178 subtitleopen.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_EXPLORER | OFN_READONLY | OFN_HIDEREADONLY; | |
179 subtitleopen.lpstrFile = subtitlefile; | |
180 subtitleopen.lpstrCustomFilter = NULL; | |
181 subtitleopen.nMaxFile = MAXFILE; | |
182 | |
183 if(GetOpenFileName(&subtitleopen)) | |
184 guiLoadSubtitle(subtitlefile); | |
185 } | |
186 #endif | |
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 if(add) addurl = 1; | |
378 HWND hWnd; | |
379 HINSTANCE hInstance = GetModuleHandle(NULL); | |
380 WNDCLASS wc; | |
381 int x, y; | |
382 if(FindWindow(NULL, "MPlayer - Open URL...")) return; | |
383 wc.style = CS_HREDRAW | CS_VREDRAW; | |
384 wc.lpfnWndProc = OpenUrlWndProc; | |
385 wc.cbClsExtra = 0; | |
386 wc.cbWndExtra = 0; | |
387 wc.hInstance = hInstance; | |
388 wc.hCursor = LoadCursor(NULL,IDC_ARROW); | |
389 wc.hIcon = gui->icon; | |
390 wc.hbrBackground = SOLID_GREY2; | |
391 wc.lpszClassName = "MPlayer - URL"; | |
392 wc.lpszMenuName = NULL; | |
393 RegisterClass(&wc); | |
394 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (320 / 2); | |
395 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (100 / 2); | |
396 hWnd = CreateWindow("MPlayer - URL", | |
397 "MPlayer - Open URL...", | |
398 WS_POPUPWINDOW | WS_CAPTION, | |
399 x, | |
400 y, | |
401 320, | |
402 100, | |
403 NULL, | |
404 NULL, | |
405 hInstance, | |
406 NULL); | |
407 SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD) gui); | |
408 ShowWindow(hWnd, SW_SHOW); | |
409 UpdateWindow(hWnd); | |
410 } | |
411 | |
412 static void create_playlistmenu(gui_t *gui) | |
413 { | |
414 gui->playlistmenu = CreatePopupMenu(); | |
415 AppendMenu(gui->playlistmenu, MF_STRING, ID_ADDFILE, "Add File..."); | |
416 AppendMenu(gui->playlistmenu, MF_STRING, ID_ADDURL, "Add Url..."); | |
417 AppendMenu(gui->playlistmenu, MF_SEPARATOR, 0, 0); | |
418 AppendMenu(gui->playlistmenu, MF_STRING, ID_REMOVE, "Remove Selected"); | |
419 AppendMenu(gui->playlistmenu, MF_STRING, ID_CLEAR, "Clear Playlist"); | |
420 AppendMenu(gui->playlistmenu, MF_SEPARATOR, 0, 0); | |
421 AppendMenu(gui->playlistmenu, MF_STRING, ID_CLOSE, "Close"); | |
422 } | |
423 | |
424 static void updatetracklist(HWND hwnd) | |
425 { | |
426 int i=0; | |
427 gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA); | |
428 HWND tracklist = GetDlgItem(hwnd, ID_TRACKLIST); | |
429 /* clear listbox */ | |
430 SendMessage(tracklist, LB_RESETCONTENT, 0, 0); | |
431 for (i=0; i < gui->playlist->trackcount; i++) | |
432 if (gui->playlist->tracks[i]->title) | |
433 SendMessage(tracklist, LB_ADDSTRING, 0, (LPARAM)gui->playlist->tracks[i]->title); | |
434 else | |
435 SendMessage(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 HWND tracklist = GetDlgItem(hwnd, ID_TRACKLIST); | |
521 int selected = 0; | |
522 int i; | |
523 for (i=0; i<pl->trackcount; i++) | |
524 if(0 < SendMessage(tracklist, LB_GETSEL, i, 0)) selected = i + 1; | |
525 switch (LOWORD(wParam)) | |
526 { | |
527 case ID_CLOSE: | |
528 DestroyWindow(hwnd); | |
529 return 0; | |
530 case ID_TRACKLIST: | |
531 if(HIWORD(wParam) == LBN_DBLCLK) | |
532 { | |
533 if(selected) pl->current = selected - 1; | |
534 mplGotoTheNext = 0; | |
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_PLAY: | |
551 { | |
552 if(selected) pl->current = selected - 1; | |
553 mplGotoTheNext = 0; | |
554 gui->startplay(gui); | |
555 break; | |
556 } | |
557 case ID_REMOVE: | |
558 if(selected) pl->remove_track(pl, selected); | |
559 break; | |
560 case ID_ADDFILE: | |
561 { | |
562 if(guiIntfStruct.StreamType == STREAMTYPE_DVD || | |
563 guiIntfStruct.StreamType == STREAMTYPE_DVDNAV) return 0; | |
564 display_openfilewindow(gui, 1); | |
565 break; | |
566 } | |
567 case ID_ADDURL: | |
568 { | |
569 if(guiIntfStruct.StreamType == STREAMTYPE_DVD || | |
570 guiIntfStruct.StreamType == STREAMTYPE_DVDNAV) return 0; | |
571 display_openurlwindow(gui, 1); | |
572 break; | |
573 } | |
574 case ID_CLEAR: | |
575 { | |
576 if(!gui->playlist->trackcount) return 0; | |
577 gui->playlist->clear_playlist(gui->playlist); | |
578 break; | |
579 } | |
580 case ID_PLAYLISTLOAD: | |
581 { | |
582 if(guiIntfStruct.StreamType == STREAMTYPE_DVD || | |
583 guiIntfStruct.StreamType == STREAMTYPE_DVDNAV) return 0; | |
584 display_loadplaylistwindow(gui); | |
585 break; | |
586 } | |
587 case ID_PLAYLISTSAVE: | |
588 { | |
589 /* no point saving an empty playlist */ | |
590 if(!gui->playlist->trackcount || | |
591 guiIntfStruct.StreamType == STREAMTYPE_DVD || | |
592 guiIntfStruct.StreamType == STREAMTYPE_DVDNAV) | |
593 return 0; | |
594 display_saveplaylistwindow(gui); | |
595 break; | |
596 } | |
597 } | |
598 updatetracklist(hwnd); | |
599 if(selected < 1) selected = 1; | |
600 else if(selected>pl->trackcount) selected = pl->trackcount; | |
601 SendMessage(tracklist, LB_SETCURSEL, selected - 1, 0); | |
602 return 0; | |
603 } | |
604 case WM_DROPFILES: | |
605 { | |
606 char file[MAX_PATH]; | |
607 int filecount = DragQueryFile((HDROP) wParam, -1, file, MAX_PATH); | |
608 int i; | |
609 for (i=0; i<filecount; i++) | |
610 { | |
611 DragQueryFile((HDROP) wParam, i, file, MAX_PATH); | |
612 if(!parse_filename(file, playtree, mconfig, 0)) | |
613 pl->add_track(pl, file, NULL, NULL, 0); | |
614 } | |
615 DragFinish((HDROP) wParam); | |
616 updatetracklist(hwnd); | |
617 } | |
618 break; | |
619 case WM_DESTROY: | |
620 PostQuitMessage(0); | |
621 return 0; | |
622 } | |
623 return DefWindowProc(hwnd, iMsg, wParam, lParam); | |
624 } | |
625 | |
626 void update_playlistwindow(void) | |
627 { | |
628 HWND hWnd = FindWindow(NULL, "MPlayer Playlist"); | |
629 if (hWnd) updatetracklist(hWnd); | |
630 } | |
631 | |
632 void display_playlistwindow(gui_t *gui) | |
633 { | |
634 HWND hWnd = FindWindow(NULL, "MPlayer Playlist"); | |
635 if (hWnd) | |
636 { | |
637 SendMessage(hWnd, WM_CLOSE, 0, 0); | |
638 return; | |
639 } | |
640 | |
641 HINSTANCE hInstance = GetModuleHandle(NULL); | |
642 WNDCLASS wc; | |
643 int x, y; | |
644 | |
645 wc.style = CS_HREDRAW | CS_VREDRAW; | |
646 wc.lpfnWndProc = PlayListWndProc; | |
647 wc.cbClsExtra = 0; | |
648 wc.cbWndExtra = 0; | |
649 wc.hInstance = hInstance; | |
650 wc.hCursor = LoadCursor(NULL,IDC_ARROW); | |
651 wc.hIcon = gui->icon; | |
652 wc.hbrBackground = SOLID_GREY2; | |
653 wc.lpszClassName = "MPlayer - Playlist"; | |
654 wc.lpszMenuName = NULL; | |
655 RegisterClass(&wc); | |
656 create_playlistmenu(gui); | |
657 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (400 / 2); /* Erik: center popup window on screen */ | |
658 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (254 / 2); | |
659 hWnd = CreateWindow("MPlayer - Playlist", | |
660 "MPlayer Playlist", | |
661 WS_POPUPWINDOW | WS_CAPTION | WS_MINIMIZEBOX, | |
662 x, | |
663 y, | |
664 400, | |
665 254, | |
666 NULL, | |
667 NULL, | |
668 hInstance, | |
669 NULL); | |
670 SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD)gui); | |
671 updatetracklist(hWnd); | |
672 DragAcceptFiles(hWnd,TRUE); | |
673 ShowWindow(hWnd, SW_SHOW); | |
674 UpdateWindow(hWnd); | |
675 } | |
676 | |
677 static LRESULT CALLBACK SkinBrowserWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) | |
678 { | |
679 static HWND listbox; | |
680 static char skinspath[MAX_PATH]; | |
681 gui_t* gui = (gui_t*) GetWindowLongPtr(hwnd, GWLP_USERDATA); | |
682 switch (iMsg) | |
683 { | |
684 case WM_CREATE: | |
685 { | |
686 listbox = CreateWindow("listbox", NULL, | |
687 WS_CHILD | WS_VISIBLE | LBS_NOTIFY | LBS_NOINTEGRALHEIGHT | | |
688 LBS_DISABLENOSCROLL | WS_VSCROLL | WS_TABSTOP, | |
689 4, 5, 166, 60, hwnd, | |
690 (HMENU) ID_DIR, | |
691 ((LPCREATESTRUCT) lParam) -> hInstance, | |
692 NULL); | |
693 SendMessage(listbox, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
694 | |
695 /* This opens the skins directory, lists the directory names, and adds them to the listbox */ | |
696 sprintf(skinspath, "%s/*.", get_path("skins")); | |
697 | |
698 HANDLE skinHandle = INVALID_HANDLE_VALUE; | |
699 WIN32_FIND_DATA finddata; | |
700 | |
701 skinHandle = FindFirstFile(skinspath, &finddata); | |
702 if (skinHandle != INVALID_HANDLE_VALUE) | |
703 { | |
704 do | |
705 { | |
706 if (finddata.cFileName[0] == '.') continue; | |
707 /* populate the listbox */ | |
708 capitalize(finddata.cFileName); | |
709 SendDlgItemMessage(hwnd, ID_DIR, LB_ADDSTRING, 0, (LPARAM) finddata.cFileName); | |
710 } while (FindNextFile(skinHandle, &finddata)); | |
711 FindClose(skinHandle); | |
712 } | |
713 else | |
714 mp_msg(MSGT_GPLAYER, MSGL_FATAL, "Error opening %s\n", get_path("skins")); | |
715 break; | |
716 } | |
717 case WM_COMMAND: | |
718 { | |
719 if ((HWND) lParam == listbox) | |
720 { | |
721 if(HIWORD(wParam) == LBN_DBLCLK) | |
722 { | |
723 int index = SendMessage(listbox, LB_GETCURSEL, 0, 0); | |
724 int len = SendMessage(listbox, LB_GETTEXTLEN, index, 0); | |
725 if (len) | |
726 { | |
18954
42d4e99a075e
small fix to properly display skins when switching skins during playback.
vayne
parents:
18914
diff
changeset
|
727 if (guiIntfStruct.Playing) guiGetEvent(guiCEvent, (void *) guiSetStop); |
18914 | 728 if (skinName) free(skinName); |
729 skinName = (char *) malloc(len+1); | |
730 SendMessage(listbox, LB_GETTEXT, (WPARAM) index, (LPARAM) skinName); | |
731 /* fill out the full pathname to the skin */ | |
732 strcpy(skinspath, get_path("skins")); | |
733 strcat(skinspath, "\\"); | |
734 strcat(skinspath, skinName); | |
735 ShowWindow(hwnd, SW_HIDE); | |
736 Shell_NotifyIcon(NIM_DELETE, &nid); | |
737 destroy_window(gui); | |
738 create_window(gui, skinspath); | |
739 create_subwindow(gui, skinspath); | |
740 SendMessage(hwnd, WM_CLOSE, 0, 0); /* Avoid crashing when switching skin */ | |
741 } | |
742 } | |
743 } | |
744 } | |
745 return 0; | |
746 case WM_DESTROY: | |
747 PostQuitMessage(0); | |
748 return 0; | |
749 } | |
750 return DefWindowProc(hwnd, iMsg, wParam, lParam); | |
751 } | |
752 | |
753 void display_skinbrowser(gui_t* gui) | |
754 { | |
755 HWND hWnd = FindWindow(NULL, "Skin Browser"); | |
756 if (hWnd) | |
757 { | |
758 SendMessage(hWnd, WM_CLOSE, 0, 0); | |
759 return; | |
760 } | |
761 | |
762 HINSTANCE hInstance = GetModuleHandle(NULL); | |
763 WNDCLASS wc; | |
764 int x, y; | |
765 | |
766 wc.style = CS_HREDRAW | CS_VREDRAW; | |
767 wc.lpfnWndProc = SkinBrowserWndProc; | |
768 wc.cbClsExtra = 0; | |
769 wc.cbWndExtra = 0; | |
770 wc.hInstance = hInstance; | |
771 wc.hCursor = LoadCursor(NULL, IDC_ARROW); | |
772 wc.hIcon = gui->icon; | |
773 wc.hbrBackground = SOLID_GREY2; | |
774 wc.lpszClassName = "Skin Browser"; | |
775 wc.lpszMenuName = NULL; | |
776 RegisterClass(&wc); | |
777 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (180 / 2); | |
778 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (102 / 2); | |
779 hWnd = CreateWindow("Skin Browser", | |
780 "Skin Browser", | |
781 WS_POPUPWINDOW |WS_CAPTION, | |
782 x, | |
783 y, | |
784 180, | |
785 102, | |
786 NULL, | |
787 NULL, | |
788 hInstance, | |
789 NULL); | |
790 SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD) gui); | |
791 ShowWindow(hWnd, SW_SHOW); | |
792 UpdateWindow(hWnd); | |
793 } | |
794 | |
795 #ifdef USE_DVDREAD | |
796 static LRESULT CALLBACK TitleChapterWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) | |
797 { | |
798 static HWND title; | |
799 static HWND chapter; | |
800 HWND wdg; | |
801 int i=0, j=0; | |
802 char titles[MAX_PATH] = ""; | |
803 char chapters[MAX_PATH] = ""; | |
804 switch (iMsg) | |
805 { | |
806 case WM_CREATE: | |
807 wdg = CreateWindow("button", "Ok", | |
808 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, | |
809 4, 43, 80, 25, hwnd, | |
810 (HMENU) ID_OK, | |
811 ((LPCREATESTRUCT) lParam) -> hInstance, | |
812 NULL); | |
813 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
814 | |
815 wdg = CreateWindow("button", "Cancel", | |
816 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, | |
817 90, 43, 80, 25, hwnd, | |
818 (HMENU) ID_CANCEL, | |
819 ((LPCREATESTRUCT) lParam) -> hInstance, | |
820 NULL); | |
821 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
822 | |
823 title = CreateWindow("combobox", NULL, | |
824 CBS_DROPDOWNLIST | CB_SHOWDROPDOWN | CBS_NOINTEGRALHEIGHT | CBS_HASSTRINGS | | |
825 WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, | |
826 4, 10, 80, 160, hwnd, | |
827 (HMENU) ID_TITLESEL, | |
828 ((LPCREATESTRUCT) lParam) -> hInstance, | |
829 NULL); | |
830 | |
831 SendMessage(title, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
832 | |
833 chapter = CreateWindow("combobox", NULL, | |
834 CBS_DROPDOWNLIST | CB_SHOWDROPDOWN | CBS_NOINTEGRALHEIGHT | CBS_HASSTRINGS | | |
835 WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, | |
836 90, 10, 80, 160, hwnd, | |
837 (HMENU) ID_CHAPTERSEL, | |
838 ((LPCREATESTRUCT) lParam) -> hInstance, | |
839 NULL); | |
840 SendMessage(chapter, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
841 | |
842 for (i=0; i<guiIntfStruct.DVD.titles; i++) | |
843 { | |
844 /* we have to reverse the order here because of the way CB_INSERTSTRING adds items */ | |
845 sprintf(&titles[i], "%d", guiIntfStruct.DVD.titles - i); | |
846 SendDlgItemMessage(hwnd, ID_TITLESEL, CB_INSERTSTRING, 0, (LPARAM) &titles[i]); | |
847 } | |
848 SendDlgItemMessage(hwnd, ID_TITLESEL, CB_SETCURSEL, dvd_title, 0); | |
849 | |
850 for (j=0; j<guiIntfStruct.DVD.chapters; j++) | |
851 { | |
852 sprintf(&chapters[j], "%d", guiIntfStruct.DVD.chapters - j); | |
853 SendDlgItemMessage(hwnd, ID_CHAPTERSEL, CB_INSERTSTRING, 0, (LPARAM) &chapters[j]); | |
854 } | |
855 SendDlgItemMessage(hwnd, ID_CHAPTERSEL, CB_SETCURSEL, dvd_chapter, 0); | |
856 | |
857 break; | |
858 case WM_COMMAND: | |
859 { | |
860 switch (LOWORD(wParam)) | |
861 { | |
862 case ID_CANCEL: | |
863 DestroyWindow(hwnd); | |
864 return 0; | |
865 case ID_OK: | |
866 { | |
867 guiIntfStruct.DVD.current_title = SendMessage(title, CB_GETCURSEL, 0, 0) + 1; | |
868 guiIntfStruct.DVD.current_chapter = SendMessage(chapter, CB_GETCURSEL, 0, 0) + 1; | |
869 | |
870 if((guiIntfStruct.DVD.current_title != 0 || guiIntfStruct.DVD.current_chapter != 0)) | |
871 { | |
872 mplGotoTheNext = 0; | |
873 guiGetEvent(guiCEvent, (void *) guiSetStop); | |
874 guiGetEvent(guiCEvent, (void *) guiSetPlay); | |
875 DestroyWindow(hwnd); | |
876 } | |
877 } | |
878 break; | |
879 } | |
880 } | |
881 return 0; | |
882 case WM_DESTROY: | |
883 PostQuitMessage (0); | |
884 return 0; | |
885 } | |
886 return DefWindowProc(hwnd, iMsg, wParam, lParam); | |
887 } | |
888 | |
889 void display_chapterselwindow(gui_t *gui) | |
890 { | |
891 HWND hWnd; | |
892 HINSTANCE hInstance = GetModuleHandle(NULL); | |
893 WNDCLASS wc; | |
894 int x, y; | |
895 | |
896 if (guiIntfStruct.StreamType != STREAMTYPE_DVD) return; | |
897 if (FindWindow(NULL, "Select Title/Chapter...")) return; | |
898 | |
899 wc.style = CS_HREDRAW | CS_VREDRAW; | |
900 wc.lpfnWndProc = TitleChapterWndProc; | |
901 wc.cbClsExtra = 0; | |
902 wc.cbWndExtra = 0; | |
903 wc.hInstance = hInstance; | |
904 wc.hCursor = LoadCursor(NULL,IDC_ARROW); | |
905 wc.hIcon = gui->icon; | |
906 wc.hbrBackground = SOLID_GREY2; | |
907 wc.lpszClassName = "Select Title/Chapter..."; | |
908 wc.lpszMenuName = NULL; | |
909 RegisterClass(&wc); | |
910 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (180 / 2); | |
911 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (100 / 2); | |
912 hWnd = CreateWindow("Select Title/Chapter...", | |
913 "Select Title/Chapter...", | |
914 WS_POPUPWINDOW | WS_CAPTION, | |
915 x, | |
916 y, | |
917 180, | |
918 100, | |
919 NULL, | |
920 NULL, | |
921 hInstance, | |
922 NULL); | |
923 SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD) gui); | |
924 ShowWindow(hWnd, SW_SHOW); | |
925 UpdateWindow(hWnd); | |
926 } | |
927 #endif | |
928 | |
929 static LRESULT CALLBACK EqWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) | |
930 { | |
931 HWND btn, label, eq0, eq1, eq2, eq3; | |
932 | |
933 switch (iMsg) | |
934 { | |
935 case WM_CREATE: | |
936 { | |
937 btn = CreateWindow("button", "Reset", | |
938 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, | |
939 157, 143, 80, 25, hwnd, | |
940 (HMENU) ID_DEFAULTS, | |
941 ((LPCREATESTRUCT) lParam) -> hInstance, | |
942 NULL); | |
943 SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
944 | |
945 btn = CreateWindow("button", "Close", | |
946 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, | |
947 243, 143, 80, 25, hwnd, | |
948 (HMENU) ID_CLOSE, | |
949 ((LPCREATESTRUCT) lParam) -> hInstance, | |
950 NULL); | |
951 SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
952 | |
953 label = CreateWindow("static", "Brightness", | |
954 WS_CHILD | WS_VISIBLE, | |
955 12, 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", "Contrast", | |
962 WS_CHILD | WS_VISIBLE, | |
963 99, 122, 70, 15, hwnd, | |
964 NULL, | |
965 ((LPCREATESTRUCT) lParam) -> hInstance, | |
966 NULL); | |
967 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
968 | |
969 label = CreateWindow("static", "Hue", | |
970 WS_CHILD | WS_VISIBLE, | |
971 191, 122, 70, 15, hwnd, | |
972 NULL, | |
973 ((LPCREATESTRUCT) lParam) -> hInstance, NULL); | |
974 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
975 | |
976 label = CreateWindow("static", "Saturation", | |
977 WS_CHILD | WS_VISIBLE, | |
978 260, 122, 70, 15, hwnd, | |
979 NULL, | |
980 ((LPCREATESTRUCT) lParam) -> hInstance, | |
981 NULL); | |
982 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
983 | |
984 eq0 = CreateWindow(TRACKBAR_CLASS, "brightness", | |
985 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED | | |
986 TBS_VERT | TBS_NOTICKS, | |
987 30, 0, 20, 120, hwnd, | |
988 (HMENU) ID_EQ0, | |
989 ((LPCREATESTRUCT) lParam) -> hInstance, | |
990 NULL); | |
991 SendDlgItemMessage(hwnd, ID_EQ0, TBM_SETRANGE, 1, MAKELONG(0, 200)); | |
992 | |
993 eq1 = CreateWindow(TRACKBAR_CLASS, "contrast", | |
994 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED | | |
995 TBS_VERT | TBS_NOTICKS, | |
996 112, 0, 20, 120, hwnd, | |
997 (HMENU) ID_EQ1, | |
998 ((LPCREATESTRUCT) lParam) -> hInstance, | |
999 NULL); | |
1000 SendDlgItemMessage(hwnd, ID_EQ1, TBM_SETRANGE, 1, MAKELONG(0, 200)); | |
1001 | |
1002 eq2 = CreateWindow(TRACKBAR_CLASS, "hue", | |
1003 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED | | |
1004 TBS_VERT | TBS_NOTICKS, | |
1005 194, 0, 20, 120, hwnd, | |
1006 (HMENU) ID_EQ2, | |
1007 ((LPCREATESTRUCT) lParam) -> hInstance, | |
1008 NULL); | |
1009 SendDlgItemMessage(hwnd, ID_EQ2, TBM_SETRANGE, 1, MAKELONG(0, 200)); | |
1010 | |
1011 eq3 = CreateWindow(TRACKBAR_CLASS, "saturation", | |
1012 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED | | |
1013 TBS_VERT | TBS_NOTICKS, | |
1014 276, 0, 20, 120, hwnd, | |
1015 (HMENU) ID_EQ3, | |
1016 ((LPCREATESTRUCT) lParam) -> hInstance, NULL); | |
1017 SendDlgItemMessage(hwnd, ID_EQ3, TBM_SETRANGE, 1, MAKELONG(0, 200)); | |
1018 | |
1019 if(guiIntfStruct.sh_video && guiIntfStruct.Playing) | |
1020 { | |
1021 EnableWindow(eq0, 1); EnableWindow(eq1, 1); EnableWindow(eq2, 1); EnableWindow(eq3, 1); | |
1022 get_video_colors(guiIntfStruct.sh_video, "brightness", &vo_gamma_brightness); | |
1023 get_video_colors(guiIntfStruct.sh_video, "contrast", &vo_gamma_contrast); | |
1024 get_video_colors(guiIntfStruct.sh_video, "hue", &vo_gamma_hue); | |
1025 get_video_colors(guiIntfStruct.sh_video, "saturation", &vo_gamma_saturation); | |
1026 } | |
1027 SendDlgItemMessage(hwnd, ID_EQ0, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_brightness); | |
1028 SendDlgItemMessage(hwnd, ID_EQ1, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_contrast); | |
1029 SendDlgItemMessage(hwnd, ID_EQ2, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_hue); | |
1030 SendDlgItemMessage(hwnd, ID_EQ3, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_saturation); | |
1031 break; | |
1032 } | |
1033 case WM_VSCROLL: | |
1034 { | |
1035 switch (LOWORD(wParam)) | |
1036 { | |
1037 case TB_THUMBTRACK: | |
1038 if(guiIntfStruct.sh_video && guiIntfStruct.Playing) | |
1039 { | |
1040 vo_gamma_brightness = 100 - SendDlgItemMessage(hwnd, ID_EQ0, TBM_GETPOS, 0, 0); | |
1041 set_video_colors(guiIntfStruct.sh_video, "brightness", vo_gamma_brightness); | |
1042 | |
1043 vo_gamma_contrast = 100 - SendDlgItemMessage(hwnd, ID_EQ1, TBM_GETPOS, 0, 0); | |
1044 set_video_colors(guiIntfStruct.sh_video, "contrast", vo_gamma_contrast); | |
1045 | |
1046 vo_gamma_hue = 100 - SendDlgItemMessage(hwnd, ID_EQ2, TBM_GETPOS, 0, 0); | |
1047 set_video_colors(guiIntfStruct.sh_video, "hue", vo_gamma_hue); | |
1048 | |
1049 vo_gamma_saturation = 100 - SendDlgItemMessage(hwnd, ID_EQ3, TBM_GETPOS, 0, 0); | |
1050 set_video_colors(guiIntfStruct.sh_video, "saturation", vo_gamma_saturation); | |
1051 } | |
1052 else | |
1053 { | |
1054 EnableWindow(GetDlgItem(hwnd, ID_EQ0), 0); | |
1055 EnableWindow(GetDlgItem(hwnd, ID_EQ1), 0); | |
1056 EnableWindow(GetDlgItem(hwnd, ID_EQ2), 0); | |
1057 EnableWindow(GetDlgItem(hwnd, ID_EQ3), 0); | |
1058 } | |
1059 break; | |
1060 } | |
1061 } | |
1062 case WM_CTLCOLORDLG: | |
1063 case WM_CTLCOLORSTATIC: | |
1064 { | |
1065 HDC hdc = (HDC)wParam; | |
1066 SetBkMode(hdc, TRANSPARENT); | |
1067 return (INT_PTR)SOLID_GREY2; | |
1068 } | |
1069 break; | |
1070 case WM_COMMAND: | |
1071 { | |
1072 switch (LOWORD(wParam)) | |
1073 { | |
1074 case ID_CLOSE: | |
1075 DestroyWindow(hwnd); | |
1076 return 0; | |
1077 case ID_DEFAULTS: | |
1078 if(guiIntfStruct.sh_video && guiIntfStruct.Playing) | |
1079 { | |
1080 vo_gamma_brightness=0; | |
1081 SendDlgItemMessage(hwnd, ID_EQ0, TBM_SETPOS, 1, (LPARAM)100); | |
1082 set_video_colors(guiIntfStruct.sh_video, "brightness", vo_gamma_brightness); | |
1083 | |
1084 vo_gamma_contrast=0; | |
1085 SendDlgItemMessage(hwnd, ID_EQ1, TBM_SETPOS, 1, (LPARAM)100); | |
1086 set_video_colors(guiIntfStruct.sh_video, "contrast", vo_gamma_contrast); | |
1087 | |
1088 vo_gamma_hue=0; | |
1089 SendDlgItemMessage(hwnd, ID_EQ2, TBM_SETPOS, 1, (LPARAM)100); | |
1090 set_video_colors(guiIntfStruct.sh_video, "hue", vo_gamma_hue); | |
1091 | |
1092 vo_gamma_saturation=0; | |
1093 SendDlgItemMessage(hwnd, ID_EQ3, TBM_SETPOS, 1, (LPARAM)100); | |
1094 set_video_colors(guiIntfStruct.sh_video, "saturation", vo_gamma_saturation); | |
1095 } | |
1096 break; | |
1097 } | |
1098 } | |
1099 return 0; | |
1100 case WM_DESTROY: | |
1101 PostQuitMessage (0); | |
1102 return 0; | |
1103 } | |
1104 return DefWindowProc(hwnd, iMsg, wParam, lParam); | |
1105 } | |
1106 | |
1107 void display_eqwindow(gui_t *gui) | |
1108 { | |
1109 if(!guiIntfStruct.sh_video) return; | |
1110 | |
1111 HWND hWnd; | |
1112 HINSTANCE hInstance = GetModuleHandle(NULL); | |
1113 WNDCLASS wc; | |
1114 int x, y; | |
1115 if(FindWindow(NULL, "MPlayer - Equalizer")) return; | |
1116 wc.style = CS_HREDRAW | CS_VREDRAW; | |
1117 wc.lpfnWndProc = EqWndProc; | |
1118 wc.cbClsExtra = 0; | |
1119 wc.cbWndExtra = 0; | |
1120 wc.hInstance = hInstance; | |
1121 wc.hCursor = LoadCursor(NULL,IDC_ARROW); | |
1122 wc.hIcon = gui->icon; | |
1123 wc.hbrBackground = SOLID_GREY2; | |
1124 wc.lpszClassName = "MPlayer - Equalizer"; | |
1125 wc.lpszMenuName = NULL; | |
1126 RegisterClass(&wc); | |
1127 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (332 / 2); | |
1128 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (200 / 2); | |
1129 hWnd = CreateWindow("MPlayer - Equalizer", | |
1130 "MPlayer - Equalizer", | |
1131 WS_POPUPWINDOW | WS_CAPTION, | |
1132 x, | |
1133 y, | |
1134 332, | |
1135 200, | |
1136 NULL, | |
1137 NULL, | |
1138 hInstance, | |
1139 NULL); | |
1140 SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD) gui); | |
1141 ShowWindow(hWnd, SW_SHOW); | |
1142 UpdateWindow(hWnd); | |
1143 } |