xref: /MusicPlayer2/scintilla/src/ScintillaBase.h (revision ec0490a72e915b8aa451edfc87be3aa2eecbe491)
1 // Scintilla source code edit control
2 /** @file ScintillaBase.h
3  ** Defines an enhanced subclass of Editor with calltips, autocomplete and context menu.
4  **/
5 // Copyright 1998-2002 by Neil Hodgson <[email protected]>
6 // The License.txt file describes the conditions under which this software may be distributed.
7 
8 #ifndef SCINTILLABASE_H
9 #define SCINTILLABASE_H
10 
11 #include <windows.h>
12 #include <tchar.h>
13 
14 namespace Scintilla {
15 
16 class LexState;
17 /**
18  */
19 class ScintillaBase : public Editor, IListBoxDelegate {
20 protected:
21 	/** Enumeration of commands and child windows. */
22 	enum {
23 		idCallTip=1,
24 		idAutoComplete=2,
25 
26 		idcmdUndo=10,
27 		idcmdRedo=11,
28 		idcmdCut=12,
29 		idcmdCopy=13,
30 		idcmdPaste=14,
31 		idcmdDelete=15,
32 		idcmdSelectAll=16
33 	};
34 
35 	int displayPopupMenu;
36 	Menu popup;
37 	AutoComplete ac;
38 
39 	CallTip ct;
40 
41 	int listType;			///< 0 is an autocomplete list
42 	int maxListWidth;		/// Maximum width of list, in average character widths
43 	int multiAutoCMode; /// Mode for autocompleting when multiple selections are present
44 
45 	LexState *DocumentLexState();
46 	void SetLexer(uptr_t wParam);
47 	void SetLexerLanguage(const char *languageName);
48 	void Colourise(int start, int end);
49 
50 	ScintillaBase();
51 	// Deleted so ScintillaBase objects can not be copied.
52 	ScintillaBase(const ScintillaBase &) = delete;
53 	ScintillaBase(ScintillaBase &&) = delete;
54 	ScintillaBase &operator=(const ScintillaBase &) = delete;
55 	ScintillaBase &operator=(ScintillaBase &&) = delete;
56 	// ~ScintillaBase() in public section
57 	void Initialise() override {}
58 	void Finalise() override;
59 
60 	[[deprecated]]
61 	// This method is deprecated, use InsertCharacter instead. The treatAsDBCS parameter is no longer used.
62 	virtual void AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS=false);
63 
64 	void InsertCharacter(std::string_view sv, CharacterSource charSource) override;
65 	void Command(int cmdId);
66 	void CancelModes() override;
67 	int KeyCommand(unsigned int iMessage) override;
68 
69 	void AutoCompleteInsert(Sci::Position startPos, Sci::Position removeLen, const char *text, Sci::Position textLen);
70 	void AutoCompleteStart(Sci::Position lenEntered, const char *list);
71 	void AutoCompleteCancel();
72 	void AutoCompleteMove(int delta);
73 	int AutoCompleteGetCurrent() const;
74 	int AutoCompleteGetCurrentText(char *buffer) const;
75 	void AutoCompleteCharacterAdded(char ch);
76 	void AutoCompleteCharacterDeleted();
77 	void AutoCompleteCompleted(char ch, unsigned int completionMethod);
78 	void AutoCompleteMoveToCurrentWord();
79 	void AutoCompleteSelection();
80 	void ListNotify(ListBoxEvent *plbe) override;
81 
82 	void CallTipClick();
83 	void CallTipShow(Point pt, const char *defn);
84 	virtual void CreateCallTipWindow(PRectangle rc) = 0;
85 
86 	virtual void AddToPopUp(LPCTSTR label, int cmd=0, bool enabled=true) = 0;
87 	bool ShouldDisplayPopup(Point ptInWindowCoordinates) const;
88 	void ContextMenu(Point pt);
89 
90 	void ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers) override;
91 	void RightButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers) override;
92 
93 	void NotifyStyleToNeeded(Sci::Position endStyleNeeded) override;
94 	void NotifyLexerChanged(Document *doc, void *userData) override;
95 
96 public:
97 	~ScintillaBase() override;
98 
99 	// Public so scintilla_send_message can use it
100 	sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) override;
101 };
102 
103 }
104 
105 #endif
106