Simplify and correct bugs in wxMSW wxScrollBar message handling.
For some reason we computed scroll increment from the native message and not the new position directly which is actually simpler and probably would have never resulted in a bug which exchanged the meanings of SB_TOP and SB_BOTTOM. Get rid of nScrollInc and just update the position variable directly. Closes #11741. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63587 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -119,7 +119,6 @@ bool wxScrollBar::MSWOnScroll(int WXUNUSED(orientation), WXWORD wParam,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int position = scrollInfo.nPos;
|
|
||||||
int maxPos = scrollInfo.nMax;
|
int maxPos = scrollInfo.nMax;
|
||||||
|
|
||||||
// A page size greater than one has the effect of reducing the effective
|
// A page size greater than one has the effect of reducing the effective
|
||||||
@@ -128,61 +127,54 @@ bool wxScrollBar::MSWOnScroll(int WXUNUSED(orientation), WXWORD wParam,
|
|||||||
if ( m_pageSize > 1 )
|
if ( m_pageSize > 1 )
|
||||||
maxPos -= (m_pageSize - 1);
|
maxPos -= (m_pageSize - 1);
|
||||||
|
|
||||||
|
int position = scrollInfo.nPos;
|
||||||
wxEventType scrollEvent = wxEVT_NULL;
|
wxEventType scrollEvent = wxEVT_NULL;
|
||||||
|
|
||||||
int nScrollInc;
|
|
||||||
switch ( wParam )
|
switch ( wParam )
|
||||||
{
|
{
|
||||||
case SB_TOP:
|
case SB_TOP:
|
||||||
nScrollInc = maxPos - position;
|
position = 0;
|
||||||
scrollEvent = wxEVT_SCROLL_TOP;
|
scrollEvent = wxEVT_SCROLL_TOP;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SB_BOTTOM:
|
case SB_BOTTOM:
|
||||||
nScrollInc = -position;
|
position = maxPos;
|
||||||
scrollEvent = wxEVT_SCROLL_BOTTOM;
|
scrollEvent = wxEVT_SCROLL_BOTTOM;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SB_LINEUP:
|
case SB_LINEUP:
|
||||||
nScrollInc = -1;
|
position--;
|
||||||
scrollEvent = wxEVT_SCROLL_LINEUP;
|
scrollEvent = wxEVT_SCROLL_LINEUP;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SB_LINEDOWN:
|
case SB_LINEDOWN:
|
||||||
nScrollInc = 1;
|
position++;
|
||||||
scrollEvent = wxEVT_SCROLL_LINEDOWN;
|
scrollEvent = wxEVT_SCROLL_LINEDOWN;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SB_PAGEUP:
|
case SB_PAGEUP:
|
||||||
nScrollInc = -GetPageSize();
|
position -= GetPageSize();
|
||||||
scrollEvent = wxEVT_SCROLL_PAGEUP;
|
scrollEvent = wxEVT_SCROLL_PAGEUP;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SB_PAGEDOWN:
|
case SB_PAGEDOWN:
|
||||||
nScrollInc = GetPageSize();
|
position += GetPageSize();
|
||||||
scrollEvent = wxEVT_SCROLL_PAGEDOWN;
|
scrollEvent = wxEVT_SCROLL_PAGEDOWN;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SB_THUMBPOSITION:
|
case SB_THUMBPOSITION:
|
||||||
case SB_THUMBTRACK:
|
case SB_THUMBTRACK:
|
||||||
nScrollInc = scrollInfo.nTrackPos - position;
|
position = scrollInfo.nTrackPos;
|
||||||
scrollEvent = wParam == SB_THUMBPOSITION ? wxEVT_SCROLL_THUMBRELEASE
|
scrollEvent = wParam == SB_THUMBPOSITION ? wxEVT_SCROLL_THUMBRELEASE
|
||||||
: wxEVT_SCROLL_THUMBTRACK;
|
: wxEVT_SCROLL_THUMBTRACK;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SB_ENDSCROLL:
|
case SB_ENDSCROLL:
|
||||||
nScrollInc = 0;
|
|
||||||
scrollEvent = wxEVT_SCROLL_CHANGED;
|
scrollEvent = wxEVT_SCROLL_CHANGED;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
|
||||||
nScrollInc = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( nScrollInc )
|
if ( position != scrollInfo.nPos )
|
||||||
{
|
{
|
||||||
position += nScrollInc;
|
|
||||||
|
|
||||||
if ( position < 0 )
|
if ( position < 0 )
|
||||||
position = 0;
|
position = 0;
|
||||||
if ( position > maxPos )
|
if ( position > maxPos )
|
||||||
|
Reference in New Issue
Block a user