]> git.saurik.com Git - wxWidgets.git/blobdiff - src/stc/stc.cpp
Allow --mac_universal_binary to use a "default" value.
[wxWidgets.git] / src / stc / stc.cpp
index e55e329d6f20a8758177c56ed1e2445787a0830d..15f1fcac53afa5b8d2cb45a58e16580efd3c70ac 100644 (file)
@@ -199,7 +199,6 @@ bool wxStyledTextCtrl::Create(wxWindow *parent,
     m_swx = new ScintillaWX(this);
     m_stopWatch.Start();
     m_lastKeyDownConsumed = false;
-    m_timeToBlockWheelEventsUntil = 0;
     m_vScrollBar = NULL;
     m_hScrollBar = NULL;
 #if wxUSE_UNICODE
@@ -258,7 +257,7 @@ void wxStyledTextCtrl::SetHScrollBar(wxScrollBar* bar)  {
 
 // Add text to the document at current position.
 void wxStyledTextCtrl::AddText(const wxString& text) {
-                    wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
+                    const wxWX2MBbuf buf = wx2stc(text);
                     SendMsg(2001, wx2stclen(text, buf), (sptr_t)(const char*)buf);
 }
 
@@ -1410,7 +1409,7 @@ int wxStyledTextCtrl::FindText(int minPos, int maxPos,
             TextToFind  ft;
             ft.chrg.cpMin = minPos;
             ft.chrg.cpMax = maxPos;
-            wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
+            const wxWX2MBbuf buf = wx2stc(text);
             ft.lpstrText = (char*)(const char*)buf;
 
             return SendMsg(2150, flags, (sptr_t)&ft);
@@ -1504,11 +1503,7 @@ bool wxStyledTextCtrl::GetModify() const
 
 // Retrieve the selected text.
 wxString wxStyledTextCtrl::GetSelectedText() {
-         long   start;
-         long   end;
-
-         GetSelection(&start, &end);
-         int   len  = end - start;
+         const int len = SendMsg(SCI_GETSELTEXT, 0, (sptr_t)0);
          if (!len) return wxEmptyString;
 
          wxMemoryBuffer mbuf(len+2);
@@ -1708,7 +1703,7 @@ int wxStyledTextCtrl::GetTargetEnd() const
 // Returns the length of the replacement text.
 
      int wxStyledTextCtrl::ReplaceTarget(const wxString& text) {
-         wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
+         const wxWX2MBbuf buf = wx2stc(text);
          return SendMsg(2194, wx2stclen(text, buf), (sptr_t)(const char*)buf);
 }
 
@@ -1720,7 +1715,7 @@ int wxStyledTextCtrl::GetTargetEnd() const
 // caused by processing the \d patterns.
 
      int wxStyledTextCtrl::ReplaceTargetRE(const wxString& text) {
-         wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
+         const wxWX2MBbuf buf = wx2stc(text);
          return SendMsg(2195, wx2stclen(text, buf), (sptr_t)(const char*)buf);
 }
 
@@ -1729,7 +1724,7 @@ int wxStyledTextCtrl::GetTargetEnd() const
 // Returns length of range or -1 for failure in which case target is not moved.
 
      int wxStyledTextCtrl::SearchInTarget(const wxString& text) {
-         wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
+         const wxWX2MBbuf buf = wx2stc(text);
          return SendMsg(2197, wx2stclen(text, buf), (sptr_t)(const char*)buf);
 }
 
@@ -2085,7 +2080,7 @@ bool wxStyledTextCtrl::GetUseVerticalScrollBar() const
 
 // Append a string to the end of the document without changing the selection.
 void wxStyledTextCtrl::AppendText(const wxString& text) {
-                    wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
+                    const wxWX2MBbuf buf = wx2stc(text);
                     SendMsg(2282, wx2stclen(text, buf), (sptr_t)(const char*)buf);
 }
 
@@ -4128,16 +4123,10 @@ wxCharBuffer wxStyledTextCtrl::GetLineRaw(int line)
 
 wxCharBuffer wxStyledTextCtrl::GetSelectedTextRaw()
 {
-    long   start;
-    long   end;
-
-    GetSelection(&start, &end);
-    int   len  = end - start;
-    if (!len) {
-        wxCharBuffer empty;
-        return empty;
-    }
+    // Calculate the length needed first.
+    const int len = SendMsg(SCI_GETSELTEXT, 0, (sptr_t)0);
 
+    // And then really get the data.
     wxCharBuffer buf(len);
     SendMsg(SCI_GETSELTEXT, 0, (sptr_t)buf.data());
     return buf;
@@ -4268,25 +4257,11 @@ void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) {
 
 void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt)
 {
-    // Prevent having an event queue with wheel events that cannot be processed
-    // reasonably fast (see ticket #9057) by ignoring all of them that happen
-    // during the time interval corresponding to the time it took us to handle
-    // the last one.
-    //
-    // Notice the use of TimeInMicro() instead of Time() to avoid overflow in
-    // long running programs.
-    if ( m_timeToBlockWheelEventsUntil <= m_stopWatch.TimeInMicro() )
-    {
-        const wxLongLong beforeMouseWheel = m_stopWatch.TimeInMicro();
-        m_swx->DoMouseWheel(evt.GetWheelRotation(),
-                            evt.GetWheelDelta(),
-                            evt.GetLinesPerAction(),
-                            evt.ControlDown(),
-                            evt.IsPageScroll());
-        const wxLongLong afterMouseWheel = m_stopWatch.TimeInMicro();
-        m_timeToBlockWheelEventsUntil = afterMouseWheel;
-        m_timeToBlockWheelEventsUntil += afterMouseWheel - beforeMouseWheel;
-    }
+    m_swx->DoMouseWheel(evt.GetWheelRotation(),
+                        evt.GetWheelDelta(),
+                        evt.GetLinesPerAction(),
+                        evt.ControlDown(),
+                        evt.IsPageScroll());
 }