1 /****************************************************************************
2 ** $Id: qt/qmainwindow.h 3.3.8 edited Jan 11 14:38 $
3 **
4 ** Definition of QMainWindow class
5 **
6 ** Created : 980316
7 **
8 ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
9 **
10 ** This file is part of the widgets 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 or Qt Professional Edition
22 ** licenses may use this file in accordance with the Qt Commercial License
23 ** Agreement provided 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 QMAINWINDOW_H
39 #define QMAINWINDOW_H
40
41 #ifndef QT_H
42 #include "qwidget.h"
43 #include "qtoolbar.h"
44 #include "qptrlist.h"
45 #include "qtextstream.h"
46 #endif // QT_H
47
48 #ifndef QT_NO_MAINWINDOW
49
50 class QMenuBar;
51 class QStatusBar;
52 class QToolTipGroup;
53 class QMainWindowPrivate;
54 class QMainWindowLayout;
55 class QPopupMenu;
56
57 class Q_EXPORT QMainWindow: public QWidget
58 {
59 Q_OBJECT
60 Q_PROPERTY( bool rightJustification READ rightJustification WRITE setRightJustification DESIGNABLE false )
61 Q_PROPERTY( bool usesBigPixmaps READ usesBigPixmaps WRITE setUsesBigPixmaps )
62 Q_PROPERTY( bool usesTextLabel READ usesTextLabel WRITE setUsesTextLabel )
63 Q_PROPERTY( bool dockWindowsMovable READ dockWindowsMovable WRITE setDockWindowsMovable )
64 Q_PROPERTY( bool opaqueMoving READ opaqueMoving WRITE setOpaqueMoving )
65
66 public:
67 QMainWindow( QWidget* parent=0, const char* name=0, WFlags f = WType_TopLevel );
68 ~QMainWindow();
69
70 #ifndef QT_NO_MENUBAR
71 QMenuBar * menuBar() const;
72 #endif
73 QStatusBar * statusBar() const;
74 #ifndef QT_NO_TOOLTIP
75 QToolTipGroup * toolTipGroup() const;
76 #endif
77
78 virtual void setCentralWidget( QWidget * );
79 QWidget * centralWidget() const;
80
81 virtual void setDockEnabled( Dock dock, bool enable );
82 bool isDockEnabled( Dock dock ) const;
83 bool isDockEnabled( QDockArea *area ) const;
84 virtual void setDockEnabled( QDockWindow *tb, Dock dock, bool enable );
85 bool isDockEnabled( QDockWindow *tb, Dock dock ) const;
86 bool isDockEnabled( QDockWindow *tb, QDockArea *area ) const;
87
88 virtual void addDockWindow( QDockWindow *, Dock = DockTop, bool newLine = FALSE );
89 virtual void addDockWindow( QDockWindow *, const QString &label,
90 Dock = DockTop, bool newLine = FALSE );
91 virtual void moveDockWindow( QDockWindow *, Dock = DockTop );
92 virtual void moveDockWindow( QDockWindow *, Dock, bool nl, int index, int extraOffset = -1 );
93 virtual void removeDockWindow( QDockWindow * );
94
95 void show();
96 void hide();
97 QSize sizeHint() const;
98 QSize minimumSizeHint() const;
99
100 bool rightJustification() const;
101 bool usesBigPixmaps() const;
102 bool usesTextLabel() const;
103 bool dockWindowsMovable() const;
104 bool opaqueMoving() const;
105
106 bool eventFilter( QObject*, QEvent* );
107
108 bool getLocation( QDockWindow *tb, Dock &dock, int &index, bool &nl, int &extraOffset ) const;
109
110 QPtrList<QDockWindow> dockWindows( Dock dock ) const;
111 QPtrList<QDockWindow> dockWindows() const;
112 void lineUpDockWindows( bool keepNewLines = FALSE );
113
114 bool isDockMenuEnabled() const;
115
116 // compatibility stuff
117 bool hasDockWindow( QDockWindow *dw );
118 #ifndef QT_NO_TOOLBAR
119 void addToolBar( QDockWindow *, Dock = DockTop, bool newLine = FALSE );
120 void addToolBar( QDockWindow *, const QString &label,
121 Dock = DockTop, bool newLine = FALSE );
122 void moveToolBar( QDockWindow *, Dock = DockTop );
123 void moveToolBar( QDockWindow *, Dock, bool nl, int index, int extraOffset = -1 );
124 void removeToolBar( QDockWindow * );
125
126 bool toolBarsMovable() const;
127 QPtrList<QToolBar> toolBars( Dock dock ) const;
128 void lineUpToolBars( bool keepNewLines = FALSE );
129 #endif
130
131 virtual QDockArea *dockingArea( const QPoint &p );
132 QDockArea *leftDock() const;
133 QDockArea *rightDock() const;
134 QDockArea *topDock() const;
135 QDockArea *bottomDock() const;
136
137 virtual bool isCustomizable() const;
138
139 bool appropriate( QDockWindow *dw ) const;
140
141 enum DockWindows { OnlyToolBars, NoToolBars, AllDockWindows };
142 QPopupMenu *createDockWindowMenu( DockWindows dockWindows = AllDockWindows ) const;
143
144 public slots:
145 virtual void setRightJustification( bool );
146 virtual void setUsesBigPixmaps( bool );
147 virtual void setUsesTextLabel( bool );
148 virtual void setDockWindowsMovable( bool );
149 virtual void setOpaqueMoving( bool );
150 virtual void setDockMenuEnabled( bool );
151 virtual void whatsThis();
152 virtual void setAppropriate( QDockWindow *dw, bool a );
153 virtual void customize();
154
155 // compatibility stuff
156 void setToolBarsMovable( bool );
157
158 signals:
159 void pixmapSizeChanged( bool );
160 void usesTextLabelChanged( bool );
161 void dockWindowPositionChanged( QDockWindow * );
162
163 #ifndef QT_NO_TOOLBAR
164 // compatibility stuff
165 void toolBarPositionChanged( QToolBar * );
166 #endif
167
168 protected slots:
169 virtual void setUpLayout();
170 virtual bool showDockMenu( const QPoint &globalPos );
171 void menuAboutToShow();
172
173 protected:
174 void paintEvent( QPaintEvent * );
175 void childEvent( QChildEvent * );
176 bool event( QEvent * );
177 void styleChange( QStyle& );
178
179 private slots:
180 void slotPlaceChanged();
doLineUp()181 void doLineUp() { lineUpDockWindows( TRUE ); }
182
183 private:
184 QMainWindowPrivate * d;
185 void triggerLayout( bool deleteLayout = TRUE);
186 bool dockMainWindow( QObject *dock );
187
188 #ifndef QT_NO_MENUBAR
189 virtual void setMenuBar( QMenuBar * );
190 #endif
191 virtual void setStatusBar( QStatusBar * );
192 #ifndef QT_NO_TOOLTIP
193 virtual void setToolTipGroup( QToolTipGroup * );
194 #endif
195
196 friend class QDockWindow;
197 friend class QMenuBar;
198 friend class QHideDock;
199 friend class QToolBar;
200 friend class QMainWindowLayout;
201 private: // Disabled copy constructor and operator=
202 #if defined(Q_DISABLE_COPY)
203 QMainWindow( const QMainWindow & );
204 QMainWindow& operator=( const QMainWindow & );
205 #endif
206 };
207
208 #ifndef QT_NO_TOOLBAR
addToolBar(QDockWindow * w,ToolBarDock dock,bool newLine)209 inline void QMainWindow::addToolBar( QDockWindow *w, ToolBarDock dock, bool newLine )
210 {
211 addDockWindow( w, dock, newLine );
212 }
213
addToolBar(QDockWindow * w,const QString & label,ToolBarDock dock,bool newLine)214 inline void QMainWindow::addToolBar( QDockWindow *w, const QString &label,
215 ToolBarDock dock, bool newLine )
216 {
217 addDockWindow( w, label, dock, newLine );
218 }
219
moveToolBar(QDockWindow * w,ToolBarDock dock)220 inline void QMainWindow::moveToolBar( QDockWindow *w, ToolBarDock dock )
221 {
222 moveDockWindow( w, dock );
223 }
224
moveToolBar(QDockWindow * w,ToolBarDock dock,bool nl,int index,int extraOffset)225 inline void QMainWindow::moveToolBar( QDockWindow *w, ToolBarDock dock, bool nl, int index, int extraOffset )
226 {
227 moveDockWindow( w, dock, nl, index, extraOffset );
228 }
229
removeToolBar(QDockWindow * w)230 inline void QMainWindow::removeToolBar( QDockWindow *w )
231 {
232 removeDockWindow( w );
233 }
234
toolBarsMovable()235 inline bool QMainWindow::toolBarsMovable() const
236 {
237 return dockWindowsMovable();
238 }
239
lineUpToolBars(bool keepNewLines)240 inline void QMainWindow::lineUpToolBars( bool keepNewLines )
241 {
242 lineUpDockWindows( keepNewLines );
243 }
244
setToolBarsMovable(bool b)245 inline void QMainWindow::setToolBarsMovable( bool b )
246 {
247 setDockWindowsMovable( b );
248 }
249 #endif
250
251 #ifndef QT_NO_TEXTSTREAM
252 Q_EXPORT QTextStream &operator<<( QTextStream &, const QMainWindow & );
253 Q_EXPORT QTextStream &operator>>( QTextStream &, QMainWindow & );
254 #endif
255
256 #endif // QT_NO_MAINWINDOW
257
258 #endif // QMAINWINDOW_H
259