| 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 QGRAPHICSLINEARLAYOUT_H |
| 5 | #define QGRAPHICSLINEARLAYOUT_H |
| 6 | |
| 7 | #include <QtWidgets/qtwidgetsglobal.h> |
| 8 | #include <QtWidgets/qgraphicsitem.h> |
| 9 | #include <QtWidgets/qgraphicslayout.h> |
| 10 | |
| 11 | QT_REQUIRE_CONFIG(graphicsview); |
| 12 | |
| 13 | QT_BEGIN_NAMESPACE |
| 14 | |
| 15 | class QGraphicsLinearLayoutPrivate; |
| 16 | |
| 17 | class Q_WIDGETS_EXPORT QGraphicsLinearLayout : public QGraphicsLayout |
| 18 | { |
| 19 | public: |
| 20 | QGraphicsLinearLayout(QGraphicsLayoutItem *parent = nullptr); |
| 21 | QGraphicsLinearLayout(Qt::Orientation orientation, QGraphicsLayoutItem *parent = nullptr); |
| 22 | virtual ~QGraphicsLinearLayout(); |
| 23 | |
| 24 | void setOrientation(Qt::Orientation orientation); |
| 25 | Qt::Orientation orientation() const; |
| 26 | |
| 27 | inline void addItem(QGraphicsLayoutItem *item) { insertItem(index: -1, item); } |
| 28 | inline void addStretch(int stretch = 1) { insertStretch(index: -1, stretch); } |
| 29 | |
| 30 | void insertItem(int index, QGraphicsLayoutItem *item); |
| 31 | void insertStretch(int index, int stretch = 1); |
| 32 | |
| 33 | void removeItem(QGraphicsLayoutItem *item); |
| 34 | void removeAt(int index) override; |
| 35 | |
| 36 | void setSpacing(qreal spacing); |
| 37 | qreal spacing() const; |
| 38 | void setItemSpacing(int index, qreal spacing); |
| 39 | qreal itemSpacing(int index) const; |
| 40 | |
| 41 | void setStretchFactor(QGraphicsLayoutItem *item, int stretch); |
| 42 | int stretchFactor(QGraphicsLayoutItem *item) const; |
| 43 | |
| 44 | void setAlignment(QGraphicsLayoutItem *item, Qt::Alignment alignment); |
| 45 | Qt::Alignment alignment(QGraphicsLayoutItem *item) const; |
| 46 | |
| 47 | void setGeometry(const QRectF &rect) override; |
| 48 | |
| 49 | int count() const override; |
| 50 | QGraphicsLayoutItem *itemAt(int index) const override; |
| 51 | |
| 52 | void invalidate() override; |
| 53 | QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const override; |
| 54 | |
| 55 | #if 0 // ### |
| 56 | Q5SizePolicy::ControlTypes controlTypes(LayoutSide side) const; |
| 57 | #endif |
| 58 | |
| 59 | void dump(int indent = 0) const; |
| 60 | |
| 61 | protected: |
| 62 | #if 0 |
| 63 | QSize contentsSizeHint(Qt::SizeHint which, const QSize &constraint = QSize()) const; |
| 64 | #endif |
| 65 | |
| 66 | private: |
| 67 | Q_DISABLE_COPY(QGraphicsLinearLayout) |
| 68 | Q_DECLARE_PRIVATE(QGraphicsLinearLayout) |
| 69 | }; |
| 70 | |
| 71 | QT_END_NAMESPACE |
| 72 | |
| 73 | #endif |
| 74 | |