00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include <stdlib.h>
00029 #include <string.h>
00030 #include <stdio.h>
00031 #include <vlc/vlc.h>
00032 #include <vlc/intf.h>
00033
00034 #include "wince.h"
00035
00036 #include <winuser.h>
00037 #include <windows.h>
00038 #include <windowsx.h>
00039 #include <commctrl.h>
00040 #include <commdlg.h>
00041
00042 #include <vlc_config_cat.h>
00043
00044 #include "preferences_widgets.h"
00045
00046 #define GENERAL_ID 1242
00047 #define PLUGIN_ID 1243
00048 #define CAPABILITY_ID 1244
00049
00050
00051
00052
00053
00054
00055 enum
00056 {
00057 Notebook_Event,
00058 MRL_Event,
00059 ResetAll_Event,
00060 Advanced_Event
00061 };
00062
00063
00064
00065
00066 class ConfigTreeData;
00067 class PrefsTreeCtrl
00068 {
00069 public:
00070
00071 PrefsTreeCtrl() { }
00072 PrefsTreeCtrl( intf_thread_t *_p_intf, PrefsDialog *p_prefs_dialog,
00073 HWND hwnd, HINSTANCE _hInst );
00074 virtual ~PrefsTreeCtrl();
00075
00076 void ApplyChanges();
00077
00078
00079 void OnSelectTreeItem( LPNM_TREEVIEW pnmtv, HWND parent, HINSTANCE hInst );
00080
00081 ConfigTreeData *FindModuleConfig( ConfigTreeData *config_data );
00082
00083 HWND hwndTV;
00084
00085 private:
00086 intf_thread_t *p_intf;
00087 PrefsDialog *p_prefs_dialog;
00088 vlc_bool_t b_advanced;
00089
00090 HTREEITEM general_item;
00091 HTREEITEM plugins_item;
00092 };
00093
00094 class PrefsPanel
00095 {
00096 public:
00097
00098 PrefsPanel() { }
00099 PrefsPanel( HWND parent, HINSTANCE hInst, intf_thread_t *_p_intf,
00100 PrefsDialog *, int i_object_id, char *, char * );
00101 virtual ~PrefsPanel() {}
00102
00103 void Hide();
00104 void Show();
00105
00106 HWND config_window;
00107
00108 int oldvalue;
00109 int maxvalue;
00110
00111 void ApplyChanges();
00112
00113 private:
00114 intf_thread_t *p_intf;
00115 PrefsDialog *p_prefs_dialog;
00116
00117 vlc_bool_t b_advanced;
00118
00119 HWND label;
00120
00121 vector<ConfigControl *> config_array;
00122 };
00123
00124 class ConfigTreeData
00125 {
00126 public:
00127
00128 ConfigTreeData() { b_submodule = 0; panel = NULL; psz_section = NULL;
00129 psz_help = NULL; }
00130 virtual ~ConfigTreeData() { if( panel ) delete panel;
00131 if( psz_section) free(psz_section);
00132 if( psz_help) free(psz_help); }
00133
00134 vlc_bool_t b_submodule;
00135
00136 PrefsPanel *panel;
00137 int i_object_id;
00138 char *psz_section;
00139 char *psz_help;
00140 };
00141
00142
00143
00144
00145 PrefsDialog::PrefsDialog( intf_thread_t *p_intf, CBaseWindow *p_parent,
00146 HINSTANCE h_inst )
00147 : CBaseWindow( p_intf, p_parent, h_inst )
00148 {
00149
00150 prefs_tree = NULL;
00151 }
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162 LRESULT PrefsDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
00163 {
00164 SHINITDLGINFO shidi;
00165 SHMENUBARINFO mbi;
00166 RECT rcClient;
00167
00168 switch( msg )
00169 {
00170 case WM_INITDIALOG:
00171 shidi.dwMask = SHIDIM_FLAGS;
00172 shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN |
00173 SHIDIF_FULLSCREENNOMENUBAR;
00174 shidi.hDlg = hwnd;
00175 SHInitDialog( &shidi );
00176
00177
00178 memset( &mbi, 0, sizeof (SHMENUBARINFO) );
00179 mbi.cbSize = sizeof (SHMENUBARINFO);
00180 mbi.hwndParent = hwnd;
00181 mbi.dwFlags = SHCMBF_EMPTYBAR;
00182 mbi.hInstRes = hInst;
00183
00184 if( !SHCreateMenuBar(&mbi) )
00185 {
00186 MessageBox(hwnd, _T("SHCreateMenuBar Failed"), _T("Error"), MB_OK);
00187
00188 }
00189
00190 hwndCB = mbi.hwndMB;
00191
00192
00193 GetClientRect(hwnd, &rcClient);
00194
00195
00196 advanced_checkbox =
00197 CreateWindow( _T("BUTTON"), _T("Advanced options"),
00198 WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
00199 5, 10, 15, 15, hwnd, NULL, hInst, NULL );
00200 SendMessage( advanced_checkbox, BM_SETCHECK, BST_UNCHECKED, 0 );
00201
00202 advanced_label = CreateWindow( _T("STATIC"), _T("Advanced options"),
00203 WS_CHILD | WS_VISIBLE | SS_LEFT,
00204 5 + 15 + 5, 10, 110, 15,
00205 hwnd, NULL, hInst, NULL);
00206
00207 if( config_GetInt( p_intf, "advanced" ) )
00208 {
00209 SendMessage( advanced_checkbox, BM_SETCHECK, BST_CHECKED, 0 );
00210
00211
00212 }
00213
00214 reset_button = CreateWindow( _T("BUTTON"), _T("Reset All"),
00215 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
00216 rcClient.right - 5 - 80, 10 - 3, 80, 15 + 6,
00217 hwnd, NULL, hInst, NULL );
00218
00219
00220 prefs_tree = new PrefsTreeCtrl( p_intf, this, hwnd, hInst );
00221
00222 UpdateWindow( hwnd );
00223 break;
00224
00225 case WM_CLOSE:
00226 EndDialog( hwnd, LOWORD( wp ) );
00227 break;
00228
00229 case WM_SETFOCUS:
00230 SHFullScreen( hwnd, SHFS_SHOWSIPBUTTON );
00231 break;
00232
00233 case WM_COMMAND:
00234 if( LOWORD(wp) == IDOK )
00235 {
00236 OnOk();
00237 EndDialog( hwnd, LOWORD( wp ) );
00238 }
00239 break;
00240
00241 case WM_NOTIFY:
00242
00243 if( lp && prefs_tree &&
00244 ((LPNMHDR)lp)->hwndFrom == prefs_tree->hwndTV &&
00245 ((LPNMHDR)lp)->code == TVN_SELCHANGED )
00246 {
00247 prefs_tree->OnSelectTreeItem( (NM_TREEVIEW FAR *)(LPNMHDR)lp,
00248 hwnd, hInst );
00249 }
00250 break;
00251
00252 case WM_VSCROLL:
00253 {
00254 TVITEM tvi = {0};
00255 tvi.mask = TVIF_PARAM;
00256 tvi.hItem = TreeView_GetSelection( prefs_tree->hwndTV );
00257 if( !tvi.hItem ) break;
00258
00259 if( !TreeView_GetItem( prefs_tree->hwndTV, &tvi ) ) break;
00260
00261 ConfigTreeData *config_data =
00262 prefs_tree->FindModuleConfig( (ConfigTreeData *)tvi.lParam );
00263 if( config_data && hwnd == config_data->panel->config_window )
00264 {
00265 int dy;
00266 RECT rc;
00267 GetWindowRect( hwnd, &rc);
00268 int newvalue = config_data->panel->oldvalue;
00269 switch ( GET_WM_VSCROLL_CODE(wp,lp) )
00270 {
00271 case SB_BOTTOM : newvalue = 0; break;
00272 case SB_TOP : newvalue = config_data->panel->maxvalue; break;
00273 case SB_LINEDOWN : newvalue += 10; break;
00274 case SB_PAGEDOWN : newvalue += rc.bottom - rc.top - 25; break;
00275 case SB_LINEUP : newvalue -= 10; break;
00276 case SB_PAGEUP : newvalue -= rc.bottom - rc.top - 25; break;
00277 case SB_THUMBPOSITION:
00278 case SB_THUMBTRACK : newvalue = GET_WM_VSCROLL_POS(wp,lp); break;
00279 }
00280 newvalue = max(0,min(config_data->panel->maxvalue,newvalue));
00281 SetScrollPos( hwnd,SB_VERT,newvalue,TRUE);
00282 dy = config_data->panel->oldvalue - newvalue;
00283
00284 ScrollWindowEx( hwnd, 0, dy, NULL, NULL, NULL, NULL, SW_SCROLLCHILDREN );
00285 UpdateWindow ( hwnd);
00286
00287 config_data->panel->oldvalue = newvalue;
00288 }
00289 break;
00290 }
00291
00292 default:
00293 break;
00294 }
00295
00296 return FALSE;
00297 }
00298
00299
00300
00301
00302
00303
00304
00305
00306 void PrefsDialog::OnOk( void )
00307 {
00308 prefs_tree->ApplyChanges();
00309 config_SaveConfigFile( p_intf, NULL );
00310 }
00311
00312
00313
00314
00315 PrefsTreeCtrl::PrefsTreeCtrl( intf_thread_t *_p_intf,
00316 PrefsDialog *_p_prefs_dialog, HWND hwnd,
00317 HINSTANCE hInst )
00318 {
00319 vlc_list_t *p_list;
00320 module_t *p_module;
00321 module_config_t *p_item;
00322 int i_index;
00323
00324 INITCOMMONCONTROLSEX iccex;
00325 RECT rcClient;
00326 TVITEM tvi = {0};
00327 TVINSERTSTRUCT tvins = {0};
00328 HTREEITEM hPrev;
00329
00330 size_t i_capability_count = 0;
00331 size_t i_child_index;
00332
00333 HTREEITEM capability_item;
00334
00335
00336 p_intf = _p_intf;
00337 p_prefs_dialog = _p_prefs_dialog;
00338 b_advanced = VLC_FALSE;
00339
00340
00341
00342 iccex.dwSize = sizeof( INITCOMMONCONTROLSEX );
00343 iccex.dwICC = ICC_TREEVIEW_CLASSES;
00344
00345
00346 InitCommonControlsEx( &iccex );
00347
00348
00349 GetClientRect(hwnd, &rcClient);
00350
00351
00352 hwndTV = CreateWindowEx( 0, WC_TREEVIEW, NULL,
00353 WS_VISIBLE | WS_CHILD | WS_BORDER | TVS_HASLINES |
00354 TVS_LINESATROOT | TVS_HASBUTTONS,
00355 5, 10 + 2*(15 + 10) + 105 + 5, rcClient.right - 5 - 5, 6*15,
00356 hwnd, NULL, hInst, NULL );
00357
00358 tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
00359
00360
00361 p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
00362 if( !p_list ) return;
00363
00364
00365
00366
00367 ConfigTreeData *config_data = new ConfigTreeData;
00368 config_data->i_object_id = GENERAL_ID;
00369 config_data->psz_help = strdup("nothing");
00370 config_data->psz_section = strdup( GENERAL_TITLE );
00371 tvi.pszText = _T("General settings");
00372 tvi.cchTextMax = lstrlen(_T("General settings"));
00373 tvi.lParam = (long)config_data;
00374 tvins.item = tvi;
00375 tvins.hInsertAfter = TVI_FIRST;
00376 tvins.hParent = TVI_ROOT;
00377
00378
00379 hPrev = (HTREEITEM) TreeView_InsertItem( hwndTV, &tvins);
00380 general_item = hPrev;
00381
00382 for( i_index = 0; i_index < p_list->i_count; i_index++ )
00383 {
00384 p_module = (module_t *)p_list->p_values[i_index].p_object;
00385 if( !strcmp( p_module->psz_object_name, "main" ) )
00386 break;
00387 }
00388 if( i_index < p_list->i_count )
00389 {
00390
00391
00392
00393
00394 p_item = p_module->p_config;
00395
00396 if( p_item ) do
00397 {
00398 switch( p_item->i_type )
00399 {
00400 case CONFIG_HINT_CATEGORY:
00401 ConfigTreeData *config_data = new ConfigTreeData;
00402 config_data->psz_section = strdup( p_item->psz_text );
00403 if( p_item->psz_longtext )
00404 {
00405 config_data->psz_help =
00406 strdup( p_item->psz_longtext );
00407 }
00408 else
00409 {
00410 config_data->psz_help = NULL;
00411 }
00412 config_data->i_object_id = p_module->i_object_id;
00413
00414
00415
00416 tvi.pszText = _FROMMB(p_item->psz_text);
00417 tvi.cchTextMax = _tcslen(tvi.pszText);
00418 tvi.lParam = (long)config_data;
00419 tvins.item = tvi;
00420 tvins.hInsertAfter = hPrev;
00421 tvins.hParent = general_item;
00422
00423
00424 hPrev = (HTREEITEM)TreeView_InsertItem( hwndTV, &tvins );
00425
00426 break;
00427 }
00428 }
00429 while( p_item->i_type != CONFIG_HINT_END && p_item++ );
00430
00431 TreeView_SortChildren( hwndTV, general_item, 0 );
00432 }
00433
00434
00435
00436
00437 config_data = new ConfigTreeData;
00438 config_data->i_object_id = PLUGIN_ID;
00439 config_data->psz_help = strdup("nothing");
00440 config_data->psz_section = strdup("nothing");
00441 tvi.pszText = _T("Modules");
00442 tvi.cchTextMax = lstrlen(_T("Modules"));
00443 tvi.lParam = (long)config_data;
00444 tvins.item = tvi;
00445 tvins.hInsertAfter = TVI_LAST;
00446 tvins.hParent = TVI_ROOT;
00447
00448
00449 hPrev = (HTREEITEM) TreeView_InsertItem( hwndTV, &tvins);
00450 plugins_item = hPrev;
00451
00452 i_capability_count = 0;
00453 for( i_index = 0; i_index < p_list->i_count; i_index++ )
00454 {
00455 i_child_index = 0;
00456
00457 p_module = (module_t *)p_list->p_values[i_index].p_object;
00458
00459
00460 if( !strcmp( p_module->psz_object_name, "main" ) )
00461 continue;
00462
00463
00464
00465 if( p_module->b_submodule )
00466 p_item = ((module_t *)p_module->p_parent)->p_config;
00467 else
00468 p_item = p_module->p_config;
00469
00470 if( !p_item ) continue;
00471 do
00472 {
00473 if( p_item->i_type & CONFIG_ITEM )
00474 break;
00475 }
00476 while( p_item->i_type != CONFIG_HINT_END && p_item++ );
00477 if( p_item->i_type == CONFIG_HINT_END ) continue;
00478
00479
00480
00481 capability_item = TreeView_GetChild( hwndTV, plugins_item );
00482 while( capability_item != 0 )
00483 {
00484 TVITEM capability_tvi = {0};
00485 TCHAR psz_text[256];
00486 i_child_index++;
00487
00488 capability_tvi.mask = TVIF_TEXT;
00489 capability_tvi.pszText = psz_text;
00490 capability_tvi.cchTextMax = 256;
00491 capability_tvi.hItem = capability_item;
00492 TreeView_GetItem( hwndTV, &capability_tvi );
00493 if( !strcmp( _TOMB(capability_tvi.pszText),
00494 p_module->psz_capability ) ) break;
00495
00496 capability_item =
00497 TreeView_GetNextSibling( hwndTV, capability_item );
00498 }
00499
00500 if( i_child_index == i_capability_count &&
00501 p_module->psz_capability && *p_module->psz_capability )
00502 {
00503
00504 ConfigTreeData *config_data = new ConfigTreeData;
00505 config_data->psz_section =
00506 strdup( GetCapabilityHelp( p_module->psz_capability , 1 ) );
00507 config_data->psz_help =
00508 strdup( GetCapabilityHelp( p_module->psz_capability , 2 ) );
00509 config_data->i_object_id = CAPABILITY_ID;
00510 tvi.pszText = _FROMMB(p_module->psz_capability);
00511 tvi.cchTextMax = _tcslen(tvi.pszText);
00512 tvi.lParam = (long)config_data;
00513 tvins.item = tvi;
00514 tvins.hInsertAfter = plugins_item;
00515 tvins.hParent = plugins_item;
00516
00517
00518 capability_item = (HTREEITEM) TreeView_InsertItem( hwndTV, &tvins);
00519
00520 i_capability_count++;
00521 }
00522
00523
00524 ConfigTreeData *config_data = new ConfigTreeData;
00525 config_data->b_submodule = p_module->b_submodule;
00526 config_data->i_object_id = p_module->b_submodule ?
00527 ((module_t *)p_module->p_parent)->i_object_id :
00528 p_module->i_object_id;
00529 config_data->psz_help = NULL;
00530 tvi.pszText = _FROMMB(p_module->psz_object_name);
00531 tvi.cchTextMax = _tcslen(tvi.pszText);
00532 tvi.lParam = (long)config_data;
00533 tvins.item = tvi;
00534 tvins.hInsertAfter = capability_item;
00535 tvins.hParent = capability_item;
00536
00537
00538 TreeView_InsertItem( hwndTV, &tvins );
00539 }
00540
00541
00542
00543 TreeView_SortChildren( hwndTV, plugins_item, 0 );
00544 capability_item = TreeView_GetChild( hwndTV, plugins_item );
00545 while( capability_item != 0 )
00546 {
00547 TreeView_SortChildren( hwndTV, capability_item, 0 );
00548 capability_item = TreeView_GetNextSibling( hwndTV, capability_item );
00549 }
00550
00551
00552 vlc_list_release( p_list );
00553
00554 TreeView_Expand( hwndTV, general_item, TVE_EXPANDPARTIAL |TVE_EXPAND );
00555 }
00556
00557 PrefsTreeCtrl::~PrefsTreeCtrl()
00558 {
00559 }
00560
00561 void PrefsTreeCtrl::ApplyChanges()
00562 {
00563
00564 ConfigTreeData *config_data;
00565
00566
00567 HTREEITEM item = TreeView_GetChild( hwndTV, general_item );
00568 while( item != 0 )
00569 {
00570 TVITEM tvi = {0};
00571 tvi.mask = TVIF_PARAM;
00572 tvi.hItem = item;
00573 TreeView_GetItem( hwndTV, &tvi );
00574 config_data = (ConfigTreeData *)tvi.lParam;
00575 if( config_data && config_data->panel )
00576 {
00577 config_data->panel->ApplyChanges();
00578 }
00579
00580 item = TreeView_GetNextSibling( hwndTV, item );
00581 }
00582
00583
00584 item = TreeView_GetChild( hwndTV, plugins_item );
00585 while( item != 0 )
00586 {
00587 HTREEITEM item2 = TreeView_GetChild( hwndTV, item );
00588 while( item2 != 0 )
00589 {
00590 TVITEM tvi = {0};
00591 tvi.mask = TVIF_PARAM;
00592 tvi.hItem = item2;
00593 TreeView_GetItem( hwndTV, &tvi );
00594 config_data = (ConfigTreeData *)tvi.lParam;
00595 if( config_data && config_data->panel )
00596 {
00597 config_data->panel->ApplyChanges();
00598 }
00599 item2 = TreeView_GetNextSibling( hwndTV, item2 );
00600 }
00601 item = TreeView_GetNextSibling( hwndTV, item );
00602 }
00603 }
00604
00605 ConfigTreeData *PrefsTreeCtrl::FindModuleConfig( ConfigTreeData *config_data )
00606 {
00607
00608
00609
00610 if( !config_data || !config_data->b_submodule )
00611 {
00612 return config_data;
00613 }
00614
00615
00616 ConfigTreeData *config_new;
00617 HTREEITEM item = TreeView_GetChild( hwndTV, plugins_item );
00618 while( item != 0 )
00619 {
00620 HTREEITEM item2 = TreeView_GetChild( hwndTV, item );
00621 while( item2 != 0 )
00622 {
00623 TVITEM tvi = {0};
00624 tvi.mask = TVIF_PARAM;
00625 tvi.hItem = item2;
00626 TreeView_GetItem( hwndTV, &tvi );
00627 config_new = (ConfigTreeData *)tvi.lParam;
00628 if( config_new && !config_new->b_submodule &&
00629 config_new->i_object_id == config_data->i_object_id )
00630 {
00631 return config_new;
00632 }
00633 item2 = TreeView_GetNextSibling( hwndTV, item2 );
00634 }
00635 item = TreeView_GetNextSibling( hwndTV, item );
00636 }
00637
00638
00639 return NULL;
00640 }
00641
00642 void PrefsTreeCtrl::OnSelectTreeItem( LPNM_TREEVIEW pnmtv, HWND parent,
00643 HINSTANCE hInst )
00644 {
00645 ConfigTreeData *config_data = NULL;
00646
00647 if( pnmtv->itemOld.hItem )
00648 config_data = FindModuleConfig( (ConfigTreeData *)pnmtv->itemOld.lParam );
00649
00650 if( config_data && config_data->panel )
00651 {
00652 config_data->panel->Hide();
00653 }
00654
00655
00656 TVITEM tvi = {0};
00657 tvi.mask = TVIF_PARAM;
00658 tvi.hItem = TreeView_GetSelection( hwndTV );
00659 TreeView_GetItem( hwndTV, &tvi );
00660 config_data = FindModuleConfig( (ConfigTreeData *)tvi.lParam );
00661 if( config_data )
00662 {
00663 if( !config_data->panel )
00664 {
00665
00666 config_data->panel =
00667 new PrefsPanel( parent, hInst, p_intf, p_prefs_dialog,
00668 config_data->i_object_id,
00669 config_data->psz_section,
00670 config_data->psz_help );
00671 }
00672 else
00673 {
00674 config_data->panel->Show();
00675 }
00676 }
00677 }
00678
00679
00680
00681
00682 PrefsPanel::PrefsPanel( HWND parent, HINSTANCE hInst, intf_thread_t *_p_intf,
00683 PrefsDialog *_p_prefs_dialog,
00684 int i_object_id, char *psz_section, char *psz_help )
00685 {
00686 module_config_t *p_item;
00687 module_t *p_module = NULL;
00688
00689
00690 p_intf = _p_intf;
00691 p_prefs_dialog = _p_prefs_dialog;
00692
00693 b_advanced = VLC_TRUE;
00694
00695 if( i_object_id == PLUGIN_ID || i_object_id == GENERAL_ID ||
00696 i_object_id == CAPABILITY_ID )
00697 {
00698 label = CreateWindow( _T("STATIC"), _FROMMB(psz_section),
00699 WS_CHILD | WS_VISIBLE | SS_LEFT,
00700 5, 10 + (15 + 10), 200, 15,
00701 parent, NULL, hInst, NULL );
00702 config_window = NULL;
00703 }
00704 else
00705 {
00706
00707 p_module = (module_t *)vlc_object_get( p_intf, i_object_id );
00708 if( p_module->i_object_type != VLC_OBJECT_MODULE )
00709 {
00710
00711 return;
00712 }
00713
00714
00715
00716
00717 if( p_module->b_submodule )
00718 p_item = ((module_t *)p_module->p_parent)->p_config;
00719 else
00720 p_item = p_module->p_config;
00721
00722
00723 if( psz_section && p_item->i_type == CONFIG_HINT_CATEGORY )
00724 {
00725 while( !(p_item->i_type == CONFIG_HINT_CATEGORY) ||
00726 strcmp( psz_section, p_item->psz_text ) )
00727 {
00728 if( p_item->i_type == CONFIG_HINT_END ) break;
00729 p_item++;
00730 }
00731 }
00732
00733
00734 label = CreateWindow( _T("STATIC"), _FROMMB(psz_section ?
00735 p_item->psz_text : p_module->psz_longname),
00736 WS_CHILD | WS_VISIBLE | SS_LEFT,
00737 5, 10 + (15 + 10), 250, 15,
00738 parent, NULL, hInst, NULL );
00739
00740 WNDCLASS wc;
00741 memset( &wc, 0, sizeof(wc) );
00742 wc.style = CS_HREDRAW | CS_VREDRAW;
00743 wc.lpfnWndProc = (WNDPROC) _p_prefs_dialog->BaseWndProc;
00744 wc.cbClsExtra = 0;
00745 wc.cbWndExtra = 0;
00746 wc.hInstance = hInst;
00747 wc.hIcon = 0;
00748 wc.hCursor = 0;
00749 wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
00750 wc.lpszMenuName = 0;
00751 wc.lpszClassName = _T("PrefsPanelClass");
00752 RegisterClass(&wc);
00753
00754 RECT rc;
00755 GetWindowRect( parent, &rc);
00756 config_window = CreateWindow( _T("PrefsPanelClass"),
00757 _T("config_window"),
00758 WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_BORDER,
00759 5, 10 + 2*(15 + 10), rc.right - 5 - 7, 105,
00760 parent, NULL, hInst, (void *) _p_prefs_dialog );
00761
00762 int y_pos = 5;
00763 if( p_item ) do
00764 {
00765
00766 if( psz_section && p_item->i_type == CONFIG_HINT_CATEGORY &&
00767 strcmp( psz_section, p_item->psz_text ) )
00768 break;
00769
00770 ConfigControl *control =
00771 CreateConfigControl( VLC_OBJECT(p_intf),
00772 p_item, config_window,
00773 hInst, &y_pos );
00774
00775
00776 if( control == NULL ) continue;
00777
00778
00779 config_array.push_back( control );
00780 }
00781 while( p_item->i_type != CONFIG_HINT_END && p_item++ );
00782
00783 GetWindowRect( config_window, &rc);
00784 maxvalue = y_pos - (rc.bottom - rc.top) + 5;
00785 oldvalue = 0;
00786 SetScrollRange( config_window, SB_VERT, 0, maxvalue, TRUE );
00787 }
00788 }
00789
00790 void PrefsPanel::Hide()
00791 {
00792 ShowWindow( label, SW_HIDE );
00793 if( config_window ) ShowWindow( config_window, SW_HIDE );
00794 }
00795
00796 void PrefsPanel::Show()
00797 {
00798 ShowWindow( label, SW_SHOW );
00799 if( config_window ) ShowWindow( config_window, SW_SHOW );
00800 }
00801
00802 void PrefsPanel::ApplyChanges()
00803 {
00804 vlc_value_t val;
00805
00806 for( size_t i = 0; i < config_array.size(); i++ )
00807 {
00808 ConfigControl *control = config_array[i];
00809
00810 switch( control->GetType() )
00811 {
00812 case CONFIG_ITEM_STRING:
00813 case CONFIG_ITEM_FILE:
00814 case CONFIG_ITEM_DIRECTORY:
00815 case CONFIG_ITEM_MODULE:
00816 config_PutPsz( p_intf, control->GetName(),
00817 control->GetPszValue() );
00818 break;
00819 case CONFIG_ITEM_KEY:
00820
00821 val.i_int = control->GetIntValue();
00822 var_Set( p_intf->p_vlc, control->GetName(), val );
00823 case CONFIG_ITEM_INTEGER:
00824 case CONFIG_ITEM_BOOL:
00825 config_PutInt( p_intf, control->GetName(),
00826 control->GetIntValue() );
00827 break;
00828 case CONFIG_ITEM_FLOAT:
00829 config_PutFloat( p_intf, control->GetName(),
00830 control->GetFloatValue() );
00831 break;
00832 }
00833 }
00834 }