From c6a6bbbf637a5a580b7ab182483d27522f5e3189 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 30 Mar 2007 12:58:01 +0000 Subject: [PATCH] disable select root menu command when the root is hidden git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45135 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 5baee09..1eab7f8 100644 --- a/samples/treectrl/treetest.cpp +++ b/samples/treectrl/treetest.cpp @@ -330,6 +330,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(); } @@ -522,7 +525,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)) @@ -865,7 +869,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); } @@ -873,7 +877,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); -- 2.7.4