]> git.sesse.net Git - vlc/blob - modules/gui/wxwindows/wxwindows.h
* modules/gui/skins/*: got rid of wxdialogs.h, the skins plugin is now sharing wxwind...
[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.23 2003/05/12 17:33:19 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 OnSoutEnable( wxCommandEvent& event );
230     void OnSoutSettings( wxCommandEvent& WXUNUSED(event) );
231
232     /* Event handlers for the demux dump */
233     void OnDemuxDumpEnable( wxCommandEvent& event );
234     void OnDemuxDumpBrowse( wxCommandEvent& event );
235     void OnDemuxDumpChange( wxCommandEvent& event );
236
237     DECLARE_EVENT_TABLE();
238
239     intf_thread_t *p_intf;
240     wxWindow *p_parent;
241     int i_current_access_method;
242
243     wxComboBox *mrl_combo;
244
245     /* Controls for the file panel */
246     wxComboBox *file_combo;
247
248     /* Controls for the disc panel */
249     wxRadioBox *disc_type;
250     wxTextCtrl *disc_device;
251     wxSpinCtrl *disc_title;
252     wxSpinCtrl *disc_chapter;
253
254     /* Controls for the net panel */
255     wxRadioBox *net_type;
256     int i_net_type;
257     wxPanel *net_subpanels[4];
258     wxRadioButton *net_radios[4];
259     wxSpinCtrl *net_ports[4];
260     wxTextCtrl *net_addrs[4];
261
262     /* Controls for the stream output */
263     wxButton *sout_button;
264     wxCheckBox *sout_checkbox;
265
266     /* Controls for the demux dump */
267     wxTextCtrl *demuxdump_textctrl;
268     wxButton *demuxdump_button;
269     wxCheckBox *demuxdump_checkbox;
270 };
271
272 enum
273 {
274     FILE_ACCESS = 0,
275     DISC_ACCESS,
276     NET_ACCESS,
277     SAT_ACCESS
278 };
279
280 /* Stream output Dialog */
281 class SoutDialog: public wxDialog
282 {
283 public:
284     /* Constructor */
285     SoutDialog( intf_thread_t *p_intf, wxWindow *p_parent );
286     virtual ~SoutDialog();
287
288     wxString mrl;
289
290 private:
291     void UpdateMRL();
292     wxPanel *AccessPanel( wxWindow* parent );
293     wxPanel *EncapsulationPanel( wxWindow* parent );
294     void    ParseMRL();
295
296     /* Event handlers (these functions should _not_ be virtual) */
297     void OnOk( wxCommandEvent& event );
298     void OnCancel( wxCommandEvent& event );
299     void OnMRLChange( wxCommandEvent& event );
300     void OnAccessTypeChange( wxCommandEvent& event );
301
302     /* Event handlers for the file access output */
303     void OnFileChange( wxCommandEvent& event );
304     void OnFileBrowse( wxCommandEvent& event );
305
306     /* Event handlers for the net access output */
307     void OnNetChange( wxCommandEvent& event );
308
309     /* Event handlers for the encapsulation panel */
310     void OnEncapsulationChange( wxCommandEvent& event );
311
312     DECLARE_EVENT_TABLE();
313
314     intf_thread_t *p_intf;
315     wxWindow *p_parent;
316
317     wxComboBox *mrl_combo;
318     wxPanel *access_panel;
319     wxPanel *encapsulation_panel;
320
321     /* Controls for the access outputs */
322     wxPanel *access_subpanels[4];
323     wxRadioButton *access_radios[4];
324
325     int i_access_type;
326
327     wxComboBox *file_combo;
328     wxSpinCtrl *net_port;
329     wxTextCtrl *net_addr;
330
331     /* Controls for the encapsulation */
332     wxRadioButton *encapsulation_radios[4];
333     int i_encapsulation_type;
334
335 };
336
337 /* Preferences Dialog */
338 class PrefsTreeCtrl;
339 class PrefsDialog: public wxFrame
340 {
341 public:
342     /* Constructor */
343     PrefsDialog( intf_thread_t *p_intf, Interface *p_main_interface );
344     virtual ~PrefsDialog();
345
346 private:
347     wxPanel *PrefsPanel( wxWindow* parent );
348
349     /* Event handlers (these functions should _not_ be virtual) */
350     void OnOk( wxCommandEvent& event );
351     void OnCancel( wxCommandEvent& event );
352     void OnSave( wxCommandEvent& event );
353     void OnResetAll( wxCommandEvent& event );
354
355     DECLARE_EVENT_TABLE();
356
357     intf_thread_t *p_intf;
358     Interface *p_main_interface;
359
360     PrefsTreeCtrl *prefs_tree;
361 };
362
363 /* Messages */
364 class Messages: public wxFrame
365 {
366 public:
367     /* Constructor */
368     Messages( intf_thread_t *p_intf, Interface *_p_main_interface );
369     virtual ~Messages();
370     void UpdateLog();
371
372 private:
373     /* Event handlers (these functions should _not_ be virtual) */
374     void OnClose( wxCommandEvent& event );
375     void OnVerbose( wxCommandEvent& event );
376
377     DECLARE_EVENT_TABLE();
378
379     intf_thread_t *p_intf;
380     Interface *p_main_interface;
381     wxTextCtrl *textctrl;
382     wxTextAttr *info_attr;
383     wxTextAttr *err_attr;
384     wxTextAttr *warn_attr;
385     wxTextAttr *dbg_attr;
386
387     vlc_bool_t b_verbose;
388 };
389
390 /* Playlist */
391 class Playlist: public wxFrame
392 {
393 public:
394     /* Constructor */
395     Playlist( intf_thread_t *p_intf, Interface *p_main_interface );
396     virtual ~Playlist();
397
398     void UpdatePlaylist();
399     void ShowPlaylist( bool show );
400
401     bool b_need_update;
402     vlc_mutex_t lock;
403
404 private:
405     void DeleteItem( int item );
406
407     /* Event handlers (these functions should _not_ be virtual) */
408     void OnAddMRL( wxCommandEvent& event );
409     void OnClose( wxCommandEvent& event );
410     void OnOpen( wxCommandEvent& event );
411     void OnSave( wxCommandEvent& event );
412     void OnInvertSelection( wxCommandEvent& event );
413     void OnDeleteSelection( wxCommandEvent& event );
414     void OnSelectAll( wxCommandEvent& event );
415     void OnActivateItem( wxListEvent& event );
416     void OnKeyDown( wxListEvent& event );
417     void Rebuild();
418
419     DECLARE_EVENT_TABLE();
420
421     intf_thread_t *p_intf;
422     Interface *p_main_interface;
423     wxListView *listview;
424     int i_update_counter;
425 };
426
427 /* File Info */
428 class FileInfo: public wxFrame
429 {
430 public:
431     /* Constructor */
432     FileInfo( intf_thread_t *p_intf, Interface *p_main_interface );
433     virtual ~FileInfo();
434     void UpdateFileInfo();
435
436 private:
437     void OnClose( wxCommandEvent& event );
438
439     DECLARE_EVENT_TABLE();
440    
441     intf_thread_t *p_intf;
442     wxTreeCtrl *fileinfo_tree;
443     wxTreeItemId fileinfo_root;
444     wxString fileinfo_root_label;
445
446 };
447
448 #if !defined(__WXX11__)
449 /* Drag and Drop class */
450 class DragAndDrop: public wxFileDropTarget
451 {
452 public:
453     DragAndDrop( intf_thread_t *_p_intf );
454
455     virtual bool OnDropFiles( wxCoord x, wxCoord y,
456                               const wxArrayString& filenames );
457
458 private:
459     intf_thread_t *p_intf;
460 };
461 #endif
462
463 /* Menus */
464 void PopupMenu( intf_thread_t *_p_intf, Interface *_p_main_interface,
465                 const wxPoint& pos );
466 wxMenu *AudioMenu( intf_thread_t *_p_intf, Interface *_p_main_interface );
467 wxMenu *VideoMenu( intf_thread_t *_p_intf, Interface *_p_main_interface );
468
469 class MenuEvtHandler : public wxEvtHandler
470 {
471 public:
472     MenuEvtHandler( intf_thread_t *p_intf, Interface *p_main_interface );
473     virtual ~MenuEvtHandler();
474
475     void MenuEvtHandler::OnMenuEvent( wxCommandEvent& event );
476
477 private:
478
479     DECLARE_EVENT_TABLE()
480
481     intf_thread_t *p_intf;
482     Interface *p_main_interface;
483 };
484
485 class Menu: public wxMenu
486 {
487 public:
488     /* Constructor */
489     Menu( intf_thread_t *p_intf, Interface *p_main_interface, int i_count,
490           char **ppsz_names, int *pi_objects, int i_start_id );
491     virtual ~Menu();
492
493 private:
494     /* Event handlers (these functions should _not_ be virtual) */
495     void OnClose( wxCommandEvent& event );
496     void OnEntrySelected( wxCommandEvent& event );
497
498     wxMenu *Menu::CreateDummyMenu();
499     void   Menu::CreateMenuItem( wxMenu *, char *, vlc_object_t * );
500     wxMenu *Menu::CreateChoicesMenu( char *, vlc_object_t * );
501
502     DECLARE_EVENT_TABLE();
503
504     intf_thread_t *p_intf;
505     Interface *p_main_interface;
506
507     int  i_item_id;
508 };