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