Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/QtWidgets/qlayoutitem.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Copyright (C) 2016 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 
0004 #ifndef QLAYOUTITEM_H
0005 #define QLAYOUTITEM_H
0006 
0007 #include <QtWidgets/qtwidgetsglobal.h>
0008 #include <QtWidgets/qsizepolicy.h>
0009 #include <QtCore/qrect.h>
0010 
0011 #include <limits.h>
0012 
0013 QT_BEGIN_NAMESPACE
0014 
0015 
0016 inline constexpr int QLAYOUTSIZE_MAX = INT_MAX/256/16;
0017 
0018 class QLayout;
0019 class QLayoutItem;
0020 class QSpacerItem;
0021 class QWidget;
0022 class QSize;
0023 
0024 class Q_WIDGETS_EXPORT QLayoutItem
0025 {
0026 public:
0027     inline explicit QLayoutItem(Qt::Alignment alignment = Qt::Alignment());
0028     virtual ~QLayoutItem();
0029     virtual QSize sizeHint() const = 0;
0030     virtual QSize minimumSize() const = 0;
0031     virtual QSize maximumSize() const = 0;
0032     virtual Qt::Orientations expandingDirections() const = 0;
0033     virtual void setGeometry(const QRect&) = 0;
0034     virtual QRect geometry() const = 0;
0035     virtual bool isEmpty() const = 0;
0036     virtual bool hasHeightForWidth() const;
0037     virtual int heightForWidth(int) const;
0038     virtual int minimumHeightForWidth(int) const;
0039     virtual void invalidate();
0040 
0041     virtual QWidget *widget() const;
0042     virtual QLayout *layout();
0043     virtual QSpacerItem *spacerItem();
0044 
0045     Qt::Alignment alignment() const { return align; }
0046     void setAlignment(Qt::Alignment a);
0047     virtual QSizePolicy::ControlTypes controlTypes() const;
0048 
0049 protected:
0050     Qt::Alignment align;
0051 };
0052 
0053 inline QLayoutItem::QLayoutItem(Qt::Alignment aalignment)
0054     : align(aalignment) { }
0055 
0056 class Q_WIDGETS_EXPORT QSpacerItem : public QLayoutItem
0057 {
0058 public:
0059     QSpacerItem(int w, int h,
0060                  QSizePolicy::Policy hData = QSizePolicy::Minimum,
0061                  QSizePolicy::Policy vData = QSizePolicy::Minimum)
0062         : width(w), height(h), sizeP(hData, vData) { }
0063     ~QSpacerItem();
0064 
0065     void changeSize(int w, int h,
0066                      QSizePolicy::Policy hData = QSizePolicy::Minimum,
0067                      QSizePolicy::Policy vData = QSizePolicy::Minimum);
0068     QSize sizeHint() const override;
0069     QSize minimumSize() const override;
0070     QSize maximumSize() const override;
0071     Qt::Orientations expandingDirections() const override;
0072     bool isEmpty() const override;
0073     void setGeometry(const QRect&) override;
0074     QRect geometry() const override;
0075     QSpacerItem *spacerItem() override;
0076     QSizePolicy sizePolicy() const { return sizeP; }
0077 
0078 private:
0079     int width;
0080     int height;
0081     QSizePolicy sizeP;
0082     QRect rect;
0083 };
0084 
0085 class Q_WIDGETS_EXPORT QWidgetItem : public QLayoutItem
0086 {
0087     Q_DISABLE_COPY(QWidgetItem)
0088 
0089 public:
0090     explicit QWidgetItem(QWidget *w) : wid(w) { }
0091     ~QWidgetItem();
0092 
0093     QSize sizeHint() const override;
0094     QSize minimumSize() const override;
0095     QSize maximumSize() const override;
0096     Qt::Orientations expandingDirections() const override;
0097     bool isEmpty() const override;
0098     void setGeometry(const QRect&) override;
0099     QRect geometry() const override;
0100     QWidget *widget() const override;
0101 
0102     bool hasHeightForWidth() const override;
0103     int heightForWidth(int) const override;
0104     int minimumHeightForWidth(int) const override;
0105     QSizePolicy::ControlTypes controlTypes() const override;
0106 protected:
0107     QWidget *wid;
0108 };
0109 
0110 class Q_WIDGETS_EXPORT QWidgetItemV2 : public QWidgetItem
0111 {
0112 public:
0113     explicit QWidgetItemV2(QWidget *widget);
0114     ~QWidgetItemV2();
0115 
0116     QSize sizeHint() const override;
0117     QSize minimumSize() const override;
0118     QSize maximumSize() const override;
0119     int heightForWidth(int width) const override;
0120 
0121 private:
0122     enum { Dirty = -123, HfwCacheMaxSize = 3 };
0123 
0124     inline bool useSizeCache() const;
0125     void updateCacheIfNecessary() const;
0126     inline void invalidateSizeCache() {
0127         q_cachedMinimumSize.setWidth(Dirty);
0128         q_hfwCacheSize = 0;
0129     }
0130 
0131     mutable QSize q_cachedMinimumSize;
0132     mutable QSize q_cachedSizeHint;
0133     mutable QSize q_cachedMaximumSize;
0134     mutable QSize q_cachedHfws[HfwCacheMaxSize];
0135     mutable short q_firstCachedHfw;
0136     mutable short q_hfwCacheSize;
0137     void *d;
0138 
0139     friend class QWidgetPrivate;
0140 
0141     Q_DISABLE_COPY(QWidgetItemV2)
0142 };
0143 
0144 QT_END_NAMESPACE
0145 
0146 #endif // QLAYOUTITEM_H