]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiFontExample.cpp
* fix spelling in comments to please John.
[lyx.git] / src / frontends / qt4 / GuiFontExample.cpp
1 /**
2  * \file GuiFontExample.cpp
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 "GuiFontExample.h"
14
15 #include <QPainter>
16 #include <QPaintEvent>
17
18
19 //namespace lyx {
20
21 void GuiFontExample::set(QFont const & font, QString const & text)
22 {
23         font_ = font;
24         text_ = text;
25         update();
26 }
27
28
29 QSize GuiFontExample::sizeHint() const
30 {
31         QFontMetrics m(font_);
32         return QSize(m.width(text_) + 10, m.ascent() + m.descent() + 6);
33 }
34
35
36 void GuiFontExample::paintEvent(QPaintEvent *)
37 {
38         QPainter p;
39         QFontMetrics m(font_);
40
41         p.begin(this);
42         p.setFont(font_);
43         p.drawRect(0, 0, width() - 1, height() - 1);
44         p.drawText(5, 3 + m.ascent(), text_);
45         p.end();
46 }
47
48
49 //} // namespace lyx