]> git.sesse.net Git - vlc/blob - modules/gui/wxwindows/preferences_widgets.cpp
* modules/gui/wxwindows/preferences_widgets.cpp: update events for IntegerConfigControl.
[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                            -10000000, 10000000, 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     sizer->Layout();
568     this->SetSizerAndFit( sizer );
569 }
570
571 IntegerListConfigControl::~IntegerListConfigControl()
572 {
573 }
574
575 void IntegerListConfigControl::UpdateCombo( module_config_t *p_item )
576 {
577     /* build a list of available options */
578     for( int i_index = 0; i_index < p_item->i_list; i_index++ )
579     {
580         if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
581         {
582             combo->Append( wxU(p_item->ppsz_list_text[i_index]) );
583         }
584         else
585         {
586             combo->Append( wxString::Format(wxT("%i"),
587                                             p_item->pi_list[i_index]) );
588         }
589         combo->SetClientData( i_index, (void *)p_item->pi_list[i_index] );
590         if( p_item->i_value == p_item->pi_list[i_index] )
591         {
592             combo->SetSelection( i_index );
593             if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
594             {
595                 combo->SetValue( wxU(p_item->ppsz_list_text[i_index]) );
596             }
597             else
598             {
599                 combo->SetValue( wxString::Format(wxT("%i"),
600                                                   p_item->pi_list[i_index]) );
601             }
602         }
603     }
604 }
605
606 BEGIN_EVENT_TABLE(IntegerListConfigControl, wxPanel)
607     /* Button events */
608     EVT_BUTTON(-1, IntegerListConfigControl::OnAction)
609 END_EVENT_TABLE()
610
611 void IntegerListConfigControl::OnAction( wxCommandEvent& event )
612 {
613     int i_action = event.GetId() - wxID_HIGHEST;
614
615     module_config_t *p_item;
616     p_item = config_FindConfig( p_this, GetName().mb_str() );
617     if( !p_item ) return;
618
619     if( i_action < 0 || i_action >= p_item->i_action ) return;
620
621     vlc_value_t val;
622     val.i_int = GetIntValue();
623     p_item->ppf_action[i_action]( p_this, GetName().mb_str(), val, val, 0 );
624
625     if( p_item->b_dirty )
626     {
627         combo->Clear();
628         UpdateCombo( p_item );
629         p_item->b_dirty = VLC_FALSE;
630     }
631 }
632
633 int IntegerListConfigControl::GetIntValue()
634 {
635     int selected = combo->GetSelection();
636     if( selected != -1 )
637     {
638         return (int)combo->GetClientData( selected );
639     }
640     return -1;
641 }
642
643 /*****************************************************************************
644  * RangedIntConfigControl implementation
645  *****************************************************************************/
646 BEGIN_EVENT_TABLE(RangedIntConfigControl, wxPanel)
647     EVT_COMMAND_SCROLL(-1, RangedIntConfigControl::OnUpdate)
648 END_EVENT_TABLE()
649
650 RangedIntConfigControl::RangedIntConfigControl( vlc_object_t *p_this,
651                                                 module_config_t *p_item,
652                                                 wxWindow *parent )
653   : ConfigControl( p_this, p_item, parent )
654 {
655     label = new wxStaticText(this, -1, wxU(p_item->psz_text));
656     slider = new wxSlider( this, -1, p_item->i_value, p_item->i_min,
657                            p_item->i_max, wxDefaultPosition, wxDefaultSize,
658                            wxSL_LABELS | wxSL_HORIZONTAL );
659     slider->SetToolTip( wxU(p_item->psz_longtext) );
660     sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
661     sizer->Add( slider, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
662     sizer->Layout();
663     this->SetSizerAndFit( sizer );
664 }
665
666 RangedIntConfigControl::~RangedIntConfigControl()
667 {
668     ;
669 }
670
671 int RangedIntConfigControl::GetIntValue()
672 {
673     return slider->GetValue();
674 }
675
676 /*****************************************************************************
677  * FloatConfigControl implementation
678  *****************************************************************************/
679 BEGIN_EVENT_TABLE(FloatConfigControl, wxPanel)
680     EVT_TEXT(-1, FloatConfigControl::OnUpdate)
681 END_EVENT_TABLE()
682
683 FloatConfigControl::FloatConfigControl( vlc_object_t *p_this,
684                                         module_config_t *p_item,
685                                         wxWindow *parent )
686   : ConfigControl( p_this, p_item, parent )
687 {
688     label = new wxStaticText(this, -1, wxU(p_item->psz_text));
689     textctrl = new wxTextCtrl( this, -1,
690                                wxString::Format(wxT("%f"),
691                                                 p_item->f_value),
692                                wxDefaultPosition, wxDefaultSize,
693                                wxTE_PROCESS_ENTER );
694     textctrl->SetToolTip( wxU(p_item->psz_longtext) );
695     sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
696     sizer->Add( textctrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
697     sizer->Layout();
698     this->SetSizerAndFit( sizer );
699 }
700
701 FloatConfigControl::~FloatConfigControl()
702 {
703     ;
704 }
705
706 float FloatConfigControl::GetFloatValue()
707 {
708     float f_value;
709     if( (wxSscanf(textctrl->GetValue(), wxT("%f"), &f_value) == 1) )
710         return f_value;
711     else return 0.0;
712 }
713
714 /*****************************************************************************
715  * BoolConfigControl implementation
716  *****************************************************************************/
717 BEGIN_EVENT_TABLE(BoolConfigControl, wxPanel)
718     EVT_CHECKBOX(-1, BoolConfigControl::OnUpdate)
719 END_EVENT_TABLE()
720
721 BoolConfigControl::BoolConfigControl( vlc_object_t *p_this,
722                                       module_config_t *p_item,
723                                       wxWindow *parent )
724   : ConfigControl( p_this, p_item, parent )
725 {
726     checkbox = new wxCheckBox( this, -1, wxU(p_item->psz_text) );
727     if( p_item->i_value ) checkbox->SetValue(TRUE);
728     checkbox->SetToolTip( wxU(p_item->psz_longtext) );
729     sizer->Add( checkbox, 0, wxALL, 5 );
730     sizer->Layout();
731     this->SetSizerAndFit( sizer );
732 }
733
734 BoolConfigControl::~BoolConfigControl()
735 {
736     ;
737 }
738
739 int BoolConfigControl::GetIntValue()
740 {
741     if( checkbox->IsChecked() ) return 1;
742     else return 0;
743 }