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