Mercurial > mplayer.hg
annotate gui/win32/dialogs.c @ 34317:e905a896243d
Cosmetic: Rearrange and group GUI user events.
author | ib |
---|---|
date | Thu, 08 Dec 2011 15:38:35 +0000 |
parents | 95c396eb89ab |
children | 960c785cb6ef |
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 | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
777 #ifdef CONFIG_DVDREAD |
23077 | 778 static LRESULT CALLBACK TitleChapterWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) |
779 { | |
780 static HWND title; | |
781 static HWND chapter; | |
782 HWND wdg; | |
783 int i=0, j=0; | |
784 char titles[MAX_PATH] = ""; | |
785 char chapters[MAX_PATH] = ""; | |
786 gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA); | |
787 switch (iMsg) | |
788 { | |
789 case WM_CREATE: | |
34163 | 790 wdg = CreateWindow("button", acp(MSGTR_Ok), |
23077 | 791 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, |
792 4, 43, 80, 25, hwnd, | |
793 (HMENU) ID_OK, | |
794 ((LPCREATESTRUCT) lParam) -> hInstance, | |
795 NULL); | |
796 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
797 | |
34163 | 798 wdg = CreateWindow("button", acp(MSGTR_Cancel), |
23077 | 799 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, |
800 90, 43, 80, 25, hwnd, | |
801 (HMENU) ID_CANCEL, | |
802 ((LPCREATESTRUCT) lParam) -> hInstance, | |
803 NULL); | |
804 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
805 | |
806 title = CreateWindow("combobox", NULL, | |
807 CBS_DROPDOWNLIST | CB_SHOWDROPDOWN | CBS_NOINTEGRALHEIGHT | CBS_HASSTRINGS | | |
808 WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, | |
809 4, 10, 80, 160, hwnd, | |
810 (HMENU) ID_TITLESEL, | |
811 ((LPCREATESTRUCT) lParam) -> hInstance, | |
812 NULL); | |
813 | |
814 SendMessage(title, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
815 | |
816 chapter = CreateWindow("combobox", NULL, | |
817 CBS_DROPDOWNLIST | CB_SHOWDROPDOWN | CBS_NOINTEGRALHEIGHT | CBS_HASSTRINGS | | |
818 WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, | |
819 90, 10, 80, 160, hwnd, | |
820 (HMENU) ID_CHAPTERSEL, | |
821 ((LPCREATESTRUCT) lParam) -> hInstance, | |
822 NULL); | |
823 SendMessage(chapter, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
824 | |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33790
diff
changeset
|
825 for (i=0; i<guiInfo.Tracks; i++) |
23077 | 826 { |
827 /* 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
|
828 sprintf(&titles[i], "%d", guiInfo.Tracks - i); |
23077 | 829 SendDlgItemMessage(hwnd, ID_TITLESEL, CB_INSERTSTRING, 0, (LPARAM) &titles[i]); |
830 } | |
831 SendDlgItemMessage(hwnd, ID_TITLESEL, CB_SETCURSEL, dvd_title, 0); | |
832 | |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33790
diff
changeset
|
833 for (j=0; j<guiInfo.Chapters; j++) |
23077 | 834 { |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33790
diff
changeset
|
835 sprintf(&chapters[j], "%d", guiInfo.Chapters - j); |
23077 | 836 SendDlgItemMessage(hwnd, ID_CHAPTERSEL, CB_INSERTSTRING, 0, (LPARAM) &chapters[j]); |
837 } | |
838 SendDlgItemMessage(hwnd, ID_CHAPTERSEL, CB_SETCURSEL, dvd_chapter, 0); | |
839 | |
840 break; | |
841 case WM_COMMAND: | |
842 { | |
843 switch (LOWORD(wParam)) | |
844 { | |
845 case ID_CANCEL: | |
846 DestroyWindow(hwnd); | |
847 return 0; | |
848 case ID_OK: | |
849 { | |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33790
diff
changeset
|
850 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
|
851 guiInfo.Chapter = SendMessage(chapter, CB_GETCURSEL, 0, 0) + 1; |
23077 | 852 |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33790
diff
changeset
|
853 if((guiInfo.Track != 0 || guiInfo.Chapter != 0)) |
23077 | 854 { |
855 gui->startplay(gui); | |
856 DestroyWindow(hwnd); | |
857 } | |
858 } | |
859 break; | |
860 } | |
861 } | |
862 return 0; | |
863 } | |
864 return DefWindowProc(hwnd, iMsg, wParam, lParam); | |
865 } | |
866 | |
867 void display_chapterselwindow(gui_t *gui) | |
868 { | |
869 HWND hWnd; | |
870 HINSTANCE hInstance = GetModuleHandle(NULL); | |
871 WNDCLASS wc; | |
872 int x, y; | |
873 | |
33555 | 874 if (guiInfo.StreamType != STREAMTYPE_DVD) return; |
34163 | 875 if (FindWindow(NULL, acp(MSGTR_SelectChapter))) return; |
23077 | 876 |
877 wc.style = CS_HREDRAW | CS_VREDRAW; | |
878 wc.lpfnWndProc = TitleChapterWndProc; | |
879 wc.cbClsExtra = 0; | |
880 wc.cbWndExtra = 0; | |
881 wc.hInstance = hInstance; | |
882 wc.hCursor = LoadCursor(NULL,IDC_ARROW); | |
883 wc.hIcon = gui->icon; | |
884 wc.hbrBackground = SOLID_GREY2; | |
34163 | 885 wc.lpszClassName = acp(MSGTR_SelectChapter); |
23077 | 886 wc.lpszMenuName = NULL; |
887 RegisterClass(&wc); | |
888 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (180 / 2); | |
889 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (100 / 2); | |
34163 | 890 hWnd = CreateWindow(acp(MSGTR_SelectChapter), |
891 acp(MSGTR_SelectChapter), | |
23077 | 892 WS_POPUPWINDOW | WS_CAPTION, |
893 x, | |
894 y, | |
895 180, | |
896 100, | |
897 NULL, | |
898 NULL, | |
899 hInstance, | |
900 NULL); | |
33638
dbca6aa18b50
Cast new user data value in SetWindowLongPtr() to LONG_PTR.
ib
parents:
33615
diff
changeset
|
901 SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR) gui); |
23077 | 902 ShowWindow(hWnd, SW_SHOW); |
903 UpdateWindow(hWnd); | |
904 } | |
905 #endif | |
906 | |
907 static LRESULT CALLBACK EqWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) | |
908 { | |
909 HWND btn, label, eq0, eq1, eq2, eq3; | |
910 | |
911 switch (iMsg) | |
912 { | |
913 case WM_CREATE: | |
914 { | |
34163 | 915 btn = CreateWindow("button", acp(MSGTR_Clear), |
23077 | 916 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, |
917 157, 143, 80, 25, hwnd, | |
918 (HMENU) ID_DEFAULTS, | |
919 ((LPCREATESTRUCT) lParam) -> hInstance, | |
920 NULL); | |
921 SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
922 | |
34163 | 923 btn = CreateWindow("button", acp(MSGTR_Close), |
23077 | 924 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, |
925 243, 143, 80, 25, hwnd, | |
926 (HMENU) ID_CLOSE, | |
927 ((LPCREATESTRUCT) lParam) -> hInstance, | |
928 NULL); | |
929 SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
930 | |
34163 | 931 label = CreateWindow("static", acp(MSGTR_EQU_Brightness), |
23077 | 932 WS_CHILD | WS_VISIBLE, |
933 12, 122, 70, 15, hwnd, | |
934 NULL, | |
935 ((LPCREATESTRUCT) lParam) -> hInstance, | |
936 NULL); | |
937 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
938 | |
34163 | 939 label = CreateWindow("static", acp(MSGTR_EQU_Contrast), |
23077 | 940 WS_CHILD | WS_VISIBLE, |
941 99, 122, 70, 15, hwnd, | |
942 NULL, | |
943 ((LPCREATESTRUCT) lParam) -> hInstance, | |
944 NULL); | |
945 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
946 | |
34163 | 947 label = CreateWindow("static", acp(MSGTR_EQU_Hue), |
23077 | 948 WS_CHILD | WS_VISIBLE, |
949 191, 122, 70, 15, hwnd, | |
950 NULL, | |
951 ((LPCREATESTRUCT) lParam) -> hInstance, NULL); | |
952 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
953 | |
34163 | 954 label = CreateWindow("static", acp(MSGTR_EQU_Saturation), |
23077 | 955 WS_CHILD | WS_VISIBLE, |
956 260, 122, 70, 15, hwnd, | |
957 NULL, | |
958 ((LPCREATESTRUCT) lParam) -> hInstance, | |
959 NULL); | |
960 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); | |
961 | |
962 eq0 = CreateWindow(TRACKBAR_CLASS, "brightness", | |
963 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED | | |
964 TBS_VERT | TBS_NOTICKS, | |
965 30, 0, 20, 120, hwnd, | |
966 (HMENU) ID_EQ0, | |
967 ((LPCREATESTRUCT) lParam) -> hInstance, | |
968 NULL); | |
969 SendDlgItemMessage(hwnd, ID_EQ0, TBM_SETRANGE, 1, MAKELONG(0, 200)); | |
970 | |
971 eq1 = CreateWindow(TRACKBAR_CLASS, "contrast", | |
972 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED | | |
973 TBS_VERT | TBS_NOTICKS, | |
974 112, 0, 20, 120, hwnd, | |
975 (HMENU) ID_EQ1, | |
976 ((LPCREATESTRUCT) lParam) -> hInstance, | |
977 NULL); | |
978 SendDlgItemMessage(hwnd, ID_EQ1, TBM_SETRANGE, 1, MAKELONG(0, 200)); | |
979 | |
980 eq2 = CreateWindow(TRACKBAR_CLASS, "hue", | |
981 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED | | |
982 TBS_VERT | TBS_NOTICKS, | |
983 194, 0, 20, 120, hwnd, | |
984 (HMENU) ID_EQ2, | |
985 ((LPCREATESTRUCT) lParam) -> hInstance, | |
986 NULL); | |
987 SendDlgItemMessage(hwnd, ID_EQ2, TBM_SETRANGE, 1, MAKELONG(0, 200)); | |
988 | |
989 eq3 = CreateWindow(TRACKBAR_CLASS, "saturation", | |
990 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED | | |
991 TBS_VERT | TBS_NOTICKS, | |
992 276, 0, 20, 120, hwnd, | |
993 (HMENU) ID_EQ3, | |
994 ((LPCREATESTRUCT) lParam) -> hInstance, NULL); | |
995 SendDlgItemMessage(hwnd, ID_EQ3, TBM_SETRANGE, 1, MAKELONG(0, 200)); | |
996 | |
33555 | 997 if(guiInfo.sh_video && guiInfo.Playing) |
23077 | 998 { |
999 EnableWindow(eq0, 1); EnableWindow(eq1, 1); EnableWindow(eq2, 1); EnableWindow(eq3, 1); | |
33555 | 1000 get_video_colors(guiInfo.sh_video, "brightness", &vo_gamma_brightness); |
1001 get_video_colors(guiInfo.sh_video, "contrast", &vo_gamma_contrast); | |
1002 get_video_colors(guiInfo.sh_video, "hue", &vo_gamma_hue); | |
1003 get_video_colors(guiInfo.sh_video, "saturation", &vo_gamma_saturation); | |
23077 | 1004 } |
1005 SendDlgItemMessage(hwnd, ID_EQ0, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_brightness); | |
1006 SendDlgItemMessage(hwnd, ID_EQ1, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_contrast); | |
1007 SendDlgItemMessage(hwnd, ID_EQ2, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_hue); | |
1008 SendDlgItemMessage(hwnd, ID_EQ3, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_saturation); | |
1009 break; | |
1010 } | |
1011 case WM_VSCROLL: | |
1012 { | |
1013 switch (LOWORD(wParam)) | |
1014 { | |
1015 case TB_THUMBTRACK: | |
33555 | 1016 if(guiInfo.sh_video && guiInfo.Playing) |
23077 | 1017 { |
1018 vo_gamma_brightness = 100 - SendDlgItemMessage(hwnd, ID_EQ0, TBM_GETPOS, 0, 0); | |
33555 | 1019 set_video_colors(guiInfo.sh_video, "brightness", vo_gamma_brightness); |
23077 | 1020 |
1021 vo_gamma_contrast = 100 - SendDlgItemMessage(hwnd, ID_EQ1, TBM_GETPOS, 0, 0); | |
33555 | 1022 set_video_colors(guiInfo.sh_video, "contrast", vo_gamma_contrast); |
23077 | 1023 |
1024 vo_gamma_hue = 100 - SendDlgItemMessage(hwnd, ID_EQ2, TBM_GETPOS, 0, 0); | |
33555 | 1025 set_video_colors(guiInfo.sh_video, "hue", vo_gamma_hue); |
23077 | 1026 |
1027 vo_gamma_saturation = 100 - SendDlgItemMessage(hwnd, ID_EQ3, TBM_GETPOS, 0, 0); | |
33555 | 1028 set_video_colors(guiInfo.sh_video, "saturation", vo_gamma_saturation); |
23077 | 1029 } |
1030 else | |
1031 { | |
1032 EnableWindow(GetDlgItem(hwnd, ID_EQ0), 0); | |
1033 EnableWindow(GetDlgItem(hwnd, ID_EQ1), 0); | |
1034 EnableWindow(GetDlgItem(hwnd, ID_EQ2), 0); | |
1035 EnableWindow(GetDlgItem(hwnd, ID_EQ3), 0); | |
1036 } | |
1037 break; | |
1038 } | |
1039 } | |
1040 case WM_CTLCOLORDLG: | |
1041 case WM_CTLCOLORSTATIC: | |
1042 { | |
1043 HDC hdc = (HDC)wParam; | |
1044 SetBkMode(hdc, TRANSPARENT); | |
1045 return (INT_PTR)SOLID_GREY2; | |
1046 } | |
1047 break; | |
1048 case WM_COMMAND: | |
1049 { | |
1050 switch (LOWORD(wParam)) | |
1051 { | |
1052 case ID_CLOSE: | |
1053 DestroyWindow(hwnd); | |
1054 return 0; | |
1055 case ID_DEFAULTS: | |
33555 | 1056 if(guiInfo.sh_video && guiInfo.Playing) |
23077 | 1057 { |
1058 vo_gamma_brightness=0; | |
1059 SendDlgItemMessage(hwnd, ID_EQ0, TBM_SETPOS, 1, (LPARAM)100); | |
33555 | 1060 set_video_colors(guiInfo.sh_video, "brightness", vo_gamma_brightness); |
23077 | 1061 |
1062 vo_gamma_contrast=0; | |
1063 SendDlgItemMessage(hwnd, ID_EQ1, TBM_SETPOS, 1, (LPARAM)100); | |
33555 | 1064 set_video_colors(guiInfo.sh_video, "contrast", vo_gamma_contrast); |
23077 | 1065 |
1066 vo_gamma_hue=0; | |
1067 SendDlgItemMessage(hwnd, ID_EQ2, TBM_SETPOS, 1, (LPARAM)100); | |
33555 | 1068 set_video_colors(guiInfo.sh_video, "hue", vo_gamma_hue); |
23077 | 1069 |
1070 vo_gamma_saturation=0; | |
1071 SendDlgItemMessage(hwnd, ID_EQ3, TBM_SETPOS, 1, (LPARAM)100); | |
33555 | 1072 set_video_colors(guiInfo.sh_video, "saturation", vo_gamma_saturation); |
23077 | 1073 } |
1074 break; | |
1075 } | |
1076 } | |
1077 return 0; | |
1078 } | |
1079 return DefWindowProc(hwnd, iMsg, wParam, lParam); | |
1080 } | |
1081 | |
1082 void display_eqwindow(gui_t *gui) | |
1083 { | |
1084 HWND hWnd; | |
1085 HINSTANCE hInstance = GetModuleHandle(NULL); | |
1086 WNDCLASS wc; | |
1087 int x, y; | |
1088 | |
33555 | 1089 if(!guiInfo.sh_video) return; |
34163 | 1090 if(FindWindow(NULL, acp(MSGTR_Equalizer))) return; |
23077 | 1091 wc.style = CS_HREDRAW | CS_VREDRAW; |
1092 wc.lpfnWndProc = EqWndProc; | |
1093 wc.cbClsExtra = 0; | |
1094 wc.cbWndExtra = 0; | |
1095 wc.hInstance = hInstance; | |
1096 wc.hCursor = LoadCursor(NULL,IDC_ARROW); | |
1097 wc.hIcon = gui->icon; | |
1098 wc.hbrBackground = SOLID_GREY2; | |
34163 | 1099 wc.lpszClassName = acp(MSGTR_Equalizer); |
23077 | 1100 wc.lpszMenuName = NULL; |
1101 RegisterClass(&wc); | |
1102 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (332 / 2); | |
1103 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (200 / 2); | |
34163 | 1104 hWnd = CreateWindow(acp(MSGTR_Equalizer), |
1105 acp(MSGTR_Equalizer), | |
23077 | 1106 WS_POPUPWINDOW | WS_CAPTION, |
1107 x, | |
1108 y, | |
1109 332, | |
1110 200, | |
1111 NULL, | |
1112 NULL, | |
1113 hInstance, | |
1114 NULL); | |
33638
dbca6aa18b50
Cast new user data value in SetWindowLongPtr() to LONG_PTR.
ib
parents:
33615
diff
changeset
|
1115 SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR) gui); |
23077 | 1116 ShowWindow(hWnd, SW_SHOW); |
1117 UpdateWindow(hWnd); | |
1118 } |