qmargins.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
00004 ** All rights reserved.
00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
00006 **
00007 ** This file is part of the QtCore module of the Qt Toolkit.
00008 **
00009 ** $QT_BEGIN_LICENSE:LGPL$
00010 ** Commercial Usage
00011 ** Licensees holding valid Qt Commercial licenses may use this file in
00012 ** accordance with the Qt Commercial License Agreement provided with the
00013 ** Software or, alternatively, in accordance with the terms contained in
00014 ** a written agreement between you and Nokia.
00015 **
00016 ** GNU Lesser General Public License Usage
00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
00018 ** General Public License version 2.1 as published by the Free Software
00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
00020 ** packaging of this file.  Please review the following information to
00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
00023 **
00024 ** In addition, as a special exception, Nokia gives you certain additional
00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
00027 **
00028 ** GNU General Public License Usage
00029 ** Alternatively, this file may be used under the terms of the GNU
00030 ** General Public License version 3.0 as published by the Free Software
00031 ** Foundation and appearing in the file LICENSE.GPL included in the
00032 ** packaging of this file.  Please review the following information to
00033 ** ensure the GNU General Public License version 3.0 requirements will be
00034 ** met: http://www.gnu.org/copyleft/gpl.html.
00035 **
00036 ** If you have questions regarding the use of this file, please contact
00037 ** Nokia at qt-info@nokia.com.
00038 ** $QT_END_LICENSE$
00039 **
00040 ****************************************************************************/
00041 
00042 #ifndef QMARGINS_H
00043 #define QMARGINS_H
00044 
00045 #include <QtCore/qnamespace.h>
00046 
00047 QT_BEGIN_HEADER
00048 
00049 QT_BEGIN_NAMESPACE
00050 
00051 QT_MODULE(Core)
00052 
00053 class QMargins
00054 {
00055 public:
00056     QMargins();
00057     QMargins(int left, int top, int right, int bottom);
00058 
00059     bool isNull() const;
00060 
00061     int left() const;
00062     int top() const;
00063     int right() const;
00064     int bottom() const;
00065 
00066     void setLeft(int left);
00067     void setTop(int top);
00068     void setRight(int right);
00069     void setBottom(int bottom);
00070 
00071 private:
00072     int m_left;
00073     int m_top;
00074     int m_right;
00075     int m_bottom;
00076 
00077     friend inline bool operator==(const QMargins &, const QMargins &);
00078     friend inline bool operator!=(const QMargins &, const QMargins &);
00079 };
00080 
00081 Q_DECLARE_TYPEINFO(QMargins, Q_MOVABLE_TYPE);
00082 
00083 /*****************************************************************************
00084   QMargins inline functions
00085  *****************************************************************************/
00086 
00087 inline QMargins::QMargins()
00088 { m_top = m_bottom = m_left = m_right = 0; }
00089 
00090 inline QMargins::QMargins(int aleft, int atop, int aright, int abottom)
00091     : m_left(aleft), m_top(atop), m_right(aright), m_bottom(abottom) {}
00092 
00093 inline bool QMargins::isNull() const
00094 { return m_left==0 && m_top==0 && m_right==0 && m_bottom==0; }
00095 
00096 inline int QMargins::left() const
00097 { return m_left; }
00098 
00099 inline int QMargins::top() const
00100 { return m_top; }
00101 
00102 inline int QMargins::right() const
00103 { return m_right; }
00104 
00105 inline int QMargins::bottom() const
00106 { return m_bottom; }
00107 
00108 
00109 inline void QMargins::setLeft(int aleft)
00110 { m_left = aleft; }
00111 
00112 inline void QMargins::setTop(int atop)
00113 { m_top = atop; }
00114 
00115 inline void QMargins::setRight(int aright)
00116 { m_right = aright; }
00117 
00118 inline void QMargins::setBottom(int abottom)
00119 { m_bottom = abottom; }
00120 
00121 inline bool operator==(const QMargins &m1, const QMargins &m2)
00122 {
00123     return
00124             m1.m_left == m2.m_left &&
00125             m1.m_top == m2.m_top &&
00126             m1.m_right == m2.m_right &&
00127             m1.m_bottom == m2.m_bottom;
00128 }
00129 
00130 inline bool operator!=(const QMargins &m1, const QMargins &m2)
00131 {
00132     return
00133             m1.m_left != m2.m_left ||
00134             m1.m_top != m2.m_top ||
00135             m1.m_right != m2.m_right ||
00136             m1.m_bottom != m2.m_bottom;
00137 }
00138 
00139 #ifndef QT_NO_DEBUG_STREAM
00140 Q_CORE_EXPORT QDebug operator<<(QDebug, const QMargins &);
00141 #endif
00142 
00143 QT_END_NAMESPACE
00144 
00145 QT_END_HEADER
00146 
00147 #endif // QMARGINS_H