X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/35d4c96744442614e35c2268f8851912f2a61c50..2f35f36bbcde256c802a4e0871c3d74e39ee476c:/src/generic/treectlg.cpp?ds=sidebyside diff --git a/src/generic/treectlg.cpp b/src/generic/treectlg.cpp index c7cfd6b854..39d30b7614 100644 --- a/src/generic/treectlg.cpp +++ b/src/generic/treectlg.cpp @@ -825,7 +825,20 @@ wxGenericTreeCtrl::~wxGenericTreeCtrl() size_t wxGenericTreeCtrl::GetCount() const { - return m_anchor == NULL ? 0u : m_anchor->GetChildrenCount(); + if ( !m_anchor ) + { + // the tree is empty + return 0; + } + + size_t count = m_anchor->GetChildrenCount(); + if ( !HasFlag(wxTR_HIDE_ROOT) ) + { + // take the root itself into account + count++; + } + + return count; } void wxGenericTreeCtrl::SetIndent(unsigned int indent) @@ -1878,6 +1891,8 @@ size_t wxGenericTreeCtrl::GetSelections(wxArrayTreeItemIds &array) const void wxGenericTreeCtrl::EnsureVisible(const wxTreeItemId& item) { + wxCHECK_RET( item.IsOk(), wxT("invalid tree item") ); + if (!item.IsOk()) return; wxGenericTreeItem *gitem = (wxGenericTreeItem*) item.m_pItem; @@ -2482,7 +2497,7 @@ void wxGenericTreeCtrl::DrawLine(const wxTreeItemId &item, bool below) } // ----------------------------------------------------------------------------- -// wxWindows callbacks +// wxWidgets callbacks // ----------------------------------------------------------------------------- void wxGenericTreeCtrl::OnPaint( wxPaintEvent &WXUNUSED(event) ) @@ -3446,11 +3461,17 @@ void wxGenericTreeCtrl::OnGetToolTip( wxTreeEvent &event ) // be removed, as well as the #else case below. #define _USE_VISATTR 0 +#if _USE_VISATTR #include "wx/listbox.h" +#endif //static wxVisualAttributes +#if _USE_VISATTR wxGenericTreeCtrl::GetClassDefaultAttributes(wxWindowVariant variant) +#else +wxGenericTreeCtrl::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant)) +#endif { #if _USE_VISATTR // Use the same color scheme as wxListBox