33#include <wx/version.h>
62 void SetColAttr( wxGridCellAttr* aAttr,
int aCol )
override
68 wxGridCellAttr*
GetAttr(
int aRow,
int aCol, wxGridCellAttr::wxAttrKind aKind )
override
83 wxGridCellAttr* enhanceAttr( wxGridCellAttr* aInputAttr,
int aRow,
int aCol,
84 wxGridCellAttr::wxAttrKind aKind );
95 WX_GRID( wxWindow *parent, wxWindowID
id,
96 const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
97 long style = wxWANTS_CHARS,
const wxString&
name = wxGridNameStr );
140 void SetTable( wxGridTableBase*
table,
bool aTakeOwnership =
false );
157 void OnAddRow(
const std::function<std::pair<int, int>()>& aAdder );
163 void OnDeleteRows(
const std::function<
void(
int row )>& aDeleter );
165 void OnDeleteRows(
const std::function<
bool(
int row )>& aFilter,
166 const std::function<
void(
int row )>& aDeleter );
171 void SwapRows(
int aRowA,
int aRowB );
172 void OnMoveRowUp(
const std::function<
void(
int row )>& aMover );
173 void OnMoveRowDown(
const std::function<
void(
int row )>& aMover );
174 void OnMoveRowUp(
const std::function<
bool(
int row )>& aFilter,
175 const std::function<
void(
int row )>& aMover );
176 void OnMoveRowDown(
const std::function<
bool(
int row )>& aFilter,
177 const std::function<
void(
int row )>& aMover );
196 void SetAutoEvalColUnits(
int col,
EDA_UNITS aUnit );
206 int GetUnitValue(
int aRow,
int aCol );
216 std::optional<int> GetOptionalUnitValue(
int aRow,
int aCol );
221 void SetUnitValue(
int aRow,
int aCol,
int aValue );
226 void SetOptionalUnitValue(
int aRow,
int aCol, std::optional<int> aValue );
237 int GetVisibleWidth(
int aCol,
bool aHeader =
true,
bool aContents =
true,
bool aKeep =
false );
243 void EnsureColLabelsVisible();
263 if( GetNumberRows() > 0 )
264 DeleteRows( 0, GetNumberRows(), aUpdateLabels );
270 static void CellEditorSetMargins( wxTextEntryBase* aEntry );
275 static void CellEditorTransformSizeRect( wxRect& aRect );
294 return wxGrid::DoGetBestSize();
301 void SetupColumnAutosizer(
int aFlexibleCol );
312 void DrawColLabel( wxDC& dc,
int col )
override;
317 void DrawRowLabel( wxDC& dc,
int row )
override;
322 void DrawCornerLabel( wxDC& dc )
override;
324 void onGridColMove( wxGridEvent& aEvent );
325 void onGridCellSelect( wxGridEvent& aEvent );
326 void onCellEditorShown( wxGridEvent& aEvent );
327 void onCellEditorHidden( wxGridEvent& aEvent );
329 void onDPIChanged(wxDPIChangedEvent& event);
342 std::pair<EDA_UNITS, EDA_DATA_TYPE> getColumnUnits(
int aCol )
const;
345 void recomputeGridWidths();
347 void onSizeEvent( wxSizeEvent& aEvent );
353 std::unique_ptr<NUMERIC_EVALUATOR>
m_eval;
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Icon provider for the "standard" row indicators, for example in layer selection lists.
~WX_GRID_TABLE_BASE() override
virtual GROUP_TYPE GetGroupType(int aRow) const
virtual bool IsExpanderColumn(int aCol) const
wxGridCellAttr * enhanceAttr(wxGridCellAttr *aInputAttr, int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind)
std::map< int, wxGridCellAttr * > m_colAttrs
wxGridCellAttr * GetAttr(int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind) override
void SetColAttr(wxGridCellAttr *aAttr, int aCol) override
std::map< int, int > m_autosizedCols
void SetLabelFont(const wxFont &aFont)
Hide wxGrid's SetLabelFont() because for some reason on MSW it's a one-shot and subsequent calls to i...
void ShowHideColumns(const wxString &shownColumns)
Show/hide the grid columns based on a tokenized string of shown column indexes.
void OnMoveRowUp(const std::function< void(int row)> &aMover)
std::map< int, UNITS_PROVIDER * > m_unitsProviders
std::optional< wxSize > m_minSizeOverride
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...
std::unordered_map< int, std::pair< EDA_UNITS, EDA_DATA_TYPE > > m_autoEvalColsUnits
void OverrideMinSize(double aXPct, double aYPct)
Grids that have column sizes automatically set to fill the available width don't want to shrink after...
bool CancelPendingChanges()
void SetColLabelSize(int aHeight)
Hide wxGrid's SetColLabelSize() method with one which makes sure the size is tall enough for the syst...
void SwapRows(int aRowA, int aRowB)
These aren't that tricky, but might as well share code.
WX_GRID(wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxWANTS_CHARS, const wxString &name=wxGridNameStr)
void SetGridWidthsDirty()
std::vector< int > m_autoEvalCols
UNITS_PROVIDER * getUnitsProvider(int aCol) const
std::map< std::pair< int, int >, std::pair< wxString, wxString > > m_evalBeforeAfter
void CancelShowEditorOnMouseUp()
void ClearRows(bool aUpdateLabels=true)
wxWidgets recently added an ASSERT which fires if the position is greater than or equal to the number...
ROW_ICON_PROVIDER * m_rowIconProvider
void OnMoveRowDown(const std::function< void(int row)> &aMover)
void ShowEditorOnMouseUp()
WxWidgets has a bunch of bugs in its handling of wxGrid mouse events which close cell editors right a...
void OnDeleteRows(const std::function< void(int row)> &aDeleter)
Handles a row deletion event.
wxString GetShownColumnsAsString()
Get a tokenized string containing the shown column indexes.
void OnAddRow(const std::function< std::pair< int, int >()> &aAdder)
std::bitset< 64 > GetShownColumns()
void SetAutoEvalCols(const std::vector< int > &aCols)
void EnableAlternateRowColors(bool aEnable=true)
Enable alternate row highlighting, where every odd row has a different background color than the even...
ROW_ICON_PROVIDER * GetRowIconProvider() const
void SetUnitsProvider(UNITS_PROVIDER *aProvider, int aCol=0)
Set a EUNITS_PROVIDER to enable use of unit- and eval-based Getters.
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
std::unique_ptr< NUMERIC_EVALUATOR > m_eval
wxSize DoGetBestSize() const override
EDA_DATA_TYPE
The type of unit.
enum KICOMMON_API GROUP_TYPE
GROUP_COLLAPSED_DURING_SORT