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