Oxygine  1
2g game engine
TextField.h
1 #pragma once
2 #include "oxygine-include.h"
3 #include "Actor.h"
4 #include "TextStyle.h"
5 #include "VisualStyle.h"
6 
7 namespace oxygine
8 {
9  DECLARE_SMART(TextField, spTextField);
10  class TextField : public VStyleActor
11  {
12  INHERITED(VStyleActor);
13  public:
14  static void setDefaultFont(ResFont*);
15  static ResFont* getDefaultFont();
16 
17  enum {EVENT_REBUILD = sysEventID('T', 'F', 'r') };
18 
19  DECLARE_COPYCLONE_NEW(TextField);
20  TextField();
21  ~TextField();
22 
23  void serialize(serializedata* data) override;
24  void deserialize(const deserializedata* data) override;
25 
27  const TextStyle& getStyle() const {return _style;}
29  const Rect& getTextRect(float localScale = 1.0f) const;
31  const std::string& getText() const { return _text; }
32  const ResFont* getFont() const;
33 
34  int getFontSize() const;
35  int getLinesOffset() const;
36  int getKerning() const;
37  TextStyle::VerticalAlign getVAlign() const;
38  TextStyle::HorizontalAlign getHAlign() const;
39  bool getMultiline() const;
40  bool getBreakLongWords() const;
41  text::Symbol* getSymbolAt(int pos) const;
42  const Color& getOutlineColor() const;
43  float getOutline() const;
44  const Color& getStyleColor() const;
45  float getWeight() const;
46  float getBaselineScale() const;
47  unsigned int getOptions() const;
48 
49 
50  bool getBounds(RectF&) const override;
51 
53  void setVAlign(TextStyle::VerticalAlign align);
55  void setHAlign(TextStyle::HorizontalAlign align);
56  void setAlign(TextStyle::VerticalAlign, TextStyle::HorizontalAlign);
58  void setMultiline(bool multiline);
60  void setBreakLongWords(bool val);
62  void setLinesOffset(int offset);
64  void setBaselineScale(float scale);
66  void setKerning(int kerning);
68  void setFontSize(int size);
70  void setStyleColor(const Color&);
72  void setOptions(unsigned int opt);
73 
75  void setFont(const ResFont* rs);
76 
78  void setOutlineColor(const Color&);
80  void setOutline(float v);
82  void setWeight(float w);
83 
84  void setStyle(const TextStyle& st);
86  void setText(const std::string& str);
88  void setText(const std::wstring& str);
95  void setHtmlText(const std::string& str);
96  void setHtmlText(const std::wstring& str);
97 
98  bool isOn(const Vector2& localPosition, float localScale = 1.0f) override;
99 
100 
102 
103 
104  public:
105 
106  std::string dump(const dumpOptions& options) const override;
107  void doRender(const RenderState&) override;
108 
109  text::Node* getRootNode(float scale);
110  protected:
111  enum
112  {
113  flag_html = flag_last << 1,
114  flag_rebuild = flag_last << 2,
115  };
116  std::string _text;
117  TextStyle _style;
118 
119  text::Node* _root;
120  Rect _textRect;
121  float _rtscale;
122  int _realFontSize;
123 
124 
125  void needRebuild();
126  void sizeChanged(const Vector2& size) override;
127  };
128 }
129 
130 EDITOR_INCLUDE(TextField);
Definition: Serialize.h:28
Definition: ResFont.h:8
void setFontSize(int size)
void setOptions(unsigned int opt)
void setHAlign(TextStyle::HorizontalAlign align)
Definition: TextField.h:10
Definition: Property.h:73
void setMultiline(bool multiline)
void setVAlign(TextStyle::VerticalAlign align)
void setBreakLongWords(bool val)
void setWeight(float w)
void setText(const std::string &str)
Definition: RenderState.h:27
const std::string & getText() const
Definition: TextField.h:31
void setFont(const ResFont *rs)
void setOutlineColor(const Color &)
Definition: Serialize.h:21
void setHtmlText(const std::string &str)
void setLinesOffset(int offset)
void setKerning(int kerning)
–oxgl-end–!
Definition: Actor.h:14
Definition: VisualStyle.h:29
void setStyleColor(const Color &)
Definition: TextStyle.h:8
void setBaselineScale(float scale)
std::string dump(const dumpOptions &options) const override
bool isOn(const Vector2 &localPosition, float localScale=1.0f) override
const TextStyle & getStyle() const
Definition: TextField.h:27
const Rect & getTextRect(float localScale=1.0f) const
Definition: Color.h:8
void setOutline(float v)