Changeset View
Changeset View
Standalone View
Standalone View
src/renderer/scripting/KReportScriptDraw.cpp
Show All 11 Lines | |||||
12 | * Lesser General Public License for more details. | 12 | * Lesser General Public License for more details. | ||
13 | * | 13 | * | ||
14 | * You should have received a copy of the GNU Lesser General Public | 14 | * You should have received a copy of the GNU Lesser General Public | ||
15 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | 15 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | 16 | */ | ||
17 | 17 | | |||
18 | #include "KReportScriptDraw.h" | 18 | #include "KReportScriptDraw.h" | ||
19 | #include "KReportRenderObjects.h" | 19 | #include "KReportRenderObjects.h" | ||
20 | #include "KReportPosition.h" | | |||
21 | #include "KReportSize.h" | | |||
22 | 20 | | |||
23 | #include <QFont> | 21 | #include <QFont> | ||
24 | #include <QFontMetrics> | 22 | #include <QFontMetrics> | ||
25 | 23 | | |||
26 | KReportScriptDraw::KReportScriptDraw(QObject *parent) | 24 | KReportScriptDraw::KReportScriptDraw(QObject *parent) | ||
27 | : QObject(parent) | 25 | : QObject(parent) | ||
28 | { | 26 | { | ||
29 | m_curPage = 0; | 27 | m_curPage = 0; | ||
Show All 13 Lines | |||||
43 | { | 41 | { | ||
44 | m_curOffset = off; | 42 | m_curOffset = off; | ||
45 | } | 43 | } | ||
46 | 44 | | |||
47 | void KReportScriptDraw::rectangle(qreal x, qreal y, qreal w, qreal h, const QString& lc, const QString& fc, qreal lw, int a) | 45 | void KReportScriptDraw::rectangle(qreal x, qreal y, qreal w, qreal h, const QString& lc, const QString& fc, qreal lw, int a) | ||
48 | { | 46 | { | ||
49 | if (m_curPage) { | 47 | if (m_curPage) { | ||
50 | ORORect *r = new ORORect(); | 48 | ORORect *r = new ORORect(); | ||
51 | KReportPosition p; | | |||
52 | KReportSize s; | | |||
53 | 49 | | |||
54 | p.setPointPos(QPointF(x, y)); | 50 | r->setRect(QRectF(KReportItemBase::scenePosition(QPointF(x, y)) + m_curOffset, KReportItemBase::sceneSize(QSizeF(w, h)))); | ||
55 | s.setPointSize(QSizeF(w, h)); | | |||
56 | r->setRect(QRectF(p.toScene() + m_curOffset, s.toScene())); | | |||
57 | 51 | | |||
58 | QPen pen(QColor(lc), lw); | 52 | QPen pen(QColor(lc), lw); | ||
59 | QColor c(fc); | 53 | QColor c(fc); | ||
60 | c.setAlpha(a); | 54 | c.setAlpha(a); | ||
61 | QBrush bru(c); | 55 | QBrush bru(c); | ||
62 | 56 | | |||
63 | r->setBrush(bru); | 57 | r->setBrush(bru); | ||
64 | r->setPen(pen); | 58 | r->setPen(pen); | ||
65 | m_curPage->insertPrimitive(r); | 59 | m_curPage->insertPrimitive(r); | ||
66 | } | 60 | } | ||
67 | } | 61 | } | ||
68 | 62 | | |||
69 | void KReportScriptDraw::ellipse(qreal x, qreal y, qreal w, qreal h, const QString& lc, const QString& fc, qreal lw, int a) | 63 | void KReportScriptDraw::ellipse(qreal x, qreal y, qreal w, qreal h, const QString& lc, const QString& fc, qreal lw, int a) | ||
70 | { | 64 | { | ||
71 | if (m_curPage) { | 65 | if (m_curPage) { | ||
72 | OROEllipse *e = new OROEllipse(); | 66 | OROEllipse *e = new OROEllipse(); | ||
73 | KReportPosition p; | | |||
74 | KReportSize s; | | |||
75 | 67 | | |||
76 | p.setPointPos(QPointF(x, y)); | 68 | e->setRect(QRectF(KReportItemBase::scenePosition(QPointF(x, y)) + m_curOffset, KReportItemBase::sceneSize(QSizeF(w, h)))); | ||
77 | s.setPointSize(QSizeF(w, h)); | | |||
78 | e->setRect(QRectF(p.toScene() + m_curOffset, s.toScene())); | | |||
79 | 69 | | |||
80 | QPen pen(QColor(lc), lw); | 70 | QPen pen(QColor(lc), lw); | ||
81 | QColor c(fc); | 71 | QColor c(fc); | ||
82 | c.setAlpha(a); | 72 | c.setAlpha(a); | ||
83 | QBrush bru(c); | 73 | QBrush bru(c); | ||
84 | 74 | | |||
85 | e->setBrush(bru); | 75 | e->setBrush(bru); | ||
86 | e->setPen(pen); | 76 | e->setPen(pen); | ||
87 | m_curPage->insertPrimitive(e); | 77 | m_curPage->insertPrimitive(e); | ||
88 | } | 78 | } | ||
89 | } | 79 | } | ||
90 | 80 | | |||
91 | void KReportScriptDraw::line(qreal x1, qreal y1, qreal x2, qreal y2, const QString& lc) | 81 | void KReportScriptDraw::line(qreal x1, qreal y1, qreal x2, qreal y2, const QString& lc) | ||
92 | { | 82 | { | ||
93 | if (m_curPage) { | 83 | if (m_curPage) { | ||
94 | OROLine *ln = new OROLine(); | 84 | OROLine *ln = new OROLine(); | ||
95 | KReportPosition s; | | |||
96 | KReportPosition e; | | |||
97 | 85 | | |||
98 | s.setPointPos(QPointF(x1, y1)); | 86 | ln->setStartPoint(KReportItemBase::scenePosition(QPointF(x1, y1) + m_curOffset)); | ||
99 | e.setPointPos(QPointF(x2, y2)); | 87 | ln->setEndPoint(KReportItemBase::scenePosition(QPointF(x2, y2) + m_curOffset)); | ||
100 | | ||||
101 | ln->setStartPoint(s.toScene() + m_curOffset); | | |||
102 | ln->setEndPoint(e.toScene() + m_curOffset); | | |||
103 | 88 | | |||
104 | KReportLineStyle ls; | 89 | KReportLineStyle ls; | ||
105 | ls.setColor(QColor(lc)); | 90 | ls.setColor(QColor(lc)); | ||
106 | ls.setWidth(1); | 91 | ls.setWidth(1); | ||
107 | ls.setPenStyle(Qt::SolidLine); | 92 | ls.setPenStyle(Qt::SolidLine); | ||
108 | 93 | | |||
109 | ln->setLineStyle(ls); | 94 | ln->setLineStyle(ls); | ||
110 | m_curPage->insertPrimitive(ln); | 95 | m_curPage->insertPrimitive(ln); | ||
Show All 37 Lines |