]> git.sesse.net Git - vlc/blob - modules/gui/wxwindows/wxwindows.h
* modules/gui/wxwindows/*, include/vlc_interface.h: new generic "open file" dialog.
[vlc] / modules / gui / wxwindows / wxwindows.h
1 /*****************************************************************************
2  * wxwindows.h: private wxWindows interface description
3  *****************************************************************************
4  * Copyright (C) 1999, 2000 VideoLAN
5  * $Id: wxwindows.h,v 1.47 2003/07/20 10:38:49 gbazin Exp $
6  *
7  * Authors: Gildas Bazin <gbazin@netcourrier.com>
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 #include <wx/listctrl.h>
25 #include <wx/textctrl.h>
26 #include <wx/notebook.h>
27 #include <wx/spinctrl.h>
28 #include <wx/dnd.h>
29 #include <wx/treectrl.h>
30 #include <wx/gauge.h>
31
32 DECLARE_LOCAL_EVENT_TYPE( wxEVT_DIALOG, 0 );
33
34 enum
35 {
36     FILE_ACCESS,
37     DISC_ACCESS,
38     NET_ACCESS,
39     SAT_ACCESS,
40     FILE_SIMPLE_ACCESS
41 };
42
43 class OpenDialog;
44 class Playlist;
45 class Messages;
46 class FileInfo;
47
48 #define SLIDER_MAX_POS 10000
49
50 /* wxU is used to convert ansi/utf8 strings to unicode strings (wchar_t) */
51 #if defined( ENABLE_NLS ) && defined( HAVE_GETTEXT ) && \
52     defined( WIN32 ) && !defined( HAVE_INCLUDED_GETTEXT )
53 #if wxUSE_UNICODE
54 #   define wxU(utf8) wxString(utf8, wxConvUTF8)
55 #else
56 #   define wxU(utf8) wxString(wxConvUTF8.cMB2WC(utf8), *wxConvCurrent)
57 #endif
58
59 #else // ENABLE_NLS && HAVE_GETTEXT && WIN32 && !HAVE_INCLUDED_GETTEXT
60 #if wxUSE_UNICODE
61 #   define wxU(ansi) wxString(ansi, *wxConvCurrent)
62 #else
63 #   define wxU(ansi) ansi
64 #endif
65
66 #endif
67
68 #if !defined(MODULE_NAME_IS_skins)
69 /*****************************************************************************
70  * intf_sys_t: description and status of wxwindows interface
71  *****************************************************************************/
72 struct intf_sys_t
73 {
74     /* the wx parent window */
75     wxWindow            *p_wxwindow;
76     wxIcon              *p_icon;
77
78     /* special actions */
79     vlc_bool_t          b_playing;
80
81     /* The input thread */
82     input_thread_t *    p_input;
83
84     /* The slider */
85     int                 i_slider_pos;                     /* slider position */
86     int                 i_slider_oldpos;                /* previous position */
87     vlc_bool_t          b_slider_free;                      /* slider status */
88
89     /* The messages window */
90     msg_subscription_t* p_sub;                  /* message bank subscription */
91
92     /* Playlist management */
93     int                 i_playing;                 /* playlist selected item */
94
95     /* Send an event to show a dialog */
96     void (*pf_show_dialog) ( intf_thread_t *p_intf, int i_dialog, int i_arg,
97                              intf_dialog_args_t *p_arg );
98
99     /* Popup menu */
100     wxMenu              *p_popup_menu;
101
102 };
103 #endif /* !defined(MODULE_NAME_IS_skins) */
104
105 /*****************************************************************************
106  * Prototypes
107  *****************************************************************************/
108
109 /*****************************************************************************
110  * Classes declarations.
111  *****************************************************************************/
112 class Interface;
113
114 /* Timer */
115 class Timer: public wxTimer
116 {
117 public:
118     /* Constructor */
119     Timer( intf_thread_t *p_intf, Interface *p_main_interface );
120     virtual ~Timer();
121
122     virtual void Notify();
123
124 private:
125     intf_thread_t *p_intf;
126     Interface *p_main_interface;
127     int i_old_playing_status;
128     int i_old_rate;
129 };
130
131 /* Main Interface */
132 class Interface: public wxFrame
133 {
134 public:
135     /* Constructor */
136     Interface( intf_thread_t *p_intf );
137     virtual ~Interface();
138     void TogglePlayButton( int i_playing_status );
139
140     wxBoxSizer  *frame_sizer;
141     wxStatusBar *statusbar;
142
143     wxSlider    *slider;
144     wxWindow    *slider_frame;
145     wxStaticBox *slider_box;
146
147     wxGauge     *volctrl;
148
149 private:
150     void CreateOurMenuBar();
151     void CreateOurToolBar();
152     void CreateOurSlider();
153     void Open( int i_access_method );
154
155     /* Event handlers (these functions should _not_ be virtual) */
156     void OnExit( wxCommandEvent& event );
157     void OnAbout( wxCommandEvent& event );
158
159     void OnShowDialog( wxCommandEvent& event );
160
161     void OnPlayStream( wxCommandEvent& event );
162     void OnStopStream( wxCommandEvent& event );
163     void OnSliderUpdate( wxScrollEvent& event );
164     void OnPrevStream( wxCommandEvent& event );
165     void OnNextStream( wxCommandEvent& event );
166     void OnSlowStream( wxCommandEvent& event );
167     void OnFastStream( wxCommandEvent& event );
168
169     void OnMenuOpen( wxMenuEvent& event );
170
171 #if defined( __WXMSW__ ) || defined( __WXMAC__ )
172     void OnContextMenu2(wxContextMenuEvent& event);
173 #endif
174     void OnContextMenu(wxMouseEvent& event);
175
176     DECLARE_EVENT_TABLE();
177
178     Timer *timer;
179     intf_thread_t *p_intf;
180
181 private:
182     int i_old_playing_status;
183
184     /* For auto-generated menus */
185     wxMenu *p_audio_menu;
186     vlc_bool_t b_audio_menu;
187     wxMenu *p_video_menu;
188     vlc_bool_t b_video_menu;
189     wxMenu *p_navig_menu;
190     vlc_bool_t b_navig_menu;
191 };
192
193 /* Dialogs Provider */
194 class DialogsProvider: public wxFrame
195 {
196 public:
197     /* Constructor */
198     DialogsProvider( intf_thread_t *p_intf, wxWindow *p_parent );
199     virtual ~DialogsProvider();
200
201 private:
202     void Open( int i_access_method, int i_arg );
203
204     /* Event handlers (these functions should _not_ be virtual) */
205     void OnExit( wxCommandEvent& event );
206     void OnPlaylist( wxCommandEvent& event );
207     void OnMessages( wxCommandEvent& event );
208     void OnFileInfo( wxCommandEvent& event );
209     void OnPreferences( wxCommandEvent& event );
210
211     void OnOpenFileGeneric( wxCommandEvent& event );
212     void OnOpenFileSimple( wxCommandEvent& event );
213     void OnOpenFile( wxCommandEvent& event );
214     void OnOpenDisc( wxCommandEvent& event );
215     void OnOpenNet( wxCommandEvent& event );
216     void OnOpenSat( wxCommandEvent& event );
217
218     void OnPopupMenu( wxCommandEvent& event );
219
220     void OnIdle( wxIdleEvent& event );
221
222     void OnExitThread( wxCommandEvent& event );
223
224     DECLARE_EVENT_TABLE();
225
226     intf_thread_t *p_intf;
227
228 public:
229     /* Secondary windows */
230     OpenDialog          *p_open_dialog;
231     wxFileDialog        *p_file_dialog;
232     Playlist            *p_playlist_dialog;
233     Messages            *p_messages_dialog;
234     FileInfo            *p_fileinfo_dialog;
235     wxFrame             *p_prefs_dialog;
236     wxFileDialog        *p_file_generic_dialog;
237 };
238
239 /* Open Dialog */
240 class SoutDialog;
241 class SubsFileDialog;
242 class OpenDialog: public wxFrame
243 {
244 public:
245     /* Constructor */
246     OpenDialog( intf_thread_t *p_intf, wxWindow *p_parent,
247                 int i_access_method, int i_arg = 0 );
248     virtual ~OpenDialog();
249
250     int Show();
251     int Show( int i_access_method, int i_arg = 0 );
252
253     wxArrayString mrl;
254
255 private:
256     wxPanel *FilePanel( wxWindow* parent );
257     wxPanel *DiscPanel( wxWindow* parent );
258     wxPanel *NetPanel( wxWindow* parent );
259     wxPanel *SatPanel( wxWindow* parent );
260
261     void UpdateMRL( int i_access_method );
262     wxArrayString SeparateEntries( wxString );
263
264     /* Event handlers (these functions should _not_ be virtual) */
265     void OnOk( wxCommandEvent& event );
266     void OnCancel( wxCommandEvent& event );
267
268     void OnPageChange( wxNotebookEvent& event );
269     void OnMRLChange( wxCommandEvent& event );
270
271     /* Event handlers for the file page */
272     void OnFilePanelChange( wxCommandEvent& event );
273     void OnFileBrowse( wxCommandEvent& event );
274
275     /* Event handlers for the disc page */
276     void OnDiscPanelChange( wxCommandEvent& event );
277     void OnDiscTypeChange( wxCommandEvent& event );
278
279     /* Event handlers for the net page */
280     void OnNetPanelChange( wxCommandEvent& event );
281     void OnNetTypeChange( wxCommandEvent& event );
282
283     /* Event handlers for the stream output */
284     void OnSubsFileEnable( wxCommandEvent& event );
285     void OnSubsFileSettings( wxCommandEvent& WXUNUSED(event) );
286
287     /* Event handlers for the stream output */
288     void OnSoutEnable( wxCommandEvent& event );
289     void OnSoutSettings( wxCommandEvent& WXUNUSED(event) );
290
291     /* Event handlers for the demux dump */
292     void OnDemuxDumpEnable( wxCommandEvent& event );
293     void OnDemuxDumpBrowse( wxCommandEvent& event );
294     void OnDemuxDumpChange( wxCommandEvent& event );
295
296     DECLARE_EVENT_TABLE();
297
298     intf_thread_t *p_intf;
299     wxWindow *p_parent;
300     int i_current_access_method;
301
302     wxComboBox *mrl_combo;
303     wxNotebook *notebook;
304
305     /* Controls for the file panel */
306     wxComboBox *file_combo;
307     wxFileDialog *file_dialog;
308
309     /* Controls for the disc panel */
310     wxRadioBox *disc_type;
311     wxTextCtrl *disc_device;
312     wxSpinCtrl *disc_title;
313     wxSpinCtrl *disc_chapter;
314
315     /* Controls for the net panel */
316     wxRadioBox *net_type;
317     int i_net_type;
318     wxPanel *net_subpanels[4];
319     wxRadioButton *net_radios[4];
320     wxSpinCtrl *net_ports[4];
321     wxTextCtrl *net_addrs[4];
322
323     /* Controls for the subtitles file */
324     wxButton *subsfile_button;
325     wxCheckBox *subsfile_checkbox;
326     SubsFileDialog *subsfile_dialog;
327
328     /* Controls for the stream output */
329     wxButton *sout_button;
330     wxCheckBox *sout_checkbox;
331     SoutDialog *sout_dialog;
332
333     /* Controls for the demux dump */
334     wxTextCtrl *demuxdump_textctrl;
335     wxButton *demuxdump_button;
336     wxCheckBox *demuxdump_checkbox;
337     wxFileDialog *demuxdump_dialog;
338 };
339
340 /* Stream output Dialog */
341 class SoutDialog: public wxDialog
342 {
343 public:
344     /* Constructor */
345     SoutDialog( intf_thread_t *p_intf, wxWindow *p_parent );
346     virtual ~SoutDialog();
347
348     wxString mrl;
349
350 private:
351     void UpdateMRL();
352     wxPanel *AccessPanel( wxWindow* parent );
353     wxPanel *MiscPanel( wxWindow* parent );
354     wxPanel *EncapsulationPanel( wxWindow* parent );
355     wxPanel *TranscodingPanel( wxWindow* parent );
356     void    ParseMRL();
357
358     /* Event handlers (these functions should _not_ be virtual) */
359     void OnOk( wxCommandEvent& event );
360     void OnCancel( wxCommandEvent& event );
361     void OnMRLChange( wxCommandEvent& event );
362     void OnAccessTypeChange( wxCommandEvent& event );
363
364     /* Event handlers for the file access output */
365     void OnFileChange( wxCommandEvent& event );
366     void OnFileBrowse( wxCommandEvent& event );
367
368     /* Event handlers for the net access output */
369     void OnNetChange( wxCommandEvent& event );
370
371     /* Event specific to the sap address */
372     void OnSAPAddrChange( wxCommandEvent& event );
373     
374     /* Event handlers for the encapsulation panel */
375     void OnEncapsulationChange( wxCommandEvent& event );
376
377     /* Event handlers for the transcoding panel */
378     void OnTranscodingEnable( wxCommandEvent& event );
379     void OnTranscodingChange( wxCommandEvent& event );
380
381     /* Event handlers for the misc panel */
382     void OnSAPMiscChange( wxCommandEvent& event );
383
384     DECLARE_EVENT_TABLE();
385
386     intf_thread_t *p_intf;
387     wxWindow *p_parent;
388
389     wxComboBox *mrl_combo;
390
391     /* Controls for the access outputs */
392     wxPanel *access_subpanels[5];
393     wxCheckBox *access_checkboxes[5];
394
395     int i_access_type;
396
397     wxComboBox *file_combo;
398     wxSpinCtrl *net_ports[5];
399     wxTextCtrl *net_addrs[5];
400
401     /* Controls for the SAP announces */
402     wxPanel *misc_subpanels[1];
403     wxCheckBox *sap_checkbox;
404     wxTextCtrl *sap_addr;
405                             
406     /* Controls for the encapsulation */
407     wxRadioButton *encapsulation_radios[5];
408     int i_encapsulation_type;
409
410     /* Controls for transcoding */
411     wxCheckBox *video_transc_checkbox;
412     wxComboBox *video_codec_combo;
413     wxComboBox *audio_codec_combo;
414     wxCheckBox *audio_transc_checkbox;
415     wxComboBox *video_bitrate_combo;
416     wxComboBox *audio_bitrate_combo;
417     wxComboBox *audio_channels_combo;
418 };
419
420 /* Subtitles File Dialog */
421 class SubsFileDialog: public wxDialog
422 {
423 public:
424     /* Constructor */
425     SubsFileDialog( intf_thread_t *p_intf, wxWindow *p_parent );
426     virtual ~SubsFileDialog();
427
428     wxComboBox *file_combo;
429     wxSpinCtrl *delay_spinctrl;
430     wxSpinCtrl *fps_spinctrl;
431
432 private:
433     /* Event handlers (these functions should _not_ be virtual) */
434     void OnOk( wxCommandEvent& event );
435     void OnCancel( wxCommandEvent& event );
436     void OnFileBrowse( wxCommandEvent& event );
437
438     DECLARE_EVENT_TABLE();
439
440     intf_thread_t *p_intf;
441     wxWindow *p_parent;
442 };
443
444 /* Preferences Dialog */
445 class PrefsTreeCtrl;
446 class PrefsDialog: public wxFrame
447 {
448 public:
449     /* Constructor */
450     PrefsDialog( intf_thread_t *p_intf, wxWindow *p_parent );
451     virtual ~PrefsDialog();
452
453 private:
454     wxPanel *PrefsPanel( wxWindow* parent );
455
456     /* Event handlers (these functions should _not_ be virtual) */
457     void OnOk( wxCommandEvent& event );
458     void OnCancel( wxCommandEvent& event );
459     void OnSave( wxCommandEvent& event );
460     void OnResetAll( wxCommandEvent& event );
461
462     DECLARE_EVENT_TABLE();
463
464     intf_thread_t *p_intf;
465
466     PrefsTreeCtrl *prefs_tree;
467 };
468
469 /* Messages */
470 class Messages: public wxFrame
471 {
472 public:
473     /* Constructor */
474     Messages( intf_thread_t *p_intf, wxWindow *p_parent );
475     virtual ~Messages();
476     void UpdateLog();
477
478 private:
479     /* Event handlers (these functions should _not_ be virtual) */
480     void OnClose( wxCommandEvent& event );
481     void OnVerbose( wxCommandEvent& event );
482     void OnClear( wxCommandEvent& event );
483     void OnSaveLog( wxCommandEvent& event );
484
485     DECLARE_EVENT_TABLE();
486
487     intf_thread_t *p_intf;
488     wxTextCtrl *textctrl;
489     wxTextAttr *info_attr;
490     wxTextAttr *err_attr;
491     wxTextAttr *warn_attr;
492     wxTextAttr *dbg_attr;
493
494     wxFileDialog *save_log_dialog;
495     
496     vlc_bool_t b_verbose;
497 };
498
499 /* Playlist */
500 class Playlist: public wxFrame
501 {
502 public:
503     /* Constructor */
504     Playlist( intf_thread_t *p_intf, wxWindow *p_parent );
505     virtual ~Playlist();
506
507     void UpdatePlaylist();
508     void ShowPlaylist( bool show );
509
510     bool b_need_update;
511     vlc_mutex_t lock;
512
513 private:
514     void DeleteItem( int item );
515
516     /* Event handlers (these functions should _not_ be virtual) */
517     void OnAddFile( wxCommandEvent& event );
518     void OnAddMRL( wxCommandEvent& event );
519     void OnClose( wxCommandEvent& event );
520     void OnOpen( wxCommandEvent& event );
521     void OnSave( wxCommandEvent& event );
522     void OnInvertSelection( wxCommandEvent& event );
523     void OnDeleteSelection( wxCommandEvent& event );
524     void OnSelectAll( wxCommandEvent& event );
525     void OnActivateItem( wxListEvent& event );
526     void OnKeyDown( wxListEvent& event );
527     void Rebuild();
528
529     DECLARE_EVENT_TABLE();
530
531     intf_thread_t *p_intf;
532     wxListView *listview;
533     int i_update_counter;
534 };
535
536 /* File Info */
537 class FileInfo: public wxFrame
538 {
539 public:
540     /* Constructor */
541     FileInfo( intf_thread_t *p_intf, wxWindow *p_parent );
542     virtual ~FileInfo();
543     void UpdateFileInfo();
544
545 private:
546     void OnClose( wxCommandEvent& event );
547
548     DECLARE_EVENT_TABLE();
549    
550     intf_thread_t *p_intf;
551     wxTreeCtrl *fileinfo_tree;
552     wxTreeItemId fileinfo_root;
553     wxString fileinfo_root_label;
554
555 };
556
557 #if !defined(__WXX11__)
558 /* Drag and Drop class */
559 class DragAndDrop: public wxFileDropTarget
560 {
561 public:
562     DragAndDrop( intf_thread_t *_p_intf );
563
564     virtual bool OnDropFiles( wxCoord x, wxCoord y,
565                               const wxArrayString& filenames );
566
567 private:
568     intf_thread_t *p_intf;
569 };
570 #endif
571
572 /* Menus */
573 void PopupMenu( intf_thread_t *_p_intf, wxWindow *p_parent,
574                 const wxPoint& pos );
575 wxMenu *AudioMenu( intf_thread_t *_p_intf, wxWindow *p_parent );
576 wxMenu *VideoMenu( intf_thread_t *_p_intf, wxWindow *p_parent );
577 wxMenu *NavigMenu( intf_thread_t *_p_intf, wxWindow *p_parent );
578
579 class MenuEvtHandler : public wxEvtHandler
580 {
581 public:
582     MenuEvtHandler( intf_thread_t *p_intf, Interface *p_main_interface );
583     virtual ~MenuEvtHandler();
584
585     void OnMenuEvent( wxCommandEvent& event );
586     void OnShowDialog( wxCommandEvent& event );
587
588 private:
589
590     DECLARE_EVENT_TABLE()
591
592     intf_thread_t *p_intf;
593     Interface *p_main_interface;
594 };
595
596 class Menu: public wxMenu
597 {
598 public:
599     /* Constructor */
600     Menu( intf_thread_t *p_intf, wxWindow *p_parent, int i_count,
601           char **ppsz_names, int *pi_objects, int i_start_id );
602     virtual ~Menu();
603
604 private:
605     /* Event handlers (these functions should _not_ be virtual) */
606     void OnClose( wxCommandEvent& event );
607     void OnShowDialog( wxCommandEvent& event );
608     void OnEntrySelected( wxCommandEvent& event );
609
610     wxMenu *Menu::CreateDummyMenu();
611     void   Menu::CreateMenuItem( wxMenu *, char *, vlc_object_t * );
612     wxMenu *Menu::CreateChoicesMenu( char *, vlc_object_t * );
613
614     DECLARE_EVENT_TABLE();
615
616     intf_thread_t *p_intf;
617
618     int  i_item_id;
619 };