Scintilla 4.0.3
[TortoiseGit.git] / ext / scintilla / src / ViewStyle.h
blob7565c84578425163679ecb135131fde0a57eb04c
1 // Scintilla source code edit control
2 /** @file ViewStyle.h
3 ** Store information on how the document is to be viewed.
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.
8 #ifndef VIEWSTYLE_H
9 #define VIEWSTYLE_H
11 namespace Scintilla {
13 /**
15 class MarginStyle {
16 public:
17 int style;
18 ColourDesired back;
19 int width;
20 int mask;
21 bool sensitive;
22 int cursor;
23 MarginStyle(int style_= SC_MARGIN_SYMBOL, int width_=0, int mask_=0);
26 /**
28 class FontNames {
29 private:
30 std::vector<UniqueString> names;
31 public:
32 FontNames();
33 // FontNames objects can not be copied.
34 FontNames(const FontNames &) = delete;
35 FontNames &operator=(const FontNames &) = delete;
36 ~FontNames();
37 void Clear();
38 const char *Save(const char *name);
41 class FontRealised : public FontMeasurements {
42 public:
43 Font font;
44 FontRealised();
45 // FontRealised objects can not be copied.
46 FontRealised(const FontRealised &) = delete;
47 FontRealised &operator=(const FontRealised &) = delete;
48 virtual ~FontRealised();
49 void Realise(Surface &surface, int zoomLevel, int technology, const FontSpecification &fs);
52 enum IndentView {ivNone, ivReal, ivLookForward, ivLookBoth};
54 enum WhiteSpaceVisibility {wsInvisible=0, wsVisibleAlways=1, wsVisibleAfterIndent=2, wsVisibleOnlyInIndent=3};
56 enum TabDrawMode {tdLongArrow=0, tdStrikeOut=1};
58 typedef std::map<FontSpecification, std::unique_ptr<FontRealised>> FontMap;
60 enum WrapMode { eWrapNone, eWrapWord, eWrapChar, eWrapWhitespace };
62 class ColourOptional : public ColourDesired {
63 public:
64 bool isSet;
65 ColourOptional(ColourDesired colour_=ColourDesired(0,0,0), bool isSet_=false) : ColourDesired(colour_), isSet(isSet_) {
67 ColourOptional(uptr_t wParam, sptr_t lParam) : ColourDesired(static_cast<long>(lParam)), isSet(wParam != 0) {
71 struct ForeBackColours {
72 ColourOptional fore;
73 ColourOptional back;
76 struct EdgeProperties {
77 int column;
78 ColourDesired colour;
79 EdgeProperties(int column_ = 0, ColourDesired colour_ = ColourDesired(0)) :
80 column(column_), colour(colour_) {
82 EdgeProperties(uptr_t wParam, sptr_t lParam) :
83 column(static_cast<int>(wParam)), colour(static_cast<long>(lParam)) {
87 /**
89 class ViewStyle {
90 FontNames fontNames;
91 FontMap fonts;
92 public:
93 std::vector<Style> styles;
94 size_t nextExtendedStyle;
95 std::vector<LineMarker> markers;
96 int largestMarkerHeight;
97 std::vector<Indicator> indicators;
98 bool indicatorsDynamic;
99 bool indicatorsSetFore;
100 int technology;
101 int lineHeight;
102 int lineOverlap;
103 unsigned int maxAscent;
104 unsigned int maxDescent;
105 XYPOSITION aveCharWidth;
106 XYPOSITION spaceWidth;
107 XYPOSITION tabWidth;
108 ForeBackColours selColours;
109 ColourDesired selAdditionalForeground;
110 ColourDesired selAdditionalBackground;
111 ColourDesired selBackground2;
112 int selAlpha;
113 int selAdditionalAlpha;
114 bool selEOLFilled;
115 ForeBackColours whitespaceColours;
116 int controlCharSymbol;
117 XYPOSITION controlCharWidth;
118 ColourDesired selbar;
119 ColourDesired selbarlight;
120 ColourOptional foldmarginColour;
121 ColourOptional foldmarginHighlightColour;
122 ForeBackColours hotspotColours;
123 bool hotspotUnderline;
124 bool hotspotSingleLine;
125 /// Margins are ordered: Line Numbers, Selection Margin, Spacing Margin
126 int leftMarginWidth; ///< Spacing margin on left of text
127 int rightMarginWidth; ///< Spacing margin on right of text
128 int maskInLine; ///< Mask for markers to be put into text because there is nowhere for them to go in margin
129 int maskDrawInText; ///< Mask for markers that always draw in text
130 std::vector<MarginStyle> ms;
131 int fixedColumnWidth; ///< Total width of margins
132 bool marginInside; ///< true: margin included in text view, false: separate views
133 int textStart; ///< Starting x position of text within the view
134 int zoomLevel;
135 WhiteSpaceVisibility viewWhitespace;
136 TabDrawMode tabDrawMode;
137 int whitespaceSize;
138 IndentView viewIndentationGuides;
139 bool viewEOL;
140 ColourDesired caretcolour;
141 ColourDesired additionalCaretColour;
142 int caretLineFrame;
143 bool showCaretLineBackground;
144 bool alwaysShowCaretLineBackground;
145 ColourDesired caretLineBackground;
146 int caretLineAlpha;
147 int caretStyle;
148 int caretWidth;
149 bool someStylesProtected;
150 bool someStylesForceCase;
151 int extraFontFlag;
152 int extraAscent;
153 int extraDescent;
154 int marginStyleOffset;
155 int annotationVisible;
156 int annotationStyleOffset;
157 bool braceHighlightIndicatorSet;
158 int braceHighlightIndicator;
159 bool braceBadLightIndicatorSet;
160 int braceBadLightIndicator;
161 int edgeState;
162 EdgeProperties theEdge;
163 std::vector<EdgeProperties> theMultiEdge;
164 int marginNumberPadding; // the right-side padding of the number margin
165 int ctrlCharPadding; // the padding around control character text blobs
166 int lastSegItalicsOffset; // the offset so as not to clip italic characters at EOLs
168 // Wrapping support
169 WrapMode wrapState;
170 int wrapVisualFlags;
171 int wrapVisualFlagsLocation;
172 int wrapVisualStartIndent;
173 int wrapIndentMode; // SC_WRAPINDENT_FIXED, _SAME, _INDENT
175 ViewStyle();
176 ViewStyle(const ViewStyle &source);
177 // Can only be copied through copy constructor which ensures font names initialised correctly
178 ViewStyle &operator=(const ViewStyle &) = delete;
179 ~ViewStyle();
180 void CalculateMarginWidthAndMask();
181 void Init(size_t stylesSize_=256);
182 void Refresh(Surface &surface, int tabInChars);
183 void ReleaseAllExtendedStyles();
184 int AllocateExtendedStyles(int numberStyles);
185 void EnsureStyle(size_t index);
186 void ResetDefaultStyle();
187 void ClearStyles();
188 void SetStyleFontName(int styleIndex, const char *name);
189 bool ProtectionActive() const;
190 int ExternalMarginWidth() const;
191 int MarginFromLocation(Point pt) const;
192 bool ValidStyle(size_t styleIndex) const;
193 void CalcLargestMarkerHeight();
194 int GetFrameWidth() const;
195 bool IsLineFrameOpaque(bool caretActive, bool lineContainsCaret) const;
196 ColourOptional Background(int marksOfLine, bool caretActive, bool lineContainsCaret) const;
197 bool SelectionBackgroundDrawn() const;
198 bool WhitespaceBackgroundDrawn() const;
199 ColourDesired WrapColour() const;
201 bool SetWrapState(int wrapState_);
202 bool SetWrapVisualFlags(int wrapVisualFlags_);
203 bool SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation_);
204 bool SetWrapVisualStartIndent(int wrapVisualStartIndent_);
205 bool SetWrapIndentMode(int wrapIndentMode_);
207 bool WhiteSpaceVisible(bool inIndent) const;
209 private:
210 void AllocStyles(size_t sizeNew);
211 void CreateAndAddFont(const FontSpecification &fs);
212 FontRealised *Find(const FontSpecification &fs);
213 void FindMaxAscentDescent();
218 #endif