00001 #ifndef RECTANGLE_H
00002 #define RECTANGLE_H
00003
00004 #include <QGraphicsRectItem>
00005
00013 class Rectangle : public QGraphicsRectItem
00014 {
00015 public:
00016 Rectangle(qreal x, qreal y, qreal width, qreal height,
00017 QGraphicsItem * parent = 0);
00018
00019 enum { Type = UserType + 1 };
00020 int type() const { return Type; }
00021
00022 enum ResizeHandleIdx {
00023 RH_NONE,
00024 RH_TOP_LEFT,
00025 RH_TOP_RIGHT,
00026 RH_BOTTOM_RIGHT,
00027 RH_BOTTOM_LEFT };
00028
00029 ResizeHandleIdx handleAt(QPointF pos);
00030
00031 void startResize();
00032
00033 void resize(ResizeHandleIdx hidx, QPointF pos);
00034
00035 void rotate(bool clockwise);
00036
00037 int handleWidth();
00038
00039 double actualWidth();
00040 double actualHeight();
00041
00042 QRectF boundingRect () const;
00043
00044 void resizeDone();
00045
00051 void buttonDown(QPointF scenePos);
00052 QPointF buttonDownPos() { return m_buttonDownPos; };
00053
00057 void paint ( QPainter * painter, const QStyleOptionGraphicsItem * option,
00058 QWidget * widget = 0 );
00059
00060 protected:
00061 virtual QRectF innerBoundingRect () const;
00062
00063 protected:
00064
00068 QPointF m_buttonDownPos;
00069 static QPixmap* resizeHandle;
00070 };
00071
00072 #endif // RECTANGLE_H