MENU_LINK(Quit)
MENU_LINK(About)
+ MENU_LINK(ClearLog)
MENU_LINK(TogButtons)
MENU_LINK(TogTwist)
MENU_LINK(DecSpacing)
MENU_LINK(ToggleIcon)
MENU_LINK(SelectRoot)
+
+ MENU_LINK(ShowFirstVisible)
+#ifdef wxHAS_LAST_VISIBLE
+ MENU_LINK(ShowLastVisible)
+#endif // wxHAS_LAST_VISIBLE
+ MENU_LINK(ShowNextVisible)
+ MENU_LINK(ShowPrevVisible)
#undef MENU_LINK
END_EVENT_TABLE()
EVT_TREE_KEY_DOWN(TreeTest_Ctrl, MyTreeCtrl::OnTreeKeyDown)
EVT_TREE_ITEM_ACTIVATED(TreeTest_Ctrl, MyTreeCtrl::OnItemActivated)
- // so many differents ways to handle right mouse button clicks...
+ // so many different ways to handle right mouse button clicks...
EVT_CONTEXT_MENU(MyTreeCtrl::OnContextMenu)
// EVT_TREE_ITEM_MENU is the preferred event for creating context menus
// on a tree control, because it includes the point of the click or item,
*tree_menu = new wxMenu,
*item_menu = new wxMenu;
+ file_menu->Append(TreeTest_ClearLog, wxT("&Clear log\tCtrl-L"));
+ file_menu->AppendSeparator();
file_menu->Append(TreeTest_About, wxT("&About..."));
file_menu->AppendSeparator();
file_menu->Append(TreeTest_Quit, wxT("E&xit\tAlt-X"));
style_menu->AppendCheckItem(TreeTest_TogFullHighlight, wxT("Toggle &full row highlight"));
style_menu->AppendCheckItem(TreeTest_TogEdit, wxT("Toggle &edit mode"));
#ifndef NO_MULTIPLE_SELECTION
- style_menu->AppendCheckItem(TreeTest_ToggleSel, wxT("Toggle &selection mode"));
+ style_menu->AppendCheckItem(TreeTest_ToggleSel, wxT("Toggle &selection mode\tCtrl-S"));
#endif // NO_MULTIPLE_SELECTION
style_menu->AppendCheckItem(TreeTest_ToggleImages, wxT("Toggle show ima&ges"));
style_menu->AppendCheckItem(TreeTest_ToggleAlternateImages, wxT("Toggle alternate images"));
item_menu->Append(TreeTest_ClearBold, wxT("Make item ¬ bold"));
item_menu->AppendSeparator();
item_menu->Append(TreeTest_ToggleIcon, wxT("Toggle the item's &icon"));
+ item_menu->AppendSeparator();
+ item_menu->Append(TreeTest_ShowFirstVisible, wxT("Show &first visible"));
+#ifdef wxHAS_LAST_VISIBLE
+ item_menu->Append(TreeTest_ShowLastVisible, wxT("Show &last visible"));
+#endif // wxHAS_LAST_VISIBLE
+ item_menu->Append(TreeTest_ShowNextVisible, wxT("Show &next visible"));
+ item_menu->Append(TreeTest_ShowPrevVisible, wxT("Show &previous visible"));
#ifndef NO_MULTIPLE_SELECTION
item_menu->AppendSeparator();
{
wxSize size = GetClientSize();
m_treeCtrl->SetSize(0, 0, size.x, size.y
-#if !wxUSE_LOG
- );
-#else
+#if wxUSE_LOG
*2/3);
- m_textCtrl->SetSize(0, 2*size.y/3, size.x, size.y/3);
+ m_textCtrl->SetSize(0, 2*size.y/3, size.x, size.y/3
#endif
+ );
}
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
wxOK | wxICON_INFORMATION, this);
}
+void MyFrame::OnClearLog(wxCommandEvent& WXUNUSED(event))
+{
+ m_textCtrl->Clear();
+}
+
void MyFrame::OnRename(wxCommandEvent& WXUNUSED(event))
{
wxTreeItemId item = m_treeCtrl->GetSelection();
m_treeCtrl->DoToggleIcon(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::DoShowNextOrPrev(TreeFunc1_t pfn, const wxString& label)
+{
+ wxTreeItemId item = m_treeCtrl->GetSelection();
+
+ CHECK_ITEM( item );
+
+ if ( !m_treeCtrl->IsVisible(item) )
+ {
+ wxLogMessage("The selected item must be visible.");
+ return;
+ }
+
+ item = (m_treeCtrl->*pfn)(item);
+
+ if ( !item.IsOk() )
+ wxLogMessage("There is no %s item", label);
+ else
+ wxLogMessage("The %s item is \"%s\"",
+ label, m_treeCtrl->GetItemText(item));
+}
+
void MyFrame::OnSetFgColour(wxCommandEvent& WXUNUSED(event))
{
wxColour col = wxGetColourFromUser(this, m_treeCtrl->GetForegroundColour());