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