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

Plasma

Plasma::FrameSvg

Plasma::FrameSvg Class Reference

Provides an SVG with borders. More...

#include <Plasma/FrameSvg>

Inheritance diagram for Plasma::FrameSvg:
Plasma::Svg QObject

List of all members.

Public Types

enum  EnabledBorder {
  NoBorder = 0, TopBorder = 1, BottomBorder = 2, LeftBorder = 4,
  RightBorder = 8, AllBorders = TopBorder | BottomBorder | LeftBorder | RightBorder
}

Public Member Functions

QPixmap alphaMask () const
Q_INVOKABLE bool cacheAllRenderedFrames () const
Q_INVOKABLE void clearCache ()
Q_INVOKABLE QRectF contentsRect () const
Q_INVOKABLE EnabledBorders enabledBorders () const
Q_INVOKABLE QPixmap framePixmap ()
Q_INVOKABLE QSizeF frameSize () const
Q_INVOKABLE void getMargins (qreal &left, qreal &top, qreal &right, qreal &bottom) const
Q_INVOKABLE bool hasElementPrefix (Plasma::Location location) const
Q_INVOKABLE bool hasElementPrefix (const QString &prefix) const
Q_INVOKABLE qreal marginSize (const Plasma::MarginEdge edge) const
Q_INVOKABLE QRegion mask () const
Q_INVOKABLE void paintFrame (QPainter *painter, const QPointF &pos=QPointF(0, 0))
Q_INVOKABLE void paintFrame (QPainter *painter, const QRectF &target, const QRectF &source=QRectF())
Q_INVOKABLE QString prefix ()
Q_INVOKABLE void resizeFrame (const QSizeF &size)
Q_INVOKABLE void setCacheAllRenderedFrames (bool cache)
Q_INVOKABLE void setElementPrefix (const QString &prefix)
Q_INVOKABLE void setElementPrefix (Plasma::Location location)
Q_INVOKABLE void setEnabledBorders (const EnabledBorders borders)
Q_INVOKABLE void setImagePath (const QString &path)
 ~FrameSvg ()

Related Functions

(Note that these are not member functions.)



 FrameSvg (QObject *parent=0)

Detailed Description

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

Definition at line 76 of file framesvg.h.


Member Enumeration Documentation

enum Plasma::FrameSvg::EnabledBorder

These flags represents what borders should be drawn.

Enumerator:
NoBorder 
TopBorder 
BottomBorder 
LeftBorder 
RightBorder 
AllBorders 

Definition at line 86 of file framesvg.h.


Constructor & Destructor Documentation

Plasma::FrameSvg::~FrameSvg (  ) 

Definition at line 47 of file framesvg.cpp.


Member Function Documentation

QPixmap Plasma::FrameSvg::alphaMask (  )  const
Returns:
a pixmap whose alpha channel is the opacity of the frame. It may be the frame itself or a special frame with the mask- prefix

Definition at line 268 of file framesvg.cpp.

bool Plasma::FrameSvg::cacheAllRenderedFrames (  )  const
Returns:
if all the different prefixes should be kept in a cache when rendered

Definition at line 324 of file framesvg.cpp.

void Plasma::FrameSvg::clearCache (  ) 

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).

Definition at line 329 of file framesvg.cpp.

QRectF Plasma::FrameSvg::contentsRect (  )  const
Returns:
the rectangle of the center element, taking the margins into account.

Definition at line 253 of file framesvg.cpp.

FrameSvg::EnabledBorders Plasma::FrameSvg::enabledBorders (  )  const

Convenience method to get the enabled borders.

Returns:
what borders are painted

Definition at line 75 of file framesvg.cpp.

QPixmap Plasma::FrameSvg::framePixmap (  ) 

Returns a pixmap of the SVG represented by this object.

  • 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

Definition at line 346 of file framesvg.cpp.

QSizeF Plasma::FrameSvg::frameSize (  )  const
Returns:
the size of the frame

Definition at line 201 of file framesvg.cpp.

void Plasma::FrameSvg::getMargins ( qreal &  left,
qreal &  top,
qreal &  right,
qreal &  bottom 
) const

Convenience method that extracts the size of the four margins in the four output parameters.

  • left left margin size
  • top top margin size
  • right right margin size
  • bottom bottom margin size

Definition at line 238 of file framesvg.cpp.

bool Plasma::FrameSvg::hasElementPrefix ( Plasma::Location  location  )  const

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.
  • location the given prefix we want to check if drawable

Definition at line 156 of file framesvg.cpp.

bool Plasma::FrameSvg::hasElementPrefix ( const QString &  prefix  )  const
Returns:
true if the svg has the necessary elements with the given prefix to draw a frame
  • prefix the given prefix we want to check if drawable

Definition at line 145 of file framesvg.cpp.

qreal Plasma::FrameSvg::marginSize ( const Plasma::MarginEdge  edge  )  const

Returns the margin size given the margin edge we want.

  • edge the margin edge we want, top, bottom, left or right
    Returns:
    the margin size

Definition at line 212 of file framesvg.cpp.

QRegion Plasma::FrameSvg::mask (  )  const

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

Returns:
a region of opaque areas

Definition at line 308 of file framesvg.cpp.

void Plasma::FrameSvg::paintFrame ( QPainter *  painter,
const QPointF &  pos = QPointF(0, 0) 
)

Paints the loaded SVG with the elements that represents the border This is an overloaded member provided for convenience.

  • painter the QPainter to use
  • pos where to paint the svg

Definition at line 373 of file framesvg.cpp.

void Plasma::FrameSvg::paintFrame ( QPainter *  painter,
const QRectF &  target,
const QRectF &  source = QRectF() 
)

Paints the loaded SVG with the elements that represents the border.

  • painter the QPainter to use
  • target the target rectangle on the paint device
  • source the portion rectangle of the source image

Definition at line 360 of file framesvg.cpp.

QString Plasma::FrameSvg::prefix (  ) 

Returns the prefix for SVG elements of the FrameSvg.

Returns:
the prefix

Definition at line 177 of file framesvg.cpp.

void Plasma::FrameSvg::resizeFrame ( const QSizeF &  size  ) 

Resize the frame maintaining the same border size.

  • size the new size of the frame

Definition at line 186 of file framesvg.cpp.

void Plasma::FrameSvg::setCacheAllRenderedFrames ( bool  cache  ) 

Sets whether saving all the rendered prefixes in a cache or not.

  • cache if use the cache or not

Definition at line 315 of file framesvg.cpp.

void Plasma::FrameSvg::setElementPrefix ( const 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

  • prefix prefix for the SVG element names

Definition at line 109 of file framesvg.cpp.

void Plasma::FrameSvg::setElementPrefix ( Plasma::Location  location  ) 

Sets the prefix (.

See also:
setElementPrefix) to 'north', 'south', 'west' and 'east' when the location is TopEdge, BottomEdge, LeftEdge and RightEdge, respectively. Clears the prefix in other cases.
  • location location

Definition at line 86 of file framesvg.cpp.

void Plasma::FrameSvg::setEnabledBorders ( const EnabledBorders  borders  ) 

Sets what borders should be painted.

  • flags borders we want to paint

Definition at line 65 of file framesvg.cpp.

void Plasma::FrameSvg::setImagePath ( const QString &  path  ) 

Loads a new Svg.

  • imagePath the new file

Reimplemented from Plasma::Svg.

Definition at line 52 of file framesvg.cpp.


Friends And Related Function Documentation

Plasma::FrameSvg::FrameSvg ( QObject *  parent = 0  )  [related]

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.

  • parent options QObject to parent this to

Definition at line 39 of file framesvg.cpp.


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

Plasma

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
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