File indexing completed on 2025-01-18 10:09:36
0001
0002
0003
0004 #ifndef QMDIAREA_H
0005 #define QMDIAREA_H
0006
0007 #include <QtWidgets/qtwidgetsglobal.h>
0008 #include <QtWidgets/qabstractscrollarea.h>
0009 #if QT_CONFIG(tabwidget)
0010 #include <QtWidgets/qtabwidget.h>
0011 #endif
0012
0013 QT_REQUIRE_CONFIG(mdiarea);
0014
0015 QT_BEGIN_NAMESPACE
0016
0017 class QMdiSubWindow;
0018
0019 class QMdiAreaPrivate;
0020 class Q_WIDGETS_EXPORT QMdiArea : public QAbstractScrollArea
0021 {
0022 Q_OBJECT
0023 Q_PROPERTY(QBrush background READ background WRITE setBackground)
0024 Q_PROPERTY(WindowOrder activationOrder READ activationOrder WRITE setActivationOrder)
0025 Q_PROPERTY(ViewMode viewMode READ viewMode WRITE setViewMode)
0026 #if QT_CONFIG(tabbar)
0027 Q_PROPERTY(bool documentMode READ documentMode WRITE setDocumentMode)
0028 Q_PROPERTY(bool tabsClosable READ tabsClosable WRITE setTabsClosable)
0029 Q_PROPERTY(bool tabsMovable READ tabsMovable WRITE setTabsMovable)
0030 #endif
0031 #if QT_CONFIG(tabwidget)
0032 Q_PROPERTY(QTabWidget::TabShape tabShape READ tabShape WRITE setTabShape)
0033 Q_PROPERTY(QTabWidget::TabPosition tabPosition READ tabPosition WRITE setTabPosition)
0034 #endif
0035 public:
0036 enum AreaOption {
0037 DontMaximizeSubWindowOnActivation = 0x1
0038 };
0039 Q_DECLARE_FLAGS(AreaOptions, AreaOption)
0040
0041 enum WindowOrder {
0042 CreationOrder,
0043 StackingOrder,
0044 ActivationHistoryOrder
0045 };
0046 Q_ENUM(WindowOrder)
0047
0048 enum ViewMode {
0049 SubWindowView,
0050 TabbedView
0051 };
0052 Q_ENUM(ViewMode)
0053
0054 QMdiArea(QWidget *parent = nullptr);
0055 ~QMdiArea();
0056
0057 QSize sizeHint() const override;
0058 QSize minimumSizeHint() const override;
0059
0060 QMdiSubWindow *currentSubWindow() const;
0061 QMdiSubWindow *activeSubWindow() const;
0062 QList<QMdiSubWindow *> subWindowList(WindowOrder order = CreationOrder) const;
0063
0064 QMdiSubWindow *addSubWindow(QWidget *widget, Qt::WindowFlags flags = Qt::WindowFlags());
0065 void removeSubWindow(QWidget *widget);
0066
0067 QBrush background() const;
0068 void setBackground(const QBrush &background);
0069
0070 WindowOrder activationOrder() const;
0071 void setActivationOrder(WindowOrder order);
0072
0073 void setOption(AreaOption option, bool on = true);
0074 bool testOption(AreaOption opton) const;
0075
0076 void setViewMode(ViewMode mode);
0077 ViewMode viewMode() const;
0078
0079 #if QT_CONFIG(tabbar)
0080 bool documentMode() const;
0081 void setDocumentMode(bool enabled);
0082
0083 void setTabsClosable(bool closable);
0084 bool tabsClosable() const;
0085
0086 void setTabsMovable(bool movable);
0087 bool tabsMovable() const;
0088 #endif
0089 #if QT_CONFIG(tabwidget)
0090 void setTabShape(QTabWidget::TabShape shape);
0091 QTabWidget::TabShape tabShape() const;
0092
0093 void setTabPosition(QTabWidget::TabPosition position);
0094 QTabWidget::TabPosition tabPosition() const;
0095 #endif
0096
0097 Q_SIGNALS:
0098 void subWindowActivated(QMdiSubWindow *);
0099
0100 public Q_SLOTS:
0101 void setActiveSubWindow(QMdiSubWindow *window);
0102 void tileSubWindows();
0103 void cascadeSubWindows();
0104 void closeActiveSubWindow();
0105 void closeAllSubWindows();
0106 void activateNextSubWindow();
0107 void activatePreviousSubWindow();
0108
0109 protected Q_SLOTS:
0110 void setupViewport(QWidget *viewport) override;
0111
0112 protected:
0113 bool event(QEvent *event) override;
0114 bool eventFilter(QObject *object, QEvent *event) override;
0115 void paintEvent(QPaintEvent *paintEvent) override;
0116 void childEvent(QChildEvent *childEvent) override;
0117 void resizeEvent(QResizeEvent *resizeEvent) override;
0118 void timerEvent(QTimerEvent *timerEvent) override;
0119 void showEvent(QShowEvent *showEvent) override;
0120 bool viewportEvent(QEvent *event) override;
0121 void scrollContentsBy(int dx, int dy) override;
0122
0123 private:
0124 Q_DISABLE_COPY(QMdiArea)
0125 Q_DECLARE_PRIVATE(QMdiArea)
0126 Q_PRIVATE_SLOT(d_func(), void _q_deactivateAllWindows())
0127 Q_PRIVATE_SLOT(d_func(), void _q_processWindowStateChanged(Qt::WindowStates, Qt::WindowStates))
0128 Q_PRIVATE_SLOT(d_func(), void _q_currentTabChanged(int))
0129 Q_PRIVATE_SLOT(d_func(), void _q_closeTab(int))
0130 Q_PRIVATE_SLOT(d_func(), void _q_moveTab(int, int))
0131 };
0132
0133 Q_DECLARE_OPERATORS_FOR_FLAGS(QMdiArea::AreaOptions)
0134
0135 QT_END_NAMESPACE
0136
0137 #endif