QCodeEdit  2.2
lib/qpanellayout.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 2006-2009 fullmetalcoder <fullmetalcoder@hotmail.fr>
00004 **
00005 ** This file is part of the Edyuk project <http://edyuk.org>
00006 ** 
00007 ** This file may be used under the terms of the GNU General Public License
00008 ** version 3 as published by the Free Software Foundation and appearing in the
00009 ** file GPL.txt included in the packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ****************************************************************************/
00015 
00016 #ifndef _QPANEL_LAYOUT_H_
00017 #define _QPANEL_LAYOUT_H_
00018 
00019 #include "qce-config.h"
00020 
00026 #include <QList>
00027 #include <QLayout>
00028 #include <QPointer>
00029 
00030 class QPanel;
00031 class QEditor;
00032 
00033 class QCE_EXPORT QPanelLayout : public QLayout
00034 {
00035     Q_OBJECT
00036     
00037     public:
00038         enum Position
00039         {
00040             West,
00041             North,
00042             South,
00043             East
00044         };
00045         
00046         QPanelLayout(QEditor *p);
00047         QPanelLayout(const QString& layout, QEditor *p);
00048         virtual ~QPanelLayout();
00049         
00050         virtual int count() const;
00051         virtual bool hasHeightForWidth() const;
00052         virtual Qt::Orientations expandingDirections() const;
00053         
00054         virtual QSize sizeHint() const;
00055         virtual QSize minimumSize() const;
00056         
00057         virtual QLayoutItem *itemAt(int idx) const;
00058         virtual QLayoutItem *takeAt(int idx);
00059         
00060         QString serialized() const;
00061         void addSerialized(const QString& layout);
00062         
00063         QList<QPanel*> panels() const;
00064         
00065     public slots:
00066         virtual void addItem(QLayoutItem *item);
00067         virtual void setGeometry(const QRect &rect);
00068         
00069         void add(QLayoutItem *item, Position position);
00070         void addWidget(QWidget *widget, Position position);
00071         
00072     private:
00073         QPointer<QEditor> m_parent;
00074         
00075         struct PanelWrapper
00076         {
00077             PanelWrapper(QLayoutItem *i, Position p)
00078             {
00079                 item = i;
00080                 position = p;
00081             }
00082             
00083             QLayoutItem *item;
00084             Position position;
00085         };
00086         
00087         enum SizeType { MinimumSize, SizeHint };
00088         QSize calculateSize(SizeType sizeType) const;
00089         
00090         QList<PanelWrapper*> m_list;
00091 };
00092 
00093 #endif // _QPANEL_LAYOUT_H_
00094