qmdiarea.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2016 The Qt Company Ltd.
  4. ** Contact: https://www.qt.io/licensing/
  5. **
  6. ** This file is part of the QtWidgets 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 The Qt Company. For licensing terms
  14. ** and conditions see https://www.qt.io/terms-conditions. For further
  15. ** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
  20. ** Foundation and appearing in the file LICENSE.LGPL3 included in the
  21. ** packaging of this file. Please review the following information to
  22. ** ensure the GNU Lesser General Public License version 3 requirements
  23. ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
  24. **
  25. ** GNU General Public License Usage
  26. ** Alternatively, this file may be used under the terms of the GNU
  27. ** General Public License version 2.0 or (at your option) the GNU General
  28. ** Public license version 3 or any later version approved by the KDE Free
  29. ** Qt Foundation. The licenses are as published by the Free Software
  30. ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
  31. ** included in the packaging of this file. Please review the following
  32. ** information to ensure the GNU General Public License requirements will
  33. ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
  34. ** https://www.gnu.org/licenses/gpl-3.0.html.
  35. **
  36. ** $QT_END_LICENSE$
  37. **
  38. ****************************************************************************/
  39. #ifndef QMDIAREA_H
  40. #define QMDIAREA_H
  41. #include <QtWidgets/qabstractscrollarea.h>
  42. #include <QtWidgets/qtabwidget.h>
  43. QT_BEGIN_NAMESPACE
  44. #ifndef QT_NO_MDIAREA
  45. class QMdiSubWindow;
  46. class QMdiAreaPrivate;
  47. class Q_WIDGETS_EXPORT QMdiArea : public QAbstractScrollArea
  48. {
  49. Q_OBJECT
  50. Q_PROPERTY(QBrush background READ background WRITE setBackground)
  51. Q_PROPERTY(WindowOrder activationOrder READ activationOrder WRITE setActivationOrder)
  52. Q_PROPERTY(ViewMode viewMode READ viewMode WRITE setViewMode)
  53. #ifndef QT_NO_TABBAR
  54. Q_PROPERTY(bool documentMode READ documentMode WRITE setDocumentMode)
  55. Q_PROPERTY(bool tabsClosable READ tabsClosable WRITE setTabsClosable)
  56. Q_PROPERTY(bool tabsMovable READ tabsMovable WRITE setTabsMovable)
  57. #endif
  58. #ifndef QT_NO_TABWIDGET
  59. Q_PROPERTY(QTabWidget::TabShape tabShape READ tabShape WRITE setTabShape)
  60. Q_PROPERTY(QTabWidget::TabPosition tabPosition READ tabPosition WRITE setTabPosition)
  61. #endif
  62. public:
  63. enum AreaOption {
  64. DontMaximizeSubWindowOnActivation = 0x1
  65. };
  66. Q_DECLARE_FLAGS(AreaOptions, AreaOption)
  67. enum WindowOrder {
  68. CreationOrder,
  69. StackingOrder,
  70. ActivationHistoryOrder
  71. };
  72. Q_ENUM(WindowOrder)
  73. enum ViewMode {
  74. SubWindowView,
  75. TabbedView
  76. };
  77. Q_ENUM(ViewMode)
  78. QMdiArea(QWidget *parent = Q_NULLPTR);
  79. ~QMdiArea();
  80. QSize sizeHint() const Q_DECL_OVERRIDE;
  81. QSize minimumSizeHint() const Q_DECL_OVERRIDE;
  82. QMdiSubWindow *currentSubWindow() const;
  83. QMdiSubWindow *activeSubWindow() const;
  84. QList<QMdiSubWindow *> subWindowList(WindowOrder order = CreationOrder) const;
  85. QMdiSubWindow *addSubWindow(QWidget *widget, Qt::WindowFlags flags = Qt::WindowFlags());
  86. void removeSubWindow(QWidget *widget);
  87. QBrush background() const;
  88. void setBackground(const QBrush &background);
  89. WindowOrder activationOrder() const;
  90. void setActivationOrder(WindowOrder order);
  91. void setOption(AreaOption option, bool on = true);
  92. bool testOption(AreaOption opton) const;
  93. void setViewMode(ViewMode mode);
  94. ViewMode viewMode() const;
  95. #ifndef QT_NO_TABBAR
  96. bool documentMode() const;
  97. void setDocumentMode(bool enabled);
  98. void setTabsClosable(bool closable);
  99. bool tabsClosable() const;
  100. void setTabsMovable(bool movable);
  101. bool tabsMovable() const;
  102. #endif
  103. #ifndef QT_NO_TABWIDGET
  104. void setTabShape(QTabWidget::TabShape shape);
  105. QTabWidget::TabShape tabShape() const;
  106. void setTabPosition(QTabWidget::TabPosition position);
  107. QTabWidget::TabPosition tabPosition() const;
  108. #endif
  109. Q_SIGNALS:
  110. void subWindowActivated(QMdiSubWindow *);
  111. public Q_SLOTS:
  112. void setActiveSubWindow(QMdiSubWindow *window);
  113. void tileSubWindows();
  114. void cascadeSubWindows();
  115. void closeActiveSubWindow();
  116. void closeAllSubWindows();
  117. void activateNextSubWindow();
  118. void activatePreviousSubWindow();
  119. protected Q_SLOTS:
  120. void setupViewport(QWidget *viewport) Q_DECL_OVERRIDE;
  121. protected:
  122. bool event(QEvent *event) Q_DECL_OVERRIDE;
  123. bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE;
  124. void paintEvent(QPaintEvent *paintEvent) Q_DECL_OVERRIDE;
  125. void childEvent(QChildEvent *childEvent) Q_DECL_OVERRIDE;
  126. void resizeEvent(QResizeEvent *resizeEvent) Q_DECL_OVERRIDE;
  127. void timerEvent(QTimerEvent *timerEvent) Q_DECL_OVERRIDE;
  128. void showEvent(QShowEvent *showEvent) Q_DECL_OVERRIDE;
  129. bool viewportEvent(QEvent *event) Q_DECL_OVERRIDE;
  130. void scrollContentsBy(int dx, int dy) Q_DECL_OVERRIDE;
  131. private:
  132. Q_DISABLE_COPY(QMdiArea)
  133. Q_DECLARE_PRIVATE(QMdiArea)
  134. Q_PRIVATE_SLOT(d_func(), void _q_deactivateAllWindows())
  135. Q_PRIVATE_SLOT(d_func(), void _q_processWindowStateChanged(Qt::WindowStates, Qt::WindowStates))
  136. Q_PRIVATE_SLOT(d_func(), void _q_currentTabChanged(int))
  137. Q_PRIVATE_SLOT(d_func(), void _q_closeTab(int))
  138. Q_PRIVATE_SLOT(d_func(), void _q_moveTab(int, int))
  139. };
  140. Q_DECLARE_OPERATORS_FOR_FLAGS(QMdiArea::AreaOptions)
  141. QT_END_NAMESPACE
  142. #endif // QT_NO_MDIAREA
  143. #endif // QMDIAREA_H