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