/*****************************************************************************
* wxwindows.cpp : wxWindows plugin for vlc
*****************************************************************************
- * Copyright (C) 2000-2001 VideoLAN
- * $Id: wxwindows.cpp,v 1.23 2003/07/20 10:38:49 gbazin Exp $
+ * Copyright (C) 2000-2004 VideoLAN
+ * $Id$
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
#include <stdio.h>
#include <vlc/vlc.h>
+#include <vlc/intf.h>
-#ifdef WIN32 /* mingw32 hack */
-#undef Yield
-#undef CreateDialog
-
-extern int wxEntry( HINSTANCE hInstance,
- HINSTANCE hPrevInstance = NULL,
- char *pCmdLine = NULL,
- int nCmdShow = SW_NORMAL );
+#ifdef HAVE_LOCALE_H
+# include <locale.h>
#endif
-/* Let vlc take care of the i18n stuff */
-#define WXINTL_NO_GETTEXT_MACRO
-
-#include <wx/wxprec.h>
-#include <wx/wx.h>
-
-#include <vlc/intf.h>
-
#include "wxwindows.h"
/* Temporary hack */
-#ifdef __DARWIN__
+#if defined(WIN32) && defined(_WX_INIT_H_)
+/* Hack to detect wxWindows 2.5 which has a different wxEntry() prototype */
+extern int wxEntry( HINSTANCE hInstance, HINSTANCE hPrevInstance = NULL,
+ char *pCmdLine = NULL, int nCmdShow = SW_NORMAL );
+#endif
+#ifdef SYS_DARWIN
int wxEntry( int argc, char *argv[] , bool enterLoop = TRUE );
#endif
Instance( intf_thread_t *_p_intf );
bool OnInit();
+ int OnExit();
private:
intf_thread_t *p_intf;
* Module descriptor
*****************************************************************************/
vlc_module_begin();
+#ifdef WIN32
+ int i_score = 150;
+#else
+ int i_score = getenv( "DISPLAY" ) == NULL ? 15 : 150;
+#endif
set_description( (char *) _("wxWindows interface module") );
- set_capability( "interface", 50 );
+ set_capability( "interface", i_score );
set_callbacks( Open, Close );
add_shortcut( "wxwindows" );
add_shortcut( "wxwin" );
vlc_object_release( p_intf->p_sys->p_input );
}
- msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
-
if( p_intf->pf_show_dialog )
{
/* We must destroy the dialogs thread */
vlc_thread_join( p_intf );
}
+ msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
+
/* Destroy structure */
free( p_intf->p_sys );
}
#endif
/* Hack to pass the p_intf pointer to the new wxWindow Instance object */
+#ifdef wxTheApp
+ wxApp::SetInstance( new Instance( p_intf ) );
+#else
wxTheApp = new Instance( p_intf );
+#endif
#if defined( WIN32 )
#if !defined(__BUILTIN__)
* provided facilities (eg. open file dialog) */
locale.Init( wxLANGUAGE_DEFAULT );
+ /* FIXME: The stream output mrl parsing uses ',' already so we want to
+ * keep the default '.' for floating point numbers. */
+ setlocale( LC_NUMERIC, "C" );
+
/* Make an instance of your derived frame. Passing NULL (the default value
* of Frame's constructor is NULL) as the frame doesn't have a parent
* since it is the first window */
/* Show the interface */
MainInterface->Show( TRUE );
-
SetTopWindow( MainInterface );
-
- /* Start timer */
- new Timer( p_intf, MainInterface );
+ MainInterface->Raise();
}
/* Creates the dialogs provider */
return TRUE;
}
+/*****************************************************************************
+ * Instance::OnExit: called when the interface execution stops
+ *****************************************************************************/
+int Instance::OnExit()
+{
+ if( p_intf->pf_show_dialog )
+ {
+ /* We need to manually clean up the dialogs class */
+ if( p_intf->p_sys->p_wxwindow ) delete p_intf->p_sys->p_wxwindow;
+ }
+ return 0;
+}
+
static void ShowDialog( intf_thread_t *p_intf, int i_dialog_event, int i_arg,
intf_dialog_args_t *p_arg )
{
event.SetInt( i_arg );
event.SetClientData( p_arg );
+#ifdef WIN32
+ SendMessage( (HWND)p_intf->p_sys->p_wxwindow->GetHandle(),
+ WM_CANCELMODE, 0, 0 );
+#endif
+ if( i_dialog_event == INTF_DIALOG_POPUPMENU && i_arg == 0 ) return;
+
/* Hack to prevent popup events to be enqueued when
* one is already active */
if( i_dialog_event != INTF_DIALOG_POPUPMENU ||