2007-05-22 18:48:34 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2007 by Matias Valdenegro T. <mvaldenegro@informatica.utem.cl>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Library General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __LAYOUT_ITEM__
|
|
|
|
#define __LAYOUT_ITEM__
|
|
|
|
|
|
|
|
#include <QtCore/QRectF>
|
|
|
|
#include <QtCore/QSizeF>
|
|
|
|
|
2007-06-02 19:29:39 +02:00
|
|
|
#include <plasma/plasma_export.h>
|
2007-05-22 18:48:34 +02:00
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
2007-05-28 07:46:24 +02:00
|
|
|
class Layout;
|
|
|
|
|
2007-05-25 03:27:27 +02:00
|
|
|
/**
|
|
|
|
* Base class for Plasma layout-managed items
|
2007-07-23 00:16:40 +02:00
|
|
|
*
|
|
|
|
* @author Matias Valdenegro T. <mvaldenegro@informatica.utem.cl>
|
|
|
|
*
|
|
|
|
* All layout-managed items should implement this class, but regular users just need to use
|
|
|
|
* Plasma::Widget and Plasma::Layout.
|
2007-05-25 03:27:27 +02:00
|
|
|
*/
|
2007-05-29 10:02:01 +02:00
|
|
|
class PLASMA_EXPORT LayoutItem
|
2007-05-22 18:48:34 +02:00
|
|
|
{
|
2007-05-28 07:46:24 +02:00
|
|
|
public:
|
2007-07-23 00:16:40 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor.
|
|
|
|
*/
|
2007-07-27 22:00:07 +02:00
|
|
|
explicit LayoutItem();
|
2007-07-23 00:16:40 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Virtual Destructor.
|
|
|
|
*/
|
2007-05-28 07:46:24 +02:00
|
|
|
virtual ~LayoutItem();
|
|
|
|
|
2007-07-23 00:16:40 +02:00
|
|
|
/**
|
|
|
|
* Returns a bitmask with the directions that this Item can be expanded.
|
|
|
|
*/
|
2007-05-28 07:46:24 +02:00
|
|
|
virtual Qt::Orientations expandingDirections() const = 0;
|
2007-05-22 18:48:34 +02:00
|
|
|
|
2007-07-23 00:16:40 +02:00
|
|
|
/**
|
|
|
|
* Returns the minimum size of this Item and it's contents.
|
|
|
|
*/
|
2007-05-28 07:46:24 +02:00
|
|
|
virtual QSizeF minimumSize() const = 0;
|
2007-07-23 00:16:40 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the maximum size of this Item.
|
|
|
|
*/
|
2007-05-28 07:46:24 +02:00
|
|
|
virtual QSizeF maximumSize() const = 0;
|
2007-05-22 18:48:34 +02:00
|
|
|
|
2007-07-23 00:16:40 +02:00
|
|
|
/**
|
|
|
|
* Returns true whatever this Item can use height-for-width layout management,
|
|
|
|
* false otherwise.
|
|
|
|
*/
|
2007-05-28 07:46:24 +02:00
|
|
|
virtual bool hasHeightForWidth() const;
|
2007-07-23 00:16:40 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the corresponding height for a given width.
|
|
|
|
* @param w Width
|
|
|
|
*/
|
2007-05-28 07:46:24 +02:00
|
|
|
virtual qreal heightForWidth(qreal w) const;
|
2007-05-22 18:48:34 +02:00
|
|
|
|
2007-07-23 00:16:40 +02:00
|
|
|
/**
|
|
|
|
* Returns true whatever this Item can use width-for-height layout management,
|
|
|
|
* false otherwise.
|
|
|
|
*/
|
2007-05-28 07:46:24 +02:00
|
|
|
virtual bool hasWidthForHeight() const;
|
2007-07-23 00:16:40 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the corresponding width for a given height.
|
|
|
|
* @param h Height
|
|
|
|
*/
|
2007-05-28 07:46:24 +02:00
|
|
|
virtual qreal widthForHeight(qreal h) const;
|
2007-05-22 18:48:34 +02:00
|
|
|
|
2007-07-23 00:16:40 +02:00
|
|
|
/**
|
|
|
|
* Returns the geometry of this Item.
|
|
|
|
*/
|
2007-05-28 07:46:24 +02:00
|
|
|
virtual QRectF geometry() const = 0;
|
2007-07-23 00:16:40 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the geometry of this Item.
|
|
|
|
*/
|
2007-05-28 07:46:24 +02:00
|
|
|
virtual void setGeometry(const QRectF& geometry) = 0;
|
2007-05-22 18:48:34 +02:00
|
|
|
|
2007-07-23 00:16:40 +02:00
|
|
|
/**
|
2007-07-25 13:24:07 +02:00
|
|
|
* Returns the most appropriate size of this Item to hold whatever contents it has.
|
2007-07-23 00:16:40 +02:00
|
|
|
*/
|
2007-05-28 07:46:24 +02:00
|
|
|
virtual QSizeF sizeHint() const = 0;
|
2007-05-22 18:48:34 +02:00
|
|
|
|
2007-05-28 07:52:05 +02:00
|
|
|
/**
|
2007-07-27 22:00:07 +02:00
|
|
|
* Sets the layout that will manage children items
|
2007-05-28 07:52:05 +02:00
|
|
|
*
|
|
|
|
* @param layout The Layout that this LayoutItem will be managed by.
|
|
|
|
*/
|
2007-05-28 07:46:24 +02:00
|
|
|
void setLayout(Layout* layout);
|
2007-05-28 07:52:05 +02:00
|
|
|
|
|
|
|
/**
|
2007-07-27 22:00:07 +02:00
|
|
|
* @return the layout this item is currently associated with.
|
2007-05-28 07:52:05 +02:00
|
|
|
*/
|
2007-07-29 01:40:21 +02:00
|
|
|
Layout* layout() const;
|
2007-05-22 18:48:34 +02:00
|
|
|
|
2007-07-27 22:00:07 +02:00
|
|
|
/**
|
|
|
|
* Sets the layout that manages this item's geometry
|
|
|
|
*
|
|
|
|
* @param layout the layout that manage this item's geometry
|
|
|
|
**/
|
|
|
|
void setManagingLayout(Layout* layout);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resets the layout that manges this item's geometry if it is the
|
|
|
|
* currently associated layout
|
|
|
|
*
|
|
|
|
* @param layout to unset
|
|
|
|
**/
|
|
|
|
void unsetManagingLayout(Layout* layout);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the layout that manages this item's geometry, or 0 if none
|
|
|
|
**/
|
2007-07-29 01:40:21 +02:00
|
|
|
Layout* managingLayout() const;
|
2007-07-27 22:00:07 +02:00
|
|
|
|
2007-05-28 07:46:24 +02:00
|
|
|
private:
|
|
|
|
class Private;
|
|
|
|
Private *const d;
|
2007-05-22 18:48:34 +02:00
|
|
|
};
|
|
|
|
|
2007-05-22 21:23:22 +02:00
|
|
|
}
|
2007-05-22 18:48:34 +02:00
|
|
|
|
|
|
|
#endif /* __LAYOUT_ITEM__ */
|