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