2007-09-16 11:08:08 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2007 Ivan Cukic <ivan.cukic+kde@gmail.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2007-10-12 10:45:12 +02:00
|
|
|
* it under the terms of the GNU Library/Lesser General Public License
|
|
|
|
* version 2, or (at your option) any later version, as published by the
|
|
|
|
* Free Software Foundation
|
2007-09-16 11:08:08 +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
|
|
|
|
*
|
2007-10-12 10:45:12 +02:00
|
|
|
* You should have received a copy of the GNU Library/Lesser General Public
|
2007-09-16 11:08:08 +02:00
|
|
|
* 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_BORDER_LAYOUT
|
|
|
|
#define PLASMA_BORDER_LAYOUT
|
|
|
|
|
|
|
|
#include <QtCore/QMap>
|
|
|
|
|
|
|
|
#include <plasma/plasma_export.h>
|
|
|
|
#include <plasma/plasma.h>
|
2008-02-29 18:50:57 +01:00
|
|
|
#include <plasma/layouts/layout.h>
|
2007-09-16 11:08:08 +02:00
|
|
|
|
|
|
|
namespace Plasma {
|
|
|
|
|
2008-07-01 20:56:43 +02:00
|
|
|
class BorderLayoutPrivate;
|
|
|
|
|
2007-09-16 11:08:08 +02:00
|
|
|
/**
|
|
|
|
* A layout which lays one item per border (left, top, bottom, right)
|
|
|
|
* and one item in center.
|
|
|
|
*
|
|
|
|
* Similar to java.awt.BorderLayout from the Java's standard library
|
|
|
|
*/
|
2008-02-29 18:50:57 +01:00
|
|
|
class PLASMA_EXPORT BorderLayout : public Layout {
|
2007-09-16 11:08:08 +02:00
|
|
|
public:
|
|
|
|
|
2008-02-29 18:50:57 +01:00
|
|
|
explicit BorderLayout(LayoutItem * parent = 0);
|
2007-09-16 11:08:08 +02:00
|
|
|
virtual ~BorderLayout();
|
|
|
|
|
2008-02-29 18:50:57 +01:00
|
|
|
virtual Qt::Orientations expandingDirections() const;
|
|
|
|
|
|
|
|
QSizeF sizeHint() const;
|
|
|
|
|
2007-09-16 11:08:08 +02:00
|
|
|
/**
|
|
|
|
* Adds item in the center. Equal to:
|
|
|
|
* addItem(item, Plasma::CenterPositioned);
|
|
|
|
*/
|
2008-02-29 18:50:57 +01:00
|
|
|
void addItem(Plasma::LayoutItem * item);
|
2007-09-16 11:08:08 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds item at the specified position
|
|
|
|
*/
|
2008-02-29 18:50:57 +01:00
|
|
|
void addItem(Plasma::LayoutItem * item, Position position);
|
2007-09-16 11:08:08 +02:00
|
|
|
|
2008-02-29 18:50:57 +01:00
|
|
|
void removeItem(Plasma::LayoutItem * item);
|
2007-09-16 11:08:08 +02:00
|
|
|
|
|
|
|
virtual int count() const;
|
2008-02-29 18:50:57 +01:00
|
|
|
virtual int indexOf(LayoutItem * item) const;
|
|
|
|
virtual LayoutItem * itemAt(int i) const;
|
|
|
|
virtual LayoutItem * takeAt(int i);
|
2007-09-16 11:08:08 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Deactivates the automatic sizing of a border widget,
|
|
|
|
* and sets it to the specified size.
|
|
|
|
*
|
|
|
|
* For left and right widgets, it sets the width; while
|
|
|
|
* for top and bottom ones, it sets the height.
|
|
|
|
*/
|
|
|
|
void setSize(qreal size, Position border);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Activates the automatic sizing of a border widget,
|
|
|
|
* according to it's sizeHint()
|
|
|
|
*/
|
|
|
|
void setAutoSize(Position border);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the size of the specified border widget. If
|
|
|
|
* automatic sizing for that border widget is activated,
|
|
|
|
* it will return a value less than zero.
|
|
|
|
*/
|
|
|
|
qreal size(Position border);
|
|
|
|
|
2007-11-20 00:45:56 +01:00
|
|
|
protected:
|
|
|
|
void relayout();
|
2008-02-29 18:50:57 +01:00
|
|
|
void releaseManagedItems();
|
2007-11-20 00:45:56 +01:00
|
|
|
|
2007-09-16 11:08:08 +02:00
|
|
|
private:
|
2008-07-01 20:56:43 +02:00
|
|
|
BorderLayoutPrivate * const d;
|
2007-09-16 11:08:08 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* PLASMA_BORDER_LAYOUT */
|