1 /*****************************************************************************
2 * wxwidgets.hpp: Common headers for the wxwidges interface
3 *****************************************************************************
4 * Copyright (C) 1999-2005 the VideoLAN team
7 * Authors: Gildas Bazin <gbazin@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #ifndef _WXVLC_WIDGETS_H_
25 #define _WXVLC_WIDGETS_H_
27 #ifdef WIN32 /* mingw32 hack */
33 // turn off 'identifier was truncated to '255' characters in the debug info'
34 # pragma warning( disable:4786 )
37 /* Let vlc take care of the i18n stuff */
38 #define WXINTL_NO_GETTEXT_MACRO
45 #define SLIDER_MAX_POS 10000
48 #include <wx/listctrl.h>
49 #include <wx/textctrl.h>
50 #include <wx/notebook.h>
51 #include <wx/spinctrl.h>
53 #include <wx/treectrl.h>
56 #include <wx/checkbox.h>
57 #include <wx/wizard.h>
58 #include <wx/taskbar.h>
61 #if (!wxCHECK_VERSION(2,5,0))
62 typedef long wxTreeItemIdValue;
65 DECLARE_LOCAL_EVENT_TYPE( wxEVT_DIALOG, 0 );
66 DECLARE_LOCAL_EVENT_TYPE( wxEVT_INTF, 1 );
68 /***************************************************************************
70 ***************************************************************************/
73 * wxU() is used to convert UTF-8 strings (typically from gettext)
74 * to unicode strings (wchar_t).
77 # define wxU(utf8) wxString(utf8, wxConvUTF8)
79 # define wxU(utf8) wxString(wxConvUTF8.cMB2WC(utf8), *wxConvCurrent)
83 * wxL2U() use to convert localized “data” strings (while wxU() would convert
84 * strings from gettext messages). Nowadays, the core use UTF-8 internally
85 * and wxL2U() is only an obsoleted name for wxU().
87 #define wxL2U(utf8) wxU(utf8)
90 * wxFromLocale() is a replacement for LibVLC FromLocale() that accepts
91 * a wxString. It was originally introduced because wxString::mb_str()
92 * sucks on Linux with Unicode wxWidgets. It then turned out wxWidgets
93 * did not support wc_str() when Unicode was not enabled.
95 * But heh, that's wxWidgets; you can't really expect it to actually
96 * work, let alone work like its documentation says.
98 * Did it work, we would be able to catch non-ANSI characters on Windows
99 * through wxString::wc_str(); while they are lost when using mb_str().
100 * This would be particularly useful to open files whose names contain
101 * non-ACP characters.
104 # define wxFromLocale(wxstring) FromWide(wxstring.wc_str())
105 # define wxLocaleFree(string) free(string)
107 # define wxFromLocale(wxstring) FromLocale(wxstring.mb_str())
108 # define wxLocaleFree(string) LocaleFree(string)
111 /* From Locale functions to use for File Drop targets ... go figure */
113 static inline char *wxDnDFromLocale( const wxChar *stupid )
116 * FIXME: this is yet another awful and ugly bug-to-bug work-around
117 * for the painfully broken and brain-dead wxWidgets character
118 * encoding internals. Maybe, one day the wxWidgets team will find out
119 * and we will have to remove (phew) this kludge or autodetect whether
120 * to trigger it (damn).
122 * In Unicode mode, wxWidgets will encode file names in the locale
123 * encoding with each **bytes** (rather than characters) represented
124 * by a 32 bits unsigned integer. If you are lucky enough to be using
125 * ISO-8859-1 as your local character encoding, that lame encoding
126 * scheme happens to be identical to UTF-32 with your arch native
127 * byte-endianess. If you are using anything else, including not only
128 * UTF-8 but also Windows-1252(!) and ISO-8859-15(!) or any
129 * non-western encoding, it obviously fails.
131 const wxChar *braindead;
132 for (braindead = stupid; *braindead; braindead++);
134 size_t i = (braindead - stupid);
135 char psz_local[i + 1];
137 psz_local[i] = (char)stupid[i];
140 return FromLocaleDup( psz_local );
142 # define wxDnDLocaleFree( string ) free( string )
144 # define wxDnDFromLocale( string ) wxFromLocale( string )
145 # define wxDnDLocaleFree( string ) wxLocaleFree( string )
150 #define OPEN_NORMAL 0
151 #define OPEN_STREAM 1
160 class WindowSettings;
164 using namespace wxvlc;
166 class DialogsProvider;
168 class AutoBuiltPanel;
170 /*****************************************************************************
171 * intf_sys_t: description and status of wxwindows interface
172 *****************************************************************************/
175 /* the wx parent window */
176 wxWindow *p_wxwindow;
179 /* window settings */
180 WindowSettings *p_window_settings;
182 /* special actions */
183 vlc_bool_t b_playing;
184 vlc_bool_t b_intf_show; /* interface to be shown */
186 /* The input thread */
187 input_thread_t * p_input;
189 /* The messages window */
190 msg_subscription_t* p_sub; /* message bank subscription */
192 /* Playlist management */
193 int i_playing; /* playlist selected item */
194 unsigned i_playlist_usage;
196 /* Send an event to show a dialog */
197 void (*pf_show_dialog) ( intf_thread_t *p_intf, int i_dialog, int i_arg,
198 intf_dialog_args_t *p_arg );
201 wxMenu *p_popup_menu;
204 int i_first_hotkey_event;
208 VideoWindow *p_video_window;
209 wxBoxSizer *p_video_sizer;
210 vlc_bool_t b_video_autosize;
213 aout_instance_t *p_aout;
218 wxArrayString SeparateEntries( wxString );
219 wxWindow *CreateDialogsProvider( intf_thread_t *p_intf, wxWindow *p_parent );
222 * wxWindows keeps dead locking because the timer tries to lock the playlist
223 * when it's already locked somewhere else in the very wxWindows interface
224 * module. Unless someone implements a "vlc_mutex_trylock", we need that.
226 inline void LockPlaylist( intf_sys_t *p_sys, playlist_t *p_pl )
228 if( p_sys->i_playlist_usage++ == 0)
229 vlc_mutex_lock( &p_pl->object_lock );
232 inline void UnlockPlaylist( intf_sys_t *p_sys, playlist_t *p_pl )
234 if( --p_sys->i_playlist_usage == 0)
235 vlc_mutex_unlock( &p_pl->object_lock );