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