From 673ed29d7b57e4a49c451c394c41b586b46cdd67 Mon Sep 17 00:00:00 2001 From: Ilya Sinitsyn Date: Tue, 25 Feb 2020 21:11:29 +0700 Subject: [PATCH] Make wxGridSelection to be non-friend to wxGrid Improve integrity of the wxGridSelection internal data by removing `friend` declaration. --- include/wx/generic/gridsel.h | 27 +++++++++++++++++++++++++-- src/generic/grid.cpp | 10 +++++----- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/include/wx/generic/gridsel.h b/include/wx/generic/gridsel.h index 125fc02ef9..4e9f66dd67 100644 --- a/include/wx/generic/gridsel.h +++ b/include/wx/generic/gridsel.h @@ -71,6 +71,31 @@ public: void UpdateRows( size_t pos, int numRows ); void UpdateCols( size_t pos, int numCols ); + const wxGridCellCoordsArray& GetCellSelection() const + { + return m_cellSelection; + } + + const wxGridCellCoordsArray& GetBlockSelectionTopLeft() const + { + return m_blockSelectionTopLeft; + } + + const wxGridCellCoordsArray& GetBlockSelectionBottomRight() const + { + return m_blockSelectionBottomRight; + } + + const wxArrayInt& GetRowSelection() const + { + return m_rowSelection; + } + + const wxArrayInt& GetColSelection() const + { + return m_colSelection; + } + private: int BlockContain( int topRow1, int leftCol1, int bottomRow1, int rightCol1, @@ -106,8 +131,6 @@ private: wxGrid *m_grid; wxGrid::wxGridSelectionModes m_selectionMode; - friend class WXDLLIMPEXP_FWD_CORE wxGrid; - wxDECLARE_NO_COPY_CLASS(wxGridSelection); }; diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 608feb1634..e5ecf32eee 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -10044,7 +10044,7 @@ wxGridCellCoordsArray wxGrid::GetSelectedCells() const return a; } - return m_selection->m_cellSelection; + return m_selection->GetCellSelection(); } wxGridCellCoordsArray wxGrid::GetSelectionBlockTopLeft() const @@ -10055,7 +10055,7 @@ wxGridCellCoordsArray wxGrid::GetSelectionBlockTopLeft() const return a; } - return m_selection->m_blockSelectionTopLeft; + return m_selection->GetBlockSelectionTopLeft(); } wxGridCellCoordsArray wxGrid::GetSelectionBlockBottomRight() const @@ -10066,7 +10066,7 @@ wxGridCellCoordsArray wxGrid::GetSelectionBlockBottomRight() const return a; } - return m_selection->m_blockSelectionBottomRight; + return m_selection->GetBlockSelectionBottomRight(); } wxArrayInt wxGrid::GetSelectedRows() const @@ -10077,7 +10077,7 @@ wxArrayInt wxGrid::GetSelectedRows() const return a; } - return m_selection->m_rowSelection; + return m_selection->GetRowSelection(); } wxArrayInt wxGrid::GetSelectedCols() const @@ -10088,7 +10088,7 @@ wxArrayInt wxGrid::GetSelectedCols() const return a; } - return m_selection->m_colSelection; + return m_selection->GetColSelection(); } void wxGrid::ClearSelection()