]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/qfontexample.C
Joao latest bits
[lyx.git] / src / frontends / qt2 / qfontexample.C
1 /**
2  * \file qfontexample.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "qfontexample.h"
14
15 #include <qpainter.h>
16
17 void QFontExample::set(QFont const & font, QString const & text)
18 {
19         font_ = font;
20         text_ = text;
21         repaint();
22 }
23
24
25 QSize QFontExample::sizeHint() const
26 {
27         QFontMetrics m(font_);
28         return QSize(m.width(text_) + 10, m.ascent() + m.descent() + 6);
29 }
30
31
32 void QFontExample::paintEvent(QPaintEvent *)
33 {
34         QPainter p;
35         QFontMetrics m(font_);
36
37         p.begin(this);
38         p.setFont(font_);
39         p.drawRect(0, 0, width() - 1, height() - 1);
40         p.drawText(5, 3 + m.ascent(), text_);
41         p.end();
42 }