source: trunk/src/qt3support/widgets/q3dockwindow.h@ 353

Last change on this file since 353 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 7.4 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information ([email protected])
5**
6** This file is part of the Qt3Support module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
10** Licensees holding valid Qt Commercial licenses may use this file in
11** accordance with the Qt Commercial License Agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Nokia.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file. Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
23** In addition, as a special exception, Nokia gives you certain
24** additional rights. These rights are described in the Nokia Qt LGPL
25** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26** package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you are unsure which license is appropriate for your use, please
37** contact the sales department at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef Q3DOCKWINDOW_H
43#define Q3DOCKWINDOW_H
44
45#include <Qt3Support/q3frame.h>
46
47QT_BEGIN_HEADER
48
49QT_BEGIN_NAMESPACE
50
51QT_MODULE(Qt3SupportLight)
52
53#ifndef QT_NO_MAINWINDOW
54
55class Q3DockWindowHandle;
56class Q3DockWindowTitleBar;
57class QPainter;
58class Q3DockWindowResizeHandle;
59class QBoxLayout;
60class QHBoxLayout;
61class QVBoxLayout;
62class Q3DockArea;
63class QWidgetResizeHandler;
64class Q3MainWindow;
65class Q3DockAreaLayout;
66class Q3DockWindowPrivate;
67class Q3ToolBar;
68class QWindowsXPStyle;
69class QRubberBand;
70
71class Q_COMPAT_EXPORT Q3DockWindow : public Q3Frame
72{
73 Q_OBJECT
74 Q_ENUMS(CloseMode Place)
75 Q_PROPERTY(int closeMode READ closeMode WRITE setCloseMode)
76 Q_PROPERTY(bool resizeEnabled READ isResizeEnabled WRITE setResizeEnabled)
77 Q_PROPERTY(bool movingEnabled READ isMovingEnabled WRITE setMovingEnabled)
78 Q_PROPERTY(bool horizontallyStretchable READ isHorizontallyStretchable WRITE setHorizontallyStretchable)
79 Q_PROPERTY(bool verticallyStretchable READ isVerticallyStretchable WRITE setVerticallyStretchable)
80 Q_PROPERTY(bool stretchable READ isStretchable)
81 Q_PROPERTY(bool newLine READ newLine WRITE setNewLine)
82 Q_PROPERTY(bool opaqueMoving READ opaqueMoving WRITE setOpaqueMoving)
83 Q_PROPERTY(int offset READ offset WRITE setOffset)
84 Q_PROPERTY(Place place READ place)
85
86 friend class Q3DockWindowHandle;
87 friend class Q3DockWindowTitleBar;
88 friend class Q3DockArea;
89 friend class Q3DockAreaLayout;
90 friend class Q3MainWindow;
91 friend class QCEMainWindow;
92 friend class Q3ToolBar;
93 friend class QWindowsXPStyle;
94
95public:
96 enum Place { InDock, OutsideDock };
97 enum CloseMode { Never = 0, Docked = 1, Undocked = 2, Always = Docked | Undocked };
98
99 Q3DockWindow(Place p = InDock, QWidget* parent=0, const char* name=0, Qt::WindowFlags f = 0);
100 Q3DockWindow(QWidget* parent, const char* name=0, Qt::WindowFlags f = 0);
101 ~Q3DockWindow();
102
103 virtual void setWidget(QWidget *w);
104 QWidget *widget() const;
105
106 Place place() const { return curPlace; }
107
108 Q3DockArea *area() const;
109
110 virtual void setCloseMode(int m);
111 bool isCloseEnabled() const;
112 int closeMode() const;
113
114 virtual void setResizeEnabled(bool b);
115 virtual void setMovingEnabled(bool b);
116 bool isResizeEnabled() const;
117 bool isMovingEnabled() const;
118
119 virtual void setHorizontallyStretchable(bool b);
120 virtual void setVerticallyStretchable(bool b);
121 bool isHorizontallyStretchable() const;
122 bool isVerticallyStretchable() const;
123 void setHorizontalStretchable(bool b) { setHorizontallyStretchable(b); }
124 void setVerticalStretchable(bool b) { setVerticallyStretchable(b); }
125 bool isHorizontalStretchable() const { return isHorizontallyStretchable(); }
126 bool isVerticalStretchable() const { return isVerticallyStretchable(); }
127 bool isStretchable() const;
128
129 virtual void setOffset(int o);
130 int offset() const;
131
132 virtual void setFixedExtentWidth(int w);
133 virtual void setFixedExtentHeight(int h);
134 QSize fixedExtent() const;
135
136 virtual void setNewLine(bool b);
137 bool newLine() const;
138
139 Qt::Orientation orientation() const;
140
141 QSize sizeHint() const;
142 QSize minimumSize() const;
143 QSize minimumSizeHint() const;
144
145 QBoxLayout *boxLayout();
146
147 virtual void setOpaqueMoving(bool b);
148 bool opaqueMoving() const;
149
150 bool eventFilter(QObject *o, QEvent *e);
151
152 QString windowTitle() const;
153
154Q_SIGNALS:
155 void orientationChanged(Qt::Orientation o);
156 void placeChanged(Q3DockWindow::Place p);
157 void visibilityChanged(bool);
158
159public Q_SLOTS:
160 virtual void undock(QWidget *w);
161 virtual void undock() { undock(0); }
162 virtual void dock();
163 virtual void setOrientation(Qt::Orientation o);
164
165protected:
166 void resizeEvent(QResizeEvent *e);
167 void showEvent(QShowEvent *e);
168 void hideEvent(QHideEvent *e);
169 void contextMenuEvent(QContextMenuEvent *e);
170
171 void drawFrame(QPainter *);
172 void drawContents(QPainter *);
173
174 bool event(QEvent *e);
175
176private Q_SLOTS:
177 void toggleVisible() { setVisible(!isVisible()); }
178
179private:
180 Q3DockWindow(Place p, QWidget* parent, const char* name, Qt::WindowFlags f, bool toolbar);
181
182 void handleMove(const QPoint &pos, const QPoint &gp, bool drawRect);
183 void updateGui();
184 void updateSplitterVisibility(bool visible);
185
186 void startRectDraw(const QPoint &so, bool drawRect);
187 void endRectDraw(bool drawRect);
188 void updatePosition(const QPoint &globalPos );
189 QWidget *areaAt(const QPoint &gp);
190 void removeFromDock(bool fixNewLines = true);
191 void swapRect(QRect &r, Qt::Orientation o, const QPoint &offset, Q3DockArea *area);
192 void init();
193
194private:
195 Q3DockWindowHandle *horHandle, *verHandle;
196 Q3DockWindowTitleBar *titleBar;
197 QWidget *wid;
198 QRubberBand *rubberBand;
199 Q3DockArea *dockArea, *tmpDockArea;
200 QRect currRect;
201 Place curPlace;
202 Place state;
203 bool resizeEnabled : 1;
204 bool moveEnabled : 1;
205 bool nl : 1;
206 bool opaque : 1;
207 bool isToolbar : 1;
208 bool stretchable[3];
209 Qt::Orientation startOrientation;
210 int cMode;
211 QPoint startOffset;
212 int offs;
213 QSize fExtent;
214 Q3DockWindowResizeHandle *hHandleTop, *hHandleBottom, *vHandleLeft, *vHandleRight;
215 QVBoxLayout *hbox;
216 QHBoxLayout *vbox;
217 QBoxLayout *childBox;
218 void *dockWindowData;
219 QPoint lastPos;
220 QSize lastSize;
221 QWidgetResizeHandler *widgetResizeHandler;
222 Q3DockWindowPrivate *d;
223
224private:
225 Q_DISABLE_COPY(Q3DockWindow)
226};
227
228inline Q3DockArea *Q3DockWindow::area() const
229{
230 return dockArea;
231}
232
233#endif // QT_NO_MAINWINDOW
234
235QT_END_NAMESPACE
236
237QT_END_HEADER
238
239#endif // Q3DOCKWINDOW_H
Note: See TracBrowser for help on using the repository browser.