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