]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/qcoloritem.C
mplement colors. And we're done ...
[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  
16 QColorItem::QColorItem(QColor c, QString const & t)
17         : color_(c), text_(t)
18 {
19         QFont font;
20         QFontMetrics metrics(font);
21  
22         ascent_ = metrics.ascent();
23         width_ = 40 + metrics.width(t) + 5;
24         height_ = metrics.ascent() + metrics.descent() + 6;
25 }
26
27  
28 void QColorItem::paint(QPainter * p)
29 {
30         p->fillRect(2, 2, 35, height_, color_);
31         p->drawText(40, 3 + ascent_, text_);
32 }