annotate gui/win32/gui.c @ 25101:10a3f5b4ee20

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