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