Patch [ 1114647 ] Mouse wheel support for wxVScrolledWindow
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31729 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -163,6 +163,9 @@ protected:
|
|||||||
// the event handlers
|
// the event handlers
|
||||||
void OnSize(wxSizeEvent& event);
|
void OnSize(wxSizeEvent& event);
|
||||||
void OnScroll(wxScrollWinEvent& event);
|
void OnScroll(wxScrollWinEvent& event);
|
||||||
|
#if wxUSE_MOUSEWHEEL
|
||||||
|
void OnMouseWheel(wxMouseEvent& event);
|
||||||
|
#endif
|
||||||
|
|
||||||
// find the index of the line we need to show at the top of the window such
|
// find the index of the line we need to show at the top of the window such
|
||||||
// that the last (fully or partially) visible line is the given one
|
// that the last (fully or partially) visible line is the given one
|
||||||
@@ -193,6 +196,10 @@ private:
|
|||||||
// partly, visible one)
|
// partly, visible one)
|
||||||
size_t m_nVisible;
|
size_t m_nVisible;
|
||||||
|
|
||||||
|
// accumulated mouse wheel rotation
|
||||||
|
#if wxUSE_MOUSEWHEEL
|
||||||
|
int m_sumWheelRotation;
|
||||||
|
#endif
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
DECLARE_NO_COPY_CLASS(wxVScrolledWindow)
|
DECLARE_NO_COPY_CLASS(wxVScrolledWindow)
|
||||||
|
@@ -37,6 +37,9 @@
|
|||||||
BEGIN_EVENT_TABLE(wxVScrolledWindow, wxPanel)
|
BEGIN_EVENT_TABLE(wxVScrolledWindow, wxPanel)
|
||||||
EVT_SIZE(wxVScrolledWindow::OnSize)
|
EVT_SIZE(wxVScrolledWindow::OnSize)
|
||||||
EVT_SCROLLWIN(wxVScrolledWindow::OnScroll)
|
EVT_SCROLLWIN(wxVScrolledWindow::OnScroll)
|
||||||
|
#if wxUSE_MOUSEWHEEL
|
||||||
|
EVT_MOUSEWHEEL(wxVScrolledWindow::OnMouseWheel)
|
||||||
|
#endif
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
|
||||||
@@ -60,6 +63,10 @@ void wxVScrolledWindow::Init()
|
|||||||
m_nVisible = 1;
|
m_nVisible = 1;
|
||||||
|
|
||||||
m_heightTotal = 0;
|
m_heightTotal = 0;
|
||||||
|
|
||||||
|
#if wxUSE_MOUSEWHEEL
|
||||||
|
m_sumWheelRotation = 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -421,3 +428,25 @@ void wxVScrolledWindow::OnScroll(wxScrollWinEvent& event)
|
|||||||
#endif // __WXMAC__
|
#endif // __WXMAC__
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxUSE_MOUSEWHEEL
|
||||||
|
|
||||||
|
void wxVScrolledWindow::OnMouseWheel(wxMouseEvent& event)
|
||||||
|
{
|
||||||
|
m_sumWheelRotation += event.GetWheelRotation();
|
||||||
|
int delta = event.GetWheelDelta();
|
||||||
|
|
||||||
|
// how much to scroll this time
|
||||||
|
int units_to_scroll = -(m_sumWheelRotation/delta);
|
||||||
|
if ( !units_to_scroll )
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_sumWheelRotation += units_to_scroll*delta;
|
||||||
|
|
||||||
|
if ( !event.IsPageScroll() )
|
||||||
|
ScrollLines( units_to_scroll*event.GetLinesPerAction() );
|
||||||
|
else
|
||||||
|
// scroll pages instead of lines
|
||||||
|
ScrollPages( units_to_scroll );
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
Reference in New Issue
Block a user