]> git.saurik.com Git - wxWidgets.git/blobdiff - contrib/src/gizmos/splittree.cpp
removed libxpm dependencies from makefiles
[wxWidgets.git] / contrib / src / gizmos / splittree.cpp
index 8dbd9221e4f44f19ab99fc20a659dcddae15bfa5..71b8145da1dc0518e74f64a0b0ff9d6f17ec5341 100644 (file)
@@ -38,6 +38,7 @@
 #include "wx/generic/treectlg.h"
 
 #include "wx/gizmos/splittree.h"
+#include <math.h>
 
 /*
  * wxRemotelyScrolledTreeCtrl
@@ -106,6 +107,26 @@ void wxRemotelyScrolledTreeCtrl::SetScrollbars(int pixelsPerUnitX, int pixelsPer
     }
 }
 
+// In case we're using the generic tree control.
+int wxRemotelyScrolledTreeCtrl::GetScrollPos(int orient) const
+{
+    wxScrolledWindow* scrolledWindow = GetScrolledWindow();
+
+    if (IsKindOf(CLASSINFO(wxGenericTreeCtrl)))
+    {
+        wxGenericTreeCtrl* win = (wxGenericTreeCtrl*) this;
+
+        if (orient == wxHORIZONTAL)
+            return win->wxGenericTreeCtrl::GetScrollPos(orient);
+        else
+        {
+            return scrolledWindow->GetScrollPos(orient);
+        }
+    }
+    return 0;
+}
+
+
 // In case we're using the generic tree control.
 // Get the view start
 void wxRemotelyScrolledTreeCtrl::GetViewStart(int *x, int *y) const
@@ -150,7 +171,7 @@ void wxRemotelyScrolledTreeCtrl::PrepareDC(wxDC& dc)
         scrolledWindow->GetScrollPixelsPerUnit(& xppu2, & yppu2);
 
         dc.SetDeviceOrigin( -startX * xppu1, -startY * yppu2 );
-        dc.SetUserScale( win->GetScaleX(), win->GetScaleY() );
+        // dc.SetUserScale( win->GetScaleX(), win->GetScaleY() );
     }
 }
 
@@ -224,14 +245,18 @@ void wxRemotelyScrolledTreeCtrl::AdjustRemoteScrollbars()
                        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 treeViewHeight = rect.GetHeight()/itemHeight;
+
+                double f = ((double) (rect.GetHeight()) / (double) itemHeight)  ;
+                int treeViewHeight = (int) ceil(f);
                                
                                int scrollPixelsPerLine = itemHeight;
                                int scrollPos = - (itemRect.y / itemHeight);
@@ -277,11 +302,8 @@ void wxRemotelyScrolledTreeCtrl::CalcTreeSize(wxRect& rect)
        CalcTreeSize(GetRootItem(), rect);
 }
 
-void wxRemotelyScrolledTreeCtrl::CalcTreeSize(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?
@@ -318,7 +340,7 @@ void wxRemotelyScrolledTreeCtrl::OnScroll(wxScrollWinEvent& event)
     int orient = event.GetOrientation();
     if (orient == wxHORIZONTAL)
     {
-        // Don't 'skip' or we'd get into infinite recursion
+        event.Skip();
         return;
     }
     wxScrolledWindow* scrollWin = GetScrolledWindow();
@@ -383,7 +405,7 @@ void wxTreeCompanionWindow::OnPaint(wxPaintEvent& event)
     if (!m_treeCtrl)
         return;
 
-       wxPen pen(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DLIGHT), 1, wxSOLID);
+        wxPen pen(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DLIGHT), 1, wxSOLID);
        dc.SetPen(pen);
        dc.SetBrush(* wxTRANSPARENT_BRUSH);
        wxFont font(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
@@ -400,14 +422,14 @@ void wxTreeCompanionWindow::OnPaint(wxPaintEvent& event)
                        cy = itemRect.GetTop();
                        wxRect drawItemRect(0, cy, clientSize.x, itemRect.GetHeight());
 
-                       dc.DrawLine(0, cy, clientSize.x, cy);
                        lastH = h;
 
                        // Draw the actual item
                        DrawItem(dc, h, drawItemRect);
+                       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);
@@ -419,7 +441,7 @@ void wxTreeCompanionWindow::OnScroll(wxScrollWinEvent& event)
     int orient = event.GetOrientation();
     if (orient == wxHORIZONTAL)
     {
-        // Don't 'skip' or we'd get into infinite recursion
+        event.Skip();
         return;
     }
     if (!m_treeCtrl)
@@ -551,9 +573,12 @@ void wxSplitterScrolledWindow::OnScroll(wxScrollWinEvent& event)
     // don't cause an infinite loop
     static bool inOnScroll = FALSE;
     if (inOnScroll)
+    {
+        event.Skip();
         return;
+    }
     inOnScroll = TRUE;
-
+    
     int orient = event.GetOrientation();
 
     int nScrollInc = CalcScrollInc(event);
@@ -565,8 +590,13 @@ void wxSplitterScrolledWindow::OnScroll(wxScrollWinEvent& event)
 
     if (orient == wxHORIZONTAL)
     {
+        inOnScroll = FALSE;
+        event.Skip();
+        return;
+#if 0
         int newPos = m_xScrollPosition + nScrollInc;
         SetScrollPos(wxHORIZONTAL, newPos, TRUE );
+#endif
     }
     else
     {