2006-03-05 17:24:44 +00:00
|
|
|
/**
|
|
|
|
* \file qfontexample.C
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author John Levon
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "qfontexample.h"
|
|
|
|
|
2006-06-17 09:14:58 +00:00
|
|
|
#include <QPainter>
|
2006-03-05 17:24:44 +00:00
|
|
|
#include <QPaintEvent>
|
|
|
|
|
|
|
|
void QFontExample::set(QFont const & font, QString const & text)
|
|
|
|
{
|
|
|
|
font_ = font;
|
|
|
|
text_ = text;
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QSize QFontExample::sizeHint() const
|
|
|
|
{
|
|
|
|
QFontMetrics m(font_);
|
|
|
|
return QSize(m.width(text_) + 10, m.ascent() + m.descent() + 6);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QFontExample::paintEvent(QPaintEvent *)
|
|
|
|
{
|
|
|
|
QPainter p;
|
|
|
|
QFontMetrics m(font_);
|
|
|
|
|
|
|
|
p.begin(this);
|
|
|
|
p.setFont(font_);
|
|
|
|
p.drawRect(0, 0, width() - 1, height() - 1);
|
|
|
|
p.drawText(5, 3 + m.ascent(), text_);
|
|
|
|
p.end();
|
|
|
|
}
|