From ab2dd2497697c1a8a388cfbfe3291075e24ef2a8 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 2 Sep 2022 20:52:20 +0100 Subject: [PATCH] Add wxGrid::Enable{Row,Col}Resize() These functions are needed to allow resizing the rows/columns whose size was fixed by Disable{Row,Col}Resize() as otherwise the effect of a call to the latter function can't be undone at all. --- include/wx/generic/grid.h | 7 ++++++- interface/wx/grid.h | 22 ++++++++++++++++++++++ src/generic/grid.cpp | 6 ++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/include/wx/generic/grid.h b/include/wx/generic/grid.h index 5dcb25b4fb..8fb7357755 100644 --- a/include/wx/generic/grid.h +++ b/include/wx/generic/grid.h @@ -1904,6 +1904,10 @@ public: void DisableRowResize(int row) { DoDisableLineResize(row, m_setFixedRows); } void DisableColResize(int col) { DoDisableLineResize(col, m_setFixedCols); } + // and then resizing them may be re-enabled again later + void EnableRowResize(int row) { DoEnableLineResize(row, m_setFixedRows); } + void EnableColResize(int col) { DoEnableLineResize(col, m_setFixedCols); } + // These function return true if resizing rows/columns by dragging // their edges inside the grid is enabled. Note that this doesn't cover // dragging their separators in the label windows (which can be enabled @@ -2963,8 +2967,9 @@ private: void DoSetSizes(const wxGridSizesInfo& sizeInfo, const wxGridOperations& oper); - // common part of Disable{Row,Col}Resize and CanDrag{Row,Col}Size + // common part of {Disable,Enable}{Row,Col}Resize and CanDrag{Row,Col}Size void DoDisableLineResize(int line, wxGridFixedIndicesSet *& setFixed); + void DoEnableLineResize(int line, wxGridFixedIndicesSet* setFixed); bool DoCanResizeLine(int line, const wxGridFixedIndicesSet *setFixed) const; // Helper of Render(): get grid size, origin offset and fill cell arrays diff --git a/interface/wx/grid.h b/interface/wx/grid.h index 3c4f268042..48c28bc773 100644 --- a/interface/wx/grid.h +++ b/interface/wx/grid.h @@ -4655,6 +4655,17 @@ public: */ void DisableHidingColumns(); + /** + Enable interactively resizing a column if it was previously forbidden. + + Calling this function only makes sense if the row resizing had been + previously forbidden using DisableColResize(), as it simply undoes its + effect. + + @since 3.3.0 + */ + void EnableColResize(int col); + /** Enables or disables cell dragging with the mouse. */ @@ -4726,6 +4737,17 @@ public: */ bool EnableHidingColumns(bool enable = true); + /** + Enable interactively resizing a row if it was previously forbidden. + + Calling this function only makes sense if the row resizing had been + previously forbidden using DisableRowResize(), as it simply undoes its + effect. + + @since 3.3.0 + */ + void EnableRowResize(int row)l + /** Returns the column ID of the specified column position. */ diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 2eee2517a3..e27402ff00 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -9913,6 +9913,12 @@ void wxGrid::DoDisableLineResize(int line, wxGridFixedIndicesSet *& setFixed) setFixed->insert(line); } +void wxGrid::DoEnableLineResize(int line, wxGridFixedIndicesSet* setFixed) +{ + if ( setFixed ) + setFixed->erase(line); +} + bool wxGrid::DoCanResizeLine(int line, const wxGridFixedIndicesSet *setFixed) const {