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