]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins2/win32/win32_factory.cpp
missing const to non-const cast
[vlc] / modules / gui / skins2 / win32 / win32_factory.cpp
index ea0897bd37e7eb481a077772795a217f15fcae60..d3733eb620b0a6837735aad9663c4d9825949aa0 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************
  * win32_factory.cpp
  *****************************************************************************
- * Copyright (C) 2003 VideoLAN
- * $Id: win32_factory.cpp,v 1.1 2004/01/03 23:31:34 asmax Exp $
+ * Copyright (C) 2003 the VideoLAN team
+ * $Id$
  *
  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
  *          Olivier Teulière <ipkiss@via.ecp.fr>
@@ -30,6 +30,7 @@
 #include "win32_window.hpp"
 #include "win32_tooltip.hpp"
 #include "win32_loop.hpp"
+#include "../src/theme.hpp"
 
 
 LRESULT CALLBACK Win32Proc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
@@ -79,8 +80,9 @@ LRESULT CALLBACK Win32Proc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
 
 
 Win32Factory::Win32Factory( intf_thread_t *pIntf ):
-    OSFactory( pIntf ), TransparentBlt( NULL ),
-    SetLayeredWindowAttributes( NULL )
+    OSFactory( pIntf ), TransparentBlt( NULL ), AlphaBlend( NULL ),
+    SetLayeredWindowAttributes( NULL ), m_hParentWindow( NULL ),
+    m_dirSep( "\\" )
 {
     // see init()
 }
@@ -99,13 +101,13 @@ bool Win32Factory::init()
     WNDCLASS skinWindowClass;
     skinWindowClass.style = CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS;
     skinWindowClass.lpfnWndProc = (WNDPROC) Win32Proc;
-    skinWindowClass.lpszClassName = "SkinWindowClass";
+    skinWindowClass.lpszClassName = _T("SkinWindowClass");
     skinWindowClass.lpszMenuName = NULL;
     skinWindowClass.cbClsExtra = 0;
     skinWindowClass.cbWndExtra = 0;
-    skinWindowClass.hbrBackground = HBRUSH (COLOR_WINDOW);
+    skinWindowClass.hbrBackground = NULL;
     skinWindowClass.hCursor = LoadCursor( NULL , IDC_ARROW );
-    skinWindowClass.hIcon = LoadIcon( m_hInst, "VLC_ICON" );
+    skinWindowClass.hIcon = LoadIcon( m_hInst, _T("VLC_ICON") );
     skinWindowClass.hInstance = m_hInst;
 
     // Register class and check it
@@ -115,7 +117,7 @@ bool Win32Factory::init()
 
         // Check why it failed. If it's because the class already exists
         // then fine, otherwise return with an error.
-        if( !GetClassInfo( m_hInst, "SkinWindowClass", &wndclass ) )
+        if( !GetClassInfo( m_hInst, _T("SkinWindowClass"), &wndclass ) )
         {
             msg_Err( getIntf(), "Cannot register window class" );
             return false;
@@ -123,9 +125,9 @@ bool Win32Factory::init()
     }
 
     // Create Window
-    m_hParentWindow = CreateWindowEx( WS_EX_APPWINDOW, "SkinWindowClass",
-        "VLC Media Player", WS_SYSMENU, 0, 0, 0, 0, 0, 0,
-        m_hInst, NULL );
+    m_hParentWindow = CreateWindowEx( WS_EX_APPWINDOW, _T("SkinWindowClass"),
+        _T("VLC media player"), WS_SYSMENU|WS_POPUP,
+        -200, -200, 0, 0, 0, 0, m_hInst, 0 );
     if( m_hParentWindow == NULL )
     {
         msg_Err( getIntf(), "Cannot create parent window" );
@@ -135,8 +137,8 @@ bool Win32Factory::init()
     // We do it this way otherwise CreateWindowEx will fail
     // if WS_EX_LAYERED is not supported
     SetWindowLongPtr( m_hParentWindow, GWL_EXSTYLE,
-                      GetWindowLong( m_hParentWindow, GWL_EXSTYLE )
-                      WS_EX_LAYERED );
+                      GetWindowLong( m_hParentWindow, GWL_EXSTYLE ) |
+                      WS_EX_LAYERED );
 
     // Store with it a pointer to the interface thread
     SetWindowLongPtr( m_hParentWindow, GWLP_USERDATA, (LONG_PTR)getIntf() );
@@ -146,29 +148,50 @@ bool Win32Factory::init()
     OleInitialize( NULL );
 
     // We dynamically load msimg32.dll to get a pointer to TransparentBlt()
-    m_hMsimg32 = LoadLibrary( "msimg32.dll" );
+    m_hMsimg32 = LoadLibrary( _T("msimg32.dll") );
     if( !m_hMsimg32 ||
         !( TransparentBlt =
             (BOOL (WINAPI*)(HDC, int, int, int, int,
                             HDC, int, int, int, int, unsigned int))
-            GetProcAddress( m_hMsimg32, "TransparentBlt" ) ) )
+            GetProcAddress( m_hMsimg32, _T("TransparentBlt") ) ) )
     {
         TransparentBlt = NULL;
         msg_Dbg( getIntf(), "Couldn't find TransparentBlt(), "
                  "falling back to BitBlt()" );
     }
+    if( !m_hMsimg32 ||
+        !( AlphaBlend =
+            (BOOL (WINAPI*)( HDC, int, int, int, int, HDC, int, int,
+                              int, int, BLENDFUNCTION ))
+            GetProcAddress( m_hMsimg32, _T("AlphaBlend") ) ) )
+    {
+        AlphaBlend = NULL;
+        msg_Dbg( getIntf(), "Couldn't find AlphaBlend()" );
+    }
 
     // Idem for user32.dll and SetLayeredWindowAttributes()
-    m_hUser32 = LoadLibrary( "user32.dll" );
+    m_hUser32 = LoadLibrary( _T("user32.dll") );
     if( !m_hUser32 ||
         !( SetLayeredWindowAttributes =
             (BOOL (WINAPI *)(HWND, COLORREF, BYTE, DWORD))
-            GetProcAddress( m_hUser32, "SetLayeredWindowAttributes" ) ) )
+            GetProcAddress( m_hUser32, _T("SetLayeredWindowAttributes") ) ) )
     {
         SetLayeredWindowAttributes = NULL;
         msg_Dbg( getIntf(), "Couldn't find SetLayeredWindowAttributes()" );
     }
 
+    // Initialize the resource path
+    m_resourcePath.push_back( (string)getIntf()->p_vlc->psz_homedir +
+                               "\\" + CONFIG_DIR + "\\skins" );
+    m_resourcePath.push_back( (string)getIntf()->p_libvlc->psz_vlcpath +
+                              "\\skins" );
+    m_resourcePath.push_back( (string)getIntf()->p_libvlc->psz_vlcpath +
+                              "\\skins2" );
+    m_resourcePath.push_back( (string)getIntf()->p_libvlc->psz_vlcpath +
+                              "\\share\\skins" );
+    m_resourcePath.push_back( (string)getIntf()->p_libvlc->psz_vlcpath +
+                              "\\share\\skins2" );
+
     // All went well
     return true;
 }
@@ -179,6 +202,8 @@ Win32Factory::~Win32Factory()
     // Uninitialize the OLE library
     OleUninitialize();
 
+    if( m_hParentWindow ) DestroyWindow( m_hParentWindow );
+
     // Unload msimg32.dll and user32.dll
     if( m_hMsimg32 )
         FreeLibrary( m_hMsimg32 );
@@ -204,18 +229,25 @@ void Win32Factory::destroyOSLoop()
     Win32Loop::destroy( getIntf() );
 }
 
+void Win32Factory::minimize()
+{
+    /* Make sure no tooltip is visible first */
+    getIntf()->p_sys->p_theme->getWindowManager().hideTooltip();
 
-OSTimer *Win32Factory::createOSTimer( const Callback &rCallback )
+    ShowWindow( m_hParentWindow, SW_MINIMIZE );
+}
+
+OSTimer *Win32Factory::createOSTimer( CmdGeneric &rCmd )
 {
-    return new Win32Timer( getIntf(), rCallback, m_hParentWindow );
+    return new Win32Timer( getIntf(), rCmd, m_hParentWindow );
 }
 
 
 OSWindow *Win32Factory::createOSWindow( GenericWindow &rWindow, bool dragDrop,
-                                        bool playOnDrop )
+                                        bool playOnDrop, OSWindow *pParent )
 {
     return new Win32Window( getIntf(), rWindow, m_hInst, m_hParentWindow,
-                            dragDrop, playOnDrop );
+                            dragDrop, playOnDrop, (Win32Window*)pParent );
 }
 
 
@@ -225,12 +257,6 @@ OSTooltip *Win32Factory::createOSTooltip()
 }
 
 
-const string Win32Factory::getDirSeparator() const
-{
-    return "\\";
-}
-
-
 int Win32Factory::getScreenWidth() const
 {
     return GetSystemMetrics(SM_CXSCREEN);
@@ -263,6 +289,36 @@ void Win32Factory::getMousePos( int &rXPos, int &rYPos ) const
 }
 
 
+void Win32Factory::changeCursor( CursorType_t type ) const
+{
+    LPCTSTR id;
+    switch( type )
+    {
+        case kDefaultArrow:
+            id = IDC_ARROW;
+            break;
+        case kResizeNWSE:
+            id = IDC_SIZENWSE;
+            break;
+        case kResizeNS:
+            id = IDC_SIZENS;
+            break;
+        case kResizeWE:
+            id = IDC_SIZEWE;
+            break;
+        case kResizeNESW:
+            id = IDC_SIZENESW;
+            break;
+        default:
+            id = IDC_ARROW;
+            break;
+    }
+
+    HCURSOR hCurs = LoadCursor( NULL, id );
+    SetCursor( hCurs );
+}
+
+
 void Win32Factory::rmDir( const string &rPath )
 {
     WIN32_FIND_DATA find;
@@ -300,5 +356,4 @@ void Win32Factory::rmDir( const string &rPath )
     RemoveDirectory( rPath.c_str() );
 }
 
-
 #endif