Beispiel #1
0
void MythUIText::SetFontProperties(const MythFontProperties &fontProps)
{
    m_FontStates.insert("default", fontProps);
    *m_Font = m_FontStates["default"];
    FillCutMessage();
    SetRedraw();
}
Beispiel #2
0
void MythUIText::UseAlternateArea(bool useAlt)
{
    if (useAlt && m_AltDisplayRect.width() > 1)
        MythUIType::SetArea(m_AltDisplayRect);
    else
        MythUIType::SetArea(m_OrigDisplayRect);
    FillCutMessage();
}
Beispiel #3
0
void MythUIText::SetArea(const MythRect &rect)
{
    MythUIType::SetArea(rect);
    m_CutMessage.clear();

    m_drawRect = m_Area;
    FillCutMessage();
}
Beispiel #4
0
void MythUIText::SetFontState(const QString &state)
{
    if (m_FontStates.contains(state))
        *m_Font = m_FontStates[state];
    else
        *m_Font = m_FontStates["default"];

    FillCutMessage();
    SetRedraw();
}
Beispiel #5
0
void MythUIText::SetMultiLine(bool multiline)
{
    m_MultiLine = multiline;
    if (m_MultiLine)
        m_Justification |= Qt::TextWordWrap;
    else
        m_Justification &= ~Qt::TextWordWrap;
    FillCutMessage();
    SetRedraw();
}
Beispiel #6
0
void MythUIText::SetJustification(int just)
{
    if (m_Justification != (just & ~Qt::TextWordWrap))
    {
        // preserve the wordbreak attribute, drop everything else
        m_Justification = m_Justification & Qt::TextWordWrap;
        m_Justification |= just;
        FillCutMessage();
        SetRedraw();
    }
}
Beispiel #7
0
void MythUIText::SetFontProperties(const MythFontProperties &fontProps)
{
    m_FontStates.insert("default", fontProps);
    if (m_Font->GetHash() != m_FontStates["default"].GetHash())
    {
        *m_Font = m_FontStates["default"];
        if (!m_Message.isEmpty())
        {
            FillCutMessage();
            SetRedraw();
        }
    }
}
Beispiel #8
0
void MythUIText::SetArea(const MythRect &rect)
{
    MythUIType::SetArea(rect);
    m_CutMessage.clear();

    m_drawRect = m_Area;
    if (m_scrolling)
    {
        QFontMetrics fm(GetFontProperties()->face());
        QSize stringSize = fm.size(Qt::TextSingleLine, m_Message);
        SetDrawRectSize(stringSize.width(), m_Area.height());
    }
    FillCutMessage();
}
Beispiel #9
0
void MythUIText::UseAlternateArea(bool useAlt)
{
    if (useAlt && m_AltDisplayRect.width() > 1)
    {
        MythUIType::SetArea(m_AltDisplayRect);
        m_usingAltArea = true;
    }
    else
    {
        MythUIType::SetArea(m_OrigDisplayRect);
        m_usingAltArea = false;
    }

    FillCutMessage();
}
Beispiel #10
0
void MythUIText::SetJustification(int just)
{
    int h = just & Qt::AlignHorizontal_Mask;
    int v = just & Qt::AlignVertical_Mask;

    if ((h && (m_Justification & Qt::AlignHorizontal_Mask) ^ h) ||
            (v && (m_Justification & Qt::AlignVertical_Mask) ^ v))
    {
        // preserve the wordbreak attribute, drop everything else
        m_Justification = m_Justification & Qt::TextWordWrap;
        m_Justification |= just;
        if (!m_Message.isEmpty())
        {
            FillCutMessage();
            SetRedraw();
        }
    }
}
Beispiel #11
0
void MythUIText::SetCutDown(Qt::TextElideMode mode)
{
    if (mode != m_Cutdown)
    {
        m_Cutdown = mode;
        if (m_scrolling && m_Cutdown != Qt::ElideNone)
        {
            LOG(VB_GENERAL, LOG_ERR, QString("'%1' (%2): <scroll> and "
                                             "<cutdown> are not combinable.")
                .arg(objectName()).arg(GetXMLLocation()));
            m_Cutdown = Qt::ElideNone;
        }
        if (!m_Message.isEmpty())
        {
            FillCutMessage();
            SetRedraw();
        }
    }
}
Beispiel #12
0
void MythUIText::SetFontState(const QString &state)
{
    if (m_FontStates.contains(state))
    {
        if (m_Font->GetHash() == m_FontStates[state].GetHash())
            return;
        *m_Font = m_FontStates[state];
    }
    else
    {
        if (m_Font->GetHash() == m_FontStates["default"].GetHash())
            return;
        *m_Font = m_FontStates["default"];
    }
    if (!m_Message.isEmpty())
    {
        FillCutMessage();
        SetRedraw();
    }
}
Beispiel #13
0
void MythUIText::SetText(const QString &text)
{
    QString newtext = text;

    if (!m_Layouts.isEmpty() && newtext == m_Message)
        return;

    if (newtext.isEmpty())
    {
        m_Message = m_DefaultMessage;
        emit DependChanged(true);
    }
    else
    {
        m_Message = newtext;
        emit DependChanged(false);
    }
    m_CutMessage.clear();
    FillCutMessage();

    SetRedraw();
}
Beispiel #14
0
void MythUIText::SetText(const QString &text)
{
    QString newtext = text;

    if (newtext == m_Message)
        return;

    if (newtext.isEmpty())
        m_Message = m_DefaultMessage;

    m_Message = newtext;
    m_CutMessage.clear();
    FillCutMessage();

    if (m_scrolling)
    {
        QFontMetrics fm(GetFontProperties()->face());
        QSize stringSize = fm.size(Qt::TextSingleLine, m_CutMessage);
        SetDrawRectSize(stringSize.width(), m_Area.height());
    }

    SetRedraw();
}
Beispiel #15
0
bool MythUIText::ParseElement(
    const QString &filename, QDomElement &element, bool showWarnings)
{
    if (element.tagName() == "area")
    {
        SetArea(parseRect(element));
        m_OrigDisplayRect = m_Area;
    }
//    else if (element.tagName() == "altarea") // Unused, but maybe in future?
//        m_AltDisplayRect = parseRect(element);
    else if (element.tagName() == "font")
    {
        QString fontname = getFirstText(element);
        MythFontProperties *fp = GetFont(fontname);
        if (!fp)
            fp = GetGlobalFontMap()->GetFont(fontname);
        if (fp)
        {
            MythFontProperties font = *fp;
            int screenHeight = GetMythMainWindow()->GetUIScreenRect().height();
            font.Rescale(screenHeight);
            int fontStretch = GetMythUI()->GetFontStretch();
            font.AdjustStretch(fontStretch);
            QString state = element.attribute("state","");
            if (!state.isEmpty())
            {
                m_FontStates.insert(state, font);
            }
            else
            {
                m_FontStates.insert("default", font);
                *m_Font = m_FontStates["default"];
            }
        }
    }
    else if (element.tagName() == "value")
    {
        if (element.attribute("lang","").isEmpty())
        {
            m_Message = qApp->translate("ThemeUI",
                                        parseText(element).toUtf8(), NULL,
                                        QCoreApplication::UnicodeUTF8);
        }
        else if (element.attribute("lang","").toLower() ==
                 gCoreContext->GetLanguageAndVariant())
        {
            m_Message = parseText(element);
        }
        else if (element.attribute("lang","").toLower() ==
                 gCoreContext->GetLanguage())
        {
            m_Message = parseText(element);
        }

        m_DefaultMessage = m_Message;
        SetText(m_Message);
    }
    else if (element.tagName() == "template")
    {
        m_TemplateText = parseText(element);
    }
    else if (element.tagName() == "cutdown")
    {
        SetCutDown(parseBool(element));
    }
    else if (element.tagName() == "multiline")
    {
        SetMultiLine(parseBool(element));
    }
    else if (element.tagName() == "align")
    {
        QString align = getFirstText(element).toLower();
        SetJustification(parseAlignment(align));
    }
    else if (element.tagName() == "colorcycle")
    {
        if (GetPainter()->SupportsAnimation())
        {
            QString tmp = element.attribute("start");
            if (!tmp.isEmpty())
                m_startColor = QColor(tmp);
            tmp = element.attribute("end");
            if (!tmp.isEmpty())
                m_endColor = QColor(tmp);
            tmp = element.attribute("steps");
            if (!tmp.isEmpty())
                m_numSteps = tmp.toInt();

            // initialize the rest of the stuff
            CycleColor(m_startColor, m_endColor, m_numSteps);
        }
        else
            m_colorCycling = false;

        m_colorCycling = parseBool(element.attribute("disable"));
    }
    else if (element.tagName() == "scroll")
    {
        if (GetPainter()->SupportsAnimation())
        {
            QString tmp = element.attribute("direction");
            if (!tmp.isEmpty())
            {
                tmp = tmp.toLower();
                if (tmp == "left")
                    m_scrollDirection = ScrollLeft;
                else if (tmp == "right")
                    m_scrollDirection = ScrollRight;
                else if (tmp == "up")
                    m_scrollDirection = ScrollUp;
                else if (tmp == "down")
                    m_scrollDirection = ScrollDown;
            }

            m_scrolling = true;
        }
        else
            m_scrolling = false;
    }
    else if (element.tagName() == "case")
    {
        QString stringCase = getFirstText(element).toLower();
        if (stringCase == "lower")
            m_textCase = CaseLower;
        else if (stringCase == "upper")
            m_textCase = CaseUpper;
        else if (stringCase == "capitalisefirst")
            m_textCase = CaseCapitaliseFirst;
        else  if (stringCase == "capitaliseall")
            m_textCase = CaseCapitaliseAll;
        else
            m_textCase = CaseNormal;
        FillCutMessage();
    }
    else
    {
        return MythUIType::ParseElement(filename, element, showWarnings);
    }

    return true;
}
Beispiel #16
0
void MythUIText::SetCutDown(bool cut)
{
    m_Cutdown = cut;
    FillCutMessage();
    SetRedraw();
}
Beispiel #17
0
void MythUIText::Finalize(void)
{
    FillCutMessage();
}