Add GetDirect{Function,Pointer}() methods to wxStyledTextCtrl

These methods can be useful when working with dynamic lexers.

Closes #17481.
This commit is contained in:
New Pagodi
2016-04-03 15:48:46 +02:00
committed by Vadim Zeitlin
parent a6e249ea1a
commit 0a3057b83c
6 changed files with 59 additions and 2 deletions

View File

@@ -3525,6 +3525,13 @@ public:
// Retrieve the number of characters in the document. // Retrieve the number of characters in the document.
int GetTextLength() const; 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. // Set to overtype (true) or insert mode.
void SetOvertype(bool overtype); void SetOvertype(bool overtype);

View File

@@ -4019,6 +4019,21 @@ public:
*/ */
int GetTextLength() const; 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. Set to overtype (true) or insert mode.
*/ */

View File

@@ -800,6 +800,11 @@ sptr_t ScintillaWX::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam)
LexerManager::GetInstance()->Load((const char*)lParam); LexerManager::GetInstance()->Load((const char*)lParam);
break; break;
#endif #endif
case SCI_GETDIRECTFUNCTION:
return reinterpret_cast<sptr_t>(DirectFunction);
case SCI_GETDIRECTPOINTER:
return reinterpret_cast<sptr_t>(this);
default: default:
return ScintillaBase::WndProc(iMessage, wParam, lParam); return ScintillaBase::WndProc(iMessage, wParam, lParam);
@@ -1246,6 +1251,11 @@ bool ScintillaWX::GetUseAntiAliasing() {
return vs.extraFontFlag != 0; 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);
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@@ -210,6 +210,9 @@ private:
bool HasCaretSizeChanged(); bool HasCaretSizeChanged();
bool CreateSystemCaret(); bool CreateSystemCaret();
bool DestroySystemCaret(); bool DestroySystemCaret();
static sptr_t DirectFunction(ScintillaWX* swx, unsigned int iMessage,
uptr_t wParam, sptr_t lParam);
#ifdef __WXMSW__ #ifdef __WXMSW__
HBITMAP sysCaretBitmap; HBITMAP sysCaretBitmap;
int sysCaretWidth; int sysCaretWidth;

View File

@@ -591,8 +591,19 @@ methodOverrideMap = {
('Retrieve all the text in the document.', )), ('Retrieve all the text in the document.', )),
'GetDirectFunction' : (None, 0, 0, 0), 'GetDirectFunction' :
'GetDirectPointer' : (None, 0, 0, 0), (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' : 'GetTargetText' :
(0, (0,

View File

@@ -1824,6 +1824,17 @@ int wxStyledTextCtrl::GetTextLength() const
return SendMsg(SCI_GETTEXTLENGTH, 0, 0); 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. // Set to overtype (true) or insert mode.
void wxStyledTextCtrl::SetOvertype(bool overtype) void wxStyledTextCtrl::SetOvertype(bool overtype)
{ {