Tizen 2.1 base
[framework/osp/uifw.git] / src / graphics / FGrpPoint.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /*
19  * @file        FGrpPoint.cpp
20  * @brief       This is the implementation file for Point class.
21  *
22  * This file contains implementation of Point class.
23  *
24  */
25
26 #include <FGrpPoint.h>
27
28
29 namespace Tizen { namespace Graphics
30 {
31
32 Point::Point(void)
33         : x(0)
34         , y(0)
35         , __pImpl(null)
36 {
37 }
38
39 Point::Point(const Point & rhs)
40         : x(rhs.x)
41         , y(rhs.y)
42         , __pImpl(null)
43 {
44 }
45
46 Point::Point(int x_, int y_)
47         : x(x_)
48         , y(y_)
49         , __pImpl(null)
50 {
51 }
52
53 Point::~Point(void)
54 {
55 }
56
57 Point&
58 Point::operator =(const Point & rhs)
59 {
60         if (this == &rhs)
61         {
62                 return *this;
63         }
64
65         this->x = rhs.x;
66         this->y = rhs.y;
67         this->__pImpl = null;
68
69         return *this;
70 }
71
72 bool
73 Point::operator ==(const Point& rhs) const
74 {
75         return ((this->x == rhs.x && this->y == rhs.y) ? true : false);
76 }
77
78 bool
79 Point::operator !=(const Point& rhs) const
80 {
81         return (!operator ==(rhs));
82 }
83
84 Point
85 Point::operator +(const Point& rhs) const
86 {
87         Point point;
88
89         point.x = this->x + rhs.x;
90         point.y = this->y + rhs.y;
91
92         return point;
93 }
94
95 Point
96 Point::operator -(const Point& rhs) const
97 {
98         Point point;
99
100         point.x = this->x - rhs.x;
101         point.y = this->y - rhs.y;
102
103         return point;
104 }
105
106 Point&
107 Point::operator +=(const Point& point)
108 {
109         this->x += point.x;
110         this->y += point.y;
111
112         return *this;
113 }
114
115 Point&
116 Point::operator -=(const Point& point)
117 {
118         this->x -= point.x;
119         this->y -= point.y;
120
121         return *this;
122 }
123
124 bool
125 Point::Equals(const Object& rhs) const
126 {
127         const Point* pPoint = dynamic_cast <const Point*>(&rhs);
128
129         if (pPoint == null)
130         {
131                 return false;
132         }
133
134         return (*this == *pPoint);
135 }
136
137 int
138 Point::GetHashCode(void) const
139 {
140         int bits = this->x;
141
142         bits ^= this->y * 31;
143
144         return (((int) bits) ^ ((int) (bits >> 16)));
145 }
146
147 void
148 Point::SetPosition(int x, int y)
149 {
150         this->x = x;
151         this->y = y;
152 }
153
154 void
155 Point::SetPosition(const Point& point)
156 {
157         this->x = point.x;
158         this->y = point.y;
159 }
160
161 void
162 Point::Translate(int x, int y)
163 {
164         this->x += x;
165         this->y += y;
166 }
167
168 }} // Tizen::Graphics