1//--------------------------------------------------------------------------- 2// This file is generated by wxPython's SIP generator. Do not edit by hand. 3// 4// Copyright: (c) 2018 by Total Control Software 5// License: wxWindows License 6// 7// This file will be included by _core.sip 8// 9//--------------------------------------------------------------------------- 10 11//--------------------------------------------------------------------------- 12 13enum wxRegionContain 14{ 15 wxOutRegion, 16 wxPartRegion, 17 wxInRegion 18}; 19 20class wxRegionIterator : wxObject 21{ 22 %Docstring 23 RegionIterator() 24 RegionIterator(region) 25 26 This class is used to iterate through the rectangles in a region, 27 typically when examining the damaged regions of a window within an 28 OnPaint call. 29 %End 30 %TypeHeaderCode 31 #include <wx/region.h> 32 %End 33 34public: 35 wxRegionIterator(); 36 %PreMethodCode 37 if (!wxPyCheckForApp()) return NULL; 38 %End 39 40 wxRegionIterator( 41 const wxRegion & region 42 ); 43 %PreMethodCode 44 if (!wxPyCheckForApp()) return NULL; 45 %End 46 47 wxCoord GetH() const; 48 %Docstring 49 GetH() -> Coord 50 51 An alias for GetHeight(). 52 %End 53 54 wxCoord GetHeight() const; 55 %Docstring 56 GetHeight() -> Coord 57 58 Returns the height value for the current region. 59 %End 60 61 wxRect GetRect() const; 62 %Docstring 63 GetRect() -> Rect 64 65 Returns the current rectangle. 66 %End 67 68 wxCoord GetW() const; 69 %Docstring 70 GetW() -> Coord 71 72 An alias for GetWidth(). 73 %End 74 75 wxCoord GetWidth() const; 76 %Docstring 77 GetWidth() -> Coord 78 79 Returns the width value for the current region. 80 %End 81 82 wxCoord GetX() const; 83 %Docstring 84 GetX() -> Coord 85 86 Returns the x value for the current region. 87 %End 88 89 wxCoord GetY() const; 90 %Docstring 91 GetY() -> Coord 92 93 Returns the y value for the current region. 94 %End 95 96 bool HaveRects() const; 97 %Docstring 98 HaveRects() -> bool 99 100 Returns true if there are still some rectangles; otherwise returns 101 false. 102 %End 103 104 void Reset(); 105 %Docstring 106 Reset() 107 Reset(region) 108 109 Resets the iterator to the beginning of the rectangles. 110 %End 111 112 void Reset( 113 const wxRegion & region 114 ); 115 116 int __nonzero__(); 117 %Docstring 118 __nonzero__() -> int 119 120 Returns true while there are still rectangles available in the 121 iteration. 122 %End 123 %MethodCode 124 PyErr_Clear(); 125 Py_BEGIN_ALLOW_THREADS 126 sipRes = _wxRegionIterator___nonzero__(sipCpp); 127 Py_END_ALLOW_THREADS 128 if (PyErr_Occurred()) sipIsErr = 1; 129 %End 130 %TypeCode 131 int _wxRegionIterator___nonzero__(wxRegionIterator* self) 132 { 133 return (int)self->operator bool(); 134 } 135 %End 136 137 void Next(); 138 %Docstring 139 Next() 140 141 Move the iterator to the next rectangle in the region. 142 %End 143 %MethodCode 144 PyErr_Clear(); 145 Py_BEGIN_ALLOW_THREADS 146 _wxRegionIterator_Next(sipCpp); 147 Py_END_ALLOW_THREADS 148 if (PyErr_Occurred()) sipIsErr = 1; 149 %End 150 %TypeCode 151 void _wxRegionIterator_Next(wxRegionIterator* self) 152 { 153 self->operator++(); 154 } 155 %End 156 157 public: 158 159 160 %Property(name=H, get=GetH) 161 %Property(name=Height, get=GetHeight) 162 %Property(name=Rect, get=GetRect) 163 %Property(name=W, get=GetW) 164 %Property(name=Width, get=GetWidth) 165 %Property(name=X, get=GetX) 166 %Property(name=Y, get=GetY) 167}; // end of class wxRegionIterator 168 169 170class wxRegion : wxGDIObject 171{ 172 %Docstring 173 Region() 174 Region(x, y, width, height) 175 Region(topLeft, bottomRight) 176 Region(rect) 177 Region(region) 178 Region(bmp) 179 Region(bmp, transColour, tolerance=0) 180 Region(points, fillStyle=ODDEVEN_RULE) 181 182 A wxRegion represents a simple or complex region on a device context 183 or window. 184 %End 185 %TypeHeaderCode 186 #include <wx/region.h> 187 %End 188 189 %TypeCode 190 // Convert a Python sequence of wxPoint objects, or items that can be converted 191 // to wxPoint into a C array of wxPoint instances. 192 static 193 wxPoint* wxPoint_array_helper(PyObject* source, size_t *count) 194 { 195 wxPoint* array; 196 Py_ssize_t idx, len; 197 wxPyThreadBlocker blocker; 198 199 // ensure that it is a sequence 200 if (! PySequence_Check(source)) 201 goto error0; 202 // ensure it is not a string or unicode object (they are sequences too) 203 else if (PyBytes_Check(source) || PyUnicode_Check(source)) 204 goto error0; 205 // ensure each item can be converted to wxPoint 206 else { 207 len = PySequence_Length(source); 208 for (idx=0; idx<len; idx++) { 209 PyObject* item = PySequence_ITEM(source, idx); 210 if (!sipCanConvertToType(item, sipType_wxPoint, SIP_NOT_NONE)) { 211 Py_DECREF(item); 212 goto error0; 213 } 214 Py_DECREF(item); 215 } 216 } 217 218 // The length of the sequence is returned in count. 219 *count = len; 220 array = new wxPoint[*count]; 221 if (!array) { 222 PyErr_SetString(PyExc_MemoryError, "Unable to allocate temporary array"); 223 return NULL; 224 } 225 for (idx=0; idx<len; idx++) { 226 PyObject* obj = PySequence_ITEM(source, idx); 227 int state = 0; 228 int err = 0; 229 wxPoint* item = reinterpret_cast<wxPoint*>( 230 sipConvertToType(obj, sipType_wxPoint, NULL, 0, &state, &err)); 231 array[idx] = *item; 232 sipReleaseType((void*)item, sipType_wxPoint, state); // delete temporary instances 233 Py_DECREF(obj); 234 } 235 return array; 236 237 error0: 238 PyErr_SetString(PyExc_TypeError, "Expected a sequence of length-2 sequences or wx.Point objects."); 239 return NULL; 240 } 241 %End 242public: 243 wxRegion(); 244 %PreMethodCode 245 if (!wxPyCheckForApp()) return NULL; 246 %End 247 248 wxRegion( 249 wxCoord x, 250 wxCoord y, 251 wxCoord width, 252 wxCoord height 253 ); 254 %PreMethodCode 255 if (!wxPyCheckForApp()) return NULL; 256 %End 257 258 wxRegion( 259 const wxPoint & topLeft, 260 const wxPoint & bottomRight 261 ); 262 %PreMethodCode 263 if (!wxPyCheckForApp()) return NULL; 264 %End 265 266 wxRegion( 267 const wxRect & rect 268 ); 269 %PreMethodCode 270 if (!wxPyCheckForApp()) return NULL; 271 %End 272 273 wxRegion( 274 const wxRegion & region 275 ); 276 %PreMethodCode 277 if (!wxPyCheckForApp()) return NULL; 278 %End 279 280 wxRegion( 281 const wxBitmap & bmp 282 ); 283 %PreMethodCode 284 if (!wxPyCheckForApp()) return NULL; 285 %End 286 287 wxRegion( 288 const wxBitmap & bmp, 289 const wxColour & transColour, 290 int tolerance = 0 291 ); 292 %PreMethodCode 293 if (!wxPyCheckForApp()) return NULL; 294 %End 295 296 wxRegion(PyObject* points, wxPolygonFillMode fillStyle = wxODDEVEN_RULE) /NoDerived/; 297 %MethodCode 298 size_t count; 299 wxPoint* array = wxPoint_array_helper(points, &count); 300 if ( array != NULL ) { 301 sipCpp = new wxRegion(count, array, fillStyle); 302 delete [] array; 303 } 304 if (PyErr_Occurred()) sipIsErr = 1; 305 %End 306 307 ~wxRegion(); 308 309 wxRect GetBox() const; 310 %Docstring 311 GetBox() -> Rect 312 313 Returns the outer bounds of the region. 314 %End 315 316 bool Offset( 317 wxCoord x, 318 wxCoord y 319 ); 320 %Docstring 321 Offset(x, y) -> bool 322 Offset(pt) -> bool 323 324 Moves the region by the specified offsets in horizontal and vertical 325 directions. 326 %End 327 328 bool Offset( 329 const wxPoint & pt 330 ); 331 332 void Clear(); 333 %Docstring 334 Clear() 335 336 Clears the current region. 337 %End 338 339 wxRegionContain Contains( 340 wxCoord x, 341 wxCoord y 342 ) const; 343 %Docstring 344 Contains(x, y) -> RegionContain 345 Contains(pt) -> RegionContain 346 Contains(x, y, width, height) -> RegionContain 347 Contains(rect) -> RegionContain 348 349 Returns a value indicating whether the given point is contained within 350 the region. 351 %End 352 353 wxRegionContain Contains( 354 const wxPoint & pt 355 ) const; 356 357 wxRegionContain Contains( 358 wxCoord x, 359 wxCoord y, 360 wxCoord width, 361 wxCoord height 362 ) const; 363 364 wxRegionContain Contains( 365 const wxRect & rect 366 ) const; 367 368 wxBitmap ConvertToBitmap() const; 369 %Docstring 370 ConvertToBitmap() -> Bitmap 371 372 Convert the region to a black and white bitmap with the white pixels 373 being inside the region. 374 %End 375 376 bool Intersect( 377 wxCoord x, 378 wxCoord y, 379 wxCoord width, 380 wxCoord height 381 ); 382 %Docstring 383 Intersect(x, y, width, height) -> bool 384 Intersect(rect) -> bool 385 Intersect(region) -> bool 386 387 Finds the intersection of this region and another, rectangular region, 388 specified using position and size. 389 %End 390 391 bool Intersect( 392 const wxRect & rect 393 ); 394 395 bool Intersect( 396 const wxRegion & region 397 ); 398 399 bool IsEmpty() const; 400 %Docstring 401 IsEmpty() -> bool 402 403 Returns true if the region is empty, false otherwise. 404 %End 405 406 bool IsEqual( 407 const wxRegion & region 408 ) const; 409 %Docstring 410 IsEqual(region) -> bool 411 412 Returns true if the region is equal to, i.e. covers the same area as, 413 another one. 414 %End 415 416 bool Subtract( 417 const wxRect & rect 418 ); 419 %Docstring 420 Subtract(rect) -> bool 421 Subtract(region) -> bool 422 423 Subtracts a rectangular region from this region. 424 %End 425 426 bool Subtract( 427 const wxRegion & region 428 ); 429 430 bool Union( 431 wxCoord x, 432 wxCoord y, 433 wxCoord width, 434 wxCoord height 435 ); 436 %Docstring 437 Union(x, y, width, height) -> bool 438 Union(rect) -> bool 439 Union(region) -> bool 440 Union(bmp) -> bool 441 Union(bmp, transColour, tolerance=0) -> bool 442 443 Finds the union of this region and another, rectangular region, 444 specified using position and size. 445 %End 446 447 bool Union( 448 const wxRect & rect 449 ); 450 451 bool Union( 452 const wxRegion & region 453 ); 454 455 bool Union( 456 const wxBitmap & bmp 457 ); 458 459 bool Union( 460 const wxBitmap & bmp, 461 const wxColour & transColour, 462 int tolerance = 0 463 ); 464 465 bool Xor( 466 wxCoord x, 467 wxCoord y, 468 wxCoord width, 469 wxCoord height 470 ); 471 %Docstring 472 Xor(x, y, width, height) -> bool 473 Xor(rect) -> bool 474 Xor(region) -> bool 475 476 Finds the Xor of this region and another, rectangular region, 477 specified using position and size. 478 %End 479 480 bool Xor( 481 const wxRect & rect 482 ); 483 484 bool Xor( 485 const wxRegion & region 486 ); 487 488 public: 489 490 491 %Property(name=Box, get=GetBox) 492}; // end of class wxRegion 493 494 495%Extract(id=pycode_core) 496def _Region___iter__(self): 497 """ 498 Returns a rectangle interator conforming to the Python iterator 499 protocol. 500 """ 501 return PyRegionIterator(self) 502Region.__iter__ = _Region___iter__ 503del _Region___iter__ 504%End 505 506%Extract(id=pycode_core) 507class PyRegionIterator(object): 508 "A Python iterator for wx.Region objects" 509 def __init__(self, region): 510 self._region = region 511 self._iterator = wx.RegionIterator(region) 512 def next(self): 513 if not self._iterator: 514 raise StopIteration 515 rect = self._iterator.GetRect() 516 if self._iterator.HaveRects(): 517 self._iterator.Next() 518 return rect 519 __next__ = next # for Python 3 520 521%End 522 523 524//--------------------------------------------------------------------------- 525 526