Fix wxListCtrl::GetSubItemRect(wxLIST_RECT_ICON/LABEL) in wxMSW for column 0.
Wrong width was returned for the icon or label rectangle when querying the first column. Fix this and add a test to the sample allowing to check this. GetSubItemRect() still returns wrong results for second and subsequent columns, see #11355. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62706 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1117,8 +1117,8 @@ void MyListCtrl::OnListKeyDown(wxListEvent& event)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '1': // show sub item bounding rectangle
|
case '1': // show sub item bounding rectangle for the given column
|
||||||
case '2':
|
case '2': // (and icon/label rectangle if Shift/Ctrl is pressed)
|
||||||
case '3':
|
case '3':
|
||||||
case '4': // this column is invalid but we want to test it too
|
case '4': // this column is invalid but we want to test it too
|
||||||
if ( InReportView() )
|
if ( InReportView() )
|
||||||
@@ -1126,7 +1126,14 @@ void MyListCtrl::OnListKeyDown(wxListEvent& event)
|
|||||||
int subItem = event.GetKeyCode() - '1';
|
int subItem = event.GetKeyCode() - '1';
|
||||||
item = event.GetIndex();
|
item = event.GetIndex();
|
||||||
wxRect r;
|
wxRect r;
|
||||||
if ( !GetSubItemRect(item, subItem, r) )
|
|
||||||
|
int code = wxLIST_RECT_BOUNDS;
|
||||||
|
if ( wxGetKeyState(WXK_SHIFT) )
|
||||||
|
code = wxLIST_RECT_ICON;
|
||||||
|
else if ( wxGetKeyState(WXK_CONTROL) )
|
||||||
|
code = wxLIST_RECT_LABEL;
|
||||||
|
|
||||||
|
if ( !GetSubItemRect(item, subItem, r, code) )
|
||||||
{
|
{
|
||||||
wxLogError(wxT("Failed to retrieve rect of item %ld column %d"), item, subItem + 1);
|
wxLogError(wxT("Failed to retrieve rect of item %ld column %d"), item, subItem + 1);
|
||||||
break;
|
break;
|
||||||
|
@@ -1183,7 +1183,7 @@ bool wxListCtrl::GetSubItemRect(long item, long subItem, wxRect& rect, int code)
|
|||||||
// there is no way to retrieve the first sub item bounding rectangle using
|
// there is no way to retrieve the first sub item bounding rectangle using
|
||||||
// wxGetListCtrlSubItemRect() as 0 means the whole item, so we need to
|
// wxGetListCtrlSubItemRect() as 0 means the whole item, so we need to
|
||||||
// truncate it at first column ourselves
|
// truncate it at first column ourselves
|
||||||
if ( subItem == 0 )
|
if ( subItem == 0 && code == wxLIST_RECT_BOUNDS )
|
||||||
rect.width = GetColumnWidth(0);
|
rect.width = GetColumnWidth(0);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Reference in New Issue
Block a user