00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifdef WIN32_SKINS
00026
00027 #include "../src/generic_window.hpp"
00028 #include "../src/vlcproc.hpp"
00029 #include "win32_window.hpp"
00030 #include "win32_dragdrop.hpp"
00031 #include "win32_factory.hpp"
00032
00033
00035 #ifndef LWA_COLORKEY
00036 # define LWA_COLORKEY 0x00000001
00037 # define LWA_ALPHA 0x00000002
00038 #endif
00039
00040
00041
00042 #ifndef WS_EX_LAYERED
00043 # define WS_EX_LAYERED 0x00080000
00044 #endif
00045
00046 Win32Window::Win32Window( intf_thread_t *pIntf, GenericWindow &rWindow,
00047 HINSTANCE hInst, HWND hParentWindow,
00048 bool dragDrop, bool playOnDrop,
00049 Win32Window *pParentWindow ):
00050 OSWindow( pIntf ), m_dragDrop( dragDrop ), m_isLayered( false ),
00051 m_pParent( pParentWindow )
00052 {
00053
00054 if( pParentWindow )
00055 {
00056
00057 HWND hParent = pParentWindow->getHandle();
00058 m_hWnd = CreateWindowEx( WS_EX_TOOLWINDOW, "SkinWindowClass",
00059 "default name", WS_CHILD, CW_USEDEFAULT, CW_USEDEFAULT,
00060 CW_USEDEFAULT, CW_USEDEFAULT, hParent, 0, hInst, NULL );
00061 }
00062 else
00063 {
00064
00065 m_hWnd = CreateWindowEx( WS_EX_TOOLWINDOW, "SkinWindowClass",
00066 "default name", WS_POPUP | WS_CLIPCHILDREN,
00067 CW_USEDEFAULT, CW_USEDEFAULT,
00068 CW_USEDEFAULT, CW_USEDEFAULT, hParentWindow, 0, hInst, NULL );
00069 }
00070
00071 if( !m_hWnd )
00072 {
00073 msg_Err( getIntf(), "CreateWindow failed" );
00074 return;
00075 }
00076
00077
00078 Win32Factory *pFactory = (Win32Factory*)Win32Factory::instance( getIntf() );
00079 pFactory->m_windowMap[m_hWnd] = &rWindow;
00080
00081
00082 if( m_dragDrop )
00083 {
00084 m_pDropTarget = (LPDROPTARGET) new Win32DragDrop( getIntf(),
00085 playOnDrop );
00086
00087 RegisterDragDrop( m_hWnd, m_pDropTarget );
00088 }
00089
00090
00091 if( m_pParent )
00092 {
00093 VlcProc::instance( getIntf() )->registerVoutWindow( (void*)m_hWnd );
00094 }
00095 }
00096
00097
00098 Win32Window::~Win32Window()
00099 {
00100 if( m_pParent )
00101 {
00102 VlcProc::instance( getIntf() )->unregisterVoutWindow( (void*)m_hWnd );
00103 }
00104
00105 Win32Factory *pFactory = (Win32Factory*)Win32Factory::instance( getIntf() );
00106 pFactory->m_windowMap[m_hWnd] = NULL;
00107
00108 if( m_hWnd )
00109 {
00110 if( m_dragDrop )
00111 {
00112
00113 RevokeDragDrop( m_hWnd );
00114 m_pDropTarget->Release();
00115 }
00116
00117 DestroyWindow( m_hWnd );
00118 }
00119 }
00120
00121
00122 void Win32Window::show( int left, int top ) const
00123 {
00124 ShowWindow( m_hWnd, SW_SHOW );
00125 }
00126
00127
00128 void Win32Window::hide() const
00129 {
00130 ShowWindow( m_hWnd, SW_HIDE );
00131 }
00132
00133
00134 void Win32Window::moveResize( int left, int top, int width, int height ) const
00135 {
00136 MoveWindow( m_hWnd, left, top, width, height, true );
00137 }
00138
00139
00140 void Win32Window::raise() const
00141 {
00142
00143 SetForegroundWindow( m_hWnd );
00144 }
00145
00146
00147 void Win32Window::setOpacity( uint8_t value ) const
00148 {
00149 Win32Factory *pFactory = (Win32Factory*)Win32Factory::instance( getIntf() );
00150
00151 if( value == 255 )
00152 {
00153
00154
00155 if( m_isLayered )
00156 {
00157 SetWindowLongPtr( m_hWnd, GWL_EXSTYLE,
00158 GetWindowLong( m_hWnd, GWL_EXSTYLE ) & ~WS_EX_LAYERED );
00159
00160
00161
00162 RedrawWindow(m_hWnd, NULL, NULL,
00163 RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
00164
00165 m_isLayered = false;
00166 }
00167 }
00168 else
00169 {
00170 if( pFactory->SetLayeredWindowAttributes )
00171 {
00172 if( ! m_isLayered )
00173 {
00174
00175
00176 SetWindowLongPtr( m_hWnd, GWL_EXSTYLE,
00177 GetWindowLong( m_hWnd, GWL_EXSTYLE ) | WS_EX_LAYERED );
00178
00179
00180
00181 RedrawWindow(m_hWnd, NULL, NULL,
00182 RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
00183
00184 m_isLayered = true;
00185 }
00186
00187
00188 pFactory->SetLayeredWindowAttributes(
00189 m_hWnd, 0, value, LWA_ALPHA|LWA_COLORKEY );
00190 }
00191 }
00192 }
00193
00194
00195 void Win32Window::toggleOnTop( bool onTop ) const
00196 {
00197 if( onTop )
00198 {
00199
00200 SetWindowPos( m_hWnd, HWND_TOPMOST, 0, 0, 0, 0,
00201 SWP_NOSIZE | SWP_NOMOVE );
00202 }
00203 else
00204 {
00205
00206 SetWindowPos( m_hWnd, HWND_NOTOPMOST, 0, 0, 0, 0,
00207 SWP_NOSIZE | SWP_NOMOVE );
00208 }
00209 }
00210
00211
00212 #endif