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