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