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