]> git.sesse.net Git - casparcg/blob - SFML-1.6/include/SFML/Graphics/Rect.hpp
(no commit message)
[casparcg] / SFML-1.6 / include / SFML / Graphics / Rect.hpp
1 ////////////////////////////////////////////////////////////\r
2 //\r
3 // SFML - Simple and Fast Multimedia Library\r
4 // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)\r
5 //\r
6 // This software is provided 'as-is', without any express or implied warranty.\r
7 // In no event will the authors be held liable for any damages arising from the use of this software.\r
8 //\r
9 // Permission is granted to anyone to use this software for any purpose,\r
10 // including commercial applications, and to alter it and redistribute it freely,\r
11 // subject to the following restrictions:\r
12 //\r
13 // 1. The origin of this software must not be misrepresented;\r
14 //    you must not claim that you wrote the original software.\r
15 //    If you use this software in a product, an acknowledgment\r
16 //    in the product documentation would be appreciated but is not required.\r
17 //\r
18 // 2. Altered source versions must be plainly marked as such,\r
19 //    and must not be misrepresented as being the original software.\r
20 //\r
21 // 3. This notice may not be removed or altered from any source distribution.\r
22 //\r
23 ////////////////////////////////////////////////////////////\r
24 \r
25 #ifndef SFML_RECT_HPP\r
26 #define SFML_RECT_HPP\r
27 \r
28 ////////////////////////////////////////////////////////////\r
29 // Headers\r
30 ////////////////////////////////////////////////////////////\r
31 #include <algorithm>\r
32 \r
33 \r
34 namespace sf\r
35 {\r
36 ////////////////////////////////////////////////////////////\r
37 /// Rect is an utility class for manipulating rectangles.\r
38 /// Template parameter defines the type of coordinates (integer, float, ...)\r
39 ////////////////////////////////////////////////////////////\r
40 template <typename T>\r
41 class Rect\r
42 {\r
43 public :\r
44 \r
45     ////////////////////////////////////////////////////////////\r
46     /// Default constructor\r
47     ///\r
48     ////////////////////////////////////////////////////////////\r
49     Rect();\r
50 \r
51     ////////////////////////////////////////////////////////////\r
52     /// Construct the rectangle from its coordinates\r
53     ///\r
54     /// \param LeftCoord :   Left coordinate of the rectangle\r
55     /// \param TopCoord :    Top coordinate of the rectangle\r
56     /// \param RightCoord :  Right coordinate of the rectangle\r
57     /// \param BottomCoord : Bottom coordinate of the rectangle\r
58     ///\r
59     ////////////////////////////////////////////////////////////\r
60     Rect(T LeftCoord, T TopCoord, T RightCoord, T BottomCoord);\r
61 \r
62     ////////////////////////////////////////////////////////////\r
63     /// Get the width of the rectangle\r
64     ///\r
65     /// \return Width of rectangle\r
66     ///\r
67     ////////////////////////////////////////////////////////////\r
68     T GetWidth() const;\r
69 \r
70     ////////////////////////////////////////////////////////////\r
71     /// Get the height of the rectangle\r
72     ///\r
73     /// \return Height of rectangle\r
74     ///\r
75     ////////////////////////////////////////////////////////////\r
76     T GetHeight() const;\r
77 \r
78     ////////////////////////////////////////////////////////////\r
79     /// Move the whole rectangle by the given offset\r
80     ///\r
81     /// \param OffsetX : Horizontal offset\r
82     /// \param OffsetY : Vertical offset\r
83     ///\r
84     ////////////////////////////////////////////////////////////\r
85     void Offset(T OffsetX, T OffsetY);\r
86 \r
87     ////////////////////////////////////////////////////////////\r
88     /// Check if a point is inside the rectangle's area\r
89     ///\r
90     /// \param X : X coordinate of the point to test\r
91     /// \param Y : Y coordinate of the point to test\r
92     ///\r
93     /// \return True if the point is inside\r
94     ///\r
95     ////////////////////////////////////////////////////////////\r
96     bool Contains(T X, T Y) const;\r
97 \r
98     ////////////////////////////////////////////////////////////\r
99     /// Check intersection between two rectangles\r
100     ///\r
101     /// \param Rectangle :       Rectangle to test\r
102     /// \param OverlappingRect : Rectangle to be filled with overlapping rect (NULL by default)\r
103     ///\r
104     /// \return True if rectangles overlap\r
105     ///\r
106     ////////////////////////////////////////////////////////////\r
107     bool Intersects(const Rect<T>& Rectangle, Rect<T>* OverlappingRect = NULL) const;\r
108 \r
109     ////////////////////////////////////////////////////////////\r
110     // Member data\r
111     ////////////////////////////////////////////////////////////\r
112     T Left;   ///< Left coordinate of the rectangle\r
113     T Top;    ///< Top coordinate of the rectangle\r
114     T Right;  ///< Right coordinate of the rectangle\r
115     T Bottom; ///< Bottom coordinate of the rectangle\r
116 };\r
117 \r
118 #include <SFML/Graphics/Rect.inl>\r
119 \r
120 // Define the most common types\r
121 typedef Rect<int>   IntRect;\r
122 typedef Rect<float> FloatRect;\r
123 \r
124 } // namespace sf\r
125 \r
126 \r
127 #endif // SFML_RECT_HPP\r