]> git.saurik.com Git - wxWidgets.git/commitdiff
Moved the check for page scrolling with the wheel into wxMouseEvent so
authorRobin Dunn <robin@alldunn.com>
Fri, 19 Jul 2002 21:11:31 +0000 (21:11 +0000)
committerRobin Dunn <robin@alldunn.com>
Fri, 19 Jul 2002 21:11:31 +0000 (21:11 +0000)
it wouldn't have to be duplicated everywhere.

Also fixed wxSTC so it can handle wheel page scrolling too.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16218 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

contrib/src/stc/ScintillaWX.cpp
contrib/src/stc/ScintillaWX.h
contrib/src/stc/stc.cpp
contrib/src/stc/stc.cpp.in
docs/latex/wx/mouseevt.tex
include/wx/event.h
src/generic/scrlwing.cpp
src/stc/ScintillaWX.cpp
src/stc/ScintillaWX.h
src/stc/stc.cpp
src/stc/stc.cpp.in

index 50bfac2f18b2b53a92956a4946ea0e883c52459c..10859100d6bd296dd46329734e0a115fa9e7520a 100644 (file)
@@ -467,8 +467,9 @@ void ScintillaWX::DoVScroll(int type, int pos) {
     ScrollTo(topLineNew);
 }
 
-
-void ScintillaWX::DoMouseWheel(int rotation, int delta, int linesPerAction, int ctrlDown) {
+void ScintillaWX::DoMouseWheel(int rotation, int delta,
+                               int linesPerAction, int ctrlDown,
+                               bool isPageScroll ) {
     int topLineNew = topLine;
     int lines;
 
@@ -485,7 +486,10 @@ void ScintillaWX::DoMouseWheel(int rotation, int delta, int linesPerAction, int
         lines = wheelRotation / delta;
         wheelRotation -= lines * delta;
         if (lines != 0) {
-            lines *= linesPerAction;
+            if (isPageScroll)
+                lines = lines * LinesOnScreen();  // lines is either +1 or -1
+            else
+                lines *= linesPerAction;
             topLineNew -= lines;
             ScrollTo(topLineNew);
         }
index 3174e9efc3894434456245ad2ad47c053ad6ce38..5f879119520145958e92eb5393da82149dca4929 100644 (file)
@@ -125,7 +125,7 @@ public:
     void DoButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
     void DoButtonUp(Point pt, unsigned int curTime, bool ctrl);
     void DoButtonMove(Point pt);
-    void DoMouseWheel(int rotation, int delta, int linesPerAction, int ctrlDown);
+    void DoMouseWheel(int rotation, int delta, int linesPerAction, int ctrlDown, bool isPageScroll);
     void DoAddChar(int key);
     int  DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool* consumed);
     void DoTick() { Tick(); }
index 0a8ccd6bc172c0b2728d88ff4edde912e183a59d..e44ed9856feacf1cc5c033f4d43feff9824e096e 100644 (file)
@@ -1912,7 +1912,8 @@ void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) {
     m_swx->DoMouseWheel(evt.GetWheelRotation(),
                         evt.GetWheelDelta(),
                         evt.GetLinesPerAction(),
-                        evt.ControlDown());
+                        evt.ControlDown(),
+                        evt.IsPageScroll());
 }
 
 
index fd17cb2e76aca0818efab9abd975aa1f2f1198c8..9e3083e7d2bee7bfd9dc8d0b493a94a453f9e306 100644 (file)
@@ -365,7 +365,8 @@ void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) {
     m_swx->DoMouseWheel(evt.GetWheelRotation(),
                         evt.GetWheelDelta(),
                         evt.GetLinesPerAction(),
-                        evt.ControlDown());
+                        evt.ControlDown(),
+                        evt.IsPageScroll());
 }
 
 
index 6cb90ed0ff64514eda379d457f58e9d61ccc26e4..a26d2b4c76174e098e052a9c44112fa28942978c 100644 (file)
@@ -14,15 +14,15 @@ drawbacks: the LEAVE\_WINDOW event might be received some time after the mouse
 left the window and the state variables for it may have changed during this
 time.
 
-{\bf NB:} Note the difference between methods like 
-\helpref{LeftDown}{wxmouseeventleftdown} and 
-\helpref{LeftIsDown}{wxmouseeventleftisdown}: the format returns {\tt TRUE} 
+{\bf NB:} Note the difference between methods like
+\helpref{LeftDown}{wxmouseeventleftdown} and
+\helpref{LeftIsDown}{wxmouseeventleftisdown}: the format returns {\tt TRUE}
 when the event corresponds to the left mouse button click while the latter
 returns {\tt TRUE} if the left mouse button is currently being pressed. For
-example, when the user is dragging the mouse you can use 
+example, when the user is dragging the mouse you can use
 \helpref{LeftIsDown}{wxmouseeventleftisdown} to test
 whether the left mouse button is (still) depressed. Also, by convention, if
-\helpref{LeftDown}{wxmouseeventleftdown} returns {\tt TRUE}, 
+\helpref{LeftDown}{wxmouseeventleftdown} returns {\tt TRUE},
 \helpref{LeftIsDown}{wxmouseeventleftisdown} will also return {\tt TRUE} in
 wxWindows whatever the underlying GUI behaviour is (which is
 platform-dependent). The same applies, of course, to other mouse buttons as
@@ -291,6 +291,13 @@ Returns Y coordinate of the physical mouse event position.
 Returns TRUE if the event was a mouse button event (not necessarily a button down event -
 that may be tested using {\it ButtonDown}).
 
+\membersection{wxMouseEvent::IsPageScroll}
+
+\constfunc{bool}{IsPageScroll}{\void}
+
+Returns TRUE if the system has been setup to do page scrolling with
+the mouse wheel instead of line scrolling.
+
 \membersection{wxMouseEvent::Leaving}\label{wxmouseeventleaving}
 
 \constfunc{bool}{Leaving}{\void}
index c5d9a283b743dc473367f5b7264c287aeb9c0996..2c80ffb20746b938c4f6eccd421a2e023e4dc882 100644 (file)
@@ -741,6 +741,9 @@ public:
     // wheel action.  Defaults to one.
     int GetLinesPerAction() const { return m_linesPerAction; }
 
+    // Is the system set to do page scrolling?
+    bool IsPageScroll() const { return m_linesPerAction == UINT_MAX; }
+
     virtual wxEvent *Clone() const { return new wxMouseEvent(*this); }
 
 public:
@@ -1492,7 +1495,7 @@ public:
         m_checked =
         m_enabled =
         m_setEnabled =
-        m_setText = 
+        m_setText =
         m_setChecked = FALSE;
     }
     wxUpdateUIEvent(const wxUpdateUIEvent & event)
index 489db5bbf7a3332983442a1b8bf38540f9a230ea..ae4107a1fa280217d3f7aad0c9bd3f188bd16e80 100644 (file)
@@ -1084,10 +1084,6 @@ void wxScrollHelper::HandleOnMouseLeave(wxMouseEvent& event)
 
 #if wxUSE_MOUSEWHEEL
 
-#ifndef  WHEEL_PAGESCROLL
-#define WHEEL_PAGESCROLL  (UINT_MAX)   // signifies to scroll a page
-#endif
-
 void wxScrollHelper::HandleOnMouseWheel(wxMouseEvent& event)
 {
     m_wheelRotation += event.GetWheelRotation();
@@ -1103,7 +1099,7 @@ void wxScrollHelper::HandleOnMouseWheel(wxMouseEvent& event)
         newEvent.SetOrientation(wxVERTICAL);
         newEvent.m_eventObject = m_win;
 
-        if (event.GetLinesPerAction() == WHEEL_PAGESCROLL)
+        if (event.IsPageScroll())
         {
             if (lines > 0)
                 newEvent.m_eventType = wxEVT_SCROLLWIN_PAGEUP;
index 50bfac2f18b2b53a92956a4946ea0e883c52459c..10859100d6bd296dd46329734e0a115fa9e7520a 100644 (file)
@@ -467,8 +467,9 @@ void ScintillaWX::DoVScroll(int type, int pos) {
     ScrollTo(topLineNew);
 }
 
-
-void ScintillaWX::DoMouseWheel(int rotation, int delta, int linesPerAction, int ctrlDown) {
+void ScintillaWX::DoMouseWheel(int rotation, int delta,
+                               int linesPerAction, int ctrlDown,
+                               bool isPageScroll ) {
     int topLineNew = topLine;
     int lines;
 
@@ -485,7 +486,10 @@ void ScintillaWX::DoMouseWheel(int rotation, int delta, int linesPerAction, int
         lines = wheelRotation / delta;
         wheelRotation -= lines * delta;
         if (lines != 0) {
-            lines *= linesPerAction;
+            if (isPageScroll)
+                lines = lines * LinesOnScreen();  // lines is either +1 or -1
+            else
+                lines *= linesPerAction;
             topLineNew -= lines;
             ScrollTo(topLineNew);
         }
index 3174e9efc3894434456245ad2ad47c053ad6ce38..5f879119520145958e92eb5393da82149dca4929 100644 (file)
@@ -125,7 +125,7 @@ public:
     void DoButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
     void DoButtonUp(Point pt, unsigned int curTime, bool ctrl);
     void DoButtonMove(Point pt);
-    void DoMouseWheel(int rotation, int delta, int linesPerAction, int ctrlDown);
+    void DoMouseWheel(int rotation, int delta, int linesPerAction, int ctrlDown, bool isPageScroll);
     void DoAddChar(int key);
     int  DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool* consumed);
     void DoTick() { Tick(); }
index 0a8ccd6bc172c0b2728d88ff4edde912e183a59d..e44ed9856feacf1cc5c033f4d43feff9824e096e 100644 (file)
@@ -1912,7 +1912,8 @@ void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) {
     m_swx->DoMouseWheel(evt.GetWheelRotation(),
                         evt.GetWheelDelta(),
                         evt.GetLinesPerAction(),
-                        evt.ControlDown());
+                        evt.ControlDown(),
+                        evt.IsPageScroll());
 }
 
 
index fd17cb2e76aca0818efab9abd975aa1f2f1198c8..9e3083e7d2bee7bfd9dc8d0b493a94a453f9e306 100644 (file)
@@ -365,7 +365,8 @@ void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) {
     m_swx->DoMouseWheel(evt.GetWheelRotation(),
                         evt.GetWheelDelta(),
                         evt.GetLinesPerAction(),
-                        evt.ControlDown());
+                        evt.ControlDown(),
+                        evt.IsPageScroll());
 }