Changeset View
Changeset View
Standalone View
Standalone View
src/renderer/KReportScreenRenderer_p.cpp
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | 41 | { | |||
---|---|---|---|---|---|
47 | 47 | | |||
48 | OROPage *p = document->page(page); | 48 | OROPage *p = document->page(page); | ||
49 | 49 | | |||
50 | if (!p) { | 50 | if (!p) { | ||
51 | return false; | 51 | return false; | ||
52 | } | 52 | } | ||
53 | 53 | | |||
54 | // Render Page Objects | 54 | // Render Page Objects | ||
55 | for (int i = 0; i < p->primitives(); i++) { | 55 | for (int i = 0; i < p->primitiveCount(); i++) { | ||
56 | OROPrimitive *prim = p->primitive(i); | 56 | OROPrimitive *prim = p->primitive(i); | ||
57 | 57 | | |||
58 | if (prim->type() == OROTextBox::TextBox) { | 58 | if (dynamic_cast<OROTextBox*>(prim)) { | ||
59 | OROTextBox *tb = dynamic_cast<OROTextBox*>(prim); | 59 | OROTextBox *tb = dynamic_cast<OROTextBox*>(prim); | ||
60 | 60 | | |||
61 | QPointF ps = tb->position(); | 61 | QPointF ps = tb->position(); | ||
62 | QSizeF sz = tb->size(); | 62 | QSizeF sz = tb->size(); | ||
63 | QRectF rc = QRectF(ps.x(), ps.y(), sz.width(), sz.height()); | 63 | QRectF rc = QRectF(ps.x(), ps.y(), sz.width(), sz.height()); | ||
64 | 64 | | |||
65 | context.painter->save(); | 65 | context.painter->save(); | ||
66 | //Background | 66 | //Background | ||
Show All 12 Lines | |||||
79 | 79 | | |||
80 | //outer line | 80 | //outer line | ||
81 | context.painter->setPen(QPen(tb->lineStyle().color(), tb->lineStyle().width(), tb->lineStyle().penStyle())); | 81 | context.painter->setPen(QPen(tb->lineStyle().color(), tb->lineStyle().width(), tb->lineStyle().penStyle())); | ||
82 | context.painter->drawRect(rc); | 82 | context.painter->drawRect(rc); | ||
83 | 83 | | |||
84 | //Reset back to defaults for next element | 84 | //Reset back to defaults for next element | ||
85 | context.painter->restore(); | 85 | context.painter->restore(); | ||
86 | } | 86 | } | ||
87 | else if (prim->type() == OROLine::Line) { | 87 | else if (dynamic_cast<OROLine*>(prim)) { | ||
88 | OROLine * ln = dynamic_cast<OROLine*>(prim); | 88 | OROLine * ln = dynamic_cast<OROLine*>(prim); | ||
89 | QPointF s = ln->startPoint(); | 89 | QPointF s = ln->startPoint(); | ||
90 | QPointF e = ln->endPoint(); | 90 | QPointF e = ln->endPoint(); | ||
91 | //QPen pen ( _painter->pen() ); | 91 | //QPen pen ( _painter->pen() ); | ||
92 | QPen pen(ln->lineStyle().color(), ln->lineStyle().width(), ln->lineStyle().penStyle()); | 92 | QPen pen(ln->lineStyle().color(), ln->lineStyle().width(), ln->lineStyle().penStyle()); | ||
93 | 93 | | |||
94 | context.painter->save(); | 94 | context.painter->save(); | ||
95 | context.painter->setRenderHint(QPainter::Antialiasing, true); | 95 | context.painter->setRenderHint(QPainter::Antialiasing, true); | ||
96 | context.painter->setPen(pen); | 96 | context.painter->setPen(pen); | ||
97 | context.painter->drawLine(QLineF(s.x(), s.y(), e.x(), e.y())); | 97 | context.painter->drawLine(QLineF(s.x(), s.y(), e.x(), e.y())); | ||
98 | context.painter->setRenderHint(QPainter::Antialiasing, false); | 98 | context.painter->setRenderHint(QPainter::Antialiasing, false); | ||
99 | context.painter->restore(); | 99 | context.painter->restore(); | ||
100 | } | 100 | } | ||
101 | else if (prim->type() == ORORect::Rect) { | 101 | else if (dynamic_cast<ORORect*>(prim)) { | ||
102 | ORORect * re = dynamic_cast<ORORect*>(prim); | 102 | ORORect * re = dynamic_cast<ORORect*>(prim); | ||
103 | 103 | | |||
104 | QPointF ps = re->position(); | 104 | QPointF ps = re->position(); | ||
105 | QSizeF sz = re->size(); | 105 | QSizeF sz = re->size(); | ||
106 | QRectF rc = QRectF(ps.x(), ps.y(), sz.width(), sz.height()); | 106 | QRectF rc = QRectF(ps.x(), ps.y(), sz.width(), sz.height()); | ||
107 | 107 | | |||
108 | context.painter->save(); | 108 | context.painter->save(); | ||
109 | context.painter->setPen(re->pen()); | 109 | context.painter->setPen(re->pen()); | ||
110 | context.painter->setBrush(re->brush()); | 110 | context.painter->setBrush(re->brush()); | ||
111 | context.painter->drawRect(rc); | 111 | context.painter->drawRect(rc); | ||
112 | context.painter->restore(); | 112 | context.painter->restore(); | ||
113 | } | 113 | } | ||
114 | else if (prim->type() == OROEllipse::Ellipse) { | 114 | else if (dynamic_cast<OROEllipse*>(prim)) { | ||
115 | OROEllipse * re = dynamic_cast<OROEllipse*>(prim); | 115 | OROEllipse * re = dynamic_cast<OROEllipse*>(prim); | ||
116 | 116 | | |||
117 | QPointF ps = re->position(); | 117 | QPointF ps = re->position(); | ||
118 | QSizeF sz = re->size(); | 118 | QSizeF sz = re->size(); | ||
119 | QRectF rc = QRectF(ps.x(), ps.y(), sz.width(), sz.height()); | 119 | QRectF rc = QRectF(ps.x(), ps.y(), sz.width(), sz.height()); | ||
120 | 120 | | |||
121 | context.painter->save(); | 121 | context.painter->save(); | ||
122 | context.painter->setPen(re->pen()); | 122 | context.painter->setPen(re->pen()); | ||
123 | context.painter->setBrush(re->brush()); | 123 | context.painter->setBrush(re->brush()); | ||
124 | context.painter->drawEllipse(rc); | 124 | context.painter->drawEllipse(rc); | ||
125 | context.painter->restore(); | 125 | context.painter->restore(); | ||
126 | } | 126 | } | ||
127 | else if (prim->type() == OROImage::Image) { | 127 | else if (dynamic_cast<OROImage*>(prim)) { | ||
128 | OROImage * im = dynamic_cast<OROImage*>(prim); | 128 | OROImage * im = dynamic_cast<OROImage*>(prim); | ||
129 | QPointF ps = im->position(); | 129 | QPointF ps = im->position(); | ||
130 | QSizeF sz = im->size(); | 130 | QSizeF sz = im->size(); | ||
131 | QRectF rc = QRectF(ps.x(), ps.y(), sz.width(), sz.height()); | 131 | QRectF rc = QRectF(ps.x(), ps.y(), sz.width(), sz.height()); | ||
132 | 132 | | |||
133 | QImage img = im->image(); | 133 | QImage img = im->image(); | ||
134 | if (im->scaled()) | 134 | if (im->isScaled()) | ||
135 | img = img.scaled(rc.size().toSize(), (Qt::AspectRatioMode) im->aspectRatioMode(), | 135 | img = img.scaled(rc.size().toSize(), (Qt::AspectRatioMode) im->aspectRatioMode(), | ||
136 | (Qt::TransformationMode) im->transformationMode()); | 136 | (Qt::TransformationMode) im->transformationMode()); | ||
137 | 137 | | |||
138 | QRectF sr = QRectF(QPointF(0.0, 0.0), rc.size().boundedTo(img.size())); | 138 | QRectF sr = QRectF(QPointF(0.0, 0.0), rc.size().boundedTo(img.size())); | ||
139 | context.painter->drawImage(rc.topLeft(), img, sr); | 139 | context.painter->drawImage(rc.topLeft(), img, sr); | ||
140 | } | 140 | } | ||
141 | else if (prim->type() == OROPicture::Picture) { | 141 | else if (dynamic_cast<OROPicture*>(prim)) { | ||
142 | OROPicture * im = dynamic_cast<OROPicture*>(prim); | 142 | OROPicture * im = dynamic_cast<OROPicture*>(prim); | ||
143 | QPointF ps = im->position(); | 143 | QPointF ps = im->position(); | ||
144 | QSizeF sz = im->size(); | 144 | QSizeF sz = im->size(); | ||
145 | QRectF rc = QRectF(ps.x(), ps.y(), sz.width(), sz.height()); | 145 | QRectF rc = QRectF(ps.x(), ps.y(), sz.width(), sz.height()); | ||
146 | context.painter->save(); | 146 | context.painter->save(); | ||
147 | context.painter->drawPicture(rc.topLeft(), *(im->picture())); | 147 | context.painter->drawPicture(rc.topLeft(), *(im->picture())); | ||
148 | context.painter->restore(); | 148 | context.painter->restore(); | ||
149 | } | 149 | } | ||
150 | else if (prim->type() == OROCheck::Check) { | 150 | else if (dynamic_cast<OROCheckBox*>(prim)) { | ||
151 | OROCheck * chk = dynamic_cast<OROCheck*>(prim); | 151 | OROCheckBox * chk = dynamic_cast<OROCheckBox*>(prim); | ||
152 | QPointF ps = chk->position(); | 152 | QPointF ps = chk->position(); | ||
153 | QSizeF sz = chk->size(); | 153 | QSizeF sz = chk->size(); | ||
154 | QRectF rc = QRectF(ps.x(), ps.y(), sz.width(), sz.height()); | 154 | QRectF rc = QRectF(ps.x(), ps.y(), sz.width(), sz.height()); | ||
155 | 155 | | |||
156 | context.painter->save(); | 156 | context.painter->save(); | ||
157 | 157 | | |||
158 | context.painter->setBackgroundMode(Qt::OpaqueMode); | 158 | context.painter->setBackgroundMode(Qt::OpaqueMode); | ||
159 | context.painter->setRenderHint(QPainter::Antialiasing); | 159 | context.painter->setRenderHint(QPainter::Antialiasing); | ||
160 | 160 | | |||
161 | context.painter->setPen(chk->foregroundColor()); | 161 | context.painter->setPen(chk->foregroundColor()); | ||
162 | 162 | | |||
163 | if (chk->lineStyle().penStyle() == Qt::NoPen || chk->lineStyle().width() <= 0) { | 163 | if (chk->lineStyle().penStyle() == Qt::NoPen || chk->lineStyle().width() <= 0) { | ||
164 | context.painter->setPen(QPen(Qt::lightGray)); | 164 | context.painter->setPen(QPen(Qt::lightGray)); | ||
165 | } else { | 165 | } else { | ||
166 | context.painter->setPen(QPen(chk->lineStyle().color(), chk->lineStyle().width(), chk->lineStyle().penStyle())); | 166 | context.painter->setPen(QPen(chk->lineStyle().color(), chk->lineStyle().width(), chk->lineStyle().penStyle())); | ||
167 | } | 167 | } | ||
168 | 168 | | |||
169 | qreal ox = sz.width() / 5; | 169 | qreal ox = sz.width() / 5; | ||
170 | qreal oy = sz.height() / 5; | 170 | qreal oy = sz.height() / 5; | ||
171 | 171 | | |||
172 | //Checkbox Style | 172 | //Checkbox Style | ||
173 | if (chk->checkType() == QLatin1String("Cross")) { | 173 | if (chk->checkType() == OROCheckBox::Cross) { | ||
174 | context.painter->drawRoundedRect(rc, sz.width() / 10 , sz.height() / 10); | 174 | context.painter->drawRoundedRect(rc, sz.width() / 10 , sz.height() / 10); | ||
175 | 175 | | |||
176 | if (chk->value()) { | 176 | if (chk->value()) { | ||
177 | QPen lp; | 177 | QPen lp; | ||
178 | lp.setColor(chk->foregroundColor()); | 178 | lp.setColor(chk->foregroundColor()); | ||
179 | lp.setWidth(ox > oy ? oy : ox); | 179 | lp.setWidth(ox > oy ? oy : ox); | ||
180 | context.painter->setPen(lp); | 180 | context.painter->setPen(lp); | ||
181 | context.painter->drawLine(QPointF(ox, oy) + ps, QPointF(sz.width() - ox, sz.height() - oy) + ps); | 181 | context.painter->drawLine(QPointF(ox, oy) + ps, QPointF(sz.width() - ox, sz.height() - oy) + ps); | ||
182 | context.painter->drawLine(QPointF(ox, sz.height() - oy) + ps, QPoint(sz.width() - ox, oy) + ps); | 182 | context.painter->drawLine(QPointF(ox, sz.height() - oy) + ps, QPoint(sz.width() - ox, oy) + ps); | ||
183 | } | 183 | } | ||
184 | } | 184 | } | ||
185 | else if (chk->checkType() == QLatin1String("Dot")) { | 185 | else if (chk->checkType() == OROCheckBox::Dot) { | ||
186 | //Radio Style | 186 | //Radio Style | ||
187 | context.painter->drawEllipse(rc); | 187 | context.painter->drawEllipse(rc); | ||
188 | 188 | | |||
189 | if (chk->value()) { | 189 | if (chk->value()) { | ||
190 | QBrush lb(chk->foregroundColor()); | 190 | QBrush lb(chk->foregroundColor()); | ||
191 | context.painter->setBrush(lb); | 191 | context.painter->setBrush(lb); | ||
192 | context.painter->setPen(Qt::NoPen); | 192 | context.painter->setPen(Qt::NoPen); | ||
193 | context.painter->drawEllipse(rc.center(), sz.width() / 2 - ox, sz.height() / 2 - oy); | 193 | context.painter->drawEllipse(rc.center(), sz.width() / 2 - ox, sz.height() / 2 - oy); | ||
Show All 31 Lines |