Пример #1
0
bool CGUITextLayout::UpdateW(const CStdStringW &text, float maxWidth /*= 0*/, bool forceUpdate /*= false*/, bool forceLTRReadingOrder /*= false*/)
{
  if (text.Equals(m_lastText) && !forceUpdate)
    return false;

  // parse the text for style information
  vecText parsedText;
  vecColors colors;
  ParseText(text, m_font ? m_font->GetStyle() : 0, m_textColor, colors, parsedText);

  // and update
  UpdateStyled(parsedText, colors, maxWidth, forceLTRReadingOrder);
  m_lastText = text;
  return true;
}
Пример #2
0
bool CGUITextLayout::UpdateW(const CStdStringW &text, float maxWidth /*= 0*/, bool forceUpdate /*= false*/, bool forceLTRReadingOrder /*= false*/)
{
    if (text.Equals(m_lastText) && !forceUpdate)
        return false;

    vecText parsedText;

    // empty out our previous string
    m_lines.clear();
    m_colors.clear();
    m_colors.push_back(m_textColor);

    // parse the text into our string objects
    ParseText(text, parsedText);

    // add \n to the end of the string
    parsedText.push_back(L'\n');

    // if we need to wrap the text, then do so
    if (m_wrap && maxWidth > 0)
        WrapText(parsedText, maxWidth);
    else
        LineBreakText(parsedText, m_lines);

    // remove any trailing blank lines
    while (!m_lines.empty() && m_lines.back().m_text.empty())
        m_lines.pop_back();

    BidiTransform(m_lines, forceLTRReadingOrder);

    // and cache the width and height for later reading
    CalcTextExtent();

    m_lastText = text;
    return true;
}