Fix wxGrid editors background painting.

There were two fundamental problems: first, we painted on a separately created
wxClientDC instead of using the wxPaintDC already available in wxGrid. Second,
we invalidated the control while painting, resulting in endless repainting, at
least under wxGTK.

Fix the first problem by passing wxDC to wxGridCellEditor::PaintBackground()
and the second one by not refreshing the control from there as it just seems
unnecessary.

Also pass the attribute by reference for consistency with
wxGridCellRenderer::Draw() and because this pointer can never be NULL.

Closes #2628.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72697 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-10-17 16:44:02 +00:00
parent 8ab7533289
commit ccc040255c
5 changed files with 25 additions and 20 deletions

View File

@@ -444,6 +444,9 @@ GridFrame::GridFrame()
grid->SetCellValue( 0, 5, wxT("Press\nCtrl+arrow\nto skip over\ncells") );
grid->SetRowSize( 99, 60 );
grid->SetCellValue(98, 98, "Test background colour setting");
grid->SetCellBackgroundColour(98, 99, wxColour(255, 127, 127));
grid->SetCellBackgroundColour(99, 98, wxColour(255, 127, 127));
grid->SetCellValue( 99, 99, wxT("Ctrl+End\nwill go to\nthis cell") );
grid->SetCellValue( 1, 0, wxT("This default cell will overflow into neighboring cells, but not if you turn overflow off."));
@@ -465,6 +468,7 @@ GridFrame::GridFrame()
grid->SetCellRenderer(3, 0, new wxGridCellBoolRenderer);
grid->SetCellEditor(3, 0, new wxGridCellBoolEditor);
grid->SetCellBackgroundColour(3, 0, wxColour(255, 127, 127));
wxGridCellAttr *attr;
attr = new wxGridCellAttr;