]> git.saurik.com Git - wxWidgets.git/blobdiff - src/stc/stc.cpp
Add utils and tests to OS/2 builds, #9587 from Dave Parsons.
[wxWidgets.git] / src / stc / stc.cpp
index 1b03a9725cd1054168cda2b53e13dfb940463441..bfa51d3001a173717f8a1a50d45808193f89bd2e 100644 (file)
@@ -197,6 +197,7 @@ bool wxStyledTextCtrl::Create(wxWindow *parent,
     m_swx = new ScintillaWX(this);
     m_stopWatch.Start();
     m_lastKeyDownConsumed = false;
+    m_lastWheelTimestamp = 0;
     m_vScrollBar = NULL;
     m_hScrollBar = NULL;
 #if wxUSE_UNICODE
@@ -356,7 +357,7 @@ wxMemoryBuffer wxStyledTextCtrl::GetStyledText(int startPos, int endPos) {
 }
 
 // Are there any redoable actions in the undo history?
-bool wxStyledTextCtrl::CanRedo()
+bool wxStyledTextCtrl::CanRedo() const
 {
     return SendMsg(2016, 0, 0) != 0;
 }
@@ -1580,7 +1581,7 @@ bool wxStyledTextCtrl::CanPaste()
 }
 
 // Are there any undoable actions in the undo history?
-bool wxStyledTextCtrl::CanUndo()
+bool wxStyledTextCtrl::CanUndo() const
 {
     return SendMsg(2174, 0, 0) != 0;
 }
@@ -1628,7 +1629,7 @@ void wxStyledTextCtrl::SetText(const wxString& text)
 }
 
 // Retrieve all the text in the document.
-wxString wxStyledTextCtrl::GetText() {
+wxString wxStyledTextCtrl::GetText() const {
          int len  = GetTextLength();
          wxMemoryBuffer mbuf(len+1);   // leave room for the null...
          char* buf = (char*)mbuf.GetWriteBuf(len+1);
@@ -3690,9 +3691,9 @@ void wxStyledTextCtrl::SetTextRaw(const char* text)
 
 wxCharBuffer wxStyledTextCtrl::GetTextRaw()
 {
-    int len  = GetTextLength();
-    wxCharBuffer buf(len);
-    SendMsg(SCI_GETTEXT, len, (long)buf.data());
+    int len = GetTextLength();
+    wxCharBuffer buf(len); // adds 1 for NUL automatically
+    SendMsg(SCI_GETTEXT, len + 1, (long)buf.data());
     return buf;
 }
 
@@ -3782,12 +3783,21 @@ void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) {
 }
 
 
-void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) {
-    m_swx->DoMouseWheel(evt.GetWheelRotation(),
-                        evt.GetWheelDelta(),
-                        evt.GetLinesPerAction(),
-                        evt.ControlDown(),
-                        evt.IsPageScroll());
+void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt)
+{
+    // prevent having an event queue with wheel events that cannot be processed
+    // reasonably fast (see ticket #9057)
+    if ( m_lastWheelTimestamp <= evt.GetTimestamp() )
+    {
+        m_lastWheelTimestamp = m_stopWatch.Time();
+        m_swx->DoMouseWheel(evt.GetWheelRotation(),
+                            evt.GetWheelDelta(),
+                            evt.GetLinesPerAction(),
+                            evt.ControlDown(),
+                            evt.IsPageScroll());
+        m_lastWheelTimestamp = m_stopWatch.Time() - m_lastWheelTimestamp;
+        m_lastWheelTimestamp += evt.GetTimestamp();
+    }
 }