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