wizard.cpp

来自「uclinux 下的vlc播放器源代码」· C++ 代码 · 共 1,664 行 · 第 1/4 页

CPP
1,664
字号
    WizardDialog *p_parent;    wxWizardPage *p_prev;    wxWizardPage *p_next;    wxSpinCtrl *ttl_spin;};BEGIN_EVENT_TABLE(wizStreamingExtraPage, wxWizardPage)    EVT_CHECKBOX( SAP_Event, wizStreamingExtraPage::OnSAP )    EVT_WIZARD_PAGE_CHANGING(-1, wizStreamingExtraPage::OnWizardPageChanging)END_EVENT_TABLE()/* Local functions */static void pageHeader( wxWindow *window, wxBoxSizer *sizer,                       char *psz_title, char *psz_text);static void pageHeader( wxWindow *window, wxBoxSizer *sizer,                        char *psz_title, char *psz_text){    wxStaticText *wtitle = new wxStaticText( window, -1, wxU( psz_title ) );    wxFont font = wtitle->GetFont();    font.SetPointSize(14);    wtitle->SetFont(font);    sizer->Add( wtitle, 0, wxALL, 5 );    sizer->Add( new wxStaticText( window, -1,                wxU( vlc_wraptext( psz_text , TEXTWIDTH ) ) ),                        0, wxALL, 5 );}/*************************************************************************** * Implementation of the pages ***************************************************************************//*************************************************** * First page: choose between stream and transcode * ***************************************************/wizHelloPage::wizHelloPage( wxWizard *parent) : wxWizardPageSimple(parent){        i_action = 0;        p_parent = (WizardDialog *)parent;        wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);        /* Create the texts */        pageHeader( this, mainSizer, HELLO_TITLE, HELLO_TEXT );        /* Create the radio buttons with their helps */        action_radios[0] = new wxRadioButton( this, ActionRadio0_Event,                                              wxU( HELLO_STREAMING ) );        action_radios[1] = new wxRadioButton( this, ActionRadio1_Event,                                              wxU( HELLO_TRANSCODE ) );        i_action = 0;        mainSizer->Add( 0, 0, 1 );        wxBoxSizer *stream_sizer = new wxBoxSizer( wxHORIZONTAL );        stream_sizer->Add( action_radios[0], 0, wxALL, 5 );        stream_sizer->Add( 0,0,1 );        stream_sizer->Add( new wxButton( this, MoreInfoStreaming_Event,                                wxU( _("More Info")) ), 0, 0, 0 );        mainSizer->Add( stream_sizer, 0, wxALL | wxEXPAND , 5 );        wxBoxSizer *transcode_sizer = new wxBoxSizer( wxHORIZONTAL );        transcode_sizer->Add( action_radios[1], 0, wxALL, 5 );        transcode_sizer->Add( 0,0,1);        transcode_sizer->Add( new wxButton( this, MoreInfoTranscode_Event,                                wxU( _("More Info")) ), 0 ,  0 , 0 );        mainSizer->Add( transcode_sizer, 0, wxALL | wxEXPAND, 5 );        mainSizer->Add( 0, 0, 1 );        mainSizer->Add( new wxStaticLine(this, -1 ), 0, wxEXPAND| wxTOP|                        wxBOTTOM, 5 );        mainSizer->Add( new wxStaticText(this, -1,                        wxU( vlc_wraptext(HELLO_NOTICE , TEXTWIDTH ))),                        0, wxALL, 5 );        SetSizer(mainSizer);        mainSizer->Fit(this);    }void wizHelloPage::OnMoreInfo(wxCommandEvent& event){    wxString msg;    msg.Printf( wxString( wxU( event.GetId() == MoreInfoStreaming_Event ?                                    MOREINFO_STREAM :                                    MOREINFO_TRANSCODE ) ) );    wxMessageBox( msg, wxU(_("More information")),                  wxOK | wxICON_INFORMATION, this->p_parent );}void wizHelloPage::OnActionChange( wxCommandEvent& event ){    i_action = event.GetId() - ActionRadio0_Event;    ((wizInputPage *)GetNext())->SetAction( i_action );    p_parent->SetAction( i_action );}void wizHelloPage::OnWizardPageChanging(wxWizardEvent& event){    ((wizInputPage *)GetNext())->SetAction( i_action );    p_parent->SetAction( i_action );}/************************************ * Second page: choose input stream * ************************************/wizInputPage::wizInputPage( wxWizard *parent, wxWizardPage *prev, intf_thread_t *_p_intf) :              wxWizardPage(parent){    p_prev = prev;    p_intf = _p_intf;    p_parent = (WizardDialog *)parent;    b_chosen = false;    p_open_dialog = NULL;    listview = NULL;    mrl_text = NULL;    mainSizer = new wxBoxSizer(wxVERTICAL);    /* Create the texts */    pageHeader( this, mainSizer, INPUT_TITLE, INPUT_TEXT );    mainSizer->Add( 0,20,0 );    radio_panel = new wxPanel(this, -1);    radio_panel->SetAutoLayout( TRUE );    wxBoxSizer *radioSizer = new wxBoxSizer(wxVERTICAL);    /* Create the radio buttons */    input_radios[0] = new wxRadioButton( radio_panel, InputRadio0_Event ,                               wxU( INPUT_OPEN ) );    radioSizer->Add( input_radios[0], 0, wxALL, 5 );    input_radios[1] = new wxRadioButton( radio_panel, InputRadio1_Event ,                               wxU( INPUT_PL ) );      radioSizer->Add( input_radios[1], 0, wxALL, 5 );    radio_panel->SetSizer( radioSizer );    radioSizer->Layout();    radioSizer->Fit(radio_panel);    mainSizer->Add( radio_panel );    i_input = 0;    /* Open Panel */    open_panel = new wxPanel(this, -1);    open_panel->SetAutoLayout( TRUE );    wxBoxSizer *openSizer = new wxBoxSizer(wxHORIZONTAL);    mrl_text = new wxTextCtrl( open_panel, -1, wxU( "" ), wxDefaultPosition,                              wxSize(200,25) );    openSizer->Add( mrl_text, 0 , wxALL, 5 );    openSizer->Add( new wxButton( open_panel, Choose_Event, wxU(_("Choose...")) ), 0, wxALL, 5 );    open_panel->SetSizer( openSizer );    openSizer->Layout();    openSizer->Fit(open_panel);    mainSizer->Add( open_panel );    playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,                                       VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );    if( p_playlist )    {        if( p_playlist->i_size > 0)        {            listview = new wxListView( this, ListView_Event,                                       wxDefaultPosition, wxDefaultSize,                                       wxLC_REPORT | wxSUNKEN_BORDER );            listview->InsertColumn( 0, wxU(_("Name")) );            listview->InsertColumn( 1, wxU(_("URI")) );            listview->SetColumnWidth( 0, 250 );            listview->SetColumnWidth( 1, 100 );            for( int i=0 ; i < p_playlist->i_size ; i++ )            {                wxString filename = wxL2U( p_playlist->pp_items[i]->input.                                                                    psz_name );                listview->InsertItem( i, filename );                listview->SetItem( i, 1, wxL2U( p_playlist->pp_items[i]->                                                            input.psz_uri) );                listview->SetItemData( i,                                  (long)p_playlist->pp_items[i]->input.i_id );            }            listview->Select( p_playlist->i_index , TRUE);            mainSizer->Add( listview, 1, wxALL|wxEXPAND, 5 );            listview->Hide();            mainSizer->Hide( listview );            mainSizer->Layout();        }        else        {            input_radios[1]->Disable();        }        vlc_object_release( p_playlist );    }    else    {        input_radios[1]->Disable();    }    /* Partial Extract Box */    mainSizer->Add( 0, 10, 0 );    wxStaticBox *partial_box = new wxStaticBox( this, -1,                    wxU(_("Partial Extract")) );    wxStaticBoxSizer *partial_sizer = new wxStaticBoxSizer( partial_box,                                                          wxVERTICAL );    enable_checkbox = new wxCheckBox( this, PartialEnable_Event,                                                wxU(_("Enable") ) );    enable_checkbox->SetToolTip(wxU(_(PARTIAL) ) ) ;    partial_sizer->Add( enable_checkbox, 0 , wxALIGN_CENTER_VERTICAL|wxALL, 5 ); //wxLEFT    wxFlexGridSizer *partial_sizer2 = new wxFlexGridSizer( 4 , 1 , 20 );    partial_sizer2->Add( new wxStaticText(this, -1, wxU(_( "From" ) ) ),                         0 , wxLEFT , 5 );    from_text = new wxTextCtrl( this, -1, wxT(""),                                wxDefaultPosition, wxSize( 80,25 ) );    partial_sizer2->Add( from_text, 0 , wxALIGN_RIGHT);    partial_sizer2->Add( new wxStaticText(this, -1, wxU(_( "To" ) ) ),                         0 , wxLEFT , 5 );    to_text = new wxTextCtrl( this, -1, wxT(""),                                  wxDefaultPosition, wxSize( 80 , 25 ) );    partial_sizer2->Add( to_text, 0 , wxALIGN_RIGHT );    partial_sizer->Add( partial_sizer2, 0, wxALL, 0 );    partial_sizer->Fit( partial_box );    mainSizer->Add( partial_sizer, 0, 0, 0 );    from_text->Disable();    to_text->Disable();    SetSizer(mainSizer);    mainSizer->Fit(this);    mainSizer->Layout();}wizInputPage::~wizInputPage(){}void wizInputPage::OnInputChange( wxCommandEvent& event ){    i_input = event.GetId() - InputRadio0_Event;    if( i_input == 0 )    {        if( listview )        {            listview->Hide();            mainSizer->Hide( listview );            open_panel->Show();            mainSizer->Show( open_panel );            mainSizer->Layout();        }    }    else    {        open_panel->Hide();        mainSizer->Hide( open_panel );        listview->Show();        mainSizer->Show( listview );        mainSizer->Layout();    }}void wizInputPage::OnEnablePartial(wxCommandEvent& event){   from_text->Enable( event.IsChecked() );   to_text->Enable( event.IsChecked() );}void wizInputPage::OnChoose(wxCommandEvent& event){    p_open_dialog = new OpenDialog( p_intf, this, -1, -1, OPEN_STREAM );    if(  p_open_dialog->ShowModal() == wxID_OK &&         !p_open_dialog->mrl.IsEmpty() )    {        mrl_text->SetValue(p_open_dialog->mrl[0] );    }    delete p_open_dialog;    p_open_dialog = NULL;}void wizInputPage::OnWizardPageChanging(wxWizardEvent& event){    if( i_input == 0)    {        if( mrl_text->GetValue().IsSameAs( wxT(""), TRUE ) &&                        event.GetDirection() )        {            wxMessageBox( wxU( CHOOSE_STREAM ), wxU( ERROR_MSG ),                          wxICON_WARNING | wxOK, this->p_parent );            event.Veto();            return;        }        else        {            p_parent->SetMrl( (const char *)mrl_text->GetValue().mb_str(wxConvUTF8) );        }    }    else    {        int i = -1;        i = listview->GetNextItem( i , wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);        if( i != -1 )        {            long data = listview->GetItemData( i );                        playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,                                      VLC_OBJECT_PLAYLIST, FIND_ANYWHERE);            if( p_playlist )            {                playlist_item_t * p_item = playlist_LockItemGetById(                                                   p_playlist, (int)data );                if( p_item )                {                    p_parent->SetMrl( (const char*)p_item->input.psz_uri );                }                else                    event.Veto();            }            else                event.Veto();        }    }    if( enable_checkbox->IsChecked() )    {        int i_from = atoi( from_text->GetValue().mb_str(wxConvUTF8) );        int i_to = atoi( to_text->GetValue().mb_str(wxConvUTF8) );        p_parent->SetPartial( i_from, i_to );    }    return;}wxWizardPage *wizInputPage::GetPrev() const { return p_prev; }wxWizardPage *wizInputPage::GetNext() const{    if( i_action == ACTION_STREAM )        return p_streaming_page;    else       return p_transcode_page;}void wizInputPage::SetStreamingPage( wxWizardPage *page){    p_streaming_page = page;}void wizInputPage::SetTranscodePage( wxWizardPage *page){    p_transcode_page = page;}void wizInputPage::SetAction( int i_action ){    this->i_action = i_action;}void wizInputPage::SetPintf( intf_thread_t *p_intf ){    this->p_intf = p_intf;}void wizInputPage::SetUri( char *psz_uri ){    mrl_text->SetValue( wxU( psz_uri ) );}void wizInputPage::SetPartial( int i_from, int i_to ){   wxString msg;   msg.Printf( wxString( wxT( "%i") ), i_from );   from_text->Enable( TRUE );   from_text->SetValue( msg );   msg.Printf( wxString( wxT( "%i") ), i_to );   to_text->Enable( TRUE );   to_text->SetValue( msg );   enable_checkbox->SetValue( TRUE );}/*************************************************** * First transcode page: choose codecs             * ***************************************************/wizTranscodeCodecPage::wizTranscodeCodecPage( wxWizard *parent,                       wxWizardPage *next) : wxWizardPage(parent){    int i;    p_next = next;    acodec = NULL;    vcodec = NULL;    p_parent = (WizardDialog *) parent;    wxBoxSizer *main_sizer = new wxBoxSizer(wxVERTICAL);    /* Header */    pageHeader( this, main_sizer,  TRANSCODE1_TITLE, TRANSCODE1_TEXT );    /* Video Box */    wxStaticBox *video_box = new wxStaticBox( this, -1, wxU(_("Video")) );    wxStaticBoxSizer *video_sizer = new wxStaticBoxSizer( video_box,                                                          wxVERTICAL );    /* Line 1 : only the checkbox */    wxFlexGridSizer *video_sizer1 = new wxFlexGridSizer( 2,3,20 );    video_sizer1->Add( new wxCheckBox( this, VideoEnable_Event,                       wxU(_("Transcode video") ) ), 0 , wxALIGN_CENTER_VERTICAL|wxALL , 5 );    video_sizer1->Add( 0,0,1);    /* Line 2 : codec */    video_sizer1->Add( new wxStaticText(this, -1, wxU(_("Codec"))),0,wxLEFT ,5);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?