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