rock_widget_collection  0.1
TextItem.cc
Go to the documentation of this file.
1 /*
2  * File: TextItem.cc
3  * Author: blueck
4  *
5  * Created on 24. Juni 2010, 13:14
6  */
7 
8 #include "TextItem.h"
9 #include <iostream>
10 
11 
12 TextItem::TextItem(int posX, int posY, int groupNr,const QString &text) :
13 DrawItem(posX, posY, groupNr, QColor(0,0,0)),text(text),font(QFont("Serif")),background(false)
14 {
15  original_point_size = font.pointSizeF();
16 }
17 
18 void TextItem::draw(QPainter* painter, QRectF &source, QRectF &target)
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 }
30 
31 void TextItem::renderOnGl(QGLWidget &widget,QRectF &source, QRectF &target)
32 {
33  widget.qglColor(color);
34  widget.renderText(position_factor_x*widget.width()+posX,position_factor_y*widget.height()+posY,text,font);
35 }
TextItem(int posX, int posY, int groupNr, const QString &text)
Definition: TextItem.cc:12
virtual void renderOnGl(QGLWidget &widget, QRectF &source, QRectF &target)
Definition: TextItem.cc:31
void draw(QPainter *painter, QRectF &source, QRectF &target)
Definition: TextItem.cc:18
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