comparison Gui/win32/dialogs.c @ 18914:d450ec82ae57

Initial win32 gui release.
author vayne
date Thu, 06 Jul 2006 02:07:03 +0000
parents
children 42d4e99a075e
comparison
equal deleted inserted replaced
18913:2dc84d07332c 18914:d450ec82ae57
1 /*
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 program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA
20 */
21
22 #include <windows.h>
23 #include <commctrl.h>
24 #include <interface.h>
25 #include <mp_msg.h>
26 #include <help_mp.h>
27 #include <libmpdemux/stream.h>
28 #include <libmpdemux/demuxer.h>
29 #include <libmpdemux/stheader.h>
30 #include "gui.h"
31 #include "wincfg.h"
32 #include "dialogs.h"
33
34 WNDPROC OldUrlWndProc;
35 LRESULT CALLBACK SubUrlWndProc(HWND, UINT, WPARAM, LPARAM);
36 extern int vo_gamma_brightness;
37 extern int vo_gamma_saturation;
38 extern int vo_gamma_contrast;
39 extern int vo_gamma_hue;
40 extern int set_video_colors(sh_video_t *sh_video, char *item, int value);
41 extern int get_video_colors(sh_video_t *sh_video, char *item, int *value);
42
43 guiInterface_t guiIntfStruct;
44 int addurl = 0;
45
46 #ifdef USE_SUB
47 extern mp_osd_obj_t* vo_osd_list;
48 extern char **sub_name;
49
50 void guiLoadSubtitle(char *name)
51 {
52 if (!guiIntfStruct.Playing)
53 {
54 guiIntfStruct.SubtitleChanged = 1;
55 return;
56 }
57 if (subdata)
58 {
59 mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_DeletingSubtitles);
60 sub_free(subdata);
61 subdata = NULL;
62 vo_sub = NULL;
63 if (vo_osd_list)
64 {
65 int len;
66 mp_osd_obj_t *osd = vo_osd_list;
67 while (osd)
68 {
69 if (osd->type == OSDTYPE_SUBTITLE) break;
70 osd = osd->next;
71 }
72 if (osd && osd->flags & OSDFLAG_VISIBLE)
73 {
74 len = osd->stride * (osd->bbox.y2 - osd->bbox.y1);
75 memset(osd->bitmap_buffer, 0, len);
76 memset(osd->alpha_buffer, 0, len);
77 }
78 }
79 }
80
81 if (name)
82 {
83 mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_LoadingSubtitles, name);
84 subdata = sub_read_file(strdup(name), guiIntfStruct.FPS);
85 if (!subdata) mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_CantLoadSub,name);
86 sub_name = (malloc(2 * sizeof(char*))); /* when mplayer will be restarted */
87 sub_name[0] = strdup(name); /* sub_name[0] will be read */
88 sub_name[1] = NULL;
89 }
90 update_set_of_subtitles();
91 }
92 #endif
93
94 int display_openfilewindow(gui_t *gui, int add)
95 {
96 OPENFILENAME fileopen;
97 int result = 0;
98 char filelist[MAXFILE];
99 char filename[MAX_PATH];
100 char directory[MAX_PATH];
101 char *filespec = NULL;
102 char *filepart = NULL;
103
104 memset(&fileopen, 0, sizeof(OPENFILENAME));
105 memset(filelist, 0, sizeof(filelist));
106
107 fileopen.lStructSize = sizeof(OPENFILENAME);
108 fileopen.hwndOwner = gui->mainwindow;
109 fileopen.hInstance = GetModuleHandle(NULL);
110 fileopen.lpstrFilter = "All Files (*.*)\0*.*\0"
111 "Media Files (*.avi;*.asf;*.wmv;*.mpg;*.mpeg;*.m2v;*.mov;\
112 *.rmvb;*.rm;*.ogm;*.mp3;*.wav;*.wma;*.ra;*.ogg)\0\
113 *.avi;*.asf;*.wmv;*.mpg;*.mpeg;*.m2v;*.mov;\
114 *.rmvb;*.rm;*.ogm;*.mp3;*.wav;*.wma;*.ra;*.ogg\0"
115 "Video Files (*.avi;*.mpg;*.mpeg;*.mov)\0*.avi;*.mpg;*.mpeg;*.mov\0"
116 "Avisynth Scripts (*.avs)\0*.avs\0"
117 "Audio Files (*.mp3;*.wav;*.ra)\0*.mp3;*.wav;*.ra\000";
118 fileopen.nFilterIndex = 0;
119 fileopen.lpstrTitle = "Add file(s)...";
120 fileopen.Flags = OFN_ALLOWMULTISELECT | OFN_FILEMUSTEXIST| OFN_LONGNAMES | OFN_EXPLORER| OFN_READONLY | OFN_HIDEREADONLY;
121 fileopen.lpstrFile = filelist;
122 fileopen.lpstrCustomFilter = NULL;
123 fileopen.nMaxFile = MAXFILE;
124
125 if(GetOpenFileName(&fileopen))
126 {
127 /* clear playlist */
128 if(!add) gui->playlist->clear_playlist(gui->playlist);
129
130 memcpy(directory, fileopen.lpstrFile, fileopen.nFileOffset - 1);
131 directory[fileopen.nFileOffset - 1] = 0;
132
133 do
134 {
135 filespec = &fileopen.lpstrFile[fileopen.nFileOffset];
136 filename[0] = 0;
137 strcat(filename, directory);
138 strcat(filename, "\\");
139 strcat(filename, filespec);
140
141 if (GetFileAttributes(filename) & FILE_ATTRIBUTE_DIRECTORY)
142 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] %s is a directory, skipping...\n", filename);
143 else
144 {
145 if (GetFullPathName(filename, MAX_PATH, filename, &filepart))
146 {
147 if(!parse_filename(filename, playtree, mconfig, add? 0 : 1))
148 gui->playlist->add_track(gui->playlist, filename, NULL, filepart, 0);
149 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Adding file: %s - path %s\n", filespec, filename);
150 result++;
151 }
152 }
153 fileopen.nFileOffset += strlen(filespec) + 1;
154 } while (*filespec);
155 }
156 return result;
157 }
158
159 #ifdef USE_SUB
160 void display_opensubtitlewindow(gui_t *gui)
161 {
162 OPENFILENAME subtitleopen;
163 char subtitlefile[MAX_PATH];
164
165 /* Safety check */
166 if (guiIntfStruct.Playing == 0 || !guiIntfStruct.sh_video) return;
167
168 memset(&subtitleopen, 0, sizeof(OPENFILENAME));
169 memset(subtitlefile, 0, sizeof(subtitlefile));
170
171 subtitleopen.lStructSize = sizeof(OPENFILENAME);
172 subtitleopen.hwndOwner = gui->mainwindow;
173 subtitleopen.hInstance = GetModuleHandle(NULL);
174 subtitleopen.lpstrFilter = "All Files (*.*)\0*.*\0"
175 "Subtitle Files (*.srt;*.txt;*.vob)\0*.srt;*.txt;*.vob\0";
176 subtitleopen.nFilterIndex = 0;
177 subtitleopen.lpstrTitle = "Add Subtitle...";
178 subtitleopen.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_EXPLORER | OFN_READONLY | OFN_HIDEREADONLY;
179 subtitleopen.lpstrFile = subtitlefile;
180 subtitleopen.lpstrCustomFilter = NULL;
181 subtitleopen.nMaxFile = MAXFILE;
182
183 if(GetOpenFileName(&subtitleopen))
184 guiLoadSubtitle(subtitlefile);
185 }
186 #endif
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 PostQuitMessage (0);
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 if(add) addurl = 1;
378 HWND hWnd;
379 HINSTANCE hInstance = GetModuleHandle(NULL);
380 WNDCLASS wc;
381 int x, y;
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 HWND tracklist = GetDlgItem(hwnd, ID_TRACKLIST);
429 /* clear listbox */
430 SendMessage(tracklist, LB_RESETCONTENT, 0, 0);
431 for (i=0; i < gui->playlist->trackcount; i++)
432 if (gui->playlist->tracks[i]->title)
433 SendMessage(tracklist, LB_ADDSTRING, 0, (LPARAM)gui->playlist->tracks[i]->title);
434 else
435 SendMessage(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 HWND tracklist = GetDlgItem(hwnd, ID_TRACKLIST);
521 int selected = 0;
522 int i;
523 for (i=0; i<pl->trackcount; i++)
524 if(0 < SendMessage(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 if(selected) pl->current = selected - 1;
534 mplGotoTheNext = 0;
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_PLAY:
551 {
552 if(selected) pl->current = selected - 1;
553 mplGotoTheNext = 0;
554 gui->startplay(gui);
555 break;
556 }
557 case ID_REMOVE:
558 if(selected) pl->remove_track(pl, selected);
559 break;
560 case ID_ADDFILE:
561 {
562 if(guiIntfStruct.StreamType == STREAMTYPE_DVD ||
563 guiIntfStruct.StreamType == STREAMTYPE_DVDNAV) return 0;
564 display_openfilewindow(gui, 1);
565 break;
566 }
567 case ID_ADDURL:
568 {
569 if(guiIntfStruct.StreamType == STREAMTYPE_DVD ||
570 guiIntfStruct.StreamType == STREAMTYPE_DVDNAV) return 0;
571 display_openurlwindow(gui, 1);
572 break;
573 }
574 case ID_CLEAR:
575 {
576 if(!gui->playlist->trackcount) return 0;
577 gui->playlist->clear_playlist(gui->playlist);
578 break;
579 }
580 case ID_PLAYLISTLOAD:
581 {
582 if(guiIntfStruct.StreamType == STREAMTYPE_DVD ||
583 guiIntfStruct.StreamType == STREAMTYPE_DVDNAV) return 0;
584 display_loadplaylistwindow(gui);
585 break;
586 }
587 case ID_PLAYLISTSAVE:
588 {
589 /* no point saving an empty playlist */
590 if(!gui->playlist->trackcount ||
591 guiIntfStruct.StreamType == STREAMTYPE_DVD ||
592 guiIntfStruct.StreamType == STREAMTYPE_DVDNAV)
593 return 0;
594 display_saveplaylistwindow(gui);
595 break;
596 }
597 }
598 updatetracklist(hwnd);
599 if(selected < 1) selected = 1;
600 else if(selected>pl->trackcount) selected = pl->trackcount;
601 SendMessage(tracklist, LB_SETCURSEL, selected - 1, 0);
602 return 0;
603 }
604 case WM_DROPFILES:
605 {
606 char file[MAX_PATH];
607 int filecount = DragQueryFile((HDROP) wParam, -1, file, MAX_PATH);
608 int i;
609 for (i=0; i<filecount; i++)
610 {
611 DragQueryFile((HDROP) wParam, i, file, MAX_PATH);
612 if(!parse_filename(file, playtree, mconfig, 0))
613 pl->add_track(pl, file, NULL, NULL, 0);
614 }
615 DragFinish((HDROP) wParam);
616 updatetracklist(hwnd);
617 }
618 break;
619 case WM_DESTROY:
620 PostQuitMessage(0);
621 return 0;
622 }
623 return DefWindowProc(hwnd, iMsg, wParam, lParam);
624 }
625
626 void update_playlistwindow(void)
627 {
628 HWND hWnd = FindWindow(NULL, "MPlayer Playlist");
629 if (hWnd) updatetracklist(hWnd);
630 }
631
632 void display_playlistwindow(gui_t *gui)
633 {
634 HWND hWnd = FindWindow(NULL, "MPlayer Playlist");
635 if (hWnd)
636 {
637 SendMessage(hWnd, WM_CLOSE, 0, 0);
638 return;
639 }
640
641 HINSTANCE hInstance = GetModuleHandle(NULL);
642 WNDCLASS wc;
643 int x, y;
644
645 wc.style = CS_HREDRAW | CS_VREDRAW;
646 wc.lpfnWndProc = PlayListWndProc;
647 wc.cbClsExtra = 0;
648 wc.cbWndExtra = 0;
649 wc.hInstance = hInstance;
650 wc.hCursor = LoadCursor(NULL,IDC_ARROW);
651 wc.hIcon = gui->icon;
652 wc.hbrBackground = SOLID_GREY2;
653 wc.lpszClassName = "MPlayer - Playlist";
654 wc.lpszMenuName = NULL;
655 RegisterClass(&wc);
656 create_playlistmenu(gui);
657 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (400 / 2); /* Erik: center popup window on screen */
658 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (254 / 2);
659 hWnd = CreateWindow("MPlayer - Playlist",
660 "MPlayer Playlist",
661 WS_POPUPWINDOW | WS_CAPTION | WS_MINIMIZEBOX,
662 x,
663 y,
664 400,
665 254,
666 NULL,
667 NULL,
668 hInstance,
669 NULL);
670 SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD)gui);
671 updatetracklist(hWnd);
672 DragAcceptFiles(hWnd,TRUE);
673 ShowWindow(hWnd, SW_SHOW);
674 UpdateWindow(hWnd);
675 }
676
677 static LRESULT CALLBACK SkinBrowserWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
678 {
679 static HWND listbox;
680 static char skinspath[MAX_PATH];
681 gui_t* gui = (gui_t*) GetWindowLongPtr(hwnd, GWLP_USERDATA);
682 switch (iMsg)
683 {
684 case WM_CREATE:
685 {
686 listbox = CreateWindow("listbox", NULL,
687 WS_CHILD | WS_VISIBLE | LBS_NOTIFY | LBS_NOINTEGRALHEIGHT |
688 LBS_DISABLENOSCROLL | WS_VSCROLL | WS_TABSTOP,
689 4, 5, 166, 60, hwnd,
690 (HMENU) ID_DIR,
691 ((LPCREATESTRUCT) lParam) -> hInstance,
692 NULL);
693 SendMessage(listbox, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
694
695 /* This opens the skins directory, lists the directory names, and adds them to the listbox */
696 sprintf(skinspath, "%s/*.", get_path("skins"));
697
698 HANDLE skinHandle = INVALID_HANDLE_VALUE;
699 WIN32_FIND_DATA finddata;
700
701 skinHandle = FindFirstFile(skinspath, &finddata);
702 if (skinHandle != INVALID_HANDLE_VALUE)
703 {
704 do
705 {
706 if (finddata.cFileName[0] == '.') continue;
707 /* populate the listbox */
708 capitalize(finddata.cFileName);
709 SendDlgItemMessage(hwnd, ID_DIR, LB_ADDSTRING, 0, (LPARAM) finddata.cFileName);
710 } while (FindNextFile(skinHandle, &finddata));
711 FindClose(skinHandle);
712 }
713 else
714 mp_msg(MSGT_GPLAYER, MSGL_FATAL, "Error opening %s\n", get_path("skins"));
715 break;
716 }
717 case WM_COMMAND:
718 {
719 if ((HWND) lParam == listbox)
720 {
721 if(HIWORD(wParam) == LBN_DBLCLK)
722 {
723 int index = SendMessage(listbox, LB_GETCURSEL, 0, 0);
724 int len = SendMessage(listbox, LB_GETTEXTLEN, index, 0);
725 if (len)
726 {
727 if (skinName) free(skinName);
728 skinName = (char *) malloc(len+1);
729 SendMessage(listbox, LB_GETTEXT, (WPARAM) index, (LPARAM) skinName);
730 /* fill out the full pathname to the skin */
731 strcpy(skinspath, get_path("skins"));
732 strcat(skinspath, "\\");
733 strcat(skinspath, skinName);
734 ShowWindow(hwnd, SW_HIDE);
735 Shell_NotifyIcon(NIM_DELETE, &nid);
736 destroy_window(gui);
737 create_window(gui, skinspath);
738 create_subwindow(gui, skinspath);
739 SendMessage(hwnd, WM_CLOSE, 0, 0); /* Avoid crashing when switching skin */
740 }
741 }
742 }
743 }
744 return 0;
745 case WM_DESTROY:
746 PostQuitMessage(0);
747 return 0;
748 }
749 return DefWindowProc(hwnd, iMsg, wParam, lParam);
750 }
751
752 void display_skinbrowser(gui_t* gui)
753 {
754 HWND hWnd = FindWindow(NULL, "Skin Browser");
755 if (hWnd)
756 {
757 SendMessage(hWnd, WM_CLOSE, 0, 0);
758 return;
759 }
760
761 HINSTANCE hInstance = GetModuleHandle(NULL);
762 WNDCLASS wc;
763 int x, y;
764
765 wc.style = CS_HREDRAW | CS_VREDRAW;
766 wc.lpfnWndProc = SkinBrowserWndProc;
767 wc.cbClsExtra = 0;
768 wc.cbWndExtra = 0;
769 wc.hInstance = hInstance;
770 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
771 wc.hIcon = gui->icon;
772 wc.hbrBackground = SOLID_GREY2;
773 wc.lpszClassName = "Skin Browser";
774 wc.lpszMenuName = NULL;
775 RegisterClass(&wc);
776 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (180 / 2);
777 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (102 / 2);
778 hWnd = CreateWindow("Skin Browser",
779 "Skin Browser",
780 WS_POPUPWINDOW |WS_CAPTION,
781 x,
782 y,
783 180,
784 102,
785 NULL,
786 NULL,
787 hInstance,
788 NULL);
789 SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD) gui);
790 ShowWindow(hWnd, SW_SHOW);
791 UpdateWindow(hWnd);
792 }
793
794 #ifdef USE_DVDREAD
795 static LRESULT CALLBACK TitleChapterWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
796 {
797 static HWND title;
798 static HWND chapter;
799 HWND wdg;
800 int i=0, j=0;
801 char titles[MAX_PATH] = "";
802 char chapters[MAX_PATH] = "";
803 switch (iMsg)
804 {
805 case WM_CREATE:
806 wdg = CreateWindow("button", "Ok",
807 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
808 4, 43, 80, 25, hwnd,
809 (HMENU) ID_OK,
810 ((LPCREATESTRUCT) lParam) -> hInstance,
811 NULL);
812 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
813
814 wdg = CreateWindow("button", "Cancel",
815 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
816 90, 43, 80, 25, hwnd,
817 (HMENU) ID_CANCEL,
818 ((LPCREATESTRUCT) lParam) -> hInstance,
819 NULL);
820 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
821
822 title = CreateWindow("combobox", NULL,
823 CBS_DROPDOWNLIST | CB_SHOWDROPDOWN | CBS_NOINTEGRALHEIGHT | CBS_HASSTRINGS |
824 WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP,
825 4, 10, 80, 160, hwnd,
826 (HMENU) ID_TITLESEL,
827 ((LPCREATESTRUCT) lParam) -> hInstance,
828 NULL);
829
830 SendMessage(title, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
831
832 chapter = CreateWindow("combobox", NULL,
833 CBS_DROPDOWNLIST | CB_SHOWDROPDOWN | CBS_NOINTEGRALHEIGHT | CBS_HASSTRINGS |
834 WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP,
835 90, 10, 80, 160, hwnd,
836 (HMENU) ID_CHAPTERSEL,
837 ((LPCREATESTRUCT) lParam) -> hInstance,
838 NULL);
839 SendMessage(chapter, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
840
841 for (i=0; i<guiIntfStruct.DVD.titles; i++)
842 {
843 /* we have to reverse the order here because of the way CB_INSERTSTRING adds items */
844 sprintf(&titles[i], "%d", guiIntfStruct.DVD.titles - i);
845 SendDlgItemMessage(hwnd, ID_TITLESEL, CB_INSERTSTRING, 0, (LPARAM) &titles[i]);
846 }
847 SendDlgItemMessage(hwnd, ID_TITLESEL, CB_SETCURSEL, dvd_title, 0);
848
849 for (j=0; j<guiIntfStruct.DVD.chapters; j++)
850 {
851 sprintf(&chapters[j], "%d", guiIntfStruct.DVD.chapters - j);
852 SendDlgItemMessage(hwnd, ID_CHAPTERSEL, CB_INSERTSTRING, 0, (LPARAM) &chapters[j]);
853 }
854 SendDlgItemMessage(hwnd, ID_CHAPTERSEL, CB_SETCURSEL, dvd_chapter, 0);
855
856 break;
857 case WM_COMMAND:
858 {
859 switch (LOWORD(wParam))
860 {
861 case ID_CANCEL:
862 DestroyWindow(hwnd);
863 return 0;
864 case ID_OK:
865 {
866 guiIntfStruct.DVD.current_title = SendMessage(title, CB_GETCURSEL, 0, 0) + 1;
867 guiIntfStruct.DVD.current_chapter = SendMessage(chapter, CB_GETCURSEL, 0, 0) + 1;
868
869 if((guiIntfStruct.DVD.current_title != 0 || guiIntfStruct.DVD.current_chapter != 0))
870 {
871 mplGotoTheNext = 0;
872 guiGetEvent(guiCEvent, (void *) guiSetStop);
873 guiGetEvent(guiCEvent, (void *) guiSetPlay);
874 DestroyWindow(hwnd);
875 }
876 }
877 break;
878 }
879 }
880 return 0;
881 case WM_DESTROY:
882 PostQuitMessage (0);
883 return 0;
884 }
885 return DefWindowProc(hwnd, iMsg, wParam, lParam);
886 }
887
888 void display_chapterselwindow(gui_t *gui)
889 {
890 HWND hWnd;
891 HINSTANCE hInstance = GetModuleHandle(NULL);
892 WNDCLASS wc;
893 int x, y;
894
895 if (guiIntfStruct.StreamType != STREAMTYPE_DVD) return;
896 if (FindWindow(NULL, "Select Title/Chapter...")) return;
897
898 wc.style = CS_HREDRAW | CS_VREDRAW;
899 wc.lpfnWndProc = TitleChapterWndProc;
900 wc.cbClsExtra = 0;
901 wc.cbWndExtra = 0;
902 wc.hInstance = hInstance;
903 wc.hCursor = LoadCursor(NULL,IDC_ARROW);
904 wc.hIcon = gui->icon;
905 wc.hbrBackground = SOLID_GREY2;
906 wc.lpszClassName = "Select Title/Chapter...";
907 wc.lpszMenuName = NULL;
908 RegisterClass(&wc);
909 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (180 / 2);
910 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (100 / 2);
911 hWnd = CreateWindow("Select Title/Chapter...",
912 "Select Title/Chapter...",
913 WS_POPUPWINDOW | WS_CAPTION,
914 x,
915 y,
916 180,
917 100,
918 NULL,
919 NULL,
920 hInstance,
921 NULL);
922 SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD) gui);
923 ShowWindow(hWnd, SW_SHOW);
924 UpdateWindow(hWnd);
925 }
926 #endif
927
928 static LRESULT CALLBACK EqWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
929 {
930 HWND btn, label, eq0, eq1, eq2, eq3;
931
932 switch (iMsg)
933 {
934 case WM_CREATE:
935 {
936 btn = CreateWindow("button", "Reset",
937 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
938 157, 143, 80, 25, hwnd,
939 (HMENU) ID_DEFAULTS,
940 ((LPCREATESTRUCT) lParam) -> hInstance,
941 NULL);
942 SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
943
944 btn = CreateWindow("button", "Close",
945 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
946 243, 143, 80, 25, hwnd,
947 (HMENU) ID_CLOSE,
948 ((LPCREATESTRUCT) lParam) -> hInstance,
949 NULL);
950 SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
951
952 label = CreateWindow("static", "Brightness",
953 WS_CHILD | WS_VISIBLE,
954 12, 122, 70, 15, hwnd,
955 NULL,
956 ((LPCREATESTRUCT) lParam) -> hInstance,
957 NULL);
958 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
959
960 label = CreateWindow("static", "Contrast",
961 WS_CHILD | WS_VISIBLE,
962 99, 122, 70, 15, hwnd,
963 NULL,
964 ((LPCREATESTRUCT) lParam) -> hInstance,
965 NULL);
966 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
967
968 label = CreateWindow("static", "Hue",
969 WS_CHILD | WS_VISIBLE,
970 191, 122, 70, 15, hwnd,
971 NULL,
972 ((LPCREATESTRUCT) lParam) -> hInstance, NULL);
973 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
974
975 label = CreateWindow("static", "Saturation",
976 WS_CHILD | WS_VISIBLE,
977 260, 122, 70, 15, hwnd,
978 NULL,
979 ((LPCREATESTRUCT) lParam) -> hInstance,
980 NULL);
981 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
982
983 eq0 = CreateWindow(TRACKBAR_CLASS, "brightness",
984 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED |
985 TBS_VERT | TBS_NOTICKS,
986 30, 0, 20, 120, hwnd,
987 (HMENU) ID_EQ0,
988 ((LPCREATESTRUCT) lParam) -> hInstance,
989 NULL);
990 SendDlgItemMessage(hwnd, ID_EQ0, TBM_SETRANGE, 1, MAKELONG(0, 200));
991
992 eq1 = CreateWindow(TRACKBAR_CLASS, "contrast",
993 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED |
994 TBS_VERT | TBS_NOTICKS,
995 112, 0, 20, 120, hwnd,
996 (HMENU) ID_EQ1,
997 ((LPCREATESTRUCT) lParam) -> hInstance,
998 NULL);
999 SendDlgItemMessage(hwnd, ID_EQ1, TBM_SETRANGE, 1, MAKELONG(0, 200));
1000
1001 eq2 = CreateWindow(TRACKBAR_CLASS, "hue",
1002 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED |
1003 TBS_VERT | TBS_NOTICKS,
1004 194, 0, 20, 120, hwnd,
1005 (HMENU) ID_EQ2,
1006 ((LPCREATESTRUCT) lParam) -> hInstance,
1007 NULL);
1008 SendDlgItemMessage(hwnd, ID_EQ2, TBM_SETRANGE, 1, MAKELONG(0, 200));
1009
1010 eq3 = CreateWindow(TRACKBAR_CLASS, "saturation",
1011 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED |
1012 TBS_VERT | TBS_NOTICKS,
1013 276, 0, 20, 120, hwnd,
1014 (HMENU) ID_EQ3,
1015 ((LPCREATESTRUCT) lParam) -> hInstance, NULL);
1016 SendDlgItemMessage(hwnd, ID_EQ3, TBM_SETRANGE, 1, MAKELONG(0, 200));
1017
1018 if(guiIntfStruct.sh_video && guiIntfStruct.Playing)
1019 {
1020 EnableWindow(eq0, 1); EnableWindow(eq1, 1); EnableWindow(eq2, 1); EnableWindow(eq3, 1);
1021 get_video_colors(guiIntfStruct.sh_video, "brightness", &vo_gamma_brightness);
1022 get_video_colors(guiIntfStruct.sh_video, "contrast", &vo_gamma_contrast);
1023 get_video_colors(guiIntfStruct.sh_video, "hue", &vo_gamma_hue);
1024 get_video_colors(guiIntfStruct.sh_video, "saturation", &vo_gamma_saturation);
1025 }
1026 SendDlgItemMessage(hwnd, ID_EQ0, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_brightness);
1027 SendDlgItemMessage(hwnd, ID_EQ1, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_contrast);
1028 SendDlgItemMessage(hwnd, ID_EQ2, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_hue);
1029 SendDlgItemMessage(hwnd, ID_EQ3, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_saturation);
1030 break;
1031 }
1032 case WM_VSCROLL:
1033 {
1034 switch (LOWORD(wParam))
1035 {
1036 case TB_THUMBTRACK:
1037 if(guiIntfStruct.sh_video && guiIntfStruct.Playing)
1038 {
1039 vo_gamma_brightness = 100 - SendDlgItemMessage(hwnd, ID_EQ0, TBM_GETPOS, 0, 0);
1040 set_video_colors(guiIntfStruct.sh_video, "brightness", vo_gamma_brightness);
1041
1042 vo_gamma_contrast = 100 - SendDlgItemMessage(hwnd, ID_EQ1, TBM_GETPOS, 0, 0);
1043 set_video_colors(guiIntfStruct.sh_video, "contrast", vo_gamma_contrast);
1044
1045 vo_gamma_hue = 100 - SendDlgItemMessage(hwnd, ID_EQ2, TBM_GETPOS, 0, 0);
1046 set_video_colors(guiIntfStruct.sh_video, "hue", vo_gamma_hue);
1047
1048 vo_gamma_saturation = 100 - SendDlgItemMessage(hwnd, ID_EQ3, TBM_GETPOS, 0, 0);
1049 set_video_colors(guiIntfStruct.sh_video, "saturation", vo_gamma_saturation);
1050 }
1051 else
1052 {
1053 EnableWindow(GetDlgItem(hwnd, ID_EQ0), 0);
1054 EnableWindow(GetDlgItem(hwnd, ID_EQ1), 0);
1055 EnableWindow(GetDlgItem(hwnd, ID_EQ2), 0);
1056 EnableWindow(GetDlgItem(hwnd, ID_EQ3), 0);
1057 }
1058 break;
1059 }
1060 }
1061 case WM_CTLCOLORDLG:
1062 case WM_CTLCOLORSTATIC:
1063 {
1064 HDC hdc = (HDC)wParam;
1065 SetBkMode(hdc, TRANSPARENT);
1066 return (INT_PTR)SOLID_GREY2;
1067 }
1068 break;
1069 case WM_COMMAND:
1070 {
1071 switch (LOWORD(wParam))
1072 {
1073 case ID_CLOSE:
1074 DestroyWindow(hwnd);
1075 return 0;
1076 case ID_DEFAULTS:
1077 if(guiIntfStruct.sh_video && guiIntfStruct.Playing)
1078 {
1079 vo_gamma_brightness=0;
1080 SendDlgItemMessage(hwnd, ID_EQ0, TBM_SETPOS, 1, (LPARAM)100);
1081 set_video_colors(guiIntfStruct.sh_video, "brightness", vo_gamma_brightness);
1082
1083 vo_gamma_contrast=0;
1084 SendDlgItemMessage(hwnd, ID_EQ1, TBM_SETPOS, 1, (LPARAM)100);
1085 set_video_colors(guiIntfStruct.sh_video, "contrast", vo_gamma_contrast);
1086
1087 vo_gamma_hue=0;
1088 SendDlgItemMessage(hwnd, ID_EQ2, TBM_SETPOS, 1, (LPARAM)100);
1089 set_video_colors(guiIntfStruct.sh_video, "hue", vo_gamma_hue);
1090
1091 vo_gamma_saturation=0;
1092 SendDlgItemMessage(hwnd, ID_EQ3, TBM_SETPOS, 1, (LPARAM)100);
1093 set_video_colors(guiIntfStruct.sh_video, "saturation", vo_gamma_saturation);
1094 }
1095 break;
1096 }
1097 }
1098 return 0;
1099 case WM_DESTROY:
1100 PostQuitMessage (0);
1101 return 0;
1102 }
1103 return DefWindowProc(hwnd, iMsg, wParam, lParam);
1104 }
1105
1106 void display_eqwindow(gui_t *gui)
1107 {
1108 if(!guiIntfStruct.sh_video) return;
1109
1110 HWND hWnd;
1111 HINSTANCE hInstance = GetModuleHandle(NULL);
1112 WNDCLASS wc;
1113 int x, y;
1114 if(FindWindow(NULL, "MPlayer - Equalizer")) return;
1115 wc.style = CS_HREDRAW | CS_VREDRAW;
1116 wc.lpfnWndProc = EqWndProc;
1117 wc.cbClsExtra = 0;
1118 wc.cbWndExtra = 0;
1119 wc.hInstance = hInstance;
1120 wc.hCursor = LoadCursor(NULL,IDC_ARROW);
1121 wc.hIcon = gui->icon;
1122 wc.hbrBackground = SOLID_GREY2;
1123 wc.lpszClassName = "MPlayer - Equalizer";
1124 wc.lpszMenuName = NULL;
1125 RegisterClass(&wc);
1126 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (332 / 2);
1127 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (200 / 2);
1128 hWnd = CreateWindow("MPlayer - Equalizer",
1129 "MPlayer - Equalizer",
1130 WS_POPUPWINDOW | WS_CAPTION,
1131 x,
1132 y,
1133 332,
1134 200,
1135 NULL,
1136 NULL,
1137 hInstance,
1138 NULL);
1139 SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD) gui);
1140 ShowWindow(hWnd, SW_SHOW);
1141 UpdateWindow(hWnd);
1142 }