1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtCore module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
45 #include <QtCore/qnamespace.h>
55 Q_DECL_CONSTEXPR QMargins();
56 Q_DECL_CONSTEXPR QMargins(int left, int top, int right, int bottom);
58 Q_DECL_CONSTEXPR bool isNull() const;
60 Q_DECL_CONSTEXPR int left() const;
61 Q_DECL_CONSTEXPR int top() const;
62 Q_DECL_CONSTEXPR int right() const;
63 Q_DECL_CONSTEXPR int bottom() const;
65 void setLeft(int left);
67 void setRight(int right);
68 void setBottom(int bottom);
76 friend Q_DECL_CONSTEXPR inline bool operator==(const QMargins &, const QMargins &);
77 friend Q_DECL_CONSTEXPR inline bool operator!=(const QMargins &, const QMargins &);
80 Q_DECLARE_TYPEINFO(QMargins, Q_MOVABLE_TYPE);
82 /*****************************************************************************
83 QMargins stream functions
84 *****************************************************************************/
85 #ifndef QT_NO_DATASTREAM
86 Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QMargins &);
87 Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QMargins &);
90 /*****************************************************************************
91 QMargins inline functions
92 *****************************************************************************/
94 Q_DECL_CONSTEXPR inline QMargins::QMargins() : m_left(0), m_top(0), m_right(0), m_bottom(0) {}
96 Q_DECL_CONSTEXPR inline QMargins::QMargins(int aleft, int atop, int aright, int abottom)
97 : m_left(aleft), m_top(atop), m_right(aright), m_bottom(abottom) {}
99 Q_DECL_CONSTEXPR inline bool QMargins::isNull() const
100 { return m_left==0 && m_top==0 && m_right==0 && m_bottom==0; }
102 Q_DECL_CONSTEXPR inline int QMargins::left() const
105 Q_DECL_CONSTEXPR inline int QMargins::top() const
108 Q_DECL_CONSTEXPR inline int QMargins::right() const
111 Q_DECL_CONSTEXPR inline int QMargins::bottom() const
115 inline void QMargins::setLeft(int aleft)
118 inline void QMargins::setTop(int atop)
121 inline void QMargins::setRight(int aright)
122 { m_right = aright; }
124 inline void QMargins::setBottom(int abottom)
125 { m_bottom = abottom; }
127 Q_DECL_CONSTEXPR inline bool operator==(const QMargins &m1, const QMargins &m2)
130 m1.m_left == m2.m_left &&
131 m1.m_top == m2.m_top &&
132 m1.m_right == m2.m_right &&
133 m1.m_bottom == m2.m_bottom;
136 Q_DECL_CONSTEXPR inline bool operator!=(const QMargins &m1, const QMargins &m2)
139 m1.m_left != m2.m_left ||
140 m1.m_top != m2.m_top ||
141 m1.m_right != m2.m_right ||
142 m1.m_bottom != m2.m_bottom;
145 #ifndef QT_NO_DEBUG_STREAM
146 Q_CORE_EXPORT QDebug operator<<(QDebug, const QMargins &);