EVT_MENU(TreeTest_CollapseAndReset, MyFrame::OnCollapseAndReset)
EVT_MENU(TreeTest_EnsureVisible, MyFrame::OnEnsureVisible)
EVT_MENU(TreeTest_AddItem, MyFrame::OnAddItem)
+ EVT_MENU(TreeTest_InsertItem, MyFrame::OnInsertItem)
EVT_MENU(TreeTest_IncIndent, MyFrame::OnIncIndent)
EVT_MENU(TreeTest_DecIndent, MyFrame::OnDecIndent)
EVT_MENU(TreeTest_IncSpacing, MyFrame::OnIncSpacing)
tree_menu->Append(TreeTest_CollapseAndReset, "C&ollapse and reset");
tree_menu->AppendSeparator();
tree_menu->Append(TreeTest_AddItem, "Append a &new item");
+ tree_menu->Append(TreeTest_InsertItem, "&Insert a new item");
tree_menu->Append(TreeTest_Delete, "&Delete this item");
tree_menu->Append(TreeTest_DeleteChildren, "Delete &children");
tree_menu->Append(TreeTest_DeleteAll, "Delete &all items");
wxTR_HAS_VARIABLE_ROW_HEIGHT |
#endif
wxSUNKEN_BORDER);
+
+ m_treeCtrl->SetBackgroundColour(wxColour(204, 205, 79));
+
wxTextCtrl *textCtrl = new wxTextCtrl(this, -1, "",
wxDefaultPosition, wxDefaultSize,
wxTE_MULTILINE | wxSUNKEN_BORDER);
CHECK_ITEM( item );
int i = m_treeCtrl->GetChildrenCount( item, FALSE );
-
- wxLogMessage(_T("%d children"), i);
+
+ wxLogMessage(wxT("%d children"), i);
}
void MyFrame::OnCountRec(wxCommandEvent& WXUNUSED(event))
CHECK_ITEM( item );
int i = m_treeCtrl->GetChildrenCount( item );
-
- wxLogMessage(_T("%d children"), i);
+
+ wxLogMessage(wxT("%d children"), i);
}
void MyFrame::DoSort(bool reverse)
wxArrayTreeItemIds array;
size_t count = m_treeCtrl->GetSelections(array);
- wxLogMessage(_T("%u items selected"), count);
+ wxLogMessage(wxT("%u items selected"), count);
for ( size_t n = 0; n < count; n++ )
{
m_treeCtrl->DoEnsureVisible();
}
+void MyFrame::OnInsertItem(wxCommandEvent& WXUNUSED(event))
+{
+ m_treeCtrl->InsertItem(m_treeCtrl->GetRootItem(), 1, "2nd item");
+}
+
void MyFrame::OnAddItem(wxCommandEvent& WXUNUSED(event))
{
static int s_num = 0;
SetItemImage(rootId, TreeCtrlIcon_FolderOpened, wxTreeItemIcon_Expanded);
AddItemsRecursively(rootId, numChildren, depth, 0);
+
+ // set some colours/fonts for testing
+ SetItemFont(rootId, *wxITALIC_FONT);
+
+ long cookie;
+ wxTreeItemId id = GetFirstChild(rootId, cookie);
+ SetItemTextColour(id, *wxBLUE);
+
+ id = GetNextChild(rootId, cookie);
+ id = GetNextChild(rootId, cookie);
+ SetItemTextColour(id, *wxRED);
+ SetItemBackgroundColour(id, *wxLIGHT_GREY);
}
void MyTreeCtrl::GetItemsRecursively(const wxTreeItemId& idParent, long cookie)