src/gui/kernel/qgridlayout.h
changeset 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the QtGui module of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #ifndef QGRIDLAYOUT_H
       
    43 #define QGRIDLAYOUT_H
       
    44 
       
    45 #include <QtGui/qlayout.h>
       
    46 #ifdef QT_INCLUDE_COMPAT
       
    47 #include <QtGui/qwidget.h>
       
    48 #endif
       
    49 
       
    50 #include <limits.h>
       
    51 
       
    52 QT_BEGIN_HEADER
       
    53 
       
    54 QT_BEGIN_NAMESPACE
       
    55 
       
    56 QT_MODULE(Gui)
       
    57 
       
    58 class QGridLayoutPrivate;
       
    59 
       
    60 class Q_GUI_EXPORT QGridLayout : public QLayout
       
    61 {
       
    62     Q_OBJECT
       
    63     Q_DECLARE_PRIVATE(QGridLayout)
       
    64     QDOC_PROPERTY(int horizontalSpacing READ horizontalSpacing WRITE setHorizontalSpacing)
       
    65     QDOC_PROPERTY(int verticalSpacing READ verticalSpacing WRITE setVerticalSpacing)
       
    66 
       
    67 public:
       
    68     explicit QGridLayout(QWidget *parent);
       
    69     QGridLayout();
       
    70 
       
    71 #ifdef QT3_SUPPORT
       
    72     QT3_SUPPORT_CONSTRUCTOR QGridLayout(QWidget *parent, int nRows , int nCols = 1, int border = 0,
       
    73                                       int spacing = -1, const char *name = 0);
       
    74     QT3_SUPPORT_CONSTRUCTOR QGridLayout(int nRows , int nCols = 1, int spacing = -1, const char *name = 0);
       
    75     QT3_SUPPORT_CONSTRUCTOR QGridLayout(QLayout *parentLayout, int nRows = 1, int nCols = 1, int spacing = -1,
       
    76                                       const char *name = 0);
       
    77 #endif
       
    78     ~QGridLayout();
       
    79 
       
    80     QSize sizeHint() const;
       
    81     QSize minimumSize() const;
       
    82     QSize maximumSize() const;
       
    83 
       
    84     void setHorizontalSpacing(int spacing);
       
    85     int horizontalSpacing() const;
       
    86     void setVerticalSpacing(int spacing);
       
    87     int verticalSpacing() const;
       
    88     void setSpacing(int spacing);
       
    89     int spacing() const;
       
    90 
       
    91     void setRowStretch(int row, int stretch);
       
    92     void setColumnStretch(int column, int stretch);
       
    93     int rowStretch(int row) const;
       
    94     int columnStretch(int column) const;
       
    95 
       
    96     void setRowMinimumHeight(int row, int minSize);
       
    97     void setColumnMinimumWidth(int column, int minSize);
       
    98     int rowMinimumHeight(int row) const;
       
    99     int columnMinimumWidth(int column) const;
       
   100 
       
   101     int columnCount() const;
       
   102     int rowCount() const;
       
   103 
       
   104     QRect cellRect(int row, int column) const;
       
   105 #ifdef QT3_SUPPORT
       
   106     inline QT3_SUPPORT QRect cellGeometry(int row, int column) const {return cellRect(row, column);}
       
   107 #endif
       
   108 
       
   109     bool hasHeightForWidth() const;
       
   110     int heightForWidth(int) const;
       
   111     int minimumHeightForWidth(int) const;
       
   112 
       
   113     Qt::Orientations expandingDirections() const;
       
   114     void invalidate();
       
   115 
       
   116     inline void addWidget(QWidget *w) { QLayout::addWidget(w); }
       
   117     void addWidget(QWidget *, int row, int column, Qt::Alignment = 0);
       
   118     void addWidget(QWidget *, int row, int column, int rowSpan, int columnSpan, Qt::Alignment = 0);
       
   119     void addLayout(QLayout *, int row, int column, Qt::Alignment = 0);
       
   120     void addLayout(QLayout *, int row, int column, int rowSpan, int columnSpan, Qt::Alignment = 0);
       
   121 
       
   122     void setOriginCorner(Qt::Corner);
       
   123     Qt::Corner originCorner() const;
       
   124 
       
   125 #ifdef QT3_SUPPORT
       
   126     inline QT3_SUPPORT void setOrigin(Qt::Corner corner) { setOriginCorner(corner); }
       
   127     inline QT3_SUPPORT Qt::Corner origin() const { return originCorner(); }
       
   128 #endif
       
   129     QLayoutItem *itemAt(int index) const;
       
   130     QLayoutItem *itemAtPosition(int row, int column) const;
       
   131     QLayoutItem *takeAt(int index);
       
   132     int count() const;
       
   133     void setGeometry(const QRect&);
       
   134 
       
   135     void addItem(QLayoutItem *item, int row, int column, int rowSpan = 1, int columnSpan = 1, Qt::Alignment = 0);
       
   136 
       
   137     void setDefaultPositioning(int n, Qt::Orientation orient);
       
   138     void getItemPosition(int idx, int *row, int *column, int *rowSpan, int *columnSpan);
       
   139 
       
   140 protected:
       
   141 #ifdef QT3_SUPPORT
       
   142     QT3_SUPPORT bool findWidget(QWidget* w, int *r, int *c);
       
   143 #endif
       
   144     void addItem(QLayoutItem *);
       
   145 
       
   146 private:
       
   147     Q_DISABLE_COPY(QGridLayout)
       
   148 
       
   149 #ifdef QT3_SUPPORT
       
   150 public:
       
   151     QT3_SUPPORT void expand(int rows, int cols);
       
   152     inline QT3_SUPPORT void addRowSpacing(int row, int minsize) { addItem(new QSpacerItem(0,minsize), row, 0); }
       
   153     inline QT3_SUPPORT void addColSpacing(int col, int minsize) { addItem(new QSpacerItem(minsize,0), 0, col); }
       
   154     inline QT3_SUPPORT void addMultiCellWidget(QWidget *w, int fromRow, int toRow, int fromCol, int toCol, Qt::Alignment _align = 0)
       
   155         { addWidget(w, fromRow, fromCol, (toRow < 0) ? -1 : toRow - fromRow + 1, (toCol < 0) ? -1 : toCol - fromCol + 1, _align); }
       
   156     inline QT3_SUPPORT void addMultiCell(QLayoutItem *l, int fromRow, int toRow, int fromCol, int toCol, Qt::Alignment _align = 0)
       
   157         { addItem(l, fromRow, fromCol, (toRow < 0) ? -1 : toRow - fromRow + 1, (toCol < 0) ? -1 : toCol - fromCol + 1, _align); }
       
   158     inline QT3_SUPPORT void addMultiCellLayout(QLayout *layout, int fromRow, int toRow, int fromCol, int toCol, Qt::Alignment _align = 0)
       
   159         { addLayout(layout, fromRow, fromCol, (toRow < 0) ? -1 : toRow - fromRow + 1, (toCol < 0) ? -1 : toCol - fromCol + 1, _align); }
       
   160 
       
   161     inline QT3_SUPPORT int numRows() const { return rowCount(); }
       
   162     inline QT3_SUPPORT int numCols() const { return columnCount(); }
       
   163     inline QT3_SUPPORT void setColStretch(int col, int stretch) {setColumnStretch(col, stretch); }
       
   164     inline QT3_SUPPORT int colStretch(int col) const {return columnStretch(col); }
       
   165     inline QT3_SUPPORT void setColSpacing(int col, int minSize) { setColumnMinimumWidth(col, minSize); }
       
   166     inline QT3_SUPPORT int colSpacing(int col) const { return columnMinimumWidth(col); }
       
   167     inline QT3_SUPPORT void setRowSpacing(int row, int minSize) {setRowMinimumHeight(row, minSize); }
       
   168     inline QT3_SUPPORT int rowSpacing(int row) const {return rowMinimumHeight(row); }
       
   169 #endif
       
   170 };
       
   171 
       
   172 QT_END_NAMESPACE
       
   173 
       
   174 QT_END_HEADER
       
   175 
       
   176 #endif // QGRIDLAYOUT_H