* skin-main.cpp: skins plugin for VLC
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: skin_main.cpp,v 1.20 2003/04/28 12:00:14 asmax Exp $
+ * $Id: skin_main.cpp,v 1.33 2003/06/06 23:34:35 asmax Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
* USA.
*****************************************************************************/
-//--- GENERAL ---------------------------------------------------------------
-#include <wx/wx.h>
-
//--- VLC -------------------------------------------------------------------
#include <vlc/vlc.h>
#include <vlc/intf.h>
#include <vlc/aout.h>
+//--- GENERAL ---------------------------------------------------------------
+#ifndef BASIC_SKINS
+#ifdef WIN32 /* mingw32 hack */
+# undef Yield
+# undef CreateDialog
+#endif
+/* Let vlc take care of the i18n stuff */
+#define WXINTL_NO_GETTEXT_MACRO
+#include <wx/wx.h>
+#endif
+
//--- SKIN ------------------------------------------------------------------
#include "../os_api.h"
#include "event.h"
#include "themeloader.h"
#include "vlcproc.h"
#include "skin_common.h"
-#include "wxdialogs.h"
+#include "dialogs.h"
+#ifndef BASIC_SKINS
+#include "../../wxwindows/wxwindows.h"
+#endif
+
+#ifdef X11_SKINS
+#include <X11/Xlib.h>
+#endif
//---------------------------------------------------------------------------
// Interface thread
// Set no new theme when opening file
p_intf->p_sys->p_new_theme_file = NULL;
- // Initialize Win32 thread
+ // Initialize info on playlist
p_intf->p_sys->i_index = -1;
p_intf->p_sys->i_size = 0;
-
p_intf->p_sys->i_close_status = VLC_NOTHING;
p_intf->p_sys->p_input = NULL;
char **pp_args = p_args;
gdk_init( &i_args, &pp_args );
-#endif
- // Initialize conditions and mutexes
- vlc_mutex_init( p_intf, &p_intf->p_sys->init_lock );
- vlc_cond_init( p_intf, &p_intf->p_sys->init_cond );
+#elif defined X11_SKINS
+ // Initialize X11
+ p_intf->p_sys->display = XOpenDisplay( NULL );
+ vlc_mutex_init( p_intf, &p_intf->p_sys->xlock );
+
+#elif defined WIN32
+ // Interface thread id used to post broadcast messages
+ p_intf->p_sys->dwThreadId = GetCurrentThreadId();
+
+ // We dynamically load msimg32.dll to get a pointer to TransparentBlt()
+ p_intf->p_sys->h_msimg32_dll = LoadLibrary("msimg32.dll");
+ if( !p_intf->p_sys->h_msimg32_dll ||
+ !( p_intf->p_sys->TransparentBlt =
+ (BOOL (WINAPI*)(HDC,int,int,int,int,HDC,
+ int,int,int,int,unsigned int))
+ GetProcAddress( p_intf->p_sys->h_msimg32_dll, "TransparentBlt" ) ) )
+ {
+ p_intf->p_sys->TransparentBlt = NULL;
+ msg_Dbg( p_intf, "Couldn't find TransparentBlt(), "
+ "falling back to BitBlt()" );
+ }
+
+ // idem for user32.dll and SetLayeredWindowAttributes()
+ p_intf->p_sys->h_user32_dll = LoadLibrary("user32.dll");
+ if( !p_intf->p_sys->h_user32_dll ||
+ !( p_intf->p_sys->SetLayeredWindowAttributes =
+ (BOOL (WINAPI *)(HWND,COLORREF,BYTE,DWORD))
+ GetProcAddress( p_intf->p_sys->h_user32_dll,
+ "SetLayeredWindowAttributes" ) ) )
+ {
+ p_intf->p_sys->SetLayeredWindowAttributes = NULL;
+ msg_Dbg( p_intf, "Couldn't find SetLayeredWindowAttributes()" );
+ }
+
+#endif
p_intf->p_sys->p_theme = (Theme *)new OSTheme( p_intf );
{
intf_thread_t *p_intf = (intf_thread_t *)p_this;
-
if( p_intf->p_sys->p_input )
{
vlc_object_release( p_intf->p_sys->p_input );
// Unsuscribe to messages bank
msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
- // Destroy conditions and mutexes
- vlc_cond_destroy( &p_intf->p_sys->init_cond );
- vlc_mutex_destroy( &p_intf->p_sys->init_lock );
+#ifdef WIN32
+ // Unload msimg32.dll and user32.dll
+ if( p_intf->p_sys->h_msimg32_dll )
+ FreeLibrary( p_intf->p_sys->h_msimg32_dll );
+ if( p_intf->p_sys->h_user32_dll )
+ FreeLibrary( p_intf->p_sys->h_user32_dll );
+#elif defined X11_SKINS
+ vlc_mutex_destroy( &p_intf->p_sys->xlock );
+#endif
// Destroy structure
free( p_intf->p_sys );
int a = OSAPI_GetTime();
+#ifndef BASIC_SKINS
+ // Initialize the dialog boxes
+ p_intf->p_sys->p_dialogs = new Dialogs( p_intf );
+ if( !p_intf->p_sys->p_dialogs ||
+ !p_intf->p_sys->p_dialogs->OpenDlg ) return;
+#endif
+
// Load a theme
char *skin_last = config_GetPsz( p_intf, "skin_last" );
ThemeLoader *Loader = new ThemeLoader( p_intf );
#endif
{
// Last chance: the user can select a new theme file
- wxFileDialog dialog( NULL, _("Open a skin file"), "", "",
- "Skin files (*.vlt)|*.vlt|Skin files (*.xml)|*.xml|"
- "All files|*.*", wxOPEN );
+#ifndef BASIC_SKINS
+ wxFileDialog dialog( NULL,
+ wxU(_("Open a skin file")), wxT(""), wxT(""),
+ wxT("Skin files (*.vlt)|*.vlt|Skin files (*.xml)|*.xml|"
+ "All files|*.*"), wxOPEN );
if( dialog.ShowModal() == wxID_OK )
{
// try to load selected file
- if( ! Loader->Load( dialog.GetPath().c_str() ) )
+ if( ! Loader->Load( (string)dialog.GetPath().mb_str() ) )
{
// He, he, what the hell is he doing ?
delete Loader;
}
}
else
+#endif
{
delete Loader;
return;
delete Loader;
- msg_Err( p_intf, "Load theme time : %i ms", OSAPI_GetTime() - a );
+ msg_Dbg( p_intf, "Load theme time : %i ms", OSAPI_GetTime() - a );
// Refresh the whole interface
OSAPI_PostMessage( NULL, VLC_INTF_REFRESH, 0, (int)true );
OSRun( p_intf );
+
+#ifndef BASIC_SKINS
+ // clean up the dialog boxes
+ delete p_intf->p_sys->p_dialogs;
+#endif
}
//---------------------------------------------------------------------------
set_description( _("Skinnable Interface") );
set_capability( "interface", 30 );
set_callbacks( Open, Close );
- add_shortcut( "skins" );
vlc_module_end();
OSAPI_PostMessage( NULL, VLC_INTF_REFRESH, 0, (long)false );
+#ifndef BASIC_SKINS //FIXME
// Update the log window
- p_intf->p_sys->MessagesDlg->UpdateLog();
+ p_intf->p_sys->p_dialogs->MessagesDlg->UpdateLog();
// Update the file info window
- p_intf->p_sys->InfoDlg->UpdateFileInfo();
+ p_intf->p_sys->p_dialogs->FileInfoDlg->UpdateFileInfo();
+#endif
//-------------------------------------------------------------------------
if( p_intf->p_sys->p_input != NULL && !p_intf->p_sys->p_input->b_die )