wxMSW: Fix incorrect subitem rect calculation in wxListCtrl.

HandleSubItemPrepaint() calls wxGetListCtrlSubItemRect() (a thin
replacement of ListView_GetSubItemRect) with subitem argument
corresponding to MSDN documentation: it should be 0 for the whole item
and 1-based for subitems.

Unfortunately, as pointed out in an explanatory comment for
wxGetListCtrlSubItemRect(), MSDN lies and the index actually is 0-based.

The bug causes wxListCtrl's content to be shifted by one column and
rendered with additional artifacts as soon as custom drawing is used,
e.g. when a custom font is used.

This bug was introduced in r55378; the code correctly accounted for this
before that. This change partially reverts that commit.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72427 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík 2012-09-07 09:51:10 +00:00
parent b7e3daf441
commit c9a695b777

View File

@ -2661,10 +2661,21 @@ bool HandleSubItemPrepaint(LPNMLVCUSTOMDRAW pLVCD, HFONT hfont, int colCount)
SelectInHDC selFont(hdc, hfont);
// get the rectangle to paint
int subitem = colCount ? col + 1 : col;
RECT rc;
wxGetListCtrlSubItemRect(hwndList, item, subitem, LVIR_BOUNDS, rc);
rc.left += 6;
wxGetListCtrlSubItemRect(hwndList, item, col, LVIR_BOUNDS, rc);
if ( !col && colCount > 1 )
{
// ListView_GetSubItemRect() returns the entire item rect for 0th
// subitem while we really need just the part for this column
RECT rc2;
wxGetListCtrlSubItemRect(hwndList, item, 1, LVIR_BOUNDS, rc2);
rc.right = rc2.left;
rc.left += 4;
}
else // not first subitem
{
rc.left += 6;
}
// get the image and text to draw
wxChar text[512];