TinkerCell Core 1.0
TinkerCell's Core library providing all basic functionalities
TextGraphicsItem.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 
00003 Copyright (c) 2008 Deepak Chandran
00004 Contact: Deepak Chandran (dchandran1@gmail.com)
00005 See COPYRIGHT.TXT
00006 
00007 Class for drawing text on a GraphicsScene. The text can be associated with 
00008 a handle
00009 
00010 ****************************************************************************/
00011 
00012 #ifndef TINKERCELL_TEXTGRAPHICSITEM_H
00013 #define TINKERCELL_TEXTGRAPHICSITEM_H
00014 
00015 #include <QGraphicsTextItem>
00016 #include <QTextCursor>
00017 #include <QUndoCommand>
00018 #include "ItemHandle.h"
00019 
00020 namespace Tinkercell
00021 {
00022         class ItemHandle;
00023 
00027         class TINKERCELLCOREEXPORT TextGraphicsItem : public QGraphicsTextItem
00028         {
00029                 Q_OBJECT
00030 
00031         public:
00033                 virtual ItemHandle * handle() const;
00035                 void setHandle(ItemHandle *);
00040                 TextGraphicsItem(const QString& text, QGraphicsItem* parent = 0);
00044                 TextGraphicsItem(QGraphicsItem* parent = 0);
00048                 TextGraphicsItem(const TextGraphicsItem& copy);
00051                 virtual TextGraphicsItem* clone();
00056                 TextGraphicsItem(ItemHandle * handle, QGraphicsItem* parent = 0);
00059                 virtual ~TextGraphicsItem();
00062                 virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget);
00065                 virtual void showBorder(bool show=true);
00069                 virtual QString text() const;
00073                 virtual void setText(const QString&);
00078                 static TextGraphicsItem* cast(QGraphicsItem *);
00083                 static QList<TextGraphicsItem*> cast(const QList<QGraphicsItem*>&);
00086                 QPair<QGraphicsItem*,QPointF> relativePosition;
00090                 QGraphicsItem* closestItem() const;
00091 
00093                 enum { Type = UserType + 8};
00095                 int type() const
00096                 {
00097                         // Enable the use of dynamic_cast with this item.
00098                         return Type;
00099                 }
00100 
00102                 QString groupID;
00103 
00104 signals:
00105                 // void lostFocus(TextGraphicsItem *item);
00106                 // void selectedChange(QGraphicsItem *item);
00107 
00108         protected:
00109                 //QVariant itemChange(GraphicsItemChange change, const QVariant &value);
00110                 //void focusOutEvent(QFocusEvent *event);
00111                 //void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
00112 
00114                 QGraphicsRectItem * boundingRectItem;
00117                 ItemHandle * itemHandle;
00118 
00119         };
00120 }
00121 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines