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