made wxTreeCtrl::GetNextVisible() behave in the same way in Win32 as in the generic version and implemented GetPrevVisible() in the generic version

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49085 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-10-07 21:58:51 +00:00
parent f0eebb39bc
commit f73eddd2a5
6 changed files with 149 additions and 26 deletions

View File

@@ -1315,6 +1315,7 @@ wxTreeItemId wxGenericTreeCtrl::GetFirstVisibleItem() const
wxTreeItemId wxGenericTreeCtrl::GetNextVisible(const wxTreeItemId& item) const
{
wxCHECK_MSG( item.IsOk(), wxTreeItemId(), wxT("invalid tree item") );
wxASSERT_MSG( IsVisible(item), wxT("this item itself should be visible") );
wxTreeItemId id = item;
if (id.IsOk())
@@ -1331,10 +1332,37 @@ wxTreeItemId wxGenericTreeCtrl::GetNextVisible(const wxTreeItemId& item) const
wxTreeItemId wxGenericTreeCtrl::GetPrevVisible(const wxTreeItemId& item) const
{
wxCHECK_MSG( item.IsOk(), wxTreeItemId(), wxT("invalid tree item") );
wxASSERT_MSG( IsVisible(item), wxT("this item itself should be visible") );
wxFAIL_MSG(wxT("not implemented"));
// find out the starting point
wxTreeItemId prevItem = GetPrevSibling(item);
if ( !prevItem.IsOk() )
{
prevItem = GetItemParent(item);
}
return wxTreeItemId();
// find the first visible item after it
while ( prevItem.IsOk() && !IsVisible(prevItem) )
{
prevItem = GetNext(prevItem);
if ( !prevItem.IsOk() || prevItem == item )
{
// there are no visible items before item
return wxTreeItemId();
}
}
// from there we must be able to navigate until this item
while ( prevItem.IsOk() )
{
const wxTreeItemId nextItem = GetNextVisible(prevItem);
if ( !nextItem.IsOk() || nextItem == item )
break;
prevItem = nextItem;
}
return prevItem;
}
// called by wxTextTreeCtrl when it marks itself for deletion