]> git.sesse.net Git - vlc/blob - modules/gui/wxwindows/wxwindows.h
VLC update checker in the wxWidgets interface (in help menu)
[vlc] / modules / gui / wxwindows / wxwindows.h
1 /*****************************************************************************
2  * wxwindows.h: private wxWindows interface description
3  *****************************************************************************
4  * Copyright (C) 1999-2005 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Gildas Bazin <gbazin@videolan.org>
8  *
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.
13  *
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.
18  *
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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 #ifdef WIN32                                                 /* mingw32 hack */
25 #undef Yield
26 #undef CreateDialog
27 #endif
28
29 /* Let vlc take care of the i18n stuff */
30 #define WXINTL_NO_GETTEXT_MACRO
31
32 #include <list>
33
34 #include <wx/wxprec.h>
35 #include <wx/wx.h>
36
37 #include <wx/listctrl.h>
38 #include <wx/textctrl.h>
39 #include <wx/notebook.h>
40 #include <wx/spinctrl.h>
41 #include <wx/dnd.h>
42 #include <wx/treectrl.h>
43 #include <wx/gauge.h>
44 #include <wx/accel.h>
45 #include <wx/checkbox.h>
46 #include <wx/wizard.h>
47 #include <wx/taskbar.h>
48 #include "vlc_keys.h"
49
50 #if (!wxCHECK_VERSION(2,5,0))
51 typedef long wxTreeItemIdValue;
52 #endif
53
54 DECLARE_LOCAL_EVENT_TYPE( wxEVT_DIALOG, 0 );
55 DECLARE_LOCAL_EVENT_TYPE( wxEVT_INTF, 1 );
56
57 #define SLIDER_MAX_POS 10000
58
59 /* wxU is used to convert ansi/utf8 strings to unicode strings (wchar_t) */
60 #if defined( ENABLE_NLS ) && defined( ENABLE_UTF8 )
61 #if wxUSE_UNICODE
62 #   define wxU(utf8) wxString(utf8, wxConvUTF8)
63 #else
64 #   define wxU(utf8) wxString(wxConvUTF8.cMB2WC(utf8), *wxConvCurrent)
65 #endif
66 #define ISUTF8 1
67
68 #else // ENABLE_NLS && ENABLE_UTF8
69 #if wxUSE_UNICODE
70 #   define wxU(ansi) wxString(ansi, wxConvLocal)
71 #else
72 #   define wxU(ansi) (ansi)
73 #endif
74 #define ISUTF8 0
75
76 #endif
77
78 /* wxL2U (locale to unicode) is used to convert ansi strings to unicode
79  * strings (wchar_t) */
80 #define wxL2U(ansi) wxU(ansi)
81
82 #define WRAPCOUNT 80
83
84 #define OPEN_NORMAL 0
85 #define OPEN_STREAM 1
86
87 #define MODE_NONE 0
88 #define MODE_GROUP 1
89 #define MODE_AUTHOR 2
90 #define MODE_TITLE 3
91
92 enum{
93   ID_CONTROLS_TIMER,
94   ID_SLIDER_TIMER,
95 };
96
97 class DialogsProvider;
98 class PrefsTreeCtrl;
99 class AutoBuiltPanel;
100 class VideoWindow;
101 class WindowSettings;
102
103 /*****************************************************************************
104  * intf_sys_t: description and status of wxwindows interface
105  *****************************************************************************/
106 struct intf_sys_t
107 {
108     /* the wx parent window */
109     wxWindow            *p_wxwindow;
110     wxIcon              *p_icon;
111
112     /* window settings */
113     WindowSettings      *p_window_settings;
114
115     /* special actions */
116     vlc_bool_t          b_playing;
117     vlc_bool_t          b_intf_show;                /* interface to be shown */
118
119     /* The input thread */
120     input_thread_t *    p_input;
121
122     /* The slider */
123     int                 i_slider_pos;                     /* slider position */
124     int                 i_slider_oldpos;                /* previous position */
125     vlc_bool_t          b_slider_free;                      /* slider status */
126
127     /* The messages window */
128     msg_subscription_t* p_sub;                  /* message bank subscription */
129
130     /* Playlist management */
131     int                 i_playing;                 /* playlist selected item */
132     unsigned            i_playlist_usage;
133
134     /* Send an event to show a dialog */
135     void (*pf_show_dialog) ( intf_thread_t *p_intf, int i_dialog, int i_arg,
136                              intf_dialog_args_t *p_arg );
137
138     /* Popup menu */
139     wxMenu              *p_popup_menu;
140
141     /* Hotkeys */
142     int                 i_first_hotkey_event;
143     int                 i_hotkeys;
144
145     /* Embedded vout */
146     VideoWindow         *p_video_window;
147     wxBoxSizer          *p_video_sizer;
148     vlc_bool_t          b_video_autosize;
149
150     /* Aout */
151     aout_instance_t     *p_aout;
152 };
153
154 /*****************************************************************************
155  * Prototypes
156  *****************************************************************************/
157 wxArrayString SeparateEntries( wxString );
158 wxWindow *CreateVideoWindow( intf_thread_t *p_intf, wxWindow *p_parent );
159 void UpdateVideoWindow( intf_thread_t *p_intf, wxWindow *p_window );
160 wxWindow *BookmarksDialog( intf_thread_t *p_intf, wxWindow *p_parent );
161 wxWindow *CreateDialogsProvider( intf_thread_t *p_intf, wxWindow *p_parent );
162
163 namespace wxvlc
164 {
165 class Interface;
166 class OpenDialog;
167 class SoutDialog;
168 class SubsFileDialog;
169 class Playlist;
170 class Messages;
171 class FileInfo;
172 class StreamDialog;
173 class WizardDialog;
174 class ItemInfoDialog;
175 class NewGroup;
176 class ExportPlaylist;
177
178 /*****************************************************************************
179  * Classes declarations.
180  *****************************************************************************/
181 /* Timer */
182 class Timer: public wxTimer
183 {
184 public:
185     /* Constructor */
186     Timer( intf_thread_t *p_intf, Interface *p_main_interface );
187     virtual ~Timer();
188
189     virtual void Notify();
190
191 private:
192     //use wxWindow::IsShown instead
193     //vlc_bool_t b_slider_shown;
194     //vlc_bool_t b_disc_shown;
195     intf_thread_t *p_intf;
196     Interface *p_main_interface;
197     vlc_bool_t b_init;
198     int i_old_playing_status;
199     int i_old_rate;
200 };
201
202
203 /* Extended panel */
204 class ExtraPanel: public wxPanel
205 {
206 public:
207     /* Constructor */
208     ExtraPanel( intf_thread_t *p_intf, wxWindow *p_parent );
209     virtual ~ExtraPanel();
210
211     wxStaticBox *adjust_box;
212     wxButton *restoredefaults_button;
213     wxSlider *brightness_slider;
214     wxSlider *contrast_slider;
215     wxSlider *saturation_slider;
216     wxSlider *hue_slider;
217     wxSlider *gamma_slider;
218
219     wxStaticBox *other_box;
220     wxComboBox *ratio_combo;
221
222     char *psz_bands;
223     float f_preamp;
224     vlc_bool_t b_update;
225
226 private:
227
228     wxPanel *VideoPanel( wxWindow * );
229     wxPanel *EqzPanel( wxWindow * );
230     wxPanel *AudioPanel( wxWindow * );
231
232     wxNotebook *notebook;
233
234     wxCheckBox *eq_chkbox;
235
236     wxCheckBox *eq_2p_chkbox;
237
238     wxButton *eq_restoredefaults_button;
239
240     wxSlider *smooth_slider;
241     wxStaticText *smooth_text;
242
243     wxSlider *preamp_slider;
244     wxStaticText * preamp_text;
245
246     int i_smooth;
247     wxWindow *p_parent;
248
249     wxSlider *band_sliders[10];
250     wxStaticText *band_texts[10];
251
252     int i_values[10];
253
254     void CheckAout();
255
256     /* Event handlers (these functions should _not_ be virtual) */
257
258     void OnEnableAdjust( wxCommandEvent& );
259     void OnEnableEqualizer( wxCommandEvent& );
260     void OnRestoreDefaults( wxCommandEvent& );
261     void OnChangeEqualizer( wxScrollEvent& );
262     void OnAdjustUpdate( wxScrollEvent& );
263     void OnRatio( wxCommandEvent& );
264     void OnFiltersInfo( wxCommandEvent& );
265     void OnSelectFilter( wxCommandEvent& );
266
267     void OnEqSmooth( wxScrollEvent& );
268     void OnPreamp( wxScrollEvent& );
269     void OnEq2Pass( wxCommandEvent& );
270     void OnEqRestore( wxCommandEvent& );
271
272     void OnHeadphone( wxCommandEvent& );
273     void OnNormvol( wxCommandEvent& );
274     void OnNormvolSlider( wxScrollEvent& );
275
276     void OnIdle( wxIdleEvent& );
277
278     DECLARE_EVENT_TABLE();
279
280     intf_thread_t *p_intf;
281     vlc_bool_t b_my_update;
282 };
283
284 #if 0
285 /* Extended Window  */
286 class ExtraWindow: public wxFrame
287 {
288 public:
289     /* Constructor */
290     ExtraWindow( intf_thread_t *p_intf, wxWindow *p_parent, wxPanel *panel );
291     virtual ~ExtraWindow();
292
293 private:
294
295     wxPanel *panel;
296
297     DECLARE_EVENT_TABLE();
298
299     intf_thread_t *p_intf;
300 };
301 #endif
302
303 /* Systray integration */
304 #ifdef wxHAS_TASK_BAR_ICON
305 class Systray: public wxTaskBarIcon
306 {
307 public:
308     Systray( Interface* p_main_interface, intf_thread_t *p_intf );
309     virtual ~Systray() {};
310     wxMenu* CreatePopupMenu();
311     void UpdateTooltip( const wxChar* tooltip );
312
313 private:
314     void OnMenuIconize( wxCommandEvent& event );
315     void OnLeftClick( wxTaskBarIconEvent& event );
316     void OnPlayStream ( wxCommandEvent& event );
317     void OnStopStream ( wxCommandEvent& event );
318     void OnPrevStream ( wxCommandEvent& event );
319     void OnNextStream ( wxCommandEvent& event );
320     void OnExit(  wxCommandEvent& event );
321     Interface* p_main_interface;
322     intf_thread_t *p_intf;
323     DECLARE_EVENT_TABLE()
324 };
325 #endif
326
327 /* Main Interface */
328 class Interface: public wxFrame
329 {
330 public:
331     /* Constructor */
332     Interface( intf_thread_t *p_intf, long style = wxDEFAULT_FRAME_STYLE );
333     virtual ~Interface();
334     void Init();
335     void TogglePlayButton( int i_playing_status );
336     void Update();
337     void PlayStream();
338     void StopStream();
339     void PrevStream();
340     void NextStream();
341
342     wxBoxSizer  *frame_sizer;
343     wxStatusBar *statusbar;
344
345     void HideSlider(bool layout = true);
346     void ShowSlider(bool show = true, bool layout = true);
347
348     wxSlider    *slider;
349     wxWindow    *slider_frame;
350     wxBoxSizer  *slider_sizer;
351     wxPanel     *extra_frame;
352
353     void HideDiscFrame(bool layout = true);
354     void ShowDiscFrame(bool show = true, bool layout = true);
355
356     wxPanel         *disc_frame;
357     wxBoxSizer      *disc_sizer;
358     wxBitmapButton  *disc_menu_button;
359     wxBitmapButton  *disc_prev_button;
360     wxBitmapButton  *disc_next_button;
361
362     wxFrame    *extra_window;
363
364     vlc_bool_t b_extra;
365     vlc_bool_t b_undock;
366
367     wxControl  *volctrl;
368
369 #ifdef wxHAS_TASK_BAR_ICON
370     Systray     *p_systray;
371 #endif
372
373     wxTimer m_controls_timer;
374     wxTimer m_slider_timer;
375
376 private:
377     void SetupHotkeys();
378     void CreateOurMenuBar();
379     void CreateOurToolBar();
380     void CreateOurExtendedPanel();
381     void CreateOurSlider();
382     void Open( int i_access_method );
383
384     /* Event handlers (these functions should _not_ be virtual) */
385     void OnControlsTimer(wxTimerEvent& WXUNUSED(event));
386     void OnSliderTimer(wxTimerEvent& WXUNUSED(event));
387
388     void OnExit( wxCommandEvent& event );
389     void OnAbout( wxCommandEvent& event );
390
391     void OnOpenFileSimple( wxCommandEvent& event );
392     void OnOpenDir( wxCommandEvent& event );
393     void OnOpenFile( wxCommandEvent& event );
394     void OnOpenDisc( wxCommandEvent& event );
395     void OnOpenNet( wxCommandEvent& event );
396     void OnOpenSat( wxCommandEvent& event );
397
398     void OnExtended( wxCommandEvent& event );
399     //void OnUndock( wxCommandEvent& event );
400
401     void OnBookmarks( wxCommandEvent& event );
402     void OnShowDialog( wxCommandEvent& event );
403     void OnPlayStream( wxCommandEvent& event );
404     void OnStopStream( wxCommandEvent& event );
405     void OnSliderUpdate( wxScrollEvent& event );
406     void OnPrevStream( wxCommandEvent& event );
407     void OnNextStream( wxCommandEvent& event );
408     void OnSlowStream( wxCommandEvent& event );
409     void OnFastStream( wxCommandEvent& event );
410
411     void OnDiscMenu( wxCommandEvent& event );
412     void OnDiscPrev( wxCommandEvent& event );
413     void OnDiscNext( wxCommandEvent& event );
414
415     void OnMenuOpen( wxMenuEvent& event );
416
417 #if defined( __WXMSW__ ) || defined( __WXMAC__ )
418     void OnContextMenu2(wxContextMenuEvent& event);
419 #endif
420     void OnContextMenu(wxMouseEvent& event);
421
422     void OnControlEvent( wxCommandEvent& event );
423
424     DECLARE_EVENT_TABLE();
425
426     Timer *timer;
427     intf_thread_t *p_intf;
428
429     wxWindow *video_window;
430
431     int i_old_playing_status;
432
433     /* For auto-generated menus */
434     wxMenu *p_settings_menu;
435     wxMenu *p_audio_menu;
436     wxMenu *p_video_menu;
437     wxMenu *p_navig_menu;
438 };
439
440 /* Open Dialog */
441 WX_DEFINE_ARRAY(AutoBuiltPanel *, ArrayOfAutoBuiltPanel);
442 class OpenDialog: public wxDialog
443 {
444 public:
445     /* Constructor */
446     OpenDialog( intf_thread_t *p_intf, wxWindow *p_parent,
447                 int i_access_method, int i_arg = 0  );
448
449     /* Extended Contructor */
450     OpenDialog( intf_thread_t *p_intf, wxWindow *p_parent,
451                 int i_access_method, int i_arg = 0 , int _i_method = 0 );
452     virtual ~OpenDialog();
453
454     int Show();
455     int Show( int i_access_method, int i_arg = 0 );
456
457     void UpdateMRL();
458     void UpdateMRL( int i_access_method );
459
460     wxArrayString mrl;
461
462 private:
463     wxPanel *FilePanel( wxWindow* parent );
464     wxPanel *DiscPanel( wxWindow* parent );
465     wxPanel *NetPanel( wxWindow* parent );
466
467     ArrayOfAutoBuiltPanel input_tab_array;
468
469     /* Event handlers (these functions should _not_ be virtual) */
470     void OnOk( wxCommandEvent& event );
471     void OnCancel( wxCommandEvent& event );
472     void OnClose( wxCloseEvent& event );
473
474     void OnPageChange( wxNotebookEvent& event );
475     void OnMRLChange( wxCommandEvent& event );
476
477     /* Event handlers for the file page */
478     void OnFilePanelChange( wxCommandEvent& event );
479     void OnFileBrowse( wxCommandEvent& event );
480
481     /* Event handlers for the disc page */
482     void OnDiscPanelChangeSpin( wxSpinEvent& event );
483     void OnDiscPanelChange( wxCommandEvent& event );
484     void OnDiscTypeChange( wxCommandEvent& event );
485 #ifdef HAVE_LIBCDIO
486     void OnDiscProbe( wxCommandEvent& event );
487 #endif
488     void OnDiscDeviceChange( wxCommandEvent& event );
489
490     /* Event handlers for the net page */
491     void OnNetPanelChangeSpin( wxSpinEvent& event );
492     void OnNetPanelChange( wxCommandEvent& event );
493     void OnNetTypeChange( wxCommandEvent& event );
494
495     /* Event handlers for the stream output */
496     void OnSubsFileEnable( wxCommandEvent& event );
497     void OnSubsFileSettings( wxCommandEvent& WXUNUSED(event) );
498
499     /* Event handlers for the stream output */
500     void OnSoutEnable( wxCommandEvent& event );
501     void OnSoutSettings( wxCommandEvent& WXUNUSED(event) );
502
503     /* Event handlers for the caching option */
504     void OnCachingEnable( wxCommandEvent& event );
505     void OnCachingChange( wxCommandEvent& event );
506     void OnCachingChangeSpin( wxSpinEvent& event );
507
508     DECLARE_EVENT_TABLE();
509
510     intf_thread_t *p_intf;
511     wxWindow *p_parent;
512     int i_current_access_method;
513     int i_disc_type_selection;
514
515     int i_method; /* Normal or for the stream dialog ? */
516     int i_open_arg;
517
518     wxComboBox *mrl_combo;
519     wxNotebook *notebook;
520
521     /* Controls for the file panel */
522     wxComboBox *file_combo;
523     wxFileDialog *file_dialog;
524
525     /* Controls for the disc panel */
526     wxRadioBox *disc_type;
527     wxCheckBox *disc_probe;
528     wxTextCtrl *disc_device;
529     wxSpinCtrl *disc_title; int i_disc_title;
530     wxSpinCtrl *disc_chapter; int i_disc_chapter;
531     wxSpinCtrl *disc_sub; int i_disc_sub;
532     wxSpinCtrl *disc_audio; int i_disc_audio;
533
534     /* The media equivalent name for a DVD names. For example,
535      * "Title", is "Track" for a CD-DA */
536     wxStaticText *disc_title_label;
537     wxStaticText *disc_chapter_label;
538     wxStaticText *disc_sub_label;
539     wxStaticText *disc_audio_label;
540
541     /* Indicates if the disc device control was modified */
542     bool b_disc_device_changed;
543
544     /* Controls for the net panel */
545     wxRadioBox *net_type;
546     int i_net_type;
547     wxPanel *net_subpanels[4];
548     wxRadioButton *net_radios[4];
549     wxSpinCtrl *net_ports[4];
550     int        i_net_ports[4];
551     wxTextCtrl *net_addrs[4];
552     wxCheckBox *net_timeshift;
553     wxCheckBox *net_ipv6;
554
555     /* Controls for the subtitles file */
556     wxButton *subsfile_button;
557     wxCheckBox *subsfile_checkbox;
558     SubsFileDialog *subsfile_dialog;
559     wxArrayString subsfile_mrl;
560
561     /* Controls for the stream output */
562     wxButton *sout_button;
563     wxCheckBox *sout_checkbox;
564     SoutDialog *sout_dialog;
565     wxArrayString sout_mrl;
566
567     /* Controls for the caching options */
568     wxCheckBox *caching_checkbox;
569     wxSpinCtrl *caching_value;
570     int i_caching;
571 };
572
573 enum
574 {
575     FILE_ACCESS = 0,
576     DISC_ACCESS,
577     NET_ACCESS,
578
579     /* Auto-built panels */
580     CAPTURE_ACCESS
581 };
582 #define MAX_ACCESS CAPTURE_ACCESS
583
584 /* Stream output Dialog */
585 enum
586 {
587     PLAY_ACCESS_OUT = 0,
588     FILE_ACCESS_OUT,
589     HTTP_ACCESS_OUT,
590     MMSH_ACCESS_OUT,
591     UDP_ACCESS_OUT,
592     ACCESS_OUT_NUM
593 };
594
595 enum
596 {
597     TS_ENCAPSULATION = 0,
598     PS_ENCAPSULATION,
599     MPEG1_ENCAPSULATION,
600     OGG_ENCAPSULATION,
601     ASF_ENCAPSULATION,
602     MP4_ENCAPSULATION,
603     MOV_ENCAPSULATION,
604     WAV_ENCAPSULATION,
605     RAW_ENCAPSULATION,
606     AVI_ENCAPSULATION,
607     ENCAPS_NUM
608 };
609
610 enum
611 {
612     ANN_MISC_SOUT = 0,
613     MISC_SOUT_NUM
614 };
615
616 class SoutDialog: public wxDialog
617 {
618 public:
619     /* Constructor */
620     SoutDialog( intf_thread_t *p_intf, wxWindow *p_parent );
621     virtual ~SoutDialog();
622
623     wxArrayString GetOptions();
624
625 private:
626     void UpdateMRL();
627     wxPanel *AccessPanel( wxWindow* parent );
628     wxPanel *MiscPanel( wxWindow* parent );
629     wxPanel *EncapsulationPanel( wxWindow* parent );
630     wxPanel *TranscodingPanel( wxWindow* parent );
631     void    ParseMRL();
632
633     /* Event handlers (these functions should _not_ be virtual) */
634     void OnOk( wxCommandEvent& event );
635     void OnCancel( wxCommandEvent& event );
636     void OnMRLChange( wxCommandEvent& event );
637     void OnAccessTypeChange( wxCommandEvent& event );
638
639     /* Event handlers for the file access output */
640     void OnFileChange( wxCommandEvent& event );
641     void OnFileBrowse( wxCommandEvent& event );
642     void OnFileDump( wxCommandEvent& event );
643
644     /* Event handlers for the net access output */
645     void OnNetChange( wxCommandEvent& event );
646
647     /* Event specific to the announce address */
648     void OnAnnounceGroupChange( wxCommandEvent& event );
649     void OnAnnounceAddrChange( wxCommandEvent& event );
650
651     /* Event handlers for the encapsulation panel */
652     void OnEncapsulationChange( wxCommandEvent& event );
653
654     /* Event handlers for the transcoding panel */
655     void OnTranscodingEnable( wxCommandEvent& event );
656     void OnTranscodingChange( wxCommandEvent& event );
657
658     /* Event handlers for the misc panel */
659     void OnSAPMiscChange( wxCommandEvent& event );
660     void OnSLPMiscChange( wxCommandEvent& event );
661
662     DECLARE_EVENT_TABLE();
663
664     intf_thread_t *p_intf;
665     wxWindow *p_parent;
666
667     wxComboBox *mrl_combo;
668
669     /* Controls for the access outputs */
670     wxPanel *access_panel;
671     wxPanel *access_subpanels[ACCESS_OUT_NUM];
672     wxCheckBox *access_checkboxes[ACCESS_OUT_NUM];
673
674     int i_access_type;
675
676     wxComboBox *file_combo;
677     wxCheckBox *dump_checkbox;
678     wxSpinCtrl *net_ports[ACCESS_OUT_NUM];
679     wxTextCtrl *net_addrs[ACCESS_OUT_NUM];
680
681     /* Controls for the SAP announces */
682     wxPanel *misc_panel;
683     wxPanel *misc_subpanels[MISC_SOUT_NUM];
684     wxCheckBox *sap_checkbox;
685     wxCheckBox *slp_checkbox;
686     wxTextCtrl *announce_group;
687     wxTextCtrl *announce_addr;
688
689     /* Controls for the encapsulation */
690     wxPanel *encapsulation_panel;
691     wxRadioButton *encapsulation_radios[ENCAPS_NUM];
692     int i_encapsulation_type;
693
694     /* Controls for transcoding */
695     wxPanel *transcoding_panel;
696     wxCheckBox *video_transc_checkbox;
697     wxComboBox *video_codec_combo;
698     wxComboBox *audio_codec_combo;
699     wxCheckBox *audio_transc_checkbox;
700     wxComboBox *video_bitrate_combo;
701     wxComboBox *audio_bitrate_combo;
702     wxComboBox *audio_channels_combo;
703     wxComboBox *video_scale_combo;
704     wxComboBox *subtitles_codec_combo;
705     wxCheckBox *subtitles_transc_checkbox;
706     wxCheckBox *subtitles_overlay_checkbox;
707
708     /* Misc controls */
709     wxCheckBox *sout_all_checkbox;
710 };
711
712 /* Subtitles File Dialog */
713 class SubsFileDialog: public wxDialog
714 {
715 public:
716     /* Constructor */
717     SubsFileDialog( intf_thread_t *p_intf, wxWindow *p_parent );
718     virtual ~SubsFileDialog();
719
720     wxComboBox *file_combo;
721     wxComboBox *encoding_combo;
722     wxComboBox *size_combo;
723     wxComboBox *align_combo;
724     wxSpinCtrl *fps_spinctrl;
725     wxSpinCtrl *delay_spinctrl;
726
727 private:
728     /* Event handlers (these functions should _not_ be virtual) */
729     void OnOk( wxCommandEvent& event );
730     void OnCancel( wxCommandEvent& event );
731     void OnFileBrowse( wxCommandEvent& event );
732
733     DECLARE_EVENT_TABLE();
734
735     intf_thread_t *p_intf;
736     wxWindow *p_parent;
737 };
738
739 /* Stream */
740 class StreamDialog: public wxFrame
741 {
742 public:
743     /* Constructor */
744     StreamDialog( intf_thread_t *p_intf, wxWindow *p_parent );
745     virtual ~StreamDialog();
746
747 private:
748     void OnClose( wxCommandEvent& event );
749     void OnOpen( wxCommandEvent& event );
750     void OnSout( wxCommandEvent& event );
751     void OnStart( wxCommandEvent& event );
752
753     DECLARE_EVENT_TABLE();
754
755     intf_thread_t *p_intf;
756
757     wxStaticText *step2_label;
758     wxStaticText *step3_label;
759     wxButton *sout_button;
760     wxButton *start_button;
761     wxArrayString mrl;
762     wxArrayString sout_mrl;
763     OpenDialog *p_open_dialog;
764     SoutDialog *p_sout_dialog;
765 };
766
767 /* Wizard */
768 class WizardDialog : public wxWizard
769 {
770 public:
771     /* Constructor */
772     WizardDialog( intf_thread_t *, wxWindow *p_parent, char *, int, int );
773     virtual ~WizardDialog();
774     void SetTranscode( char const *vcodec, int vb, char const *acodec, int ab);
775     void SetMrl( const char *mrl );
776     void SetTTL( int i_ttl );
777     void SetPartial( int, int );
778     void SetStream( char const *method, char const *address );
779     void SetTranscodeOut( char const *address );
780     void SetAction( int i_action );
781     int  GetAction();
782     void SetSAP( bool b_enabled, const char *psz_name );
783     void SetMux( char const *mux );
784     void Run();
785     int i_action;
786     char *method;
787
788 protected:
789     int vb,ab;
790     int i_from, i_to, i_ttl;
791     char *vcodec , *acodec , *address , *mrl , *mux ;
792     char *psz_sap_name;
793     bool b_sap;
794     DECLARE_EVENT_TABLE();
795
796     intf_thread_t *p_intf;
797 };
798
799
800 /* Preferences Dialog */
801 class PrefsDialog: public wxFrame
802 {
803 public:
804     /* Constructor */
805     PrefsDialog( intf_thread_t *p_intf, wxWindow *p_parent );
806     virtual ~PrefsDialog();
807
808 private:
809     wxPanel *PrefsPanel( wxWindow* parent );
810
811     /* Event handlers (these functions should _not_ be virtual) */
812     void OnOk( wxCommandEvent& event );
813     void OnCancel( wxCommandEvent& event );
814     void OnSave( wxCommandEvent& event );
815     void OnResetAll( wxCommandEvent& event );
816     void OnAdvanced( wxCommandEvent& event );
817     void OnClose( wxCloseEvent& event );
818
819     DECLARE_EVENT_TABLE();
820
821     intf_thread_t *p_intf;
822
823     PrefsTreeCtrl *prefs_tree;
824 };
825
826 /* Messages */
827 class Messages: public wxFrame
828 {
829 public:
830     /* Constructor */
831     Messages( intf_thread_t *p_intf, wxWindow *p_parent );
832     virtual ~Messages();
833     bool Show( bool show = TRUE );
834     void UpdateLog();
835
836 private:
837     /* Event handlers (these functions should _not_ be virtual) */
838     void OnButtonClose( wxCommandEvent& event );
839     void OnClose( wxCloseEvent& WXUNUSED(event) );
840     void OnClear( wxCommandEvent& event );
841     void OnSaveLog( wxCommandEvent& event );
842
843     DECLARE_EVENT_TABLE();
844
845     intf_thread_t *p_intf;
846     wxTextCtrl *textctrl;
847     wxTextAttr *info_attr;
848     wxTextAttr *err_attr;
849     wxTextAttr *warn_attr;
850     wxTextAttr *dbg_attr;
851
852     wxFileDialog *save_log_dialog;
853
854     vlc_bool_t b_verbose;
855 };
856
857 /* Playlist */
858 class Playlist: public wxFrame
859 {
860 public:
861     /* Constructor */
862     Playlist( intf_thread_t *p_intf, wxWindow *p_parent );
863     virtual ~Playlist();
864
865     void UpdatePlaylist();
866     void ShowPlaylist( bool show );
867     void UpdateItem( int );
868     void AppendItem( wxCommandEvent& );
869
870     bool b_need_update;
871
872 private:
873     void RemoveItem( int );
874     void DeleteTreeItem( wxTreeItemId );
875     void DeleteItem( int item );
876     void DeleteNode( playlist_item_t *node );
877
878     void RecursiveDeleteSelection( wxTreeItemId );
879
880     /* Event handlers (these functions should _not_ be virtual) */
881
882     /* Menu Handlers */
883     void OnAddFile( wxCommandEvent& event );
884     void OnAddDir( wxCommandEvent& event );
885     void OnAddMRL( wxCommandEvent& event );
886     void OnMenuClose( wxCommandEvent& event );
887     void OnClose( wxCloseEvent& WXUNUSED(event) );
888
889     void OnDeleteSelection( wxCommandEvent& event );
890
891     void OnOpen( wxCommandEvent& event );
892     void OnSave( wxCommandEvent& event );
893
894     /* Search (user) */
895     void OnSearch( wxCommandEvent& event );
896     /*void OnSearchTextChange( wxCommandEvent& event );*/
897     wxTextCtrl *search_text;
898     wxButton *search_button;
899     wxTreeItemId search_current;
900
901     void OnEnDis( wxCommandEvent& event );
902
903     /* Sort */
904     int i_sort_mode;
905     void OnSort( wxCommandEvent& event );
906     int i_title_sorted;
907     int i_group_sorted;
908     int i_duration_sorted;
909
910     /* Dynamic menus */
911     void OnMenuEvent( wxCommandEvent& event );
912     void OnMenuOpen( wxMenuEvent& event );
913     wxMenu *p_view_menu;
914     wxMenu *p_sd_menu;
915     wxMenu *ViewMenu();
916     wxMenu *SDMenu();
917
918     void OnUp( wxCommandEvent& event);
919     void OnDown( wxCommandEvent& event);
920
921     void OnRandom( wxCommandEvent& event );
922     void OnRepeat( wxCommandEvent& event );
923     void OnLoop ( wxCommandEvent& event );
924
925     void OnActivateItem( wxTreeEvent& event );
926     void OnKeyDown( wxTreeEvent& event );
927     void OnNewGroup( wxCommandEvent& event );
928
929     /* Popup  */
930     wxMenu *item_popup;
931     wxMenu *node_popup;
932     wxTreeItemId i_wx_popup_item;
933     int i_popup_item;
934     int i_popup_parent;
935     void OnPopup( wxContextMenuEvent& event );
936     void OnPopupPlay( wxCommandEvent& event );
937     void OnPopupPreparse( wxCommandEvent& event );
938     void OnPopupSort( wxCommandEvent& event );
939     void OnPopupDel( wxCommandEvent& event );
940     void OnPopupEna( wxCommandEvent& event );
941     void OnPopupInfo( wxCommandEvent& event );
942     void Rebuild( vlc_bool_t );
943
944     void Preparse();
945
946     /* Update */
947     void UpdateNode( playlist_item_t*, wxTreeItemId );
948     void UpdateNodeChildren( playlist_item_t*, wxTreeItemId );
949     void CreateNode( playlist_item_t*, wxTreeItemId );
950     void UpdateTreeItem( wxTreeItemId );
951
952     /* Search (internal) */
953     int CountItems( wxTreeItemId);
954     wxTreeItemId FindItem( wxTreeItemId, int );
955     wxTreeItemId FindItemByName( wxTreeItemId, wxString,
956                                  wxTreeItemId, vlc_bool_t *);
957
958     wxTreeItemId saved_tree_item;
959     int i_saved_id;
960
961     playlist_t *p_playlist;
962
963
964     /* Custom events */
965     void OnPlaylistEvent( wxCommandEvent& event );
966
967     DECLARE_EVENT_TABLE();
968
969
970     /* Global widgets */
971     wxStatusBar *statusbar;
972     ItemInfoDialog *iteminfo_dialog;
973
974     int i_update_counter;
975
976     intf_thread_t *p_intf;
977     wxTreeCtrl *treectrl;
978     int i_current_view;
979     vlc_bool_t b_changed_view;
980     char **pp_sds;
981
982
983 };
984
985 /* ItemInfo Dialog */
986 class ItemInfoDialog: public wxDialog
987 {
988 public:
989     /* Constructor */
990     ItemInfoDialog( intf_thread_t *p_intf, playlist_item_t *_p_item,
991                     wxWindow *p_parent );
992     virtual ~ItemInfoDialog();
993
994     wxArrayString GetOptions();
995
996 private:
997     wxPanel *InfoPanel( wxWindow* parent );
998     wxPanel *GroupPanel( wxWindow* parent );
999
1000     /* Event handlers (these functions should _not_ be virtual) */
1001     void OnOk( wxCommandEvent& event );
1002     void OnCancel( wxCommandEvent& event );
1003
1004     void UpdateInfo();
1005
1006     DECLARE_EVENT_TABLE();
1007
1008     intf_thread_t *p_intf;
1009     playlist_item_t *p_item;
1010     wxWindow *p_parent;
1011
1012     /* Controls for the iteminfo dialog box */
1013     wxPanel *info_subpanel;
1014     wxPanel *info_panel;
1015
1016     wxPanel *group_subpanel;
1017     wxPanel *group_panel;
1018
1019     wxTextCtrl *uri_text;
1020     wxTextCtrl *name_text;
1021
1022     wxTreeCtrl *info_tree;
1023     wxTreeItemId info_root;
1024
1025 };
1026
1027
1028 /* File Info */
1029 class FileInfo: public wxFrame
1030 {
1031 public:
1032     /* Constructor */
1033     FileInfo( intf_thread_t *p_intf, wxWindow *p_parent );
1034     virtual ~FileInfo();
1035     void UpdateFileInfo();
1036
1037     vlc_bool_t b_need_update;
1038
1039 private:
1040     void OnButtonClose( wxCommandEvent& event );
1041     void OnClose( wxCloseEvent& WXUNUSED(event) );
1042
1043     DECLARE_EVENT_TABLE();
1044
1045     intf_thread_t *p_intf;
1046     wxTreeCtrl *fileinfo_tree;
1047     wxTreeItemId fileinfo_root;
1048     wxString fileinfo_root_label;
1049
1050 };
1051
1052 /* Update VLC */
1053 class UpdateVLC: public wxFrame
1054 {
1055 public:
1056     /* Constructor */
1057     UpdateVLC( intf_thread_t *p_intf, wxWindow *p_parent );
1058     virtual ~UpdateVLC();
1059
1060 private:
1061     void OnButtonClose( wxCommandEvent& event );
1062     void OnClose( wxCloseEvent& WXUNUSED(event) );
1063     void GetData();
1064     void OnCheckForUpdate( wxCommandEvent& event );
1065     void OnMirrorChoice( wxCommandEvent& event );
1066     void UpdateUpdatesTree();
1067     void UpdateMirrorsChoice();
1068     void OnUpdatesTreeActivate( wxTreeEvent& event );
1069     void DownloadFile( wxString url, wxString dst );
1070
1071     DECLARE_EVENT_TABLE();
1072
1073     intf_thread_t *p_intf;
1074     wxTreeCtrl *updates_tree;
1075     wxTreeItemId updates_root;
1076
1077     wxChoice *mirrors_choice;
1078
1079     wxString release_type; /* could be "stable", "test", "nightly" ... */
1080
1081     struct update_file_t
1082     {
1083         wxString type;
1084         wxString md5;
1085         wxString size;
1086         wxString url;
1087         wxString description;
1088     };
1089
1090     struct update_version_t
1091     {
1092         wxString type;
1093         wxString major;
1094         wxString minor;
1095         wxString revision;
1096         wxString extra;
1097         std::list<update_file_t> m_files;
1098     };
1099
1100     std::list<update_version_t> m_versions;
1101
1102     struct update_mirror_t
1103     {
1104         wxString name;
1105         wxString location;
1106         wxString type;
1107         wxString base_url;
1108     };
1109
1110     std::list<update_mirror_t> m_mirrors;
1111 };
1112
1113 #if wxUSE_DRAG_AND_DROP
1114 /* Drag and Drop class */
1115 class DragAndDrop: public wxFileDropTarget
1116 {
1117 public:
1118     DragAndDrop( intf_thread_t *_p_intf, vlc_bool_t b_enqueue = VLC_FALSE );
1119
1120     virtual bool OnDropFiles( wxCoord x, wxCoord y,
1121                               const wxArrayString& filenames );
1122
1123 private:
1124     intf_thread_t *p_intf;
1125     vlc_bool_t b_enqueue;
1126 };
1127 #endif
1128 } // end of wxvlc namespace
1129
1130 /* */
1131 class WindowSettings
1132 {
1133 public:
1134     WindowSettings( intf_thread_t *_p_intf );
1135     virtual ~WindowSettings();
1136     enum
1137     {
1138         ID_SCREEN = -1,
1139         ID_MAIN,
1140         ID_PLAYLIST,
1141         ID_MESSAGES,
1142         ID_FILE_INFO,
1143         ID_BOOKMARKS,
1144         ID_VIDEO,
1145
1146         ID_MAX,
1147     };
1148
1149     void SetSettings( int id, bool _b_shown,
1150                       wxPoint p = wxDefaultPosition, wxSize s = wxDefaultSize );
1151     bool GetSettings( int id, bool& _b_shown, wxPoint& p, wxSize& s );
1152
1153     void SetScreen( int i_screen_w, int i_screen_h );
1154
1155 private:
1156     intf_thread_t *p_intf;
1157
1158     int     i_screen_w;
1159     int     i_screen_h;
1160     bool    b_valid[ID_MAX];
1161     bool    b_shown[ID_MAX];
1162     wxPoint position[ID_MAX];
1163     wxSize  size[ID_MAX];
1164 };
1165
1166 /* Menus */
1167 void PopupMenu( intf_thread_t *, wxWindow *, const wxPoint& );
1168 wxMenu *SettingsMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
1169 wxMenu *AudioMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
1170 wxMenu *VideoMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
1171 wxMenu *NavigMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
1172
1173 namespace wxvlc
1174 {
1175 class MenuEvtHandler : public wxEvtHandler
1176 {
1177 public:
1178     MenuEvtHandler( intf_thread_t *p_intf, Interface *p_main_interface );
1179     virtual ~MenuEvtHandler();
1180
1181     void OnMenuEvent( wxCommandEvent& event );
1182     void OnShowDialog( wxCommandEvent& event );
1183
1184 private:
1185
1186     DECLARE_EVENT_TABLE()
1187
1188     intf_thread_t *p_intf;
1189     Interface *p_main_interface;
1190 };
1191
1192 } // end of wxvlc namespace
1193
1194
1195 /*
1196  * wxWindows keeps dead locking because the timer tries to lock the playlist
1197  * when it's already locked somewhere else in the very wxWindows interface
1198  * module. Unless someone implements a "vlc_mutex_trylock", we need that.
1199  */
1200 inline void LockPlaylist( intf_sys_t *p_sys, playlist_t *p_pl )
1201 {
1202     if( p_sys->i_playlist_usage++ == 0)
1203         vlc_mutex_lock( &p_pl->object_lock );
1204 }
1205
1206 inline void UnlockPlaylist( intf_sys_t *p_sys, playlist_t *p_pl )
1207 {
1208     if( --p_sys->i_playlist_usage == 0)
1209         vlc_mutex_unlock( &p_pl->object_lock );
1210 }
1211
1212 using namespace wxvlc;
1213