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