]> git.saurik.com Git - wxWidgets.git/blobdiff - contrib/src/gizmos/splittree.cpp
implemented (untested) work around for wxScrolledWindow painting bug
[wxWidgets.git] / contrib / src / gizmos / splittree.cpp
index fbb38850814e86fd26ea644061626c440785362d..86d7b720606b72a6b7130eafec337443b215baf3 100644 (file)
     #include "wx/wx.h"
 #endif
 
     #include "wx/wx.h"
 #endif
 
+#ifdef __WXMSW__
+#include <windows.h>
+#include "wx/msw/winundef.h"
+#endif
+
 #include "wx/generic/treectlg.h"
 
 #include "wx/gizmos/splittree.h"
 #include "wx/generic/treectlg.h"
 
 #include "wx/gizmos/splittree.h"
+#include <math.h>
 
 /*
  * wxRemotelyScrolledTreeCtrl
 
 /*
  * wxRemotelyScrolledTreeCtrl
@@ -170,7 +176,7 @@ void wxRemotelyScrolledTreeCtrl::PrepareDC(wxDC& dc)
         scrolledWindow->GetScrollPixelsPerUnit(& xppu2, & yppu2);
 
         dc.SetDeviceOrigin( -startX * xppu1, -startY * yppu2 );
         scrolledWindow->GetScrollPixelsPerUnit(& xppu2, & yppu2);
 
         dc.SetDeviceOrigin( -startX * xppu1, -startY * yppu2 );
-        dc.SetUserScale( win->GetScaleX(), win->GetScaleY() );
+        // dc.SetUserScale( win->GetScaleX(), win->GetScaleY() );
     }
 }
 
     }
 }
 
@@ -244,14 +250,18 @@ void wxRemotelyScrolledTreeCtrl::AdjustRemoteScrollbars()
                        wxRect itemRect;
                        if (GetBoundingRect(GetRootItem(), itemRect))
                        {
                        wxRect itemRect;
                        if (GetBoundingRect(GetRootItem(), itemRect))
                        {
-                               int itemHeight = itemRect.GetHeight();
+                // Actually, the real height seems to be 1 less than reported
+                // (e.g. 16 instead of 16)
+                int itemHeight = itemRect.GetHeight() - 1;
                                
                                int w, h;
                                GetClientSize(&w, &h);
                                
                                wxRect rect(0, 0, 0, 0);
                                CalcTreeSize(rect);
                                
                                int w, h;
                                GetClientSize(&w, &h);
                                
                                wxRect rect(0, 0, 0, 0);
                                CalcTreeSize(rect);
-                               int treeViewHeight = rect.GetHeight()/itemHeight;
+
+                double f = ((double) (rect.GetHeight()) / (double) itemHeight)  ;
+                int treeViewHeight = (int) ceil(f);
                                
                                int scrollPixelsPerLine = itemHeight;
                                int scrollPos = - (itemRect.y / itemHeight);
                                
                                int scrollPixelsPerLine = itemHeight;
                                int scrollPos = - (itemRect.y / itemHeight);
@@ -299,9 +309,6 @@ void wxRemotelyScrolledTreeCtrl::CalcTreeSize(wxRect& rect)
 
 void wxRemotelyScrolledTreeCtrl::CalcTreeSize(const wxTreeItemId& id, wxRect& rect)
 {
 
 void wxRemotelyScrolledTreeCtrl::CalcTreeSize(const wxTreeItemId& id, wxRect& rect)
 {
-       // TODO: implement GetFirst/NextVisibleItem
-       // for wxGenericTreeCtrl, plus GetBoundingRect.
-
        // More efficient implementation would be to find the last item (but how?)
        // Q: is the bounding rect relative to the top of the virtual tree workspace
        // or the top of the window? How would we convert?
        // More efficient implementation would be to find the last item (but how?)
        // Q: is the bounding rect relative to the top of the virtual tree workspace
        // or the top of the window? How would we convert?
@@ -427,7 +434,7 @@ void wxTreeCompanionWindow::OnPaint(wxPaintEvent& event)
                        dc.DrawLine(0, cy, clientSize.x, cy);
                }
        }
                        dc.DrawLine(0, cy, clientSize.x, cy);
                }
        }
-       if (m_treeCtrl->GetBoundingRect(lastH, itemRect))
+       if (lastH.IsOk() && m_treeCtrl->GetBoundingRect(lastH, itemRect))
        {
                cy = itemRect.GetBottom();
                dc.DrawLine(0, cy, clientSize.x, cy);
        {
                cy = itemRect.GetBottom();
                dc.DrawLine(0, cy, clientSize.x, cy);
@@ -571,9 +578,12 @@ void wxSplitterScrolledWindow::OnScroll(wxScrollWinEvent& event)
     // don't cause an infinite loop
     static bool inOnScroll = FALSE;
     if (inOnScroll)
     // don't cause an infinite loop
     static bool inOnScroll = FALSE;
     if (inOnScroll)
+    {
+        event.Skip();
         return;
         return;
+    }
     inOnScroll = TRUE;
     inOnScroll = TRUE;
-
+    
     int orient = event.GetOrientation();
 
     int nScrollInc = CalcScrollInc(event);
     int orient = event.GetOrientation();
 
     int nScrollInc = CalcScrollInc(event);