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

libplasma

Plasma::Widget

Plasma::Widget Class Reference

#include <widget.h>

Inheritance diagram for Plasma::Widget:

Inheritance graph
[legend]

List of all members.


Detailed Description

Base class for all Widgets in Plasma.

Author:
Alexander Wiedenbruch

Matias Valdenegro

Widgets are the basis for User Interfaces inside Plasma. Widgets are rectangular, but can be in any visible shape by just using transparency to mask out non-rectangular areas.

To implement a Widget, just subclass Plasma::Widget and implement at minimum, sizeHint() and paintWidget()

Definition at line 66 of file widget.h.


Public Types

enum  CachePaintMode { NoCacheMode, ItemCoordinateCacheMode, DeviceCoordinateCacheMode }

Public Member Functions

 Widget (QGraphicsItem *parent=0, QObject *parentObject=0)
virtual ~Widget ()
virtual Qt::Orientations expandingDirections () const
void setMinimumSize (const QSizeF &size)
QSizeF minimumSize () const
void setMaximumSize (const QSizeF &size)
QSizeF maximumSize () const
virtual bool hasHeightForWidth () const
virtual qreal heightForWidth (qreal width) const
virtual bool hasWidthForHeight () const
virtual qreal widthForHeight (qreal h) const
QRectF geometry () const
virtual void setGeometry (const QRectF &geometry)
Q_INVOKABLE void updateGeometry ()
virtual QSizeF sizeHint () const
QSizeF size () const
QFont font () const
virtual QRectF boundingRect () const
Q_INVOKABLE void resize (const QSizeF &size)
Q_INVOKABLE void resize (qreal width, qreal height)
Q_INVOKABLE Widget * parent () const
Q_INVOKABLE void addChild (Widget *widget)
void setOpacity (qreal opacity)
qreal opacity () const
void setCachePaintMode (CachePaintMode mode, const QSize &size=QSize())
CachePaintMode cachePaintMode () const
void update (const QRectF &rect=QRectF())
void update (qreal _x, qreal _y, qreal w, qreal h)
virtual QGraphicsItem * graphicsItem ()
QGraphicsView * view () const
QRectF mapFromView (const QGraphicsView *view, const QRect &rect) const
QRect mapToView (const QGraphicsView *view, const QRectF &rect) const
ToolTipData toolTip () const
void setToolTip (const ToolTipData &dt)

Protected Member Functions

virtual void paintWidget (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)
virtual void contextMenuEvent (QGraphicsSceneContextMenuEvent *event)
QVariant itemChange (GraphicsItemChange change, const QVariant &value)
void setSize (qreal width, qreal height)
void setSize (const QSizeF &size)
void managingLayoutChanged ()
virtual bool sceneEvent (QEvent *event)

Properties

Qt::Orientations expandingDirections
QSizeF minimumSize
QSizeF maximumSize
QRectF geometry
QSizeF sizeHint
QSizeF size
qreal opacity

Member Enumeration Documentation

enum Plasma::Widget::CachePaintMode

Enumerator:
NoCacheMode 
ItemCoordinateCacheMode 
DeviceCoordinateCacheMode 

Definition at line 80 of file widget.h.


Constructor & Destructor Documentation

Plasma::Widget::Widget ( QGraphicsItem *  parent = 0,
QObject *  parentObject = 0 
) [explicit]

Creates a new Plasma::Widget.

Parameters:
parent the QGraphicsItem this icon is parented to.

Definition at line 128 of file widget.cpp.

Plasma::Widget::~Widget (  )  [virtual]

Destroys a Plasma::Widget.

Definition at line 143 of file widget.cpp.


Member Function Documentation

virtual Qt::Orientations Plasma::Widget::expandingDirections (  )  const [virtual]

This method is used by Plasma::Layout to determine which directions the widget naturally expands.

Returns:
bitmask with the directions that this Widget can be expanded.

Implements Plasma::LayoutItem.

Reimplemented in Plasma::Label, Plasma::PushButton, Plasma::Rectangle, and Plasma::SignalPlotter.

void Plasma::Widget::setMinimumSize ( const QSizeF &  size  ) 

Sets the minimum size of the Widget.

Parameters:
size the size to set as the minimum size.

Definition at line 193 of file widget.cpp.

QSizeF Plasma::Widget::minimumSize (  )  const [virtual]

Returns:
minimum size of the Widget.

Implements Plasma::LayoutItem.

Reimplemented in Plasma::PushButton.

void Plasma::Widget::setMaximumSize ( const QSizeF &  size  ) 

Sets the maximum size of the Widget.

Parameters:
size the size to set as the maximum size.

Definition at line 207 of file widget.cpp.

QSizeF Plasma::Widget::maximumSize (  )  const [virtual]

Returns:
maximum size of the Widget.

Implements Plasma::LayoutItem.

bool Plasma::Widget::hasHeightForWidth (  )  const [virtual]

This method is used by Plasma::Layout to determine whether this widget can provide a height value given a width value.

Returns:
whether or not this Widget has heightForWidth.

Reimplemented from Plasma::LayoutItem.

Reimplemented in Plasma::Label.

Definition at line 221 of file widget.cpp.

qreal Plasma::Widget::heightForWidth ( qreal  width  )  const [virtual]

This method is used by Plasma::Layout to determine a height value given a width value.

Parameters:
width the width to use to determine height.
Returns:
height calculated using width given.

Reimplemented from Plasma::LayoutItem.

Reimplemented in Plasma::Label.

Definition at line 226 of file widget.cpp.

bool Plasma::Widget::hasWidthForHeight (  )  const [virtual]

This method is used by Plasma::Layout to determine whether this widget can provide a width value given a height value.

Returns:
whether or not this Widget has widthForHeight.

Reimplemented from Plasma::LayoutItem.

Definition at line 233 of file widget.cpp.

qreal Plasma::Widget::widthForHeight ( qreal  h  )  const [virtual]

This method is used by Plasma::Layout to determine a width value given a height value.

Parameters:
height the width to use to determine width.
Returns:
width calculated using height given.

Reimplemented from Plasma::LayoutItem.

Definition at line 238 of file widget.cpp.

QRectF Plasma::Widget::geometry (  )  const [virtual]

Returns:
geometry of this widget.

Implements Plasma::LayoutItem.

void Plasma::Widget::setGeometry ( const QRectF &  geometry  )  [virtual]

Sets the geometry of this Widget.

Sets the geometry of this Plasma::Widget

Parameters:
geometry the geometry to apply to this Plasma::Widget.

Implements Plasma::LayoutItem.

Reimplemented in Plasma::Applet, and Plasma::SignalPlotter.

Definition at line 257 of file widget.cpp.

void Plasma::Widget::updateGeometry (  )  [virtual]

This method is used to notify any containing Plasma::Layout that it should reset its geometry.

Implements Plasma::LayoutItem.

Definition at line 289 of file widget.cpp.

virtual QSizeF Plasma::Widget::sizeHint (  )  const [virtual]

Returns the recommended size for this widget.

Note that this size is not necessarily only the size for the widget, but might also include margins etc.

Returns:
recommended size for this Plasma::Widget.

Implements Plasma::LayoutItem.

Reimplemented in Plasma::Applet, Plasma::Label, Plasma::Meter, Plasma::ProgressBar, and Plasma::PushButton.

QSizeF Plasma::Widget::size (  )  const

Returns:
the size of this Plasma::Widget

QFont Plasma::Widget::font (  )  const

Returns:
the font currently set for this widget

Reimplemented in Plasma::Label, and Plasma::SignalPlotter.

Definition at line 312 of file widget.cpp.

QRectF Plasma::Widget::boundingRect (  )  const [virtual]

Set the font for this widget.

Parameters:
font the new font
TODO: implement once we decide how to handle the font system void setFont(const QFont& font); Reimplemented from QGraphicsItem
Returns:
the bounding rectangle for this Plasma::Widget

Reimplemented in Plasma::Applet, Plasma::Flash, and Plasma::RadioButton.

Definition at line 323 of file widget.cpp.

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

Resizes this Plasma::Widget.

Parameters:
size the new size of this Plasma::Widget.

Definition at line 328 of file widget.cpp.

void Plasma::Widget::resize ( qreal  width,
qreal  height 
)

Convenience method for resizing this Plasma::Widget.

Parameters:
width the new width.
height the new height.

Definition at line 334 of file widget.cpp.

Widget * Plasma::Widget::parent (  )  const

Returns:
this Plasma::Widget's parent, returns a null pointer if none exist.

Definition at line 339 of file widget.cpp.

void Plasma::Widget::addChild ( Widget *  widget  ) 

Add another Plasma::Widget as a child of this one.

Parameters:
widget the widget to reparent to this Plasma::Widget.

Definition at line 355 of file widget.cpp.

void Plasma::Widget::setOpacity ( qreal  opacity  ) 

Definition at line 151 of file widget.cpp.

qreal Plasma::Widget::opacity (  )  const

void Plasma::Widget::setCachePaintMode ( CachePaintMode  mode,
const QSize &  size = QSize() 
)

Sets the widget's cache paint mode and cache size.

Parameters:
mode the new cache paint mode
mode the new cache size, only applies to ItemCoordinateCacheMode

Definition at line 161 of file widget.cpp.

Widget::CachePaintMode Plasma::Widget::cachePaintMode (  )  const

The current cache paint mode.

Definition at line 175 of file widget.cpp.

void Plasma::Widget::update ( const QRectF &  rect = QRectF()  ) 

Invalidates the widget's cache paint mode for a given item rectangle.

Parameters:
rect the optional invalidated rectangle; if null, defaults to boundingRect().

Definition at line 180 of file widget.cpp.

void Plasma::Widget::update ( qreal  _x,
qreal  _y,
qreal  w,
qreal  h 
) [inline]

Reimplemented from QGraphicsItem.

Definition at line 255 of file widget.h.

QGraphicsItem * Plasma::Widget::graphicsItem (  )  [virtual]

Returns the graphics item associated with this layout item or 0 if there is no associated graphics item.

The default implementation returns 0.

Reimplemented from Plasma::LayoutItem.

Definition at line 82 of file widget.cpp.

QGraphicsView * Plasma::Widget::view (  )  const

Returns the view this widget is visible on.

Definition at line 87 of file widget.cpp.

QRectF Plasma::Widget::mapFromView ( const QGraphicsView *  view,
const QRect &  rect 
) const

Maps a QRect from a view's coordinates to local coordinates.

Parameters:
view the view from which rect should be mapped
rect the rect to be mapped

Definition at line 105 of file widget.cpp.

QRect Plasma::Widget::mapToView ( const QGraphicsView *  view,
const QRectF &  rect 
) const

Maps a QRectF from local coordinates to a view's coordinates.

Parameters:
view the view to which rect should be mapped
rect the rect to be mapped

Definition at line 112 of file widget.cpp.

ToolTipData Plasma::Widget::toolTip (  )  const

The Data from the tooltip.

Returns:
A ToolTip::Data object with current information

Definition at line 500 of file widget.cpp.

void Plasma::Widget::setToolTip ( const ToolTipData &  dt  ) 

Setter for data shown in tooltip.

Parameters:
data a ToolTip::Data object containing icon and text

Definition at line 505 of file widget.cpp.

void Plasma::Widget::paintWidget ( QPainter *  painter,
const QStyleOptionGraphicsItem *  option,
QWidget *  widget = 0 
) [protected, virtual]

Paints the widget.

Parameters:
painter the QPainter to use to paint.
option the style option used to give specific info on the item being dawn.
widget the parent QWidget (most likely the Corona)

Reimplemented in Plasma::CheckBox, Plasma::Flash, Plasma::Icon, Plasma::Label, Plasma::Meter, Plasma::ProgressBar, Plasma::PushButton, Plasma::RadioButton, Plasma::Rectangle, and Plasma::SignalPlotter.

Definition at line 515 of file widget.cpp.

void Plasma::Widget::contextMenuEvent ( QGraphicsSceneContextMenuEvent *  event  )  [protected, virtual]

Reimplemented from QGraphicsItem.

Reimplemented from QGraphicsItem.

Reimplemented in Plasma::Containment.

Definition at line 548 of file widget.cpp.

QVariant Plasma::Widget::itemChange ( GraphicsItemChange  change,
const QVariant &  value 
) [protected]

Reimplemented from QGraphicsItem.

Reimplemented in Plasma::Applet.

Definition at line 524 of file widget.cpp.

void Plasma::Widget::setSize ( qreal  width,
qreal  height 
) [protected]

Definition at line 279 of file widget.cpp.

void Plasma::Widget::setSize ( const QSizeF &  size  )  [protected]

Definition at line 284 of file widget.cpp.

void Plasma::Widget::managingLayoutChanged (  )  [protected, virtual]

Reimplement to respond to a change in managing layout.

Reimplemented from Plasma::LayoutItem.

Definition at line 536 of file widget.cpp.

bool Plasma::Widget::sceneEvent ( QEvent *  event  )  [protected, virtual]

Reimplemented from QGraphicsItem.

Definition at line 559 of file widget.cpp.


Property Documentation

Qt::Orientations Plasma::Widget::expandingDirections [read]

Definition at line 71 of file widget.h.

QSizeF Plasma::Widget::minimumSize [read, write]

Definition at line 72 of file widget.h.

QSizeF Plasma::Widget::maximumSize [read, write]

Definition at line 73 of file widget.h.

QRectF Plasma::Widget::geometry [read, write]

Reimplemented in Plasma::Applet.

Definition at line 74 of file widget.h.

QSizeF Plasma::Widget::sizeHint [read]

Definition at line 75 of file widget.h.

QSizeF Plasma::Widget::size [read, write]

Definition at line 76 of file widget.h.

qreal Plasma::Widget::opacity [read, write]

Definition at line 77 of file widget.h.


The documentation for this class was generated from the following files:
  • widget.h
  • widget.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