OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
StyledTextStyle.h
Go to the documentation of this file.
1
4// ###########################################################################################################################################################################################################################################################################################################################
5
6#pragma once
7
8// OpenTwin header
10#include "OTGui/StyledText.h"
12
13namespace ot {
14
16 public:
17 enum class TextSize {
18 Regular,
19 Header1,
20 Header2,
21 Header3
22 };
23
24 static std::string toString(TextSize _size);
25 static TextSize stringToTextSize(const std::string& _size);
26
28 StyledTextStyle(const ConstJsonObject& _jsonObject);
30 virtual ~StyledTextStyle() = default;
31 StyledTextStyle& operator = (const StyledTextStyle&) = default;
32
33 bool operator == (const StyledTextStyle& _other) const;
34 bool operator != (const StyledTextStyle& _other) const;
35
39 virtual void addToJsonObject(ot::JsonValue& _object, ot::JsonAllocator& _allocator) const override;
40
44 virtual void setFromJsonObject(const ot::ConstJsonObject& _object) override;
45
46 void setColorReference(StyledText::ColorReference _colorReference) { m_colorReference = _colorReference; };
47 StyledText::ColorReference getColorReference(void) const { return m_colorReference; };
48
49 void setBold(bool _isBold) { m_isBold = _isBold; };
50 bool getBold(void) const { return m_isBold; };
51
52 void setItalic(bool _isItalic) { m_isItalic = _isItalic; };
53 bool getItalic(void) const { return m_isItalic; };
54
55 void setUnderline(bool _isUnderline) { m_isUnderline = _isUnderline; };
56 bool getUnderline(void) const { return m_isUnderline; };
57
58 void setLineTrough(bool _isLineTrough) { m_isLineTrough = _isLineTrough; };
59 bool getLineTrough(void) const { return m_isLineTrough; };
60
61 void setTextSize(TextSize _size) { m_size = _size; };
62 TextSize getTextSize(void) const { return m_size; };
63
66 bool hasStyleSet(void) const { return m_colorReference != StyledText::ColorReference::Default || m_isBold || m_isItalic || m_isUnderline || m_isLineTrough || m_size != TextSize::Regular; };
67
68 private:
69 StyledText::ColorReference m_colorReference;
70 bool m_isBold;
71 bool m_isItalic;
72 bool m_isUnderline;
73 bool m_isLineTrough;
74 TextSize m_size;
75
76 };
77
78}
bool operator==(const FaceSelection &left, const FaceSelection &right)
Definition Model.cpp:55
#define OT_GUI_API_EXPORT
Definition OTGuiAPIExport.h:9
The Serializable class is the default interface of serializable objects.
Definition Serializable.h:17
ColorReference
Controls color style references.
Definition StyledText.h:19
Definition StyledTextStyle.h:15
void setItalic(bool _isItalic)
Definition StyledTextStyle.h:52
void setLineTrough(bool _isLineTrough)
Definition StyledTextStyle.h:58
bool getLineTrough(void) const
Definition StyledTextStyle.h:59
void setColorReference(StyledText::ColorReference _colorReference)
Definition StyledTextStyle.h:46
bool getItalic(void) const
Definition StyledTextStyle.h:53
TextSize getTextSize(void) const
Definition StyledTextStyle.h:62
void setUnderline(bool _isUnderline)
Definition StyledTextStyle.h:55
TextSize
Definition StyledTextStyle.h:17
virtual ~StyledTextStyle()=default
void setTextSize(TextSize _size)
Definition StyledTextStyle.h:61
StyledTextStyle(const StyledTextStyle &)=default
bool getUnderline(void) const
Definition StyledTextStyle.h:56
void setBold(bool _isBold)
Definition StyledTextStyle.h:49
bool hasStyleSet(void) const
Returns true if any style changes are set. If any style is set the generated text requires styling ot...
Definition StyledTextStyle.h:66
StyledText::ColorReference getColorReference(void) const
Definition StyledTextStyle.h:47
bool getBold(void) const
Definition StyledTextStyle.h:50
Definition Connector.h:8
rapidjson::Value JsonValue
Writable JSON value.
Definition JSON.h:27
rapidjson::GenericObject< true, rapidjson::GenericValue< rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > > > ConstJsonObject
Read only JSON Object.
Definition JSON.h:35
OT_GUI_API_EXPORT std::string toString(ColorStyleName _colorStyleName)
Definition ColorStyleTypes.cpp:10
rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > JsonAllocator
Allocator used for writing to JSON values.
Definition JSON.h:30