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