aboutsummaryrefslogtreecommitdiff
path: root/include/cru/ui/document/TextDocumentElement.h
blob: f7205b59310008a012998e1cedc65950621c6b60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#pragma once

#include "../Base.h"
#include "DocumentElement.h"
#include "cru/common/Base.h"
#include "cru/common/Bitmask.h"

namespace cru::ui::document {
namespace details {
struct TextStyleTag {};
}  // namespace details

using TextStyle = Bitmask<details::TextStyleTag>;

struct TextStyles {
  static constexpr TextStyle Normal;
  static constexpr TextStyle Bold{0x1};
  static constexpr TextStyle Italic{0x2};
};

struct IDocumentLink : virtual Interface {
  virtual void Open() = 0;
};

class CRU_UI_API TextDocumentElement : public DocumentElement {
 public:
  TextDocumentElement(String text, TextStyle style, IDocumentLink* link);

  ~TextDocumentElement() override;

  String GetText() const { return text_; }
  void SetText(String text);

  TextStyle GetStyle() const { return style_; }
  void SetStyle(TextStyle style);

  IDocumentLink* GetLink() const { return link_; }
  void SetLink(IDocumentLink link);

 private:
  String text_;
  TextStyle style_;
  IDocumentLink* link_;
};
}  // namespace cru::ui::document