annotate Gui/win32/gui.c @ 21715:9d96f4df253a

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