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 
21  MythFontProperties font,
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 
32 void 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 }
MythUISimpleText::CopyFrom
void CopyFrom(MythUIType *base) override
Copy this widgets state from another.
Definition: mythuisimpletext.cpp:44
MythUIType::CalcAlpha
int CalcAlpha(int alphamod) const
Definition: mythuitype.cpp:474
MythRect::toQRect
QRect toQRect(void) const
Definition: mythrect.cpp:405
mythuisimpletext.h
MythUIType::SetArea
virtual void SetArea(const MythRect &rect)
Definition: mythuitype.cpp:610
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
MythUISimpleText::m_justification
Qt::Alignment m_justification
Definition: mythuisimpletext.h:39
MythRect
Wrapper around QRect allowing us to handle percentage and other relative values for areas in mythui.
Definition: mythrect.h:17
MythUISimpleText::CreateCopy
void CreateCopy(MythUIType *parent) override
Copy the state of this widget to the one given, it must be of the same type.
Definition: mythuisimpletext.cpp:61
MythUIType::GetArea
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
mythlogging.h
hardwareprofile.config.p
p
Definition: config.py:33
compat.h
MythFontProperties
Definition: mythfontproperties.h:13
MythUIType::CopyFrom
virtual void CopyFrom(MythUIType *base)
Copy this widgets state from another.
Definition: mythuitype.cpp:1171
mythpainter.h
MythUISimpleText::MythUISimpleText
MythUISimpleText(MythUIType *parent, const QString &name)
Definition: mythuisimpletext.h:25
MythUIType
The base class on which all widgets and screens are based.
Definition: mythuitype.h:85
MythUISimpleText::DrawSelf
void DrawSelf(MythPainter *p, int xoffset, int yoffset, int alphaMod, QRect clipRect) override
Definition: mythuisimpletext.cpp:32
mythuihelper.h
MythUISimpleText::m_font
MythFontProperties m_font
Definition: mythuisimpletext.h:40
MythPainter
Definition: mythpainter.h:34
MythUISimpleText::m_message
QString m_message
Definition: mythuisimpletext.h:41
MythUISimpleText
Simplified text widget, displays a text string.
Definition: mythuisimpletext.h:22
mythmainwindow.h