From: Julian Smart Date: Mon, 3 Dec 2001 20:52:06 +0000 (+0000) Subject: Moved line-drawing to splittree implementation. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/a18b162dc101592073a3bd26fd49e27a227d8280 Moved line-drawing to splittree implementation. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12845 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/contrib/include/wx/gizmos/splittree.h b/contrib/include/wx/gizmos/splittree.h index 1b5f543796..78ae37adbc 100644 --- a/contrib/include/wx/gizmos/splittree.h +++ b/contrib/include/wx/gizmos/splittree.h @@ -64,6 +64,7 @@ public: void OnSize(wxSizeEvent& event); void OnExpand(wxTreeEvent& event); void OnScroll(wxScrollWinEvent& event); + void OnPaint(wxPaintEvent& event); //// Overrides // Override this in case we're using the generic tree control. diff --git a/contrib/samples/gizmos/splittree/tree.cpp b/contrib/samples/gizmos/splittree/tree.cpp index 2a776cc8c2..a422ac2816 100644 --- a/contrib/samples/gizmos/splittree/tree.cpp +++ b/contrib/samples/gizmos/splittree/tree.cpp @@ -169,8 +169,10 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) m_splitter = new wxThinSplitterWindow(m_scrolledWindow, idSPLITTER_WINDOW, wxDefaultPosition, wxDefaultSize, wxSP_3DBORDER | wxCLIP_CHILDREN /* | wxSP_LIVE_UPDATE */); m_splitter->SetSashSize(2); - m_tree = new TestTree(m_splitter, idTREE_CTRL, wxDefaultPosition, - wxDefaultSize, wxTR_HAS_BUTTONS | wxTR_NO_LINES | wxNO_BORDER ); + + /* Note the wxTR_ROW_LINES style: draws horizontal lines between items */ + m_tree = new TestTree(m_splitter , idTREE_CTRL, wxDefaultPosition, + wxDefaultSize, wxTR_HAS_BUTTONS | wxTR_NO_LINES | wxNO_BORDER | wxTR_ROW_LINES ); m_valueWindow = new TestValueWindow(m_splitter, idVALUE_WINDOW, wxDefaultPosition, wxDefaultSize, wxNO_BORDER); m_splitter->SplitVertically(m_tree, m_valueWindow); @@ -230,7 +232,6 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) IMPLEMENT_CLASS(TestTree, wxRemotelyScrolledTreeCtrl) BEGIN_EVENT_TABLE(TestTree, wxRemotelyScrolledTreeCtrl) - EVT_PAINT(TestTree::OnPaint) END_EVENT_TABLE() TestTree::TestTree(wxWindow* parent, wxWindowID id, const wxPoint& pt, @@ -273,39 +274,6 @@ TestTree::~TestTree() delete m_imageList; } -void TestTree::OnPaint(wxPaintEvent& event) -{ - wxPaintDC dc(this); - - wxTreeCtrl::OnPaint(event); - - // Reset the device origin since it may have been set - dc.SetDeviceOrigin(0, 0); - - wxPen pen(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DLIGHT), 1, wxSOLID); - dc.SetPen(pen); - dc.SetBrush(* wxTRANSPARENT_BRUSH); - - wxSize clientSize = GetClientSize(); - wxRect itemRect; - int cy=0; - wxTreeItemId h, lastH; - for(h=GetFirstVisibleItem();h;h=GetNextVisible(h)) - { - if (GetBoundingRect(h, itemRect)) - { - cy = itemRect.GetTop(); - dc.DrawLine(0, cy, clientSize.x, cy); - lastH = h; - } - } - if (GetBoundingRect(lastH, itemRect)) - { - cy = itemRect.GetBottom(); - dc.DrawLine(0, cy, clientSize.x, cy); - } -} - /* * TestValueWindow */ diff --git a/contrib/samples/gizmos/splittree/tree.h b/contrib/samples/gizmos/splittree/tree.h index 382d580f66..c799a1309a 100644 --- a/contrib/samples/gizmos/splittree/tree.h +++ b/contrib/samples/gizmos/splittree/tree.h @@ -45,6 +45,7 @@ protected: wxRemotelyScrolledTreeCtrl* m_tree; wxThinSplitterWindow* m_splitter; wxSplitterScrolledWindow* m_scrolledWindow; + //wxScrolledWindow* m_scrolledWindow; TestValueWindow* m_valueWindow; private: @@ -78,7 +79,6 @@ public: const wxSize& sz = wxDefaultSize, long style = wxTR_HAS_BUTTONS); ~TestTree(); - void OnPaint(wxPaintEvent& event); DECLARE_EVENT_TABLE() protected: wxImageList* m_imageList; diff --git a/contrib/src/gizmos/splittree.cpp b/contrib/src/gizmos/splittree.cpp index 84f52d8431..031a39cb8a 100644 --- a/contrib/src/gizmos/splittree.cpp +++ b/contrib/src/gizmos/splittree.cpp @@ -59,6 +59,7 @@ BEGIN_EVENT_TABLE(wxRemotelyScrolledTreeCtrl, wxGenericTreeCtrl) BEGIN_EVENT_TABLE(wxRemotelyScrolledTreeCtrl, wxTreeCtrl) #endif EVT_SIZE(wxRemotelyScrolledTreeCtrl::OnSize) + EVT_PAINT(wxRemotelyScrolledTreeCtrl::OnPaint) EVT_TREE_ITEM_EXPANDED(-1, wxRemotelyScrolledTreeCtrl::OnExpand) EVT_TREE_ITEM_COLLAPSED(-1, wxRemotelyScrolledTreeCtrl::OnExpand) EVT_SCROLLWIN(wxRemotelyScrolledTreeCtrl::OnScroll) @@ -245,6 +246,43 @@ void wxRemotelyScrolledTreeCtrl::OnExpand(wxTreeEvent& event) m_companionWindow->GetEventHandler()->ProcessEvent(event); } +void wxRemotelyScrolledTreeCtrl::OnPaint(wxPaintEvent& event) +{ + wxPaintDC dc(this); + + wxTreeCtrl::OnPaint(event); + + if ((GetWindowStyle() & wxTR_ROW_LINES) == 0) + return ; + + // Reset the device origin since it may have been set + dc.SetDeviceOrigin(0, 0); + + wxPen pen(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DLIGHT), 1, wxSOLID); + dc.SetPen(pen); + dc.SetBrush(* wxTRANSPARENT_BRUSH); + + wxSize clientSize = GetClientSize(); + wxRect itemRect; + int cy=0; + wxTreeItemId h, lastH; + for(h=GetFirstVisibleItem();h;h=GetNextVisible(h)) + { + if (GetBoundingRect(h, itemRect)) + { + cy = itemRect.GetTop(); + dc.DrawLine(0, cy, clientSize.x, cy); + lastH = h; + } + } + if (GetBoundingRect(lastH, itemRect)) + { + cy = itemRect.GetBottom(); + dc.DrawLine(0, cy, clientSize.x, cy); + } +} + + // Adjust the containing wxScrolledWindow's scrollbars appropriately void wxRemotelyScrolledTreeCtrl::AdjustRemoteScrollbars() {