]> git.cworth.org Git - apitrace/blob - gui/graphing/graphlabelwidget.h
Update downloads link.
[apitrace] / gui / graphing / graphlabelwidget.h
1 #ifndef GRAPHLABELWIDGET_H
2 #define GRAPHLABELWIDGET_H
3
4 #include <QWidget>
5 #include <QPainter>
6
7 /**
8  * A very simple label widget, basically a box with text in.
9  */
10 class GraphLabelWidget : public QWidget {
11 public:
12     GraphLabelWidget(QString text = QString(), QWidget* parent = 0) :
13         QWidget(parent),
14         m_flags(Qt::AlignHCenter | Qt::AlignVCenter),
15         m_text(text)
16     {
17     }
18
19     void setText(const QString& text)
20     {
21         m_text = text;
22     }
23
24     void setFlags(int flags)
25     {
26         m_flags = flags;
27     }
28
29     virtual void paintEvent(QPaintEvent *)
30     {
31         QPainter painter(this);
32         painter.setPen(Qt::black);
33         painter.fillRect(rect(), Qt::lightGray);
34         painter.drawText(rect(), m_flags, m_text);
35     }
36
37 protected:
38     int m_flags;
39     QString m_text;
40 };
41
42 #endif