annotate Gui/win32/gui.c @ 19616:98204aa21b0a

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