summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qpainter.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-02-14 18:50:51 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-02-14 18:50:51 (GMT)
commit9f387357a7e171636c97a7ef13afca60c01a9e3b (patch)
tree80d99a746f81358196a75058a5276493fb8a71de /src/gui/painting/qpainter.cpp
parent02e9f3f25bdcc1b13ecf9ffaf43716c8f7053e88 (diff)
downloadQt-9f387357a7e171636c97a7ef13afca60c01a9e3b.zip
Qt-9f387357a7e171636c97a7ef13afca60c01a9e3b.tar.gz
Qt-9f387357a7e171636c97a7ef13afca60c01a9e3b.tar.bz2
Add API for rich text and getting actual size of QStaticText
Required for several use cases, support for some html tags to change font, color and do advanced text layouts, as well as getting the bounds of the text when drawn.
Diffstat (limited to 'src/gui/painting/qpainter.cpp')
-rw-r--r--src/gui/painting/qpainter.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 8ab813d..2b5a0c5 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -5745,10 +5745,7 @@ void QPainter::drawStaticText(const QPointF &position, const QStaticText &static
// If we don't have an extended paint engine, or if the painter is projected,
// we go through standard code path
if (d->extended == 0 || !d->state->matrix.isAffine()) {
- if (staticText_d->size.isValid())
- drawText(QRectF(position, staticText_d->size), staticText_d->text);
- else
- drawText(position, staticText_d->text);
+ staticText_d->paintText(this);
return;
}
@@ -5784,7 +5781,7 @@ void QPainter::drawStaticText(const QPointF &position, const QStaticText &static
bool restoreWhenFinished = false;
if (staticText_d->needsClipRect) {
save();
- setClipRect(QRectF(position, staticText_d->size));
+ setClipRect(QRectF(position, staticText_d->maximumSize));
restoreWhenFinished = true;
}
@@ -5815,10 +5812,18 @@ void QPainter::drawStaticText(const QPointF &position, const QStaticText &static
staticText_d->position = transformedPosition;
}
+ QPen oldPen = d->state->pen;
+ QColor currentColor = oldPen.color();
for (int i=0; i<staticText_d->itemCount; ++i) {
QStaticTextItem *item = staticText_d->items + i;
+ if (currentColor != item->color) {
+ setPen(item->color);
+ currentColor = item->color;
+ }
d->extended->drawStaticTextItem(item);
}
+ if (currentColor != oldPen.color())
+ setPen(oldPen);
if (restoreWhenFinished)
restore();