📄 open.cpp
字号:
/***************************************************************************** * open.cpp : wxWindows plugin for vlc ***************************************************************************** * Copyright (C) 2000-2004 VideoLAN * $Id: open.cpp,v 1.69 2004/02/14 12:36:16 gbazin Exp $ * * Authors: Gildas Bazin <gbazin@netcourrier.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. *****************************************************************************//***************************************************************************** * Preamble *****************************************************************************/#include <stdlib.h> /* malloc(), free() */#include <errno.h> /* ENOMEM */#include <string.h> /* strerror() */#include <stdio.h>#include <vlc/vlc.h>#include <wx/combobox.h>#include <wx/statline.h>#include <wx/tokenzr.h>#include <vlc/intf.h>#include "wxwindows.h"#include "preferences_widgets.h"#ifndef wxRB_SINGLE# define wxRB_SINGLE 0#endif/***************************************************************************** * Event Table. *****************************************************************************//* IDs for the controls and the menu commands */enum{ Notebook_Event = wxID_HIGHEST, MRL_Event, FileBrowse_Event, FileName_Event, DiscType_Event, DiscDevice_Event, DiscTitle_Event, DiscChapter_Event, NetType_Event, NetRadio1_Event, NetRadio2_Event, NetRadio3_Event, NetRadio4_Event, NetPort1_Event, NetPort2_Event, NetPort3_Event, NetAddr1_Event, NetAddr2_Event, NetAddr3_Event, NetAddr4_Event, NetForceIPv6_Event,#ifndef WIN32 VideoType_Event, VideoDevice_Event, VideoChannel_Event, V4LSettings_Event,#endif SubsFileEnable_Event, SubsFileSettings_Event, SoutEnable_Event, SoutSettings_Event,};BEGIN_EVENT_TABLE(OpenDialog, wxFrame) /* Button events */ EVT_BUTTON(wxID_OK, OpenDialog::OnOk) EVT_BUTTON(wxID_CANCEL, OpenDialog::OnCancel) EVT_NOTEBOOK_PAGE_CHANGED(Notebook_Event, OpenDialog::OnPageChange) EVT_TEXT(MRL_Event, OpenDialog::OnMRLChange) /* Events generated by the file panel */ EVT_TEXT(FileName_Event, OpenDialog::OnFilePanelChange) EVT_BUTTON(FileBrowse_Event, OpenDialog::OnFileBrowse) /* Events generated by the disc panel */ EVT_RADIOBOX(DiscType_Event, OpenDialog::OnDiscTypeChange) EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscDeviceChange) EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscPanelChange) EVT_TEXT(DiscTitle_Event, OpenDialog::OnDiscPanelChange) EVT_SPINCTRL(DiscTitle_Event, OpenDialog::OnDiscPanelChange) EVT_TEXT(DiscChapter_Event, OpenDialog::OnDiscPanelChange) EVT_SPINCTRL(DiscChapter_Event, OpenDialog::OnDiscPanelChange) /* Events generated by the net panel */ EVT_RADIOBUTTON(NetRadio1_Event, OpenDialog::OnNetTypeChange) EVT_RADIOBUTTON(NetRadio2_Event, OpenDialog::OnNetTypeChange) EVT_RADIOBUTTON(NetRadio3_Event, OpenDialog::OnNetTypeChange) EVT_RADIOBUTTON(NetRadio4_Event, OpenDialog::OnNetTypeChange) EVT_TEXT(NetPort1_Event, OpenDialog::OnNetPanelChange) EVT_SPINCTRL(NetPort1_Event, OpenDialog::OnNetPanelChange) EVT_TEXT(NetPort2_Event, OpenDialog::OnNetPanelChange) EVT_SPINCTRL(NetPort2_Event, OpenDialog::OnNetPanelChange) EVT_TEXT(NetPort3_Event, OpenDialog::OnNetPanelChange) EVT_SPINCTRL(NetPort3_Event, OpenDialog::OnNetPanelChange) EVT_TEXT(NetAddr2_Event, OpenDialog::OnNetPanelChange) EVT_TEXT(NetAddr3_Event, OpenDialog::OnNetPanelChange) EVT_TEXT(NetAddr4_Event, OpenDialog::OnNetPanelChange) EVT_CHECKBOX(NetForceIPv6_Event, OpenDialog::OnNetPanelChange)#ifndef WIN32 /* Events generated by the v4l panel */ EVT_RADIOBOX(VideoType_Event, OpenDialog::OnV4LTypeChange) EVT_TEXT(VideoDevice_Event, OpenDialog::OnV4LPanelChange) EVT_SPINCTRL(VideoChannel_Event, OpenDialog::OnV4LPanelChange) EVT_BUTTON(V4LSettings_Event, OpenDialog::OnV4LSettingsChange)#endif /* Events generated by the subtitle file buttons */ EVT_CHECKBOX(SubsFileEnable_Event, OpenDialog::OnSubsFileEnable) EVT_BUTTON(SubsFileSettings_Event, OpenDialog::OnSubsFileSettings) /* Events generated by the stream output buttons */ EVT_CHECKBOX(SoutEnable_Event, OpenDialog::OnSoutEnable) EVT_BUTTON(SoutSettings_Event, OpenDialog::OnSoutSettings) /* Hide the window when the user closes the window */ EVT_CLOSE(OpenDialog::OnCancel)END_EVENT_TABLE()/***************************************************************************** * AutoBuiltPanel. *****************************************************************************/WX_DEFINE_ARRAY(ConfigControl *, ArrayOfConfigControls);class AutoBuiltPanel : public wxPanel{public: AutoBuiltPanel() { } AutoBuiltPanel( wxWindow *, OpenDialog *, intf_thread_t *, const module_t * ); virtual ~AutoBuiltPanel() {} wxString name; ArrayOfConfigControls config_array;private: intf_thread_t *p_intf;};void AutoBuildCallback( void *p_data ){ ((OpenDialog *)p_data)->UpdateMRL();}AutoBuiltPanel::AutoBuiltPanel( wxWindow *parent, OpenDialog *dialog, intf_thread_t *_p_intf, const module_t *p_module ) : wxPanel( parent, -1, wxDefaultPosition, wxSize(200, 200) ), name( wxU(p_module->psz_object_name) ), p_intf( _p_intf ){ wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL ); module_config_t *p_item = p_module->p_config; if( p_item ) do { if( p_item->i_type & CONFIG_HINT || p_item->b_advanced ) continue; ConfigControl *control = CreateConfigControl( VLC_OBJECT(p_intf), p_item, this ); config_array.Add( control ); /* Don't add items that were not recognized */ if( control == NULL ) continue; control->SetUpdateCallback( AutoBuildCallback, (void *)dialog ); sizer->Add( control, 0, wxEXPAND | wxALL, 2 ); } while( p_item->i_type != CONFIG_HINT_END && p_item++ ); this->SetSizerAndFit( sizer );}/***************************************************************************** * Constructor. *****************************************************************************/OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent, int i_access_method, int i_arg ): wxFrame( _p_parent, -1, wxU(_("Open...")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE ){ OpenDialog( _p_intf, _p_parent, i_access_method, i_arg, OPEN_NORMAL );}OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent, int i_access_method, int i_arg, int _i_method ): wxFrame( _p_parent, -1, wxU(_("Open...")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE ){ /* Initializations */ i_method = _i_method; p_intf = _p_intf; p_parent = _p_parent; SetIcon( *p_intf->p_sys->p_icon ); file_dialog = NULL; i_disc_type_selection = 0; i_open_arg = i_arg;#ifndef WIN32 v4l_dialog = NULL;#endif sout_dialog = NULL; subsfile_dialog = NULL; b_disc_device_changed = false; /* Create a panel to put everything in */ wxPanel *panel = new wxPanel( this, -1 ); panel->SetAutoLayout( TRUE ); /* Create MRL combobox */ wxBoxSizer *mrl_sizer_sizer = new wxBoxSizer( wxHORIZONTAL ); wxStaticBox *mrl_box = new wxStaticBox( panel, -1, wxU(_("Media Resource Locator (MRL)")) ); wxStaticBoxSizer *mrl_sizer = new wxStaticBoxSizer( mrl_box, wxHORIZONTAL ); wxStaticText *mrl_label = new wxStaticText( panel, -1, wxU(_("Open :")) ); mrl_combo = new wxComboBox( panel, MRL_Event, wxT(""), wxPoint(20,25), wxSize(120, -1), 0, NULL ); mrl_combo->SetToolTip( wxU(_("You can use this field directly by typing " "the full MRL you want to open.\n""Alternatively, the field will be " "filled automatically when you use the controls below.")) ); mrl_sizer->Add( mrl_label, 0, wxALL | wxALIGN_CENTER, 5 ); mrl_sizer->Add( mrl_combo, 1, wxALL | wxALIGN_CENTER, 5 ); mrl_sizer_sizer->Add( mrl_sizer, 1, wxEXPAND | wxALL, 5 ); /* Create Static Text */ wxStaticText *label = new wxStaticText( panel, -1, wxU(_("Alternatively, you can build an MRL using one of the " "following predefined targets:")) ); wxFlexGridSizer *sout_sizer = NULL; wxStaticLine *static_line = NULL; if( i_method == OPEN_NORMAL ) { /* Create Stream Output checkox */ sout_sizer = new wxFlexGridSizer( 2, 1, 20 ); sout_checkbox = new wxCheckBox( panel, SoutEnable_Event, wxU(_("Stream output")) ); sout_checkbox->SetToolTip( wxU(_("Use VLC as a server of streams")) ); sout_sizer->Add( sout_checkbox, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL ); sout_button = new wxButton( panel, SoutSettings_Event, wxU(_("Settings...")) ); sout_button->Disable(); char *psz_sout = config_GetPsz( p_intf, "sout" ); if( psz_sout && *psz_sout ) { sout_checkbox->SetValue(TRUE); sout_button->Enable(); subsfile_mrl.Add( wxString(wxT("sout=")) + wxL2U(psz_sout) ); } if( psz_sout ) free( psz_sout ); sout_sizer->Add( sout_button, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL ); /* Separation */ static_line = new wxStaticLine( panel, wxID_OK ); } /* Create the buttons */ wxButton *ok_button = new wxButton( panel, wxID_OK, wxU(_("OK")) ); ok_button->SetDefault(); wxButton *cancel_button = new wxButton( panel, wxID_CANCEL, wxU(_("Cancel")) ); /* Create notebook */ notebook = new wxNotebook( panel, Notebook_Event ); wxNotebookSizer *notebook_sizer = new wxNotebookSizer( notebook ); notebook->AddPage( FilePanel( notebook ), wxU(_("File")), i_access_method == FILE_ACCESS ); notebook->AddPage( DiscPanel( notebook ), wxU(_("Disc")), i_access_method == DISC_ACCESS ); notebook->AddPage( NetPanel( notebook ), wxU(_("Network")), i_access_method == NET_ACCESS );#ifndef WIN32 notebook->AddPage( V4LPanel( notebook ), wxU(_("Video for Linux")), i_access_method == V4L_ACCESS );#endif module_t *p_module = config_FindModule( VLC_OBJECT(p_intf), "dshow" ); if( p_module ) { AutoBuiltPanel *autopanel = new AutoBuiltPanel( notebook, this, p_intf, p_module ); input_tab_array.Add( autopanel ); notebook->AddPage( autopanel, wxU( p_module->psz_longname ) ); } /* Update Disc panel */ wxCommandEvent dummy_event; OnDiscTypeChange( dummy_event ); /* Update Net panel */ dummy_event.SetId( NetRadio1_Event ); OnNetTypeChange( dummy_event );#ifndef WIN32 /* Update v4l panel */ dummy_event.SetId( VideoType_Event ); OnV4LTypeChange( dummy_event );#endif /* Update MRL */ wxNotebookEvent event( wxEVT_NULL, 0, i_access_method ); OnPageChange( event ); /* Place everything in sizers */ wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL ); button_sizer->Add( ok_button, 0, wxALL, 5 ); button_sizer->Add( cancel_button, 0, wxALL, 5 ); button_sizer->Layout(); wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL ); panel_sizer->Add( mrl_sizer_sizer, 0, wxEXPAND, 5 ); panel_sizer->Add( label, 0, wxEXPAND | wxALL, 5 ); panel_sizer->Add( notebook_sizer, 1, wxEXPAND | wxALL, 5 ); if( i_method == OPEN_NORMAL) { panel_sizer->Add( sout_sizer, 0, wxALIGN_LEFT | wxALL, 5 ); panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 ); } panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALL, 5 ); panel_sizer->Layout(); panel->SetSizerAndFit( panel_sizer ); main_sizer->Add( panel, 1, wxGROW, 0 ); main_sizer->Layout(); SetSizerAndFit( main_sizer );}OpenDialog::~OpenDialog(){ /* Clean up */ if( file_dialog ) delete file_dialog;#ifndef WIN32 if( v4l_dialog ) delete v4l_dialog;#endif if( sout_dialog ) delete sout_dialog; if( subsfile_dialog ) delete subsfile_dialog;}int OpenDialog::Show( int i_access_method, int i_arg ){ int i_ret; notebook->SetSelection( i_access_method ); i_ret = wxFrame::Show(); Raise(); SetFocus(); i_open_arg = i_arg; return i_ret;}int OpenDialog::Show(){ int i_ret; i_ret = wxFrame::Show(); Raise(); SetFocus(); return i_ret;}/***************************************************************************** * Private methods. *****************************************************************************/wxPanel *OpenDialog::FilePanel( wxWindow* parent ){ wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition, wxSize(200, 200) ); wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL ); /* Create browse file line */ wxBoxSizer *file_sizer = new wxBoxSizer( wxHORIZONTAL ); file_combo = new wxComboBox( panel, FileName_Event, wxT(""), wxPoint(20,25), wxSize(200, -1), 0, NULL ); wxButton *browse_button = new wxButton( panel, FileBrowse_Event, wxU(_("Browse...")) ); file_sizer->Add( file_combo, 1, wxALL, 5 ); file_sizer->Add( browse_button, 0, wxALL, 5 ); /* Create Subtitles File checkox */ wxFlexGridSizer *subsfile_sizer = new wxFlexGridSizer( 2, 1, 20 ); subsfile_checkbox = new wxCheckBox( panel, SubsFileEnable_Event, wxU(_("Subtitle options")) ); subsfile_checkbox->SetToolTip( wxU(_("Force options for seperate subtitle files.")) ); subsfile_sizer->Add( subsfile_checkbox, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL ); subsfile_button = new wxButton( panel, SubsFileSettings_Event, wxU(_("Settings...")) ); subsfile_button->Disable();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -