9 #include <QGraphicsRectItem> 10 #include <QGraphicsScene> 11 #include <QGraphicsTextItem> 12 #include "TutorialButton.h" 13 #include "TutorialButtonRect.h" 14 #include "TutorialButtonText.h" 16 const int HORIZONTAL_PADDING = 10;
17 const int VERTICAL_PADDING = 5;
18 const double Z_IN_FRONT = 1;
21 QGraphicsScene &scene) :
29 TutorialButton::~TutorialButton ()
31 QGraphicsScene *scene = m_rect->scene();
32 scene->removeItem (m_rect);
38 void TutorialButton::createRect (QGraphicsScene &scene)
43 m_rect->setPen (QPen (Qt::gray));
44 m_rect->setBrush (QBrush (Qt::white));
45 m_rect->setZValue (Z_IN_FRONT);
46 scene.addItem (m_rect);
49 void TutorialButton::createText (
const QString &text)
62 return QSize (m_text->boundingRect().size().width() + 2 * HORIZONTAL_PADDING,
63 m_text->boundingRect().size().height() + 2 * VERTICAL_PADDING);
68 LOG4CPP_INFO_S ((*mainCat)) <<
"TutorialButton::handleTriggered";
77 m_rect->setRect(pos.x(),
79 m_text->boundingRect().width() + 2 * HORIZONTAL_PADDING,
80 m_text->boundingRect().height() + 2 * VERTICAL_PADDING);
83 m_text->setPos (pos.x() + m_rect->boundingRect().width() / 2.0 - m_text->boundingRect().width() / 2.0,
84 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.