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