]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/vscroll.cpp
compile fix
[wxWidgets.git] / src / generic / vscroll.cpp
index ad0951f3a7dfc87908ff27611356247e57d5ffe3..d8d57b6e97f46986d00bdef1bc229bdb4a5f1d4b 100644 (file)
@@ -37,6 +37,9 @@
 BEGIN_EVENT_TABLE(wxVScrolledWindow, wxPanel)
     EVT_SIZE(wxVScrolledWindow::OnSize)
     EVT_SCROLLWIN(wxVScrolledWindow::OnScroll)
+#if wxUSE_MOUSEWHEEL
+    EVT_MOUSEWHEEL(wxVScrolledWindow::OnMouseWheel)
+#endif
 END_EVENT_TABLE()
 
 
@@ -60,6 +63,10 @@ void wxVScrolledWindow::Init()
     m_nVisible = 1;
 
     m_heightTotal = 0;
+
+#if wxUSE_MOUSEWHEEL
+    m_sumWheelRotation = 0;
+#endif
 }
 
 // ----------------------------------------------------------------------------
@@ -407,7 +414,7 @@ void wxVScrolledWindow::OnScroll(wxScrollWinEvent& event)
     {
         lineFirstNew = event.GetPosition();
     }
-        
+
     else // unknown scroll event?
     {
         wxFAIL_MSG( _T("unknown scroll event type?") );
@@ -421,3 +428,25 @@ void wxVScrolledWindow::OnScroll(wxScrollWinEvent& event)
 #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