Public Member Functions
TextItem Class Reference

Brief description of class still missing. More...

#include <TextItem.h>

List of all members.

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 ()

Detailed Description

Brief description of class still missing.

Full description of class still missing


Constructor & Destructor Documentation

TextItem::TextItem ( const QString &  t,
QGraphicsItem *  parent = 0 
)

Description of constructor still missing

References TRACE.

  : QAbstractGraphicsShapeItem(parent)
{
  TRACE;
  _text=t;
  _scale=1.0;
}

Description of destructor still missing

References TRACE.

{
  TRACE;
}

Member Function Documentation

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;}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines