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 <bitmaps.h>
25 #include <class_libentry.h>
26 #include <common.h>
27 #include <confirm.h>
28 #include <dialog_helpers.h>
29 #include <dialog_text_entry.h>
30 #include <eeschema_settings.h>
31 #include <fctsys.h>
32 #include <general.h>
33 #include <kiface_i.h>
34 #include <kiway.h>
35 #include <lib_edit_frame.h>
36 #include <lib_manager.h>
37 #include <math/util.h> // for KiROUND
38 #include <pgm_base.h>
39 #include <sch_component.h>
40 #include <sch_item.h>
41 #include <symbol_lib_table.h>
43 #include <widgets/wx_grid.h>
44 
45 #ifdef KICAD_SPICE
46 #include <dialog_spice_model.h>
48 #endif /* KICAD_SPICE */
49 
52 #include <libedit_settings.h>
53 
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 {
73  // Give a bit more room for combobox editors
74  m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 );
75  m_fields = new FIELDS_GRID_TABLE<LIB_FIELD>( this, aParent, m_libEntry );
77  m_grid->PushEventHandler( new FIELDS_GRID_TRICKS( m_grid, this ) );
78 
79  // Show/hide columns according to the user's preference
80  auto cfg = Pgm().GetSettingsManager().GetAppSettings<LIBEDIT_SETTINGS>();
81  m_grid->ShowHideColumns( cfg->m_EditComponentVisibleColumns );
82 
83  wxGridCellAttr* attr = new wxGridCellAttr;
84  attr->SetEditor( new GRID_CELL_URL_EDITOR( this ) );
85  m_grid->SetAttr( DATASHEET, FDC_VALUE, attr );
86 
87  m_SymbolNameCtrl->SetValidator( SCH_FIELD_VALIDATOR( true, VALUE ) );
88 
89  // Configure button logos
90  m_bpAdd->SetBitmap( KiBitmap( small_plus_xpm ) );
91  m_bpDelete->SetBitmap( KiBitmap( trash_xpm ) );
92  m_bpMoveUp->SetBitmap( KiBitmap( small_up_xpm ) );
93  m_bpMoveDown->SetBitmap( KiBitmap( small_down_xpm ) );
94  m_addFilterButton->SetBitmap( KiBitmap( small_plus_xpm ) );
95  m_deleteFilterButton->SetBitmap( KiBitmap( trash_xpm ) );
97 
98  m_stdSizerButtonOK->SetDefault();
99 
100 #ifndef KICAD_SPICE
101  m_spiceFieldsButton->Hide();
102 #endif
103 
104  // wxFormBuilder doesn't include this event...
105  m_grid->Connect( wxEVT_GRID_CELL_CHANGING,
107  NULL, this );
108 
110  {
113  {
114  ResetSize();
115  }
116  }
117 
120 
121  m_grid->GetParent()->Layout();
123  Layout();
124 
126 }
127 
128 
130 {
131  m_lastOpenedPage = m_NoteBook->GetSelection( );
132 
133  auto cfg = Pgm().GetSettingsManager().GetAppSettings<LIBEDIT_SETTINGS>();
135 
136  // Prevents crash bug in wxGrid's d'tor
138 
139  m_grid->Disconnect( wxEVT_GRID_CELL_CHANGING,
141  NULL, this );
142 
143  // Delete the GRID_TRICKS.
144  m_grid->PopEventHandler( true );
145 }
146 
147 
149 {
150  if( !wxDialog::TransferDataToWindow() )
151  return false;
152 
153  // Push a copy of each field into m_fields
155 
156  // Copy the data sheet field from the old alias document file name if it's not empty.
157  if( !m_libEntry->GetDocFileName().IsEmpty() )
158  m_fields->at( DATASHEET ).SetText( m_libEntry->GetDocFileName() );
159 
160  // The Y axis for components in lib is from bottom to top while the screen axis is top
161  // to bottom: we must change the y coord sign for editing
162  for( size_t i = 0; i < m_fields->size(); ++i )
163  {
164  wxPoint pos = m_fields->at( i ).GetPosition();
165  pos.y = -pos.y;
166  m_fields->at( i ).SetPosition( pos );
167  }
168 
169  // notify the grid
170  wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, m_fields->GetNumberRows() );
171  m_grid->ProcessTableMessage( msg );
172  adjustGridColumns( m_grid->GetRect().GetWidth() );
173 
174  m_SymbolNameCtrl->SetValue( m_libEntry->GetName() );
175 
176  m_DescCtrl->SetValue( m_libEntry->GetDescription() );
177  m_KeywordCtrl->SetValue( m_libEntry->GetKeyWords() );
180  m_AsConvertButt->SetValue( m_libEntry->HasConversion() );
181  m_OptionPower->SetValue( m_libEntry->IsPower() );
182 
184  m_ShowPinNameButt->SetValue( m_libEntry->ShowPinNames() );
185  m_PinsNameInsideButt->SetValue( m_libEntry->GetPinNameOffset() != 0 );
187 
188  wxArrayString tmp = m_libEntry->GetFootprints();
189  m_FootprintFilterListBox->Append( tmp );
190 
191  // Populate the list of root parts for inherited objects.
192  if( m_libEntry->IsAlias() )
193  {
194  wxArrayString rootSymbolNames;
195  wxString libName = m_Parent->GetCurLib();
196 
197  // Someone forgot to set the current library in the editor frame window.
198  wxCHECK( !libName.empty(), false );
199 
200  m_Parent->GetLibManager().GetRootSymbolNames( libName, rootSymbolNames );
201  m_inheritanceSelectCombo->Append( rootSymbolNames );
202 
203  PART_SPTR rootPart = m_libEntry->GetParent().lock();
204 
205  wxCHECK( rootPart, false );
206 
207  wxString parentName = rootPart->GetName();
208  int selection = m_inheritanceSelectCombo->FindString( parentName );
209 
210  wxCHECK( selection != wxNOT_FOUND, false );
211  m_inheritanceSelectCombo->SetSelection( selection );
212 
213  // Copy the reference field from the root symbol to prevent validation errors.
214  m_fields->at( REFERENCE ).SetText( rootPart->GetReferenceField().GetText() );
215  m_lastOpenedPage = 0;
216  }
217 
218  m_NoteBook->SetSelection( (unsigned) m_lastOpenedPage );
219 
220  return true;
221 }
222 
223 
225 {
226  if( !m_grid->CommitPendingChanges() )
227  return false;
228 
229  if( !SCH_COMPONENT::IsReferenceStringValid( m_fields->at( REFERENCE ).GetText() ) )
230  {
231  if( m_NoteBook->GetSelection() != 0 )
232  m_NoteBook->SetSelection( 0 );
233 
234  m_delayedErrorMessage = _( "References must start with a letter." );
238  m_delayedFocusPage = 0;
239 
240  return false;
241  }
242 
243  // Check for missing field names.
244  for( size_t i = MANDATORY_FIELDS; i < m_fields->size(); ++i )
245  {
246  LIB_FIELD& field = m_fields->at( i );
247  wxString fieldName = field.GetName( false );
248 
249  if( fieldName.IsEmpty() )
250  {
251  if( m_NoteBook->GetSelection() != 0 )
252  m_NoteBook->SetSelection( 0 );
253 
254  m_delayedErrorMessage = _( "Fields must have a name." );
257  m_delayedFocusRow = i;
258  m_delayedFocusPage = 0;
259 
260  return false;
261  }
262  }
263 
264  if( m_SelNumberOfUnits->GetValue() < m_libEntry->GetUnitCount() )
265  {
266  if( !IsOK( this, _( "Delete extra units from symbol?" ) ) )
267  return false;
268  }
269 
270  if( m_AsConvertButt->GetValue() && !m_libEntry->HasConversion() )
271  {
272  if( !IsOK( this, _( "Add new pins for alternate body style (DeMorgan) to symbol?" ) ) )
273  return false;
274  }
275  else if( !m_AsConvertButt->GetValue() && m_libEntry->HasConversion() )
276  {
277  if( !IsOK( this, _( "Delete alternate body style (DeMorgan) draw items from symbol?" ) ) )
278  return false;
279  }
280 
281  return true;
282 }
283 
284 
286 {
287  if( !wxDialog::TransferDataFromWindow() )
288  return false;
289 
290  // We need to keep the name and the value the same at the moment!
291  wxString newName = m_fields->at( VALUE ).GetText();
292  wxString oldName = m_libEntry->GetName();
293 
294  if( oldName != newName )
295  {
296  wxString libName = m_Parent->GetCurLib();
297 
298  if( m_Parent->GetLibManager().PartExists( newName, libName ) )
299  {
300  wxString msg;
301 
302  msg.Printf( _( "The name '%s' conflicts with an existing entry in the library '%s'." ),
303  newName, libName );
304  DisplayErrorMessage( this, msg );
305  return false;
306  }
307 
309  }
310  else
311  {
313  }
314 
315  // The Y axis for components in lib is from bottom to top while the screen axis is top
316  // to bottom: we must change the y coord sign when writing back to the library
317  for( size_t i = 0; i < m_fields->size(); ++i )
318  {
319  wxPoint pos = m_fields->at( i ).GetPosition();
320  pos.y = -pos.y;
321  m_fields->at( i ).SetPosition( pos );
322  }
323 
324  // Datasheet field is special; copy it to the root alias docfilename
325  m_libEntry->SetDocFileName( m_fields->at( DATASHEET ).GetText() );
327 
328  // We need to keep the name and the value the same at the moment!
329  m_libEntry->SetName( newName );
330  m_libEntry->SetDescription( m_DescCtrl->GetValue() );
331  m_libEntry->SetKeyWords( m_KeywordCtrl->GetValue() );
334  m_libEntry->SetConversion( m_AsConvertButt->GetValue() );
335 
336  if( m_OptionPower->GetValue() )
337  m_libEntry->SetPower();
338  else
340 
343 
344  if( m_PinsNameInsideButt->GetValue() )
345  {
346  int offset = KiROUND( (double) m_pinNameOffset.GetValue() );
347 
348  // We interpret an offset of 0 as "outside", so make sure it's non-zero
349  m_libEntry->SetPinNameOffset( offset == 0 ? 20 : offset );
350  }
351  else
352  {
353  m_libEntry->SetPinNameOffset( 0 ); // pin text outside the body (name is on the pin)
354  }
355 
357 
358  if( oldName != newName )
360  else
362 
363  return true;
364 }
365 
366 
368 {
369  wxGridCellEditor* editor = m_grid->GetCellEditor( event.GetRow(), event.GetCol() );
370  wxControl* control = editor->GetControl();
371 
372  if( control && control->GetValidator() && !control->GetValidator()->Validate( control ) )
373  {
374  event.Veto();
375 
377  m_delayedFocusRow = event.GetRow();
378  m_delayedFocusColumn = event.GetCol();
379  m_delayedFocusPage = 0;
380  }
381  else if( event.GetRow() == VALUE && event.GetCol() == FDC_VALUE )
382  m_SymbolNameCtrl->ChangeValue( event.GetString() );
383 
384  editor->DecRef();
385 }
386 
387 
389 {
390  m_grid->SetCellValue( VALUE, FDC_VALUE, m_SymbolNameCtrl->GetValue() );
391 }
392 
393 
395 {
396  if( !m_delayedFocusCtrl && !m_SymbolNameCtrl->GetValidator()->Validate( m_SymbolNameCtrl ) )
397  {
399  m_delayedFocusPage = 0;
400  }
401 
402  event.Skip();
403 }
404 
405 
406 void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnAddField( wxCommandEvent& event )
407 {
408  if( !m_grid->CommitPendingChanges() )
409  return;
410 
411  int fieldID = m_fields->size();
412  LIB_FIELD newField( m_libEntry, fieldID );
413 
414  m_fields->push_back( newField );
415 
416  // notify the grid
417  wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
418  m_grid->ProcessTableMessage( msg );
419 
420  m_grid->MakeCellVisible( m_fields->size() - 1, 0 );
421  m_grid->SetGridCursor( m_fields->size() - 1, 0 );
422 
423  m_grid->EnableCellEditControl();
424  m_grid->ShowCellEditControl();
425 }
426 
427 
429 {
430  int curRow = m_grid->GetGridCursorRow();
431 
432  if( curRow < 0 )
433  return;
434  else if( curRow < MANDATORY_FIELDS )
435  {
436  DisplayError( this, wxString::Format( _( "The first %d fields are mandatory." ),
437  MANDATORY_FIELDS ) );
438  return;
439  }
440 
441  m_grid->CommitPendingChanges( true /* quiet mode */ );
442 
443  m_fields->erase( m_fields->begin() + curRow );
444 
445  // notify the grid
446  wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, curRow, 1 );
447  m_grid->ProcessTableMessage( msg );
448 
449  if( m_grid->GetNumberRows() > 0 )
450  {
451  m_grid->MakeCellVisible( std::max( 0, curRow-1 ), m_grid->GetGridCursorCol() );
452  m_grid->SetGridCursor( std::max( 0, curRow-1 ), m_grid->GetGridCursorCol() );
453  }
454 }
455 
456 
457 void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnMoveUp( wxCommandEvent& event )
458 {
459  if( !m_grid->CommitPendingChanges() )
460  return;
461 
462  int i = m_grid->GetGridCursorRow();
463 
464  if( i > MANDATORY_FIELDS )
465  {
466  LIB_FIELD tmp = m_fields->at( (unsigned) i );
467  m_fields->erase( m_fields->begin() + i, m_fields->begin() + i + 1 );
468  m_fields->insert( m_fields->begin() + i - 1, tmp );
469  m_grid->ForceRefresh();
470 
471  m_grid->SetGridCursor( i - 1, m_grid->GetGridCursorCol() );
472  m_grid->MakeCellVisible( m_grid->GetGridCursorRow(), m_grid->GetGridCursorCol() );
473  }
474  else
475  wxBell();
476 }
477 
478 
479 void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnMoveDown( wxCommandEvent& event )
480 {
481  if( !m_grid->CommitPendingChanges() )
482  return;
483 
484  int i = m_grid->GetGridCursorRow();
485 
486  if( i >= MANDATORY_FIELDS && i + 1 < m_fields->GetNumberRows() )
487  {
488  LIB_FIELD tmp = m_fields->at( (unsigned) i );
489  m_fields->erase( m_fields->begin() + i, m_fields->begin() + i + 1 );
490  m_fields->insert( m_fields->begin() + i + 1, tmp );
491  m_grid->ForceRefresh();
492 
493  m_grid->SetGridCursor( i + 1, m_grid->GetGridCursorCol() );
494  m_grid->MakeCellVisible( m_grid->GetGridCursorRow(), m_grid->GetGridCursorCol() );
495  }
496  else
497  wxBell();
498 }
499 
500 
502 {
503 #ifdef KICAD_SPICE
504  int diff = m_fields->size();
505  auto cmp = SCH_COMPONENT( *m_libEntry, m_libEntry->GetLibId(), nullptr );
506 
507  DIALOG_SPICE_MODEL dialog( this, cmp, m_fields );
508 
509  if( dialog.ShowModal() != wxID_OK )
510  return;
511 
512  diff = m_fields->size() - diff;
513 
514  if( diff > 0 )
515  {
516  wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, diff );
517  m_grid->ProcessTableMessage( msg );
518  }
519  else if( diff < 0 )
520  {
521  wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, 0, -diff );
522  m_grid->ProcessTableMessage( msg );
523  }
524 
525  m_grid->ForceRefresh();
526 #endif /* KICAD_SPICE */
527 }
528 
529 
531 {
532  int idx = m_FootprintFilterListBox->HitTest( event.GetPosition() );
533  wxCommandEvent dummy;
534 
535  if( idx >= 0 )
537  else
539 }
540 
541 
543 {
544  // Running the Footprint Browser gums up the works and causes the automatic cancel
545  // stuff to no longer work. So we do it here ourselves.
546  EndQuasiModal( wxID_CANCEL );
547 }
548 
549 
551 {
552  wxString filterLine;
553  WX_TEXT_ENTRY_DIALOG dlg( this, _( "Filter:" ), _( "Add Footprint Filter" ), filterLine );
554 
555  if( dlg.ShowModal() == wxID_CANCEL || dlg.GetValue().IsEmpty() )
556  return;
557 
558  filterLine = dlg.GetValue();
559  filterLine.Replace( wxT( " " ), wxT( "_" ) );
560 
561  // duplicate filters do no harm, so don't be a nanny.
562 
563  m_FootprintFilterListBox->Append( filterLine );
564  m_FootprintFilterListBox->SetSelection( m_FootprintFilterListBox->GetCount() - 1 );
565 }
566 
567 
569 {
570  int ii = m_FootprintFilterListBox->GetSelection();
571 
572  if( ii >= 0 )
573  {
574  m_FootprintFilterListBox->Delete( (unsigned) ii );
575 
576  if( m_FootprintFilterListBox->GetCount() == 0 )
577  m_FootprintFilterListBox->SetSelection( wxNOT_FOUND );
578  else
579  m_FootprintFilterListBox->SetSelection( std::max( 0, ii - 1 ) );
580  }
581 }
582 
583 
585 {
586  int idx = m_FootprintFilterListBox->GetSelection();
587 
588  if( idx >= 0 )
589  {
590  wxString filter = m_FootprintFilterListBox->GetStringSelection();
591 
592  WX_TEXT_ENTRY_DIALOG dlg( this, _( "Filter:" ), _( "Edit Footprint Filter" ), filter );
593 
594  if( dlg.ShowModal() == wxID_OK && !dlg.GetValue().IsEmpty() )
595  m_FootprintFilterListBox->SetString( (unsigned) idx, dlg.GetValue() );
596  }
597 }
598 
599 
601 {
602  m_width = aWidth;
603 
604  // Account for scroll bars
605  aWidth -= ( m_grid->GetSize().x - m_grid->GetClientSize().x );
606 
607  m_grid->AutoSizeColumn( FDC_NAME );
608 
609  int fixedColsWidth = m_grid->GetColSize( FDC_NAME );
610 
611  for( int i = 2; i < m_grid->GetNumberCols(); i++ )
612  fixedColsWidth += m_grid->GetColSize( i );
613 
614  m_grid->SetColSize( FDC_VALUE, aWidth - fixedColsWidth );
615 }
616 
617 
618 void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnUpdateUI( wxUpdateUIEvent& event )
619 {
620  m_OptionPartsLocked->Enable( m_SelNumberOfUnits->GetValue() > 1 );
622 
623  if( m_grid->IsCellEditControlShown() )
624  {
625  int row = m_grid->GetGridCursorRow();
626  int col = m_grid->GetGridCursorCol();
627 
628  if( row == VALUE && col == FDC_VALUE )
629  {
630  wxGridCellEditor* editor = m_grid->GetCellEditor( row, col );
631  m_SymbolNameCtrl->ChangeValue( editor->GetValue() );
632  editor->DecRef();
633  }
634  }
635 
636  // Handle shown columns changes
637  wxString shownColumns = m_grid->GetShownColumns();
638 
639  if( shownColumns != m_shownColumns )
640  {
641  m_shownColumns = shownColumns;
642 
643  if( !m_grid->IsCellEditControlShown() )
644  adjustGridColumns( m_grid->GetRect().GetWidth() );
645  }
646 
647  // Handle a delayed focus. The delay allows us to:
648  // a) change focus when the error was triggered from within a killFocus handler
649  // b) show the correct notebook page in the background before the error dialog comes up
650  // when triggered from an OK or a notebook page change
651 
652  if( m_delayedFocusPage >= 0 && m_NoteBook->GetSelection() != m_delayedFocusPage )
653  {
654  m_NoteBook->SetSelection( (unsigned) m_delayedFocusPage );
655  m_delayedFocusPage = -1;
656  }
657 
658  if( !m_delayedErrorMessage.IsEmpty() )
659  {
660  // We will re-enter this routine when the error dialog is displayed, so make
661  // sure we don't keep putting up more dialogs.
662  wxString msg = m_delayedErrorMessage;
663  m_delayedErrorMessage = wxEmptyString;
664 
665  // Do not use DisplayErrorMessage(); it screws up window order on Mac
666  DisplayError( nullptr, msg );
667  }
668 
669  if( m_delayedFocusCtrl )
670  {
671  m_delayedFocusCtrl->SetFocus();
672 
673  if( auto textEntry = dynamic_cast<wxTextEntry*>( m_delayedFocusCtrl ) )
674  textEntry->SelectAll();
675 
676  m_delayedFocusCtrl = nullptr;
677  }
678  else if( m_delayedFocusGrid )
679  {
680  m_delayedFocusGrid->SetFocus();
683 
684  m_delayedFocusGrid->EnableCellEditControl( true );
685  m_delayedFocusGrid->ShowCellEditControl();
686 
687  m_delayedFocusGrid = nullptr;
688  m_delayedFocusRow = -1;
690  }
691 }
692 
693 
695 {
696  auto new_size = event.GetSize().GetX();
697 
698  if( new_size != m_width )
699  {
700  adjustGridColumns( event.GetSize().GetX() );
701  }
702 
703  // Always propagate a wxSizeEvent:
704  event.Skip();
705 }
706 
707 
709 {
710  // Remove the not wanted notebook page.
711  // *Do not use* Hide(), it is suitable to hide a widget,
712  // but it is not suitable to hide a notebook page (that is not a widget)
713  if( aIsAlias )
714  m_NoteBook->RemovePage( 1 );
715 
716  bSizerLowerBasicPanel->Show( !aIsAlias );
717  bButtonSize->Show( !aIsAlias );
718 
719 #ifdef KICAD_SPICE
720  m_spiceFieldsButton->Show( !aIsAlias );
721 #endif
722 
723  m_inheritanceSelectCombo->Enable( aIsAlias );
724  m_inheritsStaticText->Enable( aIsAlias );
725  m_grid->ForceRefresh();
726 }
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:103
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: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 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 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: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)
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.
wxString m_EditComponentVisibleColumns
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
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
wxString GetName(bool aTranslate) const
Definition: lib_field.cpp:387
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
SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:99
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: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()