1 // Copyright (C) 2006-2008 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
19 #include "SceneHeaderItem.hxx"
20 #include "SceneHeaderNodeItem.hxx"
21 #include "SceneTextItem.hxx"
23 #include <QGraphicsSceneMouseEvent>
25 // #include "QtGuiContext.hxx"
26 // #include "Menus.hxx"
27 // #include <QGraphicsSceneHoverEvent>
33 #include "YacsTrace.hxx"
36 using namespace YACS::ENGINE;
37 using namespace YACS::HMI;
40 SceneHeaderItem::SceneHeaderItem(QGraphicsScene *scene, SceneItem *parent,
42 : SceneItem(scene, parent, label)
46 _width = _parent->getInternWidth();
48 _brushColor = QColor(215,220,238);
49 _hiBrushColor = QColor(161,178,238);
50 // _penColor = QColor(120,120,120);
51 // _hiPenColor = QColor( 60, 60, 60);
55 SceneHeaderItem::~SceneHeaderItem()
59 QRectF SceneHeaderItem::getMinimalBoundingRect() const
61 return QRectF(x(), y(), 5, _height);
64 void SceneHeaderItem::paint(QPainter *painter,
65 const QStyleOptionGraphicsItem *option,
68 // DEBTRACE("SceneHeaderItem::paint");
70 painter->setPen(getPenColor());
71 painter->setBrush(getBrushColor());
72 painter->drawRoundRect(QRectF(0, 0, _width, _height), 33*_height/_width, 33);
76 void SceneHeaderItem::setText(QString label)
79 _text = new SceneTextItem(_scene,
83 _text->setPlainText(label);
86 void SceneHeaderItem::popupMenu(QWidget *caller, const QPoint &globalPos)
88 if (_parent) _parent->popupMenu(caller, globalPos);
91 void SceneHeaderItem::adjustGeometry()
93 _width = _parent->getInternWidth() -1;
96 QColor SceneHeaderItem::getPenColor()
98 QColor color = _penColor;
100 if(getParent()->getParent())
101 if (getParent()->getParent()->isSelected())
106 QColor SceneHeaderItem::getBrushColor()
108 QColor color = _brushColor;
109 if (dynamic_cast<SceneHeaderNodeItem*>(getParent()))
110 if (getParent()->getParent()->isSelected())
111 color = _hiBrushColor;
113 color = hoverColor(color);
117 void SceneHeaderItem::mousePressEvent(QGraphicsSceneMouseEvent *event)