]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/qcoloritem.C
better selection and scrolling behaviour
[lyx.git] / src / frontends / qt2 / qcoloritem.C
1 /**
2  * \file qcoloritem.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 "qcoloritem.h"
12
13 #include <qfont.h>
14 #include <qfontmetrics.h>
15 #include <qpainter.h>
16
17 QColorItem::QColorItem(QColor c, QString const & t)
18         : color_(c), text_(t)
19 {
20         QFont font;
21         QFontMetrics metrics(font);
22
23         ascent_ = metrics.ascent();
24         width_ = 40 + metrics.width(t);
25         height_ = metrics.ascent() + metrics.descent() + 6;
26 }
27
28
29 void QColorItem::paint(QPainter * p)
30 {
31         p->fillRect(2, 2, 35, height_, color_);
32         p->drawText(40, 3 + ascent_, text_);
33 }