]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/qfontexample.C
rename LFUN enum values according to their command (as used in th minibuffer/bind...
[lyx.git] / src / frontends / qt4 / 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 //Added by qt3to4:
17 #include <QPaintEvent>
18
19 void QFontExample::set(QFont const & font, QString const & text)
20 {
21         font_ = font;
22         text_ = text;
23         update();
24 }
25
26
27 QSize QFontExample::sizeHint() const
28 {
29         QFontMetrics m(font_);
30         return QSize(m.width(text_) + 10, m.ascent() + m.descent() + 6);
31 }
32
33
34 void QFontExample::paintEvent(QPaintEvent *)
35 {
36         QPainter p;
37         QFontMetrics m(font_);
38
39         p.begin(this);
40         p.setFont(font_);
41         p.drawRect(0, 0, width() - 1, height() - 1);
42         p.drawText(5, 3 + m.ascent(), text_);
43         p.end();
44 }