+ wxGenericTreeItem *i = (wxGenericTreeItem*) item.m_pItem;
+ wxGenericTreeItem *parent = i->GetParent();
+ if ( parent == NULL )
+ {
+ // root item doesn't have any siblings
+ return wxTreeItemId();
+ }
+
+ wxArrayGenericTreeItems& 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)]);
+}
+
+// Only for internal use right now, but should probably be public
+wxTreeItemId wxGenericTreeCtrl::GetNext(const wxTreeItemId& item) const
+{
+ wxCHECK_MSG( item.IsOk(), wxTreeItemId(), wxT("invalid tree item") );
+
+ wxGenericTreeItem *i = (wxGenericTreeItem*) item.m_pItem;
+
+ // First see if there are any children.
+ wxArrayGenericTreeItems& children = i->GetChildren();
+ if (children.GetCount() > 0)
+ {
+ return children.Item(0);
+ }
+ else
+ {
+ // Try a sibling of this or ancestor instead
+ wxTreeItemId p = item;
+ wxTreeItemId toFind;
+ do
+ {
+ toFind = GetNextSibling(p);
+ p = GetParent(p);
+ } while (p.IsOk() && !toFind.IsOk());
+ return toFind;
+ }
+}
+
+wxTreeItemId wxGenericTreeCtrl::GetPrev(const wxTreeItemId& item) const
+{
+ wxCHECK_MSG( item.IsOk(), wxTreeItemId(), wxT("invalid tree item") );