Add support for icon/label rectangles to generic wxListCtrl
Honour the value of "code" parameter in GetSubItemRect().
This commit is contained in:
@@ -649,7 +649,8 @@ public:
|
|||||||
{
|
{
|
||||||
return GetSubItemRect(item, wxLIST_GETSUBITEMRECT_WHOLEITEM, rect);
|
return GetSubItemRect(item, wxLIST_GETSUBITEMRECT_WHOLEITEM, rect);
|
||||||
}
|
}
|
||||||
bool GetSubItemRect( long item, long subItem, wxRect& rect ) const;
|
bool GetSubItemRect( long item, long subItem, wxRect& rect,
|
||||||
|
int code = wxLIST_RECT_BOUNDS ) const;
|
||||||
wxRect GetViewRect() const;
|
wxRect GetViewRect() const;
|
||||||
bool GetItemPosition( long item, wxPoint& pos ) const;
|
bool GetItemPosition( long item, wxPoint& pos ) const;
|
||||||
int GetSelectedItemCount() const;
|
int GetSelectedItemCount() const;
|
||||||
|
@@ -809,6 +809,8 @@ void wxListLineData::DrawInReportMode( wxDC *dc,
|
|||||||
// different columns - to do it, just add "col" argument to
|
// different columns - to do it, just add "col" argument to
|
||||||
// GetAttr() and move these lines into the loop below
|
// 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);
|
ApplyAttributes(dc, rectHL, highlighted, current);
|
||||||
|
|
||||||
wxCoord x = rect.x + HEADER_OFFSET_X + ICON_OFFSET_X,
|
wxCoord x = rect.x + HEADER_OFFSET_X + ICON_OFFSET_X,
|
||||||
@@ -3678,7 +3680,8 @@ wxRect wxListMainWindow::GetViewRect() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
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(),
|
wxCHECK_MSG( subItem == wxLIST_GETSUBITEMRECT_WHOLEITEM || InReportView(),
|
||||||
false,
|
false,
|
||||||
@@ -3706,6 +3709,51 @@ wxListMainWindow::GetSubItemRect(long item, long subItem, wxRect& rect) const
|
|||||||
rect.x += GetColumnWidth(i);
|
rect.x += GetColumnWidth(i);
|
||||||
}
|
}
|
||||||
rect.width = GetColumnWidth(subItem);
|
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);
|
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,
|
bool wxGenericListCtrl::GetSubItemRect(long item,
|
||||||
long subItem,
|
long subItem,
|
||||||
wxRect& rect,
|
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;
|
return false;
|
||||||
|
|
||||||
if ( m_mainWin->HasHeader() )
|
if ( m_mainWin->HasHeader() )
|
||||||
|
Reference in New Issue
Block a user