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