#ifndef QRECT_H_
#define QRECT_H_
#include "KWQSize.h"
#include "KWQPointArray.h"
typedef struct _NSRect NSRect;
class QRect {
public:
QRect();
QRect(QPoint p, QSize s);
QRect(int, int, int, int);
explicit QRect(const NSRect &);
bool isNull() const;
bool isValid() const;
bool isEmpty() const;
int x() const { return xp; }
int y() const { return yp; }
int left() const { return xp; }
int top() const { return yp; }
int right() const;
int bottom() const;
int width() const { return w; }
int height() const { return h; }
QPoint topLeft() const;
QPoint bottomRight() const;
QSize size() const;
void setX(int x) { xp = x; }
void setY(int y) { yp = y; }
void setWidth(int width) { w = width; }
void setHeight(int height) { h = height; }
void setRect(int x, int y, int width, int height) { xp = x; yp = y; w = width; h = height; }
QRect intersect(const QRect &) const;
bool intersects(const QRect &) const;
QRect unite(const QRect &) const;
bool contains(int x, int y, bool proper = false) const {
if (proper)
return x > xp && (x < (xp + w - 1)) && y > yp && y < (yp + h - 1);
return x >= xp && x < (xp + w) && y >= yp && y < (yp + h);
}
void inflate(int s);
inline QRect operator&(const QRect &r) const { return intersect(r); }
operator NSRect() const;
#ifdef _KWQ_IOSTREAM_
friend std::ostream &operator<<(std::ostream &, const QRect &);
#endif
private:
int xp;
int yp;
int w;
int h;
friend bool operator==(const QRect &, const QRect &);
friend bool operator!=(const QRect &, const QRect &);
};
#endif