MyGUI 3.4.1
MyGUI_TextBox.cpp
Go to the documentation of this file.
1/*
2 * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3 * Distributed under the MIT License
4 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5 */
6
7#include "MyGUI_Precompiled.h"
8#include "MyGUI_TextBox.h"
10#include "MyGUI_Constants.h"
11
12namespace MyGUI
13{
14
16 {
17 }
18
20 {
21 return (nullptr == getSubWidgetText()) ? IntCoord() : getSubWidgetText()->getCoord();
22 }
23
25 {
26 return (nullptr == getSubWidgetText()) ? IntSize() : getSubWidgetText()->getTextSize();
27 }
28
30 {
31 if (getSubWidgetText() != nullptr)
33 }
34
36 {
37 if (getSubWidgetText() != nullptr)
39 return Align::Default;
40 }
41
42 void TextBox::setTextColour(const Colour& _value)
43 {
44 if (nullptr != getSubWidgetText())
46 }
47
49 {
50 return (nullptr == getSubWidgetText()) ? Colour::Zero : getSubWidgetText()->getTextColour();
51 }
52
53 void TextBox::setFontName(const std::string& _value)
54 {
55 if (nullptr != getSubWidgetText())
57 }
58
59 const std::string& TextBox::getFontName() const
60 {
61 if (nullptr == getSubWidgetText())
63 return getSubWidgetText()->getFontName();
64 }
65
66 void TextBox::setFontHeight(int _height)
67 {
68 if (nullptr != getSubWidgetText())
70 }
71
73 {
74 return (nullptr == getSubWidgetText()) ? 0 : getSubWidgetText()->getFontHeight();
75 }
76
77 void TextBox::setCaption(const UString& _caption)
78 {
79 if (nullptr != getSubWidgetText())
80 getSubWidgetText()->setCaption(_caption);
81 }
82
84 {
85 if (nullptr == getSubWidgetText())
87 return getSubWidgetText()->getCaption();
88 }
89
90 void TextBox::setCaptionWithReplacing(const std::string& _value)
91 {
92 // replace "\\n" with char '\n'
93 size_t pos = _value.find("\\n");
94 if (pos == std::string::npos)
95 {
96 setCaption(LanguageManager::getInstance().replaceTags(_value));
97 }
98 else
99 {
100 std::string value(_value);
101 while (pos != std::string::npos)
102 {
103 value[pos++] = '\n';
104 value.erase(pos, 1);
105 pos = value.find("\\n");
106 }
107 setCaption(LanguageManager::getInstance().replaceTags(value));
108 }
109 }
110
112 {
113 if (nullptr != getSubWidgetText())
115 }
116
118 {
119 return (nullptr == getSubWidgetText()) ? Colour::Black : getSubWidgetText()->getShadowColour();
120 }
121
122 void TextBox::setTextShadow(bool _value)
123 {
124 if (nullptr != getSubWidgetText())
125 getSubWidgetText()->setShadow(_value);
126 }
127
129 {
130 return (nullptr == getSubWidgetText()) ? false : getSubWidgetText()->getShadow();
131 }
132
133 void TextBox::setPropertyOverride(const std::string& _key, const std::string& _value)
134 {
136 if (_key == "TextColour")
137 setTextColour(utility::parseValue<Colour>(_value));
138
140 else if (_key == "TextAlign")
141 setTextAlign(utility::parseValue<Align>(_value));
142
144 else if (_key == "FontName")
145 setFontName(_value);
146
148 else if (_key == "FontHeight")
149 setFontHeight(utility::parseValue<int>(_value));
150
152 else if (_key == "Caption")
154
156 else if (_key == "TextShadowColour")
157 setTextShadowColour(utility::parseValue<Colour>(_value));
158
160 else if (_key == "TextShadow")
161 setTextShadow(utility::parseValue<bool>(_value));
162
163 else
164 {
165 Base::setPropertyOverride(_key, _value);
166 return;
167 }
168
169 eventChangeProperty(this, _key, _value);
170 }
171
172} // namespace MyGUI
static const std::string & getEmptyString()
static const UString & getEmptyUString()
const IntCoord & getCoord() const
virtual void setTextAlign(Align _value)
virtual bool getShadow() const
virtual const Colour & getTextColour() const
virtual const UString & getCaption() const
virtual void setShadowColour(const Colour &_value)
virtual const std::string & getFontName() const
virtual IntSize getTextSize() const
virtual void setShadow(bool _value)
virtual int getFontHeight() const
virtual void setFontHeight(int _value)
virtual void setTextColour(const Colour &_value)
virtual Align getTextAlign() const
virtual const Colour & getShadowColour() const
virtual void setFontName(const std::string &_value)
virtual void setCaption(const UString &_value)
static LanguageManager & getInstance()
ISubWidgetText * getSubWidgetText() const
const Colour & getTextShadowColour() const
virtual void setTextAlign(Align _value)
void setCaptionWithReplacing(const std::string &_value)
const std::string & getFontName() const
virtual int getFontHeight() const
virtual void setTextColour(const Colour &_value)
virtual void setFontHeight(int _value)
void setPropertyOverride(const std::string &_key, const std::string &_value) override
virtual const UString & getCaption() const
virtual IntSize getTextSize() const
bool getTextShadow() const
virtual void setTextShadowColour(const Colour &_value)
virtual void setTextShadow(bool _value)
const Colour & getTextColour() const
virtual void setFontName(const std::string &_value)
virtual void setCaption(const UString &_value)
virtual IntCoord getTextRegion() const
Align getTextAlign() const
A UTF-16 string with implicit conversion to/from std::string and std::wstring.
EventHandle_WidgetStringString eventChangeProperty
Definition: MyGUI_Widget.h:267
types::TCoord< int > IntCoord
Definition: MyGUI_Types.h:35
types::TSize< int > IntSize
Definition: MyGUI_Types.h:29
static const Colour Zero
Definition: MyGUI_Colour.h:55
static const Colour Black
Definition: MyGUI_Colour.h:56