-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathText.cpp
68 lines (61 loc) · 1.32 KB
/
Text.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "Text.h"
//using namespace std;
class Text;
Text::Text(int id, ShapeType type)
:Shape(id, type)
{
}
Text::~Text()
{}
void Text::draw(QPainter* shape)
{
shape->save(); //save original state of qpainter
shape->setPen(getPen());
shape->setBrush(getBrush());
shape->drawText(getDimensions()[0], getDimensions()[1], getDimensions()[2], getDimensions()[3], 0, text.toPlainText());
int xVal = getDimensions()[0];
int yVal = getDimensions()[1] + 30;
shape->drawText(xVal, yVal, QString::fromStdString("Shape Id: ") + QString::number(getId()));
shape->restore(); //restore to the original state of qpainter
}
QFont Text::getFont()
{
return font;
}
QTextEdit& Text::getText()
{
return text;
}
void Text::move(int dims_[])
{
getDimensions()[0] = dims_[0];
getDimensions()[1]= dims_[1];
}
void Text::setText(const QString &text_)
{
text.setText(text_);
}
void Text::setTColor(const QColor &c)
{
text.setTextColor(c);
}
void Text::setAlignment(Qt::Alignment a)
{
text.setAlignment(a);
}
void Text::setPointSize(qreal s)
{
text.setFontPointSize(s);
}
void Text::setFontFamily(const QString &fontFamily)
{
text.setFontFamily(fontFamily);
}
void Text::setFontStyle(QFont::Style style)
{
font.setStyle(style);
}
void Text::setFontWeight(QFont::Weight weight)
{
text.setFontWeight(weight);
}