4d29ae0b6971340b62867fcd8467c03d644b8ba2
[platform/core/location/maps-plugin-here.git] / inc / engine / graphic / Rectangle.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #ifndef HERE_GRAPHIC_RECTANGLE_H
18 #define HERE_GRAPHIC_RECTANGLE_H
19
20 #include "common/HereMaps_global.h"
21 #include "base/BaseObject.h"
22 #include "graphic/Point.h"
23 #include "graphic/Dimension.h"
24
25 TIZEN_MAPS_BEGIN_NAMESPACE
26
27 class Rectangle;
28
29 class EXPORT_API Rectangle      : public Object
30 {
31 public:
32         /**
33          * This is the default constructor for this class. @n
34          * It initializes an instance of %Rectangle with all its attributes set to @c 0.
35          *
36          * @since               2.0
37          *
38          * @remarks             The attribute value is @c 0 when initialized.
39          */
40         Rectangle(void);
41
42         /**
43         * This is the copy constructor for the %Rectangle class.
44         *
45         * @since 2.0
46         *
47         * @param[in]    rhs             An instance of %Rectangle
48         */
49         Rectangle(const Rectangle& rhs);
50
51         /**
52          * Initializes an instance of %Rectangle with the specified location and dimension.
53          *
54          * @since               2.0
55          *
56          * @param[in]   x               The x-coordinate of the top-left corner of the rectangle
57          * @param[in]   y               The y-coordinate of the top-left corner of the rectangle
58          * @param[in]   width   The width of the rectangle
59          * @param[in]   height  The height of the rectangle
60          *
61          */
62         Rectangle(int x, int y, int width, int height);
63
64         /**
65          * Initializes an instance of %Rectangle at the location specified by @c point and
66          * with dimension specified by @c dim.
67          *
68          * @since               2.0
69          *
70          * @param[in]   point           The location of the top-left corner of the rectangle
71          * @param[in]   dim                     The width and height of the rectangle
72          */
73         Rectangle(const Point& point, const Dimension& dim);
74
75         /**
76          * This is the destructor for this class.
77          *
78          * @since               2.0
79          */
80         virtual ~Rectangle(void);
81
82         /**
83         * Assigns the value of the specified instance to the current instance of %Rectangle.
84         *
85         * @since 2.0
86         *
87         * @param[in]    rhs             An instance of %Rectangle
88         */
89         Rectangle& operator =(const Rectangle& rhs);
90
91         /**
92          * Checks whether the location and dimension of the current instance of %Rectangle match those of the
93          * specified instance of %Rectangle.
94          *
95          * @since               2.0
96          *
97          * @return              @c true if the location and dimension of the current instance match those of the specified instance, @n
98          *                              else @c false
99          * @param[in]   rhs             An instance of %Rectangle
100          */
101         bool operator ==(const Rectangle& rhs) const;
102
103         /**
104          * Checks whether the location and dimension of the current instance of %Rectangle do not match those of the
105          * specified instance of %Rectangle.
106          *
107          * @since               2.0
108          *
109          * @return              @c true if the location and dimension of the current instance do not match those of the specified instance, @n
110          *                              else @c false
111          * @param[in]   rhs             An instance of %Rectangle
112          */
113         bool operator !=(const Rectangle& rhs) const;
114
115         /**
116          * Checks whether the specified point lies inside the current instance of %Rectangle.
117          *
118          * @since               2.0
119          *
120          * @return              @c true if the location represented by the specified @c point lies inside the current instance of %Rectangle, @n
121          *                              else @c false
122          * @param[in]   point   An instance of %Point
123          */
124         bool Contains(const Point& point) const;
125
126         /**
127          * Checks whether the value of the current instance of %Rectangle equals the value of the specified instance of
128          * %Rectangle.
129          *
130          * @since               2.0
131          *
132          * @return              @c true if the value of the current instance of %Rectangle equals the value of the specified instance of %Rectangle, @n
133          *                              else @c false
134          * @param[in]   rhs             An instance of %Rectangle
135          * @remarks             The %Rectangle class has a semantic value, which means that the Equals() method checks whether the
136          *                              two instances have the same location and size.
137          */
138         virtual bool Equals(const Object& rhs) const;
139
140         /**
141          * Gets the hash value of the current instance.
142          *
143          * @since 2.0
144          *
145          * @return              The hash value of the current instance
146          */
147         virtual long GetHashCode(void) const;
148
149         /**
150          * Gets the intersection of the current instance and the specified instance of %Rectangle. @n
151          * If the two instances of %Rectangle do not intersect, an empty instance is returned.
152          *
153          * @since               2.0
154          *
155          * @param[in]   rect    An instance of %Rectangle
156          */
157         Rectangle GetIntersection(const Rectangle& rect) const;
158
159         /**
160          * Checks whether the current instance of %Rectangle intersects with the specified instance of %Rectangle.
161          *
162          * @since               2.0
163          *
164          * @return              @c true if the current instance of %Rectangle intersects with the specified instance of %Rectangle, @n
165          *                              else @c false
166          * @param[in]   rect    An instance of %Rectangle
167          *
168          */
169         bool IsIntersected(const Rectangle& rect) const;
170
171         /**
172          * Gets the union of the current instance and the specified instance of %Rectangle.
173          *
174          * @since               2.0
175          *
176          * @return              An instance of %Rectangle containing the union of the two rectangles
177          * @param[in]   rect    An instance of %Rectangle
178          */
179         Rectangle GetUnion(const Rectangle& rect) const;
180
181         /**
182          * Gets the coordinates of the point at the bottom-right corner of the rectangle.
183          *
184          * @since               2.0
185          *
186          * @return              The coordinates of the point at the bottom-right corner of the rectangle
187          */
188         Point GetBottomRight(void) const;
189
190         /**
191          * Gets the coordinates of the point at the top-left corner of the rectangle.
192          *
193          * @since               2.0
194          *
195          * @return              The coordinates of the point at the top-left corner of the rectangle
196          */
197         Point GetTopLeft(void) const;
198
199         /**
200          * Checks whether this %Rectangle is empty. @n
201          * A %Rectangle is empty if its width or its height is less than or equal to @c 0.
202          *
203          * @since               2.0
204          *
205          * @return              @c true if this rectangle is empty,     @n
206          *                              else @c false
207          */
208         bool IsEmpty(void) const;
209
210         /**
211          * Sets the size of this %Rectangle to match the specified Dimension.
212          *
213          * @since               2.0
214          *
215          * @param[in]   dim             The new size for the Dimension
216          */
217         void SetSize(const Dimension& dim);
218
219         /**
220          * Sets the size of this %Rectangle to match the specified dimension.
221          *
222          * @since               2.0
223          *
224          * @param[in]   width   The new width
225          * @param[in]   height  The new height
226          */
227         void SetSize(int width, int height);
228
229         /**
230          * Sets the position of this %Rectangle to the specified point.
231          *
232          * @since               2.0
233          *
234          * @param[in]   point   The new position
235          */
236         void SetPosition(const Point& point);
237
238         /**
239          * Sets the location of the current instance of %Rectangle with the specified values of the
240          * x and y coordinates of the top-left corner point.
241          *
242          * @since               2.0
243          *
244          * @param[in]   x               The new x-coordinate
245          * @param[in]   y               The new y-coordinate
246          */
247         void SetPosition(int x, int y);
248
249         /**
250          * Sets the location and the dimensions of the current instance of %Rectangle with the specified x and y
251          * coordinates of the top-left corner point and the specified dimensions.
252          *
253          * @since               2.0
254          *
255          * @param[in]   x               The new x coordinate
256          * @param[in]   y               The new y coordinate
257          * @param[in]   width   The new width
258          * @param[in]   height  The new height
259          */
260         void SetBounds(int x, int y, int width, int height);
261
262         /**
263          * Sets the location and the dimensions of the current instance of %Rectangle with the specified location and
264          * dimension.
265          *
266          * @since               2.0
267          *
268          * @param[in]   point   An instance of Point
269          * @param[in]   dim             An instance of Dimension
270          */
271         void SetBounds(const Point& point, const Dimension& dim);
272
273         /**
274          * Translates this %Rectangle to the new point by the specified distance along the x-axis and y-axis.
275          *
276          * @since               2.0
277          *
278          * @param[in]   deltaX  The distance to move this %Rectangle along the x-axis
279          * @param[in]   deltaY  The distance to move this %Rectangle along the y-axis
280          */
281         void Translate(int deltaX, int deltaY);
282
283 public:
284         /**
285          * The x-coordinate of the top-left corner of the rectangle.
286          *
287          * @since       2.0
288          */
289         int x;
290
291         /**
292          * The y-coordinate of the top-left corner of the rectangle.
293          *
294          * @since       2.0
295          */
296         int y;
297
298         /**
299          * The width of this rectangle.
300          *
301          * @since       2.0
302          */
303         int width;
304
305         /**
306          * The height of this rectangle.
307          *
308          * @since       2.0
309          */
310         int height;
311
312 private:
313         friend class _RectangleImpl;
314
315         //
316         // This variable is for internal use only.
317         // Using this variable can cause behavioral, security-related, and consistency-related issues in the application.
318         //
319         // @since 2.0
320         //
321         class _RectangleImpl * __pImpl;
322
323 }; // Rectangle
324
325 TIZEN_MAPS_END_NAMESPACE
326
327 #endif /* HERE_GRAPHIC_RECTANGLE_H */