+ wxCHECK_MSG( item.IsOk(), FALSE, _T("invalid tree item") );
+
+ return item.m_pItem->IsBold();
+}
+
+// -----------------------------------------------------------------------------
+// navigation
+// -----------------------------------------------------------------------------
+
+wxTreeItemId wxTreeCtrl::GetParent(const wxTreeItemId& item) const
+{
+ wxCHECK_MSG( item.IsOk(), wxTreeItemId(), _T("invalid tree item") );
+
+ return item.m_pItem->GetParent();
+}
+
+wxTreeItemId wxTreeCtrl::GetFirstChild(const wxTreeItemId& item, long& cookie) const
+{
+ wxCHECK_MSG( item.IsOk(), wxTreeItemId(), _T("invalid tree item") );
+
+ cookie = 0;
+ return GetNextChild(item, cookie);
+}
+
+wxTreeItemId wxTreeCtrl::GetNextChild(const wxTreeItemId& item, long& cookie) const
+{
+ wxCHECK_MSG( item.IsOk(), wxTreeItemId(), _T("invalid tree item") );
+
+ wxArrayTreeItems& children = item.m_pItem->GetChildren();
+ if ( (size_t)cookie < children.Count() )
+ {
+ return children.Item(cookie++);
+ }
+ else
+ {
+ // there are no more of them
+ return wxTreeItemId();
+ }
+}
+
+wxTreeItemId wxTreeCtrl::GetLastChild(const wxTreeItemId& item) const
+{
+ wxCHECK_MSG( item.IsOk(), wxTreeItemId(), _T("invalid tree item") );
+
+ wxArrayTreeItems& children = item.m_pItem->GetChildren();
+ return (children.IsEmpty() ? wxTreeItemId() : wxTreeItemId(children.Last()));
+}
+
+wxTreeItemId wxTreeCtrl::GetNextSibling(const wxTreeItemId& item) const
+{
+ wxCHECK_MSG( item.IsOk(), wxTreeItemId(), _T("invalid tree item") );
+
+ wxGenericTreeItem *i = item.m_pItem;
+ wxGenericTreeItem *parent = i->GetParent();
+ if ( parent == NULL )
+ {
+ // root item doesn't have any siblings
+ return wxTreeItemId();
+ }
+
+ wxArrayTreeItems& siblings = parent->GetChildren();
+ int index = siblings.Index(i);
+ wxASSERT( index != wxNOT_FOUND ); // I'm not a child of my parent?
+
+ size_t n = (size_t)(index + 1);
+ return n == siblings.Count() ? wxTreeItemId() : wxTreeItemId(siblings[n]);
+}
+
+wxTreeItemId wxTreeCtrl::GetPrevSibling(const wxTreeItemId& item) const
+{
+ wxCHECK_MSG( item.IsOk(), wxTreeItemId(), _T("invalid tree item") );
+
+ wxGenericTreeItem *i = item.m_pItem;
+ wxGenericTreeItem *parent = i->GetParent();
+ if ( parent == NULL )
+ {
+ // root item doesn't have any siblings
+ return wxTreeItemId();
+ }
+
+ wxArrayTreeItems& siblings = parent->GetChildren();
+ int index = siblings.Index(i);
+ wxASSERT( index != wxNOT_FOUND ); // I'm not a child of my parent?
+
+ return index == 0 ? wxTreeItemId()
+ : wxTreeItemId(siblings[(size_t)(index - 1)]);
+}
+
+wxTreeItemId wxTreeCtrl::GetFirstVisibleItem() const
+{
+ wxFAIL_MSG(_T("not implemented"));
+
+ return wxTreeItemId();
+}
+
+wxTreeItemId wxTreeCtrl::GetNextVisible(const wxTreeItemId& item) const
+{
+ wxCHECK_MSG( item.IsOk(), wxTreeItemId(), _T("invalid tree item") );
+
+ wxFAIL_MSG(_T("not implemented"));
+
+ return wxTreeItemId();
+}
+
+wxTreeItemId wxTreeCtrl::GetPrevVisible(const wxTreeItemId& item) const
+{
+ wxCHECK_MSG( item.IsOk(), wxTreeItemId(), _T("invalid tree item") );
+
+ wxFAIL_MSG(_T("not implemented"));
+
+ return wxTreeItemId();
+}
+
+// -----------------------------------------------------------------------------
+// operations
+// -----------------------------------------------------------------------------
+
+wxTreeItemId wxTreeCtrl::DoInsertItem(const wxTreeItemId& parentId,
+ size_t previous,
+ const wxString& text,
+ int image, int selImage,
+ wxTreeItemData *data)
+{
+ wxGenericTreeItem *parent = parentId.m_pItem;
+ if ( !parent )
+ {
+ // should we give a warning here?
+ return AddRoot(text, image, selImage, data);
+ }
+
+ wxClientDC dc(this);
+ wxGenericTreeItem *item = new wxGenericTreeItem(parent,
+ text, dc,
+ image, selImage,
+ data);
+
+ if ( data != NULL )
+ {
+ data->m_pItem = item;
+ }
+
+ parent->Insert( item, previous );
+
+ m_dirty = TRUE;
+
+ return item;
+}
+
+wxTreeItemId wxTreeCtrl::AddRoot(const wxString& text,
+ int image, int selImage,
+ wxTreeItemData *data)
+{
+ wxCHECK_MSG( !m_anchor, wxTreeItemId(), _T("tree can have only one root") );
+
+ wxClientDC dc(this);
+ m_anchor = new wxGenericTreeItem((wxGenericTreeItem *)NULL, text, dc,
+ image, selImage, data);
+ if ( data != NULL )
+ {
+ data->m_pItem = m_anchor;
+ }
+
+ AdjustMyScrollbars();