Commit 3173b30a authored by Gildas Bazin's avatar Gildas Bazin

* modules/gui/wxwindows/preferences*: added GetName(), GetType() and...

* modules/gui/wxwindows/preferences*: added GetName(), GetType() and IsAdvanced() to ConfigControl and got rid of ConfigData for even more simplifications.
parent de1be1c1
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* preferences.cpp : wxWindows plugin for vlc * preferences.cpp : wxWindows plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2001 VideoLAN * Copyright (C) 2000-2001 VideoLAN
* $Id: preferences.cpp,v 1.37 2003/10/20 00:09:27 gbazin Exp $ * $Id: preferences.cpp,v 1.38 2003/10/20 12:25:22 gbazin Exp $
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -89,22 +89,7 @@ private: ...@@ -89,22 +89,7 @@ private:
wxTreeItemId plugins_item; wxTreeItemId plugins_item;
}; };
struct ConfigData WX_DEFINE_ARRAY(ConfigControl *, ArrayOfConfigControls);
{
ConfigData( int _i_conf_type, vlc_bool_t _b_advanced, char *psz_name )
{ control = NULL; b_advanced = _b_advanced; b_config_list = VLC_FALSE;
i_config_type = _i_conf_type; option_name = wxU(psz_name); }
vlc_bool_t b_advanced;
int i_config_type;
vlc_bool_t b_config_list;
ConfigControl *control;
wxString option_name;
};
WX_DEFINE_ARRAY(ConfigData *, ArrayOfConfigData);
class PrefsPanel : public wxPanel class PrefsPanel : public wxPanel
{ {
...@@ -127,7 +112,7 @@ private: ...@@ -127,7 +112,7 @@ private:
wxBoxSizer *config_sizer; wxBoxSizer *config_sizer;
wxScrolledWindow *config_window; wxScrolledWindow *config_window;
ArrayOfConfigData config_array; ArrayOfConfigControls config_array;
}; };
class ConfigTreeData : public wxTreeItemData class ConfigTreeData : public wxTreeItemData
...@@ -832,65 +817,17 @@ PrefsPanel::PrefsPanel( wxWindow* parent, intf_thread_t *_p_intf, ...@@ -832,65 +817,17 @@ PrefsPanel::PrefsPanel( wxWindow* parent, intf_thread_t *_p_intf,
strcmp( psz_section, p_item->psz_text ) ) strcmp( psz_section, p_item->psz_text ) )
break; break;
ConfigData *config_data = ConfigControl *control =
new ConfigData( p_item->i_type, p_item->b_advanced, CreateConfigControl( VLC_OBJECT(p_intf),
p_item->psz_name ); p_item, config_window );
switch( p_item->i_type )
{
case CONFIG_ITEM_MODULE:
config_data->control = new ModuleConfigControl( p_intf, p_item, config_window );
break;
case CONFIG_ITEM_STRING:
if( !p_item->ppsz_list )
{
config_data->control = new StringConfigControl( p_item, config_window );
}
else
{
config_data->control = new StringListConfigControl( p_item, config_window );
}
break;
case CONFIG_ITEM_FILE:
case CONFIG_ITEM_DIRECTORY:
config_data->control = new FileConfigControl( p_item, config_window );
break;
case CONFIG_ITEM_INTEGER:
if( p_item->i_min != 0 || p_item->i_max != 0 )
{
config_data->control = new RangedIntConfigControl( p_item, config_window );
}
else
{
config_data->control = new IntegerConfigControl( p_item, config_window );
}
break;
case CONFIG_ITEM_KEY:
config_data->control = new KeyConfigControl( p_item, config_window );
break;
case CONFIG_ITEM_FLOAT:
config_data->control = new FloatConfigControl( p_item, config_window );
break;
case CONFIG_ITEM_BOOL:
config_data->control = new BoolConfigControl( p_item, config_window );
break;
default:
break;
}
/* Don't add items that were not recognized */ /* Don't add items that were not recognized */
if( config_data->control == NULL ) continue; if( control == NULL ) continue;
/* Add the config data to our array so we can keep a trace of it */ /* Add the config data to our array so we can keep a trace of it */
config_array.Add( config_data ); config_array.Add( control );
config_sizer->Add( config_data->control, 0, wxEXPAND | wxALL, 2 ); config_sizer->Add( control, 0, wxEXPAND | wxALL, 2 );
} }
while( p_item->i_type != CONFIG_HINT_END && p_item++ ); while( p_item->i_type != CONFIG_HINT_END && p_item++ );
...@@ -919,26 +856,26 @@ void PrefsPanel::ApplyChanges() ...@@ -919,26 +856,26 @@ void PrefsPanel::ApplyChanges()
{ {
for( size_t i = 0; i < config_array.GetCount(); i++ ) for( size_t i = 0; i < config_array.GetCount(); i++ )
{ {
ConfigData *config_data = config_array.Item(i); ConfigControl *control = config_array.Item(i);
switch( config_data->i_config_type ) switch( control->GetType() )
{ {
case CONFIG_ITEM_STRING: case CONFIG_ITEM_STRING:
case CONFIG_ITEM_FILE: case CONFIG_ITEM_FILE:
case CONFIG_ITEM_DIRECTORY: case CONFIG_ITEM_DIRECTORY:
case CONFIG_ITEM_MODULE: case CONFIG_ITEM_MODULE:
config_PutPsz( p_intf, config_data->option_name.mb_str(), config_PutPsz( p_intf, control->GetName().mb_str(),
config_data->control->GetPszValue().mb_str() ); control->GetPszValue().mb_str() );
break; break;
case CONFIG_ITEM_INTEGER: case CONFIG_ITEM_INTEGER:
case CONFIG_ITEM_KEY: case CONFIG_ITEM_KEY:
case CONFIG_ITEM_BOOL: case CONFIG_ITEM_BOOL:
config_PutInt( p_intf, config_data->option_name.mb_str(), config_PutInt( p_intf, control->GetName().mb_str(),
config_data->control->GetIntValue() ); control->GetIntValue() );
break; break;
case CONFIG_ITEM_FLOAT: case CONFIG_ITEM_FLOAT:
config_PutFloat( p_intf, config_data->option_name.mb_str(), config_PutFloat( p_intf, control->GetName().mb_str(),
config_data->control->GetFloatValue() ); control->GetFloatValue() );
break; break;
} }
} }
...@@ -954,11 +891,11 @@ void PrefsPanel::SwitchAdvanced( vlc_bool_t b_new_advanced ) ...@@ -954,11 +891,11 @@ void PrefsPanel::SwitchAdvanced( vlc_bool_t b_new_advanced )
for( size_t i = 0; i < config_array.GetCount(); i++ ) for( size_t i = 0; i < config_array.GetCount(); i++ )
{ {
ConfigData *config_data = config_array.Item(i); ConfigControl *control = config_array.Item(i);
if( config_data->b_advanced ) if( control->IsAdvanced() )
{ {
config_data->control->Show( b_advanced ); control->Show( b_advanced );
config_sizer->Show( config_data->control, b_advanced ); config_sizer->Show( control, b_advanced );
} }
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* preferences_widgets.cpp : wxWindows plugin for vlc * preferences_widgets.cpp : wxWindows plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2001 VideoLAN * Copyright (C) 2000-2001 VideoLAN
* $Id: preferences_widgets.cpp,v 1.3 2003/10/20 00:09:27 gbazin Exp $ * $Id: preferences_widgets.cpp,v 1.4 2003/10/20 12:25:22 gbazin Exp $
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* Sigmund Augdal <sigmunau@idi.ntnu.no> * Sigmund Augdal <sigmunau@idi.ntnu.no>
...@@ -38,20 +38,78 @@ ...@@ -38,20 +38,78 @@
#include "wxwindows.h" #include "wxwindows.h"
#include "preferences_widgets.h" #include "preferences_widgets.h"
/*****************************************************************************
* CreateConfigControl wrapper
*****************************************************************************/
ConfigControl *CreateConfigControl( vlc_object_t *p_this,
module_config_t *p_item, wxWindow *parent )
{
ConfigControl *p_control = NULL;
switch( p_item->i_type )
{
case CONFIG_ITEM_MODULE:
p_control = new ModuleConfigControl( p_this, p_item, parent );
break;
case CONFIG_ITEM_STRING:
if( !p_item->ppsz_list )
{
p_control = new StringConfigControl( p_item, parent );
}
else
{
p_control = new StringListConfigControl( p_item, parent );
}
break;
case CONFIG_ITEM_FILE:
case CONFIG_ITEM_DIRECTORY:
p_control = new FileConfigControl( p_item, parent );
break;
case CONFIG_ITEM_INTEGER:
if( p_item->i_min != 0 || p_item->i_max != 0 )
{
p_control = new RangedIntConfigControl( p_item, parent );
}
else
{
p_control = new IntegerConfigControl( p_item, parent );
}
break;
case CONFIG_ITEM_KEY:
p_control = new KeyConfigControl( p_item, parent );
break;
case CONFIG_ITEM_FLOAT:
p_control = new FloatConfigControl( p_item, parent );
break;
case CONFIG_ITEM_BOOL:
p_control = new BoolConfigControl( p_item, parent );
break;
default:
break;
}
return p_control;
}
/***************************************************************************** /*****************************************************************************
* ConfigControl implementation * ConfigControl implementation
*****************************************************************************/ *****************************************************************************/
ConfigControl::ConfigControl( wxWindow *parent ): wxPanel( parent ) ConfigControl::ConfigControl( module_config_t *p_item, wxWindow *parent )
: wxPanel( parent ), name( wxU(p_item->psz_name) ),
i_type( p_item->i_type ), b_advanced( p_item->b_advanced )
{ {
sizer = new wxBoxSizer( wxHORIZONTAL ); sizer = new wxBoxSizer( wxHORIZONTAL );
i_value = 0;
f_value = 0;
psz_value = NULL;
} }
ConfigControl::~ConfigControl() ConfigControl::~ConfigControl()
{ {
if( psz_value ) free( psz_value );
} }
wxSizer *ConfigControl::Sizer() wxSizer *ConfigControl::Sizer()
...@@ -59,26 +117,26 @@ wxSizer *ConfigControl::Sizer() ...@@ -59,26 +117,26 @@ wxSizer *ConfigControl::Sizer()
return sizer; return sizer;
} }
int ConfigControl::GetIntValue() wxString ConfigControl::GetName()
{ {
return i_value; return name;
} }
float ConfigControl::GetFloatValue() int ConfigControl::GetType()
{ {
return f_value; return i_type;
} }
wxString ConfigControl::GetPszValue() vlc_bool_t ConfigControl::IsAdvanced()
{ {
return wxString(psz_value ? wxU(psz_value) : wxT("")); return b_advanced;
} }
/***************************************************************************** /*****************************************************************************
* KeyConfigControl implementation * KeyConfigControl implementation
*****************************************************************************/ *****************************************************************************/
KeyConfigControl::KeyConfigControl( module_config_t *p_item, wxWindow *parent ) KeyConfigControl::KeyConfigControl( module_config_t *p_item, wxWindow *parent )
: ConfigControl( parent ) : ConfigControl( p_item, parent )
{ {
label = new wxStaticText(this, -1, wxU(p_item->psz_text)); label = new wxStaticText(this, -1, wxU(p_item->psz_text));
alt = new wxCheckBox( this, -1, wxU(_("Alt")) ); alt = new wxCheckBox( this, -1, wxU(_("Alt")) );
...@@ -140,10 +198,10 @@ int KeyConfigControl::GetIntValue() ...@@ -140,10 +198,10 @@ int KeyConfigControl::GetIntValue()
/***************************************************************************** /*****************************************************************************
* ModuleConfigControl implementation * ModuleConfigControl implementation
*****************************************************************************/ *****************************************************************************/
ModuleConfigControl::ModuleConfigControl( intf_thread_t *p_intf, ModuleConfigControl::ModuleConfigControl( vlc_object_t *p_this,
module_config_t *p_item, module_config_t *p_item,
wxWindow *parent ) wxWindow *parent )
: ConfigControl( parent ) : ConfigControl( p_item, parent )
{ {
vlc_list_t *p_list; vlc_list_t *p_list;
module_t *p_parser; module_t *p_parser;
...@@ -154,7 +212,7 @@ ModuleConfigControl::ModuleConfigControl( intf_thread_t *p_intf, ...@@ -154,7 +212,7 @@ ModuleConfigControl::ModuleConfigControl( intf_thread_t *p_intf,
0, NULL, wxCB_READONLY | wxCB_SORT ); 0, NULL, wxCB_READONLY | wxCB_SORT );
/* build a list of available modules */ /* build a list of available modules */
p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE ); p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
combo->Append( wxU(_("Default")), (void *)NULL ); combo->Append( wxU(_("Default")), (void *)NULL );
combo->SetSelection( 0 ); combo->SetSelection( 0 );
for( int i_index = 0; i_index < p_list->i_count; i_index++ ) for( int i_index = 0; i_index < p_list->i_count; i_index++ )
...@@ -194,7 +252,7 @@ wxString ModuleConfigControl::GetPszValue() ...@@ -194,7 +252,7 @@ wxString ModuleConfigControl::GetPszValue()
*****************************************************************************/ *****************************************************************************/
StringConfigControl::StringConfigControl( module_config_t *p_item, StringConfigControl::StringConfigControl( module_config_t *p_item,
wxWindow *parent ) wxWindow *parent )
: ConfigControl( parent ) : ConfigControl( p_item, parent )
{ {
label = new wxStaticText(this, -1, wxU(p_item->psz_text)); label = new wxStaticText(this, -1, wxU(p_item->psz_text));
sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
...@@ -224,7 +282,7 @@ wxString StringConfigControl::GetPszValue() ...@@ -224,7 +282,7 @@ wxString StringConfigControl::GetPszValue()
*****************************************************************************/ *****************************************************************************/
StringListConfigControl::StringListConfigControl( module_config_t *p_item, StringListConfigControl::StringListConfigControl( module_config_t *p_item,
wxWindow *parent ) wxWindow *parent )
: ConfigControl( parent ) : ConfigControl( p_item, parent )
{ {
label = new wxStaticText(this, -1, wxU(p_item->psz_text)); label = new wxStaticText(this, -1, wxU(p_item->psz_text));
sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
...@@ -265,7 +323,7 @@ wxString StringListConfigControl::GetPszValue() ...@@ -265,7 +323,7 @@ wxString StringListConfigControl::GetPszValue()
*****************************************************************************/ *****************************************************************************/
FileConfigControl::FileConfigControl( module_config_t *p_item, FileConfigControl::FileConfigControl( module_config_t *p_item,
wxWindow *parent ) wxWindow *parent )
: ConfigControl( parent ) : ConfigControl( p_item, parent )
{ {
directory = p_item->i_type == CONFIG_ITEM_DIRECTORY; directory = p_item->i_type == CONFIG_ITEM_DIRECTORY;
label = new wxStaticText(this, -1, wxU(p_item->psz_text)); label = new wxStaticText(this, -1, wxU(p_item->psz_text));
...@@ -327,7 +385,7 @@ wxString FileConfigControl::GetPszValue() ...@@ -327,7 +385,7 @@ wxString FileConfigControl::GetPszValue()
*****************************************************************************/ *****************************************************************************/
IntegerConfigControl::IntegerConfigControl( module_config_t *p_item, IntegerConfigControl::IntegerConfigControl( module_config_t *p_item,
wxWindow *parent ) wxWindow *parent )
: ConfigControl( parent ) : ConfigControl( p_item, parent )
{ {
label = new wxStaticText(this, -1, wxU(p_item->psz_text)); label = new wxStaticText(this, -1, wxU(p_item->psz_text));
spin = new wxSpinCtrl( this, -1, spin = new wxSpinCtrl( this, -1,
...@@ -358,7 +416,7 @@ int IntegerConfigControl::GetIntValue() ...@@ -358,7 +416,7 @@ int IntegerConfigControl::GetIntValue()
*****************************************************************************/ *****************************************************************************/
RangedIntConfigControl::RangedIntConfigControl( module_config_t *p_item, RangedIntConfigControl::RangedIntConfigControl( module_config_t *p_item,
wxWindow *parent ) wxWindow *parent )
: ConfigControl( parent ) : ConfigControl( p_item, parent )
{ {
label = new wxStaticText(this, -1, wxU(p_item->psz_text)); label = new wxStaticText(this, -1, wxU(p_item->psz_text));
slider = new wxSlider( this, -1, p_item->i_value, p_item->i_min, slider = new wxSlider( this, -1, p_item->i_value, p_item->i_min,
...@@ -385,7 +443,7 @@ int RangedIntConfigControl::GetIntValue() ...@@ -385,7 +443,7 @@ int RangedIntConfigControl::GetIntValue()
*****************************************************************************/ *****************************************************************************/
FloatConfigControl::FloatConfigControl( module_config_t *p_item, FloatConfigControl::FloatConfigControl( module_config_t *p_item,
wxWindow *parent ) wxWindow *parent )
: ConfigControl( parent ) : ConfigControl( p_item, parent )
{ {
label = new wxStaticText(this, -1, wxU(p_item->psz_text)); label = new wxStaticText(this, -1, wxU(p_item->psz_text));
textctrl = new wxTextCtrl( this, -1, textctrl = new wxTextCtrl( this, -1,
...@@ -418,7 +476,7 @@ float FloatConfigControl::GetFloatValue() ...@@ -418,7 +476,7 @@ float FloatConfigControl::GetFloatValue()
*****************************************************************************/ *****************************************************************************/
BoolConfigControl::BoolConfigControl( module_config_t *p_item, BoolConfigControl::BoolConfigControl( module_config_t *p_item,
wxWindow *parent ) wxWindow *parent )
: ConfigControl( parent ) : ConfigControl( p_item, parent )
{ {
checkbox = new wxCheckBox( this, -1, wxU(p_item->psz_text) ); checkbox = new wxCheckBox( this, -1, wxU(p_item->psz_text) );
if( p_item->i_value ) checkbox->SetValue(TRUE); if( p_item->i_value ) checkbox->SetValue(TRUE);
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* preferences_widgets.h : wxWindows plugin for vlc * preferences_widgets.h : wxWindows plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2003 VideoLAN * Copyright (C) 2000-2003 VideoLAN
* $Id: preferences_widgets.h,v 1.2 2003/10/20 00:09:27 gbazin Exp $ * $Id: preferences_widgets.h,v 1.3 2003/10/20 12:25:22 gbazin Exp $
* *
* Authors: Sigmund Augdal <sigmunau@idi.ntnu.no> * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
* *
...@@ -24,21 +24,31 @@ ...@@ -24,21 +24,31 @@
class ConfigControl: public wxPanel class ConfigControl: public wxPanel
{ {
public: public:
ConfigControl( wxWindow *parent ); ConfigControl( module_config_t *, wxWindow *parent );
~ConfigControl(); ~ConfigControl();
wxSizer *Sizer(); wxSizer *Sizer();
virtual int GetIntValue();
virtual float GetFloatValue(); virtual int GetIntValue() {return 0;}
virtual wxString GetPszValue(); virtual float GetFloatValue() {return 0;}
virtual wxString GetPszValue() {return wxString();}
wxString GetName();
int GetType();
vlc_bool_t IsAdvanced();
protected: protected:
wxBoxSizer *sizer; wxBoxSizer *sizer;
wxStaticText *label; wxStaticText *label;
private: private:
int i_value; wxString name;
float f_value; int i_type;
char *psz_value; vlc_bool_t b_advanced;
}; };
ConfigControl *CreateConfigControl( vlc_object_t *,
module_config_t *, wxWindow * );
class KeyConfigControl: public ConfigControl class KeyConfigControl: public ConfigControl
{ {
public: public:
...@@ -55,7 +65,7 @@ private: ...@@ -55,7 +65,7 @@ private:
class ModuleConfigControl: public ConfigControl class ModuleConfigControl: public ConfigControl
{ {
public: public:
ModuleConfigControl( intf_thread_t *p_intf, module_config_t *p_item, ModuleConfigControl( vlc_object_t *p_this, module_config_t *p_item,
wxWindow *parent ); wxWindow *parent );
~ModuleConfigControl(); ~ModuleConfigControl();
virtual wxString GetPszValue(); virtual wxString GetPszValue();
...@@ -136,4 +146,3 @@ public: ...@@ -136,4 +146,3 @@ public:
private: private:
wxCheckBox *checkbox; wxCheckBox *checkbox;
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment