]> git.sesse.net Git - vlc/blob - modules/gui/wxwindows/wxwindows.h
- Fix playlist deadlock between Timer and Playlist stuff
[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_ipv6;
517
518     /* Controls for the subtitles file */
519     wxButton *subsfile_button;
520     wxCheckBox *subsfile_checkbox;
521     SubsFileDialog *subsfile_dialog;
522     wxArrayString subsfile_mrl;
523
524     /* Controls for the stream output */
525     wxButton *sout_button;
526     wxCheckBox *sout_checkbox;
527     SoutDialog *sout_dialog;
528     wxArrayString sout_mrl;
529
530     /* Controls for the caching options */
531     wxCheckBox *caching_checkbox;
532     wxSpinCtrl *caching_value;
533     int i_caching;
534 };
535
536 enum
537 {
538     FILE_ACCESS = 0,
539     DISC_ACCESS,
540     NET_ACCESS,
541
542     /* Auto-built panels */
543     CAPTURE_ACCESS
544 };
545 #define MAX_ACCESS CAPTURE_ACCESS
546
547 /* Stream output Dialog */
548 enum
549 {
550     PLAY_ACCESS_OUT = 0,
551     FILE_ACCESS_OUT,
552     HTTP_ACCESS_OUT,
553     MMSH_ACCESS_OUT,
554     UDP_ACCESS_OUT,
555     ACCESS_OUT_NUM
556 };
557
558 enum
559 {
560     TS_ENCAPSULATION = 0,
561     PS_ENCAPSULATION,
562     MPEG1_ENCAPSULATION,
563     OGG_ENCAPSULATION,
564     ASF_ENCAPSULATION,
565     MP4_ENCAPSULATION,
566     MOV_ENCAPSULATION,
567     WAV_ENCAPSULATION,
568     RAW_ENCAPSULATION,
569     AVI_ENCAPSULATION,
570     ENCAPS_NUM
571 };
572
573 enum
574 {
575     ANN_MISC_SOUT = 0,
576     MISC_SOUT_NUM
577 };
578
579 class SoutDialog: public wxDialog
580 {
581 public:
582     /* Constructor */
583     SoutDialog( intf_thread_t *p_intf, wxWindow *p_parent );
584     virtual ~SoutDialog();
585
586     wxArrayString GetOptions();
587
588 private:
589     void UpdateMRL();
590     wxPanel *AccessPanel( wxWindow* parent );
591     wxPanel *MiscPanel( wxWindow* parent );
592     wxPanel *EncapsulationPanel( wxWindow* parent );
593     wxPanel *TranscodingPanel( wxWindow* parent );
594     void    ParseMRL();
595
596     /* Event handlers (these functions should _not_ be virtual) */
597     void OnOk( wxCommandEvent& event );
598     void OnCancel( wxCommandEvent& event );
599     void OnMRLChange( wxCommandEvent& event );
600     void OnAccessTypeChange( wxCommandEvent& event );
601
602     /* Event handlers for the file access output */
603     void OnFileChange( wxCommandEvent& event );
604     void OnFileBrowse( wxCommandEvent& event );
605     void OnFileDump( wxCommandEvent& event );
606
607     /* Event handlers for the net access output */
608     void OnNetChange( wxCommandEvent& event );
609
610     /* Event specific to the announce address */
611     void OnAnnounceGroupChange( wxCommandEvent& event );
612     void OnAnnounceAddrChange( wxCommandEvent& event );
613
614     /* Event handlers for the encapsulation panel */
615     void OnEncapsulationChange( wxCommandEvent& event );
616
617     /* Event handlers for the transcoding panel */
618     void OnTranscodingEnable( wxCommandEvent& event );
619     void OnTranscodingChange( wxCommandEvent& event );
620
621     /* Event handlers for the misc panel */
622     void OnSAPMiscChange( wxCommandEvent& event );
623     void OnSLPMiscChange( wxCommandEvent& event );
624
625     DECLARE_EVENT_TABLE();
626
627     intf_thread_t *p_intf;
628     wxWindow *p_parent;
629
630     wxComboBox *mrl_combo;
631
632     /* Controls for the access outputs */
633     wxPanel *access_panel;
634     wxPanel *access_subpanels[ACCESS_OUT_NUM];
635     wxCheckBox *access_checkboxes[ACCESS_OUT_NUM];
636
637     int i_access_type;
638
639     wxComboBox *file_combo;
640     wxCheckBox *dump_checkbox;
641     wxSpinCtrl *net_ports[ACCESS_OUT_NUM];
642     wxTextCtrl *net_addrs[ACCESS_OUT_NUM];
643
644     /* Controls for the SAP announces */
645     wxPanel *misc_panel;
646     wxPanel *misc_subpanels[MISC_SOUT_NUM];
647     wxCheckBox *sap_checkbox;
648     wxCheckBox *slp_checkbox;
649     wxTextCtrl *announce_group;
650     wxTextCtrl *announce_addr;
651
652     /* Controls for the encapsulation */
653     wxPanel *encapsulation_panel;
654     wxRadioButton *encapsulation_radios[ENCAPS_NUM];
655     int i_encapsulation_type;
656
657     /* Controls for transcoding */
658     wxPanel *transcoding_panel;
659     wxCheckBox *video_transc_checkbox;
660     wxComboBox *video_codec_combo;
661     wxComboBox *audio_codec_combo;
662     wxCheckBox *audio_transc_checkbox;
663     wxComboBox *video_bitrate_combo;
664     wxComboBox *audio_bitrate_combo;
665     wxComboBox *audio_channels_combo;
666     wxComboBox *video_scale_combo;
667
668     /* Misc controls */
669     wxCheckBox *sout_all_checkbox;
670 };
671
672 /* Subtitles File Dialog */
673 class SubsFileDialog: public wxDialog
674 {
675 public:
676     /* Constructor */
677     SubsFileDialog( intf_thread_t *p_intf, wxWindow *p_parent );
678     virtual ~SubsFileDialog();
679
680     wxComboBox *file_combo;
681     wxComboBox *encoding_combo;
682     wxComboBox *size_combo;
683     wxComboBox *align_combo;
684     wxSpinCtrl *fps_spinctrl;
685     wxSpinCtrl *delay_spinctrl;
686
687 private:
688     /* Event handlers (these functions should _not_ be virtual) */
689     void OnOk( wxCommandEvent& event );
690     void OnCancel( wxCommandEvent& event );
691     void OnFileBrowse( wxCommandEvent& event );
692
693     DECLARE_EVENT_TABLE();
694
695     intf_thread_t *p_intf;
696     wxWindow *p_parent;
697 };
698
699 /* Stream */
700 class StreamDialog: public wxFrame
701 {
702 public:
703     /* Constructor */
704     StreamDialog( intf_thread_t *p_intf, wxWindow *p_parent );
705     virtual ~StreamDialog();
706
707 private:
708     void OnClose( wxCommandEvent& event );
709     void OnOpen( wxCommandEvent& event );
710     void OnSout( wxCommandEvent& event );
711     void OnStart( wxCommandEvent& event );
712
713     DECLARE_EVENT_TABLE();
714
715     intf_thread_t *p_intf;
716
717     wxStaticText *step2_label;
718     wxStaticText *step3_label;
719     wxButton *sout_button;
720     wxButton *start_button;
721     wxArrayString mrl;
722     wxArrayString sout_mrl;
723     OpenDialog *p_open_dialog;
724     SoutDialog *p_sout_dialog;
725 };
726
727 /* Wizard */
728 class WizardDialog : public wxWizard
729 {
730 public:
731     /* Constructor */
732     WizardDialog( intf_thread_t *p_intf, wxWindow *p_parent,char *, int, int );
733     virtual ~WizardDialog();
734     void SetTranscode( char *vcodec, int vb, char *acodec,int ab);
735     void SetMrl( const char *mrl );
736     void SetTTL( int i_ttl );
737     void SetPartial( int, int );
738     void SetStream( char *method, char *address );
739     void SetTranscodeOut( const char *address );
740     void SetAction( int i_action );
741     int  GetAction();
742     void SetSAP( bool b_enabled, const char *psz_name );
743     void SetMux( char *mux );
744     void Run();
745     int i_action;
746     char *method;
747
748 protected:
749     int vb,ab;
750     int i_from, i_to, i_ttl;
751     char *vcodec , *acodec , *address , *mrl , *mux ;
752     char *psz_sap_name;
753     bool b_sap;
754     DECLARE_EVENT_TABLE();
755
756     intf_thread_t *p_intf;
757 };
758
759
760 /* Preferences Dialog */
761 class PrefsDialog: public wxFrame
762 {
763 public:
764     /* Constructor */
765     PrefsDialog( intf_thread_t *p_intf, wxWindow *p_parent );
766     virtual ~PrefsDialog();
767
768 private:
769     wxPanel *PrefsPanel( wxWindow* parent );
770
771     /* Event handlers (these functions should _not_ be virtual) */
772     void OnOk( wxCommandEvent& event );
773     void OnCancel( wxCommandEvent& event );
774     void OnSave( wxCommandEvent& event );
775     void OnResetAll( wxCommandEvent& event );
776     void OnAdvanced( wxCommandEvent& event );
777
778     DECLARE_EVENT_TABLE();
779
780     intf_thread_t *p_intf;
781
782     PrefsTreeCtrl *prefs_tree;
783 };
784
785 /* Messages */
786 class Messages: public wxFrame
787 {
788 public:
789     /* Constructor */
790     Messages( intf_thread_t *p_intf, wxWindow *p_parent );
791     virtual ~Messages();
792     bool Show( bool show = TRUE );
793     void UpdateLog();
794
795 private:
796     /* Event handlers (these functions should _not_ be virtual) */
797     void OnClose( wxCommandEvent& event );
798     void OnClear( wxCommandEvent& event );
799     void OnSaveLog( wxCommandEvent& event );
800
801     DECLARE_EVENT_TABLE();
802
803     intf_thread_t *p_intf;
804     wxTextCtrl *textctrl;
805     wxTextAttr *info_attr;
806     wxTextAttr *err_attr;
807     wxTextAttr *warn_attr;
808     wxTextAttr *dbg_attr;
809
810     wxFileDialog *save_log_dialog;
811
812     vlc_bool_t b_verbose;
813 };
814
815 /* Playlist */
816 class Playlist: public wxFrame
817 {
818 public:
819     /* Constructor */
820     Playlist( intf_thread_t *p_intf, wxWindow *p_parent );
821     virtual ~Playlist();
822
823     void UpdatePlaylist();
824     void ShowPlaylist( bool show );
825     void UpdateItem( int );
826     void AppendItem( wxCommandEvent& );
827
828     bool b_need_update;
829
830 private:
831     void RemoveItem( int );
832     void DeleteItem( int item );
833     void DeleteNode( playlist_item_t *node );
834
835     /* Event handlers (these functions should _not_ be virtual) */
836
837     /* Menu Handlers */
838     void OnAddFile( wxCommandEvent& event );
839     void OnAddDir( wxCommandEvent& event );
840     void OnAddMRL( wxCommandEvent& event );
841     void OnClose( wxCommandEvent& event );
842
843     void OnEnableSelection( wxCommandEvent& event );
844     void OnDisableSelection( wxCommandEvent& event );
845     void OnInvertSelection( wxCommandEvent& event );
846     void OnDeleteSelection( wxCommandEvent& event );
847     void OnSelectAll( wxCommandEvent& event );
848
849     void OnOpen( wxCommandEvent& event );
850     void OnSave( wxCommandEvent& event );
851
852     /* Search (user) */
853     void OnSearch( wxCommandEvent& event );
854     void OnSearchTextChange( wxCommandEvent& event );
855     wxTextCtrl *search_text;
856     wxButton *search_button;
857     wxTreeItemId search_current;
858
859     void OnEnDis( wxCommandEvent& event );
860
861     /* Sort */
862     int i_sort_mode;
863     void OnSort( wxCommandEvent& event );
864     int i_title_sorted;
865     int i_group_sorted;
866     int i_duration_sorted;
867
868     /* Dynamic menus */
869     void OnMenuEvent( wxCommandEvent& event );
870     void OnMenuOpen( wxMenuEvent& event );
871     wxMenu *p_view_menu;
872     wxMenu *p_sd_menu;
873     wxMenu *ViewMenu();
874     wxMenu *SDMenu();
875
876     void OnUp( wxCommandEvent& event);
877     void OnDown( wxCommandEvent& event);
878
879     void OnRandom( wxCommandEvent& event );
880     void OnRepeat( wxCommandEvent& event );
881     void OnLoop ( wxCommandEvent& event );
882
883     void OnActivateItem( wxTreeEvent& event );
884     void OnKeyDown( wxTreeEvent& event );
885     void OnNewGroup( wxCommandEvent& event );
886
887     /* Popup  */
888     wxMenu *item_popup;
889     wxMenu *node_popup;
890     wxTreeItemId i_popup_item;
891     playlist_item_t *p_popup_item;
892     playlist_item_t *p_popup_parent;
893     void OnPopup( wxContextMenuEvent& event );
894     void OnPopupPlay( wxMenuEvent& event );
895     void OnPopupPreparse( wxMenuEvent& event );
896     void OnPopupSort( wxMenuEvent& event );
897     void OnPopupDel( wxMenuEvent& event );
898     void OnPopupEna( wxMenuEvent& event );
899     void OnPopupInfo( wxMenuEvent& event );
900     void Rebuild( vlc_bool_t );
901
902     void Preparse( playlist_t *p_playlist );
903
904     /* Update */
905     void UpdateNode( playlist_t *, playlist_item_t*, wxTreeItemId );
906     void UpdateNodeChildren( playlist_t *, playlist_item_t*, wxTreeItemId );
907     void CreateNode( playlist_t *, playlist_item_t*, wxTreeItemId );
908     void UpdateTreeItem( playlist_t *, wxTreeItemId );
909
910     /* Search (internal) */
911     int CountItems( wxTreeItemId);
912     wxTreeItemId FindItem( wxTreeItemId, playlist_item_t * );
913     wxTreeItemId FindItem( wxTreeItemId, int );
914     wxTreeItemId FindItemByName( wxTreeItemId, wxString,
915                                  wxTreeItemId, vlc_bool_t *);
916
917     wxTreeItemId saved_tree_item;
918     playlist_item_t *p_saved_item;
919
920
921     /* Custom events */
922     void OnPlaylistEvent( wxCommandEvent& event );
923
924     DECLARE_EVENT_TABLE();
925
926
927     /* Global widgets */
928     wxStatusBar *statusbar;
929     ItemInfoDialog *iteminfo_dialog;
930
931     int i_update_counter;
932
933     intf_thread_t *p_intf;
934     wxTreeCtrl *treectrl;
935     int i_current_view;
936     vlc_bool_t b_changed_view;
937     char **pp_sds;
938
939
940 };
941
942 /* ItemInfo Dialog */
943 class ItemInfoDialog: public wxDialog
944 {
945 public:
946     /* Constructor */
947     ItemInfoDialog( intf_thread_t *p_intf, playlist_item_t *_p_item,
948                     wxWindow *p_parent );
949     virtual ~ItemInfoDialog();
950
951     wxArrayString GetOptions();
952
953 private:
954     wxPanel *InfoPanel( wxWindow* parent );
955     wxPanel *GroupPanel( wxWindow* parent );
956
957     /* Event handlers (these functions should _not_ be virtual) */
958     void OnOk( wxCommandEvent& event );
959     void OnCancel( wxCommandEvent& event );
960
961     void UpdateInfo();
962
963     DECLARE_EVENT_TABLE();
964
965     intf_thread_t *p_intf;
966     playlist_item_t *p_item;
967     wxWindow *p_parent;
968
969     /* Controls for the iteminfo dialog box */
970     wxPanel *info_subpanel;
971     wxPanel *info_panel;
972
973     wxPanel *group_subpanel;
974     wxPanel *group_panel;
975
976     wxTextCtrl *uri_text;
977     wxTextCtrl *name_text;
978
979     wxTreeCtrl *info_tree;
980     wxTreeItemId info_root;
981
982 };
983
984
985 /* File Info */
986 class FileInfo: public wxFrame
987 {
988 public:
989     /* Constructor */
990     FileInfo( intf_thread_t *p_intf, wxWindow *p_parent );
991     virtual ~FileInfo();
992     void UpdateFileInfo();
993
994     vlc_bool_t b_need_update;
995
996 private:
997     void OnClose( wxCommandEvent& event );
998
999     DECLARE_EVENT_TABLE();
1000
1001     intf_thread_t *p_intf;
1002     wxTreeCtrl *fileinfo_tree;
1003     wxTreeItemId fileinfo_root;
1004     wxString fileinfo_root_label;
1005
1006 };
1007
1008 #if wxUSE_DRAG_AND_DROP
1009 /* Drag and Drop class */
1010 class DragAndDrop: public wxFileDropTarget
1011 {
1012 public:
1013     DragAndDrop( intf_thread_t *_p_intf, vlc_bool_t b_enqueue = VLC_FALSE );
1014
1015     virtual bool OnDropFiles( wxCoord x, wxCoord y,
1016                               const wxArrayString& filenames );
1017
1018 private:
1019     intf_thread_t *p_intf;
1020     vlc_bool_t b_enqueue;
1021 };
1022 #endif
1023 } // end of wxvlc namespace
1024
1025 /* */
1026 class WindowSettings
1027 {
1028 public:
1029     WindowSettings( intf_thread_t *_p_intf );
1030     virtual ~WindowSettings();
1031     enum
1032     {
1033         ID_SCREEN = -1,
1034         ID_MAIN,
1035         ID_PLAYLIST,
1036         ID_MESSAGES,
1037         ID_FILE_INFO,
1038         ID_BOOKMARKS,
1039
1040         ID_MAX,
1041     };
1042
1043     void SetSettings( int id, bool _b_shown,
1044                       wxPoint p = wxDefaultPosition, wxSize s = wxDefaultSize );
1045     bool GetSettings( int id, bool& _b_shown, wxPoint& p, wxSize& s );
1046
1047     void SetScreen( int i_screen_w, int i_screen_h );
1048
1049 private:
1050     intf_thread_t *p_intf;
1051
1052     int     i_screen_w;
1053     int     i_screen_h;
1054     bool    b_valid[ID_MAX];
1055     bool    b_shown[ID_MAX];
1056     wxPoint position[ID_MAX];
1057     wxSize  size[ID_MAX];
1058 };
1059
1060 /* Menus */
1061 void PopupMenu( intf_thread_t *, wxWindow *, const wxPoint& );
1062 wxMenu *SettingsMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
1063 wxMenu *AudioMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
1064 wxMenu *VideoMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
1065 wxMenu *NavigMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
1066
1067 namespace wxvlc
1068 {
1069 class MenuEvtHandler : public wxEvtHandler
1070 {
1071 public:
1072     MenuEvtHandler( intf_thread_t *p_intf, Interface *p_main_interface );
1073     virtual ~MenuEvtHandler();
1074
1075     void OnMenuEvent( wxCommandEvent& event );
1076     void OnShowDialog( wxCommandEvent& event );
1077
1078 private:
1079
1080     DECLARE_EVENT_TABLE()
1081
1082     intf_thread_t *p_intf;
1083     Interface *p_main_interface;
1084 };
1085
1086 } // end of wxvlc namespace
1087
1088
1089 /*
1090  * wxWindows keeps dead locking because the timer tries to lock the playlist
1091  * when it's already locked somewhere else in the very wxWindows interface
1092  * module. Unless someone implements a "vlc_mutex_trylock", we need that.
1093  */
1094 inline void LockPlaylist( intf_sys_t *p_sys, playlist_t *p_pl )
1095 {
1096     if( p_sys->i_playlist_usage++ == 0)
1097         vlc_mutex_lock( &p_pl->object_lock );
1098 }
1099
1100 inline void UnlockPlaylist( intf_sys_t *p_sys, playlist_t *p_pl )
1101 {
1102     if( --p_sys->i_playlist_usage == 0)
1103         vlc_mutex_unlock( &p_pl->object_lock );
1104 }
1105
1106 using namespace wxvlc;
1107