X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1e545382cad98c65c608aa91622e37257aff1425..d66c3960d541cf9e3ba10519a49a9e34b4ddfc81:/contrib/src/stc/ScintillaWX.cpp diff --git a/contrib/src/stc/ScintillaWX.cpp b/contrib/src/stc/ScintillaWX.cpp index 73fd2d1f75..a324274b7c 100644 --- a/contrib/src/stc/ScintillaWX.cpp +++ b/contrib/src/stc/ScintillaWX.cpp @@ -19,6 +19,7 @@ #include "ExternalLexer.h" #include "wx/stc/stc.h" #include "PlatWX.h" +#include //---------------------------------------------------------------------- // Helper classes @@ -136,6 +137,7 @@ END_EVENT_TABLE() ScintillaWX::ScintillaWX(wxStyledTextCtrl* win) { capturedMouse = false; + focusEvent = false; wMain = win; stc = win; wheelRotation = 0; @@ -144,7 +146,7 @@ ScintillaWX::ScintillaWX(wxStyledTextCtrl* win) { ScintillaWX::~ScintillaWX() { - SetTicking(false); + Finalise(); } //---------------------------------------------------------------------- @@ -163,6 +165,8 @@ void ScintillaWX::Initialise() { void ScintillaWX::Finalise() { ScintillaBase::Finalise(); + SetTicking(false); + SetIdle(false); } @@ -197,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) { @@ -217,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; + } } @@ -333,6 +352,18 @@ void ScintillaWX::NotifyParent(SCNotification scn) { } +// This method is overloaded from ScintillaBase in order to prevent the +// AutoComplete window from being destroyed when it gets the focus. There is +// a side effect that the AutoComp will also not be destroyed when switching +// to another window, but I think that is okay. +void ScintillaWX::CancelModes() { + if (! focusEvent) + AutoCompleteCancel(); + ct.CallTipCancel(); + Editor::CancelModes(); +} + + void ScintillaWX::Copy() { if (currentPos != anchor) { @@ -371,7 +402,7 @@ void ScintillaWX::Paste() { void ScintillaWX::CopyToClipboard(const SelectionText& st) { if (wxTheClipboard->Open()) { wxTheClipboard->UsePrimarySelection(FALSE); - wxString text = stc2wx(st.s, st.len); + wxString text = wxTextBuffer::Translate(stc2wx(st.s, st.len)); wxTheClipboard->SetData(new wxTextDataObject(text)); wxTheClipboard->Close(); } @@ -514,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; } @@ -606,11 +637,15 @@ void ScintillaWX::DoSize(int WXUNUSED(width), int WXUNUSED(height)) { } void ScintillaWX::DoLoseFocus(){ + focusEvent = true; SetFocusState(false); + focusEvent = false; } void ScintillaWX::DoGainFocus(){ + focusEvent = true; SetFocusState(true); + focusEvent = false; } void ScintillaWX::DoSysColourChange() { @@ -634,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; @@ -757,6 +792,15 @@ void ScintillaWX::DoOnListBox() { AutoCompleteCompleted(); } + +void ScintillaWX::DoOnIdle(wxIdleEvent& evt) { + + if ( Idle() ) + evt.RequestMore(); + else + SetIdle(false); +} + //---------------------------------------------------------------------- #if wxUSE_DRAG_AND_DROP @@ -815,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;