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 "SceneHeaderItem.hxx"
21 #include "SceneHeaderNodeItem.hxx"
22 #include "SceneTextItem.hxx"
24 #include <QGraphicsSceneMouseEvent>
26 #include "Resource.hxx"
28 // #include "QtGuiContext.hxx"
29 // #include "Menus.hxx"
30 // #include <QGraphicsSceneHoverEvent>
36 #include "YacsTrace.hxx"
39 using namespace YACS::ENGINE;
40 using namespace YACS::HMI;
43 SceneHeaderItem::SceneHeaderItem(QGraphicsScene *scene, SceneItem *parent,
45 : SceneItem(scene, parent, label)
48 _width = 2*Resource::DataPort_Width - 2*Resource::CtrlPort_Width - Resource::Space_Margin;
49 _height = Resource::CtrlPort_Height;
51 _brushColor = Resource::Header_brush;
52 _hiBrushColor = Resource::Header_hiBrush;
53 _penColor = Resource::Header_pen;
54 _hiPenColor = Resource::Header_hiPen;
57 SceneHeaderItem::~SceneHeaderItem()
61 QRectF SceneHeaderItem::getMinimalBoundingRect() const
63 return QRectF(x(), y(), 5, _height);
66 void SceneHeaderItem::paint(QPainter *painter,
67 const QStyleOptionGraphicsItem *option,
70 // DEBTRACE("SceneHeaderItem::paint");
73 void SceneHeaderItem::setText(QString label)
76 _text = new SceneTextItem(_scene, this, label);
78 _text->setPlainTextTrunc(label);
79 QGraphicsItem::update();
82 void SceneHeaderItem::popupMenu(QWidget *caller, const QPoint &globalPos)
84 if (_parent) _parent->popupMenu(caller, globalPos);
87 void SceneHeaderItem::adjustGeometry()
89 prepareGeometryChange();
90 _width = _parent->getWidth() - 2*Resource::Corner_Margin - 2*Resource::Space_Margin - 2*Resource::CtrlPort_Width;
94 QColor SceneHeaderItem::getPenColor()
96 QColor color = _penColor;
98 if(getParent()->getParent())
99 if (getParent()->getParent()->isSelected())
104 QColor SceneHeaderItem::getBrushColor()
106 QColor color = _brushColor;
107 if (dynamic_cast<SceneHeaderNodeItem*>(this))
108 if (getParent()->isSelected())
109 color = _hiBrushColor;
111 color = hoverColor(color);
115 void SceneHeaderItem::mousePressEvent(QGraphicsSceneMouseEvent *event)