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 )
65 m_grid->SetDefaultRowSize(
m_grid->GetDefaultRowSize() + 4 );
69 m_grid->SetSelectionMode( wxGrid::wxGridSelectRows );
75 wxGridCellAttr* attr =
new wxGridCellAttr;
105 m_grid->Connect( wxEVT_GRID_CELL_CHANGING,
121 m_grid->GetParent()->Layout();
139 m_grid->Disconnect( wxEVT_GRID_CELL_CHANGING,
144 m_grid->PopEventHandler(
true );
150 if( !wxDialog::TransferDataToWindow() )
158 for(
size_t i = 0; i <
m_fields->size(); ++i )
162 m_fields->at( i ).SetPosition( pos );
167 m_grid->ProcessTableMessage( msg );
205 wxArrayString rootSymbolNames;
209 wxCHECK( !libName.empty(),
false );
216 wxCHECK( rootSymbol,
false );
221 wxCHECK( selection != wxNOT_FOUND,
false );
236 int simEnableFieldRow = -1;
241 simEnableFieldRow = ii;
244 if( event.IsChecked() )
246 if( simEnableFieldRow == -1 )
248 simEnableFieldRow = (int)
m_fields->size();
252 wxGridTableMessage msg(
m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
253 m_grid->ProcessTableMessage( msg );
260 else if( simEnableFieldRow >= 0 )
265 wxGridTableMessage msg(
m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, simEnableFieldRow, 1 );
266 m_grid->ProcessTableMessage( msg );
299 wxString fieldName = field.
GetName(
false );
301 if( fieldName.IsEmpty() )
321 if( parentName.IsEmpty() )
335 if( !
IsOK(
this,
_(
"Delete extra units from symbol?" ) ) )
341 if( !
IsOK(
this,
_(
"Delete alternate body style (De Morgan) from symbol?" ) ) )
351 if( !wxDialog::TransferDataFromWindow() )
360 if( oldName != newName )
368 msg.Printf(
_(
"Symbol name '%s' already in use in library '%s'." ),
384 for(
int ii = 0; ii < (int)
m_fields->size(); ++ii )
388 m_fields->at( ii ).SetPosition( pos );
406 wxCHECK( newParent,
false );
409 wxCHECK( !newParent->
IsAlias(),
false );
467 wxGridCellEditor*
editor =
m_grid->GetCellEditor( event.GetRow(), event.GetCol() );
479 else if( event.GetCol() ==
FDC_NAME )
481 wxString newName =
event.GetString();
483 for(
int i = 0; i <
m_grid->GetNumberRows(); ++i )
485 if( i == event.GetRow() )
488 if( newName.CmpNoCase(
m_grid->GetCellValue( i,
FDC_NAME ) ) == 0 )
537 int fieldID = (int)
m_fields->size();
546 wxGridTableMessage msg(
m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
547 m_grid->ProcessTableMessage( msg );
552 m_grid->EnableCellEditControl();
553 m_grid->ShowCellEditControl();
561 wxArrayInt selectedRows =
m_grid->GetSelectedRows();
563 if( selectedRows.empty() &&
m_grid->GetGridCursorRow() >= 0 )
564 selectedRows.push_back(
m_grid->GetGridCursorRow() );
566 if( selectedRows.empty() )
569 for(
int row : selectedRows )
582 selectedRows.Sort( [](
int* first,
int* second ) {
return *second - *first; } );
584 for(
int row : selectedRows )
589 wxGridTableMessage msg(
m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, row, 1 );
590 m_grid->ProcessTableMessage( msg );
592 if(
m_grid->GetNumberRows() > 0 )
594 m_grid->MakeCellVisible( std::max( 0, row-1 ),
m_grid->GetGridCursorCol() );
595 m_grid->SetGridCursor( std::max( 0, row-1 ),
m_grid->GetGridCursorCol() );
608 int i =
m_grid->GetGridCursorRow();
617 m_grid->SetGridCursor( i - 1,
m_grid->GetGridCursorCol() );
634 int i =
m_grid->GetGridCursorRow();
643 m_grid->SetGridCursor( i + 1,
m_grid->GetGridCursorCol() );
661 std::vector<LIB_FIELD> fields;
664 fields.emplace_back( field );
668 if( dialog.ShowModal() != wxID_OK )
672 for(
const LIB_FIELD& editedField : fields )
678 if( existingField.GetName() == editedField.GetName() )
681 existingField.SetText( editedField.GetText() );
688 m_fields->emplace_back( editedField );
689 wxGridTableMessage msg(
m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
690 m_grid->ProcessTableMessage( msg );
695 for(
int ii = (
int)
m_fields->size() - 1; ii >= 0; )
702 if( editedField.GetName() == existingField.
GetName() )
716 wxGridTableMessage msg(
m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, ii, 1 );
717 m_grid->ProcessTableMessage( msg );
730 wxCommandEvent
dummy;
752 if( dlg.ShowModal() == wxID_CANCEL || dlg.
GetValue().IsEmpty() )
756 filterLine.Replace( wxT(
" " ), wxT(
"_" ) );
795 if( dlg.ShowModal() == wxID_OK && !dlg.
GetValue().IsEmpty() )
814 for(
int i = 2; i <
m_grid->GetNumberCols(); i++ )
815 fixedColsWidth +=
m_grid->GetColSize( i );
817 m_grid->SetColSize(
FDC_VALUE, std::max( 120, width - fixedColsWidth ) );
826 if(
m_grid->IsCellEditControlShown() )
828 int row =
m_grid->GetGridCursorRow();
829 int col =
m_grid->GetGridCursorCol();
833 wxGridCellEditor*
editor =
m_grid->GetCellEditor( row, col );
846 if( !
m_grid->IsCellEditControlShown() )
877 textEntry->SelectAll();
914 auto new_size =
event.GetSize();
constexpr EDA_IU_SCALE schIUScale
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Class DIALOG_LIB_SYMBOL_PROPERTIES_BASE.
STD_BITMAP_BUTTON * m_editFilterButton
wxButton * m_spiceFieldsButton
wxTextCtrl * m_KeywordCtrl
STD_BITMAP_BUTTON * m_bpAdd
wxButton * m_stdSizerButtonOK
wxBoxSizer * bSizerLowerBasicPanel
STD_BITMAP_BUTTON * m_bpDelete
wxCheckBox * m_PinsNameInsideButt
STD_BITMAP_BUTTON * m_deleteFilterButton
wxListBox * m_FootprintFilterListBox
wxCheckBox * m_AsConvertButt
wxComboBox * m_inheritanceSelectCombo
wxSpinCtrl * m_SelNumberOfUnits
wxCheckBox * m_ShowPinNumButt
wxCheckBox * m_OptionPower
wxCheckBox * m_excludeFromBoardCheckBox
STD_BITMAP_BUTTON * m_bpMoveDown
wxButton * m_stdSizerButtonCancel
wxCheckBox * m_excludeFromSim
STD_BITMAP_BUTTON * m_addFilterButton
wxCheckBox * m_excludeFromBomCheckBox
wxCheckBox * m_OptionPartsInterchangeable
STD_BITMAP_BUTTON * m_bpMoveUp
wxTextCtrl * m_SymbolNameCtrl
wxStaticText * m_inheritsStaticText
wxCheckBox * m_ShowPinNameButt
void OnSymbolNameKillFocus(wxFocusEvent &event) override
void OnFilterDClick(wxMouseEvent &event) override
wxString m_delayedErrorMessage
void OnSpinCtrlText(wxCommandEvent &event) override
WX_GRID * m_delayedFocusGrid
void OnSizeGrid(wxSizeEvent &event) override
DIALOG_LIB_SYMBOL_PROPERTIES(SYMBOL_EDIT_FRAME *parent, LIB_SYMBOL *aLibEntry)
wxControl * m_delayedFocusCtrl
void OnUpdateUI(wxUpdateUIEvent &event) override
static LAST_LAYOUT m_lastLayout
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
bool TransferDataFromWindow() override
void OnCombobox(wxCommandEvent &event) override
void OnMoveUp(wxCommandEvent &event) override
SYMBOL_EDIT_FRAME * m_Parent
void OnText(wxCommandEvent &event) override
~DIALOG_LIB_SYMBOL_PROPERTIES()
static int m_lastOpenedPage
void OnExcludeFromSimulation(wxCommandEvent &event) override
void OnMoveDown(wxCommandEvent &event) override
void OnAddFootprintFilter(wxCommandEvent &event) override
void syncControlStates(bool aIsAlias)
void OnCheckBox(wxCommandEvent &event) override
void OnSymbolNameText(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 OnSpinCtrl(wxSpinEvent &event) override
UNIT_BINDER m_pinNameOffset
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...
virtual const wxString & GetText() const
Return the string associated with the text object.
void SetTextSize(const VECTOR2I &aNewSize)
virtual void SetText(const wxString &aText)
wxString GetValue(int aRow, int aCol) override
int GetNumberRows() override
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
Field object used in symbol libraries.
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
Define a library symbol object.
void SetIncludeOnBoard(bool aIncludeOnBoard)
Set or clear include in board netlist flag.
void SetShowPinNames(bool aShow)
Set or clear the pin name visibility flag.
int GetPinNameOffset() const
wxString GetKeyWords() const
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.
bool IsRoot() const override
For symbols derived from other symbols, IsRoot() indicates no derivation.
void SetPinNameOffset(int aOffset)
Set the offset in mils of the pin name text from the pin symbol.
bool GetIncludeOnBoard() const
bool ShowPinNames() const
void LockUnits(bool aLockUnits)
Set interchangeable the property for symbol units.
void SetShowPinNumbers(bool aShow)
Set or clear the pin number visibility flag.
void SetParent(LIB_SYMBOL *aParent=nullptr)
wxString GetName() const override
void SetDescription(const wxString &aDescription)
void SetKeyWords(const wxString &aKeyWords)
void GetFields(std::vector< LIB_FIELD * > &aList)
Return a list of fields within this symbol.
LIB_FIELD * FindField(const wxString &aFieldName)
Find a field within this symbol matching aFieldName and returns it or NULL if not found.
wxArrayString GetFPFilters() const
LIB_FIELD & GetValueField()
Return reference to the value field.
void SetFPFilters(const wxArrayString &aFilters)
bool GetIncludeInBom() const
wxString GetDescription() override
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.
bool HasConversion() const
Test if symbol has more than one body conversion type (DeMorgan).
LIB_SYMBOL_REF & GetParent()
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)
bool ShowPinNumbers() const
A text control validator used for validating the text allowed in library and schematic symbol fields.
static bool IsReferenceStringValid(const wxString &aReferenceString)
Test for an acceptable reference string.
wxString m_EditSymbolVisibleColumns
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.
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...
void DestroyTable(wxGridTableBase *aTable)
Work-around for a bug in wxGrid which crashes when deleting the table if the cell edit control was no...
wxString GetShownColumns()
Get a tokenized string containing the shown column indexes.
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
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 DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
std::shared_ptr< LIB_SYMBOL > LIB_SYMBOL_SPTR
shared pointer to LIB_SYMBOL
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.
std::vector< FAB_LAYER_COLOR > dummy
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:...
constexpr int MilsToIU(int mils) const
@ 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".