MythTV  master
mythrect.h
Go to the documentation of this file.
1 #ifndef MYTHRECT_H_
2 #define MYTHRECT_H_
3 
4 #include <QRect>
5 #include <QPoint>
6 #include <QString>
7 
8 #include "mythuiexp.h"
9 
10 class MythPoint;
11 
17 class MUI_PUBLIC MythRect : public QRect
18 {
19 
20  public:
22  : QRect() {}
23  MythRect(int x, int y, int width, int height)
24  : QRect(x, y, width, height) {}
25  MythRect(const QString &sX, const QString &sY, const QString &sWidth,
26  const QString &sHeight, const QString &baseRes = QString());
27  MythRect(QRect rect)
28  : QRect(rect) {}
29  bool operator== (const MythRect &other) const;
30 
31  void Reset(void);
32  void CalculateArea(const MythRect & parentArea);
33 
34  void NormRect(void);
35 
36  void setRect(const QString &sX, const QString &sY, const QString &sWidth,
37  const QString &sHeight, const QString &baseRes = QString());
38  void setRect(int X, int Y, int w,int h) { QRect::setRect(X,Y,w,h); }
39  void setX(const QString &sX);
40  void setX(int X) { QRect::setX(X); }
41  void setY(const QString &sY);
42  void setY(int Y) { QRect::setY(Y); }
43  void setWidth(const QString &sWidth);
44  void setWidth(int width) { QRect::setWidth(width); }
45  void setHeight(const QString &sHeight);
46  void setHeight(int height) { QRect::setHeight(height); }
47 
48  QString getX(void) const;
49  QString getY(void) const;
50  QString getWidth(void) const;
51  QString getHeight(void) const;
52 
53  MythPoint topLeft(void) const;
54  void moveTopLeft(const MythPoint &point);
55  void moveLeft(const QString &sX);
56  void moveLeft(int X) { QRect::moveLeft(X); }
57  void moveTop(const QString &sY);
58  void moveTop(int Y) { QRect::moveTop(Y); }
59 
60  QString toString(bool details = false) const;
61  QRect toQRect(void) const;
62 
63  private:
64  static bool parsePosition(float &percent, int &offset, int &absolute,
65  const QString &value, bool is_size);
66 
67  float m_percentWidth {0.0F};
68  float m_percentHeight {0.0F};
69  float m_percentX {0.0F};
70  float m_percentY {0.0F};
71  int m_offsetWidth {0};
72  int m_offsetHeight {0};
73  int m_offsetX {0};
74  int m_offsetY {0};
75 
76  bool m_needsUpdate {true};
77 
78  QRect m_parentArea {0,0,0,0};
79 };
80 
86 class MUI_PUBLIC MythPoint : public QPoint
87 {
88 
89  public:
91  : QPoint(), m_valid(false) {};
92  MythPoint(int x, int y)
93  : QPoint(x, y) {}
94  MythPoint(const QString &sX, const QString &sY);
95  MythPoint(QPoint point)
96  : QPoint(point) {}
97 
98  bool isValid(void) const { return m_valid; }
99  void CalculatePoint(const MythRect & parentArea);
100 
101  void NormPoint(void);
102 
103  void setX(const QString &sX);
104  void setX(int X) { QPoint::setX(X); }
105  void setY(const QString &sY);
106  void setY(int Y) { QPoint::setY(Y); }
107 
108  QString getX(void) const;
109  QString getY(void) const;
110 
111  QString toString(bool details = false) const;
112  QPoint toQPoint(void) const;
113 
114  private:
115  static bool parsePosition(float &percent, int &offset, int &absolute,
116  const QString &value);
117 
118  float m_percentX {0.0F};
119  float m_percentY {0.0F};
120  int m_offsetX {0};
121  int m_offsetY {0};
122 
123  bool m_needsUpdate {true};
124 
126 
127  bool m_valid {true};
128 };
129 
130 #endif
MythPoint(QPoint point)
Definition: mythrect.h:95
void moveLeft(int X)
Definition: mythrect.h:56
QString toString(MarkTypes type)
MythRect(QRect rect)
Definition: mythrect.h:27
bool operator==(MusicMetadata &a, MusicMetadata &b)
void setY(int Y)
Definition: mythrect.h:42
MythPoint()
Definition: mythrect.h:90
void setX(int X)
Definition: mythrect.h:40
void setHeight(int height)
Definition: mythrect.h:46
VERBOSE_PREAMBLE false
Definition: verbosedefs.h:85
QRect m_parentArea
Definition: mythrect.h:125
void moveTop(int Y)
Definition: mythrect.h:58
Wrapper around QRect allowing us to handle percentage and other relative values for areas in mythui.
Definition: mythrect.h:17
void setWidth(int width)
Definition: mythrect.h:44
bool isValid(void) const
Definition: mythrect.h:98
MythRect(int x, int y, int width, int height)
Definition: mythrect.h:23
#define MUI_PUBLIC
Definition: mythuiexp.h:9
void setRect(int X, int Y, int w, int h)
Definition: mythrect.h:38
Wrapper around QPoint allowing us to handle percentage and other relative values for positioning in m...
Definition: mythrect.h:86
void setX(int X)
Definition: mythrect.h:104
MythPoint(int x, int y)
Definition: mythrect.h:92
MythRect()
Definition: mythrect.h:21
void setY(int Y)
Definition: mythrect.h:106