KiCad PCB EDA Suite
fields_grid_table.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2018-2021 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 #include <kiway.h>
25 #include <kiway_player.h>
26 #include <dialog_shim.h>
27 #include <fields_grid_table.h>
28 #include <sch_base_frame.h>
29 #include <sch_field.h>
30 #include <sch_validators.h>
31 #include <validators.h>
32 #include <symbol_library.h>
33 #include <template_fieldnames.h>
36 #include <project/project_file.h>
37 #include "eda_doc.h"
38 #include <wx/settings.h>
39 #include <kicad_string.h>
40 
41 
42 enum
43 {
44  MYID_SELECT_FOOTPRINT = 991, // must be within GRID_TRICKS' enum range
46 };
47 
48 
49 template <class T>
51  WX_GRID* aGrid, LIB_SYMBOL* aSymbol ) :
52  m_frame( aFrame ),
53  m_userUnits( aDialog->GetUserUnits() ),
54  m_grid( aGrid ),
55  m_parentType( SCH_SYMBOL_T ),
56  m_mandatoryFieldCount( MANDATORY_FIELDS ),
57  m_part( aSymbol ),
58  m_fieldNameValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_NAME ),
59  m_referenceValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), REFERENCE_FIELD ),
60  m_valueValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), VALUE_FIELD ),
61  m_libIdValidator(),
62  m_urlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ),
63  m_nonUrlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ),
64  m_filepathValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), SHEETFILENAME )
65 {
66  initGrid( aDialog, aGrid );
67 }
68 
69 
70 template <class T>
72  WX_GRID* aGrid, SCH_SHEET* aSheet ) :
73  m_frame( aFrame ),
74  m_userUnits( aDialog->GetUserUnits() ),
75  m_grid( aGrid ),
76  m_parentType( SCH_SHEET_T ),
77  m_mandatoryFieldCount( SHEET_MANDATORY_FIELDS ),
78  m_part( nullptr ),
79  m_fieldNameValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_NAME ),
80  m_referenceValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), SHEETNAME_V ),
81  m_valueValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), VALUE_FIELD ),
82  m_libIdValidator(),
83  m_urlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ),
84  m_nonUrlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ),
85  m_filepathValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), SHEETFILENAME_V )
86 {
87  initGrid( aDialog, aGrid );
88 }
89 
90 
91 template <class T>
93 {
94  // Build the various grid cell attributes.
95  // NOTE: validators and cellAttrs are member variables to get the destruction order
96  // right. wxGrid is VERY cranky about this.
97 
98  m_readOnlyAttr = new wxGridCellAttr;
99  m_readOnlyAttr->SetReadOnly( true );
100 
101  m_fieldNameAttr = new wxGridCellAttr;
102  GRID_CELL_TEXT_EDITOR* nameEditor = new GRID_CELL_TEXT_EDITOR();
103  nameEditor->SetValidator( m_fieldNameValidator );
104  m_fieldNameAttr->SetEditor( nameEditor );
105 
106  m_referenceAttr = new wxGridCellAttr;
107  GRID_CELL_TEXT_EDITOR* referenceEditor = new GRID_CELL_TEXT_EDITOR();
108  referenceEditor->SetValidator( m_referenceValidator );
109  m_referenceAttr->SetEditor( referenceEditor );
110 
111  m_valueAttr = new wxGridCellAttr;
112  GRID_CELL_TEXT_EDITOR* valueEditor = new GRID_CELL_TEXT_EDITOR();
113  valueEditor->SetValidator( m_valueValidator );
114  m_valueAttr->SetEditor( valueEditor );
115 
116  m_footprintAttr = new wxGridCellAttr;
118  fpIdEditor->SetValidator( m_libIdValidator );
119  m_footprintAttr->SetEditor( fpIdEditor );
120 
121  m_urlAttr = new wxGridCellAttr;
122  GRID_CELL_URL_EDITOR* urlEditor = new GRID_CELL_URL_EDITOR( aDialog );
123  urlEditor->SetValidator( m_urlValidator );
124  m_urlAttr->SetEditor( urlEditor );
125 
126  m_nonUrlAttr = new wxGridCellAttr;
127  GRID_CELL_TEXT_EDITOR* nonUrlEditor = new GRID_CELL_TEXT_EDITOR();
128  nonUrlEditor->SetValidator( m_nonUrlValidator );
129  m_nonUrlAttr->SetEditor( nonUrlEditor );
130 
131  m_curdir = m_frame->Prj().GetProjectPath();
132  m_filepathAttr = new wxGridCellAttr;
133 
134  // Create a wild card using wxFileDialog syntax.
135  wxString wildCard( _( "Schematic Files" ) );
136  std::vector<std::string> exts;
137  exts.push_back( KiCadSchematicFileExtension );
138  wildCard += AddFileExtListToFilter( exts );
139 
140  auto filepathEditor = new GRID_CELL_PATH_EDITOR( aDialog, aGrid, &m_curdir, wildCard );
141  filepathEditor->SetValidator( m_filepathValidator );
142  m_filepathAttr->SetEditor( filepathEditor );
143 
144  m_boolAttr = new wxGridCellAttr;
145  m_boolAttr->SetRenderer( new wxGridCellBoolRenderer() );
146  m_boolAttr->SetEditor( new wxGridCellBoolEditor() );
147  m_boolAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
148 
149  wxArrayString vAlignNames;
150  vAlignNames.Add( _( "Top" ) );
151  vAlignNames.Add( _( "Center" ) );
152  vAlignNames.Add( _( "Bottom" ) );
153  m_vAlignAttr = new wxGridCellAttr;
154  m_vAlignAttr->SetEditor( new wxGridCellChoiceEditor( vAlignNames ) );
155  m_vAlignAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_BOTTOM );
156 
157  wxArrayString hAlignNames;
158  hAlignNames.Add( _( "Left" ) );
159  hAlignNames.Add(_( "Center" ) );
160  hAlignNames.Add(_( "Right" ) );
161  m_hAlignAttr = new wxGridCellAttr;
162  m_hAlignAttr->SetEditor( new wxGridCellChoiceEditor( hAlignNames ) );
163  m_hAlignAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_BOTTOM );
164 
165  wxArrayString orientationNames;
166  orientationNames.Add( _( "Horizontal" ) );
167  orientationNames.Add(_( "Vertical" ) );
168  m_orientationAttr = new wxGridCellAttr;
169  m_orientationAttr->SetEditor( new wxGridCellChoiceEditor( orientationNames ) );
170  m_orientationAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_BOTTOM );
171 }
172 
173 
174 template <class T>
176 {
177  m_readOnlyAttr->DecRef();
178  m_fieldNameAttr->DecRef();
179  m_boolAttr->DecRef();
180  m_referenceAttr->DecRef();
181  m_valueAttr->DecRef();
182  m_footprintAttr->DecRef();
183  m_urlAttr->DecRef();
184  m_nonUrlAttr->DecRef();
185  m_filepathAttr->DecRef();
186  m_vAlignAttr->DecRef();
187  m_hAlignAttr->DecRef();
188  m_orientationAttr->DecRef();
189 }
190 
191 
192 template <class T>
194 {
195  switch( aCol )
196  {
197  case FDC_NAME: return _( "Name" );
198  case FDC_VALUE: return _( "Value" );
199  case FDC_SHOWN: return _( "Show" );
200  case FDC_H_ALIGN: return _( "H Align" );
201  case FDC_V_ALIGN: return _( "V Align" );
202  case FDC_ITALIC: return _( "Italic" );
203  case FDC_BOLD: return _( "Bold" );
204  case FDC_TEXT_SIZE: return _( "Text Size" );
205  case FDC_ORIENTATION: return _( "Orientation" );
206  case FDC_POSX: return _( "X Position" );
207  case FDC_POSY: return _( "Y Position" );
208  default: wxFAIL; return wxEmptyString;
209  }
210 }
211 
212 
213 template <class T>
214 bool FIELDS_GRID_TABLE<T>::CanGetValueAs( int aRow, int aCol, const wxString& aTypeName )
215 {
216  switch( aCol )
217  {
218  case FDC_NAME:
219  case FDC_VALUE:
220  case FDC_H_ALIGN:
221  case FDC_V_ALIGN:
222  case FDC_TEXT_SIZE:
223  case FDC_ORIENTATION:
224  case FDC_POSX:
225  case FDC_POSY:
226  return aTypeName == wxGRID_VALUE_STRING;
227 
228  case FDC_SHOWN:
229  case FDC_ITALIC:
230  case FDC_BOLD:
231  return aTypeName == wxGRID_VALUE_BOOL;
232 
233  default:
234  wxFAIL;
235  return false;
236  }
237 }
238 
239 
240 template <class T>
241 bool FIELDS_GRID_TABLE<T>::CanSetValueAs( int aRow, int aCol, const wxString& aTypeName )
242 {
243  return CanGetValueAs( aRow, aCol, aTypeName );
244 }
245 
246 
247 template <class T>
248 wxGridCellAttr* FIELDS_GRID_TABLE<T>::GetAttr( int aRow, int aCol, wxGridCellAttr::wxAttrKind )
249 {
250  wxGridCellAttr* tmp;
251 
252  switch( aCol )
253  {
254  case FDC_NAME:
255  if( aRow < m_mandatoryFieldCount )
256  {
257  tmp = m_fieldNameAttr->Clone();
258  tmp->SetReadOnly( true );
259  return tmp;
260  }
261  else
262  {
263  m_fieldNameAttr->IncRef();
264  return m_fieldNameAttr;
265  }
266 
267  case FDC_VALUE:
268  if( m_parentType == SCH_SYMBOL_T && aRow == REFERENCE_FIELD )
269  {
270  m_referenceAttr->IncRef();
271  return m_referenceAttr;
272  }
273  else if( m_parentType == SCH_SYMBOL_T && aRow == VALUE_FIELD )
274  {
275  // For power symbols, the value is not editable, because value and pin name must
276  // be the same and can be edited only in library editor.
277  if( ( m_part && m_part->IsPower() && !m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) ) )
278  {
279  tmp = m_readOnlyAttr->Clone();
280  tmp->SetReadOnly( true );
281  tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
282  return tmp;
283  }
284  else
285  {
286  m_valueAttr->IncRef();
287  return m_valueAttr;
288  }
289  }
290  else if( m_parentType == SCH_SYMBOL_T && aRow == FOOTPRINT_FIELD )
291  {
292  m_footprintAttr->IncRef();
293  return m_footprintAttr;
294  }
295  else if( m_parentType == SCH_SYMBOL_T && aRow == DATASHEET_FIELD )
296  {
297  m_urlAttr->IncRef();
298  return m_urlAttr;
299  }
300  else if( m_parentType == SCH_SHEET_T && aRow == SHEETNAME )
301  {
302  m_referenceAttr->IncRef();
303  return m_referenceAttr;
304  }
305  else if( m_parentType == SCH_SHEET_T && aRow == SHEETFILENAME )
306  {
307  m_filepathAttr->IncRef();
308  return m_filepathAttr;
309  }
310  else
311  {
312  wxString fn = GetValue( aRow, FDC_NAME );
313 
314  SCHEMATIC_SETTINGS* settings = m_frame->Prj().GetProjectFile().m_SchematicSettings;
315 
316  const TEMPLATE_FIELDNAME* templateFn =
317  settings ? settings->m_TemplateFieldNames.GetFieldName( fn ) : nullptr;
318 
319  if( templateFn && templateFn->m_URL )
320  {
321  m_urlAttr->IncRef();
322  return m_urlAttr;
323  }
324  else
325  {
326  m_nonUrlAttr->IncRef();
327  return m_nonUrlAttr;
328  }
329  }
330 
331  return nullptr;
332 
333  case FDC_TEXT_SIZE:
334  case FDC_POSX:
335  case FDC_POSY:
336  return nullptr;
337 
338  case FDC_H_ALIGN:
339  m_hAlignAttr->IncRef();
340  return m_hAlignAttr;
341 
342  case FDC_V_ALIGN:
343  m_vAlignAttr->IncRef();
344  return m_vAlignAttr;
345 
346  case FDC_ORIENTATION:
347  m_orientationAttr->IncRef();
348  return m_orientationAttr;
349 
350  case FDC_SHOWN:
351  case FDC_ITALIC:
352  case FDC_BOLD:
353  m_boolAttr->IncRef();
354  return m_boolAttr;
355 
356  default:
357  wxFAIL;
358  return nullptr;
359  }
360 }
361 
362 
363 template <class T>
364 wxString FIELDS_GRID_TABLE<T>::GetValue( int aRow, int aCol )
365 {
366  wxCHECK( aRow < GetNumberRows(), wxEmptyString );
367  const T& field = this->at( (size_t) aRow );
368 
369  switch( aCol )
370  {
371  case FDC_NAME:
372  // Use default field name for mandatory fields, because they are translated
373  // according to the current locale
374  if( aRow < m_mandatoryFieldCount )
375  {
376  if( m_parentType == SCH_SYMBOL_T )
378  else if( m_parentType == SCH_SHEET_T )
379  return SCH_SHEET::GetDefaultFieldName( aRow );
380  }
381 
382  return field.GetName( false );
383 
384  case FDC_VALUE:
385  return UnescapeString( field.GetText() );
386 
387  case FDC_SHOWN:
388  return StringFromBool( field.IsVisible() );
389 
390  case FDC_H_ALIGN:
391  switch ( field.GetHorizJustify() )
392  {
393  case GR_TEXT_HJUSTIFY_LEFT: return _( "Left" );
394  case GR_TEXT_HJUSTIFY_CENTER: return _( "Center" );
395  case GR_TEXT_HJUSTIFY_RIGHT: return _( "Right" );
396  }
397 
398  break;
399 
400  case FDC_V_ALIGN:
401  switch ( field.GetVertJustify() )
402  {
403  case GR_TEXT_VJUSTIFY_TOP: return _( "Top" );
404  case GR_TEXT_VJUSTIFY_CENTER: return _( "Center" );
405  case GR_TEXT_VJUSTIFY_BOTTOM: return _( "Bottom" );
406  }
407 
408  break;
409 
410  case FDC_ITALIC:
411  return StringFromBool( field.IsItalic() );
412 
413  case FDC_BOLD:
414  return StringFromBool( field.IsBold() );
415 
416  case FDC_TEXT_SIZE:
417  return StringFromValue( m_userUnits, field.GetTextSize().GetHeight() );
418 
419  case FDC_ORIENTATION:
420  switch ( (int) field.GetTextAngle() )
421  {
422  case TEXT_ANGLE_HORIZ: return _( "Horizontal" );
423  case TEXT_ANGLE_VERT: return _( "Vertical" );
424  }
425 
426  break;
427 
428  case FDC_POSX:
429  return StringFromValue( m_userUnits, field.GetTextPos().x );
430 
431  case FDC_POSY:
432  return StringFromValue( m_userUnits, field.GetTextPos().y );
433 
434  default:
435  // we can't assert here because wxWidgets sometimes calls this without checking
436  // the column type when trying to see if there's an overflow
437  break;
438  }
439 
440  return wxT( "bad wxWidgets!" );
441 }
442 
443 
444 template <class T>
445 bool FIELDS_GRID_TABLE<T>::GetValueAsBool( int aRow, int aCol )
446 {
447  wxCHECK( aRow < GetNumberRows(), false );
448  const T& field = this->at( (size_t) aRow );
449 
450  switch( aCol )
451  {
452  case FDC_SHOWN: return field.IsVisible();
453  case FDC_ITALIC: return field.IsItalic();
454  case FDC_BOLD: return field.IsBold();
455  default:
456  wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a bool value" ), aCol ) );
457  return false;
458  }
459 }
460 
461 
462 template <class T>
463 void FIELDS_GRID_TABLE<T>::SetValue( int aRow, int aCol, const wxString &aValue )
464 {
465  wxCHECK( aRow < GetNumberRows(), /*void*/ );
466  T& field = this->at( (size_t) aRow );
467  wxPoint pos;
468 
469  switch( aCol )
470  {
471  case FDC_NAME:
472  field.SetName( aValue );
473  break;
474 
475  case FDC_VALUE:
476  {
477  wxString value( aValue );
478 
479  if( m_parentType == SCH_SHEET_T && aRow == SHEETFILENAME )
480  {
481  wxFileName fn( value );
482 
483  // It's annoying to throw up nag dialogs when the extension isn't right. Just
484  // fix it.
485  if( fn.GetExt().CmpNoCase( KiCadSchematicFileExtension ) != 0 )
486  {
487  fn.SetExt( KiCadSchematicFileExtension );
488  value = fn.GetFullPath();
489  }
490  }
491  else if( m_parentType == SCH_SYMBOL_T && aRow == VALUE_FIELD )
492  {
493  value = EscapeString( value, CTX_LIBID );
494  }
495 
496  field.SetText( value );
497  }
498  break;
499 
500  case FDC_SHOWN:
501  field.SetVisible( BoolFromString( aValue ) );
502  break;
503 
504  case FDC_H_ALIGN:
505  if( aValue == _( "Left" ) )
506  field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
507  else if( aValue == _( "Center" ) )
508  field.SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
509  else if( aValue == _( "Right" ) )
510  field.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
511  else
512  wxFAIL_MSG( wxT( "unknown horizontal alignment: " ) + aValue );
513  break;
514 
515  case FDC_V_ALIGN:
516  if( aValue == _( "Top" ) )
517  field.SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
518  else if( aValue == _( "Center" ) )
519  field.SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
520  else if( aValue == _( "Bottom" ) )
521  field.SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
522  else
523  wxFAIL_MSG( wxT( "unknown vertical alignment: " ) + aValue);
524  break;
525 
526  case FDC_ITALIC:
527  field.SetItalic( BoolFromString( aValue ) );
528  break;
529 
530  case FDC_BOLD:
531  field.SetBold( BoolFromString( aValue ) );
532  break;
533 
534  case FDC_TEXT_SIZE:
535  field.SetTextSize( wxSize( ValueFromString( m_userUnits, aValue ),
536  ValueFromString( m_userUnits, aValue ) ) );
537  break;
538 
539  case FDC_ORIENTATION:
540  if( aValue == _( "Horizontal" ) )
541  field.SetTextAngle( TEXT_ANGLE_HORIZ );
542  else if( aValue == _( "Vertical" ) )
543  field.SetTextAngle( TEXT_ANGLE_VERT );
544  else
545  wxFAIL_MSG( wxT( "unknown orientation: " ) + aValue );
546  break;
547 
548  case FDC_POSX:
549  case FDC_POSY:
550  pos = field.GetTextPos();
551  if( aCol == FDC_POSX )
552  pos.x = ValueFromString( m_userUnits, aValue );
553  else
554  pos.y = ValueFromString( m_userUnits, aValue );
555  field.SetTextPos( pos );
556  break;
557 
558  default:
559  wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a string value" ), aCol ) );
560  break;
561  }
562 
563  GetView()->Refresh();
564 }
565 
566 
567 template <class T>
568 void FIELDS_GRID_TABLE<T>::SetValueAsBool( int aRow, int aCol, bool aValue )
569 {
570  wxCHECK( aRow < GetNumberRows(), /*void*/ );
571  T& field = this->at( (size_t) aRow );
572 
573  switch( aCol )
574  {
575  case FDC_SHOWN:
576  field.SetVisible( aValue );
577  break;
578  case FDC_ITALIC:
579  field.SetItalic( aValue );
580  break;
581  case FDC_BOLD:
582  field.SetBold( aValue );
583  break;
584  default:
585  wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a bool value" ), aCol ) );
586  break;
587  }
588 }
589 
590 
591 // Explicit Instantiations
592 
593 template class FIELDS_GRID_TABLE<SCH_FIELD>;
594 template class FIELDS_GRID_TABLE<LIB_FIELD>;
595 
596 
598 {
599  if( m_grid->GetGridCursorRow() == FOOTPRINT_FIELD && m_grid->GetGridCursorCol() == FDC_VALUE )
600  {
601  menu.Append( MYID_SELECT_FOOTPRINT, _( "Select Footprint..." ),
602  _( "Browse for footprint" ) );
603  menu.AppendSeparator();
604  }
605  else if( m_grid->GetGridCursorRow() == DATASHEET_FIELD && m_grid->GetGridCursorCol() == FDC_VALUE )
606  {
607  menu.Append( MYID_SHOW_DATASHEET, _( "Show Datasheet" ),
608  _( "Show datasheet in browser" ) );
609  menu.AppendSeparator();
610  }
611 
613 }
614 
615 
616 void FIELDS_GRID_TRICKS::doPopupSelection( wxCommandEvent& event )
617 {
618  if( event.GetId() == MYID_SELECT_FOOTPRINT )
619  {
620  // pick a footprint using the footprint picker.
621  wxString fpid = m_grid->GetCellValue( FOOTPRINT_FIELD, FDC_VALUE );
623 
624  if( frame->ShowModal( &fpid, m_dlg ) )
625  m_grid->SetCellValue( FOOTPRINT_FIELD, FDC_VALUE, fpid );
626 
627  frame->Destroy();
628  }
629  else if (event.GetId() == MYID_SHOW_DATASHEET )
630  {
631  wxString datasheet_uri = m_grid->GetCellValue( DATASHEET_FIELD, FDC_VALUE );
632  GetAssociatedDocument( m_dlg, datasheet_uri, &m_dlg->Prj() );
633  }
634  else
635  {
637  }
638 }
639 
640 
641 template <class T>
642 wxString FIELDS_GRID_TABLE<T>::StringFromBool( bool aValue ) const
643 {
644  if( aValue )
645  return wxT( "1" );
646  else
647  return wxT( "0" );
648 }
649 
650 
651 template <class T>
652 bool FIELDS_GRID_TABLE<T>::BoolFromString( wxString aValue ) const
653 {
654  if( aValue == "1" )
655  {
656  return true;
657  }
658  else if( aValue == "0" )
659  {
660  return false;
661  }
662  else
663  {
664  wxFAIL_MSG( wxString::Format( "string \"%s\" can't be converted to boolean "
665  "correctly, it will have been perceived as FALSE", aValue ) );
666  return false;
667  }
668 }
Field Reference of part, i.e. "IC21".
virtual bool ShowModal(wxString *aResult=nullptr, wxWindow *aResultantFocusWindow=nullptr)
Show this wxFrame as if it were a modal dialog, with all other instantiated wxFrames disabled until t...
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
virtual void showPopupMenu(wxMenu &menu) override
bool GetAssociatedDocument(wxWindow *aParent, const wxString &aDocName, PROJECT *aProject)
Open a document (file) with the suitable browser.
Definition: eda_doc.cpp:79
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:64
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
int GetUserUnits()
Return the currently selected user unit value for the interface.
bool CanSetValueAs(int aRow, int aCol, const wxString &aTypeName) override
The first 2 are mandatory, and must be instantiated in SCH_SHEET.
Definition: sch_sheet.h:47
This file is part of the common library.
TEMPLATES m_TemplateFieldNames
#define FIELD_VALUE
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:382
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
Definition: dialog_shim.h:82
wxString GetColLabelValue(int aCol) override
Define a library symbol object.
Definition: lib_symbol.h:96
#define SHEETNAME_V
name of datasheet
This class works around a bug in wxGrid where the first keystroke doesn't get sent through the valida...
Definition: validators.h:44
WX_GRID * m_grid
I don't own the grid, but he owns me.
Definition: grid_tricks.h:81
wxString StringFromBool(bool aValue) const
Field Value of part, i.e. "3.3K".
long long int ValueFromString(EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType)
Function ValueFromString converts aTextValue in aUnits to internal units used by the application.
Definition: base_units.cpp:416
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
Definitions of control validators for schematic dialogs.
wxString GetValue(int aRow, int aCol) override
#define SHEETFILENAME_V
bool CanGetValueAs(int aRow, int aCol, const wxString &aTypeName) override
Definition of file extensions used in Kicad.
#define FIELD_NAME
Definition for symbol library class.
#define _(s)
FIELDS_GRID_TABLE(DIALOG_SHIM *aDialog, SCH_BASE_FRAME *aFrame, WX_GRID *aGrid, LIB_SYMBOL *aSymbol)
static const wxString GetDefaultFieldName(int aFieldNdx)
Definition: sch_sheet.cpp:47
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslate=true)
Return a default symbol field name for field aFieldNdx for all components.
Editor for wxGrid cells that adds a file/folder browser to the grid input field.
wxGridCellAttr * GetAttr(int row, int col, wxGridCellAttr::wxAttrKind kind) override
virtual void SetValidator(const wxValidator &validator) override
Definition: validators.cpp:46
const TEMPLATE_FIELDNAME * GetFieldName(const wxString &aName)
Search for aName in the template field name list.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:54
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
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
virtual void doPopupSelection(wxCommandEvent &event)
void initGrid(DIALOG_SHIM *aDialog, WX_GRID *aGrid)
bool GetValueAsBool(int aRow, int aCol) override
virtual void showPopupMenu(wxMenu &menu)
void SetValue(int aRow, int aCol, const wxString &aValue) override
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:222
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
Definition: string.cpp:141
const std::string KiCadSchematicFileExtension
These settings were stored in SCH_BASE_FRAME previously.
Hold a name of a symbol's field, field value, and default visibility.
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
wxString StringFromValue(EDA_UNITS aUnits, double aValue, bool aAddUnitSymbol, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
Definition: base_units.cpp:204
#define TEXT_ANGLE_VERT
Definition: eda_text.h:51
void SetValueAsBool(int aRow, int aCol, bool aValue) override
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
virtual void doPopupSelection(wxCommandEvent &event) override
Custom text control validator definitions.
wxString AddFileExtListToFilter(const std::vector< std::string > &aExts)
Build the wildcard extension file dialog wildcard filter to add to the base message dialog.
Field Name Module PCB, i.e. "16DIP300".