1 /*****************************************************************************
2 * wxwindows.h: private wxWindows interface description
3 *****************************************************************************
4 * Copyright (C) 1999, 2000 VideoLAN
5 * $Id: wxwindows.h,v 1.56 2003/08/22 08:06:25 asmax 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 );
41 #define SLIDER_MAX_POS 10000
43 /* wxU is used to convert ansi/utf8 strings to unicode strings (wchar_t) */
44 #if defined( ENABLE_NLS ) && defined( HAVE_GETTEXT ) && \
45 defined( WIN32 ) && !defined( HAVE_INCLUDED_GETTEXT )
47 # define wxU(utf8) wxString(utf8, wxConvUTF8)
49 # define wxU(utf8) wxString(wxConvUTF8.cMB2WC(utf8), *wxConvCurrent)
52 #else // ENABLE_NLS && HAVE_GETTEXT && WIN32 && !HAVE_INCLUDED_GETTEXT
54 # define wxU(ansi) wxString(ansi, *wxConvCurrent)
56 # define wxU(ansi) ansi
61 wxArrayString SeparateEntries( wxString );
63 /*****************************************************************************
64 * intf_sys_t: description and status of wxwindows interface
65 *****************************************************************************/
68 /* the wx parent window */
75 /* The input thread */
76 input_thread_t * p_input;
79 int i_slider_pos; /* slider position */
80 int i_slider_oldpos; /* previous position */
81 vlc_bool_t b_slider_free; /* slider status */
83 /* The messages window */
84 msg_subscription_t* p_sub; /* message bank subscription */
86 /* Playlist management */
87 int i_playing; /* playlist selected item */
89 /* Send an event to show a dialog */
90 void (*pf_show_dialog) ( intf_thread_t *p_intf, int i_dialog, int i_arg,
91 intf_dialog_args_t *p_arg );
98 /*****************************************************************************
100 *****************************************************************************/
102 /*****************************************************************************
103 * Classes declarations.
104 *****************************************************************************/
108 class Timer: public wxTimer
112 Timer( intf_thread_t *p_intf, Interface *p_main_interface );
115 virtual void Notify();
118 intf_thread_t *p_intf;
119 Interface *p_main_interface;
120 int i_old_playing_status;
125 class Interface: public wxFrame
129 Interface( intf_thread_t *p_intf );
130 virtual ~Interface();
131 void TogglePlayButton( int i_playing_status );
133 wxBoxSizer *frame_sizer;
134 wxStatusBar *statusbar;
137 wxWindow *slider_frame;
138 wxStaticBox *slider_box;
143 void UpdateAcceleratorTable();
144 void CreateOurMenuBar();
145 void CreateOurToolBar();
146 void CreateOurSlider();
147 void Open( int i_access_method );
149 /* Event handlers (these functions should _not_ be virtual) */
150 void OnExit( wxCommandEvent& event );
151 void OnAbout( wxCommandEvent& event );
153 void OnOpenFileSimple( wxCommandEvent& event );
154 void OnOpenFile( wxCommandEvent& event );
155 void OnOpenDisc( wxCommandEvent& event );
156 void OnOpenNet( wxCommandEvent& event );
157 void OnOpenSat( wxCommandEvent& event );
158 void OnOpenV4L( wxCommandEvent& event );
159 void OnShowDialog( wxCommandEvent& event );
160 void OnPlayStream( wxCommandEvent& event );
161 void OnStopStream( wxCommandEvent& event );
162 void OnSliderUpdate( wxScrollEvent& event );
163 void OnPrevStream( wxCommandEvent& event );
164 void OnNextStream( wxCommandEvent& event );
165 void OnSlowStream( wxCommandEvent& event );
166 void OnFastStream( wxCommandEvent& event );
168 void OnMenuOpen( wxMenuEvent& event );
170 #if defined( __WXMSW__ ) || defined( __WXMAC__ )
171 void OnContextMenu2(wxContextMenuEvent& event);
173 void OnContextMenu(wxMouseEvent& event);
175 DECLARE_EVENT_TABLE();
178 intf_thread_t *p_intf;
181 int i_old_playing_status;
183 /* For auto-generated menus */
184 wxMenu *p_audio_menu;
185 vlc_bool_t b_audio_menu;
186 wxMenu *p_video_menu;
187 vlc_bool_t b_video_menu;
188 wxMenu *p_navig_menu;
189 vlc_bool_t b_navig_menu;
192 /* Dialogs Provider */
193 class DialogsProvider: public wxFrame
197 DialogsProvider( intf_thread_t *p_intf, wxWindow *p_parent );
198 virtual ~DialogsProvider();
201 void Open( int i_access_method, int i_arg );
203 /* Event handlers (these functions should _not_ be virtual) */
204 void OnExit( wxCommandEvent& event );
205 void OnPlaylist( wxCommandEvent& event );
206 void OnMessages( wxCommandEvent& event );
207 void OnFileInfo( wxCommandEvent& event );
208 void OnPreferences( wxCommandEvent& event );
210 void OnOpenFileGeneric( wxCommandEvent& event );
211 void OnOpenFileSimple( wxCommandEvent& event );
212 void OnOpenFile( wxCommandEvent& event );
213 void OnOpenDisc( wxCommandEvent& event );
214 void OnOpenNet( wxCommandEvent& event );
215 void OnOpenSat( wxCommandEvent& event );
217 void OnPopupMenu( wxCommandEvent& event );
219 void OnIdle( wxIdleEvent& event );
221 void OnExitThread( wxCommandEvent& event );
223 DECLARE_EVENT_TABLE();
225 intf_thread_t *p_intf;
228 /* Secondary windows */
229 OpenDialog *p_open_dialog;
230 wxFileDialog *p_file_dialog;
231 Playlist *p_playlist_dialog;
232 Messages *p_messages_dialog;
233 FileInfo *p_fileinfo_dialog;
234 wxFrame *p_prefs_dialog;
235 wxFileDialog *p_file_generic_dialog;
241 class SubsFileDialog;
242 class OpenDialog: public wxFrame
246 OpenDialog( intf_thread_t *p_intf, wxWindow *p_parent,
247 int i_access_method, int i_arg = 0 );
248 virtual ~OpenDialog();
251 int Show( int i_access_method, int i_arg = 0 );
256 wxPanel *FilePanel( wxWindow* parent );
257 wxPanel *DiscPanel( wxWindow* parent );
258 wxPanel *NetPanel( wxWindow* parent );
259 wxPanel *SatPanel( wxWindow* parent );
260 wxPanel *V4LPanel( wxWindow* parent );
262 void UpdateMRL( int i_access_method );
264 /* Event handlers (these functions should _not_ be virtual) */
265 void OnOk( wxCommandEvent& event );
266 void OnCancel( wxCommandEvent& event );
268 void OnPageChange( wxNotebookEvent& event );
269 void OnMRLChange( wxCommandEvent& event );
271 /* Event handlers for the file page */
272 void OnFilePanelChange( wxCommandEvent& event );
273 void OnFileBrowse( wxCommandEvent& event );
275 /* Event handlers for the disc page */
276 void OnDiscPanelChange( wxCommandEvent& event );
277 void OnDiscTypeChange( wxCommandEvent& event );
279 /* Event handlers for the net page */
280 void OnNetPanelChange( wxCommandEvent& event );
281 void OnNetTypeChange( wxCommandEvent& event );
283 /* Event handlers for the v4l page */
284 void OnV4LPanelChange( wxCommandEvent& event );
285 void OnV4LTypeChange( wxCommandEvent& event );
286 void OnV4LSettingsChange( wxCommandEvent& event );
288 /* Event handlers for the stream output */
289 void OnSubsFileEnable( wxCommandEvent& event );
290 void OnSubsFileSettings( wxCommandEvent& WXUNUSED(event) );
292 /* Event handlers for the stream output */
293 void OnSoutEnable( wxCommandEvent& event );
294 void OnSoutSettings( wxCommandEvent& WXUNUSED(event) );
296 /* Event handlers for the demux dump */
297 void OnDemuxDumpEnable( wxCommandEvent& event );
298 void OnDemuxDumpBrowse( wxCommandEvent& event );
299 void OnDemuxDumpChange( wxCommandEvent& event );
301 DECLARE_EVENT_TABLE();
303 intf_thread_t *p_intf;
305 int i_current_access_method;
307 wxComboBox *mrl_combo;
308 wxNotebook *notebook;
310 /* Controls for the file panel */
311 wxComboBox *file_combo;
312 wxFileDialog *file_dialog;
314 /* Controls for the disc panel */
315 wxRadioBox *disc_type;
316 wxTextCtrl *disc_device;
317 wxSpinCtrl *disc_title;
319 wxSpinCtrl *disc_chapter;
322 /* Controls for the net panel */
323 wxRadioBox *net_type;
325 wxPanel *net_subpanels[4];
326 wxRadioButton *net_radios[4];
327 wxSpinCtrl *net_ports[4];
329 wxTextCtrl *net_addrs[4];
331 /* Controls for the v4l panel */
332 wxRadioBox *video_type;
333 wxTextCtrl *video_device;
334 wxSpinCtrl *video_channel;
335 wxButton *v4l_button;
336 V4LDialog *v4l_dialog;
337 wxArrayString v4l_mrl;
339 /* Controls for the subtitles file */
340 wxButton *subsfile_button;
341 wxCheckBox *subsfile_checkbox;
342 SubsFileDialog *subsfile_dialog;
343 wxArrayString subsfile_mrl;
345 /* Controls for the stream output */
346 wxButton *sout_button;
347 wxCheckBox *sout_checkbox;
348 SoutDialog *sout_dialog;
349 wxArrayString sout_mrl;
351 /* Controls for the demux dump */
352 wxTextCtrl *demuxdump_textctrl;
353 wxButton *demuxdump_button;
354 wxCheckBox *demuxdump_checkbox;
355 wxFileDialog *demuxdump_dialog;
369 class V4LDialog: public wxDialog
373 V4LDialog( intf_thread_t *p_intf, wxWindow *p_parent );
374 virtual ~V4LDialog();
376 wxArrayString GetOptions();
380 wxPanel *AudioPanel( wxWindow* parent );
381 wxPanel *CommonPanel( wxWindow* parent );
382 wxPanel *BitratePanel( wxWindow* parent );
385 /* Event handlers (these functions should _not_ be virtual) */
386 void OnOk( wxCommandEvent& event );
387 void OnCancel( wxCommandEvent& event );
388 void OnMRLChange( wxCommandEvent& event );
389 void OnAudioEnable( wxCommandEvent& event );
390 void OnAudioChannel( wxCommandEvent& event );
391 void OnSizeEnable( wxCommandEvent& event );
392 void OnSize( wxCommandEvent& event );
393 void OnNormEnable( wxCommandEvent& event );
394 void OnNorm( wxCommandEvent& event );
395 void OnFrequencyEnable( wxCommandEvent& event );
396 void OnFrequency( wxCommandEvent& event );
397 void OnBitrateEnable( wxCommandEvent& event );
398 void OnBitrate( wxCommandEvent& event );
399 void OnMaxBitrateEnable( wxCommandEvent& event );
400 void OnMaxBitrate( wxCommandEvent& event );
402 DECLARE_EVENT_TABLE();
404 intf_thread_t *p_intf;
407 wxComboBox *mrl_combo;
411 /* Controls for the v4l advanced options */
412 wxPanel *common_subpanel;
413 wxPanel *common_panel;
414 wxCheckBox *size_checkbox;
415 wxComboBox *size_combo;
416 wxCheckBox *norm_checkbox;
417 wxComboBox *norm_combo;
418 wxCheckBox *frequency_checkbox;
419 wxSpinCtrl *frequency;
421 wxPanel *audio_subpanel;
422 wxPanel *audio_panel;
423 wxCheckBox *audio_checkbox;
424 wxTextCtrl *audio_device;
425 wxSpinCtrl *audio_channel;
427 wxPanel *bitrate_subpanel;
428 wxPanel *bitrate_panel;
429 wxCheckBox *bitrate_checkbox;
431 wxCheckBox *maxbitrate_checkbox;
432 wxSpinCtrl *maxbitrate;
436 /* Stream output Dialog */
437 class SoutDialog: public wxDialog
441 SoutDialog( intf_thread_t *p_intf, wxWindow *p_parent );
442 virtual ~SoutDialog();
444 wxArrayString GetOptions();
448 wxPanel *AccessPanel( wxWindow* parent );
449 wxPanel *MiscPanel( wxWindow* parent );
450 wxPanel *EncapsulationPanel( wxWindow* parent );
451 wxPanel *TranscodingPanel( wxWindow* parent );
454 /* Event handlers (these functions should _not_ be virtual) */
455 void OnOk( wxCommandEvent& event );
456 void OnCancel( wxCommandEvent& event );
457 void OnMRLChange( wxCommandEvent& event );
458 void OnAccessTypeChange( wxCommandEvent& event );
460 /* Event handlers for the file access output */
461 void OnFileChange( wxCommandEvent& event );
462 void OnFileBrowse( wxCommandEvent& event );
464 /* Event handlers for the net access output */
465 void OnNetChange( wxCommandEvent& event );
467 /* Event specific to the announce address */
468 void OnAnnounceAddrChange( wxCommandEvent& event );
470 /* Event handlers for the encapsulation panel */
471 void OnEncapsulationChange( wxCommandEvent& event );
473 /* Event handlers for the transcoding panel */
474 void OnTranscodingEnable( wxCommandEvent& event );
475 void OnTranscodingChange( wxCommandEvent& event );
477 /* Event handlers for the misc panel */
478 void OnSAPMiscChange( wxCommandEvent& event );
479 void OnSLPMiscChange( wxCommandEvent& event );
481 DECLARE_EVENT_TABLE();
483 intf_thread_t *p_intf;
486 wxComboBox *mrl_combo;
488 /* Controls for the access outputs */
489 wxPanel *access_subpanels[5];
490 wxCheckBox *access_checkboxes[5];
494 wxComboBox *file_combo;
495 wxSpinCtrl *net_ports[5];
496 wxTextCtrl *net_addrs[5];
498 /* Controls for the SAP announces */
499 wxPanel *misc_subpanels[1];
500 wxCheckBox *sap_checkbox;
501 wxCheckBox *slp_checkbox;
502 wxTextCtrl *announce_addr;
504 /* Controls for the encapsulation */
505 wxRadioButton *encapsulation_radios[5];
506 int i_encapsulation_type;
508 /* Controls for transcoding */
509 wxCheckBox *video_transc_checkbox;
510 wxComboBox *video_codec_combo;
511 wxComboBox *audio_codec_combo;
512 wxCheckBox *audio_transc_checkbox;
513 wxComboBox *video_bitrate_combo;
514 wxComboBox *audio_bitrate_combo;
515 wxComboBox *audio_channels_combo;
518 /* Subtitles File Dialog */
519 class SubsFileDialog: public wxDialog
523 SubsFileDialog( intf_thread_t *p_intf, wxWindow *p_parent );
524 virtual ~SubsFileDialog();
526 wxComboBox *file_combo;
527 wxComboBox *encoding_combo;
528 wxSpinCtrl *delay_spinctrl;
529 wxSpinCtrl *fps_spinctrl;
532 /* Event handlers (these functions should _not_ be virtual) */
533 void OnOk( wxCommandEvent& event );
534 void OnCancel( wxCommandEvent& event );
535 void OnFileBrowse( wxCommandEvent& event );
537 DECLARE_EVENT_TABLE();
539 intf_thread_t *p_intf;
543 /* Preferences Dialog */
545 class PrefsDialog: public wxFrame
549 PrefsDialog( intf_thread_t *p_intf, wxWindow *p_parent );
550 virtual ~PrefsDialog();
553 wxPanel *PrefsPanel( wxWindow* parent );
555 /* Event handlers (these functions should _not_ be virtual) */
556 void OnOk( wxCommandEvent& event );
557 void OnCancel( wxCommandEvent& event );
558 void OnSave( wxCommandEvent& event );
559 void OnResetAll( wxCommandEvent& event );
561 DECLARE_EVENT_TABLE();
563 intf_thread_t *p_intf;
565 PrefsTreeCtrl *prefs_tree;
569 class Messages: public wxFrame
573 Messages( intf_thread_t *p_intf, wxWindow *p_parent );
578 /* Event handlers (these functions should _not_ be virtual) */
579 void OnClose( wxCommandEvent& event );
580 void OnVerbose( wxCommandEvent& event );
581 void OnClear( wxCommandEvent& event );
582 void OnSaveLog( wxCommandEvent& event );
584 DECLARE_EVENT_TABLE();
586 intf_thread_t *p_intf;
587 wxTextCtrl *textctrl;
588 wxTextAttr *info_attr;
589 wxTextAttr *err_attr;
590 wxTextAttr *warn_attr;
591 wxTextAttr *dbg_attr;
593 wxFileDialog *save_log_dialog;
595 vlc_bool_t b_verbose;
599 class Playlist: public wxFrame
603 Playlist( intf_thread_t *p_intf, wxWindow *p_parent );
606 void UpdatePlaylist();
607 void ShowPlaylist( bool show );
613 void DeleteItem( int item );
615 /* Event handlers (these functions should _not_ be virtual) */
616 void OnAddFile( wxCommandEvent& event );
617 void OnAddMRL( wxCommandEvent& event );
618 void OnClose( wxCommandEvent& event );
619 void OnOpen( wxCommandEvent& event );
620 void OnSave( wxCommandEvent& event );
621 void OnInvertSelection( wxCommandEvent& event );
622 void OnDeleteSelection( wxCommandEvent& event );
623 void OnSelectAll( wxCommandEvent& event );
624 void OnRandom( wxCommandEvent& event );
625 void OnLoop ( wxCommandEvent& event );
626 void OnActivateItem( wxListEvent& event );
627 void OnKeyDown( wxListEvent& event );
630 DECLARE_EVENT_TABLE();
632 intf_thread_t *p_intf;
633 wxListView *listview;
634 int i_update_counter;
638 class FileInfo: public wxFrame
642 FileInfo( intf_thread_t *p_intf, wxWindow *p_parent );
644 void UpdateFileInfo();
647 void OnClose( wxCommandEvent& event );
649 DECLARE_EVENT_TABLE();
651 intf_thread_t *p_intf;
652 wxTreeCtrl *fileinfo_tree;
653 wxTreeItemId fileinfo_root;
654 wxString fileinfo_root_label;
658 #if !defined(__WXX11__)
659 /* Drag and Drop class */
660 class DragAndDrop: public wxFileDropTarget
663 DragAndDrop( intf_thread_t *_p_intf );
665 virtual bool OnDropFiles( wxCoord x, wxCoord y,
666 const wxArrayString& filenames );
669 intf_thread_t *p_intf;
674 void PopupMenu( intf_thread_t *_p_intf, wxWindow *p_parent,
675 const wxPoint& pos );
676 wxMenu *AudioMenu( intf_thread_t *_p_intf, wxWindow *p_parent );
677 wxMenu *VideoMenu( intf_thread_t *_p_intf, wxWindow *p_parent );
678 wxMenu *NavigMenu( intf_thread_t *_p_intf, wxWindow *p_parent );
680 class MenuEvtHandler : public wxEvtHandler
683 MenuEvtHandler( intf_thread_t *p_intf, Interface *p_main_interface );
684 virtual ~MenuEvtHandler();
686 void OnMenuEvent( wxCommandEvent& event );
687 void OnShowDialog( wxCommandEvent& event );
691 DECLARE_EVENT_TABLE()
693 intf_thread_t *p_intf;
694 Interface *p_main_interface;
697 class Menu: public wxMenu
701 Menu( intf_thread_t *p_intf, wxWindow *p_parent, int i_count,
702 char **ppsz_names, int *pi_objects, int i_start_id );
706 /* Event handlers (these functions should _not_ be virtual) */
707 void OnClose( wxCommandEvent& event );
708 void OnShowDialog( wxCommandEvent& event );
709 void OnEntrySelected( wxCommandEvent& event );
711 wxMenu *Menu::CreateDummyMenu();
712 void Menu::CreateMenuItem( wxMenu *, char *, vlc_object_t * );
713 wxMenu *Menu::CreateChoicesMenu( char *, vlc_object_t * );
715 DECLARE_EVENT_TABLE();
717 intf_thread_t *p_intf;
722 static inline int ConvertHotkeyModifiers( int i_hotkey )
724 int i_accel_flags = 0;
725 if( i_hotkey & KEY_MODIFIER_ALT ) i_accel_flags |= wxACCEL_ALT;
726 if( i_hotkey & KEY_MODIFIER_CTRL ) i_accel_flags |= wxACCEL_CTRL;
727 if( i_hotkey & KEY_MODIFIER_SHIFT ) i_accel_flags |= wxACCEL_SHIFT;
728 return i_accel_flags;
731 static inline int ConvertHotkey( int i_hotkey )
733 int i_key = i_hotkey & ~KEY_MODIFIER;
734 if( i_key & KEY_ASCII ) return i_key & KEY_ASCII;
735 else if( i_key & KEY_SPECIAL )
739 case KEY_LEFT: return WXK_LEFT;
740 case KEY_RIGHT: return WXK_RIGHT;
741 case KEY_UP: return WXK_UP;
742 case KEY_DOWN: return WXK_DOWN;
743 case KEY_SPACE: return WXK_SPACE;
744 case KEY_ENTER: return WXK_RETURN;
745 case KEY_F1: return WXK_F1;
746 case KEY_F2: return WXK_F2;
747 case KEY_F3: return WXK_F3;
748 case KEY_F4: return WXK_F4;
749 case KEY_F5: return WXK_F5;
750 case KEY_F6: return WXK_F6;
751 case KEY_F7: return WXK_F7;
752 case KEY_F8: return WXK_F8;
753 case KEY_F9: return WXK_F9;
754 case KEY_F10: return WXK_F10;
755 case KEY_F11: return WXK_F11;
756 case KEY_F12: return WXK_F12;
757 case KEY_HOME: return WXK_HOME;
758 case KEY_END: return WXK_HOME;
759 case KEY_MENU: return WXK_MENU;
760 case KEY_ESC: return WXK_ESCAPE;
761 case KEY_PAGEUP: return WXK_PRIOR;
762 case KEY_PAGEDOWN: return WXK_NEXT;
763 case KEY_TAB: return WXK_TAB;
764 case KEY_BACKSPACE: return WXK_BACK;