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:
@@ -1324,15 +1324,25 @@ void MyListCtrl::OnListKeyDown(wxListEvent& event)
|
|||||||
wxLogError("Failed to retrieve rect of item %ld column %d", item, subItem + 1);
|
wxLogError("Failed to retrieve rect of item %ld column %d", item, subItem + 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
wxString message = "Bounding rect of %s item %ld column %d is (%d, %d)-(%d, %d)";
|
|
||||||
wxString part;
|
wxString part;
|
||||||
if( code == wxLIST_RECT_BOUNDS )
|
switch ( code )
|
||||||
part = "subitem";
|
{
|
||||||
if( code == wxLIST_RECT_ICON )
|
case wxLIST_RECT_BOUNDS:
|
||||||
part = "icon";
|
part = "total rectangle";
|
||||||
if( code == wxLIST_RECT_LABEL )
|
break;
|
||||||
part = "label";
|
|
||||||
wxLogMessage( message, part, item, subItem + 1, r.x, r.y, r.x + r.width, r.y + r.height );
|
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;
|
break;
|
||||||
|
|
||||||
|
@@ -1241,15 +1241,18 @@ bool wxListCtrl::GetSubItemRect(long item, long subItem, wxRect& rect, int code)
|
|||||||
{
|
{
|
||||||
return false;
|
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;
|
RECT rectIcon;
|
||||||
rectIcon.top = subItem;
|
if ( !wxGetListCtrlSubItemRect(GetHwnd(), item, subItem, LVIR_ICON,
|
||||||
rectIcon.left = LVIR_ICON;
|
rectIcon) )
|
||||||
if( !( ::SendMessageA(GetHwnd(), LVM_GETSUBITEMRECT, item, (LPARAM)&rectIcon) ) )
|
|
||||||
return false;
|
return false;
|
||||||
else
|
|
||||||
rectWin.left = rectIcon.right;
|
rectWin.left = rectIcon.right;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxCopyRECTToRect(rectWin, rect);
|
wxCopyRECTToRect(rectWin, rect);
|
||||||
|
Reference in New Issue
Block a user