1 // Scintilla source code edit control
3 ** Store information on how the document is to be viewed.
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.
23 MarginStyle(int style_
= SC_MARGIN_SYMBOL
, int width_
=0, int mask_
=0) noexcept
;
30 class FontRealised
: public FontMeasurements
{
33 FontRealised() noexcept
;
34 // FontRealised objects can not be copied.
35 FontRealised(const FontRealised
&) = delete;
36 FontRealised(FontRealised
&&) = delete;
37 FontRealised
&operator=(const FontRealised
&) = delete;
38 FontRealised
&operator=(FontRealised
&&) = delete;
39 virtual ~FontRealised();
40 void Realise(Surface
&surface
, int zoomLevel
, int technology
, const FontSpecification
&fs
);
43 enum IndentView
{ivNone
, ivReal
, ivLookForward
, ivLookBoth
};
45 enum WhiteSpaceVisibility
{wsInvisible
=0, wsVisibleAlways
=1, wsVisibleAfterIndent
=2, wsVisibleOnlyInIndent
=3};
47 enum TabDrawMode
{tdLongArrow
=0, tdStrikeOut
=1};
49 typedef std::map
<FontSpecification
, std::unique_ptr
<FontRealised
>> FontMap
;
51 enum WrapMode
{ eWrapNone
, eWrapWord
, eWrapChar
, eWrapWhitespace
};
53 class ColourOptional
: public ColourDesired
{
56 ColourOptional(ColourDesired colour_
=ColourDesired(0,0,0), bool isSet_
=false) noexcept
: ColourDesired(colour_
), isSet(isSet_
) {
58 ColourOptional(uptr_t wParam
, sptr_t lParam
) noexcept
: ColourDesired(static_cast<int>(lParam
)), isSet(wParam
!= 0) {
62 struct ForeBackColours
{
67 struct EdgeProperties
{
70 EdgeProperties(int column_
= 0, ColourDesired colour_
= ColourDesired(0)) noexcept
:
71 column(column_
), colour(colour_
) {
73 EdgeProperties(uptr_t wParam
, sptr_t lParam
) noexcept
:
74 column(static_cast<int>(wParam
)), colour(static_cast<int>(lParam
)) {
81 UniqueStringSet fontNames
;
84 std::vector
<Style
> styles
;
85 int nextExtendedStyle
;
86 std::vector
<LineMarker
> markers
;
87 int largestMarkerHeight
;
88 std::vector
<Indicator
> indicators
;
89 bool indicatorsDynamic
;
90 bool indicatorsSetFore
;
94 unsigned int maxAscent
;
95 unsigned int maxDescent
;
96 XYPOSITION aveCharWidth
;
97 XYPOSITION spaceWidth
;
99 ForeBackColours selColours
;
100 ColourDesired selAdditionalForeground
;
101 ColourDesired selAdditionalBackground
;
102 ColourDesired selBackground2
;
104 int selAdditionalAlpha
;
106 ForeBackColours whitespaceColours
;
107 int controlCharSymbol
;
108 XYPOSITION controlCharWidth
;
109 ColourDesired selbar
;
110 ColourDesired selbarlight
;
111 ColourOptional foldmarginColour
;
112 ColourOptional foldmarginHighlightColour
;
113 ForeBackColours hotspotColours
;
114 bool hotspotUnderline
;
115 bool hotspotSingleLine
;
116 /// Margins are ordered: Line Numbers, Selection Margin, Spacing Margin
117 int leftMarginWidth
; ///< Spacing margin on left of text
118 int rightMarginWidth
; ///< Spacing margin on right of text
119 int maskInLine
; ///< Mask for markers to be put into text because there is nowhere for them to go in margin
120 int maskDrawInText
; ///< Mask for markers that always draw in text
121 std::vector
<MarginStyle
> ms
;
122 int fixedColumnWidth
; ///< Total width of margins
123 bool marginInside
; ///< true: margin included in text view, false: separate views
124 int textStart
; ///< Starting x position of text within the view
126 WhiteSpaceVisibility viewWhitespace
;
127 TabDrawMode tabDrawMode
;
129 IndentView viewIndentationGuides
;
131 ColourDesired caretcolour
;
132 ColourDesired additionalCaretColour
;
134 bool showCaretLineBackground
;
135 bool alwaysShowCaretLineBackground
;
136 ColourDesired caretLineBackground
;
140 bool someStylesProtected
;
141 bool someStylesForceCase
;
145 int marginStyleOffset
;
146 int annotationVisible
;
147 int annotationStyleOffset
;
148 bool braceHighlightIndicatorSet
;
149 int braceHighlightIndicator
;
150 bool braceBadLightIndicatorSet
;
151 int braceBadLightIndicator
;
153 EdgeProperties theEdge
;
154 std::vector
<EdgeProperties
> theMultiEdge
;
155 int marginNumberPadding
; // the right-side padding of the number margin
156 int ctrlCharPadding
; // the padding around control character text blobs
157 int lastSegItalicsOffset
; // the offset so as not to clip italic characters at EOLs
162 int wrapVisualFlagsLocation
;
163 int wrapVisualStartIndent
;
164 int wrapIndentMode
; // SC_WRAPINDENT_FIXED, _SAME, _INDENT
167 ViewStyle(const ViewStyle
&source
);
168 ViewStyle(ViewStyle
&&) = delete;
169 // Can only be copied through copy constructor which ensures font names initialised correctly
170 ViewStyle
&operator=(const ViewStyle
&) = delete;
171 ViewStyle
&operator=(ViewStyle
&&) = delete;
173 void CalculateMarginWidthAndMask();
174 void Init(size_t stylesSize_
=256);
175 void Refresh(Surface
&surface
, int tabInChars
);
176 void ReleaseAllExtendedStyles() noexcept
;
177 int AllocateExtendedStyles(int numberStyles
);
178 void EnsureStyle(size_t index
);
179 void ResetDefaultStyle();
181 void SetStyleFontName(int styleIndex
, const char *name
);
182 bool ProtectionActive() const noexcept
;
183 int ExternalMarginWidth() const noexcept
;
184 int MarginFromLocation(Point pt
) const;
185 bool ValidStyle(size_t styleIndex
) const noexcept
;
186 void CalcLargestMarkerHeight();
187 int GetFrameWidth() const noexcept
;
188 bool IsLineFrameOpaque(bool caretActive
, bool lineContainsCaret
) const noexcept
;
189 ColourOptional
Background(int marksOfLine
, bool caretActive
, bool lineContainsCaret
) const;
190 bool SelectionBackgroundDrawn() const noexcept
;
191 bool WhitespaceBackgroundDrawn() const noexcept
;
192 ColourDesired
WrapColour() const;
194 bool SetWrapState(int wrapState_
) noexcept
;
195 bool SetWrapVisualFlags(int wrapVisualFlags_
) noexcept
;
196 bool SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation_
) noexcept
;
197 bool SetWrapVisualStartIndent(int wrapVisualStartIndent_
) noexcept
;
198 bool SetWrapIndentMode(int wrapIndentMode_
) noexcept
;
200 bool WhiteSpaceVisible(bool inIndent
) const noexcept
;
202 enum class CaretShape
{ invisible
, line
, block
, bar
};
203 bool IsBlockCaretStyle() const noexcept
;
204 CaretShape
CaretShapeForMode(bool inOverstrike
) const noexcept
;
207 void AllocStyles(size_t sizeNew
);
208 void CreateAndAddFont(const FontSpecification
&fs
);
209 FontRealised
*Find(const FontSpecification
&fs
);
210 void FindMaxAscentDescent();