PageRenderTime 58ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/wxPython-src-2.8.12.0/docs/html/wx/wx_wxrect.html

#
HTML | 419 lines | 344 code | 75 blank | 0 comment | 0 complexity | 30bdb34752396319ccce65c6b43e1061 MD5 | raw file
Possible License(s): BSD-2-Clause, GPL-2.0, LGPL-2.0, LGPL-3.0, AGPL-3.0, CC-BY-SA-3.0, BSD-3-Clause
  1. <HTML>
  2. <head><link rel=stylesheet type="text/css" href="wx.css"><title>wxRect</title></head>
  3. <BODY BGCOLOR=#FFFFFF>
  4. <A NAME="wxrect"></A><CENTER>
  5. <A HREF="wx_contents.html"><img align=center src="contents.gif" BORDER=0 ALT="Contents"></A> <A HREF="wx_classref.html#classref"><img align=center src="up.gif" BORDER=0 ALT="Up"></A> <A HREF="wx_wxrealpoint.html#wxrealpoint"><img align=center src="back.gif" BORDER=0 ALT="Previous"></A> <A HREF="wx_wxrecursionguard.html#wxrecursionguard"><img align=center src="forward.gif" BORDER=0 ALT="Next"></A> </CENTER><HR>
  6. <H2>wxRect</H2>
  7. <P>
  8. A class for manipulating rectangles.<P>
  9. <B><FONT COLOR="#FF0000">Derived from</FONT></B><P>
  10. None<P>
  11. <B><FONT COLOR="#FF0000">Include files</FONT></B><P>
  12. &lt;wx/gdicmn.h&gt;<P>
  13. <B><FONT COLOR="#FF0000">See also</FONT></B><P>
  14. <A HREF="wx_wxpoint.html#wxpoint">wxPoint</A>, <A HREF="wx_wxsize.html#wxsize">wxSize</A><P>
  15. <B><FONT COLOR="#FF0000">Members</FONT></B><P>
  16. <A HREF="#wxrectctor">wxRect::wxRect</A><BR>
  17. <A HREF="#wxrectx">wxRect::x</A><BR>
  18. <A HREF="#wxrecty">wxRect::y</A><BR>
  19. <A HREF="#wxrectwidth">wxRect::width</A><BR>
  20. <A HREF="#wxrectheight">wxRect::height</A><BR>
  21. <A HREF="#wxrectcentrein">wxRect::CentreIn</A><BR>
  22. <A HREF="#wxrectcontains">wxRect::Contains</A><BR>
  23. <A HREF="#wxrectdeflate">wxRect::Deflate</A><BR>
  24. <A HREF="#wxrectgetbottom">wxRect::GetBottom</A><BR>
  25. <A HREF="#wxrectgetheight">wxRect::GetHeight</A><BR>
  26. <A HREF="#wxrectgetleft">wxRect::GetLeft</A><BR>
  27. <A HREF="#wxrectgetposition">wxRect::GetPosition</A><BR>
  28. <A HREF="#wxrectgettopleft">wxRect::GetTopLeft</A><BR>
  29. <A HREF="#wxrectgettopright">wxRect::GetTopRight</A><BR>
  30. <A HREF="#wxrectgetbottomleft">wxRect::GetBottomLeft</A><BR>
  31. <A HREF="#wxrectgetbottomright">wxRect::GetBottomRight</A><BR>
  32. <A HREF="#wxrectgetright">wxRect::GetRight</A><BR>
  33. <A HREF="#wxrectgetsize">wxRect::GetSize</A><BR>
  34. <A HREF="#wxrectgettop">wxRect::GetTop</A><BR>
  35. <A HREF="#wxrectgetwidth">wxRect::GetWidth</A><BR>
  36. <A HREF="#wxrectgetx">wxRect::GetX</A><BR>
  37. <A HREF="#wxrectgety">wxRect::GetY</A><BR>
  38. <A HREF="#wxrectinflate">wxRect::Inflate</A><BR>
  39. <A HREF="#wxrectintersect">wxRect::Intersect</A><BR>
  40. <A HREF="#wxrectintersects">wxRect::Intersects</A><BR>
  41. <A HREF="#wxrectisempty">wxRect::IsEmpty</A><BR>
  42. <A HREF="#wxrectoffset">wxRect::Offset</A><BR>
  43. <A HREF="#wxrectsetheight">wxRect::SetHeight</A><BR>
  44. <A HREF="#wxrectsetsize">wxRect::SetSize</A><BR>
  45. <A HREF="#wxrectsetwidth">wxRect::SetWidth</A><BR>
  46. <A HREF="#wxrectsetx">wxRect::SetX</A><BR>
  47. <A HREF="#wxrectsety">wxRect::SetY</A><BR>
  48. <A HREF="#wxrectunion">wxRect::Union</A><BR>
  49. <A HREF="#wxrectassign">wxRect::operator =</A><BR>
  50. <A HREF="#wxrectequal">wxRect::operator ==</A><BR>
  51. <A HREF="#wxrectnotequal">wxRect::operator !=</A><BR>
  52. <P>
  53. <HR>
  54. <A NAME="wxrectctor"></A>
  55. <H3>wxRect::wxRect</H3>
  56. <P>
  57. <B></B> <B>wxRect</B>()<P>
  58. Default constructor.<P>
  59. <B></B> <B>wxRect</B>(<B>int</B><I> x</I>, <B>int</B><I> y</I>, <B>int</B><I> width</I>, <B>int</B><I> height</I>)<P>
  60. Creates a wxRect object from x, y, width and height values.<P>
  61. <B></B> <B>wxRect</B>(<B>const <A HREF="wx_wxpoint.html#wxpoint">wxPoint</A>&</B></B><I> topLeft</I>, <B>const <A HREF="wx_wxpoint.html#wxpoint">wxPoint</A>&</B></B><I> bottomRight</I>)<P>
  62. Creates a wxRect object from top-left and bottom-right points.<P>
  63. <B></B> <B>wxRect</B>(<B>const <A HREF="wx_wxpoint.html#wxpoint">wxPoint</A>&</B></B><I> pos</I>, <B>const <A HREF="wx_wxsize.html#wxsize">wxSize</A>&</B></B><I> size</I>)<P>
  64. Creates a wxRect object from position and size values.<P>
  65. <B></B> <B>wxRect</B>(<B>const <A HREF="wx_wxsize.html#wxsize">wxSize</A>&</B></B><I> size</I>)<P>
  66. Creates a wxRect object from size values at the origin.<P>
  67. <HR>
  68. <A NAME="wxrectx"></A>
  69. <H3>wxRect::x</H3>
  70. <P>
  71. int x<P>
  72. x coordinate of the top-level corner of the rectangle.<P>
  73. <HR>
  74. <A NAME="wxrecty"></A>
  75. <H3>wxRect::y</H3>
  76. <P>
  77. int y<P>
  78. y coordinate of the top-level corner of the rectangle.<P>
  79. <HR>
  80. <A NAME="wxrectwidth"></A>
  81. <H3>wxRect::width</H3>
  82. <P>
  83. int width<P>
  84. Width member.<P>
  85. <HR>
  86. <A NAME="wxrectheight"></A>
  87. <H3>wxRect::height</H3>
  88. <P>
  89. int height<P>
  90. Height member.<P>
  91. <HR>
  92. <A NAME="wxrectcentrein"></A>
  93. <H3>wxRect::CentreIn</H3>
  94. <P>
  95. <B><A HREF="wx_wxrect.html#wxrect">wxRect</A></B> </B> <B>CentreIn</B>(<B>const <A HREF="wx_wxrect.html#wxrect">wxRect</A>& </B></B><I>r</I>, <B>int </B><I>dir = wxBOTH</I>) <B>const</B><P>
  96. <B><A HREF="wx_wxrect.html#wxrect">wxRect</A></B> </B> <B>CenterIn</B>(<B>const <A HREF="wx_wxrect.html#wxrect">wxRect</A>& </B></B><I>r</I>, <B>int </B><I>dir = wxBOTH</I>) <B>const</B><P>
  97. Returns the rectangle having the same size as this one but centered relatively
  98. to the given rectangle <I>r</I>. By default, rectangle is centred in both
  99. directions but if <I>dir</I> includes only <TT>wxVERTICAL</TT> or only
  100. <TT>wxHORIZONTAL</TT> flag, then it is only centered in this direction while
  101. the other component of its position remains unchanged.<P>
  102. <HR>
  103. <A NAME="wxrectcontains"></A>
  104. <H3>wxRect::Contains</H3>
  105. <P>
  106. <B>bool</B> <B>Contains</B>(<B>int </B><I>x</I>, <B>int </B><I>y</I>) <B>const</B><P>
  107. <B>bool</B> <B>Contains</B>(<B>const <A HREF="wx_wxpoint.html#wxpoint">wxPoint</A>& </B></B><I>pt</I>) <B>const</B><P>
  108. Returns <TT>true</TT> if the given point is inside the rectangle (or on its
  109. boundary) and <TT>false</TT> otherwise.<P>
  110. <B>bool</B> <B>Contains</B>(<B>const <A HREF="wx_wxrect.html#wxrect">wxRect</A>& </B></B><I>rect</I>) <B>const</B><P>
  111. Returns <TT>true</TT> if the given rectangle is completely inside this rectangle
  112. (or touches its boundary) and <TT>false</TT> otherwise.<P>
  113. <HR>
  114. <A NAME="wxrectdeflate"></A>
  115. <H3>wxRect::Deflate</H3>
  116. <P>
  117. <B>void</B> <B>Deflate</B>(<B>wxCoord </B><I>dx</I>, <B>wxCoord </B><I>dy</I>)<P>
  118. <B>void</B> <B>Deflate</B>(<B>const <A HREF="wx_wxsize.html#wxsize">wxSize</A>& </B></B><I>diff</I>)<P>
  119. <B>void</B> <B>Deflate</B>(<B>wxCoord </B><I>diff</I>)<P>
  120. <B><A HREF="wx_wxrect.html#wxrect">wxRect</A></B> </B> <B>Deflate</B>(<B>wxCoord </B><I>dx</I>, <B>wxCoord </B><I>dy</I>) <B>const</B><P>
  121. Decrease the rectangle size.<P>
  122. This method is the opposite from <A HREF="wx_wxrect.html#wxrectinflate">Inflate</A>:
  123. Deflate(a, b) is equivalent to Inflate(-a, -b).
  124. Please refer to <A HREF="wx_wxrect.html#wxrectinflate">Inflate</A> for full description.<P>
  125. <B><FONT COLOR="#FF0000">See also</FONT></B><P>
  126. <A HREF="wx_wxrect.html#wxrectinflate">Inflate</A><P>
  127. <HR>
  128. <A NAME="wxrectgetbottom"></A>
  129. <H3>wxRect::GetBottom</H3>
  130. <P>
  131. <B>int</B> <B>GetBottom</B>() <B>const</B><P>
  132. Gets the bottom point of the rectangle.<P>
  133. <HR>
  134. <A NAME="wxrectgetheight"></A>
  135. <H3>wxRect::GetHeight</H3>
  136. <P>
  137. <B>int</B> <B>GetHeight</B>() <B>const</B><P>
  138. Gets the height member.<P>
  139. <HR>
  140. <A NAME="wxrectgetleft"></A>
  141. <H3>wxRect::GetLeft</H3>
  142. <P>
  143. <B>int</B> <B>GetLeft</B>() <B>const</B><P>
  144. Gets the left point of the rectangle (the same as <A HREF="wx_wxrect.html#wxrectgetx">wxRect::GetX</A>).<P>
  145. <HR>
  146. <A NAME="wxrectgetposition"></A>
  147. <H3>wxRect::GetPosition</H3>
  148. <P>
  149. <B><A HREF="wx_wxpoint.html#wxpoint">wxPoint</A></B> </B> <B>GetPosition</B>() <B>const</B><P>
  150. Gets the position.<P>
  151. <HR>
  152. <A NAME="wxrectgettopleft"></A>
  153. <H3>wxRect::GetTopLeft</H3>
  154. <P>
  155. <B><A HREF="wx_wxpoint.html#wxpoint">wxPoint</A></B> </B> <B>GetTopLeft</B>() <B>const</B><P>
  156. Gets the position of the top left corner of the rectangle, same as
  157. <A HREF="wx_wxrect.html#wxrectgetposition">GetPosition</A>.<P>
  158. <HR>
  159. <A NAME="wxrectgettopright"></A>
  160. <H3>wxRect::GetTopRight</H3>
  161. <P>
  162. <B><A HREF="wx_wxpoint.html#wxpoint">wxPoint</A></B> </B> <B>GetTopRight</B>() <B>const</B><P>
  163. Gets the position of the top right corner.<P>
  164. <HR>
  165. <A NAME="wxrectgetbottomleft"></A>
  166. <H3>wxRect::GetBottomLeft</H3>
  167. <P>
  168. <B><A HREF="wx_wxpoint.html#wxpoint">wxPoint</A></B> </B> <B>GetBottomLeft</B>() <B>const</B><P>
  169. Gets the position of the bottom left corner.<P>
  170. <HR>
  171. <A NAME="wxrectgetbottomright"></A>
  172. <H3>wxRect::GetBottomRight</H3>
  173. <P>
  174. <B><A HREF="wx_wxpoint.html#wxpoint">wxPoint</A></B> </B> <B>GetBottomRight</B>() <B>const</B><P>
  175. Gets the position of the bottom right corner.<P>
  176. <HR>
  177. <A NAME="wxrectgetright"></A>
  178. <H3>wxRect::GetRight</H3>
  179. <P>
  180. <B>int</B> <B>GetRight</B>() <B>const</B><P>
  181. Gets the right point of the rectangle.<P>
  182. <HR>
  183. <A NAME="wxrectgetsize"></A>
  184. <H3>wxRect::GetSize</H3>
  185. <P>
  186. <B><A HREF="wx_wxsize.html#wxsize">wxSize</A></B> </B> <B>GetSize</B>() <B>const</B><P>
  187. Gets the size.<P>
  188. <B><FONT COLOR="#FF0000">See also</FONT></B><P>
  189. <A HREF="wx_wxrect.html#wxrectsetsize">wxRect::SetSize</A><P>
  190. <HR>
  191. <A NAME="wxrectgettop"></A>
  192. <H3>wxRect::GetTop</H3>
  193. <P>
  194. <B>int</B> <B>GetTop</B>() <B>const</B><P>
  195. Gets the top point of the rectangle (the same as <A HREF="wx_wxrect.html#wxrectgety">wxRect::GetY</A>).<P>
  196. <HR>
  197. <A NAME="wxrectgetwidth"></A>
  198. <H3>wxRect::GetWidth</H3>
  199. <P>
  200. <B>int</B> <B>GetWidth</B>() <B>const</B><P>
  201. Gets the width member.<P>
  202. <HR>
  203. <A NAME="wxrectgetx"></A>
  204. <H3>wxRect::GetX</H3>
  205. <P>
  206. <B>int</B> <B>GetX</B>() <B>const</B><P>
  207. Gets the x member.<P>
  208. <HR>
  209. <A NAME="wxrectgety"></A>
  210. <H3>wxRect::GetY</H3>
  211. <P>
  212. <B>int</B> <B>GetY</B>() <B>const</B><P>
  213. Gets the y member.<P>
  214. <HR>
  215. <A NAME="wxrectinflate"></A>
  216. <H3>wxRect::Inflate</H3>
  217. <P>
  218. <B>void</B> <B>Inflate</B>(<B>wxCoord </B><I>dx</I>, <B>wxCoord </B><I>dy</I>)<P>
  219. <B>void</B> <B>Inflate</B>(<B>const <A HREF="wx_wxsize.html#wxsize">wxSize</A>& </B></B><I>diff</I>)<P>
  220. <B>void</B> <B>Inflate</B>(<B>wxCoord </B><I>diff</I>)<P>
  221. <B><A HREF="wx_wxrect.html#wxrect">wxRect</A></B> </B> <B>Inflate</B>(<B>wxCoord </B><I>dx</I>, <B>wxCoord </B><I>dy</I>) <B>const</B><P>
  222. Increases the size of the rectangle.<P>
  223. The second form uses the same <I>diff</I> for both <I>dx</I> and <I>dy</I>.<P>
  224. The first two versions modify the rectangle in place, the last one returns a
  225. new rectangle leaving this one unchanged.<P>
  226. The left border is moved farther left and the right border is moved farther
  227. right by <I>dx</I>. The upper border is moved farther up and the bottom border
  228. is moved farther down by <I>dy</I>. (Note the the width and height of the
  229. rectangle thus change by 2*<I>dx</I> and 2*<I>dy</I>, respectively.) If one or
  230. both of <I>dx</I> and <I>dy</I> are negative, the opposite happens: the rectangle
  231. size decreases in the respective direction.<P>
  232. Inflating and deflating behaves "naturally''. Defined more precisely, that
  233. means:
  234. <OL>
  235. <LI> "Real'' inflates (that is, <I>dx</I> and/or <I>dy</I> &gt;= 0) are not
  236. constrained. Thus inflating a rectangle can cause its upper left corner
  237. to move into the negative numbers. (the versions prior to 2.5.4 forced
  238. the top left coordinate to not fall below (0, 0), which implied a
  239. forced move of the rectangle.)<P>
  240. <LI> Deflates are clamped to not reduce the width or height of the
  241. rectangle below zero. In such cases, the top-left corner is nonetheless
  242. handled properly. For example, a rectangle at (10, 10) with size (20,
  243. 40) that is inflated by (-15, -15) will become located at (20, 25) at
  244. size (0, 10). Finally, observe that the width and height are treated
  245. independently. In the above example, the width is reduced by 20,
  246. whereas the height is reduced by the full 30 (rather than also stopping
  247. at 20, when the width reached zero).
  248. </OL>
  249. <P>
  250. <B><FONT COLOR="#FF0000">See also</FONT></B><P>
  251. <A HREF="wx_wxrect.html#wxrectdeflate">Deflate</A><P>
  252. <HR>
  253. <A NAME="wxrectintersect"></A>
  254. <H3>wxRect::Intersect</H3>
  255. <P>
  256. <B><A HREF="wx_wxrect.html#wxrect">wxRect</A></B> </B> <B>Intersect</B>(<B>const <A HREF="wx_wxrect.html#wxrect">wxRect</A>& </B></B><I>rect</I>) <B>const</B><P>
  257. <B><A HREF="wx_wxrect.html#wxrect">wxRect</A>&</B> </B> <B>Intersect</B>(<B>const <A HREF="wx_wxrect.html#wxrect">wxRect</A>& </B></B><I>rect</I>)<P>
  258. Modifies the rectangle to contain the overlapping box of this rectangle and the
  259. one passed in as parameter. The const version returns the new rectangle, the
  260. other one modifies this rectangle in place.<P>
  261. <HR>
  262. <A NAME="wxrectintersects"></A>
  263. <H3>wxRect::Intersects</H3>
  264. <P>
  265. <B>bool</B> <B>Intersects</B>(<B>const <A HREF="wx_wxrect.html#wxrect">wxRect</A>& </B></B><I>rect</I>) <B>const</B><P>
  266. Returns <TT>true</TT> if this rectangle has a non-empty intersection with the
  267. rectangle <I>rect</I> and <TT>false</TT> otherwise.<P>
  268. <HR>
  269. <A NAME="wxrectisempty"></A>
  270. <H3>wxRect::IsEmpty</H3>
  271. <P>
  272. <B>bool</B> <B>IsEmpty</B>() <B>const</B><P>
  273. Returns <TT>true</TT> if this rectangle has a width or height less than or equal to
  274. 0 and <TT>false</TT> otherwise.<P>
  275. <HR>
  276. <A NAME="wxrectoffset"></A>
  277. <H3>wxRect::Offset</H3>
  278. <P>
  279. <B>void</B> <B>Offset</B>(<B>wxCoord </B><I>dx</I>, <B>wxCoord </B><I>dy</I>)<P>
  280. <B>void</B> <B>Offset</B>(<B>const <A HREF="wx_wxpoint.html#wxpoint">wxPoint</A>& </B></B><I>pt</I>)<P>
  281. Moves the rectangle by the specified offset. If <I>dx</I> is positive, the
  282. rectangle is moved to the right, if <I>dy</I> is positive, it is moved to the
  283. bottom, otherwise it is moved to the left or top respectively.<P>
  284. <HR>
  285. <A NAME="wxrectsetheight"></A>
  286. <H3>wxRect::SetHeight</H3>
  287. <P>
  288. <B>void</B> <B>SetHeight</B>(<B>int</B><I> height</I>)<P>
  289. Sets the height.<P>
  290. <HR>
  291. <A NAME="wxrectsetsize"></A>
  292. <H3>wxRect::SetSize</H3>
  293. <P>
  294. <B>void</B> <B>SetSize</B>(<B>const <A HREF="wx_wxsize.html#wxsize">wxSize</A>&</B></B><I> s</I>)<P>
  295. Sets the size.<P>
  296. <B><FONT COLOR="#FF0000">See also</FONT></B><P>
  297. <A HREF="wx_wxrect.html#wxrectgetsize">wxRect::GetSize</A><P>
  298. <HR>
  299. <A NAME="wxrectsetwidth"></A>
  300. <H3>wxRect::SetWidth</H3>
  301. <P>
  302. <B>void</B> <B>SetWidth</B>(<B>int</B><I> width</I>)<P>
  303. Sets the width.<P>
  304. <HR>
  305. <A NAME="wxrectsetx"></A>
  306. <H3>wxRect::SetX</H3>
  307. <P>
  308. <B>void</B> <B>SetX</B>(<B>int</B><I> x</I>)<P>
  309. Sets the x position.<P>
  310. <HR>
  311. <A NAME="wxrectsety"></A>
  312. <H3>wxRect::SetY</H3>
  313. <P>
  314. <B>void</B> <B>SetY</B>(<B>int</B><I> y</I>)<P>
  315. Sets the y position.<P>
  316. <HR>
  317. <A NAME="wxrectunion"></A>
  318. <H3>wxRect::Union</H3>
  319. <P>
  320. <B><A HREF="wx_wxrect.html#wxrect">wxRect</A></B> </B> <B>Union</B>(<B>const <A HREF="wx_wxrect.html#wxrect">wxRect</A>&</B></B><I> rect</I>) <B>const</B><P>
  321. <B><A HREF="wx_wxrect.html#wxrect">wxRect</A>&</B> </B> <B>Union</B>(<B>const <A HREF="wx_wxrect.html#wxrect">wxRect</A>&</B></B><I> rect</I>)<P>
  322. Modifies the rectangle to contain the bounding box of this rectangle and the
  323. one passed in as parameter. The const version returns the new rectangle, the
  324. other one modifies this rectangle in place.<P>
  325. <HR>
  326. <A NAME="wxrectassign"></A>
  327. <H3>wxRect::operator =</H3>
  328. <P>
  329. <B>void</B> <B>operator =</B>(<B>const <A HREF="wx_wxrect.html#wxrect">wxRect</A>& </B></B><I>rect</I>)<P>
  330. Assignment operator.<P>
  331. <HR>
  332. <A NAME="wxrectequal"></A>
  333. <H3>wxRect::operator ==</H3>
  334. <P>
  335. <B>bool</B> <B>operator ==</B>(<B>const <A HREF="wx_wxrect.html#wxrect">wxRect</A>& </B></B><I>rect</I>)<P>
  336. Equality operator.<P>
  337. <HR>
  338. <A NAME="wxrectnotequal"></A>
  339. <H3>wxRect::operator !=</H3>
  340. <P>
  341. <B>bool</B> <B>operator !=</B>(<B>const <A HREF="wx_wxrect.html#wxrect">wxRect</A>& </B></B><I>rect</I>)<P>
  342. Inequality operator.<P>
  343. </FONT></BODY></HTML>