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