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