1 \section{\class{wxRect
}}\label{wxrect
}
3 A class for manipulating rectangles.
5 \wxheading{Derived from
}
9 \wxheading{Include files
}
15 \helpref{wxCore
}{librarieslist
}
19 \helpref{wxPoint
}{wxpoint
},
\helpref{wxSize
}{wxsize
}
21 \latexignore{\rtfignore{\wxheading{Members
}}}
24 \membersection{wxRect::wxRect
}\label{wxrectctor
}
26 \func{}{wxRect
}{\void}
30 \func{}{wxRect
}{\param{int
}{ x
},
\param{int
}{ y
},
\param{int
}{ width
},
\param{int
}{ height
}}
32 Creates a wxRect object from x, y, width and height values.
34 \func{}{wxRect
}{\param{const wxPoint\&
}{ topLeft
},
\param{const wxPoint\&
}{ bottomRight
}}
36 Creates a wxRect object from top-left and bottom-right points.
38 \func{}{wxRect
}{\param{const wxPoint\&
}{ pos
},
\param{const wxSize\&
}{ size
}}
40 Creates a wxRect object from position and size values.
42 \func{}{wxRect
}{\param{const wxSize\&
}{ size
}}
44 Creates a wxRect object from size values at the origin.
47 \membersection{wxRect::x
}\label{wxrectx
}
51 x coordinate of the top-level corner of the rectangle.
54 \membersection{wxRect::y
}\label{wxrecty
}
58 y coordinate of the top-level corner of the rectangle.
61 \membersection{wxRect::width
}\label{wxrectwidth
}
68 \membersection{wxRect::height
}\label{wxrectheight
}
75 \membersection{wxRect::CentreIn
}\label{wxrectcentrein
}
77 \constfunc{wxRect
}{CentreIn
}{\param{const wxRect\&
}{r
},
\param{int
}{dir = wxBOTH
}}
79 \constfunc{wxRect
}{CenterIn
}{\param{const wxRect\&
}{r
},
\param{int
}{dir = wxBOTH
}}
81 Returns the rectangle having the same size as this one but centered relatively
82 to the given rectangle
\arg{r
}. By default, rectangle is centred in both
83 directions but if
\arg{dir
} includes only
\texttt{wxVERTICAL
} or only
84 \texttt{wxHORIZONTAL
} flag, then it is only centered in this direction while
85 the other component of its position remains unchanged.
88 \membersection{wxRect::Contains
}\label{wxrectcontains
}
90 \constfunc{bool
}{Contains
}{\param{int
}{x
},
\param{int
}{y
}}
92 \constfunc{bool
}{Contains
}{\param{const wxPoint\&
}{pt
}}
94 Returns
{\tt true
} if the given point is inside the rectangle (or on its
95 boundary) and
{\tt false
} otherwise.
97 \constfunc{bool
}{Contains
}{\param{const wxRect\&
}{rect
}}
99 Returns
\true if the given rectangle is completely inside this rectangle
100 (or touches its boundary) and
\false otherwise.
103 \membersection{wxRect::Deflate
}\label{wxrectdeflate
}
105 \func{void
}{Deflate
}{\param{wxCoord
}{dx
},
\param{wxCoord
}{dy
}}
107 \func{void
}{Deflate
}{\param{const wxSize\&
}{diff
}}
109 \func{void
}{Deflate
}{\param{wxCoord
}{diff
}}
111 \constfunc{wxRect
}{Deflate
}{\param{wxCoord
}{dx
},
\param{wxCoord
}{dy
}}
113 Decrease the rectangle size.
115 This method is the opposite from
\helpref{Inflate
}{wxrectinflate
}:
116 Deflate(a, b) is equivalent to Inflate(-a, -b).
117 Please refer to
\helpref{Inflate
}{wxrectinflate
} for full description.
121 \helpref{Inflate
}{wxrectinflate
}
124 \membersection{wxRect::GetBottom
}\label{wxrectgetbottom
}
126 \constfunc{int
}{GetBottom
}{\void}
128 Gets the bottom point of the rectangle.
131 \membersection{wxRect::GetHeight
}\label{wxrectgetheight
}
133 \constfunc{int
}{GetHeight
}{\void}
135 Gets the height member.
138 \membersection{wxRect::GetLeft
}\label{wxrectgetleft
}
140 \constfunc{int
}{GetLeft
}{\void}
142 Gets the left point of the rectangle (the same as
\helpref{wxRect::GetX
}{wxrectgetx
}).
145 \membersection{wxRect::GetPosition
}\label{wxrectgetposition
}
147 \constfunc{wxPoint
}{GetPosition
}{\void}
152 \membersection{wxRect::GetTopLeft
}\label{wxrectgettopleft
}
154 \constfunc{wxPoint
}{GetTopLeft
}{\void}
156 Gets the position of the top left corner of the rectangle, same as
157 \helpref{GetPosition
}{wxrectgetposition
}.
160 \membersection{wxRect::GetTopRight
}\label{wxrectgettopright
}
162 \constfunc{wxPoint
}{GetTopRight
}{\void}
164 Gets the position of the top right corner.
167 \membersection{wxRect::GetBottomLeft
}\label{wxrectgetbottomleft
}
169 \constfunc{wxPoint
}{GetBottomLeft
}{\void}
171 Gets the position of the bottom left corner.
174 \membersection{wxRect::GetBottomRight
}\label{wxrectgetbottomright
}
176 \constfunc{wxPoint
}{GetBottomRight
}{\void}
178 Gets the position of the bottom right corner.
181 \membersection{wxRect::GetRight
}\label{wxrectgetright
}
183 \constfunc{int
}{GetRight
}{\void}
185 Gets the right point of the rectangle.
188 \membersection{wxRect::GetSize
}\label{wxrectgetsize
}
190 \constfunc{wxSize
}{GetSize
}{\void}
196 \helpref{wxRect::SetSize
}{wxrectsetsize
}
199 \membersection{wxRect::GetTop
}\label{wxrectgettop
}
201 \constfunc{int
}{GetTop
}{\void}
203 Gets the top point of the rectangle (the same as
\helpref{wxRect::GetY
}{wxrectgety
}).
206 \membersection{wxRect::GetWidth
}\label{wxrectgetwidth
}
208 \constfunc{int
}{GetWidth
}{\void}
210 Gets the width member.
213 \membersection{wxRect::GetX
}\label{wxrectgetx
}
215 \constfunc{int
}{GetX
}{\void}
220 \membersection{wxRect::GetY
}\label{wxrectgety
}
222 \constfunc{int
}{GetY
}{\void}
227 \membersection{wxRect::Inflate
}\label{wxrectinflate
}
229 \func{void
}{Inflate
}{\param{wxCoord
}{dx
},
\param{wxCoord
}{dy
}}
231 \func{void
}{Inflate
}{\param{const wxSize\&
}{diff
}}
233 \func{void
}{Inflate
}{\param{wxCoord
}{diff
}}
235 \constfunc{wxRect
}{Inflate
}{\param{wxCoord
}{dx
},
\param{wxCoord
}{dy
}}
237 Increases the size of the rectangle.
239 The second form uses the same
{\it diff
} for both
{\it dx
} and
{\it dy
}.
241 The first two versions modify the rectangle in place, the last one returns a
242 new rectangle leaving this one unchanged.
244 The left border is moved farther left and the right border is moved farther
245 right by
{\it dx
}. The upper border is moved farther up and the bottom border
246 is moved farther down by
{\it dy
}. (Note the the width and height of the
247 rectangle thus change by
2*
{\it dx
} and
2*
{\it dy
}, respectively.) If one or
248 both of
{\it dx
} and
{\it dy
} are negative, the opposite happens: the rectangle
249 size decreases in the respective direction.
251 Inflating and deflating behaves ``naturally''. Defined more precisely, that
254 \item ``Real'' inflates (that is,
{\it dx
} and/or
{\it dy
} >=
0) are not
255 constrained. Thus inflating a rectangle can cause its upper left corner
256 to move into the negative numbers. (the versions prior to
2.5.4 forced
257 the top left coordinate to not fall below (
0,
0), which implied a
258 forced move of the rectangle.)
260 \item Deflates are clamped to not reduce the width or height of the
261 rectangle below zero. In such cases, the top-left corner is nonetheless
262 handled properly. For example, a rectangle at (
10,
10) with size (
20,
263 40) that is inflated by (-
15, -
15) will become located at (
20,
25) at
264 size (
0,
10). Finally, observe that the width and height are treated
265 independently. In the above example, the width is reduced by
20,
266 whereas the height is reduced by the full
30 (rather than also stopping
267 at
20, when the width reached zero).
272 \helpref{Deflate
}{wxrectdeflate
}
275 \membersection{wxRect::Intersects
}\label{wxrectintersects
}
277 \constfunc{bool
}{Intersects
}{\param{const wxRect\&
}{rect
}}
279 Returns
{\tt true
} if this rectangle has a non-empty intersection with the
280 rectangle
{\it rect
} and
{\tt false
} otherwise.
283 \membersection{wxRect::IsEmpty
}\label{wxrectisempty
}
285 \constfunc{bool
}{IsEmpty
}{}
287 Returns
{\tt true
} if this rectangle has a width or height less than or equal to
288 0 and
{\tt false
} otherwise.
291 \membersection{wxRect::Offset
}\label{wxrectoffset
}
293 \func{void
}{Offset
}{\param{wxCoord
}{dx
},
\param{wxCoord
}{dy
}}
295 \func{void
}{Offset
}{\param{const wxPoint\&
}{pt
}}
297 Moves the rectangle by the specified offset. If
{\it dx
} is positive, the
298 rectangle is moved to the right, if
{\it dy
} is positive, it is moved to the
299 bottom, otherwise it is moved to the left or top respectively.
302 \membersection{wxRect::SetHeight
}\label{wxrectsetheight
}
304 \func{void
}{SetHeight
}{\param{int
}{ height
}}
309 \membersection{wxRect::SetSize
}\label{wxrectsetsize
}
311 \func{void
}{SetSize
}{\param{const wxSize\&
}{ s
}}
317 \helpref{wxRect::GetSize
}{wxrectgetsize
}
320 \membersection{wxRect::SetWidth
}\label{wxrectsetwidth
}
322 \func{void
}{SetWidth
}{\param{int
}{ width
}}
327 \membersection{wxRect::SetX
}\label{wxrectsetx
}
329 \func{void
}{SetX
}{\param{int
}{ x
}}
334 \membersection{wxRect::SetY
}\label{wxrectsety
}
336 \func{void
}{SetY
}{\param{int
}{ y
}}
341 \membersection{wxRect::Union
}\label{wxrectunion
}
343 \constfunc{wxRect
}{Union
}{\param{const wxRect\&
}{ rect
}}
345 \func{wxRect\&
}{Union
}{\param{const wxRect\&
}{ rect
}}
347 Modifies the rectangle to contain the bounding box of this rectangle and the
348 one passed in as parameter. The const version returns the new rectangle, the
349 other one modifies this rectangle in place.
352 \membersection{wxRect::operator $=$
}\label{wxrectassign
}
354 \func{void
}{operator $=$
}{\param{const wxRect\&
}{rect
}}
359 \membersection{wxRect::operator $==$
}\label{wxrectequal
}
361 \func{bool
}{operator $==$
}{\param{const wxRect\&
}{r1
},
\param{const wxRect\&
}{r2
}}
366 \membersection{wxRect::operator $!=$
}\label{wxrectnotequal
}
368 \func{bool
}{operator $!=$
}{\param{const wxRect\&
}{r1
},
\param{const wxRect\&
}{r2
}}
373 \func{wxRect
}{operator $+$
}{\param{const wxRect\&
}{r1
},
\param{const wxRect\&
}{r2
}}
375 \func{wxRect\&
}{operator $+=$
}{\param{const wxRect\&
}{r
}}
377 Like
\helpref{Union
}{wxrectunion
} but don't treat empty rectangles specially.
381 \helpref{wxRect::Union
}{wxrectunion
}
384 \func{wxRect
}{operator $*$
}{\param{const wxRect\&
}{r1
},
\param{const wxRect\&
}{r2
}}
386 \func{wxRect\&
}{operator $*=$
}{\param{const wxRect\&
}{r
}}
388 Returns the intersection of two rectangles (which may be empty).