X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/67879c5b4197a9ec278a24b44806b896d61982b4..69659fd770f615210efac4b4fa741b3ad6223616:/src/stc/ScintillaWX.cpp diff --git a/src/stc/ScintillaWX.cpp b/src/stc/ScintillaWX.cpp index 000db9a24b..76af113dd7 100644 --- a/src/stc/ScintillaWX.cpp +++ b/src/stc/ScintillaWX.cpp @@ -14,7 +14,21 @@ // Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// -#include "wx/wx.h" +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#if wxUSE_STC + +#ifndef WX_PRECOMP + #include "wx/scrolbar.h" + #include "wx/menu.h" + #include "wx/timer.h" +#endif // WX_PRECOMP + #include "wx/textbuf.h" #include "wx/dataobj.h" #include "wx/clipbrd.h" @@ -23,6 +37,7 @@ #include "ScintillaWX.h" #include "ExternalLexer.h" #include "wx/stc/stc.h" +#include "wx/stc/private.h" #include "PlatWX.h" #ifdef __WXMSW__ @@ -36,15 +51,15 @@ class wxSTCTimer : public wxTimer { public: wxSTCTimer(ScintillaWX* swx) { - this->swx = swx; + m_swx = swx; } void Notify() { - swx->DoTick(); + m_swx->DoTick(); } private: - ScintillaWX* swx; + ScintillaWX* m_swx; }; @@ -52,46 +67,47 @@ private: class wxStartDragTimer : public wxTimer { public: wxStartDragTimer(ScintillaWX* swx) { - this->swx = swx; + m_swx = swx; } void Notify() { - swx->DoStartDrag(); + m_swx->DoStartDrag(); } private: - ScintillaWX* swx; + ScintillaWX* m_swx; }; bool wxSTCDropTarget::OnDropText(wxCoord x, wxCoord y, const wxString& data) { - return swx->DoDropText(x, y, data); + return m_swx->DoDropText(x, y, data); } wxDragResult wxSTCDropTarget::OnEnter(wxCoord x, wxCoord y, wxDragResult def) { - return swx->DoDragEnter(x, y, def); + return m_swx->DoDragEnter(x, y, def); } wxDragResult wxSTCDropTarget::OnDragOver(wxCoord x, wxCoord y, wxDragResult def) { - return swx->DoDragOver(x, y, def); + return m_swx->DoDragOver(x, y, def); } void wxSTCDropTarget::OnLeave() { - swx->DoDragLeave(); + m_swx->DoDragLeave(); } #endif // wxUSE_DRAG_AND_DROP #if wxUSE_POPUPWIN && wxSTC_USE_POPUP -#include +#include "wx/popupwin.h" #define wxSTCCallTipBase wxPopupWindow #define param2 wxBORDER_NONE // popup's 2nd param is flags #else +#include "wx/frame.h" #define wxSTCCallTipBase wxFrame #define param2 -1 // wxWindow's 2nd param is ID #endif -#include +#include "wx/dcbuffer.h" class wxSTCCallTip : public wxSTCCallTipBase { public: @@ -508,8 +524,8 @@ void ScintillaWX::Paste() { wxTextDataObject data; bool gotData = false; + wxTheClipboard->UsePrimarySelection(false); if (wxTheClipboard->Open()) { - wxTheClipboard->UsePrimarySelection(false); gotData = wxTheClipboard->GetData(data); wxTheClipboard->Close(); } @@ -537,8 +553,8 @@ void ScintillaWX::Paste() { void ScintillaWX::CopyToClipboard(const SelectionText& st) { #if wxUSE_CLIPBOARD + wxTheClipboard->UsePrimarySelection(false); if (wxTheClipboard->Open()) { - wxTheClipboard->UsePrimarySelection(false); wxString text = wxTextBuffer::Translate(stc2wx(st.s, st.len-1)); wxTheClipboard->SetData(new wxTextDataObject(text)); wxTheClipboard->Close(); @@ -555,12 +571,12 @@ bool ScintillaWX::CanPaste() { bool didOpen; if (Editor::CanPaste()) { + wxTheClipboard->UsePrimarySelection(false); didOpen = !wxTheClipboard->IsOpened(); if ( didOpen ) wxTheClipboard->Open(); if (wxTheClipboard->IsOpened()) { - wxTheClipboard->UsePrimarySelection(false); canPaste = wxTheClipboard->IsSupported(wxUSE_UNICODE ? wxDF_UNICODETEXT : wxDF_TEXT); if (didOpen) wxTheClipboard->Close(); @@ -591,28 +607,24 @@ void ScintillaWX::AddToPopUp(const char *label, int cmd, bool enabled) { } -// This is called by the Editor base class whenever something is selected +// This is called by the Editor base class whenever something is selected. +// For wxGTK we can put this text in the primary selection and then other apps +// can paste with the middle button. void ScintillaWX::ClaimSelection() { -#if 0 - // Until wxGTK is able to support using both the primary selection and the - // clipboard at the same time I think it causes more problems than it is - // worth to implement this method. Selecting text should not clear the - // clipboard. --Robin #ifdef __WXGTK__ // Put the selected text in the PRIMARY selection if (currentPos != anchor) { SelectionText st; CopySelectionRange(&st); + wxTheClipboard->UsePrimarySelection(true); if (wxTheClipboard->Open()) { - wxTheClipboard->UsePrimarySelection(true); wxString text = stc2wx(st.s, st.len); wxTheClipboard->SetData(new wxTextDataObject(text)); - wxTheClipboard->UsePrimarySelection(false); wxTheClipboard->Close(); } + wxTheClipboard->UsePrimarySelection(false); } #endif -#endif } @@ -680,11 +692,11 @@ bool ScintillaWX::DestroySystemCaret() { //---------------------------------------------------------------------- -long ScintillaWX::DefWndProc(unsigned int /*iMessage*/, unsigned long /*wParam*/, long /*lParam*/) { +sptr_t ScintillaWX::DefWndProc(unsigned int /*iMessage*/, uptr_t /*wParam*/, sptr_t /*lParam*/) { return 0; } -long ScintillaWX::WndProc(unsigned int iMessage, unsigned long wParam, long lParam) { +sptr_t ScintillaWX::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { switch (iMessage) { case SCI_CALLTIPSHOW: { // NOTE: This is copied here from scintilla/src/ScintillaBase.cxx @@ -891,12 +903,12 @@ void ScintillaWX::DoMiddleButtonUp(Point pt) { pdoc->BeginUndoAction(); wxTextDataObject data; bool gotData = false; + wxTheClipboard->UsePrimarySelection(true); if (wxTheClipboard->Open()) { - wxTheClipboard->UsePrimarySelection(true); gotData = wxTheClipboard->GetData(data); - wxTheClipboard->UsePrimarySelection(false); wxTheClipboard->Close(); } + wxTheClipboard->UsePrimarySelection(false); if (gotData) { wxString text = wxTextBuffer::Translate(data.GetText(), wxConvertEOLMode(pdoc->eolMode)); @@ -1137,3 +1149,5 @@ bool ScintillaWX::GetUseAntiAliasing() { //---------------------------------------------------------------------- //---------------------------------------------------------------------- + +#endif // wxUSE_STC