2006-03-05 17:24:44 +00:00
|
|
|
/**
|
2007-08-31 05:53:55 +00:00
|
|
|
* \file GuiFontExample.cpp
|
2006-03-05 17:24:44 +00:00
|
|
|
* 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>
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
#include "GuiFontExample.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2006-06-17 09:14:58 +00:00
|
|
|
#include <QPainter>
|
2006-03-05 17:24:44 +00:00
|
|
|
#include <QPaintEvent>
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
//namespace lyx {
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
void GuiFontExample::set(QFont const & font, QString const & text)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
font_ = font;
|
|
|
|
text_ = text;
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
QSize GuiFontExample::sizeHint() const
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
QFontMetrics m(font_);
|
|
|
|
return QSize(m.width(text_) + 10, m.ascent() + m.descent() + 6);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
void GuiFontExample::paintEvent(QPaintEvent *)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
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();
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
//} // namespace lyx
|