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