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, LIB_PART *aPart)
 
 FIELDS_GRID_TABLE (DIALOG_SHIM *aDialog, SCH_BASE_FRAME *aFrame, 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)
 
bool BoolFromString (wxString aValue)
 

Protected Member Functions

void initGrid (DIALOG_SHIM *aDialog)
 

Private Attributes

SCH_BASE_FRAMEm_frame
 
EDA_UNITS m_userUnits
 
KICAD_T m_parentType
 
int m_mandatoryFieldCount
 
LIB_PARTm_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,
LIB_PART aPart 
)

Definition at line 49 of file fields_grid_table.cpp.

50  :
51  m_frame( aFrame ),
52  m_userUnits( aDialog->GetUserUnits() ),
55  m_part( aPart ),
63 {
64  initGrid( aDialog );
65 }
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
#define FIELD_VALUE
SCH_BASE_FRAME * m_frame
Field Reference of part, i.e. "IC21".
EDA_UNITS GetUserUnits() const
Definition: dialog_shim.h:131
SCH_FIELD_VALIDATOR m_referenceValidator
SCH_FIELD_VALIDATOR m_fieldNameValidator
#define FIELD_NAME
void initGrid(DIALOG_SHIM *aDialog)
Field Value of part, i.e. "3.3K".
SCH_FIELD_VALIDATOR m_valueValidator
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,
SCH_SHEET aSheet 
)

Definition at line 69 of file fields_grid_table.cpp.

70  :
71  m_frame( aFrame ),
72  m_userUnits( aDialog->GetUserUnits() ),
75  m_part( nullptr ),
83 {
84  initGrid( aDialog );
85 }
The first 2 are mandatory, and must be instantiated in SCH_SHEET.
Definition: sch_sheet.h:70
#define FIELD_VALUE
SCH_BASE_FRAME * m_frame
#define SHEETNAME_V
EDA_UNITS GetUserUnits() const
Definition: dialog_shim.h:131
SCH_FIELD_VALIDATOR m_referenceValidator
SCH_FIELD_VALIDATOR m_fieldNameValidator
#define SHEETFILENAME_V
#define FIELD_NAME
void initGrid(DIALOG_SHIM *aDialog)
Field Value of part, i.e. "3.3K".
SCH_FIELD_VALIDATOR m_valueValidator
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 173 of file fields_grid_table.cpp.

174 {
175  m_readOnlyAttr->DecRef();
176  m_fieldNameAttr->DecRef();
177  m_boolAttr->DecRef();
178  m_referenceAttr->DecRef();
179  m_valueAttr->DecRef();
180  m_footprintAttr->DecRef();
181  m_urlAttr->DecRef();
182  m_nonUrlAttr->DecRef();
183  m_filepathAttr->DecRef();
184  m_vAlignAttr->DecRef();
185  m_hAlignAttr->DecRef();
186  m_orientationAttr->DecRef();
187 }
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)

Definition at line 627 of file fields_grid_table.cpp.

628 {
629  if( aValue == "1" )
630  {
631  return true;
632  }
633  else if( aValue == "0" )
634  {
635  return false;
636  }
637  else
638  {
639  wxFAIL_MSG( wxString::Format( "string \"%s\" can't be converted to boolean "
640  "correctly, it will have been perceived as FALSE", aValue ) );
641  return false;
642  }
643 }
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:201

◆ CanGetValueAs()

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

Definition at line 212 of file fields_grid_table.cpp.

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

◆ CanSetValueAs()

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

Definition at line 239 of file fields_grid_table.cpp.

240 {
241  return CanGetValueAs( aRow, aCol, aTypeName );
242 }
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 246 of file fields_grid_table.cpp.

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

◆ GetColLabelValue()

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

Definition at line 191 of file fields_grid_table.cpp.

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

◆ GetNumberCols()

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

Definition at line 80 of file fields_grid_table.h.

80 { return FDC_COUNT; }

◆ GetNumberRows()

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

Definition at line 79 of file fields_grid_table.h.

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

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

◆ GetValue()

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

Definition at line 360 of file fields_grid_table.cpp.

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

◆ GetValueAsBool()

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

Definition at line 441 of file fields_grid_table.cpp.

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

◆ initGrid()

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

Definition at line 89 of file fields_grid_table.cpp.

90 {
91  // Build the various grid cell attributes.
92  // NOTE: validators and cellAttrs are member variables to get the destruction order
93  // right. wxGrid is VERY cranky about this.
94 
95  m_readOnlyAttr = new wxGridCellAttr;
96  m_readOnlyAttr->SetReadOnly( true );
97 
98  m_fieldNameAttr = new wxGridCellAttr;
99  GRID_CELL_TEXT_EDITOR* nameEditor = new GRID_CELL_TEXT_EDITOR();
100  nameEditor->SetValidator( m_fieldNameValidator );
101  m_fieldNameAttr->SetEditor( nameEditor );
102 
103  m_referenceAttr = new wxGridCellAttr;
104  GRID_CELL_TEXT_EDITOR* referenceEditor = new GRID_CELL_TEXT_EDITOR();
105  referenceEditor->SetValidator( m_referenceValidator );
106  m_referenceAttr->SetEditor( referenceEditor );
107 
108  m_valueAttr = new wxGridCellAttr;
109  GRID_CELL_TEXT_EDITOR* valueEditor = new GRID_CELL_TEXT_EDITOR();
110  valueEditor->SetValidator( m_valueValidator );
111  m_valueAttr->SetEditor( valueEditor );
112 
113  m_footprintAttr = new wxGridCellAttr;
115  fpIdEditor->SetValidator( m_libIdValidator );
116  m_footprintAttr->SetEditor( fpIdEditor );
117 
118  m_urlAttr = new wxGridCellAttr;
119  GRID_CELL_URL_EDITOR* urlEditor = new GRID_CELL_URL_EDITOR( aDialog );
120  urlEditor->SetValidator( m_urlValidator );
121  m_urlAttr->SetEditor( urlEditor );
122 
123  m_nonUrlAttr = new wxGridCellAttr;
124  GRID_CELL_TEXT_EDITOR* nonUrlEditor = new GRID_CELL_TEXT_EDITOR();
125  nonUrlEditor->SetValidator( m_nonUrlValidator );
126  m_nonUrlAttr->SetEditor( nonUrlEditor );
127 
129  m_filepathAttr = new wxGridCellAttr;
130 
131  // Create a wild card using wxFileDialog syntax.
132  wxString wildCard( _( "Schematic Files" ) );
133  std::vector<std::string> exts;
134  exts.push_back( KiCadSchematicFileExtension );
135  wildCard += AddFileExtListToFilter( exts );
136 
137  GRID_CELL_PATH_EDITOR* filepathEditor =
138  new GRID_CELL_PATH_EDITOR( aDialog, &m_curdir, wildCard );
139  filepathEditor->SetValidator( m_filepathValidator );
140  m_filepathAttr->SetEditor( filepathEditor );
141 
142  m_boolAttr = new wxGridCellAttr;
143  m_boolAttr->SetRenderer( new wxGridCellBoolRenderer() );
144  m_boolAttr->SetEditor( new wxGridCellBoolEditor() );
145  m_boolAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
146 
147  wxArrayString vAlignNames;
148  vAlignNames.Add( _( "Top" ) );
149  vAlignNames.Add( _( "Center" ) );
150  vAlignNames.Add( _( "Bottom" ) );
151  m_vAlignAttr = new wxGridCellAttr;
152  m_vAlignAttr->SetEditor( new wxGridCellChoiceEditor( vAlignNames ) );
153  m_vAlignAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_BOTTOM );
154 
155  wxArrayString hAlignNames;
156  hAlignNames.Add( _( "Left" ) );
157  hAlignNames.Add(_( "Center" ) );
158  hAlignNames.Add(_( "Right" ) );
159  m_hAlignAttr = new wxGridCellAttr;
160  m_hAlignAttr->SetEditor( new wxGridCellChoiceEditor( hAlignNames ) );
161  m_hAlignAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_BOTTOM );
162 
163  wxArrayString orientationNames;
164  orientationNames.Add( _( "Horizontal" ) );
165  orientationNames.Add(_( "Vertical" ) );
166  m_orientationAttr = new wxGridCellAttr;
167  m_orientationAttr->SetEditor( new wxGridCellChoiceEditor( orientationNames ) );
168  m_orientationAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_BOTTOM );
169 }
wxGridCellAttr * m_referenceAttr
SCH_BASE_FRAME * m_frame
VTBL_ENTRY const wxString GetProjectPath() const
Function GetProjectPath returns the full path of the project.
Definition: project.cpp:124
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
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
SCH_FIELD_VALIDATOR m_fieldNameValidator
wxGridCellAttr * m_boolAttr
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
#define _(s)
Definition: 3d_actions.cpp:33
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 84 of file fields_grid_table.h.

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

◆ SetValue()

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

Definition at line 459 of file fields_grid_table.cpp.

460 {
461  wxCHECK( aRow < GetNumberRows(), /*void*/ );
462  T& field = this->at( (size_t) aRow );
463  wxPoint pos;
464 
465  switch( aCol )
466  {
467  case FDC_NAME:
468  field.SetName( aValue );
469  break;
470 
471  case FDC_VALUE:
472  field.SetText( aValue );
473  break;
474 
475  case FDC_SHOWN:
476  field.SetVisible( BoolFromString( aValue ) );
477  break;
478 
479  case FDC_H_ALIGN:
480  if( aValue == _( "Left" ) )
481  field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
482  else if( aValue == _( "Center" ) )
483  field.SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
484  else if( aValue == _( "Right" ) )
485  field.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
486  else
487  wxFAIL_MSG( wxT( "unknown horizontal alignment: " ) + aValue );
488  break;
489 
490  case FDC_V_ALIGN:
491  if( aValue == _( "Top" ) )
492  field.SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
493  else if( aValue == _( "Center" ) )
494  field.SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
495  else if( aValue == _( "Bottom" ) )
496  field.SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
497  else
498  wxFAIL_MSG( wxT( "unknown vertical alignment: " ) + aValue);
499  break;
500 
501  case FDC_ITALIC:
502  field.SetItalic( BoolFromString( aValue ) );
503  break;
504 
505  case FDC_BOLD:
506  field.SetBold( BoolFromString( aValue ) );
507  break;
508 
509  case FDC_TEXT_SIZE:
510  field.SetTextSize( wxSize( ValueFromString( m_userUnits, aValue, true ),
511  ValueFromString( m_userUnits, aValue, true ) ) );
512  break;
513 
514  case FDC_ORIENTATION:
515  if( aValue == _( "Horizontal" ) )
516  field.SetTextAngle( TEXT_ANGLE_HORIZ );
517  else if( aValue == _( "Vertical" ) )
518  field.SetTextAngle( TEXT_ANGLE_VERT );
519  else
520  wxFAIL_MSG( wxT( "unknown orientation: " ) + aValue );
521  break;
522 
523  case FDC_POSX:
524  case FDC_POSY:
525  pos = field.GetTextPos();
526  if( aCol == FDC_POSX )
527  pos.x = ValueFromString( m_userUnits, aValue );
528  else
529  pos.y = ValueFromString( m_userUnits, aValue );
530  field.SetTextPos( pos );
531  break;
532 
533  default:
534  wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a string value" ), aCol ) );
535  break;
536  }
537 
538  GetView()->Refresh();
539 }
#define TEXT_ANGLE_HORIZ
Frequent text rotations, used with {Set,Get}TextAngle(), in 0.1 degrees for now, hoping to migrate to...
Definition: common.h:185
int GetNumberRows() override
#define TEXT_ANGLE_VERT
Definition: common.h:186
bool BoolFromString(wxString aValue)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:201
#define _(s)
Definition: 3d_actions.cpp:33
long long int ValueFromString(EDA_UNITS aUnits, const wxString &aTextValue, bool aUseMils, EDA_DATA_TYPE aType)
Function ValueFromString converts aTextValue in aUnits to internal units used by the application.
Definition: base_units.cpp:471

◆ SetValueAsBool()

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

Definition at line 543 of file fields_grid_table.cpp.

544 {
545  wxCHECK( aRow < GetNumberRows(), /*void*/ );
546  T& field = this->at( (size_t) aRow );
547 
548  switch( aCol )
549  {
550  case FDC_SHOWN:
551  field.SetVisible( aValue );
552  break;
553  case FDC_ITALIC:
554  field.SetItalic( aValue );
555  break;
556  case FDC_BOLD:
557  field.SetBold( aValue );
558  break;
559  default:
560  wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a bool value" ), aCol ) );
561  break;
562  }
563 }
int GetNumberRows() override
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:201

◆ StringFromBool()

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

Definition at line 617 of file fields_grid_table.cpp.

618 {
619  if( aValue )
620  return wxT( "1" );
621  else
622  return wxT( "0" );
623 }

Member Data Documentation

◆ m_boolAttr

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

Definition at line 129 of file fields_grid_table.h.

◆ m_curdir

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

Definition at line 111 of file fields_grid_table.h.

◆ m_fieldNameAttr

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

Definition at line 122 of file fields_grid_table.h.

◆ m_fieldNameValidator

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

Definition at line 113 of file fields_grid_table.h.

◆ m_filepathAttr

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

Definition at line 128 of file fields_grid_table.h.

◆ m_filepathValidator

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

Definition at line 119 of file fields_grid_table.h.

◆ m_footprintAttr

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

Definition at line 125 of file fields_grid_table.h.

◆ m_frame

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

Definition at line 106 of file fields_grid_table.h.

◆ m_hAlignAttr

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

Definition at line 131 of file fields_grid_table.h.

◆ m_libIdValidator

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

Definition at line 116 of file fields_grid_table.h.

◆ m_mandatoryFieldCount

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

Definition at line 109 of file fields_grid_table.h.

◆ m_nonUrlAttr

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

Definition at line 127 of file fields_grid_table.h.

◆ m_nonUrlValidator

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

Definition at line 118 of file fields_grid_table.h.

◆ m_orientationAttr

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

Definition at line 132 of file fields_grid_table.h.

◆ m_parentType

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

Definition at line 108 of file fields_grid_table.h.

◆ m_part

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

Definition at line 110 of file fields_grid_table.h.

◆ m_readOnlyAttr

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

Definition at line 121 of file fields_grid_table.h.

◆ m_referenceAttr

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

Definition at line 123 of file fields_grid_table.h.

◆ m_referenceValidator

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

Definition at line 114 of file fields_grid_table.h.

◆ m_urlAttr

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

Definition at line 126 of file fields_grid_table.h.

◆ m_urlValidator

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

Definition at line 117 of file fields_grid_table.h.

◆ m_userUnits

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

Definition at line 107 of file fields_grid_table.h.

◆ m_vAlignAttr

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

Definition at line 130 of file fields_grid_table.h.

◆ m_valueAttr

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

Definition at line 124 of file fields_grid_table.h.

◆ m_valueValidator

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

Definition at line 115 of file fields_grid_table.h.


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