1 /**************************************************************************** 2 ** 3 ** DQt - D bindings for the Qt Toolkit 4 ** 5 ** GNU Lesser General Public License Usage 6 ** This file may be used under the terms of the GNU Lesser 7 ** General Public License version 3 as published by the Free Software 8 ** Foundation and appearing in the file LICENSE.LGPL3 included in the 9 ** packaging of this file. Please review the following information to 10 ** ensure the GNU Lesser General Public License version 3 requirements 11 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 12 ** 13 ****************************************************************************/ 14 module qt.gui.region; 15 extern(C++): 16 17 import qt.config; 18 import qt.core.metatype; 19 import qt.core.namespace; 20 import qt.core.point; 21 import qt.core.rect; 22 import qt.core.refcount; 23 import qt.core.variant; 24 import qt.core.vector; 25 import qt.gui.bitmap; 26 import qt.gui.polygon; 27 import qt.helpers; 28 version(QT_NO_DATASTREAM){}else 29 { 30 import qt.core.bytearray; 31 import qt.core.datastream; 32 } 33 34 /+ #ifndef QT_NO_DATASTREAM 35 #endif 36 37 38 39 template <class T> class QVector; 40 class QVariant; +/ 41 42 struct QRegionPrivate; 43 44 /+ class QBitmap; +/ 45 46 @(QMetaType.Type.QRegion) extern(C++, class) struct /+ Q_GUI_EXPORT +/ QRegion 47 { 48 public: 49 enum RegionType { Rectangle, Ellipse } 50 51 version(Windows) 52 { 53 @disable this(); 54 pragma(mangle, defaultConstructorMangling(__traits(identifier, typeof(this)))) 55 ref typeof(this) rawConstructor(); 56 static typeof(this) create() 57 { 58 typeof(this) r = typeof(this).init; 59 r.rawConstructor(); 60 return r; 61 } 62 } 63 else 64 { 65 static typeof(this) create() 66 { 67 return typeof(this).init; 68 } 69 } 70 71 this(int x, int y, int w, int h, RegionType t = RegionType.Rectangle); 72 this(ref const(QRect) r, RegionType t = RegionType.Rectangle); 73 this(ref const(QPolygon) pa, /+ Qt:: +/qt.core.namespace.FillRule fillRule = /+ Qt:: +/qt.core.namespace.FillRule.OddEvenFill); 74 @disable this(this); 75 this(ref const(QRegion) region); 76 /+ QRegion(QRegion &&other) noexcept 77 : d(other.d) { other.d = const_cast<QRegionData*>(&shared_empty); } +/ 78 this(ref const(QBitmap) bitmap); 79 ~this(); 80 /+ref QRegion operator =(ref const(QRegion) );+/ 81 /+ inline QRegion &operator=(QRegion &&other) noexcept 82 { qSwap(d, other.d); return *this; } +/ 83 /+ inline void swap(QRegion &other) noexcept { qSwap(d, other.d); } +/ 84 bool isEmpty() const; 85 bool isNull() const; 86 87 alias const_iterator = const(QRect)*; 88 /+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator; +/ 89 90 const_iterator begin() const/+ noexcept+/; 91 const_iterator cbegin() const/+ noexcept+/ { return begin(); } 92 const_iterator end() const/+ noexcept+/; 93 const_iterator cend() const/+ noexcept+/ { return end(); } 94 /+ const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } +/ 95 /+ const_reverse_iterator crbegin() const noexcept { return rbegin(); } +/ 96 /+ const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } +/ 97 /+ const_reverse_iterator crend() const noexcept { return rend(); } +/ 98 99 bool contains(ref const(QPoint) p) const; 100 bool contains(ref const(QRect) r) const; 101 102 void translate(int dx, int dy); 103 pragma(inline, true) void translate(ref const(QPoint) p) { translate(p.x(), p.y()); } 104 /+ Q_REQUIRED_RESULT +/ QRegion translated(int dx, int dy) const; 105 /+ Q_REQUIRED_RESULT +/ pragma(inline, true) QRegion translated(ref const(QPoint) p) const { return translated(p.x(), p.y()); } 106 107 /+ Q_REQUIRED_RESULT +/ QRegion united(ref const(QRegion) r) const; 108 /+ Q_REQUIRED_RESULT +/ QRegion united(ref const(QRect) r) const; 109 /+ Q_REQUIRED_RESULT +/ QRegion intersected(ref const(QRegion) r) const; 110 /+ Q_REQUIRED_RESULT +/ QRegion intersected(ref const(QRect) r) const; 111 /+ Q_REQUIRED_RESULT +/ QRegion subtracted(ref const(QRegion) r) const; 112 /+ Q_REQUIRED_RESULT +/ QRegion xored(ref const(QRegion) r) const; 113 114 /+ #if QT_DEPRECATED_SINCE(5, 0) 115 Q_REQUIRED_RESULT inline QT_DEPRECATED QRegion unite(const QRegion &r) const { return united(r); } 116 Q_REQUIRED_RESULT inline QT_DEPRECATED QRegion unite(const QRect &r) const { return united(r); } 117 Q_REQUIRED_RESULT inline QT_DEPRECATED QRegion intersect(const QRegion &r) const { return intersected(r); } 118 Q_REQUIRED_RESULT inline QT_DEPRECATED QRegion intersect(const QRect &r) const { return intersected(r); } 119 Q_REQUIRED_RESULT inline QT_DEPRECATED QRegion subtract(const QRegion &r) const { return subtracted(r); } 120 Q_REQUIRED_RESULT inline QT_DEPRECATED QRegion eor(const QRegion &r) const { return xored(r); } 121 #endif +/ 122 123 bool intersects(ref const(QRegion) r) const; 124 bool intersects(ref const(QRect) r) const; 125 126 QRect boundingRect() const/+ noexcept+/; 127 /+ #if QT_DEPRECATED_SINCE(5, 11) +/ 128 /+ QT_DEPRECATED_X("Use begin()/end() instead") +/ 129 QVector!(QRect) rects() const; 130 /+ #endif +/ 131 void setRects(const(QRect)* rect, int num); 132 int rectCount() const/+ noexcept+/; 133 static if(defined!"Q_COMPILER_MANGLES_RETURN_TYPE") 134 { 135 // ### Qt 6: remove these, they're kept for MSVC compat 136 /+const(QRegion) operator |(ref const(QRegion) r) const;+/ 137 /+const(QRegion) operator +(ref const(QRegion) r) const;+/ 138 /+const(QRegion) operator +(ref const(QRect) r) const;+/ 139 /+const(QRegion) operator &(ref const(QRegion) r) const;+/ 140 /+const(QRegion) operator &(ref const(QRect) r) const;+/ 141 /+const(QRegion) operator -(ref const(QRegion) r) const;+/ 142 /+const(QRegion) operator ^(ref const(QRegion) r) const;+/ 143 } 144 else 145 { 146 /+QRegion operator |(ref const(QRegion) r) const;+/ 147 /+QRegion operator +(ref const(QRegion) r) const;+/ 148 /+QRegion operator +(ref const(QRect) r) const;+/ 149 /+QRegion operator &(ref const(QRegion) r) const;+/ 150 /+QRegion operator &(ref const(QRect) r) const;+/ 151 /+QRegion operator -(ref const(QRegion) r) const;+/ 152 /+QRegion operator ^(ref const(QRegion) r) const;+/ 153 } 154 ref QRegion opOpAssign(string op)(ref const(QRegion) r) if(op == "|"); 155 ref QRegion opOpAssign(string op)(ref const(QRegion) r) if(op == "+"); 156 ref QRegion opOpAssign(string op)(ref const(QRect) r) if(op == "+"); 157 ref QRegion opOpAssign(string op)(ref const(QRegion) r) if(op == "&"); 158 ref QRegion opOpAssign(string op)(ref const(QRect) r) if(op == "&"); 159 ref QRegion opOpAssign(string op)(ref const(QRegion) r) if(op == "-"); 160 /+ref QRegion operator ^=(ref const(QRegion) r);+/ 161 162 /+bool operator ==(ref const(QRegion) r) const;+/ 163 /+pragma(inline, true) bool operator !=(ref const(QRegion) r) const { return !(operator==(r)); }+/ 164 /+auto opCast(T : QVariant)() const;+/ 165 166 version(QT_NO_DATASTREAM){}else 167 { 168 /+ friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QRegion &); +/ 169 /+ friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QRegion &); +/ 170 } 171 private: 172 /+ QRegion copy() const; +/ // helper of detach. 173 void detach(); 174 /+ Q_GUI_EXPORT 175 friend bool qt_region_strictContains(const QRegion ®ion, 176 const QRect &rect); +/ 177 /+ friend struct QRegionPrivate; +/ 178 179 version(QT_NO_DATASTREAM){}else 180 { 181 void exec(ref const(QByteArray) ba, int ver = 0, QDataStream.ByteOrder byteOrder = QDataStream.ByteOrder.BigEndian); 182 } 183 struct QRegionData { 184 /+ QtPrivate:: +/qt.core.refcount.RefCount ref_; 185 QRegionPrivate* qt_rgn; 186 } 187 version(Windows) 188 QRegionData* d; 189 else 190 { 191 union 192 { 193 const(QRegionData)* d2 = &shared_empty; 194 QRegionData* d; 195 } 196 } 197 extern static __gshared const(QRegionData) shared_empty; 198 static void cleanUp(QRegionData* x); 199 } 200 /+ Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QRegion) 201 202 /***************************************************************************** 203 QRegion stream functions 204 *****************************************************************************/ 205 206 #ifndef QT_NO_DATASTREAM 207 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QRegion &); 208 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QRegion &); 209 #endif 210 211 #ifndef QT_NO_DEBUG_STREAM 212 Q_GUI_EXPORT QDebug operator<<(QDebug, const QRegion &); 213 #endif +/ 214