]> git.saurik.com Git - wxWidgets.git/commitdiff
Added MouseWheel support to wxSTC
authorRobin Dunn <robin@alldunn.com>
Sun, 6 May 2001 01:20:41 +0000 (01:20 +0000)
committerRobin Dunn <robin@alldunn.com>
Sun, 6 May 2001 01:20:41 +0000 (01:20 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10013 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

14 files changed:
contrib/include/wx/stc/stc.h
contrib/src/stc/ScintillaWX.cpp
contrib/src/stc/ScintillaWX.h
contrib/src/stc/gen_iface.py
contrib/src/stc/stc.cpp
contrib/src/stc/stc.cpp.in
contrib/src/stc/stc.h.in
include/wx/stc/stc.h
src/stc/ScintillaWX.cpp
src/stc/ScintillaWX.h
src/stc/gen_iface.py
src/stc/stc.cpp
src/stc/stc.cpp.in
src/stc/stc.h.in

index e2ec7c4b957ac886db669086c7d01ce3bf7e604e..f9b26bdb8ac3ca535fc29cfff40ab3956313865a 100644 (file)
@@ -1256,6 +1256,7 @@ private:
     void OnMouseMove(wxMouseEvent& evt);
     void OnMouseLeftUp(wxMouseEvent& evt);
     void OnMouseRightUp(wxMouseEvent& evt);
+    void OnMouseWheel(wxMouseEvent& evt);
     void OnChar(wxKeyEvent& evt);
     void OnKeyDown(wxKeyEvent& evt);
     void OnLoseFocus(wxFocusEvent& evt);
index e652082bb95b0e2060cffdfa146bf50562ed8d36..30a896b9038e23101c679210c62bbc41d09b5269 100644 (file)
@@ -95,6 +95,7 @@ ScintillaWX::ScintillaWX(wxStyledTextCtrl* win) {
     wMain = win;
     wDraw = win;
     stc   = win;
+    wheelRotation = 0;
     Initialise();
 }
 
@@ -363,6 +364,22 @@ void ScintillaWX::DoVScroll(int type, int pos) {
     ScrollTo(topLineNew);
 }
 
+
+void ScintillaWX::DoMouseWheel(int rotation, int delta, int linesPerAction) {
+    int topLineNew = topLine;
+    int lines;
+
+    wheelRotation += rotation;
+    lines = wheelRotation / delta;
+    wheelRotation -= lines * delta;
+    if (lines != 0) {
+        lines *= linesPerAction;
+        topLineNew -= lines;
+        ScrollTo(topLineNew);
+    }
+}
+
+
 void ScintillaWX::DoSize(int width, int height) {
     PRectangle rcClient(0,0,width,height);
     SetScrollBarsTo(rcClient);
index b773eac3a98db80780692c09b20451055f87ab09..fdd4f98dbdf3e8d6e882fcc208c75d22ed06436c 100644 (file)
@@ -119,6 +119,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);
     void DoAddChar(char ch);
     int  DoKeyDown(int key, bool shift, bool ctrl, bool alt);
     void DoTick() { Tick(); }
@@ -146,6 +147,7 @@ private:
 
     wxSTCDropTarget*    dropTarget;
     wxDragResult        dragResult;
+    int                 wheelRotation;
 };
 
 //----------------------------------------------------------------------
index 8348993acc898df07d47b88986f3378e65481adf..6798593426e25d97e7818f572a3a690b890aa3eb 100644 (file)
@@ -19,14 +19,14 @@ from fileinput import FileInput
 IFACE         = './scintilla/include/Scintilla.iface'
 H_TEMPLATE    = './stc.h.in'
 CPP_TEMPLATE  = './stc.cpp.in'
-H_DEST        = '../../include/wx/stc/stc.h' # './stc_test.h' #
-CPP_DEST      = './stc.cpp' #'./stc_test.cpp'
+H_DEST        = '../../include/wx/stc/stc.h'
+CPP_DEST      = './stc.cpp'
 
 
 # Value prefixes to convert
 valPrefixes = [('SCI_', ''),
                ('SC_',  ''),
-               ('SCN_', None),  # just toss these...
+               ('SCN_', None),  # just toss these out...
                ('SCEN_', None),
                ('SCE_', ''),
                ('SCLEX_', 'LEX_'),
index 9b46ce051069833e91ebe03f588da337baa6a9d4..8a96ed76dfe6958cdb3baa80e63bc746eb5294b7 100644 (file)
@@ -91,6 +91,7 @@ BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
     EVT_MOTION                  (wxStyledTextCtrl::OnMouseMove)
     EVT_LEFT_UP                 (wxStyledTextCtrl::OnMouseLeftUp)
     EVT_RIGHT_UP                (wxStyledTextCtrl::OnMouseRightUp)
+    EVT_MOUSEWHEEL              (wxStyledTextCtrl::OnMouseWheel)
     EVT_CHAR                    (wxStyledTextCtrl::OnChar)
     EVT_KEY_DOWN                (wxStyledTextCtrl::OnKeyDown)
     EVT_KILL_FOCUS              (wxStyledTextCtrl::OnLoseFocus)
@@ -1556,6 +1557,14 @@ void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) {
     m_swx->DoContextMenu(Point(pt.x, pt.y));
 }
 
+
+void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) {
+    m_swx->DoMouseWheel(evt.GetWheelRotation(),
+                        evt.GetWheelDelta(),
+                        evt.GetLinesPerAction());
+}
+
+
 void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
     long key = evt.KeyCode();
     if ((key > WXK_ESCAPE) &&
index 13a2f1f49abbc9155735cbb84896d02d5dbcdd21..b2a778bb31ffe1512471ef18486a700696372f32 100644 (file)
@@ -91,6 +91,7 @@ BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
     EVT_MOTION                  (wxStyledTextCtrl::OnMouseMove)
     EVT_LEFT_UP                 (wxStyledTextCtrl::OnMouseLeftUp)
     EVT_RIGHT_UP                (wxStyledTextCtrl::OnMouseRightUp)
+    EVT_MOUSEWHEEL              (wxStyledTextCtrl::OnMouseWheel)
     EVT_CHAR                    (wxStyledTextCtrl::OnChar)
     EVT_KEY_DOWN                (wxStyledTextCtrl::OnKeyDown)
     EVT_KILL_FOCUS              (wxStyledTextCtrl::OnLoseFocus)
@@ -350,6 +351,14 @@ void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) {
     m_swx->DoContextMenu(Point(pt.x, pt.y));
 }
 
+
+void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) {
+    m_swx->DoMouseWheel(evt.GetWheelRotation(),
+                        evt.GetWheelDelta(),
+                        evt.GetLinesPerAction());
+}
+
+
 void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
     long key = evt.KeyCode();
     if ((key > WXK_ESCAPE) &&
index 36c25c2bf2a4a9b215b40ec5c5a246ba028df3b9..bab374459a231a9680a379ac03b03c5371aac593 100644 (file)
@@ -154,6 +154,7 @@ private:
     void OnMouseMove(wxMouseEvent& evt);
     void OnMouseLeftUp(wxMouseEvent& evt);
     void OnMouseRightUp(wxMouseEvent& evt);
+    void OnMouseWheel(wxMouseEvent& evt);
     void OnChar(wxKeyEvent& evt);
     void OnKeyDown(wxKeyEvent& evt);
     void OnLoseFocus(wxFocusEvent& evt);
index e2ec7c4b957ac886db669086c7d01ce3bf7e604e..f9b26bdb8ac3ca535fc29cfff40ab3956313865a 100644 (file)
@@ -1256,6 +1256,7 @@ private:
     void OnMouseMove(wxMouseEvent& evt);
     void OnMouseLeftUp(wxMouseEvent& evt);
     void OnMouseRightUp(wxMouseEvent& evt);
+    void OnMouseWheel(wxMouseEvent& evt);
     void OnChar(wxKeyEvent& evt);
     void OnKeyDown(wxKeyEvent& evt);
     void OnLoseFocus(wxFocusEvent& evt);
index e652082bb95b0e2060cffdfa146bf50562ed8d36..30a896b9038e23101c679210c62bbc41d09b5269 100644 (file)
@@ -95,6 +95,7 @@ ScintillaWX::ScintillaWX(wxStyledTextCtrl* win) {
     wMain = win;
     wDraw = win;
     stc   = win;
+    wheelRotation = 0;
     Initialise();
 }
 
@@ -363,6 +364,22 @@ void ScintillaWX::DoVScroll(int type, int pos) {
     ScrollTo(topLineNew);
 }
 
+
+void ScintillaWX::DoMouseWheel(int rotation, int delta, int linesPerAction) {
+    int topLineNew = topLine;
+    int lines;
+
+    wheelRotation += rotation;
+    lines = wheelRotation / delta;
+    wheelRotation -= lines * delta;
+    if (lines != 0) {
+        lines *= linesPerAction;
+        topLineNew -= lines;
+        ScrollTo(topLineNew);
+    }
+}
+
+
 void ScintillaWX::DoSize(int width, int height) {
     PRectangle rcClient(0,0,width,height);
     SetScrollBarsTo(rcClient);
index b773eac3a98db80780692c09b20451055f87ab09..fdd4f98dbdf3e8d6e882fcc208c75d22ed06436c 100644 (file)
@@ -119,6 +119,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);
     void DoAddChar(char ch);
     int  DoKeyDown(int key, bool shift, bool ctrl, bool alt);
     void DoTick() { Tick(); }
@@ -146,6 +147,7 @@ private:
 
     wxSTCDropTarget*    dropTarget;
     wxDragResult        dragResult;
+    int                 wheelRotation;
 };
 
 //----------------------------------------------------------------------
index 8348993acc898df07d47b88986f3378e65481adf..6798593426e25d97e7818f572a3a690b890aa3eb 100644 (file)
@@ -19,14 +19,14 @@ from fileinput import FileInput
 IFACE         = './scintilla/include/Scintilla.iface'
 H_TEMPLATE    = './stc.h.in'
 CPP_TEMPLATE  = './stc.cpp.in'
-H_DEST        = '../../include/wx/stc/stc.h' # './stc_test.h' #
-CPP_DEST      = './stc.cpp' #'./stc_test.cpp'
+H_DEST        = '../../include/wx/stc/stc.h'
+CPP_DEST      = './stc.cpp'
 
 
 # Value prefixes to convert
 valPrefixes = [('SCI_', ''),
                ('SC_',  ''),
-               ('SCN_', None),  # just toss these...
+               ('SCN_', None),  # just toss these out...
                ('SCEN_', None),
                ('SCE_', ''),
                ('SCLEX_', 'LEX_'),
index 9b46ce051069833e91ebe03f588da337baa6a9d4..8a96ed76dfe6958cdb3baa80e63bc746eb5294b7 100644 (file)
@@ -91,6 +91,7 @@ BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
     EVT_MOTION                  (wxStyledTextCtrl::OnMouseMove)
     EVT_LEFT_UP                 (wxStyledTextCtrl::OnMouseLeftUp)
     EVT_RIGHT_UP                (wxStyledTextCtrl::OnMouseRightUp)
+    EVT_MOUSEWHEEL              (wxStyledTextCtrl::OnMouseWheel)
     EVT_CHAR                    (wxStyledTextCtrl::OnChar)
     EVT_KEY_DOWN                (wxStyledTextCtrl::OnKeyDown)
     EVT_KILL_FOCUS              (wxStyledTextCtrl::OnLoseFocus)
@@ -1556,6 +1557,14 @@ void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) {
     m_swx->DoContextMenu(Point(pt.x, pt.y));
 }
 
+
+void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) {
+    m_swx->DoMouseWheel(evt.GetWheelRotation(),
+                        evt.GetWheelDelta(),
+                        evt.GetLinesPerAction());
+}
+
+
 void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
     long key = evt.KeyCode();
     if ((key > WXK_ESCAPE) &&
index 13a2f1f49abbc9155735cbb84896d02d5dbcdd21..b2a778bb31ffe1512471ef18486a700696372f32 100644 (file)
@@ -91,6 +91,7 @@ BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
     EVT_MOTION                  (wxStyledTextCtrl::OnMouseMove)
     EVT_LEFT_UP                 (wxStyledTextCtrl::OnMouseLeftUp)
     EVT_RIGHT_UP                (wxStyledTextCtrl::OnMouseRightUp)
+    EVT_MOUSEWHEEL              (wxStyledTextCtrl::OnMouseWheel)
     EVT_CHAR                    (wxStyledTextCtrl::OnChar)
     EVT_KEY_DOWN                (wxStyledTextCtrl::OnKeyDown)
     EVT_KILL_FOCUS              (wxStyledTextCtrl::OnLoseFocus)
@@ -350,6 +351,14 @@ void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) {
     m_swx->DoContextMenu(Point(pt.x, pt.y));
 }
 
+
+void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) {
+    m_swx->DoMouseWheel(evt.GetWheelRotation(),
+                        evt.GetWheelDelta(),
+                        evt.GetLinesPerAction());
+}
+
+
 void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
     long key = evt.KeyCode();
     if ((key > WXK_ESCAPE) &&
index 36c25c2bf2a4a9b215b40ec5c5a246ba028df3b9..bab374459a231a9680a379ac03b03c5371aac593 100644 (file)
@@ -154,6 +154,7 @@ private:
     void OnMouseMove(wxMouseEvent& evt);
     void OnMouseLeftUp(wxMouseEvent& evt);
     void OnMouseRightUp(wxMouseEvent& evt);
+    void OnMouseWheel(wxMouseEvent& evt);
     void OnChar(wxKeyEvent& evt);
     void OnKeyDown(wxKeyEvent& evt);
     void OnLoseFocus(wxFocusEvent& evt);