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