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