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:
committed by
Vadim Zeitlin
parent
3bb74df215
commit
43c519e04f
@@ -67,6 +67,10 @@
|
||||
#define NO_ITEM (-1)
|
||||
#endif
|
||||
|
||||
#ifndef LVM_ISITEMVISIBLE
|
||||
#define LVM_ISITEMVISIBLE (LVM_FIRST + 182)
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// private functions
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -880,6 +884,25 @@ bool wxListCtrl::GetItem(wxListItem& info) const
|
||||
return success;
|
||||
}
|
||||
|
||||
// Check if the item is visible
|
||||
bool wxListCtrl::IsVisible(long item) const
|
||||
{
|
||||
bool result = ::SendMessage( GetHwnd(), LVM_ISITEMVISIBLE, (WPARAM) item, 0 ) != 0;
|
||||
if ( result )
|
||||
{
|
||||
HWND hwndHdr = ListView_GetHeader(GetHwnd());
|
||||
wxRect itemRect;
|
||||
RECT headerRect;
|
||||
if ( Header_GetItemRect( hwndHdr, 0, &headerRect ) )
|
||||
{
|
||||
GetItemRect( item, itemRect );
|
||||
wxRect rectHeader = wxRectFromRECT( headerRect );
|
||||
result = itemRect.GetBottom() > rectHeader.GetBottom();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Sets information about the item
|
||||
bool wxListCtrl::SetItem(wxListItem& info)
|
||||
{
|
||||
|
Reference in New Issue
Block a user