/src/libreoffice/include/basegfx/tuple/Size2D.hxx
Line | Count | Source |
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 | | |
13 | | #include <basegfx/tuple/Tuple2D.hxx> |
14 | | |
15 | | namespace basegfx |
16 | | { |
17 | | template <typename TYPE> class Size2D : protected Tuple2D<TYPE> |
18 | | { |
19 | | public: |
20 | | Size2D(TYPE width, TYPE height) |
21 | 0 | : Tuple2D<TYPE>(width, height) |
22 | 0 | { |
23 | 0 | } Unexecuted instantiation: basegfx::Size2D<double>::Size2D(double, double) Unexecuted instantiation: basegfx::Size2D<int>::Size2D(int, int) |
24 | | |
25 | | Size2D(Tuple2D<TYPE> const& rTuple) |
26 | | : Tuple2D<TYPE>(rTuple.getX(), rTuple.getY()) |
27 | | { |
28 | | } |
29 | | |
30 | 0 | TYPE getWidth() const { return Tuple2D<TYPE>::getX(); }Unexecuted instantiation: basegfx::Size2D<double>::getWidth() const Unexecuted instantiation: basegfx::Size2D<int>::getWidth() const |
31 | | |
32 | 0 | TYPE getHeight() const { return Tuple2D<TYPE>::getY(); }Unexecuted instantiation: basegfx::Size2D<double>::getHeight() const Unexecuted instantiation: basegfx::Size2D<int>::getHeight() const |
33 | | |
34 | 0 | void setWidth(TYPE const& rWidth) { Tuple2D<TYPE>::setX(rWidth); } |
35 | | |
36 | 0 | void setHeight(TYPE const& rHeight) { Tuple2D<TYPE>::setY(rHeight); } |
37 | | |
38 | 0 | 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 | | |
42 | | Size2D<TYPE>& operator-=(Size2D<TYPE> const& rSize) |
43 | | { |
44 | | Tuple2D<TYPE>::operator-=(rSize); |
45 | | return *this; |
46 | | } |
47 | | |
48 | | Size2D<TYPE>& operator+=(Size2D<TYPE> const& rSize) |
49 | | { |
50 | | Tuple2D<TYPE>::operator+=(rSize); |
51 | | return *this; |
52 | | } |
53 | | |
54 | | Size2D<TYPE>& operator/=(Size2D<TYPE> const& rSize) |
55 | | { |
56 | | Tuple2D<TYPE>::operator/=(rSize); |
57 | | return *this; |
58 | | } |
59 | | |
60 | | Size2D<TYPE>& operator*=(Size2D<TYPE> const& rSize) |
61 | | { |
62 | | Tuple2D<TYPE>::operator*=(rSize); |
63 | | return *this; |
64 | | } |
65 | | |
66 | | Size2D<TYPE>& operator*=(TYPE value) |
67 | | { |
68 | | Tuple2D<TYPE>::operator*=(value); |
69 | | return *this; |
70 | | } |
71 | | |
72 | | Size2D<TYPE>& operator/=(TYPE value) |
73 | | { |
74 | | Tuple2D<TYPE>::operator/=(value); |
75 | | return *this; |
76 | | } |
77 | | |
78 | | Size2D<TYPE> operator-(void) const { return Tuple2D<TYPE>::operator-(); } |
79 | | |
80 | | using Tuple2D<TYPE>::equalZero; |
81 | | }; |
82 | | |
83 | | template <typename TYPE> |
84 | | inline 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 | | |
91 | | template <typename TYPE> |
92 | | inline 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 | | |
99 | | template <typename TYPE> |
100 | | inline 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 | | |
107 | | template <typename TYPE> |
108 | | inline 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: */ |