• Main Page
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

C:/Users/David/Documents/QtProjects/visualsc/scgraphicsview/cornergrabber.h

Go to the documentation of this file.
00001 /*
00002     visualsc - Visual State Chart Editing for SCXML State Engines
00003     Copyright (C) 2011  David W. Drell (david@davidwdrell.net) and
00004     Contributing Authors:
00005 
00006 
00007     This program is free software: you can redistribute it and/or modify
00008     it under the terms of the GNU General Public License as published by
00009     the Free Software Foundation, either version 3 of the License, or
00010     (at your option) any later version.
00011 
00012     This program is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015     GNU General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program.  If not, see <http://www.gnu.org/licenses/>.
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     // once the hover event handlers are implemented in this class,
00073     // the mouse events must also be implemented because of
00074     // some linkage issue - apparrently there is some connection
00075     // between the hover events and mouseMove/Press/Release
00076     // events which triggers a vtable issue
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;// 0,1,2,3  - starting at x=0,y=0 and moving clockwise around the box
00090 
00091     int _mouseButtonState;
00092     bool _placedOnASquare;
00093 
00094     PaintStyle _paintStyle;
00095 
00096 };
00097 
00098 #endif // CORNERGRABBER_H

Generated on Mon Sep 26 2011 06:59:25 for visualsc by  doxygen 1.7.1