]> 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 c91d46eb49abcedb5695a6cb447b645beaa35844..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;
 }
@@ -393,7 +394,7 @@ void wxStyledTextCtrl::SetViewWhiteSpace(int viewWS)
 }
 
 // Find the position from a point within the window.
-int wxStyledTextCtrl::PositionFromPoint(wxPoint pt) {
+int wxStyledTextCtrl::PositionFromPoint(wxPoint pt) const {
         return SendMsg(2022, pt.x, pt.y);
 }
 
@@ -1439,7 +1440,7 @@ int wxStyledTextCtrl::GetFirstVisibleLine() const
 }
 
 // Retrieve the contents of a line.
-wxString wxStyledTextCtrl::GetLine(int line) {
+wxString wxStyledTextCtrl::GetLine(int line) const {
          int len = LineLength(line);
          if (!len) return wxEmptyString;
 
@@ -1538,13 +1539,13 @@ void wxStyledTextCtrl::HideSelection(bool normal)
 }
 
 // Retrieve the line containing a position.
-int wxStyledTextCtrl::LineFromPosition(int pos)
+int wxStyledTextCtrl::LineFromPosition(int pos) const
 {
     return SendMsg(2166, pos, 0);
 }
 
 // Retrieve the position at the start of a line.
-int wxStyledTextCtrl::PositionFromLine(int line)
+int wxStyledTextCtrl::PositionFromLine(int line) const
 {
     return SendMsg(2167, line, 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);
@@ -2464,7 +2465,7 @@ void wxStyledTextCtrl::MoveCaretInsideView()
 }
 
 // How many characters are on a line, not including end of line characters?
-int wxStyledTextCtrl::LineLength(int line)
+int wxStyledTextCtrl::LineLength(int line) const
 {
     return SendMsg(2350, line, 0);
 }
@@ -3513,7 +3514,11 @@ void wxStyledTextCtrl::ScrollToColumn(int column) {
 }
 
 
+#if wxUSE_TEXTCTRL
+bool wxStyledTextCtrl::DoSaveFile(const wxString& filename, int WXUNUSED(fileType))
+#else
 bool wxStyledTextCtrl::SaveFile(const wxString& filename)
+#endif
 {
     wxFile file(filename, wxFile::write);
 
@@ -3528,7 +3533,11 @@ bool wxStyledTextCtrl::SaveFile(const wxString& filename)
     return success;
 }
 
+#if wxUSE_TEXTCTRL
+bool wxStyledTextCtrl::DoLoadFile(const wxString& filename, int WXUNUSED(fileType))
+#else
 bool wxStyledTextCtrl::LoadFile(const wxString& filename)
+#endif
 {
     bool success = false;
     wxFile file(filename, wxFile::read);
@@ -3682,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;
 }
 
@@ -3774,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();
+    }
 }