wxwidgets.hpp

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * wxwidgets.hpp: Common headers for the wxwidgets interface
00003  *****************************************************************************
00004  * Copyright (C) 1999-2005 the VideoLAN team
00005  * $Id$
00006  *
00007  * Authors: Gildas Bazin <gbazin@videolan.org>
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00022  *****************************************************************************/
00023 
00024 #ifdef HAVE_CONFIG_H
00025 # include "config.h"
00026 #endif
00027 
00028 #ifndef _WXVLC_WIDGETS_H_
00029 #define _WXVLC_WIDGETS_H_
00030 
00031 #ifdef WIN32                                                 /* mingw32 hack */
00032 #undef Yield
00033 #undef CreateDialog
00034 #endif
00035 
00036 #ifdef _MSC_VER
00037 // turn off 'identifier was truncated to '255' characters in the debug info'
00038 #   pragma warning( disable:4786 )
00039 #endif
00040 
00041 /* Let vlc take care of the i18n stuff */
00042 #define WXINTL_NO_GETTEXT_MACRO
00043 
00044 #include <vlc_common.h>
00045 #include <vlc_interface.h>
00046 #include "vlc_charset.h"
00047 #include <vlc_playlist.h>
00048 #include <wx/wx.h>
00049 #define SLIDER_MAX_POS 10000
00050 
00051 /*
00052 #include <wx/listctrl.h>
00053 #include <wx/textctrl.h>
00054 #include <wx/notebook.h>
00055 #include <wx/spinctrl.h>
00056 #include <wx/dnd.h>
00057 #include <wx/treectrl.h>
00058 #include <wx/gauge.h>
00059 #include <wx/accel.h>
00060 #include <wx/checkbox.h>
00061 #include <wx/wizard.h>
00062 #include <wx/taskbar.h>
00063 #include "vlc_keys.h"
00064 */
00065 #if (!wxCHECK_VERSION(2,5,0))
00066 typedef long wxTreeItemIdValue;
00067 #endif
00068 
00069 DECLARE_LOCAL_EVENT_TYPE( wxEVT_DIALOG, 0 );
00070 DECLARE_LOCAL_EVENT_TYPE( wxEVT_INTF, 1 );
00071 
00072 /***************************************************************************
00073  * I18N macros
00074  ***************************************************************************/
00075 
00076 /*
00077  * wxU() is used to convert UTF-8 strings (typically from gettext)
00078  * to unicode strings (wchar_t).
00079  */
00080 #if wxUSE_UNICODE
00081 #   define wxU(utf8) wxString(utf8, wxConvUTF8)
00082 #else
00083 #   define wxU(utf8) wxString(wxConvUTF8.cMB2WC(utf8), *wxConvCurrent)
00084 #endif
00085 
00086 /*
00087  * wxL2U() use to convert localized “data” strings (while wxU() would convert
00088  * strings from gettext messages). Nowadays, the core use UTF-8 internally
00089  * and wxL2U() is only an obsoleted name for wxU().
00090  */
00091 #define wxL2U(utf8) wxU(utf8)
00092 
00093 /*
00094  * wxFromLocale() is a replacement for LibVLC FromLocale() that accepts
00095  * a wxString.
00096  *
00097  * Note that if you want to use non-ANSI code page characters on Windows,
00098  * you MUST build WxWidgets in “Unicode” mode. wxConvUTF8
00099  */
00100 static inline char *wxFromLocale (const wxString& string)
00101 {
00102 #if defined( wxUSE_UNICODE )
00103 # if defined( WIN32 )
00104     return FromWide ((const wchar_t *)string.c_str());
00105 #  define wxLocaleFree free
00106 # else
00107     return FromLocaleDup (string.mb_str());
00108 #  define wxLocaleFree free
00109 # endif
00110 #else
00111 # warning Please use WxWidgets with Unicode.
00112     return FromLocale (string.c_str());
00113 # define wxLocaleFree LocaleFree
00114 #endif
00115 }
00116     
00117 /* From Locale functions to use for File Drop targets ... go figure */
00118 #if defined( wxUSE_UNICODE ) && !defined( WIN32 )
00119 static inline char *wxDnDFromLocale( const wxChar *stupid )
00120 {
00121     /*
00122      * In Unicode mode, wxWidgets will encode file names in the locale
00123      * encoding with each **bytes** (rather than characters) represented
00124      * by a 32 bits unsigned integer. If you are lucky enough to be using
00125      * ISO-8859-1 as your local character encoding, that lame encoding
00126      * scheme happens to be identical to UTF-32 with your arch native
00127      * byte-endianess. If you are using anything else, including not only
00128      * UTF-8 but also Windows-1252(!) and ISO-8859-15(!) or any
00129      * non-western encoding, it obviously fails.
00130      */
00131     size_t n = 0;
00132     while (stupid[n])
00133         n++;
00134 
00135     char psz_local[n + 1];
00136     for (size_t i = 0; i <= n; i++)
00137         psz_local[i] = stupid[i];
00138 
00139     // Kludge for (broken?) apps that adds a LF at the end of DnD
00140     if ((n >= 1) && (strchr ("\n\r", stupid[n - 1]) != NULL))
00141         psz_local[n - 1] = '\0';
00142 
00143     return FromLocaleDup( psz_local );
00144 }
00145 #   define wxDnDLocaleFree free
00146 #else
00147 #   define wxDnDFromLocale wxFromLocale
00148 #   define wxDnDLocaleFree wxLocaleFree
00149 #endif
00150 
00151 #define WRAPCOUNT 80
00152 
00153 #define OPEN_NORMAL 0
00154 #define OPEN_STREAM 1
00155 
00156 enum
00157 {
00158   ID_CONTROLS_TIMER,
00159   ID_SLIDER_TIMER,
00160 };
00161 
00162 namespace wxvlc {
00163     class WindowSettings;
00164     class VideoWindow;
00165 };
00166 
00167 using namespace wxvlc;
00168 
00169 /*****************************************************************************
00170  * intf_sys_t: description and status of wxwindows interface
00171  *****************************************************************************/
00172 struct intf_sys_t
00173 {
00174     /* the wx parent window */
00175     wxWindow            *p_wxwindow;
00176     wxIcon              *p_icon;
00177 
00178     /* window settings */
00179     WindowSettings      *p_window_settings;
00180 
00181     /* special actions */
00182     bool          b_playing;
00183     bool          b_intf_show;                /* interface to be shown */
00184 
00185     /* The input thread */
00186     input_thread_t *    p_input;
00187 
00188     /* The messages window */
00189     msg_subscription_t* p_sub;                  /* message bank subscription */
00190 
00191     /* Playlist management */
00192     int                 i_playing;                 /* playlist selected item */
00193     unsigned            i_playlist_usage;
00194 
00195     /* Send an event to show a dialog */
00196     void (*pf_show_dialog) ( intf_thread_t *p_intf, int i_dialog, int i_arg,
00197                              intf_dialog_args_t *p_arg );
00198 
00199     /* Popup menu */
00200     wxMenu              *p_popup_menu;
00201 
00202     /* Hotkeys */
00203     int                 i_first_hotkey_event;
00204     int                 i_hotkeys;
00205 
00206     /* Embedded vout */
00207     VideoWindow         *p_video_window;
00208     wxBoxSizer          *p_video_sizer;
00209     bool          b_video_autosize;
00210 
00211     /* Aout */
00212     aout_instance_t     *p_aout;
00213 };
00214 
00215 
00216 
00217 wxArrayString SeparateEntries( wxString );
00218 wxWindow *CreateDialogsProvider( intf_thread_t *p_intf, wxWindow *p_parent );
00219 
00220 /*
00221  * wxWindows keeps dead locking because the timer tries to lock the playlist
00222  * when it's already locked somewhere else in the very wxWindows interface
00223  * module. Unless someone implements a "vlc_mutex_trylock", we need that.
00224  */
00225 inline void LockPlaylist( intf_sys_t *p_sys, playlist_t *p_pl )
00226 {
00227     if( p_sys->i_playlist_usage++ == 0)
00228         vlc_object_lock( p_pl );
00229 }
00230 
00231 inline void UnlockPlaylist( intf_sys_t *p_sys, playlist_t *p_pl )
00232 {
00233     if( --p_sys->i_playlist_usage == 0)
00234         vlc_object_unlock( p_pl );
00235 }
00236 
00237 #endif

Generated on Wed Aug 13 08:02:38 2008 for VLC by  doxygen 1.5.1