/*****************************************************************************
- * wxwidgets.hpp: Common headers for the wxwidges interface
+ * wxwidgets.hpp: Common headers for the wxwidgets interface
*****************************************************************************
* Copyright (C) 1999-2005 the VideoLAN team
* $Id$
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#ifndef _WXVLC_WIDGETS_H_
#define _WXVLC_WIDGETS_H_
/* Let vlc take care of the i18n stuff */
#define WXINTL_NO_GETTEXT_MACRO
-#include <vlc/vlc.h>
-#include <vlc/intf.h>
-
+#include <vlc_common.h>
+#include <vlc_interface.h>
+#include "vlc_charset.h"
+#include <vlc_playlist.h>
#include <wx/wx.h>
#define SLIDER_MAX_POS 10000
* I18N macros
***************************************************************************/
-/* wxU is used to convert ansi/utf8 strings to unicode strings (wchar_t) */
-#if defined( ENABLE_NLS )
+/*
+ * wxU() is used to convert UTF-8 strings (typically from gettext)
+ * to unicode strings (wchar_t).
+ */
#if wxUSE_UNICODE
# define wxU(utf8) wxString(utf8, wxConvUTF8)
#else
# define wxU(utf8) wxString(wxConvUTF8.cMB2WC(utf8), *wxConvCurrent)
#endif
-#else // ENABLE_NLS
-#if wxUSE_UNICODE
-# define wxU(ansi) wxString(ansi, wxConvLocal)
-#else
-# define wxU(ansi) (ansi)
-#endif
-#endif
-/* wxL2U (locale to unicode) is used to convert ansi strings to unicode
- * strings (wchar_t) */
-#define wxL2U(ansi) wxU(ansi)
+/*
+ * wxL2U() use to convert localized “data” strings (while wxU() would convert
+ * strings from gettext messages). Nowadays, the core use UTF-8 internally
+ * and wxL2U() is only an obsoleted name for wxU().
+ */
+#define wxL2U(utf8) wxU(utf8)
-#if wxUSE_UNICODE
-# define wxFromLocale(wxstring) FromUTF32(wxstring.wc_str())
-# define wxLocaleFree(string) free(string)
+/*
+ * wxFromLocale() is a replacement for LibVLC FromLocale() that accepts
+ * a wxString.
+ *
+ * Note that if you want to use non-ANSI code page characters on Windows,
+ * you MUST build WxWidgets in “Unicode” mode. wxConvUTF8
+ */
+static inline char *wxFromLocale (const wxString& string)
+{
+#if defined( wxUSE_UNICODE )
+# if defined( WIN32 )
+ return FromWide ((const wchar_t *)string.c_str());
+# define wxLocaleFree free
+# else
+ return FromLocaleDup (string.mb_str());
+# define wxLocaleFree free
+# endif
#else
-# define wxFromLocale(wxstring) FromLocale(wxstring.mb_str())
-# define wxLocaleFree(string) LocaleFree(string)
+# warning Please use WxWidgets with Unicode.
+ return FromLocale (string.c_str());
+# define wxLocaleFree LocaleFree
#endif
-
+}
+
/* From Locale functions to use for File Drop targets ... go figure */
-#ifdef wxUSE_UNICODE
-inline const char *wxDnDFromLocale( const wxChar *stupid )
+#if defined( wxUSE_UNICODE ) && !defined( WIN32 )
+static inline char *wxDnDFromLocale( const wxChar *stupid )
{
/*
- * FIXME: this is yet another awful and ugly bug-to-bug work-around
- * for the painfully broken and brain-dead wxWidgets character
- * encoding internals. Maybe, one day the wxWidgets team will find out
- * and we will have to remove (phew) this kludge or autodetect whether
- * to trigger it (damn).
- *
* In Unicode mode, wxWidgets will encode file names in the locale
* encoding with each **bytes** (rather than characters) represented
* by a 32 bits unsigned integer. If you are lucky enough to be using
* UTF-8 but also Windows-1252(!) and ISO-8859-15(!) or any
* non-western encoding, it obviously fails.
*/
- const wxChar *braindead;
- for (braindead = stupid; *braindead; braindead++);
-
- size_t i = (braindead - stupid);
- char *psz_local = (char *)malloc( i + 1 );
- do
- psz_local[i] = (char)stupid[i];
- while (i--);
-
- const char *psz_utf8 = FromLocale( psz_local );
- free( psz_local );
- return psz_utf8;
+ size_t n = 0;
+ while (stupid[n])
+ n++;
+
+ char psz_local[n + 1];
+ for (size_t i = 0; i <= n; i++)
+ psz_local[i] = stupid[i];
+
+ // Kludge for (broken?) apps that adds a LF at the end of DnD
+ if ((n >= 1) && (strchr ("\n\r", stupid[n - 1]) != NULL))
+ psz_local[n - 1] = '\0';
+
+ return FromLocaleDup( psz_local );
}
+# define wxDnDLocaleFree free
#else
-# define wxDnDFromLocale( string ) wxFromLocale( string )
+# define wxDnDFromLocale wxFromLocale
+# define wxDnDLocaleFree wxLocaleFree
#endif
-#define wxDnDLocaleFree(string) LocaleFree( string )
#define WRAPCOUNT 80
using namespace wxvlc;
-class DialogsProvider;
-class PrefsTreeCtrl;
-class AutoBuiltPanel;
-
/*****************************************************************************
* intf_sys_t: description and status of wxwindows interface
*****************************************************************************/
WindowSettings *p_window_settings;
/* special actions */
- vlc_bool_t b_playing;
- vlc_bool_t b_intf_show; /* interface to be shown */
+ bool b_playing;
+ bool b_intf_show; /* interface to be shown */
/* The input thread */
input_thread_t * p_input;
/* Embedded vout */
VideoWindow *p_video_window;
wxBoxSizer *p_video_sizer;
- vlc_bool_t b_video_autosize;
+ bool b_video_autosize;
/* Aout */
aout_instance_t *p_aout;
inline void LockPlaylist( intf_sys_t *p_sys, playlist_t *p_pl )
{
if( p_sys->i_playlist_usage++ == 0)
- vlc_mutex_lock( &p_pl->object_lock );
+ vlc_object_lock( p_pl );
}
inline void UnlockPlaylist( intf_sys_t *p_sys, playlist_t *p_pl )
{
if( --p_sys->i_playlist_usage == 0)
- vlc_mutex_unlock( &p_pl->object_lock );
+ vlc_object_unlock( p_pl );
}
#endif