Mercurial > mplayer.hg
annotate gui/win32/gui.c @ 36900:ecf965eee74d
Remove casts.
Make use of implicit arithmetic conversion
and increase precision at that.
author | ib |
---|---|
date | Wed, 12 Mar 2014 12:01:40 +0000 |
parents | 049db0aeea85 |
children | 40ad45360c8a |
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 <stdio.h> | |
25 #include <stdlib.h> | |
26 #include <ctype.h> | |
27 #include <fcntl.h> | |
28 #include <windows.h> | |
29 #include <windowsx.h> | |
30 #include <shlobj.h> | |
23091
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
31 |
35450 | 32 #include "config.h" |
31511
13ca93203358
Factorize MPlayer/MEncoder version string handling.
diego
parents:
30684
diff
changeset
|
33 #include "mpcommon.h" |
23091
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
34 #include "mplayer.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
35 #include "mp_fifo.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
36 #include "mp_msg.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
37 #include "help_mp.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
38 #include "input/input.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
39 #include "input/mouse.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
40 #include "osdep/keycodes.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
41 #include "stream/stream.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
42 #include "libvo/video_out.h" |
30684
dc7ed18ea0df
Include libmpcodecs/vd.h for declaration of "fullscreen".
zuxy
parents:
30558
diff
changeset
|
43 #include "libmpcodecs/vd.h" |
26372
76413880bfad
Update include paths to account for build system changes.
diego
parents:
26193
diff
changeset
|
44 #include "gui/interface.h" |
33761 | 45 #include "gui/ui/actions.h" |
35528 | 46 #include "gui/ui/ui.h" |
33770 | 47 #include "gui/util/mem.h" |
23077 | 48 #include "gui.h" |
49 #include "dialogs.h" | |
33965 | 50 #include "version.h" |
23077 | 51 |
34684 | 52 /* HACK around bug in old mingw */ |
23077 | 53 #undef INVALID_FILE_ATTRIBUTES |
54 #define INVALID_FILE_ATTRIBUTES ((DWORD)-1) | |
55 | |
56 #ifndef WM_XBUTTONDOWN | |
57 # define WM_XBUTTONDOWN 0x020B | |
58 # define WM_XBUTTONUP 0x020C | |
59 # define WM_XBUTTONDBLCLK 0x020D | |
60 #endif | |
61 | |
62 /* Globals / Externs */ | |
34697 | 63 float video_aspect; |
23077 | 64 |
65 DWORD oldtime; | |
66 NOTIFYICONDATA nid; | |
35501 | 67 int console_state = FALSE; |
23077 | 68 play_tree_t *playtree = NULL; |
69 | |
70 static HBRUSH colorbrush = NULL; //Handle to colorkey brush | |
71 static COLORREF windowcolor = RGB(255,0,255); //Windowcolor == colorkey | |
72 | |
34163 | 73 /** |
74 * @brief Convert an UTF-8 encoded string into ANSI codepage encoding. | |
75 * | |
76 * @param utf8 UTF-8 encoded string | |
77 * | |
78 * @return string containing ANSI codepage encoding of @a utf8 (or, in case | |
79 * of error, a string containing the question mark character) | |
80 */ | |
81 LPSTR acp (LPCSTR utf8) | |
82 { | |
83 static LPSTR acp_str = NULL; | |
84 int chars; | |
85 LPWSTR uc_str; | |
86 | |
87 chars = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, NULL, 0); | |
88 | |
89 if (chars) | |
90 { | |
91 uc_str = malloc(sizeof(*uc_str) * (chars + 1)); | |
92 | |
93 if (uc_str) | |
94 { | |
95 MultiByteToWideChar(CP_UTF8, 0, utf8, -1, uc_str, chars); | |
96 | |
97 chars = WideCharToMultiByte(CP_ACP, 0, uc_str, -1, NULL, 0, NULL, 0); | |
98 | |
99 if (chars) | |
100 { | |
101 free(acp_str); | |
102 acp_str = malloc(sizeof(*acp_str) * (chars + 1)); | |
103 | |
104 if (acp_str) | |
105 { | |
106 WideCharToMultiByte(CP_ACP, 0, uc_str, -1, acp_str, chars, NULL, 0); | |
107 free(uc_str); | |
108 | |
109 return acp_str; | |
110 } | |
111 } | |
112 | |
113 free(uc_str); | |
114 } | |
115 } | |
116 | |
117 return "?"; | |
118 } | |
119 | |
35001 | 120 static void console_toggle(gui_t *gui) |
23077 | 121 { |
122 if (console_state) | |
123 { | |
124 FreeConsole(); | |
35501 | 125 console = FALSE; |
126 console_state = FALSE; | |
23077 | 127 } |
128 else | |
129 { | |
130 /* This code comes from: http://dslweb.nwnexus.com/~ast/dload/guicon.htm */ | |
131 CONSOLE_SCREEN_BUFFER_INFO coninfo; | |
132 FILE *fp; | |
133 HWND hwnd = NULL; | |
35501 | 134 console = TRUE; |
23077 | 135 AllocConsole(); |
31511
13ca93203358
Factorize MPlayer/MEncoder version string handling.
diego
parents:
30684
diff
changeset
|
136 SetConsoleTitle(mplayer_version); |
23077 | 137 |
138 /* disable the close button for now */ | |
139 while (!hwnd) | |
140 { | |
31511
13ca93203358
Factorize MPlayer/MEncoder version string handling.
diego
parents:
30684
diff
changeset
|
141 hwnd = FindWindow(NULL, mplayer_version); |
23077 | 142 Sleep(100); |
143 } | |
144 DeleteMenu(GetSystemMenu(hwnd, 0), SC_CLOSE, MF_BYCOMMAND); | |
145 | |
146 GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo); | |
147 coninfo.dwSize.Y = 1000; | |
148 SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coninfo.dwSize); | |
149 fp = freopen("con", "w", stdout); | |
150 *stdout = *fp; | |
151 setvbuf(stdout, NULL, _IONBF, 0); | |
152 fp = freopen("con", "r", stdin); | |
153 *stdin = *fp; | |
154 setvbuf(stdin, NULL, _IONBF, 0); | |
155 fp = freopen("con", "w", stdout); | |
156 *stderr = *fp; | |
157 setvbuf(stderr, NULL, _IONBF, 0); | |
36053 | 158 print_version(MPlayer); |
35501 | 159 console_state = TRUE; |
23077 | 160 } |
35002
64d72a128ea8
Rewrite condition and use console_state instead of console.
ib
parents:
35001
diff
changeset
|
161 |
64d72a128ea8
Rewrite condition and use console_state instead of console.
ib
parents:
35001
diff
changeset
|
162 if (gui) |
64d72a128ea8
Rewrite condition and use console_state instead of console.
ib
parents:
35001
diff
changeset
|
163 { |
64d72a128ea8
Rewrite condition and use console_state instead of console.
ib
parents:
35001
diff
changeset
|
164 CheckMenuItem(gui->traymenu, ID_CONSOLE, MF_BYCOMMAND | (console_state ? MF_CHECKED : MF_UNCHECKED)); |
64d72a128ea8
Rewrite condition and use console_state instead of console.
ib
parents:
35001
diff
changeset
|
165 CheckMenuItem(gui->menu, ID_CONSOLE, MF_BYCOMMAND | (console_state ? MF_CHECKED : MF_UNCHECKED)); |
64d72a128ea8
Rewrite condition and use console_state instead of console.
ib
parents:
35001
diff
changeset
|
166 } |
23077 | 167 } |
168 | |
35521 | 169 void capitalize(char *fname) |
23077 | 170 { |
171 unsigned int i; | |
172 BOOL cap = TRUE; | |
35521 | 173 for (i=0; i < strlen(fname); i++) |
23077 | 174 { |
175 if (cap) | |
176 { | |
177 cap = FALSE; | |
35521 | 178 fname[i] = toupper(fname[i]); |
23077 | 179 } |
35521 | 180 else if (fname[i] == ' ') |
23077 | 181 cap = TRUE; |
182 else | |
35521 | 183 fname[i] = tolower(fname[i]); |
23077 | 184 } |
185 } | |
33965 | 186 static void display_about_box(HWND hWnd) |
187 { | |
188 char about_msg[512]; | |
36053 | 189 snprintf(about_msg, sizeof(about_msg), MP_TITLE "\n" COPYRIGHT, MPlayer); |
36694 | 190 MessageBox(hWnd, about_msg, acp(MSGTR_GUI_AboutMPlayer), MB_OK); |
33965 | 191 } |
23077 | 192 |
193 static image *get_drawground(HWND hwnd) | |
194 { | |
195 gui_t * gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA); | |
196 unsigned int i; | |
197 if(!gui) return NULL; | |
198 for(i=0; i<gui->window_priv_count; i++) | |
199 if(gui->window_priv[i]->hwnd==hwnd) | |
200 return &gui->window_priv[i]->img; | |
201 return NULL; | |
202 } | |
203 | |
204 static HBITMAP get_bitmap(HWND hwnd) | |
205 { | |
206 gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA); | |
207 unsigned int i; | |
208 if(!gui) return NULL; | |
209 for(i=0; i<gui->window_priv_count; i++) | |
210 if(gui->window_priv[i]->hwnd == hwnd) | |
211 return gui->window_priv[i]->bitmap; | |
212 return NULL; | |
213 } | |
214 | |
215 static int get_windowtype(HWND hwnd) | |
216 { | |
217 gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA); | |
218 unsigned int i; | |
219 if(!gui) return -1; | |
220 for(i=0; i<gui->window_priv_count; i++) | |
221 if(gui->window_priv[i]->hwnd == hwnd) | |
222 return gui->window_priv[i]->type; | |
223 return -1; | |
224 } | |
225 | |
226 static void uninit(gui_t *gui) | |
227 { | |
228 if(gui->skin) destroy_window(gui); | |
229 if(gui->playlist) gui->playlist->free_playlist(gui->playlist); | |
230 gui->playlist = NULL; | |
231 } | |
232 | |
233 /* | |
234 the gui message handler | |
235 tries to handle the incoming messages | |
236 and passes them to the player's message handler if it can't handle them | |
237 */ | |
238 static void handlemsg(HWND hWnd, int msg) | |
239 { | |
240 gui_t *gui = (gui_t *) GetWindowLongPtr(hWnd, GWLP_USERDATA); | |
241 if(msg == evNone) return; | |
242 | |
243 switch(msg) | |
244 { | |
245 case evLoadPlay: | |
246 case evLoad: | |
247 if(display_openfilewindow(gui, 0) && (msg == evLoadPlay)) | |
34325 | 248 gui->playercontrol(evLoadPlay); |
23077 | 249 return; |
250 case evLoadSubtitle: | |
251 display_opensubtitlewindow(gui); | |
252 break; | |
253 case evPreferences: | |
254 display_prefswindow(gui); | |
255 return; | |
34321
daebf766dea6
Cosmetic: Synchronize evPlaylist event and message names.
ib
parents:
34315
diff
changeset
|
256 case evPlaylist: |
23077 | 257 display_playlistwindow(gui); |
258 return; | |
259 case evSkinBrowser: | |
260 display_skinbrowser(gui); | |
261 break; | |
262 case evEqualizer: | |
263 display_eqwindow(gui); | |
264 break; | |
265 case evAbout: | |
33965 | 266 display_about_box(hWnd); |
23077 | 267 break; |
268 case evIconify: | |
269 ShowWindow(hWnd, SW_MINIMIZE); | |
270 break; | |
271 case evIncVolume: | |
272 mplayer_put_key(KEY_VOLUME_UP); | |
273 break; | |
274 case evDecVolume: | |
275 mplayer_put_key(KEY_VOLUME_DOWN); | |
276 break; | |
277 default: | |
278 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] received msg %s (%i)\n", gui->skin->geteventname(msg), msg); | |
279 break; | |
280 } | |
281 gui->playercontrol(msg); | |
282 } | |
283 | |
284 static widget *clickedinsidewidget(gui_t *gui, int window, int x, int y) | |
285 { | |
286 unsigned int i; | |
287 widget *item; | |
288 for(i=0; i<gui->skin->widgetcount; i++) | |
289 { | |
290 item = gui->skin->widgets[i]; | |
291 if((item->window == window) && (item->x <= x) && (item->x + item->width >= x) && | |
292 (item->y <= y) && (item->y + item->height >= y)) | |
293 return item; | |
294 } | |
295 return NULL; | |
296 } | |
297 | |
298 /* updates sliders and the display */ | |
299 static void updatedisplay(gui_t *gui, HWND hwnd) | |
300 { | |
301 unsigned int i; | |
302 window_priv_t *priv = NULL; | |
303 DWORD time = timeGetTime(); | |
304 | |
305 if(!hwnd) return; | |
306 | |
36898 | 307 /* load all potmeters hpotmeters vpotmeters */ |
23077 | 308 for(i=0; i<gui->skin->widgetcount; i++) |
309 { | |
36898 | 310 if(gui->skin->widgets[i]->type == tyHpotmeter || gui->skin->widgets[i]->type == tyVpotmeter || gui->skin->widgets[i]->type == tyPotmeter) |
23077 | 311 { |
312 if(gui->skin->widgets[i]->msg == evSetVolume) | |
33555 | 313 gui->skin->widgets[i]->value = guiInfo.Volume; |
23077 | 314 else if(gui->skin->widgets[i]->msg == evSetMoviePosition) |
33555 | 315 gui->skin->widgets[i]->value = guiInfo.Position; |
23077 | 316 else if(gui->skin->widgets[i]->msg == evSetBalance) |
33555 | 317 gui->skin->widgets[i]->value = guiInfo.Balance; |
23077 | 318 if(gui->skin->widgets[i]->window == get_windowtype(hwnd)) |
319 renderwidget(gui->skin, get_drawground(hwnd), gui->skin->widgets[i], | |
320 gui->skin->widgets[i]->pressed ? 0 : 1); | |
321 } | |
322 /* update some buttons */ | |
323 if(gui->skin->widgets[i]->type == tyButton && gui->skin->widgets[i]->window == get_windowtype(hwnd)) | |
324 { | |
325 if(gui->skin->widgets[i]->msg == evPlaySwitchToPause) | |
326 { | |
33555 | 327 gui->skin->widgets[i]->value = guiInfo.Playing; |
23077 | 328 renderwidget(gui->skin, get_drawground(hwnd), gui->skin->widgets[i], |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33580
diff
changeset
|
329 guiInfo.Playing == GUI_PLAY ? 0 : 1); |
23077 | 330 } |
331 if(gui->skin->widgets[i]->msg == evMute) | |
332 { | |
33555 | 333 gui->skin->widgets[i]->value = guiInfo.Volume; |
23077 | 334 renderwidget(gui->skin, get_drawground(hwnd), gui->skin->widgets[i], |
33555 | 335 guiInfo.Volume == 0.0f ? 0 : 1); |
23077 | 336 } |
337 } | |
338 } | |
339 | |
340 /* updating the display once a 100.second is enough imo */ | |
341 if((time - oldtime) < 100) return; | |
342 oldtime=time; | |
343 | |
344 for (i=0; i<gui->window_priv_count; i++) | |
345 { | |
346 if(gui->window_priv[i]->hwnd == hwnd) | |
347 priv=gui->window_priv[i]; | |
348 }// Sherpya | |
349 /* display the status msgs */ | |
350 renderinfobox(gui->skin, priv); | |
351 RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE); | |
352 } | |
353 | |
34697 | 354 static LRESULT CALLBACK VideoProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) |
23077 | 355 { |
36262
703a51ce08c8
Enable the change of the movie aspect ratio on the fly.
ib
parents:
36053
diff
changeset
|
356 float aspect; |
36274 | 357 char cmd[40]; |
23077 | 358 gui_t *gui = (gui_t *) GetWindowLongPtr(hWnd, GWLP_USERDATA); |
34697 | 359 if (gui && (gui->videowindow != hWnd)) return FALSE; |
23077 | 360 |
361 switch (message) | |
362 { | |
363 case WM_CLOSE: | |
364 handlemsg(hWnd, evExit); | |
365 return 0; | |
366 case WM_DESTROY: | |
367 PostQuitMessage(0); | |
368 return 0; | |
369 case WM_KEYDOWN: | |
370 { | |
371 switch(wParam) | |
372 { | |
373 case VK_LEFT: | |
374 mplayer_put_key(KEY_LEFT); | |
375 break; | |
376 case VK_UP: | |
377 mplayer_put_key(KEY_UP); | |
378 break; | |
379 case VK_RIGHT: | |
380 mplayer_put_key(KEY_RIGHT); | |
381 break; | |
382 case VK_DOWN: | |
383 mplayer_put_key(KEY_DOWN); | |
384 break; | |
385 case VK_TAB: | |
386 mplayer_put_key(KEY_TAB); | |
387 break; | |
388 case VK_BACK: | |
389 mplayer_put_key(KEY_BS); | |
390 break; | |
391 case VK_DELETE: | |
392 mplayer_put_key(KEY_DELETE); | |
393 break; | |
394 case VK_INSERT: | |
395 mplayer_put_key(KEY_INSERT); | |
396 break; | |
397 case VK_HOME: | |
398 mplayer_put_key(KEY_HOME); | |
399 break; | |
400 case VK_END: | |
401 mplayer_put_key(KEY_END); | |
402 break; | |
403 case VK_PRIOR: | |
404 mplayer_put_key(KEY_PAGE_UP); | |
405 break; | |
406 case VK_NEXT: | |
407 mplayer_put_key(KEY_PAGE_DOWN); | |
408 break; | |
409 case VK_ESCAPE: | |
410 mplayer_put_key(KEY_ESC); | |
411 break; | |
412 } | |
413 break; | |
414 } | |
415 case WM_COMMAND: | |
416 { | |
417 switch(LOWORD(wParam)) | |
418 { | |
419 case IDEXIT: | |
420 PostQuitMessage(0); | |
421 handlemsg(hWnd, evExit); | |
422 break; | |
423 case IDFILE_OPEN: | |
424 handlemsg(hWnd, evLoadPlay); | |
425 break; | |
426 case IDURL_OPEN: | |
427 display_openurlwindow(gui, 0); | |
428 break; | |
429 case IDDIR_OPEN: | |
430 { | |
431 static char path[MAX_PATH]; | |
432 BROWSEINFO bi; | |
433 LPITEMIDLIST pidl; | |
434 memset(&bi, 0, sizeof(BROWSEINFO)); | |
36694 | 435 bi.lpszTitle = acp(MSGTR_GUI_WIN32_DirectoryList":"); |
23077 | 436 pidl = SHBrowseForFolder(&bi); |
437 if (SHGetPathFromIDList(pidl, path)) | |
438 { | |
439 gui->playlist->clear_playlist(gui->playlist); | |
440 adddirtoplaylist(gui->playlist, path, TRUE); | |
441 gui->startplay(gui); | |
442 } | |
443 break; | |
444 } | |
445 case ID_PTRACK: | |
446 handlemsg(hWnd, evPrev); | |
447 break; | |
448 case ID_SEEKB: | |
449 handlemsg(hWnd, evBackward10sec); | |
450 break; | |
451 case ID_PLAY: | |
452 handlemsg(hWnd, evPlaySwitchToPause); | |
453 break; | |
454 case ID_STOP: | |
455 handlemsg(hWnd, evStop); | |
456 break; | |
457 case ID_SEEKF: | |
458 handlemsg(hWnd, evForward10sec); | |
459 break; | |
460 case ID_NTRACK: | |
461 handlemsg(hWnd, evNext); | |
462 break; | |
463 case ID_CHAPTERSEL: | |
464 display_chapterselwindow(gui); | |
465 break; | |
466 case ID_FULLSCREEN: | |
467 mp_input_queue_cmd(mp_input_parse_cmd("vo_fullscreen")); | |
468 break; | |
469 case ID_MUTE: | |
470 mp_input_queue_cmd(mp_input_parse_cmd("mute")); | |
471 break; | |
472 case ID_ASPECT1: | |
36262
703a51ce08c8
Enable the change of the movie aspect ratio on the fly.
ib
parents:
36053
diff
changeset
|
473 case ID_ASPECT2: |
703a51ce08c8
Enable the change of the movie aspect ratio on the fly.
ib
parents:
36053
diff
changeset
|
474 case ID_ASPECT3: |
703a51ce08c8
Enable the change of the movie aspect ratio on the fly.
ib
parents:
36053
diff
changeset
|
475 case ID_ASPECT4: |
703a51ce08c8
Enable the change of the movie aspect ratio on the fly.
ib
parents:
36053
diff
changeset
|
476 switch (LOWORD(wParam)) |
703a51ce08c8
Enable the change of the movie aspect ratio on the fly.
ib
parents:
36053
diff
changeset
|
477 { |
36263 | 478 case ID_ASPECT1: |
479 aspect = 16.0f / 9.0f; | |
480 break; | |
481 case ID_ASPECT2: | |
482 aspect = 4.0f / 3.0f; | |
483 break; | |
484 case ID_ASPECT3: | |
36276 | 485 aspect = 2.35f; |
36263 | 486 break; |
487 default: | |
36272
aa0011dfbfdc
Use again special value -1 to set original aspect ratio.
ib
parents:
36264
diff
changeset
|
488 aspect = -1; |
36263 | 489 break; |
36262
703a51ce08c8
Enable the change of the movie aspect ratio on the fly.
ib
parents:
36053
diff
changeset
|
490 } |
36274 | 491 snprintf(cmd, sizeof(cmd), "pausing_keep switch_ratio %f", aspect); |
36262
703a51ce08c8
Enable the change of the movie aspect ratio on the fly.
ib
parents:
36053
diff
changeset
|
492 mp_input_queue_cmd(mp_input_parse_cmd(cmd)); |
23077 | 493 break; |
494 case IDSUB_TOGGLE: | |
495 mp_input_queue_cmd(mp_input_parse_cmd("sub_visibility")); | |
496 break; | |
497 case IDSUB_CYCLE: | |
498 mp_input_queue_cmd(mp_input_parse_cmd("sub_select")); | |
499 break; | |
500 } | |
501 return 0; | |
502 } | |
503 case WM_CHAR: | |
504 mplayer_put_key(wParam); | |
505 break; | |
506 case WM_DROPFILES: | |
507 { | |
508 if(!lParam) | |
509 { | |
510 char file[MAX_PATH]; | |
511 int filecount = DragQueryFile((HDROP) wParam, -1, file, MAX_PATH); | |
512 int i; | |
513 for(i=0; i<filecount; i++) | |
514 { | |
515 DragQueryFile((HDROP) wParam, i, file, MAX_PATH); | |
35452 | 516 uiSetFile(NULL, file, STREAMTYPE_FILE); |
23077 | 517 if(!parse_filename(file, playtree, mconfig, 1)) |
518 gui->playlist->add_track(gui->playlist, file, NULL, NULL, 0); | |
519 } | |
520 DragFinish((HDROP) wParam); | |
34325 | 521 gui->playercontrol(evLoadPlay); |
23077 | 522 } |
523 else | |
524 { | |
525 gui->playlist->clear_playlist(gui->playlist); | |
526 gui->playlist->add_track(gui->playlist, (const char *) wParam, NULL, NULL, 0); | |
34325 | 527 gui->playercontrol(evLoadPlay); |
23077 | 528 } |
34697 | 529 SetForegroundWindow(gui->videowindow); |
23077 | 530 return 0; |
531 } | |
532 case WM_LBUTTONDOWN: | |
533 { | |
534 if(!vo_nomouse_input) | |
535 mplayer_put_key(MOUSE_BTN0); | |
536 break; | |
537 } | |
538 case WM_MBUTTONDOWN: | |
539 { | |
540 if(!vo_nomouse_input) | |
541 mplayer_put_key(MOUSE_BTN1); | |
542 break; | |
543 } | |
544 case WM_RBUTTONDOWN: | |
545 { | |
546 POINT point; | |
547 point.x = GET_X_LPARAM(lParam); | |
548 point.y = GET_Y_LPARAM(lParam); | |
549 ClientToScreen(hWnd, &point); | |
33555 | 550 if(guiInfo.StreamType == STREAMTYPE_DVD) |
23077 | 551 EnableMenuItem(gui->dvdmenu, ID_CHAPTERSEL, MF_BYCOMMAND | MF_ENABLED); |
34697 | 552 TrackPopupMenu(gui->videomenu, 0, point.x, point.y, 0, hWnd, NULL); |
23077 | 553 return 0; |
554 } | |
555 case WM_LBUTTONDBLCLK: | |
556 { | |
557 if(!vo_nomouse_input) | |
558 mplayer_put_key(MOUSE_BTN0_DBL); | |
559 break; | |
560 } | |
561 case WM_MBUTTONDBLCLK: | |
562 { | |
563 if(!vo_nomouse_input) | |
564 mplayer_put_key(MOUSE_BTN1_DBL); | |
565 break; | |
566 } | |
567 case WM_RBUTTONDBLCLK: | |
568 { | |
569 if(!vo_nomouse_input) | |
570 mplayer_put_key(MOUSE_BTN2_DBL); | |
571 break; | |
572 } | |
573 case WM_MOUSEWHEEL: | |
574 { | |
575 int x = GET_WHEEL_DELTA_WPARAM(wParam); | |
576 if(vo_nomouse_input) | |
577 break; | |
578 if (x > 0) | |
579 mplayer_put_key(MOUSE_BTN3); | |
580 else | |
581 mplayer_put_key(MOUSE_BTN4); | |
582 break; | |
583 } | |
584 case WM_XBUTTONDOWN: | |
585 { | |
586 if(vo_nomouse_input) | |
587 break; | |
588 if(HIWORD(wParam) == 1) | |
589 mplayer_put_key(MOUSE_BTN5); | |
590 else | |
591 mplayer_put_key(MOUSE_BTN6); | |
592 break; | |
593 } | |
594 case WM_XBUTTONDBLCLK: | |
595 { | |
596 if(vo_nomouse_input) | |
597 break; | |
598 if(HIWORD(wParam) == 1) | |
599 mplayer_put_key(MOUSE_BTN5_DBL); | |
600 else | |
601 mplayer_put_key(MOUSE_BTN6_DBL); | |
602 break; | |
603 } | |
604 case WM_TIMER: | |
605 { | |
606 if(fullscreen) while(ShowCursor(FALSE) >= 0){} | |
607 KillTimer(hWnd, ID_TIMER); | |
608 return 0; | |
609 } | |
610 case WM_MOUSEMOVE: | |
611 { | |
612 ShowCursor(TRUE); | |
613 SetTimer(hWnd, ID_TIMER, 3000, (TIMERPROC) NULL); | |
614 break; | |
615 } | |
616 case WM_WINDOWPOSCHANGED: | |
617 { | |
34996
ebcc17a3c165
Fix compiler warnings (comparison between signed and unsigned).
ib
parents:
34995
diff
changeset
|
618 uint32_t tmpheight=0; |
23077 | 619 static uint32_t rect_width; |
620 static uint32_t rect_height; | |
621 RECT rd; | |
622 POINT pt; | |
623 pt.x = 0; | |
624 pt.y = 0; | |
625 GetClientRect(hWnd, &rd); | |
626 ClientToScreen(hWnd, &pt); | |
627 | |
628 rect_width = rd.right - rd.left; | |
629 rect_height = rd.bottom - rd.top; | |
630 | |
631 /* maintain our aspect ratio */ | |
36842 | 632 tmpheight = rect_width/video_aspect; |
23077 | 633 tmpheight += tmpheight % 2; |
634 if(tmpheight > rect_height) | |
635 { | |
36842 | 636 rect_width = rect_height*video_aspect; |
23077 | 637 rect_width += rect_width % 2; |
638 } | |
639 else rect_height = tmpheight; | |
640 | |
641 rd.right = rd.left + rect_width; | |
642 rd.bottom = rd.top + rect_height; | |
643 | |
644 AdjustWindowRect(&rd, WS_OVERLAPPEDWINDOW | WS_SIZEBOX, 0); | |
645 SetWindowPos(hWnd, 0, fullscreen?0:pt.x+rd.left, fullscreen?0:pt.y+rd.top, | |
646 fullscreen?vo_screenwidth:rd.right-rd.left, fullscreen?vo_screenheight:rd.bottom-rd.top, SWP_NOOWNERZORDER); | |
647 SetForegroundWindow(hWnd); | |
648 return 0; | |
649 } | |
650 case WM_SYSCOMMAND: | |
651 { | |
652 switch(wParam) | |
653 { | |
654 case SC_SCREENSAVE: | |
655 case SC_MONITORPOWER: | |
656 mp_msg(MSGT_VO, MSGL_V ,"<vo_directx><INFO>killing screensaver\n" ); | |
657 return 0; | |
658 } | |
659 break; | |
660 } | |
661 case WM_PAINT: | |
662 { | |
663 PAINTSTRUCT ps; | |
664 RECT rect; | |
665 HDC hdc = BeginPaint(hWnd, &ps); | |
666 HDC hMemDC = CreateCompatibleDC(hdc); | |
667 HBRUSH blackbrush = (HBRUSH)GetStockObject(BLACK_BRUSH); | |
668 int width, height; | |
669 GetClientRect(hWnd, &rect); | |
670 width = rect.right - rect.left; | |
671 height = rect.bottom - rect.top; | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33580
diff
changeset
|
672 if(guiInfo.Playing == GUI_STOP) |
23077 | 673 { |
34996
ebcc17a3c165
Fix compiler warnings (comparison between signed and unsigned).
ib
parents:
34995
diff
changeset
|
674 unsigned int i; |
23077 | 675 window *desc = NULL; |
676 | |
677 for (i=0; i<gui->skin->windowcount; i++) | |
34697 | 678 if(gui->skin->windows[i]->type == wiVideo) |
23077 | 679 desc = gui->skin->windows[i]; |
680 | |
681 SelectObject(hMemDC, get_bitmap(hWnd)); | |
682 StretchBlt(hdc, 0, 0, width, height, hMemDC, 0, 0, desc->base->bitmap[0]->width, | |
683 desc->base->bitmap[0]->height, SRCCOPY); | |
684 } else { | |
685 FillRect(GetDC(hWnd), &rect, fullscreen?blackbrush:colorbrush); | |
686 } | |
687 DeleteDC(hMemDC); | |
688 EndPaint(hWnd, &ps); | |
689 return 0; | |
690 } | |
691 } | |
692 return DefWindowProc(hWnd, message, wParam, lParam); | |
693 } | |
694 | |
695 /* Window Proc for the gui Window */ | |
696 static LRESULT CALLBACK EventProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) | |
697 { | |
698 gui_t *gui = (gui_t *) GetWindowLongPtr(hWnd, GWLP_USERDATA); | |
699 | |
700 /* Avoid processing when then window doesn't match gui mainwindow */ | |
701 if (gui && (gui->mainwindow != hWnd)) return FALSE; | |
702 | |
703 switch (message) | |
704 { | |
705 case WM_CLOSE: | |
706 handlemsg(hWnd, evExit); | |
707 return 0; | |
708 case WM_DESTROY: | |
709 PostQuitMessage(0); | |
710 return 0; | |
711 case WM_SYSTRAY: | |
712 { | |
713 switch(lParam) | |
714 { | |
715 POINT cursor; | |
716 case WM_RBUTTONDOWN: | |
717 { | |
718 GetCursorPos(&cursor); | |
719 SetForegroundWindow(hWnd); | |
720 TrackPopupMenu(gui->traymenu, 0, cursor.x, cursor.y, 0, hWnd, NULL); | |
721 break; | |
722 } | |
723 case WM_MBUTTONDBLCLK: | |
724 case WM_LBUTTONDBLCLK: | |
725 { | |
726 if(IsWindowVisible(hWnd)) ShowWindow(hWnd, SW_HIDE); | |
727 else { ShowWindow(hWnd, SW_SHOW); SetForegroundWindow(hWnd); } | |
728 break; | |
729 } | |
730 } | |
731 break; | |
732 } | |
733 case WM_KEYDOWN: | |
734 { | |
735 switch(wParam) | |
736 { | |
737 case VK_LEFT: | |
738 mplayer_put_key(KEY_LEFT); | |
739 break; | |
740 case VK_UP: | |
741 mplayer_put_key(KEY_UP); | |
742 break; | |
743 case VK_RIGHT: | |
744 mplayer_put_key(KEY_RIGHT); | |
745 break; | |
746 case VK_DOWN: | |
747 mplayer_put_key(KEY_DOWN); | |
748 break; | |
749 case VK_TAB: | |
750 mplayer_put_key(KEY_TAB); | |
751 break; | |
752 case VK_BACK: | |
753 mplayer_put_key(KEY_BS); | |
754 break; | |
755 case VK_DELETE: | |
756 mplayer_put_key(KEY_DELETE); | |
757 break; | |
758 case VK_INSERT: | |
759 mplayer_put_key(KEY_INSERT); | |
760 break; | |
761 case VK_HOME: | |
762 mplayer_put_key(KEY_HOME); | |
763 break; | |
764 case VK_END: | |
765 mplayer_put_key(KEY_END); | |
766 break; | |
767 case VK_PRIOR: | |
768 mplayer_put_key(KEY_PAGE_UP); | |
769 break; | |
770 case VK_NEXT: | |
771 mplayer_put_key(KEY_PAGE_DOWN); | |
772 break; | |
773 case VK_ESCAPE: | |
774 mplayer_put_key(KEY_ESC); | |
775 break; | |
776 } | |
777 break; | |
778 } | |
779 case WM_CHAR: | |
780 mplayer_put_key(wParam); | |
781 break; | |
782 case WM_COPYDATA: | |
783 { | |
784 if(lParam) | |
785 { | |
786 PCOPYDATASTRUCT cdData; | |
787 cdData = (PCOPYDATASTRUCT) lParam; | |
35452 | 788 uiSetFile(NULL, cdData->lpData, STREAMTYPE_FILE); |
23077 | 789 if(!parse_filename(cdData->lpData, playtree, mconfig, 1)) |
790 gui->playlist->add_track(gui->playlist, cdData->lpData, NULL, NULL, 0); | |
791 gui->startplay(gui); | |
792 } | |
793 break; | |
794 } | |
795 case WM_DROPFILES: | |
796 { | |
797 if(!lParam) | |
798 { | |
799 char file[MAX_PATH]; | |
800 int filecount = DragQueryFile((HDROP) wParam, -1, file, MAX_PATH); | |
801 int i; | |
802 for(i=0; i<filecount; i++) | |
803 { | |
804 DragQueryFile((HDROP) wParam, i, file, MAX_PATH); | |
35452 | 805 uiSetFile(NULL, file, STREAMTYPE_FILE); |
23077 | 806 if(!parse_filename(file, playtree, mconfig, 1)) |
807 gui->playlist->add_track(gui->playlist, file, NULL, NULL, 0); | |
808 } | |
809 DragFinish((HDROP) wParam); | |
34325 | 810 gui->playercontrol(evLoadPlay); |
23077 | 811 } |
812 else | |
813 { | |
814 gui->playlist->clear_playlist(gui->playlist); | |
815 gui->playlist->add_track(gui->playlist, (const char *) wParam, NULL, NULL, 0); | |
34325 | 816 gui->playercontrol(evLoadPlay); |
23077 | 817 } |
818 SetForegroundWindow(gui->mainwindow); | |
819 return 0; | |
820 } | |
821 case WM_LBUTTONDOWN: | |
822 { | |
823 SetCapture(hWnd); | |
824 gui->mousex = GET_X_LPARAM(lParam); | |
825 gui->mousey = GET_Y_LPARAM(lParam); | |
826 /* inside a widget */ | |
827 gui->activewidget = clickedinsidewidget(gui, get_windowtype(hWnd), gui->mousex, gui->mousey); | |
828 if(gui->activewidget) | |
829 { | |
830 gui->activewidget->pressed = 1; | |
831 gui->mousewx = gui->mousex - gui->activewidget->x; | |
832 gui->mousewy = gui->mousey - gui->activewidget->y; | |
833 renderwidget(gui->skin, get_drawground(hWnd), gui->activewidget, 0); | |
834 RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE); | |
835 handlemsg(hWnd, gui->activewidget->msg); | |
836 } | |
837 break; | |
838 } | |
839 case WM_CAPTURECHANGED: | |
840 { | |
841 if(gui->activewidget) | |
842 { | |
843 gui->activewidget->pressed = 0; | |
844 renderwidget(gui->skin, get_drawground(hWnd), gui->activewidget, 1); | |
845 RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE); | |
846 gui->activewidget = NULL; | |
847 } | |
848 break; | |
849 } | |
850 case WM_LBUTTONUP: | |
851 { | |
852 ReleaseCapture(); | |
853 if(gui->activewidget) | |
854 { | |
855 gui->activewidget->pressed = 0; | |
856 renderwidget(gui->skin, get_drawground(hWnd), gui->activewidget, 1); | |
857 RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE); | |
858 gui->activewidget = NULL; | |
859 } | |
860 break; | |
861 } | |
862 case WM_RBUTTONDOWN: | |
863 { | |
864 POINT point; | |
865 char device[MAX_PATH]; | |
866 char searchpath[MAX_PATH]; | |
867 int len, pos = 0, cdromdrive = 0; | |
868 UINT errmode; | |
869 point.x = GET_X_LPARAM(lParam); | |
870 point.y = GET_Y_LPARAM(lParam); | |
871 ClientToScreen(hWnd, &point); | |
872 errmode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); | |
873 while (GetMenuItemCount(gui->diskmenu) > 0) | |
874 DeleteMenu(gui->diskmenu, 0, MF_BYPOSITION); | |
875 len = GetLogicalDriveStrings(MAX_PATH, device); | |
876 while(pos < len) | |
877 { | |
878 if(GetDriveType(device + pos) == DRIVE_CDROM) | |
879 { | |
880 char volname[MAX_PATH]; | |
881 char menuitem[MAX_PATH]; | |
35501 | 882 int flags = MF_STRING, enable = FALSE; |
23077 | 883 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] checking %s for CD/VCD/SVCD/DVDs\n", device + pos); |
34454 | 884 #ifdef CONFIG_DVDREAD |
23077 | 885 sprintf(searchpath, "%sVIDEO_TS", device + pos); |
34452
c3e63d8b6cf3
Reduce number and avoid conditional definition of searchpath variables.
ib
parents:
34405
diff
changeset
|
886 if(GetFileAttributes(searchpath) != INVALID_FILE_ATTRIBUTES) |
35501 | 887 enable = TRUE; |
34454 | 888 #endif |
34452
c3e63d8b6cf3
Reduce number and avoid conditional definition of searchpath variables.
ib
parents:
34405
diff
changeset
|
889 sprintf(searchpath, "%sMpegav", device + pos); |
23077 | 890 if(GetFileAttributes(searchpath) != INVALID_FILE_ATTRIBUTES) |
35501 | 891 enable = TRUE; |
34405
35fd66684548
Use cdparanoia compatibility names for CD function calls.
ib
parents:
34391
diff
changeset
|
892 #ifdef CONFIG_CDDA |
34452
c3e63d8b6cf3
Reduce number and avoid conditional definition of searchpath variables.
ib
parents:
34405
diff
changeset
|
893 sprintf(searchpath, "%sTrack01.cda", device + pos); |
c3e63d8b6cf3
Reduce number and avoid conditional definition of searchpath variables.
ib
parents:
34405
diff
changeset
|
894 if(GetFileAttributes(searchpath) != INVALID_FILE_ATTRIBUTES) |
35501 | 895 enable = TRUE; |
23077 | 896 #endif |
34452
c3e63d8b6cf3
Reduce number and avoid conditional definition of searchpath variables.
ib
parents:
34405
diff
changeset
|
897 flags |= (enable ? MF_ENABLED : MF_GRAYED); |
23077 | 898 volname[0] = 0; |
899 strcpy(menuitem, device + pos); | |
900 menuitem[strlen(menuitem) - 1]=0; | |
901 GetVolumeInformation(device + pos, volname, MAX_PATH, NULL, NULL, NULL, NULL, 0); | |
902 if (strlen(volname)) | |
903 { | |
904 capitalize(volname); | |
905 strcat(menuitem, " - "); | |
906 strcat(menuitem, volname); | |
907 } | |
908 AppendMenu(gui->diskmenu, flags, IDPLAYDISK + cdromdrive, menuitem); | |
34979 | 909 if (++cdromdrive == IDPLAYDISK_LIMIT - IDPLAYDISK) break; |
23077 | 910 } |
911 pos += strlen(device + pos) + 1; | |
912 } | |
913 SetErrorMode(errmode); | |
914 TrackPopupMenu(gui->menu, 0, point.x, point.y, 0, hWnd, NULL); | |
915 return 0; | |
916 } | |
917 case WM_MOUSEMOVE: | |
918 { | |
919 if(wParam & MK_LBUTTON) | |
920 { | |
921 POINT point; | |
922 RECT rect; | |
923 if(gui->activewidget) | |
924 { | |
925 widget *item = gui->activewidget; | |
926 | |
927 if(item->type == tyHpotmeter) | |
928 { | |
36892 | 929 int wd = item->wwidth - item->width; |
930 | |
931 if (wd == 0) // legacy (potmeter) | |
932 { | |
933 item->x = GET_X_LPARAM(lParam); | |
934 wd = item->wwidth; | |
935 } | |
36893 | 936 else item->x = GET_X_LPARAM(lParam) - gui->mousewx; |
36892 | 937 |
36900 | 938 item->value = 100.0 * (item->x - item->wx) / wd; |
23077 | 939 } |
36898 | 940 if(item->type == tyVpotmeter) |
941 { | |
942 item->y = GET_Y_LPARAM(lParam) - gui->mousewy; | |
36900 | 943 item->value = 100.0 - 100.0 * (item->y - item->wy) / (item->wheight - item->height); |
36898 | 944 } |
23077 | 945 if(item->type == tyPotmeter) |
946 { | |
947 gui->mousewx = GET_X_LPARAM(lParam) - gui->activewidget->x; | |
36900 | 948 item->value = 100.0 * gui->mousewx / item->wwidth; |
23077 | 949 } |
950 | |
951 if((item->type == tyPotmeter) || (item->type == tyHpotmeter) || (item->type == tyVpotmeter)) | |
952 { | |
953 /* Bound checks */ | |
954 if(item->value > 100.0f) | |
955 item->value = 100.0f; | |
956 else if(item->value < 0.0f) | |
957 item->value = 0.0f; | |
958 | |
959 if(item->msg == evSetVolume) | |
36842 | 960 guiInfo.Volume = item->value; |
23077 | 961 else if(item->msg == evSetMoviePosition) |
36842 | 962 guiInfo.Position = item->value; |
23077 | 963 else if(item->msg == evSetBalance) |
964 { | |
965 /* make the range for 50% a bit bigger, because the sliders for balance usually suck */ | |
966 if((item->value - 50.0f < 1.5f) && (item->value - 50.0f > -1.5f)) | |
967 item->value = 50.0f; | |
36842 | 968 guiInfo.Balance = item->value; |
23077 | 969 } |
970 updatedisplay(gui, hWnd); | |
971 handlemsg(hWnd, item->msg); | |
972 } | |
973 break; | |
974 } | |
975 point.x = GET_X_LPARAM(lParam); | |
976 point.y = GET_Y_LPARAM(lParam); | |
977 ClientToScreen(hWnd, &point); | |
978 GetWindowRect(hWnd, &rect); | |
979 MoveWindow(hWnd, point.x - gui->mousex, point.y - gui->mousey, | |
980 rect.right-rect.left,rect.bottom-rect.top,TRUE); | |
981 break; | |
982 } | |
983 break; | |
984 } | |
985 case WM_COMMAND: | |
986 { | |
987 switch(LOWORD(wParam)) | |
988 { | |
989 case IDEXIT: | |
990 PostQuitMessage(0); | |
991 handlemsg(hWnd, evExit); | |
992 break; | |
993 case IDFILE_OPEN: | |
994 handlemsg(hWnd, evLoadPlay); | |
995 break; | |
996 case IDDIR_OPEN: | |
997 { | |
998 static char path[MAX_PATH]; | |
999 BROWSEINFO bi; | |
1000 LPITEMIDLIST pidl; | |
1001 memset(&bi, 0, sizeof(BROWSEINFO)); | |
36694 | 1002 bi.lpszTitle = acp(MSGTR_GUI_WIN32_DirectoryList":"); |
23077 | 1003 pidl = SHBrowseForFolder(&bi); |
1004 if (SHGetPathFromIDList(pidl, path)) | |
1005 { | |
1006 gui->playlist->clear_playlist(gui->playlist); | |
1007 adddirtoplaylist(gui->playlist, path, TRUE); | |
1008 gui->startplay(gui); | |
1009 } | |
1010 break; | |
1011 } | |
1012 case ID_SKINBROWSER: | |
1013 handlemsg(hWnd, evSkinBrowser); | |
1014 break; | |
1015 case IDURL_OPEN: | |
1016 display_openurlwindow(gui, 0); | |
1017 break; | |
1018 case ID_MUTE: | |
1019 mp_input_queue_cmd(mp_input_parse_cmd("mute")); | |
1020 break; | |
1021 case IDSUBTITLE_OPEN: | |
1022 display_opensubtitlewindow(gui); | |
1023 break; | |
1024 case ID_PTRACK: | |
1025 handlemsg(hWnd, evPrev); | |
1026 break; | |
1027 case ID_SEEKB: | |
1028 handlemsg(hWnd, evBackward10sec); | |
1029 break; | |
1030 case ID_PLAY: | |
1031 handlemsg(hWnd, evPlaySwitchToPause); | |
1032 break; | |
1033 case ID_STOP: | |
1034 handlemsg(hWnd, evStop); | |
1035 break; | |
1036 case ID_SEEKF: | |
1037 handlemsg(hWnd, evForward10sec); | |
1038 break; | |
1039 case ID_NTRACK: | |
1040 handlemsg(hWnd, evNext); | |
1041 break; | |
1042 case ID_SHOWHIDE: | |
1043 { | |
1044 if(IsWindowVisible(hWnd)) ShowWindow(hWnd, SW_HIDE); | |
1045 else ShowWindow(hWnd, SW_SHOW); | |
1046 break; | |
1047 } | |
1048 case ID_PLAYLIST: | |
34321
daebf766dea6
Cosmetic: Synchronize evPlaylist event and message names.
ib
parents:
34315
diff
changeset
|
1049 handlemsg(hWnd, evPlaylist); |
23077 | 1050 break; |
1051 case ID_PREFS: | |
1052 handlemsg(hWnd, evPreferences); | |
1053 break; | |
1054 case ID_CONSOLE: | |
35001 | 1055 console_toggle(gui); |
23077 | 1056 break; |
1057 case ID_ONLINEHELP: | |
1058 ShellExecute(NULL, "open", ONLINE_HELP_URL, NULL, NULL, SW_SHOWNORMAL); | |
1059 break; | |
33965 | 1060 case IDHELP_ABOUT: |
1061 handlemsg(hWnd, evAbout); | |
1062 break; | |
23077 | 1063 } |
34979 | 1064 if(LOWORD(wParam) >= IDPLAYDISK && LOWORD(wParam) < IDPLAYDISK_LIMIT) |
23077 | 1065 { |
1066 char device[MAX_PATH]; | |
1067 char searchpath[MAX_PATH]; | |
35521 | 1068 char file[MAX_PATH]; |
23077 | 1069 int len, pos = 0, cdromdrive = 0; |
1070 len = GetLogicalDriveStrings(MAX_PATH, device); | |
1071 while(pos < len) | |
1072 { | |
1073 if(GetDriveType(device + pos)==DRIVE_CDROM) | |
1074 { | |
1075 if(LOWORD(wParam) - IDPLAYDISK == cdromdrive) | |
1076 { | |
1077 sprintf(searchpath, "%sVIDEO_TS", device + pos); | |
1078 if(GetFileAttributes(searchpath) != INVALID_FILE_ATTRIBUTES) | |
1079 { | |
32537
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
31532
diff
changeset
|
1080 free(dvd_device); |
23077 | 1081 dvd_device = strdup(device + pos); |
1082 handlemsg(hWnd, evPlayDVD); | |
1083 } | |
1084 sprintf(searchpath, "%sTrack01.cda", device + pos); | |
1085 if(GetFileAttributes(searchpath) != INVALID_FILE_ATTRIBUTES) | |
1086 { | |
32537
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
31532
diff
changeset
|
1087 free(cdrom_device); |
23077 | 1088 cdrom_device = strdup(device + pos); |
1089 /* mplayer doesn't seem to like the trailing \ after the device name */ | |
1090 cdrom_device[2]=0; | |
1091 handlemsg(hWnd, evPlayCD); | |
23147
21c35763b178
compilation fix for disabling dvd functionality, patch by <bangbangbear at gmail dot com>, slightly modified by me.
vayne
parents:
23091
diff
changeset
|
1092 } else { |
23077 | 1093 HANDLE searchhndl; |
1094 WIN32_FIND_DATA finddata; | |
34092
dbf5042ab255
Don't use the Windows style path separator character in Win32 GUI.
ib
parents:
33965
diff
changeset
|
1095 sprintf(searchpath, "%smpegav/*.dat", device + pos); |
23077 | 1096 if((searchhndl=FindFirstFile(searchpath, &finddata)) != INVALID_HANDLE_VALUE) |
1097 { | |
1098 mp_msg(MSGT_GPLAYER,MSGL_V, "Opening VCD/SVCD\n"); | |
1099 gui->playlist->clear_playlist(gui->playlist); | |
1100 do | |
1101 { | |
35521 | 1102 sprintf(file, "%smpegav/%s", device + pos, finddata.cFileName); |
1103 gui->playlist->add_track(gui->playlist, file, NULL, NULL, 0); | |
23077 | 1104 } |
1105 while(FindNextFile(searchhndl, &finddata)); | |
1106 FindClose(searchhndl); | |
1107 } | |
1108 gui->startplay(gui); | |
1109 } | |
1110 } | |
1111 cdromdrive++; | |
1112 } | |
1113 pos += strlen(device + pos) + 1; | |
1114 } | |
1115 } | |
1116 break; | |
1117 } | |
1118 case WM_PAINT: | |
1119 { | |
1120 PAINTSTRUCT ps; | |
1121 RECT rd; | |
1122 HDC hdc = BeginPaint(hWnd, &ps); | |
1123 HDC hMemDC = CreateCompatibleDC(hdc); | |
1124 int width, height; | |
1125 GetClientRect(hWnd, &rd); | |
1126 width = rd.right - rd.left; | |
1127 height = rd.bottom - rd.top; | |
1128 SelectObject(hMemDC, get_bitmap(hWnd)); | |
1129 BitBlt(hdc, 0, 0, width, height, hMemDC, 0, 0, SRCCOPY); | |
1130 DeleteDC(hMemDC); | |
1131 EndPaint(hWnd, &ps); | |
1132 return 0; | |
1133 } | |
1134 return 0; | |
1135 } | |
1136 return DefWindowProc(hWnd, message, wParam, lParam); | |
1137 } | |
1138 | |
27292 | 1139 static void startplay(gui_t *gui) |
23077 | 1140 { |
34325 | 1141 gui->playercontrol(evLoadPlay); |
23077 | 1142 } |
1143 | |
1144 /* returns the bits per pixel of the desktop */ | |
1145 /* the format is always in BGR byte order */ | |
1146 static int GetDesktopBitsPerPixel(void) | |
1147 { | |
1148 HWND desktop=GetDesktopWindow(); | |
1149 HDC dc=GetDC(desktop); | |
1150 int bpp=GetDeviceCaps(dc, BITSPIXEL); | |
1151 ReleaseDC(desktop, dc); | |
1152 return bpp; | |
1153 } | |
1154 | |
1155 /* unloads a skin and destroys its windows */ | |
28051 | 1156 int destroy_window(gui_t *gui) |
23077 | 1157 { |
1158 RECT rd; | |
1159 unsigned int i; | |
1160 | |
1161 /* Save position: MSDN says don't pass workspace coordinates | |
1162 * to CreateWindow() or SetWindowPos(), as both of which expect | |
1163 * screen coordinates; resulting in the window appearing in the | |
1164 * wrong location. | |
1165 * -Erik | |
1166 */ | |
1167 | |
1168 /* main window position */ | |
1169 if(IsIconic(gui->mainwindow)) | |
1170 ShowWindow(gui->mainwindow, SW_SHOWNORMAL); | |
1171 GetWindowRect(gui->mainwindow, &rd); | |
1172 gui_main_pos_x = rd.left; | |
1173 gui_main_pos_y = rd.top; | |
1174 | |
34697 | 1175 /* video window position */ |
1176 if(IsIconic(gui->videowindow)) | |
1177 ShowWindow(gui->videowindow, SW_SHOWNORMAL); | |
1178 GetWindowRect(gui->videowindow, &rd); | |
1179 gui_video_pos_x = rd.left; | |
1180 gui_video_pos_y = rd.top; | |
23077 | 1181 |
1182 for(i=0; i<gui->window_priv_count; i++) | |
1183 { | |
1184 if(gui->window_priv[i]->bitmap) | |
1185 DeleteObject(gui->window_priv[i]->bitmap); | |
1186 free(gui->window_priv[i]); | |
1187 } | |
33770 | 1188 nfree(gui->window_priv); |
23077 | 1189 gui->window_priv_count = 0; |
1190 | |
1191 /* destroy the main window */ | |
1192 if(gui->mainwindow) | |
1193 DestroyWindow(gui->mainwindow); | |
1194 gui->mainwindow = NULL; | |
1195 | |
34697 | 1196 /* destroy the video window */ |
1197 if(gui->videowindow) | |
1198 DestroyWindow(gui->videowindow); | |
1199 gui->videowindow = NULL; | |
23077 | 1200 |
1201 UnregisterClass(gui->classname, 0); | |
1202 DestroyIcon(gui->icon); | |
1203 | |
1204 gui->skin->freeskin(gui->skin); | |
1205 gui->skin = NULL; | |
1206 return 0; | |
1207 } | |
1208 | |
1209 static void create_menu(gui_t *gui) | |
1210 { | |
1211 gui->diskmenu = CreatePopupMenu(); | |
1212 gui->menu=CreatePopupMenu(); | |
1213 gui->trayplaymenu = CreatePopupMenu(); | |
36694 | 1214 AppendMenu(gui->menu, MF_STRING | MF_POPUP, (UINT_PTR) gui->trayplaymenu, acp(MSGTR_GUI_Open)); |
1215 AppendMenu(gui->trayplaymenu, MF_STRING, IDFILE_OPEN, acp(MSGTR_GUI_File"...")); | |
1216 AppendMenu(gui->trayplaymenu, MF_STRING, IDURL_OPEN, acp(MSGTR_GUI_URL"...")); | |
1217 AppendMenu(gui->trayplaymenu, MF_STRING, IDDIR_OPEN, acp(MSGTR_GUI_Directory"...")); | |
23077 | 1218 AppendMenu(gui->menu, MF_SEPARATOR, 0, 0); |
36694 | 1219 AppendMenu(gui->menu, MF_STRING | MF_POPUP, (UINT_PTR) gui->diskmenu, acp(MSGTR_GUI_Play)); |
23077 | 1220 AppendMenu(gui->menu, MF_SEPARATOR, 0, 0); |
36694 | 1221 AppendMenu(gui->menu, MF_STRING, IDSUBTITLE_OPEN, acp(MSGTR_GUI_Subtitle"...")); |
1222 AppendMenu(gui->menu, MF_STRING, ID_SKINBROWSER, acp(MSGTR_GUI_SkinBrowser)); | |
23077 | 1223 AppendMenu(gui->menu, MF_SEPARATOR, 0, 0); |
36694 | 1224 AppendMenu(gui->menu, MF_STRING, ID_PREFS, acp(MSGTR_GUI_Preferences)); |
1225 AppendMenu(gui->menu, MF_STRING, ID_CONSOLE, acp(MSGTR_GUI_WIN32_DebugConsole)); | |
1226 AppendMenu(gui->menu, MF_STRING, ID_ONLINEHELP, acp(MSGTR_GUI_WIN32_OnlineHelp)); | |
1227 AppendMenu(gui->menu, MF_STRING, IDHELP_ABOUT, acp(MSGTR_GUI_AboutMPlayer)); | |
23077 | 1228 AppendMenu(gui->menu, MF_SEPARATOR, 0, 0); |
36694 | 1229 AppendMenu(gui->menu, MF_STRING, IDEXIT, acp(MSGTR_GUI_Quit)); |
23077 | 1230 } |
1231 | |
1232 static void create_traymenu(gui_t *gui) | |
1233 { | |
1234 gui->traymenu = CreatePopupMenu(); | |
1235 gui->trayplaybackmenu = CreatePopupMenu(); | |
36694 | 1236 AppendMenu(gui->traymenu, MF_STRING | MF_POPUP, (UINT_PTR) gui->trayplaymenu, acp(MSGTR_GUI_Open)); |
23077 | 1237 AppendMenu(gui->traymenu, MF_SEPARATOR, 0, 0); |
36694 | 1238 AppendMenu(gui->traymenu, MF_STRING | MF_POPUP, (UINT_PTR) gui->trayplaybackmenu, acp(MSGTR_GUI_Playback)); |
1239 AppendMenu(gui->trayplaybackmenu, MF_STRING, ID_SEEKB, acp(MSGTR_GUI_WIN32_SeekBackwards)); | |
1240 AppendMenu(gui->trayplaybackmenu, MF_STRING, ID_PTRACK, acp(MSGTR_GUI_Previous)); | |
1241 AppendMenu(gui->trayplaybackmenu, MF_STRING, ID_PLAY, acp(MSGTR_GUI_Play "/" MSGTR_GUI_Pause)); | |
1242 AppendMenu(gui->trayplaybackmenu, MF_STRING, ID_STOP, acp(MSGTR_GUI_Stop)); | |
1243 AppendMenu(gui->trayplaybackmenu, MF_STRING, ID_NTRACK, acp(MSGTR_GUI_Next)); | |
1244 AppendMenu(gui->trayplaybackmenu, MF_STRING, ID_SEEKF, acp(MSGTR_GUI_WIN32_SeekForwards)); | |
23077 | 1245 AppendMenu(gui->traymenu, MF_SEPARATOR, 0, 0); |
36694 | 1246 AppendMenu(gui->traymenu, MF_STRING, ID_MUTE, acp(MSGTR_GUI_Mute)); |
23077 | 1247 AppendMenu(gui->traymenu, MF_SEPARATOR, 0, 0); |
36694 | 1248 AppendMenu(gui->traymenu, MF_STRING, IDSUBTITLE_OPEN, acp(MSGTR_GUI_Subtitle)); |
1249 AppendMenu(gui->traymenu, MF_STRING, ID_PLAYLIST, acp(MSGTR_GUI_Playlist)); | |
23077 | 1250 AppendMenu(gui->traymenu, MF_SEPARATOR, 0, 0); |
36694 | 1251 AppendMenu(gui->traymenu, MF_STRING, ID_SHOWHIDE, acp(MSGTR_GUI_WIN32_ShowHide)); |
23077 | 1252 AppendMenu(gui->traymenu, MF_SEPARATOR, 0, 0); |
36694 | 1253 AppendMenu(gui->traymenu, MF_STRING, ID_PREFS, acp(MSGTR_GUI_Preferences)); |
1254 AppendMenu(gui->traymenu, MF_STRING, ID_CONSOLE, acp(MSGTR_GUI_WIN32_DebugConsole)); | |
1255 AppendMenu(gui->traymenu, MF_STRING, ID_ONLINEHELP, acp(MSGTR_GUI_WIN32_OnlineHelp)); | |
1256 AppendMenu(gui->traymenu, MF_STRING, IDHELP_ABOUT, acp(MSGTR_GUI_AboutMPlayer)); | |
23077 | 1257 AppendMenu(gui->traymenu, MF_SEPARATOR, 0, 0); |
36694 | 1258 AppendMenu(gui->traymenu, MF_STRING, IDEXIT, acp(MSGTR_GUI_Quit)); |
23077 | 1259 } |
1260 | |
34697 | 1261 static void create_videomenu(gui_t *gui) |
23077 | 1262 { |
34697 | 1263 gui->videomenu = CreatePopupMenu(); |
23077 | 1264 gui->dvdmenu = CreatePopupMenu(); |
1265 gui->aspectmenu = CreatePopupMenu(); | |
1266 gui->subtitlemenu = CreatePopupMenu(); | |
36694 | 1267 AppendMenu(gui->videomenu, MF_STRING | MF_POPUP, (UINT_PTR) gui->trayplaymenu, acp(MSGTR_GUI_Open)); |
34697 | 1268 AppendMenu(gui->videomenu, MF_SEPARATOR, 0, 0); |
36694 | 1269 AppendMenu(gui->videomenu, MF_STRING, ID_SEEKB, acp(MSGTR_GUI_WIN32_SeekBackwards)); |
1270 AppendMenu(gui->videomenu, MF_STRING, ID_PTRACK, acp(MSGTR_GUI_Previous)); | |
1271 AppendMenu(gui->videomenu, MF_STRING, ID_PLAY, acp(MSGTR_GUI_Play "/" MSGTR_GUI_Pause)); | |
1272 AppendMenu(gui->videomenu, MF_STRING, ID_STOP, acp(MSGTR_GUI_Stop)); | |
1273 AppendMenu(gui->videomenu, MF_STRING, ID_NTRACK, acp(MSGTR_GUI_Next)); | |
1274 AppendMenu(gui->videomenu, MF_STRING, ID_SEEKF, acp(MSGTR_GUI_WIN32_SeekForwards)); | |
34697 | 1275 AppendMenu(gui->videomenu, MF_SEPARATOR, 0, 0); |
36694 | 1276 AppendMenu(gui->videomenu, MF_STRING, ID_FULLSCREEN, acp(MSGTR_GUI_SizeFullscreen)); |
1277 AppendMenu(gui->videomenu, MF_STRING, ID_MUTE, acp(MSGTR_GUI_Mute)); | |
34697 | 1278 AppendMenu(gui->videomenu, MF_SEPARATOR, 0, 0); |
36694 | 1279 AppendMenu(gui->videomenu, MF_STRING | MF_POPUP, (UINT_PTR) gui->aspectmenu, acp(MSGTR_GUI_AspectRatio)); |
1280 AppendMenu(gui->videomenu, MF_STRING | MF_POPUP, (UINT_PTR) gui->subtitlemenu, acp(MSGTR_GUI_Subtitles)); | |
34454 | 1281 #ifdef CONFIG_DVDREAD |
36694 | 1282 AppendMenu(gui->videomenu, MF_STRING | MF_POPUP, (UINT_PTR) gui->dvdmenu, acp(MSGTR_GUI_DVD)); |
1283 AppendMenu(gui->dvdmenu, MF_STRING | MF_GRAYED, ID_CHAPTERSEL, acp(MSGTR_GUI_WIN32_SelectTitleChapter"...")); | |
23077 | 1284 #endif |
36694 | 1285 AppendMenu(gui->subtitlemenu, MF_STRING, IDSUB_TOGGLE, acp(MSGTR_GUI_WIN32_SubtitleOnOff)); |
1286 AppendMenu(gui->subtitlemenu, MF_STRING, IDSUB_CYCLE, acp(MSGTR_GUI_Subtitles)); | |
34163 | 1287 AppendMenu(gui->aspectmenu, MF_STRING, ID_ASPECT1, "16:9"); |
1288 AppendMenu(gui->aspectmenu, MF_STRING, ID_ASPECT2, "4:3"); | |
36694 | 1289 AppendMenu(gui->aspectmenu, MF_STRING, ID_ASPECT3, acp(MSGTR_GUI_235To1)); |
23077 | 1290 AppendMenu(gui->aspectmenu, MF_SEPARATOR, 0, 0); |
36694 | 1291 AppendMenu(gui->aspectmenu, MF_STRING, ID_ASPECT4, acp(MSGTR_GUI_Original)); |
34697 | 1292 AppendMenu(gui->videomenu, MF_SEPARATOR, 0, 0); |
36694 | 1293 AppendMenu(gui->videomenu, MF_STRING, IDEXIT, acp(MSGTR_GUI_Quit)); |
23077 | 1294 } |
1295 | |
1296 static void maketransparent(HWND hwnd, COLORREF crTransparent) | |
1297 { | |
1298 HDC mdc = GetDC(hwnd); | |
34133
568f3a8e1b89
Support transparency in decorated windows in the Win32 GUI.
ib
parents:
34092
diff
changeset
|
1299 RECT wrd, crd; |
23077 | 1300 HRGN crRgnres, crRgn, crRgnTmp; |
1301 int iX = 0, iY = 0, iLeftX = 0; | |
34133
568f3a8e1b89
Support transparency in decorated windows in the Win32 GUI.
ib
parents:
34092
diff
changeset
|
1302 int border, title; |
23077 | 1303 int width, height; |
34133
568f3a8e1b89
Support transparency in decorated windows in the Win32 GUI.
ib
parents:
34092
diff
changeset
|
1304 |
568f3a8e1b89
Support transparency in decorated windows in the Win32 GUI.
ib
parents:
34092
diff
changeset
|
1305 GetWindowRect(hwnd, &wrd); |
568f3a8e1b89
Support transparency in decorated windows in the Win32 GUI.
ib
parents:
34092
diff
changeset
|
1306 GetClientRect(hwnd, &crd); |
23077 | 1307 |
34133
568f3a8e1b89
Support transparency in decorated windows in the Win32 GUI.
ib
parents:
34092
diff
changeset
|
1308 border = (wrd.right - wrd.left - crd.right) / 2; |
568f3a8e1b89
Support transparency in decorated windows in the Win32 GUI.
ib
parents:
34092
diff
changeset
|
1309 title = (wrd.bottom - wrd.top - crd.bottom) - border; |
568f3a8e1b89
Support transparency in decorated windows in the Win32 GUI.
ib
parents:
34092
diff
changeset
|
1310 |
568f3a8e1b89
Support transparency in decorated windows in the Win32 GUI.
ib
parents:
34092
diff
changeset
|
1311 width = crd.right - crd.left; |
568f3a8e1b89
Support transparency in decorated windows in the Win32 GUI.
ib
parents:
34092
diff
changeset
|
1312 height = crd.bottom - crd.top; |
568f3a8e1b89
Support transparency in decorated windows in the Win32 GUI.
ib
parents:
34092
diff
changeset
|
1313 |
568f3a8e1b89
Support transparency in decorated windows in the Win32 GUI.
ib
parents:
34092
diff
changeset
|
1314 /* create the title bar region */ |
568f3a8e1b89
Support transparency in decorated windows in the Win32 GUI.
ib
parents:
34092
diff
changeset
|
1315 crRgn = CreateRectRgn(0, 0, width + border + border, title); |
23077 | 1316 |
1317 /* Create a region from a bitmap with transparency colour of Purple */ | |
1318 for (iY = -1; iY < height; iY++) | |
1319 { | |
1320 do | |
1321 { | |
1322 /* skip over transparent pixels at start of lines */ | |
1323 while (iX <= width && GetPixel(mdc,iX, iY) == crTransparent) iX++; | |
1324 | |
1325 /* remember this pixel */ | |
1326 iLeftX = iX; | |
1327 | |
34133
568f3a8e1b89
Support transparency in decorated windows in the Win32 GUI.
ib
parents:
34092
diff
changeset
|
1328 /* now find last non transparent pixel */ |
23077 | 1329 while (iX <= width && GetPixel(mdc,iX, iY) != crTransparent) ++iX; |
1330 | |
1331 /* create a temp region on this info */ | |
34133
568f3a8e1b89
Support transparency in decorated windows in the Win32 GUI.
ib
parents:
34092
diff
changeset
|
1332 crRgnTmp = CreateRectRgn(iLeftX + border, iY + title, iX + border, iY + title + 1); |
23077 | 1333 |
1334 /* combine into main region */ | |
1335 crRgnres = crRgn; | |
1336 CombineRgn(crRgnres, crRgn, crRgnTmp, RGN_OR); | |
1337 crRgn = crRgnres; | |
1338 | |
1339 /* delete the temp region for next pass (otherwise you'll get an ASSERT) */ | |
1340 DeleteObject(crRgnTmp); | |
1341 } while (iX < width); | |
1342 iX = 0; | |
1343 } | |
34133
568f3a8e1b89
Support transparency in decorated windows in the Win32 GUI.
ib
parents:
34092
diff
changeset
|
1344 |
568f3a8e1b89
Support transparency in decorated windows in the Win32 GUI.
ib
parents:
34092
diff
changeset
|
1345 /* left border region */ |
568f3a8e1b89
Support transparency in decorated windows in the Win32 GUI.
ib
parents:
34092
diff
changeset
|
1346 crRgnTmp = CreateRectRgn(0, title, border, title + height); |
568f3a8e1b89
Support transparency in decorated windows in the Win32 GUI.
ib
parents:
34092
diff
changeset
|
1347 CombineRgn(crRgn, crRgn, crRgnTmp, RGN_OR); |
568f3a8e1b89
Support transparency in decorated windows in the Win32 GUI.
ib
parents:
34092
diff
changeset
|
1348 DeleteObject(crRgnTmp); |
568f3a8e1b89
Support transparency in decorated windows in the Win32 GUI.
ib
parents:
34092
diff
changeset
|
1349 |
568f3a8e1b89
Support transparency in decorated windows in the Win32 GUI.
ib
parents:
34092
diff
changeset
|
1350 /* right border region */ |
568f3a8e1b89
Support transparency in decorated windows in the Win32 GUI.
ib
parents:
34092
diff
changeset
|
1351 crRgnTmp = CreateRectRgn(width + border, title, width + border + border, title + height); |
568f3a8e1b89
Support transparency in decorated windows in the Win32 GUI.
ib
parents:
34092
diff
changeset
|
1352 CombineRgn(crRgn, crRgn, crRgnTmp, RGN_OR); |
568f3a8e1b89
Support transparency in decorated windows in the Win32 GUI.
ib
parents:
34092
diff
changeset
|
1353 DeleteObject(crRgnTmp); |
568f3a8e1b89
Support transparency in decorated windows in the Win32 GUI.
ib
parents:
34092
diff
changeset
|
1354 |
568f3a8e1b89
Support transparency in decorated windows in the Win32 GUI.
ib
parents:
34092
diff
changeset
|
1355 /* bottom region */ |
568f3a8e1b89
Support transparency in decorated windows in the Win32 GUI.
ib
parents:
34092
diff
changeset
|
1356 crRgnTmp = CreateRectRgn(0, title + height, width + border + border, title + height + border); |
568f3a8e1b89
Support transparency in decorated windows in the Win32 GUI.
ib
parents:
34092
diff
changeset
|
1357 CombineRgn(crRgn, crRgn, crRgnTmp, RGN_OR); |
568f3a8e1b89
Support transparency in decorated windows in the Win32 GUI.
ib
parents:
34092
diff
changeset
|
1358 DeleteObject(crRgnTmp); |
568f3a8e1b89
Support transparency in decorated windows in the Win32 GUI.
ib
parents:
34092
diff
changeset
|
1359 |
23077 | 1360 SetWindowRgn(hwnd, crRgn, TRUE); |
1361 DeleteObject(crRgn); | |
1362 ReleaseDC(hwnd,mdc); | |
1363 } | |
1364 | |
1365 static int window_render(gui_t *gui, HWND hWnd, HDC hdc, window_priv_t *priv, window *desc, BITMAPINFO binfo) | |
1366 { | |
34996
ebcc17a3c165
Fix compiler warnings (comparison between signed and unsigned).
ib
parents:
34995
diff
changeset
|
1367 unsigned int i; |
33638
dbca6aa18b50
Cast new user data value in SetWindowLongPtr() to LONG_PTR.
ib
parents:
33615
diff
changeset
|
1368 SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR) gui); |
23077 | 1369 (gui->window_priv_count)++; |
1370 gui->window_priv = realloc(gui->window_priv, sizeof(window_priv_t *) * gui->window_priv_count); | |
1371 priv = gui->window_priv[gui->window_priv_count - 1] = calloc(1, sizeof(window_priv_t)); | |
1372 priv->hwnd = hWnd; | |
1373 priv->type = desc->type; | |
1374 priv->background = desc->base->bitmap[0]; | |
1375 memcpy(&priv->img, desc->base->bitmap[0], sizeof(image)); | |
1376 hdc = GetDC(hWnd); | |
1377 binfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); | |
1378 binfo.bmiHeader.biWidth = priv->img.width; | |
1379 binfo.bmiHeader.biHeight = -priv->img.height; | |
1380 binfo.bmiHeader.biPlanes = 1; | |
1381 binfo.bmiHeader.biSizeImage = priv->img.width * priv->img.height * (gui->screenbpp / 8); | |
1382 binfo.bmiHeader.biXPelsPerMeter = 0; | |
1383 binfo.bmiHeader.biYPelsPerMeter = 0; | |
1384 binfo.bmiHeader.biClrUsed = 0; | |
1385 binfo.bmiHeader.biClrImportant = 0; | |
1386 binfo.bmiHeader.biBitCount = gui->screenbpp; | |
1387 binfo.bmiHeader.biCompression = BI_RGB; | |
1388 priv->bitmap = CreateDIBSection(hdc, &binfo, DIB_RGB_COLORS, (void **) &priv->img.data, NULL, 0); | |
1389 if(!priv->bitmap) | |
1390 { | |
1391 mp_msg(MSGT_GPLAYER, MSGL_FATAL, "[GUI] unable to create bitmap for skinned window\n"); | |
1392 return 0; | |
1393 } | |
1394 memcpy(priv->img.data, desc->base->bitmap[0]->data, binfo.bmiHeader.biSizeImage); | |
1395 ReleaseDC(hWnd,hdc); | |
1396 | |
1397 for (i=0; i<gui->skin->widgetcount; i++) | |
1398 if(gui->skin->widgets[i]->window == desc->type) | |
1399 renderwidget(gui->skin, &priv->img, gui->skin->widgets[i], 1); | |
1400 | |
1401 return 0; | |
1402 } | |
1403 | |
34697 | 1404 /* creates the video window */ |
1405 int create_videowindow(gui_t *gui) | |
23077 | 1406 { |
1407 HINSTANCE instance = GetModuleHandle(NULL); | |
1408 WNDCLASS wc; | |
1409 RECT rect; | |
1410 DWORD style = 0; | |
1411 HDC hdc = NULL; | |
1412 BITMAPINFO binfo; | |
1413 window_priv_t *priv = NULL; | |
1414 window *desc = NULL; | |
34996
ebcc17a3c165
Fix compiler warnings (comparison between signed and unsigned).
ib
parents:
34995
diff
changeset
|
1415 unsigned int i; |
ebcc17a3c165
Fix compiler warnings (comparison between signed and unsigned).
ib
parents:
34995
diff
changeset
|
1416 int x = -1, y = -1; |
23077 | 1417 vo_colorkey = 0xff00ff; |
1418 | |
1419 for (i=0; i<gui->skin->windowcount; i++) | |
34697 | 1420 if(gui->skin->windows[i]->type == wiVideo) |
23077 | 1421 desc = gui->skin->windows[i]; |
1422 | |
1423 if(!desc) | |
1424 { | |
1425 mp_msg(MSGT_GPLAYER, MSGL_FATAL, "[GUI] Invalid skin description\n"); | |
1426 return 1; | |
1427 } | |
1428 | |
1429 windowcolor = vo_colorkey; | |
1430 colorbrush = CreateSolidBrush(windowcolor); | |
1431 wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; | |
34697 | 1432 wc.lpfnWndProc = VideoProc; |
23077 | 1433 wc.cbClsExtra = 0; |
1434 wc.cbWndExtra = 0; | |
1435 wc.hInstance = instance; | |
1436 wc.hCursor = LoadCursor(NULL, IDC_ARROW); | |
1437 wc.hIcon = gui->icon; | |
1438 wc.hbrBackground = NULL; //WM_PAINT will handle background color switching; | |
34162 | 1439 wc.lpszClassName = "MPlayer - Video"; |
23077 | 1440 wc.lpszMenuName = NULL; |
1441 RegisterClass(&wc); | |
1442 | |
34697 | 1443 /* create the video window menu */ |
1444 create_videomenu(gui); | |
23077 | 1445 |
1446 rect.top = rect.left = 100; | |
1447 rect.bottom = rect.top+desc->base->bitmap[0]->height; | |
1448 rect.right = rect.left+desc->base->bitmap[0]->width; | |
1449 | |
1450 /* our window aspect */ | |
34697 | 1451 video_aspect = (float)(rect.right-rect.left)/(rect.bottom-rect.top); |
23077 | 1452 |
1453 style = fullscreen?WS_VISIBLE | WS_POPUP:WS_OVERLAPPEDWINDOW | WS_SYSMENU | WS_MINIMIZEBOX; | |
1454 AdjustWindowRect(&rect, style, 0); | |
1455 | |
34697 | 1456 if (gui_video_pos_x >= 0) |
1457 x = gui_video_pos_x; | |
1458 if (gui_video_pos_y >= 0) | |
1459 y = gui_video_pos_y; | |
23077 | 1460 |
1461 /* out of bounds check */ | |
1462 if (x <= -1 || (x+(rect.right-rect.left) > GetSystemMetrics(SM_CXSCREEN))) | |
1463 x = CW_USEDEFAULT; | |
1464 if (y <= -1 || (y+(rect.bottom-rect.top) > GetSystemMetrics(SM_CYSCREEN))) | |
1465 y = x; | |
1466 | |
34994 | 1467 gui->videowindow = CreateWindowEx(0, "MPlayer - Video", "MPlayer - Video", style, |
34995 | 1468 x, y, rect.right-rect.left, rect.bottom-rect.top, |
1469 NULL, NULL, instance, NULL); | |
23077 | 1470 |
1471 /* load all the window images */ | |
34994 | 1472 window_render(gui, gui->videowindow, hdc, priv, desc, binfo); |
23077 | 1473 |
1474 /* enable drag and drop support */ | |
34994 | 1475 DragAcceptFiles(gui->videowindow, TRUE); |
23077 | 1476 |
34697 | 1477 if(video_window) |
36843 | 1478 WinID = (INT_PTR) gui->videowindow; |
34697 | 1479 ShowWindow(gui->videowindow, SW_SHOW); |
1480 UpdateWindow(gui->videowindow); | |
23077 | 1481 return 0; |
1482 } | |
1483 | |
1484 /* loads/updates a skin and creates windows for it */ | |
28051 | 1485 int create_window(gui_t *gui, char *skindir) |
23077 | 1486 { |
1487 HINSTANCE instance = GetModuleHandle(NULL); | |
1488 WNDCLASS wc; | |
1489 RECT rect; | |
1490 DWORD style = 0; | |
1491 HDC hdc = NULL; | |
1492 BITMAPINFO binfo; | |
1493 window_priv_t *priv = NULL; | |
1494 window *desc = NULL; | |
1495 char dir[MAX_PATH]; | |
1496 unsigned int i; | |
1497 int x = -1, y = -1; | |
1498 | |
1499 /* destroy the current main window */ | |
1500 if(gui->skin) destroy_window(gui); | |
1501 | |
1502 /* get screenproperties */ | |
1503 gui->screenbpp = GetDesktopBitsPerPixel(); | |
1504 gui->screenw = GetSystemMetrics(SM_CXSCREEN); | |
1505 gui->screenh = GetSystemMetrics(SM_CYSCREEN); | |
1506 | |
1507 /* load the new skin */ | |
1508 gui->skin = loadskin(skindir, gui->screenbpp); | |
1509 if(!gui->skin) | |
1510 { | |
1511 mp_msg(MSGT_GPLAYER, MSGL_FATAL, "[GUI] fatal error during skinload\n"); | |
1512 /* Set default Skin */ | |
32537
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
31532
diff
changeset
|
1513 free(skinName); |
23077 | 1514 skinName = strdup("Blue"); |
1515 /* then force write conf */ | |
1516 cfg_write(); | |
1517 return 1; | |
1518 } | |
1519 | |
1520 /* find the description of the mainwindow */ | |
1521 for (i=0; i<gui->skin->windowcount; i++) | |
1522 if(gui->skin->windows[i]->type == wiMain) | |
1523 desc = gui->skin->windows[i]; | |
1524 | |
1525 if(!desc) | |
1526 { | |
1527 mp_msg(MSGT_GPLAYER, MSGL_FATAL, "[GUI] Invalid skin description\n"); | |
1528 return 1; | |
1529 } | |
1530 | |
1531 /* load the icon from the executable */ | |
1532 GetModuleFileName(NULL, dir, MAX_PATH); | |
1533 gui->icon = ExtractIcon(instance, dir, 0); | |
1534 | |
1535 /* create the window class */ | |
1536 wc.style = CS_HREDRAW | CS_VREDRAW; | |
1537 wc.lpfnWndProc = EventProc; | |
1538 wc.cbClsExtra = 0; | |
1539 wc.cbWndExtra = 0; | |
1540 wc.hInstance = instance; | |
1541 wc.hCursor = LoadCursor(NULL, IDC_ARROW); | |
1542 wc.hIcon = gui->icon; | |
1543 wc.hbrBackground = CreateSolidBrush(RGB(0, 0, 0)); | |
36053 | 1544 wc.lpszClassName = gui->classname = MPlayer; |
23077 | 1545 wc.lpszMenuName = NULL; |
1546 RegisterClass(&wc); | |
1547 | |
1548 /* create a context menu */ | |
1549 create_menu(gui); | |
1550 /* create the systray menu */ | |
1551 create_traymenu(gui); | |
1552 | |
1553 /* create the mainwindow */ | |
1554 /* TODO implement aligning as described in skin.html */ | |
1555 rect.top = rect.left = 100; | |
1556 rect.bottom = rect.top+desc->base->bitmap[0]->height; | |
1557 rect.right = rect.left+desc->base->bitmap[0]->width; | |
1558 if(desc->decoration) style = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX; | |
1559 else style = WS_POPUP | WS_SYSMENU; | |
1560 | |
1561 AdjustWindowRect(&rect, style, 0); | |
1562 | |
1563 /* Check if out of screen */ | |
1564 if (gui_main_pos_x >= 0) | |
1565 x = gui_main_pos_x; | |
1566 if (gui_main_pos_y >= 0) | |
1567 y = gui_main_pos_y; | |
1568 | |
1569 if (x <= -1 || (x+(rect.right-rect.left) > GetSystemMetrics(SM_CXFULLSCREEN))) | |
1570 { | |
1571 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - ((rect.right-rect.left) / 2); | |
1572 gui_main_pos_x = x; | |
1573 } | |
1574 if (y <= -1 || (y+(rect.bottom-rect.top) > GetSystemMetrics(SM_CYFULLSCREEN))) | |
1575 { | |
1576 y = ((GetSystemMetrics(SM_CYSCREEN)-40) - (rect.bottom-rect.top)); | |
1577 gui_main_pos_y = y; | |
1578 } | |
1579 | |
36053 | 1580 gui->mainwindow = CreateWindowEx(0, gui->classname, MPlayer, style, |
34995 | 1581 x, y, rect.right-rect.left, rect.bottom-rect.top, |
1582 NULL, NULL, instance, NULL); | |
23077 | 1583 |
1584 /* set the systray icon properties */ | |
1585 nid.cbSize = sizeof(NOTIFYICONDATA); | |
34994 | 1586 nid.hWnd = gui->mainwindow; |
23077 | 1587 nid.uID = 1; |
1588 nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; | |
1589 nid.uCallbackMessage = WM_SYSTRAY; | |
1590 nid.hIcon = gui->icon; | |
36053 | 1591 strcpy(nid.szTip, MPlayer); |
23077 | 1592 |
1593 /* register the systray icon */ | |
1594 Shell_NotifyIcon(NIM_ADD, &nid); | |
1595 | |
1596 /* load all the window images */ | |
34994 | 1597 window_render(gui, gui->mainwindow, hdc, priv, desc, binfo); |
23077 | 1598 |
1599 /* enable drag and drop support */ | |
34994 | 1600 DragAcceptFiles(gui->mainwindow, TRUE); |
23077 | 1601 |
34994 | 1602 updatedisplay(gui, gui->mainwindow); |
23077 | 1603 |
1604 /* display */ | |
1605 ShowWindow(gui->mainwindow, SW_SHOW); | |
1606 UpdateWindow(gui->mainwindow); | |
1607 maketransparent(gui->mainwindow, RGB(255, 0, 255)); | |
1608 return 0; | |
1609 } | |
1610 | |
33781 | 1611 gui_t *create_gui(char *skindir, void (*playercontrol)(int event)) |
23077 | 1612 { |
1613 gui_t *gui = calloc(1, sizeof(gui_t)); | |
1614 char temp[MAX_PATH]; | |
36053 | 1615 HWND runningmplayer = FindWindow(MPlayer, MPlayer); |
23077 | 1616 |
1617 if(runningmplayer) | |
1618 { | |
1619 free(gui); | |
1620 return NULL; | |
1621 } | |
1622 | |
1623 gui->startplay = startplay; | |
1624 gui->playercontrol = playercontrol; | |
1625 gui->uninit = uninit; | |
1626 gui->updatedisplay = updatedisplay; | |
1627 | |
1628 /* create playlist */ | |
1629 gui->playlist = create_playlist(); | |
1630 | |
34092
dbf5042ab255
Don't use the Windows style path separator character in Win32 GUI.
ib
parents:
33965
diff
changeset
|
1631 sprintf(temp, "%s/%s", skindir, skinName); |
23077 | 1632 if(create_window(gui, temp)) return NULL; |
34697 | 1633 if(create_videowindow(gui)) return NULL; |
35001 | 1634 if(console) console_toggle(gui); |
23077 | 1635 return gui; |
1636 } |