1 /*****************************************************************************
2 * video.cpp : WinCE gui plugin for VLC
3 *****************************************************************************
4 * Copyright (C) 2000-2004, 2003 the VideoLAN team
7 * Authors: Marodon Cedric <cedric_marodon@yahoo.fr>
8 * Gildas Bazin <gbazin@videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
30 #include <vlc_interface.h>
34 static void *GetWindow( intf_thread_t *p_intf, vout_thread_t *,
35 int *pi_x_hint, int *pi_y_hint,
36 unsigned int *pi_width_hint,
37 unsigned int *pi_height_hint );
38 static void ReleaseWindow( intf_thread_t *p_intf, void *p_window );
40 static int ControlWindow( intf_thread_t *p_intf, void *p_window,
41 int i_query, va_list args );
43 /* IDs for the controls and the menu commands */
46 UpdateSize_Event = 1000 + 1,
51 class VideoWindow : public CBaseWindow
55 VideoWindow( intf_thread_t *_p_intf, HWND _p_parent );
56 virtual ~VideoWindow();
58 void *GetWindow( vout_thread_t *, int *, int *, unsigned int *,
60 void ReleaseWindow( void * );
61 int ControlWindow( void *, int, va_list );
63 HWND p_child_window; // public because of menu
66 intf_thread_t *p_intf;
67 vout_thread_t *p_vout;
71 virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
74 /*****************************************************************************
76 *****************************************************************************/
77 CBaseWindow *CreateVideoWindow( intf_thread_t *p_intf, HWND p_parent )
79 return new VideoWindow( p_intf, p_parent );
82 /*****************************************************************************
84 *****************************************************************************/
85 VideoWindow::VideoWindow( intf_thread_t *_p_intf, HWND _p_parent )
93 p_child_window = NULL;
95 vlc_mutex_init( p_intf, &lock );
99 p_intf->pf_request_window = ::GetWindow;
100 p_intf->pf_release_window = ::ReleaseWindow;
101 p_intf->pf_control_window = ::ControlWindow;
103 p_intf->p_sys->p_video_window = this;
105 GetClientRect( p_parent, &rect );
107 wc.style = CS_HREDRAW | CS_VREDRAW ;
108 wc.lpfnWndProc = (WNDPROC)BaseWndProc;
112 wc.hInstance = GetModuleHandle(0);
114 wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
115 wc.lpszMenuName = NULL;
116 wc.lpszClassName = _T("VIDEOWINDOW");
117 RegisterClass( &wc );
119 p_child_window = CreateWindow (
120 _T("VIDEOWINDOW"), _T(""),
121 WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | WS_BORDER,
122 0, 20, rect.right - rect.left,
123 rect.bottom - rect.top - 2*(MENU_HEIGHT-1) - SLIDER_HEIGHT - 20,
124 p_parent, NULL, GetModuleHandle(0), (void *)this );
126 ShowWindow( p_child_window, SW_SHOW );
127 UpdateWindow( p_child_window );
129 ReleaseWindow( (void*)p_child_window );
132 VideoWindow::~VideoWindow()
134 vlc_mutex_destroy( &lock );
137 /*****************************************************************************
139 *****************************************************************************/
140 static void *GetWindow( intf_thread_t *p_intf, vout_thread_t *p_vout,
141 int *pi_x_hint, int *pi_y_hint,
142 unsigned int *pi_width_hint,
143 unsigned int *pi_height_hint )
145 return p_intf->p_sys->p_video_window->GetWindow( p_vout, pi_x_hint,
146 pi_y_hint, pi_width_hint, pi_height_hint );
149 void *VideoWindow::GetWindow( vout_thread_t *_p_vout,
150 int *pi_x_hint, int *pi_y_hint,
151 unsigned int *pi_width_hint,
152 unsigned int *pi_height_hint )
154 vlc_mutex_lock( &lock );
158 vlc_mutex_unlock( &lock );
159 msg_Dbg( p_intf, "Video window already in use" );
165 vlc_mutex_unlock( &lock );
167 ShowWindow( (HWND)p_child_window, SW_SHOW );
168 return p_child_window;
171 static void ReleaseWindow( intf_thread_t *p_intf, void *p_window )
173 p_intf->p_sys->p_video_window->ReleaseWindow( p_window );
176 void VideoWindow::ReleaseWindow( void *p_window )
178 vlc_mutex_lock( &lock );
180 vlc_mutex_unlock( &lock );
182 ShowWindow( (HWND)p_window, SW_HIDE );
183 SetForegroundWindow( p_parent );
186 /***********************************************************************
192 Processes messages sent to the main window.
194 ***********************************************************************/
195 LRESULT VideoWindow::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
201 vout_Control( p_vout, VOUT_SET_FOCUS, (vlc_bool_t)VLC_FALSE );
206 vout_Control( p_vout, VOUT_SET_FOCUS, (vlc_bool_t)VLC_TRUE );
210 return DefWindowProc( hwnd, msg, wp, lp );
215 static int ControlWindow( intf_thread_t *p_intf, void *p_window,
216 int i_query, va_list args )
218 return p_intf->p_sys->p_video_window->ControlWindow( p_window, i_query,
222 int VideoWindow::ControlWindow( void *p_window, int i_query, va_list args )
224 int i_ret = VLC_EGENERIC;
226 vlc_mutex_lock( &lock );
230 case VOUT_SET_STAY_ON_TOP:
234 msg_Dbg( p_intf, "control query not supported" );
238 vlc_mutex_unlock( &lock );