X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d1558f3d532c2e1c15e385d17c6200069f72714b..b6a20a20d010d643e52914f51aa0700df0da925f:/src/stc/ScintillaWX.cpp diff --git a/src/stc/ScintillaWX.cpp b/src/stc/ScintillaWX.cpp index f1ebd65117..f9da687f62 100644 --- a/src/stc/ScintillaWX.cpp +++ b/src/stc/ScintillaWX.cpp @@ -1,6 +1,6 @@ //////////////////////////////////////////////////////////////////////////// // Name: ScintillaWX.cxx -// Purpose: A wxWindows implementation of Scintilla. A class derived +// Purpose: A wxWidgets implementation of Scintilla. A class derived // from ScintillaBase that uses the "wx platform" defined in // PlatformWX.cxx This class is one end of a bridge between // the wx world and the Scintilla world. It needs a peer @@ -58,11 +58,6 @@ void wxSTCDropTarget::OnLeave() { #endif -#ifdef __WXGTK__ -#undef wxSTC_USE_POPUP -#define wxSTC_USE_POPUP 0 -#endif - #if wxUSE_POPUPWIN && wxSTC_USE_POPUP #include #define wxSTCCallTipBase wxPopupWindow @@ -72,6 +67,8 @@ void wxSTCDropTarget::OnLeave() { #define param2 -1 // wxWindow's 2nd param is ID #endif +#include + class wxSTCCallTip : public wxSTCCallTipBase { public: wxSTCCallTip(wxWindow* parent, CallTip* ct, ScintillaWX* swx) @@ -81,12 +78,17 @@ public: } ~wxSTCCallTip() { +#if wxUSE_POPUPWIN && wxSTC_USE_POPUP && defined(__WXGTK__) + wxRect rect = GetRect(); + GetParent()->ScreenToClient(&rect.x, &rect.y); + GetParent()->Refresh(false, &rect); +#endif } bool AcceptsFocus() const { return FALSE; } void OnPaint(wxPaintEvent& WXUNUSED(evt)) { - wxPaintDC dc(this); + wxBufferedPaintDC dc(this); Surface* surfaceWindow = Surface::Allocate(); surfaceWindow->Init(&dc, m_ct->wDraw.GetID()); m_ct->PaintCT(surfaceWindow); @@ -131,6 +133,33 @@ BEGIN_EVENT_TABLE(wxSTCCallTip, wxSTCCallTipBase) END_EVENT_TABLE() +//---------------------------------------------------------------------- + +static wxTextFileType wxConvertEOLMode(int scintillaMode) +{ + wxTextFileType type; + + switch (scintillaMode) { + case wxSTC_EOL_CRLF: + type = wxTextFileType_Dos; + break; + + case wxSTC_EOL_CR: + type = wxTextFileType_Mac; + break; + + case wxSTC_EOL_LF: + type = wxTextFileType_Unix; + break; + + default: + type = wxTextBuffer::typeDefault; + break; + } + return type; +} + + //---------------------------------------------------------------------- // Constructor/Destructor @@ -160,7 +189,11 @@ void ScintillaWX::Initialise() { dropTarget->SetScintilla(this); stc->SetDropTarget(dropTarget); #endif - vs.extraFontFlag = true; +#ifdef __WXMAC__ + vs.extraFontFlag = false; // UseAntiAliasing +#else + vs.extraFontFlag = true; // UseAntiAliasing +#endif } @@ -390,7 +423,9 @@ void ScintillaWX::Paste() { wxTheClipboard->Close(); } if (gotData) { - wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(data.GetText()); + wxString text = wxTextBuffer::Translate(data.GetText(), + wxConvertEOLMode(pdoc->eolMode)); + wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); int len = strlen(buf); pdoc->InsertString(currentPos, buf, len); SetEmptySelection(currentPos + len); @@ -543,14 +578,15 @@ void ScintillaWX::DoPaint(wxDC* dc, wxRect rect) { dc->BeginDrawing(); ClipChildren(*dc, rcPaint); Paint(surfaceWindow, rcPaint); - dc->EndDrawing(); delete surfaceWindow; if (paintState == paintAbandoned) { - // Painting area was insufficient to cover new styling or brace highlight positions - FullPaint(dc); + // Painting area was insufficient to cover new styling or brace + // highlight positions + FullPaint(); } paintState = notPainting; + dc->EndDrawing(); } @@ -684,7 +720,9 @@ void ScintillaWX::DoMiddleButtonUp(Point pt) { wxTheClipboard->Close(); } if (gotData) { - wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(data.GetText()); + wxString text = wxTextBuffer::Translate(data.GetText(), + wxConvertEOLMode(pdoc->eolMode)); + wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); int len = strlen(buf); pdoc->InsertString(currentPos, buf, len); SetEmptySelection(currentPos + len); @@ -810,6 +848,9 @@ void ScintillaWX::DoOnIdle(wxIdleEvent& evt) { bool ScintillaWX::DoDropText(long x, long y, const wxString& data) { SetDragPosition(invalidPosition); + wxString text = wxTextBuffer::Translate(data, + wxConvertEOLMode(pdoc->eolMode)); + // Send an event to allow the drag details to be changed wxStyledTextEvent evt(wxEVT_STC_DO_DROP, stc->GetId()); evt.SetEventObject(stc); @@ -817,7 +858,7 @@ bool ScintillaWX::DoDropText(long x, long y, const wxString& data) { evt.SetX(x); evt.SetY(y); evt.SetPosition(PositionFromLocation(Point(x,y))); - evt.SetDragText(data); + evt.SetDragText(text); stc->GetEventHandler()->ProcessEvent(evt); dragResult = evt.GetDragResult(); @@ -861,22 +902,10 @@ void ScintillaWX::DoDragLeave() { #endif //---------------------------------------------------------------------- -// Redraw all of text area. This paint will not be abandoned. -void ScintillaWX::FullPaint(wxDC *dc) { - wxCHECK_RET(dc != NULL, wxT("Invalid wxDC in ScintillaWX::FillPaint")); - paintState = painting; - rcPaint = GetClientRectangle(); - paintingAllText = true; - Surface* surfaceWindow = Surface::Allocate(); - surfaceWindow->Init(dc, wMain.GetID()); - - dc->BeginDrawing(); - ClipChildren(*dc, rcPaint); - Paint(surfaceWindow, rcPaint); - dc->EndDrawing(); - - delete surfaceWindow; - paintState = notPainting; +// Force the whole window to be repainted +void ScintillaWX::FullPaint() { + stc->Refresh(false); + stc->Update(); } @@ -897,7 +926,11 @@ void ScintillaWX::ClipChildren(wxDC& dc, PRectangle rect) { rgn.Subtract(childRect); } if (ct.inCallTipMode) { - wxRect childRect = ((wxWindow*)ct.wCallTip.GetID())->GetRect(); + wxWindow* tip = (wxWindow*)ct.wCallTip.GetID(); + wxRect childRect = tip->GetRect(); +#if wxUSE_POPUPWIN && wxSTC_USE_POPUP + tip->GetParent()->ScreenToClient(&childRect.x, &childRect.y); +#endif rgn.Subtract(childRect); }