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