From e3646f4afd1360faed9f5fd71ddb938d47825c52 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 8 Feb 2009 10:23:19 +0000 Subject: [PATCH] fix repaining of highlight for merged cells [backport of r55630 from trunk] (closes #9718) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@58753 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + src/generic/grid.cpp | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/docs/changes.txt b/docs/changes.txt index 3f5d619d9b..b21d83f107 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -132,6 +132,7 @@ All (GUI): wxMac with CoreGraphics where sash drawing isn't implemented. - Use bitmap mask in wxSplashScreen. - Translate "(c)" and "(C)" to the real copyright sign in wxAboutBox. +- Fix painting of highlight border for merged cells in wxGrid (K. Jones). All (Unix): diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 5839709c99..aad126d88c 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -7859,7 +7859,27 @@ void wxGrid::DrawHighlight(wxDC& dc, const wxGridCellCoordsArray& cells) size_t count = cells.GetCount(); for ( size_t n = 0; n < count; n++ ) { - if ( cells[n] == m_currentCellCoords ) + wxGridCellCoords cell = cells[n]; + + // If we are using attributes, then we may have just exposed another + // cell in a partially-visible merged cluster of cells. If the "anchor" + // (upper left) cell of this merged cluster is the cell indicated by + // m_currentCellCoords, then we need to refresh the cell highlight even + // though the "anchor" itself is not part of our update segment. + if ( CanHaveAttributes() ) + { + int rows = 0, + cols = 0; + GetCellSize(cell.GetRow(), cell.GetCol(), &rows, &cols); + + if ( rows < 0 ) + cell.SetRow(cell.GetRow() + rows); + + if ( cols < 0 ) + cell.SetCol(cell.GetCol() + cols); + } + + if ( cell == m_currentCellCoords ) { wxGridCellAttr* attr = GetCellAttr(m_currentCellCoords); DrawCellHighlight(dc, attr);