qgridlayout.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 QGRIDLAYOUT_H
00043 #define QGRIDLAYOUT_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 QGridLayoutPrivate;
00059 
00060 class Q_GUI_EXPORT QGridLayout : public QLayout
00061 {
00062     Q_OBJECT
00063     Q_DECLARE_PRIVATE(QGridLayout)
00064     QDOC_PROPERTY(int horizontalSpacing READ horizontalSpacing WRITE setHorizontalSpacing)
00065     QDOC_PROPERTY(int verticalSpacing READ verticalSpacing WRITE setVerticalSpacing)
00066 
00067 public:
00068     explicit QGridLayout(QWidget *parent);
00069     QGridLayout();
00070 
00071 #ifdef QT3_SUPPORT
00072     QT3_SUPPORT_CONSTRUCTOR QGridLayout(QWidget *parent, int nRows , int nCols = 1, int border = 0,
00073                                       int spacing = -1, const char *name = 0);
00074     QT3_SUPPORT_CONSTRUCTOR QGridLayout(int nRows , int nCols = 1, int spacing = -1, const char *name = 0);
00075     QT3_SUPPORT_CONSTRUCTOR QGridLayout(QLayout *parentLayout, int nRows = 1, int nCols = 1, int spacing = -1,
00076                                       const char *name = 0);
00077 #endif
00078     ~QGridLayout();
00079 
00080     QSize sizeHint() const;
00081     QSize minimumSize() const;
00082     QSize maximumSize() const;
00083 
00084     void setHorizontalSpacing(int spacing);
00085     int horizontalSpacing() const;
00086     void setVerticalSpacing(int spacing);
00087     int verticalSpacing() const;
00088     void setSpacing(int spacing);
00089     int spacing() const;
00090 
00091     void setRowStretch(int row, int stretch);
00092     void setColumnStretch(int column, int stretch);
00093     int rowStretch(int row) const;
00094     int columnStretch(int column) const;
00095 
00096     void setRowMinimumHeight(int row, int minSize);
00097     void setColumnMinimumWidth(int column, int minSize);
00098     int rowMinimumHeight(int row) const;
00099     int columnMinimumWidth(int column) const;
00100 
00101     int columnCount() const;
00102     int rowCount() const;
00103 
00104     QRect cellRect(int row, int column) const;
00105 #ifdef QT3_SUPPORT
00106     inline QT3_SUPPORT QRect cellGeometry(int row, int column) const {return cellRect(row, column);}
00107 #endif
00108 
00109     bool hasHeightForWidth() const;
00110     int heightForWidth(int) const;
00111     int minimumHeightForWidth(int) const;
00112 
00113     Qt::Orientations expandingDirections() const;
00114     void invalidate();
00115 
00116     inline void addWidget(QWidget *w) { QLayout::addWidget(w); }
00117     void addWidget(QWidget *, int row, int column, Qt::Alignment = 0);
00118     void addWidget(QWidget *, int row, int column, int rowSpan, int columnSpan, Qt::Alignment = 0);
00119     void addLayout(QLayout *, int row, int column, Qt::Alignment = 0);
00120     void addLayout(QLayout *, int row, int column, int rowSpan, int columnSpan, Qt::Alignment = 0);
00121 
00122     void setOriginCorner(Qt::Corner);
00123     Qt::Corner originCorner() const;
00124 
00125 #ifdef QT3_SUPPORT
00126     inline QT3_SUPPORT void setOrigin(Qt::Corner corner) { setOriginCorner(corner); }
00127     inline QT3_SUPPORT Qt::Corner origin() const { return originCorner(); }
00128 #endif
00129     QLayoutItem *itemAt(int index) const;
00130     QLayoutItem *itemAtPosition(int row, int column) const;
00131     QLayoutItem *takeAt(int index);
00132     int count() const;
00133     void setGeometry(const QRect&);
00134 
00135     void addItem(QLayoutItem *item, int row, int column, int rowSpan = 1, int columnSpan = 1, Qt::Alignment = 0);
00136 
00137     void setDefaultPositioning(int n, Qt::Orientation orient);
00138     void getItemPosition(int idx, int *row, int *column, int *rowSpan, int *columnSpan);
00139 
00140 protected:
00141 #ifdef QT3_SUPPORT
00142     QT3_SUPPORT bool findWidget(QWidget* w, int *r, int *c);
00143 #endif
00144     void addItem(QLayoutItem *);
00145 
00146 private:
00147     Q_DISABLE_COPY(QGridLayout)
00148 
00149 #ifdef QT3_SUPPORT
00150 public:
00151     QT3_SUPPORT void expand(int rows, int cols);
00152     inline QT3_SUPPORT void addRowSpacing(int row, int minsize) { addItem(new QSpacerItem(0,minsize), row, 0); }
00153     inline QT3_SUPPORT void addColSpacing(int col, int minsize) { addItem(new QSpacerItem(minsize,0), 0, col); }
00154     inline QT3_SUPPORT void addMultiCellWidget(QWidget *w, int fromRow, int toRow, int fromCol, int toCol, Qt::Alignment _align = 0)
00155         { addWidget(w, fromRow, fromCol, (toRow < 0) ? -1 : toRow - fromRow + 1, (toCol < 0) ? -1 : toCol - fromCol + 1, _align); }
00156     inline QT3_SUPPORT void addMultiCell(QLayoutItem *l, int fromRow, int toRow, int fromCol, int toCol, Qt::Alignment _align = 0)
00157         { addItem(l, fromRow, fromCol, (toRow < 0) ? -1 : toRow - fromRow + 1, (toCol < 0) ? -1 : toCol - fromCol + 1, _align); }
00158     inline QT3_SUPPORT void addMultiCellLayout(QLayout *layout, int fromRow, int toRow, int fromCol, int toCol, Qt::Alignment _align = 0)
00159         { addLayout(layout, fromRow, fromCol, (toRow < 0) ? -1 : toRow - fromRow + 1, (toCol < 0) ? -1 : toCol - fromCol + 1, _align); }
00160 
00161     inline QT3_SUPPORT int numRows() const { return rowCount(); }
00162     inline QT3_SUPPORT int numCols() const { return columnCount(); }
00163     inline QT3_SUPPORT void setColStretch(int col, int stretch) {setColumnStretch(col, stretch); }
00164     inline QT3_SUPPORT int colStretch(int col) const {return columnStretch(col); }
00165     inline QT3_SUPPORT void setColSpacing(int col, int minSize) { setColumnMinimumWidth(col, minSize); }
00166     inline QT3_SUPPORT int colSpacing(int col) const { return columnMinimumWidth(col); }
00167     inline QT3_SUPPORT void setRowSpacing(int row, int minSize) {setRowMinimumHeight(row, minSize); }
00168     inline QT3_SUPPORT int rowSpacing(int row) const {return rowMinimumHeight(row); }
00169 #endif
00170 };
00171 
00172 QT_END_NAMESPACE
00173 
00174 QT_END_HEADER
00175 
00176 #endif // QGRIDLAYOUT_H