From b0ff3bf3eac6beb97fcc9431e9ffba3f4f4c9b14 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 24 Sep 2019 01:44:55 +0200 Subject: [PATCH] Ensure that wxGrid appearance always reflects its enabled state Override DoEnable() in wxGrid instead of Enable() to ensure that the grid is shown appropriately for its current state whenever either it or its parent is disabled. Note that this also fixes the bug with only the main grid window being refreshed, but not the row/column headers, which also need to be. --- include/wx/generic/grid.h | 2 +- src/generic/grid.cpp | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/include/wx/generic/grid.h b/include/wx/generic/grid.h index e3c5c8752c..e9d3d1652d 100644 --- a/include/wx/generic/grid.h +++ b/include/wx/generic/grid.h @@ -1947,7 +1947,6 @@ public: // override some base class functions - virtual bool Enable(bool enable = true) wxOVERRIDE; virtual wxWindow *GetMainWindowOfCompositeControl() wxOVERRIDE { return (wxWindow*)m_gridWin; } virtual void Fit() wxOVERRIDE; @@ -1957,6 +1956,7 @@ public: protected: virtual wxSize DoGetBestSize() const wxOVERRIDE; + virtual void DoEnable(bool enable) wxOVERRIDE; bool m_created; diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 5c5132c83b..a7c5648aba 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -6817,15 +6817,11 @@ void wxGrid::ForceRefresh() EndBatch(); } -bool wxGrid::Enable(bool enable) +void wxGrid::DoEnable(bool enable) { - if ( !wxScrolledWindow::Enable(enable) ) - return false; + wxScrolledWindow::DoEnable(enable); - // redraw in the new state - m_gridWin->Refresh(); - - return true; + Refresh(false /* don't erase background */); } //