]>
Commit | Line | Data |
---|---|---|
a660d684 KB |
1 | \section{\class{wxRect}}\label{wxrect} |
2 | ||
3 | A class for manipulating rectangles. | |
4 | ||
5 | \wxheading{Derived from} | |
6 | ||
9838df2c | 7 | None |
a660d684 | 8 | |
954b8ae6 JS |
9 | \wxheading{Include files} |
10 | ||
11 | <wx/gdicmn.h> | |
12 | ||
a7af285d VZ |
13 | \wxheading{Library} |
14 | ||
15 | \helpref{wxCore}{librarieslist} | |
16 | ||
a660d684 KB |
17 | \wxheading{See also} |
18 | ||
19 | \helpref{wxPoint}{wxpoint}, \helpref{wxSize}{wxsize} | |
20 | ||
21 | \latexignore{\rtfignore{\wxheading{Members}}} | |
22 | ||
df83b840 | 23 | |
39275175 | 24 | \membersection{wxRect::wxRect}\label{wxrectctor} |
a660d684 KB |
25 | |
26 | \func{}{wxRect}{\void} | |
27 | ||
28 | Default constructor. | |
29 | ||
eaaa6a06 | 30 | \func{}{wxRect}{\param{int}{ x}, \param{int}{ y}, \param{int}{ width}, \param{int}{ height}} |
a660d684 KB |
31 | |
32 | Creates a wxRect object from x, y, width and height values. | |
33 | ||
34 | \func{}{wxRect}{\param{const wxPoint\&}{ topLeft}, \param{const wxPoint\&}{ bottomRight}} | |
35 | ||
36 | Creates a wxRect object from top-left and bottom-right points. | |
37 | ||
38 | \func{}{wxRect}{\param{const wxPoint\&}{ pos}, \param{const wxSize\&}{ size}} | |
39 | ||
40 | Creates a wxRect object from position and size values. | |
41 | ||
8d8fbb9d WS |
42 | \func{}{wxRect}{\param{const wxSize\&}{ size}} |
43 | ||
44 | Creates a wxRect object from size values at the origin. | |
45 | ||
df83b840 | 46 | |
39275175 | 47 | \membersection{wxRect::x}\label{wxrectx} |
a660d684 KB |
48 | |
49 | \member{int}{x} | |
50 | ||
f6bcfd97 | 51 | x coordinate of the top-level corner of the rectangle. |
a660d684 | 52 | |
df83b840 | 53 | |
39275175 | 54 | \membersection{wxRect::y}\label{wxrecty} |
a660d684 KB |
55 | |
56 | \member{int}{y} | |
57 | ||
f6bcfd97 | 58 | y coordinate of the top-level corner of the rectangle. |
a660d684 | 59 | |
df83b840 | 60 | |
39275175 | 61 | \membersection{wxRect::width}\label{wxrectwidth} |
a660d684 KB |
62 | |
63 | \member{int}{width} | |
64 | ||
65 | Width member. | |
66 | ||
df83b840 | 67 | |
39275175 | 68 | \membersection{wxRect::height}\label{wxrectheight} |
a660d684 KB |
69 | |
70 | \member{int}{height} | |
71 | ||
72 | Height member. | |
73 | ||
df83b840 | 74 | |
1bfb73b8 VZ |
75 | \membersection{wxRect::CentreIn}\label{wxrectcentrein} |
76 | ||
77 | \constfunc{wxRect}{CentreIn}{\param{const wxRect\& }{r}, \param{int }{dir = wxBOTH}} | |
78 | ||
79 | \constfunc{wxRect}{CenterIn}{\param{const wxRect\& }{r}, \param{int }{dir = wxBOTH}} | |
80 | ||
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. | |
86 | ||
87 | ||
23621b35 VS |
88 | \membersection{wxRect::Contains}\label{wxrectcontains} |
89 | ||
90 | \constfunc{bool}{Contains}{\param{int }{x}, \param{int }{y}} | |
91 | ||
92 | \constfunc{bool}{Contains}{\param{const wxPoint\& }{pt}} | |
93 | ||
94 | Returns {\tt true} if the given point is inside the rectangle (or on its | |
95 | boundary) and {\tt false} otherwise. | |
96 | ||
97 | \constfunc{bool}{Contains}{\param{const wxRect\& }{rect}} | |
98 | ||
99 | Returns \true if the given rectangle is completely inside this rectangle | |
100 | (or touches its boundary) and \false otherwise. | |
101 | ||
102 | ||
f4c43a17 VZ |
103 | \membersection{wxRect::Deflate}\label{wxrectdeflate} |
104 | ||
105 | \func{void}{Deflate}{\param{wxCoord }{dx}, \param{wxCoord }{dy}} | |
106 | ||
c2c4d939 VZ |
107 | \func{void}{Deflate}{\param{const wxSize\& }{diff}} |
108 | ||
f4c43a17 VZ |
109 | \func{void}{Deflate}{\param{wxCoord }{diff}} |
110 | ||
111 | \constfunc{wxRect}{Deflate}{\param{wxCoord }{dx}, \param{wxCoord }{dy}} | |
112 | ||
8673a125 | 113 | Decrease the rectangle size. |
f4c43a17 | 114 | |
8673a125 VZ |
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. | |
f4c43a17 VZ |
118 | |
119 | \wxheading{See also} | |
120 | ||
121 | \helpref{Inflate}{wxrectinflate} | |
122 | ||
df83b840 | 123 | |
a660d684 KB |
124 | \membersection{wxRect::GetBottom}\label{wxrectgetbottom} |
125 | ||
126 | \constfunc{int}{GetBottom}{\void} | |
127 | ||
128 | Gets the bottom point of the rectangle. | |
129 | ||
df83b840 | 130 | |
a660d684 KB |
131 | \membersection{wxRect::GetHeight}\label{wxrectgetheight} |
132 | ||
133 | \constfunc{int}{GetHeight}{\void} | |
134 | ||
135 | Gets the height member. | |
136 | ||
df83b840 | 137 | |
a660d684 KB |
138 | \membersection{wxRect::GetLeft}\label{wxrectgetleft} |
139 | ||
140 | \constfunc{int}{GetLeft}{\void} | |
141 | ||
142 | Gets the left point of the rectangle (the same as \helpref{wxRect::GetX}{wxrectgetx}). | |
143 | ||
df83b840 | 144 | |
a660d684 KB |
145 | \membersection{wxRect::GetPosition}\label{wxrectgetposition} |
146 | ||
147 | \constfunc{wxPoint}{GetPosition}{\void} | |
148 | ||
149 | Gets the position. | |
150 | ||
df83b840 | 151 | |
355a5e2b JS |
152 | \membersection{wxRect::GetTopLeft}\label{wxrectgettopleft} |
153 | ||
154 | \constfunc{wxPoint}{GetTopLeft}{\void} | |
155 | ||
f790ec82 VZ |
156 | Gets the position of the top left corner of the rectangle, same as |
157 | \helpref{GetPosition}{wxrectgetposition}. | |
158 | ||
159 | ||
160 | \membersection{wxRect::GetTopRight}\label{wxrectgettopright} | |
161 | ||
162 | \constfunc{wxPoint}{GetTopRight}{\void} | |
163 | ||
164 | Gets the position of the top right corner. | |
165 | ||
166 | ||
167 | \membersection{wxRect::GetBottomLeft}\label{wxrectgetbottomleft} | |
168 | ||
169 | \constfunc{wxPoint}{GetBottomLeft}{\void} | |
170 | ||
171 | Gets the position of the bottom left corner. | |
355a5e2b | 172 | |
df83b840 | 173 | |
355a5e2b JS |
174 | \membersection{wxRect::GetBottomRight}\label{wxrectgetbottomright} |
175 | ||
176 | \constfunc{wxPoint}{GetBottomRight}{\void} | |
177 | ||
f790ec82 | 178 | Gets the position of the bottom right corner. |
355a5e2b | 179 | |
df83b840 | 180 | |
a660d684 KB |
181 | \membersection{wxRect::GetRight}\label{wxrectgetright} |
182 | ||
183 | \constfunc{int}{GetRight}{\void} | |
184 | ||
185 | Gets the right point of the rectangle. | |
186 | ||
df83b840 | 187 | |
a660d684 KB |
188 | \membersection{wxRect::GetSize}\label{wxrectgetsize} |
189 | ||
190 | \constfunc{wxSize}{GetSize}{\void} | |
191 | ||
192 | Gets the size. | |
193 | ||
f050223c WS |
194 | \wxheading{See also} |
195 | ||
196 | \helpref{wxRect::SetSize}{wxrectsetsize} | |
197 | ||
df83b840 | 198 | |
a660d684 KB |
199 | \membersection{wxRect::GetTop}\label{wxrectgettop} |
200 | ||
201 | \constfunc{int}{GetTop}{\void} | |
202 | ||
203 | Gets the top point of the rectangle (the same as \helpref{wxRect::GetY}{wxrectgety}). | |
204 | ||
df83b840 | 205 | |
a660d684 KB |
206 | \membersection{wxRect::GetWidth}\label{wxrectgetwidth} |
207 | ||
208 | \constfunc{int}{GetWidth}{\void} | |
209 | ||
210 | Gets the width member. | |
211 | ||
df83b840 | 212 | |
a660d684 KB |
213 | \membersection{wxRect::GetX}\label{wxrectgetx} |
214 | ||
215 | \constfunc{int}{GetX}{\void} | |
216 | ||
217 | Gets the x member. | |
218 | ||
df83b840 | 219 | |
a660d684 KB |
220 | \membersection{wxRect::GetY}\label{wxrectgety} |
221 | ||
222 | \constfunc{int}{GetY}{\void} | |
223 | ||
224 | Gets the y member. | |
225 | ||
df83b840 | 226 | |
45816ddd VZ |
227 | \membersection{wxRect::Inflate}\label{wxrectinflate} |
228 | ||
229 | \func{void}{Inflate}{\param{wxCoord }{dx}, \param{wxCoord }{dy}} | |
230 | ||
c2c4d939 VZ |
231 | \func{void}{Inflate}{\param{const wxSize\& }{diff}} |
232 | ||
45816ddd VZ |
233 | \func{void}{Inflate}{\param{wxCoord }{diff}} |
234 | ||
f4c43a17 VZ |
235 | \constfunc{wxRect}{Inflate}{\param{wxCoord }{dx}, \param{wxCoord }{dy}} |
236 | ||
8673a125 | 237 | Increases the size of the rectangle. |
45816ddd VZ |
238 | |
239 | The second form uses the same {\it diff} for both {\it dx} and {\it dy}. | |
240 | ||
f4c43a17 VZ |
241 | The first two versions modify the rectangle in place, the last one returns a |
242 | new rectangle leaving this one unchanged. | |
243 | ||
8673a125 VZ |
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. | |
250 | ||
251 | Inflating and deflating behaves ``naturally''. Defined more precisely, that | |
252 | means: | |
253 | \begin{enumerate} | |
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.) | |
259 | ||
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). | |
268 | \end{enumerate} | |
269 | ||
f4c43a17 VZ |
270 | \wxheading{See also} |
271 | ||
272 | \helpref{Deflate}{wxrectdeflate} | |
273 | ||
df83b840 | 274 | |
c0f62256 | 275 | \membersection{wxRect::Intersects}\label{wxrectintersects} |
f4c43a17 VZ |
276 | |
277 | \constfunc{bool}{Intersects}{\param{const wxRect\& }{rect}} | |
278 | ||
154b6b0f | 279 | Returns {\tt true} if this rectangle has a non-empty intersection with the |
cc81d32f | 280 | rectangle {\it rect} and {\tt false} otherwise. |
f4c43a17 | 281 | |
df83b840 | 282 | |
b737ad10 RR |
283 | \membersection{wxRect::IsEmpty}\label{wxrectisempty} |
284 | ||
285 | \constfunc{bool}{IsEmpty}{} | |
286 | ||
287 | Returns {\tt true} if this rectangle has a width or height less than or equal to | |
288 | 0 and {\tt false} otherwise. | |
289 | ||
290 | ||
f4c43a17 VZ |
291 | \membersection{wxRect::Offset}\label{wxrectoffset} |
292 | ||
293 | \func{void}{Offset}{\param{wxCoord }{dx}, \param{wxCoord }{dy}} | |
294 | ||
295 | \func{void}{Offset}{\param{const wxPoint\& }{pt}} | |
296 | ||
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. | |
300 | ||
df83b840 | 301 | |
a660d684 KB |
302 | \membersection{wxRect::SetHeight}\label{wxrectsetheight} |
303 | ||
eaaa6a06 | 304 | \func{void}{SetHeight}{\param{int}{ height}} |
a660d684 KB |
305 | |
306 | Sets the height. | |
307 | ||
df83b840 | 308 | |
f050223c WS |
309 | \membersection{wxRect::SetSize}\label{wxrectsetsize} |
310 | ||
311 | \func{void}{SetSize}{\param{const wxSize\&}{ s}} | |
312 | ||
313 | Sets the size. | |
314 | ||
315 | \wxheading{See also} | |
316 | ||
317 | \helpref{wxRect::GetSize}{wxrectgetsize} | |
318 | ||
319 | ||
a660d684 KB |
320 | \membersection{wxRect::SetWidth}\label{wxrectsetwidth} |
321 | ||
eaaa6a06 | 322 | \func{void}{SetWidth}{\param{int}{ width}} |
a660d684 KB |
323 | |
324 | Sets the width. | |
325 | ||
df83b840 | 326 | |
a660d684 KB |
327 | \membersection{wxRect::SetX}\label{wxrectsetx} |
328 | ||
eaaa6a06 | 329 | \func{void}{SetX}{\param{int}{ x}} |
a660d684 KB |
330 | |
331 | Sets the x position. | |
332 | ||
df83b840 | 333 | |
a660d684 KB |
334 | \membersection{wxRect::SetY}\label{wxrectsety} |
335 | ||
eaaa6a06 | 336 | \func{void}{SetY}{\param{int}{ y}} |
a660d684 KB |
337 | |
338 | Sets the y position. | |
339 | ||
df83b840 VZ |
340 | |
341 | \membersection{wxRect::Union}\label{wxrectunion} | |
342 | ||
343 | \constfunc{wxRect}{Union}{\param{const wxRect\&}{ rect}} | |
344 | ||
345 | \func{wxRect\&}{Union}{\param{const wxRect\&}{ rect}} | |
346 | ||
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. | |
350 | ||
351 | ||
39275175 | 352 | \membersection{wxRect::operator $=$}\label{wxrectassign} |
a660d684 KB |
353 | |
354 | \func{void}{operator $=$}{\param{const wxRect\& }{rect}} | |
355 | ||
356 | Assignment operator. | |
357 | ||
df83b840 | 358 | |
39275175 | 359 | \membersection{wxRect::operator $==$}\label{wxrectequal} |
a660d684 | 360 | |
bc5e942b | 361 | \func{bool}{operator $==$}{\param{const wxRect\& }{r1}, \param{const wxRect\& }{r2}} |
a660d684 KB |
362 | |
363 | Equality operator. | |
364 | ||
df83b840 | 365 | |
39275175 | 366 | \membersection{wxRect::operator $!=$}\label{wxrectnotequal} |
a660d684 | 367 | |
bc5e942b | 368 | \func{bool}{operator $!=$}{\param{const wxRect\& }{r1}, \param{const wxRect\& }{r2}} |
a660d684 KB |
369 | |
370 | Inequality operator. | |
371 | ||
bc5e942b VZ |
372 | |
373 | \func{wxRect}{operator $+$}{\param{const wxRect\& }{r1}, \param{const wxRect\& }{r2}} | |
374 | ||
375 | \func{wxRect\&}{operator $+=$}{\param{const wxRect\& }{r}} | |
376 | ||
377 | Like \helpref{Union}{wxrectunion} but don't treat empty rectangles specially. | |
378 | ||
379 | \wxheading{See also} | |
380 | ||
381 | \helpref{wxRect::Union}{wxrectunion} | |
382 | ||
383 | ||
384 | \func{wxRect}{operator $*$}{\param{const wxRect\& }{r1}, \param{const wxRect\& }{r2}} | |
385 | ||
386 | \func{wxRect\&}{operator $*=$}{\param{const wxRect\& }{r}} | |
387 | ||
388 | Returns the intersection of two rectangles (which may be empty). | |
389 |