From e97276184dc260742cf34229395753caf12c43bb Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Mon, 13 Jun 2011 19:40:18 +1000 Subject: Added Identifier property. --- doc/ScintillaDoc.html | 27 +++++++++++++++++++-------- include/Scintilla.h | 2 ++ include/Scintilla.iface | 6 ++++++ src/Editor.cxx | 11 +++++++++++ src/Editor.h | 1 + win32/ScintillaWin.cxx | 45 ++++++++++++++++++++++++++++----------------- 6 files changed, 67 insertions(+), 25 deletions(-) diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index 8ed6dd9d1..8446cf895 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -79,7 +79,7 @@

Scintilla Documentation

-

Last edited 21/May/2011 NH

+

Last edited 13/June/2011 NH

There is an overview of the internal design of Scintilla.
@@ -5831,11 +5831,12 @@ struct SCNotification {

The following SCI_* messages are associated with these notifications:

- SCI_SETMODEVENTMASK(int - eventMask)
+ SCI_SETMODEVENTMASK(int eventMask)
SCI_GETMODEVENTMASK
- SCI_SETMOUSEDWELLTIME
+ SCI_SETMOUSEDWELLTIME(int milliseconds)
SCI_GETMOUSEDWELLTIME
+ SCI_SETIDENTIFIER(int identifier)
+ SCI_GETIDENTIFIER

The following additional notifications are sent using the WM_COMMAND message on @@ -5846,6 +5847,17 @@ struct SCNotification { SCEN_KILLFOCUS
+

SCI_SETIDENTIFIER(int identifier)
+ SCI_GETIDENTIFIER
+ These two messages set and get the identifier of the Scintilla instance which is included in notifications as the + ídFrom field. + When an application creates multiple Scintilla widgets, this allows the source of each notification to be found. + On Windows, this value is initialised in the CreateWindow call and stored as the + GWLP_ID attribute of the window. + The value should be small, preferrably less than 16 bits, + rather than a pointer as some of the functions will only transmit 16 or 32 bits. +

+

SCN_STYLENEEDED
If you used SCI_SETLEXER(SCLEX_CONTAINER) to make the container act as the @@ -6489,7 +6501,7 @@ for line = lineStart to lineEnd do SCI_ENSUREVISIBLE(line) next
-

SCI_SETMOUSEDWELLTIME
+

SCI_SETMOUSEDWELLTIME(int milliseconds)
SCI_GETMOUSEDWELLTIME
These two messages set and get the time the mouse must sit still, in milliseconds, to generate a SCN_DWELLSTART notification. If @@ -6582,9 +6594,8 @@ for line = lineStart to lineEnd do SCI_ENSUREVISIBLE(line) next

void scintilla_set_id(ScintillaObject *sci, uptr_t id)
Set the control ID which will be used in the idFrom field of the NotifyHeader structure of all - notifications for this instance. When an application creates multiple Scintilla widgets, this allows - the source of each notification to be found. The value should be small, preferrably less than 16 bits, - rather than a pointer as some of the functions will only transmit 16 or 32 bits.

+ notifications for this instance. + This is equivalent to SCI_SETIDENTIFIER.

sptr_t scintilla_send_message(ScintillaObject *sci,unsigned int iMessage, uptr_t wParam, sptr_t lParam)
The main entry point allows sending any of the messages described in this document.

diff --git a/include/Scintilla.h b/include/Scintilla.h index 8819b1b0c..d1f3c9dd2 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -807,6 +807,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_VERTICALCENTRECARET 2619 #define SCI_MOVESELECTEDLINESUP 2620 #define SCI_MOVESELECTEDLINESDOWN 2621 +#define SCI_SETIDENTIFIER 2622 +#define SCI_GETIDENTIFIER 2623 #define SCI_STARTRECORD 3001 #define SCI_STOPRECORD 3002 #define SCI_SETLEXER 4001 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index 773e29427..6bfac5d98 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -2143,6 +2143,12 @@ fun void MoveSelectedLinesUp=2620(,) # Move the selected lines down one line, shifting the line below before the selection fun void MoveSelectedLinesDown=2621(,) +# Set the identifier reported as idFrom in notification messages. +set void SetIdentifier=2622(int identifier,) + +# Get the identifier. +get int GetIdentifier=2623(,) + # Start notifying the container of all key presses and commands. fun void StartRecord=3001(,) diff --git a/src/Editor.cxx b/src/Editor.cxx index 160f94d7c..3f6e533b6 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -4303,6 +4303,10 @@ void Editor::DelCharBack(bool allowLineStartDeletion) { void Editor::NotifyFocus(bool) {} +void Editor::SetCtrlID(int identifier) { + ctrlID = identifier; +} + void Editor::NotifyStyleToNeeded(int endStyleNeeded) { SCNotification scn = {0}; scn.nmhdr.code = SCN_STYLENEEDED; @@ -9119,6 +9123,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_CHANGELEXERSTATE: pdoc->ChangeLexerState(wParam, lParam); break; + + case SCI_SETIDENTIFIER: + SetCtrlID(wParam); + break; + + case SCI_GETIDENTIFIER: + return GetCtrlID(); default: return DefWndProc(iMessage, wParam, lParam); diff --git a/src/Editor.h b/src/Editor.h index 48f4d1ccd..eccdb717f 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -422,6 +422,7 @@ protected: // ScintillaBase subclass needs access to much of Editor virtual void NotifyChange() = 0; virtual void NotifyFocus(bool focus); + virtual void SetCtrlID(int identifier); virtual int GetCtrlID() { return ctrlID; } virtual void NotifyParent(SCNotification scn) = 0; virtual void NotifyStyleToNeeded(int endStyleNeeded); diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index d4d3b24da..8092edcd8 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -102,6 +102,29 @@ const TCHAR callClassName[] = TEXT("CallTip"); using namespace Scintilla; #endif +// Take care of 32/64 bit pointers +#ifdef GetWindowLongPtr +static void *PointerFromWindow(HWND hWnd) { + return reinterpret_cast(::GetWindowLongPtr(hWnd, 0)); +} +static void SetWindowPointer(HWND hWnd, void *ptr) { + ::SetWindowLongPtr(hWnd, 0, reinterpret_cast(ptr)); +} +static void SetWindowID(HWND hWnd, int identifier) { + ::SetWindowLongPtr(hWnd, GWLP_ID, identifier); +} +#else +static void *PointerFromWindow(HWND hWnd) { + return reinterpret_cast(::GetWindowLong(hWnd, 0)); +} +static void SetWindowPointer(HWND hWnd, void *ptr) { + ::SetWindowLong(hWnd, 0, reinterpret_cast(ptr)); +} +static void SetWindowID(HWND hWnd, int identifier) { + ::SetWindowLong(hWnd, GWL_ID, identifier); +} +#endif + class ScintillaWin; // Forward declaration for COM interface subobjects typedef void VFunction(void); @@ -211,6 +234,7 @@ class ScintillaWin : virtual bool ModifyScrollBars(int nMax, int nPage); virtual void NotifyChange(); virtual void NotifyFocus(bool focus); + virtual void SetCtrlID(int identifier); virtual int GetCtrlID(); virtual void NotifyParent(SCNotification scn); virtual void NotifyDoubleClick(Point pt, bool shift, bool ctrl, bool alt); @@ -1278,6 +1302,10 @@ void ScintillaWin::NotifyFocus(bool focus) { reinterpret_cast(MainHWND())); } +void ScintillaWin::SetCtrlID(int identifier) { + ::SetWindowID(reinterpret_cast(wMain.GetID()), identifier); +} + int ScintillaWin::GetCtrlID() { return ::GetDlgCtrlID(reinterpret_cast(wMain.GetID())); } @@ -2628,23 +2656,6 @@ BOOL ScintillaWin::DestroySystemCaret() { return retval; } -// Take care of 32/64 bit pointers -#ifdef GetWindowLongPtr -static void *PointerFromWindow(HWND hWnd) { - return reinterpret_cast(::GetWindowLongPtr(hWnd, 0)); -} -static void SetWindowPointer(HWND hWnd, void *ptr) { - ::SetWindowLongPtr(hWnd, 0, reinterpret_cast(ptr)); -} -#else -static void *PointerFromWindow(HWND hWnd) { - return reinterpret_cast(::GetWindowLong(hWnd, 0)); -} -static void SetWindowPointer(HWND hWnd, void *ptr) { - ::SetWindowLong(hWnd, 0, reinterpret_cast(ptr)); -} -#endif - sptr_t PASCAL ScintillaWin::CTWndProc( HWND hWnd, UINT iMessage, WPARAM wParam, sptr_t lParam) { // Find C++ object associated with window. -- cgit v1.2.3