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 
39 
40 enum
41 {
42  MYID_SELECT_FOOTPRINT = 991, // must be within GRID_TRICKS' enum range
44 };
45 
46 
47 template <class T>
49  WX_GRID* aGrid, LIB_PART* aPart ) :
50  m_frame( aFrame ),
51  m_userUnits( aDialog->GetUserUnits() ),
52  m_grid( aGrid ),
53  m_parentType( SCH_COMPONENT_T ),
54  m_mandatoryFieldCount( MANDATORY_FIELDS ),
55  m_part( aPart ),
56  m_fieldNameValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_NAME ),
57  m_referenceValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), REFERENCE_FIELD ),
58  m_valueValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), VALUE_FIELD ),
59  m_libIdValidator(),
60  m_urlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ),
61  m_nonUrlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ),
62  m_filepathValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), SHEETFILENAME )
63 {
64  initGrid( aDialog, aGrid );
65 }
66 
67 
68 template <class T>
70  WX_GRID* aGrid, SCH_SHEET* aSheet ) :
71  m_frame( aFrame ),
72  m_userUnits( aDialog->GetUserUnits() ),
73  m_grid( aGrid ),
74  m_parentType( SCH_SHEET_T ),
75  m_mandatoryFieldCount( SHEET_MANDATORY_FIELDS ),
76  m_part( nullptr ),
77  m_fieldNameValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_NAME ),
78  m_referenceValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), SHEETNAME_V ),
79  m_valueValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), VALUE_FIELD ),
80  m_libIdValidator(),
81  m_urlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ),
82  m_nonUrlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ),
83  m_filepathValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), SHEETFILENAME_V )
84 {
85  initGrid( aDialog, aGrid );
86 }
87 
88 
89 template <class T>
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 
129  m_curdir = m_frame->Prj().GetProjectPath();
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 }
170 
171 
172 template <class T>
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 }
188 
189 
190 template <class T>
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 }
209 
210 
211 template <class T>
212 bool FIELDS_GRID_TABLE<T>::CanGetValueAs( int aRow, int aCol, const wxString& aTypeName )
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 }
236 
237 
238 template <class T>
239 bool FIELDS_GRID_TABLE<T>::CanSetValueAs( int aRow, int aCol, const wxString& aTypeName )
240 {
241  return CanGetValueAs( aRow, aCol, aTypeName );
242 }
243 
244 
245 template <class T>
246 wxGridCellAttr* FIELDS_GRID_TABLE<T>::GetAttr( int aRow, int aCol, wxGridCellAttr::wxAttrKind )
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.
275  if( ( m_part && m_part->IsPower() && !m_frame->IsType( FRAME_SCH_SYMBOL_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 
312  SCHEMATIC_SETTINGS* settings = m_frame->Prj().GetProjectFile().m_SchematicSettings;
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 }
359 
360 
361 template <class T>
362 wxString FIELDS_GRID_TABLE<T>::GetValue( int aRow, int aCol )
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  {
374  if( m_parentType == SCH_COMPONENT_T )
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 }
440 
441 
442 template <class T>
443 bool FIELDS_GRID_TABLE<T>::GetValueAsBool( int aRow, int aCol )
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 }
458 
459 
460 template <class T>
461 void FIELDS_GRID_TABLE<T>::SetValue( int aRow, int aCol, const wxString &aValue )
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  field.SetText( aValue );
475  break;
476 
477  case FDC_SHOWN:
478  field.SetVisible( BoolFromString( aValue ) );
479  break;
480 
481  case FDC_H_ALIGN:
482  if( aValue == _( "Left" ) )
483  field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
484  else if( aValue == _( "Center" ) )
485  field.SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
486  else if( aValue == _( "Right" ) )
487  field.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
488  else
489  wxFAIL_MSG( wxT( "unknown horizontal alignment: " ) + aValue );
490  break;
491 
492  case FDC_V_ALIGN:
493  if( aValue == _( "Top" ) )
494  field.SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
495  else if( aValue == _( "Center" ) )
496  field.SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
497  else if( aValue == _( "Bottom" ) )
498  field.SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
499  else
500  wxFAIL_MSG( wxT( "unknown vertical alignment: " ) + aValue);
501  break;
502 
503  case FDC_ITALIC:
504  field.SetItalic( BoolFromString( aValue ) );
505  break;
506 
507  case FDC_BOLD:
508  field.SetBold( BoolFromString( aValue ) );
509  break;
510 
511  case FDC_TEXT_SIZE:
512  field.SetTextSize( wxSize( ValueFromString( m_userUnits, aValue ),
513  ValueFromString( m_userUnits, aValue ) ) );
514  break;
515 
516  case FDC_ORIENTATION:
517  if( aValue == _( "Horizontal" ) )
518  field.SetTextAngle( TEXT_ANGLE_HORIZ );
519  else if( aValue == _( "Vertical" ) )
520  field.SetTextAngle( TEXT_ANGLE_VERT );
521  else
522  wxFAIL_MSG( wxT( "unknown orientation: " ) + aValue );
523  break;
524 
525  case FDC_POSX:
526  case FDC_POSY:
527  pos = field.GetTextPos();
528  if( aCol == FDC_POSX )
529  pos.x = ValueFromString( m_userUnits, aValue );
530  else
531  pos.y = ValueFromString( m_userUnits, aValue );
532  field.SetTextPos( pos );
533  break;
534 
535  default:
536  wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a string value" ), aCol ) );
537  break;
538  }
539 
540  GetView()->Refresh();
541 }
542 
543 
544 template <class T>
545 void FIELDS_GRID_TABLE<T>::SetValueAsBool( int aRow, int aCol, bool aValue )
546 {
547  wxCHECK( aRow < GetNumberRows(), /*void*/ );
548  T& field = this->at( (size_t) aRow );
549 
550  switch( aCol )
551  {
552  case FDC_SHOWN:
553  field.SetVisible( aValue );
554  break;
555  case FDC_ITALIC:
556  field.SetItalic( aValue );
557  break;
558  case FDC_BOLD:
559  field.SetBold( aValue );
560  break;
561  default:
562  wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a bool value" ), aCol ) );
563  break;
564  }
565 }
566 
567 
568 // Explicit Instantiations
569 
570 template class FIELDS_GRID_TABLE<SCH_FIELD>;
571 template class FIELDS_GRID_TABLE<LIB_FIELD>;
572 
573 
575 {
576  if( m_grid->GetGridCursorRow() == FOOTPRINT_FIELD && m_grid->GetGridCursorCol() == FDC_VALUE )
577  {
578  menu.Append( MYID_SELECT_FOOTPRINT, _( "Select Footprint..." ),
579  _( "Browse for footprint" ) );
580  menu.AppendSeparator();
581  }
582  else if( m_grid->GetGridCursorRow() == DATASHEET_FIELD && m_grid->GetGridCursorCol() == FDC_VALUE )
583  {
584  menu.Append( MYID_SHOW_DATASHEET, _( "Show Datasheet" ),
585  _( "Show datasheet in browser" ) );
586  menu.AppendSeparator();
587  }
588 
590 }
591 
592 
593 void FIELDS_GRID_TRICKS::doPopupSelection( wxCommandEvent& event )
594 {
595  if( event.GetId() == MYID_SELECT_FOOTPRINT )
596  {
597  // pick a footprint using the footprint picker.
598  wxString fpid = m_grid->GetCellValue( FOOTPRINT_FIELD, FDC_VALUE );
600 
601  if( frame->ShowModal( &fpid, m_dlg ) )
602  m_grid->SetCellValue( FOOTPRINT_FIELD, FDC_VALUE, fpid );
603 
604  frame->Destroy();
605  }
606  else if (event.GetId() == MYID_SHOW_DATASHEET )
607  {
608  wxString datasheet_uri = m_grid->GetCellValue( DATASHEET_FIELD, FDC_VALUE );
609  GetAssociatedDocument( m_dlg, datasheet_uri, &m_dlg->Prj() );
610  }
611  else
612  {
614  }
615 }
616 
617 
618 template <class T>
619 wxString FIELDS_GRID_TABLE<T>::StringFromBool( bool aValue ) const
620 {
621  if( aValue )
622  return wxT( "1" );
623  else
624  return wxT( "0" );
625 }
626 
627 
628 template <class T>
629 bool FIELDS_GRID_TABLE<T>::BoolFromString( wxString aValue ) const
630 {
631  if( aValue == "1" )
632  {
633  return true;
634  }
635  else if( aValue == "0" )
636  {
637  return false;
638  }
639  else
640  {
641  wxFAIL_MSG( wxString::Format( "string \"%s\" can't be converted to boolean "
642  "correctly, it will have been perceived as FALSE", aValue ) );
643  return false;
644  }
645 }
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:71
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:345
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:451
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:44
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:219
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:225
#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".