+void MyFrame::OnToggleState(wxCommandEvent& WXUNUSED(event))
+{
+ wxTreeItemId item = m_treeCtrl->GetFocusedItem();
+
+ CHECK_ITEM( item );
+
+ m_treeCtrl->DoToggleState(item);
+}
+
+void MyFrame::DoShowFirstOrLast(TreeFunc0_t pfn, const wxString& label)
+{
+ const wxTreeItemId item = (m_treeCtrl->*pfn)();
+
+ if ( !item.IsOk() )
+ {
+ wxLogMessage("There is no %s item", label);
+ }
+ else
+ {
+ wxLogMessage("The %s item is \"%s\"",
+ label, m_treeCtrl->GetItemText(item));
+ }
+}
+
+void MyFrame::DoShowRelativeItem(TreeFunc1_t pfn, const wxString& label)
+{
+ wxTreeItemId item = m_treeCtrl->GetFocusedItem();
+
+ CHECK_ITEM( item );
+
+ if ((pfn == (TreeFunc1_t) &wxTreeCtrl::GetPrevVisible
+ || pfn == (TreeFunc1_t) &wxTreeCtrl::GetNextVisible)
+ && !m_treeCtrl->IsVisible(item))
+ {
+ wxLogMessage("The selected item must be visible.");
+ return;
+ }
+
+ wxTreeItemId new_item = (m_treeCtrl->*pfn)(item);
+
+ if ( !new_item.IsOk() )
+ {
+ wxLogMessage("There is no %s item", label);
+ }
+ else
+ {
+ wxLogMessage("The %s item is \"%s\"",
+ label, m_treeCtrl->GetItemText(new_item));
+ }
+}
+
+void MyFrame::OnScrollTo(wxCommandEvent& WXUNUSED(event))
+{
+ // scroll to the last but one top level child
+ wxTreeItemId item = m_treeCtrl->GetPrevSibling(
+ m_treeCtrl->GetLastChild(
+ m_treeCtrl->GetRootItem()));
+ CHECK_ITEM( item );
+
+ m_treeCtrl->ScrollTo(item);
+}
+
+void MyFrame::OnSelectLast(wxCommandEvent& WXUNUSED(event))
+{
+ // select the very last item of the tree
+ wxTreeItemId item = m_treeCtrl->GetRootItem();
+ for ( ;; )
+ {
+ wxTreeItemId itemChild = m_treeCtrl->GetLastChild(item);
+ if ( !itemChild.IsOk() )
+ break;
+
+ item = itemChild;
+ }
+
+ CHECK_ITEM( item );
+
+ m_treeCtrl->SelectItem(item);
+}
+