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

📄 preferences.cpp

📁 video linux conference
💻 CPP
📖 第 1 页 / 共 3 页
字号:
            switch( p_item->i_type )            {            case CONFIG_CATEGORY:                config_data = new ConfigTreeData;                config_data->psz_name = strdup( config_CategoryNameGet(                                                            p_item->i_value ) );                psz_help = config_CategoryHelpGet( p_item->i_value );                if( psz_help )                {                    config_data->psz_help = wraptext( strdup( psz_help ),                                                      72 , ISUTF8 );                }                else                {                    config_data->psz_help = NULL;                }                config_data->i_type = TYPE_CATEGORY;                config_data->i_object_id = p_item->i_value;                /* Add the category to the tree */                switch( p_item->i_value )                {                    case CAT_AUDIO:                        i_image = 0; break;                    case CAT_VIDEO:                        i_image = 1; break;                    case CAT_INPUT:                        i_image = 2; break;                    case CAT_SOUT:                        i_image = 3; break;                    case CAT_ADVANCED:                        i_image = 4; break;                    case CAT_PLAYLIST:                        i_image = 5; break;                    case CAT_INTERFACE:                        i_image = 6; break;                }                current_item = AppendItem( root_item,                                           wxU( config_data->psz_name ),                                           i_image, -1, config_data );                break;            case CONFIG_SUBCATEGORY:                if( p_item->i_value == SUBCAT_VIDEO_GENERAL ||                    p_item->i_value == SUBCAT_AUDIO_GENERAL )                {                    ConfigTreeData *cd = (ConfigTreeData *)                                            GetItemData( current_item );                    cd->i_type = TYPE_CATSUBCAT;                    cd->i_subcat_id = p_item->i_value;                    if( cd->psz_name ) free( cd->psz_name );                    cd->psz_name = strdup(  config_CategoryNameGet(                                                      p_item->i_value ) );                    if( cd->psz_help ) free( cd->psz_help );                    char *psz_help = config_CategoryHelpGet( p_item->i_value );                    if( psz_help )                    {                        cd->psz_help = wraptext( strdup( psz_help ),72 ,                                                 ISUTF8 );                    }                    else                    {                        cd->psz_help = NULL;                    }                    continue;                }                config_data = new ConfigTreeData;                config_data->psz_name = strdup(  config_CategoryNameGet(                                                           p_item->i_value ) );                psz_help = config_CategoryHelpGet( p_item->i_value );                if( psz_help )                {                    config_data->psz_help = wraptext( strdup( psz_help ) ,                                                      72 , ISUTF8 );                }                else                {                    config_data->psz_help = NULL;                }                config_data->i_type = TYPE_SUBCATEGORY;                config_data->i_object_id = p_item->i_value;                /* WXMSW doesn't know image -1 ... FIXME */                #ifdef __WXMSW__                switch( p_item->i_value / 100 )                {                    case CAT_AUDIO:                        i_image = 0; break;                    case CAT_VIDEO:                        i_image = 1; break;                    case CAT_INPUT:                        i_image = 2; break;                    case CAT_SOUT:                        i_image = 3; break;                    case CAT_ADVANCED:                        i_image = 4; break;                    case CAT_PLAYLIST:                        i_image = 5; break;                    case CAT_INTERFACE:                        i_image = 6; break;                }                #else                i_image = -1;                #endif                AppendItem( current_item, wxU( config_data->psz_name ),                            i_image, -1, config_data );                break;            }        }        while( p_item->i_type != CONFIG_HINT_END && p_item++ );    }    /*     * Build a tree of all the plugins     */    for( i_index = 0; i_index < p_list->i_count; i_index++ )    {        int i_category = -1;        int i_subcategory = -1;        int i_options = 0;        p_module = (module_t *)p_list->p_values[i_index].p_object;        /* Exclude the main module */        if( !strcmp( p_module->psz_object_name, "main" ) )            continue;        /* Exclude empty plugins (submodules don't have config options, they         * are stored in the parent module) */        if( p_module->b_submodule )              continue;//            p_item = ((module_t *)p_module->p_parent)->p_config;        else            p_item = p_module->p_config;        if( !p_item ) continue;        do        {            if( p_item->i_type == CONFIG_CATEGORY )            {                i_category = p_item->i_value;            }            else if( p_item->i_type == CONFIG_SUBCATEGORY )            {                i_subcategory = p_item->i_value;            }            if( p_item->i_type & CONFIG_ITEM )                i_options ++;            if( i_options > 0 && i_category >= 0 && i_subcategory >= 0 )            {                break;            }        }        while( p_item->i_type != CONFIG_HINT_END && p_item++ );        if( !i_options ) continue;        /* Find the right category item */        wxTreeItemIdValue cookie;        vlc_bool_t b_found = VLC_FALSE;        wxTreeItemId category_item = GetFirstChild( root_item , cookie);        while( category_item.IsOk() )        {            ConfigTreeData *config_data =                    (ConfigTreeData *)GetItemData( category_item );            if( config_data->i_object_id == i_category )            {                b_found = VLC_TRUE;                break;            }            category_item = GetNextChild( root_item, cookie );        }        if( !b_found ) continue;        /* Find subcategory item */        b_found = VLC_FALSE;        //cookie = -1;        wxTreeItemId subcategory_item = GetFirstChild( category_item, cookie );        while( subcategory_item.IsOk() )        {            ConfigTreeData *config_data =                    (ConfigTreeData *)GetItemData( subcategory_item );            if( config_data->i_object_id == i_subcategory )            {                b_found = VLC_TRUE;                break;            }            subcategory_item = GetNextChild( category_item, cookie );        }        if( !b_found )        {            subcategory_item = category_item;        }        /* Add the plugin to the tree */        ConfigTreeData *config_data = new ConfigTreeData;        config_data->b_submodule = p_module->b_submodule;        config_data->i_type = TYPE_MODULE;        config_data->i_object_id = p_module->b_submodule ?            ((module_t *)p_module->p_parent)->i_object_id :            p_module->i_object_id;        config_data->psz_help = NULL;        /* WXMSW doesn't know image -1 ... FIXME */        #ifdef __WXMSW__        switch( i_subcategory / 100 )        {            case CAT_AUDIO:                i_image = 0; break;            case CAT_VIDEO:                i_image = 1; break;            case CAT_INPUT:                i_image = 2; break;            case CAT_SOUT:                i_image = 3; break;            case CAT_ADVANCED:                i_image = 4; break;            case CAT_PLAYLIST:                i_image = 5; break;            case CAT_INTERFACE:                i_image = 6; break;        }        #else        i_image = -1;        #endif        AppendItem( subcategory_item, wxU( p_module->psz_shortname ?                       p_module->psz_shortname : p_module->psz_object_name )                                    , i_image, -1,                    config_data );    }    /* Sort all this mess */    wxTreeItemIdValue cookie;     size_t i_child_index;    wxTreeItemId capability_item = GetFirstChild( root_item, cookie);    for( i_child_index = 0;         (capability_item.IsOk() &&           //(i_child_index < GetChildrenCount( plugins_item, FALSE )));          (i_child_index < GetChildrenCount( root_item, FALSE )));         i_child_index++ )    {        SortChildren( capability_item );        //capability_item = GetNextChild( plugins_item, cookie );        capability_item = GetNextChild( root_item, cookie );    }    /* Clean-up everything */    vlc_list_release( p_list );    p_sizer->Add( this, 1, wxEXPAND | wxALL, 0 );    p_sizer->Layout();    /* Update Tree Ctrl */#ifndef WIN32 /* Workaround a bug in win32 implementation */    SelectItem( GetFirstChild( root_item, cookie ) );#endif    //cannot expand hidden root item    //Expand( root_item );}PrefsTreeCtrl::~PrefsTreeCtrl(){}void PrefsTreeCtrl::ApplyChanges(){    wxTreeItemIdValue cookie, cookie2, cookie3;    ConfigTreeData *config_data;    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_data = (ConfigTreeData *)GetItemData( module );                if( config_data && config_data->panel )                {                    config_data->panel->ApplyChanges();                }                module = GetNextChild( subcategory, cookie3 );            }            config_data = (ConfigTreeData *)GetItemData( subcategory );            if( config_data && config_data->panel )            {                config_data->panel->ApplyChanges();            }            subcategory = GetNextChild( category, cookie2 );        }        config_data = (ConfigTreeData *)GetItemData( category );        if( config_data && config_data->panel )        {            config_data->panel->ApplyChanges();        }        category = GetNextChild( root_item, cookie );    }}void PrefsTreeCtrl::CleanChanges(){    wxTreeItemIdValue cookie, cookie2, cookie3;    ConfigTreeData *config_data;    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    }    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_data = (ConfigTreeData *)GetItemData( module );                if( config_data && config_data->panel )                {                    delete config_data->panel;                    config_data->panel = NULL;                }                module = GetNextChild( subcategory, cookie3 );            }            config_data = (ConfigTreeData *)GetItemData( subcategory );            if( config_data && config_data->panel )            {                delete config_data->panel;                config_data->panel = NULL;            }            subcategory = GetNextChild( category, cookie2 );        }        config_data = (ConfigTreeData *)GetItemData( category );        if( config_data && config_data->panel )        {            delete config_data->panel;            config_data->panel = NULL;        }        category = GetNextChild( root_item, cookie );    }    if( GetSelection() )    {        wxTreeEvent event;        OnSelectTreeItem( event );    }}ConfigTreeData *PrefsTreeCtrl::FindModuleConfig( ConfigTreeData *config_data ){    /* We need this complexity because submodules don't have their own config     * options. They use the parent module ones. */    if( !config_data || !config_data->b_submodule )    {        return config_data;    }

⌨️ 快捷键说明

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