Mercurial > mplayer.hg
annotate gui/win32/dialogs.c @ 34634:0ef7177a063b
Fix linking after FFmpeg merge.
Protocols that are available only when librtmp is present
are no longer disabled in the code, so we have to remove
them in our configure.
author | iive |
---|---|
date | Tue, 14 Feb 2012 16:50:42 +0000 |
parents | 5a45efc630b8 |
children | ac6b38cd0d45 |
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; | |
34163 | 113 fileopen.lpstrTitle = acp(MSGTR_FileSelect); |
23077 | 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]; | |
34093 | 130 strcpy(filename, directory); |
131 | |
132 if (*filespec) | |
133 { | |
34094 | 134 strcat(filename, "/"); |
135 strcat(filename, filespec); | |
34093 | 136 } |
23077 | 137 |
138 if (GetFileAttributes(filename) & FILE_ATTRIBUTE_DIRECTORY) | |
139 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] %s is a directory, skipping...\n", filename); | |
140 else | |
141 { | |
142 if (GetFullPathName(filename, MAX_PATH, filename, &filepart)) | |
143 { | |
33555 | 144 uiSetFileName(NULL, filename, STREAMTYPE_FILE); |
23077 | 145 if(!parse_filename(filename, playtree, mconfig, 0)) |
146 gui->playlist->add_track(gui->playlist, filename, NULL, filepart, 0); | |
147 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Adding file: %s - path %s\n", filespec, filename); | |
148 result++; | |
149 } | |
150 } | |
151 fileopen.nFileOffset += strlen(filespec) + 1; | |
152 } while (*filespec); | |
153 } | |
154 return result; | |
155 } | |
156 | |
157 void display_opensubtitlewindow(gui_t *gui) | |
158 { | |
159 OPENFILENAME subtitleopen; | |
160 char subtitlefile[MAX_PATH]; | |
161 | |
162 /* Safety check */ | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
163 if (guiInfo.Playing == GUI_STOP || !guiInfo.sh_video) return; |
23077 | 164 |
165 memset(&subtitleopen, 0, sizeof(OPENFILENAME)); | |
166 memset(subtitlefile, 0, sizeof(subtitlefile)); | |
167 | |
168 subtitleopen.lStructSize = sizeof(OPENFILENAME); | |
169 subtitleopen.hwndOwner = gui->mainwindow; | |
170 subtitleopen.hInstance = GetModuleHandle(NULL); | |
171 subtitleopen.lpstrFilter = "All Files (*.*)\0*.*\0" | |
172 "Subtitle Files (*.srt;*.txt;*.vob)\0*.srt;*.txt;*.vob\0"; | |
173 subtitleopen.nFilterIndex = 0; | |
34163 | 174 subtitleopen.lpstrTitle = acp(MSGTR_SubtitleSelect); |
23077 | 175 subtitleopen.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_EXPLORER | OFN_READONLY | OFN_HIDEREADONLY; |
176 subtitleopen.lpstrFile = subtitlefile; | |
177 subtitleopen.lpstrCustomFilter = NULL; | |
178 subtitleopen.nMaxFile = MAXFILE; | |
179 | |
180 if(GetOpenFileName(&subtitleopen)) | |
33763 | 181 mplayerLoadSubtitle(subtitlefile); |
23077 | 182 } |
183 | |
33579 | 184 static void display_loadplaylistwindow(gui_t *gui) |
23077 | 185 { |
186 OPENFILENAME playlistopen; | |
187 char playlistfile[MAX_PATH]; | |
188 | |
189 memset(&playlistopen, 0, sizeof(OPENFILENAME)); | |
190 memset(playlistfile, 0, sizeof(playlistfile)); | |
191 | |
192 playlistopen.lStructSize = sizeof(OPENFILENAME); | |
193 playlistopen.hwndOwner = gui->mainwindow; | |
194 playlistopen.hInstance = GetModuleHandle(NULL); | |
195 playlistopen.lpstrFilter = "All Files (*.*)\0*.*\0" | |
196 "Playlist Files (*.m3u;*.pls;*.txt)\0*.m3u;*.pls;*.txt\0"; | |
197 playlistopen.nFilterIndex = 0; | |
34163 | 198 playlistopen.lpstrTitle = acp(MSGTR_PlaylistSelect); |
23077 | 199 playlistopen.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_EXPLORER | OFN_READONLY | OFN_HIDEREADONLY; |
200 playlistopen.lpstrFile = playlistfile; | |
201 playlistopen.lpstrCustomFilter = NULL; | |
202 playlistopen.nMaxFile = MAXFILE; | |
203 | |
204 if(GetOpenFileName(&playlistopen)) | |
205 { | |
206 if(parse_filename(playlistfile, playtree, mconfig, 1)) | |
207 gui->startplay(gui); | |
208 } | |
209 } | |
210 | |
33579 | 211 static void display_saveplaylistwindow(gui_t* gui) |
23077 | 212 { |
213 OPENFILENAME playlistsave; | |
214 static FILE *playlist_file = NULL; | |
215 char playlistname[MAX_PATH]; | |
216 | |
217 memset(&playlistsave, 0, sizeof(OPENFILENAME)); | |
218 memset(playlistname, 0, sizeof(playlistname)); | |
219 | |
220 playlistsave.lStructSize = sizeof(OPENFILENAME); | |
221 playlistsave.hwndOwner = gui->mainwindow; | |
222 playlistsave.hInstance = GetModuleHandle(NULL); | |
223 playlistsave.lpstrFilter = "Playlist Files (*.pls)\0*.pls\0"; | |
224 playlistsave.nFilterIndex = 0; | |
34163 | 225 playlistsave.lpstrTitle = acp(MSGTR_PlaylistSave); |
23077 | 226 playlistsave.Flags = OFN_LONGNAMES | OFN_EXPLORER | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY; |
227 playlistsave.lpstrFile = playlistname; | |
228 playlistsave.lpstrCustomFilter = NULL; | |
229 playlistsave.nMaxFile = MAXFILE; | |
230 | |
231 if(GetSaveFileName(&playlistsave)) | |
232 { | |
233 int i=0; | |
234 HANDLE my_playlist; | |
235 | |
236 if(!strstr(playlistname, ".pls")) strcat(playlistname, ".pls"); | |
237 | |
238 my_playlist = CreateFile(playlistname, | |
239 GENERIC_WRITE, | |
240 0, | |
241 NULL, | |
242 CREATE_ALWAYS, | |
243 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, | |
244 NULL); | |
245 | |
246 if(my_playlist != INVALID_HANDLE_VALUE) | |
247 { | |
248 CloseHandle(my_playlist); /* close the file first so we can write to it */ | |
249 playlist_file = fopen(playlistsave.lpstrFile, "w"); | |
250 fprintf(playlist_file, "[playlist]\n"); | |
251 fprintf(playlist_file, "numberofentries=%d\n", gui->playlist->trackcount); | |
252 | |
253 for(i=0; i<(gui->playlist->trackcount); i++) | |
254 { | |
255 fprintf(playlist_file, "File%i=%s\n", i + 1, gui->playlist->tracks[i]->filename); | |
256 fprintf(playlist_file, "Length%i=-1\n", i + 1); | |
257 } | |
258 fclose(playlist_file); | |
259 } | |
260 } | |
261 } | |
262 | |
263 static LRESULT CALLBACK OpenUrlWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) | |
264 { | |
265 static HWND url; | |
266 HWND wdg; | |
267 FILE *f; | |
268 char *history = get_path("gui.url"); | |
269 gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA); | |
270 switch (iMsg) | |
271 { | |
272 case WM_CREATE: | |
34163 | 273 wdg = CreateWindow("button", acp(MSGTR_Ok), |
23077 | 274 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, |
275 4, 43, 80, 25, hwnd, | |
276 (HMENU) ID_OK, | |
277 ((LPCREATESTRUCT) lParam) -> hInstance, | |
278 NULL); | |
279 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
280 | |
34163 | 281 wdg = CreateWindow("button", acp(MSGTR_Cancel), |
23077 | 282 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, |
283 90, 43, 80, 25, hwnd, | |
284 (HMENU) ID_CANCEL, | |
285 ((LPCREATESTRUCT) lParam) -> hInstance, | |
286 NULL); | |
287 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
288 | |
289 url = wdg = CreateWindowEx(WS_EX_CLIENTEDGE, | |
290 "edit", NULL, | |
291 WS_CHILD | WS_VISIBLE | ES_LEFT | ES_AUTOHSCROLL, | |
292 4, 10, 300, 25, hwnd, | |
293 (HMENU) ID_URL, | |
294 ((LPCREATESTRUCT) lParam) -> hInstance, | |
295 NULL); | |
296 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
297 SendMessage(wdg, EM_SETLIMITTEXT, MAX_PATH, 0); | |
298 | |
299 /*subclass the edit box to capture the VK_RETURN key*/ | |
300 OldUrlWndProc = (WNDPROC)SetWindowLongPtr(url, GWLP_WNDPROC, (LONG_PTR)SubUrlWndProc); | |
301 | |
302 if((f = fopen(history, "r"))) | |
303 { | |
304 char lasturl[MAX_PATH]; | |
305 fgets(lasturl, MAX_PATH, f); | |
306 SendMessage(url, WM_SETTEXT, 0, (LPARAM) lasturl); | |
307 SendMessage(url, EM_SETSEL, 0, -1); | |
308 fclose(f); | |
309 } | |
310 break; | |
311 case WM_KEYDOWN: | |
312 switch (LOWORD(wParam)) | |
313 { | |
314 case VK_RETURN: | |
315 SendMessage(hwnd, WM_COMMAND, (WPARAM) ID_OK, 0); | |
316 break; | |
317 } | |
318 case WM_COMMAND: | |
319 { | |
320 switch (LOWORD(wParam)) | |
321 { | |
322 case ID_CANCEL: | |
323 DestroyWindow(hwnd); | |
324 return 0; | |
325 case ID_OK: | |
326 { | |
327 char file[MAX_PATH]; | |
328 SendMessage(url, WM_GETTEXT, MAX_PATH, (LPARAM) file); | |
33555 | 329 uiSetFileName(NULL, file, STREAMTYPE_STREAM); |
23077 | 330 if((f = fopen(history, "wt+"))) |
331 { | |
332 fprintf(f, file); | |
333 fclose(f); | |
334 } | |
335 if(!parse_filename(file, playtree, mconfig, addurl? 0 : 1)) | |
336 gui->playlist->add_track(gui->playlist, file, NULL, NULL, 0); | |
337 if(!addurl) | |
338 gui->startplay(gui); | |
339 else update_playlistwindow(); | |
340 DestroyWindow(hwnd); | |
341 } | |
342 break; | |
343 } | |
344 } | |
345 return 0; | |
346 case WM_DESTROY: | |
347 { | |
348 addurl = 0; | |
349 return 0; | |
350 } | |
351 } | |
352 return DefWindowProc(hwnd, iMsg, wParam, lParam); | |
353 } | |
354 | |
355 LRESULT CALLBACK SubUrlWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) | |
356 { | |
357 switch(iMsg) | |
358 { | |
359 case WM_KEYDOWN: | |
360 switch (LOWORD(wParam)) | |
361 { | |
362 case VK_RETURN: | |
34163 | 363 SendMessage(FindWindow(NULL, acp(MSGTR_Network)), WM_COMMAND, (WPARAM) ID_OK, 0); |
23077 | 364 break; |
365 } | |
366 } | |
367 return CallWindowProc(OldUrlWndProc, hwnd, iMsg, wParam, lParam); | |
368 } | |
369 | |
370 void display_openurlwindow(gui_t *gui, int add) | |
371 { | |
372 HWND hWnd; | |
373 HINSTANCE hInstance = GetModuleHandle(NULL); | |
374 WNDCLASS wc; | |
375 int x, y; | |
376 | |
377 if(add) addurl = 1; | |
34163 | 378 if(FindWindow(NULL, acp(MSGTR_Network))) return; |
23077 | 379 wc.style = CS_HREDRAW | CS_VREDRAW; |
380 wc.lpfnWndProc = OpenUrlWndProc; | |
381 wc.cbClsExtra = 0; | |
382 wc.cbWndExtra = 0; | |
383 wc.hInstance = hInstance; | |
384 wc.hCursor = LoadCursor(NULL,IDC_ARROW); | |
385 wc.hIcon = gui->icon; | |
386 wc.hbrBackground = SOLID_GREY2; | |
34163 | 387 wc.lpszClassName = acp(MSGTR_Network); |
23077 | 388 wc.lpszMenuName = NULL; |
389 RegisterClass(&wc); | |
390 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (320 / 2); | |
391 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (100 / 2); | |
34163 | 392 hWnd = CreateWindow(acp(MSGTR_Network), |
393 acp(MSGTR_Network), | |
23077 | 394 WS_POPUPWINDOW | WS_CAPTION, |
395 x, | |
396 y, | |
397 320, | |
398 100, | |
399 NULL, | |
400 NULL, | |
401 hInstance, | |
402 NULL); | |
33638
dbca6aa18b50
Cast new user data value in SetWindowLongPtr() to LONG_PTR.
ib
parents:
33615
diff
changeset
|
403 SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR) gui); |
23077 | 404 ShowWindow(hWnd, SW_SHOW); |
405 UpdateWindow(hWnd); | |
406 } | |
407 | |
408 static void create_playlistmenu(gui_t *gui) | |
409 { | |
410 gui->playlistmenu = CreatePopupMenu(); | |
34163 | 411 AppendMenu(gui->playlistmenu, MF_STRING, ID_ADDFILE, acp(MSGTR_PLAYLIST_AddFile)); |
412 AppendMenu(gui->playlistmenu, MF_STRING, ID_ADDURL, acp(MSGTR_PLAYLIST_AddURL)); | |
23077 | 413 AppendMenu(gui->playlistmenu, MF_SEPARATOR, 0, 0); |
34163 | 414 AppendMenu(gui->playlistmenu, MF_STRING, ID_REMOVE, acp(MSGTR_Remove)); |
415 AppendMenu(gui->playlistmenu, MF_STRING, ID_CLEAR, acp(MSGTR_Clear)); | |
23077 | 416 AppendMenu(gui->playlistmenu, MF_SEPARATOR, 0, 0); |
34163 | 417 AppendMenu(gui->playlistmenu, MF_STRING, ID_CLOSE, acp(MSGTR_Close)); |
23077 | 418 } |
419 | |
420 static void updatetracklist(HWND hwnd) | |
421 { | |
422 int i=0; | |
423 gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA); | |
424 /* clear listbox */ | |
425 SendDlgItemMessage(hwnd, ID_TRACKLIST, LB_RESETCONTENT, 0, 0); | |
426 for (i=0; i < gui->playlist->trackcount; i++) | |
427 if (gui->playlist->tracks[i]->title) | |
428 SendDlgItemMessage(hwnd, ID_TRACKLIST, LB_ADDSTRING, 0, (LPARAM)gui->playlist->tracks[i]->title); | |
429 else | |
430 SendDlgItemMessage(hwnd, ID_TRACKLIST, LB_ADDSTRING, 0, (LPARAM)gui->playlist->tracks[i]->filename); | |
431 } | |
432 | |
433 static LRESULT CALLBACK PlayListWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) | |
434 { | |
435 HWND wdg; | |
436 POINT cursor; | |
437 gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA); | |
438 playlist_t *pl = gui ? gui->playlist : NULL; | |
439 switch (iMsg) | |
440 { | |
441 case WM_CREATE: | |
442 { | |
34163 | 443 wdg = CreateWindow("button", acp(MSGTR_MENU_Play), |
23077 | 444 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, |
445 4, 10, 80, 25, hwnd, | |
446 (HMENU) ID_PLAY, | |
447 ((LPCREATESTRUCT) lParam) -> hInstance, | |
448 NULL); | |
449 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
450 | |
34163 | 451 wdg = CreateWindow ("button", acp(MSGTR_Up), |
23077 | 452 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, |
453 4, 37, 80, 25, hwnd, | |
454 (HMENU) ID_UP, | |
455 ((LPCREATESTRUCT) lParam) -> hInstance, | |
456 NULL); | |
457 SendMessage(wdg, WM_SETFONT,(WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
458 | |
34163 | 459 wdg = CreateWindow ("button", acp(MSGTR_Down), |
23077 | 460 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, |
461 4, 64, 80, 25, hwnd, | |
462 (HMENU) ID_DOWN, | |
463 ((LPCREATESTRUCT) lParam) -> hInstance, | |
464 NULL); | |
465 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0); | |
466 | |
34163 | 467 wdg = CreateWindow ("button", acp(MSGTR_Remove), |
23077 | 468 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, |
469 4, 91, 80, 25, hwnd, | |
470 (HMENU) ID_REMOVE, | |
471 ((LPCREATESTRUCT) lParam) -> hInstance, | |
472 NULL); | |
473 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0); | |
474 | |
34163 | 475 wdg = CreateWindow ("button", acp(MSGTR_Load), |
23077 | 476 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, |
477 4, 118, 80, 25, hwnd, | |
478 (HMENU) ID_PLAYLISTLOAD, | |
479 ((LPCREATESTRUCT) lParam) -> hInstance, | |
480 NULL); | |
481 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0); | |
482 | |
34163 | 483 wdg = CreateWindow ("button", acp(MSGTR_Save), |
23077 | 484 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, |
485 4, 145, 80, 25, hwnd, | |
486 (HMENU) ID_PLAYLISTSAVE, | |
487 ((LPCREATESTRUCT) lParam) -> hInstance, | |
488 NULL); | |
489 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0); | |
490 | |
34163 | 491 wdg = CreateWindow ("button", acp(MSGTR_Close), |
23077 | 492 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, |
493 4, 193, 80, 25, hwnd, | |
494 (HMENU) ID_CLOSE, | |
495 ((LPCREATESTRUCT) lParam) -> hInstance, | |
496 NULL); | |
497 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0); | |
498 | |
499 wdg = CreateWindow ("listbox", "tracklist", WS_CHILD | WS_VISIBLE | LBS_NOTIFY | WS_VSCROLL | | |
500 WS_HSCROLL | LBS_DISABLENOSCROLL, 92, 10, 300, 208, hwnd, (HMENU) ID_TRACKLIST, | |
501 ((LPCREATESTRUCT) lParam) -> hInstance, NULL); | |
502 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
503 SendMessage(wdg, LB_SETHORIZONTALEXTENT, MAX_PATH*4, 0); | |
504 break; | |
505 } | |
506 case WM_CONTEXTMENU: | |
507 { | |
508 GetCursorPos(&cursor); | |
509 SetForegroundWindow(hwnd); | |
510 TrackPopupMenu(gui->playlistmenu, 0, cursor.x, cursor.y, 0, hwnd, NULL); | |
511 break; | |
512 } | |
513 case WM_COMMAND: | |
514 { | |
515 int selected = 0; | |
516 int i; | |
517 for (i=0; i<pl->trackcount; i++) | |
518 if(0 < SendDlgItemMessage(hwnd, ID_TRACKLIST, LB_GETSEL, i, 0)) selected = i + 1; | |
519 switch (LOWORD(wParam)) | |
520 { | |
521 case ID_CLOSE: | |
522 DestroyWindow(hwnd); | |
523 return 0; | |
524 case ID_TRACKLIST: | |
525 if(HIWORD(wParam) == LBN_DBLCLK) | |
526 { | |
527 case ID_PLAY: | |
528 if(selected) pl->current = selected - 1; | |
34075 | 529 uiSetFileName(NULL, pl->tracks[pl->current]->filename, STREAMTYPE_FILE); |
23077 | 530 gui->startplay(gui); |
531 } | |
532 return 0; | |
533 case ID_UP: | |
534 { | |
535 if(selected) pl->moveup_track(pl, selected); | |
536 selected--; | |
537 break; | |
538 } | |
539 case ID_DOWN: | |
540 { | |
541 if(selected) pl->movedown_track(pl, selected); | |
542 selected++; | |
543 break; | |
544 } | |
545 case ID_REMOVE: | |
546 if(selected) pl->remove_track(pl, selected); | |
547 break; | |
548 case ID_ADDFILE: | |
549 { | |
33555 | 550 if(guiInfo.StreamType == STREAMTYPE_DVD || |
551 guiInfo.StreamType == STREAMTYPE_DVDNAV) return 0; | |
23077 | 552 display_openfilewindow(gui, 1); |
553 break; | |
554 } | |
555 case ID_ADDURL: | |
556 { | |
33555 | 557 if(guiInfo.StreamType == STREAMTYPE_DVD || |
558 guiInfo.StreamType == STREAMTYPE_DVDNAV) return 0; | |
23077 | 559 display_openurlwindow(gui, 1); |
560 break; | |
561 } | |
562 case ID_CLEAR: | |
563 { | |
564 if(!gui->playlist->trackcount) return 0; | |
565 gui->playlist->clear_playlist(gui->playlist); | |
566 break; | |
567 } | |
568 case ID_PLAYLISTLOAD: | |
569 { | |
33555 | 570 if(guiInfo.StreamType == STREAMTYPE_DVD || |
571 guiInfo.StreamType == STREAMTYPE_DVDNAV) return 0; | |
23077 | 572 display_loadplaylistwindow(gui); |
573 break; | |
574 } | |
575 case ID_PLAYLISTSAVE: | |
576 { | |
577 /* no point saving an empty playlist */ | |
578 if(!gui->playlist->trackcount || | |
33555 | 579 guiInfo.StreamType == STREAMTYPE_DVD || |
580 guiInfo.StreamType == STREAMTYPE_DVDNAV) | |
23077 | 581 return 0; |
582 display_saveplaylistwindow(gui); | |
583 break; | |
584 } | |
585 } | |
586 updatetracklist(hwnd); | |
587 if(selected < 1) selected = 1; | |
588 else if(selected>pl->trackcount) selected = pl->trackcount; | |
589 SendDlgItemMessage(hwnd, ID_TRACKLIST, LB_SETCURSEL, selected - 1, 0); | |
590 return 0; | |
591 } | |
592 case WM_DROPFILES: | |
593 { | |
594 char file[MAX_PATH]; | |
595 int filecount = DragQueryFile((HDROP) wParam, -1, file, MAX_PATH); | |
596 int i; | |
597 for (i=0; i<filecount; i++) | |
598 { | |
599 DragQueryFile((HDROP) wParam, i, file, MAX_PATH); | |
600 if(!parse_filename(file, playtree, mconfig, 0)) | |
601 pl->add_track(pl, file, NULL, NULL, 0); | |
602 } | |
603 DragFinish((HDROP) wParam); | |
604 updatetracklist(hwnd); | |
605 } | |
606 break; | |
607 } | |
608 return DefWindowProc(hwnd, iMsg, wParam, lParam); | |
609 } | |
610 | |
611 void update_playlistwindow(void) | |
612 { | |
34163 | 613 HWND hWnd = FindWindow(NULL, acp(MSGTR_PlayList)); |
23077 | 614 if (hWnd) updatetracklist(hWnd); |
615 } | |
616 | |
617 void display_playlistwindow(gui_t *gui) | |
618 { | |
34163 | 619 HWND hWnd = FindWindow(NULL, acp(MSGTR_PlayList)); |
23077 | 620 HINSTANCE hInstance = GetModuleHandle(NULL); |
621 WNDCLASS wc; | |
622 int x, y; | |
623 | |
624 if (hWnd) | |
625 { | |
626 SendMessage(hWnd, WM_CLOSE, 0, 0); | |
627 return; | |
628 } | |
629 | |
630 wc.style = CS_HREDRAW | CS_VREDRAW; | |
631 wc.lpfnWndProc = PlayListWndProc; | |
632 wc.cbClsExtra = 0; | |
633 wc.cbWndExtra = 0; | |
634 wc.hInstance = hInstance; | |
635 wc.hCursor = LoadCursor(NULL,IDC_ARROW); | |
636 wc.hIcon = gui->icon; | |
637 wc.hbrBackground = SOLID_GREY2; | |
34163 | 638 wc.lpszClassName = acp(MSGTR_PlayList); |
23077 | 639 wc.lpszMenuName = NULL; |
640 RegisterClass(&wc); | |
641 create_playlistmenu(gui); | |
642 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (400 / 2); /* Erik: center popup window on screen */ | |
643 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (254 / 2); | |
34163 | 644 hWnd = CreateWindow(acp(MSGTR_PlayList), |
645 acp(MSGTR_PlayList), | |
23077 | 646 WS_POPUPWINDOW | WS_CAPTION | WS_MINIMIZEBOX, |
647 x, | |
648 y, | |
649 400, | |
650 254, | |
651 NULL, | |
652 NULL, | |
653 hInstance, | |
654 NULL); | |
33638
dbca6aa18b50
Cast new user data value in SetWindowLongPtr() to LONG_PTR.
ib
parents:
33615
diff
changeset
|
655 SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)gui); |
23077 | 656 updatetracklist(hWnd); |
657 DragAcceptFiles(hWnd,TRUE); | |
658 ShowWindow(hWnd, SW_SHOW); | |
659 UpdateWindow(hWnd); | |
660 } | |
661 | |
662 static LRESULT CALLBACK SkinBrowserWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) | |
663 { | |
664 static HWND listbox; | |
665 static char skinspath[MAX_PATH]; | |
33735 | 666 gui_t* mygui = (gui_t*) GetWindowLongPtr(hwnd, GWLP_USERDATA); |
23077 | 667 switch (iMsg) |
668 { | |
669 case WM_CREATE: | |
670 { | |
671 HANDLE skinHandle = INVALID_HANDLE_VALUE; | |
672 WIN32_FIND_DATA finddata; | |
673 | |
674 listbox = CreateWindow("listbox", NULL, | |
675 WS_CHILD | WS_VISIBLE | LBS_NOTIFY | LBS_NOINTEGRALHEIGHT | | |
676 LBS_DISABLENOSCROLL | WS_VSCROLL | WS_TABSTOP, | |
677 4, 5, 166, 60, hwnd, | |
678 (HMENU) ID_DIR, | |
679 ((LPCREATESTRUCT) lParam) -> hInstance, | |
680 NULL); | |
681 SendMessage(listbox, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
682 | |
683 /* This opens the skins directory, lists the directory names, and adds them to the listbox */ | |
684 sprintf(skinspath, "%s/*.", get_path("skins")); | |
685 | |
686 skinHandle = FindFirstFile(skinspath, &finddata); | |
687 if (skinHandle != INVALID_HANDLE_VALUE) | |
688 { | |
689 do | |
690 { | |
691 if (finddata.cFileName[0] == '.') continue; | |
692 /* populate the listbox */ | |
693 capitalize(finddata.cFileName); | |
694 SendDlgItemMessage(hwnd, ID_DIR, LB_ADDSTRING, 0, (LPARAM) finddata.cFileName); | |
695 } while (FindNextFile(skinHandle, &finddata)); | |
696 FindClose(skinHandle); | |
697 } | |
698 else | |
699 mp_msg(MSGT_GPLAYER, MSGL_FATAL, "Error opening %s\n", get_path("skins")); | |
700 break; | |
701 } | |
702 case WM_COMMAND: | |
703 { | |
704 if ((HWND) lParam == listbox) | |
705 { | |
706 if(HIWORD(wParam) == LBN_DBLCLK) | |
707 { | |
708 int index = SendMessage(listbox, LB_GETCURSEL, 0, 0); | |
709 int len = SendMessage(listbox, LB_GETTEXTLEN, index, 0); | |
710 if (len) | |
711 { | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33725
diff
changeset
|
712 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
|
713 free(skinName); |
30702 | 714 skinName = malloc(len + 1); |
23077 | 715 SendMessage(listbox, LB_GETTEXT, (WPARAM) index, (LPARAM) skinName); |
716 /* fill out the full pathname to the skin */ | |
717 strcpy(skinspath, get_path("skins")); | |
34092
dbf5042ab255
Don't use the Windows style path separator character in Win32 GUI.
ib
parents:
34075
diff
changeset
|
718 strcat(skinspath, "/"); |
23077 | 719 strcat(skinspath, skinName); |
720 ShowWindow(hwnd, SW_HIDE); | |
721 Shell_NotifyIcon(NIM_DELETE, &nid); | |
33735 | 722 destroy_window(mygui); |
723 create_window(mygui, skinspath); | |
33782
896b427e598e
Remove unused parameter skindir from create_subwindow() in Win32 GUI.
ib
parents:
33775
diff
changeset
|
724 create_subwindow(mygui); |
23077 | 725 SendMessage(hwnd, WM_CLOSE, 0, 0); /* Avoid crashing when switching skin */ |
726 } | |
727 } | |
728 } | |
729 } | |
730 return 0; | |
731 } | |
732 return DefWindowProc(hwnd, iMsg, wParam, lParam); | |
733 } | |
734 | |
735 void display_skinbrowser(gui_t* gui) | |
736 { | |
34163 | 737 HWND hWnd = FindWindow(NULL, acp(MSGTR_SkinBrowser)); |
23077 | 738 HINSTANCE hInstance = GetModuleHandle(NULL); |
739 WNDCLASS wc; | |
740 int x, y; | |
741 | |
742 if (hWnd) | |
743 { | |
744 SendMessage(hWnd, WM_CLOSE, 0, 0); | |
745 return; | |
746 } | |
747 | |
748 wc.style = CS_HREDRAW | CS_VREDRAW; | |
749 wc.lpfnWndProc = SkinBrowserWndProc; | |
750 wc.cbClsExtra = 0; | |
751 wc.cbWndExtra = 0; | |
752 wc.hInstance = hInstance; | |
753 wc.hCursor = LoadCursor(NULL, IDC_ARROW); | |
754 wc.hIcon = gui->icon; | |
755 wc.hbrBackground = SOLID_GREY2; | |
34163 | 756 wc.lpszClassName = acp(MSGTR_SkinBrowser); |
23077 | 757 wc.lpszMenuName = NULL; |
758 RegisterClass(&wc); | |
759 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (180 / 2); | |
760 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (102 / 2); | |
34163 | 761 hWnd = CreateWindow(acp(MSGTR_SkinBrowser), |
762 acp(MSGTR_SkinBrowser), | |
23077 | 763 WS_POPUPWINDOW |WS_CAPTION, |
764 x, | |
765 y, | |
766 180, | |
767 102, | |
768 NULL, | |
769 NULL, | |
770 hInstance, | |
771 NULL); | |
33638
dbca6aa18b50
Cast new user data value in SetWindowLongPtr() to LONG_PTR.
ib
parents:
33615
diff
changeset
|
772 SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR) gui); |
23077 | 773 ShowWindow(hWnd, SW_SHOW); |
774 UpdateWindow(hWnd); | |
775 } | |
776 | |
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: | |
34163 | 789 wdg = CreateWindow("button", acp(MSGTR_Ok), |
23077 | 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 | |
34163 | 797 wdg = CreateWindow("button", acp(MSGTR_Cancel), |
23077 | 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 | |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33790
diff
changeset
|
824 for (i=0; i<guiInfo.Tracks; i++) |
23077 | 825 { |
826 /* 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
|
827 sprintf(&titles[i], "%d", guiInfo.Tracks - i); |
23077 | 828 SendDlgItemMessage(hwnd, ID_TITLESEL, CB_INSERTSTRING, 0, (LPARAM) &titles[i]); |
829 } | |
830 SendDlgItemMessage(hwnd, ID_TITLESEL, CB_SETCURSEL, dvd_title, 0); | |
831 | |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33790
diff
changeset
|
832 for (j=0; j<guiInfo.Chapters; j++) |
23077 | 833 { |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33790
diff
changeset
|
834 sprintf(&chapters[j], "%d", guiInfo.Chapters - j); |
23077 | 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 { | |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33790
diff
changeset
|
849 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
|
850 guiInfo.Chapter = SendMessage(chapter, CB_GETCURSEL, 0, 0) + 1; |
23077 | 851 |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33790
diff
changeset
|
852 if((guiInfo.Track != 0 || guiInfo.Chapter != 0)) |
23077 | 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 | |
33555 | 873 if (guiInfo.StreamType != STREAMTYPE_DVD) return; |
34382 | 874 if (FindWindow(NULL, acp(MSGTR_SelectTitleChapter))) return; |
23077 | 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; | |
34382 | 884 wc.lpszClassName = acp(MSGTR_SelectTitleChapter); |
23077 | 885 wc.lpszMenuName = NULL; |
886 RegisterClass(&wc); | |
887 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (180 / 2); | |
888 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (100 / 2); | |
34382 | 889 hWnd = CreateWindow(acp(MSGTR_SelectTitleChapter), |
890 acp(MSGTR_SelectTitleChapter), | |
23077 | 891 WS_POPUPWINDOW | WS_CAPTION, |
892 x, | |
893 y, | |
894 180, | |
895 100, | |
896 NULL, | |
897 NULL, | |
898 hInstance, | |
899 NULL); | |
33638
dbca6aa18b50
Cast new user data value in SetWindowLongPtr() to LONG_PTR.
ib
parents:
33615
diff
changeset
|
900 SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR) gui); |
23077 | 901 ShowWindow(hWnd, SW_SHOW); |
902 UpdateWindow(hWnd); | |
903 } | |
904 | |
905 static LRESULT CALLBACK EqWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) | |
906 { | |
907 HWND btn, label, eq0, eq1, eq2, eq3; | |
908 | |
909 switch (iMsg) | |
910 { | |
911 case WM_CREATE: | |
912 { | |
34163 | 913 btn = CreateWindow("button", acp(MSGTR_Clear), |
23077 | 914 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, |
915 157, 143, 80, 25, hwnd, | |
916 (HMENU) ID_DEFAULTS, | |
917 ((LPCREATESTRUCT) lParam) -> hInstance, | |
918 NULL); | |
919 SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
920 | |
34163 | 921 btn = CreateWindow("button", acp(MSGTR_Close), |
23077 | 922 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, |
923 243, 143, 80, 25, hwnd, | |
924 (HMENU) ID_CLOSE, | |
925 ((LPCREATESTRUCT) lParam) -> hInstance, | |
926 NULL); | |
927 SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
928 | |
34163 | 929 label = CreateWindow("static", acp(MSGTR_EQU_Brightness), |
23077 | 930 WS_CHILD | WS_VISIBLE, |
931 12, 122, 70, 15, hwnd, | |
932 NULL, | |
933 ((LPCREATESTRUCT) lParam) -> hInstance, | |
934 NULL); | |
935 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
936 | |
34163 | 937 label = CreateWindow("static", acp(MSGTR_EQU_Contrast), |
23077 | 938 WS_CHILD | WS_VISIBLE, |
939 99, 122, 70, 15, hwnd, | |
940 NULL, | |
941 ((LPCREATESTRUCT) lParam) -> hInstance, | |
942 NULL); | |
943 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
944 | |
34163 | 945 label = CreateWindow("static", acp(MSGTR_EQU_Hue), |
23077 | 946 WS_CHILD | WS_VISIBLE, |
947 191, 122, 70, 15, hwnd, | |
948 NULL, | |
949 ((LPCREATESTRUCT) lParam) -> hInstance, NULL); | |
950 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
951 | |
34163 | 952 label = CreateWindow("static", acp(MSGTR_EQU_Saturation), |
23077 | 953 WS_CHILD | WS_VISIBLE, |
954 260, 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 eq0 = CreateWindow(TRACKBAR_CLASS, "brightness", | |
961 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED | | |
962 TBS_VERT | TBS_NOTICKS, | |
963 30, 0, 20, 120, hwnd, | |
964 (HMENU) ID_EQ0, | |
965 ((LPCREATESTRUCT) lParam) -> hInstance, | |
966 NULL); | |
967 SendDlgItemMessage(hwnd, ID_EQ0, TBM_SETRANGE, 1, MAKELONG(0, 200)); | |
968 | |
969 eq1 = CreateWindow(TRACKBAR_CLASS, "contrast", | |
970 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED | | |
971 TBS_VERT | TBS_NOTICKS, | |
972 112, 0, 20, 120, hwnd, | |
973 (HMENU) ID_EQ1, | |
974 ((LPCREATESTRUCT) lParam) -> hInstance, | |
975 NULL); | |
976 SendDlgItemMessage(hwnd, ID_EQ1, TBM_SETRANGE, 1, MAKELONG(0, 200)); | |
977 | |
978 eq2 = CreateWindow(TRACKBAR_CLASS, "hue", | |
979 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED | | |
980 TBS_VERT | TBS_NOTICKS, | |
981 194, 0, 20, 120, hwnd, | |
982 (HMENU) ID_EQ2, | |
983 ((LPCREATESTRUCT) lParam) -> hInstance, | |
984 NULL); | |
985 SendDlgItemMessage(hwnd, ID_EQ2, TBM_SETRANGE, 1, MAKELONG(0, 200)); | |
986 | |
987 eq3 = CreateWindow(TRACKBAR_CLASS, "saturation", | |
988 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED | | |
989 TBS_VERT | TBS_NOTICKS, | |
990 276, 0, 20, 120, hwnd, | |
991 (HMENU) ID_EQ3, | |
992 ((LPCREATESTRUCT) lParam) -> hInstance, NULL); | |
993 SendDlgItemMessage(hwnd, ID_EQ3, TBM_SETRANGE, 1, MAKELONG(0, 200)); | |
994 | |
33555 | 995 if(guiInfo.sh_video && guiInfo.Playing) |
23077 | 996 { |
997 EnableWindow(eq0, 1); EnableWindow(eq1, 1); EnableWindow(eq2, 1); EnableWindow(eq3, 1); | |
33555 | 998 get_video_colors(guiInfo.sh_video, "brightness", &vo_gamma_brightness); |
999 get_video_colors(guiInfo.sh_video, "contrast", &vo_gamma_contrast); | |
1000 get_video_colors(guiInfo.sh_video, "hue", &vo_gamma_hue); | |
1001 get_video_colors(guiInfo.sh_video, "saturation", &vo_gamma_saturation); | |
23077 | 1002 } |
1003 SendDlgItemMessage(hwnd, ID_EQ0, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_brightness); | |
1004 SendDlgItemMessage(hwnd, ID_EQ1, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_contrast); | |
1005 SendDlgItemMessage(hwnd, ID_EQ2, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_hue); | |
1006 SendDlgItemMessage(hwnd, ID_EQ3, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_saturation); | |
1007 break; | |
1008 } | |
1009 case WM_VSCROLL: | |
1010 { | |
1011 switch (LOWORD(wParam)) | |
1012 { | |
1013 case TB_THUMBTRACK: | |
33555 | 1014 if(guiInfo.sh_video && guiInfo.Playing) |
23077 | 1015 { |
1016 vo_gamma_brightness = 100 - SendDlgItemMessage(hwnd, ID_EQ0, TBM_GETPOS, 0, 0); | |
33555 | 1017 set_video_colors(guiInfo.sh_video, "brightness", vo_gamma_brightness); |
23077 | 1018 |
1019 vo_gamma_contrast = 100 - SendDlgItemMessage(hwnd, ID_EQ1, TBM_GETPOS, 0, 0); | |
33555 | 1020 set_video_colors(guiInfo.sh_video, "contrast", vo_gamma_contrast); |
23077 | 1021 |
1022 vo_gamma_hue = 100 - SendDlgItemMessage(hwnd, ID_EQ2, TBM_GETPOS, 0, 0); | |
33555 | 1023 set_video_colors(guiInfo.sh_video, "hue", vo_gamma_hue); |
23077 | 1024 |
1025 vo_gamma_saturation = 100 - SendDlgItemMessage(hwnd, ID_EQ3, TBM_GETPOS, 0, 0); | |
33555 | 1026 set_video_colors(guiInfo.sh_video, "saturation", vo_gamma_saturation); |
23077 | 1027 } |
1028 else | |
1029 { | |
1030 EnableWindow(GetDlgItem(hwnd, ID_EQ0), 0); | |
1031 EnableWindow(GetDlgItem(hwnd, ID_EQ1), 0); | |
1032 EnableWindow(GetDlgItem(hwnd, ID_EQ2), 0); | |
1033 EnableWindow(GetDlgItem(hwnd, ID_EQ3), 0); | |
1034 } | |
1035 break; | |
1036 } | |
1037 } | |
1038 case WM_CTLCOLORDLG: | |
1039 case WM_CTLCOLORSTATIC: | |
1040 { | |
1041 HDC hdc = (HDC)wParam; | |
1042 SetBkMode(hdc, TRANSPARENT); | |
1043 return (INT_PTR)SOLID_GREY2; | |
1044 } | |
1045 break; | |
1046 case WM_COMMAND: | |
1047 { | |
1048 switch (LOWORD(wParam)) | |
1049 { | |
1050 case ID_CLOSE: | |
1051 DestroyWindow(hwnd); | |
1052 return 0; | |
1053 case ID_DEFAULTS: | |
33555 | 1054 if(guiInfo.sh_video && guiInfo.Playing) |
23077 | 1055 { |
1056 vo_gamma_brightness=0; | |
1057 SendDlgItemMessage(hwnd, ID_EQ0, TBM_SETPOS, 1, (LPARAM)100); | |
33555 | 1058 set_video_colors(guiInfo.sh_video, "brightness", vo_gamma_brightness); |
23077 | 1059 |
1060 vo_gamma_contrast=0; | |
1061 SendDlgItemMessage(hwnd, ID_EQ1, TBM_SETPOS, 1, (LPARAM)100); | |
33555 | 1062 set_video_colors(guiInfo.sh_video, "contrast", vo_gamma_contrast); |
23077 | 1063 |
1064 vo_gamma_hue=0; | |
1065 SendDlgItemMessage(hwnd, ID_EQ2, TBM_SETPOS, 1, (LPARAM)100); | |
33555 | 1066 set_video_colors(guiInfo.sh_video, "hue", vo_gamma_hue); |
23077 | 1067 |
1068 vo_gamma_saturation=0; | |
1069 SendDlgItemMessage(hwnd, ID_EQ3, TBM_SETPOS, 1, (LPARAM)100); | |
33555 | 1070 set_video_colors(guiInfo.sh_video, "saturation", vo_gamma_saturation); |
23077 | 1071 } |
1072 break; | |
1073 } | |
1074 } | |
1075 return 0; | |
1076 } | |
1077 return DefWindowProc(hwnd, iMsg, wParam, lParam); | |
1078 } | |
1079 | |
1080 void display_eqwindow(gui_t *gui) | |
1081 { | |
1082 HWND hWnd; | |
1083 HINSTANCE hInstance = GetModuleHandle(NULL); | |
1084 WNDCLASS wc; | |
1085 int x, y; | |
1086 | |
33555 | 1087 if(!guiInfo.sh_video) return; |
34163 | 1088 if(FindWindow(NULL, acp(MSGTR_Equalizer))) return; |
23077 | 1089 wc.style = CS_HREDRAW | CS_VREDRAW; |
1090 wc.lpfnWndProc = EqWndProc; | |
1091 wc.cbClsExtra = 0; | |
1092 wc.cbWndExtra = 0; | |
1093 wc.hInstance = hInstance; | |
1094 wc.hCursor = LoadCursor(NULL,IDC_ARROW); | |
1095 wc.hIcon = gui->icon; | |
1096 wc.hbrBackground = SOLID_GREY2; | |
34163 | 1097 wc.lpszClassName = acp(MSGTR_Equalizer); |
23077 | 1098 wc.lpszMenuName = NULL; |
1099 RegisterClass(&wc); | |
1100 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (332 / 2); | |
1101 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (200 / 2); | |
34163 | 1102 hWnd = CreateWindow(acp(MSGTR_Equalizer), |
1103 acp(MSGTR_Equalizer), | |
23077 | 1104 WS_POPUPWINDOW | WS_CAPTION, |
1105 x, | |
1106 y, | |
1107 332, | |
1108 200, | |
1109 NULL, | |
1110 NULL, | |
1111 hInstance, | |
1112 NULL); | |
33638
dbca6aa18b50
Cast new user data value in SetWindowLongPtr() to LONG_PTR.
ib
parents:
33615
diff
changeset
|
1113 SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR) gui); |
23077 | 1114 ShowWindow(hWnd, SW_SHOW); |
1115 UpdateWindow(hWnd); | |
1116 } |