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