]> git.sesse.net Git - vlc/blob - modules/gui/wxwindows/wxwindows.h
* modules/gui/wxwindows/*: new subtitles file 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.24 2003/05/13 22:33:33 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 };
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     wxMenu      *p_popup_menu;
137
138     wxArrayString mrl_history;
139
140 private:
141     void CreateOurMenuBar();
142     void CreateOurToolBar();
143     void CreateOurSlider();
144     void Open( int i_access_method );
145
146     /* Event handlers (these functions should _not_ be virtual) */
147     void OnExit( wxCommandEvent& event );
148     void OnAbout( wxCommandEvent& event );
149     void OnMessages( wxCommandEvent& event );
150     void OnPlaylist( wxCommandEvent& event );
151     void OnLogs( wxCommandEvent& event );
152     void OnFileInfo( wxCommandEvent& event );
153     void OnPreferences( wxCommandEvent& event );
154
155     void OnOpenFile( wxCommandEvent& event );
156     void OnOpenDisc( wxCommandEvent& event );
157     void OnOpenNet( wxCommandEvent& event );
158     void OnOpenSat( 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
166     void OnMenuOpen( wxMenuEvent& event );
167
168 #if defined( __WXMSW__ ) || defined( __WXMAC__ )
169     void OnContextMenu(wxContextMenuEvent& event);
170 #else
171     void OnContextMenu(wxMouseEvent& event);
172 #endif
173
174     DECLARE_EVENT_TABLE();
175
176     Timer *timer;
177     intf_thread_t *p_intf;
178
179     wxFrame *p_prefs_dialog;
180
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 };
189
190 /* Open Dialog */
191 class OpenDialog: public wxDialog
192 {
193 public:
194     /* Constructor */
195     OpenDialog( intf_thread_t *p_intf, wxWindow *p_parent,
196                 int i_access_method );
197     virtual ~OpenDialog();
198
199     wxString mrl;
200
201 private:
202     wxPanel *FilePanel( wxWindow* parent );
203     wxPanel *DiscPanel( wxWindow* parent );
204     wxPanel *NetPanel( wxWindow* parent );
205     wxPanel *SatPanel( wxWindow* parent );
206
207     void UpdateMRL( int i_access_method );
208
209     /* Event handlers (these functions should _not_ be virtual) */
210     void OnOk( wxCommandEvent& event );
211     void OnCancel( wxCommandEvent& event );
212
213     void OnPageChange( wxNotebookEvent& event );
214     void OnMRLChange( wxCommandEvent& event );
215
216     /* Event handlers for the file page */
217     void OnFilePanelChange( wxCommandEvent& event );
218     void OnFileBrowse( wxCommandEvent& event );
219
220     /* Event handlers for the disc page */
221     void OnDiscPanelChange( wxCommandEvent& event );
222     void OnDiscTypeChange( wxCommandEvent& event );
223
224     /* Event handlers for the net page */
225     void OnNetPanelChange( wxCommandEvent& event );
226     void OnNetTypeChange( wxCommandEvent& event );
227
228     /* Event handlers for the stream output */
229     void OnSubsFileEnable( wxCommandEvent& event );
230     void OnSubsFileSettings( wxCommandEvent& WXUNUSED(event) );
231
232     /* Event handlers for the stream output */
233     void OnSoutEnable( wxCommandEvent& event );
234     void OnSoutSettings( wxCommandEvent& WXUNUSED(event) );
235
236     /* Event handlers for the demux dump */
237     void OnDemuxDumpEnable( wxCommandEvent& event );
238     void OnDemuxDumpBrowse( wxCommandEvent& event );
239     void OnDemuxDumpChange( wxCommandEvent& event );
240
241     DECLARE_EVENT_TABLE();
242
243     intf_thread_t *p_intf;
244     wxWindow *p_parent;
245     int i_current_access_method;
246
247     wxComboBox *mrl_combo;
248
249     /* Controls for the file panel */
250     wxComboBox *file_combo;
251
252     /* Controls for the disc panel */
253     wxRadioBox *disc_type;
254     wxTextCtrl *disc_device;
255     wxSpinCtrl *disc_title;
256     wxSpinCtrl *disc_chapter;
257
258     /* Controls for the net panel */
259     wxRadioBox *net_type;
260     int i_net_type;
261     wxPanel *net_subpanels[4];
262     wxRadioButton *net_radios[4];
263     wxSpinCtrl *net_ports[4];
264     wxTextCtrl *net_addrs[4];
265
266     /* Controls for the subtitles file */
267     wxButton *subsfile_button;
268     wxCheckBox *subsfile_checkbox;
269
270     /* Controls for the stream output */
271     wxButton *sout_button;
272     wxCheckBox *sout_checkbox;
273
274     /* Controls for the demux dump */
275     wxTextCtrl *demuxdump_textctrl;
276     wxButton *demuxdump_button;
277     wxCheckBox *demuxdump_checkbox;
278 };
279
280 enum
281 {
282     FILE_ACCESS = 0,
283     DISC_ACCESS,
284     NET_ACCESS,
285     SAT_ACCESS
286 };
287
288 /* Stream output Dialog */
289 class SoutDialog: public wxDialog
290 {
291 public:
292     /* Constructor */
293     SoutDialog( intf_thread_t *p_intf, wxWindow *p_parent );
294     virtual ~SoutDialog();
295
296     wxString mrl;
297
298 private:
299     void UpdateMRL();
300     wxPanel *AccessPanel( wxWindow* parent );
301     wxPanel *EncapsulationPanel( wxWindow* parent );
302     void    ParseMRL();
303
304     /* Event handlers (these functions should _not_ be virtual) */
305     void OnOk( wxCommandEvent& event );
306     void OnCancel( wxCommandEvent& event );
307     void OnMRLChange( wxCommandEvent& event );
308     void OnAccessTypeChange( wxCommandEvent& event );
309
310     /* Event handlers for the file access output */
311     void OnFileChange( wxCommandEvent& event );
312     void OnFileBrowse( wxCommandEvent& event );
313
314     /* Event handlers for the net access output */
315     void OnNetChange( wxCommandEvent& event );
316
317     /* Event handlers for the encapsulation panel */
318     void OnEncapsulationChange( wxCommandEvent& event );
319
320     DECLARE_EVENT_TABLE();
321
322     intf_thread_t *p_intf;
323     wxWindow *p_parent;
324
325     wxComboBox *mrl_combo;
326     wxPanel *access_panel;
327     wxPanel *encapsulation_panel;
328
329     /* Controls for the access outputs */
330     wxPanel *access_subpanels[4];
331     wxRadioButton *access_radios[4];
332
333     int i_access_type;
334
335     wxComboBox *file_combo;
336     wxSpinCtrl *net_port;
337     wxTextCtrl *net_addr;
338
339     /* Controls for the encapsulation */
340     wxRadioButton *encapsulation_radios[4];
341     int i_encapsulation_type;
342
343 };
344
345 /* Subtitles File Dialog */
346 class SubsFileDialog: public wxDialog
347 {
348 public:
349     /* Constructor */
350     SubsFileDialog( intf_thread_t *p_intf, wxWindow *p_parent );
351     virtual ~SubsFileDialog();
352
353     wxComboBox *file_combo;
354     wxSpinCtrl *delay_spinctrl;
355     wxSpinCtrl *fps_spinctrl;
356
357 private:
358     /* Event handlers (these functions should _not_ be virtual) */
359     void OnOk( wxCommandEvent& event );
360     void OnCancel( wxCommandEvent& event );
361     void OnFileBrowse( wxCommandEvent& event );
362
363     DECLARE_EVENT_TABLE();
364
365     intf_thread_t *p_intf;
366     wxWindow *p_parent;
367 };
368
369 /* Preferences Dialog */
370 class PrefsTreeCtrl;
371 class PrefsDialog: public wxFrame
372 {
373 public:
374     /* Constructor */
375     PrefsDialog( intf_thread_t *p_intf, Interface *p_main_interface );
376     virtual ~PrefsDialog();
377
378 private:
379     wxPanel *PrefsPanel( wxWindow* parent );
380
381     /* Event handlers (these functions should _not_ be virtual) */
382     void OnOk( wxCommandEvent& event );
383     void OnCancel( wxCommandEvent& event );
384     void OnSave( wxCommandEvent& event );
385     void OnResetAll( wxCommandEvent& event );
386
387     DECLARE_EVENT_TABLE();
388
389     intf_thread_t *p_intf;
390     Interface *p_main_interface;
391
392     PrefsTreeCtrl *prefs_tree;
393 };
394
395 /* Messages */
396 class Messages: public wxFrame
397 {
398 public:
399     /* Constructor */
400     Messages( intf_thread_t *p_intf, Interface *_p_main_interface );
401     virtual ~Messages();
402     void UpdateLog();
403
404 private:
405     /* Event handlers (these functions should _not_ be virtual) */
406     void OnClose( wxCommandEvent& event );
407     void OnVerbose( wxCommandEvent& event );
408
409     DECLARE_EVENT_TABLE();
410
411     intf_thread_t *p_intf;
412     Interface *p_main_interface;
413     wxTextCtrl *textctrl;
414     wxTextAttr *info_attr;
415     wxTextAttr *err_attr;
416     wxTextAttr *warn_attr;
417     wxTextAttr *dbg_attr;
418
419     vlc_bool_t b_verbose;
420 };
421
422 /* Playlist */
423 class Playlist: public wxFrame
424 {
425 public:
426     /* Constructor */
427     Playlist( intf_thread_t *p_intf, Interface *p_main_interface );
428     virtual ~Playlist();
429
430     void UpdatePlaylist();
431     void ShowPlaylist( bool show );
432
433     bool b_need_update;
434     vlc_mutex_t lock;
435
436 private:
437     void DeleteItem( int item );
438
439     /* Event handlers (these functions should _not_ be virtual) */
440     void OnAddMRL( wxCommandEvent& event );
441     void OnClose( wxCommandEvent& event );
442     void OnOpen( wxCommandEvent& event );
443     void OnSave( wxCommandEvent& event );
444     void OnInvertSelection( wxCommandEvent& event );
445     void OnDeleteSelection( wxCommandEvent& event );
446     void OnSelectAll( wxCommandEvent& event );
447     void OnActivateItem( wxListEvent& event );
448     void OnKeyDown( wxListEvent& event );
449     void Rebuild();
450
451     DECLARE_EVENT_TABLE();
452
453     intf_thread_t *p_intf;
454     Interface *p_main_interface;
455     wxListView *listview;
456     int i_update_counter;
457 };
458
459 /* File Info */
460 class FileInfo: public wxFrame
461 {
462 public:
463     /* Constructor */
464     FileInfo( intf_thread_t *p_intf, Interface *p_main_interface );
465     virtual ~FileInfo();
466     void UpdateFileInfo();
467
468 private:
469     void OnClose( wxCommandEvent& event );
470
471     DECLARE_EVENT_TABLE();
472    
473     intf_thread_t *p_intf;
474     wxTreeCtrl *fileinfo_tree;
475     wxTreeItemId fileinfo_root;
476     wxString fileinfo_root_label;
477
478 };
479
480 #if !defined(__WXX11__)
481 /* Drag and Drop class */
482 class DragAndDrop: public wxFileDropTarget
483 {
484 public:
485     DragAndDrop( intf_thread_t *_p_intf );
486
487     virtual bool OnDropFiles( wxCoord x, wxCoord y,
488                               const wxArrayString& filenames );
489
490 private:
491     intf_thread_t *p_intf;
492 };
493 #endif
494
495 /* Menus */
496 void PopupMenu( intf_thread_t *_p_intf, Interface *_p_main_interface,
497                 const wxPoint& pos );
498 wxMenu *AudioMenu( intf_thread_t *_p_intf, Interface *_p_main_interface );
499 wxMenu *VideoMenu( intf_thread_t *_p_intf, Interface *_p_main_interface );
500
501 class MenuEvtHandler : public wxEvtHandler
502 {
503 public:
504     MenuEvtHandler( intf_thread_t *p_intf, Interface *p_main_interface );
505     virtual ~MenuEvtHandler();
506
507     void MenuEvtHandler::OnMenuEvent( wxCommandEvent& event );
508
509 private:
510
511     DECLARE_EVENT_TABLE()
512
513     intf_thread_t *p_intf;
514     Interface *p_main_interface;
515 };
516
517 class Menu: public wxMenu
518 {
519 public:
520     /* Constructor */
521     Menu( intf_thread_t *p_intf, Interface *p_main_interface, int i_count,
522           char **ppsz_names, int *pi_objects, int i_start_id );
523     virtual ~Menu();
524
525 private:
526     /* Event handlers (these functions should _not_ be virtual) */
527     void OnClose( wxCommandEvent& event );
528     void OnEntrySelected( wxCommandEvent& event );
529
530     wxMenu *Menu::CreateDummyMenu();
531     void   Menu::CreateMenuItem( wxMenu *, char *, vlc_object_t * );
532     wxMenu *Menu::CreateChoicesMenu( char *, vlc_object_t * );
533
534     DECLARE_EVENT_TABLE();
535
536     intf_thread_t *p_intf;
537     Interface *p_main_interface;
538
539     int  i_item_id;
540 };