libplasma
Plasma::Widget Class Reference
#include <widget.h>

Detailed Description
Base class for all Widgets in Plasma.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
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] |
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] |
| 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] |
| 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 |
| 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
- 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 |
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] |
| 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 |
| 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] |
Property Documentation
QRectF Plasma::Widget::geometry [read, write] |
The documentation for this class was generated from the following files:
KDE 4.0 API Reference