]> git.sesse.net Git - vlc/blob - modules/gui/wince/preferences_widgets.cpp
macosx: fixed menubar appearance in fullscreen mode by partially reverting [46c93c9cc...
[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     // 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_type & 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_type & 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_type & 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_type) & ~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     module_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 = module_list_get( NULL );
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
315     for( size_t i_index = 0; p_list[i_index]; i_index++ )
316     {
317         p_parser = p_list[i_index];
318
319         if( module_provides( p_parser, p_item->psz_type ) )
320         {
321             ComboBox_AddString( combo, _FROMMB(module_GetLongName( p_parser ) ));
322             ComboBox_SetItemData( combo, i_index,
323                                   (void *) module_get_object( p_parser ) );
324             if( p_item->value.psz && !strcmp( p_item->value.psz,
325                                              module_get_object( p_parser )) )
326             {
327                 ComboBox_SetCurSel( combo, i_index );
328                 //ComboBox_SetText( combo, _FROMMB( module_GetLongName(p_parser)) );
329             }
330         }
331     }
332     module_list_free( p_list );
333 }
334
335 ModuleConfigControl::~ModuleConfigControl()
336 {
337     ;
338 }
339
340 char *ModuleConfigControl::GetPszValue()
341 {
342     int selected = ComboBox_GetCurSel( combo );
343     if( selected != -1 )
344         return (char *)ComboBox_GetItemData( combo, selected );
345     else return NULL;
346 }
347
348 /*****************************************************************************
349  * StringConfigControl implementation
350  *****************************************************************************/
351 StringConfigControl::StringConfigControl( vlc_object_t *p_this,
352                                           module_config_t *p_item,
353                                           HWND parent, HINSTANCE hInst,
354                                           int * py_pos )
355   : ConfigControl( p_this, p_item, parent, hInst )
356 {
357     label = CreateWindow( _T("STATIC"), _FROMMB(p_item->psz_text),
358                           WS_CHILD | WS_VISIBLE | SS_LEFT,
359                           5, *py_pos, 200, 15,
360                           parent, NULL, hInst, NULL );
361
362     *py_pos += 15 + 10;
363
364     textctrl = CreateWindow( _T("EDIT"), p_item->psz_type ?
365                              _FROMMB(p_item->psz_type) : _T(""),
366                              WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT |
367                              ES_AUTOHSCROLL, 20, *py_pos - 3, 180, 15 + 3,
368                              parent, NULL, hInst, NULL );
369
370     *py_pos += 15 + 10;
371 }
372
373 StringConfigControl::~StringConfigControl()
374 {
375     ;
376 }
377
378 char *StringConfigControl::GetPszValue()
379 {
380     int i_size;
381     char *psz_result;
382     TCHAR *psz_string;
383
384     i_size = Edit_GetTextLength( textctrl );
385     psz_string = (TCHAR *)malloc( (i_size + 1) * sizeof(TCHAR) );
386     Edit_GetText( textctrl, psz_string, i_size + 1 );
387     psz_result = strdup( _TOMB(psz_string) );
388     free( psz_string );
389     return psz_result;
390 }
391
392 #if 0
393 /*****************************************************************************
394  * StringListConfigControl implementation
395  *****************************************************************************/
396 StringListConfigControl::StringListConfigControl( vlc_object_t *p_this,
397                                                   module_config_t *p_item,
398                                                   HWND parent, HINSTANCE hInst,
399                                                   int * py_pos )
400   : ConfigControl( p_this, p_item, parent, hInst )
401 {
402     label = new wxStaticText(this, -1, wxU(p_item->psz_text));
403     sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
404     combo = new wxComboBox( this, -1, wxT(""),
405                             wxDefaultPosition, wxDefaultSize,
406                             0, NULL, wxCB_READONLY );
407     UpdateCombo( p_item );
408
409     combo->SetToolTip( wxU(p_item->psz_longtext) );
410     sizer->Add( combo, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
411
412     for( int i = 0; i < p_item->i_action; i++ )
413     {
414         wxButton *button =
415             new wxButton( this, wxID_HIGHEST+i,
416                           wxU(p_item->ppsz_action_text[i]) );
417         sizer->Add( button, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
418     }
419
420     sizer->Layout();
421     this->SetSizerAndFit( sizer );
422 }
423
424 StringListConfigControl::~StringListConfigControl()
425 {
426 }
427
428 void StringListConfigControl::UpdateCombo( module_config_t *p_item )
429 {
430     /* build a list of available options */
431     for( int i_index = 0; i_index < p_item->i_list; i_index++ )
432     {
433         combo->Append( ( p_item->ppsz_list_text &&
434                          p_item->ppsz_list_text[i_index] ) ?
435                        wxU(p_item->ppsz_list_text[i_index]) :
436                        wxL2U(p_item->ppsz_list[i_index]) );
437         combo->SetClientData( i_index, (void *)p_item->ppsz_list[i_index] );
438         if( ( p_item->psz_value &&
439               !strcmp( p_item->psz_value, p_item->ppsz_list[i_index] ) ) ||
440              ( !p_item->psz_value && !*p_item->ppsz_list[i_index] ) )
441         {
442             combo->SetSelection( i_index );
443             combo->SetValue( ( p_item->ppsz_list_text &&
444                                p_item->ppsz_list_text[i_index] ) ?
445                              wxU(p_item->ppsz_list_text[i_index]) :
446                              wxL2U(p_item->ppsz_list[i_index]) );
447         }
448     }
449 }
450
451 BEGIN_EVENT_TABLE(StringListConfigControl, wxPanel)
452     /* Button events */
453     EVT_BUTTON(-1, StringListConfigControl::OnAction)
454
455     /* Text events */
456     EVT__T(-1, StringListConfigControl::OnUpdate)
457 END_EVENT_TABLE()
458
459 void StringListConfigControl::OnAction( wxCommandEvent& event )
460 {
461     int i_action = event.GetId() - wxID_HIGHEST;
462
463     module_config_t *p_item = config_FindConfig( p_this, GetName().mb_str() );
464     if( !p_item ) return;
465
466     if( i_action < 0 || i_action >= p_item->i_action ) return;
467
468     vlc_value_t val;
469     wxString value = GetPszValue();
470     (const char *)val.psz_string = value.mb_str();
471     p_item->ppf_action[i_action]( p_this, GetName().mb_str(), val, val, 0 );
472
473     if( p_item->b_dirty )
474     {
475         combo->Clear();
476         UpdateCombo( p_item );
477         p_item->b_dirty = false;
478     }
479 }
480
481 wxString StringListConfigControl::GetPszValue()
482 {
483     int selected = combo->GetSelection();
484     if( selected != -1 )
485     {
486         return wxL2U((char *)combo->GetClientData( selected ));
487     }
488     return wxString();
489 }
490
491 /*****************************************************************************
492  * FileConfigControl implementation
493  *****************************************************************************/
494 FileConfigControl::FileConfigControl( vlc_object_t *p_this,
495                                       module_config_t *p_item,
496                                       HWND parent, HINSTANCE hInst,
497                                       int * py_pos )
498   : ConfigControl( p_this, p_item, parent, hInst )
499 {
500     directory = p_item->i_type == CONFIG_ITEM_DIRECTORY;
501     label = new wxStaticText(this, -1, wxU(p_item->psz_text));
502     sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
503     textctrl = new wxTextCtrl( this, -1,
504                                wxL2U(p_item->psz_value),
505                                wxDefaultPosition,
506                                wxDefaultSize,
507                                wxTE_PROCESS_ENTER);
508     textctrl->SetToolTip( wxU(p_item->psz_longtext) );
509     sizer->Add( textctrl, 1, wxALL, 5 );
510     browse = new wxButton( this, wxID_HIGHEST, wxU(_("Browse...")) );
511     sizer->Add( browse, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
512     sizer->Layout();
513     this->SetSizerAndFit( sizer );
514 }
515
516 BEGIN_EVENT_TABLE(FileConfigControl, wxPanel)
517     /* Button events */
518     EVT_BUTTON(wxID_HIGHEST, FileConfigControl::OnBrowse)
519 END_EVENT_TABLE()
520
521 void FileConfigControl::OnBrowse( wxCommandEvent& event )
522 {
523     if( directory )
524     {
525         wxDirDialog dialog( this, wxU(_("Choose directory")) );
526
527         if( dialog.ShowModal() == wxID_OK )
528         {
529             textctrl->SetValue( dialog.GetPath() );
530         }
531     }
532     else
533     {
534         wxFileDialog dialog( this, wxU(_("Choose file")),
535                              wxT(""), wxT(""), wxT("*.*"),
536 #if defined( __WXMSW__ )
537                              wxOPEN
538 #else
539                              wxOPEN | wxSAVE
540 #endif
541                            );
542         if( dialog.ShowModal() == wxID_OK )
543         {
544             textctrl->SetValue( dialog.GetPath() );
545         }
546     }
547 }
548
549 FileConfigControl::~FileConfigControl()
550 {
551     ;
552 }
553
554 wxString FileConfigControl::GetPszValue()
555 {
556     return textctrl->GetValue();
557 }
558
559 /*****************************************************************************
560  * IntegerConfigControl implementation
561  *****************************************************************************/
562 IntegerConfigControl::IntegerConfigControl( vlc_object_t *p_this,
563                                             module_config_t *p_item,
564                                             HWND parent, HINSTANCE hInst,
565                                             int * py_pos )
566   : ConfigControl( p_this, p_item, parent, hInst )
567 {
568     label = new wxStaticText(this, -1, wxU(p_item->psz_text));
569     spin = new wxSpinCtrl( this, -1,
570                            wxString::Format(wxT("%d"),
571                                             p_item->i_value),
572                            wxDefaultPosition, wxDefaultSize,
573                            wxSP_ARROW_KEYS,
574                            -10000000, 10000000, p_item->i_value);
575     spin->SetToolTip( wxU(p_item->psz_longtext) );
576     sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
577     sizer->Add( spin, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
578     sizer->Layout();
579     this->SetSizerAndFit( sizer );
580 }
581
582 IntegerConfigControl::~IntegerConfigControl()
583 {
584     ;
585 }
586
587 int IntegerConfigControl::GetIntValue()
588 {
589     return spin->GetValue();
590 }
591
592 /*****************************************************************************
593  * IntegerListConfigControl implementation
594  *****************************************************************************/
595 IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *p_this,
596                                                     module_config_t *p_item,
597                                                     HWND parent,
598                                                     HINSTANCE hInst,
599                                                     int * py_pos )
600   : ConfigControl( p_this, p_item, parent, hInst )
601 {
602     label = new wxStaticText(this, -1, wxU(p_item->psz_text));
603     sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
604     combo = new wxComboBox( this, -1, wxT(""),
605                             wxDefaultPosition, wxDefaultSize,
606                             0, NULL, wxCB_READONLY );
607
608     UpdateCombo( p_item );
609
610     combo->SetToolTip( wxU(p_item->psz_longtext) );
611     sizer->Add( combo, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
612
613     sizer->Layout();
614     this->SetSizerAndFit( sizer );
615 }
616
617 IntegerListConfigControl::~IntegerListConfigControl()
618 {
619 }
620
621 void IntegerListConfigControl::UpdateCombo( module_config_t *p_item )
622 {
623     /* build a list of available options */
624     for( int i_index = 0; i_index < p_item->i_list; i_index++ )
625     {
626         if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
627         {
628             combo->Append( wxU(p_item->ppsz_list_text[i_index]) );
629         }
630         else
631         {
632             combo->Append( wxString::Format(wxT("%i"),
633                                             p_item->pi_list[i_index]) );
634         }
635         combo->SetClientData( i_index, (void *)p_item->pi_list[i_index] );
636         if( p_item->i_value == p_item->pi_list[i_index] )
637         {
638             combo->SetSelection( i_index );
639             if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
640             {
641                 combo->SetValue( wxU(p_item->ppsz_list_text[i_index]) );
642             }
643             else
644             {
645                 combo->SetValue( wxString::Format(wxT("%i"),
646                                                   p_item->pi_list[i_index]) );
647             }
648         }
649     }
650 }
651
652 BEGIN_EVENT_TABLE(IntegerListConfigControl, wxPanel)
653     /* Button events */
654     EVT_BUTTON(-1, IntegerListConfigControl::OnAction)
655 END_EVENT_TABLE()
656
657 void IntegerListConfigControl::OnAction( wxCommandEvent& event )
658 {
659     int i_action = event.GetId() - wxID_HIGHEST;
660
661     module_config_t *p_item;
662     p_item = config_FindConfig( p_this, GetName().mb_str() );
663     if( !p_item ) return;
664
665     if( i_action < 0 || i_action >= p_item->i_action ) return;
666
667     vlc_value_t val;
668     val.i_int = GetIntValue();
669     p_item->ppf_action[i_action]( p_this, GetName().mb_str(), val, val, 0 );
670
671     if( p_item->b_dirty )
672     {
673         combo->Clear();
674         UpdateCombo( p_item );
675         p_item->b_dirty = false;
676     }
677 }
678
679 int IntegerListConfigControl::GetIntValue()
680 {
681     int selected = combo->GetSelection();
682     if( selected != -1 )
683     {
684         return (int)combo->GetClientData( selected );
685     }
686     return -1;
687 }
688
689 /*****************************************************************************
690  * RangedIntConfigControl implementation
691  *****************************************************************************/
692 RangedIntConfigControl::RangedIntConfigControl( vlc_object_t *p_this,
693                                                 module_config_t *p_item,
694                                                 HWND parent, HINSTANCE hInst,
695                                                 int * py_pos )
696   : ConfigControl( p_this, p_item, parent, hInst )
697 {
698     label = new wxStaticText(this, -1, wxU(p_item->psz_text));
699     slider = new wxSlider( this, -1, p_item->i_value, p_item->i_min,
700                            p_item->i_max, wxDefaultPosition, wxDefaultSize,
701                            wxSL_LABELS | wxSL_HORIZONTAL );
702     slider->SetToolTip( wxU(p_item->psz_longtext) );
703     sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
704     sizer->Add( slider, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
705     sizer->Layout();
706     this->SetSizerAndFit( sizer );
707 }
708
709 RangedIntConfigControl::~RangedIntConfigControl()
710 {
711     ;
712 }
713
714 int RangedIntConfigControl::GetIntValue()
715 {
716     return slider->GetValue();
717 }
718
719 #endif
720 /*****************************************************************************
721  * FloatConfigControl implementation
722  *****************************************************************************/
723 FloatConfigControl::FloatConfigControl( vlc_object_t *p_this,
724                                         module_config_t *p_item,
725                                         HWND parent, HINSTANCE hInst,
726                                         int *py_pos )
727   : ConfigControl( p_this, p_item, parent, hInst )
728 {
729     label = CreateWindow( _T("STATIC"), _FROMMB(p_item->psz_text),
730                           WS_CHILD | WS_VISIBLE | SS_LEFT,
731                           5, *py_pos, 200, 15,
732                           parent, NULL, hInst, NULL );
733
734     *py_pos += 15 + 10;
735
736     TCHAR psz_string[100];
737     _stprintf( psz_string, _T("%d"), p_item->i_type );
738     textctrl = CreateWindow( _T("EDIT"), psz_string,
739         WS_CHILD | WS_VISIBLE | WS_BORDER | SS_RIGHT | ES_AUTOHSCROLL,
740         20, *py_pos - 3, 70, 15 + 3, parent, NULL, hInst, NULL );
741
742     *py_pos += 15 + 10;
743 }
744
745 FloatConfigControl::~FloatConfigControl()
746 {
747     ;
748 }
749
750 float FloatConfigControl::GetFloatValue()
751 {
752     float f_value;
753
754     int i_size = Edit_GetTextLength( textctrl );
755     TCHAR *psz_string = (TCHAR *)malloc( (i_size + 1) * sizeof(TCHAR) );
756     Edit_GetText( textctrl, psz_string, i_size + 1 );
757
758     if( _tscanf( psz_string, _T("%f"), &f_value ) == 1 )
759     {
760         free( psz_string );
761         return f_value;
762     }
763
764     free( psz_string );
765     return 0.0;
766 }
767
768 /*****************************************************************************
769  * BoolConfigControl implementation
770  *****************************************************************************/
771 BoolConfigControl::BoolConfigControl( vlc_object_t *p_this,
772                                       module_config_t *p_item, HWND parent,
773                                       HINSTANCE hInst, int * py_pos )
774   : ConfigControl( p_this, p_item, parent, hInst )
775 {
776     checkbox = CreateWindow( _T("BUTTON"), _T(""),
777                              WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
778                              5, *py_pos, 15, 15,
779                              parent, NULL, hInst, NULL );
780     Button_SetCheck( checkbox, config_GetInt(p_this, p_item->psz_name) ? BST_CHECKED : BST_UNCHECKED );
781
782     checkbox_label = CreateWindow( _T("STATIC"), _FROMMB(p_item->psz_text),
783                                    WS_CHILD | WS_VISIBLE | SS_LEFT,
784                                    5 + 15 + 5, *py_pos, 180, 15,
785                                    parent, NULL, hInst, NULL );
786
787     *py_pos += 15 + 10;
788 }
789
790 BoolConfigControl::~BoolConfigControl()
791 {
792     ;
793 }
794
795 int BoolConfigControl::GetIntValue()
796 {
797     if( Button_GetCheck( checkbox ) ) return 1;
798     else return 0;
799 }