/***************************************************************************** * ModuleConfigControl implementation *****************************************************************************/ ModuleConfigControl::ModuleConfigControl( vlc_object_t *p_this, module_config_t *p_item, HWND parent, HINSTANCE hInst, int * py_pos ) : ConfigControl( p_this, p_item, parent, hInst ) { module_t **p_list; module_t *p_parser; label = CreateWindow( _T("STATIC"), _FROMMB(p_item->psz_text), WS_CHILD | WS_VISIBLE | SS_LEFT, 5, *py_pos, 200, 15, parent, NULL, hInst, NULL ); *py_pos += 15 + 10; combo = CreateWindow( _T("COMBOBOX"), _T(""), WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL, 20, *py_pos, 180, 5*15 + 6, parent, NULL, hInst, NULL); *py_pos += 15 + 10; /* build a list of available modules */ p_list = module_list_get( NULL ); ComboBox_AddString( combo, _T("Default") ); ComboBox_SetItemData( combo, 0, (void *)NULL ); ComboBox_SetCurSel( combo, 0 ); //ComboBox_SetText( combo, _T("Default") ); for( size_t i_index = 0; p_list[i_index]; i_index++ ) { p_parser = p_list[i_index]; if( module_provides( p_parser, p_item->psz_type ) ) { ComboBox_AddString( combo, _FROMMB(module_GetLongName( p_parser ) )); ComboBox_SetItemData( combo, i_index, (void *) module_get_object( p_parser ) ); if( p_item->value.psz && !strcmp( p_item->value.psz, module_get_object( p_parser )) ) { ComboBox_SetCurSel( combo, i_index ); //ComboBox_SetText( combo, _FROMMB( module_GetLongName(p_parser)) ); } } } module_list_free( p_list ); }
/***************************************************************************** * ModuleConfigControl implementation *****************************************************************************/ ModuleConfigControl::ModuleConfigControl( vlc_object_t *p_this, module_config_t *p_item, HWND parent, HINSTANCE hInst, int * py_pos ) : ConfigControl( p_this, p_item, parent, hInst ) { vlc_list_t *p_list; module_t *p_parser; label = CreateWindow( _T("STATIC"), _FROMMB(p_item->psz_text), WS_CHILD | WS_VISIBLE | SS_LEFT, 5, *py_pos, 200, 15, parent, NULL, hInst, NULL ); *py_pos += 15 + 10; combo = CreateWindow( _T("COMBOBOX"), _T(""), WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL, 20, *py_pos, 180, 5*15 + 6, parent, NULL, hInst, NULL); *py_pos += 15 + 10; /* build a list of available modules */ p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE ); ComboBox_AddString( combo, _T("Default") ); ComboBox_SetItemData( combo, 0, (void *)NULL ); ComboBox_SetCurSel( combo, 0 ); //ComboBox_SetText( combo, _T("Default") ); for( int i_index = 0; i_index < p_list->i_count; i_index++ ) { p_parser = (module_t *)p_list->p_values[i_index].p_object ; if( !strcmp( p_parser->psz_capability, p_item->psz_type ) ) { ComboBox_AddString( combo, _FROMMB(p_parser->psz_longname) ); ComboBox_SetItemData( combo, i_index, (void*)p_parser->psz_object_name ); if( p_item->psz_value && !strcmp(p_item->psz_value, p_parser->psz_object_name) ) { ComboBox_SetCurSel( combo, i_index ); //ComboBox_SetText( combo, _FROMMB(p_parser->psz_longname) ); } } } vlc_list_release( p_list ); }
/***************************************************************************** * StringConfigControl implementation *****************************************************************************/ StringConfigControl::StringConfigControl( vlc_object_t *p_this, module_config_t *p_item, HWND parent, HINSTANCE hInst, int * py_pos ) : ConfigControl( p_this, p_item, parent, hInst ) { label = CreateWindow( _T("STATIC"), _FROMMB(p_item->psz_text), WS_CHILD | WS_VISIBLE | SS_LEFT, 5, *py_pos, 200, 15, parent, NULL, hInst, NULL ); *py_pos += 15 + 10; textctrl = CreateWindow( _T("EDIT"), p_item->psz_type ? _FROMMB(p_item->psz_type) : _T(""), WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL, 20, *py_pos - 3, 180, 15 + 3, parent, NULL, hInst, NULL ); *py_pos += 15 + 10; }
/***************************************************************************** * Refresh the menu. *****************************************************************************/ void RefreshMenu( intf_thread_t *p_intf, vector<MenuItemExt*> *p_menu_list, HMENU hMenu , int i_count, char **ppsz_varnames, vlc_object_t **pi_objects, int i_start_id ) { vlc_object_t *p_object; bool b_section_empty = false; int i; /* Initializations */ int i_item_id = i_start_id; for( i = 0; i < i_count; i++ ) { if( !ppsz_varnames[i] ) { if( b_section_empty ) { AppendMenu( hMenu, MF_GRAYED | MF_STRING, MenuDummy_Event + i, _T("Empty") ); } AppendMenu( hMenu, MF_SEPARATOR, 0, _T("") ); b_section_empty = true; continue; } if( !pi_objects[i] ) { AppendMenu( hMenu, MF_GRAYED | MF_STRING, MenuDummy_Event, _FROMMB(ppsz_varnames[i]) ); b_section_empty = false; continue; } p_object = pi_objects[i]; if( p_object == NULL ) continue; b_section_empty = false; CreateMenuItem( p_intf, p_menu_list, hMenu, ppsz_varnames[i], p_object, &i_item_id ); vlc_object_release( p_object ); } /* Special case for empty menus */ if( wce_GetMenuItemCount(hMenu) == 0 || b_section_empty ) { AppendMenu( hMenu, MF_GRAYED | MF_STRING, MenuDummy_Event + i, _T("Empty") ); } }
/***************************************************************************** * BoolConfigControl implementation *****************************************************************************/ BoolConfigControl::BoolConfigControl( vlc_object_t *p_this, module_config_t *p_item, HWND parent, HINSTANCE hInst, int * py_pos ) : ConfigControl( p_this, p_item, parent, hInst ) { checkbox = CreateWindow( _T("BUTTON"), _T(""), WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, 5, *py_pos, 15, 15, parent, NULL, hInst, NULL ); Button_SetCheck( checkbox, config_GetInt(p_this, p_item->psz_name) ? BST_CHECKED : BST_UNCHECKED ); checkbox_label = CreateWindow( _T("STATIC"), _FROMMB(p_item->psz_text), WS_CHILD | WS_VISIBLE | SS_LEFT, 5 + 15 + 5, *py_pos, 180, 15, parent, NULL, hInst, NULL ); *py_pos += 15 + 10; }
/***************************************************************************** * FloatConfigControl implementation *****************************************************************************/ FloatConfigControl::FloatConfigControl( vlc_object_t *p_this, module_config_t *p_item, HWND parent, HINSTANCE hInst, int *py_pos ) : ConfigControl( p_this, p_item, parent, hInst ) { label = CreateWindow( _T("STATIC"), _FROMMB(p_item->psz_text), WS_CHILD | WS_VISIBLE | SS_LEFT, 5, *py_pos, 200, 15, parent, NULL, hInst, NULL ); *py_pos += 15 + 10; TCHAR psz_string[100]; _stprintf( psz_string, _T("%d"), p_item->i_type ); textctrl = CreateWindow( _T("EDIT"), psz_string, WS_CHILD | WS_VISIBLE | WS_BORDER | SS_RIGHT | ES_AUTOHSCROLL, 20, *py_pos - 3, 70, 15 + 3, parent, NULL, hInst, NULL ); *py_pos += 15 + 10; }
KeyConfigControl::KeyConfigControl( vlc_object_t *p_this, module_config_t *p_item, HWND parent, HINSTANCE hInst, int * py_pos ) : ConfigControl( p_this, p_item, parent, hInst ) { // Init the keys decriptions array if( m_keysList == NULL ) { m_keysList = new string[vlc_num_keys]; for( size_t i = 0; i < vlc_num_keys; ++i ) { m_keysList[i] = vlc_keys[i].psz_key_string; } } label = CreateWindow( _T("STATIC"), _FROMMB(p_item->psz_text), WS_CHILD | WS_VISIBLE | SS_LEFT, 5, *py_pos, 200, 15, parent, NULL, hInst, NULL ); *py_pos += 15 + 10; alt = CreateWindow( _T("BUTTON"), _T("Alt"), WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, 20, *py_pos, 15, 15, parent, NULL, hInst, NULL ); Button_SetCheck( alt, p_item->i_type & KEY_MODIFIER_ALT ? BST_CHECKED : BST_UNCHECKED ); alt_label = CreateWindow( _T("STATIC"), _T("Alt"), WS_CHILD | WS_VISIBLE | SS_LEFT, 20 + 15 + 5, *py_pos, 30, 15, parent, NULL, hInst, NULL ); ctrl = CreateWindow( _T("BUTTON"), _T("Ctrl"), WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, 20 + 15 + 5 + 30 + 5, *py_pos, 15, 15, parent, NULL, hInst, NULL ); Button_SetCheck( ctrl, p_item->i_type & KEY_MODIFIER_CTRL ? BST_CHECKED : BST_UNCHECKED ); ctrl_label = CreateWindow( _T("STATIC"), _T("Ctrl"), WS_CHILD | WS_VISIBLE | SS_LEFT, 20 + 15 + 5 + 30 + 5 + 15 + 5, *py_pos, 30, 15, parent, NULL, hInst, NULL ); shift = CreateWindow( _T("BUTTON"), _T("Shift"), WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, 20 + 15 + 5 + 2*(30 + 5) + 15 + 5, *py_pos, 15, 15, parent, NULL, hInst, NULL ); Button_SetCheck( shift, p_item->i_type & KEY_MODIFIER_SHIFT ? BST_CHECKED : BST_UNCHECKED ); shift_label = CreateWindow( _T("STATIC"), _T("Shift"), WS_CHILD | WS_VISIBLE | SS_LEFT, 20 + 15 + 5 + 2*(30 + 5) + 2*(15 + 5), *py_pos, 30, 15, parent, NULL, hInst, NULL ); *py_pos += 15 + 10; combo = CreateWindow( _T("COMBOBOX"), _T(""), WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL, 20, *py_pos, 130, 5*15 + 6, parent, NULL, hInst, NULL ); *py_pos += 15 + 10; for( size_t i = 0; i < vlc_num_keys ; ++i ) { ComboBox_AddString( combo, _FROMMB(m_keysList[i].c_str()) ); ComboBox_SetItemData( combo, i, (void*)vlc_keys[i].i_key_code ); if( (unsigned int)vlc_keys[i].i_key_code == ( ((unsigned int)p_item->i_type) & ~KEY_MODIFIER ) ) { ComboBox_SetCurSel( combo, i ); ComboBox_SetText( combo, _FROMMB(m_keysList[i].c_str()) ); } } }
/***************************************************************************** * PrefsPanel class definition. *****************************************************************************/ PrefsPanel::PrefsPanel( HWND parent, HINSTANCE hInst, intf_thread_t *_p_intf, PrefsDialog *_p_prefs_dialog, int i_object_id, char *psz_section, char *psz_help ) { module_config_t *p_item; module_t *p_module = NULL; /* Initializations */ p_intf = _p_intf; p_prefs_dialog = _p_prefs_dialog; b_advanced = VLC_TRUE; if( i_object_id == PLUGIN_ID || i_object_id == GENERAL_ID || i_object_id == CAPABILITY_ID ) { label = CreateWindow( _T("STATIC"), _FROMMB(psz_section), WS_CHILD | WS_VISIBLE | SS_LEFT, 5, 10 + (15 + 10), 200, 15, parent, NULL, hInst, NULL ); config_window = NULL; } else { /* Get a pointer to the module */ p_module = (module_t *)vlc_object_get( p_intf, i_object_id ); 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( psz_section && p_item->i_type == CONFIG_HINT_CATEGORY ) { while( !(p_item->i_type == CONFIG_HINT_CATEGORY) || strcmp( psz_section, p_item->psz_text ) ) { if( p_item->i_type == CONFIG_HINT_END ) break; p_item++; } } /* Add a head title to the panel */ label = CreateWindow( _T("STATIC"), _FROMMB(psz_section ? p_item->psz_text : p_module->psz_longname), WS_CHILD | WS_VISIBLE | SS_LEFT, 5, 10 + (15 + 10), 250, 15, parent, NULL, hInst, NULL ); WNDCLASS wc; memset( &wc, 0, sizeof(wc) ); wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = (WNDPROC) _p_prefs_dialog->BaseWndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInst; wc.hIcon = 0; wc.hCursor = 0; wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); wc.lpszMenuName = 0; wc.lpszClassName = _T("PrefsPanelClass"); RegisterClass(&wc); RECT rc; GetWindowRect( parent, &rc); config_window = CreateWindow( _T("PrefsPanelClass"), _T("config_window"), WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_BORDER, 5, 10 + 2*(15 + 10), rc.right - 5 - 7, 105, parent, NULL, hInst, (void *) _p_prefs_dialog ); int y_pos = 5; if( p_item ) do { /* If a category has been specified, check we finished the job */ if( psz_section && p_item->i_type == CONFIG_HINT_CATEGORY && strcmp( psz_section, p_item->psz_text ) ) break; ConfigControl *control = CreateConfigControl( VLC_OBJECT(p_intf), p_item, config_window, hInst, &y_pos ); /* 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.push_back( control ); } while( p_item->i_type != CONFIG_HINT_END && p_item++ ); GetWindowRect( config_window, &rc); maxvalue = y_pos - (rc.bottom - rc.top) + 5; oldvalue = 0; SetScrollRange( config_window, SB_VERT, 0, maxvalue, TRUE ); } }
/***************************************************************************** * 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 ); }
HMENU CreateChoicesMenu( intf_thread_t *p_intf, vector<MenuItemExt*> *p_menu_list, char *psz_var, vlc_object_t *p_object, int *pi_item_id ) { MenuItemExt *pMenuItemExt; vlc_value_t val, val_list, text_list; int i_type, i; HMENU hSubMenu = CreatePopupMenu(); /* Check the type of the object variable */ i_type = var_Type( p_object, psz_var ); /* Make sure we want to display the variable */ if( i_type & VLC_VAR_HASCHOICE ) { var_Change( p_object, psz_var, VLC_VAR_CHOICESCOUNT, &val, NULL ); if( val.i_int == 0 ) return NULL; if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 ) return NULL; } else { return NULL; } switch( i_type & VLC_VAR_TYPE ) { case VLC_VAR_VOID: case VLC_VAR_BOOL: case VLC_VAR_VARIABLE: case VLC_VAR_STRING: case VLC_VAR_INTEGER: break; default: /* Variable doesn't exist or isn't handled */ return NULL; } if( var_Get( p_object, psz_var, &val ) < 0 ) return NULL; if( var_Change( p_object, psz_var, VLC_VAR_GETLIST, &val_list, &text_list ) < 0 ) { if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string ); return NULL; } for( i = 0; i < val_list.p_list->i_count; i++ ) { vlc_value_t another_val; HMENU hMenuItem; char *psz_tmp; switch( i_type & VLC_VAR_TYPE ) { case VLC_VAR_VARIABLE: hMenuItem = CreateChoicesMenu( p_intf, p_menu_list, val_list.p_list->p_values[i].psz_string, p_object, pi_item_id ); AppendMenu( hSubMenu, MF_STRING | MF_POPUP, (UINT)hMenuItem, _FROMMB(text_list.p_list->p_values[i].psz_string ? text_list.p_list->p_values[i].psz_string : val_list.p_list->p_values[i].psz_string) ); break; case VLC_VAR_STRING: another_val.psz_string = strdup(val_list.p_list->p_values[i].psz_string); AppendMenu( hSubMenu, MF_STRING, ++(*pi_item_id), _FROMMB(text_list.p_list->p_values[i].psz_string ? text_list.p_list->p_values[i].psz_string : val_list.p_list->p_values[i].psz_string) ); pMenuItemExt = new MenuItemExt( p_intf, *pi_item_id, psz_var, p_object, another_val, i_type ); p_menu_list->push_back( pMenuItemExt ); if( !(i_type & VLC_VAR_ISCOMMAND) && val.psz_string && !strcmp( val.psz_string, val_list.p_list->p_values[i].psz_string ) ) CheckMenuItem( hSubMenu, *pi_item_id, MF_CHECKED | MF_BYCOMMAND); break; case VLC_VAR_INTEGER: asprintf( &psz_tmp, "%d", val_list.p_list->p_values[i].i_int ); AppendMenu( hSubMenu, MF_STRING, ++(*pi_item_id), _FROMMB(text_list.p_list->p_values[i].psz_string ? text_list.p_list->p_values[i].psz_string : psz_tmp)); free( psz_tmp ); pMenuItemExt = new MenuItemExt( p_intf, *pi_item_id, psz_var, p_object, val_list.p_list->p_values[i], i_type ); p_menu_list->push_back( pMenuItemExt ); if( val_list.p_list->p_values[i].i_int == val.i_int ) CheckMenuItem( hSubMenu, *pi_item_id, MF_CHECKED | MF_BYCOMMAND); break; default: break; } } /* Clean up everything */ if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string ); var_FreeList( &val_list, &text_list ); return hSubMenu; }
/***************************************************************************** * Private methods. *****************************************************************************/ void CreateMenuItem( intf_thread_t *p_intf, vector<MenuItemExt*> *p_menu_list, HMENU hMenu, char *psz_var, vlc_object_t *p_object, int *pi_item_id ) { MenuItemExt *pMenuItemExt; HMENU hMenuItem; vlc_value_t val, text; int i_type; /* Check the type of the object variable */ i_type = var_Type( p_object, psz_var ); switch( i_type & VLC_VAR_TYPE ) { case VLC_VAR_VOID: case VLC_VAR_BOOL: case VLC_VAR_VARIABLE: case VLC_VAR_STRING: case VLC_VAR_INTEGER: case VLC_VAR_FLOAT: break; default: /* Variable doesn't exist or isn't handled */ return; } /* Make sure we want to display the variable */ if( i_type & VLC_VAR_HASCHOICE ) { var_Change( p_object, psz_var, VLC_VAR_CHOICESCOUNT, &val, NULL ); if( val.i_int == 0 ) return; if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 ) return; } /* Get the descriptive name of the variable */ var_Change( p_object, psz_var, VLC_VAR_GETTEXT, &text, NULL ); var_Get( p_object, psz_var, &val ); if( i_type & VLC_VAR_HASCHOICE ) { hMenuItem = CreateChoicesMenu( p_intf, p_menu_list, psz_var, p_object, pi_item_id ); AppendMenu( hMenu, MF_STRING | MF_POPUP, (UINT)hMenuItem, _FROMMB(text.psz_string ? text.psz_string : psz_var) ); if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string ); free( text.psz_string ); return; } switch( i_type & VLC_VAR_TYPE ) { case VLC_VAR_VOID: AppendMenu( hMenu, MF_STRING , ++(*pi_item_id), _FROMMB(text.psz_string ? text.psz_string : psz_var) ); pMenuItemExt = new MenuItemExt( p_intf, *pi_item_id, psz_var, p_object, val, i_type ); p_menu_list->push_back( pMenuItemExt ); break; case VLC_VAR_BOOL: val.b_bool = !val.b_bool; AppendMenu( hMenu, MF_STRING | MF_CHECKED, ++(*pi_item_id), _FROMMB(text.psz_string ? text.psz_string : psz_var) ); pMenuItemExt = new MenuItemExt( p_intf, *pi_item_id, psz_var, p_object, val, i_type ); p_menu_list->push_back( pMenuItemExt ); CheckMenuItem( hMenu, *pi_item_id , ( val.b_bool ? MF_UNCHECKED : MF_CHECKED ) | MF_BYCOMMAND ); break; default: free( text.psz_string ); return; } if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string ); free( text.psz_string ); }
/*********************************************************************** FUNCTION: UpdateFileInfo PURPOSE: Update the TreeView with file information. ***********************************************************************/ void FileInfo::UpdateFileInfo() { TVITEM tvi = {0}; TVINSERTSTRUCT tvins = {0}; HTREEITEM hPrev = (HTREEITEM)TVI_FIRST; HTREEITEM hPrevRootItem = NULL; HTREEITEM hPrevLev2Item = NULL; p_intf->p_sys->p_input = (input_thread_t *) vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); input_thread_t *p_input = p_intf->p_sys->p_input; if( !p_input ) return; tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM; // Set the text of the item. tvi.pszText = _FROMMB( p_input->input.p_item->psz_name ); tvi.cchTextMax = _tcslen( tvi.pszText ); // Save the heading level in the item's application-defined data area tvi.lParam = (LPARAM)1; tvins.item = tvi; //tvins.hInsertAfter = TVI_LAST; tvins.hInsertAfter = hPrev; tvins.hParent = TVI_ROOT; // Add the item to the tree-view control. hPrev = (HTREEITEM)TreeView_InsertItem( hwndTV, &tvins ); hPrevRootItem = hPrev; vlc_mutex_lock( &p_input->input.p_item->lock ); for( int i = 0; i < p_input->input.p_item->i_categories; i++ ) { info_category_t *p_cat = p_input->input.p_item->pp_categories[i]; // Set the text of the item. tvi.pszText = _FROMMB( p_input->input.p_item->psz_name ); tvi.cchTextMax = _tcslen( tvi.pszText ); // Save the heading level in the item's application-defined data area tvi.lParam = (LPARAM)2; // level 2 tvins.item = tvi; tvins.hInsertAfter = hPrev; tvins.hParent = hPrevRootItem; // Add the item to the tree-view control. hPrev = (HTREEITEM)TreeView_InsertItem( hwndTV, &tvins ); hPrevLev2Item = hPrev; for( int j = 0; j < p_cat->i_infos; j++ ) { info_t *p_info = p_cat->pp_infos[j]; // Set the text of the item. string szAnsi = (string)p_info->psz_name; szAnsi += ": "; szAnsi += p_info->psz_value; tvi.pszText = (TCHAR *)_FROMMB( szAnsi.c_str() ); tvi.cchTextMax = _tcslen( tvi.pszText ); tvi.lParam = (LPARAM)3; // level 3 tvins.item = tvi; tvins.hInsertAfter = hPrev; tvins.hParent = hPrevLev2Item; // Add the item to the tree-view control. hPrev = (HTREEITEM)TreeView_InsertItem( hwndTV, &tvins ); } TreeView_Expand( hwndTV, hPrevLev2Item, TVE_EXPANDPARTIAL|TVE_EXPAND ); } vlc_mutex_unlock( &p_input->input.p_item->lock ); TreeView_Expand( hwndTV, hPrevRootItem, TVE_EXPANDPARTIAL|TVE_EXPAND ); return; }
/***************************************************************************** * Manage: manage main thread messages ***************************************************************************** * In this function, called approx. 10 times a second, we check what the * main program wanted to tell us. *****************************************************************************/ void Timer::Notify( void ) { vlc_value_t val; char *shortname; /* Update the input */ if( p_intf->p_sys->p_input == NULL ) { p_intf->p_sys->p_input = (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); /* Show slider */ if( p_intf->p_sys->p_input ) { ShowWindow( p_main_interface->hwndSlider, SW_SHOW ); ShowWindow( p_main_interface->hwndLabel, SW_SHOW ); ShowWindow( p_main_interface->hwndVol, SW_SHOW ); // only for local file, check if works well with net url input_item_t *p_item =input_GetItem(p_intf->p_sys->p_input); shortname = strrchr( input_item_GetURL(p_item), '\\' ); if (! shortname) shortname = input_item_GetURL(p_item); else shortname++; SendMessage( p_main_interface->hwndSB, SB_SETTEXT, (WPARAM) 0, (LPARAM)_FROMMB(shortname) ); p_main_interface->TogglePlayButton( PLAYING_S ); i_old_playing_status = PLAYING_S; } } else if( p_intf->p_sys->p_input->b_dead ) { /* Hide slider */ ShowWindow( p_main_interface->hwndSlider, SW_HIDE); ShowWindow( p_main_interface->hwndLabel, SW_HIDE); ShowWindow( p_main_interface->hwndVol, SW_HIDE); p_main_interface->TogglePlayButton( PAUSE_S ); i_old_playing_status = PAUSE_S; SendMessage( p_main_interface->hwndSB, SB_SETTEXT, (WPARAM) 0, (LPARAM)(LPCTSTR) TEXT("")); vlc_object_release( p_intf->p_sys->p_input ); p_intf->p_sys->p_input = NULL; } if( p_intf->p_sys->p_input ) { input_thread_t *p_input = p_intf->p_sys->p_input; if( vlc_object_alive (p_input) ) { /* New input or stream map change */ p_intf->p_sys->b_playing = 1; /* Manage the slider */ if( /*p_input->stream.b_seekable &&*/ p_intf->p_sys->b_playing ) { /* Update the slider if the user isn't dragging it. */ if( p_intf->p_sys->b_slider_free ) { vlc_value_t pos; char psz_time[ MSTRTIME_MAX_SIZE ]; vlc_value_t time; mtime_t i_seconds; /* Update the value */ var_Get( p_input, "position", &pos ); if( pos.f_float >= 0.0 ) { p_intf->p_sys->i_slider_pos = (int)(SLIDER_MAX_POS * pos.f_float); SendMessage( p_main_interface->hwndSlider, TBM_SETPOS, 1, p_intf->p_sys->i_slider_pos ); var_Get( p_intf->p_sys->p_input, "time", &time ); i_seconds = time.i_time / 1000000; secstotimestr ( psz_time, i_seconds ); SendMessage( p_main_interface->hwndLabel, WM_SETTEXT, (WPARAM)1, (LPARAM)_FROMMB(psz_time) ); } } } /* Take care of the volume, etc... */ p_main_interface->Update(); /* Manage Playing status */ var_Get( p_input, "state", &val ); if( i_old_playing_status != val.i_int ) { if( val.i_int == PAUSE_S ) { p_main_interface->TogglePlayButton( PAUSE_S ); } else { p_main_interface->TogglePlayButton( PLAYING_S ); } i_old_playing_status = val.i_int; } /* Manage Speed status */ var_Get( p_input, "rate", &val ); if( i_old_rate != val.i_int ) { TCHAR psz_text[15]; _stprintf( psz_text + 2, _T("x%.2f"), 1000.0 / val.i_int ); psz_text[0] = psz_text[1] = _T('\t'); SendMessage( p_main_interface->hwndSB, SB_SETTEXT, (WPARAM) 1, (LPARAM)(LPCTSTR) psz_text ); i_old_rate = val.i_int; } } } else if( p_intf->p_sys->b_playing && vlc_object_alive( p_intf ) ) { p_intf->p_sys->b_playing = 0; p_main_interface->TogglePlayButton( PAUSE_S ); i_old_playing_status = PAUSE_S; } if( !vlc_object_alive( p_intf ) ) { /* Prepare to die, young Skywalker */ /* p_main_interface->Close(TRUE);*/ return; } }