don't allow expanding/collapsing hidden root node
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15063 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1212,7 +1212,8 @@ wxTreeItemId wxGenericTreeCtrl::AddRoot(const wxString& text,
|
|||||||
// if root is hidden, make sure we can navigate
|
// if root is hidden, make sure we can navigate
|
||||||
// into children
|
// into children
|
||||||
m_anchor->SetHasPlus();
|
m_anchor->SetHasPlus();
|
||||||
Expand(m_anchor);
|
m_anchor->Expand();
|
||||||
|
CalculatePositions();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!HasFlag(wxTR_MULTIPLE))
|
if (!HasFlag(wxTR_MULTIPLE))
|
||||||
@@ -1356,6 +1357,8 @@ void wxGenericTreeCtrl::Expand(const wxTreeItemId& itemId)
|
|||||||
wxGenericTreeItem *item = (wxGenericTreeItem*) itemId.m_pItem;
|
wxGenericTreeItem *item = (wxGenericTreeItem*) itemId.m_pItem;
|
||||||
|
|
||||||
wxCHECK_RET( item, _T("invalid item in wxGenericTreeCtrl::Expand") );
|
wxCHECK_RET( item, _T("invalid item in wxGenericTreeCtrl::Expand") );
|
||||||
|
wxCHECK_RET( !HasFlag(wxTR_HIDE_ROOT) || itemId != GetRootItem(),
|
||||||
|
_T("can't expand hidden root") );
|
||||||
|
|
||||||
if ( !item->HasPlus() )
|
if ( !item->HasPlus() )
|
||||||
return;
|
return;
|
||||||
@@ -1400,6 +1403,9 @@ void wxGenericTreeCtrl::ExpandAll(const wxTreeItemId& item)
|
|||||||
|
|
||||||
void wxGenericTreeCtrl::Collapse(const wxTreeItemId& itemId)
|
void wxGenericTreeCtrl::Collapse(const wxTreeItemId& itemId)
|
||||||
{
|
{
|
||||||
|
wxCHECK_RET( !HasFlag(wxTR_HIDE_ROOT) || itemId != GetRootItem(),
|
||||||
|
_T("can't collapse hidden root") );
|
||||||
|
|
||||||
wxGenericTreeItem *item = (wxGenericTreeItem*) itemId.m_pItem;
|
wxGenericTreeItem *item = (wxGenericTreeItem*) itemId.m_pItem;
|
||||||
|
|
||||||
if ( !item->IsExpanded() )
|
if ( !item->IsExpanded() )
|
||||||
@@ -1680,10 +1686,22 @@ void wxGenericTreeCtrl::EnsureVisible(const wxTreeItemId& item)
|
|||||||
|
|
||||||
// first expand all parent branches
|
// first expand all parent branches
|
||||||
wxGenericTreeItem *parent = gitem->GetParent();
|
wxGenericTreeItem *parent = gitem->GetParent();
|
||||||
while ( parent )
|
|
||||||
|
if ( HasFlag(wxTR_HIDE_ROOT) )
|
||||||
{
|
{
|
||||||
Expand(parent);
|
while ( parent != m_anchor )
|
||||||
parent = parent->GetParent();
|
{
|
||||||
|
Expand(parent);
|
||||||
|
parent = parent->GetParent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while ( parent )
|
||||||
|
{
|
||||||
|
Expand(parent);
|
||||||
|
parent = parent->GetParent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (parent) CalculatePositions();
|
//if (parent) CalculatePositions();
|
||||||
|
Reference in New Issue
Block a user