00001 #ifndef MYTHRECT_H_
00002 #define MYTHRECT_H_
00003
00004 #include <QRect>
00005 #include <QPoint>
00006 #include <QString>
00007
00008 #include "mythuiexp.h"
00009
00010 class MythPoint;
00011
00017 class MUI_PUBLIC MythRect : public QRect
00018 {
00019
00020 public:
00021 MythRect();
00022 MythRect(int x, int y, int width, int height);
00023 MythRect(const QString &sX, const QString &sY, const QString &sWidth,
00024 const QString &sHeight);
00025 MythRect(QRect rect);
00026 bool operator== (const MythRect &other) const;
00027
00028 void Init(void);
00029 void Reset(void);
00030 void CalculateArea(const MythRect & parentArea);
00031
00032 void NormRect(void);
00033
00034 void setRect(const QString &sX, const QString &sY, const QString &sWidth,
00035 const QString &sHeight);
00036 void setRect(int X, int Y, int w,int h) { QRect::setRect(X,Y,w,h); }
00037 void setX(const QString &sX);
00038 void setX(int X) { QRect::setX(X); }
00039 void setY(const QString &sY);
00040 void setY(int Y) { QRect::setY(Y); }
00041 void setWidth(const QString &sWidth);
00042 void setWidth(int width) { QRect::setWidth(width); }
00043 void setHeight(const QString &sHeight);
00044 void setHeight(int height) { QRect::setHeight(height); }
00045
00046 QString getX(void) const;
00047 QString getY(void) const;
00048 QString getWidth(void) const;
00049 QString getHeight(void) const;
00050
00051 MythPoint topLeft(void) const;
00052 void moveTopLeft(const MythPoint &point);
00053 void moveLeft(const QString &sX);
00054 void moveLeft(int X) { QRect::moveLeft(X); }
00055 void moveTop(const QString &sX);
00056 void moveTop(int Y) { QRect::moveTop(Y); }
00057
00058 QString toString(bool details = false) const;
00059 QRect toQRect(void) const;
00060
00061 private:
00062 bool parsePosition(float &percent, int &offset, int &absolute,
00063 const QString &value, bool is_size);
00064
00065 float m_percentWidth;
00066 float m_percentHeight;
00067 float m_percentX;
00068 float m_percentY;
00069 int m_offsetWidth;
00070 int m_offsetHeight;
00071 int m_offsetX;
00072 int m_offsetY;
00073
00074 bool m_needsUpdate;
00075
00076 QRect m_parentArea;
00077 };
00078
00084 class MUI_PUBLIC MythPoint : public QPoint
00085 {
00086
00087 public:
00088 MythPoint();
00089 MythPoint(int x, int y);
00090 MythPoint(const QString &sX, const QString &sY);
00091 MythPoint(QPoint point);
00092
00093 void Init(void);
00094 bool isValid(void) const { return valid; }
00095 void CalculatePoint(const MythRect & parentArea);
00096
00097 void NormPoint(void);
00098
00099 void setX(const QString &sX);
00100 void setX(int X) { QPoint::setX(X); }
00101 void setY(const QString &sY);
00102 void setY(int Y) { QPoint::setY(Y); }
00103
00104 QString getX(void) const;
00105 QString getY(void) const;
00106
00107 QString toString(bool details = false) const;
00108 QPoint toQPoint(void) const;
00109
00110 private:
00111 bool parsePosition(float &percent, int &offset, int &absolute,
00112 const QString &value);
00113
00114 float m_percentX;
00115 float m_percentY;
00116 int m_offsetX;
00117 int m_offsetY;
00118
00119 bool m_needsUpdate;
00120
00121 QRect m_parentArea;
00122
00123 bool valid;
00124 };
00125
00126 #endif