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.
25 MarginStyle(int style_
= SC_MARGIN_SYMBOL
, int width_
=0, int mask_
=0);
32 std::vector
<UniqueString
> names
;
35 // FontNames objects can not be copied.
36 FontNames(const FontNames
&) = delete;
37 FontNames
&operator=(const FontNames
&) = delete;
40 const char *Save(const char *name
);
43 class FontRealised
: public FontMeasurements
{
47 // FontRealised objects can not be copied.
48 FontRealised(const FontRealised
&) = delete;
49 FontRealised
&operator=(const FontRealised
&) = delete;
50 virtual ~FontRealised();
51 void Realise(Surface
&surface
, int zoomLevel
, int technology
, const FontSpecification
&fs
);
54 enum IndentView
{ivNone
, ivReal
, ivLookForward
, ivLookBoth
};
56 enum WhiteSpaceVisibility
{wsInvisible
=0, wsVisibleAlways
=1, wsVisibleAfterIndent
=2, wsVisibleOnlyInIndent
=3};
58 enum TabDrawMode
{tdLongArrow
=0, tdStrikeOut
=1};
60 typedef std::map
<FontSpecification
, std::unique_ptr
<FontRealised
>> FontMap
;
62 enum WrapMode
{ eWrapNone
, eWrapWord
, eWrapChar
, eWrapWhitespace
};
64 class ColourOptional
: public ColourDesired
{
67 ColourOptional(ColourDesired colour_
=ColourDesired(0,0,0), bool isSet_
=false) : ColourDesired(colour_
), isSet(isSet_
) {
69 ColourOptional(uptr_t wParam
, sptr_t lParam
) : ColourDesired(static_cast<long>(lParam
)), isSet(wParam
!= 0) {
73 struct ForeBackColours
{
78 struct EdgeProperties
{
81 EdgeProperties(int column_
= 0, ColourDesired colour_
= ColourDesired(0)) :
82 column(column_
), colour(colour_
) {
84 EdgeProperties(uptr_t wParam
, sptr_t lParam
) :
85 column(static_cast<int>(wParam
)), colour(static_cast<long>(lParam
)) {
95 std::vector
<Style
> styles
;
96 size_t nextExtendedStyle
;
97 std::vector
<LineMarker
> markers
;
98 int largestMarkerHeight
;
99 std::vector
<Indicator
> indicators
;
100 bool indicatorsDynamic
;
101 bool indicatorsSetFore
;
105 unsigned int maxAscent
;
106 unsigned int maxDescent
;
107 XYPOSITION aveCharWidth
;
108 XYPOSITION spaceWidth
;
110 ForeBackColours selColours
;
111 ColourDesired selAdditionalForeground
;
112 ColourDesired selAdditionalBackground
;
113 ColourDesired selBackground2
;
115 int selAdditionalAlpha
;
117 ForeBackColours whitespaceColours
;
118 int controlCharSymbol
;
119 XYPOSITION controlCharWidth
;
120 ColourDesired selbar
;
121 ColourDesired selbarlight
;
122 ColourOptional foldmarginColour
;
123 ColourOptional foldmarginHighlightColour
;
124 ForeBackColours hotspotColours
;
125 bool hotspotUnderline
;
126 bool hotspotSingleLine
;
127 /// Margins are ordered: Line Numbers, Selection Margin, Spacing Margin
128 int leftMarginWidth
; ///< Spacing margin on left of text
129 int rightMarginWidth
; ///< Spacing margin on right of text
130 int maskInLine
; ///< Mask for markers to be put into text because there is nowhere for them to go in margin
131 int maskDrawInText
; ///< Mask for markers that always draw in text
132 std::vector
<MarginStyle
> ms
;
133 int fixedColumnWidth
; ///< Total width of margins
134 bool marginInside
; ///< true: margin included in text view, false: separate views
135 int textStart
; ///< Starting x position of text within the view
137 WhiteSpaceVisibility viewWhitespace
;
138 TabDrawMode tabDrawMode
;
140 IndentView viewIndentationGuides
;
142 ColourDesired caretcolour
;
143 ColourDesired additionalCaretColour
;
145 bool showCaretLineBackground
;
146 bool alwaysShowCaretLineBackground
;
147 ColourDesired caretLineBackground
;
151 bool someStylesProtected
;
152 bool someStylesForceCase
;
156 int marginStyleOffset
;
157 int annotationVisible
;
158 int annotationStyleOffset
;
159 bool braceHighlightIndicatorSet
;
160 int braceHighlightIndicator
;
161 bool braceBadLightIndicatorSet
;
162 int braceBadLightIndicator
;
164 EdgeProperties theEdge
;
165 std::vector
<EdgeProperties
> theMultiEdge
;
166 int marginNumberPadding
; // the right-side padding of the number margin
167 int ctrlCharPadding
; // the padding around control character text blobs
168 int lastSegItalicsOffset
; // the offset so as not to clip italic characters at EOLs
173 int wrapVisualFlagsLocation
;
174 int wrapVisualStartIndent
;
175 int wrapIndentMode
; // SC_WRAPINDENT_FIXED, _SAME, _INDENT
178 ViewStyle(const ViewStyle
&source
);
179 // Can only be copied through copy constructor which ensures font names initialised correctly
180 ViewStyle
&operator=(const ViewStyle
&) = delete;
182 void CalculateMarginWidthAndMask();
183 void Init(size_t stylesSize_
=256);
184 void Refresh(Surface
&surface
, int tabInChars
);
185 void ReleaseAllExtendedStyles();
186 int AllocateExtendedStyles(int numberStyles
);
187 void EnsureStyle(size_t index
);
188 void ResetDefaultStyle();
190 void SetStyleFontName(int styleIndex
, const char *name
);
191 bool ProtectionActive() const;
192 int ExternalMarginWidth() const;
193 int MarginFromLocation(Point pt
) const;
194 bool ValidStyle(size_t styleIndex
) const;
195 void CalcLargestMarkerHeight();
196 int GetFrameWidth() const;
197 bool IsLineFrameOpaque(bool caretActive
, bool lineContainsCaret
) const;
198 ColourOptional
Background(int marksOfLine
, bool caretActive
, bool lineContainsCaret
) const;
199 bool SelectionBackgroundDrawn() const;
200 bool WhitespaceBackgroundDrawn() const;
201 ColourDesired
WrapColour() const;
203 bool SetWrapState(int wrapState_
);
204 bool SetWrapVisualFlags(int wrapVisualFlags_
);
205 bool SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation_
);
206 bool SetWrapVisualStartIndent(int wrapVisualStartIndent_
);
207 bool SetWrapIndentMode(int wrapIndentMode_
);
209 bool WhiteSpaceVisible(bool inIndent
) const;
212 void AllocStyles(size_t sizeNew
);
213 void CreateAndAddFont(const FontSpecification
&fs
);
214 FontRealised
*Find(const FontSpecification
&fs
);
215 void FindMaxAscentDescent();