qboxlayout.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
00004 ** All rights reserved.
00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
00006 **
00007 ** This file is part of the QtGui module of the Qt Toolkit.
00008 **
00009 ** $QT_BEGIN_LICENSE:LGPL$
00010 ** Commercial Usage
00011 ** Licensees holding valid Qt Commercial licenses may use this file in
00012 ** accordance with the Qt Commercial License Agreement provided with the
00013 ** Software or, alternatively, in accordance with the terms contained in
00014 ** a written agreement between you and Nokia.
00015 **
00016 ** GNU Lesser General Public License Usage
00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
00018 ** General Public License version 2.1 as published by the Free Software
00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
00020 ** packaging of this file.  Please review the following information to
00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
00023 **
00024 ** In addition, as a special exception, Nokia gives you certain additional
00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
00027 **
00028 ** GNU General Public License Usage
00029 ** Alternatively, this file may be used under the terms of the GNU
00030 ** General Public License version 3.0 as published by the Free Software
00031 ** Foundation and appearing in the file LICENSE.GPL included in the
00032 ** packaging of this file.  Please review the following information to
00033 ** ensure the GNU General Public License version 3.0 requirements will be
00034 ** met: http://www.gnu.org/copyleft/gpl.html.
00035 **
00036 ** If you have questions regarding the use of this file, please contact
00037 ** Nokia at qt-info@nokia.com.
00038 ** $QT_END_LICENSE$
00039 **
00040 ****************************************************************************/
00041 
00042 #ifndef QBOXLAYOUT_H
00043 #define QBOXLAYOUT_H
00044 
00045 #include <QtGui/qlayout.h>
00046 #ifdef QT_INCLUDE_COMPAT
00047 #include <QtGui/qwidget.h>
00048 #endif
00049 
00050 #include <limits.h>
00051 
00052 QT_BEGIN_HEADER
00053 
00054 QT_BEGIN_NAMESPACE
00055 
00056 QT_MODULE(Gui)
00057 
00058 class QBoxLayoutPrivate;
00059 
00060 class Q_GUI_EXPORT QBoxLayout : public QLayout
00061 {
00062     Q_OBJECT
00063     Q_DECLARE_PRIVATE(QBoxLayout)
00064 public:
00065     enum Direction { LeftToRight, RightToLeft, TopToBottom, BottomToTop,
00066                      Down = TopToBottom, Up = BottomToTop };
00067 
00068     explicit QBoxLayout(Direction, QWidget *parent = 0);
00069 
00070 #ifdef QT3_SUPPORT
00071     QT3_SUPPORT_CONSTRUCTOR QBoxLayout(QWidget *parent, Direction, int border = 0, int spacing = -1,
00072                 const char *name = 0);
00073     QT3_SUPPORT_CONSTRUCTOR  QBoxLayout(QLayout *parentLayout, Direction, int spacing = -1,
00074                 const char *name = 0);
00075     QT3_SUPPORT_CONSTRUCTOR  QBoxLayout(Direction, int spacing, const char *name = 0);
00076 #endif
00077     ~QBoxLayout();
00078 
00079     Direction direction() const;
00080     void setDirection(Direction);
00081 
00082     void addSpacing(int size);
00083     void addStretch(int stretch = 0);
00084     void addSpacerItem(QSpacerItem *spacerItem);
00085     void addWidget(QWidget *, int stretch = 0, Qt::Alignment alignment = 0);
00086     void addLayout(QLayout *layout, int stretch = 0);
00087     void addStrut(int);
00088     void addItem(QLayoutItem *);
00089 
00090     void insertSpacing(int index, int size);
00091     void insertStretch(int index, int stretch = 0);
00092     void insertSpacerItem(int index, QSpacerItem *spacerItem);
00093     void insertWidget(int index, QWidget *widget, int stretch = 0, Qt::Alignment alignment = 0);
00094     void insertLayout(int index, QLayout *layout, int stretch = 0);
00095 
00096     int spacing() const;
00097     void setSpacing(int spacing);
00098 
00099     bool setStretchFactor(QWidget *w, int stretch);
00100     bool setStretchFactor(QLayout *l, int stretch);
00101     void setStretch(int index, int stretch);
00102     int stretch(int index) const;
00103 
00104     QSize sizeHint() const;
00105     QSize minimumSize() const;
00106     QSize maximumSize() const;
00107 
00108     bool hasHeightForWidth() const;
00109     int heightForWidth(int) const;
00110     int minimumHeightForWidth(int) const;
00111 
00112     Qt::Orientations expandingDirections() const;
00113     void invalidate();
00114     QLayoutItem *itemAt(int) const;
00115     QLayoutItem *takeAt(int);
00116     int count() const;
00117     void setGeometry(const QRect&);
00118 #ifdef QT3_SUPPORT
00119     inline QT3_SUPPORT int findWidget(QWidget* w) {return indexOf(w);}
00120 #endif
00121 protected:
00122     // ### Qt 5: make public
00123     void insertItem(int index, QLayoutItem *);
00124 
00125 private:
00126     Q_DISABLE_COPY(QBoxLayout)
00127 };
00128 
00129 class Q_GUI_EXPORT QHBoxLayout : public QBoxLayout
00130 {
00131     Q_OBJECT
00132 public:
00133     QHBoxLayout();
00134     explicit QHBoxLayout(QWidget *parent);
00135     ~QHBoxLayout();
00136 
00137 #ifdef QT3_SUPPORT
00138     QT3_SUPPORT_CONSTRUCTOR QHBoxLayout(QWidget *parent, int border,
00139                  int spacing = -1, const char *name = 0);
00140     QT3_SUPPORT_CONSTRUCTOR QHBoxLayout(QLayout *parentLayout,
00141                  int spacing = -1, const char *name = 0);
00142     QT3_SUPPORT_CONSTRUCTOR QHBoxLayout(int spacing, const char *name = 0);
00143 #endif
00144 
00145 private:
00146     Q_DISABLE_COPY(QHBoxLayout)
00147 };
00148 
00149 class Q_GUI_EXPORT QVBoxLayout : public QBoxLayout
00150 {
00151     Q_OBJECT
00152 public:
00153     QVBoxLayout();
00154     explicit QVBoxLayout(QWidget *parent);
00155     ~QVBoxLayout();
00156 
00157 #ifdef QT3_SUPPORT
00158     QT3_SUPPORT_CONSTRUCTOR QVBoxLayout(QWidget *parent, int border,
00159                  int spacing = -1, const char *name = 0);
00160     QT3_SUPPORT_CONSTRUCTOR QVBoxLayout(QLayout *parentLayout,
00161                  int spacing = -1, const char *name = 0);
00162     QT3_SUPPORT_CONSTRUCTOR QVBoxLayout(int spacing, const char *name = 0);
00163 #endif
00164 
00165 private:
00166     Q_DISABLE_COPY(QVBoxLayout)
00167 };
00168 
00169 QT_END_NAMESPACE
00170 
00171 QT_END_HEADER
00172 
00173 #endif // QBOXLAYOUT_H