]> git.sesse.net Git - vlc/blob - modules/gui/wxwidgets/wxwindows.h
* implemented MMS-support (refs #271)
[vlc] / modules / gui / wxwidgets / 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 wxFrame *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     TTL_MISC_SOUT,
614     MISC_SOUT_NUM
615 };
616
617 class SoutDialog: public wxDialog
618 {
619 public:
620     /* Constructor */
621     SoutDialog( intf_thread_t *p_intf, wxWindow *p_parent );
622     virtual ~SoutDialog();
623
624     wxArrayString GetOptions();
625
626 private:
627     void UpdateMRL();
628     wxPanel *AccessPanel( wxWindow* parent );
629     wxPanel *MiscPanel( wxWindow* parent );
630     wxPanel *EncapsulationPanel( wxWindow* parent );
631     wxPanel *TranscodingPanel( wxWindow* parent );
632     void    ParseMRL();
633
634     /* Event handlers (these functions should _not_ be virtual) */
635     void OnOk( wxCommandEvent& event );
636     void OnCancel( wxCommandEvent& event );
637     void OnMRLChange( wxCommandEvent& event );
638     void OnAccessTypeChange( wxCommandEvent& event );
639
640     /* Event handlers for the file access output */
641     void OnFileChange( wxCommandEvent& event );
642     void OnFileBrowse( wxCommandEvent& event );
643     void OnFileDump( wxCommandEvent& event );
644
645     /* Event handlers for the net access output */
646     void OnNetChange( wxCommandEvent& event );
647
648     /* Event specific to the announce address */
649     void OnAnnounceGroupChange( wxCommandEvent& event );
650     void OnAnnounceAddrChange( wxCommandEvent& event );
651
652     /* Event handlers for the encapsulation panel */
653     void OnEncapsulationChange( wxCommandEvent& event );
654
655     /* Event handlers for the transcoding panel */
656     void OnTranscodingEnable( wxCommandEvent& event );
657     void OnTranscodingChange( wxCommandEvent& event );
658
659     /* Event handlers for the misc panel */
660     void OnSAPMiscChange( wxCommandEvent& event );
661     void OnSLPMiscChange( wxCommandEvent& event );
662
663     DECLARE_EVENT_TABLE();
664
665     intf_thread_t *p_intf;
666     wxWindow *p_parent;
667
668     wxComboBox *mrl_combo;
669
670     /* Controls for the access outputs */
671     wxPanel *access_panel;
672     wxPanel *access_subpanels[ACCESS_OUT_NUM];
673     wxCheckBox *access_checkboxes[ACCESS_OUT_NUM];
674
675     int i_access_type;
676
677     wxComboBox *file_combo;
678     wxCheckBox *dump_checkbox;
679     wxSpinCtrl *net_ports[ACCESS_OUT_NUM];
680     wxTextCtrl *net_addrs[ACCESS_OUT_NUM];
681
682     /* Controls for the SAP announces and TTL setting */
683     wxPanel *misc_panel;
684     wxPanel *misc_subpanels[MISC_SOUT_NUM];
685     wxCheckBox *sap_checkbox;
686     wxCheckBox *slp_checkbox;
687     wxTextCtrl *announce_group;
688     wxTextCtrl *announce_addr;
689     wxSpinCtrl *ttl_spin;
690
691     /* Controls for the encapsulation */
692     wxPanel *encapsulation_panel;
693     wxRadioButton *encapsulation_radios[ENCAPS_NUM];
694     int i_encapsulation_type;
695
696     /* Controls for transcoding */
697     wxPanel *transcoding_panel;
698     wxCheckBox *video_transc_checkbox;
699     wxComboBox *video_codec_combo;
700     wxComboBox *audio_codec_combo;
701     wxCheckBox *audio_transc_checkbox;
702     wxComboBox *video_bitrate_combo;
703     wxComboBox *audio_bitrate_combo;
704     wxComboBox *audio_channels_combo;
705     wxComboBox *video_scale_combo;
706     wxComboBox *subtitles_codec_combo;
707     wxCheckBox *subtitles_transc_checkbox;
708     wxCheckBox *subtitles_overlay_checkbox;
709
710     /* Misc controls */
711     wxCheckBox *sout_all_checkbox;
712 };
713
714 /* Subtitles File Dialog */
715 class SubsFileDialog: public wxDialog
716 {
717 public:
718     /* Constructor */
719     SubsFileDialog( intf_thread_t *p_intf, wxWindow *p_parent );
720     virtual ~SubsFileDialog();
721
722     wxComboBox *file_combo;
723     wxComboBox *encoding_combo;
724     wxComboBox *size_combo;
725     wxComboBox *align_combo;
726     wxSpinCtrl *fps_spinctrl;
727     wxSpinCtrl *delay_spinctrl;
728
729 private:
730     /* Event handlers (these functions should _not_ be virtual) */
731     void OnOk( wxCommandEvent& event );
732     void OnCancel( wxCommandEvent& event );
733     void OnFileBrowse( wxCommandEvent& event );
734
735     DECLARE_EVENT_TABLE();
736
737     intf_thread_t *p_intf;
738     wxWindow *p_parent;
739 };
740
741 /* Stream */
742 class StreamDialog: public wxFrame
743 {
744 public:
745     /* Constructor */
746     StreamDialog( intf_thread_t *p_intf, wxWindow *p_parent );
747     virtual ~StreamDialog();
748
749 private:
750     void OnClose( wxCommandEvent& event );
751     void OnOpen( wxCommandEvent& event );
752     void OnSout( wxCommandEvent& event );
753     void OnStart( wxCommandEvent& event );
754
755     DECLARE_EVENT_TABLE();
756
757     intf_thread_t *p_intf;
758
759     wxStaticText *step2_label;
760     wxStaticText *step3_label;
761     wxButton *sout_button;
762     wxButton *start_button;
763     wxArrayString mrl;
764     wxArrayString sout_mrl;
765     OpenDialog *p_open_dialog;
766     SoutDialog *p_sout_dialog;
767 };
768
769 /* Wizard */
770 class WizardDialog : public wxWizard
771 {
772 public:
773     /* Constructor */
774     WizardDialog( intf_thread_t *, wxWindow *p_parent, char *, int, int );
775     virtual ~WizardDialog();
776     void SetTranscode( char const *vcodec, int vb, char const *acodec, int ab);
777     void SetMrl( const char *mrl );
778     void SetTTL( int i_ttl );
779     void SetPartial( int, int );
780     void SetStream( char const *method, char const *address );
781     void SetTranscodeOut( char const *address );
782     void SetAction( int i_action );
783     int  GetAction();
784     void SetSAP( bool b_enabled, const char *psz_name );
785     void SetMux( char const *mux );
786     void Run();
787     int i_action;
788     char *method;
789
790 protected:
791     int vb,ab;
792     int i_from, i_to, i_ttl;
793     char *vcodec , *acodec , *address , *mrl , *mux ;
794     char *psz_sap_name;
795     bool b_sap;
796     DECLARE_EVENT_TABLE();
797
798     intf_thread_t *p_intf;
799 };
800
801
802 /* Preferences Dialog */
803 class PrefsDialog: public wxFrame
804 {
805 public:
806     /* Constructor */
807     PrefsDialog( intf_thread_t *p_intf, wxWindow *p_parent );
808     virtual ~PrefsDialog();
809
810 private:
811     wxPanel *PrefsPanel( wxWindow* parent );
812
813     /* Event handlers (these functions should _not_ be virtual) */
814     void OnOk( wxCommandEvent& event );
815     void OnCancel( wxCommandEvent& event );
816     void OnSave( wxCommandEvent& event );
817     void OnResetAll( wxCommandEvent& event );
818     void OnAdvanced( wxCommandEvent& event );
819     void OnClose( wxCloseEvent& event );
820
821     DECLARE_EVENT_TABLE();
822
823     intf_thread_t *p_intf;
824
825     PrefsTreeCtrl *prefs_tree;
826 };
827
828 /* Messages */
829 class Messages: public wxFrame
830 {
831 public:
832     /* Constructor */
833     Messages( intf_thread_t *p_intf, wxWindow *p_parent );
834     virtual ~Messages();
835     bool Show( bool show = TRUE );
836     void UpdateLog();
837
838 private:
839     /* Event handlers (these functions should _not_ be virtual) */
840     void OnButtonClose( wxCommandEvent& event );
841     void OnClose( wxCloseEvent& WXUNUSED(event) );
842     void OnClear( wxCommandEvent& event );
843     void OnSaveLog( wxCommandEvent& event );
844
845     DECLARE_EVENT_TABLE();
846
847     intf_thread_t *p_intf;
848     wxTextCtrl *textctrl;
849     wxTextAttr *info_attr;
850     wxTextAttr *err_attr;
851     wxTextAttr *warn_attr;
852     wxTextAttr *dbg_attr;
853
854     wxFileDialog *save_log_dialog;
855
856     vlc_bool_t b_verbose;
857 };
858
859 /* Playlist */
860 class Playlist: public wxFrame
861 {
862 public:
863     /* Constructor */
864     Playlist( intf_thread_t *p_intf, wxWindow *p_parent );
865     virtual ~Playlist();
866
867     void UpdatePlaylist();
868     void ShowPlaylist( bool show );
869     void UpdateItem( int );
870     void AppendItem( wxCommandEvent& );
871
872     bool b_need_update;
873
874 private:
875     void RemoveItem( int );
876     void DeleteTreeItem( wxTreeItemId );
877     void DeleteItem( int item );
878     void DeleteNode( playlist_item_t *node );
879
880     void RecursiveDeleteSelection( wxTreeItemId );
881
882     /* Event handlers (these functions should _not_ be virtual) */
883
884     /* Menu Handlers */
885     void OnAddFile( wxCommandEvent& event );
886     void OnAddDir( wxCommandEvent& event );
887     void OnAddMRL( wxCommandEvent& event );
888     void OnMenuClose( wxCommandEvent& event );
889     void OnClose( wxCloseEvent& WXUNUSED(event) );
890
891     void OnDeleteSelection( wxCommandEvent& event );
892
893     void OnOpen( wxCommandEvent& event );
894     void OnSave( wxCommandEvent& event );
895
896     /* Search (user) */
897     void OnSearch( wxCommandEvent& event );
898     /*void OnSearchTextChange( wxCommandEvent& event );*/
899     wxTextCtrl *search_text;
900     wxButton *search_button;
901     wxTreeItemId search_current;
902
903     void OnEnDis( wxCommandEvent& event );
904
905     /* Sort */
906     int i_sort_mode;
907     void OnSort( wxCommandEvent& event );
908     int i_title_sorted;
909     int i_group_sorted;
910     int i_duration_sorted;
911
912     /* Dynamic menus */
913     void OnMenuEvent( wxCommandEvent& event );
914     void OnMenuOpen( wxMenuEvent& event );
915     wxMenu *p_view_menu;
916     wxMenu *p_sd_menu;
917     wxMenu *ViewMenu();
918     wxMenu *SDMenu();
919
920     void OnUp( wxCommandEvent& event);
921     void OnDown( wxCommandEvent& event);
922
923     void OnRandom( wxCommandEvent& event );
924     void OnRepeat( wxCommandEvent& event );
925     void OnLoop ( wxCommandEvent& event );
926
927     void OnActivateItem( wxTreeEvent& event );
928     void OnKeyDown( wxTreeEvent& event );
929     void OnNewGroup( wxCommandEvent& event );
930
931     /* Popup  */
932     wxMenu *item_popup;
933     wxMenu *node_popup;
934     wxTreeItemId i_wx_popup_item;
935     int i_popup_item;
936     int i_popup_parent;
937     void OnPopup( wxContextMenuEvent& event );
938     void OnPopupPlay( wxCommandEvent& event );
939     void OnPopupPreparse( wxCommandEvent& event );
940     void OnPopupSort( wxCommandEvent& event );
941     void OnPopupDel( wxCommandEvent& event );
942     void OnPopupEna( wxCommandEvent& event );
943     void OnPopupInfo( wxCommandEvent& event );
944     void Rebuild( vlc_bool_t );
945
946     void Preparse();
947
948     /* Update */
949     void UpdateNode( playlist_item_t*, wxTreeItemId );
950     void UpdateNodeChildren( playlist_item_t*, wxTreeItemId );
951     void CreateNode( playlist_item_t*, wxTreeItemId );
952     void UpdateTreeItem( wxTreeItemId );
953
954     /* Search (internal) */
955     int CountItems( wxTreeItemId);
956     wxTreeItemId FindItem( wxTreeItemId, int );
957     wxTreeItemId FindItemByName( wxTreeItemId, wxString,
958                                  wxTreeItemId, vlc_bool_t *);
959
960     wxTreeItemId saved_tree_item;
961     int i_saved_id;
962
963     playlist_t *p_playlist;
964
965
966     /* Custom events */
967     void OnPlaylistEvent( wxCommandEvent& event );
968
969     DECLARE_EVENT_TABLE();
970
971
972     /* Global widgets */
973     wxStatusBar *statusbar;
974     ItemInfoDialog *iteminfo_dialog;
975
976     int i_update_counter;
977
978     intf_thread_t *p_intf;
979     wxTreeCtrl *treectrl;
980     int i_current_view;
981     vlc_bool_t b_changed_view;
982     char **pp_sds;
983
984
985 };
986
987 /* ItemInfo Dialog */
988 class ItemInfoDialog: public wxDialog
989 {
990 public:
991     /* Constructor */
992     ItemInfoDialog( intf_thread_t *p_intf, playlist_item_t *_p_item,
993                     wxWindow *p_parent );
994     virtual ~ItemInfoDialog();
995
996     wxArrayString GetOptions();
997
998 private:
999     wxPanel *InfoPanel( wxWindow* parent );
1000     wxPanel *GroupPanel( wxWindow* parent );
1001
1002     /* Event handlers (these functions should _not_ be virtual) */
1003     void OnOk( wxCommandEvent& event );
1004     void OnCancel( wxCommandEvent& event );
1005
1006     void UpdateInfo();
1007
1008     DECLARE_EVENT_TABLE();
1009
1010     intf_thread_t *p_intf;
1011     playlist_item_t *p_item;
1012     wxWindow *p_parent;
1013
1014     /* Controls for the iteminfo dialog box */
1015     wxPanel *info_subpanel;
1016     wxPanel *info_panel;
1017
1018     wxPanel *group_subpanel;
1019     wxPanel *group_panel;
1020
1021     wxTextCtrl *uri_text;
1022     wxTextCtrl *name_text;
1023
1024     wxTreeCtrl *info_tree;
1025     wxTreeItemId info_root;
1026
1027 };
1028
1029
1030 /* File Info */
1031 class FileInfo: public wxFrame
1032 {
1033 public:
1034     /* Constructor */
1035     FileInfo( intf_thread_t *p_intf, wxWindow *p_parent );
1036     virtual ~FileInfo();
1037     void UpdateFileInfo();
1038
1039     vlc_bool_t b_need_update;
1040
1041 private:
1042     void OnButtonClose( wxCommandEvent& event );
1043     void OnClose( wxCloseEvent& WXUNUSED(event) );
1044
1045     DECLARE_EVENT_TABLE();
1046
1047     intf_thread_t *p_intf;
1048     wxTreeCtrl *fileinfo_tree;
1049     wxTreeItemId fileinfo_root;
1050     wxString fileinfo_root_label;
1051
1052 };
1053
1054 /* Update VLC */
1055 class UpdateVLC: public wxFrame
1056 {
1057 public:
1058     /* Constructor */
1059     UpdateVLC( intf_thread_t *p_intf, wxWindow *p_parent );
1060     virtual ~UpdateVLC();
1061
1062 private:
1063     void OnButtonClose( wxCommandEvent& event );
1064     void OnClose( wxCloseEvent& WXUNUSED(event) );
1065     void GetData();
1066     void OnCheckForUpdate( wxCommandEvent& event );
1067     void OnMirrorChoice( wxCommandEvent& event );
1068     void UpdateUpdatesTree();
1069     void UpdateMirrorsChoice();
1070     void OnUpdatesTreeActivate( wxTreeEvent& event );
1071     void DownloadFile( wxString url, wxString dst );
1072
1073     DECLARE_EVENT_TABLE();
1074
1075     intf_thread_t *p_intf;
1076     wxTreeCtrl *updates_tree;
1077     wxTreeItemId updates_root;
1078
1079     wxChoice *mirrors_choice;
1080
1081     wxString release_type; /* could be "stable", "test", "nightly" ... */
1082
1083     struct update_file_t
1084     {
1085         wxString type;
1086         wxString md5;
1087         wxString size;
1088         wxString url;
1089         wxString description;
1090     };
1091
1092     struct update_version_t
1093     {
1094         wxString type;
1095         wxString major;
1096         wxString minor;
1097         wxString revision;
1098         wxString extra;
1099         std::list<update_file_t> m_files;
1100     };
1101
1102     std::list<update_version_t> m_versions;
1103
1104     struct update_mirror_t
1105     {
1106         wxString name;
1107         wxString location;
1108         wxString type;
1109         wxString base_url;
1110     };
1111
1112     std::list<update_mirror_t> m_mirrors;
1113 };
1114
1115 #if wxUSE_DRAG_AND_DROP
1116 /* Drag and Drop class */
1117 class DragAndDrop: public wxFileDropTarget
1118 {
1119 public:
1120     DragAndDrop( intf_thread_t *_p_intf, vlc_bool_t b_enqueue = VLC_FALSE );
1121
1122     virtual bool OnDropFiles( wxCoord x, wxCoord y,
1123                               const wxArrayString& filenames );
1124
1125 private:
1126     intf_thread_t *p_intf;
1127     vlc_bool_t b_enqueue;
1128 };
1129 #endif
1130 } // end of wxvlc namespace
1131
1132 /* */
1133 class WindowSettings
1134 {
1135 public:
1136     WindowSettings( intf_thread_t *_p_intf );
1137     virtual ~WindowSettings();
1138     enum
1139     {
1140         ID_SCREEN = -1,
1141         ID_MAIN,
1142         ID_PLAYLIST,
1143         ID_MESSAGES,
1144         ID_FILE_INFO,
1145         ID_BOOKMARKS,
1146         ID_VIDEO,
1147
1148         ID_MAX,
1149     };
1150
1151     void SetSettings( int id, bool _b_shown,
1152                       wxPoint p = wxDefaultPosition, wxSize s = wxDefaultSize );
1153     bool GetSettings( int id, bool& _b_shown, wxPoint& p, wxSize& s );
1154
1155     void SetScreen( int i_screen_w, int i_screen_h );
1156
1157 private:
1158     intf_thread_t *p_intf;
1159
1160     int     i_screen_w;
1161     int     i_screen_h;
1162     bool    b_valid[ID_MAX];
1163     bool    b_shown[ID_MAX];
1164     wxPoint position[ID_MAX];
1165     wxSize  size[ID_MAX];
1166 };
1167
1168 /* Menus */
1169 void PopupMenu( intf_thread_t *, wxWindow *, const wxPoint& );
1170 wxMenu *SettingsMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
1171 wxMenu *AudioMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
1172 wxMenu *VideoMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
1173 wxMenu *NavigMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
1174
1175 namespace wxvlc
1176 {
1177 class MenuEvtHandler : public wxEvtHandler
1178 {
1179 public:
1180     MenuEvtHandler( intf_thread_t *p_intf, Interface *p_main_interface );
1181     virtual ~MenuEvtHandler();
1182
1183     void OnMenuEvent( wxCommandEvent& event );
1184     void OnShowDialog( wxCommandEvent& event );
1185
1186 private:
1187
1188     DECLARE_EVENT_TABLE()
1189
1190     intf_thread_t *p_intf;
1191     Interface *p_main_interface;
1192 };
1193
1194 } // end of wxvlc namespace
1195
1196
1197 /*
1198  * wxWindows keeps dead locking because the timer tries to lock the playlist
1199  * when it's already locked somewhere else in the very wxWindows interface
1200  * module. Unless someone implements a "vlc_mutex_trylock", we need that.
1201  */
1202 inline void LockPlaylist( intf_sys_t *p_sys, playlist_t *p_pl )
1203 {
1204     if( p_sys->i_playlist_usage++ == 0)
1205         vlc_mutex_lock( &p_pl->object_lock );
1206 }
1207
1208 inline void UnlockPlaylist( intf_sys_t *p_sys, playlist_t *p_pl )
1209 {
1210     if( --p_sys->i_playlist_usage == 0)
1211         vlc_mutex_unlock( &p_pl->object_lock );
1212 }
1213
1214 using namespace wxvlc;
1215