Add wxListCtrl::IsVisible()

Allow checking if the given item is (at least partially) visible on
screen.

Closes https://github.com/wxWidgets/wxWidgets/pull/1444

Closes #9949.
This commit is contained in:
oneeyeman1
2019-08-04 20:09:03 -05:00
committed by Vadim Zeitlin
parent 3bb74df215
commit 43c519e04f
8 changed files with 73 additions and 2 deletions

View File

@@ -151,6 +151,23 @@ wxListItemData::wxListItemData(wxListMainWindow *owner)
m_rect = new wxRect;
}
// Check if the item is visible
bool wxGenericListCtrl::IsVisible(long item) const
{
wxRect itemRect;
GetItemRect( item, itemRect );
const wxRect clientRect = GetClientRect();
bool visible = clientRect.Intersects( itemRect );
if ( visible && m_headerWin )
{
wxRect headerRect = m_headerWin->GetClientRect();
// take into account the +1 added in GetSubItemRect()
headerRect.height++;
visible = itemRect.GetBottom() > headerRect.GetBottom();
}
return visible;
}
void wxListItemData::SetItem( const wxListItem &info )
{
if ( info.m_mask & wxLIST_MASK_TEXT )