open.cpp
来自「video linux conference」· C++ 代码 · 共 1,444 行 · 第 1/4 页
CPP
1,444 行
}OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent, int i_access_method, int i_arg, int _i_method ): wxDialog( _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_disc_title = 0; i_open_arg = i_arg; 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) ); 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 *common_opt_sizer = new wxFlexGridSizer( 5, 1, 20 ); if( i_method == OPEN_NORMAL ) { /* Create Stream Output checkox */ sout_checkbox = new wxCheckBox( panel, SoutEnable_Event, wxU(_("Stream output")) ); sout_checkbox->SetToolTip( wxU(_("Use VLC as a server of streams")) ); common_opt_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 ); common_opt_sizer->Add( sout_button, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL ); common_opt_sizer->Add( new wxPanel( this, -1 ), 1, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL ); } /* Create caching options */ caching_checkbox = new wxCheckBox( panel, CachingEnable_Event, wxU(_("Caching")) ); caching_checkbox->SetToolTip( wxU(_("Change the default caching value " "(in milliseconds)")) ); common_opt_sizer->Add( caching_checkbox, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL ); caching_value = new wxSpinCtrl( panel, CachingChange_Event ); caching_value->SetRange( 0, 1000000 ); caching_value->Disable(); common_opt_sizer->Add( caching_value, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL ); /* Separation */ wxStaticLine *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 );#if (!wxCHECK_VERSION(2,5,0)) wxNotebookSizer *notebook_sizer = new wxNotebookSizer( notebook );#endif 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 ); module_t *p_module = config_FindModule( VLC_OBJECT(p_intf), "v4l" ); 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_shortname ? p_module->psz_shortname : p_module->psz_object_name ), i_access_method == CAPTURE_ACCESS ); } p_module = config_FindModule( VLC_OBJECT(p_intf), "pvr" ); 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_shortname ? p_module->psz_shortname : p_module->psz_object_name ), i_access_method == CAPTURE_ACCESS ); } p_module = config_FindModule( VLC_OBJECT(p_intf), "dvb" ); 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_shortname ? p_module->psz_shortname : p_module->psz_object_name ), i_access_method == CAPTURE_ACCESS ); } 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_shortname ? p_module->psz_shortname : p_module->psz_object_name ), i_access_method == CAPTURE_ACCESS ); } /* Update Disc panel */ wxCommandEvent dummy_event; OnDiscTypeChange( dummy_event ); /* Update Net panel */ dummy_event.SetId( NetRadio1_Event ); OnNetTypeChange( dummy_event ); /* 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 );#if (!wxCHECK_VERSION(2,5,0)) panel_sizer->Add( notebook_sizer, 1, wxEXPAND | wxALL, 5 );#else panel_sizer->Add( notebook, 1, wxEXPAND | wxALL, 5 );#endif panel_sizer->Add( common_opt_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; if( sout_dialog ) delete sout_dialog; if( subsfile_dialog ) delete subsfile_dialog;}int OpenDialog::Show( int i_access_method, int i_arg ){ notebook->SetSelection( i_access_method ); int i_ret = wxDialog::Show(); Raise(); SetFocus(); i_open_arg = i_arg; return i_ret;}int OpenDialog::Show(){ int i_ret = wxDialog::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) ); 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 separate 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(); char *psz_subsfile = config_GetPsz( p_intf, "sub-file" ); if( psz_subsfile && *psz_subsfile ) { subsfile_checkbox->SetValue(TRUE); subsfile_button->Enable(); subsfile_mrl.Add( wxString(wxT("sub-file=")) + wxL2U(psz_subsfile) ); } if( psz_subsfile ) free( psz_subsfile ); subsfile_sizer->Add( subsfile_button, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL ); sizer->Add( file_sizer, 0, wxEXPAND | wxALL, 5 ); sizer->Add( subsfile_sizer, 0, wxEXPAND | wxALL, 5 ); panel->SetSizerAndFit( sizer ); return panel;}wxPanel *OpenDialog::DiscPanel( wxWindow* parent ){ wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition, wxSize(200, 200) ); wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL ); wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 3, 20 ); static const wxString disc_type_array[] = { wxU(_("DVD (menus)")), wxU(_("DVD")), wxU(_("VCD")), wxU(_("Audio CD")), }; disc_type = new wxRadioBox( panel, DiscType_Event, wxU(_("Disc type")), wxDefaultPosition, wxDefaultSize, WXSIZEOF(disc_type_array), disc_type_array, WXSIZEOF(disc_type_array), wxRA_SPECIFY_COLS ); sizer_row->Add( disc_type, i_disc_type_selection, wxEXPAND | wxALL, 5 ); wxStaticText *label = new wxStaticText( panel, -1, wxU(_("Device name")) ); disc_device = new wxTextCtrl( panel, DiscDevice_Event, wxT(""), wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER); sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL ); sizer->Add( disc_device, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL ); disc_title_label = new wxStaticText( panel, -1, wxU(_("Title")) ); disc_title = new wxSpinCtrl( panel, DiscTitle_Event ); sizer->Add( disc_title_label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL ); sizer->Add( disc_title, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL ); disc_chapter_label = new wxStaticText( panel, -1, wxU(_("Chapter")) ); disc_chapter = new wxSpinCtrl( panel, DiscChapter_Event ); sizer->Add( disc_chapter_label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL ); sizer->Add( disc_chapter, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL ); disc_sub_label = new wxStaticText( panel, -1, wxU(_("Subtitles track")) ); disc_sub = new wxSpinCtrl( panel, DiscSub_Event ); sizer->Add( disc_sub_label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL ); sizer->Add( disc_sub, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL ); disc_sub->SetRange( -1, 255 ); i_disc_sub = config_GetInt( p_intf, "sub-track" ); disc_sub->SetValue( i_disc_sub ); sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 ); panel->SetSizerAndFit( sizer_row ); return panel;}wxPanel *OpenDialog::NetPanel( wxWindow* parent ){ int i; wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition, wxSize(200, 200) ); wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL ); wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 4, 20 ); static const wxString net_type_array[] = { wxU(_("UDP/RTP")), wxU(_("UDP/RTP Multicast")), wxU(_("HTTP/HTTPS/FTP/MMS")), wxU(_("RTSP")) }; for( i=0; i<4; i++ ) { net_radios[i] = new wxRadioButton( panel, NetRadio1_Event + i, net_type_array[i], wxDefaultPosition, wxDefaultSize, wxRB_SINGLE ); net_subpanels[i] = new wxPanel( panel, -1, wxDefaultPosition, wxDefaultSize ); } /* Timeshift */ net_timeshift = new wxCheckBox( panel, NetTimeshift_Event, wxU(_("Allow timeshifting")) ); /* UDP/RTP row */ wxFlexGridSizer *subpanel_sizer;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?