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