QSapecNG
 All Classes Functions Enumerations Properties
label.h
00001 /*
00002     QSapecNG - Qt based SapecNG GUI front-end
00003     Copyright (C) 2009, Michele Caini
00004 
00005     This program is free software: you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation, either version 3 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017 */
00018 
00019 
00020 #ifndef LABEL_H
00021 #define LABEL_H
00022 
00023 
00024 #include "gui/editor/item.h"
00025 
00026 #include <QtGui/QGraphicsTextItem>
00027 #include <QtGui/QPainterPath>
00028 #include <QtGui/QPen>
00029 
00030 
00031 namespace qsapecng
00032 {
00033 
00034 
00035 class SchematicScene;
00036 
00037 
00038 class Label: public Item
00039 {
00040 
00041 public:
00042   enum { Hook = 10 };
00043 
00044 public:
00045   Label(QGraphicsItem* parent = 0, SchematicScene* scene = 0);
00046 
00047   inline ItemType itemType() const { return Item::Label; }
00048 
00049   QRectF boundingRect() const;
00050   void paint(
00051     QPainter* painter,
00052     const QStyleOptionGraphicsItem* option,
00053     QWidget* widget
00054   );
00055 
00056   QString text() const;
00057   void setText(const QString& label);
00058 
00059 protected:
00060   void focusInEvent(QFocusEvent* event);
00061   void focusOutEvent(QFocusEvent* event);
00062 
00063 private:
00064   qreal penWidth() const;
00065 
00066   QGraphicsTextItem label_;
00067   QPainterPath path_;
00068 
00069 };
00070 
00071 
00072 }
00073 
00074 
00075 #endif // LABEL_H
 All Classes Functions Enumerations Properties