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