From 69155230cd3e6078d7bd5c2788c556983361d48b Mon Sep 17 00:00:00 2001 From: Davide Bettio Date: Fri, 17 Oct 2008 17:45:18 +0000 Subject: [PATCH] Added a new useful overload. svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=872636 --- svg.cpp | 6 ++++++ svg.h | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/svg.cpp b/svg.cpp index 6b9d933db..33984ac80 100644 --- a/svg.cpp +++ b/svg.cpp @@ -376,6 +376,12 @@ void Svg::paint(QPainter *painter, const QRectF &rect, const QString &elementID) painter->drawPixmap(rect, pix, QRectF(QPointF(0, 0), pix.size())); } +void Svg::paint(QPainter *painter, int x, int y, int width, int height, const QString &elementID) +{ + QPixmap pix(d->findInCache(elementID, QSizeF(width, height))); + painter->drawPixmap(x, y, pix, 0, 0, pix.size().width(), pix.size().height()); +} + QSize Svg::size() const { return d->size.toSize(); diff --git a/svg.h b/svg.h index 3ad6f42ef..d76b899e5 100644 --- a/svg.h +++ b/svg.h @@ -120,6 +120,19 @@ class PLASMA_EXPORT Svg : public QObject Q_INVOKABLE void paint(QPainter *painter, const QRectF &rect, const QString &elementID = QString()); + /** + * Paints the SVG represented by this object + * @arg painter the QPainter to use + * @arg x the horizontal coordinate to start painting from + * @arg y the vertical coordinate to start painting from + * @arg width the width of the element to draw + * @arg height the height of the element do draw + * @arg elelementId the ID string of the element to render, or an empty + * string for the whole SVG (the default) + */ + Q_INVOKABLE void paint(QPainter *painter, int x, int y, int width, + int height, const QString &elementID = QString()); + /** * Currently set size of the SVG * @return the current size of a given element