Add support for icon/label rectangles to generic wxListCtrl
Honour the value of "code" parameter in GetSubItemRect().
This commit is contained in:
@@ -809,6 +809,8 @@ void wxListLineData::DrawInReportMode( wxDC *dc,
|
||||
// different columns - to do it, just add "col" argument to
|
||||
// GetAttr() and move these lines into the loop below
|
||||
|
||||
// Note: GetSubItemRect() needs to be modified if the layout here changes.
|
||||
|
||||
ApplyAttributes(dc, rectHL, highlighted, current);
|
||||
|
||||
wxCoord x = rect.x + HEADER_OFFSET_X + ICON_OFFSET_X,
|
||||
@@ -3678,7 +3680,8 @@ wxRect wxListMainWindow::GetViewRect() const
|
||||
}
|
||||
|
||||
bool
|
||||
wxListMainWindow::GetSubItemRect(long item, long subItem, wxRect& rect) const
|
||||
wxListMainWindow::GetSubItemRect(long item, long subItem, wxRect& rect,
|
||||
int code) const
|
||||
{
|
||||
wxCHECK_MSG( subItem == wxLIST_GETSUBITEMRECT_WHOLEITEM || InReportView(),
|
||||
false,
|
||||
@@ -3706,6 +3709,51 @@ wxListMainWindow::GetSubItemRect(long item, long subItem, wxRect& rect) const
|
||||
rect.x += GetColumnWidth(i);
|
||||
}
|
||||
rect.width = GetColumnWidth(subItem);
|
||||
|
||||
switch ( code )
|
||||
{
|
||||
case wxLIST_RECT_BOUNDS:
|
||||
// Nothing to do.
|
||||
break;
|
||||
|
||||
case wxLIST_RECT_ICON:
|
||||
case wxLIST_RECT_LABEL:
|
||||
// Note: this needs to be kept in sync with DrawInReportMode().
|
||||
{
|
||||
rect.x += ICON_OFFSET_X;
|
||||
rect.width -= ICON_OFFSET_X;
|
||||
|
||||
wxListLineData* const line = GetLine(item);
|
||||
if ( subItem == 0 && line->HasImage() )
|
||||
{
|
||||
int ix, iy;
|
||||
GetImageSize(line->GetImage(), ix, iy);
|
||||
|
||||
const int iconWidth = ix + IMAGE_MARGIN_IN_REPORT_MODE;
|
||||
|
||||
if ( code == wxLIST_RECT_ICON )
|
||||
{
|
||||
rect.width = iconWidth;
|
||||
}
|
||||
else // wxLIST_RECT_LABEL
|
||||
{
|
||||
rect.x += iconWidth;
|
||||
rect.width -= iconWidth;
|
||||
}
|
||||
}
|
||||
else // No icon
|
||||
{
|
||||
if ( code == wxLIST_RECT_ICON )
|
||||
rect = wxRect();
|
||||
//else: label rect is the same as the full one
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
wxFAIL_MSG(wxS("Unknown rectangle requested"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
GetListCtrl()->CalcScrolledPosition(rect.x, rect.y, &rect.x, &rect.y);
|
||||
@@ -5033,9 +5081,9 @@ bool wxGenericListCtrl::GetItemRect(long item, wxRect& rect, int code) const
|
||||
bool wxGenericListCtrl::GetSubItemRect(long item,
|
||||
long subItem,
|
||||
wxRect& rect,
|
||||
int WXUNUSED(code)) const
|
||||
int code) const
|
||||
{
|
||||
if ( !m_mainWin->GetSubItemRect( item, subItem, rect ) )
|
||||
if ( !m_mainWin->GetSubItemRect( item, subItem, rect, code ) )
|
||||
return false;
|
||||
|
||||
if ( m_mainWin->HasHeader() )
|
||||
|
Reference in New Issue
Block a user