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:132
#define VALUE
SCH_FIELD_VALIDATOR m_referenceValidator
SCH_FIELD_VALIDATOR m_fieldNameValidator
#define FIELD_NAME
void initGrid(DIALOG_SHIM *aDialog)
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
Field Reference of part, i.e. "IC21".
EDA_UNITS GetUserUnits() const
Definition: dialog_shim.h:132
#define VALUE
SCH_FIELD_VALIDATOR m_referenceValidator
SCH_FIELD_VALIDATOR m_fieldNameValidator
#define FIELD_NAME
void initGrid(DIALOG_SHIM *aDialog)
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 166 of file fields_grid_table.cpp.

167 {
168  m_readOnlyAttr->DecRef();
169  m_fieldNameAttr->DecRef();
170  m_boolAttr->DecRef();
171  m_referenceAttr->DecRef();
172  m_valueAttr->DecRef();
173  m_footprintAttr->DecRef();
174  m_urlAttr->DecRef();
175  m_nonUrlAttr->DecRef();
176  m_filepathAttr->DecRef();
177  m_vAlignAttr->DecRef();
178  m_hAlignAttr->DecRef();
179  m_orientationAttr->DecRef();
180 }
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 707 of file fields_grid_table.cpp.

708 {
709  if( aValue == "1" )
710  {
711  return true;
712  }
713  else if( aValue == "0" )
714  {
715  return false;
716  }
717  else
718  {
719  wxFAIL_MSG( wxString::Format( "string \"%s\" can't be converted to boolean "
720  "correctly, it will have been perceived as FALSE", aValue ) );
721  return false;
722  }
723 }
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:205

◆ CanGetValueAs()

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

Definition at line 205 of file fields_grid_table.cpp.

206 {
207  switch( aCol )
208  {
209  case FDC_NAME:
210  case FDC_VALUE:
211  case FDC_H_ALIGN:
212  case FDC_V_ALIGN:
213  case FDC_TEXT_SIZE:
214  case FDC_ORIENTATION:
215  case FDC_POSX:
216  case FDC_POSY:
217  return aTypeName == wxGRID_VALUE_STRING;
218 
219  case FDC_SHOWN:
220  case FDC_ITALIC:
221  case FDC_BOLD:
222  return aTypeName == wxGRID_VALUE_BOOL;
223 
224  default:
225  wxFAIL;
226  return false;
227  }
228 }

◆ CanSetValueAs()

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

Definition at line 232 of file fields_grid_table.cpp.

233 {
234  return CanGetValueAs( aRow, aCol, aTypeName );
235 }
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 239 of file fields_grid_table.cpp.

240 {
241  wxGridCellAttr* tmp;
242 
243  // Only the VALUE and DATASHEET fields can be edited for inherited symbols.
244  bool rowIsReadOnly = m_part && m_part->IsAlias() && ( aRow == REFERENCE || aRow == FOOTPRINT );
245 
246  switch( aCol )
247  {
248  case FDC_NAME:
249  if( aRow < m_mandatoryFieldCount || rowIsReadOnly )
250  {
251  tmp = m_fieldNameAttr->Clone();
252  tmp->SetReadOnly( true );
253  tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
254  return tmp;
255  }
256  else
257  {
258  m_fieldNameAttr->IncRef();
259  return m_fieldNameAttr;
260  }
261 
262  case FDC_VALUE:
263  if( m_parentType == SCH_COMPONENT_T && aRow == REFERENCE )
264  {
265  if( rowIsReadOnly )
266  {
267  tmp = m_referenceAttr->Clone();
268  tmp->SetReadOnly( true );
269  tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
270  return tmp;
271  }
272  else
273  {
274  m_referenceAttr->IncRef();
275  return m_referenceAttr;
276  }
277  }
278  else if( m_parentType == SCH_COMPONENT_T && aRow == VALUE )
279  {
280  // For power symbols, the value is not editable, because value and pin name must
281  // be the same and can be edited only in library editor.
283  || rowIsReadOnly )
284  {
285  tmp = m_readOnlyAttr->Clone();
286  tmp->SetReadOnly( true );
287  tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
288  return tmp;
289  }
290  else
291  {
292  m_valueAttr->IncRef();
293  return m_valueAttr;
294  }
295  }
296  else if( m_parentType == SCH_COMPONENT_T && aRow == FOOTPRINT )
297  {
298  if( rowIsReadOnly )
299  {
300  tmp = m_footprintAttr->Clone();
301  tmp->SetReadOnly( true );
302  tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
303  return tmp;
304  }
305  else
306  {
307  m_footprintAttr->IncRef();
308  return m_footprintAttr;
309  }
310  }
311  else if( m_parentType == SCH_COMPONENT_T && aRow == DATASHEET )
312  {
313  m_urlAttr->IncRef();
314  return m_urlAttr;
315  }
316  else if( m_parentType == SCH_SHEET_T && aRow == SHEETFILENAME )
317  {
318  m_filepathAttr->IncRef();
319  return m_filepathAttr;
320  }
321  else
322  {
323  wxString fieldname = GetValue( aRow, FDC_NAME );
324  const TEMPLATE_FIELDNAME* templateFn = m_frame->GetTemplateFieldName( fieldname );
325 
326  if( templateFn && templateFn->m_URL )
327  {
328  if( rowIsReadOnly )
329  {
330  tmp = m_urlAttr->Clone();
331  tmp->SetReadOnly( true );
332  tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
333  return tmp;
334  }
335  else
336  {
337  m_urlAttr->IncRef();
338  return m_urlAttr;
339  }
340  }
341  else
342  {
343  if( rowIsReadOnly )
344  {
345  tmp = m_nonUrlAttr->Clone();
346  tmp->SetReadOnly( true );
347  tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
348  return tmp;
349  }
350  else
351  {
352  m_nonUrlAttr->IncRef();
353  return m_nonUrlAttr;
354  }
355  }
356  }
357 
358  return nullptr;
359 
360  case FDC_TEXT_SIZE:
361  case FDC_POSX:
362  case FDC_POSY:
363  if( rowIsReadOnly )
364  {
365  tmp = m_readOnlyAttr->Clone();
366  tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
367  return tmp;
368  }
369  else
370  {
371  return nullptr;
372  }
373 
374  case FDC_H_ALIGN:
375  if( rowIsReadOnly )
376  {
377  tmp = m_hAlignAttr->Clone();
378  tmp->SetReadOnly( true );
379  tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
380  return tmp;
381  }
382  else
383  {
384  m_hAlignAttr->IncRef();
385  return m_hAlignAttr;
386  }
387 
388  case FDC_V_ALIGN:
389  if( rowIsReadOnly )
390  {
391  tmp = m_vAlignAttr->Clone();
392  tmp->SetReadOnly( true );
393  tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
394  return tmp;
395  }
396  else
397  {
398  m_vAlignAttr->IncRef();
399  return m_vAlignAttr;
400  }
401 
402  case FDC_ORIENTATION:
403  if( rowIsReadOnly )
404  {
405  tmp = m_orientationAttr->Clone();
406  tmp->SetReadOnly( true );
407  tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
408  return tmp;
409  }
410  else
411  {
412  m_orientationAttr->IncRef();
413  return m_orientationAttr;
414  }
415 
416  case FDC_SHOWN:
417  case FDC_ITALIC:
418  case FDC_BOLD:
419  if( rowIsReadOnly )
420  {
421  tmp = m_boolAttr->Clone();
422  tmp->SetReadOnly( true );
423  tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
424  return tmp;
425  }
426  else
427  {
428  m_boolAttr->IncRef();
429  return m_boolAttr;
430  }
431 
432  default:
433  wxFAIL;
434  return nullptr;
435  }
436 }
name of datasheet
wxGridCellAttr * m_referenceAttr
SCH_BASE_FRAME * m_frame
Field Reference of part, i.e. "IC21".
wxGridCellAttr * m_readOnlyAttr
wxGridCellAttr * m_filepathAttr
#define VALUE
wxGridCellAttr * m_hAlignAttr
wxString GetValue(int aRow, int aCol) override
wxGridCellAttr * m_boolAttr
wxGridCellAttr * m_fieldNameAttr
wxGridCellAttr * m_urlAttr
bool IsPower() const
bool IsType(FRAME_T aType) const
wxGridCellAttr * m_vAlignAttr
wxGridCellAttr * m_orientationAttr
wxGridCellAttr * m_valueAttr
bool IsAlias() const
Struct TEMPLATE_FIELDNAME holds a name of a component's field, field value, and default visibility.
wxGridCellAttr * m_nonUrlAttr
const TEMPLATE_FIELDNAME * GetTemplateFieldName(const wxString &aName)
Search for aName in the the template field name list.
wxGridCellAttr * m_footprintAttr

◆ GetColLabelValue()

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

Definition at line 184 of file fields_grid_table.cpp.

185 {
186  switch( aCol )
187  {
188  case FDC_NAME: return _( "Name" );
189  case FDC_VALUE: return _( "Value" );
190  case FDC_SHOWN: return _( "Show" );
191  case FDC_H_ALIGN: return _( "H Align" );
192  case FDC_V_ALIGN: return _( "V Align" );
193  case FDC_ITALIC: return _( "Italic" );
194  case FDC_BOLD: return _( "Bold" );
195  case FDC_TEXT_SIZE: return _( "Text Size" );
196  case FDC_ORIENTATION: return _( "Orientation" );
197  case FDC_POSX: return _( "X Position" );
198  case FDC_POSY: return _( "Y Position" );
199  default: wxFAIL; return wxEmptyString;
200  }
201 }
#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 440 of file fields_grid_table.cpp.

441 {
442  wxCHECK( aRow < GetNumberRows(), wxEmptyString );
443  const T& field = this->at( (size_t) aRow );
444 
445  switch( aCol )
446  {
447  case FDC_NAME:
448  // Use default field name for mandatory fields, because they are translated
449  // according to the current locale
450  if( aRow < m_mandatoryFieldCount )
451  {
454  else if( m_parentType == SCH_SHEET_T )
455  return SCH_SHEET::GetDefaultFieldName( aRow );
456  }
457 
458  return field.GetName( false );
459 
460  case FDC_VALUE:
461  return field.GetText();
462 
463  case FDC_SHOWN:
464  return StringFromBool( field.IsVisible() );
465 
466  case FDC_H_ALIGN:
467  switch ( field.GetHorizJustify() )
468  {
469  case GR_TEXT_HJUSTIFY_LEFT: return _( "Left" );
470  case GR_TEXT_HJUSTIFY_CENTER: return _( "Center" );
471  case GR_TEXT_HJUSTIFY_RIGHT: return _( "Right" );
472  }
473 
474  break;
475 
476  case FDC_V_ALIGN:
477  switch ( field.GetVertJustify() )
478  {
479  case GR_TEXT_VJUSTIFY_TOP: return _( "Top" );
480  case GR_TEXT_VJUSTIFY_CENTER: return _( "Center" );
481  case GR_TEXT_VJUSTIFY_BOTTOM: return _( "Bottom" );
482  }
483 
484  break;
485 
486  case FDC_ITALIC:
487  return StringFromBool( field.IsItalic() );
488 
489  case FDC_BOLD:
490  return StringFromBool( field.IsBold() );
491 
492  case FDC_TEXT_SIZE:
493  return StringFromValue( m_userUnits, field.GetTextSize().GetHeight(), true, true );
494 
495  case FDC_ORIENTATION:
496  switch ( (int) field.GetTextAngle() )
497  {
498  case TEXT_ANGLE_HORIZ: return _( "Horizontal" );
499  case TEXT_ANGLE_VERT: return _( "Vertical" );
500  }
501 
502  break;
503 
504  case FDC_POSX:
505  return StringFromValue( m_userUnits, field.GetTextPos().x, true );
506 
507  case FDC_POSY:
508  return StringFromValue( m_userUnits, field.GetTextPos().y, true );
509 
510  default:
511  // we can't assert here because wxWidgets sometimes calls this without checking
512  // the column type when trying to see if there's an overflow
513  break;
514  }
515 
516  return wxT( "bad wxWidgets!" );
517 }
#define TEXT_ANGLE_HORIZ
int GetNumberRows() override
#define TEXT_ANGLE_VERT
wxString StringFromValue(EDA_UNITS aUnits, double aValue, bool aAddUnitSymbol, bool aUseMils)
Function StringFromValue returns the string from aValue according to units (inch, mm ....
Definition: base_units.cpp:234
static const wxString GetDefaultFieldName(int aFieldNdx)
Function GetDefaultFieldName returns a default symbol field name for field aFieldNdx for all componen...
static const wxString GetDefaultFieldName(int aFieldNdx)
Definition: sch_sheet.cpp:43
#define _(s)
Definition: 3d_actions.cpp:33
wxString StringFromBool(bool aValue)

◆ GetValueAsBool()

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

Definition at line 521 of file fields_grid_table.cpp.

522 {
523  wxCHECK( aRow < GetNumberRows(), false );
524  const T& field = this->at( (size_t) aRow );
525 
526  switch( aCol )
527  {
528  case FDC_SHOWN: return field.IsVisible();
529  case FDC_ITALIC: return field.IsItalic();
530  case FDC_BOLD: return field.IsBold();
531  default:
532  wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a bool value" ), aCol ) );
533  return false;
534  }
535 }
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:205

◆ 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  GRID_CELL_PATH_EDITOR* filepathEditor =
132  filepathEditor->SetValidator( m_filepathValidator );
133  m_filepathAttr->SetEditor( filepathEditor );
134 
135  m_boolAttr = new wxGridCellAttr;
136  m_boolAttr->SetRenderer( new wxGridCellBoolRenderer() );
137  m_boolAttr->SetEditor( new wxGridCellBoolEditor() );
138  m_boolAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_BOTTOM );
139 
140  wxArrayString vAlignNames;
141  vAlignNames.Add( _( "Top" ) );
142  vAlignNames.Add( _( "Center" ) );
143  vAlignNames.Add( _( "Bottom" ) );
144  m_vAlignAttr = new wxGridCellAttr;
145  m_vAlignAttr->SetEditor( new wxGridCellChoiceEditor( vAlignNames ) );
146  m_vAlignAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_BOTTOM );
147 
148  wxArrayString hAlignNames;
149  hAlignNames.Add( _( "Left" ) );
150  hAlignNames.Add(_( "Center" ) );
151  hAlignNames.Add(_( "Right" ) );
152  m_hAlignAttr = new wxGridCellAttr;
153  m_hAlignAttr->SetEditor( new wxGridCellChoiceEditor( hAlignNames ) );
154  m_hAlignAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_BOTTOM );
155 
156  wxArrayString orientationNames;
157  orientationNames.Add( _( "Horizontal" ) );
158  orientationNames.Add(_( "Vertical" ) );
159  m_orientationAttr = new wxGridCellAttr;
160  m_orientationAttr->SetEditor( new wxGridCellChoiceEditor( orientationNames ) );
161  m_orientationAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_BOTTOM );
162 }
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:102
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
const std::string LegacySchematicFileExtension
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
LIB_ID_VALIDATOR m_libIdValidator
SCH_FIELD_VALIDATOR m_urlValidator
wxGridCellAttr * m_nonUrlAttr
wxGridCellAttr * m_footprintAttr
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 539 of file fields_grid_table.cpp.

540 {
541  wxCHECK( aRow < GetNumberRows(), /*void*/ );
542  T& field = this->at( (size_t) aRow );
543  wxPoint pos;
544 
545  switch( aCol )
546  {
547  case FDC_NAME:
548  field.SetName( aValue );
549  break;
550 
551  case FDC_VALUE:
552  field.SetText( aValue );
553  break;
554 
555  case FDC_SHOWN:
556  field.SetVisible( BoolFromString( aValue ) );
557  break;
558 
559  case FDC_H_ALIGN:
560  if( aValue == _( "Left" ) )
561  field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
562  else if( aValue == _( "Center" ) )
563  field.SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
564  else if( aValue == _( "Right" ) )
565  field.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
566  else
567  wxFAIL_MSG( wxT( "unknown horizontal alignment: " ) + aValue );
568  break;
569 
570  case FDC_V_ALIGN:
571  if( aValue == _( "Top" ) )
572  field.SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
573  else if( aValue == _( "Center" ) )
574  field.SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
575  else if( aValue == _( "Bottom" ) )
576  field.SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
577  else
578  wxFAIL_MSG( wxT( "unknown vertical alignment: " ) + aValue);
579  break;
580 
581  case FDC_ITALIC:
582  field.SetItalic( BoolFromString( aValue ) );
583  break;
584 
585  case FDC_BOLD:
586  field.SetBold( BoolFromString( aValue ) );
587  break;
588 
589  case FDC_TEXT_SIZE:
590  field.SetTextSize( wxSize( ValueFromString( m_userUnits, aValue ),
591  ValueFromString( m_userUnits, aValue ) ) );
592  break;
593 
594  case FDC_ORIENTATION:
595  if( aValue == _( "Horizontal" ) )
596  field.SetTextAngle( TEXT_ANGLE_HORIZ );
597  else if( aValue == _( "Vertical" ) )
598  field.SetTextAngle( TEXT_ANGLE_VERT );
599  else
600  wxFAIL_MSG( wxT( "unknown orientation: " ) + aValue );
601  break;
602 
603  case FDC_POSX:
604  case FDC_POSY:
605  pos = field.GetTextPos();
606  if( aCol == FDC_POSX )
607  pos.x = ValueFromString( m_userUnits, aValue );
608  else
609  pos.y = ValueFromString( m_userUnits, aValue );
610  field.SetTextPos( pos );
611  break;
612 
613  default:
614  wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a string value" ), aCol ) );
615  break;
616  }
617 
618  GetView()->Refresh();
619 }
#define TEXT_ANGLE_HORIZ
int GetNumberRows() override
#define TEXT_ANGLE_VERT
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:205
#define _(s)
Definition: 3d_actions.cpp:33
long long int ValueFromString(EDA_UNITS aUnits, const wxString &aTextValue, bool aUseMils)
Function ValueFromString converts aTextValue in aUnits to internal units used by the application.
Definition: base_units.cpp:444

◆ SetValueAsBool()

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

Definition at line 623 of file fields_grid_table.cpp.

624 {
625  wxCHECK( aRow < GetNumberRows(), /*void*/ );
626  T& field = this->at( (size_t) aRow );
627 
628  switch( aCol )
629  {
630  case FDC_SHOWN:
631  field.SetVisible( aValue );
632  break;
633  case FDC_ITALIC:
634  field.SetItalic( aValue );
635  break;
636  case FDC_BOLD:
637  field.SetBold( aValue );
638  break;
639  default:
640  wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a bool value" ), aCol ) );
641  break;
642  }
643 }
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:205

◆ StringFromBool()

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

Definition at line 697 of file fields_grid_table.cpp.

698 {
699  if( aValue )
700  return wxT( "1" );
701  else
702  return wxT( "0" );
703 }

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: