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-2020 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 <class_library.h>
33 #include <template_fieldnames.h>
36 #include <project/project_file.h>
37 #include "eda_doc.h"
38 #include <wx/settings.h>
39 
40 
41 enum
42 {
43  MYID_SELECT_FOOTPRINT = 991, // must be within GRID_TRICKS' enum range
45 };
46 
47 
48 template <class T>
50  WX_GRID* aGrid, LIB_PART* aPart ) :
51  m_frame( aFrame ),
52  m_userUnits( aDialog->GetUserUnits() ),
53  m_grid( aGrid ),
54  m_parentType( SCH_COMPONENT_T ),
55  m_mandatoryFieldCount( MANDATORY_FIELDS ),
56  m_part( aPart ),
57  m_fieldNameValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_NAME ),
58  m_referenceValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), REFERENCE_FIELD ),
59  m_valueValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), VALUE_FIELD ),
60  m_libIdValidator(),
61  m_urlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ),
62  m_nonUrlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ),
63  m_filepathValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), SHEETFILENAME )
64 {
65  initGrid( aDialog, aGrid );
66 }
67 
68 
69 template <class T>
71  WX_GRID* aGrid, SCH_SHEET* aSheet ) :
72  m_frame( aFrame ),
73  m_userUnits( aDialog->GetUserUnits() ),
74  m_grid( aGrid ),
75  m_parentType( SCH_SHEET_T ),
76  m_mandatoryFieldCount( SHEET_MANDATORY_FIELDS ),
77  m_part( nullptr ),
78  m_fieldNameValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_NAME ),
79  m_referenceValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), SHEETNAME_V ),
80  m_valueValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), VALUE_FIELD ),
81  m_libIdValidator(),
82  m_urlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ),
83  m_nonUrlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ),
84  m_filepathValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), SHEETFILENAME_V )
85 {
86  initGrid( aDialog, aGrid );
87 }
88 
89 
90 template <class T>
92 {
93  // Build the various grid cell attributes.
94  // NOTE: validators and cellAttrs are member variables to get the destruction order
95  // right. wxGrid is VERY cranky about this.
96 
97  m_readOnlyAttr = new wxGridCellAttr;
98  m_readOnlyAttr->SetReadOnly( true );
99 
100  m_fieldNameAttr = new wxGridCellAttr;
101  GRID_CELL_TEXT_EDITOR* nameEditor = new GRID_CELL_TEXT_EDITOR();
102  nameEditor->SetValidator( m_fieldNameValidator );
103  m_fieldNameAttr->SetEditor( nameEditor );
104 
105  m_referenceAttr = new wxGridCellAttr;
106  GRID_CELL_TEXT_EDITOR* referenceEditor = new GRID_CELL_TEXT_EDITOR();
107  referenceEditor->SetValidator( m_referenceValidator );
108  m_referenceAttr->SetEditor( referenceEditor );
109 
110  m_valueAttr = new wxGridCellAttr;
111  GRID_CELL_TEXT_EDITOR* valueEditor = new GRID_CELL_TEXT_EDITOR();
112  valueEditor->SetValidator( m_valueValidator );
113  m_valueAttr->SetEditor( valueEditor );
114 
115  m_footprintAttr = new wxGridCellAttr;
117  fpIdEditor->SetValidator( m_libIdValidator );
118  m_footprintAttr->SetEditor( fpIdEditor );
119 
120  m_urlAttr = new wxGridCellAttr;
121  GRID_CELL_URL_EDITOR* urlEditor = new GRID_CELL_URL_EDITOR( aDialog );
122  urlEditor->SetValidator( m_urlValidator );
123  m_urlAttr->SetEditor( urlEditor );
124 
125  m_nonUrlAttr = new wxGridCellAttr;
126  GRID_CELL_TEXT_EDITOR* nonUrlEditor = new GRID_CELL_TEXT_EDITOR();
127  nonUrlEditor->SetValidator( m_nonUrlValidator );
128  m_nonUrlAttr->SetEditor( nonUrlEditor );
129 
130  m_curdir = m_frame->Prj().GetProjectPath();
131  m_filepathAttr = new wxGridCellAttr;
132 
133  // Create a wild card using wxFileDialog syntax.
134  wxString wildCard( _( "Schematic Files" ) );
135  std::vector<std::string> exts;
136  exts.push_back( KiCadSchematicFileExtension );
137  wildCard += AddFileExtListToFilter( exts );
138 
139  auto filepathEditor = new GRID_CELL_PATH_EDITOR( aDialog, aGrid, &m_curdir, wildCard );
140  filepathEditor->SetValidator( m_filepathValidator );
141  m_filepathAttr->SetEditor( filepathEditor );
142 
143  m_boolAttr = new wxGridCellAttr;
144  m_boolAttr->SetRenderer( new wxGridCellBoolRenderer() );
145  m_boolAttr->SetEditor( new wxGridCellBoolEditor() );
146  m_boolAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
147 
148  wxArrayString vAlignNames;
149  vAlignNames.Add( _( "Top" ) );
150  vAlignNames.Add( _( "Center" ) );
151  vAlignNames.Add( _( "Bottom" ) );
152  m_vAlignAttr = new wxGridCellAttr;
153  m_vAlignAttr->SetEditor( new wxGridCellChoiceEditor( vAlignNames ) );
154  m_vAlignAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_BOTTOM );
155 
156  wxArrayString hAlignNames;
157  hAlignNames.Add( _( "Left" ) );
158  hAlignNames.Add(_( "Center" ) );
159  hAlignNames.Add(_( "Right" ) );
160  m_hAlignAttr = new wxGridCellAttr;
161  m_hAlignAttr->SetEditor( new wxGridCellChoiceEditor( hAlignNames ) );
162  m_hAlignAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_BOTTOM );
163 
164  wxArrayString orientationNames;
165  orientationNames.Add( _( "Horizontal" ) );
166  orientationNames.Add(_( "Vertical" ) );
167  m_orientationAttr = new wxGridCellAttr;
168  m_orientationAttr->SetEditor( new wxGridCellChoiceEditor( orientationNames ) );
169  m_orientationAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_BOTTOM );
170 }
171 
172 
173 template <class T>
175 {
176  m_readOnlyAttr->DecRef();
177  m_fieldNameAttr->DecRef();
178  m_boolAttr->DecRef();
179  m_referenceAttr->DecRef();
180  m_valueAttr->DecRef();
181  m_footprintAttr->DecRef();
182  m_urlAttr->DecRef();
183  m_nonUrlAttr->DecRef();
184  m_filepathAttr->DecRef();
185  m_vAlignAttr->DecRef();
186  m_hAlignAttr->DecRef();
187  m_orientationAttr->DecRef();
188 }
189 
190 
191 template <class T>
193 {
194  switch( aCol )
195  {
196  case FDC_NAME: return _( "Name" );
197  case FDC_VALUE: return _( "Value" );
198  case FDC_SHOWN: return _( "Show" );
199  case FDC_H_ALIGN: return _( "H Align" );
200  case FDC_V_ALIGN: return _( "V Align" );
201  case FDC_ITALIC: return _( "Italic" );
202  case FDC_BOLD: return _( "Bold" );
203  case FDC_TEXT_SIZE: return _( "Text Size" );
204  case FDC_ORIENTATION: return _( "Orientation" );
205  case FDC_POSX: return _( "X Position" );
206  case FDC_POSY: return _( "Y Position" );
207  default: wxFAIL; return wxEmptyString;
208  }
209 }
210 
211 
212 template <class T>
213 bool FIELDS_GRID_TABLE<T>::CanGetValueAs( int aRow, int aCol, const wxString& aTypeName )
214 {
215  switch( aCol )
216  {
217  case FDC_NAME:
218  case FDC_VALUE:
219  case FDC_H_ALIGN:
220  case FDC_V_ALIGN:
221  case FDC_TEXT_SIZE:
222  case FDC_ORIENTATION:
223  case FDC_POSX:
224  case FDC_POSY:
225  return aTypeName == wxGRID_VALUE_STRING;
226 
227  case FDC_SHOWN:
228  case FDC_ITALIC:
229  case FDC_BOLD:
230  return aTypeName == wxGRID_VALUE_BOOL;
231 
232  default:
233  wxFAIL;
234  return false;
235  }
236 }
237 
238 
239 template <class T>
240 bool FIELDS_GRID_TABLE<T>::CanSetValueAs( int aRow, int aCol, const wxString& aTypeName )
241 {
242  return CanGetValueAs( aRow, aCol, aTypeName );
243 }
244 
245 
246 template <class T>
247 wxGridCellAttr* FIELDS_GRID_TABLE<T>::GetAttr( int aRow, int aCol, wxGridCellAttr::wxAttrKind )
248 {
249  wxGridCellAttr* tmp;
250 
251  switch( aCol )
252  {
253  case FDC_NAME:
254  if( aRow < m_mandatoryFieldCount )
255  {
256  tmp = m_fieldNameAttr->Clone();
257  tmp->SetReadOnly( true );
258  return tmp;
259  }
260  else
261  {
262  m_fieldNameAttr->IncRef();
263  return m_fieldNameAttr;
264  }
265 
266  case FDC_VALUE:
267  if( m_parentType == SCH_COMPONENT_T && aRow == REFERENCE_FIELD )
268  {
269  m_referenceAttr->IncRef();
270  return m_referenceAttr;
271  }
272  else if( m_parentType == SCH_COMPONENT_T && aRow == VALUE_FIELD )
273  {
274  // For power symbols, the value is not editable, because value and pin name must
275  // be the same and can be edited only in library editor.
276  if( ( m_part && m_part->IsPower() && !m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) ) )
277  {
278  tmp = m_readOnlyAttr->Clone();
279  tmp->SetReadOnly( true );
280  tmp->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
281  return tmp;
282  }
283  else
284  {
285  m_valueAttr->IncRef();
286  return m_valueAttr;
287  }
288  }
289  else if( m_parentType == SCH_COMPONENT_T && aRow == FOOTPRINT_FIELD )
290  {
291  m_footprintAttr->IncRef();
292  return m_footprintAttr;
293  }
294  else if( m_parentType == SCH_COMPONENT_T && aRow == DATASHEET_FIELD )
295  {
296  m_urlAttr->IncRef();
297  return m_urlAttr;
298  }
299  else if( m_parentType == SCH_SHEET_T && aRow == SHEETNAME )
300  {
301  m_referenceAttr->IncRef();
302  return m_referenceAttr;
303  }
304  else if( m_parentType == SCH_SHEET_T && aRow == SHEETFILENAME )
305  {
306  m_filepathAttr->IncRef();
307  return m_filepathAttr;
308  }
309  else
310  {
311  wxString fn = GetValue( aRow, FDC_NAME );
312 
313  SCHEMATIC_SETTINGS* settings = m_frame->Prj().GetProjectFile().m_SchematicSettings;
314 
315  const TEMPLATE_FIELDNAME* templateFn =
316  settings ? settings->m_TemplateFieldNames.GetFieldName( fn ) : nullptr;
317 
318  if( templateFn && templateFn->m_URL )
319  {
320  m_urlAttr->IncRef();
321  return m_urlAttr;
322  }
323  else
324  {
325  m_nonUrlAttr->IncRef();
326  return m_nonUrlAttr;
327  }
328  }
329 
330  return nullptr;
331 
332  case FDC_TEXT_SIZE:
333  case FDC_POSX:
334  case FDC_POSY:
335  return nullptr;
336 
337  case FDC_H_ALIGN:
338  m_hAlignAttr->IncRef();
339  return m_hAlignAttr;
340 
341  case FDC_V_ALIGN:
342  m_vAlignAttr->IncRef();
343  return m_vAlignAttr;
344 
345  case FDC_ORIENTATION:
346  m_orientationAttr->IncRef();
347  return m_orientationAttr;
348 
349  case FDC_SHOWN:
350  case FDC_ITALIC:
351  case FDC_BOLD:
352  m_boolAttr->IncRef();
353  return m_boolAttr;
354 
355  default:
356  wxFAIL;
357  return nullptr;
358  }
359 }
360 
361 
362 template <class T>
363 wxString FIELDS_GRID_TABLE<T>::GetValue( int aRow, int aCol )
364 {
365  wxCHECK( aRow < GetNumberRows(), wxEmptyString );
366  const T& field = this->at( (size_t) aRow );
367 
368  switch( aCol )
369  {
370  case FDC_NAME:
371  // Use default field name for mandatory fields, because they are translated
372  // according to the current locale
373  if( aRow < m_mandatoryFieldCount )
374  {
375  if( m_parentType == SCH_COMPONENT_T )
377  else if( m_parentType == SCH_SHEET_T )
378  return SCH_SHEET::GetDefaultFieldName( aRow );
379  }
380 
381  return field.GetName( false );
382 
383  case FDC_VALUE:
384  return field.GetText();
385 
386  case FDC_SHOWN:
387  return StringFromBool( field.IsVisible() );
388 
389  case FDC_H_ALIGN:
390  switch ( field.GetHorizJustify() )
391  {
392  case GR_TEXT_HJUSTIFY_LEFT: return _( "Left" );
393  case GR_TEXT_HJUSTIFY_CENTER: return _( "Center" );
394  case GR_TEXT_HJUSTIFY_RIGHT: return _( "Right" );
395  }
396 
397  break;
398 
399  case FDC_V_ALIGN:
400  switch ( field.GetVertJustify() )
401  {
402  case GR_TEXT_VJUSTIFY_TOP: return _( "Top" );
403  case GR_TEXT_VJUSTIFY_CENTER: return _( "Center" );
404  case GR_TEXT_VJUSTIFY_BOTTOM: return _( "Bottom" );
405  }
406 
407  break;
408 
409  case FDC_ITALIC:
410  return StringFromBool( field.IsItalic() );
411 
412  case FDC_BOLD:
413  return StringFromBool( field.IsBold() );
414 
415  case FDC_TEXT_SIZE:
416  return StringFromValue( m_userUnits, field.GetTextSize().GetHeight() );
417 
418  case FDC_ORIENTATION:
419  switch ( (int) field.GetTextAngle() )
420  {
421  case TEXT_ANGLE_HORIZ: return _( "Horizontal" );
422  case TEXT_ANGLE_VERT: return _( "Vertical" );
423  }
424 
425  break;
426 
427  case FDC_POSX:
428  return StringFromValue( m_userUnits, field.GetTextPos().x );
429 
430  case FDC_POSY:
431  return StringFromValue( m_userUnits, field.GetTextPos().y );
432 
433  default:
434  // we can't assert here because wxWidgets sometimes calls this without checking
435  // the column type when trying to see if there's an overflow
436  break;
437  }
438 
439  return wxT( "bad wxWidgets!" );
440 }
441 
442 
443 template <class T>
444 bool FIELDS_GRID_TABLE<T>::GetValueAsBool( int aRow, int aCol )
445 {
446  wxCHECK( aRow < GetNumberRows(), false );
447  const T& field = this->at( (size_t) aRow );
448 
449  switch( aCol )
450  {
451  case FDC_SHOWN: return field.IsVisible();
452  case FDC_ITALIC: return field.IsItalic();
453  case FDC_BOLD: return field.IsBold();
454  default:
455  wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a bool value" ), aCol ) );
456  return false;
457  }
458 }
459 
460 
461 template <class T>
462 void FIELDS_GRID_TABLE<T>::SetValue( int aRow, int aCol, const wxString &aValue )
463 {
464  wxCHECK( aRow < GetNumberRows(), /*void*/ );
465  T& field = this->at( (size_t) aRow );
466  wxPoint pos;
467 
468  switch( aCol )
469  {
470  case FDC_NAME:
471  field.SetName( aValue );
472  break;
473 
474  case FDC_VALUE:
475  {
476  wxString value( aValue );
477 
478  if( m_parentType == SCH_SHEET_T && aRow == SHEETFILENAME )
479  {
480  wxFileName fn( value );
481 
482  // It's annoying to throw up nag dialogs when the extension isn't right. Just
483  // fix it.
484  if( fn.GetExt().CmpNoCase( KiCadSchematicFileExtension ) != 0 )
485  {
486  fn.SetExt( KiCadSchematicFileExtension );
487  value = fn.GetFullPath();
488  }
489  }
490 
491  field.SetText( value );
492  }
493  break;
494 
495  case FDC_SHOWN:
496  field.SetVisible( BoolFromString( aValue ) );
497  break;
498 
499  case FDC_H_ALIGN:
500  if( aValue == _( "Left" ) )
501  field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
502  else if( aValue == _( "Center" ) )
503  field.SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
504  else if( aValue == _( "Right" ) )
505  field.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
506  else
507  wxFAIL_MSG( wxT( "unknown horizontal alignment: " ) + aValue );
508  break;
509 
510  case FDC_V_ALIGN:
511  if( aValue == _( "Top" ) )
512  field.SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
513  else if( aValue == _( "Center" ) )
514  field.SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
515  else if( aValue == _( "Bottom" ) )
516  field.SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
517  else
518  wxFAIL_MSG( wxT( "unknown vertical alignment: " ) + aValue);
519  break;
520 
521  case FDC_ITALIC:
522  field.SetItalic( BoolFromString( aValue ) );
523  break;
524 
525  case FDC_BOLD:
526  field.SetBold( BoolFromString( aValue ) );
527  break;
528 
529  case FDC_TEXT_SIZE:
530  field.SetTextSize( wxSize( ValueFromString( m_userUnits, aValue ),
531  ValueFromString( m_userUnits, aValue ) ) );
532  break;
533 
534  case FDC_ORIENTATION:
535  if( aValue == _( "Horizontal" ) )
536  field.SetTextAngle( TEXT_ANGLE_HORIZ );
537  else if( aValue == _( "Vertical" ) )
538  field.SetTextAngle( TEXT_ANGLE_VERT );
539  else
540  wxFAIL_MSG( wxT( "unknown orientation: " ) + aValue );
541  break;
542 
543  case FDC_POSX:
544  case FDC_POSY:
545  pos = field.GetTextPos();
546  if( aCol == FDC_POSX )
547  pos.x = ValueFromString( m_userUnits, aValue );
548  else
549  pos.y = ValueFromString( m_userUnits, aValue );
550  field.SetTextPos( pos );
551  break;
552 
553  default:
554  wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a string value" ), aCol ) );
555  break;
556  }
557 
558  GetView()->Refresh();
559 }
560 
561 
562 template <class T>
563 void FIELDS_GRID_TABLE<T>::SetValueAsBool( int aRow, int aCol, bool aValue )
564 {
565  wxCHECK( aRow < GetNumberRows(), /*void*/ );
566  T& field = this->at( (size_t) aRow );
567 
568  switch( aCol )
569  {
570  case FDC_SHOWN:
571  field.SetVisible( aValue );
572  break;
573  case FDC_ITALIC:
574  field.SetItalic( aValue );
575  break;
576  case FDC_BOLD:
577  field.SetBold( aValue );
578  break;
579  default:
580  wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a bool value" ), aCol ) );
581  break;
582  }
583 }
584 
585 
586 // Explicit Instantiations
587 
588 template class FIELDS_GRID_TABLE<SCH_FIELD>;
589 template class FIELDS_GRID_TABLE<LIB_FIELD>;
590 
591 
593 {
594  if( m_grid->GetGridCursorRow() == FOOTPRINT_FIELD && m_grid->GetGridCursorCol() == FDC_VALUE )
595  {
596  menu.Append( MYID_SELECT_FOOTPRINT, _( "Select Footprint..." ),
597  _( "Browse for footprint" ) );
598  menu.AppendSeparator();
599  }
600  else if( m_grid->GetGridCursorRow() == DATASHEET_FIELD && m_grid->GetGridCursorCol() == FDC_VALUE )
601  {
602  menu.Append( MYID_SHOW_DATASHEET, _( "Show Datasheet" ),
603  _( "Show datasheet in browser" ) );
604  menu.AppendSeparator();
605  }
606 
608 }
609 
610 
611 void FIELDS_GRID_TRICKS::doPopupSelection( wxCommandEvent& event )
612 {
613  if( event.GetId() == MYID_SELECT_FOOTPRINT )
614  {
615  // pick a footprint using the footprint picker.
616  wxString fpid = m_grid->GetCellValue( FOOTPRINT_FIELD, FDC_VALUE );
618 
619  if( frame->ShowModal( &fpid, m_dlg ) )
620  m_grid->SetCellValue( FOOTPRINT_FIELD, FDC_VALUE, fpid );
621 
622  frame->Destroy();
623  }
624  else if (event.GetId() == MYID_SHOW_DATASHEET )
625  {
626  wxString datasheet_uri = m_grid->GetCellValue( DATASHEET_FIELD, FDC_VALUE );
627  GetAssociatedDocument( m_dlg, datasheet_uri, &m_dlg->Prj() );
628  }
629  else
630  {
632  }
633 }
634 
635 
636 template <class T>
637 wxString FIELDS_GRID_TABLE<T>::StringFromBool( bool aValue ) const
638 {
639  if( aValue )
640  return wxT( "1" );
641  else
642  return wxT( "0" );
643 }
644 
645 
646 template <class T>
647 bool FIELDS_GRID_TABLE<T>::BoolFromString( wxString aValue ) const
648 {
649  if( aValue == "1" )
650  {
651  return true;
652  }
653  else if( aValue == "0" )
654  {
655  return false;
656  }
657  else
658  {
659  wxFAIL_MSG( wxString::Format( "string \"%s\" can't be converted to boolean "
660  "correctly, it will have been perceived as FALSE", aValue ) );
661  return false;
662  }
663 }
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:61
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:56
int GetUserUnits()
Returns 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:368
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
Definition: dialog_shim.h:83
wxString GetColLabelValue(int aCol) override
#define SHEETNAME_V
FIELDS_GRID_TABLE(DIALOG_SHIM *aDialog, SCH_BASE_FRAME *aFrame, WX_GRID *aGrid, LIB_PART *aPart)
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:402
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
Define a library symbol object.
Definition: lib_symbol.h:93
Definition of file extensions used in Kicad.
#define FIELD_NAME
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.
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 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
#define _(s)
Definition: 3d_actions.cpp:33
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:190
#define TEXT_ANGLE_VERT
Definition: eda_text.h:51
Definition for part library class.
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".