-// Adjust the scrollbars - new version.
-void wxScrollHelper::AdjustScrollbars()
-{
-    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;
-
-    int oldXScroll = m_xScrollPosition;
-    int oldYScroll = m_yScrollPosition;
-
-    // VZ: at least under Windows this loop is useless because when scrollbars
-    //     [dis]appear we get a WM_SIZE resulting in another call to
-    //     AdjustScrollbars() anyhow. As it doesn't seem to do any harm I leave
-    //     it here for now but it would be better to ensure that all ports
-    //     generate EVT_SIZE when scrollbars [dis]appear, emulating it if
-    //     necessary, and remove it later
-    // JACS: Stop potential infinite loop by limiting number of iterations
-    int iterationCount = 0;
-    const int iterationMax = 5;
-    do
-    {
-        iterationCount ++;
-
-        GetTargetSize(&w, 0);
-
-        // scroll lines per page: if 0, no scrolling is needed
-        int linesPerPage;
-
-        if ( m_xScrollPixelsPerLine == 0 )
-        {
-            // scrolling is disabled
-            m_xScrollLines = 0;
-            m_xScrollPosition = 0;
-            linesPerPage = 0;
-        }
-        else // might need scrolling
-        {
-            // Round up integer division to catch any "leftover" client space.
-            const int wVirt = m_targetWindow->GetVirtualSize().GetWidth();
-            m_xScrollLines = (wVirt + m_xScrollPixelsPerLine - 1) / m_xScrollPixelsPerLine;
-
-            // Calculate page size i.e. number of scroll units you get on the
-            // current client window.
-            linesPerPage = w / m_xScrollPixelsPerLine;
-
-            // Special case. When client and virtual size are very close but
-            // the client is big enough, kill scrollbar.
-            if ((linesPerPage < m_xScrollLines) && (w >= wVirt)) ++linesPerPage;
-
-            if (linesPerPage >= m_xScrollLines)
-            {
-                // we're big enough to not need scrolling
-                linesPerPage =
-                m_xScrollLines =
-                m_xScrollPosition = 0;
-            }
-            else // we do need a scrollbar
-            {
-                if ( linesPerPage < 1 )
-                    linesPerPage = 1;
-
-                // Correct position if greater than extent of canvas minus
-                // the visible portion of it or if below zero
-                const int posMax = m_xScrollLines - linesPerPage;
-                if ( m_xScrollPosition > posMax )
-                    m_xScrollPosition = posMax;
-                else if ( m_xScrollPosition < 0 )
-                    m_xScrollPosition = 0;
-            }
-        }
-
-        m_win->SetScrollbar(wxHORIZONTAL, m_xScrollPosition,
-                            linesPerPage, m_xScrollLines);
-
-        // The amount by which we scroll when paging
-        SetScrollPageSize(wxHORIZONTAL, linesPerPage);
-
-        GetTargetSize(0, &h);
-
-        if ( m_yScrollPixelsPerLine == 0 )
-        {
-            // scrolling is disabled
-            m_yScrollLines = 0;
-            m_yScrollPosition = 0;
-            linesPerPage = 0;
-        }
-        else // might need scrolling
-        {
-            // Round up integer division to catch any "leftover" client space.
-            const int hVirt = m_targetWindow->GetVirtualSize().GetHeight();
-            m_yScrollLines = ( hVirt + m_yScrollPixelsPerLine - 1 ) / m_yScrollPixelsPerLine;
-
-            // Calculate page size i.e. number of scroll units you get on the
-            // current client window.
-            linesPerPage = h / m_yScrollPixelsPerLine;
-
-            // Special case. When client and virtual size are very close but
-            // the client is big enough, kill scrollbar.
-            if ((linesPerPage < m_yScrollLines) && (h >= hVirt)) ++linesPerPage;
-
-            if (linesPerPage >= m_yScrollLines)
-            {
-                // we're big enough to not need scrolling
-                linesPerPage =
-                m_yScrollLines =
-                m_yScrollPosition = 0;
-            }
-            else // we do need a scrollbar
-            {
-                if ( linesPerPage < 1 )
-                    linesPerPage = 1;
-
-                // Correct position if greater than extent of canvas minus
-                // the visible portion of it or if below zero
-                const int posMax = m_yScrollLines - linesPerPage;
-                if ( m_yScrollPosition > posMax )
-                    m_yScrollPosition = posMax;
-                else if ( m_yScrollPosition < 0 )
-                    m_yScrollPosition = 0;
-            }
-        }
-
-        m_win->SetScrollbar(wxVERTICAL, m_yScrollPosition,
-                            linesPerPage, m_yScrollLines);
-
-        // The amount by which we scroll when paging
-        SetScrollPageSize(wxVERTICAL, linesPerPage);
-
-
-        // If a scrollbar (dis)appeared as a result of this, adjust them again.
-        oldw = w;
-        oldh = h;
-
-        GetTargetSize( &w, &h );
-    } while ( (w != oldw || h != oldh) && (iterationCount < iterationMax) );
-
-#ifdef __WXMOTIF__
-    // Sorry, some Motif-specific code to implement a backing pixmap
-    // for the wxRETAINED style. Implementing a backing store can't
-    // be entirely generic because it relies on the wxWindowDC implementation
-    // to duplicate X drawing calls for the backing pixmap.
-
-    if ( m_targetWindow->GetWindowStyle() & wxRETAINED )
-    {
-        Display* dpy = XtDisplay((Widget)m_targetWindow->GetMainWidget());
-
-        int totalPixelWidth = m_xScrollLines * m_xScrollPixelsPerLine;
-        int totalPixelHeight = m_yScrollLines * m_yScrollPixelsPerLine;
-        if (m_targetWindow->GetBackingPixmap() &&
-           !((m_targetWindow->GetPixmapWidth() == totalPixelWidth) &&
-             (m_targetWindow->GetPixmapHeight() == totalPixelHeight)))
-        {
-            XFreePixmap (dpy, (Pixmap) m_targetWindow->GetBackingPixmap());
-            m_targetWindow->SetBackingPixmap((WXPixmap) 0);
-        }
-
-        if (!m_targetWindow->GetBackingPixmap() &&
-           (m_xScrollLines != 0) && (m_yScrollLines != 0))
-        {
-            int depth = wxDisplayDepth();
-            m_targetWindow->SetPixmapWidth(totalPixelWidth);
-            m_targetWindow->SetPixmapHeight(totalPixelHeight);
-            m_targetWindow->SetBackingPixmap((WXPixmap) XCreatePixmap (dpy, RootWindow (dpy, DefaultScreen (dpy)),
-              m_targetWindow->GetPixmapWidth(), m_targetWindow->GetPixmapHeight(), depth));
-        }
-
-    }
-#endif // Motif
-
-    if (oldXScroll != m_xScrollPosition)
-    {
-       if (m_xScrollingEnabled)
-            m_targetWindow->ScrollWindow( m_xScrollPixelsPerLine * (oldXScroll - m_xScrollPosition), 0,
-                                          GetScrollRect() );
-       else
-            m_targetWindow->Refresh(true, GetScrollRect());
-    }
-
-    if (oldYScroll != m_yScrollPosition)
-    {
-        if (m_yScrollingEnabled)
-            m_targetWindow->ScrollWindow( 0, m_yScrollPixelsPerLine * (oldYScroll-m_yScrollPosition),
-                                          GetScrollRect() );
-        else
-            m_targetWindow->Refresh(true, GetScrollRect());
-    }
-}
-
-void wxScrollHelper::DoPrepareDC(wxDC& dc)