Engauge Digitizer  2
 All Classes Files Functions Variables Enumerations Enumerator Friends Pages
TutorialStateAbstractBase.cpp
1 #include <QGraphicsPixmapItem>
2 #include <QGraphicsScene>
3 #include <QGraphicsTextItem>
4 #include "TutorialDlg.h"
5 #include "TutorialStateAbstractBase.h"
6 #include "TutorialStateContext.h"
7 
8 const int DELTA_FONT_SIZE = 2;
9 const int TITLE_PADDING = 5;
10 const double Z_TITLE = 2.0; // On top of everything else
11 
13  m_context (context)
14 {
15 }
16 
17 TutorialStateAbstractBase::~TutorialStateAbstractBase()
18 {
19 }
20 
22 {
23  return 10;
24 }
25 
27 {
28  return m_context;
29 }
30 
31 QGraphicsPixmapItem *TutorialStateAbstractBase::createPixmapItem (const QString &resource,
32  const QPoint &pos)
33 {
34  QGraphicsPixmapItem *item = new QGraphicsPixmapItem (QPixmap (resource));
35  item->setPos (pos);
36  context().tutorialDlg().scene().addItem (item);
37 
38  return item;
39 }
40 
41 QGraphicsTextItem *TutorialStateAbstractBase::createTextItem (const QString &text,
42  const QPoint &pos)
43 {
44  QGraphicsTextItem *item = new QGraphicsTextItem (text);
45  item->setPos (pos);
46  context().tutorialDlg().scene().addItem (item);
47 
48  return item;
49 }
50 
51 QGraphicsTextItem *TutorialStateAbstractBase::createTitle (const QString &text)
52 {
53  QSize backgroundSize = context().tutorialDlg().backgroundSize();
54 
55  QGraphicsTextItem *item = new QGraphicsTextItem (text);
56  item->setZValue(Z_TITLE);
57  item->setPos (backgroundSize.width() / 2.0 - item->boundingRect().width() / 2.0,
58  TITLE_PADDING);
59  context().tutorialDlg().scene().addItem (item);
60 
61  // Highlight the text
62  QFont font = item->font();
63  font.setBold (true);
64 // font.setPixelSize (font.pixelSize() + DELTA_FONT_SIZE);
65  item->setFont (font);
66  return item;
67 }
int buttonMargin() const
Buttons are placed up against bottom side, and left or right side, separated by this margin...
QGraphicsScene & scene()
Single scene the covers the entire tutorial dialog.
Definition: TutorialDlg.cpp:60
TutorialStateContext & context()
Context class for the tutorial state machine.
QGraphicsTextItem * createTextItem(const QString &text, const QPoint &pos)
Factory method for text items.
QSize backgroundSize() const
Make geometry available for layout.
Definition: TutorialDlg.cpp:28
QGraphicsTextItem * createTitle(const QString &text)
Factory method for title items.
QGraphicsPixmapItem * createPixmapItem(const QString &resource, const QPoint &pos)
Factory method for pixmap items.
Context class for tutorial state machine.
TutorialStateAbstractBase(TutorialStateContext &context)
Single constructor.
TutorialDlg & tutorialDlg()
Access to tutorial dialogs and its scene.