rock_widget_collection  0.1
Public Slots | Public Member Functions | List of all members
TextItem Class Reference

#include <TextItem.h>

Inherits DrawItem.

Public Slots

QString getText ()
 
QFont getFont ()
 
DrawType getType ()
 
void setText (const QString &text)
 
void setFont (const QFont &font)
 
void setBackgroundColor (QColor color)
 
- Public Slots inherited from DrawItem
int getPosX ()
 
int getPosY ()
 
int getGroupNr ()
 
QColor getColor ()
 
void setPosX (int posX)
 
void setPosY (int posY)
 
void setGroupNr (int groupNr)
 
void setColor (const QColor &color)
 
int getLineWidth ()
 
Qt::PenStyle getPenStyle ()
 
Qt::PenCapStyle getPenCapStyle ()
 
void setLineWidth (int lineWidth)
 
void setPenStyle (Qt::PenStyle penStyle)
 
void setPenCapStyle (Qt::PenCapStyle penCapStyle)
 
int getID () const
 
void openGL (bool value)
 
bool onOpenGL ()
 
void setPosFactor (float fx, float fy)
 

Public Member Functions

 TextItem (int posX, int posY, int groupNr, const QString &text)
 
virtual ~TextItem ()
 
void draw (QPainter *painter, QRectF &source, QRectF &target)
 
virtual void renderOnGl (QGLWidget &widget, QRectF &source, QRectF &target)
 
- Public Member Functions inherited from DrawItem
 DrawItem (int posX, int posY, int groupNr, const QColor &color)
 
virtual ~DrawItem ()
 
virtual DrawType getType ()=0
 
bool operator== (const DrawItem &other)
 

Additional Inherited Members

- Protected Member Functions inherited from DrawItem
void addPenStyle (QPainter *painter)
 
- Protected Attributes inherited from DrawItem
int groupNr
 
int posX
 
int posY
 
QColor color
 
int lineWidth
 
Qt::PenCapStyle penCapStyle
 
Qt::PenStyle penStyle
 
int m_id
 
float position_factor_x
 
float position_factor_y
 
bool brender_on_opengl
 
- Static Protected Attributes inherited from DrawItem
static int _ID = 0
 

Detailed Description

DrawItem that draws text.
the standard font used is QFont("Serif", 24, QFont::Normal)

Definition at line 19 of file TextItem.h.

Constructor & Destructor Documentation

TextItem::TextItem ( int  posX,
int  posY,
int  groupNr,
const QString &  text 
)

Creates a Textitem

Parameters
posXthe x start position
posYthe y start position
groupNrthe group number
colorthe color of teh text
textthe text to display

Definition at line 12 of file TextItem.cc.

12  :
13 DrawItem(posX, posY, groupNr, QColor(0,0,0)),text(text),font(QFont("Serif")),background(false)
14 {
15  original_point_size = font.pointSizeF();
16 }
DrawItem(int posX, int posY, int groupNr, const QColor &color)
Definition: DrawItem.cc:11
int posY
Definition: DrawItem.h:182
int posX
Definition: DrawItem.h:180
int groupNr
Definition: DrawItem.h:169
virtual TextItem::~TextItem ( )
inlinevirtual

Destructor

Definition at line 36 of file TextItem.h.

36 {};

Member Function Documentation

void TextItem::draw ( QPainter *  painter,
QRectF &  source,
QRectF &  target 
)
virtual
See Also
DrawItem::draw

Implements DrawItem.

Definition at line 18 of file TextItem.cc.

19 {
20  QRect rect = painter->viewport();
21  painter->setFont(font);
22  painter->setPen(color);
23  if(background)
24  {
25  painter->setBackgroundMode(Qt::OpaqueMode);
26  painter->setBackground(QBrush(background_color));
27  }
28  painter->drawText(position_factor_x*rect.width()+posX,position_factor_y*rect.height(), text);
29 }
int posX
Definition: DrawItem.h:180
float position_factor_y
Definition: DrawItem.h:194
float position_factor_x
Definition: DrawItem.h:193
QColor color
Definition: DrawItem.h:184
QFont TextItem::getFont ( )
inlineslot

Returns the font used

Returns
the font used.

Definition at line 55 of file TextItem.h.

55 {return font;};
QString TextItem::getText ( )
inlineslot

Returns the text of the item

Returns
the text of the item

Definition at line 49 of file TextItem.h.

49 {return text;};
DrawType TextItem::getType ( )
inlineslot

Returns DrawType::Text

Returns
DrawType::Text

Definition at line 61 of file TextItem.h.

61 {return Text;};
Definition: DrawItem.h:19
void TextItem::renderOnGl ( QGLWidget &  widget,
QRectF &  source,
QRectF &  target 
)
virtual

Reimplemented from DrawItem.

Definition at line 31 of file TextItem.cc.

32 {
33  widget.qglColor(color);
34  widget.renderText(position_factor_x*widget.width()+posX,position_factor_y*widget.height()+posY,text,font);
35 }
int posY
Definition: DrawItem.h:182
int posX
Definition: DrawItem.h:180
float position_factor_y
Definition: DrawItem.h:194
float position_factor_x
Definition: DrawItem.h:193
QColor color
Definition: DrawItem.h:184
void TextItem::setBackgroundColor ( QColor  color)
inlineslot

Definition at line 74 of file TextItem.h.

74 {this->background_color = color;background=true;};
QColor color
Definition: DrawItem.h:184
void TextItem::setFont ( const QFont &  font)
inlineslot

Sets the font of the item

Parameters
fontthe font of the item

Definition at line 73 of file TextItem.h.

73 {this->font = font; original_point_size = font.pointSizeF();};
void TextItem::setText ( const QString &  text)
inlineslot

Sets the text of the item

Parameters
textthe text of the item

Definition at line 67 of file TextItem.h.

67 {this->text = text;};

The documentation for this class was generated from the following files: