MythTV master
mythuisimpletext.cpp
Go to the documentation of this file.
1
2#include "mythuisimpletext.h"
3
4#include <utility>
5
6#include <QCoreApplication>
7#include <QDomDocument>
8#include <QFontMetrics>
9#include <QHash>
10#include <QString>
11#include <QtGlobal>
12
13#include "libmythbase/compat.h"
15
16#include "mythuihelper.h"
17#include "mythpainter.h"
18#include "mythmainwindow.h"
19
22 const QRect rect, Qt::Alignment align,
23 MythUIType *parent, const QString &name)
24 : MythUIType(parent, name),
25 m_justification(align),
26 m_font(std::move(font)),
27 m_message(text.trimmed())
28{
29 SetArea(MythRect(rect));
30}
31
32void MythUISimpleText::DrawSelf(MythPainter *p, int xoffset, int yoffset,
33 int alphaMod, QRect clipRect)
34{
35 QRect area = GetArea().toQRect();
36 area.translate(xoffset, yoffset);
37
38 int alpha = CalcAlpha(alphaMod);
39
40 p->SetClipRect(clipRect);
41 p->DrawText(area, m_message, m_justification, m_font, alpha, area);
42}
43
45{
46 auto *text = dynamic_cast<MythUISimpleText *>(base);
47
48 if (!text)
49 {
50 LOG(VB_GENERAL, LOG_ERR, "ERROR, bad parsing");
51 return;
52 }
53
54 m_justification = text->m_justification;
55 m_message = text->m_message;
56 m_font = text->m_font;
57
59}
60
62{
63 auto *text = new MythUISimpleText(parent, objectName());
64 text->CopyFrom(this);
65}
Wrapper around QRect allowing us to handle percentage and other relative values for areas in mythui.
Definition: mythrect.h:18
QRect toQRect(void) const
Definition: mythrect.cpp:405
Simplified text widget, displays a text string.
void DrawSelf(MythPainter *p, int xoffset, int yoffset, int alphaMod, QRect clipRect) override
void CreateCopy(MythUIType *parent) override
Copy the state of this widget to the one given, it must be of the same type.
Qt::Alignment m_justification
MythFontProperties m_font
void CopyFrom(MythUIType *base) override
Copy this widgets state from another.
MythUISimpleText(MythUIType *parent, const QString &name)
The base class on which all widgets and screens are based.
Definition: mythuitype.h:86
virtual void SetArea(const MythRect &rect)
Definition: mythuitype.cpp:610
virtual void CopyFrom(MythUIType *base)
Copy this widgets state from another.
virtual MythRect GetArea(void) const
If the object has a minimum area defined, return it, other wise return the default area.
Definition: mythuitype.cpp:885
int CalcAlpha(int alphamod) const
Definition: mythuitype.cpp:474
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
STL namespace.