KDE 4.2 PyKDE API Reference

- KDE's Python API

# FrameSvg Class Reference

`from PyKDE4.plasma import *`

Inherits: Plasma.Svg → QObject
Namespace: Plasma

## Detailed Description

FrameSvg plasma/framesvg.h <Plasma/FrameSvg>

Provides an SVG with borders.

When using SVG images for a background of an object that may change its aspect ratio, such as a dialog, simply scaling a single image may not be enough.

FrameSvg allows SVGs to provide several elements for borders as well as a central element, each of which are scaled individually. These elements should be named

- center - the central element, which will be scaled in both directions - top - the top border; the height is fixed, but it will be scaled horizontally to the same width as center - bottom - the bottom border; scaled in the same way as top - left - the left border; the width is fixed, but it will be scaled vertically to the same height as center - right - the right border; scaled in the same way as left - topleft - fixed size; must be the same height as top and the same width as left - bottomleft, topright, bottomright - similar to topleft

center must exist, but all the others are optional. topleft and topright will be ignored if top does not exist, and similarly for bottomleft and bottomright.

See also:
  Plamsa.Svg

## Enumerations

EnabledBorder | { NoBorder, TopBorder, BottomBorder, LeftBorder, RightBorder, AllBorders }

## Methods

| __init__ (self, QObject parent=0)
bool | cacheAllRenderedFrames (self)
| clearCache (self)
QRectF | contentsRect (self)
Plasma.FrameSvg.EnabledBorders | enabledBorders (self)
QPixmap | framePixmap (self)
QSizeF | frameSize (self)
| getMargins (self, float left, float top, float right, float bottom)
bool | hasElementPrefix (self, QString prefix)
bool | hasElementPrefix (self, Plasma.Location location)
float | marginSize (self, Plasma.MarginEdge edge)
QRegion | mask (self)
| paintFrame (self, QPainter painter, QRectF target, QRectF source=QRectF())
| paintFrame (self, QPainter painter, QPointF pos=QPointF(0,0))
QString | prefix (self)
| resizeFrame (self, QSizeF size)
| setCacheAllRenderedFrames (self, bool cache)
| setElementPrefix (self, Plasma.Location location)
| setElementPrefix (self, QString prefix)
| setEnabledBorders (self, Plasma.FrameSvg.EnabledBorders borders)
| setImagePath (self, QString path)

## Method Documentation

__init__ | ( | self, |
|  | QObject | parent=0
| ) |  |  |

Constructs a new FrameSvg that paints the proper named subelements as borders. It may also be used as a regular Plasma.Svg object for direct access to elements in the Svg.

@arg parent options QObject to parent this to

@related Plasma.Theme

bool cacheAllRenderedFrames | ( |  | self ) |

Returns:
  if all the different prefixes should be kept in a cache when rendered

clearCache | ( |  | self ) |

Deletes the internal cache freeing memory: use this if you want to switch the rendered element and you don't plan to switch back to the previous one for a long time and you used setUseCache(true)

QRectF contentsRect | ( |  | self ) |

Returns:
  the rectangle of the center element, taking the margins into account.

Plasma.FrameSvg.EnabledBorders enabledBorders | ( |  | self ) |

Convenience method to get the enabled borders

Returns:
  what borders are painted

QPixmap framePixmap | ( |  | self ) |

Returns a pixmap of the SVG represented by this object.

@arg elelementId the ID string of the element to render, or an empty string for the whole SVG (the default)

Returns:
  a QPixmap of the rendered SVG

QSizeF frameSize | ( |  | self ) |

Returns:
  the size of the frame

getMargins | ( | self, |
|  | float | left,
|  | float | top,
|  | float | right,
|  | float | bottom
| ) |  |  |

Convenience method that extracts the size of the four margins in the four output parameters @arg left left margin size @arg top top margin size @arg right right margin size @arg bottom bottom margin size

bool hasElementPrefix | ( | self, |
|  | QString | prefix
| ) |  |  |

Returns:
  true if the svg has the necessary elements with the given prefix to draw a frame

@arg prefix the given prefix we want to check if drawable

bool hasElementPrefix | ( | self, |
|  | Plasma.Location | location
| ) |  |  |

This is an overloaded method provided for convenience equivalent to hasElementPrefix("north"), hasElementPrefix("south") hasElementPrefix("west") and hasElementPrefix("east")

Returns:
  true if the svg has the necessary elements with the given prefix to draw a frame.

@arg location the given prefix we want to check if drawable

float marginSize | ( | self, |
|  | Plasma.MarginEdge | edge
| ) |  |  |

Returns the margin size given the margin edge we want @arg edge the margin edge we want, top, bottom, left or right

Returns:
  the margin size

QRegion mask | ( |  | self ) |

Returns a mask that tightly contains the fully opaque areas of the svg

Returns:
  a region of opaque areas

paintFrame | ( | self, |
|  | QPainter | painter,
|  | QRectF | target,
|  | QRectF | source=QRectF()
| ) |  |  |

Paints the loaded SVG with the elements that represents the border @arg painter the QPainter to use @arg target the target rectangle on the paint device @arg source the portion rectangle of the source image

paintFrame | ( | self, |
|  | QPainter | painter,
|  | QPointF | pos=QPointF(0,0)
| ) |  |  |

Paints the loaded SVG with the elements that represents the border This is an overloaded member provided for convenience @arg painter the QPainter to use @arg pos where to paint the svg

QString prefix | ( |  | self ) |

Returns the prefix for SVG elements of the FrameSvg

Returns:
  the prefix

resizeFrame | ( | self, |
|  | QSizeF | size
| ) |  |  |

Resize the frame maintaining the same border size @arg size the new size of the frame

setCacheAllRenderedFrames | ( | self, |
|  | bool | cache
| ) |  |  |

Sets whether saving all the rendered prefixes in a cache or not @arg cache if use the cache or not

setElementPrefix | ( | self, |
|  | Plasma.Location | location
| ) |  |  |

Sets the prefix (@see setElementPrefix) to 'north', 'south', 'west' and 'east' when the location is TopEdge, BottomEdge, LeftEdge and RightEdge, respectively. Clears the prefix in other cases. @arg location location

setElementPrefix | ( | self, |
|  | QString | prefix
| ) |  |  |

Sets the prefix for the SVG elements to be used for painting. For example, if prefix is 'active', then instead of using the 'top' element of the SVG file to paint the top border, 'active-top' element will be used. The same goes for other SVG elements.

If the elements with prefixes are not present, the default ones are used. (for the sake of speed, the test is present only for the 'center' element)

Setting the prefix manually resets the location to Floating. If the @arg prefix prefix for the SVG element names

setEnabledBorders | ( | self, |
|  | Plasma.FrameSvg.EnabledBorders | borders
| ) |  |  |

Sets what borders should be painted @arg flags borders we want to paint

setImagePath | ( | self, |
|  | QString | path
| ) |  |  |

Loads a new Svg @arg imagePath the new file

## Enumeration Documentation

EnabledBorder

These flags represents what borders should be drawn

Enumerator:

  NoBorder = 0 |
  TopBorder = 1 |
  BottomBorder = 2 |
  LeftBorder = 4 |
  RightBorder = 8 |
  AllBorders = TopBorder|BottomBorder|LeftBorder|RightBorder |