summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/src/declarative/cppitem.qdoc2
-rw-r--r--src/declarative/extra/qfxparticles.cpp10
-rw-r--r--src/declarative/extra/qfxparticles.h2
-rw-r--r--src/declarative/fx/qfximage.cpp48
-rw-r--r--src/declarative/fx/qfximage.h2
-rw-r--r--src/declarative/fx/qfxitem.cpp5
-rw-r--r--src/declarative/fx/qfxitem.h3
-rw-r--r--src/declarative/fx/qfxpainteditem.cpp20
-rw-r--r--src/declarative/fx/qfxpainteditem.h4
-rw-r--r--src/declarative/fx/qfxrect.cpp6
-rw-r--r--src/declarative/fx/qfxrect.h2
-rw-r--r--src/declarative/fx/qfxtext.cpp20
-rw-r--r--src/declarative/fx/qfxtext.h2
13 files changed, 61 insertions, 65 deletions
diff --git a/doc/src/declarative/cppitem.qdoc b/doc/src/declarative/cppitem.qdoc
index 97aae67..794f67a 100644
--- a/doc/src/declarative/cppitem.qdoc
+++ b/doc/src/declarative/cppitem.qdoc
@@ -99,6 +99,8 @@ a simple cached-image painting model.
\section2 Reimplementing paint functions
+\warning This section is out of date. Use the normal QGraphicsItem::paint function.
+
Two alternative painters are available, offering
different levels of performance and functionality:
QPainter, GLPainter.
diff --git a/src/declarative/extra/qfxparticles.cpp b/src/declarative/extra/qfxparticles.cpp
index 0f22165..6d41434 100644
--- a/src/declarative/extra/qfxparticles.cpp
+++ b/src/declarative/extra/qfxparticles.cpp
@@ -347,7 +347,7 @@ public:
maxX = minX = maxY = minY = 0;
}
- void paintContents(QPainter &p);
+ void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
void updateSize();
@@ -1067,13 +1067,13 @@ void QFxParticlesPainter::updateSize()
setY(myY);
}
-void QFxParticles::paintContents(QPainter &p)
+void QFxParticles::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
{
Q_UNUSED(p);
//painting is done by the ParticlesPainter, so it can have the right size
}
-void QFxParticlesPainter::paintContents(QPainter &p)
+void QFxParticlesPainter::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
{
if (d->image.isNull())
return;
@@ -1083,8 +1083,8 @@ void QFxParticlesPainter::paintContents(QPainter &p)
for (int i = 0; i < d->particles.count(); ++i) {
const QFxParticle &particle = d->particles.at(i);
- p.setOpacity(particle.opacity);
- p.drawPixmap(particle.x - myX, particle.y - myY, d->image);
+ p->setOpacity(particle.opacity);
+ p->drawPixmap(particle.x - myX, particle.y - myY, d->image);
}
}
diff --git a/src/declarative/extra/qfxparticles.h b/src/declarative/extra/qfxparticles.h
index 2574f7f..bde6ec6 100644
--- a/src/declarative/extra/qfxparticles.h
+++ b/src/declarative/extra/qfxparticles.h
@@ -203,7 +203,7 @@ public:
QFxParticleMotion *motion() const;
void setMotion(QFxParticleMotion *);
- void paintContents(QPainter &p);
+ void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
protected:
virtual void componentComplete();
diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp
index f1be4a4..15dc620 100644
--- a/src/declarative/fx/qfximage.cpp
+++ b/src/declarative/fx/qfximage.cpp
@@ -270,22 +270,22 @@ void QFxImage::setSmoothTransform(bool s)
update();
}
-void QFxImage::paintContents(QPainter &p)
+void QFxImage::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
{
Q_D(QFxImage);
if (d->pix.isNull())
return;
- bool oldAA = p.testRenderHint(QPainter::Antialiasing);
- bool oldSmooth = p.testRenderHint(QPainter::SmoothPixmapTransform);
+ bool oldAA = p->testRenderHint(QPainter::Antialiasing);
+ bool oldSmooth = p->testRenderHint(QPainter::SmoothPixmapTransform);
if (d->smooth)
- p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth);
+ p->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth);
QPixmap pix = d->pix;
if (d->tiled) {
- p.save();
- p.setClipRect(0, 0, width(), height(), Qt::IntersectClip);
+ p->save();
+ p->setClipRect(0, 0, width(), height(), Qt::IntersectClip);
QRect me = QRect(0, 0, width(), height());
int pw = pix.width();
@@ -295,13 +295,13 @@ void QFxImage::paintContents(QPainter &p)
while(yy < height()) {
int xx = 0;
while(xx < width()) {
- p.drawPixmap(xx, yy, pix);
+ p->drawPixmap(xx, yy, pix);
xx += pw;
}
yy += ph;
}
- p.restore();
+ p->restore();
} else if (!d->scaleGrid || d->scaleGrid->isNull()) {
if (width() != pix.width() || height() != pix.height()) {
qreal widthScale = width() / qreal(pix.width());
@@ -320,12 +320,12 @@ void QFxImage::paintContents(QPainter &p)
}
scale.scale(widthScale, heightScale);
- QTransform old = p.transform();
- p.setWorldTransform(scale * old);
- p.drawPixmap(0, 0, pix);
- p.setWorldTransform(old);
+ QTransform old = p->transform();
+ p->setWorldTransform(scale * old);
+ p->drawPixmap(0, 0, pix);
+ p->setWorldTransform(old);
} else {
- p.drawPixmap(0, 0, pix);
+ p->drawPixmap(0, 0, pix);
}
} else {
int sgl = d->scaleGrid->left();
@@ -345,46 +345,46 @@ void QFxImage::paintContents(QPainter &p)
// Upper left
if (sgt && sgl)
- p.drawPixmap(QRect(0, 0, sgl, sgt), pix, QRect(0, 0, sgl, sgt));
+ p->drawPixmap(QRect(0, 0, sgl, sgt), pix, QRect(0, 0, sgl, sgt));
// Upper middle
if (pix.width() - xSide && sgt)
- p.drawPixmap(QRect(sgl, 0, w - xSide, sgt), pix,
+ p->drawPixmap(QRect(sgl, 0, w - xSide, sgt), pix,
QRect(sgl, 0, pix.width() - xSide, sgt));
// Upper right
if (sgt && pix.width() - sgr)
- p.drawPixmap(QPoint(w-sgr, 0), pix,
+ p->drawPixmap(QPoint(w-sgr, 0), pix,
QRect(pix.width()-sgr, 0, sgr, sgt));
// Middle left
if (sgl && pix.height() - ySide)
- p.drawPixmap(QRect(0, sgt, sgl, h - ySide), pix,
+ p->drawPixmap(QRect(0, sgt, sgl, h - ySide), pix,
QRect(0, sgt, sgl, pix.height() - ySide));
// Middle
if (pix.width() - xSide && pix.height() - ySide)
- p.drawPixmap(QRect(sgl, sgt, w - xSide, h - ySide),
+ p->drawPixmap(QRect(sgl, sgt, w - xSide, h - ySide),
pix,
QRect(sgl, sgt, pix.width() - xSide, pix.height() - ySide));
// Middle right
if (sgr && pix.height() - ySide)
- p.drawPixmap(QRect(w-sgr, sgt, sgr, h - ySide), pix,
+ p->drawPixmap(QRect(w-sgr, sgt, sgr, h - ySide), pix,
QRect(pix.width()-sgr, sgt, sgr, pix.height() - ySide));
// Lower left
if (sgl && sgr)
- p.drawPixmap(QPoint(0, h - sgb), pix,
+ p->drawPixmap(QPoint(0, h - sgb), pix,
QRect(0, pix.height() - sgb, sgl, sgb));
// Lower Middle
if (pix.width() - xSide && sgb)
- p.drawPixmap(QRect(sgl, h - sgb, w - xSide, sgb), pix,
+ p->drawPixmap(QRect(sgl, h - sgb, w - xSide, sgb), pix,
QRect(sgl, pix.height() - sgb, pix.width() - xSide, sgb));
// Lower Right
if (sgr && sgb)
- p.drawPixmap(QPoint(w-sgr, h - sgb), pix,
+ p->drawPixmap(QPoint(w-sgr, h - sgb), pix,
QRect(pix.width()-sgr, pix.height() - sgb, sgr, sgb));
}
if (d->smooth) {
- p.setRenderHint(QPainter::Antialiasing, oldAA);
- p.setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth);
+ p->setRenderHint(QPainter::Antialiasing, oldAA);
+ p->setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth);
}
}
diff --git a/src/declarative/fx/qfximage.h b/src/declarative/fx/qfximage.h
index 4b6e700..633289f 100644
--- a/src/declarative/fx/qfximage.h
+++ b/src/declarative/fx/qfximage.h
@@ -92,7 +92,7 @@ public:
QUrl source() const;
virtual void setSource(const QUrl &url);
- void paintContents(QPainter &painter);
+ void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
Q_SIGNALS:
void sourceChanged(const QUrl &);
diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp
index 71d4ce2..a9c406d 100644
--- a/src/declarative/fx/qfxitem.cpp
+++ b/src/declarative/fx/qfxitem.cpp
@@ -1672,10 +1672,6 @@ QRectF QFxItem::boundingRect() const
return QRectF(0, 0, d->width, d->height);
}
-void QFxItem::paintContents(QPainter &)
-{
-}
-
/*!
\enum QFxItem::TransformOrigin
@@ -1906,7 +1902,6 @@ void QFxItem::setOptions(Options options, bool set)
void QFxItem::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
{
- paintContents(*p);
}
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h
index 2050ab9..d33c07e 100644
--- a/src/declarative/fx/qfxitem.h
+++ b/src/declarative/fx/qfxitem.h
@@ -206,7 +206,7 @@ public:
void setTransformOrigin(TransformOrigin);
QRectF boundingRect() const;
- virtual void paintContents(QPainter &);
+ virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
virtual bool hasFocus() const;
void setFocus(bool);
@@ -227,7 +227,6 @@ Q_SIGNALS:
protected:
bool isComponentComplete() const;
- virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
virtual void childrenChanged();
virtual bool sceneEventFilter(QGraphicsItem *, QEvent *);
virtual bool sceneEvent(QEvent *);
diff --git a/src/declarative/fx/qfxpainteditem.cpp b/src/declarative/fx/qfxpainteditem.cpp
index a4055eb..2bd17bc 100644
--- a/src/declarative/fx/qfxpainteditem.cpp
+++ b/src/declarative/fx/qfxpainteditem.cpp
@@ -209,20 +209,20 @@ void QFxPaintedItem::init()
/*!
\reimp
*/
-void QFxPaintedItem::paintContents(QPainter &p)
+void QFxPaintedItem::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
{
Q_D(QFxPaintedItem);
const QRect content(QPoint(0,0),d->contentsSize);
if (content.width() <= 0 || content.height() <= 0)
return;
- bool oldAntiAliasing = p.testRenderHint(QPainter::Antialiasing);
- bool oldSmoothPixmap = p.testRenderHint(QPainter::SmoothPixmapTransform);
+ bool oldAntiAliasing = p->testRenderHint(QPainter::Antialiasing);
+ bool oldSmoothPixmap = p->testRenderHint(QPainter::SmoothPixmapTransform);
if (oldAntiAliasing)
- p.setRenderHints(QPainter::Antialiasing, false); // cannot stitch properly otherwise
+ p->setRenderHints(QPainter::Antialiasing, false); // cannot stitch properly otherwise
if (d->smooth)
- p.setRenderHints(QPainter::SmoothPixmapTransform, true);
- QRectF clipf = p.clipRegion().boundingRect();
+ p->setRenderHints(QPainter::SmoothPixmapTransform, true);
+ QRectF clipf = p->clipRegion().boundingRect();
if (clipf.isEmpty())
clipf = mapToScene(content).boundingRect(); // ### Inefficient: Maps toScene and then fromScene
else
@@ -239,7 +239,7 @@ void QFxPaintedItem::paintContents(QPainter &p)
QRect area = d->imagecache[i]->area;
if (topaint.contains(area)) {
QRectF target(area.x(), area.y(), area.width(), area.height());
- p.drawPixmap(target.toRect(), d->imagecache[i]->image);
+ p->drawPixmap(target.toRect(), d->imagecache[i]->image);
topaint -= area;
d->imagecache[i]->age=0;
} else {
@@ -284,14 +284,14 @@ void QFxPaintedItem::paintContents(QPainter &p)
newitem->image = img;
d->imagecache.append(newitem);
QRectF target(r.x(), r.y(), r.width(), r.height());
- p.drawPixmap(target.toRect(), newitem->image);
+ p->drawPixmap(target.toRect(), newitem->image);
}
}
if (oldAntiAliasing)
- p.setRenderHints(QPainter::Antialiasing, oldAntiAliasing);
+ p->setRenderHints(QPainter::Antialiasing, oldAntiAliasing);
if (d->smooth)
- p.setRenderHints(QPainter::SmoothPixmapTransform, oldSmoothPixmap);
+ p->setRenderHints(QPainter::SmoothPixmapTransform, oldSmoothPixmap);
}
/*!
diff --git a/src/declarative/fx/qfxpainteditem.h b/src/declarative/fx/qfxpainteditem.h
index e74ead0..51e155e 100644
--- a/src/declarative/fx/qfxpainteditem.h
+++ b/src/declarative/fx/qfxpainteditem.h
@@ -66,8 +66,6 @@ public:
QFxPaintedItem(QFxItem *parent=0);
~QFxPaintedItem();
- void paintContents(QPainter &painter);
-
bool isSmooth() const;
QSize contentsSize() const;
@@ -80,6 +78,8 @@ public:
QColor fillColor() const;
void setFillColor(const QColor&);
+ void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
+
protected:
QFxPaintedItem(QFxPaintedItemPrivate &dd, QFxItem *parent);
diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp
index 955eb61..0722d26 100644
--- a/src/declarative/fx/qfxrect.cpp
+++ b/src/declarative/fx/qfxrect.cpp
@@ -471,14 +471,14 @@ void QFxRect::generateBorderedRect()
}
}
-void QFxRect::paintContents(QPainter &p)
+void QFxRect::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
{
Q_D(QFxRect);
if (d->radius > 0 || (d->pen && d->pen->isValid())
|| (d->gradient && d->gradient->gradient()) )
- drawRect(p);
+ drawRect(*p);
else
- p.fillRect(QRect(0, 0, width(), height()), d->getColor());
+ p->fillRect(QRect(0, 0, width(), height()), d->getColor());
}
void QFxRect::drawRect(QPainter &p)
diff --git a/src/declarative/fx/qfxrect.h b/src/declarative/fx/qfxrect.h
index 98f5e67..fb96217 100644
--- a/src/declarative/fx/qfxrect.h
+++ b/src/declarative/fx/qfxrect.h
@@ -159,7 +159,7 @@ public:
QRectF boundingRect() const;
- void paintContents(QPainter &painter);
+ void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
private Q_SLOTS:
void doUpdate();
diff --git a/src/declarative/fx/qfxtext.cpp b/src/declarative/fx/qfxtext.cpp
index cb8af40..1313dca 100644
--- a/src/declarative/fx/qfxtext.cpp
+++ b/src/declarative/fx/qfxtext.cpp
@@ -765,17 +765,17 @@ void QFxText::setSmoothTransform(bool s)
update();
}
-void QFxText::paintContents(QPainter &p)
+void QFxText::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
{
Q_D(QFxText);
d->checkImgCache();
if (d->imgCache.isNull())
return;
- bool oldAA = p.testRenderHint(QPainter::Antialiasing);
- bool oldSmooth = p.testRenderHint(QPainter::SmoothPixmapTransform);
+ bool oldAA = p->testRenderHint(QPainter::Antialiasing);
+ bool oldSmooth = p->testRenderHint(QPainter::SmoothPixmapTransform);
if (d->smooth)
- p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth);
+ p->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth);
int w = width();
int h = height();
@@ -811,16 +811,16 @@ void QFxText::paintContents(QPainter &p)
d->imgCache.height() > height());
if (needClip) {
- p.save();
- p.setClipRect(boundingRect());
+ p->save();
+ p->setClipRect(boundingRect());
}
- p.drawPixmap(x, y, d->imgCache);
+ p->drawPixmap(x, y, d->imgCache);
if (needClip)
- p.restore();
+ p->restore();
if (d->smooth) {
- p.setRenderHint(QPainter::Antialiasing, oldAA);
- p.setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth);
+ p->setRenderHint(QPainter::Antialiasing, oldAA);
+ p->setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth);
}
}
diff --git a/src/declarative/fx/qfxtext.h b/src/declarative/fx/qfxtext.h
index a02b76b..41362ae 100644
--- a/src/declarative/fx/qfxtext.h
+++ b/src/declarative/fx/qfxtext.h
@@ -125,7 +125,7 @@ public:
bool smoothTransform() const;
void setSmoothTransform(bool);
- void paintContents(QPainter &p);
+ void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
virtual void componentComplete();