1 /*****************************************************************************
2 * preferences_widgets.cpp : wxWindows plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2004 the VideoLAN team
7 * Authors: Gildas Bazin <gbazin@videolan.org>
8 * Sigmund Augdal <sigmunau@idi.ntnu.no>
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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
28 #include <stdlib.h> /* malloc(), free() */
29 #include <errno.h> /* ENOMEM */
30 #include <string.h> /* strerror() */
36 #include <vlc_config_cat.h>
38 #include "wxwindows.h"
39 #include "preferences_widgets.h"
41 #include <wx/statline.h>
43 /*****************************************************************************
44 * CreateConfigControl wrapper
45 *****************************************************************************/
46 ConfigControl *CreateConfigControl( vlc_object_t *p_this,
47 module_config_t *p_item, wxWindow *parent )
49 ConfigControl *p_control = NULL;
51 /*Skip deprecated options */
52 if( p_item->psz_current )
57 switch( p_item->i_type )
59 case CONFIG_ITEM_MODULE:
60 p_control = new ModuleConfigControl( p_this, p_item, parent );
62 case CONFIG_ITEM_MODULE_CAT:
63 p_control = new ModuleCatConfigControl( p_this, p_item, parent );
65 case CONFIG_ITEM_MODULE_LIST_CAT:
66 p_control = new ModuleListCatConfigControl( p_this, p_item, parent );
69 case CONFIG_ITEM_STRING:
72 p_control = new StringConfigControl( p_this, p_item, parent );
76 p_control = new StringListConfigControl( p_this, p_item, parent );
80 case CONFIG_ITEM_FILE:
81 case CONFIG_ITEM_DIRECTORY:
82 p_control = new FileConfigControl( p_this, p_item, parent );
85 case CONFIG_ITEM_INTEGER:
88 p_control = new IntegerListConfigControl( p_this, p_item, parent );
90 else if( p_item->i_min != 0 || p_item->i_max != 0 )
92 p_control = new RangedIntConfigControl( p_this, p_item, parent );
96 p_control = new IntegerConfigControl( p_this, p_item, parent );
100 case CONFIG_ITEM_KEY:
101 p_control = new KeyConfigControl( p_this, p_item, parent );
104 case CONFIG_ITEM_FLOAT:
105 p_control = new FloatConfigControl( p_this, p_item, parent );
108 case CONFIG_ITEM_BOOL:
109 p_control = new BoolConfigControl( p_this, p_item, parent );
113 p_control = new SectionConfigControl( p_this, p_item, parent );
123 /*****************************************************************************
124 * ConfigControl implementation
125 *****************************************************************************/
126 ConfigControl::ConfigControl( vlc_object_t *_p_this,
127 module_config_t *p_item, wxWindow *parent )
128 : wxPanel( parent ), p_this( _p_this ),
129 pf_update_callback( NULL ), p_update_data( NULL ),
130 name( wxU(p_item->psz_name) ), i_type( p_item->i_type ),
131 b_advanced( p_item->b_advanced )
134 sizer = new wxBoxSizer( wxHORIZONTAL );
137 ConfigControl::~ConfigControl()
141 wxSizer *ConfigControl::Sizer()
146 wxString ConfigControl::GetName()
151 int ConfigControl::GetType()
156 vlc_bool_t ConfigControl::IsAdvanced()
161 void ConfigControl::SetUpdateCallback( void (*p_callback)( void * ),
164 pf_update_callback = p_callback;
165 p_update_data = p_data;
168 void ConfigControl::OnUpdate( wxCommandEvent& WXUNUSED(event) )
170 if( pf_update_callback )
172 pf_update_callback( p_update_data );
176 void ConfigControl::OnUpdateScroll( wxScrollEvent& WXUNUSED(event) )
178 wxCommandEvent cevent;
183 /*****************************************************************************
184 * KeyConfigControl implementation
185 *****************************************************************************/
186 wxString *KeyConfigControl::m_keysList = NULL;
188 KeyConfigControl::KeyConfigControl( vlc_object_t *p_this,
189 module_config_t *p_item, wxWindow *parent )
190 : ConfigControl( p_this, p_item, parent )
192 // Number of keys descriptions
193 unsigned int i_keys = sizeof(vlc_keys)/sizeof(key_descriptor_t);
195 // Init the keys decriptions array
196 if( m_keysList == NULL )
198 m_keysList = new wxString[i_keys];
199 for( unsigned int i = 0; i < i_keys; i++ )
201 m_keysList[i] = wxU(vlc_keys[i].psz_key_string);
205 label = new wxStaticText(this, -1, wxU(p_item->psz_text));
206 alt = new wxCheckBox( this, -1, wxU(_("Alt")) );
207 alt->SetValue( p_item->i_value & KEY_MODIFIER_ALT );
208 ctrl = new wxCheckBox( this, -1, wxU(_("Ctrl")) );
209 ctrl->SetValue( p_item->i_value & KEY_MODIFIER_CTRL );
210 shift = new wxCheckBox( this, -1, wxU(_("Shift")) );
211 shift->SetValue( p_item->i_value & KEY_MODIFIER_SHIFT );
212 combo = new wxComboBox( this, -1, wxT(""), wxDefaultPosition,
213 wxDefaultSize, i_keys, m_keysList,
215 for( unsigned int i = 0; i < i_keys; i++ )
217 combo->SetClientData( i, (void*)vlc_keys[i].i_key_code );
218 if( (unsigned int)vlc_keys[i].i_key_code ==
219 ( ((unsigned int)p_item->i_value) & ~KEY_MODIFIER ) )
221 combo->SetSelection( i );
222 combo->SetValue( wxU(_(vlc_keys[i].psz_key_string)) );
226 sizer->Add( label, 2, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 5 );
227 sizer->Add( alt, 1, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 5 );
228 sizer->Add( ctrl, 1, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 5 );
229 sizer->Add( shift, 1, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 5 );
230 sizer->Add( combo, 2, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 5 );
232 this->SetSizerAndFit( sizer );
235 KeyConfigControl::~KeyConfigControl()
244 int KeyConfigControl::GetIntValue()
247 if( alt->IsChecked() )
249 result |= KEY_MODIFIER_ALT;
251 if( ctrl->IsChecked() )
253 result |= KEY_MODIFIER_CTRL;
255 if( shift->IsChecked() )
257 result |= KEY_MODIFIER_SHIFT;
259 int selected = combo->GetSelection();
262 result |= (int)combo->GetClientData( selected );
267 /*****************************************************************************
268 * ModuleConfigControl implementation
269 *****************************************************************************/
270 ModuleConfigControl::ModuleConfigControl( vlc_object_t *p_this,
271 module_config_t *p_item,
273 : ConfigControl( p_this, p_item, parent )
278 label = new wxStaticText(this, -1, wxU(p_item->psz_text));
279 combo = new wxComboBox( this, -1, wxL2U(p_item->psz_value),
280 wxDefaultPosition, wxDefaultSize,
281 0, NULL, wxCB_READONLY | wxCB_SORT );
283 /* build a list of available modules */
284 p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
285 combo->Append( wxU(_("Default")), (void *)NULL );
286 combo->SetSelection( 0 );
287 for( int i_index = 0; i_index < p_list->i_count; i_index++ )
289 p_parser = (module_t *)p_list->p_values[i_index].p_object ;
291 if( !strcmp( p_parser->psz_capability, p_item->psz_type ) )
293 combo->Append( wxU(p_parser->psz_longname),
294 p_parser->psz_object_name );
295 if( p_item->psz_value && !strcmp(p_item->psz_value,
296 p_parser->psz_object_name) )
297 combo->SetValue( wxU(p_parser->psz_longname) );
300 vlc_list_release( p_list );
302 combo->SetToolTip( wxU(p_item->psz_longtext) );
303 sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
304 sizer->Add( combo, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
306 this->SetSizerAndFit( sizer );
309 ModuleCatConfigControl::~ModuleCatConfigControl()
314 wxString ModuleCatConfigControl::GetPszValue()
316 return wxU( (char *)combo->GetClientData( combo->GetSelection() ));
319 /*****************************************************************************
320 * ModuleCatConfigControl implementation
321 *****************************************************************************/
322 ModuleCatConfigControl::ModuleCatConfigControl( vlc_object_t *p_this,
323 module_config_t *p_item,
325 : ConfigControl( p_this, p_item, parent )
330 label = new wxStaticText(this, -1, wxU(p_item->psz_text));
331 combo = new wxComboBox( this, -1, wxL2U(p_item->psz_value),
332 wxDefaultPosition, wxDefaultSize,
333 0, NULL, wxCB_READONLY | wxCB_SORT );
335 combo->Append( wxU(_("Default")), (void *)NULL );
336 combo->SetSelection( 0 );
338 /* build a list of available modules */
339 p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
340 for( int i_index = 0; i_index < p_list->i_count; i_index++ )
342 p_parser = (module_t *)p_list->p_values[i_index].p_object ;
344 if( !strcmp( p_parser->psz_object_name, "main" ) )
347 module_config_t *p_config = p_parser->p_config;
350 /* Hack: required subcategory is stored in i_min */
351 if( p_config->i_type == CONFIG_SUBCATEGORY &&
352 p_config->i_value == p_item->i_min )
354 combo->Append( wxU(p_parser->psz_longname),
355 p_parser->psz_object_name );
356 if( p_item->psz_value && !strcmp(p_item->psz_value,
357 p_parser->psz_object_name) )
358 combo->SetValue( wxU(p_parser->psz_longname) );
360 } while( p_config->i_type != CONFIG_HINT_END && p_config++ );
362 vlc_list_release( p_list );
364 combo->SetToolTip( wxU(p_item->psz_longtext) );
365 sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
366 sizer->Add( combo, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
368 this->SetSizerAndFit( sizer );
371 ModuleConfigControl::~ModuleConfigControl()
376 wxString ModuleConfigControl::GetPszValue()
378 return wxU( (char *)combo->GetClientData( combo->GetSelection() ));
382 /*****************************************************************************
383 * ModuleListCatonfigControl implementation
384 *****************************************************************************/
385 BEGIN_EVENT_TABLE(ModuleListCatConfigControl, wxPanel)
386 EVT_CHECKBOX( wxID_HIGHEST , ModuleListCatConfigControl::OnUpdate )
390 ModuleListCatConfigControl::ModuleListCatConfigControl( vlc_object_t *p_this,
391 module_config_t *p_item,
393 : ConfigControl( p_this, p_item, parent )
399 sizer = new wxBoxSizer( wxVERTICAL );
400 label = new wxStaticText(this, -1, wxU(p_item->psz_text));
403 text = new wxTextCtrl( this, -1, wxU(p_item->psz_value),
404 wxDefaultPosition,wxSize( 300, 20 ) );
407 /* build a list of available modules */
408 p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
409 for( int i_index = 0; i_index < p_list->i_count; i_index++ )
411 p_parser = (module_t *)p_list->p_values[i_index].p_object ;
413 if( !strcmp( p_parser->psz_object_name, "main" ) )
416 module_config_t *p_config = p_parser->p_config;
419 /* Hack: required subcategory is stored in i_min */
420 if( p_config->i_type == CONFIG_SUBCATEGORY &&
421 p_config->i_value == p_item->i_min )
423 moduleCheckBox *mc = new moduleCheckBox;
424 mc->checkbox = new wxCheckBox( this, wxID_HIGHEST,
425 wxU(p_parser->psz_longname));
426 mc->psz_module = strdup( p_parser->psz_object_name );
427 pp_checkboxes.push_back( mc );
429 if( p_item->psz_value &&
430 strstr( p_item->psz_value, p_parser->psz_object_name ) )
432 mc->checkbox->SetValue( true );
434 sizer->Add( mc->checkbox );
436 } while( p_config->i_type != CONFIG_HINT_END && p_config++ );
438 vlc_list_release( p_list );
440 text->SetToolTip( wxU(p_item->psz_longtext) );
441 sizer->Add(text, 0, wxEXPAND|wxALL, 5 );
443 sizer->Add (new wxStaticText( this, -1, wxU( vlc_wraptext( _("Select modules that you want. To get more advanced control, you can also modify the resulting chain by yourself") , 72, ISUTF8 ) ) ) );
446 this->SetSizerAndFit( sizer );
449 ModuleListCatConfigControl::~ModuleListCatConfigControl()
454 wxString ModuleListCatConfigControl::GetPszValue()
456 return text->GetValue() ;
459 void ModuleListCatConfigControl::OnUpdate( wxCommandEvent &event )
461 bool b_waschecked = false;
462 wxString newtext = text->GetValue();
464 for( unsigned int i = 0 ; i< pp_checkboxes.size() ; i++ )
466 b_waschecked = newtext.Find( wxU(pp_checkboxes[i]->psz_module)) != -1 ;
467 /* For some reasons, ^^ doesn't compile :( */
468 if( (pp_checkboxes[i]->checkbox->IsChecked() && ! b_waschecked )||
469 (! pp_checkboxes[i]->checkbox->IsChecked() && b_waschecked) )
473 /* Maybe not the clest solution */
474 if( ! newtext.Replace(wxString(wxT(":"))
475 +wxU(pp_checkboxes[i]->psz_module),
478 if( ! newtext.Replace(wxString(wxU(pp_checkboxes[i]->psz_module))
481 newtext.Replace(wxU(pp_checkboxes[i]->psz_module),wxU(""));
487 if( newtext.Len() == 0 )
489 newtext = wxU(pp_checkboxes[i]->psz_module);
493 newtext += wxU( ":" );
494 newtext += wxU(pp_checkboxes[i]->psz_module);
499 text->SetValue( newtext );
502 /*****************************************************************************
503 * StringConfigControl implementation
504 *****************************************************************************/
505 StringConfigControl::StringConfigControl( vlc_object_t *p_this,
506 module_config_t *p_item,
508 : ConfigControl( p_this, p_item, parent )
510 label = new wxStaticText(this, -1, wxU(p_item->psz_text));
511 sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
512 textctrl = new wxTextCtrl( this, -1,
513 wxL2U(p_item->psz_value),
517 textctrl->SetToolTip( wxU(p_item->psz_longtext) );
518 sizer->Add( textctrl, 1, wxALL, 5 );
520 this->SetSizerAndFit( sizer );
523 StringConfigControl::~StringConfigControl()
528 wxString StringConfigControl::GetPszValue()
530 return textctrl->GetValue();
533 BEGIN_EVENT_TABLE(StringConfigControl, wxPanel)
535 EVT_TEXT(-1, StringConfigControl::OnUpdate)
538 /*****************************************************************************
539 * StringListConfigControl implementation
540 *****************************************************************************/
541 StringListConfigControl::StringListConfigControl( vlc_object_t *p_this,
542 module_config_t *p_item,
544 : ConfigControl( p_this, p_item, parent )
546 psz_default_value = p_item->psz_value;
547 if( psz_default_value ) psz_default_value = strdup( psz_default_value );
549 label = new wxStaticText(this, -1, wxU(p_item->psz_text));
550 sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
551 combo = new wxComboBox( this, -1, wxT(""),
552 wxDefaultPosition, wxDefaultSize,
553 0, NULL, wxCB_READONLY );
554 UpdateCombo( p_item );
556 combo->SetToolTip( wxU(p_item->psz_longtext) );
557 sizer->Add( combo, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
559 for( int i = 0; i < p_item->i_action; i++ )
562 new wxButton( this, wxID_HIGHEST+i,
563 wxU(p_item->ppsz_action_text[i]) );
564 sizer->Add( button, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
568 this->SetSizerAndFit( sizer );
571 StringListConfigControl::~StringListConfigControl()
573 if( psz_default_value ) free( psz_default_value );
576 void StringListConfigControl::UpdateCombo( module_config_t *p_item )
578 vlc_bool_t b_found = VLC_FALSE;
581 /* build a list of available options */
582 for( i_index = 0; i_index < p_item->i_list; i_index++ )
584 combo->Append( ( p_item->ppsz_list_text &&
585 p_item->ppsz_list_text[i_index] ) ?
586 wxU(p_item->ppsz_list_text[i_index]) :
587 wxL2U(p_item->ppsz_list[i_index]) );
588 combo->SetClientData( i_index, (void *)p_item->ppsz_list[i_index] );
589 if( ( p_item->psz_value &&
590 !strcmp( p_item->psz_value, p_item->ppsz_list[i_index] ) ) ||
591 ( !p_item->psz_value && !*p_item->ppsz_list[i_index] ) )
593 combo->SetSelection( i_index );
594 combo->SetValue( ( p_item->ppsz_list_text &&
595 p_item->ppsz_list_text[i_index] ) ?
596 wxU(p_item->ppsz_list_text[i_index]) :
597 wxL2U(p_item->ppsz_list[i_index]) );
602 if( p_item->psz_value && !b_found )
604 /* Add custom entry to list */
605 combo->Append( wxL2U(p_item->psz_value) );
606 combo->SetClientData( i_index, (void *)psz_default_value );
607 combo->SetSelection( i_index );
608 combo->SetValue( wxL2U(p_item->psz_value) );
612 BEGIN_EVENT_TABLE(StringListConfigControl, wxPanel)
614 EVT_BUTTON(-1, StringListConfigControl::OnAction)
617 EVT_TEXT(-1, StringListConfigControl::OnUpdate)
620 void StringListConfigControl::OnAction( wxCommandEvent& event )
622 int i_action = event.GetId() - wxID_HIGHEST;
624 module_config_t *p_item = config_FindConfig( p_this, GetName().mb_str() );
625 if( !p_item ) return;
627 if( i_action < 0 || i_action >= p_item->i_action ) return;
630 wxString value = GetPszValue();
631 *((const char **)&val.psz_string) = value.mb_str();
632 p_item->ppf_action[i_action]( p_this, GetName().mb_str(), val, val, 0 );
634 if( p_item->b_dirty )
637 UpdateCombo( p_item );
638 p_item->b_dirty = VLC_FALSE;
642 wxString StringListConfigControl::GetPszValue()
644 int selected = combo->GetSelection();
647 return wxL2U((char *)combo->GetClientData( selected ));
652 /*****************************************************************************
653 * FileConfigControl implementation
654 *****************************************************************************/
655 FileConfigControl::FileConfigControl( vlc_object_t *p_this,
656 module_config_t *p_item,
658 : ConfigControl( p_this, p_item, parent )
660 directory = p_item->i_type == CONFIG_ITEM_DIRECTORY;
661 label = new wxStaticText(this, -1, wxU(p_item->psz_text));
662 sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
663 textctrl = new wxTextCtrl( this, -1,
664 wxL2U(p_item->psz_value),
668 textctrl->SetToolTip( wxU(p_item->psz_longtext) );
669 sizer->Add( textctrl, 1, wxALL, 5 );
670 browse = new wxButton( this, wxID_HIGHEST, wxU(_("Browse...")) );
671 sizer->Add( browse, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
673 this->SetSizerAndFit( sizer );
676 BEGIN_EVENT_TABLE(FileConfigControl, wxPanel)
678 EVT_BUTTON(wxID_HIGHEST, FileConfigControl::OnBrowse)
681 void FileConfigControl::OnBrowse( wxCommandEvent& event )
685 wxDirDialog dialog( this, wxU(_("Choose directory")) );
687 if( dialog.ShowModal() == wxID_OK )
689 textctrl->SetValue( dialog.GetPath() );
694 wxFileDialog dialog( this, wxU(_("Choose file")),
695 wxT(""), wxT(""), wxT("*.*"),
696 #if defined( __WXMSW__ )
702 if( dialog.ShowModal() == wxID_OK )
704 textctrl->SetValue( dialog.GetPath() );
709 FileConfigControl::~FileConfigControl()
714 wxString FileConfigControl::GetPszValue()
716 return textctrl->GetValue();
719 /*****************************************************************************
720 * IntegerConfigControl implementation
721 *****************************************************************************/
722 BEGIN_EVENT_TABLE(IntegerConfigControl, wxPanel)
723 EVT_TEXT(-1, IntegerConfigControl::OnUpdate)
724 EVT_COMMAND_SCROLL(-1, IntegerConfigControl::OnUpdateScroll)
727 IntegerConfigControl::IntegerConfigControl( vlc_object_t *p_this,
728 module_config_t *p_item,
730 : ConfigControl( p_this, p_item, parent )
732 label = new wxStaticText(this, -1, wxU(p_item->psz_text));
733 spin = new wxSpinCtrl( this, -1,
734 wxString::Format(wxT("%d"),
736 wxDefaultPosition, wxDefaultSize,
738 -100000000, 100000000, p_item->i_value);
739 spin->SetToolTip( wxU(p_item->psz_longtext) );
740 sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
741 sizer->Add( spin, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
743 this->SetSizerAndFit( sizer );
744 i_value = p_item->i_value;
747 IntegerConfigControl::~IntegerConfigControl()
752 int IntegerConfigControl::GetIntValue()
754 /* We avoid using GetValue because of a recursion bug with wxSpinCtrl with
756 return i_value; //spin->GetValue();
759 void IntegerConfigControl::OnUpdate( wxCommandEvent &event )
761 i_value = event.GetInt();
762 ConfigControl::OnUpdate( event );
764 void IntegerConfigControl::OnUpdateScroll( wxScrollEvent &event )
766 wxCommandEvent cevent;
767 cevent.SetInt(event.GetPosition());
771 /*****************************************************************************
772 * IntegerListConfigControl implementation
773 *****************************************************************************/
774 IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *p_this,
775 module_config_t *p_item,
777 : ConfigControl( p_this, p_item, parent )
779 label = new wxStaticText(this, -1, wxU(p_item->psz_text));
780 sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
781 combo = new wxComboBox( this, -1, wxT(""),
782 wxDefaultPosition, wxDefaultSize,
783 0, NULL, wxCB_READONLY );
785 UpdateCombo( p_item );
787 combo->SetToolTip( wxU(p_item->psz_longtext) );
788 sizer->Add( combo, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
791 this->SetSizerAndFit( sizer );
794 IntegerListConfigControl::~IntegerListConfigControl()
798 void IntegerListConfigControl::UpdateCombo( module_config_t *p_item )
800 /* build a list of available options */
801 for( int i_index = 0; i_index < p_item->i_list; i_index++ )
803 if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
805 combo->Append( wxU(p_item->ppsz_list_text[i_index]) );
809 combo->Append( wxString::Format(wxT("%i"),
810 p_item->pi_list[i_index]) );
812 combo->SetClientData( i_index, (void *)p_item->pi_list[i_index] );
813 if( p_item->i_value == p_item->pi_list[i_index] )
815 combo->SetSelection( i_index );
816 if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
818 combo->SetValue( wxU(p_item->ppsz_list_text[i_index]) );
822 combo->SetValue( wxString::Format(wxT("%i"),
823 p_item->pi_list[i_index]) );
829 BEGIN_EVENT_TABLE(IntegerListConfigControl, wxPanel)
831 EVT_BUTTON(-1, IntegerListConfigControl::OnAction)
834 EVT_TEXT(-1, IntegerListConfigControl::OnUpdate)
837 void IntegerListConfigControl::OnAction( wxCommandEvent& event )
839 int i_action = event.GetId() - wxID_HIGHEST;
841 module_config_t *p_item;
842 p_item = config_FindConfig( p_this, GetName().mb_str() );
843 if( !p_item ) return;
845 if( i_action < 0 || i_action >= p_item->i_action ) return;
848 val.i_int = GetIntValue();
849 p_item->ppf_action[i_action]( p_this, GetName().mb_str(), val, val, 0 );
851 if( p_item->b_dirty )
854 UpdateCombo( p_item );
855 p_item->b_dirty = VLC_FALSE;
859 int IntegerListConfigControl::GetIntValue()
861 int selected = combo->GetSelection();
864 return (int)combo->GetClientData( selected );
869 /*****************************************************************************
870 * RangedIntConfigControl implementation
871 *****************************************************************************/
872 BEGIN_EVENT_TABLE(RangedIntConfigControl, wxPanel)
873 EVT_COMMAND_SCROLL(-1, RangedIntConfigControl::OnUpdateScroll)
876 RangedIntConfigControl::RangedIntConfigControl( vlc_object_t *p_this,
877 module_config_t *p_item,
879 : ConfigControl( p_this, p_item, parent )
881 label = new wxStaticText(this, -1, wxU(p_item->psz_text));
882 slider = new wxSlider( this, -1, p_item->i_value, p_item->i_min,
883 p_item->i_max, wxDefaultPosition, wxDefaultSize,
884 wxSL_LABELS | wxSL_HORIZONTAL );
885 slider->SetToolTip( wxU(p_item->psz_longtext) );
886 sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
887 sizer->Add( slider, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
889 this->SetSizerAndFit( sizer );
892 RangedIntConfigControl::~RangedIntConfigControl()
897 int RangedIntConfigControl::GetIntValue()
899 return slider->GetValue();
903 /*****************************************************************************
904 * FloatConfigControl implementation
905 *****************************************************************************/
906 BEGIN_EVENT_TABLE(FloatConfigControl, wxPanel)
907 EVT_TEXT(-1, FloatConfigControl::OnUpdate)
910 FloatConfigControl::FloatConfigControl( vlc_object_t *p_this,
911 module_config_t *p_item,
913 : ConfigControl( p_this, p_item, parent )
915 label = new wxStaticText(this, -1, wxU(p_item->psz_text));
916 textctrl = new wxTextCtrl( this, -1,
917 wxString::Format(wxT("%f"),
919 wxDefaultPosition, wxDefaultSize,
920 wxTE_PROCESS_ENTER );
921 textctrl->SetToolTip( wxU(p_item->psz_longtext) );
922 sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
923 sizer->Add( textctrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
925 this->SetSizerAndFit( sizer );
928 FloatConfigControl::~FloatConfigControl()
933 float FloatConfigControl::GetFloatValue()
936 if( (wxSscanf(textctrl->GetValue(), wxT("%f"), &f_value) == 1) )
941 /*****************************************************************************
942 * BoolConfigControl implementation
943 *****************************************************************************/
944 BEGIN_EVENT_TABLE(BoolConfigControl, wxPanel)
945 EVT_CHECKBOX(-1, BoolConfigControl::OnUpdate)
948 BoolConfigControl::BoolConfigControl( vlc_object_t *p_this,
949 module_config_t *p_item,
951 : ConfigControl( p_this, p_item, parent )
953 checkbox = new wxCheckBox( this, -1, wxU(p_item->psz_text) );
954 if( p_item->i_value ) checkbox->SetValue(TRUE);
955 checkbox->SetToolTip( wxU(p_item->psz_longtext) );
956 sizer->Add( checkbox, 0, wxALL, 5 );
958 this->SetSizerAndFit( sizer );
961 BoolConfigControl::~BoolConfigControl()
966 int BoolConfigControl::GetIntValue()
968 if( checkbox->IsChecked() ) return 1;
972 /*****************************************************************************
973 * SectionConfigControl implementation
974 *****************************************************************************/
975 SectionConfigControl::SectionConfigControl( vlc_object_t *p_this,
976 module_config_t *p_item,
978 : ConfigControl( p_this, p_item, parent )
981 sizer = new wxBoxSizer( wxVERTICAL );
982 sizer->Add( new wxStaticText( this, -1, wxU( p_item->psz_text ) ) );
983 sizer->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND, 5 );
985 this->SetSizerAndFit( sizer );
988 SectionConfigControl::~SectionConfigControl()