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>
37 
38 #include "eda_doc.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  LIB_PART* aPart ) :
51  m_frame( aFrame ),
52  m_userUnits( aDialog->GetUserUnits() ),
53  m_parentType( SCH_COMPONENT_T ),
54  m_mandatoryFieldCount( MANDATORY_FIELDS ),
55  m_part( aPart ),
56  m_fieldNameValidator( aFrame->IsType( FRAME_SCH_LIB_EDITOR ), FIELD_NAME ),
57  m_referenceValidator( aFrame->IsType( FRAME_SCH_LIB_EDITOR ), REFERENCE ),
58  m_valueValidator( aFrame->IsType( FRAME_SCH_LIB_EDITOR ), VALUE ),
59  m_libIdValidator( LIB_ID::ID_PCB ),
60  m_urlValidator( aFrame->IsType( FRAME_SCH_LIB_EDITOR ), FIELD_VALUE ),
61  m_nonUrlValidator( aFrame->IsType( FRAME_SCH_LIB_EDITOR ), FIELD_VALUE ),
62  m_filepathValidator( aFrame->IsType( FRAME_SCH_LIB_EDITOR ), SHEETFILENAME )
63 {
64  initGrid( aDialog );
65 }
66 
67 
68 template <class T>
70  SCH_SHEET* aSheet ) :
71  m_frame( aFrame ),
72  m_userUnits( aDialog->GetUserUnits() ),
73  m_parentType( SCH_SHEET_T ),
74  m_mandatoryFieldCount( SHEET_MANDATORY_FIELDS ),
75  m_part( nullptr ),
76  m_fieldNameValidator( aFrame->IsType( FRAME_SCH_LIB_EDITOR ), FIELD_NAME ),
77  m_referenceValidator( aFrame->IsType( FRAME_SCH_LIB_EDITOR ), SHEETNAME_V ),
78  m_valueValidator( aFrame->IsType( FRAME_SCH_LIB_EDITOR ), VALUE ),
79  m_libIdValidator( LIB_ID::ID_PCB ),
80  m_urlValidator( aFrame->IsType( FRAME_SCH_LIB_EDITOR ), FIELD_VALUE ),
81  m_nonUrlValidator( aFrame->IsType( FRAME_SCH_LIB_EDITOR ), FIELD_VALUE ),
82  m_filepathValidator( aFrame->IsType( FRAME_SCH_LIB_EDITOR ), SHEETFILENAME_V )
83 {
84  initGrid( aDialog );
85 }
86 
87 
88 template <class T>
90 {
91  // Build the various grid cell attributes.
92  // NOTE: validators and cellAttrs are member variables to get the destruction order
93  // right. wxGrid is VERY cranky about this.
94 
95  m_readOnlyAttr = new wxGridCellAttr;
96  m_readOnlyAttr->SetReadOnly( true );
97 
98  m_fieldNameAttr = new wxGridCellAttr;
99  GRID_CELL_TEXT_EDITOR* nameEditor = new GRID_CELL_TEXT_EDITOR();
100  nameEditor->SetValidator( m_fieldNameValidator );
101  m_fieldNameAttr->SetEditor( nameEditor );
102 
103  m_referenceAttr = new wxGridCellAttr;
104  GRID_CELL_TEXT_EDITOR* referenceEditor = new GRID_CELL_TEXT_EDITOR();
105  referenceEditor->SetValidator( m_referenceValidator );
106  m_referenceAttr->SetEditor( referenceEditor );
107 
108  m_valueAttr = new wxGridCellAttr;
109  GRID_CELL_TEXT_EDITOR* valueEditor = new GRID_CELL_TEXT_EDITOR();
110  valueEditor->SetValidator( m_valueValidator );
111  m_valueAttr->SetEditor( valueEditor );
112 
113  m_footprintAttr = new wxGridCellAttr;
115  fpIdEditor->SetValidator( m_libIdValidator );
116  m_footprintAttr->SetEditor( fpIdEditor );
117 
118  m_urlAttr = new wxGridCellAttr;
119  GRID_CELL_URL_EDITOR* urlEditor = new GRID_CELL_URL_EDITOR( aDialog );
120  urlEditor->SetValidator( m_urlValidator );
121  m_urlAttr->SetEditor( urlEditor );
122 
123  m_nonUrlAttr = new wxGridCellAttr;
124  GRID_CELL_TEXT_EDITOR* nonUrlEditor = new GRID_CELL_TEXT_EDITOR();
125  nonUrlEditor->SetValidator( m_nonUrlValidator );
126  m_nonUrlAttr->SetEditor( nonUrlEditor );
127 
128  m_curdir = m_frame->Prj().GetProjectPath();
129  m_filepathAttr = new wxGridCellAttr;
130 
131  // Create a wild card using wxFileDialog syntax.
132  wxString wildCard( _( "Schematic Files" ) );
133  std::vector<std::string> exts;
134  exts.push_back( KiCadSchematicFileExtension );
135  wildCard += AddFileExtListToFilter( exts );
136 
137  GRID_CELL_PATH_EDITOR* filepathEditor =
138  new GRID_CELL_PATH_EDITOR( aDialog, &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_BOTTOM );
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 )
267  {
268  m_referenceAttr->IncRef();
269  return m_referenceAttr;
270  }
271  else if( m_parentType == SCH_COMPONENT_T && aRow == VALUE )
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_LIB_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 )
289  {
290  m_footprintAttr->IncRef();
291  return m_footprintAttr;
292  }
293  else if( m_parentType == SCH_COMPONENT_T && aRow == DATASHEET )
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 fieldname = GetValue( aRow, FDC_NAME );
311  const TEMPLATE_FIELDNAME* templateFn = m_frame->GetTemplateFieldName( fieldname );
312 
313  if( templateFn && templateFn->m_URL )
314  {
315  m_urlAttr->IncRef();
316  return m_urlAttr;
317  }
318  else
319  {
320  m_nonUrlAttr->IncRef();
321  return m_nonUrlAttr;
322  }
323  }
324 
325  return nullptr;
326 
327  case FDC_TEXT_SIZE:
328  case FDC_POSX:
329  case FDC_POSY:
330  return nullptr;
331 
332  case FDC_H_ALIGN:
333  m_hAlignAttr->IncRef();
334  return m_hAlignAttr;
335 
336  case FDC_V_ALIGN:
337  m_vAlignAttr->IncRef();
338  return m_vAlignAttr;
339 
340  case FDC_ORIENTATION:
341  m_orientationAttr->IncRef();
342  return m_orientationAttr;
343 
344  case FDC_SHOWN:
345  case FDC_ITALIC:
346  case FDC_BOLD:
347  m_boolAttr->IncRef();
348  return m_boolAttr;
349 
350  default:
351  wxFAIL;
352  return nullptr;
353  }
354 }
355 
356 
357 template <class T>
358 wxString FIELDS_GRID_TABLE<T>::GetValue( int aRow, int aCol )
359 {
360  wxCHECK( aRow < GetNumberRows(), wxEmptyString );
361  const T& field = this->at( (size_t) aRow );
362 
363  switch( aCol )
364  {
365  case FDC_NAME:
366  // Use default field name for mandatory fields, because they are translated
367  // according to the current locale
368  if( aRow < m_mandatoryFieldCount )
369  {
370  if( m_parentType == SCH_COMPONENT_T )
372  else if( m_parentType == SCH_SHEET_T )
373  return SCH_SHEET::GetDefaultFieldName( aRow );
374  }
375 
376  return field.GetName( false );
377 
378  case FDC_VALUE:
379  return field.GetText();
380 
381  case FDC_SHOWN:
382  return StringFromBool( field.IsVisible() );
383 
384  case FDC_H_ALIGN:
385  switch ( field.GetHorizJustify() )
386  {
387  case GR_TEXT_HJUSTIFY_LEFT: return _( "Left" );
388  case GR_TEXT_HJUSTIFY_CENTER: return _( "Center" );
389  case GR_TEXT_HJUSTIFY_RIGHT: return _( "Right" );
390  }
391 
392  break;
393 
394  case FDC_V_ALIGN:
395  switch ( field.GetVertJustify() )
396  {
397  case GR_TEXT_VJUSTIFY_TOP: return _( "Top" );
398  case GR_TEXT_VJUSTIFY_CENTER: return _( "Center" );
399  case GR_TEXT_VJUSTIFY_BOTTOM: return _( "Bottom" );
400  }
401 
402  break;
403 
404  case FDC_ITALIC:
405  return StringFromBool( field.IsItalic() );
406 
407  case FDC_BOLD:
408  return StringFromBool( field.IsBold() );
409 
410  case FDC_TEXT_SIZE:
411  return StringFromValue( m_userUnits, field.GetTextSize().GetHeight(), true, true );
412 
413  case FDC_ORIENTATION:
414  switch ( (int) field.GetTextAngle() )
415  {
416  case TEXT_ANGLE_HORIZ: return _( "Horizontal" );
417  case TEXT_ANGLE_VERT: return _( "Vertical" );
418  }
419 
420  break;
421 
422  case FDC_POSX:
423  return StringFromValue( m_userUnits, field.GetTextPos().x, true );
424 
425  case FDC_POSY:
426  return StringFromValue( m_userUnits, field.GetTextPos().y, true );
427 
428  default:
429  // we can't assert here because wxWidgets sometimes calls this without checking
430  // the column type when trying to see if there's an overflow
431  break;
432  }
433 
434  return wxT( "bad wxWidgets!" );
435 }
436 
437 
438 template <class T>
439 bool FIELDS_GRID_TABLE<T>::GetValueAsBool( int aRow, int aCol )
440 {
441  wxCHECK( aRow < GetNumberRows(), false );
442  const T& field = this->at( (size_t) aRow );
443 
444  switch( aCol )
445  {
446  case FDC_SHOWN: return field.IsVisible();
447  case FDC_ITALIC: return field.IsItalic();
448  case FDC_BOLD: return field.IsBold();
449  default:
450  wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a bool value" ), aCol ) );
451  return false;
452  }
453 }
454 
455 
456 template <class T>
457 void FIELDS_GRID_TABLE<T>::SetValue( int aRow, int aCol, const wxString &aValue )
458 {
459  wxCHECK( aRow < GetNumberRows(), /*void*/ );
460  T& field = this->at( (size_t) aRow );
461  wxPoint pos;
462 
463  switch( aCol )
464  {
465  case FDC_NAME:
466  field.SetName( aValue );
467  break;
468 
469  case FDC_VALUE:
470  field.SetText( aValue );
471  break;
472 
473  case FDC_SHOWN:
474  field.SetVisible( BoolFromString( aValue ) );
475  break;
476 
477  case FDC_H_ALIGN:
478  if( aValue == _( "Left" ) )
479  field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
480  else if( aValue == _( "Center" ) )
481  field.SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
482  else if( aValue == _( "Right" ) )
483  field.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
484  else
485  wxFAIL_MSG( wxT( "unknown horizontal alignment: " ) + aValue );
486  break;
487 
488  case FDC_V_ALIGN:
489  if( aValue == _( "Top" ) )
490  field.SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
491  else if( aValue == _( "Center" ) )
492  field.SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
493  else if( aValue == _( "Bottom" ) )
494  field.SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
495  else
496  wxFAIL_MSG( wxT( "unknown vertical alignment: " ) + aValue);
497  break;
498 
499  case FDC_ITALIC:
500  field.SetItalic( BoolFromString( aValue ) );
501  break;
502 
503  case FDC_BOLD:
504  field.SetBold( BoolFromString( aValue ) );
505  break;
506 
507  case FDC_TEXT_SIZE:
508  field.SetTextSize( wxSize( ValueFromString( m_userUnits, aValue ),
509  ValueFromString( m_userUnits, aValue ) ) );
510  break;
511 
512  case FDC_ORIENTATION:
513  if( aValue == _( "Horizontal" ) )
514  field.SetTextAngle( TEXT_ANGLE_HORIZ );
515  else if( aValue == _( "Vertical" ) )
516  field.SetTextAngle( TEXT_ANGLE_VERT );
517  else
518  wxFAIL_MSG( wxT( "unknown orientation: " ) + aValue );
519  break;
520 
521  case FDC_POSX:
522  case FDC_POSY:
523  pos = field.GetTextPos();
524  if( aCol == FDC_POSX )
525  pos.x = ValueFromString( m_userUnits, aValue );
526  else
527  pos.y = ValueFromString( m_userUnits, aValue );
528  field.SetTextPos( pos );
529  break;
530 
531  default:
532  wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a string value" ), aCol ) );
533  break;
534  }
535 
536  GetView()->Refresh();
537 }
538 
539 
540 template <class T>
541 void FIELDS_GRID_TABLE<T>::SetValueAsBool( int aRow, int aCol, bool aValue )
542 {
543  wxCHECK( aRow < GetNumberRows(), /*void*/ );
544  T& field = this->at( (size_t) aRow );
545 
546  switch( aCol )
547  {
548  case FDC_SHOWN:
549  field.SetVisible( aValue );
550  break;
551  case FDC_ITALIC:
552  field.SetItalic( aValue );
553  break;
554  case FDC_BOLD:
555  field.SetBold( aValue );
556  break;
557  default:
558  wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a bool value" ), aCol ) );
559  break;
560  }
561 }
562 
563 
564 // Explicit Instantiations
565 
566 template class FIELDS_GRID_TABLE<SCH_FIELD>;
567 template class FIELDS_GRID_TABLE<LIB_FIELD>;
568 
569 
571 {
572  if( m_grid->GetGridCursorRow() == FOOTPRINT && m_grid->GetGridCursorCol() == FDC_VALUE )
573  {
574  menu.Append( MYID_SELECT_FOOTPRINT, _( "Select Footprint..." ),
575  _( "Browse for footprint" ) );
576  menu.AppendSeparator();
577  }
578  else if( m_grid->GetGridCursorRow() == DATASHEET && m_grid->GetGridCursorCol() == FDC_VALUE )
579  {
580  menu.Append( MYID_SHOW_DATASHEET, _( "Show Datasheet" ),
581  _( "Show datasheet in browser" ) );
582  menu.AppendSeparator();
583  }
584 
586 }
587 
588 
589 void FIELDS_GRID_TRICKS::doPopupSelection( wxCommandEvent& event )
590 {
591  if( event.GetId() == MYID_SELECT_FOOTPRINT )
592  {
593  // pick a footprint using the footprint picker.
594  wxString fpid = m_grid->GetCellValue( FOOTPRINT, FDC_VALUE );
596 
597  if( frame->ShowModal( &fpid, m_dlg ) )
598  m_grid->SetCellValue( FOOTPRINT, FDC_VALUE, fpid );
599 
600  frame->Destroy();
601  }
602  else if (event.GetId() == MYID_SHOW_DATASHEET )
603  {
604  wxString datasheet_uri = m_grid->GetCellValue( DATASHEET, FDC_VALUE );
605  GetAssociatedDocument( m_dlg, datasheet_uri, &m_dlg->Prj() );
606  }
607  else
608  {
610  }
611 }
612 
613 
614 template <class T>
616 {
617  if( aValue )
618  return wxT( "1" );
619  else
620  return wxT( "0" );
621 }
622 
623 
624 template <class T>
626 {
627  if( aValue == "1" )
628  {
629  return true;
630  }
631  else if( aValue == "0" )
632  {
633  return false;
634  }
635  else
636  {
637  wxFAIL_MSG( wxString::Format( "string \"%s\" can't be converted to boolean "
638  "correctly, it will have been perceived as FALSE", aValue ) );
639  return false;
640  }
641 }
#define TEXT_ANGLE_HORIZ
virtual void showPopupMenu(wxMenu &menu) override
bool GetAssociatedDocument(wxWindow *aParent, const wxString &aDocName, PROJECT *aProject)
Function GetAssociatedDocument open a document (file) with the suitable browser.
Definition: eda_doc.cpp:80
KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of ...
Definition: kiway_player.h:59
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_holder.h:56
name of datasheet
#define TEXT_ANGLE_VERT
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:70
This file is part of the common library.
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
#define FIELD_VALUE
static const wxString GetDefaultFieldName(int aFieldNdx)
Function GetDefaultFieldName returns a default symbol field name for field aFieldNdx for all componen...
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
Definition: dialog_shim.h:83
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
wxString GetColLabelValue(int aCol) override
#define SHEETNAME_V
Field Name Module PCB, i.e. "16DIP300".
Field Reference of part, i.e. "IC21".
This class works around a bug in wxGrid where the first keystroke doesn't get sent through the valida...
Definition: validators.h:44
WX_GRID * m_grid
I don't own the grid, but he owns me.
Definition: grid_tricks.h:58
#define VALUE
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:342
PROJECT & Prj() const
Function Prj returns 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 of file extensions used in Kicad.
#define FIELD_NAME
bool BoolFromString(wxString aValue)
static const wxString GetDefaultFieldName(int aFieldNdx)
Definition: sch_sheet.cpp:45
wxGridCellAttr * GetAttr(int row, int col, wxGridCellAttr::wxAttrKind kind) override
void initGrid(DIALOG_SHIM *aDialog)
virtual void SetValidator(const wxValidator &validator) override
Definition: validators.cpp:46
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:216
virtual void doPopupSelection(wxCommandEvent &event)
bool GetValueAsBool(int aRow, int aCol) override
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
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
Struct TEMPLATE_FIELDNAME holds a name of a component's field, field value, and default visibility.
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
Definition for part library class.
FIELDS_GRID_TABLE(DIALOG_SHIM *aDialog, SCH_BASE_FRAME *aFrame, LIB_PART *aPart)
void SetValueAsBool(int aRow, int aCol, bool aValue) override
A shim class between EDA_DRAW_FRAME and several derived classes: LIB_EDIT_FRAME, LIB_VIEW_FRAME,...
virtual void doPopupSelection(wxCommandEvent &event) override
virtual bool ShowModal(wxString *aResult=NULL, wxWindow *aResultantFocusWindow=NULL)
Function ShowModal puts up this wxFrame as if it were a modal dialog, with all other instantiated wxF...
wxString StringFromValue(EDA_UNITS aUnits, double aValue, bool aAddUnitSymbol, bool aUseMils, EDA_DATA_TYPE aType)
Function StringFromValue returns the string from aValue according to units (inch, mm ....
Definition: base_units.cpp:233
Custom text control validator definitions.
long long int ValueFromString(EDA_UNITS aUnits, const wxString &aTextValue, bool aUseMils, EDA_DATA_TYPE aType)
Function ValueFromString converts aTextValue in aUnits to internal units used by the application.
Definition: base_units.cpp:471
wxString AddFileExtListToFilter(const std::vector< std::string > &aExts)
Build the wildcard extension file dialog wildcard filter to add to the base message dialog.
wxString StringFromBool(bool aValue)