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 <neilh@scintilla.org> |
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::Internal { |
12 | |
13 | struct FontSpecification { |
14 | // fontName is allocated by a ViewStyle container object and may be null |
15 | const char *fontName; |
16 | int size; |
17 | Scintilla::FontWeight weight = Scintilla::FontWeight::Normal; |
18 | bool italic = false; |
19 | Scintilla::CharacterSet characterSet = Scintilla::CharacterSet::Default; |
20 | Scintilla::FontQuality = Scintilla::FontQuality::QualityDefault; |
21 | bool checkMonospaced = false; |
22 | |
23 | constexpr FontSpecification(const char *fontName_=nullptr, int size_=10*Scintilla::FontSizeMultiplier) noexcept : |
24 | fontName(fontName_), size(size_) { |
25 | } |
26 | bool operator==(const FontSpecification &other) const noexcept; |
27 | bool operator<(const FontSpecification &other) const noexcept; |
28 | }; |
29 | |
30 | struct FontMeasurements { |
31 | XYPOSITION ascent = 1; |
32 | XYPOSITION descent = 1; |
33 | XYPOSITION capitalHeight = 1; // Top of capital letter to baseline: ascent - internal leading |
34 | XYPOSITION aveCharWidth = 1; |
35 | XYPOSITION monospaceCharacterWidth = 1; |
36 | XYPOSITION spaceWidth = 1; |
37 | bool monospaceASCII = false; |
38 | int sizeZoomed = 2; |
39 | }; |
40 | |
41 | /** |
42 | */ |
43 | class Style : public FontSpecification, public FontMeasurements { |
44 | public: |
45 | ColourRGBA fore; |
46 | ColourRGBA back; |
47 | bool eolFilled; |
48 | bool underline; |
49 | enum class CaseForce {mixed, upper, lower, camel}; |
50 | CaseForce caseForce; |
51 | bool visible; |
52 | bool changeable; |
53 | bool hotspot; |
54 | |
55 | std::shared_ptr<Font> font; |
56 | |
57 | Style(const char *fontName_=nullptr) noexcept; |
58 | void Copy(std::shared_ptr<Font> font_, const FontMeasurements &fm_) noexcept; |
59 | bool IsProtected() const noexcept { return !(changeable && visible);} |
60 | }; |
61 | |
62 | } |
63 | |
64 | #endif |
65 | |