NCL Composer  0.1.5
 All Classes Functions Variables Pages
qnstgraphicsproperty.cpp
1 #include "qnstgraphicsproperty.h"
2 
3 QnstGraphicsProperty::QnstGraphicsProperty(QnstGraphicsEntity* parent)
4  : QnstGraphicsInterface(parent)
5 {
6  setnstType(Qnst::Property);
7 }
8 
9 QnstGraphicsProperty::~QnstGraphicsProperty()
10 {
11 
12 }
13 
14 void QnstGraphicsProperty::draw(QPainter* painter)
15 {
16  QColor bg;
17  QColor border;
18 
19  if (isRefer())
20  {
21  bg = QColor(153,153,153,75);
22 // border = QColor(238,238,238);
23  border = QColor(102,102,102,75);
24  }
25  else
26  {
27  bg = QColor(153,153,153);
28  border = QColor(102,102,102);
29  }
30  painter->setBrush(QBrush(bg));
31  painter->setPen(QPen(QBrush(border), 0, Qt::SolidLine));
32 
33  painter->drawRect(4 + 8/2, 4 + 8/2, getWidth()-8, getHeight()-8);
34 
35  // Draw MouseOver rectangle
36  if (!isSelected() && hasMouseHover())
37  {
38  painter->setBrush(Qt::NoBrush);
39  painter->setPen(QPen(QBrush(QColor("#999999")), 0, Qt::DashLine)); // 0px = cosmetic border
40 
41  painter->drawRect(4, 4, getWidth(), getHeight());
42  }
43 
44  if (isMoving())
45  {
46  painter->setBrush(Qt::NoBrush);
47  painter->setPen(QPen(QBrush(Qt::black), 0)); // 0px = cosmetic border
48 
49  painter->drawRect(getMoveLeft()+4-getLeft(),
50  getMoveTop()+4-getTop(),
51  getWidth()-1,
52  getHeight()-1);
53  }
54 }
55 
56 void QnstGraphicsProperty::delineate(QPainterPath* painter) const
57 {
58  painter->addRect(4 + 8/2, 4 + 8/2, getWidth()-8, getHeight()-8);
59 }