2007-12-01 10:47:15 +00:00
|
|
|
/*
|
2008-02-06 19:40:45 +00:00
|
|
|
Copyright 2006-2008 Xavier Guerrin
|
2007-12-01 10:47:15 +00:00
|
|
|
This file is part of QElectroTech.
|
|
|
|
|
|
|
|
QElectroTech is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
QElectroTech is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2007-02-24 00:26:04 +00:00
|
|
|
#ifndef ELEMENT_TEXT_ITEM_H
|
2007-04-09 02:56:47 +00:00
|
|
|
#define ELEMENT_TEXT_ITEM_H
|
2007-09-26 22:57:53 +00:00
|
|
|
#include "diagramtextitem.h"
|
2007-04-09 02:56:47 +00:00
|
|
|
#include <QtXml>
|
2007-09-25 23:24:36 +00:00
|
|
|
class Diagram;
|
2007-04-09 02:56:47 +00:00
|
|
|
/**
|
|
|
|
Cette classe represente un element de texte editable.
|
|
|
|
Il est possible pour ce champ de texte de rester dans le sens de la lecture
|
|
|
|
malgre les rotations de son element parent.
|
|
|
|
*/
|
2007-09-26 22:57:53 +00:00
|
|
|
class ElementTextItem : public DiagramTextItem {
|
2007-04-12 03:13:13 +00:00
|
|
|
// constructeurs, destructeur
|
2007-04-09 02:56:47 +00:00
|
|
|
public:
|
|
|
|
ElementTextItem(QGraphicsItem * = 0, QGraphicsScene * = 0);
|
|
|
|
ElementTextItem(const QString &, QGraphicsItem * = 0, QGraphicsScene * = 0);
|
2007-04-12 03:13:13 +00:00
|
|
|
virtual ~ElementTextItem();
|
2007-04-09 02:56:47 +00:00
|
|
|
|
|
|
|
// attributs
|
2007-04-12 03:13:13 +00:00
|
|
|
public:
|
|
|
|
enum { Type = UserType + 1003 };
|
|
|
|
|
2007-04-09 02:56:47 +00:00
|
|
|
private:
|
|
|
|
bool follow_parent_rotations;
|
2008-01-11 20:01:27 +00:00
|
|
|
QPointF original_position;
|
2007-04-09 02:56:47 +00:00
|
|
|
|
|
|
|
// methodes
|
|
|
|
public:
|
|
|
|
virtual int type() const { return Type; }
|
2007-12-16 13:21:28 +00:00
|
|
|
/// @return le rectangle delimitant le champ de texte
|
2007-12-01 21:19:01 +00:00
|
|
|
virtual QRectF boundingRect() const { return(QGraphicsTextItem::boundingRect().adjusted(0.0, -1.1, 0.0, 0.0)); }
|
2007-04-09 02:56:47 +00:00
|
|
|
bool followParentRotations() const;
|
|
|
|
void setFollowParentRotations(bool);
|
2007-04-12 03:13:13 +00:00
|
|
|
void fromXml(const QDomElement &);
|
|
|
|
QDomElement toXml(QDomDocument &) const;
|
2007-04-09 02:56:47 +00:00
|
|
|
void setPos(const QPointF &);
|
|
|
|
void setPos(qreal, qreal);
|
|
|
|
QPointF pos() const;
|
2008-01-11 20:01:27 +00:00
|
|
|
void setOriginalPos(const QPointF &);
|
|
|
|
QPointF originalPos() const;
|
2007-04-09 02:56:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
Permet de savoir si le champ de texte suit les rotations de son parent.
|
|
|
|
@return true si le champ de texte suit les rotations de son parent, false
|
|
|
|
sinon
|
|
|
|
*/
|
|
|
|
inline bool ElementTextItem::followParentRotations() const {
|
|
|
|
return(follow_parent_rotations);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Permet de specifier si le champ de texte suit les rotations de son parent.
|
|
|
|
@param frp true si le champ de texte doit suivre les rotations de son
|
|
|
|
parent, false pour qu'ils ne les suivent pas
|
|
|
|
*/
|
|
|
|
inline void ElementTextItem::setFollowParentRotations(bool frp) {
|
|
|
|
follow_parent_rotations = frp;
|
|
|
|
}
|
|
|
|
|
2007-02-24 00:26:04 +00:00
|
|
|
#endif
|