1 /*****************************************************************************
2 * preferences.cpp : WinCE gui plugin for VLC
3 *****************************************************************************
4 * Copyright (C) 2000-2004 the VideoLAN team
7 * Authors: Marodon Cedric <cedric_marodon@yahoo.fr>
8 * Gildas Bazin <gbazin@videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
32 #include <vlc_common.h>
33 #include <vlc_interface.h>
43 #include <vlc_config_cat.h>
45 #include "preferences_widgets.h"
47 #define TYPE_CATEGORY 0
48 #define TYPE_CATSUBCAT 1 /* Category with embedded subcategory */
49 #define TYPE_SUBCATEGORY 2
52 /*****************************************************************************
54 *****************************************************************************/
56 /* IDs for the controls and the menu commands */
65 /*****************************************************************************
66 * Classes declarations.
67 *****************************************************************************/
74 PrefsTreeCtrl( intf_thread_t *_p_intf, PrefsDialog *p_prefs_dialog,
75 HWND hwnd, HINSTANCE _hInst );
76 virtual ~PrefsTreeCtrl();
79 /*void CleanChanges();*/
81 void OnSelectTreeItem( LPNM_TREEVIEW pnmtv, HWND parent, HINSTANCE hInst );
83 ConfigTreeData *FindModuleConfig( ConfigTreeData *config_data );
88 intf_thread_t *p_intf;
89 PrefsDialog *p_prefs_dialog;
92 HTREEITEM general_item;
93 HTREEITEM plugins_item;
101 PrefsPanel( HWND parent, HINSTANCE hInst, intf_thread_t *_p_intf,
102 PrefsDialog *, module_t *p_module, char *, char *, ConfigTreeData * );
103 virtual ~PrefsPanel() {}
116 intf_thread_t *p_intf;
117 PrefsDialog *p_prefs_dialog;
123 vector<ConfigControl *> config_array;
130 ConfigTreeData() { b_submodule = 0; panel = NULL; psz_name = NULL;
132 virtual ~ConfigTreeData() { delete panel;
147 /*****************************************************************************
149 *****************************************************************************/
150 PrefsDialog::PrefsDialog( intf_thread_t *p_intf, CBaseWindow *p_parent,
152 : CBaseWindow( p_intf, p_parent, h_inst )
154 /* Initializations */
158 /***********************************************************************
164 Processes messages sent to the main window.
166 ***********************************************************************/
167 LRESULT PrefsDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
176 shidi.dwMask = SHIDIM_FLAGS;
177 shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN |
178 SHIDIF_FULLSCREENNOMENUBAR;//SHIDIF_SIZEDLGFULLSCREEN;
180 SHInitDialog( &shidi );
183 memset( &mbi, 0, sizeof (SHMENUBARINFO) );
184 mbi.cbSize = sizeof (SHMENUBARINFO);
185 mbi.hwndParent = hwnd;
186 mbi.dwFlags = SHCMBF_EMPTYBAR;
187 mbi.hInstRes = hInst;
189 if( !SHCreateMenuBar(&mbi) )
191 MessageBox(hwnd, _T("SHCreateMenuBar Failed"), _T("Error"), MB_OK);
197 // Get the client area rect to put the panels in
198 GetClientRect(hwnd, &rcClient);
200 /* Create the buttons */
202 CreateWindow( _T("BUTTON"), _T("Advanced options"),
203 WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
204 5, 10, 15, 15, hwnd, NULL, hInst, NULL );
205 SendMessage( advanced_checkbox, BM_SETCHECK, BST_UNCHECKED, 0 );
207 advanced_label = CreateWindow( _T("STATIC"), _T("Advanced options"),
208 WS_CHILD | WS_VISIBLE | SS_LEFT,
209 5 + 15 + 5, 10, 110, 15,
210 hwnd, NULL, hInst, NULL);
212 if( config_GetInt( p_intf, "advanced" ) )
214 SendMessage( advanced_checkbox, BM_SETCHECK, BST_CHECKED, 0 );
215 /*dummy_event.SetInt(TRUE);
216 OnAdvanced( dummy_event );*/
219 reset_button = CreateWindow( _T("BUTTON"), _T("Reset All"),
220 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
221 rcClient.right - 5 - 80, 10 - 3, 80, 15 + 6,
222 hwnd, NULL, hInst, NULL );
224 /* Create the preferences tree control */
225 prefs_tree = new PrefsTreeCtrl( p_intf, this, hwnd, hInst );
227 UpdateWindow( hwnd );
231 EndDialog( hwnd, LOWORD( wp ) );
235 SHFullScreen( hwnd, SHFS_SHOWSIPBUTTON );
239 if( LOWORD(wp) == IDOK )
242 EndDialog( hwnd, LOWORD( wp ) );
248 if( lp && prefs_tree &&
249 ((LPNMHDR)lp)->hwndFrom == prefs_tree->hwndTV &&
250 ((LPNMHDR)lp)->code == TVN_SELCHANGED )
252 prefs_tree->OnSelectTreeItem( (NM_TREEVIEW FAR *)(LPNMHDR)lp,
260 tvi.mask = TVIF_PARAM;
261 tvi.hItem = TreeView_GetSelection( prefs_tree->hwndTV );
262 if( !tvi.hItem ) break;
264 if( !TreeView_GetItem( prefs_tree->hwndTV, &tvi ) ) break;
266 ConfigTreeData *config_data =
267 prefs_tree->FindModuleConfig( (ConfigTreeData *)tvi.lParam );
268 if( config_data && hwnd == config_data->panel->config_window )
272 GetWindowRect( hwnd, &rc);
273 int newvalue = config_data->panel->oldvalue;
274 switch ( GET_WM_VSCROLL_CODE(wp,lp) )
276 case SB_BOTTOM : newvalue = 0; break;
277 case SB_TOP : newvalue = config_data->panel->maxvalue; break;
278 case SB_LINEDOWN : newvalue += 10; break;
279 case SB_PAGEDOWN : newvalue += rc.bottom - rc.top - 25; break; // wrong! one page is notebook actual length
280 case SB_LINEUP : newvalue -= 10; break;
281 case SB_PAGEUP : newvalue -= rc.bottom - rc.top - 25; break;
282 case SB_THUMBPOSITION:
283 case SB_THUMBTRACK : newvalue = GET_WM_VSCROLL_POS(wp,lp); break;
285 newvalue = max(0,min(config_data->panel->maxvalue,newvalue));
286 SetScrollPos( hwnd,SB_VERT,newvalue,TRUE);//SB_CTL si hwnd=hwndScrollBar, SB_VERT si window
287 dy = config_data->panel->oldvalue - newvalue;
289 ScrollWindowEx( hwnd, 0, dy, NULL, NULL, NULL, NULL, SW_SCROLLCHILDREN );
290 UpdateWindow ( hwnd);
292 config_data->panel->oldvalue = newvalue;
304 /*****************************************************************************
306 *****************************************************************************/
308 /*****************************************************************************
310 *****************************************************************************/
311 void PrefsDialog::OnOk( void )
313 prefs_tree->ApplyChanges();
314 config_SaveConfigFile( p_intf, NULL );
317 /*****************************************************************************
318 * PrefsTreeCtrl class definition.
319 *****************************************************************************/
320 PrefsTreeCtrl::PrefsTreeCtrl( intf_thread_t *_p_intf,
321 PrefsDialog *_p_prefs_dialog, HWND hwnd,
325 module_t *p_module = NULL;
326 module_config_t *p_item;
329 INITCOMMONCONTROLSEX iccex;
332 TVINSERTSTRUCT tvins = {0};
335 size_t i_capability_count = 0;
336 size_t i_child_index;
338 HTREEITEM category_item, subcategory_item;
340 /* Initializations */
342 p_prefs_dialog = _p_prefs_dialog;
345 /* Create a tree view */
346 // Initialize the INITCOMMONCONTROLSEX structure.
347 iccex.dwSize = sizeof( INITCOMMONCONTROLSEX );
348 iccex.dwICC = ICC_TREEVIEW_CLASSES;
350 // Registers Statusbar control classes from the common control dll
351 InitCommonControlsEx( &iccex );
353 // Get the client area rect to put the tv in
354 GetClientRect(hwnd, &rcClient);
356 // Create the tree-view control.
357 hwndTV = CreateWindowEx( 0, WC_TREEVIEW, NULL,
358 WS_VISIBLE | WS_CHILD | WS_BORDER | TVS_HASLINES |
359 TVS_LINESATROOT | TVS_HASBUTTONS,
360 5, 10 + 2*(15 + 10) + 105 + 5, rcClient.right - 5 - 5, 6*15,
361 hwnd, NULL, hInst, NULL );
363 tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
365 /* List the plugins */
366 p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
367 if( !p_list ) return;
370 * Build a tree of the main options
372 ConfigTreeData *config_data = new ConfigTreeData;
373 config_data->i_object_id = TYPE_CATEGORY;
374 config_data->psz_help = strdup(MAIN_HELP);
375 config_data->psz_name = strdup( GENERAL_TITLE );
376 tvi.pszText = _T("General settings");
377 tvi.cchTextMax = lstrlen(_T("General settings"));
378 tvi.lParam = (long)config_data;
380 tvins.hInsertAfter = TVI_FIRST;
381 tvins.hParent = TVI_ROOT;
383 // Add the item to the tree-view control.
384 hPrev = (HTREEITEM) TreeView_InsertItem( hwndTV, &tvins);
385 general_item = hPrev;
387 /* Build the categories list */
388 for( i_index = 0; i_index < p_list->i_count; i_index++ )
390 p_module = (module_t *)p_list->p_values[i_index].p_object;
391 if( strcmp( module_get_object( p_module ), "main" ) == 0 )
395 * p_module = module_get_main( p_intf );
397 if( i_index < p_list->i_count )
399 unsigned int confsize;
400 const char *psz_help;
401 module_config_t * p_config;
403 /* We found the main module */
405 /* Enumerate config categories and store a reference so we can
406 * generate their config panel them when it is asked by the user. */
407 p_config = module_config_get (p_module, &confsize);
409 for( size_t i = 0; i < confsize; i++ )
411 /* Work on a new item */
412 module_config_t *p_item = p_config + i;
414 switch( p_item->i_type )
416 case CONFIG_CATEGORY:
417 if( p_item->value.i == -1 ) break; // Don't display it
418 config_data = new ConfigTreeData;
419 config_data->psz_name = strdup( config_CategoryNameGet(p_item->value.i ) );
420 psz_help = config_CategoryHelpGet( p_item->value.i );
423 config_data->psz_help = wraptext( strdup( psz_help ), 72 );
427 config_data->psz_help = NULL;
430 config_data->i_type = TYPE_CATEGORY;
431 config_data->i_object_id = p_item->value.i;
432 config_data->p_module = p_module;
433 tvi.pszText = _FROMMB(config_data->psz_name);
434 tvi.cchTextMax = _tcslen(tvi.pszText);
436 /* Add the category to the tree */
437 tvi.lParam = (long)config_data;
439 tvins.hInsertAfter = hPrev;
440 tvins.hParent = general_item; //level 3
442 // Add the item to the tree-view control.
443 hPrev = (HTREEITEM)TreeView_InsertItem( hwndTV, &tvins );
446 case CONFIG_SUBCATEGORY:
447 if( p_item->value.i == -1 ) break; // Don't display it
448 /* Special case: move the "general" subcategories to their parent category */
449 if(config_data && p_item->value.i == SUBCAT_VIDEO_GENERAL ||
450 p_item->value.i == SUBCAT_ADVANCED_MISC ||
451 p_item->value.i == SUBCAT_INPUT_GENERAL ||
452 p_item->value.i == SUBCAT_INTERFACE_GENERAL ||
453 p_item->value.i == SUBCAT_SOUT_GENERAL||
454 p_item->value.i == SUBCAT_PLAYLIST_GENERAL||
455 p_item->value.i == SUBCAT_AUDIO_GENERAL )
458 config_data->i_type = TYPE_CATSUBCAT;
459 config_data->i_subcat_id = p_item->value.i;
460 free( config_data->psz_name );
461 config_data->psz_name = strdup( config_CategoryNameGet( p_item->value.i ) );
463 free( config_data->psz_help );
464 const char *psz_help = config_CategoryHelpGet( p_item->value.i );
467 config_data->psz_help = wraptext( strdup( psz_help ), 72 );
471 config_data->psz_help = NULL;
476 config_data = new ConfigTreeData;
478 config_data->psz_name = strdup( config_CategoryNameGet( p_item->value.i ) );
479 psz_help = config_CategoryHelpGet( p_item->value.i );
482 config_data->psz_help = wraptext( strdup( psz_help ), 72 );
486 config_data->psz_help = NULL;
488 config_data->i_type = TYPE_SUBCATEGORY;
489 config_data->i_object_id = p_item->value.i;
491 tvi.pszText = _FROMMB(config_data->psz_name);
492 tvi.cchTextMax = _tcslen(tvi.pszText);
494 tvi.lParam = (long)config_data;
496 tvins.hInsertAfter = hPrev;
497 tvins.hParent = hPrev;
499 // Add the item to the tree-view control.
500 TreeView_InsertItem( hwndTV, &tvins );
505 TreeView_SortChildren( hwndTV, general_item, 0 );
506 module_config_free( p_config );
510 module_config_t *p_config;
512 * Build a tree of all the plugins
514 for( i_index = 0; i_index < p_list->i_count; i_index++ )
516 /* Take every module */
517 p_module = (module_t *)p_list->p_values[i_index].p_object;
519 /* Exclude the main module */
520 if( !strcmp( module_get_object( p_module ), "main" ) )
523 /* Exclude empty plugins (submodules don't have config options, they
524 * are stored in the parent module) */
526 unsigned int confsize;
528 int i_category = 0, i_subcategory = 0, i_options = 0;
529 bool b_options = false;
531 p_config = module_config_get( (module_t *) p_module,&confsize);
533 /* Loop through the configurations items */
534 for( size_t i = 0; i < confsize; i++ )
536 module_config_t *p_item = p_config + i;
537 if( p_item->i_type == CONFIG_CATEGORY )
538 i_category = p_item->value.i;
539 else if( p_item->i_type == CONFIG_SUBCATEGORY )
540 i_subcategory = p_item->value.i;
542 if( p_item->i_type & CONFIG_ITEM )
545 if( b_options && i_category && i_subcategory )
548 module_config_free (p_config);
550 //if( !i_options ) continue;
551 /* Dummy item, please proceed */
552 if( !b_options || i_category == 0 || i_subcategory == 0 ) continue;
554 category_item = TreeView_GetChild( hwndTV, general_item );
555 while(category_item != 0)
557 TVITEM category_tvi = {0};
559 category_tvi.mask = TVIF_PARAM;
560 category_tvi.lParam = NULL;
561 category_tvi.hItem = category_item;
562 TreeView_GetItem( hwndTV, &category_tvi );
564 ConfigTreeData * data = (ConfigTreeData *)category_tvi.lParam;
566 if( data->i_object_id == i_category )
568 subcategory_item = TreeView_GetChild( hwndTV, category_item );
570 while(subcategory_item != 0)
572 TVITEM subcategory_tvi = {0};
574 subcategory_tvi.mask = TVIF_PARAM;
575 subcategory_tvi.lParam = NULL;
576 subcategory_tvi.hItem = subcategory_item;
577 TreeView_GetItem( hwndTV, &subcategory_tvi );
579 ConfigTreeData * subdata = (ConfigTreeData *)subcategory_tvi.lParam;
581 if( subdata->i_object_id == i_subcategory )
583 config_data = new ConfigTreeData;
585 config_data->psz_name = strdup( module_get_object( p_module ) );
586 config_data->psz_help = NULL;
587 config_data->i_type = TYPE_MODULE;
588 config_data->i_object_id = p_item->value.i;
589 config_data->p_module = p_module;
591 tvi.pszText = _FROMMB(module_name( p_module, false ));
592 tvi.cchTextMax = _tcslen(tvi.pszText);
594 tvi.lParam = (long)config_data;
596 tvins.hInsertAfter = subcategory_item;
597 tvins.hParent = subcategory_item;
599 // Add the item to the tree-view control.
600 hPrev = (HTREEITEM)TreeView_InsertItem( hwndTV, &tvins );
603 subcategory_item = TreeView_GetNextSibling( hwndTV, subcategory_item );
609 category_item = TreeView_GetNextSibling( hwndTV, category_item );
614 /* Sort all this mess */
615 TreeView_SortChildren( hwndTV, general_item, 0 );
616 category_item = TreeView_GetChild( hwndTV, general_item );
617 while( category_item != 0 )
619 TreeView_SortChildren( hwndTV, category_item, 0 );
620 category_item = TreeView_GetNextSibling( hwndTV, category_item );
623 /* Clean-up everything */
624 vlc_list_release( p_list );
626 TreeView_Expand( hwndTV, general_item, TVE_EXPANDPARTIAL |TVE_EXPAND );
629 PrefsTreeCtrl::~PrefsTreeCtrl()
633 void PrefsTreeCtrl::ApplyChanges()
635 ConfigTreeData *config_data;
637 /* Apply changes to the main module */
638 HTREEITEM item = TreeView_GetChild( hwndTV, general_item );
642 tvi.mask = TVIF_PARAM;
644 TreeView_GetItem( hwndTV, &tvi );
645 config_data = (ConfigTreeData *)tvi.lParam;
646 if( config_data && config_data->panel )
648 config_data->panel->ApplyChanges();
651 item = TreeView_GetNextSibling( hwndTV, item );
654 /* Apply changes to the plugins */
655 item = TreeView_GetChild( hwndTV, general_item );
658 HTREEITEM item2 = TreeView_GetChild( hwndTV, item );
661 HTREEITEM item3 = TreeView_GetChild( hwndTV, item2 );
665 tvi.mask = TVIF_PARAM;
667 TreeView_GetItem( hwndTV, &tvi );
668 config_data = (ConfigTreeData *)tvi.lParam;
669 if( config_data && config_data->panel )
671 config_data->panel->ApplyChanges();
673 item3 = TreeView_GetNextSibling( hwndTV, item3 );
675 item2 = TreeView_GetNextSibling( hwndTV, item2 );
677 item = TreeView_GetNextSibling( hwndTV, item );
681 ConfigTreeData *PrefsTreeCtrl::FindModuleConfig( ConfigTreeData *config_data )
683 if( !config_data || !config_data->p_module )
688 ConfigTreeData *config_new;
689 HTREEITEM item = TreeView_GetChild( hwndTV, general_item );
692 HTREEITEM item2 = TreeView_GetChild( hwndTV, item );
695 HTREEITEM item3 = TreeView_GetChild( hwndTV, item2 );
699 tvi.mask = TVIF_PARAM;
701 TreeView_GetItem( hwndTV, &tvi );
702 config_new = (ConfigTreeData *)tvi.lParam;
703 if( config_new && config_new->p_module == config_data->p_module )
707 item3 = TreeView_GetNextSibling( hwndTV, item3 );
709 item2 = TreeView_GetNextSibling( hwndTV, item2 );
711 item = TreeView_GetNextSibling( hwndTV, item );
718 void PrefsTreeCtrl::OnSelectTreeItem( LPNM_TREEVIEW pnmtv, HWND parent,
721 ConfigTreeData *config_data = NULL;
723 if( pnmtv->itemOld.hItem )
724 config_data = FindModuleConfig( (ConfigTreeData *)pnmtv->itemOld.lParam );
726 if( config_data && config_data->panel )
728 config_data->panel->Hide();
731 /* Don't use event.GetItem() because we also send fake events */
733 tvi.mask = TVIF_PARAM;
734 tvi.hItem = TreeView_GetSelection( hwndTV );
735 TreeView_GetItem( hwndTV, &tvi );
736 config_data = FindModuleConfig( (ConfigTreeData *)tvi.lParam );
739 if( !config_data->panel )
741 /* The panel hasn't been created yet. Let's do it. */
743 new PrefsPanel( parent, hInst, p_intf, p_prefs_dialog,
744 config_data->p_module,
745 config_data->psz_name,
746 config_data->psz_help, config_data );
750 config_data->panel->Show();
755 /*****************************************************************************
756 * PrefsPanel class definition.
757 *****************************************************************************/
758 PrefsPanel::PrefsPanel( HWND parent, HINSTANCE hInst, intf_thread_t *_p_intf,
759 PrefsDialog *_p_prefs_dialog,
760 module_t *p_module, char *psz_name, char *psz_help, ConfigTreeData * config_data )
762 module_config_t *p_item, *p_config, *p_end;
764 /* Initializations */
766 p_prefs_dialog = _p_prefs_dialog;
767 vlc_list_t *p_list = NULL;
771 if( config_data->i_type == TYPE_CATEGORY )
773 label = CreateWindow( _T("STATIC"), _FROMMB(psz_name),
774 WS_CHILD | WS_VISIBLE | SS_LEFT,
775 5, 10 + (15 + 10), 200, 15,
776 parent, NULL, hInst, NULL );
777 config_window = NULL;
781 /* Get a pointer to the module */
782 if( config_data->i_type == TYPE_MODULE )
784 p_module = config_data->p_module;
788 /* List the plugins */
790 bool b_found = false;
791 p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
792 if( !p_list ) return;
794 for( i_index = 0; i_index < p_list->i_count; i_index++ )
796 p_module = (module_t *)p_list->p_values[i_index].p_object;
797 if( !strcmp( module_get_object(p_module), "main" ) )
803 if( !p_module && !b_found )
805 msg_Warn( p_intf, "unable to create preferences "
806 "(main module not found)" );
811 /* Enumerate config options and add corresponding config boxes
812 * (submodules don't have config options, they are stored in the
815 p_config = module_config_get( (module_t *) p_module,&confsize);
818 p_end = p_config + confsize;
820 /* Find the category if it has been specified */
821 if( config_data->i_type == TYPE_SUBCATEGORY ||
822 config_data->i_type == TYPE_CATSUBCAT )
824 for( ; p_item && p_item < p_end ; p_item++ )
826 if( p_item->i_type == CONFIG_SUBCATEGORY &&
827 ( config_data->i_type == TYPE_SUBCATEGORY &&
828 p_item->value.i == config_data->i_object_id ) ||
829 ( config_data->i_type == TYPE_CATSUBCAT &&
830 p_item->value.i == config_data->i_subcat_id ) )
837 /* Add a head title to the panel */
838 const char *psz_head;
839 if( config_data->i_type == TYPE_SUBCATEGORY ||
840 config_data->i_type == TYPE_CATSUBCAT )
842 psz_head = config_data->psz_name;
847 psz_head = module_GetLongName(p_module);
850 label = CreateWindow( _T("STATIC"), _FROMMB(psz_head ?
851 psz_head : _("Unknown")),
852 WS_CHILD | WS_VISIBLE | SS_LEFT,
853 5, 10 + (15 + 10), 250, 15,
854 parent, NULL, hInst, NULL );
857 memset( &wc, 0, sizeof(wc) );
858 wc.style = CS_HREDRAW | CS_VREDRAW;
859 wc.lpfnWndProc = (WNDPROC) _p_prefs_dialog->BaseWndProc;
862 wc.hInstance = hInst;
865 wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
867 wc.lpszClassName = _T("PrefsPanelClass");
871 GetWindowRect( parent, &rc);
872 config_window = CreateWindow( _T("PrefsPanelClass"),
874 WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_BORDER,
875 5, 10 + 2*(15 + 10), rc.right - 5 - 7, 105,
876 parent, NULL, hInst, (void *) _p_prefs_dialog );
879 for( ; p_item && p_item < p_end ; p_item++ )
881 /* If a category has been specified, check we finished the job */
882 if( ( ( config_data->i_type == TYPE_SUBCATEGORY &&
883 p_item->value.i != config_data->i_object_id ) ||
884 ( config_data->i_type == TYPE_CATSUBCAT &&
885 p_item->value.i != config_data->i_subcat_id ) ) &&
886 (p_item->i_type == CONFIG_CATEGORY ||
887 p_item->i_type == CONFIG_SUBCATEGORY ) )
890 ConfigControl *control = NULL;
892 control = CreateConfigControl( VLC_OBJECT(p_intf),
893 p_item, config_window,
896 /* Don't add items that were not recognized */
897 if( control == NULL ) continue;
899 /* Add the config data to our array so we can keep a trace of it */
900 config_array.push_back( control );
902 GetWindowRect( config_window, &rc);
903 maxvalue = y_pos - (rc.bottom - rc.top) + 5;
905 SetScrollRange( config_window, SB_VERT, 0, maxvalue, TRUE );
909 void PrefsPanel::Hide()
911 ShowWindow( label, SW_HIDE );
912 if( config_window ) ShowWindow( config_window, SW_HIDE );
915 void PrefsPanel::Show()
917 ShowWindow( label, SW_SHOW );
918 if( config_window ) ShowWindow( config_window, SW_SHOW );
921 void PrefsPanel::ApplyChanges()
924 for( size_t i = 0; i < config_array.size(); i++ )
926 ConfigControl *control = config_array[i];
928 switch( control->GetType() )
930 case CONFIG_ITEM_STRING:
931 case CONFIG_ITEM_FILE:
932 case CONFIG_ITEM_DIRECTORY:
933 case CONFIG_ITEM_MODULE:
934 config_PutPsz( p_intf, control->GetName(),
935 control->GetPszValue() );
937 case CONFIG_ITEM_KEY:
938 /* So you don't need to restart to have the changes take effect */
939 val.i_int = control->GetIntValue();
940 var_Set( p_intf->p_libvlc, control->GetName(), val );
941 case CONFIG_ITEM_INTEGER:
942 case CONFIG_ITEM_BOOL:
943 config_PutInt( p_intf, control->GetName(),
944 control->GetIntValue() );
946 case CONFIG_ITEM_FLOAT:
947 config_PutFloat( p_intf, control->GetName(),
948 control->GetFloatValue() );