|
KiCad PCB EDA Suite
|
#include <wx_grid.h>
Public Member Functions | |
| WX_GRID (wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxWANTS_CHARS, const wxString &name=wxGridNameStr) | |
| ~WX_GRID () override | |
| void | SetColLabelSize (int aHeight) |
| Hide wxGrid's SetColLabelSize() method with one which makes sure the size is tall enough for the system GUI font. | |
| void | SetLabelFont (const wxFont &aFont) |
| Hide wxGrid's SetLabelFont() because for some reason on MSW it's a one-shot and subsequent calls to it have no effect. | |
| void | EnableAlternateRowColors (bool aEnable=true) |
| Enable alternate row highlighting, where every odd row has a different background color than the even rows. | |
| wxString | GetShownColumnsAsString () |
| Get a tokenized string containing the shown column indexes. | |
| std::bitset< 64 > | GetShownColumns () |
| 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 the table. | |
| void | DestroyTable (wxGridTableBase *aTable) |
| Work-around for a bug in wxGrid which crashes when deleting the table if the cell edit control was not closed. | |
| bool | CommitPendingChanges (bool aQuietMode=false) |
| Close any open cell edit controls. | |
| bool | CancelPendingChanges () |
| void | OnAddRow (const std::function< std::pair< int, int >()> &aAdder) |
| void | OnDeleteRows (const std::function< void(int row)> &aDeleter) |
| Handles a row deletion event. | |
| void | OnDeleteRows (const std::function< bool(int row)> &aFilter, const std::function< void(int row)> &aDeleter) |
| void | SwapRows (int aRowA, int aRowB) |
| These aren't that tricky, but might as well share code. | |
| void | OnMoveRowUp (const std::function< void(int row)> &aMover) |
| void | OnMoveRowDown (const std::function< void(int row)> &aMover) |
| void | OnMoveRowUp (const std::function< bool(int row)> &aFilter, const std::function< void(int row)> &aMover) |
| void | OnMoveRowDown (const std::function< bool(int row)> &aFilter, const std::function< void(int row)> &aMover) |
| void | SetUnitsProvider (UNITS_PROVIDER *aProvider, int aCol=0) |
| Set a EUNITS_PROVIDER to enable use of unit- and eval-based Getters. | |
| void | SetAutoEvalCols (const std::vector< int > &aCols) |
| void | SetAutoEvalColUnits (int col, EDA_UNITS aUnit, EDA_DATA_TYPE aUnitType) |
| Set the unit and unit data type to use for a given column. | |
| void | SetAutoEvalColUnits (int col, EDA_UNITS aUnit) |
| Set the unit to use for a given column. | |
| int | GetUnitValue (int aRow, int aCol) |
| Apply standard KiCad unit and eval services to a numeric cell. | |
| std::optional< int > | GetOptionalUnitValue (int aRow, int aCol) |
| Apply standard KiCad unit and eval services to a numeric cell. | |
| void | SetUnitValue (int aRow, int aCol, int aValue) |
| Set a unitized cell's value. | |
| void | SetOptionalUnitValue (int aRow, int aCol, std::optional< int > aValue) |
| Set a unitized cell's optional value. | |
| 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 | EnsureColLabelsVisible () |
| Ensure the height of the row displaying the column labels is enough, even if labels are multiline texts. | |
| void | ShowEditorOnMouseUp () |
| WxWidgets has a bunch of bugs in its handling of wxGrid mouse events which close cell editors right after opening them. | |
| 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 of rows (even if the delete count is 0). | |
| void | OverrideMinSize (double aXPct, double aYPct) |
| Grids that have column sizes automatically set to fill the available width don't want to shrink afterwards (because wxGrid reports the aggregate column size as the bestSize. | |
| wxSize | DoGetBestSize () const override |
| void | SetupColumnAutosizer (int aFlexibleCol) |
| Set autosize behaviour using wxFormBuilder column widths as minimums, with a single specified growable column. | |
| void | SetGridWidthsDirty () |
| ROW_ICON_PROVIDER * | GetRowIconProvider () const |
Static Public Member Functions | |
| static void | CellEditorSetMargins (wxTextEntryBase *aEntry) |
| A helper function to set OS-specific margins for text-based cell editors. | |
| static void | CellEditorTransformSizeRect (wxRect &aRect) |
| A helper function to tweak sizes of text-based cell editors depending on OS. | |
Protected Member Functions | |
| void | DrawColLabel (wxDC &dc, int col) override |
| A re-implementation of wxGrid::DrawColLabel which left-aligns the first column and draws flat borders. | |
| void | DrawRowLabel (wxDC &dc, int row) override |
| A re-implementation of wxGrid::DrawRowLabel which draws flat borders. | |
| void | DrawCornerLabel (wxDC &dc) override |
| A re-implementation of wxGrid::DrawCornerLabel which draws flat borders. | |
| void | onGridColMove (wxGridEvent &aEvent) |
| void | onGridCellSelect (wxGridEvent &aEvent) |
| void | onCellEditorShown (wxGridEvent &aEvent) |
| void | onCellEditorHidden (wxGridEvent &aEvent) |
| void | onDPIChanged (wxDPIChangedEvent &event) |
| UNITS_PROVIDER * | getUnitsProvider (int aCol) const |
| std::pair< EDA_UNITS, EDA_DATA_TYPE > | getColumnUnits (int aCol) const |
| Returns the units and data type associated with a given column. | |
Protected Attributes | |
| bool | m_weOwnTable |
| std::map< int, UNITS_PROVIDER * > | m_unitsProviders |
| std::unique_ptr< NUMERIC_EVALUATOR > | m_eval |
| std::vector< int > | m_autoEvalCols |
| std::unordered_map< int, std::pair< EDA_UNITS, EDA_DATA_TYPE > > | m_autoEvalColsUnits |
| std::map< std::pair< int, int >, std::pair< wxString, wxString > > | m_evalBeforeAfter |
| std::optional< wxSize > | m_minSizeOverride |
| std::map< int, int > | m_autosizedCols |
| int | m_flexibleCol |
| bool | m_gridWidthsDirty = true |
| int | m_gridWidth = 0 |
| ROW_ICON_PROVIDER * | m_rowIconProvider |
Private Member Functions | |
| void | recomputeGridWidths () |
| void | onSizeEvent (wxSizeEvent &aEvent) |
| WX_GRID::WX_GRID | ( | wxWindow * | parent, |
| wxWindowID | id, | ||
| const wxPoint & | pos = wxDefaultPosition, | ||
| const wxSize & | size = wxDefaultSize, | ||
| long | style = wxWANTS_CHARS, | ||
| const wxString & | name = wxGridNameStr ) |
Definition at line 205 of file wx_grid.cpp.
References KIUI::c_IndicatorSizeDIP, KIUI::GetControlFont(), m_rowIconProvider, m_weOwnTable, name, onCellEditorHidden(), onCellEditorShown(), onDPIChanged(), and SetLabelFont().
|
override |
Definition at line 227 of file wx_grid.cpp.
References DestroyTable(), m_rowIconProvider, m_weOwnTable, onCellEditorHidden(), onCellEditorShown(), and onDPIChanged().
| bool WX_GRID::CancelPendingChanges | ( | ) |
Definition at line 600 of file wx_grid.cpp.
References editor.
|
static |
A helper function to set OS-specific margins for text-based cell editors.
Definition at line 78 of file wx_grid.cpp.
Referenced by GRID_CELL_FPID_EDITOR::Create(), GRID_CELL_PATH_EDITOR::Create(), GRID_CELL_RUN_FUNCTION_EDITOR::Create(), GRID_CELL_SYMBOL_ID_EDITOR::Create(), and GRID_CELL_URL_EDITOR::Create().
|
static |
A helper function to tweak sizes of text-based cell editors depending on OS.
Definition at line 85 of file wx_grid.cpp.
Referenced by GRID_CELL_STC_EDITOR::SetSize(), GRID_CELL_TEXT_BUTTON::SetSize(), and GRID_CELL_TEXT_EDITOR::SetSize().
|
inline |
| bool WX_GRID::CommitPendingChanges | ( | bool | aQuietMode = false | ) |
Close any open cell edit controls.
| aQuietMode | if true don't send events (ie: for row/col delete operations). |
Definition at line 628 of file wx_grid.cpp.
References editor.
Referenced by LIB_TABLE_GRID_TRICKS::DeleteRowHandler(), DestroyTable(), OnAddRow(), OnDeleteRows(), onGridColMove(), OnMoveRowDown(), and OnMoveRowUp().
| void WX_GRID::DestroyTable | ( | wxGridTableBase * | aTable | ) |
Work-around for a bug in wxGrid which crashes when deleting the table if the cell edit control was not closed.
Definition at line 449 of file wx_grid.cpp.
References CommitPendingChanges(), onGridCellSelect(), and onGridColMove().
Referenced by ~WX_GRID().
|
inlineoverride |
Definition at line 289 of file wx_grid.h.
References m_minSizeOverride.
Referenced by OverrideMinSize().
|
overrideprotected |
A re-implementation of wxGrid::DrawColLabel which left-aligns the first column and draws flat borders.
Definition at line 531 of file wx_grid.cpp.
References WX_GRID_COLUMN_HEADER_RENDERER::DrawBorder(), and MIN_GRIDCELL_MARGIN.
|
overrideprotected |
A re-implementation of wxGrid::DrawCornerLabel which draws flat borders.
Definition at line 511 of file wx_grid.cpp.
References WX_GRID_CORNER_HEADER_RENDERER::DrawBorder().
|
overrideprotected |
A re-implementation of wxGrid::DrawRowLabel which draws flat borders.
Definition at line 569 of file wx_grid.cpp.
References WX_GRID_ROW_HEADER_RENDERER::DrawBorder(), and MIN_GRIDCELL_MARGIN.
| void WX_GRID::EnableAlternateRowColors | ( | bool | aEnable = true | ) |
Enable alternate row highlighting, where every odd row has a different background color than the even rows.
| aEnable | flag to specify to enable alternate row striping in the grid. |
Definition at line 307 of file wx_grid.cpp.
Referenced by SetTable().
| void WX_GRID::EnsureColLabelsVisible | ( | ) |
Ensure the height of the row displaying the column labels is enough, even if labels are multiline texts.
Definition at line 959 of file wx_grid.cpp.
References SetColLabelSize().
Referenced by GetVisibleWidth().
|
protected |
Returns the units and data type associated with a given column.
Definition at line 987 of file wx_grid.cpp.
References DISTANCE, getUnitsProvider(), UNITS_PROVIDER::GetUserUnits(), and m_autoEvalColsUnits.
Referenced by GetOptionalUnitValue(), GetUnitValue(), and onCellEditorHidden().
| std::optional< int > WX_GRID::GetOptionalUnitValue | ( | int | aRow, |
| int | aCol ) |
Apply standard KiCad unit and eval services to a numeric cell.
| aRow | the cell row index to fetch. |
| aCol | the cell column index to fetch. |
Definition at line 868 of file wx_grid.cpp.
References alg::contains(), getColumnUnits(), getUnitsProvider(), m_autoEvalCols, m_eval, UNITS_PROVIDER::NullUiString, and UNITS_PROVIDER::OptionalValueFromString().
|
inline |
Definition at line 305 of file wx_grid.h.
References m_rowIconProvider.
| std::bitset< 64 > WX_GRID::GetShownColumns | ( | ) |
Definition at line 482 of file wx_grid.cpp.
| wxString WX_GRID::GetShownColumnsAsString | ( | ) |
Get a tokenized string containing the shown column indexes.
Tokens are separated by spaces.
Definition at line 463 of file wx_grid.cpp.
|
inlineprotected |
Definition at line 331 of file wx_grid.h.
References m_unitsProviders.
Referenced by getColumnUnits(), GetOptionalUnitValue(), GetUnitValue(), onCellEditorHidden(), SetOptionalUnitValue(), and SetUnitValue().
| int WX_GRID::GetUnitValue | ( | int | aRow, |
| int | aCol ) |
Apply standard KiCad unit and eval services to a numeric cell.
| aRow | the cell row index to fetch. |
| aCol | the cell column index to fetch. |
| aIsOptional | if true, indicates to the unit provider the value is optional. |
Definition at line 850 of file wx_grid.cpp.
References alg::contains(), getColumnUnits(), getUnitsProvider(), m_autoEvalCols, m_eval, and UNITS_PROVIDER::ValueFromString().
| int WX_GRID::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.
| aCol | is the index of the column to resize. Specify -1 for the row labels. |
| aHeader | is the header in the width calculation. |
| aContents | is the full contents of the column. |
| aKeep | is the current size as a minimum value. |
Definition at line 919 of file wx_grid.cpp.
References EnsureColLabelsVisible().
Referenced by PANEL_SETUP_TRACKS_AND_VIAS::PANEL_SETUP_TRACKS_AND_VIAS().
| void WX_GRID::OnAddRow | ( | const std::function< std::pair< int, int >()> & | aAdder | ) |
Definition at line 680 of file wx_grid.cpp.
References CommitPendingChanges().
Referenced by LIB_TABLE_GRID_TRICKS::AppendRowHandler(), and DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::onAddGroup().
|
protected |
Definition at line 367 of file wx_grid.cpp.
References alg::contains(), getColumnUnits(), getUnitsProvider(), m_autoEvalCols, m_eval, m_evalBeforeAfter, UNITS_PROVIDER::NullUiString, UNITS_PROVIDER::OptionalValueFromString(), UNITS_PROVIDER::StringFromOptionalValue(), UNITS_PROVIDER::StringFromValue(), and UNITS_PROVIDER::ValueFromString().
Referenced by WX_GRID(), and ~WX_GRID().
|
protected |
Definition at line 352 of file wx_grid.cpp.
References alg::contains(), m_autoEvalCols, and m_evalBeforeAfter.
Referenced by WX_GRID(), and ~WX_GRID().
| void WX_GRID::OnDeleteRows | ( | const std::function< bool(int row)> & | aFilter, |
| const std::function< void(int row)> & | aDeleter ) |
Definition at line 711 of file wx_grid.cpp.
References CommitPendingChanges().
| void WX_GRID::OnDeleteRows | ( | const std::function< void(int row)> & | aDeleter | ) |
Handles a row deletion event.
This is a bit tricky due to the potential for stale selections, so we code it only once here.
Definition at line 700 of file wx_grid.cpp.
References OnDeleteRows().
Referenced by OnDeleteRows(), and DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::onRemoveGroup().
|
protected |
Definition at line 240 of file wx_grid.cpp.
Referenced by WX_GRID(), and ~WX_GRID().
|
protected |
Definition at line 325 of file wx_grid.cpp.
Referenced by DestroyTable(), and SetTable().
|
protected |
Definition at line 912 of file wx_grid.cpp.
References CommitPendingChanges().
Referenced by DestroyTable(), and SetTable().
| void WX_GRID::OnMoveRowDown | ( | const std::function< bool(int row)> & | aFilter, |
| const std::function< void(int row)> & | aMover ) |
Definition at line 806 of file wx_grid.cpp.
References CommitPendingChanges().
| void WX_GRID::OnMoveRowDown | ( | const std::function< void(int row)> & | aMover | ) |
Definition at line 795 of file wx_grid.cpp.
References OnMoveRowDown().
Referenced by LIB_TABLE_GRID_TRICKS::MoveDownHandler(), and OnMoveRowDown().
| void WX_GRID::OnMoveRowUp | ( | const std::function< bool(int row)> & | aFilter, |
| const std::function< void(int row)> & | aMover ) |
Definition at line 773 of file wx_grid.cpp.
References CommitPendingChanges().
| void WX_GRID::OnMoveRowUp | ( | const std::function< void(int row)> & | aMover | ) |
Definition at line 762 of file wx_grid.cpp.
References OnMoveRowUp().
Referenced by LIB_TABLE_GRID_TRICKS::MoveUpHandler(), and OnMoveRowUp().
|
private |
Definition at line 1074 of file wx_grid.cpp.
References m_gridWidth, and m_gridWidthsDirty.
Referenced by SetupColumnAutosizer().
|
inline |
Grids that have column sizes automatically set to fill the available width don't want to shrink afterwards (because wxGrid reports the aggregate column size as the bestSize.
| aSize |
Definition at line 283 of file wx_grid.h.
References DoGetBestSize(), KiROUND(), and m_minSizeOverride.
|
private |
Definition at line 1032 of file wx_grid.cpp.
References m_autosizedCols, m_flexibleCol, m_gridWidth, and m_gridWidthsDirty.
Referenced by SetupColumnAutosizer().
|
inline |
Definition at line 186 of file wx_grid.h.
References m_autoEvalCols.
| void WX_GRID::SetAutoEvalColUnits | ( | int | col, |
| EDA_UNITS | aUnit ) |
Set the unit to use for a given column.
The unit data type is inferred from the unit type
Definition at line 843 of file wx_grid.cpp.
References UNITS_PROVIDER::GetTypeFromUnits(), and SetAutoEvalColUnits().
| void WX_GRID::SetAutoEvalColUnits | ( | int | col, |
| EDA_UNITS | aUnit, | ||
| EDA_DATA_TYPE | aUnitType ) |
Set the unit and unit data type to use for a given column.
Definition at line 837 of file wx_grid.cpp.
References m_autoEvalColsUnits.
Referenced by SetAutoEvalColUnits().
| void WX_GRID::SetColLabelSize | ( | int | aHeight | ) |
Hide wxGrid's SetColLabelSize() method with one which makes sure the size is tall enough for the system GUI font.
| height |
Definition at line 251 of file wx_grid.cpp.
References MIN_GRIDCELL_MARGIN.
Referenced by EnsureColLabelsVisible().
|
inline |
Definition at line 303 of file wx_grid.h.
References m_gridWidthsDirty.
| void WX_GRID::SetLabelFont | ( | const wxFont & | aFont | ) |
Hide wxGrid's SetLabelFont() because for some reason on MSW it's a one-shot and subsequent calls to it have no effect.
Definition at line 266 of file wx_grid.cpp.
References KIUI::GetControlFont().
Referenced by WX_GRID().
| void WX_GRID::SetOptionalUnitValue | ( | int | aRow, |
| int | aCol, | ||
| std::optional< int > | aValue ) |
Set a unitized cell's optional value.
Definition at line 899 of file wx_grid.cpp.
References DISTANCE, getUnitsProvider(), and m_autoEvalColsUnits.
| void WX_GRID::SetTable | ( | wxGridTableBase * | table, |
| bool | aTakeOwnership = false ) |
Hide wxGrid's SetTable() method with one which doesn't mess up the grid column widths when setting the table.
Definition at line 272 of file wx_grid.cpp.
References EnableAlternateRowColors(), m_weOwnTable, MIN_GRIDCELL_MARGIN, onGridCellSelect(), onGridColMove(), and Pgm().
| void WX_GRID::SetUnitsProvider | ( | UNITS_PROVIDER * | aProvider, |
| int | aCol = 0 ) |
Set a EUNITS_PROVIDER to enable use of unit- and eval-based Getters.
| aProvider |
Definition at line 828 of file wx_grid.cpp.
References UNITS_PROVIDER::GetUserUnits(), m_eval, and m_unitsProviders.
| void WX_GRID::SetUnitValue | ( | int | aRow, |
| int | aCol, | ||
| int | aValue ) |
Set a unitized cell's value.
Definition at line 886 of file wx_grid.cpp.
References DISTANCE, getUnitsProvider(), and m_autoEvalColsUnits.
| void WX_GRID::SetupColumnAutosizer | ( | int | aFlexibleCol | ) |
Set autosize behaviour using wxFormBuilder column widths as minimums, with a single specified growable column.
Definition at line 997 of file wx_grid.cpp.
References m_autosizedCols, m_flexibleCol, m_gridWidthsDirty, onSizeEvent(), and recomputeGridWidths().
Referenced by FIELDS_GRID_TABLE::initGrid().
|
inline |
WxWidgets has a bunch of bugs in its handling of wxGrid mouse events which close cell editors right after opening them.
Helpfully, it already has a bunch of work-arounds in place (such as the SetInSetFocus() hack), including one to make slow clicks work. We re-purpose this hack to work-around the bugs when we want to open an editor.
| void WX_GRID::ShowHideColumns | ( | const wxString & | shownColumns | ) |
Show/hide the grid columns based on a tokenized string of shown column indexes.
Definition at line 493 of file wx_grid.cpp.
| void WX_GRID::SwapRows | ( | int | aRowA, |
| int | aRowB ) |
These aren't that tricky, but might as well share code.
Definition at line 751 of file wx_grid.cpp.
|
protected |
Definition at line 354 of file wx_grid.h.
Referenced by GetOptionalUnitValue(), GetUnitValue(), onCellEditorHidden(), onCellEditorShown(), and SetAutoEvalCols().
|
protected |
Definition at line 355 of file wx_grid.h.
Referenced by getColumnUnits(), SetAutoEvalColUnits(), SetOptionalUnitValue(), and SetUnitValue().
|
protected |
Definition at line 360 of file wx_grid.h.
Referenced by recomputeGridWidths(), and SetupColumnAutosizer().
|
protected |
Definition at line 353 of file wx_grid.h.
Referenced by GetOptionalUnitValue(), GetUnitValue(), onCellEditorHidden(), and SetUnitsProvider().
|
protected |
Definition at line 356 of file wx_grid.h.
Referenced by onCellEditorHidden(), and onCellEditorShown().
|
protected |
Definition at line 361 of file wx_grid.h.
Referenced by recomputeGridWidths(), and SetupColumnAutosizer().
|
protected |
Definition at line 364 of file wx_grid.h.
Referenced by onSizeEvent(), and recomputeGridWidths().
|
protected |
Definition at line 363 of file wx_grid.h.
Referenced by onSizeEvent(), recomputeGridWidths(), SetGridWidthsDirty(), and SetupColumnAutosizer().
|
protected |
Definition at line 358 of file wx_grid.h.
Referenced by DoGetBestSize(), and OverrideMinSize().
|
protected |
Definition at line 366 of file wx_grid.h.
Referenced by GetRowIconProvider(), WX_GRID(), and ~WX_GRID().
|
protected |
Definition at line 352 of file wx_grid.h.
Referenced by getUnitsProvider(), and SetUnitsProvider().
|
protected |
Definition at line 350 of file wx_grid.h.
Referenced by SetTable(), WX_GRID(), and ~WX_GRID().