diff options
author | Neil <nyamatongwe@gmail.com> | 2021-05-24 19:31:06 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2021-05-24 19:31:06 +1000 |
commit | 92290868cf9753d2df0d494cb44e2ff62a570b58 (patch) | |
tree | 001e6cfce84372a03997de3138d630751ee8d38a /src/ViewStyle.h | |
parent | ee1886079d0a5cd350ee8e3379be347943ba93ae (diff) | |
download | scintilla-mirror-92290868cf9753d2df0d494cb44e2ff62a570b58.tar.gz |
Define C++ version of the Scintilla API in ScintillaTypes.h, ScintillaMessages.h
and ScintillaStructures.h using scoped enumerations.
Use these headers instead of Scintilla.h internally.
External definitions go in the Scintilla namespace and internal definitio0ns in
Scintilla::Internal.
Diffstat (limited to 'src/ViewStyle.h')
-rw-r--r-- | src/ViewStyle.h | 102 |
1 files changed, 53 insertions, 49 deletions
diff --git a/src/ViewStyle.h b/src/ViewStyle.h index 798595ddc..b59f441b1 100644 --- a/src/ViewStyle.h +++ b/src/ViewStyle.h @@ -8,19 +8,19 @@ #ifndef VIEWSTYLE_H #define VIEWSTYLE_H -namespace Scintilla { +namespace Scintilla::Internal { /** */ class MarginStyle { public: - int style; + Scintilla::MarginType style; ColourRGBA back; int width; int mask; bool sensitive; - int cursor; - MarginStyle(int style_= SC_MARGIN_SYMBOL, int width_=0, int mask_=0) noexcept; + Scintilla::CursorShape cursor; + MarginStyle(Scintilla::MarginType style_= Scintilla::MarginType::Symbol, int width_=0, int mask_=0) noexcept; bool ShowsFolding() const noexcept; }; @@ -38,20 +38,12 @@ public: FontRealised &operator=(const FontRealised &) = delete; FontRealised &operator=(FontRealised &&) = delete; virtual ~FontRealised(); - void Realise(Surface &surface, int zoomLevel, int technology, const FontSpecification &fs, const char *localeName); + void Realise(Surface &surface, int zoomLevel, Scintilla::Technology technology, const FontSpecification &fs, const char *localeName); }; -enum class IndentView {none, real, lookForward, lookBoth}; - -enum class WhiteSpace {invisible=0, visibleAlways=1, visibleAfterIndent=2, visibleOnlyInIndent=3}; - -enum class TabDrawMode {longArrow=0, strikeOut=1}; - typedef std::map<FontSpecification, std::unique_ptr<FontRealised>> FontMap; -enum class WrapMode { none, word, character, whitespace }; - -inline std::optional<ColourRGBA> OptionalColour(uptr_t wParam, sptr_t lParam) { +inline std::optional<ColourRGBA> OptionalColour(Scintilla::uptr_t wParam, Scintilla::sptr_t lParam) { if (wParam) { return ColourRGBA::FromRGB(static_cast<int>(lParam)); } else { @@ -61,14 +53,14 @@ inline std::optional<ColourRGBA> OptionalColour(uptr_t wParam, sptr_t lParam) { struct SelectionAppearance { // Whether to draw on base layer or over text - Layer layer; + Scintilla::Layer layer; // Draw selection past line end characters up to right border bool eolFilled; }; struct CaretLineAppearance { // Whether to draw on base layer or over text - Layer layer; + Scintilla::Layer layer; // Also show when non-focused bool alwaysShow; // Non-0: draw a rectangle around line instead of filling line. Value is pixel width of frame @@ -77,22 +69,22 @@ struct CaretLineAppearance { struct CaretAppearance { // Line, block, over-strike bar ... - int style; + Scintilla::CaretStyle style; // Width in pixels int width; }; struct WrapAppearance { // No wrapping, word, character, whitespace appearance - WrapMode state; + Scintilla::Wrap state; // Show indication of wrap at line end, line start, or in margin - int visualFlags; + Scintilla::WrapVisualFlag visualFlags; // Show indication near margin or near text - int visualFlagsLocation; + Scintilla::WrapVisualLocation visualFlagsLocation; // How much indentation to show wrapping int visualStartIndent; - // SC_WRAPINDENT_FIXED, _SAME, _INDENT, _DEEPINDENT - int indentMode; + // WrapIndentMode::Fixed, _SAME, _INDENT, _DEEPINDENT + Scintilla::WrapIndentMode indentMode; }; struct EdgeProperties { @@ -101,11 +93,23 @@ struct EdgeProperties { EdgeProperties(int column_ = 0, ColourRGBA colour_ = ColourRGBA::FromRGB(0)) noexcept : column(column_), colour(colour_) { } - EdgeProperties(uptr_t wParam, sptr_t lParam) noexcept : + EdgeProperties(Scintilla::uptr_t wParam, Scintilla::sptr_t lParam) noexcept : column(static_cast<int>(wParam)), colour(ColourRGBA::FromRGB(static_cast<int>(lParam))) { } }; +// This is an old style enum so that its members can be used directly as indices without casting +enum StyleIndices { + StyleDefault = static_cast<int>(Scintilla::StylesCommon::Default), + StyleLineNumber = static_cast<int>(Scintilla::StylesCommon::LineNumber), + StyleBraceLight = static_cast<int>(Scintilla::StylesCommon::BraceLight), + StyleBraceBad = static_cast<int>(Scintilla::StylesCommon::BraceBad), + StyleControlChar = static_cast<int>(Scintilla::StylesCommon::ControlChar), + StyleIndentGuide = static_cast<int>(Scintilla::StylesCommon::IndentGuide), + StyleCallTip = static_cast<int>(Scintilla::StylesCommon::CallTip), + StyleFoldDisplayText = static_cast<int>(Scintilla::StylesCommon::FoldDisplayText), +}; + /** */ class ViewStyle { @@ -119,7 +123,7 @@ public: std::vector<Indicator> indicators; bool indicatorsDynamic; bool indicatorsSetFore; - int technology; + Scintilla::Technology technology; int lineHeight; int lineOverlap; unsigned int maxAscent; @@ -147,10 +151,10 @@ public: bool marginInside; ///< true: margin included in text view, false: separate views int textStart; ///< Starting x position of text within the view int zoomLevel; - WhiteSpace viewWhitespace; - TabDrawMode tabDrawMode; + Scintilla::WhiteSpace viewWhitespace; + Scintilla::TabDrawMode tabDrawMode; int whitespaceSize; - IndentView viewIndentationGuides; + Scintilla::IndentView viewIndentationGuides; bool viewEOL; CaretAppearance caret; @@ -159,29 +163,29 @@ public: bool someStylesProtected; bool someStylesForceCase; - int extraFontFlag; + Scintilla::FontQuality extraFontFlag; int extraAscent; int extraDescent; int marginStyleOffset; - int annotationVisible; + Scintilla::AnnotationVisible annotationVisible; int annotationStyleOffset; - int eolAnnotationVisible; + Scintilla::EOLAnnotationVisible eolAnnotationVisible; int eolAnnotationStyleOffset; bool braceHighlightIndicatorSet; int braceHighlightIndicator; bool braceBadLightIndicatorSet; int braceBadLightIndicator; - int edgeState; + Scintilla::EdgeVisualStyle edgeState; EdgeProperties theEdge; std::vector<EdgeProperties> theMultiEdge; int marginNumberPadding; // the right-side padding of the number margin int ctrlCharPadding; // the padding around control character text blobs int lastSegItalicsOffset; // the offset so as not to clip italic characters at EOLs - using ElementMap = std::map<int, std::optional<ColourRGBA>>; + using ElementMap = std::map<Scintilla::Element, std::optional<ColourRGBA>>; ElementMap elementColours; ElementMap elementBaseColours; - std::set<int> elementAllowsTranslucent; + std::set<Scintilla::Element> elementAllowsTranslucent; WrapAppearance wrap; @@ -217,23 +221,23 @@ public: bool WhitespaceBackgroundDrawn() const; ColourRGBA WrapColour() const; - void AddMultiEdge(uptr_t wParam, sptr_t lParam); - - std::optional<ColourRGBA> ElementColour(int element) const; - bool ElementAllowsTranslucent(int element) const; - bool ResetElement(int element); - bool SetElementColour(int element, ColourRGBA colour); - bool SetElementColourOptional(int element, uptr_t wParam, sptr_t lParam); - void SetElementRGB(int element, int rgb); - void SetElementAlpha(int element, int alpha); - bool ElementIsSet(int element) const; - bool SetElementBase(int element, ColourRGBA colour); - - bool SetWrapState(int wrapState_) noexcept; - bool SetWrapVisualFlags(int wrapVisualFlags_) noexcept; - bool SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation_) noexcept; + void AddMultiEdge(Scintilla::uptr_t wParam, Scintilla::sptr_t lParam); + + std::optional<ColourRGBA> ElementColour(Scintilla::Element element) const; + bool ElementAllowsTranslucent(Scintilla::Element element) const; + bool ResetElement(Scintilla::Element element); + bool SetElementColour(Scintilla::Element element, ColourRGBA colour); + bool SetElementColourOptional(Scintilla::Element element, Scintilla::uptr_t wParam, Scintilla::sptr_t lParam); + void SetElementRGB(Scintilla::Element element, int rgb); + void SetElementAlpha(Scintilla::Element element, int alpha); + bool ElementIsSet(Scintilla::Element element) const; + bool SetElementBase(Scintilla::Element element, ColourRGBA colour); + + bool SetWrapState(Scintilla::Wrap wrapState_) noexcept; + bool SetWrapVisualFlags(Scintilla::WrapVisualFlag wrapVisualFlags_) noexcept; + bool SetWrapVisualFlagsLocation(Scintilla::WrapVisualLocation wrapVisualFlagsLocation_) noexcept; bool SetWrapVisualStartIndent(int wrapVisualStartIndent_) noexcept; - bool SetWrapIndentMode(int wrapIndentMode_) noexcept; + bool SetWrapIndentMode(Scintilla::WrapIndentMode wrapIndentMode_) noexcept; bool WhiteSpaceVisible(bool inIndent) const noexcept; |