qmainwindow.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 QDYNAMICMAINWINDOW_H
00043 #define QDYNAMICMAINWINDOW_H
00044 
00045 #include <QtGui/qwidget.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_MAINWINDOW
00055 
00056 class QDockWidget;
00057 class QMainWindowPrivate;
00058 class QMenuBar;
00059 class QStatusBar;
00060 class QToolBar;
00061 class QMenu;
00062 
00063 class Q_GUI_EXPORT QMainWindow : public QWidget
00064 {
00065     Q_OBJECT
00066 
00067     Q_ENUMS(DockOption)
00068     Q_FLAGS(DockOptions)
00069     Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
00070     Q_PROPERTY(Qt::ToolButtonStyle toolButtonStyle READ toolButtonStyle WRITE setToolButtonStyle)
00071 #ifndef QT_NO_DOCKWIDGET
00072     Q_PROPERTY(bool animated READ isAnimated WRITE setAnimated)
00073 #ifndef QT_NO_TABBAR
00074     Q_PROPERTY(bool documentMode READ documentMode WRITE setDocumentMode)
00075 #endif // QT_NO_TABBAR
00076 #ifndef QT_NO_TABWIDGET
00077     Q_PROPERTY(QTabWidget::TabShape tabShape READ tabShape WRITE setTabShape)
00078 #endif // QT_NO_TABWIDGET
00079     Q_PROPERTY(bool dockNestingEnabled READ isDockNestingEnabled WRITE setDockNestingEnabled)
00080 #endif // QT_NO_DOCKWIDGET
00081     Q_PROPERTY(DockOptions dockOptions READ dockOptions WRITE setDockOptions)
00082 #ifndef QT_NO_TOOLBAR
00083     Q_PROPERTY(bool unifiedTitleAndToolBarOnMac READ unifiedTitleAndToolBarOnMac WRITE setUnifiedTitleAndToolBarOnMac)
00084 #endif
00085 
00086 public:
00087     enum DockOption {
00088         AnimatedDocks = 0x01,
00089         AllowNestedDocks = 0x02,
00090         AllowTabbedDocks = 0x04,
00091         ForceTabbedDocks = 0x08,  // implies AllowTabbedDocks, !AllowNestedDocks
00092         VerticalTabs = 0x10       // implies AllowTabbedDocks
00093     };
00094     Q_DECLARE_FLAGS(DockOptions, DockOption)
00095 
00096     explicit QMainWindow(QWidget *parent = 0, Qt::WindowFlags flags = 0);
00097     ~QMainWindow();
00098 
00099     QSize iconSize() const;
00100     void setIconSize(const QSize &iconSize);
00101 
00102     Qt::ToolButtonStyle toolButtonStyle() const;
00103     void setToolButtonStyle(Qt::ToolButtonStyle toolButtonStyle);
00104 
00105 #ifndef QT_NO_DOCKWIDGET
00106     bool isAnimated() const;
00107     bool isDockNestingEnabled() const;
00108 #endif
00109 
00110 #ifndef QT_NO_TABBAR
00111     bool documentMode() const;
00112     void setDocumentMode(bool enabled);
00113 #endif
00114 
00115 #ifndef QT_NO_TABWIDGET
00116     QTabWidget::TabShape tabShape() const;
00117     void setTabShape(QTabWidget::TabShape tabShape);
00118     QTabWidget::TabPosition tabPosition(Qt::DockWidgetArea area) const;
00119     void setTabPosition(Qt::DockWidgetAreas areas, QTabWidget::TabPosition tabPosition);
00120 #endif // QT_NO_TABWIDGET
00121 
00122     void setDockOptions(DockOptions options);
00123     DockOptions dockOptions() const;
00124 
00125     bool isSeparator(const QPoint &pos) const;
00126 
00127 #ifndef QT_NO_MENUBAR
00128     QMenuBar *menuBar() const;
00129     void setMenuBar(QMenuBar *menubar);
00130 
00131     QWidget  *menuWidget() const;
00132     void setMenuWidget(QWidget *menubar);
00133 #endif
00134 
00135 #ifndef QT_NO_STATUSBAR
00136     QStatusBar *statusBar() const;
00137     void setStatusBar(QStatusBar *statusbar);
00138 #endif
00139 
00140     QWidget *centralWidget() const;
00141     void setCentralWidget(QWidget *widget);
00142 
00143 #ifndef QT_NO_DOCKWIDGET
00144     void setCorner(Qt::Corner corner, Qt::DockWidgetArea area);
00145     Qt::DockWidgetArea corner(Qt::Corner corner) const;
00146 #endif
00147 
00148 #ifndef QT_NO_TOOLBAR
00149     void addToolBarBreak(Qt::ToolBarArea area = Qt::TopToolBarArea);
00150     void insertToolBarBreak(QToolBar *before);
00151 
00152     void addToolBar(Qt::ToolBarArea area, QToolBar *toolbar);
00153     void addToolBar(QToolBar *toolbar);
00154     QToolBar *addToolBar(const QString &title);
00155     void insertToolBar(QToolBar *before, QToolBar *toolbar);
00156     void removeToolBar(QToolBar *toolbar);
00157     void removeToolBarBreak(QToolBar *before);
00158 
00159     void setUnifiedTitleAndToolBarOnMac(bool set);
00160     bool unifiedTitleAndToolBarOnMac() const;
00161 
00162     Qt::ToolBarArea toolBarArea(QToolBar *toolbar) const;
00163     bool toolBarBreak(QToolBar *toolbar) const;
00164 #endif
00165 #ifndef QT_NO_DOCKWIDGET
00166     void addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget);
00167     void addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget,
00168                        Qt::Orientation orientation);
00169     void splitDockWidget(QDockWidget *after, QDockWidget *dockwidget,
00170                          Qt::Orientation orientation);
00171     void tabifyDockWidget(QDockWidget *first, QDockWidget *second);
00172     QList<QDockWidget*> tabifiedDockWidgets(QDockWidget *dockwidget) const;
00173     void removeDockWidget(QDockWidget *dockwidget);
00174     bool restoreDockWidget(QDockWidget *dockwidget);
00175 
00176     Qt::DockWidgetArea dockWidgetArea(QDockWidget *dockwidget) const;
00177 #endif // QT_NO_DOCKWIDGET
00178 
00179     QByteArray saveState(int version = 0) const;
00180     bool restoreState(const QByteArray &state, int version = 0);
00181 
00182 #ifndef QT_NO_MENU
00183     virtual QMenu *createPopupMenu();
00184 #endif
00185 
00186 #ifdef QT3_SUPPORT
00187     QT3_SUPPORT_CONSTRUCTOR QMainWindow(QWidget *parent, const char *name, Qt::WindowFlags flags = 0);
00188 #endif
00189 
00190 #ifndef QT_NO_DOCKWIDGET
00191 public Q_SLOTS:
00192     void setAnimated(bool enabled);
00193     void setDockNestingEnabled(bool enabled);
00194 #endif
00195 
00196 Q_SIGNALS:
00197     void iconSizeChanged(const QSize &iconSize);
00198     void toolButtonStyleChanged(Qt::ToolButtonStyle toolButtonStyle);
00199 
00200 protected:
00201 #ifndef QT_NO_CONTEXTMENU
00202     void contextMenuEvent(QContextMenuEvent *event);
00203 #endif
00204     bool event(QEvent *event);
00205 
00206 private:
00207     Q_DECLARE_PRIVATE(QMainWindow)
00208     Q_DISABLE_COPY(QMainWindow)
00209 };
00210 
00211 Q_DECLARE_OPERATORS_FOR_FLAGS(QMainWindow::DockOptions)
00212 
00213 #endif // QT_NO_MAINWINDOW
00214 
00215 QT_END_NAMESPACE
00216 
00217 QT_END_HEADER
00218 
00219 #endif // QDYNAMICMAINWINDOW_H