50#include <wx/clipbrd.h> 
   79                                                      [&]( wxCommandEvent& aEvent )
 
   83    m_grid->SetSelectionMode( wxGrid::wxGridSelectRows );
 
   86    std::vector<SCH_FIELD> fields;
 
   92    if( std::shared_ptr<LIB_SYMBOL> parent = 
m_libEntry->GetParent().lock() )
 
  105                                                             [
this]( wxCommandEvent& aEvent )
 
  115                                                           [
this]( wxCommandEvent& aEvent )
 
  155                                [&]( wxCommandEvent& aEvent )
 
  157                                    wxCommandEvent cmdEvent( EDA_EVT_LISTBOX_DELETE );
 
  163                                    [&]( wxCommandEvent& aEvent )
 
  180    m_grid->GetParent()->Layout();
 
 
  193        cfg->m_EditSymbolVisibleColumns = 
m_grid->GetShownColumnsAsString();
 
  203    m_grid->PopEventHandler( 
true );
 
 
  212    if( std::shared_ptr<LIB_SYMBOL> ancestor = aParent->GetParent().lock() )
 
  215    std::vector<SCH_FIELD*> parentFields;
 
  216    aParent->GetFields( parentFields );
 
  218    for( 
SCH_FIELD* parentField : parentFields )
 
  222        if( parentField->IsMandatory() )
 
  225        for( 
size_t ii = 0; ii < 
m_fields->size(); ++ii )
 
  234                m_fields->SetFieldInherited( ii, *parentField );
 
  241            m_fields->AddInheritedField( *parentField );
 
 
  248    if( !wxDialog::TransferDataToWindow() )
 
  251    std::set<wxString> defined;
 
  254        defined.insert( field.GetName() );
 
  262        if( !cfg->m_Drawing.field_names.IsEmpty() )
 
  267            if( defined.count( templateFieldname.m_Name ) <= 0 )
 
  270                field.
SetVisible( templateFieldname.m_Visible );
 
  281    wxGridTableMessage msg( 
m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 
m_fields->GetNumberRows() );
 
  282    m_grid->ProcessTableMessage( msg );
 
  292    for( 
int unit = 0; unit < 
m_libEntry->GetUnitCount(); unit++ )
 
  294        if( 
m_libEntry->GetUnitDisplayNames().contains( unit + 1 ) )
 
  340    wxArrayString tmp = 
m_libEntry->GetFPFilters();
 
  345    std::set<wxString> availablePins;
 
  348        availablePins.insert( 
pin->GetNumber() );
 
  354        for( 
const wxString& pinNumber : 
group )
 
  356            if( !groupTxt.IsEmpty() )
 
  359            groupTxt << pinNumber;
 
  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 )
 
  390        if( std::shared_ptr<LIB_SYMBOL> rootSymbol = 
m_libEntry->GetParent().lock() )
 
  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( !
m_grid->CommitPendingChanges()
 
  532    if( newName.IsEmpty() )
 
  534        wxMessageBox( 
_( 
"Symbol must have a name." ) );
 
  540    if( oldName != newName )
 
  542        wxString libName = 
m_Parent->GetCurLib();
 
  544        if( 
m_Parent->GetLibManager().SymbolNameInUse( newName, libName ) )
 
  548            msg.Printf( 
_( 
"Symbol name '%s' already in use in library '%s'." ),
 
  562    std::vector<SCH_FIELD> fieldsToSave;
 
  565    for( 
size_t ii = 0; ii < 
m_fields->size(); ++ii )
 
  577        if( field.
GetText().IsEmpty() )
 
  582        else if( fieldName.IsEmpty() )
 
  587        fieldsToSave.push_back( field );
 
  598        wxString libName = 
m_Parent->GetCurLib();
 
  604        wxCHECK( newParent, 
false );
 
  624        m_libEntry->SetHasDeMorganBodyStyles( 
false );
 
  625        m_libEntry->SetBodyStyleCount( 1, 
false, 
false );
 
  631        m_libEntry->SetBodyStyleCount( 2, 
false, 
true );
 
  636        std::vector<wxString> bodyStyleNames;
 
  644        m_libEntry->SetHasDeMorganBodyStyles( 
false );
 
  645        m_libEntry->SetBodyStyleCount( bodyStyleNames.size(), 
true, 
true );
 
  646        m_libEntry->SetBodyStyleNames( bodyStyleNames );
 
  657        m_libEntry->GetValueField().SetText( newName );
 
  676        m_libEntry->SetPinNameOffset( offset == 0 ? 20 : offset );
 
  687    std::vector<std::set<wxString>>& jumpers = 
m_libEntry->JumperPinGroups();
 
  692        wxStringTokenizer tokenizer( 
m_jumperGroupsGrid->GetCellValue( ii, 0 ), 
", \t\r\n", wxTOKEN_STRTOK );
 
  693        std::set<wxString>& 
group = jumpers.emplace_back();
 
  695        while( tokenizer.HasMoreTokens() )
 
  697            if( wxString token = tokenizer.GetNextToken(); !token.IsEmpty() )
 
  698                group.insert( token );
 
  702    m_Parent->UpdateAfterSymbolProperties( &oldName );
 
 
  723    wxPoint pos = aEvent.GetPosition();
 
  724    wxPoint unscolled_pos = 
m_grid->CalcUnscrolledPosition( pos );
 
  725    int row = 
m_grid->YToRow( unscolled_pos.y );
 
  726    int col = 
m_grid->XToCol( unscolled_pos.x );
 
  728    if( row == wxNOT_FOUND || col == wxNOT_FOUND || !
m_fields->IsInherited( row ) )
 
  734    m_grid->SetToolTip( wxString::Format( 
_( 
"This field is inherited from '%s'." ),
 
  735                                          m_fields->ParentField( row ).GetName() ) );
 
 
  741    wxGridCellEditor* 
editor = 
m_grid->GetCellEditor( event.GetRow(), event.GetCol() );
 
  742    wxControl* control = 
editor->GetControl();
 
  744    if( control && control->GetValidator() && !control->GetValidator()->Validate( control ) )
 
  753    else if( event.GetCol() == 
FDC_NAME )
 
  755        wxString newName = 
event.GetString();
 
  757        for( 
int i = 0; i < 
m_grid->GetNumberRows(); ++i )
 
  759            if( i == event.GetRow() )
 
  762            if( newName.CmpNoCase( 
m_grid->GetCellValue( i, 
FDC_NAME ) ) == 0 )
 
  764                DisplayError( 
this, wxString::Format( 
_( 
"The name '%s' is already in use." ), newName ) );
 
 
  816            [&]() -> std::pair<int, int>
 
  828                wxGridTableMessage msg( 
m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
 
  829                m_grid->ProcessTableMessage( msg );
 
 
  842                if( row < m_fields->GetMandatoryRowCount() )
 
  844                    DisplayError( 
this, wxString::Format( 
_( 
"The first %d fields are mandatory." ),
 
  845                                                          m_fields->GetMandatoryRowCount() ) );
 
  857                wxGridTableMessage msg( 
m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, row, 1 );
 
  858                m_grid->ProcessTableMessage( msg );
 
 
  870                return row > 
m_fields->GetMandatoryRowCount();
 
 
  886                return row >= 
m_fields->GetMandatoryRowCount();
 
 
  900            [&]() -> std::pair<int, int>
 
 
  946    if( !
m_grid->CommitPendingChanges() )
 
  951    std::vector<SCH_FIELD> fields;
 
  954        fields.emplace_back( field );
 
  962    for( 
const SCH_FIELD& editedField : fields )
 
  968            if( existingField.GetName() == editedField.GetName() )
 
  971                existingField.SetText( editedField.GetText() );
 
  978            m_fields->emplace_back( editedField );
 
  979            wxGridTableMessage msg( 
m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
 
  980            m_grid->ProcessTableMessage( msg );
 
  985    for( 
int ii = (
int) 
m_fields->size() - 1; ii >= 0; --ii )
 
  992            if( editedField.GetName() == existingField.
GetName() )
 
 1001            m_grid->ClearSelection();
 
 1004            wxGridTableMessage msg( 
m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, ii, 1 );
 
 1005            m_grid->ProcessTableMessage( msg );
 
 
 1017    wxCommandEvent 
dummy;
 
 
 1036    wxString  filterLine;
 
 1043    filterLine.Replace( wxT( 
" " ), wxT( 
"_" ) );
 
 
 1055    wxArrayInt selections;
 
 1061        int idx = selections[0];
 
 
 1080    if( 
m_grid->IsCellEditControlShown() )
 
 1082        int row = 
m_grid->GetGridCursorRow();
 
 1083        int col = 
m_grid->GetGridCursorCol();
 
 1087            wxGridCellEditor* 
editor = 
m_grid->GetCellEditor( row, col );
 
 1094    std::bitset<64> shownColumns = 
m_grid->GetShownColumns();
 
 1100        if( !
m_grid->IsCellEditControlShown() )
 
 1101            m_grid->SetGridWidthsDirty();
 
 1131            textEntry->SelectAll();
 
 
 1221        for( 
int row = 
m_unitNamesGrid->GetNumberRows() - needed; row < m_unitNamesGrid->GetNumberRows(); ++row )
 
 
 1260    if( !
m_grid->CommitPendingChanges() )
 
 
 1268            [&]() -> std::pair<int, int>
 
 
constexpr EDA_IU_SCALE schIUScale
 
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
 
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
 
STD_BITMAP_BUTTON * m_editFilterButton
 
WX_GRID * m_jumperGroupsGrid
 
STD_BITMAP_BUTTON * m_bpAddBodyStyle
 
wxButton * m_spiceFieldsButton
 
STD_BITMAP_BUTTON * m_bpAddJumperGroup
 
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
 
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
 
STD_BITMAP_BUTTON * m_addFilterButton
 
wxCheckBox * m_OptionLocalPower
 
wxTextCtrl * m_nameOffsetCtrl
 
wxCheckBox * m_excludeFromBomCheckBox
 
STD_BITMAP_BUTTON * m_bpRemoveJumperGroup
 
wxSpinCtrl * m_unitSpinCtrl
 
wxCheckBox * m_OptionPartsInterchangeable
 
wxCheckBox * m_excludeFromSimCheckBox
 
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
 
std::set< wxString > m_addedTemplateFields
 
DIALOG_LIB_SYMBOL_PROPERTIES(SYMBOL_EDIT_FRAME *parent, LIB_SYMBOL *aLibEntry)
 
wxControl * m_delayedFocusCtrl
 
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 OnAddJumperGroup(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
 
void OnRemoveJumperGroup(wxCommandEvent &event) override
 
bool TransferDataToWindow() override
 
void OnGridCellChanging(wxGridEvent &event)
 
void onPowerCheckBox(wxCommandEvent &aEvent) override
 
void OnAddField(wxCommandEvent &event) override
 
void OnEditSpiceModel(wxCommandEvent &event) override
 
void addInheritedFields(const std::shared_ptr< LIB_SYMBOL > &aParent)
 
UNIT_BINDER m_pinNameOffset
 
void OnUnitSpinCtrl(wxSpinEvent &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)
 
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 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.
 
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