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-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 <bitmaps.h>
25 #include <class_libentry.h>
26 #include <confirm.h>
27 #include <dialog_text_entry.h>
28 #include <fctsys.h>
29 #include <kiway.h>
30 #include <lib_edit_frame.h>
31 #include <lib_manager.h>
32 #include <math/util.h> // for KiROUND
33 #include <pgm_base.h>
34 #include <sch_component.h>
36 #include <widgets/wx_grid.h>
37 
38 #ifdef KICAD_SPICE
39 #include <dialog_spice_model.h>
40 #endif /* KICAD_SPICE */
41 
44 #include <libedit_settings.h>
45 
46 
50 
51 
53  LIB_PART* aLibEntry ) :
55  m_Parent( aParent ),
56  m_libEntry( aLibEntry ),
57  m_pinNameOffset( aParent, m_nameOffsetLabel, m_nameOffsetCtrl, m_nameOffsetUnits, true ),
58  m_delayedFocusCtrl( nullptr ),
59  m_delayedFocusGrid( nullptr ),
60  m_delayedFocusRow( -1 ),
61  m_delayedFocusColumn( -1 ),
62  m_delayedFocusPage( -1 ),
63  m_width( 0 )
64 {
65  // Give a bit more room for combobox editors
66  m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 );
67  m_fields = new FIELDS_GRID_TABLE<LIB_FIELD>( this, aParent, m_libEntry );
69  m_grid->PushEventHandler( new FIELDS_GRID_TRICKS( m_grid, this ) );
70 
71  // Show/hide columns according to the user's preference
72  auto cfg = Pgm().GetSettingsManager().GetAppSettings<LIBEDIT_SETTINGS>();
73  m_grid->ShowHideColumns( cfg->m_EditComponentVisibleColumns );
74 
75  wxGridCellAttr* attr = new wxGridCellAttr;
76  attr->SetEditor( new GRID_CELL_URL_EDITOR( this ) );
77  m_grid->SetAttr( DATASHEET, FDC_VALUE, attr );
78 
79  m_SymbolNameCtrl->SetValidator( SCH_FIELD_VALIDATOR( true, VALUE ) );
80 
81  // Configure button logos
82  m_bpAdd->SetBitmap( KiBitmap( small_plus_xpm ) );
83  m_bpDelete->SetBitmap( KiBitmap( trash_xpm ) );
84  m_bpMoveUp->SetBitmap( KiBitmap( small_up_xpm ) );
85  m_bpMoveDown->SetBitmap( KiBitmap( small_down_xpm ) );
86  m_addFilterButton->SetBitmap( KiBitmap( small_plus_xpm ) );
87  m_deleteFilterButton->SetBitmap( KiBitmap( trash_xpm ) );
89 
90  m_stdSizerButtonOK->SetDefault();
91 
92 #ifndef KICAD_SPICE
93  m_spiceFieldsButton->Hide();
94 #endif
95 
96  // wxFormBuilder doesn't include this event...
97  m_grid->Connect( wxEVT_GRID_CELL_CHANGING,
99  NULL, this );
100 
102  {
105  {
106  ResetSize();
107  }
108  }
109 
112 
113  m_grid->GetParent()->Layout();
115  Layout();
116 
118 }
119 
120 
122 {
123  m_lastOpenedPage = m_NoteBook->GetSelection( );
124 
125  auto cfg = Pgm().GetSettingsManager().GetAppSettings<LIBEDIT_SETTINGS>();
127 
128  // Prevents crash bug in wxGrid's d'tor
130 
131  m_grid->Disconnect( wxEVT_GRID_CELL_CHANGING,
133  NULL, this );
134 
135  // Delete the GRID_TRICKS.
136  m_grid->PopEventHandler( true );
137 }
138 
139 
141 {
142  if( !wxDialog::TransferDataToWindow() )
143  return false;
144 
145  // Push a copy of each field into m_updateFields
147 
148  // The Y axis for components in lib is from bottom to top while the screen axis is top
149  // to bottom: we must change the y coord sign for editing
150  for( size_t i = 0; i < m_fields->size(); ++i )
151  {
152  wxPoint pos = m_fields->at( i ).GetPosition();
153  pos.y = -pos.y;
154  m_fields->at( i ).SetPosition( pos );
155  }
156 
157  // notify the grid
158  wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, m_fields->GetNumberRows() );
159  m_grid->ProcessTableMessage( msg );
160  adjustGridColumns( m_grid->GetRect().GetWidth() );
161 
162  m_SymbolNameCtrl->SetValue( m_libEntry->GetName() );
163 
164  m_DescCtrl->SetValue( m_libEntry->GetDescription() );
165  m_KeywordCtrl->SetValue( m_libEntry->GetKeyWords() );
168  m_AsConvertButt->SetValue( m_libEntry->HasConversion() );
169  m_OptionPower->SetValue( m_libEntry->IsPower() );
170 
172  m_ShowPinNameButt->SetValue( m_libEntry->ShowPinNames() );
173  m_PinsNameInsideButt->SetValue( m_libEntry->GetPinNameOffset() != 0 );
175 
176  wxArrayString tmp = m_libEntry->GetFootprints();
177  m_FootprintFilterListBox->Append( tmp );
178 
179  // Populate the list of root parts for inherited objects.
180  if( m_libEntry->IsAlias() )
181  {
182  wxArrayString rootSymbolNames;
183  wxString libName = m_Parent->GetCurLib();
184 
185  // Someone forgot to set the current library in the editor frame window.
186  wxCHECK( !libName.empty(), false );
187 
188  m_Parent->GetLibManager().GetRootSymbolNames( libName, rootSymbolNames );
189  m_inheritanceSelectCombo->Append( rootSymbolNames );
190 
191  PART_SPTR rootPart = m_libEntry->GetParent().lock();
192 
193  wxCHECK( rootPart, false );
194 
195  wxString parentName = rootPart->GetName();
196  int selection = m_inheritanceSelectCombo->FindString( parentName );
197 
198  wxCHECK( selection != wxNOT_FOUND, false );
199  m_inheritanceSelectCombo->SetSelection( selection );
200 
201  m_lastOpenedPage = 0;
202  }
203 
204  m_NoteBook->SetSelection( (unsigned) m_lastOpenedPage );
205 
206  return true;
207 }
208 
209 
211 {
212  if( !m_grid->CommitPendingChanges() )
213  return false;
214 
215  // Alias symbol reference can be empty because it inherits from the parent symbol.
216  if( m_libEntry->IsRoot() &&
218  {
219  if( m_NoteBook->GetSelection() != 0 )
220  m_NoteBook->SetSelection( 0 );
221 
222  m_delayedErrorMessage = _( "References must start with a letter." );
226  m_delayedFocusPage = 0;
227 
228  return false;
229  }
230 
231  // Check for missing field names.
232  for( size_t i = MANDATORY_FIELDS; i < m_fields->size(); ++i )
233  {
234  LIB_FIELD& field = m_fields->at( i );
235  wxString fieldName = field.GetName( false );
236 
237  if( fieldName.IsEmpty() )
238  {
239  if( m_NoteBook->GetSelection() != 0 )
240  m_NoteBook->SetSelection( 0 );
241 
242  m_delayedErrorMessage = _( "Fields must have a name." );
245  m_delayedFocusRow = i;
246  m_delayedFocusPage = 0;
247 
248  return false;
249  }
250  }
251 
252  if( m_SelNumberOfUnits->GetValue() < m_libEntry->GetUnitCount() )
253  {
254  if( !IsOK( this, _( "Delete extra units from symbol?" ) ) )
255  return false;
256  }
257 
258  if( m_AsConvertButt->GetValue() && !m_libEntry->HasConversion() )
259  {
260  if( !IsOK( this, _( "Add new pins for alternate body style (DeMorgan) to symbol?" ) ) )
261  return false;
262  }
263  else if( !m_AsConvertButt->GetValue() && m_libEntry->HasConversion() )
264  {
265  if( !IsOK( this, _( "Delete alternate body style (DeMorgan) draw items from symbol?" ) ) )
266  return false;
267  }
268 
269  return true;
270 }
271 
272 
274 {
275  if( !wxDialog::TransferDataFromWindow() )
276  return false;
277 
278  // We need to keep the name and the value the same at the moment!
279  wxString newName = m_fields->at( VALUE ).GetText();
280  wxString oldName = m_libEntry->GetName();
281 
282  if( oldName != newName )
283  {
284  wxString libName = m_Parent->GetCurLib();
285 
286  if( m_Parent->GetLibManager().PartExists( newName, libName ) )
287  {
288  wxString msg;
289 
290  msg.Printf( _( "The name '%s' conflicts with an existing entry in the library '%s'." ),
291  newName, libName );
292  DisplayErrorMessage( this, msg );
293  return false;
294  }
295 
297  }
298  else
299  {
301  }
302 
303  // The Y axis for components in lib is from bottom to top while the screen axis is top
304  // to bottom: we must change the y coord sign when writing back to the library
305  for( size_t i = 0; i < m_fields->size(); ++i )
306  {
307  wxPoint pos = m_fields->at( i ).GetPosition();
308  pos.y = -pos.y;
309  m_fields->at( i ).SetPosition( pos );
310  }
311 
313 
314  // We need to keep the name and the value the same at the moment!
315  m_libEntry->SetName( newName );
316  m_libEntry->SetDescription( m_DescCtrl->GetValue() );
317  m_libEntry->SetKeyWords( m_KeywordCtrl->GetValue() );
320  m_libEntry->SetConversion( m_AsConvertButt->GetValue() );
321 
322  if( m_OptionPower->GetValue() )
323  m_libEntry->SetPower();
324  else
326 
329 
330  if( m_PinsNameInsideButt->GetValue() )
331  {
332  int offset = KiROUND( (double) m_pinNameOffset.GetValue() );
333 
334  // We interpret an offset of 0 as "outside", so make sure it's non-zero
335  m_libEntry->SetPinNameOffset( offset == 0 ? 20 : offset );
336  }
337  else
338  {
339  m_libEntry->SetPinNameOffset( 0 ); // pin text outside the body (name is on the pin)
340  }
341 
343 
344  if( oldName != newName )
346  else
348 
349  // It's possible that the symbol being edited has no pins, in which case there may be no
350  // alternate body style objects causing #LIB_PART::HasCoversion() to always return false.
351  // This allows the user to edit the alternate body style just in case this condition occurs.
352  m_Parent->SetShowDeMorgan( m_AsConvertButt->GetValue() );
353 
354  return true;
355 }
356 
357 
359 {
360  wxGridCellEditor* editor = m_grid->GetCellEditor( event.GetRow(), event.GetCol() );
361  wxControl* control = editor->GetControl();
362 
363  if( control && control->GetValidator() && !control->GetValidator()->Validate( control ) )
364  {
365  event.Veto();
366 
368  m_delayedFocusRow = event.GetRow();
369  m_delayedFocusColumn = event.GetCol();
370  m_delayedFocusPage = 0;
371  }
372  else if( event.GetCol() == FDC_NAME )
373  {
374  wxString newName = event.GetString();
375 
376  for( int i = 0; i < m_grid->GetNumberRows(); ++i )
377  {
378  if( i == event.GetRow() )
379  continue;
380 
381  if( newName.CmpNoCase( m_grid->GetCellValue( i, FDC_NAME ) ) == 0 )
382  {
383  DisplayError( this, wxString::Format( _( "The name '%s' is already in use." ),
384  newName ) );
385  event.Veto();
386  m_delayedFocusRow = event.GetRow();
387  m_delayedFocusColumn = event.GetCol();
388  }
389  }
390  }
391  else if( event.GetRow() == VALUE && event.GetCol() == FDC_VALUE )
392  m_SymbolNameCtrl->ChangeValue( event.GetString() );
393 
394  editor->DecRef();
395 }
396 
397 
399 {
400  m_grid->SetCellValue( VALUE, FDC_VALUE, m_SymbolNameCtrl->GetValue() );
401 }
402 
403 
405 {
406  if( !m_delayedFocusCtrl && !m_SymbolNameCtrl->GetValidator()->Validate( m_SymbolNameCtrl ) )
407  {
409  m_delayedFocusPage = 0;
410  }
411 
412  event.Skip();
413 }
414 
415 
416 void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnAddField( wxCommandEvent& event )
417 {
418  if( !m_grid->CommitPendingChanges() )
419  return;
420 
421  LIBEDIT_SETTINGS* settings = Pgm().GetSettingsManager().GetAppSettings<LIBEDIT_SETTINGS>();
422  int fieldID = m_fields->size();
423  LIB_FIELD newField( m_libEntry, fieldID );
424 
425  newField.SetTextSize( wxSize( Mils2iu( settings->m_Defaults.text_size ),
426  Mils2iu( settings->m_Defaults.text_size ) ) );
427 
428  m_fields->push_back( newField );
429 
430  // notify the grid
431  wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
432  m_grid->ProcessTableMessage( msg );
433 
434  m_grid->MakeCellVisible( (int) m_fields->size() - 1, 0 );
435  m_grid->SetGridCursor( (int) m_fields->size() - 1, 0 );
436 
437  m_grid->EnableCellEditControl();
438  m_grid->ShowCellEditControl();
439 }
440 
441 
443 {
444  int curRow = m_grid->GetGridCursorRow();
445 
446  if( curRow < 0 )
447  return;
448  else if( curRow < MANDATORY_FIELDS )
449  {
450  DisplayError( this, wxString::Format( _( "The first %d fields are mandatory." ),
451  MANDATORY_FIELDS ) );
452  return;
453  }
454 
455  m_grid->CommitPendingChanges( true /* quiet mode */ );
456 
457  m_fields->erase( m_fields->begin() + curRow );
458 
459  // notify the grid
460  wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, curRow, 1 );
461  m_grid->ProcessTableMessage( msg );
462 
463  if( m_grid->GetNumberRows() > 0 )
464  {
465  m_grid->MakeCellVisible( std::max( 0, curRow-1 ), m_grid->GetGridCursorCol() );
466  m_grid->SetGridCursor( std::max( 0, curRow-1 ), m_grid->GetGridCursorCol() );
467  }
468 }
469 
470 
471 void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnMoveUp( wxCommandEvent& event )
472 {
473  if( !m_grid->CommitPendingChanges() )
474  return;
475 
476  int i = m_grid->GetGridCursorRow();
477 
478  if( i > MANDATORY_FIELDS )
479  {
480  LIB_FIELD tmp = m_fields->at( (unsigned) i );
481  m_fields->erase( m_fields->begin() + i, m_fields->begin() + i + 1 );
482  m_fields->insert( m_fields->begin() + i - 1, tmp );
483  m_grid->ForceRefresh();
484 
485  m_grid->SetGridCursor( i - 1, m_grid->GetGridCursorCol() );
486  m_grid->MakeCellVisible( m_grid->GetGridCursorRow(), m_grid->GetGridCursorCol() );
487  }
488  else
489  wxBell();
490 }
491 
492 
493 void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnMoveDown( wxCommandEvent& event )
494 {
495  if( !m_grid->CommitPendingChanges() )
496  return;
497 
498  int i = m_grid->GetGridCursorRow();
499 
500  if( i >= MANDATORY_FIELDS && i + 1 < m_fields->GetNumberRows() )
501  {
502  LIB_FIELD tmp = m_fields->at( (unsigned) i );
503  m_fields->erase( m_fields->begin() + i, m_fields->begin() + i + 1 );
504  m_fields->insert( m_fields->begin() + i + 1, tmp );
505  m_grid->ForceRefresh();
506 
507  m_grid->SetGridCursor( i + 1, m_grid->GetGridCursorCol() );
508  m_grid->MakeCellVisible( m_grid->GetGridCursorRow(), m_grid->GetGridCursorCol() );
509  }
510  else
511  wxBell();
512 }
513 
514 
516 {
517 #ifdef KICAD_SPICE
518  int diff = m_fields->size();
519  auto cmp = SCH_COMPONENT( *m_libEntry, m_libEntry->GetLibId(), nullptr );
520 
521  DIALOG_SPICE_MODEL dialog( this, cmp, m_fields );
522 
523  if( dialog.ShowModal() != wxID_OK )
524  return;
525 
526  diff = (int) m_fields->size() - diff;
527 
528  if( diff > 0 )
529  {
530  wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, diff );
531  m_grid->ProcessTableMessage( msg );
532  }
533  else if( diff < 0 )
534  {
535  wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, 0, -diff );
536  m_grid->ProcessTableMessage( msg );
537  }
538 
539  m_grid->ForceRefresh();
540 #endif /* KICAD_SPICE */
541 }
542 
543 
545 {
546  int idx = m_FootprintFilterListBox->HitTest( event.GetPosition() );
547  wxCommandEvent dummy;
548 
549  if( idx >= 0 )
551  else
553 }
554 
555 
557 {
558  // Running the Footprint Browser gums up the works and causes the automatic cancel
559  // stuff to no longer work. So we do it here ourselves.
560  EndQuasiModal( wxID_CANCEL );
561 }
562 
563 
565 {
566  wxString filterLine;
567  WX_TEXT_ENTRY_DIALOG dlg( this, _( "Filter:" ), _( "Add Footprint Filter" ), filterLine );
568 
569  if( dlg.ShowModal() == wxID_CANCEL || dlg.GetValue().IsEmpty() )
570  return;
571 
572  filterLine = dlg.GetValue();
573  filterLine.Replace( wxT( " " ), wxT( "_" ) );
574 
575  // duplicate filters do no harm, so don't be a nanny.
576 
577  m_FootprintFilterListBox->Append( filterLine );
578  m_FootprintFilterListBox->SetSelection( (int) m_FootprintFilterListBox->GetCount() - 1 );
579 }
580 
581 
583 {
584  int ii = m_FootprintFilterListBox->GetSelection();
585 
586  if( ii >= 0 )
587  {
588  m_FootprintFilterListBox->Delete( (unsigned) ii );
589 
590  if( m_FootprintFilterListBox->GetCount() == 0 )
591  m_FootprintFilterListBox->SetSelection( wxNOT_FOUND );
592  else
593  m_FootprintFilterListBox->SetSelection( std::max( 0, ii - 1 ) );
594  }
595 }
596 
597 
599 {
600  int idx = m_FootprintFilterListBox->GetSelection();
601 
602  if( idx >= 0 )
603  {
604  wxString filter = m_FootprintFilterListBox->GetStringSelection();
605 
606  WX_TEXT_ENTRY_DIALOG dlg( this, _( "Filter:" ), _( "Edit Footprint Filter" ), filter );
607 
608  if( dlg.ShowModal() == wxID_OK && !dlg.GetValue().IsEmpty() )
609  m_FootprintFilterListBox->SetString( (unsigned) idx, dlg.GetValue() );
610  }
611 }
612 
613 
615 {
616  m_width = aWidth;
617 
618  // Account for scroll bars
619  aWidth -= ( m_grid->GetSize().x - m_grid->GetClientSize().x );
620 
621  m_grid->AutoSizeColumn( FDC_NAME );
622 
623  int fixedColsWidth = m_grid->GetColSize( FDC_NAME );
624 
625  for( int i = 2; i < m_grid->GetNumberCols(); i++ )
626  fixedColsWidth += m_grid->GetColSize( i );
627 
628  m_grid->SetColSize( FDC_VALUE, aWidth - fixedColsWidth );
629 }
630 
631 
632 void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnUpdateUI( wxUpdateUIEvent& event )
633 {
634  m_OptionPartsLocked->Enable( m_SelNumberOfUnits->GetValue() > 1 );
636 
637  if( m_grid->IsCellEditControlShown() )
638  {
639  int row = m_grid->GetGridCursorRow();
640  int col = m_grid->GetGridCursorCol();
641 
642  if( row == VALUE && col == FDC_VALUE )
643  {
644  wxGridCellEditor* editor = m_grid->GetCellEditor( row, col );
645  m_SymbolNameCtrl->ChangeValue( editor->GetValue() );
646  editor->DecRef();
647  }
648  }
649 
650  // Handle shown columns changes
651  wxString shownColumns = m_grid->GetShownColumns();
652 
653  if( shownColumns != m_shownColumns )
654  {
655  m_shownColumns = shownColumns;
656 
657  if( !m_grid->IsCellEditControlShown() )
658  adjustGridColumns( m_grid->GetRect().GetWidth() );
659  }
660 
661  // Handle a delayed focus. The delay allows us to:
662  // a) change focus when the error was triggered from within a killFocus handler
663  // b) show the correct notebook page in the background before the error dialog comes up
664  // when triggered from an OK or a notebook page change
665 
666  if( m_delayedFocusPage >= 0 && m_NoteBook->GetSelection() != m_delayedFocusPage )
667  {
668  m_NoteBook->SetSelection( (unsigned) m_delayedFocusPage );
669  m_delayedFocusPage = -1;
670  }
671 
672  if( !m_delayedErrorMessage.IsEmpty() )
673  {
674  // We will re-enter this routine when the error dialog is displayed, so make
675  // sure we don't keep putting up more dialogs.
676  wxString msg = m_delayedErrorMessage;
677  m_delayedErrorMessage = wxEmptyString;
678 
679  // Do not use DisplayErrorMessage(); it screws up window order on Mac
680  DisplayError( nullptr, msg );
681  }
682 
683  if( m_delayedFocusCtrl )
684  {
685  m_delayedFocusCtrl->SetFocus();
686 
687  if( auto textEntry = dynamic_cast<wxTextEntry*>( m_delayedFocusCtrl ) )
688  textEntry->SelectAll();
689 
690  m_delayedFocusCtrl = nullptr;
691  }
692  else if( m_delayedFocusGrid )
693  {
694  m_delayedFocusGrid->SetFocus();
697 
698  m_delayedFocusGrid->EnableCellEditControl( true );
699  m_delayedFocusGrid->ShowCellEditControl();
700 
701  m_delayedFocusGrid = nullptr;
702  m_delayedFocusRow = -1;
704  }
705 }
706 
707 
709 {
710  auto new_size = event.GetSize().GetX();
711 
712  if( new_size != m_width )
713  {
714  adjustGridColumns( event.GetSize().GetX() );
715  }
716 
717  // Always propagate a wxSizeEvent:
718  event.Skip();
719 }
720 
721 
723 {
724  // Remove the not wanted notebook page.
725  // *Do not use* Hide(), it is suitable to hide a widget,
726  // but it is not suitable to hide a notebook page (that is not a widget)
727  if( aIsAlias )
728  m_NoteBook->RemovePage( 1 );
729 
730  bSizerLowerBasicPanel->Show( !aIsAlias );
731  // bButtonSize->Show( !aIsAlias );
732 
733 #ifdef KICAD_SPICE
734  m_spiceFieldsButton->Show( !aIsAlias );
735 #endif
736 
737  m_inheritanceSelectCombo->Enable( aIsAlias );
738  m_inheritsStaticText->Enable( aIsAlias );
739  m_grid->ForceRefresh();
740 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:239
const BITMAP_OPAQUE trash_xpm[1]
Definition: trash.cpp:46
void OnAddFootprintFilter(wxCommandEvent &event) override
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:104
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:252
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:121
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 SetUnitCount(int aCount, bool aDuplicateDrawItems=true)
Set the units per part count.
void ResetSize()
Clear the existing dialog size and position.
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 SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:237
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:59
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".
wxString GetName(bool aUseDefaultName=true) const
Returns the field name.
Definition: lib_field.cpp:366
void OnMoveUp(wxCommandEvent &event) override
wxString GetCurLib() const
The nickname of the current library being edited and empty string if none.
void SetShowDeMorgan(bool show)
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:90
bool ShowPinNames()
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:80
#define VALUE
bool ShowPinNumbers()
void SetConversion(bool aSetConvert, bool aDuplicatePins=true)
Set or clear the alternate body style (DeMorgan) for the part.
#define NULL
int GetUnitCount() const override
For items with units, return the number of units.
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
void SetDescription(const wxString &aDescription)
const BITMAP_OPAQUE small_down_xpm[1]
Definition: small_down.cpp:25
PART_REF & GetParent()
Define a library symbol object.
wxString m_EditComponentVisibleColumns
void UpdateAfterSymbolProperties(wxString *aOldName=nullptr)
wxString GetDescription() override
void OnSymbolNameKillFocus(wxFocusEvent &event) override
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:174
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
void GetRootSymbolNames(const wxString &aLibName, wxArrayString &aRootSymbolNames)
wxString GetShownColumns()
Get a tokenized string containing the shown column indexes.
Definition: wx_grid.cpp:103
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:33
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
Schematic symbol object.
Definition: sch_component.h:88
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:68
bool IsRoot() const override
For symbols derived from other symbols, IsRoot() indicates no derivation.
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:283
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()