Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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
12#ifndef QT_NO_DATASTREAM
13#include <QtCore/qdatastream.h>
14#endif
15#include <QtCore/qspan.h>
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
31 QRegion();
32 QRegion(int x, int y, int w, int h, RegionType t = Rectangle);
33 QRegion(const QRect &r, RegionType t = Rectangle);
34 QRegion(const QPolygon &pa, Qt::FillRule fillRule = Qt::OddEvenFill);
35 QRegion(const QRegion &region);
36 QRegion(QRegion &&other) noexcept
37 : d(std::exchange(other.d, const_cast<QRegionData*>(&shared_empty))) {}
38 QRegion(const QBitmap &bitmap);
39 ~QRegion();
40 QRegion &operator=(const QRegion &);
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(); }
53 const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); }
54 const_reverse_iterator crbegin() const noexcept { return rbegin(); }
55 const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); }
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 void setRects(QSpan<const QRect> r);
79 QSpan<const QRect> rects() const noexcept;
80 int rectCount() const noexcept;
81
82 QRegion operator|(const QRegion &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 QRect &r) const;
87 QRegion operator-(const QRegion &r) const;
88 QRegion operator^(const QRegion &r) const;
89
90 QRegion& operator|=(const QRegion &r);
91 QRegion& operator+=(const QRegion &r);
92 QRegion& operator+=(const QRect &r);
93 QRegion& operator&=(const QRegion &r);
94 QRegion& operator&=(const QRect &r);
95 QRegion& operator-=(const QRegion &r);
96 QRegion& operator^=(const QRegion &r);
97
98 bool operator==(const QRegion &r) const;
99 inline bool operator!=(const QRegion &r) const { return !(operator==(r)); }
100 operator QVariant() const;
101
102 // Platform specific conversion functions
103#if defined(Q_OS_WIN) || defined(Q_QDOC)
104 HRGN toHRGN() const;
105 static QRegion fromHRGN(HRGN hrgn);
106#endif
107
108#ifndef QT_NO_DATASTREAM
109 friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QRegion &);
110 friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QRegion &);
111#endif
112private:
113 QRegion copy() const; // helper of detach.
114 void detach();
115Q_GUI_EXPORT
116 friend bool qt_region_strictContains(const QRegion &region,
117 const QRect &rect);
118 friend struct QRegionPrivate;
119
120#ifndef QT_NO_DATASTREAM
121 void exec(const QByteArray &ba, int ver = 0, QDataStream::ByteOrder byteOrder = QDataStream::BigEndian);
122#endif
123 struct QRegionData {
124 QtPrivate::RefCount ref = Q_REFCOUNT_INITIALIZE_OWNED;
125 QRegionPrivate *qt_rgn;
126 };
127 struct QRegionData *d;
128 static const struct QRegionData shared_empty;
129 static void cleanUp(QRegionData *x);
130};
132
133/*****************************************************************************
134 QRegion stream functions
135 *****************************************************************************/
136
137#ifndef QT_NO_DATASTREAM
138Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QRegion &);
139Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QRegion &);
140#endif
141
142#ifndef QT_NO_DEBUG_STREAM
143Q_GUI_EXPORT QDebug operator<<(QDebug, const QRegion &);
144#endif
145
146QT_END_NAMESPACE
147
148#endif // QREGION_H
\inmodule QtCore\reentrant
Definition qdatastream.h:50
QPaintEngine * paintEngine() const override
Definition qpicture.cpp:385
void setDpiY(int dpi)
Definition qpicture.cpp:384
int metric(PaintDeviceMetric m) const override
Definition qpicture.cpp:386
void setDpiX(int dpi)
Definition qpicture.cpp:383
The QPainterPathStroker class is used to generate fillable outlines for a given painter path.
void setCurveThreshold(qreal threshold)
Specifies the curve flattening threshold, controlling the granularity with which the generated outlin...
Qt::PenJoinStyle joinStyle() const
Returns the join style of the generated outlines.
QList< qreal > dashPattern() const
Returns the dash pattern for the generated outlines.
QPainterPathStroker(const QPen &pen)
Creates a new stroker based on pen.
void setDashPattern(Qt::PenStyle)
Sets the dash pattern for the generated outlines to style.
qreal miterLimit() const
Returns the miter limit for the generated outlines.
qreal curveThreshold() const
Returns the curve flattening threshold for the generated outlines.
Qt::PenCapStyle capStyle() const
Returns the cap style of the generated outlines.
void setDashPattern(const QList< qreal > &dashPattern)
This is an overloaded member function, provided for convenience. It differs from the above function o...
qreal width() const
Returns the width of the generated outlines.
void setDashOffset(qreal offset)
Sets the dash offset for the generated outlines to offset.
void setCapStyle(Qt::PenCapStyle style)
Sets the cap style of the generated outlines to style.
void setWidth(qreal width)
Sets the width of the generated outline painter path to width.
QPainterPath createStroke(const QPainterPath &path) const
Generates a new path that is a fillable area representing the outline of the given path.
void setJoinStyle(Qt::PenJoinStyle style)
Sets the join style of the generated outlines to style.
qreal dashOffset() const
Returns the dash offset for the generated outlines.
void setMiterLimit(qreal length)
Sets the miter limit of the generated outlines to limit.
\inmodule QtGui
friend class QPaintEngine
Definition qpainter.h:437
The QPolygonF class provides a list of points using floating point precision.
Definition qpolygon.h:96
The QRegion class specifies a clip region for a painter.
Definition qregion.h:27
QDataStream & operator>>(QDataStream &s, QKeyCombination &combination)
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
Definition qdir.cpp:2568
QPainterPath operator*(const QPainterPath &p, const QTransform &m)
static const quint16 mfhdr_maj
Definition qpicture.cpp:95
QT_BEGIN_NAMESPACE void qt_format_text(const QFont &fnt, const QRectF &_r, int tf, int alignment, const QTextOption *opt, const QString &str, QRectF *brect, int tabstops, int *, int tabarraylen, QPainter *painter)
static const quint16 mfhdr_min
Definition qpicture.cpp:96
const char * qt_mfhdr_tag
Definition qpicture.cpp:94