Example #1
0
char *StringConfigControl::GetPszValue()
{
    int i_size;
    char *psz_result;
    TCHAR *psz_string;

    i_size = Edit_GetTextLength( textctrl );
    psz_string = (TCHAR *)malloc( (i_size + 1) * sizeof(TCHAR) );
    Edit_GetText( textctrl, psz_string, i_size + 1 );
    psz_result = strdup( _TOMB(psz_string) );
    free( psz_string );
    return psz_result;
}
Example #2
0
/*****************************************************************************
 * PrefsTreeCtrl class definition.
 *****************************************************************************/
PrefsTreeCtrl::PrefsTreeCtrl( intf_thread_t *_p_intf,
                              PrefsDialog *_p_prefs_dialog, HWND hwnd,
                              HINSTANCE hInst )
{
    vlc_list_t      *p_list;
    module_t        *p_module;
    module_config_t *p_item;
    int i_index;

    INITCOMMONCONTROLSEX iccex;
    RECT rcClient;
    TVITEM tvi = {0}; 
    TVINSERTSTRUCT tvins = {0}; 
    HTREEITEM hPrev;

    size_t i_capability_count = 0;
    size_t i_child_index;

    HTREEITEM capability_item;

    /* Initializations */
    p_intf = _p_intf;
    p_prefs_dialog = _p_prefs_dialog;
    b_advanced = VLC_FALSE;

    /* Create a tree view */
    // Initialize the INITCOMMONCONTROLSEX structure.
    iccex.dwSize = sizeof( INITCOMMONCONTROLSEX );
    iccex.dwICC = ICC_TREEVIEW_CLASSES;

    // Registers Statusbar control classes from the common control dll
    InitCommonControlsEx( &iccex );

    // Get the client area rect to put the tv in
    GetClientRect(hwnd, &rcClient);

    // Create the tree-view control.
    hwndTV = CreateWindowEx( 0, WC_TREEVIEW, NULL,
        WS_VISIBLE | WS_CHILD | WS_BORDER | TVS_HASLINES |
        TVS_LINESATROOT | TVS_HASBUTTONS,
        5, 10 + 2*(15 + 10) + 105 + 5, rcClient.right - 5 - 5, 6*15,
        hwnd, NULL, hInst, NULL );

    tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;

    /* List the plugins */
    p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
    if( !p_list ) return;

    /*
     * Build a tree of the main options
     */
    ConfigTreeData *config_data = new ConfigTreeData;
    config_data->i_object_id = GENERAL_ID;
    config_data->psz_help = strdup("nothing");//strdup( GENERAL_HELP );
    config_data->psz_section = strdup( GENERAL_TITLE );
    tvi.pszText = _T("General settings");
    tvi.cchTextMax = lstrlen(_T("General settings"));
    tvi.lParam = (long)config_data;
    tvins.item = tvi;
    tvins.hInsertAfter = TVI_FIRST;
    tvins.hParent = TVI_ROOT;

    // Add the item to the tree-view control.
    hPrev = (HTREEITEM) TreeView_InsertItem( hwndTV, &tvins);
    general_item = hPrev;

    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" ) )
            break;
    }
    if( i_index < p_list->i_count )
    {
        /* We found the main module */

        /* Enumerate config categories and store a reference so we can
         * generate their config panel them when it is asked by the user. */
        p_item = p_module->p_config;

        if( p_item ) do
        {
            switch( p_item->i_type )
            {
            case CONFIG_HINT_CATEGORY:
                ConfigTreeData *config_data = new ConfigTreeData;
                config_data->psz_section = strdup( p_item->psz_text );
                if( p_item->psz_longtext )
                {
                    config_data->psz_help =
                        strdup( p_item->psz_longtext );
                }
                else
                {
                    config_data->psz_help = NULL;
                }
                config_data->i_object_id = p_module->i_object_id;

                /* Add the category to the tree */
                // Set the text of the item. 
                tvi.pszText = _FROMMB(p_item->psz_text); 
                tvi.cchTextMax = _tcslen(tvi.pszText);
                tvi.lParam = (long)config_data;
                tvins.item = tvi;
                tvins.hInsertAfter = hPrev; 
                tvins.hParent = general_item; //level 3
    
                // Add the item to the tree-view control. 
                hPrev = (HTREEITEM)TreeView_InsertItem( hwndTV, &tvins );

                break;
            }
        }
        while( p_item->i_type != CONFIG_HINT_END && p_item++ );

        TreeView_SortChildren( hwndTV, general_item, 0 );
    }
        
    /*
     * Build a tree of all the plugins
     */
    config_data = new ConfigTreeData;
    config_data->i_object_id = PLUGIN_ID;
    config_data->psz_help = strdup("nothing");//strdup( PLUGIN_HELP );
    config_data->psz_section = strdup("nothing");//strdup( PLUGIN_TITLE );
    tvi.pszText = _T("Modules");
    tvi.cchTextMax = lstrlen(_T("Modules"));
    tvi.lParam = (long)config_data;
    tvins.item = tvi;
    tvins.hInsertAfter = TVI_LAST;
    tvins.hParent = TVI_ROOT;

    // Add the item to the tree-view control.
    hPrev = (HTREEITEM) TreeView_InsertItem( hwndTV, &tvins);
    plugins_item = hPrev;

    i_capability_count = 0;
    for( i_index = 0; i_index < p_list->i_count; i_index++ )
    {
        i_child_index = 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 )
            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_ITEM )
                break;
        }
        while( p_item->i_type != CONFIG_HINT_END && p_item++ );
        if( p_item->i_type == CONFIG_HINT_END ) continue;

        /* Find the capability child item */
        /*long cookie; size_t i_child_index;*/
        capability_item = TreeView_GetChild( hwndTV, plugins_item );
        while( capability_item != 0 )
        {
            TVITEM capability_tvi = {0};
            TCHAR psz_text[256];
            i_child_index++;

            capability_tvi.mask = TVIF_TEXT;
            capability_tvi.pszText = psz_text;
            capability_tvi.cchTextMax = 256;
            capability_tvi.hItem = capability_item;
            TreeView_GetItem( hwndTV, &capability_tvi );
            if( !strcmp( _TOMB(capability_tvi.pszText),
                         p_module->psz_capability ) ) break;
 
            capability_item =
                TreeView_GetNextSibling( hwndTV, capability_item );
        }

        if( i_child_index == i_capability_count &&
            p_module->psz_capability && *p_module->psz_capability )
        {
            /* We didn't find it, add it */
            ConfigTreeData *config_data = new ConfigTreeData;
            config_data->psz_section =
                strdup( GetCapabilityHelp( p_module->psz_capability , 1 ) );
            config_data->psz_help =
                strdup( GetCapabilityHelp( p_module->psz_capability , 2 ) );
            config_data->i_object_id = CAPABILITY_ID;
            tvi.pszText = _FROMMB(p_module->psz_capability);
            tvi.cchTextMax = _tcslen(tvi.pszText);
            tvi.lParam = (long)config_data;
            tvins.item = tvi;
            tvins.hInsertAfter = plugins_item; 
            tvins.hParent = plugins_item;// level 3

            // Add the item to the tree-view control. 
            capability_item = (HTREEITEM) TreeView_InsertItem( hwndTV, &tvins);

            i_capability_count++;
        }

        /* Add the plugin to the tree */
        ConfigTreeData *config_data = new ConfigTreeData;
        config_data->b_submodule = p_module->b_submodule;
        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;
        tvi.pszText = _FROMMB(p_module->psz_object_name);
        tvi.cchTextMax = _tcslen(tvi.pszText);
        tvi.lParam = (long)config_data;
        tvins.item = tvi;
        tvins.hInsertAfter = capability_item; 
        tvins.hParent = capability_item;// level 4

        // Add the item to the tree-view control. 
        TreeView_InsertItem( hwndTV, &tvins );
    }

    /* Sort all this mess */
    /*long cookie; size_t i_child_index;*/
    TreeView_SortChildren( hwndTV, plugins_item, 0 );
    capability_item = TreeView_GetChild( hwndTV, plugins_item );
    while( capability_item != 0 )
    {
        TreeView_SortChildren( hwndTV, capability_item, 0 );
        capability_item = TreeView_GetNextSibling( hwndTV, capability_item );
    }

    /* Clean-up everything */
    vlc_list_release( p_list );

    TreeView_Expand( hwndTV, general_item, TVE_EXPANDPARTIAL |TVE_EXPAND );
}