| 1 | // Scintilla source code edit control |
| 2 | /** @file Indicator.h |
| 3 | ** Defines the style of indicators which are text decorations such as underlining. |
| 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 INDICATOR_H |
| 9 | #define INDICATOR_H |
| 10 | |
| 11 | namespace Scintilla::Internal { |
| 12 | |
| 13 | struct StyleAndColour { |
| 14 | Scintilla::IndicatorStyle style; |
| 15 | ColourRGBA fore; |
| 16 | StyleAndColour() noexcept : style(Scintilla::IndicatorStyle::Plain), fore(0, 0, 0) { |
| 17 | } |
| 18 | StyleAndColour(Scintilla::IndicatorStyle style_, ColourRGBA fore_ = ColourRGBA(0, 0, 0)) noexcept : style(style_), fore(fore_) { |
| 19 | } |
| 20 | bool operator==(const StyleAndColour &other) const noexcept { |
| 21 | return (style == other.style) && (fore == other.fore); |
| 22 | } |
| 23 | }; |
| 24 | |
| 25 | /** |
| 26 | */ |
| 27 | class Indicator { |
| 28 | public: |
| 29 | enum class State { normal, hover }; |
| 30 | StyleAndColour sacNormal; |
| 31 | StyleAndColour sacHover; |
| 32 | bool under; |
| 33 | int fillAlpha; |
| 34 | int outlineAlpha; |
| 35 | Scintilla::IndicFlag attributes; |
| 36 | XYPOSITION strokeWidth = 1.0f; |
| 37 | Indicator() noexcept : under(false), fillAlpha(30), outlineAlpha(50), attributes(Scintilla::IndicFlag::None) { |
| 38 | } |
| 39 | Indicator(Scintilla::IndicatorStyle style_, ColourRGBA fore_= ColourRGBA(0,0,0), bool under_=false, int fillAlpha_=30, int outlineAlpha_=50) noexcept : |
| 40 | sacNormal(style_, fore_), sacHover(style_, fore_), under(under_), fillAlpha(fillAlpha_), outlineAlpha(outlineAlpha_), attributes(Scintilla::IndicFlag::None) { |
| 41 | } |
| 42 | void Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine, const PRectangle &rcCharacter, State drawState, int value) const; |
| 43 | bool IsDynamic() const noexcept { |
| 44 | return !(sacNormal == sacHover); |
| 45 | } |
| 46 | bool OverridesTextFore() const noexcept { |
| 47 | return sacNormal.style == Scintilla::IndicatorStyle::TextFore || sacHover.style == Scintilla::IndicatorStyle::TextFore; |
| 48 | } |
| 49 | Scintilla::IndicFlag Flags() const noexcept { |
| 50 | return attributes; |
| 51 | } |
| 52 | void SetFlags(Scintilla::IndicFlag attributes_) noexcept; |
| 53 | }; |
| 54 | |
| 55 | } |
| 56 | |
| 57 | #endif |
| 58 | |