Mercurial > mplayer.hg
annotate Gui/win32/gui.c @ 21715:9d96f4df253a
sync with r21655, based on a file conversion of help_mp-zh_CN.h
file provided by Eric Wang, eric7wang gmail com
author | kraymer |
---|---|
date | Fri, 22 Dec 2006 22:56:07 +0000 |
parents | b42f1c1ef651 |
children | 309992959801 |
rev | line source |
---|---|
18914 | 1 /* |
2 MPlayer Gui for win32 | |
3 Copyright (c) 2003 Sascha Sommer <saschasommer@freenet.de> | |
4 Copyright (c) 2006 Erik Augustson <erik_27can@yahoo.com> | |
5 Copyright (c) 2006 Gianluigi Tiesi <sherpya@netfarm.it> | |
6 | |
7 This program is free software; you can redistribute it and/or modify | |
8 it under the terms of the GNU General Public License as published by | |
9 the Free Software Foundation; either version 2 of the License, or | |
10 (at your option) any later version. | |
11 | |
12 This program is distributed in the hope that it will be useful, | |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 GNU General Public License for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with this program; if not, write to the Free Software | |
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA | |
20 */ | |
21 | |
22 #include <stdio.h> | |
23 #include <stdlib.h> | |
24 #include <ctype.h> | |
25 #include <fcntl.h> | |
26 #include <windows.h> | |
27 #include <windowsx.h> | |
28 #include <shlobj.h> | |
29 #include <version.h> | |
30 #include <mplayer.h> | |
31 #include <mp_msg.h> | |
32 #include <help_mp.h> | |
33 #include <cpudetect.h> | |
34 #include <input/input.h> | |
35 #include <input/mouse.h> | |
36 #include <osdep/keycodes.h> | |
19271
64d82a45a05d
introduce new 'stream' directory for all stream layer related components and split them from libmpdemux
ben
parents:
19245
diff
changeset
|
37 #include <stream/stream.h> |
18914 | 38 #include <libvo/video_out.h> |
39 #include <interface.h> | |
40 #include "gui.h" | |
41 #include "wincfg.h" | |
42 #include "dialogs.h" | |
43 | |
18930
d7ab6268e3ea
Some older MinGW versions have a broken INVALID_FILE_ATTRIBUTES, so hack around that for now.
reimar
parents:
18914
diff
changeset
|
44 // HACK around bug in old mingw |
d7ab6268e3ea
Some older MinGW versions have a broken INVALID_FILE_ATTRIBUTES, so hack around that for now.
reimar
parents:
18914
diff
changeset
|
45 #undef INVALID_FILE_ATTRIBUTES |
d7ab6268e3ea
Some older MinGW versions have a broken INVALID_FILE_ATTRIBUTES, so hack around that for now.
reimar
parents:
18914
diff
changeset
|
46 #define INVALID_FILE_ATTRIBUTES ((DWORD)-1) |
d7ab6268e3ea
Some older MinGW versions have a broken INVALID_FILE_ATTRIBUTES, so hack around that for now.
reimar
parents:
18914
diff
changeset
|
47 |
18914 | 48 #ifndef WM_XBUTTONDOWN |
49 # define WM_XBUTTONDOWN 0x020B | |
50 # define WM_XBUTTONUP 0x020C | |
51 # define WM_XBUTTONDBLCLK 0x020D | |
52 #endif | |
53 | |
54 #define MP_TITLE "MPlayer " VERSION " (C) 2000-2006 MPlayer Team" | |
55 | |
56 /* Globals / Externs */ | |
57 extern void renderinfobox(skin_t *skin, window_priv_t *priv); | |
58 extern void renderwidget(skin_t *skin, image *dest, widget *item, int state); | |
59 extern void mplayer_put_key(int code); | |
60 extern int WinID; | |
61 float sub_aspect; | |
62 | |
63 DWORD oldtime; | |
64 NOTIFYICONDATA nid; | |
65 int console_state = 0; | |
66 | |
19570
e9ea7852e803
vo_colorkey change to avoid clashes with other black windows
vayne
parents:
19535
diff
changeset
|
67 static HBRUSH colorbrush = NULL; //Handle to colorkey brush |
e9ea7852e803
vo_colorkey change to avoid clashes with other black windows
vayne
parents:
19535
diff
changeset
|
68 static COLORREF windowcolor = RGB(255,0,255); //Windowcolor == colorkey |
e9ea7852e803
vo_colorkey change to avoid clashes with other black windows
vayne
parents:
19535
diff
changeset
|
69 |
18914 | 70 void console_toggle(void) |
71 { | |
72 if (console_state) | |
73 { | |
74 FreeConsole(); | |
75 console = 0; | |
76 console_state = 0; | |
77 } | |
78 else | |
79 { | |
80 /* This code comes from: http://dslweb.nwnexus.com/~ast/dload/guicon.htm */ | |
81 CONSOLE_SCREEN_BUFFER_INFO coninfo; | |
82 FILE *fp; | |
83 HWND hwnd = NULL; | |
84 console = 1; | |
85 AllocConsole(); | |
86 SetConsoleTitle(MP_TITLE); | |
87 | |
88 /* disable the close button for now */ | |
89 while (!hwnd) | |
90 { | |
91 hwnd = FindWindow(NULL, MP_TITLE); | |
92 Sleep(100); | |
93 } | |
94 DeleteMenu(GetSystemMenu(hwnd, 0), SC_CLOSE, MF_BYCOMMAND); | |
95 | |
96 GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo); | |
97 coninfo.dwSize.Y = 1000; | |
98 SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coninfo.dwSize); | |
99 fp = freopen("con", "w", stdout); | |
100 *stdout = *fp; | |
101 setvbuf(stdout, NULL, _IONBF, 0); | |
102 fp = freopen("con", "r", stdin); | |
103 *stdin = *fp; | |
104 setvbuf(stdin, NULL, _IONBF, 0); | |
105 fp = freopen("con", "w", stdout); | |
106 *stderr = *fp; | |
107 setvbuf(stderr, NULL, _IONBF, 0); | |
108 mp_msg(MSGT_CPLAYER, MSGL_INFO, "%s\n", MP_TITLE); | |
109 GetCpuCaps(&gCpuCaps); | |
20577 | 110 #ifdef ARCH_X86 |
18914 | 111 mp_msg(MSGT_CPLAYER,MSGL_INFO,"CPUflags: MMX: %d MMX2: %d 3DNow: %d 3DNow2: %d SSE: %d SSE2: %d\n", |
112 gCpuCaps.hasMMX, gCpuCaps.hasMMX2, | |
113 gCpuCaps.has3DNow, gCpuCaps.has3DNowExt, | |
114 gCpuCaps.hasSSE, gCpuCaps.hasSSE2); | |
115 #ifdef RUNTIME_CPUDETECT | |
116 mp_msg(MSGT_CPLAYER,MSGL_INFO, MSGTR_CompiledWithRuntimeDetection); | |
117 #else | |
118 mp_msg(MSGT_CPLAYER,MSGL_INFO, MSGTR_CompiledWithCPUExtensions); | |
119 #ifdef HAVE_MMX | |
120 mp_msg(MSGT_CPLAYER,MSGL_INFO," MMX"); | |
121 #endif | |
122 #ifdef HAVE_MMX2 | |
123 mp_msg(MSGT_CPLAYER,MSGL_INFO," MMX2"); | |
124 #endif | |
125 #ifdef HAVE_3DNOW | |
126 mp_msg(MSGT_CPLAYER,MSGL_INFO," 3DNow"); | |
127 #endif | |
128 #ifdef HAVE_3DNOWEX | |
129 mp_msg(MSGT_CPLAYER,MSGL_INFO," 3DNowEx"); | |
130 #endif | |
131 #ifdef HAVE_SSE | |
132 mp_msg(MSGT_CPLAYER,MSGL_INFO," SSE"); | |
133 #endif | |
134 #ifdef HAVE_SSE2 | |
135 mp_msg(MSGT_CPLAYER,MSGL_INFO," SSE2"); | |
136 #endif | |
137 mp_msg(MSGT_CPLAYER,MSGL_INFO,"\n\n"); | |
138 #endif | |
139 #endif | |
140 console_state = 1; | |
141 } | |
142 } | |
143 | |
144 void capitalize(char *filename) | |
145 { | |
146 unsigned int i; | |
147 BOOL cap = TRUE; | |
148 for (i=0; i < strlen(filename); i++) | |
149 { | |
150 if (cap) | |
151 { | |
152 cap = FALSE; | |
153 filename[i] = toupper(filename[i]); | |
154 } | |
155 else if (filename[i] == ' ') | |
156 cap = TRUE; | |
157 else | |
158 filename[i] = tolower(filename[i]); | |
159 } | |
160 } | |
161 | |
162 static image *get_drawground(HWND hwnd) | |
163 { | |
164 gui_t * gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA); | |
165 unsigned int i; | |
166 if(!gui) return NULL; | |
167 for(i=0; i<gui->window_priv_count; i++) | |
168 if(gui->window_priv[i]->hwnd==hwnd) | |
169 return &gui->window_priv[i]->img; | |
170 return NULL; | |
171 } | |
172 | |
173 static HBITMAP get_bitmap(HWND hwnd) | |
174 { | |
175 gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA); | |
176 unsigned int i; | |
177 if(!gui) return NULL; | |
178 for(i=0; i<gui->window_priv_count; i++) | |
179 if(gui->window_priv[i]->hwnd == hwnd) | |
180 return gui->window_priv[i]->bitmap; | |
181 return NULL; | |
182 } | |
183 | |
184 static int get_windowtype(HWND hwnd) | |
185 { | |
186 gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA); | |
187 unsigned int i; | |
188 if(!gui) return -1; | |
189 for(i=0; i<gui->window_priv_count; i++) | |
190 if(gui->window_priv[i]->hwnd == hwnd) | |
191 return gui->window_priv[i]->type; | |
192 return -1; | |
193 } | |
194 | |
195 static void uninit(gui_t *gui) | |
196 { | |
197 if(gui->skin) destroy_window(gui); | |
198 if(gui->playlist) gui->playlist->free_playlist(gui->playlist); | |
199 gui->playlist = NULL; | |
200 } | |
201 | |
202 /* | |
203 the gui message handler | |
204 tries to handle the incoming messages | |
205 and passes them to the player's message handler if it can't handle them | |
206 */ | |
207 static void handlemsg(HWND hWnd, int msg) | |
208 { | |
209 gui_t *gui = (gui_t *) GetWindowLongPtr(hWnd, GWLP_USERDATA); | |
210 if(msg == evNone) return; | |
211 | |
212 switch(msg) | |
213 { | |
214 case evLoadPlay: | |
215 case evLoad: | |
216 if(display_openfilewindow(gui, 0) && (msg == evLoadPlay)) | |
217 handlemsg(hWnd, evDropFile); | |
218 return; | |
219 case evLoadSubtitle: | |
220 display_opensubtitlewindow(gui); | |
221 break; | |
222 case evPreferences: | |
223 display_prefswindow(gui); | |
224 return; | |
225 case evPlayList: | |
226 display_playlistwindow(gui); | |
227 return; | |
228 case evSkinBrowser: | |
229 display_skinbrowser(gui); | |
230 break; | |
231 case evEqualizer: | |
232 display_eqwindow(gui); | |
233 break; | |
234 case evAbout: | |
235 MessageBox(hWnd, COPYRIGHT, "About", MB_OK); | |
236 break; | |
237 case evIconify: | |
238 ShowWindow(hWnd, SW_MINIMIZE); | |
239 break; | |
240 case evIncVolume: | |
241 mplayer_put_key(KEY_VOLUME_UP); | |
242 break; | |
243 case evDecVolume: | |
244 mplayer_put_key(KEY_VOLUME_DOWN); | |
245 break; | |
246 default: | |
247 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] received msg %s (%i)\n", gui->skin->geteventname(msg), msg); | |
248 break; | |
249 } | |
250 gui->playercontrol(msg); | |
251 } | |
252 | |
253 static widget *clickedinsidewidget(gui_t *gui, int window, int x, int y) | |
254 { | |
255 unsigned int i; | |
256 widget *item; | |
257 for(i=0; i<gui->skin->widgetcount; i++) | |
258 { | |
259 item = gui->skin->widgets[i]; | |
260 if((item->window == window) && (item->x <= x) && (item->x + item->width >= x) && | |
261 (item->y <= y) && (item->y + item->height >= y)) | |
262 return item; | |
263 } | |
264 return NULL; | |
265 } | |
266 | |
267 /* updates sliders and the display */ | |
268 static void updatedisplay(gui_t *gui, HWND hwnd) | |
269 { | |
270 unsigned int i; | |
271 window_priv_t *priv = NULL; | |
19718 | 272 DWORD time = timeGetTime(); |
273 | |
274 if(!hwnd) return; | |
18914 | 275 |
276 /* load all potmeters hpotmeters */ | |
277 for(i=0; i<gui->skin->widgetcount; i++) | |
278 { | |
279 if(gui->skin->widgets[i]->type == tyHpotmeter || gui->skin->widgets[i]->type == tyPotmeter) | |
280 { | |
281 if(gui->skin->widgets[i]->msg == evSetVolume) | |
282 gui->skin->widgets[i]->value = guiIntfStruct.Volume; | |
283 else if(gui->skin->widgets[i]->msg == evSetMoviePosition) | |
284 gui->skin->widgets[i]->value = guiIntfStruct.Position; | |
285 else if(gui->skin->widgets[i]->msg == evSetBalance) | |
286 gui->skin->widgets[i]->value = guiIntfStruct.Balance; | |
287 if(gui->skin->widgets[i]->window == get_windowtype(hwnd)) | |
288 renderwidget(gui->skin, get_drawground(hwnd), gui->skin->widgets[i], | |
289 gui->skin->widgets[i]->pressed ? 0 : 1); | |
290 } | |
291 /* update some buttons */ | |
292 if(gui->skin->widgets[i]->type == tyButton && gui->skin->widgets[i]->window == get_windowtype(hwnd)) | |
293 { | |
294 if(gui->skin->widgets[i]->msg == evPlaySwitchToPause) | |
295 { | |
296 gui->skin->widgets[i]->value = guiIntfStruct.Playing; | |
297 renderwidget(gui->skin, get_drawground(hwnd), gui->skin->widgets[i], | |
298 guiIntfStruct.Playing == 1 ? 0 : 1); | |
299 } | |
300 if(gui->skin->widgets[i]->msg == evMute) | |
301 { | |
302 gui->skin->widgets[i]->value = guiIntfStruct.Volume; | |
303 renderwidget(gui->skin, get_drawground(hwnd), gui->skin->widgets[i], | |
304 guiIntfStruct.Volume == 0.0f ? 0 : 1); | |
305 } | |
306 } | |
307 } | |
308 | |
309 /* updating the display once a 100.second is enough imo */ | |
310 if((time - oldtime) < 100) return; | |
311 oldtime=time; | |
312 | |
19535
69b134c4caea
Further fullscreen switching improvements. Fixes sub window position bug when exiting a file from fullscreen. Fixes sub window position when switching between windows and fullscreen modes.
vayne
parents:
19408
diff
changeset
|
313 /* suppress directx's fullscreen window when using the sub window */ |
69b134c4caea
Further fullscreen switching improvements. Fixes sub window position bug when exiting a file from fullscreen. Fixes sub window position when switching between windows and fullscreen modes.
vayne
parents:
19408
diff
changeset
|
314 if(sub_window && &video_driver_list[0] && strstr("directx", video_driver_list[0])) |
69b134c4caea
Further fullscreen switching improvements. Fixes sub window position bug when exiting a file from fullscreen. Fixes sub window position when switching between windows and fullscreen modes.
vayne
parents:
19408
diff
changeset
|
315 { |
69b134c4caea
Further fullscreen switching improvements. Fixes sub window position bug when exiting a file from fullscreen. Fixes sub window position when switching between windows and fullscreen modes.
vayne
parents:
19408
diff
changeset
|
316 HWND hWndFS = NULL; //handle to directx's fullscreen window |
69b134c4caea
Further fullscreen switching improvements. Fixes sub window position bug when exiting a file from fullscreen. Fixes sub window position when switching between windows and fullscreen modes.
vayne
parents:
19408
diff
changeset
|
317 if(hWndFS == NULL) |
69b134c4caea
Further fullscreen switching improvements. Fixes sub window position bug when exiting a file from fullscreen. Fixes sub window position when switching between windows and fullscreen modes.
vayne
parents:
19408
diff
changeset
|
318 { |
69b134c4caea
Further fullscreen switching improvements. Fixes sub window position bug when exiting a file from fullscreen. Fixes sub window position when switching between windows and fullscreen modes.
vayne
parents:
19408
diff
changeset
|
319 hWndFS = FindWindow(NULL, "MPlayer Fullscreen"); |
69b134c4caea
Further fullscreen switching improvements. Fixes sub window position bug when exiting a file from fullscreen. Fixes sub window position when switching between windows and fullscreen modes.
vayne
parents:
19408
diff
changeset
|
320 if(hWndFS != NULL) DestroyWindow(hWndFS); //sub window handles fullscreen |
69b134c4caea
Further fullscreen switching improvements. Fixes sub window position bug when exiting a file from fullscreen. Fixes sub window position when switching between windows and fullscreen modes.
vayne
parents:
19408
diff
changeset
|
321 } |
69b134c4caea
Further fullscreen switching improvements. Fixes sub window position bug when exiting a file from fullscreen. Fixes sub window position when switching between windows and fullscreen modes.
vayne
parents:
19408
diff
changeset
|
322 } |
69b134c4caea
Further fullscreen switching improvements. Fixes sub window position bug when exiting a file from fullscreen. Fixes sub window position when switching between windows and fullscreen modes.
vayne
parents:
19408
diff
changeset
|
323 |
18914 | 324 for (i=0; i<gui->window_priv_count; i++) |
325 { | |
326 if(gui->window_priv[i]->hwnd == hwnd) | |
327 priv=gui->window_priv[i]; | |
328 }// Sherpya | |
329 /* display the status msgs */ | |
330 renderinfobox(gui->skin, priv); | |
331 RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE); | |
332 } | |
333 | |
334 static LRESULT CALLBACK SubProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) | |
335 { | |
336 gui_t *gui = (gui_t *) GetWindowLongPtr(hWnd, GWLP_USERDATA); | |
337 if (gui && (gui->subwindow != hWnd)) return FALSE; | |
338 | |
339 switch (message) | |
340 { | |
341 case WM_CLOSE: | |
342 handlemsg(hWnd, evExit); | |
343 return 0; | |
344 case WM_DESTROY: | |
345 PostQuitMessage(0); | |
346 return 0; | |
347 case WM_KEYDOWN: | |
348 { | |
349 switch(wParam) | |
350 { | |
351 case VK_LEFT: | |
352 mplayer_put_key(KEY_LEFT); | |
353 break; | |
354 case VK_UP: | |
355 mplayer_put_key(KEY_UP); | |
356 break; | |
357 case VK_RIGHT: | |
358 mplayer_put_key(KEY_RIGHT); | |
359 break; | |
360 case VK_DOWN: | |
361 mplayer_put_key(KEY_DOWN); | |
362 break; | |
363 case VK_TAB: | |
364 mplayer_put_key(KEY_TAB); | |
365 break; | |
366 case VK_BACK: | |
367 mplayer_put_key(KEY_BS); | |
368 break; | |
369 case VK_DELETE: | |
370 mplayer_put_key(KEY_DELETE); | |
371 break; | |
372 case VK_INSERT: | |
373 mplayer_put_key(KEY_INSERT); | |
374 break; | |
375 case VK_HOME: | |
376 mplayer_put_key(KEY_HOME); | |
377 break; | |
378 case VK_END: | |
379 mplayer_put_key(KEY_END); | |
380 break; | |
381 case VK_PRIOR: | |
382 mplayer_put_key(KEY_PAGE_UP); | |
383 break; | |
384 case VK_NEXT: | |
385 mplayer_put_key(KEY_PAGE_DOWN); | |
386 break; | |
387 case VK_ESCAPE: | |
388 mplayer_put_key(KEY_ESC); | |
389 break; | |
390 } | |
391 break; | |
392 } | |
393 case WM_COMMAND: | |
394 { | |
395 switch(LOWORD(wParam)) | |
396 { | |
397 case IDEXIT: | |
398 PostQuitMessage(0); | |
399 handlemsg(hWnd, evExit); | |
400 break; | |
401 case IDFILE_OPEN: | |
402 handlemsg(hWnd, evLoadPlay); | |
403 break; | |
404 case IDURL_OPEN: | |
405 display_openurlwindow(gui, 0); | |
406 break; | |
407 case IDDIR_OPEN: | |
408 { | |
409 static char path[MAX_PATH]; | |
410 BROWSEINFO bi; | |
19718 | 411 LPITEMIDLIST pidl; |
18914 | 412 memset(&bi, 0, sizeof(BROWSEINFO)); |
413 bi.lpszTitle = "Choose a Directory..."; | |
19718 | 414 pidl = SHBrowseForFolder(&bi); |
18914 | 415 if (SHGetPathFromIDList(pidl, path)) |
416 { | |
417 gui->playlist->clear_playlist(gui->playlist); | |
418 adddirtoplaylist(gui->playlist, path, TRUE); | |
419 gui->startplay(gui); | |
420 } | |
421 break; | |
422 } | |
423 case ID_PTRACK: | |
424 handlemsg(hWnd, evPrev); | |
425 break; | |
426 case ID_SEEKB: | |
427 handlemsg(hWnd, evBackward10sec); | |
428 break; | |
429 case ID_PLAY: | |
430 handlemsg(hWnd, evPlaySwitchToPause); | |
431 break; | |
432 case ID_STOP: | |
433 handlemsg(hWnd, evStop); | |
434 break; | |
435 case ID_SEEKF: | |
436 handlemsg(hWnd, evForward10sec); | |
437 break; | |
438 case ID_NTRACK: | |
439 handlemsg(hWnd, evNext); | |
440 break; | |
441 #ifdef USE_DVDREAD | |
442 case ID_CHAPTERSEL: | |
443 display_chapterselwindow(gui); | |
444 break; | |
445 #endif | |
20211
26867dede11c
as per request, fullscreen and mute options have been added to the context menus.
vayne
parents:
20132
diff
changeset
|
446 case ID_FULLSCREEN: |
26867dede11c
as per request, fullscreen and mute options have been added to the context menus.
vayne
parents:
20132
diff
changeset
|
447 mp_input_queue_cmd(mp_input_parse_cmd("vo_fullscreen")); |
26867dede11c
as per request, fullscreen and mute options have been added to the context menus.
vayne
parents:
20132
diff
changeset
|
448 break; |
26867dede11c
as per request, fullscreen and mute options have been added to the context menus.
vayne
parents:
20132
diff
changeset
|
449 case ID_MUTE: |
26867dede11c
as per request, fullscreen and mute options have been added to the context menus.
vayne
parents:
20132
diff
changeset
|
450 mp_input_queue_cmd(mp_input_parse_cmd("mute")); |
26867dede11c
as per request, fullscreen and mute options have been added to the context menus.
vayne
parents:
20132
diff
changeset
|
451 break; |
18914 | 452 case ID_ASPECT1: |
453 mp_input_queue_cmd(mp_input_parse_cmd("switch_ratio 1.777777")); | |
454 break; | |
455 case ID_ASPECT2: | |
456 mp_input_queue_cmd(mp_input_parse_cmd("switch_ratio 1.333333")); | |
457 break; | |
458 case ID_ASPECT3: | |
459 mp_input_queue_cmd(mp_input_parse_cmd("switch_ratio 2.35")); | |
460 break; | |
461 case ID_ASPECT4: | |
462 mp_input_queue_cmd(mp_input_parse_cmd("switch_ratio 0")); | |
463 break; | |
464 case IDSUB_TOGGLE: | |
465 mp_input_queue_cmd(mp_input_parse_cmd("sub_visibility")); | |
466 break; | |
467 case IDSUB_CYCLE: | |
468 mp_input_queue_cmd(mp_input_parse_cmd("sub_select")); | |
469 break; | |
470 } | |
471 return 0; | |
472 } | |
473 case WM_CHAR: | |
474 mplayer_put_key(wParam); | |
475 break; | |
476 case WM_DROPFILES: | |
477 { | |
478 if(!lParam) | |
479 { | |
480 char file[MAX_PATH]; | |
481 int filecount = DragQueryFile((HDROP) wParam, -1, file, MAX_PATH); | |
482 int i; | |
483 for(i=0; i<filecount; i++) | |
484 { | |
485 DragQueryFile((HDROP) wParam, i, file, MAX_PATH); | |
486 if(!parse_filename(file, playtree, mconfig, 1)) | |
487 gui->playlist->add_track(gui->playlist, file, NULL, NULL, 0); | |
488 } | |
489 DragFinish((HDROP) wParam); | |
490 handlemsg(hWnd, evDropFile); | |
491 } | |
492 else | |
493 { | |
494 gui->playlist->clear_playlist(gui->playlist); | |
495 gui->playlist->add_track(gui->playlist, (const char *) wParam, NULL, NULL, 0); | |
496 handlemsg(hWnd, evDropFile); | |
497 } | |
498 SetForegroundWindow(gui->subwindow); | |
499 return 0; | |
500 } | |
501 case WM_LBUTTONDOWN: | |
502 { | |
503 if(!vo_nomouse_input) | |
504 mplayer_put_key(MOUSE_BTN0); | |
505 break; | |
506 } | |
507 case WM_MBUTTONDOWN: | |
508 { | |
509 if(!vo_nomouse_input) | |
510 mplayer_put_key(MOUSE_BTN1); | |
511 break; | |
512 } | |
513 case WM_RBUTTONDOWN: | |
514 { | |
515 POINT point; | |
516 point.x = GET_X_LPARAM(lParam); | |
517 point.y = GET_Y_LPARAM(lParam); | |
518 ClientToScreen(hWnd, &point); | |
519 if(guiIntfStruct.StreamType == STREAMTYPE_DVD) | |
520 EnableMenuItem(gui->dvdmenu, ID_CHAPTERSEL, MF_BYCOMMAND | MF_ENABLED); | |
521 TrackPopupMenu(gui->submenu, 0, point.x, point.y, 0, hWnd, NULL); | |
522 return 0; | |
523 } | |
524 case WM_LBUTTONDBLCLK: | |
525 { | |
526 if(!vo_nomouse_input) | |
527 mplayer_put_key(MOUSE_BTN0_DBL); | |
528 break; | |
529 } | |
530 case WM_MBUTTONDBLCLK: | |
531 { | |
532 if(!vo_nomouse_input) | |
533 mplayer_put_key(MOUSE_BTN1_DBL); | |
534 break; | |
535 } | |
536 case WM_RBUTTONDBLCLK: | |
537 { | |
538 if(!vo_nomouse_input) | |
539 mplayer_put_key(MOUSE_BTN2_DBL); | |
540 break; | |
541 } | |
542 case WM_MOUSEWHEEL: | |
543 { | |
19718 | 544 int x = GET_WHEEL_DELTA_WPARAM(wParam); |
18914 | 545 if(vo_nomouse_input) |
546 break; | |
547 if (x > 0) | |
548 mplayer_put_key(MOUSE_BTN3); | |
549 else | |
550 mplayer_put_key(MOUSE_BTN4); | |
551 break; | |
552 } | |
553 case WM_XBUTTONDOWN: | |
554 { | |
555 if(vo_nomouse_input) | |
556 break; | |
557 if(HIWORD(wParam) == 1) | |
558 mplayer_put_key(MOUSE_BTN5); | |
559 else | |
560 mplayer_put_key(MOUSE_BTN6); | |
561 break; | |
562 } | |
563 case WM_XBUTTONDBLCLK: | |
564 { | |
565 if(vo_nomouse_input) | |
566 break; | |
567 if(HIWORD(wParam) == 1) | |
568 mplayer_put_key(MOUSE_BTN5_DBL); | |
569 else | |
570 mplayer_put_key(MOUSE_BTN6_DBL); | |
571 break; | |
572 } | |
20132
a8aa764559fa
added a simple timer to hide the mouse when in fullscreen mode.
vayne
parents:
19897
diff
changeset
|
573 case WM_TIMER: |
a8aa764559fa
added a simple timer to hide the mouse when in fullscreen mode.
vayne
parents:
19897
diff
changeset
|
574 { |
a8aa764559fa
added a simple timer to hide the mouse when in fullscreen mode.
vayne
parents:
19897
diff
changeset
|
575 if(fullscreen) while(ShowCursor(FALSE) >= 0){} |
a8aa764559fa
added a simple timer to hide the mouse when in fullscreen mode.
vayne
parents:
19897
diff
changeset
|
576 KillTimer(hWnd, ID_TIMER); |
a8aa764559fa
added a simple timer to hide the mouse when in fullscreen mode.
vayne
parents:
19897
diff
changeset
|
577 return 0; |
a8aa764559fa
added a simple timer to hide the mouse when in fullscreen mode.
vayne
parents:
19897
diff
changeset
|
578 } |
a8aa764559fa
added a simple timer to hide the mouse when in fullscreen mode.
vayne
parents:
19897
diff
changeset
|
579 case WM_MOUSEMOVE: |
a8aa764559fa
added a simple timer to hide the mouse when in fullscreen mode.
vayne
parents:
19897
diff
changeset
|
580 { |
a8aa764559fa
added a simple timer to hide the mouse when in fullscreen mode.
vayne
parents:
19897
diff
changeset
|
581 ShowCursor(TRUE); |
a8aa764559fa
added a simple timer to hide the mouse when in fullscreen mode.
vayne
parents:
19897
diff
changeset
|
582 SetTimer(hWnd, ID_TIMER, 3000, (TIMERPROC) NULL); |
a8aa764559fa
added a simple timer to hide the mouse when in fullscreen mode.
vayne
parents:
19897
diff
changeset
|
583 break; |
a8aa764559fa
added a simple timer to hide the mouse when in fullscreen mode.
vayne
parents:
19897
diff
changeset
|
584 } |
18914 | 585 case WM_WINDOWPOSCHANGED: |
586 { | |
587 int tmpheight=0; | |
588 static uint32_t rect_width; | |
589 static uint32_t rect_height; | |
590 RECT rd; | |
591 POINT pt; | |
592 pt.x = 0; | |
593 pt.y = 0; | |
594 GetClientRect(hWnd, &rd); | |
595 ClientToScreen(hWnd, &pt); | |
596 | |
597 rect_width = rd.right - rd.left; | |
598 rect_height = rd.bottom - rd.top; | |
599 | |
600 /* maintain our aspect ratio */ | |
601 tmpheight = ((float)rect_width/sub_aspect); | |
602 tmpheight += tmpheight % 2; | |
603 if(tmpheight > rect_height) | |
604 { | |
605 rect_width = ((float)rect_height*sub_aspect); | |
606 rect_width += rect_width % 2; | |
607 } | |
608 else rect_height = tmpheight; | |
609 | |
610 rd.right = rd.left + rect_width; | |
611 rd.bottom = rd.top + rect_height; | |
612 | |
19408 | 613 AdjustWindowRect(&rd, WS_OVERLAPPEDWINDOW | WS_SIZEBOX, 0); |
19245 | 614 SetWindowPos(hWnd, 0, fullscreen?0:pt.x+rd.left, fullscreen?0:pt.y+rd.top, |
19408 | 615 fullscreen?vo_screenwidth:rd.right-rd.left, fullscreen?vo_screenheight:rd.bottom-rd.top, SWP_NOOWNERZORDER); |
616 SetForegroundWindow(hWnd); | |
18914 | 617 return 0; |
618 } | |
19897
b69d78e8aee8
fix for disabling screensaver when in fullscreen mode while using the sub window.
vayne
parents:
19718
diff
changeset
|
619 case WM_SYSCOMMAND: |
b69d78e8aee8
fix for disabling screensaver when in fullscreen mode while using the sub window.
vayne
parents:
19718
diff
changeset
|
620 { |
b69d78e8aee8
fix for disabling screensaver when in fullscreen mode while using the sub window.
vayne
parents:
19718
diff
changeset
|
621 switch(wParam) |
b69d78e8aee8
fix for disabling screensaver when in fullscreen mode while using the sub window.
vayne
parents:
19718
diff
changeset
|
622 { |
b69d78e8aee8
fix for disabling screensaver when in fullscreen mode while using the sub window.
vayne
parents:
19718
diff
changeset
|
623 case SC_SCREENSAVE: |
b69d78e8aee8
fix for disabling screensaver when in fullscreen mode while using the sub window.
vayne
parents:
19718
diff
changeset
|
624 case SC_MONITORPOWER: |
b69d78e8aee8
fix for disabling screensaver when in fullscreen mode while using the sub window.
vayne
parents:
19718
diff
changeset
|
625 mp_msg(MSGT_VO, MSGL_V ,"<vo_directx><INFO>killing screensaver\n" ); |
b69d78e8aee8
fix for disabling screensaver when in fullscreen mode while using the sub window.
vayne
parents:
19718
diff
changeset
|
626 return 0; |
b69d78e8aee8
fix for disabling screensaver when in fullscreen mode while using the sub window.
vayne
parents:
19718
diff
changeset
|
627 } |
b69d78e8aee8
fix for disabling screensaver when in fullscreen mode while using the sub window.
vayne
parents:
19718
diff
changeset
|
628 break; |
b69d78e8aee8
fix for disabling screensaver when in fullscreen mode while using the sub window.
vayne
parents:
19718
diff
changeset
|
629 } |
18914 | 630 case WM_PAINT: |
631 { | |
632 PAINTSTRUCT ps; | |
633 RECT rect; | |
634 HDC hdc = BeginPaint(hWnd, &ps); | |
635 HDC hMemDC = CreateCompatibleDC(hdc); | |
19570
e9ea7852e803
vo_colorkey change to avoid clashes with other black windows
vayne
parents:
19535
diff
changeset
|
636 HBRUSH blackbrush = (HBRUSH)GetStockObject(BLACK_BRUSH); |
18914 | 637 int width, height; |
638 GetClientRect(hWnd, &rect); | |
639 width = rect.right - rect.left; | |
640 height = rect.bottom - rect.top; | |
641 if(guiIntfStruct.Playing == 0) | |
642 { | |
643 int i; | |
644 window *desc = NULL; | |
645 | |
646 for (i=0; i<gui->skin->windowcount; i++) | |
647 if(gui->skin->windows[i]->type == wiSub) | |
648 desc = gui->skin->windows[i]; | |
649 | |
650 SelectObject(hMemDC, get_bitmap(hWnd)); | |
651 StretchBlt(hdc, 0, 0, width, height, hMemDC, 0, 0, desc->base->bitmap[0]->width, | |
652 desc->base->bitmap[0]->height, SRCCOPY); | |
19570
e9ea7852e803
vo_colorkey change to avoid clashes with other black windows
vayne
parents:
19535
diff
changeset
|
653 } else { |
e9ea7852e803
vo_colorkey change to avoid clashes with other black windows
vayne
parents:
19535
diff
changeset
|
654 FillRect(GetDC(hWnd), &rect, fullscreen?blackbrush:colorbrush); |
18914 | 655 } |
656 DeleteDC(hMemDC); | |
657 EndPaint(hWnd, &ps); | |
658 return 0; | |
659 } | |
660 } | |
661 return DefWindowProc(hWnd, message, wParam, lParam); | |
662 } | |
663 | |
664 /* Window Proc for the gui Window */ | |
665 static LRESULT CALLBACK EventProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) | |
666 { | |
667 gui_t *gui = (gui_t *) GetWindowLongPtr(hWnd, GWLP_USERDATA); | |
668 | |
669 /* Avoid processing when then window doesn't match gui mainwindow */ | |
670 if (gui && (gui->mainwindow != hWnd)) return FALSE; | |
671 | |
672 switch (message) | |
673 { | |
674 case WM_CLOSE: | |
675 handlemsg(hWnd, evExit); | |
676 return 0; | |
677 case WM_DESTROY: | |
678 PostQuitMessage(0); | |
679 return 0; | |
680 case WM_SYSTRAY: | |
681 { | |
682 switch(lParam) | |
683 { | |
684 POINT cursor; | |
685 case WM_RBUTTONDOWN: | |
686 { | |
687 GetCursorPos(&cursor); | |
688 SetForegroundWindow(hWnd); | |
689 TrackPopupMenu(gui->traymenu, 0, cursor.x, cursor.y, 0, hWnd, NULL); | |
690 break; | |
691 } | |
692 case WM_MBUTTONDBLCLK: | |
693 case WM_LBUTTONDBLCLK: | |
694 { | |
695 if(IsWindowVisible(hWnd)) ShowWindow(hWnd, SW_HIDE); | |
696 else { ShowWindow(hWnd, SW_SHOW); SetForegroundWindow(hWnd); } | |
697 break; | |
698 } | |
699 } | |
700 break; | |
701 } | |
702 case WM_KEYDOWN: | |
703 { | |
704 switch(wParam) | |
705 { | |
706 case VK_LEFT: | |
707 mplayer_put_key(KEY_LEFT); | |
708 break; | |
709 case VK_UP: | |
710 mplayer_put_key(KEY_UP); | |
711 break; | |
712 case VK_RIGHT: | |
713 mplayer_put_key(KEY_RIGHT); | |
714 break; | |
715 case VK_DOWN: | |
716 mplayer_put_key(KEY_DOWN); | |
717 break; | |
718 case VK_TAB: | |
719 mplayer_put_key(KEY_TAB); | |
720 break; | |
721 case VK_BACK: | |
722 mplayer_put_key(KEY_BS); | |
723 break; | |
724 case VK_DELETE: | |
725 mplayer_put_key(KEY_DELETE); | |
726 break; | |
727 case VK_INSERT: | |
728 mplayer_put_key(KEY_INSERT); | |
729 break; | |
730 case VK_HOME: | |
731 mplayer_put_key(KEY_HOME); | |
732 break; | |
733 case VK_END: | |
734 mplayer_put_key(KEY_END); | |
735 break; | |
736 case VK_PRIOR: | |
737 mplayer_put_key(KEY_PAGE_UP); | |
738 break; | |
739 case VK_NEXT: | |
740 mplayer_put_key(KEY_PAGE_DOWN); | |
741 break; | |
742 case VK_ESCAPE: | |
743 mplayer_put_key(KEY_ESC); | |
744 break; | |
745 } | |
746 break; | |
747 } | |
748 case WM_CHAR: | |
749 mplayer_put_key(wParam); | |
750 break; | |
751 case WM_COPYDATA: | |
752 { | |
753 if(lParam) | |
754 { | |
755 PCOPYDATASTRUCT cdData; | |
756 cdData = (PCOPYDATASTRUCT) lParam; | |
757 if(!parse_filename(cdData->lpData, playtree, mconfig, 1)) | |
758 gui->playlist->add_track(gui->playlist, cdData->lpData, NULL, NULL, 0); | |
759 gui->startplay(gui); | |
760 } | |
761 break; | |
762 } | |
763 case WM_DROPFILES: | |
764 { | |
765 if(!lParam) | |
766 { | |
767 char file[MAX_PATH]; | |
768 int filecount = DragQueryFile((HDROP) wParam, -1, file, MAX_PATH); | |
769 int i; | |
770 for(i=0; i<filecount; i++) | |
771 { | |
772 DragQueryFile((HDROP) wParam, i, file, MAX_PATH); | |
773 if(!parse_filename(file, playtree, mconfig, 1)) | |
774 gui->playlist->add_track(gui->playlist, file, NULL, NULL, 0); | |
775 } | |
776 DragFinish((HDROP) wParam); | |
777 handlemsg(hWnd, evDropFile); | |
778 } | |
779 else | |
780 { | |
781 gui->playlist->clear_playlist(gui->playlist); | |
782 gui->playlist->add_track(gui->playlist, (const char *) wParam, NULL, NULL, 0); | |
783 handlemsg(hWnd, evDropFile); | |
784 } | |
785 SetForegroundWindow(gui->mainwindow); | |
786 return 0; | |
787 } | |
788 case WM_LBUTTONDOWN: | |
789 { | |
790 SetCapture(hWnd); | |
791 gui->mousex = GET_X_LPARAM(lParam); | |
792 gui->mousey = GET_Y_LPARAM(lParam); | |
793 /* inside a widget */ | |
794 gui->activewidget = clickedinsidewidget(gui, get_windowtype(hWnd), gui->mousex, gui->mousey); | |
795 if(gui->activewidget) | |
796 { | |
797 gui->activewidget->pressed = 1; | |
798 gui->mousewx = gui->mousex - gui->activewidget->x; | |
799 gui->mousewy = gui->mousey - gui->activewidget->y; | |
800 renderwidget(gui->skin, get_drawground(hWnd), gui->activewidget, 0); | |
801 RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE); | |
802 handlemsg(hWnd, gui->activewidget->msg); | |
803 } | |
804 break; | |
805 } | |
806 case WM_CAPTURECHANGED: | |
807 { | |
808 if(gui->activewidget) | |
809 { | |
810 gui->activewidget->pressed = 0; | |
811 renderwidget(gui->skin, get_drawground(hWnd), gui->activewidget, 1); | |
812 RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE); | |
813 gui->activewidget = NULL; | |
814 } | |
815 break; | |
816 } | |
817 case WM_LBUTTONUP: | |
818 { | |
819 ReleaseCapture(); | |
820 if(gui->activewidget) | |
821 { | |
822 gui->activewidget->pressed = 0; | |
823 renderwidget(gui->skin, get_drawground(hWnd), gui->activewidget, 1); | |
824 RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE); | |
825 gui->activewidget = NULL; | |
826 } | |
827 break; | |
828 } | |
829 case WM_RBUTTONDOWN: | |
830 { | |
831 POINT point; | |
832 char device[MAX_PATH]; | |
833 char searchpath[MAX_PATH]; | |
834 char searchpath2[MAX_PATH]; | |
835 #ifdef HAVE_LIBCDIO | |
836 char searchpath3[MAX_PATH]; | |
837 #endif | |
838 int len, pos = 0, cdromdrive = 0; | |
20235
c7f580aa091d
Set SetErrorMode to make sure no dialog box will pop up when no disk in CD/DVD drive.
reimar
parents:
20211
diff
changeset
|
839 UINT errmode; |
18914 | 840 point.x = GET_X_LPARAM(lParam); |
841 point.y = GET_Y_LPARAM(lParam); | |
842 ClientToScreen(hWnd, &point); | |
20235
c7f580aa091d
Set SetErrorMode to make sure no dialog box will pop up when no disk in CD/DVD drive.
reimar
parents:
20211
diff
changeset
|
843 errmode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); |
20245
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
844 while (GetMenuItemCount(gui->diskmenu) > 0) |
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
845 DeleteMenu(gui->diskmenu, 0, MF_BYPOSITION); |
18914 | 846 len = GetLogicalDriveStrings(MAX_PATH, device); |
847 while(pos < len) | |
848 { | |
849 if(GetDriveType(device + pos) == DRIVE_CDROM) | |
850 { | |
20245
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
851 char volname[MAX_PATH]; |
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
852 char menuitem[MAX_PATH]; |
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
853 int flags = MF_STRING; |
18914 | 854 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] checking %s for CD/VCD/SVCD/DVDs\n", device + pos); |
855 sprintf(searchpath, "%sVIDEO_TS", device + pos); | |
856 sprintf(searchpath2, "%sMpegav", device + pos); | |
857 #ifdef HAVE_LIBCDIO | |
858 sprintf(searchpath3, "%sTrack01.cda", device + pos); | |
859 #endif | |
860 if(GetFileAttributes(searchpath) != INVALID_FILE_ATTRIBUTES) | |
20245
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
861 flags |= MF_ENABLED; |
18914 | 862 else if(GetFileAttributes(searchpath2) != INVALID_FILE_ATTRIBUTES) |
20245
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
863 flags |= MF_ENABLED; |
18914 | 864 #ifdef HAVE_LIBCDIO |
865 else if(GetFileAttributes(searchpath3) != INVALID_FILE_ATTRIBUTES) | |
20245
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
866 flags |= MF_ENABLED; |
18914 | 867 #endif |
20245
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
868 else |
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
869 flags |= MF_GRAYED; |
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
870 volname[0] = 0; |
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
871 strcpy(menuitem, device + pos); |
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
872 menuitem[strlen(menuitem) - 1]=0; |
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
873 GetVolumeInformation(device + pos, volname, MAX_PATH, NULL, NULL, NULL, NULL, 0); |
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
874 if (strlen(volname)) |
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
875 { |
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
876 capitalize(volname); |
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
877 strcat(menuitem, " - "); |
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
878 strcat(menuitem, volname); |
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
879 } |
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
880 AppendMenu(gui->diskmenu, flags, IDPLAYDISK + cdromdrive, menuitem); |
18914 | 881 cdromdrive++; |
882 } | |
883 pos += strlen(device + pos) + 1; | |
884 } | |
20235
c7f580aa091d
Set SetErrorMode to make sure no dialog box will pop up when no disk in CD/DVD drive.
reimar
parents:
20211
diff
changeset
|
885 SetErrorMode(errmode); |
18914 | 886 TrackPopupMenu(gui->menu, 0, point.x, point.y, 0, hWnd, NULL); |
887 return 0; | |
888 } | |
889 case WM_MOUSEMOVE: | |
890 { | |
891 if(wParam & MK_LBUTTON) | |
892 { | |
893 POINT point; | |
894 RECT rect; | |
895 if(gui->activewidget) | |
896 { | |
897 widget *item = gui->activewidget; | |
898 | |
899 if(item->type == tyHpotmeter) | |
900 { | |
901 item->x = GET_X_LPARAM(lParam) - gui->mousewx; | |
902 item->value = (float)((float)((item->x - item->wx) * 100.0f) / (float)(item->wwidth - item->width)); | |
903 } | |
904 if(item->type == tyPotmeter) | |
905 { | |
906 gui->mousewx = GET_X_LPARAM(lParam) - gui->activewidget->x; | |
907 item->value = (float) (gui->mousewx * 100.0f) / (float) item->wwidth; | |
908 } | |
909 | |
910 if((item->type == tyPotmeter) || (item->type == tyHpotmeter) || (item->type == tyVpotmeter)) | |
911 { | |
912 /* Bound checks */ | |
913 if(item->value > 100.0f) | |
914 item->value = 100.0f; | |
915 else if(item->value < 0.0f) | |
916 item->value = 0.0f; | |
917 | |
918 if(item->msg == evSetVolume) | |
919 guiIntfStruct.Volume = (float) item->value; | |
920 else if(item->msg == evSetMoviePosition) | |
921 guiIntfStruct.Position = (float) item->value; | |
922 else if(item->msg == evSetBalance) | |
923 { | |
924 /* make the range for 50% a bit bigger, because the sliders for balance usually suck */ | |
925 if((item->value - 50.0f < 1.5f) && (item->value - 50.0f > -1.5f)) | |
926 item->value = 50.0f; | |
927 guiIntfStruct.Balance = (float) item->value; | |
928 } | |
929 updatedisplay(gui, hWnd); | |
930 handlemsg(hWnd, item->msg); | |
931 } | |
932 break; | |
933 } | |
934 point.x = GET_X_LPARAM(lParam); | |
935 point.y = GET_Y_LPARAM(lParam); | |
936 ClientToScreen(hWnd, &point); | |
937 GetWindowRect(hWnd, &rect); | |
938 MoveWindow(hWnd, point.x - gui->mousex, point.y - gui->mousey, | |
939 rect.right-rect.left,rect.bottom-rect.top,TRUE); | |
940 break; | |
941 } | |
942 break; | |
943 } | |
944 case WM_COMMAND: | |
945 { | |
946 switch(LOWORD(wParam)) | |
947 { | |
948 case IDEXIT: | |
949 PostQuitMessage(0); | |
950 handlemsg(hWnd, evExit); | |
951 break; | |
952 case IDFILE_OPEN: | |
953 handlemsg(hWnd, evLoadPlay); | |
954 break; | |
955 case IDDIR_OPEN: | |
956 { | |
957 static char path[MAX_PATH]; | |
958 BROWSEINFO bi; | |
19718 | 959 LPITEMIDLIST pidl; |
18914 | 960 memset(&bi, 0, sizeof(BROWSEINFO)); |
961 bi.lpszTitle = "Choose a Directory..."; | |
19718 | 962 pidl = SHBrowseForFolder(&bi); |
18914 | 963 if (SHGetPathFromIDList(pidl, path)) |
964 { | |
965 gui->playlist->clear_playlist(gui->playlist); | |
966 adddirtoplaylist(gui->playlist, path, TRUE); | |
967 gui->startplay(gui); | |
968 } | |
969 break; | |
970 } | |
971 case ID_SKINBROWSER: | |
972 handlemsg(hWnd, evSkinBrowser); | |
973 break; | |
974 case IDURL_OPEN: | |
975 display_openurlwindow(gui, 0); | |
976 break; | |
20211
26867dede11c
as per request, fullscreen and mute options have been added to the context menus.
vayne
parents:
20132
diff
changeset
|
977 case ID_MUTE: |
26867dede11c
as per request, fullscreen and mute options have been added to the context menus.
vayne
parents:
20132
diff
changeset
|
978 mp_input_queue_cmd(mp_input_parse_cmd("mute")); |
26867dede11c
as per request, fullscreen and mute options have been added to the context menus.
vayne
parents:
20132
diff
changeset
|
979 break; |
18914 | 980 case IDSUBTITLE_OPEN: |
981 display_opensubtitlewindow(gui); | |
982 break; | |
983 case ID_PTRACK: | |
984 handlemsg(hWnd, evPrev); | |
985 break; | |
986 case ID_SEEKB: | |
987 handlemsg(hWnd, evBackward10sec); | |
988 break; | |
989 case ID_PLAY: | |
990 handlemsg(hWnd, evPlaySwitchToPause); | |
991 break; | |
992 case ID_STOP: | |
993 handlemsg(hWnd, evStop); | |
994 break; | |
995 case ID_SEEKF: | |
996 handlemsg(hWnd, evForward10sec); | |
997 break; | |
998 case ID_NTRACK: | |
999 handlemsg(hWnd, evNext); | |
1000 break; | |
1001 case ID_SHOWHIDE: | |
1002 { | |
1003 if(IsWindowVisible(hWnd)) ShowWindow(hWnd, SW_HIDE); | |
1004 else ShowWindow(hWnd, SW_SHOW); | |
1005 break; | |
1006 } | |
1007 case ID_PLAYLIST: | |
1008 handlemsg(hWnd, evPlayList); | |
1009 break; | |
1010 case ID_PREFS: | |
1011 handlemsg(hWnd, evPreferences); | |
1012 break; | |
1013 case ID_CONSOLE: | |
1014 console_toggle(); | |
1015 break; | |
1016 case ID_ONLINEHELP: | |
1017 ShellExecute(NULL, "open", ONLINE_HELP_URL, NULL, NULL, SW_SHOWNORMAL); | |
1018 break; | |
1019 } | |
1020 if((IDPLAYDISK <= LOWORD(wParam)) && (LOWORD(wParam) < (IDPLAYDISK + 100))) | |
1021 { | |
1022 char device[MAX_PATH]; | |
1023 char searchpath[MAX_PATH]; | |
1024 char filename[MAX_PATH]; | |
1025 int len, pos = 0, cdromdrive = 0; | |
1026 len = GetLogicalDriveStrings(MAX_PATH, device); | |
1027 while(pos < len) | |
1028 { | |
1029 if(GetDriveType(device + pos)==DRIVE_CDROM) | |
1030 { | |
1031 if(LOWORD(wParam) - IDPLAYDISK == cdromdrive) | |
1032 { | |
1033 #ifdef USE_DVDREAD | |
1034 sprintf(searchpath, "%sVIDEO_TS", device + pos); | |
1035 if(GetFileAttributes(searchpath) != INVALID_FILE_ATTRIBUTES) | |
1036 { | |
1037 if (dvd_device) free(dvd_device); | |
1038 dvd_device = strdup(device + pos); | |
1039 dvd_title = dvd_chapter = dvd_angle = 1; | |
1040 handlemsg(hWnd, evPlayDVD); | |
1041 } | |
1042 #endif | |
1043 #ifdef HAVE_LIBCDIO | |
1044 sprintf(searchpath, "%sTrack01.cda", device + pos); | |
1045 if(GetFileAttributes(searchpath) != INVALID_FILE_ATTRIBUTES) | |
1046 { | |
1047 if (cdrom_device) free(cdrom_device); | |
1048 cdrom_device = strdup(device + pos); | |
1049 /* mplayer doesn't seem to like the trailing \ after the device name */ | |
1050 cdrom_device[2]=0; | |
1051 handlemsg(hWnd, evPlayCD); | |
1052 } | |
1053 #endif | |
1054 else | |
1055 { | |
1056 HANDLE searchhndl; | |
1057 WIN32_FIND_DATA finddata; | |
1058 sprintf(searchpath, "%smpegav\\*.dat", device + pos); | |
1059 if((searchhndl=FindFirstFile(searchpath, &finddata)) != INVALID_HANDLE_VALUE) | |
1060 { | |
1061 mp_msg(MSGT_GPLAYER,MSGL_V, "Opening VCD/SVCD\n"); | |
1062 gui->playlist->clear_playlist(gui->playlist); | |
1063 do | |
1064 { | |
1065 sprintf(filename, "%smpegav\\%s", device + pos, finddata.cFileName); | |
1066 gui->playlist->add_track(gui->playlist, filename, NULL, NULL, 0); | |
1067 } | |
1068 while(FindNextFile(searchhndl, &finddata)); | |
1069 FindClose(searchhndl); | |
1070 } | |
1071 gui->startplay(gui); | |
1072 } | |
1073 } | |
1074 cdromdrive++; | |
1075 } | |
1076 pos += strlen(device + pos) + 1; | |
1077 } | |
1078 } | |
1079 break; | |
1080 } | |
1081 case WM_PAINT: | |
1082 { | |
1083 PAINTSTRUCT ps; | |
1084 RECT rd; | |
1085 HDC hdc = BeginPaint(hWnd, &ps); | |
1086 HDC hMemDC = CreateCompatibleDC(hdc); | |
1087 int width, height; | |
1088 GetClientRect(hWnd, &rd); | |
1089 width = rd.right - rd.left; | |
1090 height = rd.bottom - rd.top; | |
1091 SelectObject(hMemDC, get_bitmap(hWnd)); | |
1092 BitBlt(hdc, 0, 0, width, height, hMemDC, 0, 0, SRCCOPY); | |
1093 DeleteDC(hMemDC); | |
1094 EndPaint(hWnd, &ps); | |
1095 return 0; | |
1096 } | |
1097 return 0; | |
1098 } | |
1099 return DefWindowProc(hWnd, message, wParam, lParam); | |
1100 } | |
1101 | |
1102 inline void startplay(gui_t *gui) | |
1103 { | |
1104 handlemsg(gui->mainwindow, evDropFile); | |
1105 } | |
1106 | |
1107 /* returns the bits per pixel of the desktop */ | |
1108 /* the format is always in BGR byte order */ | |
1109 static int GetDesktopBitsPerPixel(void) | |
1110 { | |
1111 HWND desktop=GetDesktopWindow(); | |
1112 HDC dc=GetDC(desktop); | |
1113 int bpp=GetDeviceCaps(dc, BITSPIXEL); | |
1114 ReleaseDC(desktop, dc); | |
1115 return bpp; | |
1116 } | |
1117 | |
1118 /* unloads a skin and destroys its windows */ | |
1119 extern int destroy_window(gui_t *gui) | |
1120 { | |
1121 RECT rd; | |
1122 unsigned int i; | |
1123 | |
1124 /* Save position: MSDN says don't pass workspace coordinates | |
1125 * to CreateWindow() or SetWindowPos(), as both of which expect | |
1126 * screen coordinates; resulting in the window appearing in the | |
1127 * wrong location. | |
1128 * -Erik | |
1129 */ | |
1130 | |
1131 /* main window position */ | |
1132 if(IsIconic(gui->mainwindow)) | |
1133 ShowWindow(gui->mainwindow, SW_SHOWNORMAL); | |
1134 GetWindowRect(gui->mainwindow, &rd); | |
1135 gui_main_pos_x = rd.left; | |
1136 gui_main_pos_y = rd.top; | |
1137 | |
1138 /* sub window position */ | |
1139 if(IsIconic(gui->subwindow)) | |
1140 ShowWindow(gui->subwindow, SW_SHOWNORMAL); | |
1141 GetWindowRect(gui->subwindow, &rd); | |
1142 gui_sub_pos_x = rd.left; | |
1143 gui_sub_pos_y = rd.top; | |
1144 | |
1145 for(i=0; i<gui->window_priv_count; i++) | |
1146 { | |
1147 if(gui->window_priv[i]->bitmap) | |
1148 DeleteObject(gui->window_priv[i]->bitmap); | |
1149 free(gui->window_priv[i]); | |
1150 } | |
1151 free(gui->window_priv); | |
1152 gui->window_priv = NULL; | |
1153 gui->window_priv_count = 0; | |
1154 | |
1155 /* destroy the main window */ | |
1156 if(gui->mainwindow) | |
1157 DestroyWindow(gui->mainwindow); | |
1158 gui->mainwindow = NULL; | |
1159 | |
1160 /* destroy the sub window */ | |
1161 if(gui->subwindow) | |
1162 DestroyWindow(gui->subwindow); | |
1163 gui->subwindow = NULL; | |
1164 | |
1165 UnregisterClass(gui->classname, 0); | |
1166 DestroyIcon(gui->icon); | |
1167 | |
1168 gui->skin->freeskin(gui->skin); | |
1169 gui->skin = NULL; | |
1170 return 0; | |
1171 } | |
1172 | |
1173 static void create_menu(gui_t *gui) | |
1174 { | |
1175 gui->diskmenu = CreatePopupMenu(); | |
1176 gui->menu=CreatePopupMenu(); | |
1177 gui->trayplaymenu = CreatePopupMenu(); | |
1178 AppendMenu(gui->menu, MF_STRING | MF_POPUP, (UINT) gui->trayplaymenu, "Open..."); | |
1179 AppendMenu(gui->trayplaymenu, MF_STRING, IDFILE_OPEN, "File..."); | |
1180 AppendMenu(gui->trayplaymenu, MF_STRING, IDURL_OPEN, "Url..."); | |
1181 AppendMenu(gui->trayplaymenu, MF_STRING, IDDIR_OPEN, "Directory..."); | |
1182 AppendMenu(gui->menu, MF_SEPARATOR, 0, 0); | |
1183 AppendMenu(gui->menu, MF_STRING | MF_POPUP, (UINT) gui->diskmenu, "Play &CD/DVD/VCD/SVCD"); | |
1184 AppendMenu(gui->menu, MF_SEPARATOR, 0, 0); | |
1185 AppendMenu(gui->menu, MF_STRING, IDSUBTITLE_OPEN, "Open Subtitle"); | |
1186 AppendMenu(gui->menu, MF_STRING, ID_SKINBROWSER, "Skin Browser"); | |
1187 AppendMenu(gui->menu, MF_SEPARATOR, 0, 0); | |
1188 AppendMenu(gui->menu, MF_STRING, ID_PREFS, "Preferences"); | |
1189 AppendMenu(gui->menu, MF_STRING, ID_CONSOLE, "Debug Console"); | |
1190 AppendMenu(gui->menu, MF_STRING, ID_ONLINEHELP, "Online Help"); | |
1191 AppendMenu(gui->menu, MF_SEPARATOR, 0, 0); | |
1192 AppendMenu(gui->menu, MF_STRING, IDEXIT, "&Exit"); | |
1193 } | |
1194 | |
1195 static void create_traymenu(gui_t *gui) | |
1196 { | |
1197 gui->traymenu = CreatePopupMenu(); | |
1198 gui->trayplaybackmenu = CreatePopupMenu(); | |
1199 AppendMenu(gui->traymenu, MF_STRING | MF_POPUP, (UINT) gui->trayplaymenu, "Open..."); | |
1200 AppendMenu(gui->traymenu, MF_SEPARATOR, 0, 0); | |
1201 AppendMenu(gui->traymenu, MF_STRING | MF_POPUP, (UINT) gui->trayplaybackmenu, "Playback"); | |
1202 AppendMenu(gui->trayplaybackmenu, MF_STRING, ID_SEEKB, "Seek Backwards"); | |
1203 AppendMenu(gui->trayplaybackmenu, MF_STRING, ID_PTRACK, "Previous Track"); | |
1204 AppendMenu(gui->trayplaybackmenu, MF_STRING, ID_PLAY, "Play/Pause"); | |
1205 AppendMenu(gui->trayplaybackmenu, MF_STRING, ID_STOP, "Stop"); | |
1206 AppendMenu(gui->trayplaybackmenu, MF_STRING, ID_NTRACK, "Next Track"); | |
1207 AppendMenu(gui->trayplaybackmenu, MF_STRING, ID_SEEKF, "Seek Forwards"); | |
1208 AppendMenu(gui->traymenu, MF_SEPARATOR, 0, 0); | |
20211
26867dede11c
as per request, fullscreen and mute options have been added to the context menus.
vayne
parents:
20132
diff
changeset
|
1209 AppendMenu(gui->traymenu, MF_STRING, ID_MUTE, "Toggle Mute"); |
26867dede11c
as per request, fullscreen and mute options have been added to the context menus.
vayne
parents:
20132
diff
changeset
|
1210 AppendMenu(gui->traymenu, MF_SEPARATOR, 0, 0); |
18914 | 1211 AppendMenu(gui->traymenu, MF_STRING, IDSUBTITLE_OPEN, "Open Subtitle"); |
1212 AppendMenu(gui->traymenu, MF_STRING, ID_PLAYLIST, "Playlist"); | |
1213 AppendMenu(gui->traymenu, MF_SEPARATOR, 0, 0); | |
1214 AppendMenu(gui->traymenu, MF_STRING, ID_SHOWHIDE, "Show/Hide"); | |
1215 AppendMenu(gui->traymenu, MF_SEPARATOR, 0, 0); | |
1216 AppendMenu(gui->traymenu, MF_STRING, ID_PREFS, "Preferences"); | |
1217 AppendMenu(gui->traymenu, MF_STRING, ID_CONSOLE, "Debug Console"); | |
1218 AppendMenu(gui->traymenu, MF_STRING, ID_ONLINEHELP, "Online Help"); | |
1219 AppendMenu(gui->traymenu, MF_SEPARATOR, 0, 0); | |
1220 AppendMenu(gui->traymenu, MF_STRING, IDEXIT, "&Exit"); | |
1221 } | |
1222 | |
1223 static void create_submenu(gui_t *gui) | |
1224 { | |
1225 gui->submenu = CreatePopupMenu(); | |
1226 gui->dvdmenu = CreatePopupMenu(); | |
1227 gui->aspectmenu = CreatePopupMenu(); | |
1228 gui->subtitlemenu = CreatePopupMenu(); | |
1229 AppendMenu(gui->submenu, MF_STRING | MF_POPUP, (UINT) gui->trayplaymenu, "Open..."); | |
1230 AppendMenu(gui->submenu, MF_SEPARATOR, 0, 0); | |
1231 AppendMenu(gui->submenu, MF_STRING, ID_SEEKB, "Seek Backwards"); | |
1232 AppendMenu(gui->submenu, MF_STRING, ID_PTRACK, "Previous Track"); | |
1233 AppendMenu(gui->submenu, MF_STRING, ID_PLAY, "Play/Pause"); | |
1234 AppendMenu(gui->submenu, MF_STRING, ID_STOP, "Stop"); | |
1235 AppendMenu(gui->submenu, MF_STRING, ID_NTRACK, "Next Track"); | |
1236 AppendMenu(gui->submenu, MF_STRING, ID_SEEKF, "Seek Forwards"); | |
1237 AppendMenu(gui->submenu, MF_SEPARATOR, 0, 0); | |
20211
26867dede11c
as per request, fullscreen and mute options have been added to the context menus.
vayne
parents:
20132
diff
changeset
|
1238 AppendMenu(gui->submenu, MF_STRING, ID_FULLSCREEN, "Toggle Fullscreen"); |
26867dede11c
as per request, fullscreen and mute options have been added to the context menus.
vayne
parents:
20132
diff
changeset
|
1239 AppendMenu(gui->submenu, MF_STRING, ID_MUTE, "Toggle Mute"); |
26867dede11c
as per request, fullscreen and mute options have been added to the context menus.
vayne
parents:
20132
diff
changeset
|
1240 AppendMenu(gui->submenu, MF_SEPARATOR, 0, 0); |
18914 | 1241 AppendMenu(gui->submenu, MF_STRING | MF_POPUP, (UINT) gui->aspectmenu, "Aspect Ratio"); |
1242 AppendMenu(gui->submenu, MF_STRING | MF_POPUP, (UINT) gui->subtitlemenu, "Subtitle Options"); | |
1243 AppendMenu(gui->submenu, MF_STRING | MF_POPUP, (UINT) gui->dvdmenu, "DVD Options"); | |
1244 #ifdef USE_DVDREAD | |
1245 AppendMenu(gui->dvdmenu, MF_STRING | MF_GRAYED, ID_CHAPTERSEL, "Select Title/Chapter..."); | |
1246 #endif | |
1247 AppendMenu(gui->subtitlemenu, MF_STRING, IDSUB_TOGGLE, "Subtitle Visibility On/Off"); | |
1248 AppendMenu(gui->subtitlemenu, MF_STRING, IDSUB_CYCLE, "Cycle Subtitle Languages"); | |
1249 AppendMenu(gui->aspectmenu, MF_STRING, ID_ASPECT1, "Set 16:9"); | |
1250 AppendMenu(gui->aspectmenu, MF_STRING, ID_ASPECT2, "Set 4:3"); | |
1251 AppendMenu(gui->aspectmenu, MF_STRING, ID_ASPECT3, "Set 2.35"); | |
1252 AppendMenu(gui->aspectmenu, MF_SEPARATOR, 0, 0); | |
1253 AppendMenu(gui->aspectmenu, MF_STRING, ID_ASPECT4, "Original Aspect"); | |
1254 AppendMenu(gui->submenu, MF_SEPARATOR, 0, 0); | |
1255 AppendMenu(gui->submenu, MF_STRING, IDEXIT, "&Exit"); | |
1256 } | |
1257 | |
1258 static void maketransparent(HWND hwnd, COLORREF crTransparent) | |
1259 { | |
1260 HDC mdc = GetDC(hwnd); | |
1261 RECT rd; | |
1262 HRGN crRgnres, crRgn, crRgnTmp; | |
1263 int iX = 0, iY = 0, iLeftX = 0; | |
1264 int width, height; | |
1265 GetWindowRect(hwnd, &rd); | |
1266 width = rd.right - rd.left; | |
1267 height = rd.bottom - rd.top; | |
1268 | |
1269 /* create an empty region */ | |
1270 crRgn = CreateRectRgn(0, 0, 0, 0); | |
1271 | |
1272 /* Create a region from a bitmap with transparency colour of Purple */ | |
1273 for (iY = -1; iY < height; iY++) | |
1274 { | |
1275 do | |
1276 { | |
1277 /* skip over transparent pixels at start of lines */ | |
1278 while (iX <= width && GetPixel(mdc,iX, iY) == crTransparent) iX++; | |
1279 | |
1280 /* remember this pixel */ | |
1281 iLeftX = iX; | |
1282 | |
1283 /* now find first non transparent pixel */ | |
1284 while (iX <= width && GetPixel(mdc,iX, iY) != crTransparent) ++iX; | |
1285 | |
1286 /* create a temp region on this info */ | |
1287 crRgnTmp = CreateRectRgn(iLeftX, iY, iX, iY+1); | |
1288 | |
1289 /* combine into main region */ | |
1290 crRgnres = crRgn; | |
1291 CombineRgn(crRgnres, crRgn, crRgnTmp, RGN_OR); | |
1292 crRgn = crRgnres; | |
1293 | |
1294 /* delete the temp region for next pass (otherwise you'll get an ASSERT) */ | |
1295 DeleteObject(crRgnTmp); | |
1296 } while (iX < width); | |
1297 iX = 0; | |
1298 } | |
1299 SetWindowRgn(hwnd, crRgn, TRUE); | |
1300 DeleteObject(crRgn); | |
1301 ReleaseDC(hwnd,mdc); | |
1302 } | |
1303 | |
1304 static int window_render(gui_t *gui, HWND hWnd, HDC hdc, window_priv_t *priv, window *desc, BITMAPINFO binfo) | |
1305 { | |
1306 int i; | |
1307 SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD) gui); | |
1308 (gui->window_priv_count)++; | |
1309 gui->window_priv = realloc(gui->window_priv, sizeof(window_priv_t *) * gui->window_priv_count); | |
1310 priv = gui->window_priv[gui->window_priv_count - 1] = calloc(1, sizeof(window_priv_t)); | |
1311 priv->hwnd = hWnd; | |
1312 priv->type = desc->type; | |
1313 priv->background = desc->base->bitmap[0]; | |
1314 memcpy(&priv->img, desc->base->bitmap[0], sizeof(image)); | |
1315 hdc = GetDC(hWnd); | |
1316 binfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); | |
1317 binfo.bmiHeader.biWidth = priv->img.width; | |
1318 binfo.bmiHeader.biHeight = -priv->img.height; | |
1319 binfo.bmiHeader.biPlanes = 1; | |
1320 binfo.bmiHeader.biSizeImage = priv->img.width * priv->img.height * (gui->screenbpp / 8); | |
1321 binfo.bmiHeader.biXPelsPerMeter = 0; | |
1322 binfo.bmiHeader.biYPelsPerMeter = 0; | |
1323 binfo.bmiHeader.biClrUsed = 0; | |
1324 binfo.bmiHeader.biClrImportant = 0; | |
1325 binfo.bmiHeader.biBitCount = gui->screenbpp; | |
1326 binfo.bmiHeader.biCompression = BI_RGB; | |
1327 priv->bitmap = CreateDIBSection(hdc, &binfo, DIB_RGB_COLORS, (void **) &priv->img.data, NULL, 0); | |
1328 if(!priv->bitmap) | |
1329 { | |
1330 mp_msg(MSGT_GPLAYER, MSGL_FATAL, "[GUI] unable to create bitmap for skinned window\n"); | |
1331 return 0; | |
1332 } | |
1333 memcpy(priv->img.data, desc->base->bitmap[0]->data, binfo.bmiHeader.biSizeImage); | |
1334 ReleaseDC(hWnd,hdc); | |
1335 | |
1336 for (i=0; i<gui->skin->widgetcount; i++) | |
1337 if(gui->skin->widgets[i]->window == desc->type) | |
1338 renderwidget(gui->skin, &priv->img, gui->skin->widgets[i], 1); | |
1339 | |
1340 return 0; | |
1341 } | |
1342 | |
1343 /* creates the sub (AKA video) window,*/ | |
1344 extern int create_subwindow(gui_t *gui, char *skindir) | |
1345 { | |
1346 HINSTANCE instance = GetModuleHandle(NULL); | |
1347 WNDCLASS wc; | |
1348 RECT rect; | |
1349 HWND hWnd; | |
1350 DWORD style = 0; | |
1351 HDC hdc = NULL; | |
1352 BITMAPINFO binfo; | |
1353 window_priv_t *priv = NULL; | |
1354 window *desc = NULL; | |
1355 int i, x = -1, y = -1; | |
19570
e9ea7852e803
vo_colorkey change to avoid clashes with other black windows
vayne
parents:
19535
diff
changeset
|
1356 vo_colorkey = 0xff00ff; |
18914 | 1357 |
1358 for (i=0; i<gui->skin->windowcount; i++) | |
1359 if(gui->skin->windows[i]->type == wiSub) | |
1360 desc = gui->skin->windows[i]; | |
1361 | |
1362 if(!desc) | |
1363 { | |
1364 mp_msg(MSGT_GPLAYER, MSGL_FATAL, "[GUI] Invalid skin description\n"); | |
1365 return 1; | |
1366 } | |
1367 | |
19570
e9ea7852e803
vo_colorkey change to avoid clashes with other black windows
vayne
parents:
19535
diff
changeset
|
1368 windowcolor = vo_colorkey; |
e9ea7852e803
vo_colorkey change to avoid clashes with other black windows
vayne
parents:
19535
diff
changeset
|
1369 colorbrush = CreateSolidBrush(windowcolor); |
18914 | 1370 wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; |
1371 wc.lpfnWndProc = SubProc; | |
1372 wc.cbClsExtra = 0; | |
1373 wc.cbWndExtra = 0; | |
1374 wc.hInstance = instance; | |
1375 wc.hCursor = LoadCursor(NULL, IDC_ARROW); | |
1376 wc.hIcon = gui->icon; | |
19570
e9ea7852e803
vo_colorkey change to avoid clashes with other black windows
vayne
parents:
19535
diff
changeset
|
1377 wc.hbrBackground = NULL; //WM_PAINT will handle background color switching; |
18914 | 1378 wc.lpszClassName = "MPlayer Sub for Windows"; |
1379 wc.lpszMenuName = NULL; | |
1380 RegisterClass(&wc); | |
1381 | |
1382 /* create the sub window menu */ | |
1383 create_submenu(gui); | |
1384 | |
1385 rect.top = rect.left = 100; | |
1386 rect.bottom = rect.top+desc->base->bitmap[0]->height; | |
1387 rect.right = rect.left+desc->base->bitmap[0]->width; | |
1388 | |
1389 /* our window aspect */ | |
1390 sub_aspect = (float)(rect.right-rect.left)/(rect.bottom-rect.top); | |
1391 | |
19571
a894b3a3d28c
bug fix for starting gmplayer with -fs when using the sub window
vayne
parents:
19570
diff
changeset
|
1392 style = fullscreen?WS_VISIBLE | WS_POPUP:WS_OVERLAPPEDWINDOW | WS_SYSMENU | WS_MINIMIZEBOX; |
18914 | 1393 AdjustWindowRect(&rect, style, 0); |
1394 | |
1395 if (gui_sub_pos_x >= 0) | |
1396 x = gui_sub_pos_x; | |
1397 if (gui_sub_pos_y >= 0) | |
1398 y = gui_sub_pos_y; | |
1399 | |
1400 /* out of bounds check */ | |
1401 if (x <= -1 || (x+(rect.right-rect.left) > GetSystemMetrics(SM_CXSCREEN))) | |
1402 x = CW_USEDEFAULT; | |
1403 if (y <= -1 || (y+(rect.bottom-rect.top) > GetSystemMetrics(SM_CYSCREEN))) | |
1404 y = x; | |
1405 | |
1406 hWnd = CreateWindowEx(0, "MPlayer Sub for Windows", "MPlayer for Windows", style, | |
1407 x, y, rect.right-rect.left, rect.bottom-rect.top, | |
1408 gui->subwindow, NULL, instance, NULL); | |
1409 | |
1410 /* load all the window images */ | |
1411 window_render(gui, hWnd, hdc, priv, desc, binfo); | |
1412 | |
1413 /* enable drag and drop support */ | |
1414 DragAcceptFiles(hWnd, TRUE); | |
1415 | |
1416 gui->subwindow = hWnd; | |
1417 if(sub_window) | |
1418 WinID = gui->subwindow; | |
1419 ShowWindow(gui->subwindow, SW_SHOW); | |
1420 UpdateWindow(gui->subwindow); | |
1421 return 0; | |
1422 } | |
1423 | |
1424 /* loads/updates a skin and creates windows for it */ | |
1425 extern int create_window(gui_t *gui, char *skindir) | |
1426 { | |
1427 HINSTANCE instance = GetModuleHandle(NULL); | |
1428 WNDCLASS wc; | |
1429 RECT rect; | |
1430 DWORD style = 0; | |
1431 HWND hwnd; | |
1432 HDC hdc = NULL; | |
1433 BITMAPINFO binfo; | |
1434 window_priv_t *priv = NULL; | |
1435 window *desc = NULL; | |
1436 char dir[MAX_PATH]; | |
1437 unsigned int i; | |
19718 | 1438 int x = -1, y = -1; |
18914 | 1439 |
1440 /* destroy the current main window */ | |
1441 if(gui->skin) destroy_window(gui); | |
1442 | |
1443 /* get screenproperties */ | |
1444 gui->screenbpp = GetDesktopBitsPerPixel(); | |
1445 gui->screenw = GetSystemMetrics(SM_CXSCREEN); | |
1446 gui->screenh = GetSystemMetrics(SM_CYSCREEN); | |
1447 | |
1448 /* load the new skin */ | |
1449 gui->skin = loadskin(skindir, gui->screenbpp); | |
1450 if(!gui->skin) | |
1451 { | |
1452 mp_msg(MSGT_GPLAYER, MSGL_FATAL, "[GUI] fatal error during skinload\n"); | |
1453 /* Set default Skin */ | |
1454 if (skinName) free(skinName); | |
1455 skinName = strdup("Blue"); | |
1456 /* then force write conf */ | |
1457 cfg_write(); | |
1458 return 1; | |
1459 } | |
1460 | |
1461 /* find the description of the mainwindow */ | |
1462 for (i=0; i<gui->skin->windowcount; i++) | |
1463 if(gui->skin->windows[i]->type == wiMain) | |
1464 desc = gui->skin->windows[i]; | |
1465 | |
1466 if(!desc) | |
1467 { | |
1468 mp_msg(MSGT_GPLAYER, MSGL_FATAL, "[GUI] Invalid skin description\n"); | |
1469 return 1; | |
1470 } | |
1471 | |
1472 /* load the icon from the executable */ | |
1473 GetModuleFileName(NULL, dir, MAX_PATH); | |
1474 gui->icon = ExtractIcon(instance, dir, 0); | |
1475 | |
1476 /* create the window class */ | |
1477 wc.style = CS_HREDRAW | CS_VREDRAW; | |
1478 wc.lpfnWndProc = EventProc; | |
1479 wc.cbClsExtra = 0; | |
1480 wc.cbWndExtra = 0; | |
1481 wc.hInstance = instance; | |
1482 wc.hCursor = LoadCursor(NULL, IDC_ARROW); | |
1483 wc.hIcon = gui->icon; | |
1484 wc.hbrBackground = CreateSolidBrush(RGB(0, 0, 0)); | |
1485 wc.lpszClassName = gui->classname = "MPlayer GUI for Windows"; | |
1486 wc.lpszMenuName = NULL; | |
1487 RegisterClass(&wc); | |
1488 | |
1489 /* create a context menu */ | |
1490 create_menu(gui); | |
1491 /* create the systray menu */ | |
1492 create_traymenu(gui); | |
1493 | |
1494 /* create the mainwindow */ | |
1495 /* TODO implement aligning as described in skin.html */ | |
1496 rect.top = rect.left = 100; | |
1497 rect.bottom = rect.top+desc->base->bitmap[0]->height; | |
1498 rect.right = rect.left+desc->base->bitmap[0]->width; | |
1499 if(desc->decoration) style = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX; | |
1500 else style = WS_POPUP | WS_SYSMENU; | |
1501 | |
1502 AdjustWindowRect(&rect, style, 0); | |
1503 | |
1504 /* Check if out of screen */ | |
1505 if (gui_main_pos_x >= 0) | |
1506 x = gui_main_pos_x; | |
1507 if (gui_main_pos_y >= 0) | |
1508 y = gui_main_pos_y; | |
1509 | |
1510 if (x <= -1 || (x+(rect.right-rect.left) > GetSystemMetrics(SM_CXFULLSCREEN))) | |
1511 { | |
1512 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - ((rect.right-rect.left) / 2); | |
1513 gui_main_pos_x = x; | |
1514 } | |
1515 if (y <= -1 || (y+(rect.bottom-rect.top) > GetSystemMetrics(SM_CYFULLSCREEN))) | |
1516 { | |
1517 y = ((GetSystemMetrics(SM_CYSCREEN)-40) - (rect.bottom-rect.top)); | |
1518 gui_main_pos_y = y; | |
1519 } | |
1520 | |
1521 hwnd = CreateWindowEx(0, gui->classname, "MPlayer for Windows", style, | |
1522 x, y, rect.right-rect.left, rect.bottom-rect.top, | |
1523 gui->mainwindow, NULL, instance, NULL); | |
1524 | |
1525 /* set the systray icon properties */ | |
1526 nid.cbSize = sizeof(NOTIFYICONDATA); | |
1527 nid.hWnd = hwnd; | |
1528 nid.uID = 1; | |
1529 nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; | |
1530 nid.uCallbackMessage = WM_SYSTRAY; | |
1531 nid.hIcon = gui->icon; | |
1532 strcpy(nid.szTip, "MPlayer for Windows"); | |
1533 | |
1534 /* register the systray icon */ | |
1535 Shell_NotifyIcon(NIM_ADD, &nid); | |
1536 | |
1537 /* load all the window images */ | |
1538 window_render(gui, hwnd, hdc, priv, desc, binfo); | |
1539 | |
1540 /* enable drag and drop support */ | |
1541 DragAcceptFiles(hwnd, TRUE); | |
1542 | |
1543 updatedisplay(gui, hwnd); | |
1544 gui->mainwindow = hwnd; | |
1545 | |
1546 /* display */ | |
1547 ShowWindow(gui->mainwindow, SW_SHOW); | |
1548 UpdateWindow(gui->mainwindow); | |
1549 maketransparent(gui->mainwindow, RGB(255, 0, 255)); | |
1550 return 0; | |
1551 } | |
1552 | |
1553 gui_t *create_gui(char *skindir, char *skinName, void (*playercontrol)(int event)) | |
1554 { | |
1555 gui_t *gui = calloc(1, sizeof(gui_t)); | |
19718 | 1556 char temp[MAX_PATH]; |
1557 HWND runningmplayer = FindWindow("MPlayer GUI for Windows", "MPlayer for Windows"); | |
18914 | 1558 |
1559 if(runningmplayer) | |
1560 { | |
1561 free(gui); | |
1562 return NULL; | |
1563 } | |
1564 | |
1565 gui->startplay = startplay; | |
1566 gui->playercontrol = playercontrol; | |
1567 gui->uninit = uninit; | |
1568 gui->updatedisplay = updatedisplay; | |
1569 | |
1570 /* create playlist */ | |
1571 gui->playlist = create_playlist(); | |
1572 | |
1573 if(!skinName) skinName = strdup("Blue"); | |
1574 sprintf(temp, "%s\\%s", skindir, skinName); | |
1575 if(create_window(gui, temp)) return NULL; | |
1576 if(create_subwindow(gui, temp)) return NULL; | |
1577 if(console) console_toggle(); | |
1578 return gui; | |
1579 } |