2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0/
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.
19 * @file FGrpRectangle.h
20 * @brief This is the header file for the %Rectangle class.
22 * This header file contains the declarations of the %Rectangle class.
25 #ifndef _FGRP_RECTANGLE_H_
26 #define _FGRP_RECTANGLE_H_
28 #include <FBaseObject.h>
30 namespace Tizen { namespace Graphics
37 * @brief This class abstracts a rectangular region.
41 * @final This class is not intended for extension.
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.
46 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/graphics/shapes.htm">Shapes</a>.
48 class _OSP_EXPORT_ Rectangle
49 : public Tizen::Base::Object
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.
58 * @remarks The attribute value is @c 0 when initialized.
63 * This is the copy constructor for the %Rectangle class.
67 * @param[in] rhs An instance of %Rectangle
69 Rectangle(const Rectangle& rhs);
72 * Initializes an instance of %Rectangle with the specified location and dimension.
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
82 Rectangle(int x, int y, int width, int height);
85 * Initializes an instance of %Rectangle at the location specified by @c point and
86 * with dimension specified by @c dim.
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
93 Rectangle(const Point& point, const Dimension& dim);
96 * This is the destructor for this class.
100 virtual ~Rectangle(void);
103 * Assigns the value of the specified instance to the current instance of %Rectangle.
107 * @param[in] rhs An instance of %Rectangle
109 Rectangle& operator =(const Rectangle& rhs);
112 * Checks whether the location and dimension of the current instance of %Rectangle match those of the
113 * specified instance of %Rectangle.
117 * @return @c true if the location and dimension of the current instance match those of the specified instance, @n
119 * @param[in] rhs An instance of %Rectangle
121 bool operator ==(const Rectangle& rhs) const;
124 * Checks whether the location and dimension of the current instance of %Rectangle do not match those of the
125 * specified instance of %Rectangle.
129 * @return @c true if the location and dimension of the current instance do not match those of the specified instance, @n
131 * @param[in] rhs An instance of %Rectangle
133 bool operator !=(const Rectangle& rhs) const;
136 * Checks whether the specified point lies inside the current instance of %Rectangle.
140 * @return @c true if the location represented by @c point lies inside the current instance of %Rectangle, @n
142 * @param[in] point An instance of %Point
144 bool Contains(const Point& point) const;
147 * Checks whether the value of the current instance of %Rectangle equals the value of the specified instance of
152 * @return @c true if the value of the current instance of %Rectangle equals the value of the specified instance of %Rectangle, @n
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.
158 virtual bool Equals(const Tizen::Base::Object& rhs) const;
161 * Gets the hash value of the current instance.
165 * @return The hash value of the current instance
167 virtual int GetHashCode(void) const;
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.
175 * @param[in] rect An instance of %Rectangle
177 Rectangle GetIntersection(const Rectangle& rect) const;
180 * Checks whether the current instance of %Rectangle intersects with the specified instance of %Rectangle.
184 * @return @c true if the current instance of %Rectangle intersects with the specified instance of %Rectangle, @n
186 * @param[in] rect An instance of %Rectangle
189 bool IsIntersected(const Rectangle& rect) const;
192 * Gets the union of the current instance and the specified instance of %Rectangle.
196 * @return An instance of %Rectangle containing the union of the two rectangles
197 * @param[in] rect An instance of %Rectangle
199 Rectangle GetUnion(const Rectangle& rect) const;
202 * Gets the coordinates of the point at the bottom-right corner of the rectangle.
206 * @return The coordinates of the point at the bottom-right corner of the rectangle
208 Point GetBottomRight(void) const;
211 * Gets the coordinates of the point at the top-left corner of the rectangle.
215 * @return The coordinates of the point at the top-left corner of the rectangle
217 Point GetTopLeft(void) const;
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.
225 * @return @c true if this rectangle is empty, @n
228 bool IsEmpty(void) const;
231 * Sets the size of this %Rectangle to match the specified Dimension.
235 * @param[in] dim The new size for the Dimension
237 void SetSize(const Dimension& dim);
240 * Sets the size of this %Rectangle to match the specified dimension.
244 * @param[in] width The new width
245 * @param[in] height The new height
247 void SetSize(int width, int height);
250 * Sets the position of this %Rectangle to the specified point.
254 * @param[in] point The new position
256 void SetPosition(const Point& point);
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.
264 * @param[in] x The new x-coordinate
265 * @param[in] y The new y-coordinate
267 void SetPosition(int x, int y);
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.
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
280 void SetBounds(int x, int y, int width, int height);
283 * Sets the location and the dimensions of the current instance of %Rectangle with the specified location and
288 * @param[in] point An instance of Point
289 * @param[in] dim An instance of Dimension
291 void SetBounds(const Point& point, const Dimension& dim);
294 * Translates this %Rectangle to the new point by the specified distance along the x-axis and y-axis.
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
301 void Translate(int deltaX, int deltaY);
305 * The x-coordinate of the top-left corner of the rectangle.
312 * The y-coordinate of the top-left corner of the rectangle.
319 * The width of this rectangle.
326 * The height of this rectangle.
333 friend class _RectangleImpl;
336 // This variable is for internal use only.
337 // Using this variable can cause behavioral, security-related, and consistency-related issues in the application.
341 class _RectangleImpl * __pImpl;
345 }} // Tizen::Graphics
347 #endif // _FGRP_RECTANGLE_H_