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