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