Replace a chain of "if"s with a "switch" in wxMSW wxListCtrl

Also return false from GetSubItemRect() if an invalid code is passed in,
instead of silently using wxLIST_RECT_BOUNDS instead of it.
This commit is contained in:
Vadim Zeitlin
2019-08-27 16:37:48 +02:00
parent eba26cf35e
commit ba787af932

View File

@@ -1223,16 +1223,23 @@ bool wxListCtrl::GetSubItemRect(long item, long subItem, wxRect& rect, int code)
wxT("invalid item in GetSubItemRect") );
int codeWin;
if ( code == wxLIST_RECT_BOUNDS )
codeWin = LVIR_BOUNDS;
else if ( code == wxLIST_RECT_ICON )
codeWin = LVIR_ICON;
else if ( code == wxLIST_RECT_LABEL )
codeWin = LVIR_LABEL;
else
switch ( code )
{
wxFAIL_MSG( wxT("incorrect code in GetItemRect() / GetSubItemRect()") );
codeWin = LVIR_BOUNDS;
case wxLIST_RECT_BOUNDS:
codeWin = LVIR_BOUNDS;
break;
case wxLIST_RECT_ICON:
codeWin = LVIR_ICON;
break;
case wxLIST_RECT_LABEL:
codeWin = LVIR_LABEL;
break;
default:
wxFAIL_MSG( wxT("incorrect code in GetItemRect() / GetSubItemRect()") );
return false;
}
RECT rectWin;