1 // Scintilla source code edit control
2 /** @file CallTip.h
3  ** Interface to the call tip control.
4  **/
5 // Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
6 // The License.txt file describes the conditions under which this software may be distributed.
7 
8 #ifndef CALLTIP_H
9 #define CALLTIP_H
10 
11 namespace Scintilla {
12 
13 struct Chunk {
14 	size_t start;
15 	size_t end;
startChunk16 	constexpr Chunk(size_t start_=0, size_t end_=0) noexcept : start(start_), end(end_) {
17 		assert(start <= end);
18 	}
19 	size_t Length() const noexcept;
20 };
21 
22 /**
23  */
24 class CallTip {
25 	Chunk highlight;    // character offset to start and end of highlighted text
26 	std::string val;
27 	Font font;
28 	PRectangle rectUp;      // rectangle of last up angle in the tip
29 	PRectangle rectDown;    // rectangle of last down arrow in the tip
30 	int lineHeight;         // vertical line spacing
31 	int offsetMain;         // The alignment point of the call tip
32 	int tabSize;            // Tab size in pixels, <=0 no TAB expand
33 	bool useStyleCallTip;   // if true, STYLE_CALLTIP should be used
34 	bool above;		// if true, display calltip above text
35 
36 	int DrawChunk(Surface *surface, int x, std::string_view sv,
37 		int ytext, PRectangle rcClient, bool asHighlight, bool draw);
38 	int PaintContents(Surface *surfaceWindow, bool draw);
39 	bool IsTabCharacter(char ch) const noexcept;
40 	int NextTabPos(int x) const noexcept;
41 
42 public:
43 	Window wCallTip;
44 	Window wDraw;
45 	bool inCallTipMode;
46 	Sci::Position posStartCallTip;
47 	ColourDesired colourBG;
48 	ColourDesired colourUnSel;
49 	ColourDesired colourSel;
50 	ColourDesired colourShade;
51 	ColourDesired colourLight;
52 	int codePage;
53 	int clickPlace;
54 
55 	int insetX; // text inset in x from calltip border
56 	int widthArrow;
57 	int borderHeight;
58 	int verticalOffset; // pixel offset up or down of the calltip with respect to the line
59 
60 	CallTip() noexcept;
61 	// Deleted so CallTip objects can not be copied.
62 	CallTip(const CallTip &) = delete;
63 	CallTip(CallTip &&) = delete;
64 	CallTip &operator=(const CallTip &) = delete;
65 	CallTip &operator=(CallTip &&) = delete;
66 	~CallTip();
67 
68 	void PaintCT(Surface *surfaceWindow);
69 
70 	void MouseClick(Point pt) noexcept;
71 
72 	/// Setup the calltip and return a rectangle of the area required.
73 	PRectangle CallTipStart(Sci::Position pos, Point pt, int textHeight, const char *defn,
74 		const char *faceName, int size, int codePage_,
75 		int characterSet, int technology, const Window &wParent);
76 
77 	void CallTipCancel();
78 
79 	/// Set a range of characters to be displayed in a highlight style.
80 	/// Commonly used to highlight the current parameter.
81 	void SetHighlight(size_t start, size_t end);
82 
83 	/// Set the tab size in pixels for the call tip. 0 or -ve means no tab expand.
84 	void SetTabSize(int tabSz) noexcept;
85 
86 	/// Set calltip position.
87 	void SetPosition(bool aboveText) noexcept;
88 
89 	/// Used to determine which STYLE_xxxx to use for call tip information
90 	bool UseStyleCallTip() const noexcept;
91 
92 	// Modify foreground and background colours
93 	void SetForeBack(const ColourDesired &fore, const ColourDesired &back) noexcept;
94 };
95 
96 }
97 
98 #endif
99