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. 7 8 #ifndef VIEWSTYLE_H 9 #define VIEWSTYLE_H 10 11 #ifdef SCI_NAMESPACE 12 namespace Scintilla { 13 #endif 14 15 /** 16 */ 17 class MarginStyle { 18 public: 19 int style; 20 int width; 21 int mask; 22 bool sensitive; 23 int cursor; 24 MarginStyle(); 25 }; 26 27 /** 28 */ 29 class FontNames { 30 private: 31 std::vector<char *> names; 32 33 // Private so FontNames objects can not be copied 34 FontNames(const FontNames &); 35 public: 36 FontNames(); 37 ~FontNames(); 38 void Clear(); 39 const char *Save(const char *name); 40 }; 41 42 class FontRealised : public FontMeasurements { 43 // Private so FontRealised objects can not be copied 44 FontRealised(const FontRealised &); 45 FontRealised &operator=(const FontRealised &); 46 public: 47 Font font; 48 FontRealised(); 49 virtual ~FontRealised(); 50 void Realise(Surface &surface, int zoomLevel, int technology, const FontSpecification &fs); 51 }; 52 53 enum IndentView {ivNone, ivReal, ivLookForward, ivLookBoth}; 54 55 enum WhiteSpaceVisibility {wsInvisible=0, wsVisibleAlways=1, wsVisibleAfterIndent=2}; 56 57 typedef std::map<FontSpecification, FontRealised *> FontMap; 58 59 enum WrapMode { eWrapNone, eWrapWord, eWrapChar }; 60 61 class ColourOptional : public ColourDesired { 62 public: 63 bool isSet; ColourDesired(colour_)64 ColourOptional(ColourDesired colour_=ColourDesired(0,0,0), bool isSet_=false) : ColourDesired(colour_), isSet(isSet_) { 65 } ColourOptional(uptr_t wParam,sptr_t lParam)66 ColourOptional(uptr_t wParam, sptr_t lParam) : ColourDesired(lParam), isSet(wParam != 0) { 67 } 68 }; 69 70 struct ForeBackColours { 71 ColourOptional fore; 72 ColourOptional back; 73 }; 74 75 /** 76 */ 77 class ViewStyle { 78 FontNames fontNames; 79 FontMap fonts; 80 public: 81 std::vector<Style> styles; 82 size_t nextExtendedStyle; 83 LineMarker markers[MARKER_MAX + 1]; 84 int largestMarkerHeight; 85 Indicator indicators[INDIC_MAX + 1]; 86 int technology; 87 int lineHeight; 88 unsigned int maxAscent; 89 unsigned int maxDescent; 90 XYPOSITION aveCharWidth; 91 XYPOSITION spaceWidth; 92 XYPOSITION tabWidth; 93 ForeBackColours selColours; 94 ColourDesired selAdditionalForeground; 95 ColourDesired selAdditionalBackground; 96 ColourDesired selBackground2; 97 int selAlpha; 98 int selAdditionalAlpha; 99 bool selEOLFilled; 100 ForeBackColours whitespaceColours; 101 int controlCharSymbol; 102 XYPOSITION controlCharWidth; 103 ColourDesired selbar; 104 ColourDesired selbarlight; 105 ColourOptional foldmarginColour; 106 ColourOptional foldmarginHighlightColour; 107 ForeBackColours hotspotColours; 108 bool hotspotUnderline; 109 bool hotspotSingleLine; 110 /// Margins are ordered: Line Numbers, Selection Margin, Spacing Margin 111 int leftMarginWidth; ///< Spacing margin on left of text 112 int rightMarginWidth; ///< Spacing margin on right of text 113 int maskInLine; ///< Mask for markers to be put into text because there is nowhere for them to go in margin 114 MarginStyle ms[SC_MAX_MARGIN+1]; 115 int fixedColumnWidth; ///< Total width of margins 116 bool marginInside; ///< true: margin included in text view, false: separate views 117 int textStart; ///< Starting x position of text within the view 118 int zoomLevel; 119 WhiteSpaceVisibility viewWhitespace; 120 int whitespaceSize; 121 IndentView viewIndentationGuides; 122 bool viewEOL; 123 ColourDesired caretcolour; 124 ColourDesired additionalCaretColour; 125 bool showCaretLineBackground; 126 bool alwaysShowCaretLineBackground; 127 ColourDesired caretLineBackground; 128 int caretLineAlpha; 129 ColourDesired edgecolour; 130 int edgeState; 131 int caretStyle; 132 int caretWidth; 133 bool someStylesProtected; 134 bool someStylesForceCase; 135 int extraFontFlag; 136 int extraAscent; 137 int extraDescent; 138 int marginStyleOffset; 139 int annotationVisible; 140 int annotationStyleOffset; 141 bool braceHighlightIndicatorSet; 142 int braceHighlightIndicator; 143 bool braceBadLightIndicatorSet; 144 int braceBadLightIndicator; 145 int theEdge; 146 int marginNumberPadding; // the right-side padding of the number margin 147 int ctrlCharPadding; // the padding around control character text blobs 148 int lastSegItalicsOffset; // the offset so as not to clip italic characters at EOLs 149 150 // Wrapping support 151 WrapMode wrapState; 152 int wrapVisualFlags; 153 int wrapVisualFlagsLocation; 154 int wrapVisualStartIndent; 155 int wrapIndentMode; // SC_WRAPINDENT_FIXED, _SAME, _INDENT 156 157 ViewStyle(); 158 ViewStyle(const ViewStyle &source); 159 ~ViewStyle(); 160 void Init(size_t stylesSize_=64); 161 void Refresh(Surface &surface, int tabInChars); 162 void ReleaseAllExtendedStyles(); 163 int AllocateExtendedStyles(int numberStyles); 164 void EnsureStyle(size_t index); 165 void ResetDefaultStyle(); 166 void ClearStyles(); 167 void SetStyleFontName(int styleIndex, const char *name); 168 bool ProtectionActive() const; 169 int ExternalMarginWidth() const; 170 bool ValidStyle(size_t styleIndex) const; 171 void CalcLargestMarkerHeight(); 172 ColourDesired WrapColour() const; 173 bool SetWrapState(int wrapState_); 174 bool SetWrapVisualFlags(int wrapVisualFlags_); 175 bool SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation_); 176 bool SetWrapVisualStartIndent(int wrapVisualStartIndent_); 177 bool SetWrapIndentMode(int wrapIndentMode_); 178 179 private: 180 void AllocStyles(size_t sizeNew); 181 void CreateFont(const FontSpecification &fs); 182 FontRealised *Find(const FontSpecification &fs); 183 void FindMaxAscentDescent(unsigned int &maxAscent, unsigned int &maxDescent); 184 // Private so can only be copied through copy constructor which ensures font names initialised correctly 185 ViewStyle &operator=(const ViewStyle &); 186 }; 187 188 #ifdef SCI_NAMESPACE 189 } 190 #endif 191 192 #endif 193