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.core.margins;
15 extern(C++):
16 
17 import qt.config;
18 import qt.core.global;
19 import qt.core.typeinfo;
20 import qt.helpers;
21 
22 /*****************************************************************************
23   QMargins class
24  *****************************************************************************/
25 
26 @Q_MOVABLE_TYPE extern(C++, class) struct QMargins
27 {
28 public:
29     /+pragma(inline, true) this()/+ noexcept+/
30     {
31         this.m_left = 0;
32         this.m_top = 0;
33         this.m_right = 0;
34         this.m_bottom = 0;
35     }+/
36     pragma(inline, true) this(int aleft, int atop, int aright, int abottom)/+ noexcept+/
37     {
38         this.m_left = aleft;
39         this.m_top = atop;
40         this.m_right = aright;
41         this.m_bottom = abottom;
42     }
43 
44     pragma(inline, true) bool isNull() const/+ noexcept+/
45     { return m_left==0 && m_top==0 && m_right==0 && m_bottom==0; }
46 
47     pragma(inline, true) int left() const/+ noexcept+/
48     { return m_left; }
49     pragma(inline, true) int top() const/+ noexcept+/
50     { return m_top; }
51     pragma(inline, true) int right() const/+ noexcept+/
52     { return m_right; }
53     pragma(inline, true) int bottom() const/+ noexcept+/
54     { return m_bottom; }
55 
56     pragma(inline, true) void setLeft(int aleft)/+ noexcept+/
57     { m_left = aleft; }
58     pragma(inline, true) void setTop(int atop)/+ noexcept+/
59     { m_top = atop; }
60     pragma(inline, true) void setRight(int aright)/+ noexcept+/
61     { m_right = aright; }
62     pragma(inline, true) void setBottom(int abottom)/+ noexcept+/
63     { m_bottom = abottom; }
64 
65     pragma(inline, true) ref QMargins opOpAssign(string op)(ref const(QMargins) margins)/+ noexcept+/ if(op == "+")
66     {
67         return (){return this = this + margins;
68     }();
69     }
70     pragma(inline, true) ref QMargins opOpAssign(string op)(ref const(QMargins) margins)/+ noexcept+/ if(op == "-")
71     {
72         return (){return this = this - margins;
73     }();
74     }
75     pragma(inline, true) ref QMargins opOpAssign(string op)(int margin)/+ noexcept+/ if(op == "+")
76     {
77         m_left += margin;
78         m_top += margin;
79         m_right += margin;
80         m_bottom += margin;
81         return this;
82     }
83     pragma(inline, true) ref QMargins opOpAssign(string op)(int margin)/+ noexcept+/ if(op == "-")
84     {
85         m_left -= margin;
86         m_top -= margin;
87         m_right -= margin;
88         m_bottom -= margin;
89         return this;
90     }
91     /+pragma(inline, true) ref QMargins operator *=(int factor)/+ noexcept+/
92     {
93         return (){return this = this * factor;
94     }();
95     }+/
96     /+pragma(inline, true) ref QMargins operator /=(int divisor)
97     {
98         return (){return this = this / divisor;
99     }();
100     }+/
101     /+pragma(inline, true) ref QMargins operator *=(qreal factor)/+ noexcept+/
102     {
103         return (){return this = this * factor;
104     }();
105     }+/
106     /+pragma(inline, true) ref QMargins operator /=(qreal divisor)
107     {
108         return (){return this = this / divisor;
109     }();
110     }+/
111 
112 private:
113     int m_left = 0;
114     int m_top = 0;
115     int m_right = 0;
116     int m_bottom = 0;
117 
118     /+ friend inline bool operator==(const QMargins &, const QMargins &) noexcept; +/
119     /+ friend inline bool operator!=(const QMargins &, const QMargins &) noexcept; +/
120 }
121 
122 /+ Q_DECLARE_TYPEINFO(QMargins, Q_MOVABLE_TYPE);
123 
124 /*****************************************************************************
125   QMargins stream functions
126  *****************************************************************************/
127 #ifndef QT_NO_DATASTREAM
128 Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QMargins &);
129 Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QMargins &);
130 #endif +/
131 
132 /*****************************************************************************
133   QMargins inline functions
134  *****************************************************************************/
135 
136 
137 /+pragma(inline, true) bool operator ==(ref const(QMargins) m1, ref const(QMargins) m2)/+ noexcept+/
138 {
139     return
140             m1.m_left == m2.m_left &&
141             m1.m_top == m2.m_top &&
142             m1.m_right == m2.m_right &&
143             m1.m_bottom == m2.m_bottom;
144 }+/
145 
146 /+pragma(inline, true) bool operator !=(ref const(QMargins) m1, ref const(QMargins) m2)/+ noexcept+/
147 {
148     return
149             m1.m_left != m2.m_left ||
150             m1.m_top != m2.m_top ||
151             m1.m_right != m2.m_right ||
152             m1.m_bottom != m2.m_bottom;
153 }+/
154 
155 /+pragma(inline, true) QMargins operator +(ref const(QMargins) m1, ref const(QMargins) m2)/+ noexcept+/
156 {
157     return QMargins(m1.left() + m2.left(), m1.top() + m2.top(),
158                     m1.right() + m2.right(), m1.bottom() + m2.bottom());
159 }+/
160 
161 /+pragma(inline, true) QMargins operator -(ref const(QMargins) m1, ref const(QMargins) m2)/+ noexcept+/
162 {
163     return QMargins(m1.left() - m2.left(), m1.top() - m2.top(),
164                     m1.right() - m2.right(), m1.bottom() - m2.bottom());
165 }+/
166 
167 /+pragma(inline, true) QMargins operator +(ref const(QMargins) lhs, int rhs)/+ noexcept+/
168 {
169     return QMargins(lhs.left() + rhs, lhs.top() + rhs,
170                     lhs.right() + rhs, lhs.bottom() + rhs);
171 }+/
172 
173 /+pragma(inline, true) QMargins operator +(int lhs, ref const(QMargins) rhs)/+ noexcept+/
174 {
175     return QMargins(rhs.left() + lhs, rhs.top() + lhs,
176                     rhs.right() + lhs, rhs.bottom() + lhs);
177 }+/
178 
179 /+pragma(inline, true) QMargins operator -(ref const(QMargins) lhs, int rhs)/+ noexcept+/
180 {
181     return QMargins(lhs.left() - rhs, lhs.top() - rhs,
182                     lhs.right() - rhs, lhs.bottom() - rhs);
183 }+/
184 
185 /+pragma(inline, true) QMargins operator *(ref const(QMargins) margins, int factor)/+ noexcept+/
186 {
187     return QMargins(margins.left() * factor, margins.top() * factor,
188                     margins.right() * factor, margins.bottom() * factor);
189 }+/
190 
191 /+pragma(inline, true) QMargins operator *(int factor, ref const(QMargins) margins)/+ noexcept+/
192 {
193     return QMargins(margins.left() * factor, margins.top() * factor,
194                     margins.right() * factor, margins.bottom() * factor);
195 }+/
196 
197 /+pragma(inline, true) QMargins operator *(ref const(QMargins) margins, qreal factor)/+ noexcept+/
198 {
199     return QMargins(qRound(margins.left() * factor), qRound(margins.top() * factor),
200                     qRound(margins.right() * factor), qRound(margins.bottom() * factor));
201 }+/
202 
203 /+pragma(inline, true) QMargins operator *(qreal factor, ref const(QMargins) margins)/+ noexcept+/
204 {
205     return QMargins(qRound(margins.left() * factor), qRound(margins.top() * factor),
206                     qRound(margins.right() * factor), qRound(margins.bottom() * factor));
207 }+/
208 
209 /+pragma(inline, true) QMargins operator /(ref const(QMargins) margins, int divisor)
210 {
211     return QMargins(margins.left() / divisor, margins.top() / divisor,
212                     margins.right() / divisor, margins.bottom() / divisor);
213 }+/
214 
215 /+pragma(inline, true) QMargins operator /(ref const(QMargins) margins, qreal divisor)
216 {
217     return QMargins(qRound(margins.left() / divisor), qRound(margins.top() / divisor),
218                     qRound(margins.right() / divisor), qRound(margins.bottom() / divisor));
219 }+/
220 
221 /+pragma(inline, true) QMargins operator +(ref const(QMargins) margins)/+ noexcept+/
222 {
223     return margins;
224 }+/
225 
226 /+pragma(inline, true) QMargins operator -(ref const(QMargins) margins)/+ noexcept+/
227 {
228     return QMargins(-margins.left(), -margins.top(), -margins.right(), -margins.bottom());
229 }+/
230 
231 /+ #ifndef QT_NO_DEBUG_STREAM
232 Q_CORE_EXPORT QDebug operator<<(QDebug, const QMargins &);
233 #endif +/
234 
235 /*****************************************************************************
236   QMarginsF class
237  *****************************************************************************/
238 
239 @Q_MOVABLE_TYPE extern(C++, class) struct QMarginsF
240 {
241 public:
242     /+pragma(inline, true) this()/+ noexcept+/
243     {
244         this.m_left = 0;
245         this.m_top = 0;
246         this.m_right = 0;
247         this.m_bottom = 0;
248     }+/
249     pragma(inline, true) this(qreal aleft, qreal atop, qreal aright, qreal abottom)/+ noexcept+/
250     {
251         this.m_left = aleft;
252         this.m_top = atop;
253         this.m_right = aright;
254         this.m_bottom = abottom;
255     }
256     pragma(inline, true) this(ref const(QMargins) margins)/+ noexcept+/
257     {
258         this.m_left = margins.left();
259         this.m_top = margins.top();
260         this.m_right = margins.right();
261         this.m_bottom = margins.bottom();
262     }
263 
264     pragma(inline, true) bool isNull() const/+ noexcept+/
265     { return qFuzzyIsNull(m_left) && qFuzzyIsNull(m_top) && qFuzzyIsNull(m_right) && qFuzzyIsNull(m_bottom); }
266 
267     pragma(inline, true) qreal left() const/+ noexcept+/
268     { return m_left; }
269     pragma(inline, true) qreal top() const/+ noexcept+/
270     { return m_top; }
271     pragma(inline, true) qreal right() const/+ noexcept+/
272     { return m_right; }
273     pragma(inline, true) qreal bottom() const/+ noexcept+/
274     { return m_bottom; }
275 
276     pragma(inline, true) void setLeft(qreal aleft)/+ noexcept+/
277     { m_left = aleft; }
278     pragma(inline, true) void setTop(qreal atop)/+ noexcept+/
279     { m_top = atop; }
280     pragma(inline, true) void setRight(qreal aright)/+ noexcept+/
281     { m_right = aright; }
282     pragma(inline, true) void setBottom(qreal abottom)/+ noexcept+/
283     { m_bottom = abottom; }
284 
285     pragma(inline, true) ref QMarginsF opOpAssign(string op)(ref const(QMarginsF) margins)/+ noexcept+/ if(op == "+")
286     {
287         return (){return this = this + margins;
288     }();
289     }
290     pragma(inline, true) ref QMarginsF opOpAssign(string op)(ref const(QMarginsF) margins)/+ noexcept+/ if(op == "-")
291     {
292         return (){return this = this - margins;
293     }();
294     }
295     pragma(inline, true) ref QMarginsF opOpAssign(string op)(qreal addend)/+ noexcept+/ if(op == "+")
296     {
297         m_left += addend;
298         m_top += addend;
299         m_right += addend;
300         m_bottom += addend;
301         return this;
302     }
303     pragma(inline, true) ref QMarginsF opOpAssign(string op)(qreal subtrahend)/+ noexcept+/ if(op == "-")
304     {
305         m_left -= subtrahend;
306         m_top -= subtrahend;
307         m_right -= subtrahend;
308         m_bottom -= subtrahend;
309         return this;
310     }
311     /+pragma(inline, true) ref QMarginsF operator *=(qreal factor)/+ noexcept+/
312     {
313         return (){return this = this * factor;
314     }();
315     }+/
316     /+pragma(inline, true) ref QMarginsF operator /=(qreal divisor)
317     {
318         return (){return this = this / divisor;
319     }();
320     }+/
321 
322     pragma(inline, true) QMargins toMargins() const/+ noexcept+/
323     {
324         return QMargins(qRound(m_left), qRound(m_top), qRound(m_right), qRound(m_bottom));
325     }
326 
327 private:
328     qreal m_left = 0;
329     qreal m_top = 0;
330     qreal m_right = 0;
331     qreal m_bottom = 0;
332 }
333 
334 /+ Q_DECLARE_TYPEINFO(QMarginsF, Q_MOVABLE_TYPE);
335 
336 /*****************************************************************************
337   QMarginsF stream functions
338  *****************************************************************************/
339 
340 #ifndef QT_NO_DATASTREAM
341 Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QMarginsF &);
342 Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QMarginsF &);
343 #endif +/
344 
345 /*****************************************************************************
346   QMarginsF inline functions
347  *****************************************************************************/
348 
349 
350 /+pragma(inline, true) bool operator ==(ref const(QMarginsF) lhs, ref const(QMarginsF) rhs)/+ noexcept+/
351 {
352     return qFuzzyCompare(lhs.left(), rhs.left())
353            && qFuzzyCompare(lhs.top(), rhs.top())
354            && qFuzzyCompare(lhs.right(), rhs.right())
355            && qFuzzyCompare(lhs.bottom(), rhs.bottom());
356 }+/
357 
358 /+pragma(inline, true) bool operator !=(ref const(QMarginsF) lhs, ref const(QMarginsF) rhs)/+ noexcept+/
359 {
360     return !operator==(lhs, rhs);
361 }+/
362 
363 /+pragma(inline, true) QMarginsF operator +(ref const(QMarginsF) lhs, ref const(QMarginsF) rhs)/+ noexcept+/
364 {
365     return QMarginsF(lhs.left() + rhs.left(), lhs.top() + rhs.top(),
366                      lhs.right() + rhs.right(), lhs.bottom() + rhs.bottom());
367 }+/
368 
369 /+pragma(inline, true) QMarginsF operator -(ref const(QMarginsF) lhs, ref const(QMarginsF) rhs)/+ noexcept+/
370 {
371     return QMarginsF(lhs.left() - rhs.left(), lhs.top() - rhs.top(),
372                      lhs.right() - rhs.right(), lhs.bottom() - rhs.bottom());
373 }+/
374 
375 /+pragma(inline, true) QMarginsF operator +(ref const(QMarginsF) lhs, qreal rhs)/+ noexcept+/
376 {
377     return QMarginsF(lhs.left() + rhs, lhs.top() + rhs,
378                      lhs.right() + rhs, lhs.bottom() + rhs);
379 }+/
380 
381 /+pragma(inline, true) QMarginsF operator +(qreal lhs, ref const(QMarginsF) rhs)/+ noexcept+/
382 {
383     return QMarginsF(rhs.left() + lhs, rhs.top() + lhs,
384                      rhs.right() + lhs, rhs.bottom() + lhs);
385 }+/
386 
387 /+pragma(inline, true) QMarginsF operator -(ref const(QMarginsF) lhs, qreal rhs)/+ noexcept+/
388 {
389     return QMarginsF(lhs.left() - rhs, lhs.top() - rhs,
390                      lhs.right() - rhs, lhs.bottom() - rhs);
391 }+/
392 
393 /+pragma(inline, true) QMarginsF operator *(ref const(QMarginsF) lhs, qreal rhs)/+ noexcept+/
394 {
395     return QMarginsF(lhs.left() * rhs, lhs.top() * rhs,
396                      lhs.right() * rhs, lhs.bottom() * rhs);
397 }+/
398 
399 /+pragma(inline, true) QMarginsF operator *(qreal lhs, ref const(QMarginsF) rhs)/+ noexcept+/
400 {
401     return QMarginsF(rhs.left() * lhs, rhs.top() * lhs,
402                      rhs.right() * lhs, rhs.bottom() * lhs);
403 }+/
404 
405 /+pragma(inline, true) QMarginsF operator /(ref const(QMarginsF) lhs, qreal divisor)
406 {
407     return QMarginsF(lhs.left() / divisor, lhs.top() / divisor,
408                      lhs.right() / divisor, lhs.bottom() / divisor);
409 }+/
410 
411 /+pragma(inline, true) QMarginsF operator +(ref const(QMarginsF) margins)/+ noexcept+/
412 {
413     return margins;
414 }+/
415 
416 /+pragma(inline, true) QMarginsF operator -(ref const(QMarginsF) margins)/+ noexcept+/
417 {
418     return QMarginsF(-margins.left(), -margins.top(), -margins.right(), -margins.bottom());
419 }+/
420 
421 /+ #ifndef QT_NO_DEBUG_STREAM
422 Q_CORE_EXPORT QDebug operator<<(QDebug, const QMarginsF &);
423 #endif +/
424