File indexing completed on 2024-04-21 04:39:56

0001 /*
0002     SPDX-FileCopyrightText: 2006-2007 Sebastian Trueg <trueg@kde.org>
0003 
0004     KBlockLayout is based on the FlowLayout example from QT4.
0005     SPDX-FileCopyrightText: 2004-2006 Trolltech ASA.
0006 
0007     SPDX-License-Identifier: LGPL-2.0-or-later
0008 */
0009 
0010 #ifndef KBLOCKLAYOUT_H
0011 #define KBLOCKLAYOUT_H
0012 
0013 #include <QLayout>
0014 #include <QLayoutItem>
0015 
0016 /**
0017  * The KBlockLayout arranges widget in rows and columns like a text
0018  * editor does.
0019  */
0020 class KBlockLayout : public QLayout
0021 {
0022 public:
0023     explicit KBlockLayout(QWidget *parent, int margin = 0, int hSpacing = -1, int vSpacing = -1);
0024     explicit KBlockLayout(int margin = 0, int hSpacing = -1, int vSpacing = -1);
0025     ~KBlockLayout() override;
0026 
0027     /**
0028      * Set the alignment to use. It can be a combination of a horizontal and
0029      * a vertical alignment flag. The vertical flag is used to arrange widgets
0030      * that do not fill the complete height of a row.
0031      *
0032      * The default alignment is Qt::AlignLeft|Qt::AlignTop
0033      */
0034     void setAlignment(Qt::Alignment);
0035     Qt::Alignment alignment() const;
0036 
0037     int horizontalSpacing() const;
0038     int verticalSpacing() const;
0039 
0040     void setSpacing(int h, int v);
0041 
0042     void addItem(QLayoutItem *item) override;
0043     Qt::Orientations expandingDirections() const override;
0044     bool hasHeightForWidth() const override;
0045     int heightForWidth(int) const override;
0046     int count() const override;
0047     QLayoutItem *itemAt(int index) const override;
0048     QSize minimumSize() const override;
0049     void setGeometry(const QRect &rect) override;
0050     QSize sizeHint() const override;
0051     QLayoutItem *takeAt(int index) override;
0052 
0053 private:
0054     int doLayout(const QRect &rect, bool testOnly) const;
0055     int getMargin() const;
0056 
0057     class Private;
0058     Private *const d;
0059 };
0060 
0061 #endif