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:
parent
da524ebacb
commit
75134c752e
@ -1324,15 +1324,25 @@ void MyListCtrl::OnListKeyDown(wxListEvent& event)
|
||||
wxLogError("Failed to retrieve rect of item %ld column %d", item, subItem + 1);
|
||||
break;
|
||||
}
|
||||
wxString message = "Bounding rect of %s item %ld column %d is (%d, %d)-(%d, %d)";
|
||||
|
||||
wxString part;
|
||||
if( code == wxLIST_RECT_BOUNDS )
|
||||
part = "subitem";
|
||||
if( code == wxLIST_RECT_ICON )
|
||||
part = "icon";
|
||||
if( code == wxLIST_RECT_LABEL )
|
||||
part = "label";
|
||||
wxLogMessage( message, part, item, subItem + 1, r.x, r.y, r.x + r.width, r.y + r.height );
|
||||
switch ( code )
|
||||
{
|
||||
case wxLIST_RECT_BOUNDS:
|
||||
part = "total rectangle";
|
||||
break;
|
||||
|
||||
case wxLIST_RECT_ICON:
|
||||
part = "icon";
|
||||
break;
|
||||
|
||||
case wxLIST_RECT_LABEL:
|
||||
part = "label";
|
||||
break;
|
||||
}
|
||||
|
||||
wxLogMessage("Bounding rect of the %s of the item %ld column %d is (%d, %d)-(%d, %d)",
|
||||
part, item, subItem + 1, r.x, r.y, r.x + r.width, r.y + r.height);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user