qmdiarea.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 QMDIAREA_H
00043 #define QMDIAREA_H
00044 
00045 #include <QtGui/qabstractscrollarea.h>
00046 #include <QtGui/qtabwidget.h>
00047 
00048 QT_BEGIN_HEADER
00049 
00050 QT_BEGIN_NAMESPACE
00051 
00052 QT_MODULE(Gui)
00053 
00054 #ifndef QT_NO_MDIAREA
00055 
00056 class QMdiSubWindow;
00057 
00058 class QMdiAreaPrivate;
00059 class Q_GUI_EXPORT QMdiArea : public QAbstractScrollArea
00060 {
00061     Q_OBJECT
00062     Q_ENUMS(ViewMode)
00063     Q_PROPERTY(QBrush background READ background WRITE setBackground)
00064     Q_PROPERTY(WindowOrder activationOrder READ activationOrder WRITE setActivationOrder)
00065     Q_PROPERTY(ViewMode viewMode READ viewMode WRITE setViewMode)
00066 #ifndef QT_NO_TABBAR
00067     Q_PROPERTY(bool documentMode READ documentMode WRITE setDocumentMode)
00068 #endif
00069 #ifndef QT_NO_TABWIDGET
00070     Q_PROPERTY(QTabWidget::TabShape tabShape READ tabShape WRITE setTabShape)
00071     Q_PROPERTY(QTabWidget::TabPosition tabPosition READ tabPosition WRITE setTabPosition)
00072 #endif
00073     Q_ENUMS(WindowOrder)
00074 public:
00075     enum AreaOption {
00076         DontMaximizeSubWindowOnActivation = 0x1
00077     };
00078     Q_DECLARE_FLAGS(AreaOptions, AreaOption)
00079 
00080     enum WindowOrder {
00081         CreationOrder,
00082         StackingOrder,
00083         ActivationHistoryOrder
00084     };
00085 
00086     enum ViewMode {
00087         SubWindowView,
00088         TabbedView
00089     };
00090 
00091     QMdiArea(QWidget *parent = 0);
00092     ~QMdiArea();
00093 
00094     QSize sizeHint() const;
00095     QSize minimumSizeHint() const;
00096 
00097     QMdiSubWindow *currentSubWindow() const;
00098     QMdiSubWindow *activeSubWindow() const;
00099     QList<QMdiSubWindow *> subWindowList(WindowOrder order = CreationOrder) const;
00100 
00101     QMdiSubWindow *addSubWindow(QWidget *widget, Qt::WindowFlags flags = 0);
00102     void removeSubWindow(QWidget *widget);
00103 
00104     QBrush background() const;
00105     void setBackground(const QBrush &background);
00106 
00107     WindowOrder activationOrder() const;
00108     void setActivationOrder(WindowOrder order);
00109 
00110     void setOption(AreaOption option, bool on = true);
00111     bool testOption(AreaOption opton) const;
00112 
00113     void setViewMode(ViewMode mode);
00114     ViewMode viewMode() const;
00115 
00116 #ifndef QT_NO_TABBAR
00117     bool documentMode() const;
00118     void setDocumentMode(bool enabled);
00119 #endif
00120 #ifndef QT_NO_TABWIDGET
00121     void setTabShape(QTabWidget::TabShape shape);
00122     QTabWidget::TabShape tabShape() const;
00123 
00124     void setTabPosition(QTabWidget::TabPosition position);
00125     QTabWidget::TabPosition tabPosition() const;
00126 #endif
00127 
00128 Q_SIGNALS:
00129     void subWindowActivated(QMdiSubWindow *);
00130 
00131 public Q_SLOTS:
00132     void setActiveSubWindow(QMdiSubWindow *window);
00133     void tileSubWindows();
00134     void cascadeSubWindows();
00135     void closeActiveSubWindow();
00136     void closeAllSubWindows();
00137     void activateNextSubWindow();
00138     void activatePreviousSubWindow();
00139 
00140 protected Q_SLOTS:
00141     void setupViewport(QWidget *viewport);
00142 
00143 protected:
00144     bool event(QEvent *event);
00145     bool eventFilter(QObject *object, QEvent *event);
00146     void paintEvent(QPaintEvent *paintEvent);
00147     void childEvent(QChildEvent *childEvent);
00148     void resizeEvent(QResizeEvent *resizeEvent);
00149     void timerEvent(QTimerEvent *timerEvent);
00150     void showEvent(QShowEvent *showEvent);
00151     bool viewportEvent(QEvent *event);
00152     void scrollContentsBy(int dx, int dy);
00153 
00154 private:
00155     Q_DISABLE_COPY(QMdiArea)
00156     Q_DECLARE_PRIVATE(QMdiArea)
00157     Q_PRIVATE_SLOT(d_func(), void _q_deactivateAllWindows())
00158     Q_PRIVATE_SLOT(d_func(), void _q_processWindowStateChanged(Qt::WindowStates, Qt::WindowStates))
00159     Q_PRIVATE_SLOT(d_func(), void _q_currentTabChanged(int index))
00160 };
00161 
00162 Q_DECLARE_OPERATORS_FOR_FLAGS(QMdiArea::AreaOptions)
00163 
00164 QT_END_NAMESPACE
00165 
00166 QT_END_HEADER
00167 
00168 #endif // QT_NO_MDIAREA
00169 #endif // QMDIAREA_H