00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef QDYNAMICMAINWINDOWLAYOUT_P_H
00025 #define QDYNAMICMAINWINDOWLAYOUT_P_H
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
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 {
00094 VersionMarker = 0xff,
00095 ToolBarStateMarker = 0xfe,
00096 ToolBarStateMarkerEx = 0xfc
00097 };
00098 void saveState(QDataStream &stream) const;
00099 bool restoreState(QDataStream &stream);
00100
00101
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
00116 bool contains(QWidget *widget) const;
00117
00118
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;
00169
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
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
00197
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