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_PART *aPart)
 
 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_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,
WX_GRID aGrid,
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_grid( aGrid ),
55  m_part( aPart ),
63 {
64  initGrid( aDialog, aGrid );
65 }
Field Reference of part, i.e. "IC21".
#define FIELD_VALUE
SCH_BASE_FRAME * m_frame
EDA_UNITS GetUserUnits() const
Definition: dialog_shim.h:120
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 69 of file fields_grid_table.cpp.

70  :
71  m_frame( aFrame ),
72  m_userUnits( aDialog->GetUserUnits() ),
73  m_grid( aGrid ),
76  m_part( nullptr ),
84 {
85  initGrid( aDialog, aGrid );
86 }
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:120
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 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) const

Definition at line 646 of file fields_grid_table.cpp.

647 {
648  if( aValue == "1" )
649  {
650  return true;
651  }
652  else if( aValue == "0" )
653  {
654  return false;
655  }
656  else
657  {
658  wxFAIL_MSG( wxString::Format( "string \"%s\" can't be converted to boolean "
659  "correctly, it will have been perceived as FALSE", aValue ) );
660  return false;
661  }
662 }
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 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_FIELD )
267  {
268  m_referenceAttr->IncRef();
269  return m_referenceAttr;
270  }
271  else if( m_parentType == SCH_COMPONENT_T && aRow == VALUE_FIELD )
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.
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_FIELD )
289  {
290  m_footprintAttr->IncRef();
291  return m_footprintAttr;
292  }
293  else if( m_parentType == SCH_COMPONENT_T && aRow == DATASHEET_FIELD )
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 
314  const TEMPLATE_FIELDNAME* templateFn =
315  settings ? settings->m_TemplateFieldNames.GetFieldName( fn ) : nullptr;
316 
317  if( templateFn && templateFn->m_URL )
318  {
319  m_urlAttr->IncRef();
320  return m_urlAttr;
321  }
322  else
323  {
324  m_nonUrlAttr->IncRef();
325  return m_nonUrlAttr;
326  }
327  }
328 
329  return nullptr;
330 
331  case FDC_TEXT_SIZE:
332  case FDC_POSX:
333  case FDC_POSY:
334  return nullptr;
335 
336  case FDC_H_ALIGN:
337  m_hAlignAttr->IncRef();
338  return m_hAlignAttr;
339 
340  case FDC_V_ALIGN:
341  m_vAlignAttr->IncRef();
342  return m_vAlignAttr;
343 
344  case FDC_ORIENTATION:
345  m_orientationAttr->IncRef();
346  return m_orientationAttr;
347 
348  case FDC_SHOWN:
349  case FDC_ITALIC:
350  case FDC_BOLD:
351  m_boolAttr->IncRef();
352  return m_boolAttr;
353 
354  default:
355  wxFAIL;
356  return nullptr;
357  }
358 }
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
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:140
const TEMPLATE_FIELDNAME * GetFieldName(const wxString &aName)
Search for aName in the the template field name list.
wxGridCellAttr * m_fieldNameAttr
wxGridCellAttr * m_urlAttr
bool IsPower() const
Definition: lib_symbol.cpp:411
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 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 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 362 of file fields_grid_table.cpp.

363 {
364  wxCHECK( aRow < GetNumberRows(), wxEmptyString );
365  const T& field = this->at( (size_t) aRow );
366 
367  switch( aCol )
368  {
369  case FDC_NAME:
370  // Use default field name for mandatory fields, because they are translated
371  // according to the current locale
372  if( aRow < m_mandatoryFieldCount )
373  {
376  else if( m_parentType == SCH_SHEET_T )
377  return SCH_SHEET::GetDefaultFieldName( aRow );
378  }
379 
380  return field.GetName( false );
381 
382  case FDC_VALUE:
383  return field.GetText();
384 
385  case FDC_SHOWN:
386  return StringFromBool( field.IsVisible() );
387 
388  case FDC_H_ALIGN:
389  switch ( field.GetHorizJustify() )
390  {
391  case GR_TEXT_HJUSTIFY_LEFT: return _( "Left" );
392  case GR_TEXT_HJUSTIFY_CENTER: return _( "Center" );
393  case GR_TEXT_HJUSTIFY_RIGHT: return _( "Right" );
394  }
395 
396  break;
397 
398  case FDC_V_ALIGN:
399  switch ( field.GetVertJustify() )
400  {
401  case GR_TEXT_VJUSTIFY_TOP: return _( "Top" );
402  case GR_TEXT_VJUSTIFY_CENTER: return _( "Center" );
403  case GR_TEXT_VJUSTIFY_BOTTOM: return _( "Bottom" );
404  }
405 
406  break;
407 
408  case FDC_ITALIC:
409  return StringFromBool( field.IsItalic() );
410 
411  case FDC_BOLD:
412  return StringFromBool( field.IsBold() );
413 
414  case FDC_TEXT_SIZE:
415  return StringFromValue( m_userUnits, field.GetTextSize().GetHeight() );
416 
417  case FDC_ORIENTATION:
418  switch ( (int) field.GetTextAngle() )
419  {
420  case TEXT_ANGLE_HORIZ: return _( "Horizontal" );
421  case TEXT_ANGLE_VERT: return _( "Vertical" );
422  }
423 
424  break;
425 
426  case FDC_POSX:
427  return StringFromValue( m_userUnits, field.GetTextPos().x );
428 
429  case FDC_POSY:
430  return StringFromValue( m_userUnits, field.GetTextPos().y );
431 
432  default:
433  // we can't assert here because wxWidgets sometimes calls this without checking
434  // the column type when trying to see if there's an overflow
435  break;
436  }
437 
438  return wxT( "bad wxWidgets!" );
439 }
#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
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.
#define _(s)
Definition: 3d_actions.cpp:33
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:225
#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 443 of file fields_grid_table.cpp.

444 {
445  wxCHECK( aRow < GetNumberRows(), false );
446  const T& field = this->at( (size_t) aRow );
447 
448  switch( aCol )
449  {
450  case FDC_SHOWN: return field.IsVisible();
451  case FDC_ITALIC: return field.IsItalic();
452  case FDC_BOLD: return field.IsBold();
453  default:
454  wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a bool value" ), aCol ) );
455  return false;
456  }
457 }
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 90 of file fields_grid_table.cpp.

91 {
92  // Build the various grid cell attributes.
93  // NOTE: validators and cellAttrs are member variables to get the destruction order
94  // right. wxGrid is VERY cranky about this.
95 
96  m_readOnlyAttr = new wxGridCellAttr;
97  m_readOnlyAttr->SetReadOnly( true );
98 
99  m_fieldNameAttr = new wxGridCellAttr;
100  GRID_CELL_TEXT_EDITOR* nameEditor = new GRID_CELL_TEXT_EDITOR();
101  nameEditor->SetValidator( m_fieldNameValidator );
102  m_fieldNameAttr->SetEditor( nameEditor );
103 
104  m_referenceAttr = new wxGridCellAttr;
105  GRID_CELL_TEXT_EDITOR* referenceEditor = new GRID_CELL_TEXT_EDITOR();
106  referenceEditor->SetValidator( m_referenceValidator );
107  m_referenceAttr->SetEditor( referenceEditor );
108 
109  m_valueAttr = new wxGridCellAttr;
110  GRID_CELL_TEXT_EDITOR* valueEditor = new GRID_CELL_TEXT_EDITOR();
111  valueEditor->SetValidator( m_valueValidator );
112  m_valueAttr->SetEditor( valueEditor );
113 
114  m_footprintAttr = new wxGridCellAttr;
116  fpIdEditor->SetValidator( m_libIdValidator );
117  m_footprintAttr->SetEditor( fpIdEditor );
118 
119  m_urlAttr = new wxGridCellAttr;
120  GRID_CELL_URL_EDITOR* urlEditor = new GRID_CELL_URL_EDITOR( aDialog );
121  urlEditor->SetValidator( m_urlValidator );
122  m_urlAttr->SetEditor( urlEditor );
123 
124  m_nonUrlAttr = new wxGridCellAttr;
125  GRID_CELL_TEXT_EDITOR* nonUrlEditor = new GRID_CELL_TEXT_EDITOR();
126  nonUrlEditor->SetValidator( m_nonUrlValidator );
127  m_nonUrlAttr->SetEditor( nonUrlEditor );
128 
130  m_filepathAttr = new wxGridCellAttr;
131 
132  // Create a wild card using wxFileDialog syntax.
133  wxString wildCard( _( "Schematic Files" ) );
134  std::vector<std::string> exts;
135  exts.push_back( KiCadSchematicFileExtension );
136  wildCard += AddFileExtListToFilter( exts );
137 
138  auto filepathEditor = new GRID_CELL_PATH_EDITOR( aDialog, aGrid, &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
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:123
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
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 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 461 of file fields_grid_table.cpp.

462 {
463  wxCHECK( aRow < GetNumberRows(), /*void*/ );
464  T& field = this->at( (size_t) aRow );
465  wxPoint pos;
466 
467  switch( aCol )
468  {
469  case FDC_NAME:
470  field.SetName( aValue );
471  break;
472 
473  case FDC_VALUE:
474  {
475  wxString value( aValue );
476 
477  if( m_parentType == SCH_SHEET_T && aRow == SHEETFILENAME )
478  {
479  wxFileName fn( value );
480 
481  // It's annoying to throw up nag dialogs when the extension isn't right. Just
482  // fix it.
483  if( fn.GetExt().CmpNoCase( KiCadSchematicFileExtension ) != 0 )
484  {
485  fn.SetExt( KiCadSchematicFileExtension );
486  value = fn.GetFullPath();
487  }
488  }
489 
490  field.SetText( value );
491  }
492  break;
493 
494  case FDC_SHOWN:
495  field.SetVisible( BoolFromString( aValue ) );
496  break;
497 
498  case FDC_H_ALIGN:
499  if( aValue == _( "Left" ) )
500  field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
501  else if( aValue == _( "Center" ) )
502  field.SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
503  else if( aValue == _( "Right" ) )
504  field.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
505  else
506  wxFAIL_MSG( wxT( "unknown horizontal alignment: " ) + aValue );
507  break;
508 
509  case FDC_V_ALIGN:
510  if( aValue == _( "Top" ) )
511  field.SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
512  else if( aValue == _( "Center" ) )
513  field.SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
514  else if( aValue == _( "Bottom" ) )
515  field.SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
516  else
517  wxFAIL_MSG( wxT( "unknown vertical alignment: " ) + aValue);
518  break;
519 
520  case FDC_ITALIC:
521  field.SetItalic( BoolFromString( aValue ) );
522  break;
523 
524  case FDC_BOLD:
525  field.SetBold( BoolFromString( aValue ) );
526  break;
527 
528  case FDC_TEXT_SIZE:
529  field.SetTextSize( wxSize( ValueFromString( m_userUnits, aValue ),
530  ValueFromString( m_userUnits, aValue ) ) );
531  break;
532 
533  case FDC_ORIENTATION:
534  if( aValue == _( "Horizontal" ) )
535  field.SetTextAngle( TEXT_ANGLE_HORIZ );
536  else if( aValue == _( "Vertical" ) )
537  field.SetTextAngle( TEXT_ANGLE_VERT );
538  else
539  wxFAIL_MSG( wxT( "unknown orientation: " ) + aValue );
540  break;
541 
542  case FDC_POSX:
543  case FDC_POSY:
544  pos = field.GetTextPos();
545  if( aCol == FDC_POSX )
546  pos.x = ValueFromString( m_userUnits, aValue );
547  else
548  pos.y = ValueFromString( m_userUnits, aValue );
549  field.SetTextPos( pos );
550  break;
551 
552  default:
553  wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a string value" ), aCol ) );
554  break;
555  }
556 
557  GetView()->Refresh();
558 }
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
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:437
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
#define _(s)
Definition: 3d_actions.cpp:33
const std::string KiCadSchematicFileExtension
#define TEXT_ANGLE_VERT
Definition: eda_text.h:51

◆ SetValueAsBool()

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

Definition at line 562 of file fields_grid_table.cpp.

563 {
564  wxCHECK( aRow < GetNumberRows(), /*void*/ );
565  T& field = this->at( (size_t) aRow );
566 
567  switch( aCol )
568  {
569  case FDC_SHOWN:
570  field.SetVisible( aValue );
571  break;
572  case FDC_ITALIC:
573  field.SetItalic( aValue );
574  break;
575  case FDC_BOLD:
576  field.SetBold( aValue );
577  break;
578  default:
579  wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a bool value" ), aCol ) );
580  break;
581  }
582 }
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 636 of file fields_grid_table.cpp.

637 {
638  if( aValue )
639  return wxT( "1" );
640  else
641  return wxT( "0" );
642 }

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_PART* 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: