Dynamically test if text is rtl or not

This commit is contained in:
Flakebi 2015-04-09 01:54:10 +02:00
parent 66dd089902
commit effe131e4a
10 changed files with 17 additions and 23 deletions

View File

@ -229,7 +229,6 @@ if(prop_name != NULL) widget.m_properties[prop_flag] = core::stringc(prop_name).
if (text != NULL)
{
widget.m_text = _(text);
widget.m_is_text_rtl = (translations->isRTLLanguage() && widget.m_text != text);
}
const wchar_t* raw_text = xml->getAttributeValue(L"raw_text");

View File

@ -76,7 +76,6 @@ Widget::Widget(WidgetType type, bool reserve_id)
m_supports_multiplayer = false;
m_is_bounding_box_round = false;
m_has_tooltip = false;
m_is_text_rtl = false;
m_absolute_x = m_absolute_y = m_absolute_w = m_absolute_h = -1;
m_relative_x = m_relative_y = m_relative_w = m_relative_h = -1;

View File

@ -156,9 +156,6 @@ namespace GUIEngine
* go in the map above, which uses narrow strings */
irr::core::stringw m_text;
/** Whether the text in m_text is right-to-left */
bool m_is_text_rtl;
/** When true, this widget shall use a bigger and more colourful font */
bool m_title_font;

View File

@ -53,11 +53,7 @@ void BubbleWidget::add()
false, true /* word wrap */, m_parent,
(m_focusable ? getNewID() : getNewNoFocusID()));
irrwidget->setTextRestrainedInside(false);
#if IRRLICHT_VERSION_MAJOR > 1 || (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR >= 8)
irrwidget->setRightToLeft( translations->isRTLLanguage() );
#endif
irrwidget->setRightToLeft(translations->isRTLText(message));
m_element = irrwidget;
replaceText();
@ -120,9 +116,11 @@ void BubbleWidget::replaceText()
void BubbleWidget::setText(const irr::core::stringw &s)
{
Widget::setText(s);
//If add() has already been called (and thus m_element is set) we need to replace the text.
if(m_element != NULL){
if (m_element != NULL)
{
//If add() has already been called (and thus m_element is set) we need to replace the text.
replaceText();
getIrrlichtElement<IGUIStaticText>()->setRightToLeft(translations->isRTLText(getText()));
}
}

View File

@ -196,10 +196,8 @@ void IconButtonWidget::add()
setLabelFont();
#if IRRLICHT_VERSION_MAJOR > 1 || (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR >= 8)
m_label->setRightToLeft( translations->isRTLLanguage() );
m_label->setRightToLeft(translations->isRTLText(message));
m_label->setTextRestrainedInside(false);
#endif
}
// ---- IDs

View File

@ -80,13 +80,9 @@ void LabelWidget::add()
{
irrwidget = GUIEngine::getGUIEnv()->addStaticText(message.c_str(), widget_size,
false, word_wrap, m_parent, -1);
#if IRRLICHT_VERSION_MAJOR > 1 || (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR >= 8)
irrwidget->setTextRestrainedInside(false);
#endif
}
#if IRRLICHT_VERSION_MAJOR > 1 || (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR >= 8)
irrwidget->setRightToLeft( m_is_text_rtl );
#endif
irrwidget->setRightToLeft(translations->isRTLText(message));
m_element = irrwidget;
irrwidget->setTextAlignment( align, valign );
@ -155,6 +151,8 @@ void LabelWidget::setText(const wchar_t *text, bool expandIfNeeded)
}
Widget::setText(text);
if (m_element)
getIrrlichtElement<IGUIStaticText>()->setRightToLeft(translations->isRTLText(getText()));
} // setText
// ----------------------------------------------------------------------------

View File

@ -262,6 +262,7 @@ void RibbonWidget::add()
label->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);
label->setTabStop(false);
label->setNotClipped(true);
label->setRightToLeft(translations->isRTLText(message));
m_labels.push_back(label);
subbtn->setTabStop(false);

View File

@ -145,7 +145,8 @@ void SpinnerWidget::add()
else
{
rect<s32> subsize_label = rect<s32>(m_h, 0, m_w - m_h, m_h);
IGUIStaticText* label = GUIEngine::getGUIEnv()->addStaticText(stringw(m_value).c_str(), subsize_label,
const wchar_t *text = stringw(m_value).c_str();
IGUIStaticText* label = GUIEngine::getGUIEnv()->addStaticText(text, subsize_label,
false /* border */, true /* word wrap */,
btn, getNewNoFocusID());
m_children[1].m_element = label;
@ -155,6 +156,7 @@ void SpinnerWidget::add()
label->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);
label->setTabStop(false);
label->setNotClipped(true);
label->setRightToLeft(translations->isRTLText(text));
if (m_labels.size() > 0)

View File

@ -76,7 +76,7 @@ AddDeviceDialog::AddDeviceDialog() : ModalDialog(0.90f, 0.80f)
/*word wrap*/true,
m_irrlicht_window);
b->setTabStop(false);
b->setRightToLeft(translations->isRTLLanguage());
b->setRightToLeft(translations->isRTLText(msg));
// because it looks like 'setRightToLeft' applies next time
// setText is called only
b->setText(msg.c_str());

View File

@ -79,12 +79,14 @@ GPInfoDialog::~GPInfoDialog()
void GPInfoDialog::addTitle()
{
core::rect< s32 > area_top(0, 0, m_area.getWidth(), m_under_title);
const wchar_t *text = translations->fribidize(m_gp.getName());
IGUIStaticText* title = GUIEngine::getGUIEnv()->addStaticText(
translations->fribidize(m_gp.getName()),
text,
area_top, false, true, // border, word wrap
m_irrlicht_window);
title->setTabStop(false);
title->setTextAlignment(irr::gui::EGUIA_CENTER, irr::gui::EGUIA_CENTER);
title->setRightToLeft(translations->isRTLText(text));
}
// ----------------------------------------------------------------------------