Mercurial > mplayer.hg
annotate Gui/win32/dialogs.c @ 19894:bec5c0d5fb17
in the previous commit I forgot to set s->end_pos=0
author | nicodvb |
---|---|
date | Mon, 18 Sep 2006 21:26:26 +0000 |
parents | e701a6eed5cb |
children | aa7bb6ae26a7 |
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> | |
19271
64d82a45a05d
introduce new 'stream' directory for all stream layer related components and split them from libmpdemux
ben
parents:
18954
diff
changeset
|
27 #include <stream/stream.h> |
18914 | 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 HWND hWnd; | |
378 HINSTANCE hInstance = GetModuleHandle(NULL); | |
379 WNDCLASS wc; | |
380 int x, y; | |
19718 | 381 |
382 if(add) addurl = 1; | |
18914 | 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 HWND tracklist = GetDlgItem(hwnd, ID_TRACKLIST); | |
430 /* clear listbox */ | |
431 SendMessage(tracklist, LB_RESETCONTENT, 0, 0); | |
432 for (i=0; i < gui->playlist->trackcount; i++) | |
433 if (gui->playlist->tracks[i]->title) | |
434 SendMessage(tracklist, LB_ADDSTRING, 0, (LPARAM)gui->playlist->tracks[i]->title); | |
435 else | |
436 SendMessage(tracklist, LB_ADDSTRING, 0, (LPARAM)gui->playlist->tracks[i]->filename); | |
437 } | |
438 | |
439 static LRESULT CALLBACK PlayListWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) | |
440 { | |
441 HWND wdg; | |
442 POINT cursor; | |
443 gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA); | |
444 playlist_t *pl = gui ? gui->playlist : NULL; | |
445 switch (iMsg) | |
446 { | |
447 case WM_CREATE: | |
448 { | |
449 wdg = CreateWindow("button", "Play", | |
450 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, | |
451 4, 10, 80, 25, hwnd, | |
452 (HMENU) ID_PLAY, | |
453 ((LPCREATESTRUCT) lParam) -> hInstance, | |
454 NULL); | |
455 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
456 | |
457 wdg = CreateWindow ("button", "Up", | |
458 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, | |
459 4, 37, 80, 25, hwnd, | |
460 (HMENU) ID_UP, | |
461 ((LPCREATESTRUCT) lParam) -> hInstance, | |
462 NULL); | |
463 SendMessage(wdg, WM_SETFONT,(WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
464 | |
465 wdg = CreateWindow ("button", "Down", | |
466 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, | |
467 4, 64, 80, 25, hwnd, | |
468 (HMENU) ID_DOWN, | |
469 ((LPCREATESTRUCT) lParam) -> hInstance, | |
470 NULL); | |
471 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0); | |
472 | |
473 wdg = CreateWindow ("button", "Remove", | |
474 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, | |
475 4, 91, 80, 25, hwnd, | |
476 (HMENU) ID_REMOVE, | |
477 ((LPCREATESTRUCT) lParam) -> hInstance, | |
478 NULL); | |
479 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0); | |
480 | |
481 wdg = CreateWindow ("button", "Load", | |
482 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, | |
483 4, 118, 80, 25, hwnd, | |
484 (HMENU) ID_PLAYLISTLOAD, | |
485 ((LPCREATESTRUCT) lParam) -> hInstance, | |
486 NULL); | |
487 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0); | |
488 | |
489 wdg = CreateWindow ("button", "Save", | |
490 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, | |
491 4, 145, 80, 25, hwnd, | |
492 (HMENU) ID_PLAYLISTSAVE, | |
493 ((LPCREATESTRUCT) lParam) -> hInstance, | |
494 NULL); | |
495 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0); | |
496 | |
497 wdg = CreateWindow ("button", "Close", | |
498 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, | |
499 4, 193, 80, 25, hwnd, | |
500 (HMENU) ID_CLOSE, | |
501 ((LPCREATESTRUCT) lParam) -> hInstance, | |
502 NULL); | |
503 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0); | |
504 | |
505 wdg = CreateWindow ("listbox", "tracklist", WS_CHILD | WS_VISIBLE | LBS_NOTIFY | WS_VSCROLL | | |
506 WS_HSCROLL | LBS_DISABLENOSCROLL, 92, 10, 300, 208, hwnd, (HMENU) ID_TRACKLIST, | |
507 ((LPCREATESTRUCT) lParam) -> hInstance, NULL); | |
508 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
509 SendMessage(wdg, LB_SETHORIZONTALEXTENT, MAX_PATH*4, 0); | |
510 break; | |
511 } | |
512 case WM_CONTEXTMENU: | |
513 { | |
514 GetCursorPos(&cursor); | |
515 SetForegroundWindow(hwnd); | |
516 TrackPopupMenu(gui->playlistmenu, 0, cursor.x, cursor.y, 0, hwnd, NULL); | |
517 break; | |
518 } | |
519 case WM_COMMAND: | |
520 { | |
521 HWND tracklist = GetDlgItem(hwnd, ID_TRACKLIST); | |
522 int selected = 0; | |
523 int i; | |
524 for (i=0; i<pl->trackcount; i++) | |
525 if(0 < SendMessage(tracklist, LB_GETSEL, i, 0)) selected = i + 1; | |
526 switch (LOWORD(wParam)) | |
527 { | |
528 case ID_CLOSE: | |
529 DestroyWindow(hwnd); | |
530 return 0; | |
531 case ID_TRACKLIST: | |
532 if(HIWORD(wParam) == LBN_DBLCLK) | |
533 { | |
534 if(selected) pl->current = selected - 1; | |
535 mplGotoTheNext = 0; | |
536 gui->startplay(gui); | |
537 } | |
538 return 0; | |
539 case ID_UP: | |
540 { | |
541 if(selected) pl->moveup_track(pl, selected); | |
542 selected--; | |
543 break; | |
544 } | |
545 case ID_DOWN: | |
546 { | |
547 if(selected) pl->movedown_track(pl, selected); | |
548 selected++; | |
549 break; | |
550 } | |
551 case ID_PLAY: | |
552 { | |
553 if(selected) pl->current = selected - 1; | |
554 mplGotoTheNext = 0; | |
555 gui->startplay(gui); | |
556 break; | |
557 } | |
558 case ID_REMOVE: | |
559 if(selected) pl->remove_track(pl, selected); | |
560 break; | |
561 case ID_ADDFILE: | |
562 { | |
563 if(guiIntfStruct.StreamType == STREAMTYPE_DVD || | |
564 guiIntfStruct.StreamType == STREAMTYPE_DVDNAV) return 0; | |
565 display_openfilewindow(gui, 1); | |
566 break; | |
567 } | |
568 case ID_ADDURL: | |
569 { | |
570 if(guiIntfStruct.StreamType == STREAMTYPE_DVD || | |
571 guiIntfStruct.StreamType == STREAMTYPE_DVDNAV) return 0; | |
572 display_openurlwindow(gui, 1); | |
573 break; | |
574 } | |
575 case ID_CLEAR: | |
576 { | |
577 if(!gui->playlist->trackcount) return 0; | |
578 gui->playlist->clear_playlist(gui->playlist); | |
579 break; | |
580 } | |
581 case ID_PLAYLISTLOAD: | |
582 { | |
583 if(guiIntfStruct.StreamType == STREAMTYPE_DVD || | |
584 guiIntfStruct.StreamType == STREAMTYPE_DVDNAV) return 0; | |
585 display_loadplaylistwindow(gui); | |
586 break; | |
587 } | |
588 case ID_PLAYLISTSAVE: | |
589 { | |
590 /* no point saving an empty playlist */ | |
591 if(!gui->playlist->trackcount || | |
592 guiIntfStruct.StreamType == STREAMTYPE_DVD || | |
593 guiIntfStruct.StreamType == STREAMTYPE_DVDNAV) | |
594 return 0; | |
595 display_saveplaylistwindow(gui); | |
596 break; | |
597 } | |
598 } | |
599 updatetracklist(hwnd); | |
600 if(selected < 1) selected = 1; | |
601 else if(selected>pl->trackcount) selected = pl->trackcount; | |
602 SendMessage(tracklist, LB_SETCURSEL, selected - 1, 0); | |
603 return 0; | |
604 } | |
605 case WM_DROPFILES: | |
606 { | |
607 char file[MAX_PATH]; | |
608 int filecount = DragQueryFile((HDROP) wParam, -1, file, MAX_PATH); | |
609 int i; | |
610 for (i=0; i<filecount; i++) | |
611 { | |
612 DragQueryFile((HDROP) wParam, i, file, MAX_PATH); | |
613 if(!parse_filename(file, playtree, mconfig, 0)) | |
614 pl->add_track(pl, file, NULL, NULL, 0); | |
615 } | |
616 DragFinish((HDROP) wParam); | |
617 updatetracklist(hwnd); | |
618 } | |
619 break; | |
620 case WM_DESTROY: | |
621 PostQuitMessage(0); | |
622 return 0; | |
623 } | |
624 return DefWindowProc(hwnd, iMsg, wParam, lParam); | |
625 } | |
626 | |
627 void update_playlistwindow(void) | |
628 { | |
629 HWND hWnd = FindWindow(NULL, "MPlayer Playlist"); | |
630 if (hWnd) updatetracklist(hWnd); | |
631 } | |
632 | |
633 void display_playlistwindow(gui_t *gui) | |
634 { | |
635 HWND hWnd = FindWindow(NULL, "MPlayer Playlist"); | |
19718 | 636 HINSTANCE hInstance = GetModuleHandle(NULL); |
637 WNDCLASS wc; | |
638 int x, y; | |
639 | |
18914 | 640 if (hWnd) |
641 { | |
642 SendMessage(hWnd, WM_CLOSE, 0, 0); | |
643 return; | |
644 } | |
645 | |
646 wc.style = CS_HREDRAW | CS_VREDRAW; | |
647 wc.lpfnWndProc = PlayListWndProc; | |
648 wc.cbClsExtra = 0; | |
649 wc.cbWndExtra = 0; | |
650 wc.hInstance = hInstance; | |
651 wc.hCursor = LoadCursor(NULL,IDC_ARROW); | |
652 wc.hIcon = gui->icon; | |
653 wc.hbrBackground = SOLID_GREY2; | |
654 wc.lpszClassName = "MPlayer - Playlist"; | |
655 wc.lpszMenuName = NULL; | |
656 RegisterClass(&wc); | |
657 create_playlistmenu(gui); | |
658 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (400 / 2); /* Erik: center popup window on screen */ | |
659 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (254 / 2); | |
660 hWnd = CreateWindow("MPlayer - Playlist", | |
661 "MPlayer Playlist", | |
662 WS_POPUPWINDOW | WS_CAPTION | WS_MINIMIZEBOX, | |
663 x, | |
664 y, | |
665 400, | |
666 254, | |
667 NULL, | |
668 NULL, | |
669 hInstance, | |
670 NULL); | |
671 SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD)gui); | |
672 updatetracklist(hWnd); | |
673 DragAcceptFiles(hWnd,TRUE); | |
674 ShowWindow(hWnd, SW_SHOW); | |
675 UpdateWindow(hWnd); | |
676 } | |
677 | |
678 static LRESULT CALLBACK SkinBrowserWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) | |
679 { | |
680 static HWND listbox; | |
681 static char skinspath[MAX_PATH]; | |
682 gui_t* gui = (gui_t*) GetWindowLongPtr(hwnd, GWLP_USERDATA); | |
683 switch (iMsg) | |
684 { | |
685 case WM_CREATE: | |
686 { | |
19718 | 687 HANDLE skinHandle = INVALID_HANDLE_VALUE; |
688 WIN32_FIND_DATA finddata; | |
689 | |
18914 | 690 listbox = CreateWindow("listbox", NULL, |
691 WS_CHILD | WS_VISIBLE | LBS_NOTIFY | LBS_NOINTEGRALHEIGHT | | |
692 LBS_DISABLENOSCROLL | WS_VSCROLL | WS_TABSTOP, | |
693 4, 5, 166, 60, hwnd, | |
694 (HMENU) ID_DIR, | |
695 ((LPCREATESTRUCT) lParam) -> hInstance, | |
696 NULL); | |
697 SendMessage(listbox, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
698 | |
699 /* This opens the skins directory, lists the directory names, and adds them to the listbox */ | |
700 sprintf(skinspath, "%s/*.", get_path("skins")); | |
701 | |
702 skinHandle = FindFirstFile(skinspath, &finddata); | |
703 if (skinHandle != INVALID_HANDLE_VALUE) | |
704 { | |
705 do | |
706 { | |
707 if (finddata.cFileName[0] == '.') continue; | |
708 /* populate the listbox */ | |
709 capitalize(finddata.cFileName); | |
710 SendDlgItemMessage(hwnd, ID_DIR, LB_ADDSTRING, 0, (LPARAM) finddata.cFileName); | |
711 } while (FindNextFile(skinHandle, &finddata)); | |
712 FindClose(skinHandle); | |
713 } | |
714 else | |
715 mp_msg(MSGT_GPLAYER, MSGL_FATAL, "Error opening %s\n", get_path("skins")); | |
716 break; | |
717 } | |
718 case WM_COMMAND: | |
719 { | |
720 if ((HWND) lParam == listbox) | |
721 { | |
722 if(HIWORD(wParam) == LBN_DBLCLK) | |
723 { | |
724 int index = SendMessage(listbox, LB_GETCURSEL, 0, 0); | |
725 int len = SendMessage(listbox, LB_GETTEXTLEN, index, 0); | |
726 if (len) | |
727 { | |
18954
42d4e99a075e
small fix to properly display skins when switching skins during playback.
vayne
parents:
18914
diff
changeset
|
728 if (guiIntfStruct.Playing) guiGetEvent(guiCEvent, (void *) guiSetStop); |
18914 | 729 if (skinName) free(skinName); |
730 skinName = (char *) malloc(len+1); | |
731 SendMessage(listbox, LB_GETTEXT, (WPARAM) index, (LPARAM) skinName); | |
732 /* fill out the full pathname to the skin */ | |
733 strcpy(skinspath, get_path("skins")); | |
734 strcat(skinspath, "\\"); | |
735 strcat(skinspath, skinName); | |
736 ShowWindow(hwnd, SW_HIDE); | |
737 Shell_NotifyIcon(NIM_DELETE, &nid); | |
738 destroy_window(gui); | |
739 create_window(gui, skinspath); | |
740 create_subwindow(gui, skinspath); | |
741 SendMessage(hwnd, WM_CLOSE, 0, 0); /* Avoid crashing when switching skin */ | |
742 } | |
743 } | |
744 } | |
745 } | |
746 return 0; | |
747 case WM_DESTROY: | |
748 PostQuitMessage(0); | |
749 return 0; | |
750 } | |
751 return DefWindowProc(hwnd, iMsg, wParam, lParam); | |
752 } | |
753 | |
754 void display_skinbrowser(gui_t* gui) | |
755 { | |
756 HWND hWnd = FindWindow(NULL, "Skin Browser"); | |
19718 | 757 HINSTANCE hInstance = GetModuleHandle(NULL); |
758 WNDCLASS wc; | |
759 int x, y; | |
760 | |
18914 | 761 if (hWnd) |
762 { | |
763 SendMessage(hWnd, WM_CLOSE, 0, 0); | |
764 return; | |
765 } | |
766 | |
767 wc.style = CS_HREDRAW | CS_VREDRAW; | |
768 wc.lpfnWndProc = SkinBrowserWndProc; | |
769 wc.cbClsExtra = 0; | |
770 wc.cbWndExtra = 0; | |
771 wc.hInstance = hInstance; | |
772 wc.hCursor = LoadCursor(NULL, IDC_ARROW); | |
773 wc.hIcon = gui->icon; | |
774 wc.hbrBackground = SOLID_GREY2; | |
775 wc.lpszClassName = "Skin Browser"; | |
776 wc.lpszMenuName = NULL; | |
777 RegisterClass(&wc); | |
778 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (180 / 2); | |
779 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (102 / 2); | |
780 hWnd = CreateWindow("Skin Browser", | |
781 "Skin Browser", | |
782 WS_POPUPWINDOW |WS_CAPTION, | |
783 x, | |
784 y, | |
785 180, | |
786 102, | |
787 NULL, | |
788 NULL, | |
789 hInstance, | |
790 NULL); | |
791 SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD) gui); | |
792 ShowWindow(hWnd, SW_SHOW); | |
793 UpdateWindow(hWnd); | |
794 } | |
795 | |
796 #ifdef USE_DVDREAD | |
797 static LRESULT CALLBACK TitleChapterWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) | |
798 { | |
799 static HWND title; | |
800 static HWND chapter; | |
801 HWND wdg; | |
802 int i=0, j=0; | |
803 char titles[MAX_PATH] = ""; | |
804 char chapters[MAX_PATH] = ""; | |
805 switch (iMsg) | |
806 { | |
807 case WM_CREATE: | |
808 wdg = CreateWindow("button", "Ok", | |
809 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, | |
810 4, 43, 80, 25, hwnd, | |
811 (HMENU) ID_OK, | |
812 ((LPCREATESTRUCT) lParam) -> hInstance, | |
813 NULL); | |
814 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
815 | |
816 wdg = CreateWindow("button", "Cancel", | |
817 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, | |
818 90, 43, 80, 25, hwnd, | |
819 (HMENU) ID_CANCEL, | |
820 ((LPCREATESTRUCT) lParam) -> hInstance, | |
821 NULL); | |
822 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
823 | |
824 title = CreateWindow("combobox", NULL, | |
825 CBS_DROPDOWNLIST | CB_SHOWDROPDOWN | CBS_NOINTEGRALHEIGHT | CBS_HASSTRINGS | | |
826 WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, | |
827 4, 10, 80, 160, hwnd, | |
828 (HMENU) ID_TITLESEL, | |
829 ((LPCREATESTRUCT) lParam) -> hInstance, | |
830 NULL); | |
831 | |
832 SendMessage(title, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
833 | |
834 chapter = CreateWindow("combobox", NULL, | |
835 CBS_DROPDOWNLIST | CB_SHOWDROPDOWN | CBS_NOINTEGRALHEIGHT | CBS_HASSTRINGS | | |
836 WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, | |
837 90, 10, 80, 160, hwnd, | |
838 (HMENU) ID_CHAPTERSEL, | |
839 ((LPCREATESTRUCT) lParam) -> hInstance, | |
840 NULL); | |
841 SendMessage(chapter, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
842 | |
843 for (i=0; i<guiIntfStruct.DVD.titles; i++) | |
844 { | |
845 /* we have to reverse the order here because of the way CB_INSERTSTRING adds items */ | |
846 sprintf(&titles[i], "%d", guiIntfStruct.DVD.titles - i); | |
847 SendDlgItemMessage(hwnd, ID_TITLESEL, CB_INSERTSTRING, 0, (LPARAM) &titles[i]); | |
848 } | |
849 SendDlgItemMessage(hwnd, ID_TITLESEL, CB_SETCURSEL, dvd_title, 0); | |
850 | |
851 for (j=0; j<guiIntfStruct.DVD.chapters; j++) | |
852 { | |
853 sprintf(&chapters[j], "%d", guiIntfStruct.DVD.chapters - j); | |
854 SendDlgItemMessage(hwnd, ID_CHAPTERSEL, CB_INSERTSTRING, 0, (LPARAM) &chapters[j]); | |
855 } | |
856 SendDlgItemMessage(hwnd, ID_CHAPTERSEL, CB_SETCURSEL, dvd_chapter, 0); | |
857 | |
858 break; | |
859 case WM_COMMAND: | |
860 { | |
861 switch (LOWORD(wParam)) | |
862 { | |
863 case ID_CANCEL: | |
864 DestroyWindow(hwnd); | |
865 return 0; | |
866 case ID_OK: | |
867 { | |
868 guiIntfStruct.DVD.current_title = SendMessage(title, CB_GETCURSEL, 0, 0) + 1; | |
869 guiIntfStruct.DVD.current_chapter = SendMessage(chapter, CB_GETCURSEL, 0, 0) + 1; | |
870 | |
871 if((guiIntfStruct.DVD.current_title != 0 || guiIntfStruct.DVD.current_chapter != 0)) | |
872 { | |
873 mplGotoTheNext = 0; | |
874 guiGetEvent(guiCEvent, (void *) guiSetStop); | |
875 guiGetEvent(guiCEvent, (void *) guiSetPlay); | |
876 DestroyWindow(hwnd); | |
877 } | |
878 } | |
879 break; | |
880 } | |
881 } | |
882 return 0; | |
883 case WM_DESTROY: | |
884 PostQuitMessage (0); | |
885 return 0; | |
886 } | |
887 return DefWindowProc(hwnd, iMsg, wParam, lParam); | |
888 } | |
889 | |
890 void display_chapterselwindow(gui_t *gui) | |
891 { | |
892 HWND hWnd; | |
893 HINSTANCE hInstance = GetModuleHandle(NULL); | |
894 WNDCLASS wc; | |
895 int x, y; | |
896 | |
897 if (guiIntfStruct.StreamType != STREAMTYPE_DVD) return; | |
898 if (FindWindow(NULL, "Select Title/Chapter...")) return; | |
899 | |
900 wc.style = CS_HREDRAW | CS_VREDRAW; | |
901 wc.lpfnWndProc = TitleChapterWndProc; | |
902 wc.cbClsExtra = 0; | |
903 wc.cbWndExtra = 0; | |
904 wc.hInstance = hInstance; | |
905 wc.hCursor = LoadCursor(NULL,IDC_ARROW); | |
906 wc.hIcon = gui->icon; | |
907 wc.hbrBackground = SOLID_GREY2; | |
908 wc.lpszClassName = "Select Title/Chapter..."; | |
909 wc.lpszMenuName = NULL; | |
910 RegisterClass(&wc); | |
911 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (180 / 2); | |
912 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (100 / 2); | |
913 hWnd = CreateWindow("Select Title/Chapter...", | |
914 "Select Title/Chapter...", | |
915 WS_POPUPWINDOW | WS_CAPTION, | |
916 x, | |
917 y, | |
918 180, | |
919 100, | |
920 NULL, | |
921 NULL, | |
922 hInstance, | |
923 NULL); | |
924 SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD) gui); | |
925 ShowWindow(hWnd, SW_SHOW); | |
926 UpdateWindow(hWnd); | |
927 } | |
928 #endif | |
929 | |
930 static LRESULT CALLBACK EqWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) | |
931 { | |
932 HWND btn, label, eq0, eq1, eq2, eq3; | |
933 | |
934 switch (iMsg) | |
935 { | |
936 case WM_CREATE: | |
937 { | |
938 btn = CreateWindow("button", "Reset", | |
939 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, | |
940 157, 143, 80, 25, hwnd, | |
941 (HMENU) ID_DEFAULTS, | |
942 ((LPCREATESTRUCT) lParam) -> hInstance, | |
943 NULL); | |
944 SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
945 | |
946 btn = CreateWindow("button", "Close", | |
947 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, | |
948 243, 143, 80, 25, hwnd, | |
949 (HMENU) ID_CLOSE, | |
950 ((LPCREATESTRUCT) lParam) -> hInstance, | |
951 NULL); | |
952 SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
953 | |
954 label = CreateWindow("static", "Brightness", | |
955 WS_CHILD | WS_VISIBLE, | |
956 12, 122, 70, 15, hwnd, | |
957 NULL, | |
958 ((LPCREATESTRUCT) lParam) -> hInstance, | |
959 NULL); | |
960 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
961 | |
962 label = CreateWindow("static", "Contrast", | |
963 WS_CHILD | WS_VISIBLE, | |
964 99, 122, 70, 15, hwnd, | |
965 NULL, | |
966 ((LPCREATESTRUCT) lParam) -> hInstance, | |
967 NULL); | |
968 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
969 | |
970 label = CreateWindow("static", "Hue", | |
971 WS_CHILD | WS_VISIBLE, | |
972 191, 122, 70, 15, hwnd, | |
973 NULL, | |
974 ((LPCREATESTRUCT) lParam) -> hInstance, NULL); | |
975 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
976 | |
977 label = CreateWindow("static", "Saturation", | |
978 WS_CHILD | WS_VISIBLE, | |
979 260, 122, 70, 15, hwnd, | |
980 NULL, | |
981 ((LPCREATESTRUCT) lParam) -> hInstance, | |
982 NULL); | |
983 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
984 | |
985 eq0 = CreateWindow(TRACKBAR_CLASS, "brightness", | |
986 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED | | |
987 TBS_VERT | TBS_NOTICKS, | |
988 30, 0, 20, 120, hwnd, | |
989 (HMENU) ID_EQ0, | |
990 ((LPCREATESTRUCT) lParam) -> hInstance, | |
991 NULL); | |
992 SendDlgItemMessage(hwnd, ID_EQ0, TBM_SETRANGE, 1, MAKELONG(0, 200)); | |
993 | |
994 eq1 = CreateWindow(TRACKBAR_CLASS, "contrast", | |
995 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED | | |
996 TBS_VERT | TBS_NOTICKS, | |
997 112, 0, 20, 120, hwnd, | |
998 (HMENU) ID_EQ1, | |
999 ((LPCREATESTRUCT) lParam) -> hInstance, | |
1000 NULL); | |
1001 SendDlgItemMessage(hwnd, ID_EQ1, TBM_SETRANGE, 1, MAKELONG(0, 200)); | |
1002 | |
1003 eq2 = CreateWindow(TRACKBAR_CLASS, "hue", | |
1004 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED | | |
1005 TBS_VERT | TBS_NOTICKS, | |
1006 194, 0, 20, 120, hwnd, | |
1007 (HMENU) ID_EQ2, | |
1008 ((LPCREATESTRUCT) lParam) -> hInstance, | |
1009 NULL); | |
1010 SendDlgItemMessage(hwnd, ID_EQ2, TBM_SETRANGE, 1, MAKELONG(0, 200)); | |
1011 | |
1012 eq3 = CreateWindow(TRACKBAR_CLASS, "saturation", | |
1013 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED | | |
1014 TBS_VERT | TBS_NOTICKS, | |
1015 276, 0, 20, 120, hwnd, | |
1016 (HMENU) ID_EQ3, | |
1017 ((LPCREATESTRUCT) lParam) -> hInstance, NULL); | |
1018 SendDlgItemMessage(hwnd, ID_EQ3, TBM_SETRANGE, 1, MAKELONG(0, 200)); | |
1019 | |
1020 if(guiIntfStruct.sh_video && guiIntfStruct.Playing) | |
1021 { | |
1022 EnableWindow(eq0, 1); EnableWindow(eq1, 1); EnableWindow(eq2, 1); EnableWindow(eq3, 1); | |
1023 get_video_colors(guiIntfStruct.sh_video, "brightness", &vo_gamma_brightness); | |
1024 get_video_colors(guiIntfStruct.sh_video, "contrast", &vo_gamma_contrast); | |
1025 get_video_colors(guiIntfStruct.sh_video, "hue", &vo_gamma_hue); | |
1026 get_video_colors(guiIntfStruct.sh_video, "saturation", &vo_gamma_saturation); | |
1027 } | |
1028 SendDlgItemMessage(hwnd, ID_EQ0, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_brightness); | |
1029 SendDlgItemMessage(hwnd, ID_EQ1, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_contrast); | |
1030 SendDlgItemMessage(hwnd, ID_EQ2, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_hue); | |
1031 SendDlgItemMessage(hwnd, ID_EQ3, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_saturation); | |
1032 break; | |
1033 } | |
1034 case WM_VSCROLL: | |
1035 { | |
1036 switch (LOWORD(wParam)) | |
1037 { | |
1038 case TB_THUMBTRACK: | |
1039 if(guiIntfStruct.sh_video && guiIntfStruct.Playing) | |
1040 { | |
1041 vo_gamma_brightness = 100 - SendDlgItemMessage(hwnd, ID_EQ0, TBM_GETPOS, 0, 0); | |
1042 set_video_colors(guiIntfStruct.sh_video, "brightness", vo_gamma_brightness); | |
1043 | |
1044 vo_gamma_contrast = 100 - SendDlgItemMessage(hwnd, ID_EQ1, TBM_GETPOS, 0, 0); | |
1045 set_video_colors(guiIntfStruct.sh_video, "contrast", vo_gamma_contrast); | |
1046 | |
1047 vo_gamma_hue = 100 - SendDlgItemMessage(hwnd, ID_EQ2, TBM_GETPOS, 0, 0); | |
1048 set_video_colors(guiIntfStruct.sh_video, "hue", vo_gamma_hue); | |
1049 | |
1050 vo_gamma_saturation = 100 - SendDlgItemMessage(hwnd, ID_EQ3, TBM_GETPOS, 0, 0); | |
1051 set_video_colors(guiIntfStruct.sh_video, "saturation", vo_gamma_saturation); | |
1052 } | |
1053 else | |
1054 { | |
1055 EnableWindow(GetDlgItem(hwnd, ID_EQ0), 0); | |
1056 EnableWindow(GetDlgItem(hwnd, ID_EQ1), 0); | |
1057 EnableWindow(GetDlgItem(hwnd, ID_EQ2), 0); | |
1058 EnableWindow(GetDlgItem(hwnd, ID_EQ3), 0); | |
1059 } | |
1060 break; | |
1061 } | |
1062 } | |
1063 case WM_CTLCOLORDLG: | |
1064 case WM_CTLCOLORSTATIC: | |
1065 { | |
1066 HDC hdc = (HDC)wParam; | |
1067 SetBkMode(hdc, TRANSPARENT); | |
1068 return (INT_PTR)SOLID_GREY2; | |
1069 } | |
1070 break; | |
1071 case WM_COMMAND: | |
1072 { | |
1073 switch (LOWORD(wParam)) | |
1074 { | |
1075 case ID_CLOSE: | |
1076 DestroyWindow(hwnd); | |
1077 return 0; | |
1078 case ID_DEFAULTS: | |
1079 if(guiIntfStruct.sh_video && guiIntfStruct.Playing) | |
1080 { | |
1081 vo_gamma_brightness=0; | |
1082 SendDlgItemMessage(hwnd, ID_EQ0, TBM_SETPOS, 1, (LPARAM)100); | |
1083 set_video_colors(guiIntfStruct.sh_video, "brightness", vo_gamma_brightness); | |
1084 | |
1085 vo_gamma_contrast=0; | |
1086 SendDlgItemMessage(hwnd, ID_EQ1, TBM_SETPOS, 1, (LPARAM)100); | |
1087 set_video_colors(guiIntfStruct.sh_video, "contrast", vo_gamma_contrast); | |
1088 | |
1089 vo_gamma_hue=0; | |
1090 SendDlgItemMessage(hwnd, ID_EQ2, TBM_SETPOS, 1, (LPARAM)100); | |
1091 set_video_colors(guiIntfStruct.sh_video, "hue", vo_gamma_hue); | |
1092 | |
1093 vo_gamma_saturation=0; | |
1094 SendDlgItemMessage(hwnd, ID_EQ3, TBM_SETPOS, 1, (LPARAM)100); | |
1095 set_video_colors(guiIntfStruct.sh_video, "saturation", vo_gamma_saturation); | |
1096 } | |
1097 break; | |
1098 } | |
1099 } | |
1100 return 0; | |
1101 case WM_DESTROY: | |
1102 PostQuitMessage (0); | |
1103 return 0; | |
1104 } | |
1105 return DefWindowProc(hwnd, iMsg, wParam, lParam); | |
1106 } | |
1107 | |
1108 void display_eqwindow(gui_t *gui) | |
1109 { | |
1110 HWND hWnd; | |
1111 HINSTANCE hInstance = GetModuleHandle(NULL); | |
1112 WNDCLASS wc; | |
1113 int x, y; | |
19718 | 1114 |
1115 if(!guiIntfStruct.sh_video) return; | |
18914 | 1116 if(FindWindow(NULL, "MPlayer - Equalizer")) return; |
1117 wc.style = CS_HREDRAW | CS_VREDRAW; | |
1118 wc.lpfnWndProc = EqWndProc; | |
1119 wc.cbClsExtra = 0; | |
1120 wc.cbWndExtra = 0; | |
1121 wc.hInstance = hInstance; | |
1122 wc.hCursor = LoadCursor(NULL,IDC_ARROW); | |
1123 wc.hIcon = gui->icon; | |
1124 wc.hbrBackground = SOLID_GREY2; | |
1125 wc.lpszClassName = "MPlayer - Equalizer"; | |
1126 wc.lpszMenuName = NULL; | |
1127 RegisterClass(&wc); | |
1128 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (332 / 2); | |
1129 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (200 / 2); | |
1130 hWnd = CreateWindow("MPlayer - Equalizer", | |
1131 "MPlayer - Equalizer", | |
1132 WS_POPUPWINDOW | WS_CAPTION, | |
1133 x, | |
1134 y, | |
1135 332, | |
1136 200, | |
1137 NULL, | |
1138 NULL, | |
1139 hInstance, | |
1140 NULL); | |
1141 SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD) gui); | |
1142 ShowWindow(hWnd, SW_SHOW); | |
1143 UpdateWindow(hWnd); | |
1144 } |