]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/scrlwing.cpp
new default theme for wxAuiNotebook
[wxWidgets.git] / src / generic / scrlwing.cpp
index e05ecbda17a3e6fdc62db89d660022b3fb3db980..92ebe1aedb1212de389b06435165c2e563f65a62 100644 (file)
@@ -311,6 +311,8 @@ wxScrollHelper::wxScrollHelper(wxWindow *win)
     m_handler = NULL;
 
     m_win = win;
+    
+    m_win->SetScrollHelper( this );
 
     // by default, the associated window is also the target window
     DoSetTargetWindow(win);
@@ -460,6 +462,11 @@ void wxScrollHelper::HandleOnScroll(wxScrollWinEvent& event)
         return;
     }
 
+    // flush all pending repaints before we change m_{x,y}ScrollPosition, as
+    // otherwise invalidated area could be updated incorrectly later when
+    // ScrollWindow() makes sure they're repainted before scrolling them
+    m_targetWindow->Update();
+
     int orient = event.GetOrientation();
     if (orient == wxHORIZONTAL)
     {
@@ -813,8 +820,17 @@ void wxScrollHelper::AdjustScrollbars()
 void wxScrollHelper::DoPrepareDC(wxDC& dc)
 {
     wxPoint pt = dc.GetDeviceOrigin();
-    dc.SetDeviceOrigin( pt.x - m_xScrollPosition * m_xScrollPixelsPerLine,
-                        pt.y - m_yScrollPosition * m_yScrollPixelsPerLine );
+#ifdef __WXGTK__
+    // It may actually be correct to always query
+    // the m_sign from the DC here, but I leve the
+    // #ifdef GTK for now.
+    if (m_win->GetLayoutDirection() == wxLayout_RightToLeft)
+        dc.SetDeviceOrigin( pt.x + m_xScrollPosition * m_xScrollPixelsPerLine,
+                            pt.y - m_yScrollPosition * m_yScrollPixelsPerLine );
+    else
+#endif
+        dc.SetDeviceOrigin( pt.x - m_xScrollPosition * m_xScrollPixelsPerLine,
+                            pt.y - m_yScrollPosition * m_yScrollPixelsPerLine );
     dc.SetUserScale( m_scaleX, m_scaleY );
 }
 
@@ -883,6 +899,11 @@ void wxScrollHelper::Scroll( int x_pos, int y_pos )
     int w = 0, h = 0;
     GetTargetSize(&w, &h);
 
+    // flush all pending repaints before we change m_{x,y}ScrollPosition, as
+    // otherwise invalidated area could be updated incorrectly later when
+    // ScrollWindow() makes sure they're repainted before scrolling them
+    m_targetWindow->Update();
+
     if ((x_pos != -1) && (m_xScrollPixelsPerLine))
     {
         int old_x = m_xScrollPosition;
@@ -947,33 +968,7 @@ void wxScrollHelper::GetViewStart (int *x, int *y) const
 void wxScrollHelper::DoCalcScrolledPosition(int x, int y, int *xx, int *yy) const
 {
     if ( xx )
-    {
-        if ((m_xScrollLines == 0) || (m_xScrollPixelsPerLine == 0))
-        {
-            // nothing to do
-            *xx = x;
-        }
-        else
-        {
-#ifdef __WXGTK__
-            if (m_win->GetLayoutDirection() == wxLayout_RightToLeft)
-            {
-                int w = 0, h = 0;
-                GetTargetSize(&w, &h);
-
-                // Calculate page size i.e. number of scroll units you get on the
-                // current client window
-                int noPagePositions = w/m_xScrollPixelsPerLine;
-                if (noPagePositions < 1) noPagePositions = 1;
-                *xx = x - ((m_xScrollLines - noPagePositions - m_xScrollPosition) * m_xScrollPixelsPerLine);
-            }
-            else
-#endif
-            {
-                *xx = x - m_xScrollPosition * m_xScrollPixelsPerLine;
-            }
-        }
-    }
+        *xx = x - m_xScrollPosition * m_xScrollPixelsPerLine;
     if ( yy )
         *yy = y - m_yScrollPosition * m_yScrollPixelsPerLine;
 }
@@ -981,33 +976,7 @@ void wxScrollHelper::DoCalcScrolledPosition(int x, int y, int *xx, int *yy) cons
 void wxScrollHelper::DoCalcUnscrolledPosition(int x, int y, int *xx, int *yy) const
 {
     if ( xx )
-    {
-        if ((m_xScrollLines == 0) || (m_xScrollPixelsPerLine == 0))
-        {
-            // nothing to do
-            *xx = x;
-        }
-        else
-        {
-#ifdef __WXGTK__
-            if (m_win->GetLayoutDirection() == wxLayout_RightToLeft)
-            {
-                int w = 0, h = 0;
-                GetTargetSize(&w, &h);
-
-                // Calculate page size i.e. number of scroll units you get on the
-                // current client window
-                int noPagePositions = w/m_xScrollPixelsPerLine;
-                if (noPagePositions < 1) noPagePositions = 1;
-                *xx = x + ((m_xScrollLines - noPagePositions - m_xScrollPosition) * m_xScrollPixelsPerLine);
-            }
-            else
-#endif
-            {
-                *xx = x + m_xScrollPosition * m_xScrollPixelsPerLine;
-            }
-        }
-    }
+        *xx = x + m_xScrollPosition * m_xScrollPixelsPerLine;
     if ( yy )
         *yy = y + m_yScrollPosition * m_yScrollPixelsPerLine;
 }