1 // Copyright (C) 2006-2012 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "SceneTextItem.hxx"
22 // #include "QtGuiContext.hxx"
23 // #include "Menus.hxx"
24 // #include <QGraphicsSceneHoverEvent>
27 #include "Resource.hxx"
32 #include "YacsTrace.hxx"
35 using namespace YACS::ENGINE;
36 using namespace YACS::HMI;
39 SceneTextItem::SceneTextItem(QGraphicsScene *scene, SceneItem *parent,
40 QString label, bool center )
41 : QGraphicsTextItem(parent), AbstractSceneItem(scene, parent, label)
45 DEBTRACE("SceneTextItem::SceneTextItem "<<label.toStdString()<<" "<<this<<" "<<_parent<<" "<< _level);
48 SceneTextItem::~SceneTextItem()
52 QRectF SceneTextItem::boundingRect() const
54 return QGraphicsTextItem::boundingRect();
56 void SceneTextItem::paint(QPainter *painter,
57 const QStyleOptionGraphicsItem *option,
60 QGraphicsTextItem::paint(painter, option, widget);
67 dx = Resource::Text_DX;
68 fl = Qt::AlignLeft | Qt::AlignVCenter;
70 painter->drawText(dx, 0, _parent->getWidth()-dx*2, _parent->getHeight(), fl, _label);
73 void SceneTextItem::setTopLeft(QPointF topLeft)
77 void SceneTextItem::setPlainTextTrunc(QString label) {
81 void SceneTextItem::checkGeometryChange()
85 void SceneTextItem::popupMenu(QWidget *caller, const QPoint &globalPos)
87 DEBTRACE("SceneTextItem::popupMenu " << _parent);
88 if (_parent) _parent->popupMenu(caller, globalPos);
91 /*! generic behaviour for headers:
92 * obtain the tooltip from parent.
94 QString SceneTextItem::getToolTip()
96 QString tooltip = _label;
97 SceneItem *parent = getParent();
99 tooltip = parent->getToolTip();
103 void SceneTextItem::setEventPos(QPointF point)
105 _eventPos = mapFromScene(point);