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