From e525c4ff96ae2a26543480a9894d873b2fa20755 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 4 Nov 2006 11:26:51 +0000 Subject: [PATCH] test GetBoundingRect() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43021 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/treectrl/treetest.cpp | 23 +++++++++++++++++++++++ samples/treectrl/treetest.h | 2 ++ 2 files changed, 25 insertions(+) diff --git a/samples/treectrl/treetest.cpp b/samples/treectrl/treetest.cpp index 3af468f441..31666e9df6 100644 --- a/samples/treectrl/treetest.cpp +++ b/samples/treectrl/treetest.cpp @@ -76,6 +76,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) MENU_LINK(SetBgColour) MENU_LINK(ResetStyle) + MENU_LINK(Highlight) MENU_LINK(Dump) #ifndef NO_MULTIPLE_SELECTION MENU_LINK(DumpSelected) @@ -456,6 +457,26 @@ void MyFrame::DoSort(bool reverse) m_treeCtrl->DoSortChildren(item, reverse); } +void MyFrame::OnHighlight(wxCommandEvent& WXUNUSED(event)) +{ + wxTreeItemId id = m_treeCtrl->GetSelection(); + + CHECK_ITEM( id ); + + wxRect r; + if ( !m_treeCtrl->GetBoundingRect(id, r, true /* text, not full row */) ) + { + wxLogMessage(_T("Failed to get bounding item rect")); + return; + } + + wxClientDC dc(m_treeCtrl); + dc.SetBrush(*wxRED); + dc.SetPen(*wxTRANSPARENT_PEN); + dc.DrawRectangle(r); + m_treeCtrl->Update(); +} + void MyFrame::OnDump(wxCommandEvent& WXUNUSED(event)) { wxTreeItemId root = m_treeCtrl->GetSelection(); @@ -1230,6 +1251,8 @@ void MyTreeCtrl::ShowMenu(wxTreeItemId id, const wxPoint& pt) #if wxUSE_MENUS wxMenu menu(title); menu.Append(TreeTest_About, wxT("&About...")); + menu.AppendSeparator(); + menu.Append(TreeTest_Highlight, wxT("&Highlight item")); menu.Append(TreeTest_Dump, wxT("&Dump")); PopupMenu(&menu, pt); diff --git a/samples/treectrl/treetest.h b/samples/treectrl/treetest.h index 24d3320887..f9a2f3bcaa 100644 --- a/samples/treectrl/treetest.h +++ b/samples/treectrl/treetest.h @@ -177,6 +177,7 @@ public: void OnSetFgColour(wxCommandEvent& event); void OnSetBgColour(wxCommandEvent& event); + void OnHighlight(wxCommandEvent& event); void OnDump(wxCommandEvent& event); #ifndef NO_MULTIPLE_SELECTION void OnDumpSelected(wxCommandEvent& event); @@ -258,6 +259,7 @@ enum TreeTest_SetFgColour, TreeTest_SetBgColour, TreeTest_ResetStyle, + TreeTest_Highlight, TreeTest_Dump, TreeTest_DumpSelected, TreeTest_Count, -- 2.45.2