24#ifndef KICAD_WX_GRID_H
25#define KICAD_WX_GRID_H
34#include <wx/version.h>
45 wxGridCellAttr*
enhanceAttr( wxGridCellAttr* aInputAttr,
int aRow,
int aCol,
46 wxGridCellAttr::wxAttrKind aKind );
54 WX_GRID( wxWindow *parent, wxWindowID
id,
55 const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
56 long style = wxWANTS_CHARS,
const wxString&
name = wxGridNameStr );
99 void SetTable( wxGridTableBase*
table,
bool aTakeOwnership =
false );
116 void OnAddRow(
const std::function<std::pair<int, int>()>& aAdder );
122 void OnDeleteRows(
const std::function<
void(
int row )>& aDeleter );
124 void OnDeleteRows(
const std::function<
bool(
int row )>& aFilter,
125 const std::function<
void(
int row )>& aDeleter );
130 void SwapRows(
int aRowA,
int aRowB );
131 void OnMoveRowUp(
const std::function<
void(
int row )>& aMover );
132 void OnMoveRowDown(
const std::function<
void(
int row )>& aMover );
133 void OnMoveRowUp(
const std::function<
bool(
int row )>& aFilter,
134 const std::function<
void(
int row )>& aMover );
135 void OnMoveRowDown(
const std::function<
bool(
int row )>& aFilter,
136 const std::function<
void(
int row )>& aMover );
196 int GetVisibleWidth(
int aCol,
bool aHeader =
true,
bool aContents =
true,
bool aKeep =
false );
222 if( GetNumberRows() )
223 DeleteRows( 0, GetNumberRows() );
253 return wxGrid::DoGetBestSize();
291 std::pair<EDA_UNITS, EDA_DATA_TYPE>
getColumnUnits(
int aCol )
const;
297 std::unique_ptr<NUMERIC_EVALUATOR>
m_eval;
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
wxGridCellAttr * enhanceAttr(wxGridCellAttr *aInputAttr, int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind)
int GetVisibleWidth(int aCol, bool aHeader=true, bool aContents=true, bool aKeep=false)
Calculate the specified column based on the actual size of the text on screen.
void onGridCellSelect(wxGridEvent &aEvent)
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 onDPIChanged(wxDPIChangedEvent &event)
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...
void SetAutoEvalColUnits(int col, EDA_UNITS aUnit, EDA_DATA_TYPE aUnitType)
Set the unit and unit data type to use for a given column.
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.
std::pair< EDA_UNITS, EDA_DATA_TYPE > getColumnUnits(int aCol) const
Returns the units and data type associated with a given column.
void SetUnitValue(int aRow, int aCol, int aValue)
Set a unitized cell's value.
int GetUnitValue(int aRow, int aCol)
Apply standard KiCad unit and eval services to a numeric cell.
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 DrawCornerLabel(wxDC &dc) override
A re-implementation of wxGrid::DrawCornerLabel which draws flat borders.
void onCellEditorHidden(wxGridEvent &aEvent)
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 onGridColMove(wxGridEvent &aEvent)
void SetOptionalUnitValue(int aRow, int aCol, std::optional< int > aValue)
Set a unitized cell's optional value.
void onCellEditorShown(wxGridEvent &aEvent)
void EnsureColLabelsVisible()
Ensure the height of the row displaying the column labels is enough, even if labels are multiline tex...
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)
void DrawRowLabel(wxDC &dc, int row) override
A re-implementation of wxGrid::DrawRowLabel which draws flat borders.
std::bitset< 64 > GetShownColumns()
static void CellEditorSetMargins(wxTextEntryBase *aEntry)
A helper function to set OS-specific margins for text-based cell editors.
std::optional< int > GetOptionalUnitValue(int aRow, int aCol)
Apply standard KiCad unit and eval services to a numeric cell.
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...
void SetUnitsProvider(UNITS_PROVIDER *aProvider, int aCol=0)
Set a EUNITS_PROVIDER to enable use of unit- and eval-based Getters.
void ClearRows()
wxWidgets recently added an ASSERT which fires if the position is greater than or equal to the number...
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
std::unique_ptr< NUMERIC_EVALUATOR > m_eval
void DrawColLabel(wxDC &dc, int col) override
A re-implementation of wxGrid::DrawColLabel which left-aligns the first column and draws flat borders...
wxSize DoGetBestSize() const override
static void CellEditorTransformSizeRect(wxRect &aRect)
A helper function to tweak sizes of text-based cell editors depending on OS.
EDA_DATA_TYPE
The type of unit.