KiCad PCB EDA Suite
dialog_lib_symbol_properties.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-2021 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 <confirm.h>
27#include <kiway.h>
28#include <symbol_edit_frame.h>
30#include <math/util.h> // for KiROUND
31#include <sch_symbol.h>
32#include <kiplatform/ui.h>
34#include <widgets/wx_grid.h>
35#include <string_utils.h>
36
37#ifdef KICAD_SPICE
38#include <dialog_sim_model.h>
39#endif /* KICAD_SPICE */
40
44
45
49
50
52 LIB_SYMBOL* aLibEntry ) :
54 m_Parent( aParent ),
55 m_libEntry( aLibEntry ),
56 m_pinNameOffset( aParent, m_nameOffsetLabel, m_nameOffsetCtrl, m_nameOffsetUnits, true ),
57 m_delayedFocusCtrl( nullptr ),
58 m_delayedFocusGrid( nullptr ),
59 m_delayedFocusRow( -1 ),
60 m_delayedFocusColumn( -1 ),
61 m_delayedFocusPage( -1 )
62{
63 // Give a bit more room for combobox editors
64 m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 );
67 m_grid->PushEventHandler( new FIELDS_GRID_TRICKS( m_grid, this ) );
68 m_grid->SetSelectionMode( wxGrid::wxGridSelectRows );
69
70 // Show/hide columns according to the user's preference
73
74 wxGridCellAttr* attr = new wxGridCellAttr;
75 attr->SetEditor( new GRID_CELL_URL_EDITOR( this, Prj().SchSearchS() ) );
76 m_grid->SetAttr( DATASHEET_FIELD, FDC_VALUE, attr );
77
78 m_SymbolNameCtrl->SetValidator( SCH_FIELD_VALIDATOR( true, VALUE_FIELD ) );
79
80 // Configure button logos
81 m_bpAdd->SetBitmap( KiBitmap( BITMAPS::small_plus ) );
83 m_bpMoveUp->SetBitmap( KiBitmap( BITMAPS::small_up ) );
88
90
91 if( aParent->IsSymbolFromLegacyLibrary() && !aParent->IsSymbolFromSchematic() )
92 {
93 m_stdSizerButtonCancel->SetDefault();
94 m_stdSizerButtonOK->SetLabel( _( "Read Only" ) );
95 m_stdSizerButtonOK->Enable( false );
96 }
97
98#ifndef KICAD_SPICE
99 m_spiceFieldsButton->Hide();
100#endif
101
102 // wxFormBuilder doesn't include this event...
103 m_grid->Connect( wxEVT_GRID_CELL_CHANGING,
105 nullptr, this );
106
108 {
111 {
112 resetSize();
113 }
114 }
115
118
119 m_grid->GetParent()->Layout();
121 Layout();
122
124}
125
126
128{
129 m_lastOpenedPage = m_NoteBook->GetSelection( );
130
133
134 // Prevents crash bug in wxGrid's d'tor
136
137 m_grid->Disconnect( wxEVT_GRID_CELL_CHANGING,
139 nullptr, this );
140
141 // Delete the GRID_TRICKS.
142 m_grid->PopEventHandler( true );
143}
144
145
147{
148 if( !wxDialog::TransferDataToWindow() )
149 return false;
150
151 // Push a copy of each field into m_updateFields
153
154 // The Y axis for components in lib is from bottom to top while the screen axis is top
155 // to bottom: we must change the y coord sign for editing
156 for( size_t i = 0; i < m_fields->size(); ++i )
157 {
158 VECTOR2I pos = m_fields->at( i ).GetPosition();
159 pos.y = -pos.y;
160 m_fields->at( i ).SetPosition( pos );
161 }
162
163 // notify the grid
164 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, m_fields->GetNumberRows() );
165 m_grid->ProcessTableMessage( msg );
167
169
170 m_DescCtrl->ChangeValue( m_libEntry->GetDescription() );
171 m_KeywordCtrl->ChangeValue( m_libEntry->GetKeyWords() );
174 m_libEntry->GetUnitCount() == 1 );
175
176 // If a symbol contains no conversion-specific pins or graphic items, symbol->HasConversion()
177 // will return false. But when editing a symbol with DeMorgan option set, we don't want to
178 // keep turning it off just because there aren't any conversion-specific items yet, so we force
179 // it to on if the parent frame has it enabled.
181
182 m_OptionPower->SetValue( m_libEntry->IsPower() );
185
190
191 wxArrayString tmp = m_libEntry->GetFPFilters();
192 m_FootprintFilterListBox->Append( tmp );
193
194 // Populate the list of root parts for inherited objects.
195 if( m_libEntry->IsAlias() )
196 {
197 wxArrayString rootSymbolNames;
198 wxString libName = m_Parent->GetCurLib();
199
200 // Someone forgot to set the current library in the editor frame window.
201 wxCHECK( !libName.empty(), false );
202
203 m_Parent->GetLibManager().GetRootSymbolNames( libName, rootSymbolNames );
204 m_inheritanceSelectCombo->Append( rootSymbolNames );
205
206 LIB_SYMBOL_SPTR rootSymbol = m_libEntry->GetParent().lock();
207
208 wxCHECK( rootSymbol, false );
209
210 wxString parentName = UnescapeString( rootSymbol->GetName() );
211 int selection = m_inheritanceSelectCombo->FindString( parentName );
212
213 wxCHECK( selection != wxNOT_FOUND, false );
214 m_inheritanceSelectCombo->SetSelection( selection );
215
217 }
218
219 m_NoteBook->SetSelection( (unsigned) m_lastOpenedPage );
220
221 return true;
222}
223
224
226{
228 return false;
229
230 // Alias symbol reference can be empty because it inherits from the parent symbol.
231 if( m_libEntry->IsRoot() &&
233 {
234 if( m_NoteBook->GetSelection() != 0 )
235 m_NoteBook->SetSelection( 0 );
236
237 m_delayedErrorMessage = _( "References must start with a letter." );
242
243 return false;
244 }
245
246 // Check for missing field names.
247 for( size_t i = MANDATORY_FIELDS; i < m_fields->size(); ++i )
248 {
249 LIB_FIELD& field = m_fields->at( i );
250 wxString fieldName = field.GetName( false );
251
252 if( fieldName.IsEmpty() )
253 {
254 if( m_NoteBook->GetSelection() != 0 )
255 m_NoteBook->SetSelection( 0 );
256
257 m_delayedErrorMessage = _( "Fields must have a name." );
262
263 return false;
264 }
265 }
266
267 // Verify that the parent name is set if the symbol is inherited
268 if( m_libEntry->IsAlias() )
269 {
270 wxString parentName = m_inheritanceSelectCombo->GetValue();
271
272 if( parentName.IsEmpty() )
273 {
274 m_delayedErrorMessage = _( "Aliased symbol must have a parent selected" );
275
276 return false;
277 }
278 }
279
280 /*
281 * Confirm destructive actions.
282 */
283
284 if( m_SelNumberOfUnits->GetValue() < m_libEntry->GetUnitCount() )
285 {
286 if( !IsOK( this, _( "Delete extra units from symbol?" ) ) )
287 return false;
288 }
289
290 if( !m_AsConvertButt->GetValue() && m_libEntry->HasConversion() )
291 {
292 if( !IsOK( this, _( "Delete alternate body style (De Morgan) from symbol?" ) ) )
293 return false;
294 }
295
296 return true;
297}
298
299
301{
302 if( !wxDialog::TransferDataFromWindow() )
303 return false;
304
306 return false;
307
308 wxString newName = EscapeString( m_SymbolNameCtrl->GetValue(), CTX_LIBID );
309 wxString oldName = m_libEntry->GetName();
310
311 if( oldName != newName )
312 {
313 wxString libName = m_Parent->GetCurLib();
314
315 if( m_Parent->GetLibManager().SymbolExists( newName, libName ) )
316 {
317 wxString msg;
318
319 msg.Printf( _( "Symbol name '%s' already in use in library '%s'." ),
320 UnescapeString( newName ),
321 libName );
322 DisplayErrorMessage( this, msg );
323 return false;
324 }
325
327 }
328 else
329 {
331 }
332
333 // The Y axis for components in lib is from bottom to top while the screen axis is top
334 // to bottom: we must change the y coord sign when writing back to the library
335 for( size_t i = 0; i < m_fields->size(); ++i )
336 {
337 VECTOR2I pos = m_fields->at( i ).GetPosition();
338 pos.y = -pos.y;
339 m_fields->at( i ).SetPosition( pos );
340 m_fields->at( i ).SetId( i );
341 }
342
344
345 // Update the parent for inherited symbols
346 if( m_libEntry->IsAlias() )
347 {
348 wxString parentName = EscapeString( m_inheritanceSelectCombo->GetValue(), CTX_LIBID );
349
350 // The parentName was verified to be non-empty in the Validator
351 wxString libName = m_Parent->GetCurLib();
352
353 // Get the parent from the libManager based on the name set in the inheritance combo box.
354 LIB_SYMBOL* newParent = m_Parent->GetLibManager().GetAlias( parentName, libName );
355
356 // Verify that the requested parent exists
357 wxCHECK( newParent, false );
358
359 // Verify that the new parent is not an alias.
360 wxCHECK( !newParent->IsAlias(), false );
361
362 m_libEntry->SetParent( newParent );
363 }
364
365 m_libEntry->SetName( newName );
366 m_libEntry->SetDescription( m_DescCtrl->GetValue() );
367 m_libEntry->SetKeyWords( m_KeywordCtrl->GetValue() );
370 !m_OptionPartsInterchangeable->GetValue() );
373
374 if( m_OptionPower->GetValue() )
375 {
377 // Power symbols must have value matching name for now
378 m_libEntry->GetValueField().SetText( newName );
379 }
380 else
381 {
383 }
384
387
390
391 if( m_PinsNameInsideButt->GetValue() )
392 {
393 int offset = KiROUND( (double) m_pinNameOffset.GetValue() );
394
395 // We interpret an offset of 0 as "outside", so make sure it's non-zero
396 m_libEntry->SetPinNameOffset( offset == 0 ? 20 : offset );
397 }
398 else
399 {
400 m_libEntry->SetPinNameOffset( 0 ); // pin text outside the body (name is on the pin)
401 }
402
404
406
407 // It's possible that the symbol being edited has no pins, in which case there may be no
408 // alternate body style objects causing #LIB_SYMBOL::HasCoversion() to always return false.
409 // This allows the user to edit the alternate body style just in case this condition occurs.
411
412 return true;
413}
414
415
417{
418 wxGridCellEditor* editor = m_grid->GetCellEditor( event.GetRow(), event.GetCol() );
419 wxControl* control = editor->GetControl();
420
421 if( control && control->GetValidator() && !control->GetValidator()->Validate( control ) )
422 {
423 event.Veto();
424
426 m_delayedFocusRow = event.GetRow();
427 m_delayedFocusColumn = event.GetCol();
429 }
430 else if( event.GetCol() == FDC_NAME )
431 {
432 wxString newName = event.GetString();
433
434 for( int i = 0; i < m_grid->GetNumberRows(); ++i )
435 {
436 if( i == event.GetRow() )
437 continue;
438
439 if( newName.CmpNoCase( m_grid->GetCellValue( i, FDC_NAME ) ) == 0 )
440 {
441 DisplayError( this, wxString::Format( _( "The name '%s' is already in use." ),
442 newName ) );
443 event.Veto();
444 m_delayedFocusRow = event.GetRow();
445 m_delayedFocusColumn = event.GetCol();
446 }
447 }
448 }
449
450 editor->DecRef();
451}
452
453
455{
456 if( m_OptionPower->IsChecked() )
457 m_grid->SetCellValue( VALUE_FIELD, FDC_VALUE, m_SymbolNameCtrl->GetValue() );
458}
459
460
462{
463 if( !m_delayedFocusCtrl )
464 {
465 // If the validation fails and we throw up a dialog then GTK will give us another
466 // KillFocus event and we end up in infinite recursion. So we use m_delayedFocusCtrl
467 // as a re-entrancy block and then clear it again if validation passes.
470
471 if( m_SymbolNameCtrl->GetValidator()->Validate( m_SymbolNameCtrl ) )
472 {
473 m_delayedFocusCtrl = nullptr;
475 }
476 }
477
478 event.Skip();
479}
480
481
482void DIALOG_LIB_SYMBOL_PROPERTIES::OnAddField( wxCommandEvent& event )
483{
485 return;
486
488 int fieldID = m_fields->size();
489 LIB_FIELD newField( m_libEntry, fieldID );
490
491 newField.SetTextSize( wxSize( schIUScale.MilsToIU( settings->m_Defaults.text_size ),
492 schIUScale.MilsToIU( settings->m_Defaults.text_size ) ) );
493
494 m_fields->push_back( newField );
495
496 // notify the grid
497 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
498 m_grid->ProcessTableMessage( msg );
499
500 m_grid->MakeCellVisible( (int) m_fields->size() - 1, 0 );
501 m_grid->SetGridCursor( (int) m_fields->size() - 1, 0 );
502
503 m_grid->EnableCellEditControl();
504 m_grid->ShowCellEditControl();
505
506 OnModify();
507}
508
509
511{
512 wxArrayInt selectedRows = m_grid->GetSelectedRows();
513
514 if( selectedRows.empty() && m_grid->GetGridCursorRow() >= 0 )
515 selectedRows.push_back( m_grid->GetGridCursorRow() );
516
517 if( selectedRows.empty() )
518 return;
519
520 for( int row : selectedRows )
521 {
522 if( row < MANDATORY_FIELDS )
523 {
524 DisplayError( this, wxString::Format( _( "The first %d fields are mandatory." ),
526 return;
527 }
528 }
529
530 m_grid->CommitPendingChanges( true /* quiet mode */ );
531
532 // Reverse sort so deleting a row doesn't change the indexes of the other rows.
533 selectedRows.Sort( []( int* first, int* second ) { return *second - *first; } );
534
535 for( int row : selectedRows )
536 {
537 m_fields->erase( m_fields->begin() + row );
538
539 // notify the grid
540 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, row, 1 );
541 m_grid->ProcessTableMessage( msg );
542
543 if( m_grid->GetNumberRows() > 0 )
544 {
545 m_grid->MakeCellVisible( std::max( 0, row-1 ), m_grid->GetGridCursorCol() );
546 m_grid->SetGridCursor( std::max( 0, row-1 ), m_grid->GetGridCursorCol() );
547 }
548 }
549
550 OnModify();
551}
552
553
554void DIALOG_LIB_SYMBOL_PROPERTIES::OnMoveUp( wxCommandEvent& event )
555{
557 return;
558
559 int i = m_grid->GetGridCursorRow();
560
561 if( i > MANDATORY_FIELDS )
562 {
563 LIB_FIELD tmp = m_fields->at( (unsigned) i );
564 m_fields->erase( m_fields->begin() + i, m_fields->begin() + i + 1 );
565 m_fields->insert( m_fields->begin() + i - 1, tmp );
566 m_grid->ForceRefresh();
567
568 m_grid->SetGridCursor( i - 1, m_grid->GetGridCursorCol() );
569 m_grid->MakeCellVisible( m_grid->GetGridCursorRow(), m_grid->GetGridCursorCol() );
570
571 OnModify();
572 }
573 else
574 {
575 wxBell();
576 }
577}
578
579
580void DIALOG_LIB_SYMBOL_PROPERTIES::OnMoveDown( wxCommandEvent& event )
581{
583 return;
584
585 int i = m_grid->GetGridCursorRow();
586
587 if( i >= MANDATORY_FIELDS && i + 1 < m_fields->GetNumberRows() )
588 {
589 LIB_FIELD tmp = m_fields->at( (unsigned) i );
590 m_fields->erase( m_fields->begin() + i, m_fields->begin() + i + 1 );
591 m_fields->insert( m_fields->begin() + i + 1, tmp );
592 m_grid->ForceRefresh();
593
594 m_grid->SetGridCursor( i + 1, m_grid->GetGridCursorCol() );
595 m_grid->MakeCellVisible( m_grid->GetGridCursorRow(), m_grid->GetGridCursorCol() );
596
597 OnModify();
598 }
599 else
600 {
601 wxBell();
602 }
603}
604
605
607{
608#ifdef KICAD_SPICE
609 int diff = m_fields->size();
610 auto symbol = SCH_SYMBOL( *m_libEntry, m_libEntry->GetLibId(), nullptr, 0 );
611
612 DIALOG_SIM_MODEL dialog( this, symbol, *m_fields );
613
614 if( dialog.ShowModal() != wxID_OK )
615 return;
616
617 diff = (int) m_fields->size() - diff;
618
619 if( diff > 0 )
620 {
621 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, diff );
622 m_grid->ProcessTableMessage( msg );
623 }
624 else if( diff < 0 )
625 {
626 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, 0, -diff );
627 m_grid->ProcessTableMessage( msg );
628 }
629
630 OnModify();
631 m_grid->ForceRefresh();
632#endif /* KICAD_SPICE */
633}
634
635
637{
638 int idx = m_FootprintFilterListBox->HitTest( event.GetPosition() );
639 wxCommandEvent dummy;
640
641 if( idx >= 0 )
643 else
645}
646
647
649{
650 // Running the Footprint Browser gums up the works and causes the automatic cancel
651 // stuff to no longer work. So we do it here ourselves.
652 EndQuasiModal( wxID_CANCEL );
653}
654
655
657{
658 wxString filterLine;
659 WX_TEXT_ENTRY_DIALOG dlg( this, _( "Filter:" ), _( "Add Footprint Filter" ), filterLine );
660
661 if( dlg.ShowModal() == wxID_CANCEL || dlg.GetValue().IsEmpty() )
662 return;
663
664 filterLine = dlg.GetValue();
665 filterLine.Replace( wxT( " " ), wxT( "_" ) );
666
667 // duplicate filters do no harm, so don't be a nanny.
668
669 m_FootprintFilterListBox->Append( filterLine );
670 m_FootprintFilterListBox->SetSelection( (int) m_FootprintFilterListBox->GetCount() - 1 );
671
672 OnModify();
673}
674
675
677{
678 int ii = m_FootprintFilterListBox->GetSelection();
679
680 if( ii >= 0 )
681 {
682 m_FootprintFilterListBox->Delete( (unsigned) ii );
683
684 if( m_FootprintFilterListBox->GetCount() == 0 )
685 m_FootprintFilterListBox->SetSelection( wxNOT_FOUND );
686 else
687 m_FootprintFilterListBox->SetSelection( std::max( 0, ii - 1 ) );
688 }
689
690 OnModify();
691}
692
693
695{
696 int idx = m_FootprintFilterListBox->GetSelection();
697
698 if( idx >= 0 )
699 {
700 wxString filter = m_FootprintFilterListBox->GetStringSelection();
701
702 WX_TEXT_ENTRY_DIALOG dlg( this, _( "Filter:" ), _( "Edit Footprint Filter" ), filter );
703
704 if( dlg.ShowModal() == wxID_OK && !dlg.GetValue().IsEmpty() )
705 {
706 m_FootprintFilterListBox->SetString( (unsigned) idx, dlg.GetValue() );
707 OnModify();
708 }
709 }
710}
711
712
714{
715 // Account for scroll bars
717
718 m_grid->AutoSizeColumn( FDC_NAME );
719
720 int fixedColsWidth = m_grid->GetColSize( FDC_NAME );
721
722 for( int i = 2; i < m_grid->GetNumberCols(); i++ )
723 fixedColsWidth += m_grid->GetColSize( i );
724
725 m_grid->SetColSize( FDC_VALUE, width - fixedColsWidth );
726}
727
728
729void DIALOG_LIB_SYMBOL_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& event )
730{
731 m_OptionPartsInterchangeable->Enable( m_SelNumberOfUnits->GetValue() > 1 );
733
734 if( m_grid->IsCellEditControlShown() )
735 {
736 int row = m_grid->GetGridCursorRow();
737 int col = m_grid->GetGridCursorCol();
738
739 if( row == VALUE_FIELD && col == FDC_VALUE && m_OptionPower->IsChecked() )
740 {
741 wxGridCellEditor* editor = m_grid->GetCellEditor( row, col );
742 m_SymbolNameCtrl->ChangeValue( editor->GetValue() );
743 editor->DecRef();
744 }
745 }
746
747 // Handle shown columns changes
748 wxString shownColumns = m_grid->GetShownColumns();
749
750 if( shownColumns != m_shownColumns )
751 {
752 m_shownColumns = shownColumns;
753
754 if( !m_grid->IsCellEditControlShown() )
756 }
757
758 // Handle a delayed focus. The delay allows us to:
759 // a) change focus when the error was triggered from within a killFocus handler
760 // b) show the correct notebook page in the background before the error dialog comes up
761 // when triggered from an OK or a notebook page change
762
763 if( m_delayedFocusPage >= 0 && m_NoteBook->GetSelection() != m_delayedFocusPage )
764 {
765 m_NoteBook->ChangeSelection( (unsigned) m_delayedFocusPage );
767 }
768
769 if( !m_delayedErrorMessage.IsEmpty() )
770 {
771 // We will re-enter this routine when the error dialog is displayed, so make
772 // sure we don't keep putting up more dialogs.
773 wxString msg = m_delayedErrorMessage;
774 m_delayedErrorMessage = wxEmptyString;
775
776 // Do not use DisplayErrorMessage(); it screws up window order on Mac
777 DisplayError( nullptr, msg );
778 }
779
781 {
782 m_delayedFocusCtrl->SetFocus();
783
784 if( auto textEntry = dynamic_cast<wxTextEntry*>( m_delayedFocusCtrl ) )
785 textEntry->SelectAll();
786
787 m_delayedFocusCtrl = nullptr;
788 }
789 else if( m_delayedFocusGrid )
790 {
791 m_delayedFocusGrid->SetFocus();
794
795 m_delayedFocusGrid->EnableCellEditControl( true );
796 m_delayedFocusGrid->ShowCellEditControl();
797
798 m_delayedFocusGrid = nullptr;
801 }
802}
803
804
806{
807 auto new_size = event.GetSize();
808
809 if( new_size != m_size )
810 {
811 m_size = new_size;
812
814 }
815
816 // Always propagate a wxSizeEvent:
817 event.Skip();
818}
819
820
822{
823 bSizerLowerBasicPanel->Show( !aIsAlias );
824 m_inheritanceSelectCombo->Enable( aIsAlias );
825 m_inheritsStaticText->Enable( aIsAlias );
826 m_grid->ForceRefresh();
827}
828
829
831{
832 if( m_OptionPower->IsChecked() )
833 {
834 m_excludeFromBomCheckBox->SetValue( true );
835 m_excludeFromBoardCheckBox->SetValue( true );
836 m_excludeFromBomCheckBox->Enable( false );
837 m_excludeFromBoardCheckBox->Enable( false );
838 }
839 else
840 {
841 m_excludeFromBomCheckBox->Enable( true );
842 m_excludeFromBoardCheckBox->Enable( true );
843 }
844
845 OnModify();
846}
847
848
849void DIALOG_LIB_SYMBOL_PROPERTIES::OnText( wxCommandEvent& event )
850{
851 OnModify();
852}
853
854
855void DIALOG_LIB_SYMBOL_PROPERTIES::OnCombobox( wxCommandEvent& event )
856{
857 OnModify();
858}
859
860
861void DIALOG_LIB_SYMBOL_PROPERTIES::OnCheckBox( wxCommandEvent& event )
862{
863 OnModify();
864}
865
866
868{
869 OnModify();
870}
871
872
874{
875 OnModify();
876}
877
878
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
Class DIALOG_LIB_SYMBOL_PROPERTIES_BASE.
void OnSymbolNameKillFocus(wxFocusEvent &event) override
void OnFilterDClick(wxMouseEvent &event) override
void OnSpinCtrlText(wxCommandEvent &event) override
void OnSizeGrid(wxSizeEvent &event) override
DIALOG_LIB_SYMBOL_PROPERTIES(SYMBOL_EDIT_FRAME *parent, LIB_SYMBOL *aLibEntry)
void OnUpdateUI(wxUpdateUIEvent &event) override
FIELDS_GRID_TABLE< LIB_FIELD > * m_fields
void OnCancelButtonClick(wxCommandEvent &event) override
void OnDeleteFootprintFilter(wxCommandEvent &event) override
void OnEditFootprintFilter(wxCommandEvent &event) override
void OnDeleteField(wxCommandEvent &event) override
void OnCombobox(wxCommandEvent &event) override
void OnMoveUp(wxCommandEvent &event) override
void OnText(wxCommandEvent &event) override
void OnMoveDown(wxCommandEvent &event) override
void OnAddFootprintFilter(wxCommandEvent &event) override
void OnCheckBox(wxCommandEvent &event) override
void OnSymbolNameText(wxCommandEvent &event) override
void onPowerCheckBox(wxCommandEvent &aEvent) override
void OnAddField(wxCommandEvent &event) override
void OnEditSpiceModel(wxCommandEvent &event) override
void OnSpinCtrl(wxSpinEvent &event) override
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void resetSize()
Clear the existing dialog size and position.
void EndQuasiModal(int retCode)
void OnModify()
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
void SetTextSize(const VECTOR2I &aNewSize)
Definition: eda_text.cpp:347
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:163
int GetNumberRows() override
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
Field object used in symbol libraries.
Definition: lib_field.h:60
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
Definition: lib_field.cpp:459
Define a library symbol object.
Definition: lib_symbol.h:98
void SetIncludeOnBoard(bool aIncludeOnBoard)
Set or clear include in board netlist flag.
Definition: lib_symbol.h:659
void SetShowPinNames(bool aShow)
Set or clear the pin name visibility flag.
Definition: lib_symbol.h:635
int GetPinNameOffset() const
Definition: lib_symbol.h:628
wxString GetKeyWords() const
Definition: lib_symbol.h:159
void SetConversion(bool aSetConvert, bool aDuplicatePins=true)
Set or clear the alternate body style (DeMorgan) for the symbol.
void SetUnitCount(int aCount, bool aDuplicateDrawItems=true)
Set the units per symbol count.
bool UnitsLocked() const
Check whether symbol units are interchangeable.
Definition: lib_symbol.h:253
bool IsRoot() const override
For symbols derived from other symbols, IsRoot() indicates no derivation.
Definition: lib_symbol.h:182
void SetPinNameOffset(int aOffset)
Set the offset in mils of the pin name text from the pin symbol.
Definition: lib_symbol.h:627
bool IsAlias() const
Definition: lib_symbol.h:183
bool IsPower() const
Definition: lib_symbol.cpp:552
bool GetIncludeOnBoard() const
Definition: lib_symbol.h:660
void SetPower()
Definition: lib_symbol.cpp:561
bool ShowPinNames() const
Definition: lib_symbol.h:636
void LockUnits(bool aLockUnits)
Set interchangeable the property for symbol units.
Definition: lib_symbol.h:247
void SetShowPinNumbers(bool aShow)
Set or clear the pin number visibility flag.
Definition: lib_symbol.h:643
LIB_ID GetLibId() const override
Definition: lib_symbol.h:139
void SetParent(LIB_SYMBOL *aParent=nullptr)
Definition: lib_symbol.cpp:451
wxString GetName() const override
Definition: lib_symbol.h:136
void SetDescription(const wxString &aDescription)
Definition: lib_symbol.h:144
void SetKeyWords(const wxString &aKeyWords)
Definition: lib_symbol.h:157
void GetFields(std::vector< LIB_FIELD * > &aList)
Return a list of fields within this symbol.
wxArrayString GetFPFilters() const
Definition: lib_symbol.h:194
LIB_FIELD & GetValueField()
Return reference to the value field.
void SetFPFilters(const wxArrayString &aFilters)
Definition: lib_symbol.h:192
bool GetIncludeInBom() const
Definition: lib_symbol.h:652
wxString GetDescription() override
Definition: lib_symbol.h:146
int GetUnitCount() const override
For items with units, return the number of units.
void SetIncludeInBom(bool aIncludeInBom)
Set or clear the include in schematic bill of materials flag.
Definition: lib_symbol.h:651
bool HasConversion() const
Test if symbol has more than one body conversion type (DeMorgan).
LIB_SYMBOL_REF & GetParent()
Definition: lib_symbol.h:125
void SetFields(const std::vector< LIB_FIELD > &aFieldsList)
Overwrite all the existing fields in this symbol with fields supplied in aFieldsList.
virtual void SetName(const wxString &aName)
Definition: lib_symbol.cpp:441
void SetNormal()
Definition: lib_symbol.cpp:579
bool ShowPinNumbers() const
Definition: lib_symbol.h:644
A text control validator used for validating the text allowed in library and schematic symbol fields.
Schematic symbol object.
Definition: sch_symbol.h:80
static bool IsReferenceStringValid(const wxString &aReferenceString)
Test for an acceptable reference string.
Definition: sch_symbol.cpp:668
The symbol library editor main window.
void UpdateAfterSymbolProperties(wxString *aOldName=nullptr)
wxString GetCurLib() const
The nickname of the current library being edited and empty string if none.
bool GetShowDeMorgan() const
bool IsSymbolFromLegacyLibrary() const
bool IsSymbolFromSchematic() const
SYMBOL_EDITOR_SETTINGS * GetSettings() const
LIB_SYMBOL_LIBRARY_MANAGER & GetLibManager()
void SetShowDeMorgan(bool show)
void SaveCopyInUndoList(EDA_ITEM *aItem, UNDO_REDO aUndoType=UNDO_REDO::LIBEDIT, bool aAppend=false)
Create a copy of the current symbol, and save it in the undo list.
LIB_SYMBOL * GetAlias(const wxString &aAlias, const wxString &aLibrary) const
Return either an alias of a working LIB_SYMBOL copy, or alias of the original symbol if there is no w...
void GetRootSymbolNames(const wxString &aLibName, wxArrayString &aRootSymbolNames)
bool SymbolExists(const wxString &aAlias, const wxString &aLibrary) const
Return true if symbol with a specific alias exists in library (either original one or buffered).
virtual long long int GetValue()
Return the current value in Internal Units.
void Enable(bool aEnable)
Enable/disable the label, widget and units label.
virtual void ChangeValue(int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion WITHOUT trigger...
void ShowHideColumns(const wxString &shownColumns)
Show/hide the grid columns based on a tokenized string of shown column indexes.
Definition: wx_grid.cpp:172
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:93
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:139
wxString GetShownColumns()
Get a tokenized string containing the shown column indexes.
Definition: wx_grid.cpp:153
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:226
A KICAD version of wxTextEntryDialog which supports the various improvements/work-arounds from DIALOG...
wxString GetValue() const
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:342
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:280
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:299
This file is part of the common library.
#define _(s)
@ FDC_NAME
@ FDC_VALUE
std::shared_ptr< LIB_SYMBOL > LIB_SYMBOL_SPTR
shared pointer to LIB_SYMBOL
Definition: lib_symbol.h:44
wxSize GetUnobscuredSize(const wxWindow *aWindow)
Tries to determine the size of the viewport of a scrollable widget (wxDataViewCtrl,...
Definition: gtk/ui.cpp:126
must_if< error >::control< Rule > control
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:74
wxString UnescapeString(const wxString &aSource)
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
@ CTX_LIBID
Definition: string_utils.h:55
constexpr int MilsToIU(int mils) const
Definition: base_units.h:94
@ DATASHEET_FIELD
name of datasheet
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ MANDATORY_FIELDS
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".
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:80