1 /*****************************************************************************
2 * wxwindows.h: private wxWindows interface description
3 *****************************************************************************
4 * Copyright (C) 1999, 2000 VideoLAN
5 * $Id: wxwindows.h,v 1.52 2003/08/14 19:25:56 sigmunau Exp $
7 * Authors: Gildas Bazin <gbazin@netcourrier.com>
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.
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.
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 *****************************************************************************/
24 #include <wx/listctrl.h>
25 #include <wx/textctrl.h>
26 #include <wx/notebook.h>
27 #include <wx/spinctrl.h>
29 #include <wx/treectrl.h>
34 DECLARE_LOCAL_EVENT_TYPE( wxEVT_DIALOG, 0 );
50 #define SLIDER_MAX_POS 10000
52 /* wxU is used to convert ansi/utf8 strings to unicode strings (wchar_t) */
53 #if defined( ENABLE_NLS ) && defined( HAVE_GETTEXT ) && \
54 defined( WIN32 ) && !defined( HAVE_INCLUDED_GETTEXT )
56 # define wxU(utf8) wxString(utf8, wxConvUTF8)
58 # define wxU(utf8) wxString(wxConvUTF8.cMB2WC(utf8), *wxConvCurrent)
61 #else // ENABLE_NLS && HAVE_GETTEXT && WIN32 && !HAVE_INCLUDED_GETTEXT
63 # define wxU(ansi) wxString(ansi, *wxConvCurrent)
65 # define wxU(ansi) ansi
70 wxArrayString SeparateEntries( wxString );
72 /*****************************************************************************
73 * intf_sys_t: description and status of wxwindows interface
74 *****************************************************************************/
77 /* the wx parent window */
84 /* The input thread */
85 input_thread_t * p_input;
88 int i_slider_pos; /* slider position */
89 int i_slider_oldpos; /* previous position */
90 vlc_bool_t b_slider_free; /* slider status */
92 /* The messages window */
93 msg_subscription_t* p_sub; /* message bank subscription */
95 /* Playlist management */
96 int i_playing; /* playlist selected item */
98 /* Send an event to show a dialog */
99 void (*pf_show_dialog) ( intf_thread_t *p_intf, int i_dialog, int i_arg,
100 intf_dialog_args_t *p_arg );
103 wxMenu *p_popup_menu;
107 /*****************************************************************************
109 *****************************************************************************/
111 /*****************************************************************************
112 * Classes declarations.
113 *****************************************************************************/
117 class Timer: public wxTimer
121 Timer( intf_thread_t *p_intf, Interface *p_main_interface );
124 virtual void Notify();
127 intf_thread_t *p_intf;
128 Interface *p_main_interface;
129 int i_old_playing_status;
134 class Interface: public wxFrame
138 Interface( intf_thread_t *p_intf );
139 virtual ~Interface();
140 void TogglePlayButton( int i_playing_status );
142 wxBoxSizer *frame_sizer;
143 wxStatusBar *statusbar;
146 wxWindow *slider_frame;
147 wxStaticBox *slider_box;
152 void UpdateAcceleratorTable();
153 void CreateOurMenuBar();
154 void CreateOurToolBar();
155 void CreateOurSlider();
156 void Open( int i_access_method );
158 /* Event handlers (these functions should _not_ be virtual) */
159 void OnExit( wxCommandEvent& event );
160 void OnAbout( wxCommandEvent& event );
162 void OnShowDialog( wxCommandEvent& event );
164 void OnPlayStream( wxCommandEvent& event );
165 void OnStopStream( wxCommandEvent& event );
166 void OnSliderUpdate( wxScrollEvent& event );
167 void OnPrevStream( wxCommandEvent& event );
168 void OnNextStream( wxCommandEvent& event );
169 void OnSlowStream( wxCommandEvent& event );
170 void OnFastStream( wxCommandEvent& event );
172 void OnMenuOpen( wxMenuEvent& event );
174 #if defined( __WXMSW__ ) || defined( __WXMAC__ )
175 void OnContextMenu2(wxContextMenuEvent& event);
177 void OnContextMenu(wxMouseEvent& event);
179 DECLARE_EVENT_TABLE();
182 intf_thread_t *p_intf;
185 int i_old_playing_status;
187 /* For auto-generated menus */
188 wxMenu *p_audio_menu;
189 vlc_bool_t b_audio_menu;
190 wxMenu *p_video_menu;
191 vlc_bool_t b_video_menu;
192 wxMenu *p_navig_menu;
193 vlc_bool_t b_navig_menu;
196 /* Dialogs Provider */
197 class DialogsProvider: public wxFrame
201 DialogsProvider( intf_thread_t *p_intf, wxWindow *p_parent );
202 virtual ~DialogsProvider();
205 void Open( int i_access_method, int i_arg );
207 /* Event handlers (these functions should _not_ be virtual) */
208 void OnExit( wxCommandEvent& event );
209 void OnPlaylist( wxCommandEvent& event );
210 void OnMessages( wxCommandEvent& event );
211 void OnFileInfo( wxCommandEvent& event );
212 void OnPreferences( wxCommandEvent& event );
214 void OnOpenFileGeneric( wxCommandEvent& event );
215 void OnOpenFileSimple( wxCommandEvent& event );
216 void OnOpenFile( wxCommandEvent& event );
217 void OnOpenDisc( wxCommandEvent& event );
218 void OnOpenNet( wxCommandEvent& event );
219 void OnOpenSat( wxCommandEvent& event );
221 void OnPopupMenu( wxCommandEvent& event );
223 void OnIdle( wxIdleEvent& event );
225 void OnExitThread( wxCommandEvent& event );
227 DECLARE_EVENT_TABLE();
229 intf_thread_t *p_intf;
232 /* Secondary windows */
233 OpenDialog *p_open_dialog;
234 wxFileDialog *p_file_dialog;
235 Playlist *p_playlist_dialog;
236 Messages *p_messages_dialog;
237 FileInfo *p_fileinfo_dialog;
238 wxFrame *p_prefs_dialog;
239 wxFileDialog *p_file_generic_dialog;
244 class SubsFileDialog;
245 class OpenDialog: public wxFrame
249 OpenDialog( intf_thread_t *p_intf, wxWindow *p_parent,
250 int i_access_method, int i_arg = 0 );
251 virtual ~OpenDialog();
254 int Show( int i_access_method, int i_arg = 0 );
259 wxPanel *FilePanel( wxWindow* parent );
260 wxPanel *DiscPanel( wxWindow* parent );
261 wxPanel *NetPanel( wxWindow* parent );
262 wxPanel *SatPanel( wxWindow* parent );
264 void UpdateMRL( int i_access_method );
266 /* Event handlers (these functions should _not_ be virtual) */
267 void OnOk( wxCommandEvent& event );
268 void OnCancel( wxCommandEvent& event );
270 void OnPageChange( wxNotebookEvent& event );
271 void OnMRLChange( wxCommandEvent& event );
273 /* Event handlers for the file page */
274 void OnFilePanelChange( wxCommandEvent& event );
275 void OnFileBrowse( wxCommandEvent& event );
277 /* Event handlers for the disc page */
278 void OnDiscPanelChange( wxCommandEvent& event );
279 void OnDiscTypeChange( wxCommandEvent& event );
281 /* Event handlers for the net page */
282 void OnNetPanelChange( wxCommandEvent& event );
283 void OnNetTypeChange( wxCommandEvent& event );
285 /* Event handlers for the stream output */
286 void OnSubsFileEnable( wxCommandEvent& event );
287 void OnSubsFileSettings( wxCommandEvent& WXUNUSED(event) );
289 /* Event handlers for the stream output */
290 void OnSoutEnable( wxCommandEvent& event );
291 void OnSoutSettings( wxCommandEvent& WXUNUSED(event) );
293 /* Event handlers for the demux dump */
294 void OnDemuxDumpEnable( wxCommandEvent& event );
295 void OnDemuxDumpBrowse( wxCommandEvent& event );
296 void OnDemuxDumpChange( wxCommandEvent& event );
298 DECLARE_EVENT_TABLE();
300 intf_thread_t *p_intf;
302 int i_current_access_method;
304 wxComboBox *mrl_combo;
305 wxNotebook *notebook;
307 /* Controls for the file panel */
308 wxComboBox *file_combo;
309 wxFileDialog *file_dialog;
311 /* Controls for the disc panel */
312 wxRadioBox *disc_type;
313 wxTextCtrl *disc_device;
314 wxSpinCtrl *disc_title;
316 wxSpinCtrl *disc_chapter;
319 /* Controls for the net panel */
320 wxRadioBox *net_type;
322 wxPanel *net_subpanels[4];
323 wxRadioButton *net_radios[4];
324 wxSpinCtrl *net_ports[4];
326 wxTextCtrl *net_addrs[4];
328 /* Controls for the subtitles file */
329 wxButton *subsfile_button;
330 wxCheckBox *subsfile_checkbox;
331 SubsFileDialog *subsfile_dialog;
332 wxArrayString subsfile_mrl;
334 /* Controls for the stream output */
335 wxButton *sout_button;
336 wxCheckBox *sout_checkbox;
337 SoutDialog *sout_dialog;
338 wxArrayString sout_mrl;
340 /* Controls for the demux dump */
341 wxTextCtrl *demuxdump_textctrl;
342 wxButton *demuxdump_button;
343 wxCheckBox *demuxdump_checkbox;
344 wxFileDialog *demuxdump_dialog;
347 /* Stream output Dialog */
348 class SoutDialog: public wxDialog
352 SoutDialog( intf_thread_t *p_intf, wxWindow *p_parent );
353 virtual ~SoutDialog();
355 wxArrayString GetOptions();
359 wxPanel *AccessPanel( wxWindow* parent );
360 wxPanel *MiscPanel( wxWindow* parent );
361 wxPanel *EncapsulationPanel( wxWindow* parent );
362 wxPanel *TranscodingPanel( wxWindow* parent );
365 /* Event handlers (these functions should _not_ be virtual) */
366 void OnOk( wxCommandEvent& event );
367 void OnCancel( wxCommandEvent& event );
368 void OnMRLChange( wxCommandEvent& event );
369 void OnAccessTypeChange( wxCommandEvent& event );
371 /* Event handlers for the file access output */
372 void OnFileChange( wxCommandEvent& event );
373 void OnFileBrowse( wxCommandEvent& event );
375 /* Event handlers for the net access output */
376 void OnNetChange( wxCommandEvent& event );
378 /* Event specific to the sap address */
379 void OnSAPAddrChange( wxCommandEvent& event );
381 /* Event handlers for the encapsulation panel */
382 void OnEncapsulationChange( wxCommandEvent& event );
384 /* Event handlers for the transcoding panel */
385 void OnTranscodingEnable( wxCommandEvent& event );
386 void OnTranscodingChange( wxCommandEvent& event );
388 /* Event handlers for the misc panel */
389 void OnSAPMiscChange( wxCommandEvent& event );
391 DECLARE_EVENT_TABLE();
393 intf_thread_t *p_intf;
396 wxComboBox *mrl_combo;
398 /* Controls for the access outputs */
399 wxPanel *access_subpanels[5];
400 wxCheckBox *access_checkboxes[5];
404 wxComboBox *file_combo;
405 wxSpinCtrl *net_ports[5];
406 wxTextCtrl *net_addrs[5];
408 /* Controls for the SAP announces */
409 wxPanel *misc_subpanels[1];
410 wxCheckBox *sap_checkbox;
411 wxTextCtrl *sap_addr;
413 /* Controls for the encapsulation */
414 wxRadioButton *encapsulation_radios[5];
415 int i_encapsulation_type;
417 /* Controls for transcoding */
418 wxCheckBox *video_transc_checkbox;
419 wxComboBox *video_codec_combo;
420 wxComboBox *audio_codec_combo;
421 wxCheckBox *audio_transc_checkbox;
422 wxComboBox *video_bitrate_combo;
423 wxComboBox *audio_bitrate_combo;
424 wxComboBox *audio_channels_combo;
427 /* Subtitles File Dialog */
428 class SubsFileDialog: public wxDialog
432 SubsFileDialog( intf_thread_t *p_intf, wxWindow *p_parent );
433 virtual ~SubsFileDialog();
435 wxComboBox *file_combo;
436 wxComboBox *encoding_combo;
437 wxSpinCtrl *delay_spinctrl;
438 wxSpinCtrl *fps_spinctrl;
441 /* Event handlers (these functions should _not_ be virtual) */
442 void OnOk( wxCommandEvent& event );
443 void OnCancel( wxCommandEvent& event );
444 void OnFileBrowse( wxCommandEvent& event );
446 DECLARE_EVENT_TABLE();
448 intf_thread_t *p_intf;
452 /* Preferences Dialog */
454 class PrefsDialog: public wxFrame
458 PrefsDialog( intf_thread_t *p_intf, wxWindow *p_parent );
459 virtual ~PrefsDialog();
462 wxPanel *PrefsPanel( wxWindow* parent );
464 /* Event handlers (these functions should _not_ be virtual) */
465 void OnOk( wxCommandEvent& event );
466 void OnCancel( wxCommandEvent& event );
467 void OnSave( wxCommandEvent& event );
468 void OnResetAll( wxCommandEvent& event );
470 DECLARE_EVENT_TABLE();
472 intf_thread_t *p_intf;
474 PrefsTreeCtrl *prefs_tree;
478 class Messages: public wxFrame
482 Messages( intf_thread_t *p_intf, wxWindow *p_parent );
487 /* Event handlers (these functions should _not_ be virtual) */
488 void OnClose( wxCommandEvent& event );
489 void OnVerbose( wxCommandEvent& event );
490 void OnClear( wxCommandEvent& event );
491 void OnSaveLog( wxCommandEvent& event );
493 DECLARE_EVENT_TABLE();
495 intf_thread_t *p_intf;
496 wxTextCtrl *textctrl;
497 wxTextAttr *info_attr;
498 wxTextAttr *err_attr;
499 wxTextAttr *warn_attr;
500 wxTextAttr *dbg_attr;
502 wxFileDialog *save_log_dialog;
504 vlc_bool_t b_verbose;
508 class Playlist: public wxFrame
512 Playlist( intf_thread_t *p_intf, wxWindow *p_parent );
515 void UpdatePlaylist();
516 void ShowPlaylist( bool show );
522 void DeleteItem( int item );
524 /* Event handlers (these functions should _not_ be virtual) */
525 void OnAddFile( wxCommandEvent& event );
526 void OnAddMRL( wxCommandEvent& event );
527 void OnClose( wxCommandEvent& event );
528 void OnOpen( wxCommandEvent& event );
529 void OnSave( wxCommandEvent& event );
530 void OnInvertSelection( wxCommandEvent& event );
531 void OnDeleteSelection( wxCommandEvent& event );
532 void OnSelectAll( wxCommandEvent& event );
533 void OnActivateItem( wxListEvent& event );
534 void OnKeyDown( wxListEvent& event );
537 DECLARE_EVENT_TABLE();
539 intf_thread_t *p_intf;
540 wxListView *listview;
541 int i_update_counter;
545 class FileInfo: public wxFrame
549 FileInfo( intf_thread_t *p_intf, wxWindow *p_parent );
551 void UpdateFileInfo();
554 void OnClose( wxCommandEvent& event );
556 DECLARE_EVENT_TABLE();
558 intf_thread_t *p_intf;
559 wxTreeCtrl *fileinfo_tree;
560 wxTreeItemId fileinfo_root;
561 wxString fileinfo_root_label;
565 #if !defined(__WXX11__)
566 /* Drag and Drop class */
567 class DragAndDrop: public wxFileDropTarget
570 DragAndDrop( intf_thread_t *_p_intf );
572 virtual bool OnDropFiles( wxCoord x, wxCoord y,
573 const wxArrayString& filenames );
576 intf_thread_t *p_intf;
581 void PopupMenu( intf_thread_t *_p_intf, wxWindow *p_parent,
582 const wxPoint& pos );
583 wxMenu *AudioMenu( intf_thread_t *_p_intf, wxWindow *p_parent );
584 wxMenu *VideoMenu( intf_thread_t *_p_intf, wxWindow *p_parent );
585 wxMenu *NavigMenu( intf_thread_t *_p_intf, wxWindow *p_parent );
587 class MenuEvtHandler : public wxEvtHandler
590 MenuEvtHandler( intf_thread_t *p_intf, Interface *p_main_interface );
591 virtual ~MenuEvtHandler();
593 void OnMenuEvent( wxCommandEvent& event );
594 void OnShowDialog( wxCommandEvent& event );
598 DECLARE_EVENT_TABLE()
600 intf_thread_t *p_intf;
601 Interface *p_main_interface;
604 class Menu: public wxMenu
608 Menu( intf_thread_t *p_intf, wxWindow *p_parent, int i_count,
609 char **ppsz_names, int *pi_objects, int i_start_id );
613 /* Event handlers (these functions should _not_ be virtual) */
614 void OnClose( wxCommandEvent& event );
615 void OnShowDialog( wxCommandEvent& event );
616 void OnEntrySelected( wxCommandEvent& event );
618 wxMenu *Menu::CreateDummyMenu();
619 void Menu::CreateMenuItem( wxMenu *, char *, vlc_object_t * );
620 wxMenu *Menu::CreateChoicesMenu( char *, vlc_object_t * );
622 DECLARE_EVENT_TABLE();
624 intf_thread_t *p_intf;
629 static inline int ConvertHotkeyModifiers( int i_hotkey )
631 int i_accel_flags = 0;
632 if( i_hotkey & KEY_MODIFIER_ALT ) i_accel_flags |= wxACCEL_ALT;
633 if( i_hotkey & KEY_MODIFIER_CTRL ) i_accel_flags |= wxACCEL_CTRL;
634 if( i_hotkey & KEY_MODIFIER_SHIFT ) i_accel_flags |= wxACCEL_SHIFT;
635 return i_accel_flags;
638 static inline int ConvertHotkey( int i_hotkey )
640 int i_key = i_hotkey & ~KEY_MODIFIER;
641 if( i_key & KEY_ASCII ) return i_key & KEY_ASCII;
642 else if( i_key & KEY_SPECIAL )
646 case KEY_LEFT: return WXK_LEFT;
647 case KEY_RIGHT: return WXK_RIGHT;
648 case KEY_UP: return WXK_UP;
649 case KEY_DOWN: return WXK_DOWN;
650 case KEY_SPACE: return WXK_SPACE;
651 case KEY_ENTER: return WXK_RETURN;
652 case KEY_F1: return WXK_F1;
653 case KEY_F2: return WXK_F2;
654 case KEY_F3: return WXK_F3;
655 case KEY_F4: return WXK_F4;
656 case KEY_F5: return WXK_F5;
657 case KEY_F6: return WXK_F6;
658 case KEY_F7: return WXK_F7;
659 case KEY_F8: return WXK_F8;
660 case KEY_F9: return WXK_F9;
661 case KEY_F10: return WXK_F10;
662 case KEY_F11: return WXK_F11;
663 case KEY_F12: return WXK_F12;
664 case KEY_HOME: return WXK_HOME;
665 case KEY_END: return WXK_HOME;
666 case KEY_MENU: return WXK_MENU;
667 case KEY_ESC: return WXK_ESCAPE;
668 case KEY_PAGEUP: return WXK_PRIOR;
669 case KEY_PAGEDOWN: return WXK_NEXT;
670 case KEY_TAB: return WXK_TAB;
671 case KEY_BACKSPACE: return WXK_BACK;