KiCad PCB EDA Suite
TEMPLATE_FIELDNAME Struct Reference

Struct TEMPLATE_FIELDNAME holds a name of a component's field, field value, and default visibility. More...

#include <template_fieldnames.h>

Public Member Functions

 TEMPLATE_FIELDNAME ()
 
 TEMPLATE_FIELDNAME (const wxString &aName)
 
 TEMPLATE_FIELDNAME (const TEMPLATE_FIELDNAME &ref)
 
void Format (OUTPUTFORMATTER *out, int nestLevel) const
 Function Format serializes this object out as text into the given OUTPUTFORMATTER. More...
 
void Parse (TEMPLATE_FIELDNAMES_LEXER *aSpec)
 Function Parse fills this object from information in the input stream aSpec, which is a TEMPLATE_FIELDNAMES_LEXER. More...
 

Static Public Member Functions

static const wxString GetDefaultFieldName (int aFieldNdx)
 Function GetDefaultFieldName returns a default symbol field name for field aFieldNdx for all components. More...
 

Public Attributes

wxString m_Name
 The field name. More...
 
bool m_Visible
 If first appearance of the field's editor has as visible. More...
 
bool m_URL
 If field should have a browse button. More...
 

Detailed Description

Struct TEMPLATE_FIELDNAME holds a name of a component's field, field value, and default visibility.

Template fieldnames are wanted fieldnames for use in the symbol/component property editors.

Definition at line 71 of file template_fieldnames.h.

Constructor & Destructor Documentation

◆ TEMPLATE_FIELDNAME() [1/3]

TEMPLATE_FIELDNAME::TEMPLATE_FIELDNAME ( )
inline

Definition at line 77 of file template_fieldnames.h.

77  :
78  m_Visible( false ),
79  m_URL( false )
80  {
81  }
bool m_Visible
If first appearance of the field's editor has as visible.
bool m_URL
If field should have a browse button.

◆ TEMPLATE_FIELDNAME() [2/3]

TEMPLATE_FIELDNAME::TEMPLATE_FIELDNAME ( const wxString &  aName)
inline

Definition at line 83 of file template_fieldnames.h.

83  :
84  m_Name( aName ),
85  m_Visible( false ),
86  m_URL( false )
87  {
88  }
bool m_Visible
If first appearance of the field's editor has as visible.
bool m_URL
If field should have a browse button.
wxString m_Name
The field name.

◆ TEMPLATE_FIELDNAME() [3/3]

TEMPLATE_FIELDNAME::TEMPLATE_FIELDNAME ( const TEMPLATE_FIELDNAME ref)
inline

Definition at line 90 of file template_fieldnames.h.

91  {
92  m_Name = ref.m_Name;
93  m_Visible = ref.m_Visible;
94  m_URL = ref.m_URL;
95  }
bool m_Visible
If first appearance of the field's editor has as visible.
bool m_URL
If field should have a browse button.
wxString m_Name
The field name.

References m_Name, m_URL, and m_Visible.

Member Function Documentation

◆ Format()

void TEMPLATE_FIELDNAME::Format ( OUTPUTFORMATTER out,
int  nestLevel 
) const

Function Format serializes this object out as text into the given OUTPUTFORMATTER.

Definition at line 81 of file template_fieldnames.cpp.

82 {
83  out->Print( nestLevel, "(field (name %s)", out->Quotew( m_Name ).c_str() );
84 
85  if( m_Visible )
86  out->Print( 0, " visible" );
87 
88  if( m_URL )
89  out->Print( 0, " url" );
90 
91  out->Print( 0, ")\n" );
92 }
bool m_Visible
If first appearance of the field's editor has as visible.
bool m_URL
If field should have a browse button.
wxString m_Name
The field name.
std::string Quotew(const wxString &aWrapee)
Definition: richio.cpp:472
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404

References OUTPUTFORMATTER::Print(), and OUTPUTFORMATTER::Quotew().

◆ GetDefaultFieldName()

const wxString TEMPLATE_FIELDNAME::GetDefaultFieldName ( int  aFieldNdx)
static

Function GetDefaultFieldName returns a default symbol field name for field aFieldNdx for all components.

These fieldnames are not modifiable, but template fieldnames are.

Parameters
aFieldNdxThe field number index, > 0

Definition at line 34 of file template_fieldnames.cpp.

35 {
36  static void* locale = nullptr;
37  static wxString referenceDefault;
38  static wxString valueDefault;
39  static wxString footprintDefault;
40  static wxString datasheetDefault;
41  static wxString fieldDefault;
42 
43  // Fetching translations can take a surprising amount of time when loading libraries,
44  // so only do it when necessary.
45  if( Pgm().GetLocale() != locale )
46  {
47  referenceDefault = _( "Reference" );
48  valueDefault = _( "Value" );
49  footprintDefault = _( "Footprint" );
50  datasheetDefault = _( "Datasheet" );
51  fieldDefault = _( "Field" );
52  locale = Pgm().GetLocale();
53  }
54 
55  // Fixed values for the first few default fields used by EESCHEMA
56  // (mandatory fields)
57  switch( aFieldNdx )
58  {
59  case REFERENCE:
60  return referenceDefault; // The component reference, R1, C1, etc.
61 
62  case VALUE:
63  return valueDefault; // The component value + name
64 
65  case FOOTPRINT:
66  return footprintDefault; // The footprint for use with Pcbnew
67 
68  case DATASHEET:
69  return datasheetDefault; // Link to a datasheet for component
70 
71  default:
72  break;
73  }
74 
75  // Other fields are use fields, give a default name:
76  wxString fieldName = fieldDefault;
77  fieldName << aFieldNdx;
78  return fieldName;
79 }
name of datasheet
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
Field Name Module PCB, i.e. "16DIP300".
Field Reference of part, i.e. "IC21".
#define VALUE
VTBL_ENTRY wxLocale * GetLocale()
Definition: pgm_base.h:220

References DATASHEET, FOOTPRINT, PGM_BASE::GetLocale(), Pgm(), REFERENCE, and VALUE.

Referenced by TEMPLATES::AddTemplateFieldName(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::DIALOG_EDIT_COMPONENT_IN_LIBRARY(), SCH_FIELD::GetName(), FIELDS_GRID_TABLE< SCH_FIELD >::GetValue(), LIB_FIELD::Init(), SCH_COMPONENT::Init(), SCH_LEGACY_PLUGIN::loadComponent(), SCH_LEGACY_PLUGIN_CACHE::loadField(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnAddField(), SCH_LEGACY_PLUGIN_CACHE::saveField(), and DIALOG_UPDATE_FIELDS::updateFields().

◆ Parse()

void TEMPLATE_FIELDNAME::Parse ( TEMPLATE_FIELDNAMES_LEXER *  aSpec)

Function Parse fills this object from information in the input stream aSpec, which is a TEMPLATE_FIELDNAMES_LEXER.

The entire textual element spec is
(field (name yourfieldname)(value yourvalue) visible))
The presence of value is optional, the presence of visible is optional. When this function is called, the input token stream given by aSpec is assumed to be positioned at the '^' in the following example, i.e. just after the identifying keyword and before the content specifying stuff.
(field ^ (....) )

Parameters
aSpecis the input token stream of keywords and symbols.

Definition at line 95 of file template_fieldnames.cpp.

96 {
97  T tok;
98 
99  in->NeedLEFT(); // begin (name ...)
100 
101  if( (tok = in->NextTok()) != T_name )
102  in->Expecting( T_name );
103 
104  in->NeedSYMBOLorNUMBER();
105 
106  m_Name = FROM_UTF8( in->CurText() );
107 
108  in->NeedRIGHT(); // end (name ...)
109 
110  while( (tok = in->NextTok() ) != T_RIGHT && tok != T_EOF )
111  {
112  // "visible" has no '(' prefix, "value" does, so T_LEFT is optional.
113  if( tok == T_LEFT )
114  tok = in->NextTok();
115 
116  switch( tok )
117  {
118  case T_value:
119  // older format; silently skip
120  in->NeedSYMBOLorNUMBER();
121  in->NeedRIGHT();
122  break;
123 
124  case T_visible:
125  m_Visible = true;
126  break;
127 
128  case T_url:
129  m_URL = true;
130  break;
131 
132  default:
133  in->Expecting( "value|url|visible" );
134  break;
135  }
136  }
137 }
bool m_Visible
If first appearance of the field's editor has as visible.
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:61
bool m_URL
If field should have a browse button.
wxString m_Name
The field name.

References FROM_UTF8().

Referenced by TEMPLATES::Parse().

Member Data Documentation

◆ m_Name

wxString TEMPLATE_FIELDNAME::m_Name

The field name.

Definition at line 73 of file template_fieldnames.h.

Referenced by TEMPLATES::AddTemplateFieldName(), and TEMPLATE_FIELDNAME().

◆ m_URL

bool TEMPLATE_FIELDNAME::m_URL

If field should have a browse button.

Definition at line 75 of file template_fieldnames.h.

Referenced by FIELDS_GRID_TABLE< SCH_FIELD >::GetAttr(), and TEMPLATE_FIELDNAME().

◆ m_Visible

bool TEMPLATE_FIELDNAME::m_Visible

If first appearance of the field's editor has as visible.

Definition at line 74 of file template_fieldnames.h.

Referenced by PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::OnAddButtonClick(), and TEMPLATE_FIELDNAME().


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