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