Brief description of class still missing. More...
#include <TextItem.h>
Public Member Functions | |
virtual QRectF | boundingRect () const |
virtual void | paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
void | setFont (const QFont &f) |
const QString & | text () const |
TextItem (const QString &t, QGraphicsItem *parent=0) | |
~TextItem () |
Brief description of class still missing.
Full description of class still missing
TextItem::TextItem | ( | const QString & | t, |
QGraphicsItem * | parent = 0 |
||
) |
QRectF TextItem::boundingRect | ( | ) | const [virtual] |
References TRACE.
{ TRACE; QPainterPath path; path.addText(0, 0, _font, _text); QRectF textRect=path.boundingRect(); double factor=1.0/_scale; textRect.setX(textRect.x()*factor); textRect.setY(textRect.y()*factor); textRect.setWidth(textRect.width()*factor); textRect.setHeight(textRect.height()*factor); return textRect; }
void TextItem::paint | ( | QPainter * | painter, |
const QStyleOptionGraphicsItem * | option, | ||
QWidget * | widget | ||
) | [virtual] |
{ painter->save(); QPainterPath path; path.addText(0, 0, _font, _text); painter->setBrush(brush()); painter->setPen(pen()); if(_scale==1.0) { painter->drawPath(path); } else { double factor=1.0/_scale; painter->scale(factor, factor); painter->drawPath(path); } painter->restore(); }
void TextItem::setFont | ( | const QFont & | f | ) |
References TRACE.
Referenced by DrawScene::addText().
{ TRACE; if(f.pointSizeF()<10.0) { _scale=10.0/f.pointSizeF(); _font=f; _font.setPointSizeF(10.0); } else { _font=f; _scale=1.0; } }
const QString& TextItem::text | ( | ) | const [inline] |
{return _text;}