55 GetView()->ForceRefresh();
70 case COL_TYPE:
return _(
"Electrical Type" );
79 default: wxFAIL;
return wxEmptyString;
88 wxString
GetValue(
int aRow,
int aCol )
override 107 val =
pin->GetNumber();
110 val =
pin->GetName();
147 if( fieldValue.length() )
148 fieldValue += wxT(
", " );
153 if( !fieldValue.Length() )
155 else if( val != fieldValue )
163 void SetValue(
int aRow,
int aCol,
const wxString &aValue )
override 175 if( pins.size() == 1 )
176 pin->SetNumber( aValue );
180 pin->SetName( aValue );
214 pin->GetPosition().y ) );
218 pin->SetPosition( wxPoint(
pin->GetPosition().x,
234 static int findRow(
const std::vector<LIB_PINS>& aRowSet,
const wxString& aName )
236 for(
size_t i = 0; i < aRowSet.size(); ++i )
238 if( aRowSet[ i ][ 0 ] && aRowSet[ i ][ 0 ]->GetName() == aName )
248 wxString lhStr =
GetValue( lhs, sortCol, units );
249 wxString rhStr =
GetValue( rhs, sortCol, units );
255 lhStr =
GetValue( lhs, sortCol, units );
256 rhStr =
GetValue( rhs, sortCol, units );
263 auto cmp = [ ascending ](
const auto a,
const auto b )
288 res = cmp(
StrNumCmp( lhStr, rhStr ), 0 );
301 if(
auto grid = dynamic_cast<WX_GRID*>( GetView() ) )
302 grid->CommitPendingChanges(
true );
304 wxGridTableMessage msg(
this, wxGRIDTABLE_NOTIFY_ROWS_DELETED, 0,
m_rows.size() );
305 GetView()->ProcessTableMessage( msg );
320 rowIndex =
m_rows.size() - 1;
327 bool ascending =
true;
329 if( GetView() && GetView()->GetSortingColumn() != wxNOT_FOUND )
331 sortCol = GetView()->GetSortingColumn();
332 ascending = GetView()->IsSortOrderAscending();
342 wxGridTableMessage msg(
this, wxGRIDTABLE_NOTIFY_ROWS_APPENDED,
m_rows.size() );
343 GetView()->ProcessTableMessage( msg );
350 [ aSortCol, ascending, this ](
const LIB_PINS& lhs,
const LIB_PINS& rhs ) ->
bool 358 std::sort( aRow.begin(), aRow.end(),
368 row.push_back( aPin );
373 wxGridTableMessage msg(
this, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
374 GetView()->ProcessTableMessage( msg );
386 wxGridTableMessage msg(
this, wxGRIDTABLE_NOTIFY_ROWS_DELETED, aRow, 1 );
387 GetView()->ProcessTableMessage( msg );
409 if( aValue == wxT(
"1" ) )
413 else if( aValue == wxT(
"0" ) )
419 wxFAIL_MSG(
wxString::Format( wxT(
"string '%s' can't be converted to boolean " )
420 wxT(
"correctly, it will have been perceived as FALSE" ),
441 m_editFrame( parent ),
451 m_grid->SetDefaultRowSize(
m_grid->GetDefaultRowSize() + 4 );
463 wxGridCellAttr* attr;
465 attr =
new wxGridCellAttr;
472 attr =
new wxGridCellAttr;
479 attr =
new wxGridCellAttr;
483 orientationNames ) );
487 attr =
new wxGridCellAttr;
488 attr->SetRenderer(
new wxGridCellBoolRenderer() );
489 attr->SetEditor(
new wxGridCellBoolEditor() );
490 attr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
509 GetSizer()->SetSizeHints(
this);
529 m_grid->Connect( wxEVT_GRID_COL_SORT,
540 m_grid->Disconnect( wxEVT_GRID_COL_SORT,
547 m_grid->PopEventHandler(
true );
594 int sortCol = aEvent.GetCol();
599 if(
m_grid->IsSortingBy( sortCol ) )
601 ascending = !
m_grid->IsSortOrderAscending();
638 m_pins.push_back( newPin );
642 m_grid->MakeCellVisible(
m_grid->GetNumberRows() - 1, 0 );
643 m_grid->SetGridCursor(
m_grid->GetNumberRows() - 1, 0 );
645 m_grid->EnableCellEditControl(
true );
646 m_grid->ShowCellEditControl();
662 int curRow =
m_grid->GetGridCursorRow();
669 for(
auto pin : removedRow )
672 curRow = std::min( curRow,
m_grid->GetNumberRows() - 1 );
674 m_grid->SetGridCursor( curRow,
m_grid->GetGridCursorCol() );
675 m_grid->SelectRow( curRow );
703 aWidth -= (
m_grid->GetSize().x -
m_grid->GetClientSize().x );
705 wxGridUpdateLocker deferRepaintsTillLeavingScope;
724 aWidth -=
m_grid->GetColSize( i );
736 auto new_size =
event.GetSize().GetX();
756 if( !
m_grid->IsCellEditControlShown() )
773 int retval = wxID_CANCEL;
819 if(
pin->GetNumber().Length() )
PIN_TABLE_DATA_MODEL(SYMBOL_EDIT_FRAME *aFrame)
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
const std::vector< BITMAPS > & PinOrientationIcons()
void OnClose(wxCloseEvent &event) override
int GetNumberRows() override
void OnSize(wxSizeEvent &event) override
void SetOrientation(int aOrientation)
SYMBOL_EDIT_FRAME * m_editFrame
const std::vector< BITMAPS > & PinShapeIcons()
This file is part of the common library.
int GetOrientation() const
void ShowHideColumns(const wxString &shownColumns)
Show/hide the grid columns based on a tokenized string of shown column indexes.
std::vector< LIB_PIN * > LIB_PINS
Helper for defining a list of pin object pointers.
void SetShape(GRAPHIC_PINSHAPE aShape)
GRAPHIC_PINSHAPE GetShape() const
void OnAddRow(wxCommandEvent &event) override
SYMBOL_EDITOR_SETTINGS * GetSettings() const
void OnCellEdited(wxGridEvent &event) override
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
bool IsQuasiModal() const
int PinOrientationIndex(int code)
int GetNumberCols() override
int PinOrientationCode(int index)
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 RemoveDrawItem(LIB_ITEM *aItem)
Remove draw aItem from list.
LIB_PINS RemoveRow(int aRow)
wxString GetSummary() const
void SetPosition(const wxPoint &aPos) override
Define a library symbol object.
void RebuildRows(const LIB_PINS &aPins, bool groupByName)
virtual void SetParent(EDA_ITEM *aParent)
void DestroyTable(wxGridTableBase *aTable)
Work-around for a bug in wxGrid which crashes when deleting the table if the cell edit control was no...
void SortPins(LIB_PINS &aRow)
bool m_modified
true when there are unsaved changes
const wxArrayString & PinShapeNames()
void SetType(ELECTRICAL_PINTYPE aType)
bool IsEmptyCell(int row, int col) override
static int Compare(const wxString &lhs, const wxString &rhs)
bool IsSymbolAlias() const
Restore the empty editor screen, without any symbol or library selected.
~DIALOG_LIB_EDIT_PIN_TABLE() override
void insert(value_type const &v)
static bool BoolFromString(wxString aValue)
void SortRows(int aSortCol, bool ascending)
long long int ValueFromString(EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType)
Function ValueFromString converts aTextValue in aUnits to internal units used by the application.
bool TransferDataFromWindow() override
void OnRebuildRows(wxCommandEvent &event) override
void OnUpdateUI(wxUpdateUIEvent &event) override
const wxArrayString & PinTypeNames()
wxString m_PinTableVisibleColumns
wxBitmapButton * m_refreshButton
void AddDrawItem(LIB_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
SYMBOL_EDIT_FRAME * m_frame
wxButton * m_ButtonsCancel
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
wxString GetColLabelValue(int aCol) override
PIN_TABLE_DATA_MODEL * m_dataModel
wxString GetValue(int aRow, int aCol) override
static bool compare(const LIB_PINS &lhs, const LIB_PINS &rhs, int sortCol, bool ascending, EDA_UNITS units)
wxPoint GetPosition() const override
Class DIALOG_LIB_EDIT_PIN_TABLE_BASE.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
const wxArrayString & PinOrientationNames()
bool TransferDataToWindow() override
wxString GetShownColumns()
Get a tokenized string containing the shown column indexes.
const wxString & GetNumber() const
ELECTRICAL_PINTYPE GetType() const
LIB_SYMBOL * GetParent() const
void EndQuasiModal(int retCode)
static int findRow(const std::vector< LIB_PINS > &aRowSet, const wxString &aName)
void adjustGridColumns(int aWidth)
bool IsSymbolEditable() const
Test if a symbol is loaded and can be edited.
DIALOG_LIB_EDIT_PIN_TABLE(SYMBOL_EDIT_FRAME *parent, LIB_SYMBOL *aSymbol)
void OnDeleteRow(wxCommandEvent &event) override
ELECTRICAL_PINTYPE
The symbol library pin object electrical types used in ERC tests.
wxBitmapButton * m_deleteButton
void OnColSort(wxGridEvent &aEvent)
wxBitmapButton * m_addButton
static wxString GetValue(const LIB_PINS &pins, int aCol, EDA_UNITS aUserUnits)
wxString StringFromValue(EDA_UNITS aUnits, double aValue, bool aAddUnitSymbol, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
LIB_PIN * GetNextPin(LIB_PIN *aItem=nullptr)
Return the next pin object from the draw list.
void SetValue(int aRow, int aCol, const wxString &aValue) override
int StrNumCmp(const wxString &aString1, const wxString &aString2, bool aIgnoreCase)
Compare two strings with alphanumerical content.
int m_originalColWidths[COL_COUNT]
static std::map< int, wxString > shapeNames
#define INDETERMINATE_STATE
Used for holding indeterminate values, such as with multiple selections holding different values or c...
std::vector< LIB_PINS > m_rows
void OnCancel(wxCommandEvent &event) override
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
void AppendRow(LIB_PIN *aPin)
static wxString StringFromBool(bool aValue)
const std::vector< BITMAPS > & PinTypeIcons()
void onUnitsChanged(wxCommandEvent &aEvent)
The symbol library editor main window.