Mercurial > mplayer.hg
annotate gui/win32/dialogs.c @ 23541:5fda2824ce8a
add missing IDCT algothim, as defined in libavcodec/avcodec.h
author | gpoirier |
---|---|
date | Sat, 16 Jun 2007 11:49:11 +0000 |
parents | 52488bb09d90 |
children | abb784e37907 |
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; | |
44 extern int set_video_colors(sh_video_t *sh_video, char *item, int value); | |
45 extern int get_video_colors(sh_video_t *sh_video, char *item, int *value); | |
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 PostQuitMessage (0); | |
354 addurl = 0; | |
355 return 0; | |
356 } | |
357 } | |
358 return DefWindowProc(hwnd, iMsg, wParam, lParam); | |
359 } | |
360 | |
361 LRESULT CALLBACK SubUrlWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) | |
362 { | |
363 switch(iMsg) | |
364 { | |
365 case WM_KEYDOWN: | |
366 switch (LOWORD(wParam)) | |
367 { | |
368 case VK_RETURN: | |
369 SendMessage(FindWindow(NULL, "MPlayer - Open URL..."), WM_COMMAND, (WPARAM) ID_OK, 0); | |
370 break; | |
371 } | |
372 } | |
373 return CallWindowProc(OldUrlWndProc, hwnd, iMsg, wParam, lParam); | |
374 } | |
375 | |
376 void display_openurlwindow(gui_t *gui, int add) | |
377 { | |
378 HWND hWnd; | |
379 HINSTANCE hInstance = GetModuleHandle(NULL); | |
380 WNDCLASS wc; | |
381 int x, y; | |
382 | |
383 if(add) addurl = 1; | |
384 if(FindWindow(NULL, "MPlayer - Open URL...")) return; | |
385 wc.style = CS_HREDRAW | CS_VREDRAW; | |
386 wc.lpfnWndProc = OpenUrlWndProc; | |
387 wc.cbClsExtra = 0; | |
388 wc.cbWndExtra = 0; | |
389 wc.hInstance = hInstance; | |
390 wc.hCursor = LoadCursor(NULL,IDC_ARROW); | |
391 wc.hIcon = gui->icon; | |
392 wc.hbrBackground = SOLID_GREY2; | |
393 wc.lpszClassName = "MPlayer - URL"; | |
394 wc.lpszMenuName = NULL; | |
395 RegisterClass(&wc); | |
396 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (320 / 2); | |
397 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (100 / 2); | |
398 hWnd = CreateWindow("MPlayer - URL", | |
399 "MPlayer - Open URL...", | |
400 WS_POPUPWINDOW | WS_CAPTION, | |
401 x, | |
402 y, | |
403 320, | |
404 100, | |
405 NULL, | |
406 NULL, | |
407 hInstance, | |
408 NULL); | |
409 SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD) gui); | |
410 ShowWindow(hWnd, SW_SHOW); | |
411 UpdateWindow(hWnd); | |
412 } | |
413 | |
414 static void create_playlistmenu(gui_t *gui) | |
415 { | |
416 gui->playlistmenu = CreatePopupMenu(); | |
417 AppendMenu(gui->playlistmenu, MF_STRING, ID_ADDFILE, "Add File..."); | |
418 AppendMenu(gui->playlistmenu, MF_STRING, ID_ADDURL, "Add Url..."); | |
419 AppendMenu(gui->playlistmenu, MF_SEPARATOR, 0, 0); | |
420 AppendMenu(gui->playlistmenu, MF_STRING, ID_REMOVE, "Remove Selected"); | |
421 AppendMenu(gui->playlistmenu, MF_STRING, ID_CLEAR, "Clear Playlist"); | |
422 AppendMenu(gui->playlistmenu, MF_SEPARATOR, 0, 0); | |
423 AppendMenu(gui->playlistmenu, MF_STRING, ID_CLOSE, "Close"); | |
424 } | |
425 | |
426 static void updatetracklist(HWND hwnd) | |
427 { | |
428 int i=0; | |
429 gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA); | |
430 /* clear listbox */ | |
431 SendDlgItemMessage(hwnd, ID_TRACKLIST, LB_RESETCONTENT, 0, 0); | |
432 for (i=0; i < gui->playlist->trackcount; i++) | |
433 if (gui->playlist->tracks[i]->title) | |
434 SendDlgItemMessage(hwnd, ID_TRACKLIST, LB_ADDSTRING, 0, (LPARAM)gui->playlist->tracks[i]->title); | |
435 else | |
436 SendDlgItemMessage(hwnd, ID_TRACKLIST, LB_ADDSTRING, 0, (LPARAM)gui->playlist->tracks[i]->filename); | |
437 } | |
438 | |
439 static LRESULT CALLBACK PlayListWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) | |
440 { | |
441 HWND wdg; | |
442 POINT cursor; | |
443 gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA); | |
444 playlist_t *pl = gui ? gui->playlist : NULL; | |
445 switch (iMsg) | |
446 { | |
447 case WM_CREATE: | |
448 { | |
449 wdg = CreateWindow("button", "Play", | |
450 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, | |
451 4, 10, 80, 25, hwnd, | |
452 (HMENU) ID_PLAY, | |
453 ((LPCREATESTRUCT) lParam) -> hInstance, | |
454 NULL); | |
455 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
456 | |
457 wdg = CreateWindow ("button", "Up", | |
458 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, | |
459 4, 37, 80, 25, hwnd, | |
460 (HMENU) ID_UP, | |
461 ((LPCREATESTRUCT) lParam) -> hInstance, | |
462 NULL); | |
463 SendMessage(wdg, WM_SETFONT,(WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
464 | |
465 wdg = CreateWindow ("button", "Down", | |
466 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, | |
467 4, 64, 80, 25, hwnd, | |
468 (HMENU) ID_DOWN, | |
469 ((LPCREATESTRUCT) lParam) -> hInstance, | |
470 NULL); | |
471 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0); | |
472 | |
473 wdg = CreateWindow ("button", "Remove", | |
474 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, | |
475 4, 91, 80, 25, hwnd, | |
476 (HMENU) ID_REMOVE, | |
477 ((LPCREATESTRUCT) lParam) -> hInstance, | |
478 NULL); | |
479 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0); | |
480 | |
481 wdg = CreateWindow ("button", "Load", | |
482 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, | |
483 4, 118, 80, 25, hwnd, | |
484 (HMENU) ID_PLAYLISTLOAD, | |
485 ((LPCREATESTRUCT) lParam) -> hInstance, | |
486 NULL); | |
487 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0); | |
488 | |
489 wdg = CreateWindow ("button", "Save", | |
490 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, | |
491 4, 145, 80, 25, hwnd, | |
492 (HMENU) ID_PLAYLISTSAVE, | |
493 ((LPCREATESTRUCT) lParam) -> hInstance, | |
494 NULL); | |
495 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0); | |
496 | |
497 wdg = CreateWindow ("button", "Close", | |
498 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, | |
499 4, 193, 80, 25, hwnd, | |
500 (HMENU) ID_CLOSE, | |
501 ((LPCREATESTRUCT) lParam) -> hInstance, | |
502 NULL); | |
503 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0); | |
504 | |
505 wdg = CreateWindow ("listbox", "tracklist", WS_CHILD | WS_VISIBLE | LBS_NOTIFY | WS_VSCROLL | | |
506 WS_HSCROLL | LBS_DISABLENOSCROLL, 92, 10, 300, 208, hwnd, (HMENU) ID_TRACKLIST, | |
507 ((LPCREATESTRUCT) lParam) -> hInstance, NULL); | |
508 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
509 SendMessage(wdg, LB_SETHORIZONTALEXTENT, MAX_PATH*4, 0); | |
510 break; | |
511 } | |
512 case WM_CONTEXTMENU: | |
513 { | |
514 GetCursorPos(&cursor); | |
515 SetForegroundWindow(hwnd); | |
516 TrackPopupMenu(gui->playlistmenu, 0, cursor.x, cursor.y, 0, hwnd, NULL); | |
517 break; | |
518 } | |
519 case WM_COMMAND: | |
520 { | |
521 int selected = 0; | |
522 int i; | |
523 for (i=0; i<pl->trackcount; i++) | |
524 if(0 < SendDlgItemMessage(hwnd, ID_TRACKLIST, LB_GETSEL, i, 0)) selected = i + 1; | |
525 switch (LOWORD(wParam)) | |
526 { | |
527 case ID_CLOSE: | |
528 DestroyWindow(hwnd); | |
529 return 0; | |
530 case ID_TRACKLIST: | |
531 if(HIWORD(wParam) == LBN_DBLCLK) | |
532 { | |
533 case ID_PLAY: | |
534 if(selected) pl->current = selected - 1; | |
535 mplSetFileName(NULL, pl->tracks[pl->current]->filename, STREAMTYPE_STREAM); | |
536 gui->startplay(gui); | |
537 } | |
538 return 0; | |
539 case ID_UP: | |
540 { | |
541 if(selected) pl->moveup_track(pl, selected); | |
542 selected--; | |
543 break; | |
544 } | |
545 case ID_DOWN: | |
546 { | |
547 if(selected) pl->movedown_track(pl, selected); | |
548 selected++; | |
549 break; | |
550 } | |
551 case ID_REMOVE: | |
552 if(selected) pl->remove_track(pl, selected); | |
553 break; | |
554 case ID_ADDFILE: | |
555 { | |
556 if(guiIntfStruct.StreamType == STREAMTYPE_DVD || | |
557 guiIntfStruct.StreamType == STREAMTYPE_DVDNAV) return 0; | |
558 display_openfilewindow(gui, 1); | |
559 break; | |
560 } | |
561 case ID_ADDURL: | |
562 { | |
563 if(guiIntfStruct.StreamType == STREAMTYPE_DVD || | |
564 guiIntfStruct.StreamType == STREAMTYPE_DVDNAV) return 0; | |
565 display_openurlwindow(gui, 1); | |
566 break; | |
567 } | |
568 case ID_CLEAR: | |
569 { | |
570 if(!gui->playlist->trackcount) return 0; | |
571 gui->playlist->clear_playlist(gui->playlist); | |
572 break; | |
573 } | |
574 case ID_PLAYLISTLOAD: | |
575 { | |
576 if(guiIntfStruct.StreamType == STREAMTYPE_DVD || | |
577 guiIntfStruct.StreamType == STREAMTYPE_DVDNAV) return 0; | |
578 display_loadplaylistwindow(gui); | |
579 break; | |
580 } | |
581 case ID_PLAYLISTSAVE: | |
582 { | |
583 /* no point saving an empty playlist */ | |
584 if(!gui->playlist->trackcount || | |
585 guiIntfStruct.StreamType == STREAMTYPE_DVD || | |
586 guiIntfStruct.StreamType == STREAMTYPE_DVDNAV) | |
587 return 0; | |
588 display_saveplaylistwindow(gui); | |
589 break; | |
590 } | |
591 } | |
592 updatetracklist(hwnd); | |
593 if(selected < 1) selected = 1; | |
594 else if(selected>pl->trackcount) selected = pl->trackcount; | |
595 SendDlgItemMessage(hwnd, ID_TRACKLIST, LB_SETCURSEL, selected - 1, 0); | |
596 return 0; | |
597 } | |
598 case WM_DROPFILES: | |
599 { | |
600 char file[MAX_PATH]; | |
601 int filecount = DragQueryFile((HDROP) wParam, -1, file, MAX_PATH); | |
602 int i; | |
603 for (i=0; i<filecount; i++) | |
604 { | |
605 DragQueryFile((HDROP) wParam, i, file, MAX_PATH); | |
606 if(!parse_filename(file, playtree, mconfig, 0)) | |
607 pl->add_track(pl, file, NULL, NULL, 0); | |
608 } | |
609 DragFinish((HDROP) wParam); | |
610 updatetracklist(hwnd); | |
611 } | |
612 break; | |
613 case WM_DESTROY: | |
614 PostQuitMessage(0); | |
615 return 0; | |
616 } | |
617 return DefWindowProc(hwnd, iMsg, wParam, lParam); | |
618 } | |
619 | |
620 void update_playlistwindow(void) | |
621 { | |
622 HWND hWnd = FindWindow(NULL, "MPlayer Playlist"); | |
623 if (hWnd) updatetracklist(hWnd); | |
624 } | |
625 | |
626 void display_playlistwindow(gui_t *gui) | |
627 { | |
628 HWND hWnd = FindWindow(NULL, "MPlayer Playlist"); | |
629 HINSTANCE hInstance = GetModuleHandle(NULL); | |
630 WNDCLASS wc; | |
631 int x, y; | |
632 | |
633 if (hWnd) | |
634 { | |
635 SendMessage(hWnd, WM_CLOSE, 0, 0); | |
636 return; | |
637 } | |
638 | |
639 wc.style = CS_HREDRAW | CS_VREDRAW; | |
640 wc.lpfnWndProc = PlayListWndProc; | |
641 wc.cbClsExtra = 0; | |
642 wc.cbWndExtra = 0; | |
643 wc.hInstance = hInstance; | |
644 wc.hCursor = LoadCursor(NULL,IDC_ARROW); | |
645 wc.hIcon = gui->icon; | |
646 wc.hbrBackground = SOLID_GREY2; | |
647 wc.lpszClassName = "MPlayer - Playlist"; | |
648 wc.lpszMenuName = NULL; | |
649 RegisterClass(&wc); | |
650 create_playlistmenu(gui); | |
651 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (400 / 2); /* Erik: center popup window on screen */ | |
652 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (254 / 2); | |
653 hWnd = CreateWindow("MPlayer - Playlist", | |
654 "MPlayer Playlist", | |
655 WS_POPUPWINDOW | WS_CAPTION | WS_MINIMIZEBOX, | |
656 x, | |
657 y, | |
658 400, | |
659 254, | |
660 NULL, | |
661 NULL, | |
662 hInstance, | |
663 NULL); | |
664 SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD)gui); | |
665 updatetracklist(hWnd); | |
666 DragAcceptFiles(hWnd,TRUE); | |
667 ShowWindow(hWnd, SW_SHOW); | |
668 UpdateWindow(hWnd); | |
669 } | |
670 | |
671 static LRESULT CALLBACK SkinBrowserWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) | |
672 { | |
673 static HWND listbox; | |
674 static char skinspath[MAX_PATH]; | |
675 gui_t* gui = (gui_t*) GetWindowLongPtr(hwnd, GWLP_USERDATA); | |
676 switch (iMsg) | |
677 { | |
678 case WM_CREATE: | |
679 { | |
680 HANDLE skinHandle = INVALID_HANDLE_VALUE; | |
681 WIN32_FIND_DATA finddata; | |
682 | |
683 listbox = CreateWindow("listbox", NULL, | |
684 WS_CHILD | WS_VISIBLE | LBS_NOTIFY | LBS_NOINTEGRALHEIGHT | | |
685 LBS_DISABLENOSCROLL | WS_VSCROLL | WS_TABSTOP, | |
686 4, 5, 166, 60, hwnd, | |
687 (HMENU) ID_DIR, | |
688 ((LPCREATESTRUCT) lParam) -> hInstance, | |
689 NULL); | |
690 SendMessage(listbox, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
691 | |
692 /* This opens the skins directory, lists the directory names, and adds them to the listbox */ | |
693 sprintf(skinspath, "%s/*.", get_path("skins")); | |
694 | |
695 skinHandle = FindFirstFile(skinspath, &finddata); | |
696 if (skinHandle != INVALID_HANDLE_VALUE) | |
697 { | |
698 do | |
699 { | |
700 if (finddata.cFileName[0] == '.') continue; | |
701 /* populate the listbox */ | |
702 capitalize(finddata.cFileName); | |
703 SendDlgItemMessage(hwnd, ID_DIR, LB_ADDSTRING, 0, (LPARAM) finddata.cFileName); | |
704 } while (FindNextFile(skinHandle, &finddata)); | |
705 FindClose(skinHandle); | |
706 } | |
707 else | |
708 mp_msg(MSGT_GPLAYER, MSGL_FATAL, "Error opening %s\n", get_path("skins")); | |
709 break; | |
710 } | |
711 case WM_COMMAND: | |
712 { | |
713 if ((HWND) lParam == listbox) | |
714 { | |
715 if(HIWORD(wParam) == LBN_DBLCLK) | |
716 { | |
717 int index = SendMessage(listbox, LB_GETCURSEL, 0, 0); | |
718 int len = SendMessage(listbox, LB_GETTEXTLEN, index, 0); | |
719 if (len) | |
720 { | |
721 if (guiIntfStruct.Playing) guiGetEvent(guiCEvent, (void *) guiSetStop); | |
722 if (skinName) free(skinName); | |
723 skinName = (char *) malloc(len+1); | |
724 SendMessage(listbox, LB_GETTEXT, (WPARAM) index, (LPARAM) skinName); | |
725 /* fill out the full pathname to the skin */ | |
726 strcpy(skinspath, get_path("skins")); | |
727 strcat(skinspath, "\\"); | |
728 strcat(skinspath, skinName); | |
729 ShowWindow(hwnd, SW_HIDE); | |
730 Shell_NotifyIcon(NIM_DELETE, &nid); | |
731 destroy_window(gui); | |
732 create_window(gui, skinspath); | |
733 create_subwindow(gui, skinspath); | |
734 SendMessage(hwnd, WM_CLOSE, 0, 0); /* Avoid crashing when switching skin */ | |
735 } | |
736 } | |
737 } | |
738 } | |
739 return 0; | |
740 case WM_DESTROY: | |
741 PostQuitMessage(0); | |
742 return 0; | |
743 } | |
744 return DefWindowProc(hwnd, iMsg, wParam, lParam); | |
745 } | |
746 | |
747 void display_skinbrowser(gui_t* gui) | |
748 { | |
749 HWND hWnd = FindWindow(NULL, "Skin Browser"); | |
750 HINSTANCE hInstance = GetModuleHandle(NULL); | |
751 WNDCLASS wc; | |
752 int x, y; | |
753 | |
754 if (hWnd) | |
755 { | |
756 SendMessage(hWnd, WM_CLOSE, 0, 0); | |
757 return; | |
758 } | |
759 | |
760 wc.style = CS_HREDRAW | CS_VREDRAW; | |
761 wc.lpfnWndProc = SkinBrowserWndProc; | |
762 wc.cbClsExtra = 0; | |
763 wc.cbWndExtra = 0; | |
764 wc.hInstance = hInstance; | |
765 wc.hCursor = LoadCursor(NULL, IDC_ARROW); | |
766 wc.hIcon = gui->icon; | |
767 wc.hbrBackground = SOLID_GREY2; | |
768 wc.lpszClassName = "Skin Browser"; | |
769 wc.lpszMenuName = NULL; | |
770 RegisterClass(&wc); | |
771 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (180 / 2); | |
772 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (102 / 2); | |
773 hWnd = CreateWindow("Skin Browser", | |
774 "Skin Browser", | |
775 WS_POPUPWINDOW |WS_CAPTION, | |
776 x, | |
777 y, | |
778 180, | |
779 102, | |
780 NULL, | |
781 NULL, | |
782 hInstance, | |
783 NULL); | |
784 SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD) gui); | |
785 ShowWindow(hWnd, SW_SHOW); | |
786 UpdateWindow(hWnd); | |
787 } | |
788 | |
789 #ifdef USE_DVDREAD | |
790 static LRESULT CALLBACK TitleChapterWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) | |
791 { | |
792 static HWND title; | |
793 static HWND chapter; | |
794 HWND wdg; | |
795 int i=0, j=0; | |
796 char titles[MAX_PATH] = ""; | |
797 char chapters[MAX_PATH] = ""; | |
798 gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA); | |
799 switch (iMsg) | |
800 { | |
801 case WM_CREATE: | |
802 wdg = CreateWindow("button", "Ok", | |
803 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, | |
804 4, 43, 80, 25, hwnd, | |
805 (HMENU) ID_OK, | |
806 ((LPCREATESTRUCT) lParam) -> hInstance, | |
807 NULL); | |
808 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
809 | |
810 wdg = CreateWindow("button", "Cancel", | |
811 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, | |
812 90, 43, 80, 25, hwnd, | |
813 (HMENU) ID_CANCEL, | |
814 ((LPCREATESTRUCT) lParam) -> hInstance, | |
815 NULL); | |
816 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
817 | |
818 title = CreateWindow("combobox", NULL, | |
819 CBS_DROPDOWNLIST | CB_SHOWDROPDOWN | CBS_NOINTEGRALHEIGHT | CBS_HASSTRINGS | | |
820 WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, | |
821 4, 10, 80, 160, hwnd, | |
822 (HMENU) ID_TITLESEL, | |
823 ((LPCREATESTRUCT) lParam) -> hInstance, | |
824 NULL); | |
825 | |
826 SendMessage(title, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
827 | |
828 chapter = CreateWindow("combobox", NULL, | |
829 CBS_DROPDOWNLIST | CB_SHOWDROPDOWN | CBS_NOINTEGRALHEIGHT | CBS_HASSTRINGS | | |
830 WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, | |
831 90, 10, 80, 160, hwnd, | |
832 (HMENU) ID_CHAPTERSEL, | |
833 ((LPCREATESTRUCT) lParam) -> hInstance, | |
834 NULL); | |
835 SendMessage(chapter, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
836 | |
837 for (i=0; i<guiIntfStruct.DVD.titles; i++) | |
838 { | |
839 /* we have to reverse the order here because of the way CB_INSERTSTRING adds items */ | |
840 sprintf(&titles[i], "%d", guiIntfStruct.DVD.titles - i); | |
841 SendDlgItemMessage(hwnd, ID_TITLESEL, CB_INSERTSTRING, 0, (LPARAM) &titles[i]); | |
842 } | |
843 SendDlgItemMessage(hwnd, ID_TITLESEL, CB_SETCURSEL, dvd_title, 0); | |
844 | |
845 for (j=0; j<guiIntfStruct.DVD.chapters; j++) | |
846 { | |
847 sprintf(&chapters[j], "%d", guiIntfStruct.DVD.chapters - j); | |
848 SendDlgItemMessage(hwnd, ID_CHAPTERSEL, CB_INSERTSTRING, 0, (LPARAM) &chapters[j]); | |
849 } | |
850 SendDlgItemMessage(hwnd, ID_CHAPTERSEL, CB_SETCURSEL, dvd_chapter, 0); | |
851 | |
852 break; | |
853 case WM_COMMAND: | |
854 { | |
855 switch (LOWORD(wParam)) | |
856 { | |
857 case ID_CANCEL: | |
858 DestroyWindow(hwnd); | |
859 return 0; | |
860 case ID_OK: | |
861 { | |
862 guiIntfStruct.DVD.current_title = SendMessage(title, CB_GETCURSEL, 0, 0) + 1; | |
863 guiIntfStruct.DVD.current_chapter = SendMessage(chapter, CB_GETCURSEL, 0, 0) + 1; | |
864 | |
865 if((guiIntfStruct.DVD.current_title != 0 || guiIntfStruct.DVD.current_chapter != 0)) | |
866 { | |
867 gui->startplay(gui); | |
868 DestroyWindow(hwnd); | |
869 } | |
870 } | |
871 break; | |
872 } | |
873 } | |
874 return 0; | |
875 case WM_DESTROY: | |
876 PostQuitMessage (0); | |
877 return 0; | |
878 } | |
879 return DefWindowProc(hwnd, iMsg, wParam, lParam); | |
880 } | |
881 | |
882 void display_chapterselwindow(gui_t *gui) | |
883 { | |
884 HWND hWnd; | |
885 HINSTANCE hInstance = GetModuleHandle(NULL); | |
886 WNDCLASS wc; | |
887 int x, y; | |
888 | |
889 if (guiIntfStruct.StreamType != STREAMTYPE_DVD) return; | |
890 if (FindWindow(NULL, "Select Title/Chapter...")) return; | |
891 | |
892 wc.style = CS_HREDRAW | CS_VREDRAW; | |
893 wc.lpfnWndProc = TitleChapterWndProc; | |
894 wc.cbClsExtra = 0; | |
895 wc.cbWndExtra = 0; | |
896 wc.hInstance = hInstance; | |
897 wc.hCursor = LoadCursor(NULL,IDC_ARROW); | |
898 wc.hIcon = gui->icon; | |
899 wc.hbrBackground = SOLID_GREY2; | |
900 wc.lpszClassName = "Select Title/Chapter..."; | |
901 wc.lpszMenuName = NULL; | |
902 RegisterClass(&wc); | |
903 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (180 / 2); | |
904 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (100 / 2); | |
905 hWnd = CreateWindow("Select Title/Chapter...", | |
906 "Select Title/Chapter...", | |
907 WS_POPUPWINDOW | WS_CAPTION, | |
908 x, | |
909 y, | |
910 180, | |
911 100, | |
912 NULL, | |
913 NULL, | |
914 hInstance, | |
915 NULL); | |
916 SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD) gui); | |
917 ShowWindow(hWnd, SW_SHOW); | |
918 UpdateWindow(hWnd); | |
919 } | |
920 #endif | |
921 | |
922 static LRESULT CALLBACK EqWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) | |
923 { | |
924 HWND btn, label, eq0, eq1, eq2, eq3; | |
925 | |
926 switch (iMsg) | |
927 { | |
928 case WM_CREATE: | |
929 { | |
930 btn = CreateWindow("button", "Reset", | |
931 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, | |
932 157, 143, 80, 25, hwnd, | |
933 (HMENU) ID_DEFAULTS, | |
934 ((LPCREATESTRUCT) lParam) -> hInstance, | |
935 NULL); | |
936 SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
937 | |
938 btn = CreateWindow("button", "Close", | |
939 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, | |
940 243, 143, 80, 25, hwnd, | |
941 (HMENU) ID_CLOSE, | |
942 ((LPCREATESTRUCT) lParam) -> hInstance, | |
943 NULL); | |
944 SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
945 | |
946 label = CreateWindow("static", "Brightness", | |
947 WS_CHILD | WS_VISIBLE, | |
948 12, 122, 70, 15, hwnd, | |
949 NULL, | |
950 ((LPCREATESTRUCT) lParam) -> hInstance, | |
951 NULL); | |
952 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
953 | |
954 label = CreateWindow("static", "Contrast", | |
955 WS_CHILD | WS_VISIBLE, | |
956 99, 122, 70, 15, hwnd, | |
957 NULL, | |
958 ((LPCREATESTRUCT) lParam) -> hInstance, | |
959 NULL); | |
960 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
961 | |
962 label = CreateWindow("static", "Hue", | |
963 WS_CHILD | WS_VISIBLE, | |
964 191, 122, 70, 15, hwnd, | |
965 NULL, | |
966 ((LPCREATESTRUCT) lParam) -> hInstance, NULL); | |
967 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
968 | |
969 label = CreateWindow("static", "Saturation", | |
970 WS_CHILD | WS_VISIBLE, | |
971 260, 122, 70, 15, hwnd, | |
972 NULL, | |
973 ((LPCREATESTRUCT) lParam) -> hInstance, | |
974 NULL); | |
975 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
976 | |
977 eq0 = CreateWindow(TRACKBAR_CLASS, "brightness", | |
978 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED | | |
979 TBS_VERT | TBS_NOTICKS, | |
980 30, 0, 20, 120, hwnd, | |
981 (HMENU) ID_EQ0, | |
982 ((LPCREATESTRUCT) lParam) -> hInstance, | |
983 NULL); | |
984 SendDlgItemMessage(hwnd, ID_EQ0, TBM_SETRANGE, 1, MAKELONG(0, 200)); | |
985 | |
986 eq1 = CreateWindow(TRACKBAR_CLASS, "contrast", | |
987 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED | | |
988 TBS_VERT | TBS_NOTICKS, | |
989 112, 0, 20, 120, hwnd, | |
990 (HMENU) ID_EQ1, | |
991 ((LPCREATESTRUCT) lParam) -> hInstance, | |
992 NULL); | |
993 SendDlgItemMessage(hwnd, ID_EQ1, TBM_SETRANGE, 1, MAKELONG(0, 200)); | |
994 | |
995 eq2 = CreateWindow(TRACKBAR_CLASS, "hue", | |
996 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED | | |
997 TBS_VERT | TBS_NOTICKS, | |
998 194, 0, 20, 120, hwnd, | |
999 (HMENU) ID_EQ2, | |
1000 ((LPCREATESTRUCT) lParam) -> hInstance, | |
1001 NULL); | |
1002 SendDlgItemMessage(hwnd, ID_EQ2, TBM_SETRANGE, 1, MAKELONG(0, 200)); | |
1003 | |
1004 eq3 = CreateWindow(TRACKBAR_CLASS, "saturation", | |
1005 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED | | |
1006 TBS_VERT | TBS_NOTICKS, | |
1007 276, 0, 20, 120, hwnd, | |
1008 (HMENU) ID_EQ3, | |
1009 ((LPCREATESTRUCT) lParam) -> hInstance, NULL); | |
1010 SendDlgItemMessage(hwnd, ID_EQ3, TBM_SETRANGE, 1, MAKELONG(0, 200)); | |
1011 | |
1012 if(guiIntfStruct.sh_video && guiIntfStruct.Playing) | |
1013 { | |
1014 EnableWindow(eq0, 1); EnableWindow(eq1, 1); EnableWindow(eq2, 1); EnableWindow(eq3, 1); | |
1015 get_video_colors(guiIntfStruct.sh_video, "brightness", &vo_gamma_brightness); | |
1016 get_video_colors(guiIntfStruct.sh_video, "contrast", &vo_gamma_contrast); | |
1017 get_video_colors(guiIntfStruct.sh_video, "hue", &vo_gamma_hue); | |
1018 get_video_colors(guiIntfStruct.sh_video, "saturation", &vo_gamma_saturation); | |
1019 } | |
1020 SendDlgItemMessage(hwnd, ID_EQ0, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_brightness); | |
1021 SendDlgItemMessage(hwnd, ID_EQ1, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_contrast); | |
1022 SendDlgItemMessage(hwnd, ID_EQ2, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_hue); | |
1023 SendDlgItemMessage(hwnd, ID_EQ3, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_saturation); | |
1024 break; | |
1025 } | |
1026 case WM_VSCROLL: | |
1027 { | |
1028 switch (LOWORD(wParam)) | |
1029 { | |
1030 case TB_THUMBTRACK: | |
1031 if(guiIntfStruct.sh_video && guiIntfStruct.Playing) | |
1032 { | |
1033 vo_gamma_brightness = 100 - SendDlgItemMessage(hwnd, ID_EQ0, TBM_GETPOS, 0, 0); | |
1034 set_video_colors(guiIntfStruct.sh_video, "brightness", vo_gamma_brightness); | |
1035 | |
1036 vo_gamma_contrast = 100 - SendDlgItemMessage(hwnd, ID_EQ1, TBM_GETPOS, 0, 0); | |
1037 set_video_colors(guiIntfStruct.sh_video, "contrast", vo_gamma_contrast); | |
1038 | |
1039 vo_gamma_hue = 100 - SendDlgItemMessage(hwnd, ID_EQ2, TBM_GETPOS, 0, 0); | |
1040 set_video_colors(guiIntfStruct.sh_video, "hue", vo_gamma_hue); | |
1041 | |
1042 vo_gamma_saturation = 100 - SendDlgItemMessage(hwnd, ID_EQ3, TBM_GETPOS, 0, 0); | |
1043 set_video_colors(guiIntfStruct.sh_video, "saturation", vo_gamma_saturation); | |
1044 } | |
1045 else | |
1046 { | |
1047 EnableWindow(GetDlgItem(hwnd, ID_EQ0), 0); | |
1048 EnableWindow(GetDlgItem(hwnd, ID_EQ1), 0); | |
1049 EnableWindow(GetDlgItem(hwnd, ID_EQ2), 0); | |
1050 EnableWindow(GetDlgItem(hwnd, ID_EQ3), 0); | |
1051 } | |
1052 break; | |
1053 } | |
1054 } | |
1055 case WM_CTLCOLORDLG: | |
1056 case WM_CTLCOLORSTATIC: | |
1057 { | |
1058 HDC hdc = (HDC)wParam; | |
1059 SetBkMode(hdc, TRANSPARENT); | |
1060 return (INT_PTR)SOLID_GREY2; | |
1061 } | |
1062 break; | |
1063 case WM_COMMAND: | |
1064 { | |
1065 switch (LOWORD(wParam)) | |
1066 { | |
1067 case ID_CLOSE: | |
1068 DestroyWindow(hwnd); | |
1069 return 0; | |
1070 case ID_DEFAULTS: | |
1071 if(guiIntfStruct.sh_video && guiIntfStruct.Playing) | |
1072 { | |
1073 vo_gamma_brightness=0; | |
1074 SendDlgItemMessage(hwnd, ID_EQ0, TBM_SETPOS, 1, (LPARAM)100); | |
1075 set_video_colors(guiIntfStruct.sh_video, "brightness", vo_gamma_brightness); | |
1076 | |
1077 vo_gamma_contrast=0; | |
1078 SendDlgItemMessage(hwnd, ID_EQ1, TBM_SETPOS, 1, (LPARAM)100); | |
1079 set_video_colors(guiIntfStruct.sh_video, "contrast", vo_gamma_contrast); | |
1080 | |
1081 vo_gamma_hue=0; | |
1082 SendDlgItemMessage(hwnd, ID_EQ2, TBM_SETPOS, 1, (LPARAM)100); | |
1083 set_video_colors(guiIntfStruct.sh_video, "hue", vo_gamma_hue); | |
1084 | |
1085 vo_gamma_saturation=0; | |
1086 SendDlgItemMessage(hwnd, ID_EQ3, TBM_SETPOS, 1, (LPARAM)100); | |
1087 set_video_colors(guiIntfStruct.sh_video, "saturation", vo_gamma_saturation); | |
1088 } | |
1089 break; | |
1090 } | |
1091 } | |
1092 return 0; | |
1093 case WM_DESTROY: | |
1094 PostQuitMessage (0); | |
1095 return 0; | |
1096 } | |
1097 return DefWindowProc(hwnd, iMsg, wParam, lParam); | |
1098 } | |
1099 | |
1100 void display_eqwindow(gui_t *gui) | |
1101 { | |
1102 HWND hWnd; | |
1103 HINSTANCE hInstance = GetModuleHandle(NULL); | |
1104 WNDCLASS wc; | |
1105 int x, y; | |
1106 | |
1107 if(!guiIntfStruct.sh_video) return; | |
1108 if(FindWindow(NULL, "MPlayer - Equalizer")) return; | |
1109 wc.style = CS_HREDRAW | CS_VREDRAW; | |
1110 wc.lpfnWndProc = EqWndProc; | |
1111 wc.cbClsExtra = 0; | |
1112 wc.cbWndExtra = 0; | |
1113 wc.hInstance = hInstance; | |
1114 wc.hCursor = LoadCursor(NULL,IDC_ARROW); | |
1115 wc.hIcon = gui->icon; | |
1116 wc.hbrBackground = SOLID_GREY2; | |
1117 wc.lpszClassName = "MPlayer - Equalizer"; | |
1118 wc.lpszMenuName = NULL; | |
1119 RegisterClass(&wc); | |
1120 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (332 / 2); | |
1121 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (200 / 2); | |
1122 hWnd = CreateWindow("MPlayer - Equalizer", | |
1123 "MPlayer - Equalizer", | |
1124 WS_POPUPWINDOW | WS_CAPTION, | |
1125 x, | |
1126 y, | |
1127 332, | |
1128 200, | |
1129 NULL, | |
1130 NULL, | |
1131 hInstance, | |
1132 NULL); | |
1133 SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD) gui); | |
1134 ShowWindow(hWnd, SW_SHOW); | |
1135 UpdateWindow(hWnd); | |
1136 } |