MyGUI 3.4.3
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 return (nullptr == getSubWidgetText()) ? IntCoord() : getSubWidgetText()->getCoord();
18 }
19
21 {
22 return (nullptr == getSubWidgetText()) ? IntSize() : getSubWidgetText()->getTextSize();
23 }
24
26 {
27 if (getSubWidgetText() != nullptr)
29 }
30
32 {
33 if (getSubWidgetText() != nullptr)
35 return Align::Default;
36 }
37
38 void TextBox::setTextColour(const Colour& _value)
39 {
40 if (nullptr != getSubWidgetText())
42 }
43
45 {
46 return (nullptr == getSubWidgetText()) ? Colour::Zero : getSubWidgetText()->getTextColour();
47 }
48
49 void TextBox::setFontName(std::string_view _value)
50 {
51 if (nullptr != getSubWidgetText())
53 }
54
55 std::string_view TextBox::getFontName() const
56 {
57 if (nullptr == getSubWidgetText())
58 return {};
59 return getSubWidgetText()->getFontName();
60 }
61
62 void TextBox::setFontHeight(int _height)
63 {
64 if (nullptr != getSubWidgetText())
66 }
67
69 {
70 return (nullptr == getSubWidgetText()) ? 0 : getSubWidgetText()->getFontHeight();
71 }
72
73 void TextBox::setCaption(const UString& _caption)
74 {
75 if (nullptr != getSubWidgetText())
76 getSubWidgetText()->setCaption(_caption);
77 }
78
80 {
81 if (nullptr == getSubWidgetText())
83 return getSubWidgetText()->getCaption();
84 }
85
86 void TextBox::setCaptionWithReplacing(std::string_view _value)
87 {
88 // replace "\\n" with char '\n'
89 size_t pos = _value.find("\\n");
90 if (pos == std::string::npos)
91 {
92 setCaption(LanguageManager::getInstance().replaceTags(UString(_value)));
93 }
94 else
95 {
96 std::string value(_value);
97 while (pos != std::string::npos)
98 {
99 value[pos++] = '\n';
100 value.erase(pos, 1);
101 pos = value.find("\\n");
102 }
103 setCaption(LanguageManager::getInstance().replaceTags(value));
104 }
105 }
106
108 {
109 if (nullptr != getSubWidgetText())
111 }
112
114 {
115 return (nullptr == getSubWidgetText()) ? Colour::Black : getSubWidgetText()->getShadowColour();
116 }
117
118 void TextBox::setTextShadow(bool _value)
119 {
120 if (nullptr != getSubWidgetText())
121 getSubWidgetText()->setShadow(_value);
122 }
123
125 {
126 return (nullptr == getSubWidgetText()) ? false : getSubWidgetText()->getShadow();
127 }
128
129 void TextBox::setPropertyOverride(std::string_view _key, std::string_view _value)
130 {
132 if (_key == "TextColour")
134
136 else if (_key == "TextAlign")
138
140 else if (_key == "FontName")
141 setFontName(_value);
142
144 else if (_key == "FontHeight")
146
148 else if (_key == "Caption")
150
152 else if (_key == "TextShadowColour")
154
156 else if (_key == "TextShadow")
158
159 else
160 {
161 Base::setPropertyOverride(_key, _value);
162 return;
163 }
164
165 eventChangeProperty(this, _key, _value);
166 }
167
168} // namespace MyGUI
static const UString & getEmptyUString()
const IntCoord & getCoord() const
virtual bool getShadow() const
virtual void setTextColour(const Colour &)
virtual const Colour & getTextColour() const
virtual const UString & getCaption() const
virtual void setTextAlign(Align)
virtual void setCaption(const UString &)
virtual IntSize getTextSize() const
virtual void setShadowColour(const Colour &)
virtual void setFontHeight(int)
virtual int getFontHeight() const
virtual void setFontName(std::string_view)
virtual Align getTextAlign() const
virtual std::string_view getFontName() const
virtual const Colour & getShadowColour() const
virtual void setShadow(bool)
static LanguageManager & getInstance()
ISubWidgetText * getSubWidgetText() const
const Colour & getTextShadowColour() const
virtual void setTextAlign(Align _value)
virtual void setCaption(const UString &_caption)
void setPropertyOverride(std::string_view _key, std::string_view _value) override
virtual int getFontHeight() const
virtual void setTextColour(const Colour &_value)
virtual const UString & getCaption() const
virtual IntSize getTextSize() const
bool getTextShadow() const
virtual void setTextShadowColour(const Colour &_value)
void setCaptionWithReplacing(std::string_view _value)
virtual void setFontName(std::string_view _value)
virtual void setTextShadow(bool _value)
const Colour & getTextColour() const
virtual IntCoord getTextRegion() const
virtual void setFontHeight(int _height)
std::string_view getFontName() const
Align getTextAlign() const
A UTF-16 string with implicit conversion to/from std::string and std::wstring.
size_type find(const UString &str, size_type index=0) const
returns the index of the first occurrence of str within the current string, starting at index; return...
EventHandle_WidgetStringString eventChangeProperty
T parseValue(std::string_view _value)
types::TCoord< int > IntCoord
Definition MyGUI_Types.h:36
types::TSize< int > IntSize
Definition MyGUI_Types.h:30
static const Colour Zero
static const Colour Black