2007-03-08 00:27:37 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2006 Aaron Seigo <aseigo@kde.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Library General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PLASMA_SVG_H
|
|
|
|
#define PLASMA_SVG_H
|
|
|
|
|
|
|
|
#include <QtCore/QObject>
|
|
|
|
|
2007-05-20 22:13:46 +02:00
|
|
|
#include <plasma_export.h>
|
2007-03-08 00:27:37 +01:00
|
|
|
|
2007-04-22 11:35:04 +02:00
|
|
|
class QPainter;
|
|
|
|
class QPoint;
|
2007-04-23 01:04:47 +02:00
|
|
|
class QRect;
|
|
|
|
class QSize;
|
2007-04-22 11:35:04 +02:00
|
|
|
|
2007-03-08 00:27:37 +01:00
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
2007-05-20 22:13:46 +02:00
|
|
|
class PLASMA_EXPORT Svg : public QObject
|
2007-03-08 00:27:37 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Constructs an SVG object that implicitly shares and caches rendering
|
|
|
|
* As opposed to QSvgRenderer, which this class uses internally,
|
|
|
|
* Plasma::Svg represents an image generated from an SVG. As such, it
|
|
|
|
* has a related size and transform matrix (the latter being provided
|
|
|
|
* by the painter used to paint the image).
|
|
|
|
*
|
|
|
|
* The size is initialized to be the SVG's native size.
|
|
|
|
*
|
2007-03-19 16:54:54 +01:00
|
|
|
* @related Plasma::Theme
|
2007-03-08 00:27:37 +01:00
|
|
|
* @arg imagePath the image to show, used to load the image from
|
|
|
|
* Plasma::Theme
|
|
|
|
* @arg parent options QObject to parent this to
|
|
|
|
*/
|
|
|
|
explicit Svg( const QString& imagePath, QObject* parent = 0 );
|
|
|
|
~Svg();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Paints the SVG represented by this object
|
|
|
|
* @arg painter the QPainter to use
|
|
|
|
* @arg point the position to start drawing; the entire svg will be
|
|
|
|
* drawn starting at this point.
|
|
|
|
*/
|
2007-05-19 00:05:00 +02:00
|
|
|
void paint( QPainter* painter, const QPointF& point, const QString& elementID = QString() );
|
2007-03-08 00:27:37 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2007-05-19 00:05:00 +02:00
|
|
|
void paint( QPainter* painter, int x, int y, const QString& elementID = QString() );
|
2007-03-08 00:27:37 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Paints the SVG represented by this object
|
|
|
|
* @arg painter the QPainter to use
|
|
|
|
* @arg rect the rect to draw into; if small than the current size
|
|
|
|
* of the
|
|
|
|
* drawn starting at this point.
|
|
|
|
*/
|
2007-05-19 00:05:00 +02:00
|
|
|
void paint( QPainter* painter, const QRectF& rect, const QString& elementID = QString() );
|
2007-03-08 00:27:37 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Resizes the rendered image. Rendering will actually take place on
|
|
|
|
* the next call to paint.
|
|
|
|
* @arg width the new width
|
|
|
|
* @arg height the new height
|
|
|
|
**/
|
|
|
|
void resize( int width, int height );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resizes the rendered image. Rendering will actually take place on
|
|
|
|
* the next call to paint.
|
|
|
|
* @arg size the new size of the image
|
|
|
|
**/
|
2007-05-19 00:05:00 +02:00
|
|
|
void resize( const QSizeF& size );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Size of a given element
|
|
|
|
* @arg elementId the id of the element to check
|
|
|
|
* @return the current size of a given element
|
|
|
|
**/
|
|
|
|
QSize elementSize( const QString& elementId );
|
2007-03-08 00:27:37 +01:00
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void repaintNeeded();
|
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void themeChanged();
|
|
|
|
|
|
|
|
private:
|
|
|
|
class Private;
|
|
|
|
Private* d;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // Plasma namespace
|
|
|
|
|
|
|
|
#endif // multiple inclusion guard
|
|
|
|
|