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 ()
 
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)
 

Private Attributes

SCH_BASE_FRAMEm_frame
 
EDA_UNITS_T m_userUnits
 
LIB_PARTm_part
 
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
 
wxGridCellAttr * m_readOnlyAttr
 
wxGridCellAttr * m_fieldNameAttr
 
wxGridCellAttr * m_referenceAttr
 
wxGridCellAttr * m_valueAttr
 
wxGridCellAttr * m_footprintAttr
 
wxGridCellAttr * m_urlAttr
 
wxGridCellAttr * m_nonUrlAttr
 
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()

template<class T >
FIELDS_GRID_TABLE< T >::FIELDS_GRID_TABLE ( DIALOG_SHIM aDialog,
SCH_BASE_FRAME aFrame,
LIB_PART aPart 
)

Definition at line 48 of file fields_grid_table.cpp.

49  :
50  m_frame( aFrame ),
51  m_userUnits( aDialog->GetUserUnits() ),
52  m_part( aPart ),
59 {
60  // Build the various grid cell attributes.
61  // NOTE: validators and cellAttrs are member variables to get the destruction order
62  // right. wxGrid is VERY cranky about this.
63 
64  m_readOnlyAttr = new wxGridCellAttr;
65  m_readOnlyAttr->SetReadOnly( true );
66 
67  m_fieldNameAttr = new wxGridCellAttr;
68  GRID_CELL_TEXT_EDITOR* nameEditor = new GRID_CELL_TEXT_EDITOR();
69  nameEditor->SetValidator( m_fieldNameValidator );
70  m_fieldNameAttr->SetEditor( nameEditor );
71 
72  m_referenceAttr = new wxGridCellAttr;
73  GRID_CELL_TEXT_EDITOR* referenceEditor = new GRID_CELL_TEXT_EDITOR();
74  referenceEditor->SetValidator( m_referenceValidator );
75  m_referenceAttr->SetEditor( referenceEditor );
76 
77  m_valueAttr = new wxGridCellAttr;
78  GRID_CELL_TEXT_EDITOR* valueEditor = new GRID_CELL_TEXT_EDITOR();
79  valueEditor->SetValidator( m_valueValidator );
80  m_valueAttr->SetEditor( valueEditor );
81 
82  m_footprintAttr = new wxGridCellAttr;
84  fpIdEditor->SetValidator( m_libIdValidator );
85  m_footprintAttr->SetEditor( fpIdEditor );
86 
87  m_urlAttr = new wxGridCellAttr;
88  GRID_CELL_URL_EDITOR* urlEditor = new GRID_CELL_URL_EDITOR( aDialog );
89  urlEditor->SetValidator( m_urlValidator );
90  m_urlAttr->SetEditor( urlEditor );
91 
92  m_nonUrlAttr = new wxGridCellAttr;
93  GRID_CELL_TEXT_EDITOR* nonUrlEditor = new GRID_CELL_TEXT_EDITOR();
94  nonUrlEditor->SetValidator( m_nonUrlValidator );
95  m_nonUrlAttr->SetEditor( nonUrlEditor );
96 
97  m_boolAttr = new wxGridCellAttr;
98  m_boolAttr->SetRenderer( new wxGridCellBoolRenderer() );
99  m_boolAttr->SetEditor( new wxGridCellBoolEditor() );
100  m_boolAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_BOTTOM );
101 
102  wxArrayString vAlignNames;
103  vAlignNames.Add( _( "Top" ) );
104  vAlignNames.Add( _( "Center" ) );
105  vAlignNames.Add( _( "Bottom" ) );
106  m_vAlignAttr = new wxGridCellAttr;
107  m_vAlignAttr->SetEditor( new wxGridCellChoiceEditor( vAlignNames ) );
108  m_vAlignAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_BOTTOM );
109 
110  wxArrayString hAlignNames;
111  hAlignNames.Add( _( "Left" ) );
112  hAlignNames.Add(_( "Center" ) );
113  hAlignNames.Add(_( "Right" ) );
114  m_hAlignAttr = new wxGridCellAttr;
115  m_hAlignAttr->SetEditor( new wxGridCellChoiceEditor( hAlignNames ) );
116  m_hAlignAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_BOTTOM );
117 
118  wxArrayString orientationNames;
119  orientationNames.Add( _( "Horizontal" ) );
120  orientationNames.Add(_( "Vertical" ) );
121  m_orientationAttr = new wxGridCellAttr;
122  m_orientationAttr->SetEditor( new wxGridCellChoiceEditor( orientationNames ) );
123  m_orientationAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_BOTTOM );
124 }
#define FIELD_VALUE
wxGridCellAttr * m_referenceAttr
SCH_BASE_FRAME * m_frame
Field Reference of part, i.e. "IC21".
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
#define VALUE
wxGridCellAttr * m_hAlignAttr
SCH_FIELD_VALIDATOR m_referenceValidator
SCH_FIELD_VALIDATOR m_fieldNameValidator
wxGridCellAttr * m_boolAttr
#define FIELD_NAME
#define _(s)
virtual void SetValidator(const wxValidator &validator) override
Definition: validators.cpp:46
wxGridCellAttr * m_fieldNameAttr
wxGridCellAttr * m_urlAttr
SCH_FIELD_VALIDATOR m_valueValidator
EDA_UNITS_T GetUserUnits() const
Definition: dialog_shim.h:132
bool IsType(FRAME_T aType) const
wxGridCellAttr * m_vAlignAttr
wxGridCellAttr * m_orientationAttr
wxGridCellAttr * m_valueAttr
LIB_ID_VALIDATOR m_libIdValidator
SCH_FIELD_VALIDATOR m_urlValidator
wxGridCellAttr * m_nonUrlAttr
wxGridCellAttr * m_footprintAttr
SCH_FIELD_VALIDATOR m_nonUrlValidator

◆ ~FIELDS_GRID_TABLE()

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

Definition at line 128 of file fields_grid_table.cpp.

129 {
130  m_readOnlyAttr->DecRef();
131  m_fieldNameAttr->DecRef();
132  m_boolAttr->DecRef();
133  m_referenceAttr->DecRef();
134  m_valueAttr->DecRef();
135  m_footprintAttr->DecRef();
136  m_urlAttr->DecRef();
137  m_nonUrlAttr->DecRef();
138  m_vAlignAttr->DecRef();
139  m_hAlignAttr->DecRef();
140  m_orientationAttr->DecRef();
141 }
wxGridCellAttr * m_referenceAttr
wxGridCellAttr * m_readOnlyAttr
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 658 of file fields_grid_table.cpp.

659 {
660  if( aValue == "1" )
661  {
662  return true;
663  }
664  else if( aValue == "0" )
665  {
666  return false;
667  }
668  else
669  {
670  wxFAIL_MSG( wxString::Format( "string \"%s\" can't be converted to boolean "
671  "correctly, it will have been perceived as FALSE", aValue ) );
672  return false;
673  }
674 }
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 166 of file fields_grid_table.cpp.

167 {
168  switch( aCol )
169  {
170  case FDC_NAME:
171  case FDC_VALUE:
172  case FDC_H_ALIGN:
173  case FDC_V_ALIGN:
174  case FDC_TEXT_SIZE:
175  case FDC_ORIENTATION:
176  case FDC_POSX:
177  case FDC_POSY:
178  return aTypeName == wxGRID_VALUE_STRING;
179 
180  case FDC_SHOWN:
181  case FDC_ITALIC:
182  case FDC_BOLD:
183  return aTypeName == wxGRID_VALUE_BOOL;
184 
185  default:
186  wxFAIL;
187  return false;
188  }
189 }

◆ CanSetValueAs()

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

Definition at line 193 of file fields_grid_table.cpp.

194 {
195  return CanGetValueAs( aRow, aCol, aTypeName );
196 }
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 200 of file fields_grid_table.cpp.

201 {
202  wxGridCellAttr* tmp;
203 
204  // Only the VALUE and DATASHEET fields can be edited for inherited symbols.
205  bool rowIsReadOnly = m_part && m_part->IsAlias() && ( aRow == REFERENCE || aRow == FOOTPRINT );
206 
207  switch( aCol )
208  {
209  case FDC_NAME:
210  if( aRow < MANDATORY_FIELDS || rowIsReadOnly )
211  {
212  tmp = m_fieldNameAttr->Clone();
213  tmp->SetReadOnly( true );
214  tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
215  return tmp;
216  }
217  else
218  {
219  m_fieldNameAttr->IncRef();
220  return m_fieldNameAttr;
221  }
222 
223  case FDC_VALUE:
224  if( aRow == REFERENCE )
225  {
226  if( rowIsReadOnly )
227  {
228  tmp = m_referenceAttr->Clone();
229  tmp->SetReadOnly( true );
230  tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
231  return tmp;
232  }
233  else
234  {
235  m_referenceAttr->IncRef();
236  return m_referenceAttr;
237  }
238  }
239  else if( aRow == VALUE )
240  {
241  // For power symbols, the value is not editable, because value and pin name must
242  // be the same and can be edited only in library editor.
244  || rowIsReadOnly )
245  {
246  tmp = m_readOnlyAttr->Clone();
247  tmp->SetReadOnly( true );
248  tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
249  return tmp;
250  }
251  else
252  {
253  m_valueAttr->IncRef();
254  return m_valueAttr;
255  }
256  }
257  else if( aRow == FOOTPRINT )
258  {
259  if( rowIsReadOnly )
260  {
261  tmp = m_footprintAttr->Clone();
262  tmp->SetReadOnly( true );
263  tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
264  return tmp;
265  }
266  else
267  {
268  m_footprintAttr->IncRef();
269  return m_footprintAttr;
270  }
271  }
272  else if( aRow == DATASHEET )
273  {
274  m_urlAttr->IncRef();
275  return m_urlAttr;
276  }
277  else
278  {
279  wxString fieldname = GetValue( aRow, FDC_NAME );
280  const TEMPLATE_FIELDNAME* templateFn = m_frame->GetTemplateFieldName( fieldname );
281 
282  if( templateFn && templateFn->m_URL )
283  {
284  if( rowIsReadOnly )
285  {
286  tmp = m_urlAttr->Clone();
287  tmp->SetReadOnly( true );
288  tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
289  return tmp;
290  }
291  else
292  {
293  m_urlAttr->IncRef();
294  return m_urlAttr;
295  }
296  }
297  else
298  {
299  if( rowIsReadOnly )
300  {
301  tmp = m_nonUrlAttr->Clone();
302  tmp->SetReadOnly( true );
303  tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
304  return tmp;
305  }
306  else
307  {
308  m_nonUrlAttr->IncRef();
309  return m_nonUrlAttr;
310  }
311  }
312  }
313 
314  return nullptr;
315 
316  case FDC_TEXT_SIZE:
317  case FDC_POSX:
318  case FDC_POSY:
319  if( rowIsReadOnly )
320  {
321  tmp = m_readOnlyAttr->Clone();
322  tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
323  return tmp;
324  }
325  else
326  {
327  return nullptr;
328  }
329 
330  case FDC_H_ALIGN:
331  if( rowIsReadOnly )
332  {
333  tmp = m_hAlignAttr->Clone();
334  tmp->SetReadOnly( true );
335  tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
336  return tmp;
337  }
338  else
339  {
340  m_hAlignAttr->IncRef();
341  return m_hAlignAttr;
342  }
343 
344  case FDC_V_ALIGN:
345  if( rowIsReadOnly )
346  {
347  tmp = m_vAlignAttr->Clone();
348  tmp->SetReadOnly( true );
349  tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
350  return tmp;
351  }
352  else
353  {
354  m_vAlignAttr->IncRef();
355  return m_vAlignAttr;
356  }
357 
358  case FDC_ORIENTATION:
359  if( rowIsReadOnly )
360  {
361  tmp = m_orientationAttr->Clone();
362  tmp->SetReadOnly( true );
363  tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
364  return tmp;
365  }
366  else
367  {
368  m_orientationAttr->IncRef();
369  return m_orientationAttr;
370  }
371 
372  case FDC_SHOWN:
373  case FDC_ITALIC:
374  case FDC_BOLD:
375  if( rowIsReadOnly )
376  {
377  tmp = m_boolAttr->Clone();
378  tmp->SetReadOnly( true );
379  tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
380  return tmp;
381  }
382  else
383  {
384  m_boolAttr->IncRef();
385  return m_boolAttr;
386  }
387 
388  default:
389  wxFAIL;
390  return nullptr;
391  }
392 }
name of datasheet
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
wxGridCellAttr * m_referenceAttr
bool m_URL
If field should have a browse button.
SCH_BASE_FRAME * m_frame
Field Name Module PCB, i.e. "16DIP300".
Field Reference of part, i.e. "IC21".
wxGridCellAttr * m_readOnlyAttr
#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
const TEMPLATE_FIELDNAME * GetTemplateFieldName(const wxString &aName) const
Search for aName in the the template field name list.
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
wxGridCellAttr * m_footprintAttr

◆ GetColLabelValue()

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

Definition at line 145 of file fields_grid_table.cpp.

146 {
147  switch( aCol )
148  {
149  case FDC_NAME: return _( "Name" );
150  case FDC_VALUE: return _( "Value" );
151  case FDC_SHOWN: return _( "Show" );
152  case FDC_H_ALIGN: return _( "H Align" );
153  case FDC_V_ALIGN: return _( "V Align" );
154  case FDC_ITALIC: return _( "Italic" );
155  case FDC_BOLD: return _( "Bold" );
156  case FDC_TEXT_SIZE: return _( "Text Size" );
157  case FDC_ORIENTATION: return _( "Orientation" );
158  case FDC_POSX: return _( "X Position" );
159  case FDC_POSY: return _( "Y Position" );
160  default: wxFAIL; return wxEmptyString;
161  }
162 }
#define _(s)

◆ GetNumberCols()

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

Definition at line 79 of file fields_grid_table.h.

79 { return FDC_COUNT; }

◆ GetNumberRows()

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

Definition at line 78 of file fields_grid_table.h.

78 { 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 396 of file fields_grid_table.cpp.

397 {
398  wxCHECK( aRow < GetNumberRows(), wxEmptyString );
399  const T& field = this->at( (size_t) aRow );
400 
401  switch( aCol )
402  {
403  case FDC_NAME:
404  // Use default field name for mandatory fields, because they are translated
405  // according to the current locale
406  if( aRow < MANDATORY_FIELDS )
408  else
409  return field.GetName( false );
410 
411  case FDC_VALUE:
412  return field.GetText();
413 
414  case FDC_SHOWN:
415  return StringFromBool( field.IsVisible() );
416 
417  case FDC_H_ALIGN:
418  switch ( field.GetHorizJustify() )
419  {
420  case GR_TEXT_HJUSTIFY_LEFT: return _( "Left" );
421  case GR_TEXT_HJUSTIFY_CENTER: return _( "Center" );
422  case GR_TEXT_HJUSTIFY_RIGHT: return _( "Right" );
423  }
424 
425  break;
426 
427  case FDC_V_ALIGN:
428  switch ( field.GetVertJustify() )
429  {
430  case GR_TEXT_VJUSTIFY_TOP: return _( "Top" );
431  case GR_TEXT_VJUSTIFY_CENTER: return _( "Center" );
432  case GR_TEXT_VJUSTIFY_BOTTOM: return _( "Bottom" );
433  }
434 
435  break;
436 
437  case FDC_ITALIC:
438  return StringFromBool( field.IsItalic() );
439 
440  case FDC_BOLD:
441  return StringFromBool( field.IsBold() );
442 
443  case FDC_TEXT_SIZE:
444  return StringFromValue( m_userUnits, field.GetTextSize().GetHeight(), true, true );
445 
446  case FDC_ORIENTATION:
447  switch ( (int) field.GetTextAngle() )
448  {
449  case TEXT_ANGLE_HORIZ: return _( "Horizontal" );
450  case TEXT_ANGLE_VERT: return _( "Vertical" );
451  }
452 
453  break;
454 
455  case FDC_POSX:
456  return StringFromValue( m_userUnits, field.GetTextPos().x, true );
457 
458  case FDC_POSY:
459  return StringFromValue( m_userUnits, field.GetTextPos().y, true );
460 
461  default:
462  // we can't assert here because wxWidgets sometimes calls this without checking
463  // the column type when trying to see if there's an overflow
464  break;
465  }
466 
467  return wxT( "bad wxWidgets!" );
468 }
#define TEXT_ANGLE_HORIZ
int GetNumberRows() override
#define TEXT_ANGLE_VERT
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
static const wxString GetDefaultFieldName(int aFieldNdx)
Function GetDefaultFieldName returns a default symbol field name for field aFieldNdx for all componen...
#define _(s)
wxString StringFromValue(EDA_UNITS_T aUnits, double aValue, bool aAddUnitSymbol, bool aUseMils)
Function StringFromValue returns the string from aValue according to units (inch, mm ....
Definition: base_units.cpp:217
wxString StringFromBool(bool aValue)

◆ GetValueAsBool()

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

Definition at line 472 of file fields_grid_table.cpp.

473 {
474  wxCHECK( aRow < GetNumberRows(), false );
475  const T& field = this->at( (size_t) aRow );
476 
477  switch( aCol )
478  {
479  case FDC_SHOWN: return field.IsVisible();
480  case FDC_ITALIC: return field.IsItalic();
481  case FDC_BOLD: return field.IsBold();
482  default:
483  wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a bool value" ), aCol ) );
484  return false;
485  }
486 }
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

◆ IsEmptyCell()

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

Definition at line 83 of file fields_grid_table.h.

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

◆ SetValue()

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

Definition at line 490 of file fields_grid_table.cpp.

491 {
492  wxCHECK( aRow < GetNumberRows(), /*void*/ );
493  T& field = this->at( (size_t) aRow );
494  wxPoint pos;
495 
496  switch( aCol )
497  {
498  case FDC_NAME:
499  field.SetName( aValue );
500  break;
501 
502  case FDC_VALUE:
503  field.SetText( aValue );
504  break;
505 
506  case FDC_SHOWN:
507  field.SetVisible( BoolFromString( aValue ) );
508  break;
509 
510  case FDC_H_ALIGN:
511  if( aValue == _( "Left" ) )
512  field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
513  else if( aValue == _( "Center" ) )
514  field.SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
515  else if( aValue == _( "Right" ) )
516  field.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
517  else
518  wxFAIL_MSG( wxT( "unknown horizontal alignment: " ) + aValue );
519  break;
520 
521  case FDC_V_ALIGN:
522  if( aValue == _( "Top" ) )
523  field.SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
524  else if( aValue == _( "Center" ) )
525  field.SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
526  else if( aValue == _( "Bottom" ) )
527  field.SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
528  else
529  wxFAIL_MSG( wxT( "unknown vertical alignment: " ) + aValue);
530  break;
531 
532  case FDC_ITALIC:
533  field.SetItalic( BoolFromString( aValue ) );
534  break;
535 
536  case FDC_BOLD:
537  field.SetBold( BoolFromString( aValue ) );
538  break;
539 
540  case FDC_TEXT_SIZE:
541  field.SetTextSize( wxSize( ValueFromString( m_userUnits, aValue ),
542  ValueFromString( m_userUnits, aValue ) ) );
543  break;
544 
545  case FDC_ORIENTATION:
546  if( aValue == _( "Horizontal" ) )
547  field.SetTextAngle( TEXT_ANGLE_HORIZ );
548  else if( aValue == _( "Vertical" ) )
549  field.SetTextAngle( TEXT_ANGLE_VERT );
550  else
551  wxFAIL_MSG( wxT( "unknown orientation: " ) + aValue );
552  break;
553 
554  case FDC_POSX:
555  case FDC_POSY:
556  pos = field.GetTextPos();
557  if( aCol == FDC_POSX )
558  pos.x = ValueFromString( m_userUnits, aValue );
559  else
560  pos.y = ValueFromString( m_userUnits, aValue );
561  field.SetTextPos( pos );
562  break;
563 
564  default:
565  wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a string value" ), aCol ) );
566  break;
567  }
568 
569  GetView()->Refresh();
570 }
#define TEXT_ANGLE_HORIZ
int GetNumberRows() override
#define TEXT_ANGLE_VERT
bool BoolFromString(wxString aValue)
#define _(s)
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
long long int ValueFromString(EDA_UNITS_T aUnits, const wxString &aTextValue, bool aUseMils)
Function ValueFromString converts aTextValue in aUnits to internal units used by the application.
Definition: base_units.cpp:427

◆ SetValueAsBool()

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

Definition at line 574 of file fields_grid_table.cpp.

575 {
576  wxCHECK( aRow < GetNumberRows(), /*void*/ );
577  T& field = this->at( (size_t) aRow );
578 
579  switch( aCol )
580  {
581  case FDC_SHOWN:
582  field.SetVisible( aValue );
583  break;
584  case FDC_ITALIC:
585  field.SetItalic( aValue );
586  break;
587  case FDC_BOLD:
588  field.SetBold( aValue );
589  break;
590  default:
591  wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a bool value" ), aCol ) );
592  break;
593  }
594 }
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 648 of file fields_grid_table.cpp.

649 {
650  if( aValue )
651  return wxT( "1" );
652  else
653  return wxT( "0" );
654 }

Member Data Documentation

◆ m_boolAttr

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

◆ m_fieldNameAttr

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

◆ m_fieldNameValidator

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

◆ m_footprintAttr

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

◆ m_frame

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

Definition at line 102 of file fields_grid_table.h.

◆ m_hAlignAttr

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

◆ m_libIdValidator

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

◆ m_nonUrlAttr

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

◆ m_nonUrlValidator

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

◆ m_orientationAttr

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

◆ m_part

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

Definition at line 104 of file fields_grid_table.h.

◆ m_readOnlyAttr

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

◆ m_referenceAttr

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

◆ m_referenceValidator

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

◆ m_urlAttr

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

◆ m_urlValidator

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

◆ m_userUnits

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

Definition at line 103 of file fields_grid_table.h.

◆ m_vAlignAttr

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

◆ m_valueAttr

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

◆ m_valueValidator

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

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