From f61b58bba3aceae07afbf95d03ca7c56d23871c7 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 15 Jul 2019 15:51:00 +0200 Subject: [PATCH] Override wxGrid::ScrollWindow() to scroll row/column labels too Instead of doing it in overridden wxGridWindow::ScrollWindow(), do it from wxGrid::ScrollWindow() itself, this makes more sense and will make it easier to generalize it to scroll more windows. No real changes yet. --- include/wx/generic/grid.h | 2 ++ src/generic/grid.cpp | 14 +++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/wx/generic/grid.h b/include/wx/generic/grid.h index 94f8c09679..38905b2623 100644 --- a/include/wx/generic/grid.h +++ b/include/wx/generic/grid.h @@ -1068,6 +1068,8 @@ public: void DrawAllGridLines( wxDC& dc, const wxRegion & reg ); void DrawCell( wxDC& dc, const wxGridCellCoords& ); void DrawHighlight(wxDC& dc, const wxGridCellCoordsArray& cells); + void ScrollWindow( int dx, int dy, const wxRect *rect ) wxOVERRIDE; + void UpdateGridWindows() const; // this function is called when the current cell highlight must be redrawn diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index a5ef612367..844dc150bb 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -2111,9 +2111,17 @@ void wxGrid::DoRenderBox( wxDC& dc, const int& style, void wxGridWindow::ScrollWindow( int dx, int dy, const wxRect *rect ) { - wxWindow::ScrollWindow( dx, dy, rect ); - m_owner->GetGridRowLabelWindow()->ScrollWindow( 0, dy, rect ); - m_owner->GetGridColLabelWindow()->ScrollWindow( dx, 0, rect ); + m_owner->ScrollWindow(dx, dy, rect); +} + +void wxGrid::ScrollWindow( int dx, int dy, const wxRect *rect ) +{ + // We must explicitly call wxWindow version to avoid infinite recursion as + // wxGridWindow::ScrollWindow() calls this method back. + m_gridWin->wxWindow::ScrollWindow( dx, dy, rect ); + + m_rowLabelWin->ScrollWindow( 0, dy, rect ); + m_colLabelWin->ScrollWindow( dx, 0, rect ); } void wxGridWindow::OnMouseEvent( wxMouseEvent& event )