src/gui/widgets/qmainwindowlayout_p.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 1992-2006 Trolltech ASA. All rights reserved.
00004 **
00005 ** This file is part of the QtGui module of the Qt Toolkit.
00006 **
00007 ** This file may be used under the terms of the GNU General Public
00008 ** License version 2.0 as published by the Free Software Foundation
00009 ** and appearing in the file LICENSE.GPL included in the packaging of
00010 ** this file.  Please review the following information to ensure GNU
00011 ** General Public Licensing requirements will be met:
00012 ** http://www.trolltech.com/products/qt/opensource.html
00013 **
00014 ** If you are unsure which license is appropriate for your use, please
00015 ** review the following information:
00016 ** http://www.trolltech.com/products/qt/licensing.html or contact the
00017 ** sales department at sales@trolltech.com.
00018 **
00019 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00020 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00021 **
00022 ****************************************************************************/
00023 
00024 #ifndef QDYNAMICMAINWINDOWLAYOUT_P_H
00025 #define QDYNAMICMAINWINDOWLAYOUT_P_H
00026 
00027 //
00028 //  W A R N I N G
00029 //  -------------
00030 //
00031 // This file is not part of the Qt API.  It exists purely as an
00032 // implementation detail.  This header file may change from version to
00033 // version without notice, or even be removed.
00034 //
00035 // We mean it.
00036 //
00037 
00038 #include "qmainwindow.h"
00039 
00040 #ifndef QT_NO_MAINWINDOW
00041 
00042 #include "QtGui/qlayout.h"
00043 #include "QtCore/qvector.h"
00044 #include "QtCore/qset.h"
00045 #include "private/qlayoutengine_p.h"
00046 
00047 #include "qdockwidgetlayout_p.h"
00048 
00049 class QToolBar;
00050 class QWidgetAnimator;
00051 class QTabBar;
00052 class QRubberBand;
00053 
00054 class QMainWindowLayout : public QLayout
00055 {
00056     Q_OBJECT
00057 
00058 public:
00059     explicit QMainWindowLayout(QMainWindow *mainwindow);
00060     ~QMainWindowLayout();
00061 
00062     QLayoutItem *statusbar;
00063 #ifndef QT_NO_STATUSBAR
00064     QStatusBar *statusBar() const;
00065     void setStatusBar(QStatusBar *sb);
00066 #endif
00067 
00068     QWidget *centralWidget() const;
00069     void setCentralWidget(QWidget *cw);
00070 
00071 #ifndef QT_NO_TOOLBAR
00072     void addToolBarBreak(Qt::ToolBarArea area);
00073     void insertToolBarBreak(QToolBar *before);
00074     void addToolBar(Qt::ToolBarArea area, QToolBar *toolbar, bool needAddChildWidget = true);
00075     void insertToolBar(QToolBar *before, QToolBar *toolbar);
00076     Qt::ToolBarArea toolBarArea(QToolBar *toolbar) const;
00077 #endif
00078 
00079 #ifndef QT_NO_DOCKWIDGET
00080     void setCorner(Qt::Corner corner, Qt::DockWidgetArea area);
00081     Qt::DockWidgetArea corner(Qt::Corner corner) const;
00082 
00083     void addDockWidget(Qt::DockWidgetArea area,
00084                        QDockWidget *dockwidget,
00085                        Qt::Orientation orientation);
00086     void splitDockWidget(QDockWidget *after,
00087                          QDockWidget *dockwidget,
00088                          Qt::Orientation orientation);
00089     void tabifyDockWidget(QDockWidget *first, QDockWidget *second);
00090     Qt::DockWidgetArea dockWidgetArea(QDockWidget *dockwidget) const;
00091 #endif
00092 
00093     enum { // sentinel values used to validate state data
00094         VersionMarker = 0xff,
00095         ToolBarStateMarker = 0xfe,
00096         ToolBarStateMarkerEx = 0xfc
00097     };
00098     void saveState(QDataStream &stream) const;
00099     bool restoreState(QDataStream &stream);
00100 
00101     // QLayout interface
00102     void addItem(QLayoutItem *item);
00103     void setGeometry(const QRect &r);
00104     QLayoutItem *itemAt(int index) const;
00105     QLayoutItem *takeAt(int index);
00106     int count() const;
00107 
00108     QSize sizeHint() const;
00109     QSize minimumSize() const;
00110     mutable QSize szHint;
00111     mutable QSize minSize;
00112 
00113     void invalidate();
00114 
00115     // returns true if \a widget is a toolbar or dockwidget that we know about
00116     bool contains(QWidget *widget) const;
00117 
00118     // utility functions
00119     void relayout();
00120     void updateToolbarsInArea(Qt::ToolBarArea area);
00121 
00122 #ifndef QT_NO_DOCKWIDGET
00123     QWidgetAnimator *widgetAnimator;
00124     bool dockNestingEnabled;
00125     bool animationEnabled;
00126     QDockWidgetLayout dockWidgetLayout, savedDockWidgetLayout;
00127 
00128     void applyDockWidgetLayout(QDockWidgetLayout &newLayout, bool animate = true);
00129 
00130     QWidgetItem *unplug(QDockWidget *dockWidget);
00131     QList<int> hover(QWidgetItem *dockWidgetItem, const QPoint &mousePos);
00132     void plug(QWidgetItem *dockWidgetItem, const QList<int> &pathToGap);
00133     void restore();
00134     QList<int> currentGapPos;
00135     QRect currentGapRect;
00136     QDockWidget *pluggingWidget;
00137     QRubberBand *gapIndicator;
00138     void updateGapIndicator();
00139     void paintDropIndicator(QPainter *p, QWidget *widget, const QRegion &clip);
00140     void raise(QDockWidget *widget);
00141 
00142     bool startSeparatorMove(const QPoint &pos);
00143     bool separatorMove(const QPoint &pos);
00144     bool endSeparatorMove(const QPoint &pos);
00145     QList<int> movingSeparator;
00146     QPoint movingSeparatorOrigin, movingSeparatorPos;
00147     QTimer *separatorMoveTimer;
00148     QVector<QLayoutStruct> separatorMoveCache;
00149 
00150     void keepSize(QDockWidget *w);
00151 
00152 #ifndef QT_NO_TABBAR
00153     QTabBar *getTabBar();
00154     QSet<QTabBar*> usedTabBars;
00155     QList<QTabBar*> unusedTabBars;
00156 #endif
00157 
00158 private slots:
00159     void animationFinished(QWidget *widget);
00160     void allAnimationsFinished();
00161     void doSeparatorMove();
00162 #ifndef QT_NO_TABBAR
00163     void tabChanged();
00164 #endif
00165 
00166 public:
00167 #else
00168     QLayoutItem *centralWidgetItem; // a window compiled with QT_NO_TOOLBAR still needs
00169                                     // a centralWidget
00170 #endif
00171 
00172 #ifndef QT_NO_TOOLBAR
00173     int locateToolBar(QToolBar *toolbar, const QPoint &mouse) const;
00174     bool dropToolBar(QToolBar *toolbar, const QPoint &mouse, const QPoint &offset);
00175 
00176     void removeToolBarInfo(QToolBar *toolbar);
00177 
00178     // toolbar layout data
00179     struct ToolBarLayoutInfo
00180     {
00181         ToolBarLayoutInfo() : item(0) {}
00182   QLayoutItem *item;
00183   QPoint pos;
00184         QSize size;
00185   QPoint offset;
00186         QPoint user_pos;
00187     };
00188 
00189     struct ToolBarLineInfo
00190     {
00191         int pos;
00192         QList<ToolBarLayoutInfo> list;
00193     };
00194 
00195     /*
00196       helpers to return the index of next/prev visible toolbar... they
00197       return -1 if none is found
00198     */
00199     static int nextVisible(int index, const ToolBarLineInfo &lineInfo);
00200     static int prevVisible(int index, const ToolBarLineInfo &lineInfo);
00201     QList<ToolBarLineInfo> tb_layout_info, *save_tb_layout_info;
00202 #endif
00203 };
00204 
00205 #endif // QT_NO_MAINWINDOW
00206 
00207 #endif // QDYNAMICMAINWINDOWLAYOUT_P_H

Generated on Thu Mar 15 11:57:02 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1