]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/scrlwing.cpp
Applied another Marco patch (5)
[wxWidgets.git] / src / generic / scrlwing.cpp
index e05628749d846bb4f201483352620fc39da5dd5c..f65fb4b487ee62480ec3820e0db12671ebecd31e 100644 (file)
@@ -340,8 +340,16 @@ void wxScrollHelper::SetScrollbars(int pixelsPerUnitX,
     m_xScrollPosition = xPos;
     m_yScrollPosition = yPos;
 
+    // For better backward compatibility we set persisting limits
+    // here not just the size.  It makes SetScrollbars 'sticky'
+    // emulating the old non-autoscroll behaviour.
+
     m_targetWindow->SetVirtualSizeHints( noUnitsX * pixelsPerUnitX, noUnitsY * pixelsPerUnitY );
 
+    // The above should arguably be deprecated, this however we still need.
+
+    m_targetWindow->SetVirtualSize( noUnitsX * pixelsPerUnitX, noUnitsY * pixelsPerUnitY );
+
     if (do_refresh && !noRefresh)
         m_targetWindow->Refresh(TRUE, GetRect());
 
@@ -675,7 +683,7 @@ void wxScrollHelper::AdjustScrollbars()
         }
 
         if (!m_targetWindow->GetBackingPixmap() &&
-           (noUnitsX != 0) && (noUnitsY != 0))
+           (m_xScrollLines != 0) && (m_yScrollLines != 0))
         {
             int depth = wxDisplayDepth();
             m_targetWindow->SetPixmapWidth(totalPixelWidth);
@@ -865,15 +873,19 @@ void wxScrollHelper::DoCalcUnscrolledPosition(int x, int y, int *xx, int *yy) co
 // Default OnSize resets scrollbars, if any
 void wxScrollHelper::HandleOnSize(wxSizeEvent& WXUNUSED(event))
 {
-    if( m_targetWindow != m_win )
-        m_targetWindow->SetVirtualSize( m_targetWindow->GetClientSize() );
+    if( m_win->GetAutoLayout() )
+    {
+        if ( m_targetWindow != m_win )
+            m_targetWindow->FitInside();
 
-    m_win->SetVirtualSize( m_win->GetClientSize() );
+        m_win->FitInside();
 
 #if wxUSE_CONSTRAINTS
-    if (m_win->GetAutoLayout())
         m_win->Layout();
 #endif
+    }
+    else
+        AdjustScrollbars();
 }
 
 // This calls OnDraw, having adjusted the origin according to the current
@@ -1088,26 +1100,34 @@ void wxScrollHelper::HandleOnMouseWheel(wxMouseEvent& event)
 
     if (lines != 0)
     {
-        lines *= event.GetLinesPerAction();
 
         wxScrollWinEvent newEvent;
 
         newEvent.SetPosition(0);
         newEvent.SetOrientation(wxVERTICAL);
         newEvent.m_eventObject = m_win;
-        if (lines > 0)
-            newEvent.m_eventType = wxEVT_SCROLLWIN_LINEUP;
-        else
-            newEvent.m_eventType = wxEVT_SCROLLWIN_LINEDOWN;
 
-        int times = abs(lines);
-        for (; times > 0; times --)
+        if (event.IsPageScroll())
+        {
+            if (lines > 0)
+                newEvent.m_eventType = wxEVT_SCROLLWIN_PAGEUP;
+            else
+                newEvent.m_eventType = wxEVT_SCROLLWIN_PAGEDOWN;
+
             m_win->GetEventHandler()->ProcessEvent(newEvent);
+        }
+        else
+        {
+            lines *= event.GetLinesPerAction();
+            if (lines > 0)
+                newEvent.m_eventType = wxEVT_SCROLLWIN_LINEUP;
+            else
+                newEvent.m_eventType = wxEVT_SCROLLWIN_LINEDOWN;
 
-        /* Old Way */
-        // int vsx, vsy;
-        // GetViewStart(&vsx, &vsy);
-        // Scroll(-1, vsy - lines);
+            int times = abs(lines);
+            for (; times > 0; times--)
+                m_win->GetEventHandler()->ProcessEvent(newEvent);
+        }
     }
 }
 
@@ -1159,10 +1179,15 @@ bool wxGenericScrolledWindow::Layout()
     return wxPanel::Layout();
 }
 
-void wxGenericScrolledWindow::DoSetVirtualSize( int x, int y )
+void wxGenericScrolledWindow::DoSetVirtualSize(int x, int y)
 {
     wxPanel::DoSetVirtualSize( x, y );
     AdjustScrollbars();
+
+#if wxUSE_CONSTRAINTS
+    if (GetAutoLayout())
+        Layout();
+#endif
 }
 
 void wxGenericScrolledWindow::OnPaint(wxPaintEvent& event)