1 // Scintilla source code edit control 2 /** @file Style.h 3 ** Defines the font and colour style for a class of text. 4 **/ 5 // Copyright 1998-2001 by Neil Hodgson <[email protected]> 6 // The License.txt file describes the conditions under which this software may be distributed. 7 8 #ifndef STYLE_H 9 #define STYLE_H 10 11 namespace Scintilla { 12 13 struct FontSpecification { 14 const char *fontName; 15 int weight; 16 bool italic; 17 int size; 18 int characterSet; 19 int extraFontFlag; FontSpecificationFontSpecification20 FontSpecification() noexcept : 21 fontName(nullptr), 22 weight(SC_WEIGHT_NORMAL), 23 italic(false), 24 size(10 * SC_FONT_SIZE_MULTIPLIER), 25 characterSet(0), 26 extraFontFlag(0) { 27 } 28 bool operator==(const FontSpecification &other) const noexcept; 29 bool operator<(const FontSpecification &other) const noexcept; 30 }; 31 32 // Just like Font but only has a copy of the FontID so should not delete it 33 class FontAlias : public Font { 34 public: 35 FontAlias() noexcept; 36 // FontAlias objects can be copy or move constructed but not be assigned 37 FontAlias(const FontAlias &) noexcept; 38 FontAlias(FontAlias &&) noexcept; 39 FontAlias &operator=(const FontAlias &) = delete; 40 FontAlias &operator=(FontAlias &&) = delete; 41 ~FontAlias() override; 42 void MakeAlias(const Font &fontOrigin) noexcept; 43 void ClearFont() noexcept; 44 }; 45 46 struct FontMeasurements { 47 unsigned int ascent; 48 unsigned int descent; 49 XYPOSITION capitalHeight; // Top of capital letter to baseline: ascent - internal leading 50 XYPOSITION aveCharWidth; 51 XYPOSITION spaceWidth; 52 int sizeZoomed; 53 FontMeasurements() noexcept; 54 void ClearMeasurements() noexcept; 55 }; 56 57 /** 58 */ 59 class Style : public FontSpecification, public FontMeasurements { 60 public: 61 ColourDesired fore; 62 ColourDesired back; 63 bool eolFilled; 64 bool underline; 65 enum ecaseForced {caseMixed, caseUpper, caseLower, caseCamel}; 66 ecaseForced caseForce; 67 bool visible; 68 bool changeable; 69 bool hotspot; 70 71 FontAlias font; 72 73 Style(); 74 Style(const Style &source) noexcept; 75 Style(Style &&) noexcept = default; 76 ~Style(); 77 Style &operator=(const Style &source) noexcept; 78 Style &operator=(Style &&) = delete; 79 void Clear(ColourDesired fore_, ColourDesired back_, 80 int size_, 81 const char *fontName_, int characterSet_, 82 int weight_, bool italic_, bool eolFilled_, 83 bool underline_, ecaseForced caseForce_, 84 bool visible_, bool changeable_, bool hotspot_) noexcept; 85 void ClearTo(const Style &source) noexcept; 86 void Copy(const Font &font_, const FontMeasurements &fm_) noexcept; IsProtected()87 bool IsProtected() const noexcept { return !(changeable && visible);} 88 }; 89 90 } 91 92 #endif 93