File indexing completed on 2024-11-10 04:26:04
0001 /* 0002 SPDX-FileCopyrightText: 2013 Digia Plc and /or its subsidiary(-ies) <http://www.qt-project.org/legal> 0003 SPDX-License-Identifier: BSD-3-Clause 0004 This file is part of the examples of the Qt Toolkit. 0005 */ 0006 0007 #pragma once 0008 0009 #include <QLayout> 0010 #include <QRect> 0011 #include <QStyle> 0012 #include <QMutex> 0013 0014 class FlowLayout : public QLayout 0015 { 0016 public: 0017 explicit FlowLayout(QWidget *parent, int margin = -1, int hSpacing = -1, int vSpacing = -1); 0018 explicit FlowLayout(int margin = -1, int hSpacing = -1, int vSpacing = -1); 0019 ~FlowLayout() override; 0020 0021 void addItem(QLayoutItem *item) override; 0022 int horizontalSpacing() const; 0023 int verticalSpacing() const; 0024 Qt::Orientations expandingDirections() const override; 0025 bool hasHeightForWidth() const override; 0026 int heightForWidth(int) const override; 0027 int count() const override; 0028 QLayoutItem *itemAt(int index) const override; 0029 QSize minimumSize() const override; 0030 void setGeometry(const QRect &rect) override; 0031 QSize sizeHint() const override; 0032 QLayoutItem *takeAt(int index) override; 0033 int miniHeight() const; 0034 0035 private: 0036 int doLayout(const QRect &rect, bool testOnly) const; 0037 int smartSpacing(QStyle::PixelMetric pm) const; 0038 QList<QLayoutItem *> m_itemList; 0039 int m_hSpace; 0040 int m_vSpace; 0041 0042 protected: 0043 mutable QSize m_minimumSize; 0044 };