]> git.saurik.com Git - wxWidgets.git/blobdiff - contrib/src/stc/ScintillaWX.cpp
conditional compilation for compositing
[wxWidgets.git] / contrib / src / stc / ScintillaWX.cpp
index 1fbbf77860047cb87b1aa6d0a99405639151981b..a324274b7c25b73516e3a9f62ce786879ca4eade 100644 (file)
@@ -146,7 +146,7 @@ ScintillaWX::ScintillaWX(wxStyledTextCtrl* win) {
 
 
 ScintillaWX::~ScintillaWX() {
-    SetTicking(false);
+    Finalise();
 }
 
 //----------------------------------------------------------------------
@@ -165,6 +165,8 @@ void ScintillaWX::Initialise() {
 
 void ScintillaWX::Finalise() {
     ScintillaBase::Finalise();
+    SetTicking(false);
+    SetIdle(false);
 }
 
 
@@ -199,6 +201,19 @@ void ScintillaWX::StartDrag() {
 }
 
 
+bool ScintillaWX::SetIdle(bool on) {
+    if (idler.state != on) {
+        // connect or disconnect the EVT_IDLE handler
+        if (on) 
+            stc->Connect(-1, wxEVT_IDLE, (wxObjectEventFunction)&wxStyledTextCtrl::OnIdle);
+        else
+            stc->Disconnect(-1, wxEVT_IDLE, (wxObjectEventFunction)&wxStyledTextCtrl::OnIdle);
+        idler.state = on;
+    }
+    return idler.state;
+}
+
+    
 void ScintillaWX::SetTicking(bool on) {
     wxSTCTimer* steTimer;
     if (timer.ticking != on) {
@@ -219,11 +234,13 @@ void ScintillaWX::SetTicking(bool on) {
 
 
 void ScintillaWX::SetMouseCapture(bool on) {
-    if (on && !capturedMouse)
-        stc->CaptureMouse();
-    else if (!on && capturedMouse && stc->HasCapture())
-        stc->ReleaseMouse();
-    capturedMouse = on;
+    if (mouseDownCaptures) {
+        if (on && !capturedMouse)
+            stc->CaptureMouse();
+        else if (!on && capturedMouse && stc->HasCapture())
+            stc->ReleaseMouse();
+        capturedMouse = on;
+    }
 }
 
 
@@ -528,7 +545,7 @@ void ScintillaWX::DoPaint(wxDC* dc, wxRect rect) {
     delete surfaceWindow;
     if (paintState == paintAbandoned) {
         // Painting area was insufficient to cover new styling or brace highlight positions
-        FullPaint();
+        FullPaint(dc);
     }
     paintState = notPainting;
 }
@@ -652,7 +669,7 @@ void ScintillaWX::DoMiddleButtonUp(Point pt) {
     // Set the current position to the mouse click point and
     // then paste in the PRIMARY selection, if any.  wxGTK only.
     int newPos = PositionFromLocation(pt);
-    MovePositionTo(newPos, 0, 1);
+    MovePositionTo(newPos, noSel, true);
 
     pdoc->BeginUndoAction();
     wxTextDataObject data;
@@ -775,6 +792,15 @@ void ScintillaWX::DoOnListBox() {
     AutoCompleteCompleted();
 }
 
+void ScintillaWX::DoOnIdle(wxIdleEvent& evt) {
+
+    if ( Idle() )
+        evt.RequestMore();
+    else
+        SetIdle(false);
+}
 //----------------------------------------------------------------------
 
 #if wxUSE_DRAG_AND_DROP
@@ -833,18 +859,18 @@ void ScintillaWX::DoDragLeave() {
 //----------------------------------------------------------------------
 
 // Redraw all of text area. This paint will not be abandoned.
-void ScintillaWX::FullPaint() {
+void ScintillaWX::FullPaint(wxDC *dc) {
+    wxCHECK_RET(dc != NULL, wxT("Invalid wxDC in ScintillaWX::FillPaint"));
     paintState = painting;
     rcPaint = GetClientRectangle();
     paintingAllText = true;
-    wxClientDC dc(stc);
     Surface* surfaceWindow = Surface::Allocate();
-    surfaceWindow->Init(&dc, wMain.GetID());
+    surfaceWindow->Init(dc, wMain.GetID());
 
-    dc.BeginDrawing();
-    ClipChildren(dc, rcPaint);
+    dc->BeginDrawing();
+    ClipChildren(*dc, rcPaint);
     Paint(surfaceWindow, rcPaint);
-    dc.EndDrawing();
+    dc->EndDrawing();
 
     delete surfaceWindow;
     paintState = notPainting;