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:
@@ -1223,16 +1223,23 @@ bool wxListCtrl::GetSubItemRect(long item, long subItem, wxRect& rect, int code)
|
|||||||
wxT("invalid item in GetSubItemRect") );
|
wxT("invalid item in GetSubItemRect") );
|
||||||
|
|
||||||
int codeWin;
|
int codeWin;
|
||||||
if ( code == wxLIST_RECT_BOUNDS )
|
switch ( code )
|
||||||
codeWin = LVIR_BOUNDS;
|
|
||||||
else if ( code == wxLIST_RECT_ICON )
|
|
||||||
codeWin = LVIR_ICON;
|
|
||||||
else if ( code == wxLIST_RECT_LABEL )
|
|
||||||
codeWin = LVIR_LABEL;
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
wxFAIL_MSG( wxT("incorrect code in GetItemRect() / GetSubItemRect()") );
|
case wxLIST_RECT_BOUNDS:
|
||||||
codeWin = LVIR_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;
|
RECT rectWin;
|
||||||
|
Reference in New Issue
Block a user