Hasty Badger
Small UI library (a branch of Turbo Badger)
 All Classes Namespaces Functions Variables Enumerations Enumerator Friends Groups Pages
tb_style_edit_content.h
1 // ================================================================================
2 // == This file is a part of Turbo Badger. (C) 2011-2014, Emil SegerÃ¥s ==
3 // == See tb_core.h for more information. ==
4 // ================================================================================
5 
6 #ifndef TB_STYLE_EDIT_CONTENT_H
7 #define TB_STYLE_EDIT_CONTENT_H
8 
9 #include "tb_core.h"
10 
11 namespace tb {
12 
13 class TBTextFragment;
14 
18 {
19 public:
20  virtual ~TBTextFragmentContent() {}
21 
23  virtual void UpdatePos(int /*x*/, int /*y*/) {}
24 
25  virtual void Paint(TBTextFragment * /*fragment*/, int32_t /*translate_x*/, int32_t /*translate_y*/, TBTextProps * /*props*/) {}
26  virtual void Click(TBTextFragment * /*fragment*/, int /*button*/, uint32_t /*modifierkeys*/) {}
27  virtual int32_t GetWidth(TBFontFace * /*font*/, TBTextFragment * /*fragment*/) { return 0; }
28  virtual int32_t GetHeight(TBFontFace * /*font*/, TBTextFragment * /*fragment*/) { return 0; }
29  virtual int32_t GetBaseline(TBFontFace * font, TBTextFragment * fragment) { return GetHeight(font, fragment); }
30  virtual bool GetAllowBreakBefore() { return true; }
31  virtual bool GetAllowBreakAfter() { return true; }
32 
34  virtual uint32_t GetType() { return 0; }
35 };
36 
40 {
41 public:
42  TBTextFragmentContentHR(int32_t width_in_percent, int32_t height);
43 
44  virtual void Paint(TBTextFragment *fragment, int32_t translate_x, int32_t translate_y, TBTextProps *props);
45  virtual int32_t GetWidth(TBFontFace *font, TBTextFragment *fragment);
46  virtual int32_t GetHeight(TBFontFace *font, TBTextFragment *fragment);
47 private:
48  int32_t width_in_percent, height;
49 };
50 
54 {
55 public:
57  virtual void Paint(TBTextFragment *fragment, int32_t translate_x, int32_t translate_y, TBTextProps *props);
58  virtual bool GetAllowBreakBefore() { return true; }
59  virtual bool GetAllowBreakAfter() { return false; }
60 };
61 
65 {
66 public:
67  TBColor color;
68  TBTextFragmentContentTextColor(const TBColor &color) : color(color) {}
69  virtual void Paint(TBTextFragment *fragment, int32_t translate_x, int32_t translate_y, TBTextProps *props);
70  virtual bool GetAllowBreakBefore() { return true; }
71  virtual bool GetAllowBreakAfter() { return false; }
72 };
73 
77 {
78 public:
79  uint32_t _size;
80  TBTextFragmentContentTextSize(uint32_t size) : _size(size) {}
81  virtual void Paint(TBTextFragment *fragment, int32_t translate_x, int32_t translate_y, TBTextProps *props);
82  //virtual int32_t GetHeight(TBFontFace * font, TBTextFragment * /*fragment*/);
83  virtual bool GetAllowBreakBefore() { return true; }
84  virtual bool GetAllowBreakAfter() { return false; }
85 };
86 
90 {
91 public:
92  uint32_t _size;
94  virtual void Paint(TBTextFragment *fragment, int32_t translate_x, int32_t translate_y, TBTextProps *props) {}
95  //virtual int32_t GetHeight(TBFontFace * font, TBTextFragment * /*fragment*/);
96 };
97 
101 {
102 public:
103  uint32_t _size;
105  virtual void Paint(TBTextFragment *fragment, int32_t translate_x, int32_t translate_y, TBTextProps *props) {}
106  //virtual int32_t GetHeight(TBFontFace * font, TBTextFragment * /*fragment*/);
107 };
108 
112 {
113 public:
114  virtual void Paint(TBTextFragment *fragment, int32_t translate_x, int32_t translate_y, TBTextProps *props);
115  virtual bool GetAllowBreakBefore() { return false; }
116  virtual bool GetAllowBreakAfter() { return true; }
117 };
118 
119 } // namespace tb
120 
121 #endif // TB_STYLE_EDIT_CONTENT_H
A horizontal line for TBStyleEdit.
Definition: tb_style_edit_content.h:39
Fragment content that changes size in a TBStyleEdit.
Definition: tb_style_edit_content.h:100
Fragment content that changes size in a TBStyleEdit.
Definition: tb_style_edit_content.h:89
Content for a non-text TBTextFragment.
Definition: tb_style_edit_content.h:17
TBFontFace represents a loaded font that can measure and render strings.
Definition: tb_font_renderer.h:142
TBTextProps is a stack of properties used during layout & paint of TBStyleEdit.
Definition: tb_style_edit.h:146
Fragment content that enables underline in a TBStyleEdit.
Definition: tb_style_edit_content.h:53
Fragment content that changes color in a TBStyleEdit.
Definition: tb_style_edit_content.h:64
The textfragment baseclass for TBStyleEdit.
Definition: tb_style_edit.h:265
TBColor contains a 32bit color.
Definition: tb_color.h:21
virtual void UpdatePos(int, int)
Update the position of the content, relative to the first line of text (no scrolling applied)...
Definition: tb_style_edit_content.h:23
Fragment content that ends a change of style in a TBStyleEdit.
Definition: tb_style_edit_content.h:111
Fragment content that changes size in a TBStyleEdit.
Definition: tb_style_edit_content.h:76
virtual uint32_t GetType()
Get type of fragment content.
Definition: tb_style_edit_content.h:34