Merge remote-tracking branch 'origin/master' into api_changes
[profile/ivi/qtbase.git] / src / corelib / tools / qmargins.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the QtCore module of the Qt Toolkit.
7 **
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.
16 **
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.
20 **
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.
28 **
29 ** Other Usage
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.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QMARGINS_H
43 #define QMARGINS_H
44
45 #include <QtCore/qnamespace.h>
46
47 QT_BEGIN_HEADER
48
49 QT_BEGIN_NAMESPACE
50
51
52 class QMargins
53 {
54 public:
55     Q_DECL_CONSTEXPR QMargins();
56     Q_DECL_CONSTEXPR QMargins(int left, int top, int right, int bottom);
57
58     Q_DECL_CONSTEXPR bool isNull() const;
59
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;
64
65     void setLeft(int left);
66     void setTop(int top);
67     void setRight(int right);
68     void setBottom(int bottom);
69
70 private:
71     int m_left;
72     int m_top;
73     int m_right;
74     int m_bottom;
75
76     friend Q_DECL_CONSTEXPR inline bool operator==(const QMargins &, const QMargins &);
77     friend Q_DECL_CONSTEXPR inline bool operator!=(const QMargins &, const QMargins &);
78 };
79
80 Q_DECLARE_TYPEINFO(QMargins, Q_MOVABLE_TYPE);
81
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 &);
88 #endif
89
90 /*****************************************************************************
91   QMargins inline functions
92  *****************************************************************************/
93
94 Q_DECL_CONSTEXPR inline QMargins::QMargins() : m_left(0), m_top(0), m_right(0), m_bottom(0) {}
95
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) {}
98
99 Q_DECL_CONSTEXPR inline bool QMargins::isNull() const
100 { return m_left==0 && m_top==0 && m_right==0 && m_bottom==0; }
101
102 Q_DECL_CONSTEXPR inline int QMargins::left() const
103 { return m_left; }
104
105 Q_DECL_CONSTEXPR inline int QMargins::top() const
106 { return m_top; }
107
108 Q_DECL_CONSTEXPR inline int QMargins::right() const
109 { return m_right; }
110
111 Q_DECL_CONSTEXPR inline int QMargins::bottom() const
112 { return m_bottom; }
113
114
115 inline void QMargins::setLeft(int aleft)
116 { m_left = aleft; }
117
118 inline void QMargins::setTop(int atop)
119 { m_top = atop; }
120
121 inline void QMargins::setRight(int aright)
122 { m_right = aright; }
123
124 inline void QMargins::setBottom(int abottom)
125 { m_bottom = abottom; }
126
127 Q_DECL_CONSTEXPR inline bool operator==(const QMargins &m1, const QMargins &m2)
128 {
129     return
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;
134 }
135
136 Q_DECL_CONSTEXPR inline bool operator!=(const QMargins &m1, const QMargins &m2)
137 {
138     return
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;
143 }
144
145 #ifndef QT_NO_DEBUG_STREAM
146 Q_CORE_EXPORT QDebug operator<<(QDebug, const QMargins &);
147 #endif
148
149 QT_END_NAMESPACE
150
151 QT_END_HEADER
152
153 #endif // QMARGINS_H