Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qregion.h
Go to the documentation of this file.
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 QREGION_H
5#define QREGION_H
6
7#include <QtGui/qtguiglobal.h>
8#include <QtCore/qatomic.h>
9#include <QtCore/qrect.h>
10#include <QtGui/qwindowdefs.h>
11#include <QtCore/qcontainerfwd.h>
12
13#ifndef QT_NO_DATASTREAM
14#include <QtCore/qdatastream.h>
15#endif
16
18
19
20class QVariant;
21
22struct QRegionPrivate;
23
24class QBitmap;
25
26class Q_GUI_EXPORT QRegion
27{
28public:
29 enum RegionType { Rectangle, Ellipse };
30
32 QRegion(int x, int y, int w, int h, RegionType t = Rectangle);
33 QRegion(const QRect &r, RegionType t = Rectangle);
35 QRegion(const QRegion &region);
36 QRegion(QRegion &&other) noexcept
37 : d(std::exchange(other.d, const_cast<QRegionData*>(&shared_empty))) {}
41 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QRegion)
42 void swap(QRegion &other) noexcept { qt_ptr_swap(d, other.d); }
43 bool isEmpty() const;
44 bool isNull() const;
45
46 typedef const QRect *const_iterator;
47 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
48
49 const_iterator begin() const noexcept;
50 const_iterator cbegin() const noexcept { return begin(); }
51 const_iterator end() const noexcept;
52 const_iterator cend() const noexcept { return end(); }
54 const_reverse_iterator crbegin() const noexcept { return rbegin(); }
56 const_reverse_iterator crend() const noexcept { return rend(); }
57
58 bool contains(const QPoint &p) const;
59 bool contains(const QRect &r) const;
60
61 void translate(int dx, int dy);
62 inline void translate(const QPoint &p) { translate(p.x(), p.y()); }
63 [[nodiscard]] QRegion translated(int dx, int dy) const;
64 [[nodiscard]] inline QRegion translated(const QPoint &p) const { return translated(p.x(), p.y()); }
65
66 [[nodiscard]] QRegion united(const QRegion &r) const;
67 [[nodiscard]] QRegion united(const QRect &r) const;
68 [[nodiscard]] QRegion intersected(const QRegion &r) const;
69 [[nodiscard]] QRegion intersected(const QRect &r) const;
70 [[nodiscard]] QRegion subtracted(const QRegion &r) const;
71 [[nodiscard]] QRegion xored(const QRegion &r) const;
72
73 bool intersects(const QRegion &r) const;
74 bool intersects(const QRect &r) const;
75
76 QRect boundingRect() const noexcept;
77 void setRects(const QRect *rect, int num);
78 int rectCount() const noexcept;
79
80 QRegion operator|(const QRegion &r) const;
81 QRegion operator+(const QRegion &r) const;
82 QRegion operator+(const QRect &r) const;
83 QRegion operator&(const QRegion &r) const;
84 QRegion operator&(const QRect &r) const;
85 QRegion operator-(const QRegion &r) const;
86 QRegion operator^(const QRegion &r) const;
87
88 QRegion& operator|=(const QRegion &r);
89 QRegion& operator+=(const QRegion &r);
90 QRegion& operator+=(const QRect &r);
91 QRegion& operator&=(const QRegion &r);
92 QRegion& operator&=(const QRect &r);
93 QRegion& operator-=(const QRegion &r);
94 QRegion& operator^=(const QRegion &r);
95
96 bool operator==(const QRegion &r) const;
97 inline bool operator!=(const QRegion &r) const { return !(operator==(r)); }
98 operator QVariant() const;
99
100 // Platform specific conversion functions
101#if defined(Q_OS_WIN) || defined(Q_QDOC)
102 HRGN toHRGN() const;
103 static QRegion fromHRGN(HRGN hrgn);
104#endif
105
106#ifndef QT_NO_DATASTREAM
107 friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QRegion &);
108 friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QRegion &);
109#endif
110private:
111 QRegion copy() const; // helper of detach.
112 void detach();
113Q_GUI_EXPORT
114 friend bool qt_region_strictContains(const QRegion &region,
115 const QRect &rect);
116 friend struct QRegionPrivate;
117
118#ifndef QT_NO_DATASTREAM
119 void exec(const QByteArray &ba, int ver = 0, QDataStream::ByteOrder byteOrder = QDataStream::BigEndian);
120#endif
121 struct QRegionData {
123 QRegionPrivate *qt_rgn;
124 };
125 struct QRegionData *d;
126 static const struct QRegionData shared_empty;
127 static void cleanUp(QRegionData *x);
128};
129Q_DECLARE_SHARED(QRegion)
130
131/*****************************************************************************
132 QRegion stream functions
133 *****************************************************************************/
134
135#ifndef QT_NO_DATASTREAM
136Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QRegion &);
138#endif
139
140#ifndef QT_NO_DEBUG_STREAM
141Q_GUI_EXPORT QDebug operator<<(QDebug, const QRegion &);
142#endif
143
145
146#endif // QREGION_H
\inmodule QtGui
Definition qbitmap.h:16
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore\reentrant
Definition qdatastream.h:46
ByteOrder
The byte order used for reading/writing the data.
Definition qdatastream.h:96
\inmodule QtCore
\inmodule QtCore\reentrant
Definition qpoint.h:25
The QPolygon class provides a list of points using integer precision.
Definition qpolygon.h:23
\inmodule QtCore\reentrant
Definition qrect.h:30
The QRegion class specifies a clip region for a painter.
Definition qregion.h:27
const QRect * const_iterator
Definition qregion.h:46
Q_GUI_EXPORT friend bool qt_region_strictContains(const QRegion &region, const QRect &rect)
QRegion(const QRegion &region)
Constructs a new region which is equal to region r.
QRegion united(const QRegion &r) const
QRegion(const QRect &r, RegionType t=Rectangle)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QRect boundingRect() const noexcept
Returns the bounding rectangle of this region.
bool contains(const QRect &r) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
QRegion & operator=(const QRegion &)
Assigns r to this region and returns a reference to the region.
void translate(int dx, int dy)
Translates (moves) the region dx along the X axis and dy along the Y axis.
bool isNull() const
QRegion(const QPolygon &pa, Qt::FillRule fillRule=Qt::OddEvenFill)
Constructs a polygon region from the point array a with the fill rule specified by fillRule.
bool contains(const QPoint &p) const
Returns true if the region contains the point p; otherwise returns false.
const_iterator end() const noexcept
QRegion(QRegion &&other) noexcept
Definition qregion.h:36
QRegion()
Constructs an empty region.
QRegion intersected(const QRect &r) const
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
const_iterator begin() const noexcept
const_reverse_iterator rbegin() const noexcept
Definition qregion.h:53
const_reverse_iterator crbegin() const noexcept
Definition qregion.h:54
bool intersects(const QRect &r) const
QRegion xored(const QRegion &r) const
QRegion intersected(const QRegion &r) const
void translate(const QPoint &p)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qregion.h:62
RegionType
Specifies the shape of the region to be created.
Definition qregion.h:29
QRegion subtracted(const QRegion &r) const
QRegion(const QBitmap &bitmap)
Constructs a region from the bitmap bm.
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition qregion.h:47
QRegion united(const QRect &r) const
const_reverse_iterator rend() const noexcept
Definition qregion.h:55
const_reverse_iterator crend() const noexcept
Definition qregion.h:56
QRegion translated(const QPoint &p) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qregion.h:64
\inmodule QtCore
Definition qvariant.h:65
\inmodule QtCore
Definition qrefcount.h:16
rect
[4]
Combined button and popup list for selecting options.
@ OddEvenFill
static jboolean copy(JNIEnv *, jobject)
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLboolean r
[2]
GLuint GLuint end
GLint ref
GLint y
GLfloat GLfloat GLfloat GLfloat h
GLsizei GLfixed GLfixed GLfixed GLfixed const GLubyte * bitmap
GLdouble GLdouble t
Definition qopenglext.h:243
GLfloat GLfloat p
[1]
GLuint num
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
Definition qrandom.cpp:1220
Q_GUI_EXPORT QDataStream & operator>>(QDataStream &, QRegion &)
Q_GUI_EXPORT QDataStream & operator<<(QDataStream &, const QRegion &)
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
constexpr void qt_ptr_swap(T *&lhs, T *&rhs) noexcept
Definition qswap.h:29
QByteArray ba
[0]
QDataStream & operator<<(QDataStream &out, const MyClass &myObj)
[4]
QDataStream & operator>>(QDataStream &in, MyClass &myObj)
QSharedPointer< T > other(t)
[5]
this swap(other)
dialog exec()