KiCad PCB EDA Suite
PARAM_CFG_SETCOLOR Class Reference

Configuration parameter - SetColor Class. More...

#include <config_params.h>

Inheritance diagram for PARAM_CFG_SETCOLOR:
PARAM_CFG_BASE

Public Member Functions

 PARAM_CFG_SETCOLOR (const wxString &ident, COLOR4D *ptparam, COLOR4D default_val, const wxChar *group=NULL)
 
 PARAM_CFG_SETCOLOR (bool Insetup, const wxString &ident, COLOR4D *ptparam, COLOR4D default_val, const wxChar *group=NULL)
 
virtual void ReadParam (wxConfigBase *aConfig) const override
 Function ReadParam reads the value of the parameter stored in aConfig. More...
 
virtual void SaveParam (wxConfigBase *aConfig) const override
 Function SaveParam saves the value of the parameter stored in aConfig. More...
 

Public Attributes

COLOR4Dm_Pt_param
 Pointer to the parameter value. More...
 
COLOR4D m_Default
 The default value of the parameter. More...
 
wxString m_Ident
 Keyword in config data. More...
 
paramcfg_id m_Type
 Type of parameter. More...
 
wxString m_Group
 Group name (this is like a path in the config data) More...
 
bool m_Setup
 Install or Project based parameter, true == install. More...
 
wxString m_Ident_legacy
 

Detailed Description

Configuration parameter - SetColor Class.

Definition at line 193 of file config_params.h.

Constructor & Destructor Documentation

PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR ( const wxString &  ident,
COLOR4D ptparam,
COLOR4D  default_val,
const wxChar *  group = NULL 
)

Definition at line 251 of file config_params.cpp.

References m_Default, and m_Pt_param.

253  :
254  PARAM_CFG_BASE( ident, PARAM_SETCOLOR, group )
255 {
256  m_Pt_param = ptparam;
257  m_Default = default_val;
258 }
COLOR4D * m_Pt_param
Pointer to the parameter value.
PARAM_CFG_BASE(const wxString &ident, const paramcfg_id type, const wxChar *group=NULL, const wxString &legacy_ident=wxEmptyString)
COLOR4D m_Default
The default value of the parameter.
PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR ( bool  Insetup,
const wxString &  ident,
COLOR4D ptparam,
COLOR4D  default_val,
const wxChar *  group = NULL 
)

Definition at line 261 of file config_params.cpp.

References m_Default, m_Pt_param, and PARAM_CFG_BASE::m_Setup.

265  :
266  PARAM_CFG_BASE( ident, PARAM_SETCOLOR, group )
267 {
268  m_Pt_param = ptparam;
269  m_Default = default_val;
270  m_Setup = Insetup;
271 }
COLOR4D * m_Pt_param
Pointer to the parameter value.
PARAM_CFG_BASE(const wxString &ident, const paramcfg_id type, const wxChar *group=NULL, const wxString &legacy_ident=wxEmptyString)
bool m_Setup
Install or Project based parameter, true == install.
COLOR4D m_Default
The default value of the parameter.

Member Function Documentation

void PARAM_CFG_SETCOLOR::ReadParam ( wxConfigBase *  aConfig) const
overridevirtual

Function ReadParam reads the value of the parameter stored in aConfig.

Parameters
aConfig= the wxConfigBase that holds the parameter

Reimplemented from PARAM_CFG_BASE.

Definition at line 274 of file config_params.cpp.

References ColorByName(), m_Default, PARAM_CFG_BASE::m_Ident, m_Pt_param, UNSPECIFIED_COLOR, and KIGFX::COLOR4D::WithAlpha().

275 {
276  if( !m_Pt_param || !aConfig )
277  return;
278 
279  COLOR4D temp;
280 
281  if( aConfig->HasEntry( m_Ident ) )
282  {
283  if( temp.SetFromWxString( aConfig->Read( m_Ident, wxT( "NONE" ) ) ) )
284  {
285  *m_Pt_param = temp;
286  return;
287  }
288  }
289 
290  // If no luck, try reading legacy format
291  wxString legacy_Ident = m_Ident;
292  legacy_Ident.Replace( wxT( "4D" ), wxEmptyString );
293 
294  EDA_COLOR_T old = ColorByName( aConfig->Read( legacy_Ident, wxT( "NONE" ) ) );
295 
296  if( old != UNSPECIFIED_COLOR )
297  {
298  if( m_Ident == wxT( "Color4DErcWEx" ) || m_Ident == wxT( "Color4DErcEEx" ) )
299  *m_Pt_param = COLOR4D( old ).WithAlpha( 0.8 );
300  else
301  *m_Pt_param = COLOR4D( old );
302  return;
303  }
304 
306 }
EDA_COLOR_T
NOTE: EDA_COLOR_T is deprecated and is kept around for compatibility with legacy canvas.
Definition: colors.h:42
EDA_COLOR_T ColorByName(const wxString &aName)
Find a color by name.
Definition: colors.cpp:72
COLOR4D * m_Pt_param
Pointer to the parameter value.
COLOR4D WithAlpha(double aAlpha) const
Function WithAlpha Returns a colour with the same colour, but the given alpha.
Definition: color4d.h:233
COLOR4D m_Default
The default value of the parameter.
wxString m_Ident
Keyword in config data.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
void PARAM_CFG_SETCOLOR::SaveParam ( wxConfigBase *  aConfig) const
overridevirtual

Function SaveParam saves the value of the parameter stored in aConfig.

Parameters
aConfig= the wxConfigBase that can store the parameter

Reimplemented from PARAM_CFG_BASE.

Definition at line 309 of file config_params.cpp.

References PARAM_CFG_BASE::m_Ident, and m_Pt_param.

310 {
311  if( !m_Pt_param || !aConfig )
312  return;
313 
314  aConfig->Write( m_Ident, m_Pt_param->ToColour().GetAsString( wxC2S_CSS_SYNTAX ) );
315 }
COLOR4D * m_Pt_param
Pointer to the parameter value.
wxString m_Ident
Keyword in config data.

Member Data Documentation

COLOR4D PARAM_CFG_SETCOLOR::m_Default

The default value of the parameter.

Definition at line 197 of file config_params.h.

Referenced by PARAM_CFG_SETCOLOR(), and ReadParam().

wxString PARAM_CFG_BASE::m_Group
inherited

Group name (this is like a path in the config data)

Definition at line 104 of file config_params.h.

Referenced by PARAM_CFG_BASE::PARAM_CFG_BASE().

wxString PARAM_CFG_BASE::m_Ident_legacy
inherited
COLOR4D* PARAM_CFG_SETCOLOR::m_Pt_param

Pointer to the parameter value.

Definition at line 196 of file config_params.h.

Referenced by PARAM_CFG_SETCOLOR(), ReadParam(), and SaveParam().

bool PARAM_CFG_BASE::m_Setup
inherited
paramcfg_id PARAM_CFG_BASE::m_Type
inherited

Type of parameter.

Definition at line 103 of file config_params.h.

Referenced by PARAM_CFG_BASE::PARAM_CFG_BASE(), and PARAM_CFG_INT_WITH_SCALE::PARAM_CFG_INT_WITH_SCALE().


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