annotate gui/win32/gui.c @ 26457:9ba6d4487292

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