// Modified by: Ron Lee
// Created: 01/02/97
// RCS-ID: $Id$
-// Copyright: (c) Julian Smart and Markus Holzem
-// Licence: wxWindows license
+// Copyright: (c) Julian Smart
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// ============================================================================
// headers
// ----------------------------------------------------------------------------
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "scrolwin.h"
#endif
int noUnitsX, int noUnitsY,
int xPos, int yPos, bool noRefresh )
{
- int old_x = m_xScrollPixelsPerLine * m_xScrollPosition;
- int old_y = m_yScrollPixelsPerLine * m_yScrollPosition;
+ int xs, ys;
+ GetViewStart (& xs, & ys);
+
+ int old_x = m_xScrollPixelsPerLine * xs;
+ int old_y = m_yScrollPixelsPerLine * ys;
m_xScrollPixelsPerLine = pixelsPerUnitX;
m_yScrollPixelsPerLine = pixelsPerUnitY;
m_targetWindow = target;
}
-wxWindow *wxScrolledWindow::GetTargetWindow()
+wxWindow *wxScrolledWindow::GetTargetWindow() const
{
return m_targetWindow;
}
void wxScrolledWindow::DoCalcScrolledPosition(int x, int y, int *xx, int *yy) const
{
+ int xs, ys;
+ GetViewStart (& xs, & ys);
+
if ( xx )
- *xx = x - m_xScrollPosition * m_xScrollPixelsPerLine;
+ *xx = x - xs * m_xScrollPixelsPerLine;
if ( yy )
- *yy = y - m_yScrollPosition * m_yScrollPixelsPerLine;
+ *yy = y - ys * m_yScrollPixelsPerLine;
}
void wxScrolledWindow::DoCalcUnscrolledPosition(int x, int y, int *xx, int *yy) const
{
+ int xs, ys;
+ GetViewStart (& xs, & ys);
+
if ( xx )
- *xx = x + m_xScrollPosition * m_xScrollPixelsPerLine;
+ *xx = x + xs * m_xScrollPixelsPerLine;
if ( yy )
- *yy = y + m_yScrollPosition * m_yScrollPixelsPerLine;
+ *yy = y + ys * m_yScrollPixelsPerLine;
}
int wxScrolledWindow::CalcScrollInc(wxScrollWinEvent& event)
// Default OnSize resets scrollbars, if any
void wxScrolledWindow::OnSize(wxSizeEvent& WXUNUSED(event))
{
- if( GetAutoLayout() )
+ if( GetAutoLayout() || m_targetWindow->GetAutoLayout() )
{
if( m_targetWindow != this )
m_targetWindow->FitInside();
FitInside();
+
+ // FIXME: Something is really weird here... This should be
+ // called by FitInside above (and apparently is), yet the
+ // scrollsub sample will get the scrollbar wrong if resized
+ // quickly. This masks the bug, but is surely not the right
+ // answer at all.
+ AdjustScrollbars();
}
else
{