• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

libplasma

Plasma::Svg

Plasma::Svg Class Reference

#include <svg.h>

Inheritance diagram for Plasma::Svg:

Inheritance graph
[legend]

List of all members.


Detailed Description

A theme aware image-centric SVG class.

Plasma::Svg provides a class for rendering SVG images to a QPainter in a convenient manner. Unless an absolute path to a file is provided, it loads the SVG document using Plasma::Theme. It also provides a number of internal optimizations to help lower the cost of painting SVGs, such as caching.

Definition at line 47 of file svg.h.


Public Types

enum  ContentType { SingleImage = 0, ImageSet }

Signals

void repaintNeeded ()

Public Member Functions

 ~Svg ()
Q_INVOKABLE void paint (QPainter *painter, const QPointF &point, const QString &elementID=QString())
Q_INVOKABLE void paint (QPainter *painter, int x, int y, const QString &elementID=QString())
Q_INVOKABLE void paint (QPainter *painter, const QRectF &rect, const QString &elementID=QString())
Q_INVOKABLE void resize (int width, int height)
Q_INVOKABLE void resize (const QSizeF &size)
Q_INVOKABLE void resize ()
Q_INVOKABLE QSize elementSize (const QString &elementId) const
Q_INVOKABLE QRect elementRect (const QString &elementId) const
Q_INVOKABLE bool elementExists (const QString &elementId) const
Q_INVOKABLE QString elementAtPoint (const QPoint &point) const
Q_INVOKABLE QMatrix matrixForElement (const QString &elementId) const
Q_INVOKABLE bool isValid () const
QSize size () const
void setContentType (ContentType contentType)
ContentType contentType ()
void setFile (const QString &svgFilePath)
QString file () const

Properties

QSize size
ContentType contentType
QString file

Related Functions

(Note that these are not member functions.)

 Svg (const QString &imagePath=QString(), QObject *parent=0)

Member Enumeration Documentation

enum Plasma::Svg::ContentType

Describes what is in the Svg document to be loaded.

The important distinction is whether the Svg is a single image (or group of elements) that are meant to be viewed together, such as a clock face and hands, or a set of images that are meant to be displayed individually, such as a deck of cards.

Enumerator:
SingleImage  A set of elements that together make an image.

Elements may be drawn separately to accomplish this. This is the default.

ImageSet  A set of elements, each of which constitutes a whole image.

Each element will therefore be rendered to the set size of the Svg object

Definition at line 63 of file svg.h.


Constructor & Destructor Documentation

Plasma::Svg::~Svg (  ) 

Definition at line 230 of file svg.cpp.


Member Function Documentation

void Plasma::Svg::paint ( QPainter *  painter,
const QPointF &  point,
const QString &  elementID = QString() 
)

Paints the SVG represented by this object.

  • painter the QPainter to use
  • point the position to start drawing; the entire svg will be drawn starting at this point.

Definition at line 235 of file svg.cpp.

void Plasma::Svg::paint ( QPainter *  painter,
int  x,
int  y,
const QString &  elementID = QString() 
)

Paints the SVG represented by this object.

  • painter the QPainter to use
  • x the horizontal coordinate to start painting from
  • y the vertical coordinate to start painting from

Definition at line 243 of file svg.cpp.

void Plasma::Svg::paint ( QPainter *  painter,
const QRectF &  rect,
const QString &  elementID = QString() 
)

Paints the SVG represented by this object.

  • painter the QPainter to use
  • rect the rect to draw into; if small than the current size of the drawn starting at this point.

Definition at line 248 of file svg.cpp.

void Plasma::Svg::resize ( int  width,
int  height 
)

Resizes the rendered image.

Rendering will actually take place on the next call to paint.

  • width the new width
  • height the new height

Definition at line 256 of file svg.cpp.

void Plasma::Svg::resize ( const QSizeF &  size  ) 

Resizes the rendered image.

Rendering will actually take place on the next call to paint.

  • size the new size of the image

Definition at line 261 of file svg.cpp.

void Plasma::Svg::resize (  ) 

Resizes the rendered image to the natural size of the SVG.

Rendering will actually take place on the next call to paint.

Definition at line 267 of file svg.cpp.

QSize Plasma::Svg::elementSize ( const QString &  elementId  )  const

Size of a given element.

  • elementId the id of the element to check
    Returns:
    the current size of a given element, given the current size of the Svg

Definition at line 273 of file svg.cpp.

QRect Plasma::Svg::elementRect ( const QString &  elementId  )  const

The bounding rect of a given element.

  • elementId the id of the element to check
    Returns:
    the current rect of a given element, given the current size of the Svg

Definition at line 278 of file svg.cpp.

bool Plasma::Svg::elementExists ( const QString &  elementId  )  const

Check when an element exists in the loaded Svg.

  • elementId the id of the element to check
    Returns:
    true if the element is defined in the Svg, otherwise false

Definition at line 283 of file svg.cpp.

QString Plasma::Svg::elementAtPoint ( const QPoint &  point  )  const

Returns the element (by id) at the given point.

An empty string is returned if no element is at that point.

Definition at line 289 of file svg.cpp.

QMatrix Plasma::Svg::matrixForElement ( const QString &  elementId  )  const

The transformation matrix of the element.

That includes the transformation on the element itself.

  • elementId the id of the element
    Returns:
    the matrix for the element

Definition at line 300 of file svg.cpp.

bool Plasma::Svg::isValid (  )  const

Returns:
true if the SVG file exists and the document is valid, otherwise false.

This method can be expensive as it causes disk access.

Definition at line 306 of file svg.cpp.

QSize Plasma::Svg::size (  )  const

Currently set size of the SVG.

Returns:
the current size of a given element

void Plasma::Svg::setContentType ( ContentType  contentType  ) 

Sets what sort of content is in the Svg.

See also:
ContentType
  • contents whether the Svg is a single image or a set of images

Definition at line 317 of file svg.cpp.

ContentType Plasma::Svg::contentType (  ) 

Returns the content type of the Svg.

See also:
SetContentType
  • contents whether the Svg is a single image or a set of images

void Plasma::Svg::setFile ( const QString &  svgFilePath  ) 

Convenience method for setting the svg file to use for the Svg.

  • svgFilePath the filepath including name of the svg.

Definition at line 327 of file svg.cpp.

QString Plasma::Svg::file (  )  const

Convenience method to get the svg filepath and name of svg.

Returns:
the svg's filepath including name of the svg.

void Plasma::Svg::repaintNeeded (  )  [signal]


Friends And Related Function Documentation

Plasma::Svg::Svg ( const QString &  imagePath = QString(),
QObject *  parent = 0 
) [related]

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.

  • imagePath the image to show. If a relative path is passed, then Plasma::Theme is used to load the SVG.
  • parent options QObject to parent this to

Definition at line 221 of file svg.cpp.


Property Documentation

QSize Plasma::Svg::size [read]

Definition at line 51 of file svg.h.

Svg::ContentType Plasma::Svg::contentType [read, write]

Definition at line 52 of file svg.h.

QString Plasma::Svg::file [read, write]

Definition at line 53 of file svg.h.


The documentation for this class was generated from the following files:
  • svg.h
  • svg.cpp

libplasma

Skip menu "libplasma"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • KWin
  •   KWin Libraries
  • Libraries
  •   libkworkspace
  •   libplasma
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal