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);
30 std::vector
<UniqueString
> names
;
33 // FontNames objects can not be copied.
34 FontNames(const FontNames
&) = delete;
35 FontNames
&operator=(const FontNames
&) = delete;
38 const char *Save(const char *name
);
41 class FontRealised
: public FontMeasurements
{
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
{
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
{
76 struct EdgeProperties
{
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
)) {
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
;
103 unsigned int maxAscent
;
104 unsigned int maxDescent
;
105 XYPOSITION aveCharWidth
;
106 XYPOSITION spaceWidth
;
108 ForeBackColours selColours
;
109 ColourDesired selAdditionalForeground
;
110 ColourDesired selAdditionalBackground
;
111 ColourDesired selBackground2
;
113 int selAdditionalAlpha
;
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
135 WhiteSpaceVisibility viewWhitespace
;
136 TabDrawMode tabDrawMode
;
138 IndentView viewIndentationGuides
;
140 ColourDesired caretcolour
;
141 ColourDesired additionalCaretColour
;
143 bool showCaretLineBackground
;
144 bool alwaysShowCaretLineBackground
;
145 ColourDesired caretLineBackground
;
149 bool someStylesProtected
;
150 bool someStylesForceCase
;
154 int marginStyleOffset
;
155 int annotationVisible
;
156 int annotationStyleOffset
;
157 bool braceHighlightIndicatorSet
;
158 int braceHighlightIndicator
;
159 bool braceBadLightIndicatorSet
;
160 int braceBadLightIndicator
;
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
171 int wrapVisualFlagsLocation
;
172 int wrapVisualStartIndent
;
173 int wrapIndentMode
; // SC_WRAPINDENT_FIXED, _SAME, _INDENT
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;
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();
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;
210 void AllocStyles(size_t sizeNew
);
211 void CreateAndAddFont(const FontSpecification
&fs
);
212 FontRealised
*Find(const FontSpecification
&fs
);
213 void FindMaxAscentDescent();