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