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(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  MythUISimpleText *text = dynamic_cast<MythUISimpleText *>(base);
48 
49  if (!text)
50  {
51  LOG(VB_GENERAL, LOG_ERR, "ERROR, bad parsing");
52  return;
53  }
54 
56  m_Message = text->m_Message;
57  m_Font = text->m_Font;
58 
60 }
61 
63 {
64  MythUISimpleText *text = new MythUISimpleText(parent, objectName());
65  text->CopyFrom(this);
66 }
int CalcAlpha(int alphamod)
Definition: mythuitype.cpp:460
The base class on which all widgets and screens are based.
Definition: mythuitype.h:63
Simplified text widget, displays a text string.
QRect toQRect(void) const
Definition: mythrect.cpp:354
virtual MythRect GetArea(void) const
If the object has a minimum area defined, return it, other wise return the default area.
Definition: mythuitype.cpp:863
Qt::Alignment m_Justification
const char * name
Definition: ParseText.cpp:328
void CreateCopy(MythUIType *parent) override
Copy the state of this widget to the one given, it must be of the same type.
virtual void SetArea(const MythRect &rect)
Definition: mythuitype.cpp:591
#define LOG(_MASK_, _LEVEL_, _STRING_)
Definition: mythlogging.h:41
void CopyFrom(MythUIType *base) override
Copy this widgets state from another.
virtual void CopyFrom(MythUIType *base)
Copy this widgets state from another.
MythUISimpleText(MythUIType *parent, const QString &name)
void DrawSelf(MythPainter *p, int xoffset, int yoffset, int alphaMod, QRect clipRect) override
MythFontProperties m_Font