2007-05-22 18:48:34 +02:00
|
|
|
/*
|
2007-08-06 13:20:02 +02:00
|
|
|
* Copyright 2007 by Matias Valdenegro T. <mvaldenegro@informatica.utem.cl>
|
2007-05-22 18:48:34 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2007-09-14 22:17:11 +02:00
|
|
|
* it under the terms of the GNU Library General Public License as
|
2007-09-14 21:06:18 +02:00
|
|
|
* published by the Free Software Foundation; either version 2, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
2007-05-22 18:48:34 +02:00
|
|
|
*
|
|
|
|
* 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__
|
|
|
|
#define __LAYOUT__
|
|
|
|
|
|
|
|
#include <QtCore/QRectF>
|
|
|
|
#include <QtCore/QSizeF>
|
|
|
|
|
2007-11-20 00:40:03 +01:00
|
|
|
#include <plasma/layouts/layoutitem.h>
|
2007-06-02 19:29:39 +02:00
|
|
|
#include <plasma/plasma_export.h>
|
2008-02-06 20:12:21 +01:00
|
|
|
#include <plasma/plasma.h>
|
2007-05-22 18:48:34 +02:00
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
2007-08-17 09:02:24 +02:00
|
|
|
class LayoutAnimator;
|
|
|
|
|
2007-05-25 03:27:27 +02:00
|
|
|
/**
|
|
|
|
* Base class for Plasma Layout managers
|
2007-07-23 00:16:40 +02:00
|
|
|
*
|
|
|
|
* @author Matias Valdenegro T. <mvaldenegro@informatica.utem.cl>
|
|
|
|
*
|
|
|
|
* All layout managers must implement this class. Normal users should use the specific layouts,
|
|
|
|
* like Plasma::VBoxLayout, Plasma::HBoxLayout and Plasma::GridLayout.
|
2007-05-25 03:27:27 +02:00
|
|
|
*/
|
2007-05-22 18:48:34 +02:00
|
|
|
|
2007-05-29 10:02:01 +02:00
|
|
|
class PLASMA_EXPORT Layout : public LayoutItem
|
2007-05-22 18:48:34 +02:00
|
|
|
{
|
2007-09-13 19:04:04 +02:00
|
|
|
public:
|
2007-07-23 00:16:40 +02:00
|
|
|
/**
|
|
|
|
* Constructor.
|
|
|
|
*/
|
2007-09-13 19:04:04 +02:00
|
|
|
explicit Layout(LayoutItem *parent);
|
2007-07-23 00:16:40 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Virtual Destructor.
|
|
|
|
*/
|
2007-09-13 19:04:04 +02:00
|
|
|
virtual ~Layout();
|
2007-05-22 18:48:34 +02:00
|
|
|
|
2007-07-23 00:16:40 +02:00
|
|
|
/**
|
|
|
|
* Returns the margin of this Layout.
|
|
|
|
*/
|
2008-02-06 20:12:21 +01:00
|
|
|
qreal margin(Plasma::MarginEdge edge) const;
|
2007-07-23 00:16:40 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the margin of this Layout.
|
|
|
|
*/
|
2008-02-06 20:12:21 +01:00
|
|
|
void setMargin(Plasma::MarginEdge edge, qreal m);
|
2007-11-19 04:30:24 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets all the margins of this Layout.
|
|
|
|
*/
|
2007-09-13 19:04:04 +02:00
|
|
|
void setMargin(qreal m);
|
2007-05-22 18:48:34 +02:00
|
|
|
|
2007-07-23 00:16:40 +02:00
|
|
|
/**
|
|
|
|
* Returns the spacing between Layout elements of this Layout.
|
|
|
|
*/
|
2007-09-13 19:04:04 +02:00
|
|
|
qreal spacing() const;
|
2007-07-23 00:16:40 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the spacing of this Layout.
|
|
|
|
*/
|
2007-09-13 19:04:04 +02:00
|
|
|
void setSpacing(qreal s);
|
2007-05-22 18:48:34 +02:00
|
|
|
|
2007-07-23 00:16:40 +02:00
|
|
|
/**
|
|
|
|
* Returns the parent of this Layout.
|
|
|
|
*/
|
2007-09-13 19:04:04 +02:00
|
|
|
LayoutItem *parent() const;
|
2007-05-22 18:48:34 +02:00
|
|
|
|
2007-08-31 17:27:32 +02:00
|
|
|
/**
|
|
|
|
* Sets the parent of this layout.
|
|
|
|
*/
|
|
|
|
void setParent(LayoutItem *parent);
|
|
|
|
|
2007-07-23 00:16:40 +02:00
|
|
|
/**
|
|
|
|
* Returns the number of elements of this Layout.
|
|
|
|
*/
|
2007-09-13 19:04:04 +02:00
|
|
|
virtual int count() const = 0;
|
2007-07-23 00:16:40 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if this Layout contains no elements, false otherwise.
|
|
|
|
*/
|
2007-09-13 19:04:04 +02:00
|
|
|
bool isEmpty() const;
|
2007-05-22 18:48:34 +02:00
|
|
|
|
2007-07-23 00:16:40 +02:00
|
|
|
/**
|
|
|
|
* Adds a Item to this Layout.
|
|
|
|
* @param l Pointer to the Item to be added.
|
|
|
|
*/
|
2007-11-17 22:42:36 +01:00
|
|
|
virtual void addItem(LayoutItem *l) = 0;
|
2007-05-22 18:48:34 +02:00
|
|
|
|
2007-07-23 00:16:40 +02:00
|
|
|
/**
|
|
|
|
* Removes a Item from this Layout.
|
|
|
|
* @param l Pointer to the Item to be removed.
|
|
|
|
*/
|
2007-09-13 19:04:04 +02:00
|
|
|
virtual void removeItem(LayoutItem *l) = 0;
|
2007-05-22 18:48:34 +02:00
|
|
|
|
2007-07-23 00:16:40 +02:00
|
|
|
/**
|
|
|
|
* Returns the index of a Item in this Layout.
|
|
|
|
* @param l Pointer to an Item to be queryed.
|
|
|
|
*/
|
2007-09-13 19:04:04 +02:00
|
|
|
virtual int indexOf(LayoutItem *l) const = 0;
|
2007-07-23 00:16:40 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a Pointer to an Item in this Layout.
|
|
|
|
* @param i Index of the desired Item.
|
|
|
|
*/
|
2007-09-13 19:04:04 +02:00
|
|
|
virtual LayoutItem *itemAt(int i) const = 0;
|
2007-07-23 00:16:40 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Takes the Pointer of an Item in this Layout.
|
|
|
|
* @param i Index of the desired Item.
|
|
|
|
*/
|
2007-09-13 19:04:04 +02:00
|
|
|
virtual LayoutItem *takeAt(int i) = 0;
|
2007-05-22 18:48:34 +02:00
|
|
|
|
2007-08-17 09:02:24 +02:00
|
|
|
/**
|
|
|
|
* Returns the object controlling animation of changes
|
|
|
|
* in this layout or 0 if no animator has been set.
|
|
|
|
*/
|
|
|
|
virtual LayoutAnimator* animator() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the object controlling animation of changes in this
|
|
|
|
* layout.
|
|
|
|
*/
|
|
|
|
virtual void setAnimator( LayoutAnimator* animator );
|
|
|
|
|
2007-11-20 00:45:56 +01:00
|
|
|
/**
|
|
|
|
* Returns the current geometry for this layout
|
|
|
|
*/
|
|
|
|
virtual QRectF geometry() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Changes the geometry of this layout
|
|
|
|
*/
|
|
|
|
void setGeometry(const QRectF &geometry);
|
|
|
|
|
2007-08-17 09:02:24 +02:00
|
|
|
/** Triggers an update of the layout. */
|
2007-11-20 00:45:56 +01:00
|
|
|
void updateGeometry();
|
2007-08-22 22:13:24 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the minimum size of this layout.
|
|
|
|
* The default implementation allows unlimited resizing.
|
|
|
|
*/
|
|
|
|
virtual QSizeF minimumSize() const;
|
|
|
|
/**
|
|
|
|
* Returns the maximum size of this layout. The default
|
|
|
|
* implementation allows unlimited resizing.
|
|
|
|
*/
|
2007-08-31 17:27:32 +02:00
|
|
|
virtual QSizeF maximumSize() const;
|
|
|
|
|
|
|
|
/** TODO Document me */
|
2008-02-06 19:16:11 +01:00
|
|
|
void invalidate();
|
2007-08-31 17:27:32 +02:00
|
|
|
|
2007-09-03 02:52:29 +02:00
|
|
|
protected:
|
2007-11-20 00:45:56 +01:00
|
|
|
/**
|
|
|
|
* Triggers a layout, usually after a change in geometry
|
|
|
|
*/
|
|
|
|
virtual void relayout() = 0;
|
|
|
|
|
2008-02-11 06:50:47 +01:00
|
|
|
/**
|
|
|
|
* When called, the layout must cease management of any
|
|
|
|
* current LayoutItems it is managing.
|
|
|
|
*/
|
|
|
|
virtual void releaseManagedItems() = 0;
|
|
|
|
|
2007-09-03 02:52:29 +02:00
|
|
|
/**
|
|
|
|
* Starts a layout animation. Subclasses may call this
|
2007-11-20 00:45:56 +01:00
|
|
|
* at the end of their relayout() implementation to
|
2007-09-03 02:52:29 +02:00
|
|
|
* start the timeline associated with the layout's animator()
|
|
|
|
* if there is one. If an animation is already in progress then
|
|
|
|
* the timeline is reset to 0ms and the animation continues.
|
|
|
|
*/
|
|
|
|
void startAnimation();
|
|
|
|
|
2007-09-13 19:04:04 +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__ */
|