]> git.sesse.net Git - vlc/blob - modules/gui/wxwindows/wxwindows.h
* modules/gui/wxwindows/*: enable popup menu support in the "dialogs provider".
[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.44 2003/07/17 18:58:23 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 OnPopupMenu( wxCommandEvent& event );
207
208     void OnIdle( wxIdleEvent& event );
209
210     DECLARE_EVENT_TABLE();
211
212     intf_thread_t *p_intf;
213
214 public:
215     /* Secondary windows */
216     OpenDialog          *p_open_dialog;
217     wxFileDialog        *p_file_dialog;
218     Playlist            *p_playlist_dialog;
219     Messages            *p_messages_dialog;
220     FileInfo            *p_fileinfo_dialog;
221     wxFrame             *p_prefs_dialog;
222 };
223
224 /* Open Dialog */
225 class SoutDialog;
226 class SubsFileDialog;
227 class OpenDialog: public wxFrame
228 {
229 public:
230     /* Constructor */
231     OpenDialog( intf_thread_t *p_intf, wxWindow *p_parent,
232                 int i_access_method, int i_arg = 0 );
233     virtual ~OpenDialog();
234
235     int Show();
236     int Show( int i_access_method, int i_arg = 0 );
237
238     wxArrayString mrl;
239
240 private:
241     wxPanel *FilePanel( wxWindow* parent );
242     wxPanel *DiscPanel( wxWindow* parent );
243     wxPanel *NetPanel( wxWindow* parent );
244     wxPanel *SatPanel( wxWindow* parent );
245
246     void UpdateMRL( int i_access_method );
247     wxArrayString SeparateEntries( wxString );
248
249     /* Event handlers (these functions should _not_ be virtual) */
250     void OnOk( wxCommandEvent& event );
251     void OnCancel( wxCommandEvent& event );
252
253     void OnPageChange( wxNotebookEvent& event );
254     void OnMRLChange( wxCommandEvent& event );
255
256     /* Event handlers for the file page */
257     void OnFilePanelChange( wxCommandEvent& event );
258     void OnFileBrowse( wxCommandEvent& event );
259
260     /* Event handlers for the disc page */
261     void OnDiscPanelChange( wxCommandEvent& event );
262     void OnDiscTypeChange( wxCommandEvent& event );
263
264     /* Event handlers for the net page */
265     void OnNetPanelChange( wxCommandEvent& event );
266     void OnNetTypeChange( wxCommandEvent& event );
267
268     /* Event handlers for the stream output */
269     void OnSubsFileEnable( wxCommandEvent& event );
270     void OnSubsFileSettings( wxCommandEvent& WXUNUSED(event) );
271
272     /* Event handlers for the stream output */
273     void OnSoutEnable( wxCommandEvent& event );
274     void OnSoutSettings( wxCommandEvent& WXUNUSED(event) );
275
276     /* Event handlers for the demux dump */
277     void OnDemuxDumpEnable( wxCommandEvent& event );
278     void OnDemuxDumpBrowse( wxCommandEvent& event );
279     void OnDemuxDumpChange( wxCommandEvent& event );
280
281     DECLARE_EVENT_TABLE();
282
283     intf_thread_t *p_intf;
284     wxWindow *p_parent;
285     int i_current_access_method;
286
287     wxComboBox *mrl_combo;
288     wxNotebook *notebook;
289
290     /* Controls for the file panel */
291     wxComboBox *file_combo;
292     wxFileDialog *file_dialog;
293
294     /* Controls for the disc panel */
295     wxRadioBox *disc_type;
296     wxTextCtrl *disc_device;
297     wxSpinCtrl *disc_title;
298     wxSpinCtrl *disc_chapter;
299
300     /* Controls for the net panel */
301     wxRadioBox *net_type;
302     int i_net_type;
303     wxPanel *net_subpanels[4];
304     wxRadioButton *net_radios[4];
305     wxSpinCtrl *net_ports[4];
306     wxTextCtrl *net_addrs[4];
307
308     /* Controls for the subtitles file */
309     wxButton *subsfile_button;
310     wxCheckBox *subsfile_checkbox;
311     SubsFileDialog *subsfile_dialog;
312
313     /* Controls for the stream output */
314     wxButton *sout_button;
315     wxCheckBox *sout_checkbox;
316     SoutDialog *sout_dialog;
317
318     /* Controls for the demux dump */
319     wxTextCtrl *demuxdump_textctrl;
320     wxButton *demuxdump_button;
321     wxCheckBox *demuxdump_checkbox;
322     wxFileDialog *demuxdump_dialog;
323 };
324
325 /* Stream output Dialog */
326 class SoutDialog: public wxDialog
327 {
328 public:
329     /* Constructor */
330     SoutDialog( intf_thread_t *p_intf, wxWindow *p_parent );
331     virtual ~SoutDialog();
332
333     wxString mrl;
334
335 private:
336     void UpdateMRL();
337     wxPanel *AccessPanel( wxWindow* parent );
338     wxPanel *MiscPanel( wxWindow* parent );
339     wxPanel *EncapsulationPanel( wxWindow* parent );
340     wxPanel *TranscodingPanel( wxWindow* parent );
341     void    ParseMRL();
342
343     /* Event handlers (these functions should _not_ be virtual) */
344     void OnOk( wxCommandEvent& event );
345     void OnCancel( wxCommandEvent& event );
346     void OnMRLChange( wxCommandEvent& event );
347     void OnAccessTypeChange( wxCommandEvent& event );
348
349     /* Event handlers for the file access output */
350     void OnFileChange( wxCommandEvent& event );
351     void OnFileBrowse( wxCommandEvent& event );
352
353     /* Event handlers for the net access output */
354     void OnNetChange( wxCommandEvent& event );
355
356     /* Event specific to the sap address */
357     void OnSAPAddrChange( wxCommandEvent& event );
358     
359     /* Event handlers for the encapsulation panel */
360     void OnEncapsulationChange( wxCommandEvent& event );
361
362     /* Event handlers for the transcoding panel */
363     void OnTranscodingEnable( wxCommandEvent& event );
364     void OnTranscodingChange( wxCommandEvent& event );
365
366     /* Event handlers for the misc panel */
367     void OnSAPMiscChange( wxCommandEvent& event );
368
369     DECLARE_EVENT_TABLE();
370
371     intf_thread_t *p_intf;
372     wxWindow *p_parent;
373
374     wxComboBox *mrl_combo;
375
376     /* Controls for the access outputs */
377     wxPanel *access_subpanels[5];
378     wxCheckBox *access_checkboxes[5];
379
380     int i_access_type;
381
382     wxComboBox *file_combo;
383     wxSpinCtrl *net_ports[5];
384     wxTextCtrl *net_addrs[5];
385
386     /* Controls for the SAP announces */
387     wxPanel *misc_subpanels[1];
388     wxCheckBox *sap_checkbox;
389     wxTextCtrl *sap_addr;
390                             
391     /* Controls for the encapsulation */
392     wxRadioButton *encapsulation_radios[5];
393     int i_encapsulation_type;
394
395     /* Controls for transcoding */
396     wxCheckBox *video_transc_checkbox;
397     wxComboBox *video_codec_combo;
398     wxComboBox *audio_codec_combo;
399     wxCheckBox *audio_transc_checkbox;
400     wxComboBox *video_bitrate_combo;
401     wxComboBox *audio_bitrate_combo;
402     wxComboBox *audio_channels_combo;
403 };
404
405 /* Subtitles File Dialog */
406 class SubsFileDialog: public wxDialog
407 {
408 public:
409     /* Constructor */
410     SubsFileDialog( intf_thread_t *p_intf, wxWindow *p_parent );
411     virtual ~SubsFileDialog();
412
413     wxComboBox *file_combo;
414     wxSpinCtrl *delay_spinctrl;
415     wxSpinCtrl *fps_spinctrl;
416
417 private:
418     /* Event handlers (these functions should _not_ be virtual) */
419     void OnOk( wxCommandEvent& event );
420     void OnCancel( wxCommandEvent& event );
421     void OnFileBrowse( wxCommandEvent& event );
422
423     DECLARE_EVENT_TABLE();
424
425     intf_thread_t *p_intf;
426     wxWindow *p_parent;
427 };
428
429 /* Preferences Dialog */
430 class PrefsTreeCtrl;
431 class PrefsDialog: public wxFrame
432 {
433 public:
434     /* Constructor */
435     PrefsDialog( intf_thread_t *p_intf, wxWindow *p_parent );
436     virtual ~PrefsDialog();
437
438 private:
439     wxPanel *PrefsPanel( wxWindow* parent );
440
441     /* Event handlers (these functions should _not_ be virtual) */
442     void OnOk( wxCommandEvent& event );
443     void OnCancel( wxCommandEvent& event );
444     void OnSave( wxCommandEvent& event );
445     void OnResetAll( wxCommandEvent& event );
446
447     DECLARE_EVENT_TABLE();
448
449     intf_thread_t *p_intf;
450
451     PrefsTreeCtrl *prefs_tree;
452 };
453
454 /* Messages */
455 class Messages: public wxFrame
456 {
457 public:
458     /* Constructor */
459     Messages( intf_thread_t *p_intf, wxWindow *p_parent );
460     virtual ~Messages();
461     void UpdateLog();
462
463 private:
464     /* Event handlers (these functions should _not_ be virtual) */
465     void OnClose( wxCommandEvent& event );
466     void OnVerbose( wxCommandEvent& event );
467     void OnClear( wxCommandEvent& event );
468     void OnSaveLog( wxCommandEvent& event );
469
470     DECLARE_EVENT_TABLE();
471
472     intf_thread_t *p_intf;
473     wxTextCtrl *textctrl;
474     wxTextAttr *info_attr;
475     wxTextAttr *err_attr;
476     wxTextAttr *warn_attr;
477     wxTextAttr *dbg_attr;
478
479     wxFileDialog *save_log_dialog;
480     
481     vlc_bool_t b_verbose;
482 };
483
484 /* Playlist */
485 class Playlist: public wxFrame
486 {
487 public:
488     /* Constructor */
489     Playlist( intf_thread_t *p_intf, wxWindow *p_parent );
490     virtual ~Playlist();
491
492     void UpdatePlaylist();
493     void ShowPlaylist( bool show );
494
495     bool b_need_update;
496     vlc_mutex_t lock;
497
498 private:
499     void DeleteItem( int item );
500
501     /* Event handlers (these functions should _not_ be virtual) */
502     void OnAddFile( wxCommandEvent& event );
503     void OnAddMRL( wxCommandEvent& event );
504     void OnClose( wxCommandEvent& event );
505     void OnOpen( wxCommandEvent& event );
506     void OnSave( wxCommandEvent& event );
507     void OnInvertSelection( wxCommandEvent& event );
508     void OnDeleteSelection( wxCommandEvent& event );
509     void OnSelectAll( wxCommandEvent& event );
510     void OnActivateItem( wxListEvent& event );
511     void OnKeyDown( wxListEvent& event );
512     void Rebuild();
513
514     DECLARE_EVENT_TABLE();
515
516     intf_thread_t *p_intf;
517     wxListView *listview;
518     int i_update_counter;
519 };
520
521 /* File Info */
522 class FileInfo: public wxFrame
523 {
524 public:
525     /* Constructor */
526     FileInfo( intf_thread_t *p_intf, wxWindow *p_parent );
527     virtual ~FileInfo();
528     void UpdateFileInfo();
529
530 private:
531     void OnClose( wxCommandEvent& event );
532
533     DECLARE_EVENT_TABLE();
534    
535     intf_thread_t *p_intf;
536     wxTreeCtrl *fileinfo_tree;
537     wxTreeItemId fileinfo_root;
538     wxString fileinfo_root_label;
539
540 };
541
542 #if !defined(__WXX11__)
543 /* Drag and Drop class */
544 class DragAndDrop: public wxFileDropTarget
545 {
546 public:
547     DragAndDrop( intf_thread_t *_p_intf );
548
549     virtual bool OnDropFiles( wxCoord x, wxCoord y,
550                               const wxArrayString& filenames );
551
552 private:
553     intf_thread_t *p_intf;
554 };
555 #endif
556
557 /* Menus */
558 void PopupMenu( intf_thread_t *_p_intf, wxWindow *p_parent,
559                 const wxPoint& pos );
560 wxMenu *AudioMenu( intf_thread_t *_p_intf, wxWindow *p_parent );
561 wxMenu *VideoMenu( intf_thread_t *_p_intf, wxWindow *p_parent );
562 wxMenu *NavigMenu( intf_thread_t *_p_intf, wxWindow *p_parent );
563
564 class MenuEvtHandler : public wxEvtHandler
565 {
566 public:
567     MenuEvtHandler( intf_thread_t *p_intf, Interface *p_main_interface );
568     virtual ~MenuEvtHandler();
569
570     void OnMenuEvent( wxCommandEvent& event );
571     void OnShowDialog( wxCommandEvent& event );
572
573 private:
574
575     DECLARE_EVENT_TABLE()
576
577     intf_thread_t *p_intf;
578     Interface *p_main_interface;
579 };
580
581 class Menu: public wxMenu
582 {
583 public:
584     /* Constructor */
585     Menu( intf_thread_t *p_intf, wxWindow *p_parent, int i_count,
586           char **ppsz_names, int *pi_objects, int i_start_id );
587     virtual ~Menu();
588
589 private:
590     /* Event handlers (these functions should _not_ be virtual) */
591     void OnClose( wxCommandEvent& event );
592     void OnShowDialog( wxCommandEvent& event );
593     void OnEntrySelected( wxCommandEvent& event );
594
595     wxMenu *Menu::CreateDummyMenu();
596     void   Menu::CreateMenuItem( wxMenu *, char *, vlc_object_t * );
597     wxMenu *Menu::CreateChoicesMenu( char *, vlc_object_t * );
598
599     DECLARE_EVENT_TABLE();
600
601     intf_thread_t *p_intf;
602
603     int  i_item_id;
604 };