KiCad PCB EDA Suite
TOOL_SETTINGS Class Reference

#include <tool_settings.h>

Inheritance diagram for TOOL_SETTINGS:
SETTINGS

Public Member Functions

 TOOL_SETTINGS (TOOL_BASE *aTool=NULL)
 
 ~TOOL_SETTINGS ()
 
template<class T >
Get (const wxString &aName, T aDefaultValue) const
 
template<class T >
void Set (const wxString &aName, const T &aValue)
 
void SetConfigPrefix (const wxString &aPrefix)
 Set a prefix that will be prepent to the keywords when adding a setting in list. More...
 
const wxString & GetConfigPrefix ()
 
virtual void Load (wxConfigBase *aConfig)
 
virtual void Save (wxConfigBase *aConfig)
 
void Add (const wxString &name, int *aPtr, int aDefaultValue)
 
void Add (const wxString &name, bool *aPtr, bool aDefaultValue)
 
void Add (const wxString &name, KIGFX::COLOR4D *aPtr, KIGFX::COLOR4D aDefaultValue)
 
void Add (const wxString &name, KIGFX::COLOR4D *aPtr, EDA_COLOR_T aDefaultValue)
 

Private Member Functions

wxString getKeyName (const wxString &aEntryName) const override
 
wxConfigBase * getConfigBase () const
 

Returns pointer to currently used wxConfigBase.

More...
 

Private Attributes

TOOL_BASEm_tool
 

Detailed Description

Definition at line 38 of file tool_settings.h.

Constructor & Destructor Documentation

TOOL_SETTINGS::TOOL_SETTINGS ( TOOL_BASE aTool = NULL)

Definition at line 66 of file tool_base.cpp.

66  :
67  m_tool( aTool )
68 {
69 }
TOOL_BASE * m_tool
Definition: tool_settings.h:76
TOOL_SETTINGS::~TOOL_SETTINGS ( )

Definition at line 72 of file tool_base.cpp.

73 {
74 }

Member Function Documentation

void SETTINGS::Add ( const wxString &  name,
int *  aPtr,
int  aDefaultValue 
)
inlineinherited

Definition at line 93 of file settings.h.

References SETTINGS::m_params, and SETTINGS::m_prefix.

Referenced by PCB_GENERAL_SETTINGS::PCB_GENERAL_SETTINGS(), and COLORS_DESIGN_SETTINGS::setupConfigParams().

94  {
95  m_params.push_back ( new PARAM_CFG_INT ( m_prefix+name, aPtr, aDefaultValue ) );
96  }
PARAM_CFG_ARRAY m_params
Definition: settings.h:123
wxString m_prefix
Definition: settings.h:122
Configuration parameter - Integer Class.
const char * name
void SETTINGS::Add ( const wxString &  name,
bool *  aPtr,
bool  aDefaultValue 
)
inlineinherited

Definition at line 98 of file settings.h.

References SETTINGS::m_params, and SETTINGS::m_prefix.

99  {
100  m_params.push_back ( new PARAM_CFG_BOOL ( m_prefix+name, aPtr, aDefaultValue ) );
101  }
PARAM_CFG_ARRAY m_params
Definition: settings.h:123
wxString m_prefix
Definition: settings.h:122
Configuration parameter - Boolean Class.
const char * name
void SETTINGS::Add ( const wxString &  name,
KIGFX::COLOR4D aPtr,
KIGFX::COLOR4D  aDefaultValue 
)
inlineinherited

Definition at line 103 of file settings.h.

References SETTINGS::m_params, and SETTINGS::m_prefix.

104  {
105  m_params.push_back ( new PARAM_CFG_SETCOLOR ( m_prefix+name, aPtr, aDefaultValue ) );
106  }
PARAM_CFG_ARRAY m_params
Definition: settings.h:123
Configuration parameter - SetColor Class.
wxString m_prefix
Definition: settings.h:122
const char * name
void SETTINGS::Add ( const wxString &  name,
KIGFX::COLOR4D aPtr,
EDA_COLOR_T  aDefaultValue 
)
inlineinherited

Definition at line 108 of file settings.h.

References SETTINGS::m_params, and SETTINGS::m_prefix.

109  {
110  m_params.push_back ( new PARAM_CFG_SETCOLOR ( m_prefix+name, aPtr, aDefaultValue ) );
111  }
PARAM_CFG_ARRAY m_params
Definition: settings.h:123
Configuration parameter - SetColor Class.
wxString m_prefix
Definition: settings.h:122
const char * name
template<class T >
T TOOL_SETTINGS::Get ( const wxString &  aName,
aDefaultValue 
) const
inline

Definition at line 45 of file tool_settings.h.

References getConfigBase(), and getKeyName().

Referenced by PNS::ROUTING_SETTINGS::Load().

46  {
47  wxConfigBase* config = getConfigBase();
48 
49  if( !config )
50  return aDefaultValue;
51 
52  T tmp = aDefaultValue;
53 
54  config->Read( getKeyName( aName ), &tmp );
55  return tmp;
56  }
T
enum T contains all this lexer's tokens.
wxConfigBase * getConfigBase() const
Returns pointer to currently used wxConfigBase.
Definition: tool_base.cpp:92
wxString getKeyName(const wxString &aEntryName) const override
Definition: tool_base.cpp:83
wxConfigBase * TOOL_SETTINGS::getConfigBase ( ) const
private

Returns pointer to currently used wxConfigBase.

It might be NULL, if there is no

TOOL_BASE assigned.

Definition at line 92 of file tool_base.cpp.

References TOOL_BASE::getEditFrame(), and m_tool.

Referenced by Get(), and Set().

93 {
94  if( !m_tool )
95  return NULL;
96 
97  // fixme: make independent of pcbnew (post-stable)
99  return frame->GetSettings();
100 
101  return NULL;
102 }
TOOL_BASE * m_tool
Definition: tool_settings.h:76
T * getEditFrame() const
Function getEditFrame()
Definition: tool_base.h:188
const wxString& SETTINGS::GetConfigPrefix ( )
inlineinherited
Returns
the current prefix

Definition at line 57 of file settings.h.

References SETTINGS::m_prefix.

Referenced by COLORS_DESIGN_SETTINGS::setupConfigParams().

58  {
59  return m_prefix;
60  }
wxString m_prefix
Definition: settings.h:122
wxString TOOL_SETTINGS::getKeyName ( const wxString &  aEntryName) const
overrideprivatevirtual

Reimplemented from SETTINGS.

Definition at line 83 of file tool_base.cpp.

References TOOL_BASE::GetName(), and m_tool.

Referenced by Get(), and Set().

84 {
85  wxString key( m_tool->GetName() );
86  key += wxT( "." );
87  key += aEntryName;
88  return key;
89 }
TOOL_BASE * m_tool
Definition: tool_settings.h:76
const std::string & GetName() const
Function GetName() Returns the name of the tool.
Definition: tool_base.h:133
void SETTINGS::Load ( wxConfigBase *  aConfig)
virtualinherited

Reimplemented in COLORS_DESIGN_SETTINGS, and PCB_GENERAL_SETTINGS.

Definition at line 26 of file settings.cpp.

References SETTINGS::m_params.

Referenced by PCB_GENERAL_SETTINGS::Load(), and COLORS_DESIGN_SETTINGS::Load().

27 {
28  for( const PARAM_CFG_BASE& param : m_params )
29  {
30  if( !!param.m_Group )
31  aConfig->SetPath( param.m_Group );
32  else
33  aConfig->SetPath( wxT("") );
34 
35  param.ReadParam( aConfig );
36  }
37 }
PARAM_CFG_ARRAY m_params
Definition: settings.h:123
Class PARAM_CFG_BASE is a base class which establishes the interface functions ReadParam and SavePara...
Definition: config_params.h:94
void SETTINGS::Save ( wxConfigBase *  aConfig)
virtualinherited

Reimplemented in COLORS_DESIGN_SETTINGS, and PCB_GENERAL_SETTINGS.

Definition at line 39 of file settings.cpp.

References SETTINGS::m_params.

Referenced by PCB_GENERAL_SETTINGS::Save(), and COLORS_DESIGN_SETTINGS::Save().

40 {
41  for( PARAM_CFG_BASE& param : m_params )
42  {
43  if( !!param.m_Group )
44  aConfig->SetPath( param.m_Group );
45  else
46  aConfig->SetPath( wxT("") );
47 
48  param.SaveParam( aConfig );
49  }
50 }
PARAM_CFG_ARRAY m_params
Definition: settings.h:123
Class PARAM_CFG_BASE is a base class which establishes the interface functions ReadParam and SavePara...
Definition: config_params.h:94
template<class T >
void TOOL_SETTINGS::Set ( const wxString &  aName,
const T &  aValue 
)
inline

Definition at line 59 of file tool_settings.h.

References getConfigBase(), and getKeyName().

Referenced by PNS::ROUTING_SETTINGS::Save().

60  {
61  wxConfigBase* config = getConfigBase();
62 
63  if( !config )
64  return;
65 
66  config->Write( getKeyName( aName ), aValue );
67  }
wxConfigBase * getConfigBase() const
Returns pointer to currently used wxConfigBase.
Definition: tool_base.cpp:92
wxString getKeyName(const wxString &aEntryName) const override
Definition: tool_base.cpp:83
void SETTINGS::SetConfigPrefix ( const wxString &  aPrefix)
inlineinherited

Set a prefix that will be prepent to the keywords when adding a setting in list.

Parameters
aPrefixis the string to prepend to the keywords

Definition at line 50 of file settings.h.

References SETTINGS::m_prefix.

Referenced by COLORS_DESIGN_SETTINGS::setupConfigParams().

51  {
52  m_prefix = aPrefix;
53  }
wxString m_prefix
Definition: settings.h:122

Member Data Documentation

TOOL_BASE* TOOL_SETTINGS::m_tool
private

Definition at line 76 of file tool_settings.h.

Referenced by getConfigBase(), and getKeyName().


The documentation for this class was generated from the following files: