Fix incorrect scroll positions used in SetScrollbars().

SetScrollbars() passed its input positions expressed in scroll units to
CalcUnscrolledPosition() which takes positions in pixels. This was definitely
wrong so don't do this and perform the conversion from scroll units to pixels
in SetScrollbars() itself for clarity instead.

It's not clear what concrete bugs, if any, does this fix as the calculated
positions are almost never used anyhow but the old code was obviously
incorrect and the new version has a chance of not being wrong so it's already
an improvement.

Closes #9988.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70443 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-01-23 11:28:12 +00:00
parent 8ca4b822b9
commit 7fa7e46b26

View File

@@ -385,16 +385,17 @@ void wxScrollHelperBase::SetScrollbars(int pixelsPerUnitX,
int yPos, int yPos,
bool noRefresh) bool noRefresh)
{ {
int xpos, ypos; // Convert positions expressed in scroll units to positions in pixels.
int xPosInPixels = (xPos + m_xScrollPosition)*m_xScrollPixelsPerLine,
yPosInPixels = (yPos + m_yScrollPosition)*m_yScrollPixelsPerLine;
CalcUnscrolledPosition(xPos, yPos, &xpos, &ypos);
bool do_refresh = bool do_refresh =
( (
(noUnitsX != 0 && m_xScrollLines == 0) || (noUnitsX != 0 && m_xScrollLines == 0) ||
(noUnitsX < m_xScrollLines && xpos > pixelsPerUnitX * noUnitsX) || (noUnitsX < m_xScrollLines && xPosInPixels > pixelsPerUnitX * noUnitsX) ||
(noUnitsY != 0 && m_yScrollLines == 0) || (noUnitsY != 0 && m_yScrollLines == 0) ||
(noUnitsY < m_yScrollLines && ypos > pixelsPerUnitY * noUnitsY) || (noUnitsY < m_yScrollLines && yPosInPixels > pixelsPerUnitY * noUnitsY) ||
(xPos != m_xScrollPosition) || (xPos != m_xScrollPosition) ||
(yPos != m_yScrollPosition) (yPos != m_yScrollPosition)
); );