MythTV  master
mythuiguidegrid.h
Go to the documentation of this file.
1 #ifndef MYTHUIGUIDEGRID_H_
2 #define MYTHUIGUIDEGRID_H_
3 
4 // QT
5 #include <QPixmap>
6 #include <QPen>
7 #include <QBrush>
8 
9 // MythDB
10 #include "mythuiexp.h"
11 
12 // MythUI
13 #include "mythuitype.h"
14 #include "mythuiimage.h"
15 
16 #define ARROWIMAGESIZE 4
17 #define RECSTATUSSIZE 8
18 
19 
20 // max number of channels to display in the guide grid
21 #define MAX_DISPLAY_CHANS 40
22 
23 // max number of 5 minute time slots to show in guide grid (48 = 4hrs)
24 #define MAX_DISPLAY_TIMES 48
25 
26 #define GridTimeNormal 0
27 #define GridTimeStartsBefore 1
28 #define GridTimeEndsAfter 2
29 
30 class MythFontProperties;
31 
40 {
41  public:
42  MythUIGuideGrid(MythUIType *parent, const QString &name);
43  ~MythUIGuideGrid();
44 
45  void DrawSelf(MythPainter *p, int xoffset, int yoffset,
46  int alphaMod, QRect clipRect) override; // MythUIType
47 
48  enum FillType { Alpha = 10, Dense, Eco, Solid };
49 
50  bool isVerticalLayout(void) { return m_verticalLayout; }
51  int getChannelCount(void) { return m_channelCount; }
52  int getTimeCount(void) { return m_timeCount; }
53 
54  void SetCategoryColors(const QMap<QString, QString> &catColors);
55 
56  void SetTextOffset(const QPoint &to) { m_textOffset = to; }
57  void SetArrow(int, const QString &file);
58  void LoadImage(int, const QString &file);
59  void SetProgramInfo(int row, int col, const QRect &area,
60  const QString &title, const QString &genre,
61  int arrow, int recType, int recStat, bool selected);
62  void ResetData();
63  void ResetRow(int row);
64  void SetProgPast(int ppast);
65  void SetMultiLine(bool multiline);
66 
67  QPoint GetRowAndColumn(QPoint position);
68 
69  protected:
70  void Finalize(void) override; // MythUIType
71  bool ParseElement(const QString &filename, QDomElement &element,
72  bool showWarnings) override; // MythUIType
73  void CopyFrom(MythUIType *base) override; // MythUIType
74  void CreateCopy(MythUIType *parent) override; // MythUIType
75 
76  static bool parseDefaultCategoryColors(QMap<QString, QString> &catColors);
77 
78  private:
79 
80  class UIGTCon
81  {
82  public:
83  UIGTCon() { m_arrow = GridTimeNormal; m_recType = m_recStat = 0; };
84  UIGTCon(const QRect &drawArea, const QString &title,
85  const QString &category, int arrow, int recType, int recStat) :
86  m_drawArea(drawArea), m_title(title),
87  m_category(category.trimmed()), m_arrow(arrow),
88  m_recType(recType), m_recStat(recStat)
89  {}
90 
91  UIGTCon(const UIGTCon &o) :
92  m_drawArea(o.m_drawArea), m_title(o.m_title),
93  m_category(o.m_category), m_categoryColor(o.m_categoryColor),
94  m_arrow(o.m_arrow), m_recType(o.m_recType),
95  m_recStat(o.m_recStat)
96  {}
97 
98  UIGTCon& operator=(const UIGTCon&) = default;
99 
100  QRect m_drawArea;
101  QString m_title;
102  QString m_category;
104  int m_arrow;
107  };
108 
109  void drawBackground(MythPainter *p, int xoffset, int yoffset,
110  UIGTCon *data, int alphaMod);
111  void drawBox(MythPainter *p, int xoffset, int yoffset, UIGTCon *data,
112  const QColor &color, int alphaMod);
113  void drawText(MythPainter *p, int xoffset, int yoffset, UIGTCon *data,
114  int alphaMod);
115  void drawRecDecoration(MythPainter *p, int xoffset, int yoffset,
116  UIGTCon *data, int alphaMod);
117  void drawCurrent(MythPainter *p, int xoffset, int yoffset, UIGTCon *data,
118  int alphaMod);
119 
120  static QColor calcColor(const QColor &color, int alpha);
121 
122  QList<UIGTCon*> *m_allData {nullptr};
124 
125  MythUIImage *m_recImages[RECSTATUSSIZE] {};
126  MythUIImage *m_arrowImages[ARROWIMAGESIZE] {};
127 
128  // themeable settings
129  int m_channelCount {5};
130  int m_timeCount {4};
131  bool m_verticalLayout {false};
132  QPoint m_textOffset;
133 
134  MythFontProperties *m_font {nullptr};
135  int m_justification {Qt::AlignLeft | Qt::AlignTop |
136  Qt::TextWordWrap};
137  bool m_multilineText {true};
138  bool m_cutdown {true};
139 
140  QString m_selType {"box"};
141  QPen m_drawSelLine {Qt::NoPen};
142  QBrush m_drawSelFill {Qt::NoBrush};
143 
144  QColor m_solidColor;
147 
148  int m_fillType {Solid};
149 
150  int m_rowCount {0};
151  int m_progPastCol {0};
152 
153  bool m_drawCategoryColors {true};
154  bool m_drawCategoryText {true};
155  int m_categoryAlpha {255};
156 
157  QMap<QString, QColor> m_categoryColors;
158 
159 };
160 
161 #endif
A narrow purpose widget used to show television programs and the timeslots they occupy on channels.
#define ARROWIMAGESIZE
Image widget, displays a single image or multiple images in sequence.
Definition: mythuiimage.h:97
int getChannelCount(void)
bool isVerticalLayout(void)
UIGTCon(const UIGTCon &o)
The base class on which all widgets and screens are based.
Definition: mythuitype.h:63
virtual void CreateCopy(MythUIType *parent)
Copy the state of this widget to the one given, it must be of the same type.
int getTimeCount(void)
#define GridTimeNormal
virtual void DrawSelf(MythPainter *p, int xoffset, int yoffset, int alphaMod, QRect clipRect)
Definition: mythuitype.cpp:465
const char * name
Definition: ParseText.cpp:328
#define MUI_PUBLIC
Definition: mythuiexp.h:9
virtual void CopyFrom(MythUIType *base)
Copy this widgets state from another.
UIGTCon(const QRect &drawArea, const QString &title, const QString &category, int arrow, int recType, int recStat)
#define RECSTATUSSIZE
void SetTextOffset(const QPoint &to)
virtual bool ParseElement(const QString &filename, QDomElement &element, bool showWarnings)
Parse the xml definition of this widget setting the state of the object accordingly.
QMap< QString, QColor > m_categoryColors
virtual void Finalize(void)
Perform any post-xml parsing initialisation tasks.