LibreOffice Module basegfx (master) 1
Size2D.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 */
10
11#pragma once
12
14
15namespace basegfx
16{
17template <typename TYPE> class Size2D : protected Tuple2D<TYPE>
18{
19public:
20 Size2D(TYPE width, TYPE height)
21 : Tuple2D<TYPE>(width, height)
22 {
23 }
24
25 Size2D(Tuple2D<TYPE> const& rTuple)
26 : Tuple2D<TYPE>(rTuple.getX(), rTuple.getY())
27 {
28 }
29
30 TYPE getWidth() const { return Tuple2D<TYPE>::getX(); }
31
32 TYPE getHeight() const { return Tuple2D<TYPE>::getY(); }
33
34 void setWidth(TYPE const& rWidth) { Tuple2D<TYPE>::setX(rWidth); }
35
36 void setHeight(TYPE const& rHeight) { Tuple2D<TYPE>::setY(rHeight); }
37
38 bool operator==(Size2D<TYPE> const& rSize) const { return Tuple2D<TYPE>::operator==(rSize); }
39
40 bool operator!=(Size2D<TYPE> const& rSize) const { return Tuple2D<TYPE>::operator!=(rSize); }
41
43 {
45 return *this;
46 }
47
49 {
51 return *this;
52 }
53
55 {
57 return *this;
58 }
59
61 {
63 return *this;
64 }
65
67 {
69 return *this;
70 }
71
73 {
75 return *this;
76 }
77
79
81};
82
83template <typename TYPE>
84inline Size2D<TYPE> operator-(const Size2D<TYPE>& rSizeA, const Size2D<TYPE>& rSizeB)
85{
86 Size2D<TYPE> aNew(rSizeA);
87 aNew -= rSizeB;
88 return aNew;
89}
90
91template <typename TYPE>
92inline Size2D<TYPE> operator+(const Size2D<TYPE>& rSizeA, const Size2D<TYPE>& rSizeB)
93{
94 Size2D<TYPE> aNew(rSizeA);
95 aNew += rSizeB;
96 return aNew;
97}
98
99template <typename TYPE>
100inline Size2D<TYPE> operator*(const Size2D<TYPE>& rSizeA, const Size2D<TYPE>& rSizeB)
101{
102 Size2D<TYPE> aNew(rSizeA);
103 aNew *= rSizeB;
104 return aNew;
105}
106
107template <typename TYPE>
108inline Size2D<TYPE> operator/(const Size2D<TYPE>& rSizeA, const Size2D<TYPE>& rSizeB)
109{
110 Size2D<TYPE> aNew(rSizeA);
111 aNew /= rSizeB;
112 return aNew;
113}
114
115} // end of namespace gfx
116
117/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Size2D< TYPE > operator-(void) const
Definition: Size2D.hxx:78
Size2D< TYPE > & operator*=(Size2D< TYPE > const &rSize)
Definition: Size2D.hxx:60
void setHeight(TYPE const &rHeight)
Definition: Size2D.hxx:36
TYPE getWidth() const
Definition: Size2D.hxx:30
Size2D< TYPE > & operator/=(TYPE value)
Definition: Size2D.hxx:72
Size2D< TYPE > & operator*=(TYPE value)
Definition: Size2D.hxx:66
bool operator!=(Size2D< TYPE > const &rSize) const
Definition: Size2D.hxx:40
Size2D(Tuple2D< TYPE > const &rTuple)
Definition: Size2D.hxx:25
void setWidth(TYPE const &rWidth)
Definition: Size2D.hxx:34
Size2D< TYPE > & operator+=(Size2D< TYPE > const &rSize)
Definition: Size2D.hxx:48
bool operator==(Size2D< TYPE > const &rSize) const
Definition: Size2D.hxx:38
Size2D(TYPE width, TYPE height)
Definition: Size2D.hxx:20
Size2D< TYPE > & operator-=(Size2D< TYPE > const &rSize)
Definition: Size2D.hxx:42
TYPE getHeight() const
Definition: Size2D.hxx:32
Size2D< TYPE > & operator/=(Size2D< TYPE > const &rSize)
Definition: Size2D.hxx:54
bool operator!=(const Tuple2D< TYPE > &rTup) const
Definition: Tuple2D.hxx:154
Tuple2D< TYPE > & operator+=(const Tuple2D< TYPE > &rTup)
Definition: Tuple2D.hxx:108
TYPE getX() const
Get X-Coordinate of 2D Tuple.
Definition: Tuple2D.hxx:63
Tuple2D< TYPE > & operator-=(const Tuple2D< TYPE > &rTup)
Definition: Tuple2D.hxx:115
void setY(TYPE fY)
Set Y-Coordinate of 2D Tuple.
Definition: Tuple2D.hxx:72
bool operator==(const Tuple2D< TYPE > &rTup) const
Definition: Tuple2D.hxx:152
Tuple2D< TYPE > & operator/=(const Tuple2D< TYPE > &rTup)
Definition: Tuple2D.hxx:122
TYPE getY() const
Get Y-Coordinate of 2D Tuple.
Definition: Tuple2D.hxx:66
void setX(TYPE fX)
Set X-Coordinate of 2D Tuple.
Definition: Tuple2D.hxx:69
Tuple2D< TYPE > & operator*=(const Tuple2D< TYPE > &rTup)
Definition: Tuple2D.hxx:129
Tuple2D< TYPE > operator-(void) const
Definition: Tuple2D.hxx:150
Any value
B2ITuple operator+(const B2ITuple &rTupA, const B2ITuple &rTupB)
Definition: b2ituple.hxx:72
B2ITuple operator-(const B2ITuple &rTupA, const B2ITuple &rTupB)
Definition: b2ituple.hxx:79
B2DPoint operator*(const ::basegfx::B2DHomMatrix &rMat, const B2DPoint &rPoint)
Definition: b2dpoint.cxx:43
B2DTuple operator/(const B2DTuple &rTup, double t)
Definition: b2dtuple.hxx:139
TYPE