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