]> git.sesse.net Git - vlc/blob - modules/gui/wxwindows/wxwindows.h
* modules/gui/wxwindows/preferences.cpp: improved the preferences dialog box. It...
[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.13 2003/03/30 02:58:36 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
30 class Playlist;
31 class Messages;
32
33 #define SLIDER_MAX_POS 10000
34
35 /*****************************************************************************
36  * intf_sys_t: description and status of Gtk+ interface
37  *****************************************************************************/
38 struct intf_sys_t
39 {
40     /* the wx parent window */
41     wxWindow            *p_wxwindow;
42
43     /* secondary windows */
44     Playlist            *p_playlist_window;
45     Messages            *p_messages_window;
46
47     /* special actions */
48     vlc_bool_t          b_playing;
49     vlc_bool_t          b_popup_changed;                   /* display menu ? */
50     vlc_bool_t          b_window_changed;        /* window display toggled ? */
51     vlc_bool_t          b_playlist_changed;    /* playlist display toggled ? */
52     vlc_bool_t          b_slider_free;                      /* slider status */
53
54     /* menus handlers */
55     vlc_bool_t          b_program_update;   /* do we need to update programs
56                                                                         menu */
57     vlc_bool_t          b_title_update;  /* do we need to update title menus */
58     vlc_bool_t          b_chapter_update;            /* do we need to update
59                                                                chapter menus */
60     vlc_bool_t          b_audio_update;  /* do we need to update audio menus */
61     vlc_bool_t          b_spu_update;      /* do we need to update spu menus */
62
63     /* windows and widgets */
64
65     /* The input thread */
66     input_thread_t *    p_input;
67
68     /* The slider */
69     int                 i_slider_pos;                     /* slider position */
70     int                 i_slider_oldpos;                /* previous position */
71
72     /* The messages window */
73     msg_subscription_t* p_sub;                  /* message bank subscription */
74
75     /* Playlist management */
76     int                 i_playing;                 /* playlist selected item */
77
78     /* The window labels for DVD mode */
79     unsigned int        i_part;                           /* current chapter */
80 };
81
82 /*****************************************************************************
83  * Prototypes
84  *****************************************************************************/
85
86 /*****************************************************************************
87  * Classes declarations.
88  *****************************************************************************/
89 class Interface;
90
91 /* Timer */
92 class Timer: public wxTimer
93 {
94 public:
95     /* Constructor */
96     Timer( intf_thread_t *p_intf, Interface *p_main_interface );
97     virtual ~Timer();
98
99     virtual void Notify();
100
101 private:
102     intf_thread_t *p_intf;
103     Interface *p_main_interface;
104     int i_old_playing_status;
105 };
106
107 /* Main Interface */
108 class Interface: public wxFrame
109 {
110 public:
111     /* Constructor */
112     Interface( intf_thread_t *p_intf );
113     virtual ~Interface();
114     void TogglePlayButton( int i_playing_status );
115
116     wxBoxSizer  *frame_sizer;
117     wxStatusBar *statusbar;
118
119     wxSlider    *slider;
120     wxWindow    *slider_frame;
121     wxStaticBox *slider_box;
122
123     wxMenu      *p_popup_menu;
124
125     wxArrayString mrl_history;
126
127 private:
128     void CreateOurMenuBar();
129     void CreateOurToolBar();
130     void CreateOurSlider();
131     void Open( int i_access_method );
132
133     /* Event handlers (these functions should _not_ be virtual) */
134     void OnExit( wxCommandEvent& event );
135     void OnAbout( wxCommandEvent& event );
136     void OnMessages( wxCommandEvent& event );
137     void OnPlaylist( wxCommandEvent& event );
138     void OnLogs( wxCommandEvent& event );
139     void OnFileInfo( wxCommandEvent& event );
140     void OnPreferences( wxCommandEvent& event );
141
142     void OnOpenFile( wxCommandEvent& event );
143     void OnOpenDisc( wxCommandEvent& event );
144     void OnOpenNet( wxCommandEvent& event );
145     void OnOpenSat( wxCommandEvent& event );
146
147     void OnPlayStream( wxCommandEvent& event );
148     void OnStopStream( wxCommandEvent& event );
149     void OnSliderUpdate( wxScrollEvent& event );
150     void OnPrevStream( wxCommandEvent& event );
151     void OnNextStream( wxCommandEvent& event );
152
153     DECLARE_EVENT_TABLE();
154
155     Timer *timer;
156     intf_thread_t *p_intf;
157
158     wxDialog *p_prefs_dialog;
159     wxFrame  *p_fileinfo_window;
160
161     int i_old_playing_status;
162 };
163
164 /* Open Dialog */
165 class OpenDialog: public wxDialog
166 {
167 public:
168     /* Constructor */
169     OpenDialog( intf_thread_t *p_intf, Interface *p_main_interface,
170                 int i_access_method );
171     virtual ~OpenDialog();
172     void Rebuild();
173     void Manage();
174
175     wxString mrl;
176
177 private:
178     wxPanel *FilePanel( wxWindow* parent );
179     wxPanel *DiscPanel( wxWindow* parent );
180     wxPanel *NetPanel( wxWindow* parent );
181     wxPanel *SatPanel( wxWindow* parent );
182
183     void UpdateMRL( int i_access_method );
184
185     /* Event handlers (these functions should _not_ be virtual) */
186     void OnOk( wxCommandEvent& event );
187     void OnCancel( wxCommandEvent& event );
188
189     void OnPageChange( wxNotebookEvent& event );
190     void OnMRLChange( wxCommandEvent& event );
191
192     /* Event handlers for the file page */
193     void OnFilePanelChange( wxCommandEvent& event );
194     void OnFileBrowse( wxCommandEvent& event );
195
196     /* Event handlers for the disc page */
197     void OnDiscPanelChange( wxCommandEvent& event );
198     void OnDiscTypeChange( wxCommandEvent& event );
199
200     /* Event handlers for the net page */
201     void OnNetPanelChange( wxCommandEvent& event );
202     void OnNetTypeChange( wxCommandEvent& event );
203
204     /* Event handlers for the stream output */
205     void OnSoutEnable( wxCommandEvent& event );
206     void OnSoutSettings( wxCommandEvent& WXUNUSED(event) );
207
208     /* Event handlers for the demux dump */
209     void OnDemuxDumpEnable( wxCommandEvent& event );
210     void OnDemuxDumpBrowse( wxCommandEvent& event );
211     void OnDemuxDumpChange( wxCommandEvent& event );
212
213     DECLARE_EVENT_TABLE();
214
215     intf_thread_t *p_intf;
216     Interface *p_main_interface;
217     int i_current_access_method;
218
219     wxComboBox *mrl_combo;
220
221     /* Controls for the file panel */
222     wxComboBox *file_combo;
223
224     /* Controls for the disc panel */
225     wxRadioBox *disc_type;
226     wxTextCtrl *disc_device;
227     wxSpinCtrl *disc_title;
228     wxSpinCtrl *disc_chapter;
229
230     /* Controls for the net panel */
231     wxRadioBox *net_type;
232     int i_net_type;
233     wxPanel *net_subpanels[4];
234     wxRadioButton *net_radios[4];
235     wxSpinCtrl *net_ports[4];
236     wxTextCtrl *net_addrs[4];
237
238     /* Controls for the stream output */
239     wxButton *sout_button;
240     wxCheckBox *sout_checkbox;
241
242     /* Controls for the demux dump */
243     wxTextCtrl *demuxdump_textctrl;
244     wxButton *demuxdump_button;
245     wxCheckBox *demuxdump_checkbox;
246 };
247
248 enum
249 {
250     FILE_ACCESS = 0,
251     DISC_ACCESS,
252     NET_ACCESS,
253     SAT_ACCESS
254 };
255
256 /* Stream output Dialog */
257 class SoutDialog: public wxDialog
258 {
259 public:
260     /* Constructor */
261     SoutDialog( intf_thread_t *p_intf, Interface *p_main_interface );
262     virtual ~SoutDialog();
263
264     wxString mrl;
265
266 private:
267     void UpdateMRL();
268     wxPanel *AccessPanel( wxWindow* parent );
269     wxPanel *EncapsulationPanel( wxWindow* parent );
270     void    ParseMRL();
271
272     /* Event handlers (these functions should _not_ be virtual) */
273     void OnOk( wxCommandEvent& event );
274     void OnCancel( wxCommandEvent& event );
275     void OnMRLChange( wxCommandEvent& event );
276     void OnAccessTypeChange( wxCommandEvent& event );
277
278     /* Event handlers for the file access output */
279     void OnFileChange( wxCommandEvent& event );
280     void OnFileBrowse( wxCommandEvent& event );
281
282     /* Event handlers for the net access output */
283     void OnNetChange( wxCommandEvent& event );
284
285     /* Event handlers for the encapsulation panel */
286     void OnEncapsulationChange( wxCommandEvent& event );
287
288     DECLARE_EVENT_TABLE();
289
290     intf_thread_t *p_intf;
291     Interface *p_main_interface;
292
293     wxComboBox *mrl_combo;
294     wxPanel *access_panel;
295     wxPanel *encapsulation_panel;
296
297     /* Controls for the access outputs */
298     wxPanel *access_subpanels[4];
299     wxRadioButton *access_radios[4];
300
301     int i_access_type;
302
303     wxComboBox *file_combo;
304     wxSpinCtrl *net_port;
305     wxTextCtrl *net_addr;
306
307     /* Controls for the encapsulation */
308     wxRadioButton *encapsulation_radios[4];
309     int i_encapsulation_type;
310
311 };
312
313 /* Preferences Dialog */
314 class PrefsTreeCtrl;
315 class PrefsDialog: public wxDialog
316 {
317 public:
318     /* Constructor */
319     PrefsDialog( intf_thread_t *p_intf, Interface *p_main_interface );
320     virtual ~PrefsDialog();
321
322 private:
323     wxPanel *PrefsPanel( wxWindow* parent );
324
325     /* Event handlers (these functions should _not_ be virtual) */
326     void OnOk( wxCommandEvent& event );
327     void OnCancel( wxCommandEvent& event );
328     void OnSave( wxCommandEvent& event );
329
330     DECLARE_EVENT_TABLE();
331
332     intf_thread_t *p_intf;
333     Interface *p_main_interface;
334
335     PrefsTreeCtrl *prefs_tree;
336 };
337
338 /* Messages */
339 class Messages: public wxFrame
340 {
341 public:
342     /* Constructor */
343     Messages( intf_thread_t *p_intf, Interface *_p_main_interface );
344     virtual ~Messages();
345     void UpdateLog();
346
347 private:
348     /* Event handlers (these functions should _not_ be virtual) */
349     void OnClose( wxCommandEvent& event );
350
351     DECLARE_EVENT_TABLE();
352
353     intf_thread_t *p_intf;
354     Interface *p_main_interface;
355     wxButton *ok_button;
356     wxTextCtrl *textctrl;
357     wxTextAttr *info_attr;
358     wxTextAttr *err_attr;
359     wxTextAttr *warn_attr;
360     wxTextAttr *dbg_attr;
361 };
362
363 /* Playlist */
364 class Playlist: public wxFrame
365 {
366 public:
367     /* Constructor */
368     Playlist( intf_thread_t *p_intf, Interface *p_main_interface );
369     virtual ~Playlist();
370     void Rebuild();
371     void Manage();
372
373 private:
374     void DeleteItem( int item );
375
376     /* Event handlers (these functions should _not_ be virtual) */
377     void OnAddUrl( wxCommandEvent& event );
378     void OnAddDirectory( wxCommandEvent& event );
379     void OnClose( wxCommandEvent& event );
380     void OnInvertSelection( wxCommandEvent& event );
381     void OnDeleteSelection( wxCommandEvent& event );
382     void OnSelectAll( wxCommandEvent& event );
383     void OnActivateItem( wxListEvent& event );
384     void OnKeyDown( wxListEvent& event );
385
386     DECLARE_EVENT_TABLE();
387
388     intf_thread_t *p_intf;
389     Interface *p_main_interface;
390     wxListView *listview;
391     wxButton *ok_button;
392 };
393
394 /* File Info */
395 class FileInfo: public wxFrame
396 {
397 public:
398     /* Constructor */
399     FileInfo( intf_thread_t *p_intf, Interface *p_main_interface );
400     virtual ~FileInfo();
401
402 private:
403     void OnClose( wxCommandEvent& event );
404     DECLARE_EVENT_TABLE();
405     
406 };
407
408 #if !defined(__WXX11__)
409 /* Drag and Drop class */
410 class DragAndDrop: public wxFileDropTarget
411 {
412 public:
413     DragAndDrop( intf_thread_t *_p_intf );
414
415     virtual bool OnDropFiles( wxCoord x, wxCoord y,
416                               const wxArrayString& filenames );
417
418 private:
419     intf_thread_t *p_intf;
420 };
421 #endif
422
423 /* Popup contextual menu */
424 class PopupMenu: public wxMenu
425 {
426 public:
427     /* Constructor */
428     PopupMenu( intf_thread_t *p_intf, Interface *p_main_interface );
429     virtual ~PopupMenu();
430
431 private:
432     /* Event handlers (these functions should _not_ be virtual) */
433     void OnClose( wxCommandEvent& event );
434     void OnEntrySelected( wxCommandEvent& event );
435
436     wxMenu *PopupMenu::CreateDummyMenu();
437     void   PopupMenu::CreateMenuEntry( char *, vlc_object_t * );
438     wxMenu *PopupMenu::CreateSubMenu( char *, vlc_object_t * );
439
440     DECLARE_EVENT_TABLE();
441
442     intf_thread_t *p_intf;
443     Interface *p_main_interface;
444
445     int  i_item_id;
446 };
447
448 class PopupEvtHandler : public wxEvtHandler
449 {
450 public:
451     PopupEvtHandler( intf_thread_t *p_intf, Interface *p_main_interface );
452     virtual ~PopupEvtHandler();
453
454     void PopupEvtHandler::OnMenuEvent( wxCommandEvent& event );
455
456 private:
457
458     DECLARE_EVENT_TABLE()
459
460     intf_thread_t *p_intf;
461     Interface *p_main_interface;
462 };
463
464 class wxMenuItemExt: public wxMenuItem
465 {
466 public:
467     /* Constructor */
468     wxMenuItemExt( wxMenu* parentMenu, int id,
469                    const wxString& text,
470                    const wxString& helpString,
471                    wxItemKind kind,
472                    char *_psz_var, int _i_object_id, vlc_value_t _val ):
473         wxMenuItem( parentMenu, id, text, helpString, kind )
474     {
475         /* Initializations */
476         psz_var = _psz_var;
477         i_object_id = _i_object_id;
478         val = _val;
479     };
480
481     virtual ~wxMenuItemExt() { if( psz_var ) free( psz_var ); };
482
483     char *psz_var;
484     int  i_object_id;
485     vlc_value_t val;
486
487 private:
488
489 };