MythTV  master
mythuisimpletext.cpp
Go to the documentation of this file.
1 
2 #include "mythuisimpletext.h"
3 
4 #include <QCoreApplication>
5 #include <QtGlobal>
6 #include <QDomDocument>
7 #include <QFontMetrics>
8 #include <QString>
9 #include <QHash>
10 
11 #include "mythlogging.h"
12 
13 #include "mythuihelper.h"
14 #include "mythpainter.h"
15 #include "mythmainwindow.h"
16 #include "mythcorecontext.h"
17 
18 #include "compat.h"
19 
21  const 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(font),
27  m_message(text.trimmed())
28 {
29  SetArea(MythRect(rect));
30  m_font = font;
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:459
MythRect::toQRect
QRect toQRect(void) const
Definition: mythrect.cpp:405
mythuisimpletext.h
MythUIType::SetArea
virtual void SetArea(const MythRect &rect)
Definition: mythuitype.cpp:595
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
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:18
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:870
mythlogging.h
hardwareprofile.config.p
p
Definition: config.py:33
compat.h
MythFontProperties
Definition: mythfontproperties.h:14
MythUIType::CopyFrom
virtual void CopyFrom(MythUIType *base)
Copy this widgets state from another.
Definition: mythuitype.cpp:1152
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:33
MythUISimpleText::m_message
QString m_message
Definition: mythuisimpletext.h:41
MythUISimpleText
Simplified text widget, displays a text string.
Definition: mythuisimpletext.h:23
mythmainwindow.h