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

@@ -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;