annotate Gui/win32/gui.c @ 19311:0a4df538c136

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