⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 preferences.cpp

📁 uclinux 下的vlc播放器源代码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
    }    wxTreeItemIdValue cookie, cookie2, cookie3;    ConfigTreeData *config_new;    wxTreeItemId category = GetFirstChild( root_item, cookie );    while( category.IsOk() )    {        wxTreeItemId subcategory = GetFirstChild( category, cookie2 );        while( subcategory.IsOk() )        {            wxTreeItemId module = GetFirstChild( subcategory, cookie3 );            while( module.IsOk() )            {                config_new = (ConfigTreeData *)GetItemData( module );                if( config_new && !config_new->b_submodule &&                    config_new->i_object_id == config_data->i_object_id )                {                    return config_new;                }                module = GetNextChild( subcategory, cookie3 );            }            subcategory = GetNextChild( category, cookie2 );        }        category = GetNextChild( root_item, cookie );    }    /* Found nothing */    return NULL;}void PrefsTreeCtrl::OnSelectTreeItem( wxTreeEvent& event ){    ConfigTreeData *config_data = NULL;    if( p_current )    {        p_current->Hide();#if (wxCHECK_VERSION(2,5,0))        p_sizer->Detach( p_current  );#else        p_sizer->Remove( p_current );#endif        p_current = NULL;    }    /* Don't use event.GetItem() because we also send fake events */    config_data = FindModuleConfig( (ConfigTreeData *)GetItemData(                                    GetSelection() ) );    if( config_data )    {        if( !config_data->panel )        {            /* The panel hasn't been created yet. Let's do it. */            config_data->panel =                new PrefsPanel( p_parent, p_intf, p_prefs_dialog,                                config_data );            config_data->panel->SwitchAdvanced( b_advanced );        }        else        {            config_data->panel->SwitchAdvanced( b_advanced );            config_data->panel->Show();        }        p_current = config_data->panel;        p_sizer->Add( config_data->panel, 3, wxEXPAND | wxALL, 0 );        p_sizer->Layout();    }}void PrefsTreeCtrl::OnAdvanced( wxCommandEvent& event ){    b_advanced = event.GetInt();    ConfigTreeData *config_data = !GetSelection() ? NULL :        FindModuleConfig( (ConfigTreeData *)GetItemData( GetSelection() ) );    if( config_data  )    {        config_data->panel->Hide();#if (wxCHECK_VERSION(2,5,0))        p_sizer->Detach( config_data->panel );#else        p_sizer->Remove( config_data->panel );#endif        p_current = NULL;    }    if( GetSelection() )    {        wxTreeEvent event;        OnSelectTreeItem( event );    }}/***************************************************************************** * PrefsPanel class definition. *****************************************************************************/PrefsPanel::PrefsPanel( wxWindow* parent, intf_thread_t *_p_intf,                        PrefsDialog *_p_prefs_dialog,                        ConfigTreeData *config_data )  :  wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize ){    module_config_t *p_item;    vlc_list_t *p_list = NULL;;    wxStaticText *label;    wxStaticText *help;    wxArrayString array;    module_t *p_module = NULL;    /* Initializations */    p_intf = _p_intf;    p_prefs_dialog =_p_prefs_dialog,    b_advanced = VLC_TRUE;    SetAutoLayout( TRUE );    Hide();    wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );    if( config_data->i_type == TYPE_CATEGORY )    {        label = new wxStaticText( this, -1,wxU(_( config_data->psz_name )));        wxFont heading_font = label->GetFont();        heading_font.SetPointSize( heading_font.GetPointSize() + 5 );        label->SetFont( heading_font );        sizer->Add( label, 0, wxEXPAND | wxLEFT, 10 );        sizer->Add( new wxStaticLine( this, 0 ), 0,                    wxEXPAND | wxLEFT | wxRIGHT, 2 );        hidden_text = NULL;        help = new wxStaticText( this, -1, wxU(_( config_data->psz_help ) ) );        sizer->Add( help ,0 ,wxEXPAND | wxALL, 5 );        config_sizer = NULL; config_window = NULL;    }    else    {        /* Get a pointer to the module */        if( config_data->i_type == TYPE_MODULE )        {            p_module = (module_t *)vlc_object_get( p_intf,                                                   config_data->i_object_id );        }        else        {            /* List the plugins */            int i_index;            vlc_bool_t b_found = VLC_FALSE;            p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );            if( !p_list ) return;            for( i_index = 0; i_index < p_list->i_count; i_index++ )            {                p_module = (module_t *)p_list->p_values[i_index].p_object;                if( !strcmp( p_module->psz_object_name, "main" ) )                {                    b_found = VLC_TRUE;                    break;                }            }            if( !p_module && !b_found )            {                msg_Warn( p_intf, "unable to create preferences "                                  "(main module not found)" );                return;            }        }        if( p_module->i_object_type != VLC_OBJECT_MODULE )        {            /* 0OOoo something went really bad */            return;        }        /* Enumerate config options and add corresponding config boxes         * (submodules don't have config options, they are stored in the         *  parent module) */        if( p_module->b_submodule )            p_item = ((module_t *)p_module->p_parent)->p_config;        else            p_item = p_module->p_config;        /* Find the category if it has been specified */        if( config_data->i_type == TYPE_SUBCATEGORY ||            config_data->i_type == TYPE_CATSUBCAT )        {            do            {                if( p_item->i_type == CONFIG_SUBCATEGORY &&                    ( config_data->i_type == TYPE_SUBCATEGORY &&                      p_item->i_value == config_data->i_object_id ) ||                    ( config_data->i_type == TYPE_CATSUBCAT &&                      p_item->i_value == config_data->i_subcat_id ) )                {                    break;                }                if( p_item->i_type == CONFIG_HINT_END )                    break;            } while( p_item++ );        }        /* Add a head title to the panel */        char *psz_head;        if( config_data->i_type == TYPE_SUBCATEGORY ||            config_data->i_type == TYPE_CATSUBCAT )        {            psz_head = config_data->psz_name;            p_item++;        }        else        {            psz_head = p_module->psz_longname;        }        label = new wxStaticText( this, -1,                      wxU(_( psz_head ? psz_head : _("Unknown") ) ) );        wxFont heading_font = label->GetFont();        heading_font.SetPointSize( heading_font.GetPointSize() + 5 );        label->SetFont( heading_font );        sizer->Add( label, 0, wxEXPAND | wxLEFT, 10 );        sizer->Add( new wxStaticLine( this, 0 ), 0,                    wxEXPAND | wxLEFT | wxRIGHT, 2 );        /* Now put all the config options into a scrolled window */        config_sizer = new wxBoxSizer( wxVERTICAL );        config_window = new wxScrolledWindow( this, -1, wxDefaultPosition,            wxDefaultSize, wxBORDER_NONE | wxHSCROLL | wxVSCROLL );        config_window->SetAutoLayout( TRUE );        config_window->SetScrollRate( 5, 5 );        if( p_item ) do        {            /* If a category has been specified, check we finished the job */            if( ( ( config_data->i_type == TYPE_SUBCATEGORY &&                    p_item->i_value != config_data->i_object_id ) ||                  ( config_data->i_type == TYPE_CATSUBCAT  &&                    p_item->i_value != config_data->i_subcat_id ) ) &&                (p_item->i_type == CONFIG_CATEGORY ||                  p_item->i_type == CONFIG_SUBCATEGORY ) )                break;            ConfigControl *control =                CreateConfigControl( VLC_OBJECT(p_intf),                                     p_item, config_window );            /* Don't add items that were not recognized */            if( control == NULL ) continue;            /* Add the config data to our array so we can keep a trace of it */            config_array.Add( control );            config_sizer->Add( control, 0, wxEXPAND | wxALL, 2 );        }        while( !( p_item->i_type == CONFIG_HINT_END ||               ( ( config_data->i_type == TYPE_SUBCATEGORY ||                   config_data->i_type == TYPE_CATSUBCAT ) &&                 ( p_item->i_type == CONFIG_CATEGORY ||                   p_item->i_type == CONFIG_SUBCATEGORY ) ) ) && p_item++ );        config_sizer->Layout();        config_window->SetSizer( config_sizer );        sizer->Add( config_window, 1, wxEXPAND | wxALL, 5 );        hidden_text = new wxStaticText( this, -1,                        wxU( _( "Some options are available but hidden. " \                                "Check \"Advanced options\" to see them." ) ) );        sizer->Add( hidden_text );        /* And at last put a useful help string if available */        if( config_data->psz_help && *config_data->psz_help )        {            sizer->Add( new wxStaticLine( this, 0 ), 0,                        wxEXPAND | wxLEFT | wxRIGHT, 2 );            help = new wxStaticText( this, -1, wxU(_(config_data->psz_help)),                                     wxDefaultPosition, wxDefaultSize,                                     wxALIGN_LEFT,                                     wxT("") );            sizer->Add( help ,0 ,wxEXPAND | wxALL, 5 );        }        if( config_data->i_type == TYPE_MODULE )        {            vlc_object_release( p_module );        }        else        {            vlc_list_release( p_list );        }    }    sizer->Layout();    SetSizer( sizer );    Show();}void PrefsPanel::ApplyChanges(){    vlc_value_t val;    for( size_t i = 0; i < config_array.GetCount(); i++ )    {        ConfigControl *control = config_array.Item(i);        switch( control->GetType() )        {        case CONFIG_ITEM_STRING:        case CONFIG_ITEM_FILE:        case CONFIG_ITEM_DIRECTORY:        case CONFIG_ITEM_MODULE:        case CONFIG_ITEM_MODULE_CAT:        case CONFIG_ITEM_MODULE_LIST:        case CONFIG_ITEM_MODULE_LIST_CAT:            config_PutPsz( p_intf, control->GetName().mb_str(wxConvUTF8),                           control->GetPszValue().mb_str(wxConvUTF8) );            break;        case CONFIG_ITEM_KEY:            /* So you don't need to restart to have the changes take effect */            val.i_int = control->GetIntValue();            var_Set( p_intf->p_vlc, control->GetName().mb_str(wxConvUTF8), val );        case CONFIG_ITEM_INTEGER:        case CONFIG_ITEM_BOOL:            config_PutInt( p_intf, control->GetName().mb_str(wxConvUTF8),                           control->GetIntValue() );            break;        case CONFIG_ITEM_FLOAT:            config_PutFloat( p_intf, control->GetName().mb_str(wxConvUTF8),                             control->GetFloatValue() );            break;        }    }}void PrefsPanel::SwitchAdvanced( vlc_bool_t b_new_advanced ){    bool hidden = false;    if( b_advanced == b_new_advanced )    {        goto hide;    }    if( config_sizer && config_window )    {        b_advanced = b_new_advanced;        for( size_t i = 0; i < config_array.GetCount(); i++ )        {            ConfigControl *control = config_array.Item(i);            if( control->IsAdvanced() )            {                if( !b_advanced ) hidden = true;                control->Show( b_advanced );                config_sizer->Show( control, b_advanced );            }        }        config_sizer->Layout();        config_window->FitInside();        config_window->Refresh();    }hide:    if( hidden && hidden_text )    {        hidden_text->Show( true );        config_sizer->Show( hidden_text, true );    }    else if ( hidden_text )    {        hidden_text->Show( false );        config_sizer->Show( hidden_text, false );    }    return;}

⌨️ 快捷键说明

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