Prettify the changes of the previous commit

Use switch over enum value instead of consecutive ifs.

Don't duplicate wxGetListCtrlSubItemRect() code, just call it instead.

See https://github.com/wxWidgets/wxWidgets/pull/1461
This commit is contained in:
Vadim Zeitlin
2019-08-06 00:02:35 +02:00
parent da524ebacb
commit 75134c752e
2 changed files with 27 additions and 14 deletions

View File

@@ -1241,15 +1241,18 @@ bool wxListCtrl::GetSubItemRect(long item, long subItem, wxRect& rect, int code)
{
return false;
}
if( code == wxLIST_RECT_LABEL )
// Although LVIR_LABEL exists, it returns the same results as LVIR_BOUNDS
// and not just the label rectangle as would be expected, so account for
// the icon ourselves in this case.
if ( code == wxLIST_RECT_LABEL )
{
RECT rectIcon;
rectIcon.top = subItem;
rectIcon.left = LVIR_ICON;
if( !( ::SendMessageA(GetHwnd(), LVM_GETSUBITEMRECT, item, (LPARAM)&rectIcon) ) )
if ( !wxGetListCtrlSubItemRect(GetHwnd(), item, subItem, LVIR_ICON,
rectIcon) )
return false;
else
rectWin.left = rectIcon.right;
rectWin.left = rectIcon.right;
}
wxCopyRECTToRect(rectWin, rect);