Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/QtGui/qregion.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 QREGION_H
0005 #define QREGION_H
0006 
0007 #include <QtGui/qtguiglobal.h>
0008 #include <QtCore/qatomic.h>
0009 #include <QtCore/qrect.h>
0010 #include <QtGui/qwindowdefs.h>
0011 
0012 #ifndef QT_NO_DATASTREAM
0013 #include <QtCore/qdatastream.h>
0014 #endif
0015 #include <QtCore/qspan.h>
0016 
0017 QT_BEGIN_NAMESPACE
0018 
0019 
0020 class QVariant;
0021 
0022 struct QRegionPrivate;
0023 
0024 class QBitmap;
0025 
0026 class Q_GUI_EXPORT QRegion
0027 {
0028 public:
0029     enum RegionType { Rectangle, Ellipse };
0030 
0031     QRegion();
0032     QRegion(int x, int y, int w, int h, RegionType t = Rectangle);
0033     QRegion(const QRect &r, RegionType t = Rectangle);
0034     QRegion(const QPolygon &pa, Qt::FillRule fillRule = Qt::OddEvenFill);
0035     QRegion(const QRegion &region);
0036     QRegion(QRegion &&other) noexcept
0037         : d(std::exchange(other.d, const_cast<QRegionData*>(&shared_empty))) {}
0038     QRegion(const QBitmap &bitmap);
0039     ~QRegion();
0040     QRegion &operator=(const QRegion &);
0041     QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QRegion)
0042     void swap(QRegion &other) noexcept { qt_ptr_swap(d, other.d); }
0043     bool isEmpty() const;
0044     bool isNull() const;
0045 
0046     typedef const QRect *const_iterator;
0047     typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
0048 
0049     const_iterator begin()  const noexcept;
0050     const_iterator cbegin() const noexcept { return begin(); }
0051     const_iterator end()    const noexcept;
0052     const_iterator cend()   const noexcept { return end(); }
0053     const_reverse_iterator rbegin()  const noexcept { return const_reverse_iterator(end()); }
0054     const_reverse_iterator crbegin() const noexcept { return rbegin(); }
0055     const_reverse_iterator rend()    const noexcept { return const_reverse_iterator(begin()); }
0056     const_reverse_iterator crend()   const noexcept { return rend(); }
0057 
0058     bool contains(const QPoint &p) const;
0059     bool contains(const QRect &r) const;
0060 
0061     void translate(int dx, int dy);
0062     inline void translate(const QPoint &p) { translate(p.x(), p.y()); }
0063     [[nodiscard]] QRegion translated(int dx, int dy) const;
0064     [[nodiscard]] inline QRegion translated(const QPoint &p) const { return translated(p.x(), p.y()); }
0065 
0066     [[nodiscard]] QRegion united(const QRegion &r) const;
0067     [[nodiscard]] QRegion united(const QRect &r) const;
0068     [[nodiscard]] QRegion intersected(const QRegion &r) const;
0069     [[nodiscard]] QRegion intersected(const QRect &r) const;
0070     [[nodiscard]] QRegion subtracted(const QRegion &r) const;
0071     [[nodiscard]] QRegion xored(const QRegion &r) const;
0072 
0073     bool intersects(const QRegion &r) const;
0074     bool intersects(const QRect &r) const;
0075 
0076     QRect boundingRect() const noexcept;
0077     void setRects(const QRect *rect, int num);
0078     void setRects(QSpan<const QRect> r);
0079     QSpan<const QRect> rects() const noexcept;
0080     int rectCount() const noexcept;
0081 
0082     QRegion operator|(const QRegion &r) const;
0083     QRegion operator+(const QRegion &r) const;
0084     QRegion operator+(const QRect &r) const;
0085     QRegion operator&(const QRegion &r) const;
0086     QRegion operator&(const QRect &r) const;
0087     QRegion operator-(const QRegion &r) const;
0088     QRegion operator^(const QRegion &r) const;
0089 
0090     QRegion& operator|=(const QRegion &r);
0091     QRegion& operator+=(const QRegion &r);
0092     QRegion& operator+=(const QRect &r);
0093     QRegion& operator&=(const QRegion &r);
0094     QRegion& operator&=(const QRect &r);
0095     QRegion& operator-=(const QRegion &r);
0096     QRegion& operator^=(const QRegion &r);
0097 
0098     bool operator==(const QRegion &r) const;
0099     inline bool operator!=(const QRegion &r) const { return !(operator==(r)); }
0100     operator QVariant() const;
0101 
0102     // Platform specific conversion functions
0103 #if defined(Q_OS_WIN) || defined(Q_QDOC)
0104     HRGN toHRGN() const;
0105     static QRegion fromHRGN(HRGN hrgn);
0106 #endif
0107 
0108 #ifndef QT_NO_DATASTREAM
0109     friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QRegion &);
0110     friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QRegion &);
0111 #endif
0112 private:
0113     QRegion copy() const;   // helper of detach.
0114     void detach();
0115 Q_GUI_EXPORT
0116     friend bool qt_region_strictContains(const QRegion &region,
0117                                          const QRect &rect);
0118     friend struct QRegionPrivate;
0119 
0120 #ifndef QT_NO_DATASTREAM
0121     void exec(const QByteArray &ba, int ver = 0, QDataStream::ByteOrder byteOrder = QDataStream::BigEndian);
0122 #endif
0123     struct QRegionData {
0124         QtPrivate::RefCount ref;
0125         QRegionPrivate *qt_rgn;
0126     };
0127     struct QRegionData *d;
0128     static const struct QRegionData shared_empty;
0129     static void cleanUp(QRegionData *x);
0130 };
0131 Q_DECLARE_SHARED(QRegion)
0132 
0133 /*****************************************************************************
0134   QRegion stream functions
0135  *****************************************************************************/
0136 
0137 #ifndef QT_NO_DATASTREAM
0138 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QRegion &);
0139 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QRegion &);
0140 #endif
0141 
0142 #ifndef QT_NO_DEBUG_STREAM
0143 Q_GUI_EXPORT QDebug operator<<(QDebug, const QRegion &);
0144 #endif
0145 
0146 QT_END_NAMESPACE
0147 
0148 #endif // QREGION_H