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