convenience methods for content size access

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=750257
This commit is contained in:
Aaron J. Seigo 2007-12-19 00:45:29 +00:00
parent d7f413742a
commit 65af194560
2 changed files with 45 additions and 6 deletions

View File

@ -869,6 +869,7 @@ void Applet::paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *opti
}
}
//kDebug() << "paint interface of" << (QObject*) this;
paintInterface(painter, option, QRect(QPoint(0,0), d->contentSize(this).toSize()));
}
@ -890,12 +891,7 @@ void Applet::paintInterface(QPainter *painter, const QStyleOptionGraphicsItem *o
FormFactor Applet::formFactor() const
{
Containment* c = containment();
if (!c) {
return Plasma::Planar;
}
return c->formFactor();
return c ? c->formFactor() : Plasma::Planar;
}
Containment* Applet::containment() const
@ -946,6 +942,11 @@ void Applet::setContentSize(const QSizeF &size)
resize(size + QSizeF(left + right, top + bottom));
}
void Applet::setContentSize(int width, int height)
{
setContentSize(QSizeF(width, height));
}
QSizeF Applet::contentSizeHint() const
{
if (layout()) {
@ -963,6 +964,11 @@ void Applet::setMinimumContentSize(const QSizeF &minSize)
setMinimumSize(minSize + QSizeF(left + right, top + bottom));
}
void Applet::setMinimumContentSize(int minWidth, int minHeight)
{
setMinimumContentSize(QSizeF(minWidth, minHeight));
}
QSizeF Applet::minimumContentSize() const
{
int top, left, right, bottom;
@ -979,6 +985,11 @@ void Applet::setMaximumContentSize(const QSizeF &maxSize)
setMaximumSize(maxSize + QSizeF(left + right, top + bottom));
}
void Applet::setMaximumContentSize(int maxWidth, int maxHeight)
{
setMaximumContentSize(QSizeF(maxWidth, maxHeight));
}
QSizeF Applet::maximumContentSize() const
{
int top, left, right, bottom;

View File

@ -236,6 +236,18 @@ class PLASMA_EXPORT Applet : public Widget
*/
void setContentSize(const QSizeF &size);
/**
* Sets the content size.
*
* @note Normally an applet should never
* call this directly except in the constructor to provide a default
* size
*
* @arg width the new width of the contents area
* @arg height the new height of the contents area
*/
void setContentSize(int width, int height);
/**
* Returns an ideal size for the applet's content.
* Applets can re-implement this to provide a suitable size based
@ -254,6 +266,14 @@ class PLASMA_EXPORT Applet : public Widget
*/
void setMinimumContentSize(const QSizeF &minSize);
/**
* Sets the minimum size for the content of this applet
*
* @arg minWidth the new minimum width of the contents area
* @arg minHeight the new minimum height of the contents area
*/
void setMinimumContentSize(int minWidth, int minHeight);
/**
* Get the minimum size for the content of this applet
*/
@ -264,6 +284,14 @@ class PLASMA_EXPORT Applet : public Widget
*/
void setMaximumContentSize(const QSizeF &maxSize);
/**
* Sets the maximum size for the content of this applet
*
* @arg maxWidth the new maximum width of the contents area
* @arg maxHeight the new maximum height of the contents area
*/
void setMaximumContentSize(int maxWidth, int maxHeight);
/**
* Get the minimum size for the content of this applet
*/