From 731991e499ce7f9c6cd298fc99433897960101ce Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 29 Feb 2008 19:51:05 +0000 Subject: [PATCH] fix asserts when the root is hidden [backport of r45135 from trunk] git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@52196 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/treectrl/treetest.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/samples/treectrl/treetest.cpp b/samples/treectrl/treetest.cpp index a32d4d0c81..7b16668926 100644 --- a/samples/treectrl/treetest.cpp +++ b/samples/treectrl/treetest.cpp @@ -327,6 +327,9 @@ void MyFrame::CreateTree(long style) m_treeCtrl = new MyTreeCtrl(m_panel, TreeTest_Ctrl, wxDefaultPosition, wxDefaultSize, style); + + GetMenuBar()->Enable(TreeTest_SelectRoot, !(style & wxTR_HIDE_ROOT)); + Resize(); } @@ -519,7 +522,8 @@ void MyFrame::OnSelect(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnSelectRoot(wxCommandEvent& WXUNUSED(event)) { - m_treeCtrl->SelectItem(m_treeCtrl->GetRootItem()); + if ( !m_treeCtrl->HasFlag(wxTR_HIDE_ROOT) ) + m_treeCtrl->SelectItem(m_treeCtrl->GetRootItem()); } void MyFrame::OnUnselect(wxCommandEvent& WXUNUSED(event)) @@ -862,7 +866,7 @@ void MyTreeCtrl::AddTestItemsToTree(size_t numChildren, wxTreeItemId rootId = AddRoot(wxT("Root"), image, image, new MyTreeItemData(wxT("Root item"))); - if ( image != -1 ) + if ( !HasFlag(wxTR_HIDE_ROOT) && image != -1 ) { SetItemImage(rootId, TreeCtrlIcon_FolderOpened, wxTreeItemIcon_Expanded); } @@ -870,7 +874,8 @@ void MyTreeCtrl::AddTestItemsToTree(size_t numChildren, AddItemsRecursively(rootId, numChildren, depth, 0); // set some colours/fonts for testing - SetItemFont(rootId, *wxITALIC_FONT); + if ( !HasFlag(wxTR_HIDE_ROOT) ) + SetItemFont(rootId, *wxITALIC_FONT); wxTreeItemIdValue cookie; wxTreeItemId id = GetFirstChild(rootId, cookie);