1 /****************************************************************************
2 ** $Id: qt/qdockarea.h   3.3.8   edited Jan 11 14:38 $
3 **
4 ** Definition of the QDockArea class
5 **
6 ** Created : 001010
7 **
8 ** Copyright (C) 1992-2007 Trolltech ASA.  All rights reserved.
9 **
10 ** This file is part of the workspace module of the Qt GUI Toolkit.
11 **
12 ** This file may be distributed under the terms of the Q Public License
13 ** as defined by Trolltech ASA of Norway and appearing in the file
14 ** LICENSE.QPL included in the packaging of this file.
15 **
16 ** This file may be distributed and/or modified under the terms of the
17 ** GNU General Public License version 2 as published by the Free Software
18 ** Foundation and appearing in the file LICENSE.GPL included in the
19 ** packaging of this file.
20 **
21 ** Licensees holding valid Qt Enterprise Edition licenses may use this
22 ** file in accordance with the Qt Commercial License Agreement provided
23 ** with the Software.
24 **
25 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27 **
28 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29 **   information about Qt Commercial License Agreements.
30 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
31 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
32 **
33 ** Contact info@trolltech.com if any conditions of this licensing are
34 ** not clear to you.
35 **
36 **********************************************************************/
37 
38 #ifndef QDOCKAREA_H
39 #define QDOCKAREA_H
40 
41 #ifndef QT_H
42 #include "qwidget.h"
43 #include "qptrlist.h"
44 #include "qdockwindow.h"
45 #include "qlayout.h"
46 #include "qvaluelist.h"
47 #include "qguardedptr.h"
48 #include "qtextstream.h"
49 #endif // QT_H
50 
51 #ifndef QT_NO_MAINWINDOW
52 
53 class QSplitter;
54 class QBoxLayout;
55 class QDockAreaLayout;
56 class QMouseEvent;
57 class QDockWindowResizeHandle;
58 class QDockAreaPrivate;
59 
60 class Q_EXPORT QDockAreaLayout : public QLayout
61 {
62     Q_OBJECT
63     friend class QDockArea;
64 
65 public:
66     QDockAreaLayout( QWidget* parent, Qt::Orientation o, QPtrList<QDockWindow> *wl, int space = -1, int margin = -1, const char *name = 0 )
QLayout(parent,space,margin,name)67 	: QLayout( parent, space, margin, name ), orient( o ), dockWindows( wl ), parentWidget( parent ) { init(); }
~QDockAreaLayout()68     ~QDockAreaLayout() {}
69 
addItem(QLayoutItem *)70     void addItem( QLayoutItem * ) {}
71     bool hasHeightForWidth() const;
72     int heightForWidth( int ) const;
73     int widthForHeight( int ) const;
74     QSize sizeHint() const;
75     QSize minimumSize() const;
76     QLayoutIterator iterator();
expanding()77     QSizePolicy::ExpandData expanding() const { return QSizePolicy::NoDirection; }
78     void invalidate();
orientation()79     Qt::Orientation orientation() const { return orient; }
lineList()80     QValueList<QRect> lineList() const { return lines; }
lineStarts()81     QPtrList<QDockWindow> lineStarts() const { return ls; }
82 
83 protected:
84     void setGeometry( const QRect& );
85 
86 private:
87     void init();
88     int layoutItems( const QRect&, bool testonly = FALSE );
89     Qt::Orientation orient;
90     bool dirty;
91     int cached_width, cached_height;
92     int cached_hfw, cached_wfh;
93     QPtrList<QDockWindow> *dockWindows;
94     QWidget *parentWidget;
95     QValueList<QRect> lines;
96     QPtrList<QDockWindow> ls;
97 #if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator=
98     QDockAreaLayout( const QDockAreaLayout & );
99     QDockAreaLayout &operator=( const QDockAreaLayout & );
100 #endif
101 };
102 
103 class Q_EXPORT QDockArea : public QWidget
104 {
105     Q_OBJECT
106     Q_ENUMS( HandlePosition )
107     Q_PROPERTY( Orientation orientation READ orientation )
108     Q_PROPERTY( int count READ count )
109     Q_PROPERTY( bool empty READ isEmpty )
110     Q_PROPERTY( HandlePosition handlePosition READ handlePosition )
111 
112     friend class QDockWindow;
113     friend class QDockWindowResizeHandle;
114     friend class QDockAreaLayout;
115 
116 public:
117     enum HandlePosition { Normal, Reverse };
118 
119     QDockArea( Orientation o, HandlePosition h = Normal, QWidget* parent=0, const char* name=0 );
120     ~QDockArea();
121 
122     void moveDockWindow( QDockWindow *w, const QPoint &globalPos, const QRect &rect, bool swap );
123     void removeDockWindow( QDockWindow *w, bool makeFloating, bool swap, bool fixNewLines = TRUE );
124     void moveDockWindow( QDockWindow *w, int index = -1 );
125     bool hasDockWindow( QDockWindow *w, int *index = 0 );
126 
127     void invalidNextOffset( QDockWindow *dw );
128 
orientation()129     Orientation orientation() const { return orient; }
handlePosition()130     HandlePosition handlePosition() const { return hPos; }
131 
132     bool eventFilter( QObject *, QEvent * );
133     bool isEmpty() const;
134     int count() const;
135     QPtrList<QDockWindow> dockWindowList() const;
136 
137     bool isDockWindowAccepted( QDockWindow *dw );
138     void setAcceptDockWindow( QDockWindow *dw, bool accept );
139 
140 public slots:
141     void lineUp( bool keepNewLines );
142 
143 private:
144     struct DockWindowData
145     {
146 	int index;
147 	int offset;
148 	int line;
149 	QSize fixedExtent;
150 	QGuardedPtr<QDockArea> area;
151     };
152 
153     int findDockWindow( QDockWindow *w );
154     int lineOf( int index );
155     DockWindowData *dockWindowData( QDockWindow *w );
156     void dockWindow( QDockWindow *dockWindow, DockWindowData *data );
157     void updateLayout();
158     void invalidateFixedSizes();
159     int maxSpace( int hint, QDockWindow *dw );
160     void setFixedExtent( int d, QDockWindow *dw );
161     bool isLastDockWindow( QDockWindow *dw );
162 
163 private:
164     Orientation orient;
165     QPtrList<QDockWindow> *dockWindows;
166     QDockAreaLayout *layout;
167     HandlePosition hPos;
168     QPtrList<QDockWindow> forbiddenWidgets;
169     QDockAreaPrivate *d;
170 
171 private:	// Disabled copy constructor and operator=
172 #if defined(Q_DISABLE_COPY)
173     QDockArea( const QDockArea & );
174     QDockArea& operator=( const QDockArea & );
175 #endif
176 
177 };
178 
179 #ifndef QT_NO_TEXTSTREAM
180 Q_EXPORT QTextStream &operator<<( QTextStream &, const QDockArea & );
181 Q_EXPORT QTextStream &operator>>( QTextStream &, QDockArea & );
182 #endif
183 
184 #define Q_DEFINED_QDOCKAREA
185 #include "qwinexport.h"
186 #endif
187 
188 #endif //QT_NO_MAINWINDOW
189