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
11namespace Scintilla::Internal {
12
13struct Chunk {
14 size_t start;
15 size_t end;
16 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 */
24class CallTip {
25 Chunk highlight; // character offset to start and end of highlighted text
26 std::string val;
27 std::shared_ptr<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, StyleCallTip 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
42public:
43 Window wCallTip;
44 Window wDraw;
45 bool inCallTipMode;
46 Sci::Position posStartCallTip;
47 ColourRGBA colourBG;
48 ColourRGBA colourUnSel;
49 ColourRGBA colourSel;
50 ColourRGBA colourShade;
51 ColourRGBA 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 Scintilla::CharacterSet characterSet, Scintilla::Technology technology, const char *localeName,
76 const Window &wParent);
77
78 void CallTipCancel() noexcept;
79
80 /// Set a range of characters to be displayed in a highlight style.
81 /// Commonly used to highlight the current parameter.
82 void SetHighlight(size_t start, size_t end);
83
84 /// Set the tab size in pixels for the call tip. 0 or -ve means no tab expand.
85 void SetTabSize(int tabSz) noexcept;
86
87 /// Set calltip position.
88 void SetPosition(bool aboveText) noexcept;
89
90 /// Used to determine which STYLE_xxxx to use for call tip information
91 bool UseStyleCallTip() const noexcept;
92
93 // Modify foreground and background colours
94 void SetForeBack(const ColourRGBA &fore, const ColourRGBA &back) noexcept;
95};
96
97}
98
99#endif
100