1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QBOXLAYOUT_H |
5 | #define QBOXLAYOUT_H |
6 | |
7 | #include <QtWidgets/qtwidgetsglobal.h> |
8 | #include <QtWidgets/qlayout.h> |
9 | #ifdef QT_INCLUDE_COMPAT |
10 | #include <QtWidgets/qwidget.h> |
11 | #endif |
12 | |
13 | #include <limits.h> |
14 | |
15 | QT_BEGIN_NAMESPACE |
16 | |
17 | |
18 | class QBoxLayoutPrivate; |
19 | |
20 | class Q_WIDGETS_EXPORT QBoxLayout : public QLayout |
21 | { |
22 | Q_OBJECT |
23 | Q_DECLARE_PRIVATE(QBoxLayout) |
24 | public: |
25 | enum Direction { LeftToRight, RightToLeft, TopToBottom, BottomToTop, |
26 | Down = TopToBottom, Up = BottomToTop }; |
27 | |
28 | explicit QBoxLayout(Direction, QWidget *parent = nullptr); |
29 | |
30 | ~QBoxLayout(); |
31 | |
32 | Direction direction() const; |
33 | void setDirection(Direction); |
34 | |
35 | void addSpacing(int size); |
36 | void addStretch(int stretch = 0); |
37 | void addSpacerItem(QSpacerItem *spacerItem); |
38 | void addWidget(QWidget *, int stretch = 0, Qt::Alignment alignment = Qt::Alignment()); |
39 | void addLayout(QLayout *layout, int stretch = 0); |
40 | void addStrut(int); |
41 | void addItem(QLayoutItem *) override; |
42 | |
43 | void insertSpacing(int index, int size); |
44 | void insertStretch(int index, int stretch = 0); |
45 | void insertSpacerItem(int index, QSpacerItem *spacerItem); |
46 | void insertWidget(int index, QWidget *widget, int stretch = 0, Qt::Alignment alignment = Qt::Alignment()); |
47 | void insertLayout(int index, QLayout *layout, int stretch = 0); |
48 | void insertItem(int index, QLayoutItem *); |
49 | |
50 | int spacing() const override; |
51 | void setSpacing(int spacing) override; |
52 | |
53 | bool setStretchFactor(QWidget *w, int stretch); |
54 | bool setStretchFactor(QLayout *l, int stretch); |
55 | void setStretch(int index, int stretch); |
56 | int stretch(int index) const; |
57 | |
58 | QSize sizeHint() const override; |
59 | QSize minimumSize() const override; |
60 | QSize maximumSize() const override; |
61 | |
62 | bool hasHeightForWidth() const override; |
63 | int heightForWidth(int) const override; |
64 | int minimumHeightForWidth(int) const override; |
65 | |
66 | Qt::Orientations expandingDirections() const override; |
67 | void invalidate() override; |
68 | QLayoutItem *itemAt(int) const override; |
69 | QLayoutItem *takeAt(int) override; |
70 | int count() const override; |
71 | void setGeometry(const QRect&) override; |
72 | |
73 | private: |
74 | Q_DISABLE_COPY(QBoxLayout) |
75 | }; |
76 | |
77 | class Q_WIDGETS_EXPORT QHBoxLayout : public QBoxLayout |
78 | { |
79 | Q_OBJECT |
80 | public: |
81 | QHBoxLayout(); |
82 | explicit QHBoxLayout(QWidget *parent); |
83 | ~QHBoxLayout(); |
84 | |
85 | |
86 | private: |
87 | Q_DISABLE_COPY(QHBoxLayout) |
88 | }; |
89 | |
90 | class Q_WIDGETS_EXPORT QVBoxLayout : public QBoxLayout |
91 | { |
92 | Q_OBJECT |
93 | public: |
94 | QVBoxLayout(); |
95 | explicit QVBoxLayout(QWidget *parent); |
96 | ~QVBoxLayout(); |
97 | |
98 | |
99 | private: |
100 | Q_DISABLE_COPY(QVBoxLayout) |
101 | }; |
102 | |
103 | QT_END_NAMESPACE |
104 | |
105 | #endif // QBOXLAYOUT_H |
106 | |