// if root is hidden, make sure we can navigate
// into children
m_anchor->SetHasPlus();
- Expand(m_anchor);
+ m_anchor->Expand();
+ CalculatePositions();
}
if (!HasFlag(wxTR_MULTIPLE))
wxGenericTreeItem *item = (wxGenericTreeItem*) itemId.m_pItem;
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() )
return;
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;
if ( !item->IsExpanded() )
// first expand all parent branches
wxGenericTreeItem *parent = gitem->GetParent();
- while ( parent )
+
+ if ( HasFlag(wxTR_HIDE_ROOT) )
{
- Expand(parent);
- parent = parent->GetParent();
+ while ( parent != m_anchor )
+ {
+ Expand(parent);
+ parent = parent->GetParent();
+ }
+ }
+ else
+ {
+ while ( parent )
+ {
+ Expand(parent);
+ parent = parent->GetParent();
+ }
}
//if (parent) CalculatePositions();
wxSize client = GetClientSize();
wxRect rect;
- CalcScrolledPosition(0, item->GetY(), &rect.x, &rect.y);
+ CalcScrolledPosition(0, item->GetY(), NULL, &rect.y);
rect.width = client.x;
rect.height = client.y;
if (m_dirty) return;
wxRect rect;
- CalcScrolledPosition(0, item->GetY(), &rect.x, &rect.y);
+ CalcScrolledPosition(0, item->GetY(), NULL, &rect.y);
rect.width = GetClientSize().x;
rect.height = GetLineHeight(item); //dc.GetCharHeight() + 6;