X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5fd11f09718445c5795526c393f2b2a1875f6870..0dfef5a8124ac0f1bb2aed6ef5ddfa833e8e2c6e:/samples/treectrl/treetest.cpp?ds=sidebyside diff --git a/samples/treectrl/treetest.cpp b/samples/treectrl/treetest.cpp index 6e8dc94fd0..2bd8bfa646 100644 --- a/samples/treectrl/treetest.cpp +++ b/samples/treectrl/treetest.cpp @@ -85,6 +85,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) 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) @@ -153,6 +154,7 @@ MyFrame::MyFrame(const wxString& title, int x, int y, int w, int h) 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"); @@ -204,6 +206,9 @@ MyFrame::MyFrame(const wxString& title, int x, int y, int w, int h) 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); @@ -284,8 +289,8 @@ void MyFrame::OnCount(wxCommandEvent& WXUNUSED(event)) 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)) @@ -295,8 +300,8 @@ 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) @@ -324,7 +329,7 @@ void MyFrame::OnDumpSelected(wxCommandEvent& WXUNUSED(event)) 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++ ) { @@ -392,6 +397,11 @@ void MyFrame::OnEnsureVisible(wxCommandEvent& event) 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; @@ -565,6 +575,18 @@ void MyTreeCtrl::AddTestItemsToTree(size_t numChildren, 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)