2007-07-26 00:20:15 +02:00
|
|
|
/*
|
2007-08-06 13:20:02 +02:00
|
|
|
* Copyright 2007 by Matias Valdenegro T. <mvaldenegro@informatica.utem.cl>
|
2007-09-01 14:34:22 +02:00
|
|
|
* Copyright 2007 by Robert Knight <robertknight@gmail.com>
|
2007-07-26 00:20:15 +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-07-26 00:20:15 +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 PLASMA_BOX_LAYOUT
|
|
|
|
#define PLASMA_BOX_LAYOUT
|
|
|
|
|
|
|
|
#include <QtCore/QList>
|
|
|
|
|
|
|
|
#include <plasma/plasma_export.h>
|
2007-11-20 00:40:03 +01:00
|
|
|
#include <plasma/layouts/layout.h>
|
2007-07-26 00:20:15 +02:00
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
2007-09-01 14:34:22 +02:00
|
|
|
* The BoxLayout class lays out items in a horizontal or vertical line.
|
2007-07-26 00:20:15 +02:00
|
|
|
*/
|
|
|
|
class PLASMA_EXPORT BoxLayout : public Layout
|
|
|
|
{
|
|
|
|
public:
|
2007-09-01 14:34:22 +02:00
|
|
|
/**
|
|
|
|
* This enum describes the directions in which items can be laid
|
|
|
|
* out.
|
|
|
|
*/
|
|
|
|
enum Direction
|
|
|
|
{
|
|
|
|
/** Lay items out horizontally, from left to right. */
|
|
|
|
LeftToRight,
|
|
|
|
/** Lay items out horizontally, from right to left. */
|
|
|
|
RightToLeft,
|
|
|
|
/** Lay items out vertically, from top to bottom. */
|
|
|
|
TopToBottom,
|
|
|
|
/** Lay items out vertically, from bottom to top. */
|
|
|
|
BottomToTop
|
|
|
|
};
|
2007-07-26 00:20:15 +02:00
|
|
|
|
|
|
|
/**
|
2007-09-01 14:34:22 +02:00
|
|
|
* Creates a new box layout which lays items out in the specified
|
|
|
|
* @p direction
|
|
|
|
*/
|
|
|
|
explicit BoxLayout(Direction direction , LayoutItem *parent = 0);
|
2007-07-26 00:20:15 +02:00
|
|
|
~BoxLayout();
|
|
|
|
|
2007-09-01 14:34:22 +02:00
|
|
|
/** Sets the direction in which items are laid out. */
|
|
|
|
void setDirection(Direction direction);
|
|
|
|
/** Returns the direction in which items are laid out. */
|
|
|
|
Direction direction() const;
|
2007-07-26 00:20:15 +02:00
|
|
|
|
2007-09-01 14:34:22 +02:00
|
|
|
/** Inserts a new item into the layout at the specified index. */
|
2007-07-26 00:20:15 +02:00
|
|
|
void insertItem(int index, LayoutItem *l);
|
2007-09-13 19:04:04 +02:00
|
|
|
|
2007-09-01 14:34:22 +02:00
|
|
|
// reimplemented from Layout
|
|
|
|
virtual void addItem(LayoutItem *l);
|
|
|
|
virtual void removeItem(LayoutItem *l);
|
|
|
|
virtual int indexOf(LayoutItem *l) const;
|
|
|
|
virtual LayoutItem *itemAt(int i) const;
|
|
|
|
virtual LayoutItem *takeAt(int i);
|
|
|
|
virtual Qt::Orientations expandingDirections() const;
|
|
|
|
virtual int count() const;
|
2008-01-13 09:22:04 +01:00
|
|
|
virtual void setAnimator(LayoutAnimator* animator);
|
2007-09-01 14:34:22 +02:00
|
|
|
|
|
|
|
virtual QSizeF minimumSize() const;
|
|
|
|
virtual QSizeF maximumSize() const;
|
|
|
|
virtual QSizeF sizeHint() const;
|
2007-07-26 00:20:15 +02:00
|
|
|
|
2007-11-20 00:45:56 +01:00
|
|
|
protected:
|
|
|
|
void relayout();
|
|
|
|
|
2007-07-26 00:20:15 +02:00
|
|
|
private:
|
|
|
|
class Private;
|
|
|
|
Private *const d;
|
|
|
|
};
|
|
|
|
|
2007-09-01 14:34:22 +02:00
|
|
|
/**
|
|
|
|
* A BoxLayout which defaults to laying items out
|
|
|
|
* horizontally in a left-to-right order.
|
|
|
|
*
|
|
|
|
* Equivalent to creating a BoxLayout and passing LeftToRight
|
|
|
|
* in the constructor.
|
|
|
|
*/
|
|
|
|
class PLASMA_EXPORT HBoxLayout : public BoxLayout
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit HBoxLayout(LayoutItem *parent = 0);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A BoxLayout which defaults to laying items out
|
|
|
|
* vertically in a top-to-bottom order.
|
|
|
|
*
|
|
|
|
* Equivalent to creating a BoxLayout and passing TopToBottom
|
|
|
|
* in the constructor.
|
|
|
|
*/
|
|
|
|
class PLASMA_EXPORT VBoxLayout : public BoxLayout
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit VBoxLayout(LayoutItem *parent = 0);
|
|
|
|
};
|
|
|
|
|
2007-07-26 00:20:15 +02:00
|
|
|
}
|
|
|
|
|
2007-09-01 14:34:22 +02:00
|
|
|
#endif /* PLASMA_BOX_LAYOUT */
|