50#include <wx/clipbrd.h>
79 [&]( wxCommandEvent& aEvent )
83 m_grid->SetSelectionMode( wxGrid::wxGridSelectRows );
86 std::vector<SCH_FIELD> fields;
96 std::vector<SCH_FIELD*> parentFields;
97 parent->GetFields( parentFields );
99 for(
size_t ii = 0; ii < parentFields.size(); ++ii )
107 for(
size_t jj = 0; jj <
m_fields->size(); ++jj )
116 m_fields->SetFieldInherited( jj, *pf );
138 [
this]( wxCommandEvent& aEvent )
179 [&]( wxCommandEvent& aEvent )
181 wxCommandEvent cmdEvent( EDA_EVT_LISTBOX_DELETE );
187 [&]( wxCommandEvent& aEvent )
204 m_grid->GetParent()->Layout();
217 cfg->m_EditSymbolVisibleColumns =
m_grid->GetShownColumnsAsString();
227 m_grid->PopEventHandler(
true );
235 if( !wxDialog::TransferDataToWindow() )
238 std::set<wxString> defined;
241 defined.insert( field.GetName() );
249 if( !cfg->m_Drawing.field_names.IsEmpty() )
254 if( defined.count( templateFieldname.m_Name ) <= 0 )
257 field.
SetVisible( templateFieldname.m_Visible );
266 for(
size_t i = 0; i <
m_fields->size(); ++i )
270 m_fields->at( i ).SetPosition( pos );
274 wxGridTableMessage msg(
m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED,
m_fields->GetNumberRows() );
275 m_grid->ProcessTableMessage( msg );
286 for(
int unit = 0; unit <
m_libEntry->GetUnitCount(); unit++ )
288 if(
m_libEntry->GetUnitDisplayNames().contains( unit + 1 ) )
334 wxArrayString tmp =
m_libEntry->GetFPFilters();
341 std::set<wxString> availablePins;
344 availablePins.insert(
pin->GetNumber() );
351 for(
const wxString& pinNumber :
group )
353 availablePins.erase( pinNumber );
354 groupTxt << pinNumber;
356 if( ++i <
group.size() )
363 for(
const wxString&
pin : availablePins )
369 wxArrayString symbolNames;
370 wxString libName =
m_Parent->GetCurLib();
373 wxCHECK( !libName.empty(),
false );
375 m_Parent->GetLibManager().GetSymbolNames( libName, symbolNames );
379 [](
const wxString& a,
const wxString& b ) ->
int
385 if( symbolNames.Index(
m_libEntry->GetName() ) != wxNOT_FOUND )
395 if( selection == wxNOT_FOUND )
414 if( !
m_grid->CommitPendingChanges() )
438 for(
int ii = 0; ii < (int)
m_fields->size(); ++ii )
445 wxString fieldName = field.
GetName(
false );
447 if( fieldName.IsEmpty() && !field.
GetText().IsEmpty() )
467 if( parentName.IsEmpty() )
480 if( !
IsOK(
this,
_(
"Delete extra units from symbol?" ) ) )
484 int bodyStyleCount = 0;
503 if( bodyStyleCount == 0 )
509 if( bodyStyleCount < m_libEntry->GetBodyStyleCount() )
511 if( !
IsOK(
this,
_(
"Delete extra body styles from symbol?" ) ) )
521 if( !wxDialog::TransferDataFromWindow() )
524 if( !
m_grid->CommitPendingChanges() )
536 if( newName.IsEmpty() )
538 wxMessageBox(
_(
"Symbol must have a name." ) );
544 if( oldName != newName )
546 wxString libName =
m_Parent->GetCurLib();
548 if(
m_Parent->GetLibManager().SymbolNameInUse( newName, libName ) )
552 msg.Printf(
_(
"Symbol name '%s' already in use in library '%s'." ),
566 std::vector<SCH_FIELD> fieldsToSave;
569 for(
size_t ii = 0; ii <
m_fields->size(); ++ii )
585 if( field.
GetText().IsEmpty() )
590 else if( fieldName.IsEmpty() )
595 fieldsToSave.push_back( field );
606 wxString libName =
m_Parent->GetCurLib();
612 wxCHECK( newParent,
false );
632 m_libEntry->SetHasDeMorganBodyStyles(
false );
633 m_libEntry->SetBodyStyleCount( 1,
false,
false );
639 m_libEntry->SetBodyStyleCount( 2,
false,
true );
644 std::vector<wxString> bodyStyleNames;
652 m_libEntry->SetHasDeMorganBodyStyles(
false );
653 m_libEntry->SetBodyStyleCount( bodyStyleNames.size(),
true,
true );
654 m_libEntry->SetBodyStyleNames( bodyStyleNames );
665 m_libEntry->GetValueField().SetText( newName );
684 m_libEntry->SetPinNameOffset( offset == 0 ? 20 : offset );
695 std::vector<std::set<wxString>>& jumpers =
m_libEntry->JumperPinGroups();
701 std::set<wxString>&
group = jumpers.emplace_back();
703 while( tokenizer.HasMoreTokens() )
705 if( wxString token = tokenizer.GetNextToken(); !token.IsEmpty() )
706 group.insert( token );
710 m_Parent->UpdateAfterSymbolProperties( &oldName );
731 wxPoint pos = aEvent.GetPosition();
732 wxPoint unscolled_pos =
m_grid->CalcUnscrolledPosition( pos );
733 int row =
m_grid->YToRow( unscolled_pos.y );
734 int col =
m_grid->XToCol( unscolled_pos.x );
736 if( row == wxNOT_FOUND || col == wxNOT_FOUND || !
m_fields->IsInherited( row ) )
742 m_grid->SetToolTip( wxString::Format(
_(
"This field is inherited from '%s'." ),
743 m_fields->ParentField( row ).GetName() ) );
749 wxGridCellEditor*
editor =
m_grid->GetCellEditor( event.GetRow(), event.GetCol() );
750 wxControl* control =
editor->GetControl();
752 if( control && control->GetValidator() && !control->GetValidator()->Validate( control ) )
761 else if( event.GetCol() ==
FDC_NAME )
763 wxString newName =
event.GetString();
765 for(
int i = 0; i <
m_grid->GetNumberRows(); ++i )
767 if( i == event.GetRow() )
770 if( newName.CmpNoCase(
m_grid->GetCellValue( i,
FDC_NAME ) ) == 0 )
772 DisplayError(
this, wxString::Format(
_(
"The name '%s' is already in use." ), newName ) );
824 [&]() -> std::pair<int, int>
836 wxGridTableMessage msg(
m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
837 m_grid->ProcessTableMessage( msg );
850 if( row < m_fields->GetMandatoryRowCount() )
852 DisplayError(
this, wxString::Format(
_(
"The first %d fields are mandatory." ),
853 m_fields->GetMandatoryRowCount() ) );
865 wxGridTableMessage msg(
m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, row, 1 );
866 m_grid->ProcessTableMessage( msg );
878 return row >
m_fields->GetMandatoryRowCount();
894 return row >=
m_fields->GetMandatoryRowCount();
908 [&]() -> std::pair<int, int>
954 if( !
m_grid->CommitPendingChanges() )
959 std::vector<SCH_FIELD> fields;
962 fields.emplace_back( field );
970 for(
const SCH_FIELD& editedField : fields )
976 if( existingField.GetName() == editedField.GetName() )
979 existingField.SetText( editedField.GetText() );
986 m_fields->emplace_back( editedField );
987 wxGridTableMessage msg(
m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
988 m_grid->ProcessTableMessage( msg );
993 for(
int ii = (
int)
m_fields->size() - 1; ii >= 0; --ii )
1000 if( editedField.GetName() == existingField.
GetName() )
1009 m_grid->ClearSelection();
1012 wxGridTableMessage msg(
m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, ii, 1 );
1013 m_grid->ProcessTableMessage( msg );
1025 wxCommandEvent
dummy;
1044 wxString filterLine;
1051 filterLine.Replace( wxT(
" " ), wxT(
"_" ) );
1063 wxArrayInt selections;
1069 int idx = selections[0];
1093 for(
int i = 2; i <
m_grid->GetNumberCols(); i++ )
1094 fixedColsWidth +=
m_grid->GetColSize( i );
1096 m_grid->SetColSize(
FDC_VALUE, std::max( 120, width - fixedColsWidth ) );
1105 if(
m_grid->IsCellEditControlShown() )
1107 int row =
m_grid->GetGridCursorRow();
1108 int col =
m_grid->GetGridCursorCol();
1112 wxGridCellEditor*
editor =
m_grid->GetCellEditor( row, col );
1119 std::bitset<64> shownColumns =
m_grid->GetShownColumns();
1125 if( !
m_grid->IsCellEditControlShown() )
1156 textEntry->SelectAll();
1178 auto new_size =
event.GetSize();
1262 for(
int row =
m_unitNamesGrid->GetNumberRows() - needed; row < m_unitNamesGrid->GetNumberRows(); ++row )
1301 if( !
m_grid->CommitPendingChanges() )
1308 wxArrayInt selections;
1311 if( !selections.empty() )
1319 for(
int idx : selections )
1323 if( ++i < selections.Count() )
1327 for(
int idx = (
int) selections.size() - 1; idx >= 0; --idx )
1340 wxArrayInt selections;
1343 if( !selections.empty() )
1348 for(
int idx : selections )
1352 while( tokenizer.HasMoreTokens() )
1354 if( wxString token = tokenizer.GetNextToken(); !token.IsEmpty() )
1359 for(
int idx = (
int) selections.size() - 1; idx >= 0; --idx )
1370 wxArrayInt selections;
1378 wxArrayInt selections;
constexpr EDA_IU_SCALE schIUScale
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
STD_BITMAP_BUTTON * m_editFilterButton
wxBitmapButton * m_btnCreateJumperPinGroup
STD_BITMAP_BUTTON * m_bpAddBodyStyle
wxButton * m_spiceFieldsButton
DIALOG_LIB_SYMBOL_PROPERTIES_BASE(wxWindow *parent, wxWindowID id=ID_LIBEDIT_NOTEBOOK, const wxString &title=_("Library Symbol Properties"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
wxTextCtrl * m_KeywordCtrl
STD_BITMAP_BUTTON * m_bpAdd
wxListBox * m_listJumperPinGroups
WX_GRID * m_bodyStyleNamesGrid
wxButton * m_stdSizerButtonOK
wxBoxSizer * bSizerLowerBasicPanel
STD_BITMAP_BUTTON * m_bpDelete
wxCheckBox * m_PinsNameInsideButt
wxRadioButton * m_radioSingle
STD_BITMAP_BUTTON * m_deleteFilterButton
wxListBox * m_FootprintFilterListBox
STD_BITMAP_BUTTON * m_bpMoveDownBodyStyle
wxStaticText * m_nameOffsetUnits
wxComboBox * m_inheritanceSelectCombo
STD_BITMAP_BUTTON * m_bpDeleteBodyStyle
wxCheckBox * m_ShowPinNumButt
wxCheckBox * m_OptionPower
wxRadioButton * m_radioDeMorgan
wxStaticText * m_nameOffsetLabel
wxCheckBox * m_excludeFromBoardCheckBox
wxCheckBox * m_cbDuplicatePinsAreJumpers
STD_BITMAP_BUTTON * m_bpMoveUpBodyStyle
STD_BITMAP_BUTTON * m_bpMoveDown
wxButton * m_stdSizerButtonCancel
WX_GRID * m_unitNamesGrid
wxListBox * m_listAvailablePins
STD_BITMAP_BUTTON * m_addFilterButton
wxCheckBox * m_OptionLocalPower
wxTextCtrl * m_nameOffsetCtrl
wxCheckBox * m_excludeFromBomCheckBox
wxSpinCtrl * m_unitSpinCtrl
wxCheckBox * m_OptionPartsInterchangeable
wxCheckBox * m_excludeFromSimCheckBox
wxBitmapButton * m_btnRemoveJumperPinGroup
wxRadioButton * m_radioCustom
STD_BITMAP_BUTTON * m_bpMoveUp
wxTextCtrl * m_SymbolNameCtrl
wxStaticText * m_inheritsStaticText
wxCheckBox * m_ShowPinNameButt
void OnSymbolNameKillFocus(wxFocusEvent &event) override
void OnUnitSpinCtrlText(wxCommandEvent &event) override
std::unique_ptr< LISTBOX_TRICKS > m_fpFilterTricks
void OnPageChanging(wxNotebookEvent &event) override
wxString m_delayedErrorMessage
void OnBodyStyle(wxCommandEvent &event) override
FIELDS_GRID_TABLE * m_fields
WX_GRID * m_delayedFocusGrid
void OnSizeGrid(wxSizeEvent &event) override
std::set< wxString > m_addedTemplateFields
DIALOG_LIB_SYMBOL_PROPERTIES(SYMBOL_EDIT_FRAME *parent, LIB_SYMBOL *aLibEntry)
wxControl * m_delayedFocusCtrl
void OnGroupedPinListClick(wxCommandEvent &event) override
void OnUpdateUI(wxUpdateUIEvent &event) override
static LAST_LAYOUT m_lastLayout
void OnBodyStyleMoveUp(wxCommandEvent &event) override
void OnCancelButtonClick(wxCommandEvent &event) override
PANEL_EMBEDDED_FILES * m_embeddedFiles
void OnEditFootprintFilter(wxCommandEvent &event) override
void OnDeleteField(wxCommandEvent &event) override
bool TransferDataFromWindow() override
void OnCombobox(wxCommandEvent &event) override
void OnFpFilterDClick(wxMouseEvent &event) override
void OnUnitSpinCtrlEnter(wxCommandEvent &event) override
void OnAddBodyStyle(wxCommandEvent &event) override
void OnGridCellChanged(wxGridEvent &event)
std::bitset< 64 > m_shownColumns
void OnMoveUp(wxCommandEvent &event) override
void OnDeleteBodyStyle(wxCommandEvent &event) override
void OnAvailablePinsClick(wxCommandEvent &event) override
SYMBOL_EDIT_FRAME * m_Parent
void OnText(wxCommandEvent &event) override
void OnGridMotion(wxMouseEvent &event)
void OnUnitSpinCtrlKillFocus(wxFocusEvent &event) override
~DIALOG_LIB_SYMBOL_PROPERTIES()
static int m_lastOpenedPage
void OnMoveDown(wxCommandEvent &event) override
void OnAddFootprintFilter(wxCommandEvent &event) override
void syncControlStates(bool aIsAlias)
void OnCheckBox(wxCommandEvent &event) override
void OnSymbolNameText(wxCommandEvent &event) override
void OnBodyStyleMoveDown(wxCommandEvent &event) override
bool TransferDataToWindow() override
void OnGridCellChanging(wxGridEvent &event)
void onPowerCheckBox(wxCommandEvent &aEvent) override
void OnBtnCreateJumperPinGroup(wxCommandEvent &event) override
void OnAddField(wxCommandEvent &event) override
void OnEditSpiceModel(wxCommandEvent &event) override
UNIT_BINDER m_pinNameOffset
void OnUnitSpinCtrl(wxSpinEvent &event) override
void OnBtnRemoveJumperPinGroup(wxCommandEvent &event) override
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void resetSize()
Clear the existing dialog size and position.
void EndQuasiModal(int retCode)
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
EDA_BASE_FRAME * m_parentFrame
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
virtual const wxString & GetText() const
Return the string associated with the text object.
virtual void SetVisible(bool aVisible)
A text control validator used for validating the text allowed in fields.
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
Define a library symbol object.
bool IsRoot() const override
For symbols derived from other symbols, IsRoot() indicates no derivation.
static wxString LetterSubReference(int aUnit, wxChar aInitialLetter)
void SetOrdinal(int aOrdinal)
VECTOR2I GetPosition() const override
wxString GetCanonicalName() const
Get a non-language-specific name for a field which can be used for storage, variable look-up,...
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
void SetPosition(const VECTOR2I &aPosition) override
void SetName(const wxString &aName)
wxString m_EditSymbolVisibleColumns
The symbol library editor main window.
bool IsSymbolFromLegacyLibrary() const
bool IsSymbolFromSchematic() const
void AddTemplateFieldNames(const wxString &aSerializedFieldNames)
Add a serialized list of template field names.
const std::vector< TEMPLATE_FIELDNAME > & GetTemplateFieldNames()
Return a template field name list for read only access.
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.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
This file is part of the common library.
std::shared_ptr< LIB_SYMBOL > LIB_SYMBOL_SPTR
shared pointer to LIB_SYMBOL
wxString GetRefDesPrefix(const wxString &aRefDes)
Get the (non-numeric) prefix from a refdes - e.g.
Collection of utility functions for component reference designators (refdes)
T * GetAppSettings(const char *aFilename)
std::vector< FAB_LAYER_COLOR > dummy
int StrNumCmp(const wxString &aString1, const wxString &aString2, bool aIgnoreCase)
Compare two strings with alphanumerical content.
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:...
Hold a name of a symbol's field, field value, and default visibility.
wxString GetUserFieldName(int aFieldNdx, bool aTranslateForHI)
@ USER
The field ID hasn't been set yet; field is invalid.
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ VALUE
Field Value of part, i.e. "3.3K".
UNDO_REDO
Undo Redo considerations: Basically we have 3 cases New item Deleted item Modified item there is also...
VECTOR2< int32_t > VECTOR2I