]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/scrlwing.cpp
reSWIGged
[wxWidgets.git] / src / generic / scrlwing.cpp
index 46b409c65dc0b6c6beb3f029d8c5c53f5e8f4347..f2c4ba0af70be8e3d4e797d103ba8ae8f1ced66b 100644 (file)
@@ -44,6 +44,7 @@
 #include "wx/timer.h"
 #endif
 #include "wx/sizer.h"
+#include "wx/recguard.h"
 
 #ifdef __WXMSW__
     #include <windows.h> // for DLGC_WANTARROWS
@@ -382,9 +383,6 @@ void wxScrollHelper::SetScrollbars(int pixelsPerUnitX,
     else
     {
         // otherwise this has been done by AdjustScrollbars, above
-#ifdef __WXMAC__
-        m_targetWindow->Update() ;
-#endif
     }
 #endif // !__WXUNIVERSAL__
 }
@@ -512,10 +510,6 @@ void wxScrollHelper::HandleOnScroll(wxScrollWinEvent& event)
     {
         m_targetWindow->ScrollWindow(dx, dy, GetScrollRect());
     }
-
-#ifdef __WXMAC__
-    m_targetWindow->Update() ;
-#endif
 }
 
 int wxScrollHelper::CalcScrollInc(wxScrollWinEvent& event)
@@ -621,9 +615,18 @@ int wxScrollHelper::CalcScrollInc(wxScrollWinEvent& event)
 // Adjust the scrollbars - new version.
 void wxScrollHelper::AdjustScrollbars()
 {
-#ifdef __WXMAC__
-    m_targetWindow->Update();
-#endif
+    static wxRecursionGuardFlag s_flagReentrancy;
+    wxRecursionGuard guard(s_flagReentrancy);
+    if ( guard.IsInside() )
+    {
+        // don't reenter AdjustScrollbars() while another call to
+        // AdjustScrollbars() is in progress because this may lead to calling
+        // ScrollWindow() twice and this can really happen under MSW if
+        // SetScrollbar() call below adds or removes the scrollbar which
+        // changes the window size and hence results in another
+        // AdjustScrollbars() call
+        return;
+    }
 
     int w = 0, h = 0;
     int oldw, oldh;
@@ -722,7 +725,7 @@ void wxScrollHelper::AdjustScrollbars()
         oldh = h;
 
         GetTargetSize( &w, &h );
-    } while ( w != oldw && h != oldh );
+    } while ( w != oldw || h != oldh );
 
 #ifdef __WXMOTIF__
     // Sorry, some Motif-specific code to implement a backing pixmap
@@ -774,10 +777,6 @@ void wxScrollHelper::AdjustScrollbars()
         else
             m_targetWindow->Refresh(TRUE, GetScrollRect());
     }
-
-#ifdef __WXMAC__
-    m_targetWindow->Update();
-#endif
 }
 
 void wxScrollHelper::DoPrepareDC(wxDC& dc)
@@ -841,10 +840,6 @@ void wxScrollHelper::Scroll( int x_pos, int y_pos )
     if (((x_pos == -1) || (x_pos == m_xScrollPosition)) &&
         ((y_pos == -1) || (y_pos == m_yScrollPosition))) return;
 
-#ifdef __WXMAC__
-    m_targetWindow->Update();
-#endif
-
     int w, h;
     GetTargetSize(&w, &h);
 
@@ -890,11 +885,6 @@ void wxScrollHelper::Scroll( int x_pos, int y_pos )
                                           GetScrollRect() );
         }
     }
-
-#ifdef __WXMAC__
-    m_targetWindow->Update();
-#endif
-
 }
 
 void wxScrollHelper::EnableScrolling (bool x_scroll, bool y_scroll)
@@ -1212,6 +1202,21 @@ BEGIN_EVENT_TABLE(wxGenericScrolledWindow, wxPanel)
     EVT_PAINT(wxGenericScrolledWindow::OnPaint)
 END_EVENT_TABLE()
 
+wxGenericScrolledWindow::wxGenericScrolledWindow() : wxScrollHelper(this)
+{
+}
+
+wxGenericScrolledWindow::wxGenericScrolledWindow(wxWindow *parent,
+                         wxWindowID winid,
+                         const wxPoint& pos,
+                         const wxSize& size,
+                         long style,
+                         const wxString& name)
+                         : wxScrollHelper(this)
+{
+    Create(parent, winid, pos, size, style, name);
+}
+
 bool wxGenericScrolledWindow::Create(wxWindow *parent,
                               wxWindowID id,
                               const wxPoint& pos,
@@ -1253,10 +1258,8 @@ void wxGenericScrolledWindow::DoSetVirtualSize(int x, int y)
     wxPanel::DoSetVirtualSize( x, y );
     AdjustScrollbars();
 
-#if wxUSE_CONSTRAINTS
     if (GetAutoLayout())
         Layout();
-#endif
 }
 
 void wxGenericScrolledWindow::OnPaint(wxPaintEvent& event)
@@ -1289,24 +1292,24 @@ wxGenericScrolledWindow::MSWWindowProc(WXUINT nMsg,
 
 #endif // __WXMSW__
 
-#if WXWIN_COMPATIBILITY
+// ----------------------------------------------------------------------------
+// wxScrolledWindow implementation
+// ----------------------------------------------------------------------------
 
-void wxGenericScrolledWindow::GetScrollUnitsPerPage (int *x_page, int *y_page) const
+wxScrolledWindow::wxScrolledWindow()
 {
-      *x_page = GetScrollPageSize(wxHORIZONTAL);
-      *y_page = GetScrollPageSize(wxVERTICAL);
 }
 
-void wxGenericScrolledWindow::CalcUnscrolledPosition(int x, int y, float *xx, float *yy) const
+wxScrolledWindow::wxScrolledWindow(wxWindow *parent,
+                                   wxWindowID winid,
+                                   const wxPoint& pos,
+                                   const wxSize& size,
+                                   long style,
+                                   const wxString& name)
+                                   : wxGenericScrolledWindow(parent, winid, pos, size, style, name)
 {
-    if ( xx )
-        *xx = (float)(x + m_xScrollPosition * m_xScrollPixelsPerLine);
-    if ( yy )
-        *yy = (float)(y + m_yScrollPosition * m_yScrollPixelsPerLine);
 }
 
-#endif // WXWIN_COMPATIBILITY
-
 #endif // !wxGTK
 
 // vi:sts=4:sw=4:et