- if (m_yScrollLines > 0)
- {
- int nMaxHeight = m_yScrollLines*m_yScrollPixelsPerLine;
- int newRange = (int) ( ((nMaxHeight)/(float)m_yScrollPixelsPerLine) + 0.5 );
- if (newRange < 0)
- newRange = 0;
-
- m_yScrollPosition = wxMin(newRange, m_yScrollPosition);
-
- // Calculate page size i.e. number of scroll units you get on the
- // current client window
- int noPagePositions = (int) ( (h/(float)m_yScrollPixelsPerLine) + 0.5 );
- if (noPagePositions < 1)
- noPagePositions = 1;
-
- SetScrollbar(wxVERTICAL, m_yScrollPosition, noPagePositions, newRange);
- SetScrollPageSize(wxVERTICAL, noPagePositions);
- }
- else
- {
- m_yScrollPosition = 0;
- SetScrollbar (wxVERTICAL, 0, 0, 0, FALSE); // Robert Roebling
- }
-
+ int oldXScroll = m_xScrollPosition;
+ int oldYScroll = m_yScrollPosition;
+
+ if (m_xScrollLines > 0)
+ {
+ // Calculate page size i.e. number of scroll units you get on the
+ // current client window
+ int noPagePositions = (int) ( (w/(double)m_xScrollPixelsPerLine) + 0.5 );
+ if (noPagePositions < 1) noPagePositions = 1;
+
+ // Correct position if greater than extent of canvas minus
+ // the visible portion of it or if below zero
+ m_xScrollPosition = wxMin( m_xScrollLines-noPagePositions, m_xScrollPosition);
+ m_xScrollPosition = wxMax( 0, m_xScrollPosition );
+
+ SetScrollbar(wxHORIZONTAL, m_xScrollPosition, noPagePositions, m_xScrollLines);
+ // The amount by which we scroll when paging
+ SetScrollPageSize(wxHORIZONTAL, noPagePositions);
+ }
+ else
+ {
+ m_xScrollPosition = 0;
+ SetScrollbar (wxHORIZONTAL, 0, 0, 0, FALSE);
+ }
+
+ if (m_yScrollLines > 0)
+ {
+ // Calculate page size i.e. number of scroll units you get on the
+ // current client window
+ int noPagePositions = (int) ( (h/(double)m_yScrollPixelsPerLine) + 0.5 );
+ if (noPagePositions < 1) noPagePositions = 1;
+
+ // Correct position if greater than extent of canvas minus
+ // the visible portion of it or if below zero
+ m_yScrollPosition = wxMin( m_yScrollLines-noPagePositions, m_yScrollPosition );
+ m_yScrollPosition = wxMax( 0, m_yScrollPosition );
+
+ SetScrollbar(wxVERTICAL, m_yScrollPosition, noPagePositions, m_yScrollLines);
+ // The amount by which we scroll when paging
+ SetScrollPageSize(wxVERTICAL, noPagePositions);
+ }
+ else
+ {
+ m_yScrollPosition = 0;
+ SetScrollbar (wxVERTICAL, 0, 0, 0, FALSE);
+ }
+
+ if (oldXScroll != m_xScrollPosition)
+ {
+ if (m_xScrollingEnabled)
+ m_targetWindow->ScrollWindow( m_xScrollPixelsPerLine * (oldXScroll-m_xScrollPosition), 0, (const wxRect *) NULL );
+ else
+ m_targetWindow->Refresh();
+ }
+
+ if (oldYScroll != m_yScrollPosition)
+ {
+ if (m_yScrollingEnabled)
+ m_targetWindow->ScrollWindow( 0, m_yScrollPixelsPerLine * (oldYScroll-m_yScrollPosition), (const wxRect *) NULL );
+ else
+ m_targetWindow->Refresh();
+ }