Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / include / basegfx / tuple / Size2D.hxx
blobd4e2a2a784bc99329063c359c5ec8f22d88422ed
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 */
11 #pragma once
13 #include <basegfx/tuple/Tuple2D.hxx>
15 namespace basegfx
17 template <typename TYPE> class Size2D : protected Tuple2D<TYPE>
19 public:
20 Size2D(TYPE width, TYPE height)
21 : Tuple2D<TYPE>(width, height)
25 Size2D(Tuple2D<TYPE> const& rTuple)
26 : Tuple2D<TYPE>(rTuple.getX(), rTuple.getY())
30 TYPE getWidth() const { return Tuple2D<TYPE>::getX(); }
32 TYPE getHeight() const { return Tuple2D<TYPE>::getY(); }
34 void setWidth(TYPE const& rWidth) { Tuple2D<TYPE>::setX(rWidth); }
36 void setHeight(TYPE const& rHeight) { Tuple2D<TYPE>::setY(rHeight); }
38 bool operator==(Size2D<TYPE> const& rSize) const { return Tuple2D<TYPE>::operator==(rSize); }
40 bool operator!=(Size2D<TYPE> const& rSize) const { return Tuple2D<TYPE>::operator!=(rSize); }
42 Size2D<TYPE>& operator-=(Size2D<TYPE> const& rSize)
44 Tuple2D<TYPE>::operator-=(rSize);
45 return *this;
48 Size2D<TYPE>& operator+=(Size2D<TYPE> const& rSize)
50 Tuple2D<TYPE>::operator+=(rSize);
51 return *this;
54 Size2D<TYPE>& operator/=(Size2D<TYPE> const& rSize)
56 Tuple2D<TYPE>::operator/=(rSize);
57 return *this;
60 Size2D<TYPE>& operator*=(Size2D<TYPE> const& rSize)
62 Tuple2D<TYPE>::operator*=(rSize);
63 return *this;
66 Size2D<TYPE>& operator*=(TYPE value)
68 Tuple2D<TYPE>::operator*=(value);
69 return *this;
72 Size2D<TYPE>& operator/=(TYPE value)
74 Tuple2D<TYPE>::operator/=(value);
75 return *this;
78 Size2D<TYPE> operator-(void) const { return Tuple2D<TYPE>::operator-(); }
81 template <typename TYPE>
82 inline Size2D<TYPE> operator-(const Size2D<TYPE>& rSizeA, const Size2D<TYPE>& rSizeB)
84 Size2D<TYPE> aNew(rSizeA);
85 aNew -= rSizeB;
86 return aNew;
89 template <typename TYPE>
90 inline Size2D<TYPE> operator+(const Size2D<TYPE>& rSizeA, const Size2D<TYPE>& rSizeB)
92 Size2D<TYPE> aNew(rSizeA);
93 aNew += rSizeB;
94 return aNew;
97 template <typename TYPE>
98 inline Size2D<TYPE> operator*(const Size2D<TYPE>& rSizeA, const Size2D<TYPE>& rSizeB)
100 Size2D<TYPE> aNew(rSizeA);
101 aNew *= rSizeB;
102 return aNew;
105 template <typename TYPE>
106 inline Size2D<TYPE> operator/(const Size2D<TYPE>& rSizeA, const Size2D<TYPE>& rSizeB)
108 Size2D<TYPE> aNew(rSizeA);
109 aNew /= rSizeB;
110 return aNew;
113 } // end of namespace gfx
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */