From 0a3057b83c58ca7261d56167e134ef5c14e14e08 Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Sun, 3 Apr 2016 15:48:46 +0200 Subject: [PATCH] Add GetDirect{Function,Pointer}() methods to wxStyledTextCtrl These methods can be useful when working with dynamic lexers. Closes #17481. --- include/wx/stc/stc.h | 7 +++++++ interface/wx/stc/stc.h | 15 +++++++++++++++ src/stc/ScintillaWX.cpp | 10 ++++++++++ src/stc/ScintillaWX.h | 3 +++ src/stc/gen_iface.py | 15 +++++++++++++-- src/stc/stc.cpp | 11 +++++++++++ 6 files changed, 59 insertions(+), 2 deletions(-) diff --git a/include/wx/stc/stc.h b/include/wx/stc/stc.h index c0569b8f9b..1d9e5230e7 100644 --- a/include/wx/stc/stc.h +++ b/include/wx/stc/stc.h @@ -3525,6 +3525,13 @@ public: // Retrieve the number of characters in the document. int GetTextLength() const; + // Retrieve a pointer to a function that processes messages for this Scintilla. + void* GetDirectFunction() const; + + // Retrieve a pointer value to use as the first argument when calling + // the function returned by GetDirectFunction. + void* GetDirectPointer() const; + // Set to overtype (true) or insert mode. void SetOvertype(bool overtype); diff --git a/interface/wx/stc/stc.h b/interface/wx/stc/stc.h index a649508fb0..bfc63b2534 100644 --- a/interface/wx/stc/stc.h +++ b/interface/wx/stc/stc.h @@ -4019,6 +4019,21 @@ public: */ int GetTextLength() const; + /** + Retrieve a pointer to a function that processes messages for this Scintilla. + + @since 3.1.1 + */ + void* GetDirectFunction() const; + + /** + Retrieve a pointer value to use as the first argument when calling + the function returned by GetDirectFunction. + + @since 3.1.1 + */ + void* GetDirectPointer() const; + /** Set to overtype (true) or insert mode. */ diff --git a/src/stc/ScintillaWX.cpp b/src/stc/ScintillaWX.cpp index 52c7aa7882..aebf75b4f9 100644 --- a/src/stc/ScintillaWX.cpp +++ b/src/stc/ScintillaWX.cpp @@ -800,6 +800,11 @@ sptr_t ScintillaWX::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) LexerManager::GetInstance()->Load((const char*)lParam); break; #endif + case SCI_GETDIRECTFUNCTION: + return reinterpret_cast(DirectFunction); + + case SCI_GETDIRECTPOINTER: + return reinterpret_cast(this); default: return ScintillaBase::WndProc(iMessage, wParam, lParam); @@ -1246,6 +1251,11 @@ bool ScintillaWX::GetUseAntiAliasing() { return vs.extraFontFlag != 0; } +sptr_t ScintillaWX::DirectFunction( + ScintillaWX* swx, unsigned int iMessage, uptr_t wParam, sptr_t lParam) { + return swx->WndProc(iMessage, wParam, lParam); +} + //---------------------------------------------------------------------- //---------------------------------------------------------------------- diff --git a/src/stc/ScintillaWX.h b/src/stc/ScintillaWX.h index d8b885fba8..1afb3be108 100644 --- a/src/stc/ScintillaWX.h +++ b/src/stc/ScintillaWX.h @@ -210,6 +210,9 @@ private: bool HasCaretSizeChanged(); bool CreateSystemCaret(); bool DestroySystemCaret(); + + static sptr_t DirectFunction(ScintillaWX* swx, unsigned int iMessage, + uptr_t wParam, sptr_t lParam); #ifdef __WXMSW__ HBITMAP sysCaretBitmap; int sysCaretWidth; diff --git a/src/stc/gen_iface.py b/src/stc/gen_iface.py index 89130de3d7..adfc9193a6 100755 --- a/src/stc/gen_iface.py +++ b/src/stc/gen_iface.py @@ -591,8 +591,19 @@ methodOverrideMap = { ('Retrieve all the text in the document.', )), - 'GetDirectFunction' : (None, 0, 0, 0), - 'GetDirectPointer' : (None, 0, 0, 0), + 'GetDirectFunction' : + (0, + 'void* %s() const;', + '''void* %s() const { + return (void*)SendMsg(%s);''', + 0), + + 'GetDirectPointer' : + (0, + 'void* %s() const;', + '''void* %s() const { + return (void*)SendMsg(%s);''', + 0), 'GetTargetText' : (0, diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index 6d9c56b711..aba47e1891 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -1824,6 +1824,17 @@ int wxStyledTextCtrl::GetTextLength() const return SendMsg(SCI_GETTEXTLENGTH, 0, 0); } +// Retrieve a pointer to a function that processes messages for this Scintilla. +void* wxStyledTextCtrl::GetDirectFunction() const { + return (void*)SendMsg(SCI_GETDIRECTFUNCTION); +} + +// Retrieve a pointer value to use as the first argument when calling +// the function returned by GetDirectFunction. +void* wxStyledTextCtrl::GetDirectPointer() const { + return (void*)SendMsg(SCI_GETDIRECTPOINTER); +} + // Set to overtype (true) or insert mode. void wxStyledTextCtrl::SetOvertype(bool overtype) {