From 003d61a3e60cd1b3101feec5ba1db6cb26e7e3a0 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Wed, 19 Mar 2003 01:02:45 +0000 Subject: [PATCH] Backported recent wxGenericTreeCtrl fixes git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@19609 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/treectlg.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/generic/treectlg.cpp b/src/generic/treectlg.cpp index 8b173566d1..edc1b0d090 100644 --- a/src/generic/treectlg.cpp +++ b/src/generic/treectlg.cpp @@ -291,7 +291,7 @@ private: short m_images[wxTreeItemIcon_Max]; wxCoord m_x; // (virtual) offset from top - short m_y; // (virtual) offset from left + wxCoord m_y; // (virtual) offset from left short m_width; // width of this item unsigned char m_height; // height of this item @@ -2329,8 +2329,8 @@ void wxGenericTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level MacWindowToRootWindow( & loc_x , & loc_y ) ; Rect bounds = { loc_y , loc_x , loc_y + 18 , loc_x + 12 } ; ThemeButtonDrawInfo info = { kThemeStateActive , item->IsExpanded() ? kThemeDisclosureDown : kThemeDisclosureRight , - kThemeAdornmentNone }; - DrawThemeButton( &bounds, kThemeDisclosureButton , + kThemeAdornmentNone }; + DrawThemeButton( &bounds, kThemeDisclosureButton , &info , NULL , NULL , NULL , NULL ) ; #else if (item->IsExpanded()) @@ -2410,7 +2410,23 @@ void wxGenericTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level // draw line down to last child oldY += GetLineHeight(children[n-1])>>1; if (HasButtons()) y_mid += 5; - dc.DrawLine(x, y_mid, x, oldY); + + // Only draw the portion of the line that is visible, in case it is huge + wxCoord xOrigin=0, yOrigin=0, width, height; + dc.GetDeviceOrigin(&xOrigin, &yOrigin); + yOrigin = abs(yOrigin); + GetClientSize(&width, &height); + + // Move end points to the begining/end of the view? + if (y_mid < yOrigin) + y_mid = yOrigin; + if (oldY > yOrigin + height) + oldY = yOrigin + height; + + // after the adjustments if y_mid is larger than oldY then the line + // isn't visible at all so don't draw anything + if (y_mid < oldY) + dc.DrawLine(x, y_mid, x, oldY); } } }