]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/qfontexample.C
Strip trailing whitespace.
[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
12 #include "qfontexample.h"
13
14 #include <qpainter.h>
15
16 void QFontExample::set(QFont const & font, QString const & text)
17 {
18         font_ = font;
19         text_ = text;
20         repaint();
21 }
22
23
24 QSize QFontExample::sizeHint() const
25 {
26         QFontMetrics m(font_);
27         return QSize(m.width(text_) + 10, m.ascent() + m.descent() + 6);
28 }
29
30
31 void QFontExample::paintEvent(QPaintEvent *)
32 {
33         QPainter p;
34         QFontMetrics m(font_);
35
36         p.begin(this);
37         p.setFont(font_);
38         p.drawRect(0, 0, width() - 1, height() - 1);
39         p.drawText(5, 3 + m.ascent(), text_);
40         p.end();
41 }