KiCad PCB EDA Suite
dialog_edit_component_in_lib.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) 1992-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 <fctsys.h>
25 #include <kiway.h>
26 #include <common.h>
27 #include <confirm.h>
28 #include <pgm_base.h>
29 #include <kiface_i.h>
30 #include <dialog_text_entry.h>
31 #include <math/util.h> // for KiROUND
32 
33 #include <general.h>
34 #include <widgets/wx_grid.h>
36 #include <lib_edit_frame.h>
37 #include <lib_manager.h>
38 #include <class_libentry.h>
39 #include <symbol_lib_table.h>
40 #include <sch_item.h>
41 #include <sch_component.h>
42 #include <dialog_helpers.h>
43 #include <bitmaps.h>
44 
45 #ifdef KICAD_SPICE
46 #include <dialog_spice_model.h>
48 #endif /* KICAD_SPICE */
49 
51 
52 
53 #define LibEditFieldsShownColumnsKey wxT( "LibEditFieldsShownColumns" )
54 
58 
59 
61  LIB_PART* aLibEntry ) :
63  m_Parent( aParent ),
64  m_libEntry( aLibEntry ),
65  m_pinNameOffset( aParent, m_nameOffsetLabel, m_nameOffsetCtrl, m_nameOffsetUnits, true ),
66  m_delayedFocusCtrl( nullptr ),
67  m_delayedFocusGrid( nullptr ),
68  m_delayedFocusRow( -1 ),
69  m_delayedFocusColumn( -1 ),
70  m_delayedFocusPage( -1 ),
71  m_width( 0 )
72 {
74 
75  // Give a bit more room for combobox editors
76  m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 );
77  m_fields = new FIELDS_GRID_TABLE<LIB_FIELD>( this, aParent, m_libEntry );
79  m_grid->PushEventHandler( new FIELDS_GRID_TRICKS( m_grid, this ) );
80 
81  // Show/hide columns according to the user's preference
82  m_config->Read( LibEditFieldsShownColumnsKey, &m_shownColumns, wxT( "0 1 2 3 4 5 6 7" ) );
84 
85  wxGridCellAttr* attr = new wxGridCellAttr;
86  attr->SetEditor( new GRID_CELL_URL_EDITOR( this ) );
87  m_grid->SetAttr( DATASHEET, FDC_VALUE, attr );
88 
89  m_SymbolNameCtrl->SetValidator( SCH_FIELD_VALIDATOR( true, VALUE ) );
90 
91  // Configure button logos
92  m_bpAdd->SetBitmap( KiBitmap( small_plus_xpm ) );
93  m_bpDelete->SetBitmap( KiBitmap( trash_xpm ) );
94  m_bpMoveUp->SetBitmap( KiBitmap( small_up_xpm ) );
95  m_bpMoveDown->SetBitmap( KiBitmap( small_down_xpm ) );
96  m_addFilterButton->SetBitmap( KiBitmap( small_plus_xpm ) );
97  m_deleteFilterButton->SetBitmap( KiBitmap( trash_xpm ) );
99 
100  m_stdSizerButtonOK->SetDefault();
101 
102 #ifndef KICAD_SPICE
103  m_spiceFieldsButton->Hide();
104 #endif
105 
106  // wxFormBuilder doesn't include this event...
107  m_grid->Connect( wxEVT_GRID_CELL_CHANGING,
109  NULL, this );
110 
112  {
115  {
116  ResetSize();
117  }
118  }
119 
122 
123  m_grid->GetParent()->Layout();
125  Layout();
126 
128 }
129 
130 
132 {
133  m_lastOpenedPage = m_NoteBook->GetSelection( );
134 
136 
137  // Prevents crash bug in wxGrid's d'tor
139 
140  m_grid->Disconnect( wxEVT_GRID_CELL_CHANGING,
142  NULL, this );
143 
144  // Delete the GRID_TRICKS.
145  m_grid->PopEventHandler( true );
146 }
147 
148 
150 {
151  if( !wxDialog::TransferDataToWindow() )
152  return false;
153 
154  // Push a copy of each field into m_fields
156 
157  // Copy the data sheet field from the old alias document file name if it's not empty.
158  if( !m_libEntry->GetDocFileName().IsEmpty() )
159  m_fields->at( DATASHEET ).SetText( m_libEntry->GetDocFileName() );
160 
161  // The Y axis for components in lib is from bottom to top while the screen axis is top
162  // to bottom: we must change the y coord sign for editing
163  for( size_t i = 0; i < m_fields->size(); ++i )
164  {
165  wxPoint pos = m_fields->at( i ).GetPosition();
166  pos.y = -pos.y;
167  m_fields->at( i ).SetPosition( pos );
168  }
169 
170  // notify the grid
171  wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, m_fields->GetNumberRows() );
172  m_grid->ProcessTableMessage( msg );
173  adjustGridColumns( m_grid->GetRect().GetWidth() );
174 
175  m_SymbolNameCtrl->SetValue( m_libEntry->GetName() );
176 
177  m_DescCtrl->SetValue( m_libEntry->GetDescription() );
178  m_KeywordCtrl->SetValue( m_libEntry->GetKeyWords() );
181  m_AsConvertButt->SetValue( m_libEntry->HasConversion() );
182  m_OptionPower->SetValue( m_libEntry->IsPower() );
183 
185  m_ShowPinNameButt->SetValue( m_libEntry->ShowPinNames() );
186  m_PinsNameInsideButt->SetValue( m_libEntry->GetPinNameOffset() != 0 );
188 
189  wxArrayString tmp = m_libEntry->GetFootprints();
190  m_FootprintFilterListBox->Append( tmp );
191 
192  // Populate the list of root parts for inherited objects.
193  if( m_libEntry->IsAlias() )
194  {
195  wxArrayString rootSymbolNames;
196  wxString libName = m_Parent->GetCurLib();
197 
198  // Someone forgot to set the current library in the editor frame window.
199  wxCHECK( !libName.empty(), false );
200 
201  m_Parent->GetLibManager().GetRootSymbolNames( libName, rootSymbolNames );
202  m_inheritanceSelectCombo->Append( rootSymbolNames );
203 
204  PART_SPTR rootPart = m_libEntry->GetParent().lock();
205 
206  wxCHECK( rootPart, false );
207 
208  wxString parentName = rootPart->GetName();
209  int selection = m_inheritanceSelectCombo->FindString( parentName );
210 
211  wxCHECK( selection != wxNOT_FOUND, false );
212  m_inheritanceSelectCombo->SetSelection( selection );
213 
214  // Copy the reference field from the root symbol to prevent validation errors.
215  m_fields->at( REFERENCE ).SetText( rootPart->GetReferenceField().GetText() );
216  m_lastOpenedPage = 0;
217  }
218 
219  m_NoteBook->SetSelection( (unsigned) m_lastOpenedPage );
220 
221  return true;
222 }
223 
224 
226 {
227  if( !m_grid->CommitPendingChanges() )
228  return false;
229 
230  if( !SCH_COMPONENT::IsReferenceStringValid( m_fields->at( REFERENCE ).GetText() ) )
231  {
232  if( m_NoteBook->GetSelection() != 0 )
233  m_NoteBook->SetSelection( 0 );
234 
235  m_delayedErrorMessage = _( "References must start with a letter." );
239  m_delayedFocusPage = 0;
240 
241  return false;
242  }
243 
244  // Check for missing field names.
245  for( size_t i = MANDATORY_FIELDS; i < m_fields->size(); ++i )
246  {
247  LIB_FIELD& field = m_fields->at( i );
248  wxString fieldName = field.GetName( false );
249 
250  if( fieldName.IsEmpty() )
251  {
252  if( m_NoteBook->GetSelection() != 0 )
253  m_NoteBook->SetSelection( 0 );
254 
255  m_delayedErrorMessage = _( "Fields must have a name." );
258  m_delayedFocusRow = i;
259  m_delayedFocusPage = 0;
260 
261  return false;
262  }
263  }
264 
265  if( m_SelNumberOfUnits->GetValue() < m_libEntry->GetUnitCount() )
266  {
267  if( !IsOK( this, _( "Delete extra units from symbol?" ) ) )
268  return false;
269  }
270 
271  if( m_AsConvertButt->GetValue() && !m_libEntry->HasConversion() )
272  {
273  if( !IsOK( this, _( "Add new pins for alternate body style (DeMorgan) to symbol?" ) ) )
274  return false;
275  }
276  else if( !m_AsConvertButt->GetValue() && m_libEntry->HasConversion() )
277  {
278  if( !IsOK( this, _( "Delete alternate body style (DeMorgan) draw items from symbol?" ) ) )
279  return false;
280  }
281 
282  return true;
283 }
284 
285 
287 {
288  if( !wxDialog::TransferDataFromWindow() )
289  return false;
290 
291  // We need to keep the name and the value the same at the moment!
292  wxString newName = m_fields->at( VALUE ).GetText();
293  wxString oldName = m_libEntry->GetName();
294 
295  if( oldName != newName )
296  {
297  wxString libName = m_Parent->GetCurLib();
298 
299  if( m_Parent->GetLibManager().PartExists( newName, libName ) )
300  {
301  wxString msg;
302 
303  msg.Printf( _( "The name '%s' conflicts with an existing entry in the library '%s'." ),
304  newName, libName );
305  DisplayErrorMessage( this, msg );
306  return false;
307  }
308 
310  }
311  else
312  {
314  }
315 
316  // The Y axis for components in lib is from bottom to top while the screen axis is top
317  // to bottom: we must change the y coord sign when writing back to the library
318  for( size_t i = 0; i < m_fields->size(); ++i )
319  {
320  wxPoint pos = m_fields->at( i ).GetPosition();
321  pos.y = -pos.y;
322  m_fields->at( i ).SetPosition( pos );
323  }
324 
325  // Datasheet field is special; copy it to the root alias docfilename
326  m_libEntry->SetDocFileName( m_fields->at( DATASHEET ).GetText() );
328 
329  // We need to keep the name and the value the same at the moment!
330  m_libEntry->SetName( newName );
331  m_libEntry->SetDescription( m_DescCtrl->GetValue() );
332  m_libEntry->SetKeyWords( m_KeywordCtrl->GetValue() );
335  m_libEntry->SetConversion( m_AsConvertButt->GetValue() );
336 
337  if( m_OptionPower->GetValue() )
338  m_libEntry->SetPower();
339  else
341 
344 
345  if( m_PinsNameInsideButt->GetValue() )
346  {
347  int offset = KiROUND( (double) m_pinNameOffset.GetValue() );
348 
349  // We interpret an offset of 0 as "outside", so make sure it's non-zero
350  m_libEntry->SetPinNameOffset( offset == 0 ? 20 : offset );
351  }
352  else
353  {
354  m_libEntry->SetPinNameOffset( 0 ); // pin text outside the body (name is on the pin)
355  }
356 
358 
359  if( oldName != newName )
361  else
363 
364  return true;
365 }
366 
367 
369 {
370  wxGridCellEditor* editor = m_grid->GetCellEditor( event.GetRow(), event.GetCol() );
371  wxControl* control = editor->GetControl();
372 
373  if( control && control->GetValidator() && !control->GetValidator()->Validate( control ) )
374  {
375  event.Veto();
376 
378  m_delayedFocusRow = event.GetRow();
379  m_delayedFocusColumn = event.GetCol();
380  m_delayedFocusPage = 0;
381  }
382  else if( event.GetRow() == VALUE && event.GetCol() == FDC_VALUE )
383  m_SymbolNameCtrl->ChangeValue( event.GetString() );
384 
385  editor->DecRef();
386 }
387 
388 
390 {
391  m_grid->SetCellValue( VALUE, FDC_VALUE, m_SymbolNameCtrl->GetValue() );
392 }
393 
394 
396 {
397  if( !m_delayedFocusCtrl && !m_SymbolNameCtrl->GetValidator()->Validate( m_SymbolNameCtrl ) )
398  {
400  m_delayedFocusPage = 0;
401  }
402 
403  event.Skip();
404 }
405 
406 
407 void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnAddField( wxCommandEvent& event )
408 {
409  if( !m_grid->CommitPendingChanges() )
410  return;
411 
412  int fieldID = m_fields->size();
413  LIB_FIELD newField( m_libEntry, fieldID );
414 
415  m_fields->push_back( newField );
416 
417  // notify the grid
418  wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
419  m_grid->ProcessTableMessage( msg );
420 
421  m_grid->MakeCellVisible( m_fields->size() - 1, 0 );
422  m_grid->SetGridCursor( m_fields->size() - 1, 0 );
423 
424  m_grid->EnableCellEditControl();
425  m_grid->ShowCellEditControl();
426 }
427 
428 
430 {
431  int curRow = m_grid->GetGridCursorRow();
432 
433  if( curRow < 0 )
434  return;
435  else if( curRow < MANDATORY_FIELDS )
436  {
437  DisplayError( this, wxString::Format( _( "The first %d fields are mandatory." ),
438  MANDATORY_FIELDS ) );
439  return;
440  }
441 
442  m_grid->CommitPendingChanges( true /* quiet mode */ );
443 
444  m_fields->erase( m_fields->begin() + curRow );
445 
446  // notify the grid
447  wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, curRow, 1 );
448  m_grid->ProcessTableMessage( msg );
449 
450  if( m_grid->GetNumberRows() > 0 )
451  {
452  m_grid->MakeCellVisible( std::max( 0, curRow-1 ), m_grid->GetGridCursorCol() );
453  m_grid->SetGridCursor( std::max( 0, curRow-1 ), m_grid->GetGridCursorCol() );
454  }
455 }
456 
457 
458 void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnMoveUp( wxCommandEvent& event )
459 {
460  if( !m_grid->CommitPendingChanges() )
461  return;
462 
463  int i = m_grid->GetGridCursorRow();
464 
465  if( i > MANDATORY_FIELDS )
466  {
467  LIB_FIELD tmp = m_fields->at( (unsigned) i );
468  m_fields->erase( m_fields->begin() + i, m_fields->begin() + i + 1 );
469  m_fields->insert( m_fields->begin() + i - 1, tmp );
470  m_grid->ForceRefresh();
471 
472  m_grid->SetGridCursor( i - 1, m_grid->GetGridCursorCol() );
473  m_grid->MakeCellVisible( m_grid->GetGridCursorRow(), m_grid->GetGridCursorCol() );
474  }
475  else
476  wxBell();
477 }
478 
479 
480 void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnMoveDown( wxCommandEvent& event )
481 {
482  if( !m_grid->CommitPendingChanges() )
483  return;
484 
485  int i = m_grid->GetGridCursorRow();
486 
487  if( i >= MANDATORY_FIELDS && i + 1 < m_fields->GetNumberRows() )
488  {
489  LIB_FIELD tmp = m_fields->at( (unsigned) i );
490  m_fields->erase( m_fields->begin() + i, m_fields->begin() + i + 1 );
491  m_fields->insert( m_fields->begin() + i + 1, tmp );
492  m_grid->ForceRefresh();
493 
494  m_grid->SetGridCursor( i + 1, m_grid->GetGridCursorCol() );
495  m_grid->MakeCellVisible( m_grid->GetGridCursorRow(), m_grid->GetGridCursorCol() );
496  }
497  else
498  wxBell();
499 }
500 
501 
503 {
504 #ifdef KICAD_SPICE
505  int diff = m_fields->size();
506  auto cmp = SCH_COMPONENT( *m_libEntry, m_libEntry->GetLibId(), nullptr );
507 
508  DIALOG_SPICE_MODEL dialog( this, cmp, m_fields );
509 
510  if( dialog.ShowModal() != wxID_OK )
511  return;
512 
513  diff = m_fields->size() - diff;
514 
515  if( diff > 0 )
516  {
517  wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, diff );
518  m_grid->ProcessTableMessage( msg );
519  }
520  else if( diff < 0 )
521  {
522  wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, 0, diff );
523  m_grid->ProcessTableMessage( msg );
524  }
525 
526  m_grid->ForceRefresh();
527 #endif /* KICAD_SPICE */
528 }
529 
530 
532 {
533  int idx = m_FootprintFilterListBox->HitTest( event.GetPosition() );
534  wxCommandEvent dummy;
535 
536  if( idx >= 0 )
538  else
540 }
541 
542 
544 {
545  // Running the Footprint Browser gums up the works and causes the automatic cancel
546  // stuff to no longer work. So we do it here ourselves.
547  EndQuasiModal( wxID_CANCEL );
548 }
549 
550 
552 {
553  wxString filterLine;
554  WX_TEXT_ENTRY_DIALOG dlg( this, _( "Filter:" ), _( "Add Footprint Filter" ), filterLine );
555 
556  if( dlg.ShowModal() == wxID_CANCEL || dlg.GetValue().IsEmpty() )
557  return;
558 
559  filterLine = dlg.GetValue();
560  filterLine.Replace( wxT( " " ), wxT( "_" ) );
561 
562  // duplicate filters do no harm, so don't be a nanny.
563 
564  m_FootprintFilterListBox->Append( filterLine );
565  m_FootprintFilterListBox->SetSelection( m_FootprintFilterListBox->GetCount() - 1 );
566 }
567 
568 
570 {
571  int ii = m_FootprintFilterListBox->GetSelection();
572 
573  if( ii >= 0 )
574  {
575  m_FootprintFilterListBox->Delete( (unsigned) ii );
576 
577  if( m_FootprintFilterListBox->GetCount() == 0 )
578  m_FootprintFilterListBox->SetSelection( wxNOT_FOUND );
579  else
580  m_FootprintFilterListBox->SetSelection( std::max( 0, ii - 1 ) );
581  }
582 }
583 
584 
586 {
587  int idx = m_FootprintFilterListBox->GetSelection();
588 
589  if( idx >= 0 )
590  {
591  wxString filter = m_FootprintFilterListBox->GetStringSelection();
592 
593  WX_TEXT_ENTRY_DIALOG dlg( this, _( "Filter:" ), _( "Edit Footprint Filter" ), filter );
594 
595  if( dlg.ShowModal() == wxID_OK && !dlg.GetValue().IsEmpty() )
596  m_FootprintFilterListBox->SetString( (unsigned) idx, dlg.GetValue() );
597  }
598 }
599 
600 
602 {
603  m_width = aWidth;
604 
605  // Account for scroll bars
606  aWidth -= ( m_grid->GetSize().x - m_grid->GetClientSize().x );
607 
608  m_grid->AutoSizeColumn( FDC_NAME );
609 
610  int fixedColsWidth = m_grid->GetColSize( FDC_NAME );
611 
612  for( int i = 2; i < m_grid->GetNumberCols(); i++ )
613  fixedColsWidth += m_grid->GetColSize( i );
614 
615  m_grid->SetColSize( FDC_VALUE, aWidth - fixedColsWidth );
616 }
617 
618 
619 void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnUpdateUI( wxUpdateUIEvent& event )
620 {
621  m_OptionPartsLocked->Enable( m_SelNumberOfUnits->GetValue() > 1 );
623 
624  if( m_grid->IsCellEditControlShown() )
625  {
626  int row = m_grid->GetGridCursorRow();
627  int col = m_grid->GetGridCursorCol();
628 
629  if( row == VALUE && col == FDC_VALUE )
630  {
631  wxGridCellEditor* editor = m_grid->GetCellEditor( row, col );
632  m_SymbolNameCtrl->ChangeValue( editor->GetValue() );
633  editor->DecRef();
634  }
635  }
636 
637  // Handle shown columns changes
638  wxString shownColumns = m_grid->GetShownColumns();
639 
640  if( shownColumns != m_shownColumns )
641  {
642  m_shownColumns = shownColumns;
643 
644  if( !m_grid->IsCellEditControlShown() )
645  adjustGridColumns( m_grid->GetRect().GetWidth() );
646  }
647 
648  // Handle a delayed focus. The delay allows us to:
649  // a) change focus when the error was triggered from within a killFocus handler
650  // b) show the correct notebook page in the background before the error dialog comes up
651  // when triggered from an OK or a notebook page change
652 
653  if( m_delayedFocusPage >= 0 && m_NoteBook->GetSelection() != m_delayedFocusPage )
654  {
655  m_NoteBook->SetSelection( (unsigned) m_delayedFocusPage );
656  m_delayedFocusPage = -1;
657  }
658 
659  if( !m_delayedErrorMessage.IsEmpty() )
660  {
661  // We will re-enter this routine when the error dialog is displayed, so make
662  // sure we don't keep putting up more dialogs.
663  wxString msg = m_delayedErrorMessage;
664  m_delayedErrorMessage = wxEmptyString;
665 
666  // Do not use DisplayErrorMessage(); it screws up window order on Mac
667  DisplayError( nullptr, msg );
668  }
669 
670  if( m_delayedFocusCtrl )
671  {
672  m_delayedFocusCtrl->SetFocus();
673 
674  if( auto textEntry = dynamic_cast<wxTextEntry*>( m_delayedFocusCtrl ) )
675  textEntry->SelectAll();
676 
677  m_delayedFocusCtrl = nullptr;
678  }
679  else if( m_delayedFocusGrid )
680  {
681  m_delayedFocusGrid->SetFocus();
684 
685  m_delayedFocusGrid->EnableCellEditControl( true );
686  m_delayedFocusGrid->ShowCellEditControl();
687 
688  m_delayedFocusGrid = nullptr;
689  m_delayedFocusRow = -1;
691  }
692 }
693 
694 
696 {
697  auto new_size = event.GetSize().GetX();
698 
699  if( new_size != m_width )
700  {
701  adjustGridColumns( event.GetSize().GetX() );
702  }
703 
704  // Always propagate a wxSizeEvent:
705  event.Skip();
706 }
707 
708 
710 {
711  // Remove the not wanted notebook page.
712  // *Do not use* Hide(), it is suitable to hide a widget,
713  // but it is not suitable to hide a notebook page (that is not a widget)
714  if( aIsAlias )
715  m_NoteBook->RemovePage( 1 );
716 
717  bSizerLowerBasicPanel->Show( !aIsAlias );
718  bButtonSize->Show( !aIsAlias );
719 
720 #ifdef KICAD_SPICE
721  m_spiceFieldsButton->Show( !aIsAlias );
722 #endif
723 
724  m_inheritanceSelectCombo->Enable( aIsAlias );
725  m_inheritsStaticText->Enable( aIsAlias );
726  m_grid->ForceRefresh();
727 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:236
wxString GetName(bool aTranslate=true) const
Returns the field name.
Definition: lib_field.cpp:366
const BITMAP_OPAQUE trash_xpm[1]
Definition: trash.cpp:46
void OnAddFootprintFilter(wxCommandEvent &event) override
void SetConversion(bool aSetConvert)
Set or clear the alternate body style (DeMorgan) for the part.
void SetPower()
name of datasheet
LIB_ID GetLibId() const override
void OnUpdateUI(wxUpdateUIEvent &event) override
int GetPinNameOffset()
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:249
int GetNumberRows() override
void OnEditFootprintFilter(wxCommandEvent &event) override
wxString GetName() const override
void OnSizeGrid(wxSizeEvent &event) override
This file is part of the common library.
bool HasConversion() const
Test if part has more than one body conversion type (DeMorgan).
void ShowHideColumns(const wxString &shownColumns)
Show/hide the grid columns based on a tokenized string of shown column indexes.
Definition: wx_grid.cpp:119
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
Field object used in symbol libraries.
Definition: lib_field.h:59
void ResetSize()
Clear the existing dialog size and position.
wxConfigBase * KifaceSettings() const
Definition: kiface_i.h:103
void FinishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
void SetFootprintFilters(const wxArrayString &aFootprintFilters)
void SetTable(wxGridTableBase *table, bool aTakeOwnership=false)
Hide wxGrid's SetTable() method with one which doesn't mess up the grid column widths when setting th...
Definition: wx_grid.cpp:57
wxString GetKeyWords() const
void OnSymbolNameText(wxCommandEvent &event) override
void OnCancelButtonClick(wxCommandEvent &event) override
void OnDeleteFootprintFilter(wxCommandEvent &event) override
Field Reference of part, i.e. "IC21".
void OnMoveUp(wxCommandEvent &event) override
wxString GetCurLib() const
The nickname of the current library being edited and empty string if none.
DIALOG_EDIT_COMPONENT_IN_LIBRARY(LIB_EDIT_FRAME *parent, LIB_PART *aLibEntry)
Constructors.
void DestroyTable(wxGridTableBase *aTable)
Work-around for a bug in wxGrid which crashes when deleting the table if the cell edit control was no...
Definition: wx_grid.cpp:88
bool ShowPinNames()
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:79
#define VALUE
bool ShowPinNumbers()
#define NULL
int GetUnitCount() const override
For items with units, return the number of units.
void SetUnitCount(int count)
Set the units per part count.
void OnFilterDClick(wxMouseEvent &event) override
void OnDeleteField(wxCommandEvent &event) override
Class LIB_PIN definition.
std::shared_ptr< LIB_PART > PART_SPTR
shared pointer to LIB_PART
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
void SetDescription(const wxString &aDescription)
void SetDocFileName(const wxString &aDocFileName)
const BITMAP_OPAQUE small_down_xpm[1]
Definition: small_down.cpp:25
PART_REF & GetParent()
Define a library symbol object.
void UpdateAfterSymbolProperties(wxString *aOldName=nullptr)
Helper dialog and control classes.
wxString GetDocFileName() const
wxString GetDescription() override
void OnSymbolNameKillFocus(wxFocusEvent &event) override
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:172
bool PartExists(const wxString &aAlias, const wxString &aLibrary) const
Returns true if part with a specific alias exists in library (either original one or buffered).
wxArrayString GetFootprints() const
const BITMAP_OPAQUE small_up_xpm[1]
Definition: small_up.cpp:26
void OnMoveDown(wxCommandEvent &event) override
#define LibEditFieldsShownColumnsKey
void GetRootSymbolNames(const wxString &aLibName, wxArrayString &aRootSymbolNames)
wxString GetShownColumns()
Get a tokenized string containing the shown column indexes.
Definition: wx_grid.cpp:101
void EndQuasiModal(int retCode)
const BITMAP_OPAQUE small_edit_xpm[1]
Definition: small_edit.cpp:26
wxString GetValue()
The symbol library editor main window.
bool IsPower() const
see class PGM_BASE
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
void SetShowPinNumbers(bool aShow)
Set or clear the pin number visibility flag.
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
#define _(s)
Definition: 3d_actions.cpp:31
virtual void SetValue(int aValue)
Function SetValue Sets new value (in Internal Units) for the text field, taking care of units convers...
void SetKeyWords(const wxString &aKeyWords)
bool IsAlias() const
SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:89
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:61
bool IsRoot() const override
For symbols derived from other symbols, IsRoot() indicates no derivation.
The common library.
Class DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE.
virtual long long int GetValue()
Function GetValue Returns the current value in Internal Units.
virtual void SetName(const wxString &aName)
void OnEditSpiceModel(wxCommandEvent &event) override
A text control validator used for validating the text allowed in library and schematic component fiel...
static bool IsReferenceStringValid(const wxString &aReferenceString)
Tests for an acceptable reference string.
LIB_MANAGER & GetLibManager()
void SetShowPinNames(bool aShow)
Set or clear the pin name visibility flag.
void SetPinNameOffset(int aOffset)
Set the offset in mils of the pin name text from the pin symbol.
void SetFields(const std::vector< LIB_FIELD > &aFieldsList)
Overwrite all the existing fields in this symbol with fields supplied in aFieldsList.
void OnAddField(wxCommandEvent &event) override
FIELDS_GRID_TABLE< LIB_FIELD > * m_fields
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:280
const BITMAP_OPAQUE small_plus_xpm[1]
Definition: small_plus.cpp:20
bool UnitsLocked() const
Check whether part units are interchangeable.
void SaveCopyInUndoList(EDA_ITEM *ItemToCopy, UNDO_REDO_T undoType=UR_LIBEDIT, bool aAppend=false)
Create a copy of the current component, and save it in the undo list.
void Enable(bool aEnable)
Function Enable Enables/diasables the label, widget and units label.
void GetFields(LIB_FIELDS &aList)
Return a list of fields within this part.
void LockUnits(bool aLockUnits)
Set interchangeable the property for part units.
void SetNormal()