]> git.sesse.net Git - vlc/blob - modules/gui/wxwindows/wxwindows.h
* modules/gui/wxwindows/*: Added a stream output 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.9 2003/03/22 03:14:34 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 };
105
106 /* Main Interface */
107 class Interface: public wxFrame
108 {
109 public:
110     /* Constructor */
111     Interface( intf_thread_t *p_intf );
112     virtual ~Interface();
113
114     wxBoxSizer  *frame_sizer;
115     wxStatusBar *statusbar;
116
117     wxSlider    *slider;
118     wxWindow    *slider_frame;
119     wxStaticBox *slider_box;
120
121     wxMenu      *p_popup_menu;
122
123     wxArrayString mrl_history;
124
125 private:
126     void CreateOurMenuBar();
127     void CreateOurToolBar();
128     void CreateOurSlider();
129     void Open( int i_access_method );
130
131     /* Event handlers (these functions should _not_ be virtual) */
132     void OnExit( wxCommandEvent& event );
133     void OnAbout( wxCommandEvent& event );
134     void OnMessages( wxCommandEvent& event );
135     void OnPlaylist( wxCommandEvent& event );
136     void OnLogs( wxCommandEvent& event );
137     void OnFileInfo( wxCommandEvent& event );
138
139     void OnOpenFile( wxCommandEvent& event );
140     void OnOpenDisc( wxCommandEvent& event );
141     void OnOpenNet( wxCommandEvent& event );
142     void OnOpenSat( wxCommandEvent& event );
143
144     void OnPlayStream( wxCommandEvent& event );
145     void OnStopStream( wxCommandEvent& event );
146     void OnSliderUpdate( wxScrollEvent& event );
147     void OnPrevStream( wxCommandEvent& event );
148     void OnNextStream( wxCommandEvent& event );
149
150     void TogglePlayButton();
151
152     DECLARE_EVENT_TABLE();
153
154     Timer *timer;
155     intf_thread_t *p_intf;
156     int i_playing_status;
157 };
158
159 /* Open Dialog */
160 class OpenDialog: public wxDialog
161 {
162 public:
163     /* Constructor */
164     OpenDialog( intf_thread_t *p_intf, Interface *p_main_interface,
165                 int i_access_method );
166     virtual ~OpenDialog();
167     void Rebuild();
168     void Manage();
169
170     wxString mrl;
171
172 private:
173     wxPanel *FilePanel( wxWindow* parent );
174     wxPanel *DiscPanel( wxWindow* parent );
175     wxPanel *NetPanel( wxWindow* parent );
176     wxPanel *SatPanel( wxWindow* parent );
177
178     void UpdateMRL( int i_access_method );
179
180     /* Event handlers (these functions should _not_ be virtual) */
181     void OnOk( wxCommandEvent& event );
182     void OnCancel( wxCommandEvent& event );
183
184     void OnPageChange( wxNotebookEvent& event );
185     void OnMRLChange( wxCommandEvent& event );
186
187     /* Event handlers for the file page */
188     void OnFilePanelChange( wxCommandEvent& event );
189     void OnFileBrowse( wxCommandEvent& event );
190
191     /* Event handlers for the disc page */
192     void OnDiscPanelChange( wxCommandEvent& event );
193     void OnDiscTypeChange( wxCommandEvent& event );
194
195     /* Event handlers for the net page */
196     void OnNetPanelChange( wxCommandEvent& event );
197     void OnNetTypeChange( wxCommandEvent& event );
198
199     /* Event handlers for the stream output */
200     void OnSoutEnable( wxCommandEvent& event );
201     void OnSoutSettings( wxCommandEvent& WXUNUSED(event) );
202
203     DECLARE_EVENT_TABLE();
204
205     intf_thread_t *p_intf;
206     Interface *p_main_interface;
207
208     wxComboBox *mrl_combo;
209
210     /* Controls for the file panel */
211     wxComboBox *file_combo;
212
213     /* Controls for the disc panel */
214     wxRadioBox *disc_type;
215     wxTextCtrl *disc_device;
216     wxSpinCtrl *disc_title;
217     wxSpinCtrl *disc_chapter;
218
219     /* Controls for the net panel */
220     wxRadioBox *net_type;
221     int i_net_type;
222     wxPanel *net_subpanels[4];
223     wxRadioButton *net_radios[4];
224     wxSpinCtrl *net_ports[4];
225     wxTextCtrl *net_addrs[4];
226
227     /* Controls for the stream output */
228     wxButton *sout_button;
229 };
230
231 enum
232 {
233     FILE_ACCESS = 0,
234     DISC_ACCESS,
235     NET_ACCESS,
236     SAT_ACCESS
237 };
238
239 /* Stream output Dialog */
240 class SoutDialog: public wxDialog
241 {
242 public:
243     /* Constructor */
244     SoutDialog( intf_thread_t *p_intf, Interface *p_main_interface );
245     virtual ~SoutDialog();
246
247     wxString mrl;
248
249 private:
250     void UpdateMRL();
251     wxPanel *AccessPanel( wxWindow* parent );
252     wxPanel *EncapsulationPanel( wxWindow* parent );
253
254     /* Event handlers (these functions should _not_ be virtual) */
255     void OnOk( wxCommandEvent& event );
256     void OnCancel( wxCommandEvent& event );
257     void OnMRLChange( wxCommandEvent& event );
258     void OnAccessTypeChange( wxCommandEvent& event );
259
260     /* Event handlers for the file access output */
261     void OnFileChange( wxCommandEvent& event );
262     void OnFileBrowse( wxCommandEvent& event );
263
264     /* Event handlers for the net access output */
265     void OnNetChange( wxCommandEvent& event );
266     void OnMulticastChange( wxCommandEvent& event );
267
268     /* Event handlers for the encapsulation panel */
269     void OnEncapsulationChange( wxCommandEvent& event );
270
271     DECLARE_EVENT_TABLE();
272
273     intf_thread_t *p_intf;
274     Interface *p_main_interface;
275
276     wxComboBox *mrl_combo;
277     wxPanel *access_panel;
278     wxPanel *encapsulation_panel;
279
280     /* Controls for the access outputs */
281     wxPanel *access_subpanels[4];
282     wxRadioButton *access_radios[4];
283     wxCheckBox *multicast_checkbox;
284
285     int i_access_type;
286     vlc_bool_t b_multicast;
287
288     wxComboBox *file_combo;
289     wxSpinCtrl *net_port;
290     wxTextCtrl *net_addr;
291
292     /* Controls for the encapsulation */
293     wxRadioButton *encapsulation_radios[4];
294     int i_encapsulation_type;
295
296 };
297
298 /* Messages */
299 class Messages: public wxFrame
300 {
301 public:
302     /* Constructor */
303     Messages( intf_thread_t *p_intf, Interface *_p_main_interface );
304     virtual ~Messages();
305     void UpdateLog();
306
307 private:
308     /* Event handlers (these functions should _not_ be virtual) */
309     void OnClose( wxCommandEvent& event );
310
311     DECLARE_EVENT_TABLE();
312
313     intf_thread_t *p_intf;
314     Interface *p_main_interface;
315     wxButton *ok_button;
316     wxTextCtrl *textctrl;
317     wxTextAttr *info_attr;
318     wxTextAttr *err_attr;
319     wxTextAttr *warn_attr;
320     wxTextAttr *dbg_attr;
321 };
322
323 /* Playlist */
324 class Playlist: public wxFrame
325 {
326 public:
327     /* Constructor */
328     Playlist( intf_thread_t *p_intf, Interface *p_main_interface );
329     virtual ~Playlist();
330     void Rebuild();
331     void Manage();
332
333 private:
334     void DeleteItem( int item );
335
336     /* Event handlers (these functions should _not_ be virtual) */
337     void OnAddUrl( wxCommandEvent& event );
338     void OnAddDirectory( wxCommandEvent& event );
339     void OnClose( wxCommandEvent& event );
340     void OnInvertSelection( wxCommandEvent& event );
341     void OnDeleteSelection( wxCommandEvent& event );
342     void OnSelectAll( wxCommandEvent& event );
343     void OnActivateItem( wxListEvent& event );
344     void OnKeyDown( wxListEvent& event );
345
346     DECLARE_EVENT_TABLE();
347
348     intf_thread_t *p_intf;
349     Interface *p_main_interface;
350     wxListView *listview;
351     wxButton *ok_button;
352 };
353
354 /* File Info */
355 class FileInfo: public wxFrame
356 {
357 public:
358     /* Constructor */
359     FileInfo( intf_thread_t *p_intf, Interface *p_main_interface );
360     virtual ~FileInfo();
361
362 private:
363     void OnClose( wxCommandEvent& event );
364     DECLARE_EVENT_TABLE();
365     
366 };
367
368 #if !defined(__WXX11__)
369 /* Drag and Drop class */
370 class DragAndDrop: public wxFileDropTarget
371 {
372 public:
373     DragAndDrop( intf_thread_t *_p_intf );
374
375     virtual bool OnDropFiles( wxCoord x, wxCoord y,
376                               const wxArrayString& filenames );
377
378 private:
379     intf_thread_t *p_intf;
380 };
381 #endif
382
383 /* Popup contextual menu */
384 class PopupMenu: public wxMenu
385 {
386 public:
387     /* Constructor */
388     PopupMenu( intf_thread_t *p_intf, Interface *p_main_interface );
389     virtual ~PopupMenu();
390
391 private:
392     /* Event handlers (these functions should _not_ be virtual) */
393     void OnClose( wxCommandEvent& event );
394     void OnEntrySelected( wxCommandEvent& event );
395
396     wxMenu *PopupMenu::CreateDummyMenu();
397     void   PopupMenu::CreateMenuEntry( char *, vlc_object_t * );
398     wxMenu *PopupMenu::CreateSubMenu( char *, vlc_object_t * );
399
400     DECLARE_EVENT_TABLE();
401
402     intf_thread_t *p_intf;
403     Interface *p_main_interface;
404
405     int  i_item_id;
406 };
407
408 class PopupEvtHandler : public wxEvtHandler
409 {
410 public:
411     PopupEvtHandler( intf_thread_t *p_intf, Interface *p_main_interface );
412     virtual ~PopupEvtHandler();
413
414     void PopupEvtHandler::OnMenuEvent( wxCommandEvent& event );
415
416 private:
417
418     DECLARE_EVENT_TABLE()
419
420     intf_thread_t *p_intf;
421     Interface *p_main_interface;
422 };
423
424 class wxMenuItemExt: public wxMenuItem
425 {
426 public:
427     /* Constructor */
428     wxMenuItemExt( wxMenu* parentMenu, int id,
429                    const wxString& text,
430                    const wxString& helpString,
431                    wxItemKind kind,
432                    char *_psz_var, int _i_object_id, vlc_value_t _val ):
433         wxMenuItem( parentMenu, id, text, helpString, kind )
434     {
435         /* Initializations */
436         psz_var = _psz_var;
437         i_object_id = _i_object_id;
438         val = _val;
439     };
440
441     virtual ~wxMenuItemExt() { if( psz_var ) free( psz_var ); };
442
443     char *psz_var;
444     int  i_object_id;
445     vlc_value_t val;
446
447 private:
448
449 };