From 7e79925fb70a9e327795c7929458efafc05e73d4 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 22 Jun 2020 03:06:41 +0200 Subject: [PATCH] Do erase background even in wxGridCellTextEditor It is necessary to do it since the switch to double buffering wxGrid painting in ebbadae09a (Double buffer wxGridWindow drawing, 2020-01-28) as even a "full cell" editor such as wxGridCellTextEditor still doesn't fill the entire cell, as there are margins around it, and the backing bitmap could keep whatever junk happened to be there if we didn't erase it, so do erase it now. Remove the code doing the same thing from ShowCellEditControl(), however, as it's redundant and doesn't do anything except creating some flicker, and also doesn't work on the platforms not supporting the use of wxClientDC anyhow. --- include/wx/generic/grideditors.h | 4 ---- src/generic/grid.cpp | 10 +--------- src/generic/grideditors.cpp | 8 -------- 3 files changed, 1 insertion(+), 21 deletions(-) diff --git a/include/wx/generic/grideditors.h b/include/wx/generic/grideditors.h index 6e53a89dd7..4ffd61ef62 100644 --- a/include/wx/generic/grideditors.h +++ b/include/wx/generic/grideditors.h @@ -60,10 +60,6 @@ public: wxEvtHandler* evtHandler) wxOVERRIDE; virtual void SetSize(const wxRect& rect) wxOVERRIDE; - virtual void PaintBackground(wxDC& dc, - const wxRect& rectCell, - const wxGridCellAttr& attr) wxOVERRIDE; - virtual bool IsAcceptedKey(wxKeyEvent& event) wxOVERRIDE; virtual void BeginEdit(int row, int col, wxGrid* grid) wxOVERRIDE; virtual bool EndEdit(int row, int col, const wxGrid* grid, diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index c2bcc35305..ee845891df 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -7265,15 +7265,6 @@ void wxGrid::ShowCellEditControl() m_currentCellCoords.SetCol( col ); } - // erase the highlight and the cell contents because the editor - // might not cover the entire cell - wxClientDC dc( gridWindow ); - PrepareDCFor(dc, gridWindow); - wxGridCellAttrPtr attr = GetCellAttrPtr(row, col); - dc.SetBrush(wxBrush(attr->GetBackgroundColour())); - dc.SetPen(*wxTRANSPARENT_PEN); - dc.DrawRectangle(rect); - rect.Offset(-GetGridWindowOffset(gridWindow)); // convert to scrolled coords @@ -7286,6 +7277,7 @@ void wxGrid::ShowCellEditControl() rect.Deflate(1, 1); #endif + wxGridCellAttrPtr attr = GetCellAttrPtr(row, col); wxGridCellEditorPtr editor = attr->GetEditorPtr(this, row, col); if ( !editor->IsCreated() ) { diff --git a/src/generic/grideditors.cpp b/src/generic/grideditors.cpp index bff361f195..0524b997d5 100644 --- a/src/generic/grideditors.cpp +++ b/src/generic/grideditors.cpp @@ -426,14 +426,6 @@ void wxGridCellTextEditor::DoCreate(wxWindow* parent, wxGridCellEditor::Create(parent, id, evtHandler); } -void wxGridCellTextEditor::PaintBackground(wxDC& WXUNUSED(dc), - const wxRect& WXUNUSED(rectCell), - const wxGridCellAttr& WXUNUSED(attr)) -{ - // as we fill the entire client area, - // don't do anything here to minimize flicker -} - void wxGridCellTextEditor::SetSize(const wxRect& rectOrig) { wxRect rect(rectOrig);