Allow to use stringw directly when setText

This commit is contained in:
Benau 2019-06-15 13:56:36 +08:00
parent a56343b7e3
commit fc143276fe
15 changed files with 19 additions and 32 deletions

View File

@ -477,7 +477,7 @@ public:
//! Sets the new caption of this element.
virtual void setText(const wchar_t* text)
virtual void setText(const irr::core::stringw& text)
{
Text = text;
}

View File

@ -916,7 +916,7 @@ void CGUIEditBox::draw()
//! Sets the new caption of this element.
void CGUIEditBox::setText(const wchar_t* text)
void CGUIEditBox::setText(const core::stringw& text)
{
Text = text;
if (u32(CursorPos) > Text.size())

View File

@ -97,7 +97,7 @@ namespace gui
virtual void draw();
//! Sets the new caption of this element.
virtual void setText(const wchar_t* text);
virtual void setText(const core::stringw& text);
//! Sets the maximum amount of characters which may be entered in the box.
//! \param max: Maximum amount of characters. If 0, the character amount is

View File

@ -284,7 +284,7 @@ void CGUISpinBox::verifyValueRange()
//! Sets the new caption of the element
void CGUISpinBox::setText(const wchar_t* text)
void CGUISpinBox::setText(const core::stringw& text)
{
EditBox->setText(text);
setValue(getValue());

View File

@ -66,7 +66,7 @@ namespace gui
virtual void draw();
//! Sets the new caption of the element
virtual void setText(const wchar_t* text);
virtual void setText(const core::stringw& text);
//! Returns caption of this element.
virtual const wchar_t* getText() const;

View File

@ -302,8 +302,10 @@ void CGUIStaticText::breakText()
//! Sets the new caption of this element.
void CGUIStaticText::setText(const wchar_t* text)
void CGUIStaticText::setText(const core::stringw& text)
{
if (text == Text)
return;
IGUIElement::setText(text);
breakText();
}

View File

@ -88,7 +88,7 @@ namespace gui
virtual bool isWordWrapEnabled() const;
//! Sets the new caption of this element.
virtual void setText(const wchar_t* text);
virtual void setText(const core::stringw& text);
//! Returns the height of the text in pixels when it is drawn.
virtual s32 getTextHeight() const;

View File

@ -121,7 +121,7 @@ Widget::~Widget()
}
// -----------------------------------------------------------------------------
void Widget::setText(const wchar_t *s)
void Widget::setText(const irr::core::stringw &s)
{
m_text = s;
if(m_element)

View File

@ -475,17 +475,7 @@ namespace GUIEngine
* \note Changing the text property will only take effect the next time this widget
* is add()ed
*/
virtual void setText(const wchar_t *s);
/**
* Sets the text of a widget from a stringw.
* \note This method uses the virtual setText(wchar_t*) function, so only the latter
* needs to be overwritten by other classes.
* \note Not all widgets use strings, so some widgets may ignore this text property
* \note Changing the text property will only take effect the next time this widget
* is add()ed
*/
virtual void setText(const irr::core::stringw &s) { setText(s.c_str()); }
virtual void setText(const irr::core::stringw &s);
/** Returns the text of a widget. */
const irr::core::stringw &getText() const {return m_text; }

View File

@ -1029,7 +1029,7 @@ void CGUIEditBox::draw()
//! Sets the new caption of this element.
void CGUIEditBox::setText(const wchar_t* text)
void CGUIEditBox::setText(const core::stringw& text)
{
m_edit_text = StringUtils::wideToUtf32(text);
updateGlyphLayouts();

View File

@ -95,7 +95,7 @@ namespace GUIEngine
virtual void draw();
//! Sets the new caption of this element.
virtual void setText(const wchar_t* text);
virtual void setText(const core::stringw& text);
//! Sets the maximum amount of characters which may be entered in the box.
//! \param max: Maximum amount of characters. If 0, the character amount is

View File

@ -763,7 +763,7 @@ void DynamicRibbonWidget::onRibbonWidgetScroll(const int delta_x)
// -----------------------------------------------------------------------------
void DynamicRibbonWidget::setText(const wchar_t *text)
void DynamicRibbonWidget::setText(const irr::core::stringw& text)
{
Widget::setText(text);

View File

@ -310,7 +310,7 @@ namespace GUIEngine
/** \brief callback from IRibbonListener */
virtual void onSelectionChange(){}
virtual void setText(const wchar_t *text);
virtual void setText(const irr::core::stringw& text);
virtual void update(float delta);

View File

@ -117,14 +117,15 @@ void LabelWidget::add()
// ----------------------------------------------------------------------------
void LabelWidget::setText(const wchar_t *text, bool expandIfNeeded)
void LabelWidget::setText(const core::stringw& text, bool expandIfNeeded)
{
m_scroll_offset = 0;
if (expandIfNeeded)
{
assert(m_element != NULL);
const int fwidth = (m_title_font ? GUIEngine::getTitleFont() : GUIEngine::getFont())->getDimension(text).Width;
const int fwidth = (m_title_font ? GUIEngine::getTitleFont() : GUIEngine::getFont())
->getDimension(text.c_str()).Width;
core::rect<s32> rect = m_element->getRelativePosition();
if (rect.getWidth() < fwidth)

View File

@ -86,13 +86,7 @@ namespace GUIEngine
* too small to contain \c text. Note that this option may
* only be passed after the widget has been add()ed.
*/
virtual void setText(const wchar_t *text, bool expandAsNeeded);
/** Overloaded function which takes a stringw. */
virtual void setText(const irr::core::stringw &s, bool expandAsNeeded)
{
setText(s.c_str(), expandAsNeeded);
}
virtual void setText(const irr::core::stringw& text, bool expandAsNeeded);
// --------------------------------------------------------------------