1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the QtCore module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
24 | ** |
25 | ** GNU General Public License Usage |
26 | ** Alternatively, this file may be used under the terms of the GNU |
27 | ** General Public License version 2.0 or (at your option) the GNU General |
28 | ** Public license version 3 or any later version approved by the KDE Free |
29 | ** Qt Foundation. The licenses are as published by the Free Software |
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
31 | ** included in the packaging of this file. Please review the following |
32 | ** information to ensure the GNU General Public License requirements will |
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
35 | ** |
36 | ** $QT_END_LICENSE$ |
37 | ** |
38 | ****************************************************************************/ |
39 | |
40 | #include "qmargins.h" |
41 | #include "qdatastream.h" |
42 | |
43 | #include <private/qdebug_p.h> |
44 | |
45 | QT_BEGIN_NAMESPACE |
46 | |
47 | /*! |
48 | \class QMargins |
49 | \inmodule QtCore |
50 | \ingroup painting |
51 | \since 4.6 |
52 | |
53 | \brief The QMargins class defines the four margins of a rectangle. |
54 | |
55 | QMargin defines a set of four margins; left, top, right and bottom, |
56 | that describe the size of the borders surrounding a rectangle. |
57 | |
58 | The isNull() function returns \c true only if all margins are set to zero. |
59 | |
60 | QMargin objects can be streamed as well as compared. |
61 | */ |
62 | |
63 | |
64 | /***************************************************************************** |
65 | QMargins member functions |
66 | *****************************************************************************/ |
67 | |
68 | /*! |
69 | \fn QMargins::QMargins() |
70 | |
71 | Constructs a margins object with all margins set to 0. |
72 | |
73 | \sa isNull() |
74 | */ |
75 | |
76 | /*! |
77 | \fn QMargins::QMargins(int left, int top, int right, int bottom) |
78 | |
79 | Constructs margins with the given \a left, \a top, \a right, \a bottom |
80 | |
81 | \sa setLeft(), setRight(), setTop(), setBottom() |
82 | */ |
83 | |
84 | /*! |
85 | \fn bool QMargins::isNull() const |
86 | |
87 | Returns \c true if all margins are is 0; otherwise returns |
88 | false. |
89 | */ |
90 | |
91 | |
92 | /*! |
93 | \fn int QMargins::left() const |
94 | |
95 | Returns the left margin. |
96 | |
97 | \sa setLeft() |
98 | */ |
99 | |
100 | /*! |
101 | \fn int QMargins::top() const |
102 | |
103 | Returns the top margin. |
104 | |
105 | \sa setTop() |
106 | */ |
107 | |
108 | /*! |
109 | \fn int QMargins::right() const |
110 | |
111 | Returns the right margin. |
112 | */ |
113 | |
114 | /*! |
115 | \fn int QMargins::bottom() const |
116 | |
117 | Returns the bottom margin. |
118 | */ |
119 | |
120 | |
121 | /*! |
122 | \fn void QMargins::setLeft(int left) |
123 | |
124 | Sets the left margin to \a left. |
125 | */ |
126 | |
127 | /*! |
128 | \fn void QMargins::setTop(int Top) |
129 | |
130 | Sets the Top margin to \a Top. |
131 | */ |
132 | |
133 | /*! |
134 | \fn void QMargins::setRight(int right) |
135 | |
136 | Sets the right margin to \a right. |
137 | */ |
138 | |
139 | /*! |
140 | \fn void QMargins::setBottom(int bottom) |
141 | |
142 | Sets the bottom margin to \a bottom. |
143 | */ |
144 | |
145 | /*! |
146 | \fn bool operator==(const QMargins &m1, const QMargins &m2) |
147 | \relates QMargins |
148 | |
149 | Returns \c true if \a m1 and \a m2 are equal; otherwise returns \c false. |
150 | */ |
151 | |
152 | /*! |
153 | \fn bool operator!=(const QMargins &m1, const QMargins &m2) |
154 | \relates QMargins |
155 | |
156 | Returns \c true if \a m1 and \a m2 are different; otherwise returns \c false. |
157 | */ |
158 | |
159 | /*! |
160 | \fn QMargins operator+(const QMargins &m1, const QMargins &m2) |
161 | \relates QMargins |
162 | |
163 | Returns a QMargins object that is the sum of the given margins, \a m1 |
164 | and \a m2; each component is added separately. |
165 | |
166 | \sa QMargins::operator+=(), QMargins::operator-=() |
167 | |
168 | \since 5.1 |
169 | */ |
170 | |
171 | /*! |
172 | \fn QMargins operator-(const QMargins &m1, const QMargins &m2) |
173 | \relates QMargins |
174 | |
175 | Returns a QMargins object that is formed by subtracting \a m2 from |
176 | \a m1; each component is subtracted separately. |
177 | |
178 | \sa QMargins::operator+=(), QMargins::operator-=() |
179 | |
180 | \since 5.1 |
181 | */ |
182 | |
183 | /*! |
184 | \fn QMargins operator+(const QMargins &lhs, int rhs) |
185 | \relates QMargins |
186 | |
187 | Returns a QMargins object that is formed by adding \a rhs to |
188 | \a lhs. |
189 | |
190 | \sa QMargins::operator+=(), QMargins::operator-=() |
191 | |
192 | \since 5.3 |
193 | */ |
194 | |
195 | /*! |
196 | \fn QMargins operator+(int lhs, const QMargins &rhs) |
197 | \relates QMargins |
198 | |
199 | Returns a QMargins object that is formed by adding \a lhs to |
200 | \a rhs. |
201 | |
202 | \sa QMargins::operator+=(), QMargins::operator-=() |
203 | |
204 | \since 5.3 |
205 | */ |
206 | |
207 | /*! |
208 | \fn QMargins operator-(const QMargins &lhs, int rhs) |
209 | \relates QMargins |
210 | |
211 | Returns a QMargins object that is formed by subtracting \a rhs from |
212 | \a lhs. |
213 | |
214 | \sa QMargins::operator+=(), QMargins::operator-=() |
215 | |
216 | \since 5.3 |
217 | */ |
218 | |
219 | /*! |
220 | \fn QMargins operator*(const QMargins &margins, int factor) |
221 | \relates QMargins |
222 | |
223 | Returns a QMargins object that is formed by multiplying each component |
224 | of the given \a margins by \a factor. |
225 | |
226 | \sa QMargins::operator*=(), QMargins::operator/=() |
227 | |
228 | \since 5.1 |
229 | */ |
230 | |
231 | /*! |
232 | \fn QMargins operator*(int factor, const QMargins &margins) |
233 | \relates QMargins |
234 | \overload |
235 | |
236 | Returns a QMargins object that is formed by multiplying each component |
237 | of the given \a margins by \a factor. |
238 | |
239 | \sa QMargins::operator*=(), QMargins::operator/=() |
240 | |
241 | \since 5.1 |
242 | */ |
243 | |
244 | /*! |
245 | \fn QMargins operator*(const QMargins &margins, qreal factor) |
246 | \relates QMargins |
247 | \overload |
248 | |
249 | Returns a QMargins object that is formed by multiplying each component |
250 | of the given \a margins by \a factor. |
251 | |
252 | \sa QMargins::operator*=(), QMargins::operator/=() |
253 | |
254 | \since 5.1 |
255 | */ |
256 | |
257 | /*! |
258 | \fn QMargins operator*(qreal factor, const QMargins &margins) |
259 | \relates QMargins |
260 | \overload |
261 | |
262 | Returns a QMargins object that is formed by multiplying each component |
263 | of the given \a margins by \a factor. |
264 | |
265 | \sa QMargins::operator*=(), QMargins::operator/=() |
266 | |
267 | \since 5.1 |
268 | */ |
269 | |
270 | /*! |
271 | \fn QMargins operator/(const QMargins &margins, int divisor) |
272 | \relates QMargins |
273 | |
274 | Returns a QMargins object that is formed by dividing the components of |
275 | the given \a margins by the given \a divisor. |
276 | |
277 | \sa QMargins::operator*=(), QMargins::operator/=() |
278 | |
279 | \since 5.1 |
280 | */ |
281 | |
282 | /*! |
283 | \fn QMargins operator/(const QMargins &, qreal) |
284 | \relates QMargins |
285 | \overload |
286 | |
287 | Returns a QMargins object that is formed by dividing the components of |
288 | the given \a margins by the given \a divisor. |
289 | |
290 | \sa QMargins::operator*=(), QMargins::operator/=() |
291 | |
292 | \since 5.1 |
293 | */ |
294 | |
295 | /*! |
296 | \fn QMargins operator+(const QMargins &margins) |
297 | \relates QMargins |
298 | |
299 | Returns a QMargin object that is formed from all components of \a margins. |
300 | |
301 | \since 5.3 |
302 | */ |
303 | |
304 | /*! |
305 | \fn QMargins operator-(const QMargins &margins) |
306 | \relates QMargins |
307 | |
308 | Returns a QMargin object that is formed by negating all components of \a margins. |
309 | |
310 | \since 5.1 |
311 | */ |
312 | |
313 | /*! |
314 | \fn QMargins operator|(const QMargins &m1, const QMargins &m2) |
315 | \relates QMargins |
316 | |
317 | Returns a QMargins object that is formed from the maximum of each |
318 | component of \a m2 and \a m1. |
319 | |
320 | \sa QMargins::operator+=(), QMargins::operator-=() |
321 | |
322 | \since 6.0 |
323 | */ |
324 | |
325 | /*! |
326 | \fn QMargins &QMargins::operator+=(const QMargins &margins) |
327 | |
328 | Add each component of \a margins to the respective component of this object |
329 | and returns a reference to it. |
330 | |
331 | \sa operator-=() |
332 | |
333 | \since 5.1 |
334 | */ |
335 | |
336 | /*! |
337 | \fn QMargins &QMargins::operator-=(const QMargins &margins) |
338 | |
339 | Subtract each component of \a margins from the respective component of this object |
340 | and returns a reference to it. |
341 | |
342 | \sa operator+=() |
343 | |
344 | \since 5.1 |
345 | */ |
346 | |
347 | /*! |
348 | \fn QMargins &QMargins::operator+=(int addend) |
349 | \overload |
350 | |
351 | Adds the \a addend to each component of this object |
352 | and returns a reference to it. |
353 | |
354 | \sa operator-=() |
355 | */ |
356 | |
357 | /*! |
358 | \fn QMargins &QMargins::operator-=(int subtrahend) |
359 | \overload |
360 | |
361 | Subtracts the \a subtrahend from each component of this object |
362 | and returns a reference to it. |
363 | |
364 | \sa operator+=() |
365 | */ |
366 | |
367 | /*! |
368 | \fn QMargins &QMargins::operator*=(int factor) |
369 | |
370 | Multiplies each component of this object by \a factor |
371 | and returns a reference to it. |
372 | |
373 | \sa operator/=() |
374 | |
375 | \since 5.1 |
376 | */ |
377 | |
378 | /*! |
379 | \fn QMargins &QMargins::operator*=(qreal factor) |
380 | \overload |
381 | |
382 | Multiplies each component of this object by \a factor |
383 | and returns a reference to it. |
384 | |
385 | \sa operator/=() |
386 | |
387 | \since 5.1 |
388 | */ |
389 | |
390 | /*! |
391 | \fn QMargins &QMargins::operator/=(int divisor) |
392 | |
393 | Divides each component of this object by \a divisor |
394 | and returns a reference to it. |
395 | |
396 | \sa operator*=() |
397 | |
398 | \since 5.1 |
399 | */ |
400 | |
401 | /*! |
402 | \fn QMargins &QMargins::operator/=(qreal divisor) |
403 | |
404 | \overload |
405 | |
406 | \sa operator*=() |
407 | |
408 | \since 5.1 |
409 | */ |
410 | |
411 | /***************************************************************************** |
412 | QMargins stream functions |
413 | *****************************************************************************/ |
414 | #ifndef QT_NO_DATASTREAM |
415 | /*! |
416 | \fn QDataStream &operator<<(QDataStream &stream, const QMargins &m) |
417 | \relates QMargins |
418 | |
419 | Writes margin \a m to the given \a stream and returns a |
420 | reference to the stream. |
421 | |
422 | \sa {Serializing Qt Data Types} |
423 | */ |
424 | |
425 | QDataStream &operator<<(QDataStream &s, const QMargins &m) |
426 | { |
427 | s << m.left() << m.top() << m.right() << m.bottom(); |
428 | return s; |
429 | } |
430 | |
431 | /*! |
432 | \fn QDataStream &operator>>(QDataStream &stream, QMargins &m) |
433 | \relates QMargins |
434 | |
435 | Reads a margin from the given \a stream into margin \a m |
436 | and returns a reference to the stream. |
437 | |
438 | \sa {Serializing Qt Data Types} |
439 | */ |
440 | |
441 | QDataStream &operator>>(QDataStream &s, QMargins &m) |
442 | { |
443 | int left, top, right, bottom; |
444 | s >> left; m.setLeft(left); |
445 | s >> top; m.setTop(top); |
446 | s >> right; m.setRight(right); |
447 | s >> bottom; m.setBottom(bottom); |
448 | return s; |
449 | } |
450 | #endif // QT_NO_DATASTREAM |
451 | |
452 | #ifndef QT_NO_DEBUG_STREAM |
453 | QDebug operator<<(QDebug dbg, const QMargins &m) |
454 | { |
455 | QDebugStateSaver saver(dbg); |
456 | dbg.nospace(); |
457 | dbg << "QMargins" << '('; |
458 | QtDebugUtils::formatQMargins(dbg, m); |
459 | dbg << ')'; |
460 | return dbg; |
461 | } |
462 | #endif |
463 | |
464 | /*! |
465 | \class QMarginsF |
466 | \inmodule QtCore |
467 | \ingroup painting |
468 | \since 5.3 |
469 | |
470 | \brief The QMarginsF class defines the four margins of a rectangle. |
471 | |
472 | QMarginsF defines a set of four margins; left, top, right and bottom, |
473 | that describe the size of the borders surrounding a rectangle. |
474 | |
475 | The isNull() function returns \c true only if all margins are set to zero. |
476 | |
477 | QMarginsF objects can be streamed as well as compared. |
478 | */ |
479 | |
480 | |
481 | /***************************************************************************** |
482 | QMarginsF member functions |
483 | *****************************************************************************/ |
484 | |
485 | /*! |
486 | \fn QMarginsF::QMarginsF() |
487 | |
488 | Constructs a margins object with all margins set to 0. |
489 | |
490 | \sa isNull() |
491 | */ |
492 | |
493 | /*! |
494 | \fn QMarginsF::QMarginsF(qreal left, qreal top, qreal right, qreal bottom) |
495 | |
496 | Constructs margins with the given \a left, \a top, \a right, \a bottom |
497 | |
498 | \sa setLeft(), setRight(), setTop(), setBottom() |
499 | */ |
500 | |
501 | /*! |
502 | \fn QMarginsF::QMarginsF(const QMargins &margins) |
503 | |
504 | Constructs margins copied from the given \a margins |
505 | */ |
506 | |
507 | /*! |
508 | \fn bool QMarginsF::isNull() const |
509 | |
510 | Returns \c true if all margins are 0; otherwise returns |
511 | false. |
512 | */ |
513 | |
514 | |
515 | /*! |
516 | \fn qreal QMarginsF::left() const |
517 | |
518 | Returns the left margin. |
519 | |
520 | \sa setLeft() |
521 | */ |
522 | |
523 | /*! |
524 | \fn qreal QMarginsF::top() const |
525 | |
526 | Returns the top margin. |
527 | |
528 | \sa setTop() |
529 | */ |
530 | |
531 | /*! |
532 | \fn qreal QMarginsF::right() const |
533 | |
534 | Returns the right margin. |
535 | */ |
536 | |
537 | /*! |
538 | \fn qreal QMarginsF::bottom() const |
539 | |
540 | Returns the bottom margin. |
541 | */ |
542 | |
543 | |
544 | /*! |
545 | \fn void QMarginsF::setLeft(qreal left) |
546 | |
547 | Sets the left margin to \a left. |
548 | */ |
549 | |
550 | /*! |
551 | \fn void QMarginsF::setTop(qreal Top) |
552 | |
553 | Sets the Top margin to \a Top. |
554 | */ |
555 | |
556 | /*! |
557 | \fn void QMarginsF::setRight(qreal right) |
558 | |
559 | Sets the right margin to \a right. |
560 | */ |
561 | |
562 | /*! |
563 | \fn void QMarginsF::setBottom(qreal bottom) |
564 | |
565 | Sets the bottom margin to \a bottom. |
566 | */ |
567 | |
568 | /*! |
569 | \fn bool operator==(const QMarginsF &lhs, const QMarginsF &rhs) |
570 | \relates QMarginsF |
571 | |
572 | Returns \c true if \a lhs and \a rhs are equal; otherwise returns \c false. |
573 | */ |
574 | |
575 | /*! |
576 | \fn bool operator!=(const QMarginsF &lhs, const QMarginsF &rhs) |
577 | \relates QMarginsF |
578 | |
579 | Returns \c true if \a lhs and \a rhs are different; otherwise returns \c false. |
580 | */ |
581 | |
582 | /*! |
583 | \fn const QMarginsF operator+(const QMarginsF &lhs, const QMarginsF &rhs) |
584 | \relates QMarginsF |
585 | |
586 | Returns a QMarginsF object that is the sum of the given margins, \a lhs |
587 | and \a rhs; each component is added separately. |
588 | |
589 | \sa QMarginsF::operator+=(), QMarginsF::operator-=() |
590 | */ |
591 | |
592 | /*! |
593 | \fn const QMarginsF operator-(const QMarginsF &lhs, const QMarginsF &rhs) |
594 | \relates QMarginsF |
595 | |
596 | Returns a QMarginsF object that is formed by subtracting \a rhs from |
597 | \a lhs; each component is subtracted separately. |
598 | |
599 | \sa QMarginsF::operator+=(), QMarginsF::operator-=() |
600 | */ |
601 | |
602 | /*! |
603 | \fn const QMarginsF operator+(const QMarginsF &lhs, qreal rhs) |
604 | \relates QMarginsF |
605 | |
606 | Returns a QMarginsF object that is formed by adding \a rhs to |
607 | \a lhs. |
608 | |
609 | \sa QMarginsF::operator+=(), QMarginsF::operator-=() |
610 | */ |
611 | |
612 | /*! |
613 | \fn const QMarginsF operator+(qreal lhs, const QMarginsF &rhs) |
614 | \relates QMarginsF |
615 | |
616 | Returns a QMarginsF object that is formed by adding \a lhs to |
617 | \a rhs. |
618 | |
619 | \sa QMarginsF::operator+=(), QMarginsF::operator-=() |
620 | */ |
621 | |
622 | /*! |
623 | \fn const QMarginsF operator-(const QMarginsF &lhs, qreal rhs) |
624 | \relates QMarginsF |
625 | |
626 | Returns a QMarginsF object that is formed by subtracting \a rhs from |
627 | \a lhs. |
628 | |
629 | \sa QMarginsF::operator+=(), QMarginsF::operator-=() |
630 | */ |
631 | |
632 | /*! |
633 | \fn const QMarginsF operator*(const QMarginsF &lhs, qreal rhs) |
634 | \relates QMarginsF |
635 | \overload |
636 | |
637 | Returns a QMarginsF object that is formed by multiplying each component |
638 | of the given \a lhs margins by \a rhs factor. |
639 | |
640 | \sa QMarginsF::operator*=(), QMarginsF::operator/=() |
641 | */ |
642 | |
643 | /*! |
644 | \fn const QMarginsF operator*(qreal lhs, const QMarginsF &rhs) |
645 | \relates QMarginsF |
646 | \overload |
647 | |
648 | Returns a QMarginsF object that is formed by multiplying each component |
649 | of the given \a lhs margins by \a rhs factor. |
650 | |
651 | \sa QMarginsF::operator*=(), QMarginsF::operator/=() |
652 | */ |
653 | |
654 | /*! |
655 | \fn const QMarginsF operator/(const QMarginsF &lhs, qreal rhs) |
656 | \relates QMarginsF |
657 | \overload |
658 | |
659 | Returns a QMarginsF object that is formed by dividing the components of |
660 | the given \a lhs margins by the given \a rhs divisor. |
661 | |
662 | \sa QMarginsF::operator*=(), QMarginsF::operator/=() |
663 | */ |
664 | |
665 | /*! |
666 | \fn QMarginsF operator|(const QMarginsF &m1, const QMarginsF &m2) |
667 | \relates QMarginsF |
668 | \overload |
669 | |
670 | Returns a QMarginsF object that is formed from the maximum of each |
671 | component of \a m2 and \a m1. |
672 | |
673 | \sa QMarginsF::operator+=(), QMarginsF::operator-=() |
674 | |
675 | \since 6.0 |
676 | */ |
677 | |
678 | /*! |
679 | \fn QMarginsF operator+(const QMarginsF &margins) |
680 | \relates QMarginsF |
681 | |
682 | Returns a QMargin object that is formed from all components of \a margins. |
683 | */ |
684 | |
685 | /*! |
686 | \fn QMarginsF operator-(const QMarginsF &margins) |
687 | \relates QMarginsF |
688 | |
689 | Returns a QMargin object that is formed by negating all components of \a margins. |
690 | */ |
691 | |
692 | /*! |
693 | \fn QMarginsF &QMarginsF::operator+=(const QMarginsF &margins) |
694 | |
695 | Add each component of \a margins to the respective component of this object |
696 | and returns a reference to it. |
697 | |
698 | \sa operator-=() |
699 | */ |
700 | |
701 | /*! |
702 | \fn QMarginsF &QMarginsF::operator-=(const QMarginsF &margins) |
703 | |
704 | Subtract each component of \a margins from the respective component of this object |
705 | and returns a reference to it. |
706 | |
707 | \sa operator+=() |
708 | */ |
709 | |
710 | /*! |
711 | \fn QMarginsF &QMarginsF::operator+=(qreal addend) |
712 | \overload |
713 | |
714 | Adds the \a addend to each component of this object |
715 | and returns a reference to it. |
716 | |
717 | \sa operator-=() |
718 | */ |
719 | |
720 | /*! |
721 | \fn QMarginsF &QMarginsF::operator-=(qreal subtrahend) |
722 | \overload |
723 | |
724 | Subtracts the \a subtrahend from each component of this object |
725 | and returns a reference to it. |
726 | |
727 | \sa operator+=() |
728 | */ |
729 | |
730 | /*! |
731 | \fn QMarginsF &QMarginsF::operator*=(qreal factor) |
732 | |
733 | Multiplies each component of this object by \a factor |
734 | and returns a reference to it. |
735 | |
736 | \sa operator/=() |
737 | */ |
738 | |
739 | /*! |
740 | \fn QMarginsF &QMarginsF::operator/=(qreal divisor) |
741 | |
742 | Divides each component of this object by \a divisor |
743 | and returns a reference to it. |
744 | |
745 | \sa operator*=() |
746 | */ |
747 | |
748 | /*! |
749 | \fn QMargins QMarginsF::toMargins() const |
750 | |
751 | Returns an integer based copy of this margins object. |
752 | |
753 | Note that the components in the returned margins will be rounded to |
754 | the nearest integer. |
755 | |
756 | \sa QMarginsF() |
757 | */ |
758 | |
759 | /***************************************************************************** |
760 | QMarginsF stream functions |
761 | *****************************************************************************/ |
762 | #ifndef QT_NO_DATASTREAM |
763 | /*! |
764 | \fn QDataStream &operator<<(QDataStream &stream, const QMarginsF &m) |
765 | \relates QMarginsF |
766 | |
767 | Writes margin \a m to the given \a stream and returns a |
768 | reference to the stream. |
769 | |
770 | \sa {Serializing Qt Data Types} |
771 | */ |
772 | |
773 | QDataStream &operator<<(QDataStream &s, const QMarginsF &m) |
774 | { |
775 | s << double(m.left()) << double(m.top()) << double(m.right()) << double(m.bottom()); |
776 | return s; |
777 | } |
778 | |
779 | /*! |
780 | \fn QDataStream &operator>>(QDataStream &stream, QMarginsF &m) |
781 | \relates QMarginsF |
782 | |
783 | Reads a margin from the given \a stream into margin \a m |
784 | and returns a reference to the stream. |
785 | |
786 | \sa {Serializing Qt Data Types} |
787 | */ |
788 | |
789 | QDataStream &operator>>(QDataStream &s, QMarginsF &m) |
790 | { |
791 | double left, top, right, bottom; |
792 | s >> left; |
793 | s >> top; |
794 | s >> right; |
795 | s >> bottom; |
796 | m = QMarginsF(qreal(left), qreal(top), qreal(right), qreal(bottom)); |
797 | return s; |
798 | } |
799 | #endif // QT_NO_DATASTREAM |
800 | |
801 | #ifndef QT_NO_DEBUG_STREAM |
802 | QDebug operator<<(QDebug dbg, const QMarginsF &m) |
803 | { |
804 | QDebugStateSaver saver(dbg); |
805 | dbg.nospace(); |
806 | dbg << "QMarginsF" << '('; |
807 | QtDebugUtils::formatQMargins(dbg, m); |
808 | dbg << ')'; |
809 | return dbg; |
810 | } |
811 | #endif |
812 | |
813 | QT_END_NAMESPACE |
814 | |