annotate Gui/win32/gui.c @ 21984:607909d7cc56

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