/usr/include/wx-3.0/wx/wxPython/i_files/_gdicmn.i is in python-wxgtk3.0-dev 3.0.1.1+dfsg-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 | /////////////////////////////////////////////////////////////////////////////
// Name: _gdicmn.i
// Purpose: SWIG interface for common GDI stuff and misc classes
//
// Author: Robin Dunn
//
// Created: 13-Sept-2003
// RCS-ID: $Id$
// Copyright: (c) 2003 by Total Control Software
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
// Not a %module
//---------------------------------------------------------------------------
%newgroup
// Turn off the aquisition of the Global Interpreter Lock for the classes and
// functions in this file
%threadWrapperOff
enum wxBitmapType
{
wxBITMAP_TYPE_INVALID, // should be == 0 for compatibility!
wxBITMAP_TYPE_BMP,
wxBITMAP_TYPE_ICO,
wxBITMAP_TYPE_CUR,
wxBITMAP_TYPE_XBM,
wxBITMAP_TYPE_XBM_DATA,
wxBITMAP_TYPE_XPM,
wxBITMAP_TYPE_XPM_DATA,
wxBITMAP_TYPE_TIF,
wxBITMAP_TYPE_TIFF,
wxBITMAP_TYPE_GIF,
wxBITMAP_TYPE_PNG,
wxBITMAP_TYPE_JPEG,
wxBITMAP_TYPE_PNM,
wxBITMAP_TYPE_PCX,
wxBITMAP_TYPE_PICT,
wxBITMAP_TYPE_ICON,
wxBITMAP_TYPE_ANI,
wxBITMAP_TYPE_IFF,
wxBITMAP_TYPE_TGA,
wxBITMAP_TYPE_MACCURSOR,
// wxBITMAP_TYPE_BMP_RESOURCE,
// wxBITMAP_TYPE_RESOURCE = wxBITMAP_TYPE_BMP_RESOURCE,
// wxBITMAP_TYPE_ICO_RESOURCE,
// wxBITMAP_TYPE_CUR_RESOURCE,
// wxBITMAP_TYPE_TIF_RESOURCE,
// wxBITMAP_TYPE_GIF_RESOURCE,
// wxBITMAP_TYPE_PNG_RESOURCE,
// wxBITMAP_TYPE_JPEG_RESOURCE,
// wxBITMAP_TYPE_PNM_RESOURCE,
// wxBITMAP_TYPE_PCX_RESOURCE,
// wxBITMAP_TYPE_PICT_RESOURCE,
// wxBITMAP_TYPE_ICON_RESOURCE,
// wxBITMAP_TYPE_MACCURSOR_RESOURCE,
wxBITMAP_TYPE_MAX,
wxBITMAP_TYPE_ANY,
wxBITMAP_DEFAULT_TYPE
};
enum wxPolygonFillMode {
wxODDEVEN_RULE,
wxWINDING_RULE
};
// Standard cursors
enum wxStockCursor
{
wxCURSOR_NONE, // should be 0
wxCURSOR_ARROW,
wxCURSOR_RIGHT_ARROW,
wxCURSOR_BULLSEYE,
wxCURSOR_CHAR,
wxCURSOR_CROSS,
wxCURSOR_HAND,
wxCURSOR_IBEAM,
wxCURSOR_LEFT_BUTTON,
wxCURSOR_MAGNIFIER,
wxCURSOR_MIDDLE_BUTTON,
wxCURSOR_NO_ENTRY,
wxCURSOR_PAINT_BRUSH,
wxCURSOR_PENCIL,
wxCURSOR_POINT_LEFT,
wxCURSOR_POINT_RIGHT,
wxCURSOR_QUESTION_ARROW,
wxCURSOR_RIGHT_BUTTON,
wxCURSOR_SIZENESW,
wxCURSOR_SIZENS,
wxCURSOR_SIZENWSE,
wxCURSOR_SIZEWE,
wxCURSOR_SIZING,
wxCURSOR_SPRAYCAN,
wxCURSOR_WAIT,
wxCURSOR_WATCH,
wxCURSOR_BLANK,
wxCURSOR_DEFAULT, // standard X11 cursor
wxCURSOR_COPY_ARROW , // MacOS Theme Plus arrow
// #ifdef __X__
// // Not yet implemented for Windows
// wxCURSOR_CROSS_REVERSE,
// wxCURSOR_DOUBLE_ARROW,
// wxCURSOR_BASED_ARROW_UP,
// wxCURSOR_BASED_ARROW_DOWN,
// #endif // X11
wxCURSOR_ARROWWAIT,
wxCURSOR_OPEN_HAND,
wxCURSOR_CLOSED_HAND,
wxCURSOR_MAX
};
%{
#ifndef __WXMAC__
#define wxCURSOR_COPY_ARROW wxCURSOR_ARROW
#endif
%}
//---------------------------------------------------------------------------
%newgroup
DocStr( wxSize,
"wx.Size is a useful data structure used to represent the size of
something. It simply contains integer width and height
properties. In most places in wxPython where a wx.Size is
expected a (width, height) tuple can be used instead.", "");
class wxSize
{
public:
%Rename(width, int, x);
%Rename(height,int, y);
%pythoncode { x = width; y = height }
DocCtorStr(
wxSize(int w=0, int h=0),
"Creates a size object.", "");
~wxSize();
%extend {
DocStr(__eq__, "Test for equality of wx.Size objects.", "");
bool __eq__(PyObject* other) {
wxSize temp, *obj = &temp;
if ( other == Py_None ) return false;
if ( ! wxSize_helper(other, &obj) ) {
PyErr_Clear();
return false;
}
return *self == *obj;
}
DocStr(__ne__, "Test for inequality of wx.Size objects.", "");
bool __ne__(PyObject* other) {
wxSize temp, *obj = &temp;
if ( other == Py_None ) return true;
if ( ! wxSize_helper(other, &obj)) {
PyErr_Clear();
return true;
}
return *self != *obj;
}
DocStr(__add__, "Add sz's proprties to this and return the result.", "");
wxSize __add__(const wxSize& sz) {
return *self + sz;
}
DocStr(__sub__, "Subtract sz's properties from this and return the result.", "");
wxSize __sub__(const wxSize& sz) {
return *self - sz;
}
}
DocDeclStr(
void, IncTo(const wxSize& sz),
"Increments this object so that both of its dimensions are not less
than the corresponding dimensions of the size.", "");
DocDeclStr(
void, DecTo(const wxSize& sz),
"Decrements this object so that both of its dimensions are not greater
than the corresponding dimensions of the size.", "");
DocDeclStr(
void , IncBy(int dx, int dy),
"", "");
DocDeclStr(
void , DecBy(int dx, int dy),
"", "");
// TODO: handle these overloads too?
// void IncBy(const wxSize& sz);
// void IncBy(int d);
// void DecBy(const wxSize& sz);
// void DecBy(int d);
DocDeclStr(
void , Scale(float xscale, float yscale),
"Scales the dimensions of this object by the given factors.", "");
DocDeclStr(
void, Set(int w, int h),
"Set both width and height.", "");
void SetWidth(int w);
void SetHeight(int h);
int GetWidth() const;
int GetHeight() const;
DocDeclStr(
bool , IsFullySpecified() const,
"Returns True if both components of the size are non-default values.", "");
DocDeclStr(
void , SetDefaults(const wxSize& size),
"Combine this size with the other one replacing the default components
of this object (i.e. equal to -1) with those of the other.", "");
//int GetX() const;
//int GetY() const;
%extend {
DocAStr(Get,
"Get() -> (width,height)",
"Returns the width and height properties as a tuple.", "");
PyObject* Get() {
//wxPyBlock_t blocked = wxPyBeginBlockThreads();
PyObject* tup = PyTuple_New(2);
PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
//wxPyEndBlockThreads(blocked);
return tup;
}
}
%pythoncode {
asTuple = wx.deprecated(Get, "asTuple is deprecated, use `Get` instead")
def __str__(self): return str(self.Get())
def __repr__(self): return 'wx.Size'+str(self.Get())
def __len__(self): return len(self.Get())
def __getitem__(self, index): return self.Get()[index]
def __setitem__(self, index, val):
if index == 0: self.width = val
elif index == 1: self.height = val
else: raise IndexError
def __nonzero__(self): return self.Get() != (0,0)
__safe_for_unpickling__ = True
def __reduce__(self): return (wx.Size, self.Get())
}
};
//---------------------------------------------------------------------------
%newgroup
DocStr( wxRealPoint,
"A data structure for representing a point or position with floating
point x and y properties. In wxPython most places that expect a
wx.RealPoint can also accept a (x,y) tuple.", "");
class wxRealPoint
{
public:
double x;
double y;
DocCtorStr(
wxRealPoint(double x=0.0, double y=0.0),
"Create a wx.RealPoint object", "");
~wxRealPoint();
%extend {
DocStr(__eq__, "Test for equality of wx.RealPoint objects.", "");
bool __eq__(PyObject* other) {
wxRealPoint temp, *obj = &temp;
if ( other == Py_None ) return false;
if ( ! wxRealPoint_helper(other, &obj) ) {
PyErr_Clear();
return false;
}
return *self == *obj;
}
DocStr(__ne__, "Test for inequality of wx.RealPoint objects.", "");
bool __ne__(PyObject* other) {
wxRealPoint temp, *obj = &temp;
if ( other == Py_None ) return true;
if ( ! wxRealPoint_helper(other, &obj)) {
PyErr_Clear();
return true;
}
return *self != *obj;
}
DocStr(__add__, "Add pt's proprties to this and return the result.", "");
wxRealPoint __add__(const wxRealPoint& pt) {
return *self + pt;
}
DocStr(__sub__, "Subtract pt's properties from this and return the result.", "");
wxRealPoint __sub__(const wxRealPoint& pt) {
return *self - pt;
}
DocStr(Set, "Set both the x and y properties", "");
void Set(double x, double y) {
self->x = x;
self->y = y;
}
DocAStr(Get,
"Get() -> (x,y)",
"Return the x and y properties as a tuple. ", "");
PyObject* Get() {
//wxPyBlock_t blocked = wxPyBeginBlockThreads();
PyObject* tup = PyTuple_New(2);
PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->x));
PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->y));
//PyEndBlockThreads(blocked);
return tup;
}
}
%pythoncode {
asTuple = wx.deprecated(Get, "asTuple is deprecated, use `Get` instead")
def __str__(self): return str(self.Get())
def __repr__(self): return 'wx.RealPoint'+str(self.Get())
def __len__(self): return len(self.Get())
def __getitem__(self, index): return self.Get()[index]
def __setitem__(self, index, val):
if index == 0: self.x = val
elif index == 1: self.y = val
else: raise IndexError
def __nonzero__(self): return self.Get() != (0.0, 0.0)
__safe_for_unpickling__ = True
def __reduce__(self): return (wx.RealPoint, self.Get())
}
};
//---------------------------------------------------------------------------
%newgroup
DocStr(wxPoint,
"A data structure for representing a point or position with integer x
and y properties. Most places in wxPython that expect a wx.Point can
also accept a (x,y) tuple.", "");
class wxPoint
{
public:
int x, y;
DocCtorStr(
wxPoint(int x=0, int y=0),
"Create a wx.Point object", "");
~wxPoint();
// check if both components are set/initialized
bool IsFullySpecified() const;
// fill in the unset components with the values from the other point
void SetDefaults(const wxPoint& pt);
%extend {
DocStr(__eq__, "Test for equality of wx.Point objects.", "");
bool __eq__(PyObject* other) {
wxPoint temp, *obj = &temp;
if ( other == Py_None ) return false;
if ( ! wxPoint_helper(other, &obj) ) {
PyErr_Clear();
return false;
}
return *self == *obj;
}
DocStr(__ne__, "Test for inequality of wx.Point objects.", "");
bool __ne__(PyObject* other) {
wxPoint temp, *obj = &temp;
if ( other == Py_None ) return true;
if ( ! wxPoint_helper(other, &obj)) {
PyErr_Clear();
return true;
}
return *self != *obj;
}
DocStr(__add__, "Add pt's proprties to this and return the result.", "");
wxPoint __add__(const wxPoint& pt) {
return *self + pt;
}
DocStr(__sub__, "Subtract pt's properties from this and return the result.", "");
wxPoint __sub__(const wxPoint& pt) {
return *self - pt;
}
DocStr(Set, "Set both the x and y properties", "");
void Set(long x, long y) {
self->x = x;
self->y = y;
}
DocAStr(Get,
"Get() -> (x,y)",
"Return the x and y properties as a tuple. ", "");
PyObject* Get() {
//wxPyBlock_t blocked = wxPyBeginBlockThreads();
PyObject* tup = PyTuple_New(2);
PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
//wxPyEndBlockThreads(blocked);
return tup;
}
}
%pythoncode {
asTuple = wx.deprecated(Get, "asTuple is deprecated, use `Get` instead")
def __str__(self): return str(self.Get())
def __repr__(self): return 'wx.Point'+str(self.Get())
def __len__(self): return len(self.Get())
def __getitem__(self, index): return self.Get()[index]
def __setitem__(self, index, val):
if index == 0: self.x = val
elif index == 1: self.y = val
else: raise IndexError
def __nonzero__(self): return self.Get() != (0,0)
__safe_for_unpickling__ = True
def __reduce__(self): return (wx.Point, self.Get())
}
};
//---------------------------------------------------------------------------
%newgroup
DocStr(wxRect,
"A class for representing and manipulating rectangles. It has x, y,
width and height properties. In wxPython most palces that expect a
wx.Rect can also accept a (x,y,width,height) tuple.", "");
%typemap(in) wxRect*;
class wxRect
{
public:
DocCtorStr(
wxRect(int x=0, int y=0, int width=0, int height=0),
"Create a new Rect object.", "");
DocCtorStrName(
wxRect(const wxPoint& topLeft, const wxPoint& bottomRight),
"Create a new Rect object from Points representing two corners.", "",
RectPP);
DocCtorStrName(
wxRect(const wxPoint& pos, const wxSize& size),
"Create a new Rect from a position and size.", "",
RectPS);
DocCtorStrName(
wxRect(const wxSize& size),
"Create a new Rect from a size only.", "",
RectS);
~wxRect();
int GetX() const;
void SetX(int x);
int GetY();
void SetY(int y);
int GetWidth() const;
void SetWidth(int w);
int GetHeight() const;
void SetHeight(int h);
wxPoint GetPosition() const;
void SetPosition( const wxPoint &p );
wxSize GetSize() const;
void SetSize( const wxSize &s );
bool IsEmpty() const;
wxPoint GetTopLeft() const;
void SetTopLeft(const wxPoint &p);
wxPoint GetBottomRight() const;
void SetBottomRight(const wxPoint &p);
wxPoint GetTopRight() const;
void SetTopRight(const wxPoint &p);
wxPoint GetBottomLeft() const;
void SetBottomLeft(const wxPoint &p);
// wxPoint GetLeftTop() const;
// void SetLeftTop(const wxPoint &p);
// wxPoint GetRightBottom() const;
// void SetRightBottom(const wxPoint &p);
// wxPoint GetRightTop() const;
// void SetRightTop(const wxPoint &p);
// wxPoint GetLeftBottom() const;
// void SetLeftBottom(const wxPoint &p);
int GetLeft() const;
int GetTop() const;
int GetBottom() const;
int GetRight() const;
void SetLeft(int left);
void SetRight(int right);
void SetTop(int top);
void SetBottom(int bottom);
%pythoncode {
position = property(GetPosition, SetPosition)
size = property(GetSize, SetSize)
left = property(GetLeft, SetLeft)
right = property(GetRight, SetRight)
top = property(GetTop, SetTop)
bottom = property(GetBottom, SetBottom)
}
DocDeclStr(
wxRect, Inflate(wxCoord dx, wxCoord dy),
"Increases the size of the rectangle.
The left border is moved farther left and the right border is moved
farther right by ``dx``. The upper border is moved farther up and the
bottom border is moved farther down by ``dy``. (Note the the width and
height of the rectangle thus change by ``2*dx`` and ``2*dy``,
respectively.) If one or both of ``dx`` and ``dy`` are negative, the
opposite happens: the rectangle size decreases in the respective
direction.
The change is made to the rectangle inplace, if instead you need a
copy that is inflated, preserving the original then make the copy
first::
copy = wx.Rect(*original)
copy.Inflate(10,15)
", "
Inflating and deflating behaves *naturally*. Defined more precisely,
that means:
* Real inflates (that is, ``dx`` and/or ``dy`` >= 0) are not
constrained. Thus inflating a rectangle can cause its upper left
corner to move into the negative numbers. (The versions prior to
2.5.4 forced the top left coordinate to not fall below (0, 0),
which implied a forced move of the rectangle.)
* Deflates are clamped to not reduce the width or height of the
rectangle below zero. In such cases, the top-left corner is
nonetheless handled properly. For example, a rectangle at (10,
10) with size (20, 40) that is inflated by (-15, -15) will
become located at (20, 25) at size (0, 10). Finally, observe
that the width and height are treated independently. In the
above example, the width is reduced by 20, whereas the height is
reduced by the full 30 (rather than also stopping at 20, when
the width reached zero).
:see: `Deflate`
");
// There are also these versions...
//wxRect& Inflate(const wxSize& d);
//wxRect& Inflate(wxCoord d);
DocDeclStr(
wxRect&, Deflate(wxCoord dx, wxCoord dy),
"Decrease the rectangle size. This method is the opposite of `Inflate`
in that Deflate(a,b) is equivalent to Inflate(-a,-b). Please refer to
`Inflate` for a full description.", "");
// There are also these versions...
//wxRect& Deflate(const wxSize& d) { return Inflate(-d.x, -d.y); }
//wxRect& Deflate(wxCoord d) { return Inflate(-d); }
DocDeclStrName(
void, Offset(wxCoord dx, wxCoord dy),
"Moves the rectangle by the specified offset. If dx is positive, the
rectangle is moved to the right, if dy is positive, it is moved to the
bottom, otherwise it is moved to the left or top respectively.", "",
OffsetXY);
DocDeclStr(
void, Offset(const wxPoint& pt),
"Same as `OffsetXY` but uses dx,dy from Point", "");
DocDeclStr(
wxRect, Intersect(const wxRect& rect),
"Returns the intersectsion of this rectangle and rect.", "");
DocDeclStr(
wxRect , Union(const wxRect& rect),
"Returns the union of this rectangle and rect.", "");
%extend {
DocStr(__eq__, "Test for equality of wx.Rect objects.", "");
bool __eq__(PyObject* other) {
wxRect temp, *obj = &temp;
if ( other == Py_None ) return false;
if ( ! wxRect_helper(other, &obj) ) {
PyErr_Clear();
return false;
}
return *self == *obj;
}
DocStr(__ne__, "Test for inequality of wx.Rect objects.", "");
bool __ne__(PyObject* other) {
wxRect temp, *obj = &temp;
if ( other == Py_None ) return true;
if ( ! wxRect_helper(other, &obj)) {
PyErr_Clear();
return true;
}
return *self != *obj;
}
DocStr(__add__, "Add rect's proprties to this and return the result.", "");
wxRect __add__(const wxRect& rect) {
return *self + rect;
}
DocStr(__mul__, "Calculate the intersection of the rectangles and return the result.", "");
wxRect __mul__(const wxRect& rect) {
return *self * rect;
}
}
DocDeclStr(
wxRect&, operator+=(const wxRect& rect),
"Add the properties of rect to this rectangle, updating this rectangle.", "");
DocStr( Contains, "Return True if the point is inside the rect.", "");
%Rename(ContainsXY, bool, Contains(int x, int y) const);
bool Contains(const wxPoint& pt) const;
DocDeclStrName(
bool, Contains(const wxRect& rect) const,
"Returns ``True`` if the given rectangle is completely inside this
rectangle or touches its boundary.", "",
ContainsRect);
%pythoncode {
%#Inside = wx.deprecated(Contains, "Use `Contains` instead.")
%#InsideXY = wx.deprecated(ContainsXY, "Use `ContainsXY` instead.")
%#InsideRect = wx.deprecated(ContainsRect, "Use `ContainsRect` instead.")
Inside = Contains
InsideXY = ContainsXY
InsideRect = ContainsRect
}
DocDeclStr(
bool, Intersects(const wxRect& rect) const,
"Returns True if the rectangles have a non empty intersection.", "");
DocDeclStr(
wxRect, CenterIn(const wxRect& r, int dir = wxBOTH),
"Center this rectangle within the one passed to the method, which is
usually, but not necessarily, the larger one.", "");
%pythoncode { CentreIn = CenterIn }
int x, y, width, height;
%extend {
DocStr(Set, "Set all rectangle properties.", "");
void Set(int x=0, int y=0, int width=0, int height=0) {
self->x = x;
self->y = y;
self->width = width;
self->height = height;
}
DocAStr(Get,
"Get() -> (x,y,width,height)",
"Return the rectangle properties as a tuple.", "");
PyObject* Get() {
//wxPyBlock_t blocked = wxPyBeginBlockThreads();
PyObject* tup = PyTuple_New(4);
PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
PyTuple_SET_ITEM(tup, 2, PyInt_FromLong(self->width));
PyTuple_SET_ITEM(tup, 3, PyInt_FromLong(self->height));
//wxPyEndBlockThreads(blocked);
return tup;
}
}
%pythoncode {
asTuple = wx.deprecated(Get, "asTuple is deprecated, use `Get` instead")
def __str__(self): return str(self.Get())
def __repr__(self): return 'wx.Rect'+str(self.Get())
def __len__(self): return len(self.Get())
def __getitem__(self, index): return self.Get()[index]
def __setitem__(self, index, val):
if index == 0: self.x = val
elif index == 1: self.y = val
elif index == 2: self.width = val
elif index == 3: self.height = val
else: raise IndexError
def __nonzero__(self): return self.Get() != (0,0,0,0)
__safe_for_unpickling__ = True
def __reduce__(self): return (wx.Rect, self.Get())
}
%property(Bottom, GetBottom, SetBottom, doc="See `GetBottom` and `SetBottom`");
%property(BottomRight, GetBottomRight, SetBottomRight, doc="See `GetBottomRight` and `SetBottomRight`");
%property(BottomLeft, GetBottomLeft, SetBottomLeft, doc="See `GetBottomLeft` and `SetBottomLeft`");
%property(Height, GetHeight, SetHeight, doc="See `GetHeight` and `SetHeight`");
%property(Left, GetLeft, SetLeft, doc="See `GetLeft` and `SetLeft`");
%property(Position, GetPosition, SetPosition, doc="See `GetPosition` and `SetPosition`");
%property(Right, GetRight, SetRight, doc="See `GetRight` and `SetRight`");
%property(Size, GetSize, SetSize, doc="See `GetSize` and `SetSize`");
%property(Top, GetTop, SetTop, doc="See `GetTop` and `SetTop`");
%property(TopLeft, GetTopLeft, SetTopLeft, doc="See `GetTopLeft` and `SetTopLeft`");
%property(TopRight, GetTopRight, SetTopRight, doc="See `GetTopRight` and `SetTopRight`");
%property(Width, GetWidth, SetWidth, doc="See `GetWidth` and `SetWidth`");
%property(X, GetX, SetX, doc="See `GetX` and `SetX`");
%property(Y, GetY, SetY, doc="See `GetY` and `SetY`");
%property(Empty, IsEmpty, doc="See `IsEmpty`");
};
%apply wxRect& { wxRect* };
// this uses the thread wrappers so we have to undo it in the code below
MustHaveApp(wxIntersectRect);
DocAStr(wxIntersectRect,
"IntersectRect(Rect r1, Rect r2) -> Rect",
"Calculate and return the intersection of r1 and r2.", "");
%inline %{
PyObject* wxIntersectRect(wxRect* r1, wxRect* r2) {
wxRegion reg1(*r1);
wxRegion reg2(*r2);
wxRect dest(0,0,0,0);
PyObject* obj;
reg1.Intersect(reg2);
dest = reg1.GetBox();
wxPyThreadBlocker blocker;
if (dest != wxRect(0,0,0,0)) {
wxRect* newRect = new wxRect(dest);
obj = wxPyConstructObject((void*)newRect, wxT("wxRect"), true);
return obj;
}
Py_INCREF(Py_None);
return Py_None;
}
%}
//---------------------------------------------------------------------------
%newgroup
DocStr(wxPoint2D,
"wx.Point2Ds represent a point or a vector in a 2d coordinate system
with floating point values.", "");
class wxPoint2D
{
public:
DocStr(wxPoint2D, "Create a w.Point2D object.", "");
wxPoint2D( double x=0.0 , double y=0.0 );
%RenameCtor(Point2DCopy, wxPoint2D( const wxPoint2D &pt ));
%RenameCtor(Point2DFromPoint, wxPoint2D( const wxPoint &pt ));
~wxPoint2D();
DocDeclAStr(
void, GetFloor( int *OUTPUT , int *OUTPUT ) const,
"GetFloor() -> (x,y)",
"Convert to integer", "");
DocDeclAStr(
void, GetRounded( int *OUTPUT , int *OUTPUT ) const,
"GetRounded() -> (x,y)",
"Convert to integer", "");
double GetVectorLength() const;
double GetVectorAngle() const ;
void SetVectorLength( double length );
void SetVectorAngle( double degrees );
// LinkError: void SetPolarCoordinates( double angle , double length );
// LinkError: void Normalize();
%pythoncode {
def SetPolarCoordinates(self, angle, length):
self.SetVectorLength(length)
self.SetVectorAngle(angle)
def Normalize(self):
self.SetVectorLength(1.0)
}
double GetDistance( const wxPoint2D &pt ) const;
double GetDistanceSquare( const wxPoint2D &pt ) const;
double GetDotProduct( const wxPoint2D &vec ) const;
double GetCrossProduct( const wxPoint2D &vec ) const;
DocDeclStr(
wxPoint2D, operator-(),
"the reflection of this point", "");
%nokwargs operator*=;
%nokwargs operator/=;
%typemap(out) wxPoint2D& { $result = $self; Py_INCREF($result); }
wxPoint2D& operator+=(const wxPoint2D& pt);
wxPoint2D& operator-=(const wxPoint2D& pt);
wxPoint2D& operator*=(const wxPoint2D& pt);
wxPoint2D& operator/=(const wxPoint2DDouble& pt);
%typemap(out) wxPoint2D& ;
%nokwargs __add__;
%nokwargs __sub__;
%nokwargs __mul__;
%nokwargs __div__;
%extend {
wxPoint2D __add__(const wxPoint2D& pt) {
return (*self) + pt;
}
wxPoint2D __sub__(const wxPoint2D& pt) {
return (*self) - pt;
}
wxPoint2D __mul__(const wxPoint2D& pt) {
return (*self) * pt;
}
wxPoint2D __mul__(double n) {
return (*self) * n;
}
wxPoint2D __div__(const wxPoint2D& pt) {
return (*self) / pt;
}
wxPoint2D __div__(double n) {
return (*self) / n;
}
}
%extend {
//KeepGIL(__eq__);
DocStr(__eq__, "Test for equality of wx.Point2D objects.", "");
bool __eq__(PyObject* other) {
wxPoint2D temp, *obj = &temp;
if ( other == Py_None ) return false;
if ( ! wxPoint2D_helper(other, &obj) ) {
PyErr_Clear();
return false;
}
return self->operator==(*obj);
}
//KeepGIL(__ne__);
DocStr(__ne__, "Test for inequality of wx.Point2D objects.", "");
bool __ne__(PyObject* other) {
wxPoint2D temp, *obj = &temp;
if ( other == Py_None ) return true;
if ( ! wxPoint2D_helper(other, &obj)) {
PyErr_Clear();
return true;
}
return self->operator!=(*obj);
}
}
%Rename(x, double, m_x);
%Rename(y, double, m_y);
%extend {
void Set( double x=0 , double y=0 ) {
self->m_x = x;
self->m_y = y;
}
DocAStr(Get,
"Get() -> (x,y)",
"Return x and y properties as a tuple.", "");
PyObject* Get() {
//wxPyBlock_t blocked = wxPyBeginBlockThreads();
PyObject* tup = PyTuple_New(2);
PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->m_x));
PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->m_y));
//wxPyEndBlockThreads(blocked);
return tup;
}
}
%pythoncode {
asTuple = wx.deprecated(Get, "asTuple is deprecated, use `Get` instead")
def __str__(self): return str(self.Get())
def __repr__(self): return 'wx.Point2D'+str(self.Get())
def __len__(self): return len(self.Get())
def __getitem__(self, index): return self.Get()[index]
def __setitem__(self, index, val):
if index == 0: self.x = val
elif index == 1: self.y = val
else: raise IndexError
def __nonzero__(self): return self.Get() != (0.0, 0.0)
__safe_for_unpickling__ = True
def __reduce__(self): return (wx.Point2D, self.Get())
}
%property(Floor, GetFloor, doc="See `GetFloor`");
%property(Rounded, GetRounded, doc="See `GetRounded`");
%property(VectorAngle, GetVectorAngle, SetVectorAngle, doc="See `GetVectorAngle` and `SetVectorAngle`");
%property(VectorLength, GetVectorLength, SetVectorLength, doc="See `GetVectorLength` and `SetVectorLength`");
};
//---------------------------------------------------------------------------
%newgroup
enum wxOutCode
{
wxInside = 0x00 ,
wxOutLeft = 0x01 ,
wxOutRight = 0x02 ,
wxOutTop = 0x08 ,
wxOutBottom = 0x04
};
DocStr(wxRect2D,
"wx.Rect2D is a rectangle, with position and size, in a 2D coordinate system
with floating point component values.", "");
class wxRect2D
{
public:
wxRect2D(wxDouble x=0.0, wxDouble y=0.0, wxDouble w=0.0, wxDouble h=0.0);
~wxRect2D();
wxPoint2D GetPosition();
wxSize GetSize();
// for the edge and corner accessors there are two setters conterparts,
// the Set.. functions keep the other corners at their position whenever
// sensible, the Move.. functions keep the size of the rect and move the
// other corners apropriately
wxDouble GetLeft() const;
void SetLeft( wxDouble n );
void MoveLeftTo( wxDouble n );
wxDouble GetTop() const;
void SetTop( wxDouble n );
void MoveTopTo( wxDouble n );
wxDouble GetBottom() const;
void SetBottom( wxDouble n );
void MoveBottomTo( wxDouble n );
wxDouble GetRight() const;
void SetRight( wxDouble n );
void MoveRightTo( wxDouble n );
wxPoint2D GetLeftTop() const;
void SetLeftTop( const wxPoint2D &pt );
void MoveLeftTopTo( const wxPoint2D &pt );
wxPoint2D GetLeftBottom() const;
void SetLeftBottom( const wxPoint2D &pt );
void MoveLeftBottomTo( const wxPoint2D &pt );
wxPoint2D GetRightTop() const;
void SetRightTop( const wxPoint2D &pt );
void MoveRightTopTo( const wxPoint2D &pt );
wxPoint2D GetRightBottom() const;
void SetRightBottom( const wxPoint2D &pt );
void MoveRightBottomTo( const wxPoint2D &pt );
wxPoint2D GetCentre() const;
void SetCentre( const wxPoint2D &pt );
void MoveCentreTo( const wxPoint2D &pt );
wxOutCode GetOutcode(const wxPoint2D &pt) const;
bool Contains( const wxPoint2D &pt ) const;
%Rename(ContainsRect, bool , Contains( const wxRect2D &rect ) const);
bool IsEmpty() const;
bool HaveEqualSize( const wxRect2D &rect ) const;
%nokwargs Inset;
void Inset( wxDouble x , wxDouble y );
void Inset( wxDouble left , wxDouble top ,wxDouble right , wxDouble bottom );
void Offset( const wxPoint2D &pt );
void ConstrainTo( const wxRect2D &rect );
wxPoint2D Interpolate( wxInt32 widthfactor , wxInt32 heightfactor );
//static void Intersect( const wxRect2D &src1 , const wxRect2D &src2 , wxRect2D *dest );
void Intersect( const wxRect2D &otherRect );
wxRect2D CreateIntersection( const wxRect2D &otherRect ) const;
bool Intersects( const wxRect2D &rect ) const;
// static void Union( const wxRect2D &src1 , const wxRect2D &src2 , wxRect2D *dest );
void Union( const wxRect2D &otherRect );
//void Union( const wxPoint2D &pt );
wxRect2D CreateUnion( const wxRect2D &otherRect ) const;
%nokwargs Scale;
void Scale( wxDouble f );
void Scale( int num , int denum );
//wxRect2D& operator = (const wxRect2D& rect);
//bool operator == (const wxRect2D& rect) const;
//bool operator != (const wxRect2D& rect) const;
%extend {
//KeepGIL(__eq__);
DocStr(__eq__, "Test for equality of wx.Rect2D objects.", "");
bool __eq__(PyObject* other) {
wxRect2D temp, *obj = &temp;
if ( other == Py_None ) return false;
if ( ! wxRect2D_helper(other, &obj) ) {
PyErr_Clear();
return false;
}
return self->operator==(*obj);
}
//KeepGIL(__ne__);
DocStr(__ne__, "Test for inequality of wx.Rect2D objects.", "");
bool __ne__(PyObject* other) {
wxRect2D temp, *obj = &temp;
if ( other == Py_None ) return true;
if ( ! wxRect2D_helper(other, &obj)) {
PyErr_Clear();
return true;
}
return self->operator!=(*obj);
}
}
%Rename(x, wxDouble , m_x);
%Rename(y, wxDouble , m_y);
%Rename(width, wxDouble , m_width);
%Rename(height, wxDouble , m_height);
%extend {
void Set( wxDouble x=0 , wxDouble y=0, wxDouble width=0, wxDouble height=0 ) {
self->m_x = x;
self->m_y = y;
self->m_width = width;
self->m_height = height;
}
DocAStr(Get,
"Get() -> (x,y, width, height)",
"Return x, y, width and height y properties as a tuple.", "");
PyObject* Get() {
//wxPyBlock_t blocked = wxPyBeginBlockThreads();
PyObject* tup = PyTuple_New(4);
PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->m_x));
PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->m_y));
PyTuple_SET_ITEM(tup, 2, PyFloat_FromDouble(self->m_width));
PyTuple_SET_ITEM(tup, 3, PyFloat_FromDouble(self->m_height));
//wxPyEndBlockThreads(blocked);
return tup;
}
}
%pythoncode {
def __str__(self): return str(self.Get())
def __repr__(self): return 'wx.Rect2D'+str(self.Get())
def __len__(self): return len(self.Get())
def __getitem__(self, index): return self.Get()[index]
def __setitem__(self, index, val):
if index == 0: self.x = val
elif index == 1: self.y = val
elif index == 2: self.width = val
elif index == 3: self.height = val
else: raise IndexError
def __nonzero__(self): return self.Get() != (0.0, 0.0, 0.0, 0.0)
__safe_for_unpickling__ = True
def __reduce__(self): return (wx.Rect2D, self.Get())
}
};
//---------------------------------------------------------------------------
class wxPosition
{
public:
wxPosition(int row=0, int col=0);
~wxPosition();
int GetRow() const;
int GetColumn() const;
int GetCol() const;
void SetRow(int row);
void SetColumn(int column);
void SetCol(int column);
%extend {
DocStr(__eq__, "Test for equality of wx.Position objects.", "");
bool __eq__(PyObject* other) {
wxPosition temp, *obj = &temp;
if ( other == Py_None ) return false;
if ( ! wxPosition_helper(other, &obj) ) {
PyErr_Clear();
return false;
}
return self->operator==(*obj);
}
DocStr(__ne__, "Test for inequality of wx.Position objects.", "");
bool __ne__(PyObject* other) {
wxPosition temp, *obj = &temp;
if ( other == Py_None ) return true;
if ( ! wxPosition_helper(other, &obj)) {
PyErr_Clear();
return true;
}
return self->operator!=(*obj);
}
}
%nokwargs operator+;
%nokwargs operator-;
wxPosition operator+(const wxPosition& p) const;
wxPosition operator-(const wxPosition& p) const;
wxPosition operator+(const wxSize& s) const;
wxPosition operator-(const wxSize& s) const;
%property(row, GetRow, SetRow);
%property(col, GetCol, SetCol);
};
//---------------------------------------------------------------------------
%immutable;
const wxPoint wxDefaultPosition;
const wxSize wxDefaultSize;
%mutable;
//---------------------------------------------------------------------------
// Turn GIL acquisition back on.
%threadWrapperOn
|