2
* Copyright 2007 by Matias Valdenegro T. <mvaldenegro@informatica.utem.cl>
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Library General Public License version 2 as
6
* published by the Free Software Foundation
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details
13
* You should have received a copy of the GNU Library General Public
14
* License along with this program; if not, write to the
15
* Free Software Foundation, Inc.,
16
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
#ifndef __LAYOUT_ITEM__
20
#define __LAYOUT_ITEM__
22
#include <QtCore/QRectF>
23
#include <QtCore/QSizeF>
25
#include <plasma/plasma_export.h>
35
* Base class for Plasma layout-managed items
37
* @author Matias Valdenegro T. <mvaldenegro@informatica.utem.cl>
39
* All layout-managed items should implement this class, but regular users just need to use
40
* Plasma::Widget and Plasma::Layout.
42
class PLASMA_EXPORT LayoutItem
49
explicit LayoutItem();
54
virtual ~LayoutItem();
57
* Returns a bitmask with the directions that this Item can be expanded.
59
virtual Qt::Orientations expandingDirections() const = 0;
62
* Returns the minimum size of this Item and it's contents.
64
virtual QSizeF minimumSize() const = 0;
67
* Returns the maximum size of this Item.
69
virtual QSizeF maximumSize() const = 0;
72
* Returns true whatever this Item can use height-for-width layout management,
75
virtual bool hasHeightForWidth() const;
78
* Returns the corresponding height for a given width.
81
virtual qreal heightForWidth(qreal w) const;
84
* Returns true whatever this Item can use width-for-height layout management,
87
virtual bool hasWidthForHeight() const;
90
* Returns the corresponding width for a given height.
93
virtual qreal widthForHeight(qreal h) const;
96
* Returns the geometry of this Item.
98
virtual QRectF geometry() const = 0;
101
* Sets the geometry of this Item.
103
virtual void setGeometry(const QRectF& geometry) = 0;
106
* Returns the most appropriate size of this Item to hold whatever contents it has.
108
virtual QSizeF sizeHint() const = 0;
111
* Sets the layout that will manage children items
113
* @param layout The Layout that this LayoutItem will be managed by.
115
void setLayout(Layout* layout);
118
* @return the layout this item is currently associated with.
120
Layout* layout() const;
123
* Sets the layout that manages this item's geometry
125
* @param layout the layout that manage this item's geometry
127
void setManagingLayout(Layout* layout);
130
* Resets the layout that manges this item's geometry if it is the
131
* currently associated layout
133
* @param layout to unset
135
void unsetManagingLayout(Layout* layout);
138
* @return the layout that manages this item's geometry, or 0 if none
140
Layout* managingLayout() const;
143
* Returns the graphics item associated with this layout item or 0
144
* if there is no associated graphics item.
146
* The default implementation returns 0.
148
virtual QGraphicsItem* graphicsItem();
157
#endif /* __LAYOUT_ITEM__ */