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"
16 
17 #include "mythuihelper.h"
18 #include "mythpainter.h"
19 #include "mythmainwindow.h"
20 
22  MythFontProperties font,
23  const QRect rect, Qt::Alignment align,
24  MythUIType *parent, const QString &name)
25  : MythUIType(parent, name),
26  m_justification(align),
27  m_font(std::move(font)),
28  m_message(text.trimmed())
29 {
30  SetArea(MythRect(rect));
31 }
32 
33 void MythUISimpleText::DrawSelf(MythPainter *p, int xoffset, int yoffset,
34  int alphaMod, QRect clipRect)
35 {
36  QRect area = GetArea().toQRect();
37  area.translate(xoffset, yoffset);
38 
39  int alpha = CalcAlpha(alphaMod);
40 
41  p->SetClipRect(clipRect);
42  p->DrawText(area, m_message, m_justification, m_font, alpha, area);
43 }
44 
46 {
47  auto *text = dynamic_cast<MythUISimpleText *>(base);
48 
49  if (!text)
50  {
51  LOG(VB_GENERAL, LOG_ERR, "ERROR, bad parsing");
52  return;
53  }
54 
55  m_justification = text->m_justification;
56  m_message = text->m_message;
57  m_font = text->m_font;
58 
60 }
61 
63 {
64  auto *text = new MythUISimpleText(parent, objectName());
65  text->CopyFrom(this);
66 }
MythUISimpleText::CopyFrom
void CopyFrom(MythUIType *base) override
Copy this widgets state from another.
Definition: mythuisimpletext.cpp:45
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:62
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:33
mythuihelper.h
MythUISimpleText::m_font
MythFontProperties m_font
Definition: mythuisimpletext.h:40
mythcorecontext.h
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