QtGui/qmdiarea.h Source File

qmdiarea.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QMDIAREA_H
43 #define QMDIAREA_H
44 
46 #include <QtGui/qtabwidget.h>
47 
49 
51 
52 QT_MODULE(Gui)
53 
54 #ifndef QT_NO_MDIAREA
55 
56 class QMdiSubWindow;
57 
58 class QMdiAreaPrivate;
59 class Q_GUI_EXPORT QMdiArea : public QAbstractScrollArea
60 {
61  Q_OBJECT
63  Q_PROPERTY(QBrush background READ background WRITE setBackground)
64  Q_PROPERTY(WindowOrder activationOrder READ activationOrder WRITE setActivationOrder)
65  Q_PROPERTY(ViewMode viewMode READ viewMode WRITE setViewMode)
66 #ifndef QT_NO_TABBAR
67  Q_PROPERTY(bool documentMode READ documentMode WRITE setDocumentMode)
68  Q_PROPERTY(bool tabsClosable READ tabsClosable WRITE setTabsClosable)
69  Q_PROPERTY(bool tabsMovable READ tabsMovable WRITE setTabsMovable)
70 #endif
71 #ifndef QT_NO_TABWIDGET
72  Q_PROPERTY(QTabWidget::TabShape tabShape READ tabShape WRITE setTabShape)
73  Q_PROPERTY(QTabWidget::TabPosition tabPosition READ tabPosition WRITE setTabPosition)
74 #endif
76 public:
77  enum AreaOption {
78  DontMaximizeSubWindowOnActivation = 0x1
79  };
80  Q_DECLARE_FLAGS(AreaOptions, AreaOption)
81 
82  enum WindowOrder {
85  ActivationHistoryOrder
86  };
87 
88  enum ViewMode {
90  TabbedView
91  };
92 
93  QMdiArea(QWidget *parent = 0);
94  ~QMdiArea();
95 
96  QSize sizeHint() const;
97  QSize minimumSizeHint() const;
98 
99  QMdiSubWindow *currentSubWindow() const;
100  QMdiSubWindow *activeSubWindow() const;
101  QList<QMdiSubWindow *> subWindowList(WindowOrder order = CreationOrder) const;
102 
103  QMdiSubWindow *addSubWindow(QWidget *widget, Qt::WindowFlags flags = 0);
104  void removeSubWindow(QWidget *widget);
105 
106  QBrush background() const;
107  void setBackground(const QBrush &background);
108 
109  WindowOrder activationOrder() const;
110  void setActivationOrder(WindowOrder order);
111 
112  void setOption(AreaOption option, bool on = true);
113  bool testOption(AreaOption opton) const;
114 
115  void setViewMode(ViewMode mode);
116  ViewMode viewMode() const;
117 
118 #ifndef QT_NO_TABBAR
119  bool documentMode() const;
120  void setDocumentMode(bool enabled);
121 
122  void setTabsClosable(bool closable);
123  bool tabsClosable() const;
124 
125  void setTabsMovable(bool movable);
126  bool tabsMovable() const;
127 #endif
128 #ifndef QT_NO_TABWIDGET
129  void setTabShape(QTabWidget::TabShape shape);
130  QTabWidget::TabShape tabShape() const;
131 
132  void setTabPosition(QTabWidget::TabPosition position);
133  QTabWidget::TabPosition tabPosition() const;
134 #endif
135 
136 Q_SIGNALS:
137  void subWindowActivated(QMdiSubWindow *);
138 
139 public Q_SLOTS:
140  void setActiveSubWindow(QMdiSubWindow *window);
141  void tileSubWindows();
142  void cascadeSubWindows();
143  void closeActiveSubWindow();
144  void closeAllSubWindows();
145  void activateNextSubWindow();
146  void activatePreviousSubWindow();
147 
148 protected Q_SLOTS:
149  void setupViewport(QWidget *viewport);
150 
151 protected:
152  bool event(QEvent *event);
153  bool eventFilter(QObject *object, QEvent *event);
154  void paintEvent(QPaintEvent *paintEvent);
155  void childEvent(QChildEvent *childEvent);
156  void resizeEvent(QResizeEvent *resizeEvent);
157  void timerEvent(QTimerEvent *timerEvent);
158  void showEvent(QShowEvent *showEvent);
159  bool viewportEvent(QEvent *event);
160  void scrollContentsBy(int dx, int dy);
161 
162 private:
163  Q_DISABLE_COPY(QMdiArea)
164  Q_DECLARE_PRIVATE(QMdiArea)
165  Q_PRIVATE_SLOT(d_func(), void _q_deactivateAllWindows())
166  Q_PRIVATE_SLOT(d_func(), void _q_processWindowStateChanged(Qt::WindowStates, Qt::WindowStates))
167  Q_PRIVATE_SLOT(d_func(), void _q_currentTabChanged(int))
168  Q_PRIVATE_SLOT(d_func(), void _q_closeTab(int))
169  Q_PRIVATE_SLOT(d_func(), void _q_moveTab(int, int))
170 };
171 
172 Q_DECLARE_OPERATORS_FOR_FLAGS(QMdiArea::AreaOptions)
173 
175 
177 
178 #endif // QT_NO_MDIAREA
179 #endif // QMDIAREA_H
GLint mode
Definition: GLee.h:4479
int int int int * dy
Definition: GLee.h:10535
virtual bool eventFilter(QObject *, QEvent *)
#define QT_END_NAMESPACE
Definition: qglobal.h:128
#define Q_PROPERTY(text)
Definition: qobjectdefs.h:80
#define QT_BEGIN_HEADER
Definition: qglobal.h:141
void resizeEvent(QResizeEvent *)
WindowOrder
Definition: qmdiarea.h:82
Definition: qnamespace.h:54
#define Q_PRIVATE_SLOT(d, signature)
Definition: qobjectdefs.h:73
#define Q_SLOTS
Definition: qobjectdefs.h:71
#define Q_SIGNALS
Definition: qobjectdefs.h:72
#define Q_ENUMS(x)
Definition: qobjectdefs.h:84
virtual void timerEvent(QTimerEvent *)
bool event(QEvent *)
#define QT_BEGIN_NAMESPACE
Definition: qglobal.h:127
QSize minimumSizeHint() const
virtual bool viewportEvent(QEvent *)
void setupViewport(QWidget *viewport)
#define Q_OBJECT
Definition: qobjectdefs.h:157
QSize sizeHint() const
virtual void showEvent(QShowEvent *)
Window window
Definition: GLee.h:10520
Definition: qsize.h:53
int int int * dx
Definition: GLee.h:10535
AreaOption
Definition: qmdiarea.h:77
Definition: qbrush.h:76
virtual void scrollContentsBy(int dx, int dy)
#define QT_END_HEADER
Definition: qglobal.h:142
void paintEvent(QPaintEvent *)
virtual void childEvent(QChildEvent *)