Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef FREE_LAYOUT_H
Toshihiro Shimizu 890ddd
#define FREE_LAYOUT_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzCore includes
Toshihiro Shimizu 890ddd
#include "tcommon.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// Qt includes
Toshihiro Shimizu 890ddd
#include <qlist></qlist>
Toshihiro Shimizu 890ddd
#include <qlayout></qlayout>
Toshihiro Shimizu 890ddd
#include <qwidget></qwidget>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#undef DVAPI
Toshihiro Shimizu 890ddd
#undef DVVAR
Toshihiro Shimizu 890ddd
#ifdef TOONZQT_EXPORTS
Toshihiro Shimizu 890ddd
#define DVAPI DV_EXPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_EXPORT_VAR
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#define DVAPI DV_IMPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_IMPORT_VAR
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//************************************************************************************
Toshihiro Shimizu 890ddd
//    DummyLayout   declaration
Toshihiro Shimizu 890ddd
//************************************************************************************
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*!
Toshihiro Shimizu 890ddd
  \brief    The DummyLayout class implements a layout whose items' geometry is not
Toshihiro Shimizu 890ddd
            enforced at all, ignoring parent size bounds or geometry.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
  \details  A DummyLayout serves as a simple, inert container of layout items.
Toshihiro Shimizu 890ddd
            It does not enforce geometry to items added to it, allowing objects
Toshihiro Shimizu 890ddd
            using this layout to appear as a 'viewport' for free-geometry items.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
  \note     As this layout does not effectively manage its objects' geometry, these
Toshihiro Shimizu 890ddd
            must be managed outside.
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class DVAPI DummyLayout : public QLayout
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	DummyLayout();
Toshihiro Shimizu 890ddd
	virtual ~DummyLayout();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	QSize sizeHint() const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	QSize minimumSize() const { return QSize(0, 0); }
Toshihiro Shimizu 890ddd
	QSize maximumSize() const { return QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	int count() const { return m_items.count(); }
Toshihiro Shimizu 890ddd
	void addItem(QLayoutItem *item) { m_items.push_back(item); }
Toshihiro Shimizu 890ddd
	QLayoutItem *itemAt(int index) const { return (index < count()) ? m_items.at(index) : 0; }
Toshihiro Shimizu 890ddd
	QLayoutItem *takeAt(int index) { return (index < count()) ? m_items.takeAt(index) : 0; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setGeometry(const QRect &r) {}
Toshihiro Shimizu 890ddd
	//Qt::Orientations	expandingDirections () const { return Qt::Orientations(); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Toshihiro Shimizu 890ddd
	QList<qlayoutitem *=""> m_items;</qlayoutitem>
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//************************************************************************************
Toshihiro Shimizu 890ddd
//    FreeLayout   declaration
Toshihiro Shimizu 890ddd
//************************************************************************************
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*!
Toshihiro Shimizu 890ddd
  \brief    The FreeLayout class implements a layout whose items can be freely
Toshihiro Shimizu 890ddd
            positioned, ignoring parent size bounds or geometry.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
  \details  A FreeLayout instance can be used to achieve results similar to that
Toshihiro Shimizu 890ddd
            of a QScrollArea, with a more straightforward API and without restriction
Toshihiro Shimizu 890ddd
            to just one item at a time. Please observe that layouts can be inserted too.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
            Specifically, FreeLayout is a convenience subclass of DummyLayout whose items'
Toshihiro Shimizu 890ddd
            sizes are enforced to their sizeHint() - in order to spare users from having to deal
Toshihiro Shimizu 890ddd
            with it externally. This complies with the idea that its items are comfortly
Toshihiro Shimizu 890ddd
            free to adapt to their preferred size, as it would be in a scrollable environment.
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class FreeLayout : public DummyLayout
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	FreeLayout() : DummyLayout() {}
Toshihiro Shimizu 890ddd
	~FreeLayout() {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setGeometry(const QRect &r);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif // FREE_LAYOUT_H