Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef CORNERGRABBER_H
00022 #define CORNERGRABBER_H
00023
00024 #include <QObject>
00025 #include <QGraphicsItem>
00026 #include <QGraphicsRectItem>
00027 #include <QGraphicsTextItem>
00028 #include <QGraphicsSceneHoverEvent>
00029 #include <QGraphicsSceneMouseEvent>
00030 #include <QColor>
00031 #include <QPainter>
00032 #include <QPen>
00033 #include <QPointF>
00034
00035
00036
00044 class CornerGrabber : public QGraphicsItem
00045 {
00046
00047 public:
00048 explicit CornerGrabber(QGraphicsItem *parent = 0, int corner=0, bool placedOnASquare=false);
00049
00050 int getCorner();
00051 void setMouseState(int);
00052 int getMouseState();
00053 QPointF getCenterPoint();
00054
00055 qreal mouseDownX;
00056 qreal mouseDownY;
00057
00058 enum {kMouseReleased=0, kMouseDown, kMouseMoving};
00059
00060 enum PaintStyle {kBox, kCrossHair};
00061 void setPaintStyle(PaintStyle s);
00062
00063 virtual QRectF boundingRect() const;
00064
00065 private:
00066
00067
00068 virtual void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
00069 virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event );
00070 virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
00071
00072
00073
00074
00075
00076
00077 virtual void mouseMoveEvent ( QGraphicsSceneMouseEvent * event );
00078 virtual void mouseMoveEvent(QGraphicsSceneDragDropEvent *event);
00079 virtual void mousePressEvent (QGraphicsSceneMouseEvent * event );
00080 virtual void mousePressEvent(QGraphicsSceneDragDropEvent *event);
00081 virtual void mouseReleaseEvent (QGraphicsSceneMouseEvent * event );
00082
00083 QColor _outterborderColor;
00084 QPen _outterborderPen;
00085
00086 qreal _width;
00087 qreal _height;
00088
00089 int _corner;
00090
00091 int _mouseButtonState;
00092 bool _placedOnASquare;
00093
00094 PaintStyle _paintStyle;
00095
00096 };
00097
00098 #endif // CORNERGRABBER_H