]> git.sesse.net Git - vlc/blob - modules/gui/wxwindows/preferences_widgets.cpp
acd6293ede742fedb2ac44952ab225d8914c9aa2
[vlc] / modules / gui / wxwindows / preferences_widgets.cpp
1 /*****************************************************************************
2  * preferences_widgets.cpp : wxWindows plugin for vlc
3  *****************************************************************************
4  * Copyright (C) 2000-2004 VideoLAN
5  * $Id$
6  *
7  * Authors: Gildas Bazin <gbazin@videolan.org>
8  *          Sigmund Augdal <sigmunau@idi.ntnu.no>
9  *
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.
14  *
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.
19  *
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  *****************************************************************************/
24
25 /*****************************************************************************
26  * Preamble
27  *****************************************************************************/
28 #include <stdlib.h>                                      /* malloc(), free() */
29 #include <errno.h>                                                 /* ENOMEM */
30 #include <string.h>                                            /* strerror() */
31 #include <stdio.h>
32
33 #include <vlc/vlc.h>
34 #include <vlc/intf.h>
35
36 #include <vlc_help.h>
37
38 #include "wxwindows.h"
39 #include "preferences_widgets.h"
40
41 /*****************************************************************************
42  * CreateConfigControl wrapper
43  *****************************************************************************/
44 ConfigControl *CreateConfigControl( vlc_object_t *p_this,
45                                     module_config_t *p_item, wxWindow *parent )
46 {
47     ConfigControl *p_control = NULL;
48
49     switch( p_item->i_type )
50     {
51     case CONFIG_ITEM_MODULE:
52         p_control = new ModuleConfigControl( p_this, p_item, parent );
53         break;
54
55     case CONFIG_ITEM_STRING:
56         if( !p_item->i_list )
57         {
58             p_control = new StringConfigControl( p_this, p_item, parent );
59         }
60         else
61         {
62             p_control = new StringListConfigControl( p_this, p_item, parent );
63         }
64         break;
65
66     case CONFIG_ITEM_FILE:
67     case CONFIG_ITEM_DIRECTORY:
68         p_control = new FileConfigControl( p_this, p_item, parent );
69         break;
70
71     case CONFIG_ITEM_INTEGER:
72         if( p_item->i_list )
73         {
74             p_control = new IntegerListConfigControl( p_this, p_item, parent );
75         }
76         else if( p_item->i_min != 0 || p_item->i_max != 0 )
77         {
78             p_control = new RangedIntConfigControl( p_this, p_item, parent );
79         }
80         else
81         {
82             p_control = new IntegerConfigControl( p_this, p_item, parent );
83         }
84         break;
85
86     case CONFIG_ITEM_KEY:
87         p_control = new KeyConfigControl( p_this, p_item, parent );
88         break;
89
90     case CONFIG_ITEM_FLOAT:
91         p_control = new FloatConfigControl( p_this, p_item, parent );
92         break;
93
94     case CONFIG_ITEM_BOOL:
95         p_control = new BoolConfigControl( p_this, p_item, parent );
96         break;
97
98     default:
99         break;
100     }
101
102     return p_control;
103 }
104
105 /*****************************************************************************
106  * ConfigControl implementation
107  *****************************************************************************/
108 ConfigControl::ConfigControl( vlc_object_t *_p_this,
109                               module_config_t *p_item, wxWindow *parent )
110   : wxPanel( parent ), p_this( _p_this ),
111     pf_update_callback( NULL ), p_update_data( NULL ),
112     name( wxU(p_item->psz_name) ), i_type( p_item->i_type ),
113     b_advanced( p_item->b_advanced )
114
115 {
116     sizer = new wxBoxSizer( wxHORIZONTAL );
117 }
118
119 ConfigControl::~ConfigControl()
120 {
121 }
122
123 wxSizer *ConfigControl::Sizer()
124 {
125     return sizer;
126 }
127
128 wxString ConfigControl::GetName()
129 {
130     return name;
131 }
132
133 int ConfigControl::GetType()
134 {
135     return i_type;
136 }
137
138 vlc_bool_t ConfigControl::IsAdvanced()
139 {
140     return b_advanced;
141 }
142
143 void ConfigControl::SetUpdateCallback( void (*p_callback)( void * ),
144                                              void *p_data )
145 {
146     pf_update_callback = p_callback;
147     p_update_data = p_data;
148 }
149
150 void ConfigControl::OnUpdate( wxCommandEvent& WXUNUSED(event) )
151 {
152     if( pf_update_callback )
153     {
154         pf_update_callback( p_update_data );
155     }
156 }
157
158 /*****************************************************************************
159  * KeyConfigControl implementation
160  *****************************************************************************/
161 wxString *KeyConfigControl::m_keysList = NULL;
162
163 KeyConfigControl::KeyConfigControl( vlc_object_t *p_this,
164                                     module_config_t *p_item, wxWindow *parent )
165   : ConfigControl( p_this, p_item, parent )
166 {
167     // Number of keys descriptions
168     unsigned int i_keys = sizeof(vlc_keys)/sizeof(key_descriptor_t);
169
170     // Init the keys decriptions array
171     if( m_keysList == NULL )
172     {
173         m_keysList = new wxString[i_keys];
174         for( unsigned int i = 0; i < i_keys; i++ )
175         {
176             m_keysList[i] = wxU(vlc_keys[i].psz_key_string);
177         }
178     }
179
180     label = new wxStaticText(this, -1, wxU(p_item->psz_text));
181     alt = new wxCheckBox( this, -1, wxU(_("Alt")) );
182     alt->SetValue( p_item->i_value & KEY_MODIFIER_ALT );
183     ctrl = new wxCheckBox( this, -1, wxU(_("Ctrl")) );
184     ctrl->SetValue( p_item->i_value & KEY_MODIFIER_CTRL );
185     shift = new wxCheckBox( this, -1, wxU(_("Shift")) );
186     shift->SetValue( p_item->i_value & KEY_MODIFIER_SHIFT );
187     combo = new wxComboBox( this, -1, wxT(""), wxDefaultPosition,
188                             wxDefaultSize, i_keys, m_keysList,
189                             wxCB_READONLY );
190     for( unsigned int i = 0; i < i_keys; i++ )
191     {
192         combo->SetClientData( i, (void*)vlc_keys[i].i_key_code );
193         if( (unsigned int)vlc_keys[i].i_key_code ==
194             ( ((unsigned int)p_item->i_value) & ~KEY_MODIFIER ) )
195         {
196             combo->SetSelection( i );
197             combo->SetValue( wxU(_(vlc_keys[i].psz_key_string)) );
198         }
199     }
200
201     sizer->Add( label, 2, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 5 );
202     sizer->Add( alt,   1, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 5 );
203     sizer->Add( ctrl,  1, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 5 );
204     sizer->Add( shift, 1, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 5 );
205     sizer->Add( combo, 2, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 5 );
206     sizer->Layout();
207     this->SetSizerAndFit( sizer );
208 }
209
210 KeyConfigControl::~KeyConfigControl()
211 {
212     if( m_keysList )
213     {
214         delete[] m_keysList;
215         m_keysList = NULL;
216     }
217 }
218
219 int KeyConfigControl::GetIntValue()
220 {
221     int result = 0;
222     if( alt->IsChecked() )
223     {
224         result |= KEY_MODIFIER_ALT;
225     }
226     if( ctrl->IsChecked() )
227     {
228         result |= KEY_MODIFIER_CTRL;
229     }
230     if( shift->IsChecked() )
231     {
232         result |= KEY_MODIFIER_SHIFT;
233     }
234     int selected = combo->GetSelection();
235     if( selected != -1 )
236     {
237         result |= (int)combo->GetClientData( selected );
238     }
239     return result;
240 }
241
242 /*****************************************************************************
243  * ModuleConfigControl implementation
244  *****************************************************************************/
245 ModuleConfigControl::ModuleConfigControl( vlc_object_t *p_this,
246                                           module_config_t *p_item,
247                                           wxWindow *parent )
248   : ConfigControl( p_this, p_item, parent )
249 {
250     vlc_list_t *p_list;
251     module_t *p_parser;
252
253     label = new wxStaticText(this, -1, wxU(p_item->psz_text));
254     combo = new wxComboBox( this, -1, wxL2U(p_item->psz_value),
255                             wxDefaultPosition, wxDefaultSize,
256                             0, NULL, wxCB_READONLY | wxCB_SORT );
257
258     /* build a list of available modules */
259     p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
260     combo->Append( wxU(_("Default")), (void *)NULL );
261     combo->SetSelection( 0 );
262     for( int i_index = 0; i_index < p_list->i_count; i_index++ )
263     {
264         p_parser = (module_t *)p_list->p_values[i_index].p_object ;
265
266         if( !strcmp( p_parser->psz_capability, p_item->psz_type ) )
267         {
268             combo->Append( wxU(p_parser->psz_longname),
269                            p_parser->psz_object_name );
270             if( p_item->psz_value && !strcmp(p_item->psz_value,
271                                              p_parser->psz_object_name) )
272                 combo->SetValue( wxU(p_parser->psz_longname) );
273         }
274     }
275     vlc_list_release( p_list );
276
277     combo->SetToolTip( wxU(p_item->psz_longtext) );
278     sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
279     sizer->Add( combo, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
280     sizer->Layout();
281     this->SetSizerAndFit( sizer );
282 }
283
284 ModuleConfigControl::~ModuleConfigControl()
285 {
286     ;
287 }
288
289 wxString ModuleConfigControl::GetPszValue()
290 {
291     return wxU( (char *)combo->GetClientData( combo->GetSelection() ));
292 }
293
294 /*****************************************************************************
295  * StringConfigControl implementation
296  *****************************************************************************/
297 StringConfigControl::StringConfigControl( vlc_object_t *p_this,
298                                           module_config_t *p_item,
299                                           wxWindow *parent )
300   : ConfigControl( p_this, p_item, parent )
301 {
302     label = new wxStaticText(this, -1, wxU(p_item->psz_text));
303     sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
304     textctrl = new wxTextCtrl( this, -1,
305                                wxL2U(p_item->psz_value),
306                                wxDefaultPosition,
307                                wxDefaultSize,
308                                wxTE_PROCESS_ENTER);
309     textctrl->SetToolTip( wxU(p_item->psz_longtext) );
310     sizer->Add( textctrl, 1, wxALL, 5 );
311     sizer->Layout();
312     this->SetSizerAndFit( sizer );
313 }
314
315 StringConfigControl::~StringConfigControl()
316 {
317     ;
318 }
319
320 wxString StringConfigControl::GetPszValue()
321 {
322     return textctrl->GetValue();
323 }
324
325 BEGIN_EVENT_TABLE(StringConfigControl, wxPanel)
326     /* Text events */
327     EVT_TEXT(-1, StringConfigControl::OnUpdate)
328 END_EVENT_TABLE()
329
330 /*****************************************************************************
331  * StringListConfigControl implementation
332  *****************************************************************************/
333 StringListConfigControl::StringListConfigControl( vlc_object_t *p_this,
334                                                   module_config_t *p_item,
335                                                   wxWindow *parent )
336   : ConfigControl( p_this, p_item, parent )
337 {
338     psz_default_value = p_item->psz_value;
339     if( psz_default_value ) psz_default_value = strdup( psz_default_value );
340
341     label = new wxStaticText(this, -1, wxU(p_item->psz_text));
342     sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
343     combo = new wxComboBox( this, -1, wxT(""),
344                             wxDefaultPosition, wxDefaultSize,
345                             0, NULL, wxCB_READONLY );
346     UpdateCombo( p_item );
347
348     combo->SetToolTip( wxU(p_item->psz_longtext) );
349     sizer->Add( combo, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
350
351     for( int i = 0; i < p_item->i_action; i++ )
352     {
353         wxButton *button =
354             new wxButton( this, wxID_HIGHEST+i,
355                           wxU(p_item->ppsz_action_text[i]) );
356         sizer->Add( button, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
357     }
358
359     sizer->Layout();
360     this->SetSizerAndFit( sizer );
361 }
362
363 StringListConfigControl::~StringListConfigControl()
364 {
365     if( psz_default_value ) free( psz_default_value );
366 }
367
368 void StringListConfigControl::UpdateCombo( module_config_t *p_item )
369 {
370     vlc_bool_t b_found = VLC_FALSE;
371     int i_index;
372
373     /* build a list of available options */
374     for( i_index = 0; i_index < p_item->i_list; i_index++ )
375     {
376         combo->Append( ( p_item->ppsz_list_text &&
377                          p_item->ppsz_list_text[i_index] ) ?
378                        wxU(p_item->ppsz_list_text[i_index]) :
379                        wxL2U(p_item->ppsz_list[i_index]) );
380         combo->SetClientData( i_index, (void *)p_item->ppsz_list[i_index] );
381         if( ( p_item->psz_value &&
382               !strcmp( p_item->psz_value, p_item->ppsz_list[i_index] ) ) ||
383              ( !p_item->psz_value && !*p_item->ppsz_list[i_index] ) )
384         {
385             combo->SetSelection( i_index );
386             combo->SetValue( ( p_item->ppsz_list_text &&
387                                p_item->ppsz_list_text[i_index] ) ?
388                              wxU(p_item->ppsz_list_text[i_index]) :
389                              wxL2U(p_item->ppsz_list[i_index]) );
390             b_found = VLC_TRUE;
391         }
392     }
393
394     if( p_item->psz_value && !b_found )
395     {
396         /* Add custom entry to list */
397         combo->Append( wxL2U(p_item->psz_value) );
398         combo->SetClientData( i_index, (void *)psz_default_value );
399         combo->SetSelection( i_index );
400         combo->SetValue( wxL2U(p_item->psz_value) );
401     }
402 }
403
404 BEGIN_EVENT_TABLE(StringListConfigControl, wxPanel)
405     /* Button events */
406     EVT_BUTTON(-1, StringListConfigControl::OnAction)
407
408     /* Text events */
409     EVT_TEXT(-1, StringListConfigControl::OnUpdate)
410 END_EVENT_TABLE()
411
412 void StringListConfigControl::OnAction( wxCommandEvent& event )
413 {
414     int i_action = event.GetId() - wxID_HIGHEST;
415
416     module_config_t *p_item = config_FindConfig( p_this, GetName().mb_str() );
417     if( !p_item ) return;
418
419     if( i_action < 0 || i_action >= p_item->i_action ) return;
420
421     vlc_value_t val;
422     wxString value = GetPszValue();
423     *((const char **)&val.psz_string) = value.mb_str();
424     p_item->ppf_action[i_action]( p_this, GetName().mb_str(), val, val, 0 );
425
426     if( p_item->b_dirty )
427     {
428         combo->Clear();
429         UpdateCombo( p_item );
430         p_item->b_dirty = VLC_FALSE;
431     }
432 }
433
434 wxString StringListConfigControl::GetPszValue()
435 {
436     int selected = combo->GetSelection();
437     if( selected != -1 )
438     {
439         return wxL2U((char *)combo->GetClientData( selected ));
440     }
441     return wxString();
442 }
443
444 /*****************************************************************************
445  * FileConfigControl implementation
446  *****************************************************************************/
447 FileConfigControl::FileConfigControl( vlc_object_t *p_this,
448                                       module_config_t *p_item,
449                                       wxWindow *parent )
450   : ConfigControl( p_this, p_item, parent )
451 {
452     directory = p_item->i_type == CONFIG_ITEM_DIRECTORY;
453     label = new wxStaticText(this, -1, wxU(p_item->psz_text));
454     sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
455     textctrl = new wxTextCtrl( this, -1,
456                                wxL2U(p_item->psz_value),
457                                wxDefaultPosition,
458                                wxDefaultSize,
459                                wxTE_PROCESS_ENTER);
460     textctrl->SetToolTip( wxU(p_item->psz_longtext) );
461     sizer->Add( textctrl, 1, wxALL, 5 );
462     browse = new wxButton( this, wxID_HIGHEST, wxU(_("Browse...")) );
463     sizer->Add( browse, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
464     sizer->Layout();
465     this->SetSizerAndFit( sizer );
466 }
467
468 BEGIN_EVENT_TABLE(FileConfigControl, wxPanel)
469     /* Button events */
470     EVT_BUTTON(wxID_HIGHEST, FileConfigControl::OnBrowse)
471 END_EVENT_TABLE()
472
473 void FileConfigControl::OnBrowse( wxCommandEvent& event )
474 {
475     if( directory )
476     {
477         wxDirDialog dialog( this, wxU(_("Choose directory")) );
478
479         if( dialog.ShowModal() == wxID_OK )
480         {
481             textctrl->SetValue( dialog.GetPath() );
482         }
483     }
484     else
485     {
486         wxFileDialog dialog( this, wxU(_("Choose file")),
487                              wxT(""), wxT(""), wxT("*.*"),
488 #if defined( __WXMSW__ )
489                              wxOPEN
490 #else
491                              wxOPEN | wxSAVE
492 #endif
493                            );
494         if( dialog.ShowModal() == wxID_OK )
495         {
496             textctrl->SetValue( dialog.GetPath() );
497         }
498     }
499 }
500
501 FileConfigControl::~FileConfigControl()
502 {
503     ;
504 }
505
506 wxString FileConfigControl::GetPszValue()
507 {
508     return textctrl->GetValue();
509 }
510
511 /*****************************************************************************
512  * IntegerConfigControl implementation
513  *****************************************************************************/
514 BEGIN_EVENT_TABLE(IntegerConfigControl, wxPanel)
515     EVT_TEXT(-1, IntegerConfigControl::OnUpdate)
516     EVT_COMMAND_SCROLL(-1, IntegerConfigControl::OnUpdate)
517 END_EVENT_TABLE()
518
519 IntegerConfigControl::IntegerConfigControl( vlc_object_t *p_this,
520                                             module_config_t *p_item,
521                                             wxWindow *parent )
522   : ConfigControl( p_this, p_item, parent )
523 {
524     label = new wxStaticText(this, -1, wxU(p_item->psz_text));
525     spin = new wxSpinCtrl( this, -1,
526                            wxString::Format(wxT("%d"),
527                                             p_item->i_value),
528                            wxDefaultPosition, wxDefaultSize,
529                            wxSP_ARROW_KEYS,
530                            -100000000, 100000000, p_item->i_value);
531     spin->SetToolTip( wxU(p_item->psz_longtext) );
532     sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
533     sizer->Add( spin, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
534     sizer->Layout();
535     this->SetSizerAndFit( sizer );
536     i_value = p_item->i_value;
537 }
538
539 IntegerConfigControl::~IntegerConfigControl()
540 {
541     ;
542 }
543
544 int IntegerConfigControl::GetIntValue()
545 {
546     /* We avoid using GetValue because of a recursion bug with wxSpinCtrl with
547      * wxGTK. */
548     return i_value; //spin->GetValue();
549 }
550
551 void IntegerConfigControl::OnUpdate( wxCommandEvent &event )
552 {
553     i_value = event.GetInt();
554     ConfigControl::OnUpdate( event );
555 }
556
557 /*****************************************************************************
558  * IntegerListConfigControl implementation
559  *****************************************************************************/
560 IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *p_this,
561                                                     module_config_t *p_item,
562                                                     wxWindow *parent )
563   : ConfigControl( p_this, p_item, parent )
564 {
565     label = new wxStaticText(this, -1, wxU(p_item->psz_text));
566     sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
567     combo = new wxComboBox( this, -1, wxT(""),
568                             wxDefaultPosition, wxDefaultSize,
569                             0, NULL, wxCB_READONLY );
570
571     UpdateCombo( p_item );
572
573     combo->SetToolTip( wxU(p_item->psz_longtext) );
574     sizer->Add( combo, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
575
576     sizer->Layout();
577     this->SetSizerAndFit( sizer );
578 }
579
580 IntegerListConfigControl::~IntegerListConfigControl()
581 {
582 }
583
584 void IntegerListConfigControl::UpdateCombo( module_config_t *p_item )
585 {
586     /* build a list of available options */
587     for( int i_index = 0; i_index < p_item->i_list; i_index++ )
588     {
589         if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
590         {
591             combo->Append( wxU(p_item->ppsz_list_text[i_index]) );
592         }
593         else
594         {
595             combo->Append( wxString::Format(wxT("%i"),
596                                             p_item->pi_list[i_index]) );
597         }
598         combo->SetClientData( i_index, (void *)p_item->pi_list[i_index] );
599         if( p_item->i_value == p_item->pi_list[i_index] )
600         {
601             combo->SetSelection( i_index );
602             if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
603             {
604                 combo->SetValue( wxU(p_item->ppsz_list_text[i_index]) );
605             }
606             else
607             {
608                 combo->SetValue( wxString::Format(wxT("%i"),
609                                                   p_item->pi_list[i_index]) );
610             }
611         }
612     }
613 }
614
615 BEGIN_EVENT_TABLE(IntegerListConfigControl, wxPanel)
616     /* Button events */
617     EVT_BUTTON(-1, IntegerListConfigControl::OnAction)
618 END_EVENT_TABLE()
619
620 void IntegerListConfigControl::OnAction( wxCommandEvent& event )
621 {
622     int i_action = event.GetId() - wxID_HIGHEST;
623
624     module_config_t *p_item;
625     p_item = config_FindConfig( p_this, GetName().mb_str() );
626     if( !p_item ) return;
627
628     if( i_action < 0 || i_action >= p_item->i_action ) return;
629
630     vlc_value_t val;
631     val.i_int = GetIntValue();
632     p_item->ppf_action[i_action]( p_this, GetName().mb_str(), val, val, 0 );
633
634     if( p_item->b_dirty )
635     {
636         combo->Clear();
637         UpdateCombo( p_item );
638         p_item->b_dirty = VLC_FALSE;
639     }
640 }
641
642 int IntegerListConfigControl::GetIntValue()
643 {
644     int selected = combo->GetSelection();
645     if( selected != -1 )
646     {
647         return (int)combo->GetClientData( selected );
648     }
649     return -1;
650 }
651
652 /*****************************************************************************
653  * RangedIntConfigControl implementation
654  *****************************************************************************/
655 BEGIN_EVENT_TABLE(RangedIntConfigControl, wxPanel)
656     EVT_COMMAND_SCROLL(-1, RangedIntConfigControl::OnUpdate)
657 END_EVENT_TABLE()
658
659 RangedIntConfigControl::RangedIntConfigControl( vlc_object_t *p_this,
660                                                 module_config_t *p_item,
661                                                 wxWindow *parent )
662   : ConfigControl( p_this, p_item, parent )
663 {
664     label = new wxStaticText(this, -1, wxU(p_item->psz_text));
665     slider = new wxSlider( this, -1, p_item->i_value, p_item->i_min,
666                            p_item->i_max, wxDefaultPosition, wxDefaultSize,
667                            wxSL_LABELS | wxSL_HORIZONTAL );
668     slider->SetToolTip( wxU(p_item->psz_longtext) );
669     sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
670     sizer->Add( slider, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
671     sizer->Layout();
672     this->SetSizerAndFit( sizer );
673 }
674
675 RangedIntConfigControl::~RangedIntConfigControl()
676 {
677     ;
678 }
679
680 int RangedIntConfigControl::GetIntValue()
681 {
682     return slider->GetValue();
683 }
684
685 /*****************************************************************************
686  * FloatConfigControl implementation
687  *****************************************************************************/
688 BEGIN_EVENT_TABLE(FloatConfigControl, wxPanel)
689     EVT_TEXT(-1, FloatConfigControl::OnUpdate)
690 END_EVENT_TABLE()
691
692 FloatConfigControl::FloatConfigControl( vlc_object_t *p_this,
693                                         module_config_t *p_item,
694                                         wxWindow *parent )
695   : ConfigControl( p_this, p_item, parent )
696 {
697     label = new wxStaticText(this, -1, wxU(p_item->psz_text));
698     textctrl = new wxTextCtrl( this, -1,
699                                wxString::Format(wxT("%f"),
700                                                 p_item->f_value),
701                                wxDefaultPosition, wxDefaultSize,
702                                wxTE_PROCESS_ENTER );
703     textctrl->SetToolTip( wxU(p_item->psz_longtext) );
704     sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
705     sizer->Add( textctrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
706     sizer->Layout();
707     this->SetSizerAndFit( sizer );
708 }
709
710 FloatConfigControl::~FloatConfigControl()
711 {
712     ;
713 }
714
715 float FloatConfigControl::GetFloatValue()
716 {
717     float f_value;
718     if( (wxSscanf(textctrl->GetValue(), wxT("%f"), &f_value) == 1) )
719         return f_value;
720     else return 0.0;
721 }
722
723 /*****************************************************************************
724  * BoolConfigControl implementation
725  *****************************************************************************/
726 BEGIN_EVENT_TABLE(BoolConfigControl, wxPanel)
727     EVT_CHECKBOX(-1, BoolConfigControl::OnUpdate)
728 END_EVENT_TABLE()
729
730 BoolConfigControl::BoolConfigControl( vlc_object_t *p_this,
731                                       module_config_t *p_item,
732                                       wxWindow *parent )
733   : ConfigControl( p_this, p_item, parent )
734 {
735     checkbox = new wxCheckBox( this, -1, wxU(p_item->psz_text) );
736     if( p_item->i_value ) checkbox->SetValue(TRUE);
737     checkbox->SetToolTip( wxU(p_item->psz_longtext) );
738     sizer->Add( checkbox, 0, wxALL, 5 );
739     sizer->Layout();
740     this->SetSizerAndFit( sizer );
741 }
742
743 BoolConfigControl::~BoolConfigControl()
744 {
745     ;
746 }
747
748 int BoolConfigControl::GetIntValue()
749 {
750     if( checkbox->IsChecked() ) return 1;
751     else return 0;
752 }