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