3 #include <QGraphicsRectItem>
4 #include <QGraphicsScene>
5 #include <QGraphicsTextItem>
6 #include "TutorialButton.h"
7 #include "TutorialButtonRect.h"
8 #include "TutorialButtonText.h"
10 const int HORIZONTAL_PADDING = 10;
11 const int VERTICAL_PADDING = 5;
12 const double Z_IN_FRONT = 1;
15 QGraphicsScene &scene)
21 TutorialButton::~TutorialButton ()
23 QGraphicsScene *scene = m_rect->scene();
24 scene->removeItem (m_rect);
27 void TutorialButton::createRect (QGraphicsScene &scene)
32 m_rect->setPen (QPen (Qt::gray));
33 m_rect->setBrush (QBrush (Qt::white));
34 m_rect->setZValue (Z_IN_FRONT);
35 scene.addItem (m_rect);
38 void TutorialButton::createText (
const QString &text)
51 return QSize (m_text->boundingRect().size().width() + 2 * HORIZONTAL_PADDING,
52 m_text->boundingRect().size().height() + 2 * VERTICAL_PADDING);
57 LOG4CPP_INFO_S ((*mainCat)) <<
"TutorialButton::handleTriggered";
66 m_rect->setRect(pos.x(),
68 m_text->boundingRect().width() + 2 * HORIZONTAL_PADDING,
69 m_text->boundingRect().height() + 2 * VERTICAL_PADDING);
72 m_text->setPos (pos.x() + m_rect->boundingRect().width() / 2.0 - m_text->boundingRect().width() / 2.0,
73 pos.y() + m_rect->boundingRect().height() / 2.0 - m_text->boundingRect().height() / 2.0);
This class customizes QGraphicsTextItem so it performs a callback after a mouse event.