annotate gui/win32/gui.c @ 31932:58ecd8282065

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