KiCad PCB EDA Suite
FIELDS_GRID_TABLE< T > Class Template Reference

#include <fields_grid_table.h>

Inheritance diagram for FIELDS_GRID_TABLE< T >:

Public Member Functions

 FIELDS_GRID_TABLE (DIALOG_SHIM *aDialog, SCH_BASE_FRAME *aFrame, WX_GRID *aGrid, LIB_SYMBOL *aSymbol)
 
 FIELDS_GRID_TABLE (DIALOG_SHIM *aDialog, SCH_BASE_FRAME *aFrame, WX_GRID *aGrid, SCH_SHEET *aSheet)
 
 ~FIELDS_GRID_TABLE ()
 
int GetNumberRows () override
 
int GetNumberCols () override
 
wxString GetColLabelValue (int aCol) override
 
bool IsEmptyCell (int row, int col) override
 
bool CanGetValueAs (int aRow, int aCol, const wxString &aTypeName) override
 
bool CanSetValueAs (int aRow, int aCol, const wxString &aTypeName) override
 
wxGridCellAttr * GetAttr (int row, int col, wxGridCellAttr::wxAttrKind kind) override
 
wxString GetValue (int aRow, int aCol) override
 
bool GetValueAsBool (int aRow, int aCol) override
 
void SetValue (int aRow, int aCol, const wxString &aValue) override
 
void SetValueAsBool (int aRow, int aCol, bool aValue) override
 
wxString StringFromBool (bool aValue) const
 
bool BoolFromString (wxString aValue) const
 

Protected Member Functions

void initGrid (DIALOG_SHIM *aDialog, WX_GRID *aGrid)
 

Private Attributes

SCH_BASE_FRAMEm_frame
 
EDA_UNITS m_userUnits
 
WX_GRIDm_grid
 
KICAD_T m_parentType
 
int m_mandatoryFieldCount
 
LIB_SYMBOLm_part
 
wxString m_curdir
 
SCH_FIELD_VALIDATOR m_fieldNameValidator
 
SCH_FIELD_VALIDATOR m_referenceValidator
 
SCH_FIELD_VALIDATOR m_valueValidator
 
LIB_ID_VALIDATOR m_libIdValidator
 
SCH_FIELD_VALIDATOR m_urlValidator
 
SCH_FIELD_VALIDATOR m_nonUrlValidator
 
SCH_FIELD_VALIDATOR m_filepathValidator
 
wxGridCellAttr * m_readOnlyAttr
 
wxGridCellAttr * m_fieldNameAttr
 
wxGridCellAttr * m_referenceAttr
 
wxGridCellAttr * m_valueAttr
 
wxGridCellAttr * m_footprintAttr
 
wxGridCellAttr * m_urlAttr
 
wxGridCellAttr * m_nonUrlAttr
 
wxGridCellAttr * m_filepathAttr
 
wxGridCellAttr * m_boolAttr
 
wxGridCellAttr * m_vAlignAttr
 
wxGridCellAttr * m_hAlignAttr
 
wxGridCellAttr * m_orientationAttr
 

Detailed Description

template<class T>
class FIELDS_GRID_TABLE< T >

Definition at line 72 of file fields_grid_table.h.

Constructor & Destructor Documentation

◆ FIELDS_GRID_TABLE() [1/2]

template<class T >
FIELDS_GRID_TABLE< T >::FIELDS_GRID_TABLE ( DIALOG_SHIM aDialog,
SCH_BASE_FRAME aFrame,
WX_GRID aGrid,
LIB_SYMBOL aSymbol 
)

Definition at line 50 of file fields_grid_table.cpp.

51  :
52  m_frame( aFrame ),
53  m_userUnits( aDialog->GetUserUnits() ),
54  m_grid( aGrid ),
57  m_part( aSymbol ),
65 {
66  initGrid( aDialog, aGrid );
67 }
Field Reference of part, i.e. "IC21".
#define FIELD_VALUE
SCH_BASE_FRAME * m_frame
EDA_UNITS GetUserUnits() const
Definition: dialog_shim.h:119
Field Value of part, i.e. "3.3K".
SCH_FIELD_VALIDATOR m_referenceValidator
SCH_FIELD_VALIDATOR m_fieldNameValidator
#define FIELD_NAME
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
SCH_FIELD_VALIDATOR m_valueValidator
void initGrid(DIALOG_SHIM *aDialog, WX_GRID *aGrid)
bool IsType(FRAME_T aType) const
SCH_FIELD_VALIDATOR m_filepathValidator
LIB_ID_VALIDATOR m_libIdValidator
SCH_FIELD_VALIDATOR m_urlValidator
SCH_FIELD_VALIDATOR m_nonUrlValidator

◆ FIELDS_GRID_TABLE() [2/2]

template<class T >
FIELDS_GRID_TABLE< T >::FIELDS_GRID_TABLE ( DIALOG_SHIM aDialog,
SCH_BASE_FRAME aFrame,
WX_GRID aGrid,
SCH_SHEET aSheet 
)

Definition at line 71 of file fields_grid_table.cpp.

72  :
73  m_frame( aFrame ),
74  m_userUnits( aDialog->GetUserUnits() ),
75  m_grid( aGrid ),
78  m_part( nullptr ),
86 {
87  initGrid( aDialog, aGrid );
88 }
The first 2 are mandatory, and must be instantiated in SCH_SHEET.
Definition: sch_sheet.h:47
#define FIELD_VALUE
SCH_BASE_FRAME * m_frame
#define SHEETNAME_V
EDA_UNITS GetUserUnits() const
Definition: dialog_shim.h:119
Field Value of part, i.e. "3.3K".
SCH_FIELD_VALIDATOR m_referenceValidator
SCH_FIELD_VALIDATOR m_fieldNameValidator
#define SHEETFILENAME_V
#define FIELD_NAME
SCH_FIELD_VALIDATOR m_valueValidator
void initGrid(DIALOG_SHIM *aDialog, WX_GRID *aGrid)
bool IsType(FRAME_T aType) const
SCH_FIELD_VALIDATOR m_filepathValidator
LIB_ID_VALIDATOR m_libIdValidator
SCH_FIELD_VALIDATOR m_urlValidator
SCH_FIELD_VALIDATOR m_nonUrlValidator

◆ ~FIELDS_GRID_TABLE()

template<class T >
FIELDS_GRID_TABLE< T >::~FIELDS_GRID_TABLE ( )

Definition at line 175 of file fields_grid_table.cpp.

176 {
177  m_readOnlyAttr->DecRef();
178  m_fieldNameAttr->DecRef();
179  m_boolAttr->DecRef();
180  m_referenceAttr->DecRef();
181  m_valueAttr->DecRef();
182  m_footprintAttr->DecRef();
183  m_urlAttr->DecRef();
184  m_nonUrlAttr->DecRef();
185  m_filepathAttr->DecRef();
186  m_vAlignAttr->DecRef();
187  m_hAlignAttr->DecRef();
188  m_orientationAttr->DecRef();
189 }
wxGridCellAttr * m_referenceAttr
wxGridCellAttr * m_readOnlyAttr
wxGridCellAttr * m_filepathAttr
wxGridCellAttr * m_hAlignAttr
wxGridCellAttr * m_boolAttr
wxGridCellAttr * m_fieldNameAttr
wxGridCellAttr * m_urlAttr
wxGridCellAttr * m_vAlignAttr
wxGridCellAttr * m_orientationAttr
wxGridCellAttr * m_valueAttr
wxGridCellAttr * m_nonUrlAttr
wxGridCellAttr * m_footprintAttr

Member Function Documentation

◆ BoolFromString()

template<class T >
bool FIELDS_GRID_TABLE< T >::BoolFromString ( wxString  aValue) const

Definition at line 652 of file fields_grid_table.cpp.

653 {
654  if( aValue == "1" )
655  {
656  return true;
657  }
658  else if( aValue == "0" )
659  {
660  return false;
661  }
662  else
663  {
664  wxFAIL_MSG( wxString::Format( "string \"%s\" can't be converted to boolean "
665  "correctly, it will have been perceived as FALSE", aValue ) );
666  return false;
667  }
668 }
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200

◆ CanGetValueAs()

template<class T >
bool FIELDS_GRID_TABLE< T >::CanGetValueAs ( int  aRow,
int  aCol,
const wxString &  aTypeName 
)
override

Definition at line 214 of file fields_grid_table.cpp.

215 {
216  switch( aCol )
217  {
218  case FDC_NAME:
219  case FDC_VALUE:
220  case FDC_H_ALIGN:
221  case FDC_V_ALIGN:
222  case FDC_TEXT_SIZE:
223  case FDC_ORIENTATION:
224  case FDC_POSX:
225  case FDC_POSY:
226  return aTypeName == wxGRID_VALUE_STRING;
227 
228  case FDC_SHOWN:
229  case FDC_ITALIC:
230  case FDC_BOLD:
231  return aTypeName == wxGRID_VALUE_BOOL;
232 
233  default:
234  wxFAIL;
235  return false;
236  }
237 }

◆ CanSetValueAs()

template<class T >
bool FIELDS_GRID_TABLE< T >::CanSetValueAs ( int  aRow,
int  aCol,
const wxString &  aTypeName 
)
override

Definition at line 241 of file fields_grid_table.cpp.

242 {
243  return CanGetValueAs( aRow, aCol, aTypeName );
244 }
bool CanGetValueAs(int aRow, int aCol, const wxString &aTypeName) override

◆ GetAttr()

template<class T >
wxGridCellAttr * FIELDS_GRID_TABLE< T >::GetAttr ( int  row,
int  col,
wxGridCellAttr::wxAttrKind  kind 
)
override

Definition at line 248 of file fields_grid_table.cpp.

249 {
250  wxGridCellAttr* tmp;
251 
252  switch( aCol )
253  {
254  case FDC_NAME:
255  if( aRow < m_mandatoryFieldCount )
256  {
257  tmp = m_fieldNameAttr->Clone();
258  tmp->SetReadOnly( true );
259  return tmp;
260  }
261  else
262  {
263  m_fieldNameAttr->IncRef();
264  return m_fieldNameAttr;
265  }
266 
267  case FDC_VALUE:
268  if( m_parentType == SCH_SYMBOL_T && aRow == REFERENCE_FIELD )
269  {
270  m_referenceAttr->IncRef();
271  return m_referenceAttr;
272  }
273  else if( m_parentType == SCH_SYMBOL_T && aRow == VALUE_FIELD )
274  {
275  // For power symbols, the value is not editable, because value and pin name must
276  // be the same and can be edited only in library editor.
278  {
279  tmp = m_readOnlyAttr->Clone();
280  tmp->SetReadOnly( true );
281  tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
282  return tmp;
283  }
284  else
285  {
286  m_valueAttr->IncRef();
287  return m_valueAttr;
288  }
289  }
290  else if( m_parentType == SCH_SYMBOL_T && aRow == FOOTPRINT_FIELD )
291  {
292  m_footprintAttr->IncRef();
293  return m_footprintAttr;
294  }
295  else if( m_parentType == SCH_SYMBOL_T && aRow == DATASHEET_FIELD )
296  {
297  m_urlAttr->IncRef();
298  return m_urlAttr;
299  }
300  else if( m_parentType == SCH_SHEET_T && aRow == SHEETNAME )
301  {
302  m_referenceAttr->IncRef();
303  return m_referenceAttr;
304  }
305  else if( m_parentType == SCH_SHEET_T && aRow == SHEETFILENAME )
306  {
307  m_filepathAttr->IncRef();
308  return m_filepathAttr;
309  }
310  else
311  {
312  wxString fn = GetValue( aRow, FDC_NAME );
313 
315 
316  const TEMPLATE_FIELDNAME* templateFn =
317  settings ? settings->m_TemplateFieldNames.GetFieldName( fn ) : nullptr;
318 
319  if( templateFn && templateFn->m_URL )
320  {
321  m_urlAttr->IncRef();
322  return m_urlAttr;
323  }
324  else
325  {
326  m_nonUrlAttr->IncRef();
327  return m_nonUrlAttr;
328  }
329  }
330 
331  return nullptr;
332 
333  case FDC_TEXT_SIZE:
334  case FDC_POSX:
335  case FDC_POSY:
336  return nullptr;
337 
338  case FDC_H_ALIGN:
339  m_hAlignAttr->IncRef();
340  return m_hAlignAttr;
341 
342  case FDC_V_ALIGN:
343  m_vAlignAttr->IncRef();
344  return m_vAlignAttr;
345 
346  case FDC_ORIENTATION:
347  m_orientationAttr->IncRef();
348  return m_orientationAttr;
349 
350  case FDC_SHOWN:
351  case FDC_ITALIC:
352  case FDC_BOLD:
353  m_boolAttr->IncRef();
354  return m_boolAttr;
355 
356  default:
357  wxFAIL;
358  return nullptr;
359  }
360 }
Field Reference of part, i.e. "IC21".
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:145
TEMPLATES m_TemplateFieldNames
wxGridCellAttr * m_referenceAttr
SCH_BASE_FRAME * m_frame
bool IsPower() const
Definition: lib_symbol.cpp:408
name of datasheet
wxGridCellAttr * m_readOnlyAttr
wxGridCellAttr * m_filepathAttr
Field Value of part, i.e. "3.3K".
wxGridCellAttr * m_hAlignAttr
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
wxString GetValue(int aRow, int aCol) override
wxGridCellAttr * m_boolAttr
SCHEMATIC_SETTINGS * m_SchematicSettings
Definition: project_file.h:128
const TEMPLATE_FIELDNAME * GetFieldName(const wxString &aName)
Search for aName in the template field name list.
wxGridCellAttr * m_fieldNameAttr
wxGridCellAttr * m_urlAttr
bool IsType(FRAME_T aType) const
wxGridCellAttr * m_vAlignAttr
wxGridCellAttr * m_orientationAttr
wxGridCellAttr * m_valueAttr
These settings were stored in SCH_BASE_FRAME previously.
Hold a name of a symbol's field, field value, and default visibility.
wxGridCellAttr * m_nonUrlAttr
wxGridCellAttr * m_footprintAttr
Field Name Module PCB, i.e. "16DIP300".

◆ GetColLabelValue()

template<class T >
wxString FIELDS_GRID_TABLE< T >::GetColLabelValue ( int  aCol)
override

Definition at line 193 of file fields_grid_table.cpp.

194 {
195  switch( aCol )
196  {
197  case FDC_NAME: return _( "Name" );
198  case FDC_VALUE: return _( "Value" );
199  case FDC_SHOWN: return _( "Show" );
200  case FDC_H_ALIGN: return _( "H Align" );
201  case FDC_V_ALIGN: return _( "V Align" );
202  case FDC_ITALIC: return _( "Italic" );
203  case FDC_BOLD: return _( "Bold" );
204  case FDC_TEXT_SIZE: return _( "Text Size" );
205  case FDC_ORIENTATION: return _( "Orientation" );
206  case FDC_POSX: return _( "X Position" );
207  case FDC_POSY: return _( "Y Position" );
208  default: wxFAIL; return wxEmptyString;
209  }
210 }
#define _(s)

◆ GetNumberCols()

template<class T>
int FIELDS_GRID_TABLE< T >::GetNumberCols ( )
inlineoverride

Definition at line 82 of file fields_grid_table.h.

82 { return FDC_COUNT; }

◆ GetNumberRows()

template<class T>
int FIELDS_GRID_TABLE< T >::GetNumberRows ( )
inlineoverride

Definition at line 81 of file fields_grid_table.h.

81 { return (int) this->size(); }

Referenced by DIALOG_LIB_SYMBOL_PROPERTIES::OnMoveDown(), and DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataToWindow().

◆ GetValue()

template<class T >
wxString FIELDS_GRID_TABLE< T >::GetValue ( int  aRow,
int  aCol 
)
override

Definition at line 364 of file fields_grid_table.cpp.

365 {
366  wxCHECK( aRow < GetNumberRows(), wxEmptyString );
367  const T& field = this->at( (size_t) aRow );
368 
369  switch( aCol )
370  {
371  case FDC_NAME:
372  // Use default field name for mandatory fields, because they are translated
373  // according to the current locale
374  if( aRow < m_mandatoryFieldCount )
375  {
376  if( m_parentType == SCH_SYMBOL_T )
378  else if( m_parentType == SCH_SHEET_T )
379  return SCH_SHEET::GetDefaultFieldName( aRow );
380  }
381 
382  return field.GetName( false );
383 
384  case FDC_VALUE:
385  return UnescapeString( field.GetText() );
386 
387  case FDC_SHOWN:
388  return StringFromBool( field.IsVisible() );
389 
390  case FDC_H_ALIGN:
391  switch ( field.GetHorizJustify() )
392  {
393  case GR_TEXT_HJUSTIFY_LEFT: return _( "Left" );
394  case GR_TEXT_HJUSTIFY_CENTER: return _( "Center" );
395  case GR_TEXT_HJUSTIFY_RIGHT: return _( "Right" );
396  }
397 
398  break;
399 
400  case FDC_V_ALIGN:
401  switch ( field.GetVertJustify() )
402  {
403  case GR_TEXT_VJUSTIFY_TOP: return _( "Top" );
404  case GR_TEXT_VJUSTIFY_CENTER: return _( "Center" );
405  case GR_TEXT_VJUSTIFY_BOTTOM: return _( "Bottom" );
406  }
407 
408  break;
409 
410  case FDC_ITALIC:
411  return StringFromBool( field.IsItalic() );
412 
413  case FDC_BOLD:
414  return StringFromBool( field.IsBold() );
415 
416  case FDC_TEXT_SIZE:
417  return StringFromValue( m_userUnits, field.GetTextSize().GetHeight() );
418 
419  case FDC_ORIENTATION:
420  switch ( (int) field.GetTextAngle() )
421  {
422  case TEXT_ANGLE_HORIZ: return _( "Horizontal" );
423  case TEXT_ANGLE_VERT: return _( "Vertical" );
424  }
425 
426  break;
427 
428  case FDC_POSX:
429  return StringFromValue( m_userUnits, field.GetTextPos().x );
430 
431  case FDC_POSY:
432  return StringFromValue( m_userUnits, field.GetTextPos().y );
433 
434  default:
435  // we can't assert here because wxWidgets sometimes calls this without checking
436  // the column type when trying to see if there's an overflow
437  break;
438  }
439 
440  return wxT( "bad wxWidgets!" );
441 }
#define TEXT_ANGLE_HORIZ
Frequent text rotations, used with {Set,Get}TextAngle(), in 0.1 degrees for now, hoping to migrate to...
Definition: eda_text.h:50
int GetNumberRows() override
wxString StringFromBool(bool aValue) const
#define _(s)
static const wxString GetDefaultFieldName(int aFieldNdx)
Definition: sch_sheet.cpp:46
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslate=true)
Return a default symbol field name for field aFieldNdx for all components.
wxString UnescapeString(const wxString &aSource)
wxString StringFromValue(EDA_UNITS aUnits, double aValue, bool aAddUnitSymbol, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
Definition: base_units.cpp:204
#define TEXT_ANGLE_VERT
Definition: eda_text.h:51

◆ GetValueAsBool()

template<class T >
bool FIELDS_GRID_TABLE< T >::GetValueAsBool ( int  aRow,
int  aCol 
)
override

Definition at line 445 of file fields_grid_table.cpp.

446 {
447  wxCHECK( aRow < GetNumberRows(), false );
448  const T& field = this->at( (size_t) aRow );
449 
450  switch( aCol )
451  {
452  case FDC_SHOWN: return field.IsVisible();
453  case FDC_ITALIC: return field.IsItalic();
454  case FDC_BOLD: return field.IsBold();
455  default:
456  wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a bool value" ), aCol ) );
457  return false;
458  }
459 }
int GetNumberRows() override
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200

◆ initGrid()

template<class T >
void FIELDS_GRID_TABLE< T >::initGrid ( DIALOG_SHIM aDialog,
WX_GRID aGrid 
)
protected

Definition at line 92 of file fields_grid_table.cpp.

93 {
94  // Build the various grid cell attributes.
95  // NOTE: validators and cellAttrs are member variables to get the destruction order
96  // right. wxGrid is VERY cranky about this.
97 
98  m_readOnlyAttr = new wxGridCellAttr;
99  m_readOnlyAttr->SetReadOnly( true );
100 
101  m_fieldNameAttr = new wxGridCellAttr;
102  GRID_CELL_TEXT_EDITOR* nameEditor = new GRID_CELL_TEXT_EDITOR();
103  nameEditor->SetValidator( m_fieldNameValidator );
104  m_fieldNameAttr->SetEditor( nameEditor );
105 
106  m_referenceAttr = new wxGridCellAttr;
107  GRID_CELL_TEXT_EDITOR* referenceEditor = new GRID_CELL_TEXT_EDITOR();
108  referenceEditor->SetValidator( m_referenceValidator );
109  m_referenceAttr->SetEditor( referenceEditor );
110 
111  m_valueAttr = new wxGridCellAttr;
112  GRID_CELL_TEXT_EDITOR* valueEditor = new GRID_CELL_TEXT_EDITOR();
113  valueEditor->SetValidator( m_valueValidator );
114  m_valueAttr->SetEditor( valueEditor );
115 
116  m_footprintAttr = new wxGridCellAttr;
118  fpIdEditor->SetValidator( m_libIdValidator );
119  m_footprintAttr->SetEditor( fpIdEditor );
120 
121  m_urlAttr = new wxGridCellAttr;
122  GRID_CELL_URL_EDITOR* urlEditor = new GRID_CELL_URL_EDITOR( aDialog );
123  urlEditor->SetValidator( m_urlValidator );
124  m_urlAttr->SetEditor( urlEditor );
125 
126  m_nonUrlAttr = new wxGridCellAttr;
127  GRID_CELL_TEXT_EDITOR* nonUrlEditor = new GRID_CELL_TEXT_EDITOR();
128  nonUrlEditor->SetValidator( m_nonUrlValidator );
129  m_nonUrlAttr->SetEditor( nonUrlEditor );
130 
132  m_filepathAttr = new wxGridCellAttr;
133 
134  // Create a wild card using wxFileDialog syntax.
135  wxString wildCard( _( "Schematic Files" ) );
136  std::vector<std::string> exts;
137  exts.push_back( KiCadSchematicFileExtension );
138  wildCard += AddFileExtListToFilter( exts );
139 
140  auto filepathEditor = new GRID_CELL_PATH_EDITOR( aDialog, aGrid, &m_curdir, wildCard );
141  filepathEditor->SetValidator( m_filepathValidator );
142  m_filepathAttr->SetEditor( filepathEditor );
143 
144  m_boolAttr = new wxGridCellAttr;
145  m_boolAttr->SetRenderer( new wxGridCellBoolRenderer() );
146  m_boolAttr->SetEditor( new wxGridCellBoolEditor() );
147  m_boolAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
148 
149  wxArrayString vAlignNames;
150  vAlignNames.Add( _( "Top" ) );
151  vAlignNames.Add( _( "Center" ) );
152  vAlignNames.Add( _( "Bottom" ) );
153  m_vAlignAttr = new wxGridCellAttr;
154  m_vAlignAttr->SetEditor( new wxGridCellChoiceEditor( vAlignNames ) );
155  m_vAlignAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_BOTTOM );
156 
157  wxArrayString hAlignNames;
158  hAlignNames.Add( _( "Left" ) );
159  hAlignNames.Add(_( "Center" ) );
160  hAlignNames.Add(_( "Right" ) );
161  m_hAlignAttr = new wxGridCellAttr;
162  m_hAlignAttr->SetEditor( new wxGridCellChoiceEditor( hAlignNames ) );
163  m_hAlignAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_BOTTOM );
164 
165  wxArrayString orientationNames;
166  orientationNames.Add( _( "Horizontal" ) );
167  orientationNames.Add(_( "Vertical" ) );
168  m_orientationAttr = new wxGridCellAttr;
169  m_orientationAttr->SetEditor( new wxGridCellChoiceEditor( orientationNames ) );
170  m_orientationAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_BOTTOM );
171 }
wxGridCellAttr * m_referenceAttr
SCH_BASE_FRAME * m_frame
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:122
This class works around a bug in wxGrid where the first keystroke doesn't get sent through the valida...
Definition: validators.h:44
wxGridCellAttr * m_readOnlyAttr
wxGridCellAttr * m_filepathAttr
wxGridCellAttr * m_hAlignAttr
SCH_FIELD_VALIDATOR m_referenceValidator
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
SCH_FIELD_VALIDATOR m_fieldNameValidator
wxGridCellAttr * m_boolAttr
#define _(s)
Editor for wxGrid cells that adds a file/folder browser to the grid input field.
virtual void SetValidator(const wxValidator &validator) override
Definition: validators.cpp:46
wxGridCellAttr * m_fieldNameAttr
wxGridCellAttr * m_urlAttr
SCH_FIELD_VALIDATOR m_valueValidator
wxGridCellAttr * m_vAlignAttr
wxGridCellAttr * m_orientationAttr
SCH_FIELD_VALIDATOR m_filepathValidator
wxGridCellAttr * m_valueAttr
const std::string KiCadSchematicFileExtension
LIB_ID_VALIDATOR m_libIdValidator
SCH_FIELD_VALIDATOR m_urlValidator
wxGridCellAttr * m_nonUrlAttr
wxGridCellAttr * m_footprintAttr
wxString AddFileExtListToFilter(const std::vector< std::string > &aExts)
Build the wildcard extension file dialog wildcard filter to add to the base message dialog.
SCH_FIELD_VALIDATOR m_nonUrlValidator

Referenced by FIELDS_GRID_TABLE< SCH_FIELD >::FIELDS_GRID_TABLE().

◆ IsEmptyCell()

template<class T>
bool FIELDS_GRID_TABLE< T >::IsEmptyCell ( int  row,
int  col 
)
inlineoverride

Definition at line 86 of file fields_grid_table.h.

87  {
88  return false; // don't allow adjacent cell overflow, even if we are actually empty
89  }

◆ SetValue()

template<class T >
void FIELDS_GRID_TABLE< T >::SetValue ( int  aRow,
int  aCol,
const wxString &  aValue 
)
override

Definition at line 463 of file fields_grid_table.cpp.

464 {
465  wxCHECK( aRow < GetNumberRows(), /*void*/ );
466  T& field = this->at( (size_t) aRow );
467  wxPoint pos;
468 
469  switch( aCol )
470  {
471  case FDC_NAME:
472  field.SetName( aValue );
473  break;
474 
475  case FDC_VALUE:
476  {
477  wxString value( aValue );
478 
479  if( m_parentType == SCH_SHEET_T && aRow == SHEETFILENAME )
480  {
481  wxFileName fn( value );
482 
483  // It's annoying to throw up nag dialogs when the extension isn't right. Just
484  // fix it.
485  if( fn.GetExt().CmpNoCase( KiCadSchematicFileExtension ) != 0 )
486  {
487  fn.SetExt( KiCadSchematicFileExtension );
488  value = fn.GetFullPath();
489  }
490  }
491  else if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) && aRow == VALUE_FIELD )
492  {
493  value = EscapeString( value, CTX_LIBID );
494  }
495 
496  field.SetText( value );
497  }
498  break;
499 
500  case FDC_SHOWN:
501  field.SetVisible( BoolFromString( aValue ) );
502  break;
503 
504  case FDC_H_ALIGN:
505  if( aValue == _( "Left" ) )
506  field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
507  else if( aValue == _( "Center" ) )
508  field.SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
509  else if( aValue == _( "Right" ) )
510  field.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
511  else
512  wxFAIL_MSG( wxT( "unknown horizontal alignment: " ) + aValue );
513  break;
514 
515  case FDC_V_ALIGN:
516  if( aValue == _( "Top" ) )
517  field.SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
518  else if( aValue == _( "Center" ) )
519  field.SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
520  else if( aValue == _( "Bottom" ) )
521  field.SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
522  else
523  wxFAIL_MSG( wxT( "unknown vertical alignment: " ) + aValue);
524  break;
525 
526  case FDC_ITALIC:
527  field.SetItalic( BoolFromString( aValue ) );
528  break;
529 
530  case FDC_BOLD:
531  field.SetBold( BoolFromString( aValue ) );
532  break;
533 
534  case FDC_TEXT_SIZE:
535  field.SetTextSize( wxSize( ValueFromString( m_userUnits, aValue ),
536  ValueFromString( m_userUnits, aValue ) ) );
537  break;
538 
539  case FDC_ORIENTATION:
540  if( aValue == _( "Horizontal" ) )
541  field.SetTextAngle( TEXT_ANGLE_HORIZ );
542  else if( aValue == _( "Vertical" ) )
543  field.SetTextAngle( TEXT_ANGLE_VERT );
544  else
545  wxFAIL_MSG( wxT( "unknown orientation: " ) + aValue );
546  break;
547 
548  case FDC_POSX:
549  case FDC_POSY:
550  pos = field.GetTextPos();
551  if( aCol == FDC_POSX )
552  pos.x = ValueFromString( m_userUnits, aValue );
553  else
554  pos.y = ValueFromString( m_userUnits, aValue );
555  field.SetTextPos( pos );
556  break;
557 
558  default:
559  wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a string value" ), aCol ) );
560  break;
561  }
562 
563  GetView()->Refresh();
564 }
bool BoolFromString(wxString aValue) const
#define TEXT_ANGLE_HORIZ
Frequent text rotations, used with {Set,Get}TextAngle(), in 0.1 degrees for now, hoping to migrate to...
Definition: eda_text.h:50
int GetNumberRows() override
SCH_BASE_FRAME * m_frame
Field Value of part, i.e. "3.3K".
long long int ValueFromString(EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType)
Function ValueFromString converts aTextValue in aUnits to internal units used by the application.
Definition: base_units.cpp:416
#define _(s)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
bool IsType(FRAME_T aType) const
const std::string KiCadSchematicFileExtension
#define TEXT_ANGLE_VERT
Definition: eda_text.h:51
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...

◆ SetValueAsBool()

template<class T >
void FIELDS_GRID_TABLE< T >::SetValueAsBool ( int  aRow,
int  aCol,
bool  aValue 
)
override

Definition at line 568 of file fields_grid_table.cpp.

569 {
570  wxCHECK( aRow < GetNumberRows(), /*void*/ );
571  T& field = this->at( (size_t) aRow );
572 
573  switch( aCol )
574  {
575  case FDC_SHOWN:
576  field.SetVisible( aValue );
577  break;
578  case FDC_ITALIC:
579  field.SetItalic( aValue );
580  break;
581  case FDC_BOLD:
582  field.SetBold( aValue );
583  break;
584  default:
585  wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a bool value" ), aCol ) );
586  break;
587  }
588 }
int GetNumberRows() override
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200

◆ StringFromBool()

template<class T >
wxString FIELDS_GRID_TABLE< T >::StringFromBool ( bool  aValue) const

Definition at line 642 of file fields_grid_table.cpp.

643 {
644  if( aValue )
645  return wxT( "1" );
646  else
647  return wxT( "0" );
648 }

Member Data Documentation

◆ m_boolAttr

template<class T>
wxGridCellAttr* FIELDS_GRID_TABLE< T >::m_boolAttr
private

Definition at line 132 of file fields_grid_table.h.

◆ m_curdir

template<class T>
wxString FIELDS_GRID_TABLE< T >::m_curdir
private

Definition at line 114 of file fields_grid_table.h.

◆ m_fieldNameAttr

template<class T>
wxGridCellAttr* FIELDS_GRID_TABLE< T >::m_fieldNameAttr
private

Definition at line 125 of file fields_grid_table.h.

◆ m_fieldNameValidator

template<class T>
SCH_FIELD_VALIDATOR FIELDS_GRID_TABLE< T >::m_fieldNameValidator
private

Definition at line 116 of file fields_grid_table.h.

◆ m_filepathAttr

template<class T>
wxGridCellAttr* FIELDS_GRID_TABLE< T >::m_filepathAttr
private

Definition at line 131 of file fields_grid_table.h.

◆ m_filepathValidator

template<class T>
SCH_FIELD_VALIDATOR FIELDS_GRID_TABLE< T >::m_filepathValidator
private

Definition at line 122 of file fields_grid_table.h.

◆ m_footprintAttr

template<class T>
wxGridCellAttr* FIELDS_GRID_TABLE< T >::m_footprintAttr
private

Definition at line 128 of file fields_grid_table.h.

◆ m_frame

template<class T>
SCH_BASE_FRAME* FIELDS_GRID_TABLE< T >::m_frame
private

Definition at line 108 of file fields_grid_table.h.

◆ m_grid

template<class T>
WX_GRID* FIELDS_GRID_TABLE< T >::m_grid
private

Definition at line 110 of file fields_grid_table.h.

◆ m_hAlignAttr

template<class T>
wxGridCellAttr* FIELDS_GRID_TABLE< T >::m_hAlignAttr
private

Definition at line 134 of file fields_grid_table.h.

◆ m_libIdValidator

template<class T>
LIB_ID_VALIDATOR FIELDS_GRID_TABLE< T >::m_libIdValidator
private

Definition at line 119 of file fields_grid_table.h.

◆ m_mandatoryFieldCount

template<class T>
int FIELDS_GRID_TABLE< T >::m_mandatoryFieldCount
private

Definition at line 112 of file fields_grid_table.h.

◆ m_nonUrlAttr

template<class T>
wxGridCellAttr* FIELDS_GRID_TABLE< T >::m_nonUrlAttr
private

Definition at line 130 of file fields_grid_table.h.

◆ m_nonUrlValidator

template<class T>
SCH_FIELD_VALIDATOR FIELDS_GRID_TABLE< T >::m_nonUrlValidator
private

Definition at line 121 of file fields_grid_table.h.

◆ m_orientationAttr

template<class T>
wxGridCellAttr* FIELDS_GRID_TABLE< T >::m_orientationAttr
private

Definition at line 135 of file fields_grid_table.h.

◆ m_parentType

template<class T>
KICAD_T FIELDS_GRID_TABLE< T >::m_parentType
private

Definition at line 111 of file fields_grid_table.h.

◆ m_part

template<class T>
LIB_SYMBOL* FIELDS_GRID_TABLE< T >::m_part
private

Definition at line 113 of file fields_grid_table.h.

◆ m_readOnlyAttr

template<class T>
wxGridCellAttr* FIELDS_GRID_TABLE< T >::m_readOnlyAttr
private

Definition at line 124 of file fields_grid_table.h.

◆ m_referenceAttr

template<class T>
wxGridCellAttr* FIELDS_GRID_TABLE< T >::m_referenceAttr
private

Definition at line 126 of file fields_grid_table.h.

◆ m_referenceValidator

template<class T>
SCH_FIELD_VALIDATOR FIELDS_GRID_TABLE< T >::m_referenceValidator
private

Definition at line 117 of file fields_grid_table.h.

◆ m_urlAttr

template<class T>
wxGridCellAttr* FIELDS_GRID_TABLE< T >::m_urlAttr
private

Definition at line 129 of file fields_grid_table.h.

◆ m_urlValidator

template<class T>
SCH_FIELD_VALIDATOR FIELDS_GRID_TABLE< T >::m_urlValidator
private

Definition at line 120 of file fields_grid_table.h.

◆ m_userUnits

template<class T>
EDA_UNITS FIELDS_GRID_TABLE< T >::m_userUnits
private

Definition at line 109 of file fields_grid_table.h.

◆ m_vAlignAttr

template<class T>
wxGridCellAttr* FIELDS_GRID_TABLE< T >::m_vAlignAttr
private

Definition at line 133 of file fields_grid_table.h.

◆ m_valueAttr

template<class T>
wxGridCellAttr* FIELDS_GRID_TABLE< T >::m_valueAttr
private

Definition at line 127 of file fields_grid_table.h.

◆ m_valueValidator

template<class T>
SCH_FIELD_VALIDATOR FIELDS_GRID_TABLE< T >::m_valueValidator
private

Definition at line 118 of file fields_grid_table.h.


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