N_SE-47263 : reset touch cancel when indicator touch released/N_SE-51832 : fix checki...
[platform/framework/native/uifw.git] / inc / FGrpRectangle.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0/
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        FGrpRectangle.h
20  * @brief       This is the header file for the %Rectangle class.
21  *
22  * This header file contains the declarations of the %Rectangle class.
23  */
24
25 #ifndef _FGRP_RECTANGLE_H_
26 #define _FGRP_RECTANGLE_H_
27
28 #include <FBaseObject.h>
29
30 namespace Tizen { namespace Graphics
31 {
32 class Point;
33 class Dimension;
34
35 /**
36  * @class       Rectangle
37  * @brief       This class abstracts a rectangular region.
38  *
39  * @since       2.0
40  *
41  * @final       This class is not intended for extension.
42  *
43  * The %Rectangle class represents a rectangular region in a coordinate space, which is specified by the rectangle
44  * object's top-left point (x, y) in the coordinate space, along with its width and height.
45  *
46  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/graphics/shapes.htm">Shapes</a>.
47  */
48 class _OSP_EXPORT_ Rectangle
49         : public Tizen::Base::Object
50 {
51 public:
52         /**
53          * This is the default constructor for this class. @n
54          * It initializes an instance of %Rectangle with all its attributes set to @c 0.
55          *
56          * @since               2.0
57          *
58          * @remarks             The attribute value is @c 0 when initialized.
59          */
60         Rectangle(void);
61
62         /**
63         * This is the copy constructor for the %Rectangle class.
64         *
65         * @since 2.0
66         *
67         * @param[in]    rhs             An instance of %Rectangle
68         */
69         Rectangle(const Rectangle& rhs);
70
71         /**
72          * Initializes an instance of %Rectangle with the specified location and dimension.
73          *
74          * @since               2.0
75          *
76          * @param[in]   x               The x-coordinate of the top-left corner of the rectangle
77          * @param[in]   y               The y-coordinate of the top-left corner of the rectangle
78          * @param[in]   width   The width of the rectangle
79          * @param[in]   height  The height of the rectangle
80          *
81          */
82         Rectangle(int x, int y, int width, int height);
83
84         /**
85          * Initializes an instance of %Rectangle at the location specified by @c point and
86          * with dimension specified by @c dim.
87          *
88          * @since               2.0
89          *
90          * @param[in]   point           The location of the top-left corner of the rectangle
91          * @param[in]   dim                     The width and height of the rectangle
92          */
93         Rectangle(const Point& point, const Dimension& dim);
94
95         /**
96          * This is the destructor for this class.
97          *
98          * @since               2.0
99          */
100         virtual ~Rectangle(void);
101
102         /**
103         * Assigns the value of the specified instance to the current instance of %Rectangle.
104         *
105         * @since 2.0
106         *
107         * @param[in]    rhs             An instance of %Rectangle
108         */
109         Rectangle& operator =(const Rectangle& rhs);
110
111         /**
112          * Checks whether the location and dimension of the current instance of %Rectangle match those of the
113          * specified instance of %Rectangle.
114          *
115          * @since               2.0
116          *
117          * @return              @c true if the location and dimension of the current instance match those of the specified instance, @n
118          *                              else @c false
119          * @param[in]   rhs             An instance of %Rectangle
120          */
121         bool operator ==(const Rectangle& rhs) const;
122
123         /**
124          * Checks whether the location and dimension of the current instance of %Rectangle do not match those of the
125          * specified instance of %Rectangle.
126          *
127          * @since               2.0
128          *
129          * @return              @c true if the location and dimension of the current instance do not match those of the specified instance, @n
130          *                              else @c false
131          * @param[in]   rhs             An instance of %Rectangle
132          */
133         bool operator !=(const Rectangle& rhs) const;
134
135         /**
136          * Checks whether the specified point lies inside the current instance of %Rectangle.
137          *
138          * @since               2.0
139          *
140          * @return              @c true if the location represented by @c point lies inside the current instance of %Rectangle, @n
141          *                              else @c false
142          * @param[in]   point   An instance of %Point
143          */
144         bool Contains(const Point& point) const;
145
146         /**
147          * Checks whether the value of the current instance of %Rectangle equals the value of the specified instance of
148          * %Rectangle.
149          *
150          * @since               2.0
151          *
152          * @return              @c true if the value of the current instance of %Rectangle equals the value of the specified instance of %Rectangle, @n
153          *                              else @c false
154          * @param[in]   rhs             An instance of %Rectangle
155          * @remarks             The %Rectangle class has a semantic value, which means that the Equals() method checks whether the
156          *                              two instances have the same location and size.
157          */
158         virtual bool Equals(const Tizen::Base::Object& rhs) const;
159
160         /**
161          * Gets the hash value of the current instance.
162          *
163          * @since 2.0
164          *
165          * @return              The hash value of the current instance
166          */
167         virtual int GetHashCode(void) const;
168
169         /**
170          * Gets the intersection of the current instance and the specified instance of %Rectangle. @n
171          * If the two instances of %Rectangle do not intersect, empty instance is returned.
172          *
173          * @since               2.0
174          *
175          * @param[in]   rect    An instance of %Rectangle
176          */
177         Rectangle GetIntersection(const Rectangle& rect) const;
178
179         /**
180          * Checks whether the current instance of %Rectangle intersects with the specified instance of %Rectangle.
181          *
182          * @since               2.0
183          *
184          * @return              @c true if the current instance of %Rectangle intersects with the specified instance of %Rectangle, @n
185          *                              else @c false
186          * @param[in]   rect    An instance of %Rectangle
187          *
188          */
189         bool IsIntersected(const Rectangle& rect) const;
190
191         /**
192          * Gets the union of the current instance and the specified instance of %Rectangle.
193          *
194          * @since               2.0
195          *
196          * @return              An instance of %Rectangle containing the union of the two rectangles
197          * @param[in]   rect    An instance of %Rectangle
198          */
199         Rectangle GetUnion(const Rectangle& rect) const;
200
201         /**
202          * Gets the coordinates of the point at the bottom-right corner of the rectangle.
203          *
204          * @since               2.0
205          *
206          * @return              The coordinates of the point at the bottom-right corner of the rectangle
207          */
208         Point GetBottomRight(void) const;
209
210         /**
211          * Gets the coordinates of the point at the top-left corner of the rectangle.
212          *
213          * @since               2.0
214          *
215          * @return              The coordinates of the point at the top-left corner of the rectangle
216          */
217         Point GetTopLeft(void) const;
218
219         /**
220          * Checks whether this %Rectangle is empty. @n
221          * A %Rectangle is empty if its width or its height is less than or equal to @c 0.
222          *
223          * @since               2.0
224          *
225          * @return              @c true if this rectangle is empty,     @n
226          *                              else @c false
227          */
228         bool IsEmpty(void) const;
229
230         /**
231          * Sets the size of this %Rectangle to match the specified Dimension.
232          *
233          * @since               2.0
234          *
235          * @param[in]   dim             The new size for the Dimension
236          */
237         void SetSize(const Dimension& dim);
238
239         /**
240          * Sets the size of this %Rectangle to match the specified dimension.
241          *
242          * @since               2.0
243          *
244          * @param[in]   width   The new width
245          * @param[in]   height  The new height
246          */
247         void SetSize(int width, int height);
248
249         /**
250          * Sets the position of this %Rectangle to the specified point.
251          *
252          * @since               2.0
253          *
254          * @param[in]   point   The new position
255          */
256         void SetPosition(const Point& point);
257
258         /**
259          * Sets the location of the current instance of %Rectangle with the specified values of the
260          * x and y coordinates of the top-left corner point.
261          *
262          * @since               2.0
263          *
264          * @param[in]   x               The new x-coordinate
265          * @param[in]   y               The new y-coordinate
266          */
267         void SetPosition(int x, int y);
268
269         /**
270          * Sets the location and the dimensions of the current instance of %Rectangle with the specified x and y
271          * coordinates of the top-left corner point and the specified dimensions.
272          *
273          * @since               2.0
274          *
275          * @param[in]   x               The new x coordinate
276          * @param[in]   y               The new y coordinate
277          * @param[in]   width   The new width
278          * @param[in]   height  The new height
279          */
280         void SetBounds(int x, int y, int width, int height);
281
282         /**
283          * Sets the location and the dimensions of the current instance of %Rectangle with the specified location and
284          * dimension.
285          *
286          * @since               2.0
287          *
288          * @param[in]   point   An instance of Point
289          * @param[in]   dim             An instance of Dimension
290          */
291         void SetBounds(const Point& point, const Dimension& dim);
292
293         /**
294          * Translates this %Rectangle to the new point by the specified distance along the x-axis and y-axis.
295          *
296          * @since               2.0
297          *
298          * @param[in]   deltaX  The distance to move this %Rectangle along the x-axis
299          * @param[in]   deltaY  The distance to move this %Rectangle along the y-axis
300          */
301         void Translate(int deltaX, int deltaY);
302
303 public:
304         /**
305          * The x-coordinate of the top-left corner of the rectangle.
306          *
307          * @since       2.0
308          */
309         int x;
310
311         /**
312          * The y-coordinate of the top-left corner of the rectangle.
313          *
314          * @since       2.0
315          */
316         int y;
317
318         /**
319          * The width of this rectangle.
320          *
321          * @since       2.0
322          */
323         int width;
324
325         /**
326          * The height of this rectangle.
327          *
328          * @since       2.0
329          */
330         int height;
331
332 private:
333         friend class _RectangleImpl;
334
335         //
336         // This variable is for internal use only.
337         // Using this variable can cause behavioral, security-related, and consistency-related issues in the application.
338         //
339         // @since 2.0
340         //
341         class _RectangleImpl * __pImpl;
342
343 }; // Rectangle
344
345 }} // Tizen::Graphics
346
347 #endif // _FGRP_RECTANGLE_H_