]> git.sesse.net Git - vlc/blob - modules/gui/wxwindows/wxwindows.h
corrected a newbie notation
[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.39 2003/07/09 09:30:23 adn 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 #include <wx/gauge.h>
31
32 class Playlist;
33 class Messages;
34 class FileInfo;
35
36 #define SLIDER_MAX_POS 10000
37
38 /* wxU is used to convert ansi strings to unicode strings (wchar_t) */
39 #if wxUSE_UNICODE
40 #   define wxU(ansi) wxString(ansi, *wxConvCurrent)
41 #else
42 #   define wxU(ansi) ansi
43 #endif
44
45 #if !defined(MODULE_NAME_IS_skins)
46 /*****************************************************************************
47  * intf_sys_t: description and status of wxwindows interface
48  *****************************************************************************/
49 struct intf_sys_t
50 {
51     /* the wx parent window */
52     wxWindow            *p_wxwindow;
53     wxIcon              *p_icon;
54
55     /* secondary windows */
56     Playlist            *p_playlist_window;
57     Messages            *p_messages_window;
58     FileInfo            *p_fileinfo_window;
59
60     /* special actions */
61     vlc_bool_t          b_playing;
62
63     /* The input thread */
64     input_thread_t *    p_input;
65
66     /* The slider */
67     int                 i_slider_pos;                     /* slider position */
68     int                 i_slider_oldpos;                /* previous position */
69     vlc_bool_t          b_slider_free;                      /* slider status */
70
71     /* The messages window */
72     msg_subscription_t* p_sub;                  /* message bank subscription */
73
74     /* Playlist management */
75     int                 i_playing;                 /* playlist selected item */
76
77     /* Popup menu */
78     wxMenu              *p_popup_menu;
79     vlc_bool_t          b_popup_change;
80
81 };
82 #endif /* !defined(MODULE_NAME_IS_skins) */
83
84 /*****************************************************************************
85  * Prototypes
86  *****************************************************************************/
87
88 /*****************************************************************************
89  * Classes declarations.
90  *****************************************************************************/
91 class Interface;
92
93 /* Timer */
94 class Timer: public wxTimer
95 {
96 public:
97     /* Constructor */
98     Timer( intf_thread_t *p_intf, Interface *p_main_interface );
99     virtual ~Timer();
100
101     virtual void Notify();
102
103 private:
104     intf_thread_t *p_intf;
105     Interface *p_main_interface;
106     int i_old_playing_status;
107     int i_old_rate;
108 };
109
110 /* Main Interface */
111 class OpenDialog;
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     wxGauge     *volctrl;
128
129     /* So we don't recreate the open dialog box each time
130      * (and keep the last settings) */
131     OpenDialog  *p_open_dialog;
132
133 private:
134     void CreateOurMenuBar();
135     void CreateOurToolBar();
136     void CreateOurSlider();
137     void Open( int i_access_method );
138
139     /* Event handlers (these functions should _not_ be virtual) */
140     void OnExit( wxCommandEvent& event );
141     void OnAbout( wxCommandEvent& event );
142     void OnMessages( wxCommandEvent& event );
143     void OnPlaylist( wxCommandEvent& event );
144     void OnLogs( wxCommandEvent& event );
145     void OnFileInfo( wxCommandEvent& event );
146     void OnPreferences( wxCommandEvent& event );
147
148     void OnOpenFile( wxCommandEvent& event );
149     void OnOpenDisc( wxCommandEvent& event );
150     void OnOpenNet( wxCommandEvent& event );
151     void OnOpenSat( wxCommandEvent& event );
152
153     void OnPlayStream( wxCommandEvent& event );
154     void OnStopStream( wxCommandEvent& event );
155     void OnSliderUpdate( wxScrollEvent& event );
156     void OnPrevStream( wxCommandEvent& event );
157     void OnNextStream( wxCommandEvent& event );
158     void OnSlowStream( wxCommandEvent& event );
159     void OnFastStream( wxCommandEvent& event );
160
161     void OnMenuOpen( wxMenuEvent& event );
162
163 #if defined( __WXMSW__ ) || defined( __WXMAC__ )
164     void OnContextMenu2(wxContextMenuEvent& event);
165 #endif
166     void OnContextMenu(wxMouseEvent& event);
167
168     DECLARE_EVENT_TABLE();
169
170     Timer *timer;
171     intf_thread_t *p_intf;
172
173     wxFrame *p_prefs_dialog;
174
175     int i_old_playing_status;
176
177     /* For auto-generated menus */
178     wxMenu *p_audio_menu;
179     vlc_bool_t b_audio_menu;
180     wxMenu *p_video_menu;
181     vlc_bool_t b_video_menu;
182     wxMenu *p_navig_menu;
183     vlc_bool_t b_navig_menu;
184 };
185
186 /* Open Dialog */
187 class SoutDialog;
188 class SubsFileDialog;
189 class OpenDialog: public wxDialog
190 {
191 public:
192     /* Constructor */
193     OpenDialog( intf_thread_t *p_intf, wxWindow *p_parent,
194                 int i_access_method );
195     virtual ~OpenDialog();
196
197     int ShowModal();
198     int ShowModal( int i_access_method );
199
200     wxArrayString mrl;
201
202 private:
203     wxPanel *FilePanel( wxWindow* parent );
204     wxPanel *DiscPanel( wxWindow* parent );
205     wxPanel *NetPanel( wxWindow* parent );
206     wxPanel *SatPanel( wxWindow* parent );
207
208     void UpdateMRL( int i_access_method );
209     wxArrayString SeparateEntries( wxString );
210
211     /* Event handlers (these functions should _not_ be virtual) */
212     void OnOk( wxCommandEvent& event );
213     void OnCancel( wxCommandEvent& event );
214
215     void OnPageChange( wxNotebookEvent& event );
216     void OnMRLChange( wxCommandEvent& event );
217
218     /* Event handlers for the file page */
219     void OnFilePanelChange( wxCommandEvent& event );
220     void OnFileBrowse( wxCommandEvent& event );
221
222     /* Event handlers for the disc page */
223     void OnDiscPanelChange( wxCommandEvent& event );
224     void OnDiscTypeChange( wxCommandEvent& event );
225
226     /* Event handlers for the net page */
227     void OnNetPanelChange( wxCommandEvent& event );
228     void OnNetTypeChange( wxCommandEvent& event );
229
230     /* Event handlers for the stream output */
231     void OnSubsFileEnable( wxCommandEvent& event );
232     void OnSubsFileSettings( wxCommandEvent& WXUNUSED(event) );
233
234     /* Event handlers for the stream output */
235     void OnSoutEnable( wxCommandEvent& event );
236     void OnSoutSettings( wxCommandEvent& WXUNUSED(event) );
237
238     /* Event handlers for the demux dump */
239     void OnDemuxDumpEnable( wxCommandEvent& event );
240     void OnDemuxDumpBrowse( wxCommandEvent& event );
241     void OnDemuxDumpChange( wxCommandEvent& event );
242
243     DECLARE_EVENT_TABLE();
244
245     intf_thread_t *p_intf;
246     wxWindow *p_parent;
247     int i_current_access_method;
248
249     wxComboBox *mrl_combo;
250     wxNotebook *notebook;
251
252     /* Controls for the file panel */
253     wxComboBox *file_combo;
254     wxFileDialog *file_dialog;
255
256     /* Controls for the disc panel */
257     wxRadioBox *disc_type;
258     wxTextCtrl *disc_device;
259     wxSpinCtrl *disc_title;
260     wxSpinCtrl *disc_chapter;
261
262     /* Controls for the net panel */
263     wxRadioBox *net_type;
264     int i_net_type;
265     wxPanel *net_subpanels[4];
266     wxRadioButton *net_radios[4];
267     wxSpinCtrl *net_ports[4];
268     wxTextCtrl *net_addrs[4];
269
270     /* Controls for the subtitles file */
271     wxButton *subsfile_button;
272     wxCheckBox *subsfile_checkbox;
273     SubsFileDialog *subsfile_dialog;
274
275     /* Controls for the stream output */
276     wxButton *sout_button;
277     wxCheckBox *sout_checkbox;
278     SoutDialog *sout_dialog;
279
280     /* Controls for the demux dump */
281     wxTextCtrl *demuxdump_textctrl;
282     wxButton *demuxdump_button;
283     wxCheckBox *demuxdump_checkbox;
284     wxFileDialog *demuxdump_dialog;
285 };
286
287 enum
288 {
289     FILE_ACCESS = 0,
290     DISC_ACCESS,
291     NET_ACCESS,
292     SAT_ACCESS
293 };
294
295 /* Stream output Dialog */
296 class SoutDialog: public wxDialog
297 {
298 public:
299     /* Constructor */
300     SoutDialog( intf_thread_t *p_intf, wxWindow *p_parent );
301     virtual ~SoutDialog();
302
303     wxString mrl;
304
305 private:
306     void UpdateMRL();
307     wxPanel *AccessPanel( wxWindow* parent );
308     wxPanel *MiscPanel( wxWindow* parent );
309     wxPanel *EncapsulationPanel( wxWindow* parent );
310     wxPanel *TranscodingPanel( wxWindow* parent );
311     void    ParseMRL();
312
313     /* Event handlers (these functions should _not_ be virtual) */
314     void OnOk( wxCommandEvent& event );
315     void OnCancel( wxCommandEvent& event );
316     void OnMRLChange( wxCommandEvent& event );
317     void OnAccessTypeChange( wxCommandEvent& event );
318
319     /* Event handlers for the file access output */
320     void OnFileChange( wxCommandEvent& event );
321     void OnFileBrowse( wxCommandEvent& event );
322
323     /* Event handlers for the net access output */
324     void OnNetChange( wxCommandEvent& event );
325
326     /* Event specific to the sap address */
327     void OnSAPAddrChange( wxCommandEvent& event );
328     
329     /* Event handlers for the encapsulation panel */
330     void OnEncapsulationChange( wxCommandEvent& event );
331
332     /* Event handlers for the transcoding panel */
333     void OnTranscodingEnable( wxCommandEvent& event );
334     void OnTranscodingChange( wxCommandEvent& event );
335
336     /* Event handlers for the misc panel */
337     void OnSAPMiscChange( wxCommandEvent& event );
338
339     DECLARE_EVENT_TABLE();
340
341     intf_thread_t *p_intf;
342     wxWindow *p_parent;
343
344     wxComboBox *mrl_combo;
345
346     /* Controls for the access outputs */
347     wxPanel *access_subpanels[5];
348     wxCheckBox *access_checkboxes[5];
349
350     int i_access_type;
351
352     wxComboBox *file_combo;
353     wxSpinCtrl *net_ports[5];
354     wxTextCtrl *net_addrs[5];
355
356     /* Controls for the SAP announces */
357     wxPanel *misc_subpanels[1];
358     wxCheckBox *sap_checkbox;
359     wxTextCtrl *sap_addr;
360                             
361     /* Controls for the encapsulation */
362     wxRadioButton *encapsulation_radios[5];
363     int i_encapsulation_type;
364
365     /* Controls for transcoding */
366     wxCheckBox *video_transc_checkbox;
367     wxComboBox *video_codec_combo;
368     wxComboBox *audio_codec_combo;
369     wxCheckBox *audio_transc_checkbox;
370     wxComboBox *video_bitrate_combo;
371     wxComboBox *audio_bitrate_combo;
372 };
373
374 /* Subtitles File Dialog */
375 class SubsFileDialog: public wxDialog
376 {
377 public:
378     /* Constructor */
379     SubsFileDialog( intf_thread_t *p_intf, wxWindow *p_parent );
380     virtual ~SubsFileDialog();
381
382     wxComboBox *file_combo;
383     wxSpinCtrl *delay_spinctrl;
384     wxSpinCtrl *fps_spinctrl;
385
386 private:
387     /* Event handlers (these functions should _not_ be virtual) */
388     void OnOk( wxCommandEvent& event );
389     void OnCancel( wxCommandEvent& event );
390     void OnFileBrowse( wxCommandEvent& event );
391
392     DECLARE_EVENT_TABLE();
393
394     intf_thread_t *p_intf;
395     wxWindow *p_parent;
396 };
397
398 /* Preferences Dialog */
399 class PrefsTreeCtrl;
400 class PrefsDialog: public wxFrame
401 {
402 public:
403     /* Constructor */
404     PrefsDialog( intf_thread_t *p_intf, wxWindow *p_parent );
405     virtual ~PrefsDialog();
406
407 private:
408     wxPanel *PrefsPanel( wxWindow* parent );
409
410     /* Event handlers (these functions should _not_ be virtual) */
411     void OnOk( wxCommandEvent& event );
412     void OnCancel( wxCommandEvent& event );
413     void OnSave( wxCommandEvent& event );
414     void OnResetAll( wxCommandEvent& event );
415
416     DECLARE_EVENT_TABLE();
417
418     intf_thread_t *p_intf;
419
420     PrefsTreeCtrl *prefs_tree;
421 };
422
423 /* Messages */
424 class Messages: public wxFrame
425 {
426 public:
427     /* Constructor */
428     Messages( intf_thread_t *p_intf, wxWindow *p_parent );
429     virtual ~Messages();
430     void UpdateLog();
431
432 private:
433     /* Event handlers (these functions should _not_ be virtual) */
434     void OnClose( wxCommandEvent& event );
435     void OnVerbose( wxCommandEvent& event );
436     void OnClear( wxCommandEvent& event );
437
438     DECLARE_EVENT_TABLE();
439
440     intf_thread_t *p_intf;
441     wxTextCtrl *textctrl;
442     wxTextAttr *info_attr;
443     wxTextAttr *err_attr;
444     wxTextAttr *warn_attr;
445     wxTextAttr *dbg_attr;
446
447     vlc_bool_t b_verbose;
448 };
449
450 /* Playlist */
451 class Playlist: public wxFrame
452 {
453 public:
454     /* Constructor */
455     Playlist( intf_thread_t *p_intf, Interface *p_main_interface );
456     virtual ~Playlist();
457
458     void UpdatePlaylist();
459     void ShowPlaylist( bool show );
460
461     bool b_need_update;
462     vlc_mutex_t lock;
463
464 private:
465     void DeleteItem( int item );
466
467     /* Event handlers (these functions should _not_ be virtual) */
468     void OnAddMRL( wxCommandEvent& event );
469     void OnClose( wxCommandEvent& event );
470     void OnOpen( wxCommandEvent& event );
471     void OnSave( wxCommandEvent& event );
472     void OnInvertSelection( wxCommandEvent& event );
473     void OnDeleteSelection( wxCommandEvent& event );
474     void OnSelectAll( wxCommandEvent& event );
475     void OnActivateItem( wxListEvent& event );
476     void OnKeyDown( wxListEvent& event );
477     void Rebuild();
478
479     DECLARE_EVENT_TABLE();
480
481     intf_thread_t *p_intf;
482     Interface *p_main_interface;
483     wxListView *listview;
484     int i_update_counter;
485 };
486
487 /* File Info */
488 class FileInfo: public wxFrame
489 {
490 public:
491     /* Constructor */
492     FileInfo( intf_thread_t *p_intf, wxWindow *p_parent );
493     virtual ~FileInfo();
494     void UpdateFileInfo();
495
496 private:
497     void OnClose( wxCommandEvent& event );
498
499     DECLARE_EVENT_TABLE();
500    
501     intf_thread_t *p_intf;
502     wxTreeCtrl *fileinfo_tree;
503     wxTreeItemId fileinfo_root;
504     wxString fileinfo_root_label;
505
506 };
507
508 #if !defined(__WXX11__)
509 /* Drag and Drop class */
510 class DragAndDrop: public wxFileDropTarget
511 {
512 public:
513     DragAndDrop( intf_thread_t *_p_intf );
514
515     virtual bool OnDropFiles( wxCoord x, wxCoord y,
516                               const wxArrayString& filenames );
517
518 private:
519     intf_thread_t *p_intf;
520 };
521 #endif
522
523 /* Menus */
524 void PopupMenu( intf_thread_t *_p_intf, wxWindow *p_parent,
525                 const wxPoint& pos );
526 wxMenu *AudioMenu( intf_thread_t *_p_intf, wxWindow *p_parent );
527 wxMenu *VideoMenu( intf_thread_t *_p_intf, wxWindow *p_parent );
528 wxMenu *NavigMenu( intf_thread_t *_p_intf, wxWindow *p_parent );
529
530 class MenuEvtHandler : public wxEvtHandler
531 {
532 public:
533     MenuEvtHandler( intf_thread_t *p_intf, Interface *p_main_interface );
534     virtual ~MenuEvtHandler();
535
536     void MenuEvtHandler::OnMenuEvent( wxCommandEvent& event );
537
538 private:
539
540     DECLARE_EVENT_TABLE()
541
542     intf_thread_t *p_intf;
543     Interface *p_main_interface;
544 };
545
546 class Menu: public wxMenu
547 {
548 public:
549     /* Constructor */
550     Menu( intf_thread_t *p_intf, wxWindow *p_parent, int i_count,
551           char **ppsz_names, int *pi_objects, int i_start_id );
552     virtual ~Menu();
553
554 private:
555     /* Event handlers (these functions should _not_ be virtual) */
556     void OnClose( wxCommandEvent& event );
557     void OnEntrySelected( wxCommandEvent& event );
558
559     wxMenu *Menu::CreateDummyMenu();
560     void   Menu::CreateMenuItem( wxMenu *, char *, vlc_object_t * );
561     wxMenu *Menu::CreateChoicesMenu( char *, vlc_object_t * );
562
563     DECLARE_EVENT_TABLE();
564
565     intf_thread_t *p_intf;
566
567     int  i_item_id;
568 };