]> git.sesse.net Git - vlc/blob - modules/gui/wxwindows/preferences_widgets.cpp
6f4531ebe43e82dcdb4dcb5ca44c3e6b6c2881bb
[vlc] / modules / gui / wxwindows / preferences_widgets.cpp
1 /*****************************************************************************
2  * preferences_widgets.cpp : wxWindows plugin for vlc
3  *****************************************************************************
4  * Copyright (C) 2000-2001 VideoLAN
5  * $Id: preferences_widgets.cpp,v 1.11 2003/11/05 02:43:55 gbazin Exp $
6  *
7  * Authors: Gildas Bazin <gbazin@netcourrier.com>
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 ), name( wxU(p_item->psz_name) ),
111     i_type( p_item->i_type ), b_advanced( p_item->b_advanced )
112 {
113     sizer = new wxBoxSizer( wxHORIZONTAL );
114     i_counter++;
115 }
116
117 ConfigControl::~ConfigControl()
118 {
119 }
120
121 int ConfigControl::i_counter = 0;
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 /*****************************************************************************
144  * KeyConfigControl implementation
145  *****************************************************************************/
146 static wxString KeysList[] =
147 {
148     wxT("Unset"),
149     wxT("Left"),
150     wxT("Right"),
151     wxT("Up"),
152     wxT("Down"),
153     wxT("Space"),
154     wxT("Enter"),
155     wxT("F1"),
156     wxT("F2"),
157     wxT("F3"),
158     wxT("F4"),
159     wxT("F5"),
160     wxT("F6"),
161     wxT("F7"),
162     wxT("F8"),
163     wxT("F9"),
164     wxT("F10"),
165     wxT("F11"),
166     wxT("F12"),
167     wxT("Home"),
168     wxT("End"),
169     wxT("Menu"),
170     wxT("Esc"),
171     wxT("Page Up"),
172     wxT("Page Down"),
173     wxT("Tab"),
174     wxT("Backspace"),
175     wxT("a"),
176     wxT("b"),
177     wxT("c"),
178     wxT("d"),
179     wxT("e"),
180     wxT("f"),
181     wxT("g"),
182     wxT("h"),
183     wxT("i"),
184     wxT("j"),
185     wxT("k"),
186     wxT("l"),
187     wxT("m"),
188     wxT("n"),
189     wxT("o"),
190     wxT("p"),
191     wxT("q"),
192     wxT("r"),
193     wxT("s"),
194     wxT("t"),
195     wxT("u"),
196     wxT("v"),
197     wxT("w"),
198     wxT("x"),
199     wxT("y"),
200     wxT("z"),
201     wxT("+"),
202     wxT("="),
203     wxT("-"),
204     wxT(","),
205     wxT("."),
206     wxT("<"),
207     wxT(">"),
208     wxT("`"),
209     wxT("/"),
210     wxT(";"),
211     wxT("'"),
212     wxT("\\"),
213     wxT("["),
214     wxT("]"),
215     wxT("*")
216 };
217
218 KeyConfigControl::KeyConfigControl( vlc_object_t *p_this,
219                                     module_config_t *p_item, wxWindow *parent )
220   : ConfigControl( p_this, p_item, parent )
221 {
222     label = new wxStaticText(this, -1, wxU(p_item->psz_text));
223     alt = new wxCheckBox( this, -1, wxU(_("Alt")) );
224     alt->SetValue( p_item->i_value & KEY_MODIFIER_ALT );
225     ctrl = new wxCheckBox( this, -1, wxU(_("Ctrl")) );
226     ctrl->SetValue( p_item->i_value & KEY_MODIFIER_CTRL );
227     shift = new wxCheckBox( this, -1, wxU(_("Shift")) );
228     shift->SetValue( p_item->i_value & KEY_MODIFIER_SHIFT );
229     combo = new wxComboBox( this, -1, wxT(""), wxDefaultPosition,
230                             wxDefaultSize, WXSIZEOF(KeysList), KeysList,
231                             wxCB_READONLY );
232     for( unsigned int i = 0; i < WXSIZEOF(KeysList); i++ )
233     {
234         combo->SetClientData( i, (void*)keys[i].i_key_code );
235         if( keys[i].i_key_code ==
236             ( ((unsigned int)p_item->i_value) & ~KEY_MODIFIER ) )
237         {
238             combo->SetSelection( i );
239             combo->SetValue( wxU(_(keys[i].psz_key_string)) );
240         }
241     }
242
243     sizer->Add( label, 2, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 5 );
244     sizer->Add( alt,   1, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 5 );
245     sizer->Add( ctrl,  1, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 5 );
246     sizer->Add( shift, 1, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 5 );
247     sizer->Add( combo, 2, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 5 );
248     sizer->Layout();
249     this->SetSizerAndFit( sizer );
250 }
251
252 KeyConfigControl::~KeyConfigControl()
253 {
254     ;
255 }
256
257 int KeyConfigControl::GetIntValue()
258 {
259     int result = 0;
260     if( alt->IsChecked() )
261     {
262         result |= KEY_MODIFIER_ALT;
263     }
264     if( ctrl->IsChecked() )
265     {
266         result |= KEY_MODIFIER_CTRL;
267     }
268     if( shift->IsChecked() )
269     {
270         result |= KEY_MODIFIER_SHIFT;
271     }
272     int selected = combo->GetSelection();
273     if( selected != -1 )
274     {
275         result |= (int)combo->GetClientData( selected );
276     }
277     return result;
278 }
279
280 /*****************************************************************************
281  * ModuleConfigControl implementation
282  *****************************************************************************/
283 ModuleConfigControl::ModuleConfigControl( vlc_object_t *p_this,
284                                           module_config_t *p_item,
285                                           wxWindow *parent )
286   : ConfigControl( p_this, p_item, parent )
287 {
288     vlc_list_t *p_list;
289     module_t *p_parser;
290
291     label = new wxStaticText(this, -1, wxU(p_item->psz_text));
292     combo = new wxComboBox( this, -1, wxU(p_item->psz_value),
293                             wxDefaultPosition, wxDefaultSize,
294                             0, NULL, wxCB_READONLY | wxCB_SORT );
295
296     /* build a list of available modules */
297     p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
298     combo->Append( wxU(_("Default")), (void *)NULL );
299     combo->SetSelection( 0 );
300     for( int i_index = 0; i_index < p_list->i_count; i_index++ )
301     {
302         p_parser = (module_t *)p_list->p_values[i_index].p_object ;
303
304         if( !strcmp( p_parser->psz_capability, p_item->psz_type ) )
305         {
306             combo->Append( wxU(p_parser->psz_longname),
307                            p_parser->psz_object_name );
308             if( p_item->psz_value && !strcmp(p_item->psz_value, 
309                                              p_parser->psz_object_name) )
310                 combo->SetValue( wxU(p_parser->psz_longname) );
311         }
312     }
313     vlc_list_release( p_list );
314
315     combo->SetToolTip( wxU(p_item->psz_longtext) );
316     sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
317     sizer->Add( combo, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
318     sizer->Layout();
319     this->SetSizerAndFit( sizer );
320 }
321
322 ModuleConfigControl::~ModuleConfigControl()
323 {
324     ;
325 }
326
327 wxString ModuleConfigControl::GetPszValue()
328 {
329     return wxU( (char *)combo->GetClientData( combo->GetSelection() ));
330 }
331
332 /*****************************************************************************
333  * StringConfigControl implementation
334  *****************************************************************************/
335 StringConfigControl::StringConfigControl( vlc_object_t *p_this,
336                                           module_config_t *p_item,
337                                           wxWindow *parent )
338   : ConfigControl( p_this, p_item, parent )
339 {
340     label = new wxStaticText(this, -1, wxU(p_item->psz_text));
341     sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
342     textctrl = new wxTextCtrl( this, -1, 
343                                wxU(p_item->psz_value),
344                                wxDefaultPosition,
345                                wxDefaultSize,
346                                wxTE_PROCESS_ENTER);
347     textctrl->SetToolTip( wxU(p_item->psz_longtext) );
348     sizer->Add( textctrl, 1, wxALL, 5 );
349     sizer->Layout();
350     this->SetSizerAndFit( sizer );
351 }
352
353 StringConfigControl::~StringConfigControl()
354 {
355     ;
356 }
357
358 wxString StringConfigControl::GetPszValue()
359 {
360     return textctrl->GetValue();
361 }
362
363 /*****************************************************************************
364  * StringListConfigControl implementation
365  *****************************************************************************/
366 StringListConfigControl::StringListConfigControl( vlc_object_t *p_this,
367                                                   module_config_t *p_item,
368                                                   wxWindow *parent )
369   : ConfigControl( p_this, p_item, parent ), psz_name( NULL )
370 {
371     label = new wxStaticText(this, -1, wxU(p_item->psz_text));
372     sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
373     combo = new wxComboBox( this, -1, wxT(""),
374                             wxDefaultPosition, wxDefaultSize,
375                             0, NULL, wxCB_READONLY );
376     UpdateCombo( p_item );
377
378     combo->SetToolTip( wxU(p_item->psz_longtext) );
379     sizer->Add( combo, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );    
380
381     if( p_item->pf_list_update )
382     {
383         wxButton *refresh =
384             new wxButton( this, wxID_HIGHEST, wxU(_("Refresh")) );
385         sizer->Add( refresh, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
386
387         psz_name = strdup( p_item->psz_name );
388         pf_list_update = p_item->pf_list_update;
389     }
390
391     sizer->Layout();
392     this->SetSizerAndFit( sizer );
393 }
394
395 StringListConfigControl::~StringListConfigControl()
396 {
397     if( psz_name ) free( psz_name );
398 }
399
400 void StringListConfigControl::UpdateCombo( module_config_t *p_item )
401 {
402     /* build a list of available options */
403     for( int i_index = 0; i_index < p_item->i_list; i_index++ )
404     {
405         combo->Append( ( p_item->ppsz_list_text &&
406                          p_item->ppsz_list_text[i_index] ) ?
407                        wxU(p_item->ppsz_list_text[i_index]) :
408                        wxU(p_item->ppsz_list[i_index]) );
409         combo->SetClientData( i_index, (void *)p_item->ppsz_list[i_index] );
410         if( ( p_item->psz_value &&
411               !strcmp( p_item->psz_value, p_item->ppsz_list[i_index] ) ) ||
412              ( !p_item->psz_value && !*p_item->ppsz_list[i_index] ) )
413         {
414             combo->SetSelection( i_index );
415             combo->SetValue( ( p_item->ppsz_list_text &&
416                                p_item->ppsz_list_text[i_index] ) ?
417                              wxU(p_item->ppsz_list_text[i_index]) :
418                              wxU(p_item->ppsz_list[i_index]) );
419         }
420     }
421 }
422
423 BEGIN_EVENT_TABLE(StringListConfigControl, wxPanel)
424     /* Button events */
425     EVT_BUTTON(wxID_HIGHEST+i_counter%100, StringListConfigControl::OnRefresh)
426 END_EVENT_TABLE()
427
428 void StringListConfigControl::OnRefresh( wxCommandEvent& event )
429 {
430     if( pf_list_update )
431     {
432         vlc_value_t val;
433         module_config_t *p_item;
434
435         pf_list_update( p_this, psz_name, val, val, 0 );
436         p_item = config_FindConfig( p_this, psz_name );
437
438         combo->Clear();
439         UpdateCombo( p_item );
440     }
441 }
442
443 wxString StringListConfigControl::GetPszValue()
444 {
445     int selected = combo->GetSelection();
446     if( selected != -1 )
447     {
448         return (char *)combo->GetClientData( selected );
449     }
450     return wxString();
451 }
452
453 /*****************************************************************************
454  * FileConfigControl implementation
455  *****************************************************************************/
456 FileConfigControl::FileConfigControl( vlc_object_t *p_this,
457                                       module_config_t *p_item,
458                                       wxWindow *parent )
459   : ConfigControl( p_this, p_item, parent )
460 {
461     directory = p_item->i_type == CONFIG_ITEM_DIRECTORY;
462     label = new wxStaticText(this, -1, wxU(p_item->psz_text));
463     sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
464     textctrl = new wxTextCtrl( this, -1, 
465                                wxU(p_item->psz_value),
466                                wxDefaultPosition,
467                                wxDefaultSize,
468                                wxTE_PROCESS_ENTER);
469     textctrl->SetToolTip( wxU(p_item->psz_longtext) );
470     sizer->Add( textctrl, 1, wxALL, 5 );
471     browse = new wxButton( this, wxID_HIGHEST, wxU(_("Browse...")) );
472     sizer->Add( browse, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
473     sizer->Layout();
474     this->SetSizerAndFit( sizer );
475 }
476
477 BEGIN_EVENT_TABLE(FileConfigControl, wxPanel)
478     /* Button events */
479     EVT_BUTTON(wxID_HIGHEST+i_counter%100, FileConfigControl::OnBrowse)
480 END_EVENT_TABLE()
481
482 void FileConfigControl::OnBrowse( wxCommandEvent& event )
483 {
484     if( directory )
485     {
486         wxDirDialog dialog( this, wxU(_("Choose Directory")) );
487
488         if( dialog.ShowModal() == wxID_OK )
489         {
490             textctrl->SetValue( dialog.GetPath() );      
491         }
492     }
493     else
494     {
495         wxFileDialog dialog( this, wxU(_("Choose File")),
496                              wxT(""), wxT(""), wxT("*.*"),
497 #if defined( __WXMSW__ )
498                              wxOPEN
499 #else
500                              wxOPEN | wxSAVE
501 #endif
502                            );
503     }
504 }
505
506 FileConfigControl::~FileConfigControl()
507 {
508     ;
509 }
510     
511 wxString FileConfigControl::GetPszValue()
512 {
513     return textctrl->GetValue();
514 }
515
516 /*****************************************************************************
517  * IntegerConfigControl implementation
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                            -16000, 16000, 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 }
537
538 IntegerConfigControl::~IntegerConfigControl()
539 {
540     ;
541 }
542
543 int IntegerConfigControl::GetIntValue()
544 {
545     return spin->GetValue();
546 }
547
548 /*****************************************************************************
549  * IntegerListConfigControl implementation
550  *****************************************************************************/
551 IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *p_this,
552                                                     module_config_t *p_item,
553                                                     wxWindow *parent )
554   : ConfigControl( p_this, p_item, parent )
555 {
556     label = new wxStaticText(this, -1, wxU(p_item->psz_text));
557     sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
558     combo = new wxComboBox( this, -1, wxT(""),
559                             wxDefaultPosition, wxDefaultSize,
560                             0, NULL, wxCB_READONLY );
561
562     UpdateCombo( p_item );
563
564     combo->SetToolTip( wxU(p_item->psz_longtext) );
565     sizer->Add( combo, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );    
566
567     if( p_item->pf_list_update )
568     {
569         wxButton *refresh =
570             new wxButton( this, wxID_HIGHEST, wxU(_("Refresh")) );
571         sizer->Add( refresh, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
572
573         psz_name = strdup( p_item->psz_name );
574         pf_list_update = p_item->pf_list_update;
575     }
576
577     sizer->Layout();
578     this->SetSizerAndFit( sizer );
579 }
580
581 IntegerListConfigControl::~IntegerListConfigControl()
582 {
583     if( psz_name ) free( psz_name );
584 }
585
586 void IntegerListConfigControl::UpdateCombo( module_config_t *p_item )
587 {
588     /* build a list of available options */
589     for( int i_index = 0; i_index < p_item->i_list; i_index++ )
590     {
591         combo->Append( ( p_item->ppsz_list_text &&
592                          p_item->ppsz_list_text[i_index] ) ?
593                        wxU(p_item->ppsz_list_text[i_index]) :
594                        wxString::Format(wxT("%i"),
595                                         p_item->pi_list[i_index]) );
596         combo->SetClientData( i_index, (void *)p_item->pi_list[i_index] );
597         if( p_item->i_value == p_item->pi_list[i_index] )
598         {
599             combo->SetSelection( i_index );
600             combo->SetValue( ( p_item->ppsz_list_text &&
601                                p_item->ppsz_list_text[i_index] ) ?
602                              wxU(p_item->ppsz_list_text[i_index]) :
603                              wxString::Format(wxT("%i"),
604                                               p_item->pi_list[i_index]) );
605         }
606     }
607 }
608
609 BEGIN_EVENT_TABLE(IntegerListConfigControl, wxPanel)
610     /* Button events */
611     EVT_BUTTON(wxID_HIGHEST+i_counter%100, IntegerListConfigControl::OnRefresh)
612 END_EVENT_TABLE()
613
614 void IntegerListConfigControl::OnRefresh( wxCommandEvent& event )
615 {
616     if( pf_list_update )
617     {
618         vlc_value_t val;
619         module_config_t *p_item;
620
621         pf_list_update( p_this, psz_name, val, val, 0 );
622         p_item = config_FindConfig( p_this, psz_name );
623
624         combo->Clear();
625         UpdateCombo( p_item );
626     }
627 }
628
629 int IntegerListConfigControl::GetIntValue()
630 {
631     int selected = combo->GetSelection();
632     if( selected != -1 )
633     {
634         return (int)combo->GetClientData( selected );
635     }
636     return -1;
637 }
638
639 /*****************************************************************************
640  * RangedIntConfigControl implementation
641  *****************************************************************************/
642 RangedIntConfigControl::RangedIntConfigControl( vlc_object_t *p_this,
643                                                 module_config_t *p_item,
644                                                 wxWindow *parent )
645   : ConfigControl( p_this, p_item, parent )
646 {
647     label = new wxStaticText(this, -1, wxU(p_item->psz_text));
648     slider = new wxSlider( this, -1, p_item->i_value, p_item->i_min,
649                            p_item->i_max, wxDefaultPosition, wxDefaultSize,
650                            wxSL_LABELS | wxSL_HORIZONTAL );
651     slider->SetToolTip( wxU(p_item->psz_longtext) );
652     sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
653     sizer->Add( slider, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );    
654     sizer->Layout();
655     this->SetSizerAndFit( sizer );
656 }
657
658 RangedIntConfigControl::~RangedIntConfigControl()
659 {
660     ;
661 }
662
663 int RangedIntConfigControl::GetIntValue()
664 {
665     return slider->GetValue();
666 }
667
668 /*****************************************************************************
669  * FloatConfigControl implementation
670  *****************************************************************************/
671 FloatConfigControl::FloatConfigControl( vlc_object_t *p_this,
672                                         module_config_t *p_item,
673                                         wxWindow *parent )
674   : ConfigControl( p_this, p_item, parent )
675 {
676     label = new wxStaticText(this, -1, wxU(p_item->psz_text));
677     textctrl = new wxTextCtrl( this, -1,
678                                wxString::Format(wxT("%f"),
679                                                 p_item->f_value),
680                                wxDefaultPosition, wxDefaultSize,
681                                wxTE_PROCESS_ENTER );
682     textctrl->SetToolTip( wxU(p_item->psz_longtext) );
683     sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
684     sizer->Add( textctrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
685     sizer->Layout();
686     this->SetSizerAndFit( sizer );
687 }
688
689 FloatConfigControl::~FloatConfigControl()
690 {
691     ;
692 }
693
694 float FloatConfigControl::GetFloatValue()
695 {
696     float f_value;
697     if( (wxSscanf(textctrl->GetValue(), wxT("%f"), &f_value) == 1) )
698         return f_value;
699     else return 0.0;
700 }
701
702 /*****************************************************************************
703  * BoolConfigControl implementation
704  *****************************************************************************/
705 BoolConfigControl::BoolConfigControl( vlc_object_t *p_this,
706                                       module_config_t *p_item,
707                                       wxWindow *parent )
708   : ConfigControl( p_this, p_item, parent )
709 {
710     checkbox = new wxCheckBox( this, -1, wxU(p_item->psz_text) );
711     if( p_item->i_value ) checkbox->SetValue(TRUE);
712     checkbox->SetToolTip( wxU(p_item->psz_longtext) );
713     sizer->Add( checkbox, 0, wxALL, 5 );
714     sizer->Layout();
715     this->SetSizerAndFit( sizer );
716 }
717
718 BoolConfigControl::~BoolConfigControl()
719 {
720     ;
721 }
722
723 int BoolConfigControl::GetIntValue()
724 {
725     if( checkbox->IsChecked() )
726     {
727         return 1;
728     }
729     else
730     {
731         return 0;
732     }
733 }