UGDK  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
textbox.h
Go to the documentation of this file.
1 #ifndef UGDK_GRAPHIC_DRAWABLE_TEXTBOX_H_
2 #define UGDK_GRAPHIC_DRAWABLE_TEXTBOX_H_
3 
4 #include <ugdk/math/vector2D.h>
5 #include <ugdk/text.h>
6 #include <ugdk/graphic.h>
7 #include <ugdk/ui/drawable.h>
8 #include <ugdk/util/utf8.h>
9 
10 #include <vector>
11 #include <list>
12 #include <string>
13 #include <memory>
14 
15 namespace ugdk {
16 namespace text {
17 
18 class TextBox : public ui::Drawable {
19  public:
20  TextBox(const std::string& message, double width, Font* font);
21  ~TextBox();
22 
23  enum IdentStyle {
25  };
26 
28  void ChangeMessage(const std::string& message);
29 
30  void Draw(graphic::Canvas&) const override;
31 
32  void set_ident_style(IdentStyle style) { ident_style_ = style; }
33 
34  double width() const { return width_; }
35  const ugdk::math::Vector2D& size() const override { return size_; }
36  IdentStyle ident_style() const { return ident_style_; }
37 
38  private:
39  Font* font_;
40  double width_;
41  std::vector< std::unique_ptr<Label> > labels_;
42  IdentStyle ident_style_;
43 
45 
46  void splitString(const std::u32string&, std::list<std::u32string>&);
47  double calculateWidth(std::u32string::const_iterator start, std::u32string::const_iterator end);
48 };
49 
50 } // namespace text
51 } // namespace ugdk
52 
53 #endif
Definition: canvas.h:28
Definition: vector2D.h:18
Definition: textbox.h:24
void ChangeMessage(const std::string &message)
This operation is slow.
Definition: font.h:16
Definition: animation.h:11
Definition: drawable.h:13
Definition: textbox.h:24
IdentStyle ident_style() const
Definition: textbox.h:36
const ugdk::math::Vector2D & size() const override
Definition: textbox.h:35
void Draw(graphic::Canvas &) const override
void set_ident_style(IdentStyle style)
Definition: textbox.h:32
TextBox(const std::string &message, double width, Font *font)
double width() const
Definition: textbox.h:34
Definition: textbox.h:24
IdentStyle
Definition: textbox.h:23
Definition: textbox.h:18