X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d027179b48bc55d5166cd5ab727d50bf1beff153..c42a91829519b306f3d423e1f671d5291e5bbc3d:/src/generic/treectlg.cpp diff --git a/src/generic/treectlg.cpp b/src/generic/treectlg.cpp index ce148cd301..79a9facb90 100644 --- a/src/generic/treectlg.cpp +++ b/src/generic/treectlg.cpp @@ -1212,7 +1212,8 @@ wxTreeItemId wxGenericTreeCtrl::AddRoot(const wxString& text, // 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)) @@ -1356,6 +1357,8 @@ void wxGenericTreeCtrl::Expand(const wxTreeItemId& itemId) 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; @@ -1400,6 +1403,9 @@ void wxGenericTreeCtrl::ExpandAll(const wxTreeItemId& item) 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() ) @@ -1680,10 +1686,22 @@ void wxGenericTreeCtrl::EnsureVisible(const wxTreeItemId& item) // 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(); @@ -2975,7 +2993,7 @@ void wxGenericTreeCtrl::RefreshSubtree(wxGenericTreeItem *item) 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; @@ -2989,7 +3007,7 @@ void wxGenericTreeCtrl::RefreshLine( wxGenericTreeItem *item ) 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;