00001
00002 #include "mythuisimpletext.h"
00003
00004 #include <QCoreApplication>
00005 #include <QtGlobal>
00006 #include <QDomDocument>
00007 #include <QFontMetrics>
00008 #include <QString>
00009 #include <QHash>
00010
00011 #include "mythlogging.h"
00012
00013 #include "mythuihelper.h"
00014 #include "mythpainter.h"
00015 #include "mythmainwindow.h"
00016 #include "mythcorecontext.h"
00017
00018 #include "compat.h"
00019
00020 MythUISimpleText::MythUISimpleText(MythUIType *parent, const QString &name)
00021 : MythUIType(parent, name),
00022 m_Justification(Qt::AlignLeft | Qt::AlignTop)
00023 {
00024 }
00025
00026 MythUISimpleText::MythUISimpleText(const QString &text,
00027 const MythFontProperties &font,
00028 const QRect & rect, Qt::Alignment align,
00029 MythUIType *parent, const QString &name)
00030 : MythUIType(parent, name),
00031 m_Justification(align),
00032 m_Font(font),
00033 m_Message(text.trimmed())
00034 {
00035 SetArea(rect);
00036 m_Font = font;
00037 }
00038
00039 MythUISimpleText::~MythUISimpleText()
00040 {
00041 }
00042
00043 void MythUISimpleText::DrawSelf(MythPainter *p, int xoffset, int yoffset,
00044 int alphaMod, QRect clipRect)
00045 {
00046 QRect area = GetArea().toQRect();
00047 area.translate(xoffset, yoffset);
00048
00049 int alpha = CalcAlpha(alphaMod);
00050
00051 p->DrawText(area, m_Message, m_Justification, m_Font, alpha, area);
00052 }
00053
00054 void MythUISimpleText::CopyFrom(MythUIType *base)
00055 {
00056 MythUISimpleText *text = dynamic_cast<MythUISimpleText *>(base);
00057
00058 if (!text)
00059 {
00060 LOG(VB_GENERAL, LOG_ERR, "ERROR, bad parsing");
00061 return;
00062 }
00063
00064 m_Justification = text->m_Justification;
00065 m_Message = text->m_Message;
00066 m_Font = text->m_Font;
00067
00068 MythUIType::CopyFrom(base);
00069 }
00070
00071 void MythUISimpleText::CreateCopy(MythUIType *parent)
00072 {
00073 MythUISimpleText *text = new MythUISimpleText(parent, objectName());
00074 text->CopyFrom(this);
00075 }