X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fwxwidgets%2Fwxwidgets.hpp;h=39e433b97c14c2b31d13fc246d84d8854a2f7c2c;hb=ea93da268c6617a0c5c98a2125b9aa27eba19d6d;hp=e7a10f757164fc37a4f155d612a23b12e9a9301b;hpb=b5703dcaef750542534fdd7f4d217bc03b6add1e;p=vlc diff --git a/modules/gui/wxwidgets/wxwidgets.hpp b/modules/gui/wxwidgets/wxwidgets.hpp index e7a10f7571..39e433b97c 100644 --- a/modules/gui/wxwidgets/wxwidgets.hpp +++ b/modules/gui/wxwidgets/wxwidgets.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * wxwidgets.hpp: Common headers for the wxwidges interface + * wxwidgets.hpp: Common headers for the wxwidgets interface ***************************************************************************** * Copyright (C) 1999-2005 the VideoLAN team * $Id$ @@ -21,6 +21,10 @@ * 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_ @@ -37,10 +41,10 @@ /* Let vlc take care of the i18n stuff */ #define WXINTL_NO_GETTEXT_MACRO -#include -#include -#include "charset.h" - +#include +#include +#include "vlc_charset.h" +#include #include #define SLIDER_MAX_POS 10000 @@ -88,28 +92,30 @@ DECLARE_LOCAL_EVENT_TYPE( wxEVT_INTF, 1 ); /* * wxFromLocale() is a replacement for LibVLC FromLocale() that accepts - * a wxString. It was originally introduced because wxString::mb_str() - * sucks on Linux with Unicode wxWidgets. It then turned out wxWidgets - * did not support wc_str() when Unicode was not enabled. + * a wxString. * - * But heh, that's wxWidgets; you can't really expect it to actually - * work, let alone work like its documentation says. - * - * Did it work, we would be able to catch non-ANSI characters on Windows - * through wxString::wc_str(); while they are lost when using mb_str(). - * This would be particularly useful to open files whose names contain - * non-ACP characters. + * Note that if you want to use non-ANSI code page characters on Windows, + * you MUST build WxWidgets in “Unicode” mode. wxConvUTF8 */ -#if wxUSE_UNICODE -# define wxFromLocale(wxstring) FromWide(wxstring.wc_str()) -# define wxLocaleFree(string) free(string) +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 +#if defined( wxUSE_UNICODE ) && !defined( WIN32 ) static inline char *wxDnDFromLocale( const wxChar *stupid ) { /* @@ -122,24 +128,24 @@ static inline char *wxDnDFromLocale( const wxChar *stupid ) * UTF-8 but also Windows-1252(!) and ISO-8859-15(!) or any * non-western encoding, it obviously fails. */ - size_t i = 0; - while (stupid[i]) - i++; + size_t n = 0; + while (stupid[n]) + n++; - char psz_local[i + 1]; - if ((i >= 1) && (stupid[i - 1] == '\n')) - i--; - - do + char psz_local[n + 1]; + for (size_t i = 0; i <= n; i++) psz_local[i] = stupid[i]; - while (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( string ) free( string ) +# define wxDnDLocaleFree free #else -# define wxDnDFromLocale( string ) wxFromLocale( string ) -# define wxDnDLocaleFree( string ) wxLocaleFree( string ) +# define wxDnDFromLocale wxFromLocale +# define wxDnDLocaleFree wxLocaleFree #endif #define WRAPCOUNT 80 @@ -173,8 +179,8 @@ struct intf_sys_t 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; @@ -200,7 +206,7 @@ struct intf_sys_t /* 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; @@ -219,13 +225,13 @@ wxWindow *CreateDialogsProvider( intf_thread_t *p_intf, wxWindow *p_parent ); 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