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