/usr/include/wx-3.0/wx/wxPython/i_files/_dc.i is in python-wxgtk3.0-dev 3.0.2.0+dfsg-7.
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 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 | /////////////////////////////////////////////////////////////////////////////
// Name: _dc.i
// Purpose: SWIG interface defs for wxDC and releated classes
//
// Author: Robin Dunn
//
// Created: 7-July-1997
// RCS-ID: $Id$
// Copyright: (c) 2003 by Total Control Software
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
// Not a %module
//---------------------------------------------------------------------------
%{
#include "wx/wxPython/pydrawxxx.h"
#include <wx/dcgraph.h>
%}
// TODO: 1. wrappers for wxDrawObject and wxDC::DrawObject
// 2. Do the factory and wxDCImpl classes need to be exposed?
//---------------------------------------------------------------------------
%newgroup;
class wxDCImpl;
// Logical ops
enum wxRasterOperationMode
{
wxCLEAR, // 0
wxXOR, // src XOR dst
wxINVERT, // NOT dst
wxOR_REVERSE, // src OR (NOT dst)
wxAND_REVERSE, // src AND (NOT dst)
wxCOPY, // src
wxAND, // src AND dst
wxAND_INVERT, // (NOT src) AND dst
wxNO_OP, // dst
wxNOR, // (NOT src) AND (NOT dst)
wxEQUIV, // (NOT src) XOR dst
wxSRC_INVERT, // (NOT src)
wxOR_INVERT, // (NOT src) OR dst
wxNAND, // (NOT src) OR (NOT dst)
wxOR, // src OR dst
wxSET // 1
// We never had these in wxPython, and it looks like they are going away
// so don't bother with them...
// #if WXWIN_COMPATIBILITY_2_8
// ,wxROP_BLACK = wxCLEAR,
// wxBLIT_BLACKNESS = wxCLEAR,
// wxROP_XORPEN = wxXOR,
// wxBLIT_SRCINVERT = wxXOR,
// wxROP_NOT = wxINVERT,
// wxBLIT_DSTINVERT = wxINVERT,
// wxROP_MERGEPENNOT = wxOR_REVERSE,
// wxBLIT_00DD0228 = wxOR_REVERSE,
// wxROP_MASKPENNOT = wxAND_REVERSE,
// wxBLIT_SRCERASE = wxAND_REVERSE,
// wxROP_COPYPEN = wxCOPY,
// wxBLIT_SRCCOPY = wxCOPY,
// wxROP_MASKPEN = wxAND,
// wxBLIT_SRCAND = wxAND,
// wxROP_MASKNOTPEN = wxAND_INVERT,
// wxBLIT_00220326 = wxAND_INVERT,
// wxROP_NOP = wxNO_OP,
// wxBLIT_00AA0029 = wxNO_OP,
// wxROP_NOTMERGEPEN = wxNOR,
// wxBLIT_NOTSRCERASE = wxNOR,
// wxROP_NOTXORPEN = wxEQUIV,
// wxBLIT_00990066 = wxEQUIV,
// wxROP_NOTCOPYPEN = wxSRC_INVERT,
// wxBLIT_NOTSCRCOPY = wxSRC_INVERT,
// wxROP_MERGENOTPEN = wxOR_INVERT,
// wxBLIT_MERGEPAINT = wxOR_INVERT,
// wxROP_NOTMASKPEN = wxNAND,
// wxBLIT_007700E6 = wxNAND,
// wxROP_MERGEPEN = wxOR,
// wxBLIT_SRCPAINT = wxOR,
// wxROP_WHITE = wxSET,
// wxBLIT_WHITENESS = wxSET
// #endif //WXWIN_COMPATIBILITY_2_8
};
// Flood styles
enum wxFloodFillStyle
{
wxFLOOD_SURFACE = 1,
wxFLOOD_BORDER
};
// Mapping modes (same values as used by Windows, don't change)
enum wxMappingMode
{
wxMM_TEXT = 1,
wxMM_TWIPS,
wxMM_POINTS,
wxMM_METRIC
};
struct wxFontMetrics
{
wxFontMetrics();
~wxFontMetrics();
int height, // Total character height.
ascent, // Part of the height above the baseline.
descent, // Part of the height below the baseline.
internalLeading, // Intra-line spacing.
externalLeading, // Inter-line spacing.
averageWidth; // Average font width, a.k.a. "x-width".
};
//---------------------------------------------------------------------------
DocStr(wxDC,
"A wx.DC is a device context onto which graphics and text can be
drawn. It is intended to represent a number of output devices in a
generic way, so a window can have a device context associated with it,
and a printer also has a device context. In this way, the same piece
of code may write to a number of different devices, if the device
context is used as a parameter.
Derived types of wxDC have documentation for specific features only,
so refer to this section for most device context information.
The wx.DC class is abstract and can not be instantiated, you must use
one of the derived classes instead. Which one will depend on the
situation in which it is used.", "");
class wxDC : public wxObject {
public:
// wxDC(); **** abstract base class, can't instantiate.
~wxDC();
%pythoncode {
%# These have been deprecated in wxWidgets. Since they never
%# really did anything to begin with, just make them be NOPs.
def BeginDrawing(self): pass
def EndDrawing(self): pass
}
wxDCImpl *GetImpl();
wxWindow *GetWindow();
// TODO virtual void DrawObject(wxDrawObject* drawobject);
// copy attributes (font, colours and writing direction) from another DC
void CopyAttributes(const wxDC& dc);
DocStr(
FloodFill,
"Flood fills the device context starting from the given point, using
the current brush colour, and using a style:
- **wxFLOOD_SURFACE**: the flooding occurs until a colour other than
the given colour is encountered.
- **wxFLOOD_BORDER**: the area to be flooded is bounded by the given
colour.
Returns False if the operation failed.
Note: The present implementation for non-Windows platforms may fail to
find colour borders if the pixels do not match the colour
exactly. However the function will still return true.", "");
bool FloodFill(wxCoord x, wxCoord y, const wxColour& col, wxFloodFillStyle style = wxFLOOD_SURFACE);
%Rename(FloodFillPoint, bool, FloodFill(const wxPoint& pt, const wxColour& col, wxFloodFillStyle style = wxFLOOD_SURFACE));
// fill the area specified by rect with a radial gradient, starting from
// initialColour in the centre of the cercle and fading to destColour.
DocDeclStr(
void , GradientFillConcentric(const wxRect& rect,
const wxColour& initialColour,
const wxColour& destColour,
const wxPoint& circleCenter),
"Fill the area specified by rect with a radial gradient, starting from
initialColour in the center of the circle and fading to destColour on
the outside of the circle. The circleCenter argument is the relative
coordinants of the center of the circle in the specified rect.
Note: Currently this function is very slow, don't use it for real-time
drawing.", "");
DocDeclStr(
void , GradientFillLinear(const wxRect& rect,
const wxColour& initialColour,
const wxColour& destColour,
wxDirection nDirection = wxEAST),
"Fill the area specified by rect with a linear gradient, starting from
initialColour and eventually fading to destColour. The nDirection
parameter specifies the direction of the colour change, default is to
use initialColour on the left part of the rectangle and destColour on
the right side.", "");
DocStr(
GetPixel,
"Gets the colour at the specified location on the DC.","");
%extend {
wxColour GetPixel(wxCoord x, wxCoord y) {
wxColour col;
self->GetPixel(x, y, &col);
return col;
}
wxColour GetPixelPoint(const wxPoint& pt) {
wxColour col;
self->GetPixel(pt, &col);
return col;
}
}
DocStr(
DrawLine,
"Draws a line from the first point to the second. The current pen is
used for drawing the line. Note that the second point is *not* part of
the line and is not drawn by this function (this is consistent with
the behaviour of many other toolkits).", "");
void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
%Rename(DrawLinePoint, void, DrawLine(const wxPoint& pt1, const wxPoint& pt2));
DocStr(
CrossHair,
"Displays a cross hair using the current pen. This is a vertical and
horizontal line the height and width of the window, centred on the
given point.", "");
void CrossHair(wxCoord x, wxCoord y);
%Rename(CrossHairPoint, void, CrossHair(const wxPoint& pt));
DocStr(
DrawArc,
"Draws an arc of a circle, centred on the *center* point (xc, yc), from
the first point to the second. The current pen is used for the outline
and the current brush for filling the shape.
The arc is drawn in an anticlockwise direction from the start point to
the end point.", "");
void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc);
%Rename(DrawArcPoint, void, DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& center));
DocStr(
DrawCheckMark,
"Draws a check mark inside the given rectangle.", "");
void DrawCheckMark(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
%Rename(DrawCheckMarkRect, void, DrawCheckMark(const wxRect& rect));
DocStr(
DrawEllipticArc,
"Draws an arc of an ellipse, with the given rectangle defining the
bounds of the ellipse. The current pen is used for drawing the arc and
the current brush is used for drawing the pie.
The *start* and *end* parameters specify the start and end of the arc
relative to the three-o'clock position from the center of the
rectangle. Angles are specified in degrees (360 is a complete
circle). Positive values mean counter-clockwise motion. If start is
equal to end, a complete ellipse will be drawn.", "");
void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, double start, double end);
%Rename(DrawEllipticArcPointSize, void, DrawEllipticArc(const wxPoint& pt, const wxSize& sz, double start, double end));
DocStr(
DrawPoint,
"Draws a point using the current pen.", "");
void DrawPoint(wxCoord x, wxCoord y);
%Rename(DrawPointPoint, void, DrawPoint(const wxPoint& pt));
DocStr(
DrawRectangle,
"Draws a rectangle with the given top left corner, and with the given
size. The current pen is used for the outline and the current brush
for filling the shape.", "");
void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
%Rename(DrawRectangleRect,void, DrawRectangle(const wxRect& rect));
%Rename(DrawRectanglePointSize, void, DrawRectangle(const wxPoint& pt, const wxSize& sz));
DocStr(
DrawRoundedRectangle,
"Draws a rectangle with the given top left corner, and with the given
size. The corners are quarter-circles using the given radius. The
current pen is used for the outline and the current brush for filling
the shape.
If radius is positive, the value is assumed to be the radius of the
rounded corner. If radius is negative, the absolute value is assumed
to be the proportion of the smallest dimension of the rectangle. This
means that the corner can be a sensible size relative to the size of
the rectangle, and also avoids the strange effects X produces when the
corners are too big for the rectangle.", "");
void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius);
%Rename(DrawRoundedRectangleRect, void, DrawRoundedRectangle(const wxRect& r, double radius));
%Rename(DrawRoundedRectanglePointSize, void, DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz, double radius));
DocStr(
DrawCircle,
"Draws a circle with the given center point and radius. The current
pen is used for the outline and the current brush for filling the
shape.", "
:see: `DrawEllipse`");
void DrawCircle(wxCoord x, wxCoord y, wxCoord radius);
%Rename(DrawCirclePoint, void, DrawCircle(const wxPoint& pt, wxCoord radius));
DocStr(
DrawEllipse,
"Draws an ellipse contained in the specified rectangle. The current pen
is used for the outline and the current brush for filling the shape.", "
:see: `DrawCircle`");
void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
%Rename(DrawEllipseRect, void, DrawEllipse(const wxRect& rect));
%Rename(DrawEllipsePointSize, void, DrawEllipse(const wxPoint& pt, const wxSize& sz));
DocStr(
DrawIcon,
"Draw an icon on the display (does nothing if the device context is
PostScript). This can be the simplest way of drawing bitmaps on a
window.", "");
void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y);
%Rename(DrawIconPoint, void, DrawIcon(const wxIcon& icon, const wxPoint& pt));
DocStr(
DrawBitmap,
"Draw a bitmap on the device context at the specified point. If
*transparent* is true and the bitmap has a transparency mask, (or
alpha channel on the platforms that support it) then the bitmap will
be drawn transparently.", "
When drawing a mono-bitmap, the current text foreground colour will be
used to draw the foreground of the bitmap (all bits set to 1), and the
current text background colour to draw the background (all bits set to
0).
:see: `SetTextForeground`, `SetTextBackground` and `wx.MemoryDC`");
void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask = false);
%Rename(DrawBitmapPoint, void, DrawBitmap(const wxBitmap &bmp, const wxPoint& pt, bool useMask = false));
DocStr(
DrawText,
"Draws a text string at the specified point, using the current text
font, and the current text foreground and background colours.
The coordinates refer to the top-left corner of the rectangle bounding
the string. See `GetTextExtent` for how to get the dimensions of a
text string, which can be used to position the text more precisely.
**NOTE**: under wxGTK the current logical function is used by this
function but it is ignored by wxMSW. Thus, you should avoid using
logical functions with this function in portable programs.", "
:see: `DrawRotatedText`");
void DrawText(const wxString& text, wxCoord x, wxCoord y);
%Rename(DrawTextPoint, void, DrawText(const wxString& text, const wxPoint& pt));
DocStr(
DrawRotatedText,
"Draws the text rotated by *angle* degrees, if supported by the platform.
**NOTE**: Under Win9x only TrueType fonts can be drawn by this
function. In particular, a font different from ``wx.NORMAL_FONT``
should be used as the it is not normally a TrueType
font. ``wx.SWISS_FONT`` is an example of a font which is.","
:see: `DrawText`");
void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
%Rename(DrawRotatedTextPoint, void, DrawRotatedText(const wxString& text, const wxPoint& pt, double angle));
DocDeclStr(
bool , Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
wxDC *source, wxCoord xsrc, wxCoord ysrc,
wxRasterOperationMode rop = wxCOPY, bool useMask = false,
wxCoord xsrcMask = -1, wxCoord ysrcMask = -1),
"Copy from a source DC to this DC. Parameters specify the destination
coordinates, size of area to copy, source DC, source coordinates,
logical function, whether to use a bitmap mask, and mask source
position.", "
:param xdest: Destination device context x position.
:param ydest: Destination device context y position.
:param width: Width of source area to be copied.
:param height: Height of source area to be copied.
:param source: Source device context.
:param xsrc: Source device context x position.
:param ysrc: Source device context y position.
:param rop: Logical function to use: see `SetLogicalFunction`.
:param useMask: If true, Blit does a transparent blit using the mask
that is associated with the bitmap selected into the
source device context.
:param xsrcMask: Source x position on the mask. If both xsrcMask and
ysrcMask are -1, xsrc and ysrc will be assumed for
the mask source position.
:param ysrcMask: Source y position on the mask.
");
DocDeclStrName(
bool , Blit(const wxPoint& destPt, const wxSize& sz,
wxDC *source, const wxPoint& srcPt,
wxRasterOperationMode rop = wxCOPY, bool useMask = false,
const wxPoint& srcPtMask = wxDefaultPosition),
"Copy from a source DC to this DC. Parameters specify the destination
coordinates, size of area to copy, source DC, source coordinates,
logical function, whether to use a bitmap mask, and mask source
position.", "
:param destPt: Destination device context position.
:param sz: Size of source area to be copied.
:param source: Source device context.
:param srcPt: Source device context position.
:param rop: Logical function to use: see `SetLogicalFunction`.
:param useMask: If true, Blit does a transparent blit using the mask
that is associated with the bitmap selected into the
source device context.
:param srcPtMask: Source position on the mask.
",
BlitPointSize);
DocDeclStr(
bool , StretchBlit(wxCoord dstX, wxCoord dstY,
wxCoord dstWidth, wxCoord dstHeight,
wxDC *source,
wxCoord srcX, wxCoord srcY,
wxCoord srcWidth, wxCoord srcHeight,
wxRasterOperationMode rop = wxCOPY, bool useMask = false,
wxCoord srcMaskX = wxDefaultCoord,
wxCoord srcMaskY = wxDefaultCoord),
"Copy from a source DC to this DC, specifying the destination
coordinates, destination size, source DC, source coordinates, size of
source area to copy, logical function, whether to use a bitmap mask,
and mask source position.", "
:param xdest: Destination device context x position.
:param ydest: Destination device context y position.
:param dstWidth: Width of destination area.
:param dstHeight: Height of destination area.
:param source: Source device context.
:param xsrc: Source device context x position.
:param ysrc: Source device context y position.
:param srcWidth: Width of source area to be copied.
:param srcHeight: Height of source area to be copied.
:param logicalFunc: Logical function to use: see `SetLogicalFunction`.
:param useMask: If true, StretchBlit does a transparent blit using
the mask that is associated with the bitmap selected
into the source device context.
:param xsrcMask: Source x position on the mask. If both xsrcMask and
ysrcMask are -1, xsrc and ysrc will be assumed for
the mask source position. Currently only implemented
on Windows.
:param ysrcMask: Source y position on the mask.
");
DocDeclStrName(
bool , StretchBlit(const wxPoint& dstPt, const wxSize& dstSize,
wxDC *source, const wxPoint& srcPt, const wxSize& srcSize,
wxRasterOperationMode rop = wxCOPY, bool useMask = false,
const wxPoint& srcMaskPt = wxDefaultPosition),
"Copy from a source DC to this DC, specifying the destination
coordinates, destination size, source DC, source coordinates, size of
source area to copy, logical function, whether to use a bitmap mask,
and mask source position. This version is the same as `StretchBlit`
except `wx.Point` and `wx.Size` objects are used instead of individual
position and size components.", "",
StretchBlitPointSize);
DocDeclStr(
wxBitmap , GetAsBitmap(const wxRect *subrect = NULL) const,
"", "");
DocStr(
SetClippingRegion,
"Sets the clipping region for this device context to the intersection
of the given region described by the parameters of this method and the
previously set clipping region. You should call `DestroyClippingRegion`
if you want to set the clipping region exactly to the region
specified.
The clipping region is an area to which drawing is
restricted. Possible uses for the clipping region are for clipping
text or for speeding up window redraws when only a known area of the
screen is damaged.", "
:see: `DestroyClippingRegion`, `wx.Region`");
void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
%Rename(SetClippingRegionPointSize, void, SetClippingRegion(const wxPoint& pt, const wxSize& sz));
%Rename(SetClippingRegionAsRegion, void, SetClippingRegion(const wxRegion& region));
%Rename(SetClippingRect, void, SetClippingRegion(const wxRect& rect));
DocDeclStr(
void , SetDeviceClippingRegion(const wxRegion& region),
"The coordinates of the region used in this method one are in device
coordinates, not the logical ones", "");
DocDeclAStr(
void , DrawLines(int points, wxPoint* points_array,
wxCoord xoffset = 0, wxCoord yoffset = 0),
"DrawLines(self, List points, int xoffset=0, int yoffset=0)",
"Draws lines using a sequence of `wx.Point` objects, adding the
optional offset coordinate. The current pen is used for drawing the
lines.", "");
DocDeclAStr(
void , DrawPolygon(int points, wxPoint* points_array,
wxCoord xoffset = 0, wxCoord yoffset = 0,
wxPolygonFillMode fillStyle = wxODDEVEN_RULE),
"DrawPolygon(self, List points, int xoffset=0, int yoffset=0,
wxPolygonFillMode fillStyle=ODDEVEN_RULE)",
"Draws a filled polygon using a sequence of `wx.Point` objects, adding
the optional offset coordinate. The last argument specifies the fill
rule: ``wx.ODDEVEN_RULE`` (the default) or ``wx.WINDING_RULE``.
The current pen is used for drawing the outline, and the current brush
for filling the shape. Using a transparent brush suppresses
filling. Note that wxWidgets automatically closes the first and last
points.", "");
// TODO: Figure out a good typemap for this...
// Convert the first 3 args from a sequence of sequences?
// void DrawPolyPolygon(int n, int count[], wxPoint points[],
// wxCoord xoffset = 0, wxCoord yoffset = 0,
// int fillStyle = wxODDEVEN_RULE);
DocDeclStr(
void , DrawLabel(const wxString& text, const wxRect& rect,
int alignment = wxALIGN_LEFT | wxALIGN_TOP,
int indexAccel = -1),
"Draw *text* within the specified rectangle, abiding by the alignment
flags. Will additionally emphasize the character at *indexAccel* if
it is not -1.", "
:see: `DrawImageLabel`");
%extend {
DocStr(DrawImageLabel,
"Draw *text* and an image (which may be ``wx.NullBitmap`` to skip
drawing it) within the specified rectangle, abiding by the alignment
flags. Will additionally emphasize the character at *indexAccel* if
it is not -1. Returns the bounding rectangle.", "");
wxRect DrawImageLabel(const wxString& text,
const wxBitmap& image,
const wxRect& rect,
int alignment = wxALIGN_LEFT | wxALIGN_TOP,
int indexAccel = -1) {
wxRect rv;
self->DrawLabel(text, image, rect, alignment, indexAccel, &rv);
return rv;
}
}
DocDeclAStr(
void , DrawSpline(int points, wxPoint* points_array),
"DrawSpline(self, List points)",
"Draws a spline between all given control points, (a list of `wx.Point`
objects) using the current pen. The spline is drawn using a series of
lines, using an algorithm taken from the X drawing program 'XFIG'.", "");
// global DC operations
// --------------------
DocDeclStr(
virtual void , Clear(),
"Clears the device context using the current background brush.", "");
DocDeclStr(
virtual bool , StartDoc(const wxString& message),
"Starts a document (only relevant when outputting to a
printer). *Message* is a message to show whilst printing.", "");
DocDeclStr(
virtual void , EndDoc(),
"Ends a document (only relevant when outputting to a printer).", "");
DocDeclStr(
virtual void , StartPage(),
"Starts a document page (only relevant when outputting to a printer).", "");
DocDeclStr(
virtual void , EndPage(),
"Ends a document page (only relevant when outputting to a printer).", "");
// set objects to use for drawing
// ------------------------------
DocDeclStr(
virtual void , SetFont(const wxFont& font),
"Sets the current font for the DC. It must be a valid font, in
particular you should not pass ``wx.NullFont`` to this method.","
:see: `wx.Font`");
DocDeclStr(
virtual void , SetPen(const wxPen& pen),
"Sets the current pen for the DC.
If the argument is ``wx.NullPen``, the current pen is selected out of the
device context, and the original pen restored.", "
:see: `wx.Pen`");
DocDeclStr(
virtual void , SetBrush(const wxBrush& brush),
"Sets the current brush for the DC.
If the argument is ``wx.NullBrush``, the current brush is selected out
of the device context, and the original brush restored, allowing the
current brush to be destroyed safely.","
:see: `wx.Brush`");
DocDeclStr(
virtual void , SetBackground(const wxBrush& brush),
"Sets the current background brush for the DC.", "");
DocDeclStr(
virtual void , SetBackgroundMode(int mode),
"*mode* may be one of ``wx.SOLID`` and ``wx.TRANSPARENT``. This setting
determines whether text will be drawn with a background colour or
not.", "");
DocDeclStr(
virtual void , SetPalette(const wxPalette& palette),
"If this is a window DC or memory DC, assigns the given palette to the
window or bitmap associated with the DC. If the argument is
``wx.NullPalette``, the current palette is selected out of the device
context, and the original palette restored.", "
:see: `wx.Palette`");
DocDeclStr(
virtual void , DestroyClippingRegion(),
"Destroys the current clipping region so that none of the DC is
clipped.", "
:see: `SetClippingRegion`");
DocDeclAStr(
void, GetClippingBox(wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT) const,
"GetClippingBox() -> (x, y, width, height)",
"Gets the rectangle surrounding the current clipping region.", "");
%extend {
DocStr(
GetClippingRect,
"Gets the rectangle surrounding the current clipping region.", "");
wxRect GetClippingRect() {
wxRect rect;
self->GetClippingBox(rect);
return rect;
}
}
// text extent
// -----------
DocDeclStr(
virtual wxCoord , GetCharHeight() const,
"Gets the character height of the currently set font.", "");
DocDeclStr(
virtual wxCoord , GetCharWidth() const,
"Gets the average character width of the currently set font.", "");
wxFontMetrics GetFontMetrics() const;
DocDeclAStr(
void, GetTextExtent(const wxString& string, wxCoord *OUTPUT, wxCoord *OUTPUT),
"GetTextExtent(wxString string) -> (width, height)",
"Get the width and height of the text using the current font. Only
works for single line strings.", "");
DocDeclAStrName(
void, GetTextExtent(const wxString& string,
wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord* OUTPUT,
const wxFont* font = NULL),
"GetFullTextExtent(wxString string, Font font=None) ->\n (width, height, descent, externalLeading)",
"Get the width, height, decent and leading of the text using the
current or specified font. Only works for single line strings.", "",
GetFullTextExtent);
// works for single as well as multi-line strings
DocDeclAStr(
void, GetMultiLineTextExtent(const wxString& text,
wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT,
const wxFont *font = NULL),
"GetMultiLineTextExtent(wxString string, Font font=None) ->\n (width, height, lineHeight)",
"Get the width, height, and line height of the text using the
current or specified font. Works for single as well as multi-line
strings.", "");
%extend {
DocAStr(GetPartialTextExtents,
"GetPartialTextExtents(self, text) -> [widths]",
"Returns a list of integers such that each value is the distance in
pixels from the begining of text to the coresponding character of
*text*. The generic version simply builds a running total of the widths
of each character using GetTextExtent, however if the various
platforms have a native API function that is faster or more accurate
than the generic implementation then it will be used instead.", "");
wxArrayInt GetPartialTextExtents(const wxString& text) {
wxArrayInt widths;
self->GetPartialTextExtents(text, widths);
return widths;
}
}
// size and resolution
// -------------------
DocStr(
GetSize,
"This gets the horizontal and vertical resolution in device units. It
can be used to scale graphics to fit the page. For example, if *maxX*
and *maxY* represent the maximum horizontal and vertical 'pixel' values
used in your application, the following code will scale the graphic to
fit on the printer page::
w, h = dc.GetSize()
scaleX = maxX*1.0 / w
scaleY = maxY*1.0 / h
dc.SetUserScale(min(scaleX,scaleY),min(scaleX,scaleY))
", "");
wxSize GetSize();
DocDeclAName(
void, GetSize( int *OUTPUT, int *OUTPUT ),
"GetSizeTuple() -> (width, height)",
GetSizeTuple);
DocStr(GetSizeMM, "Get the DC size in milimeters.", "");
wxSize GetSizeMM() const;
DocDeclAName(
void, GetSizeMM( int *OUTPUT, int *OUTPUT ) const,
"GetSizeMMTuple() -> (width, height)",
GetSizeMMTuple);
int GetResolution();
// coordinates conversions
// -----------------------
DocDeclStr(
wxCoord , DeviceToLogicalX(wxCoord x) const,
"Convert device X coordinate to logical coordinate, using the current
mapping mode.", "");
DocDeclStr(
wxCoord , DeviceToLogicalY(wxCoord y) const,
"Converts device Y coordinate to logical coordinate, using the current
mapping mode.", "");
DocDeclStr(
wxCoord , DeviceToLogicalXRel(wxCoord x) const,
"Convert device X coordinate to relative logical coordinate, using the
current mapping mode but ignoring the x axis orientation. Use this
function for converting a width, for example.", "");
DocDeclStr(
wxCoord , DeviceToLogicalYRel(wxCoord y) const,
"Convert device Y coordinate to relative logical coordinate, using the
current mapping mode but ignoring the y axis orientation. Use this
function for converting a height, for example.", "");
DocDeclStr(
wxCoord , LogicalToDeviceX(wxCoord x) const,
"Converts logical X coordinate to device coordinate, using the current
mapping mode.", "");
DocDeclStr(
wxCoord , LogicalToDeviceY(wxCoord y) const,
"Converts logical Y coordinate to device coordinate, using the current
mapping mode.", "");
DocDeclStr(
wxCoord , LogicalToDeviceXRel(wxCoord x) const,
"Converts logical X coordinate to relative device coordinate, using the
current mapping mode but ignoring the x axis orientation. Use this for
converting a width, for example.", "");
DocDeclStr(
wxCoord , LogicalToDeviceYRel(wxCoord y) const,
"Converts logical Y coordinate to relative device coordinate, using the
current mapping mode but ignoring the y axis orientation. Use this for
converting a height, for example.", "");
// query DC capabilities
// ---------------------
virtual bool CanDrawBitmap() const;
virtual bool CanGetTextExtent() const;
DocDeclStr(
virtual int , GetDepth() const,
"Returns the colour depth of the DC.", "");
DocDeclStr(
virtual wxSize , GetPPI() const,
"Resolution in pixels per inch", "");
DocDeclStr(
virtual bool , IsOk() const,
"Returns true if the DC is ok to use.", "");
%pythoncode { Ok = IsOk }
DocDeclStr(
int , GetBackgroundMode() const,
"Returns the current background mode, either ``wx.SOLID`` or
``wx.TRANSPARENT``.","
:see: `SetBackgroundMode`");
DocDeclStr(
const wxBrush& , GetBackground() const,
"Gets the brush used for painting the background.","
:see: `SetBackground`");
DocDeclStr(
const wxBrush& , GetBrush() const,
"Gets the current brush", "");
DocDeclStr(
const wxFont& , GetFont() const,
"Gets the current font", "");
DocDeclStr(
const wxPen& , GetPen() const,
"Gets the current pen", "");
DocDeclStr(
const wxColour , GetTextBackground() const,
"Gets the current text background colour", "");
DocDeclStr(
const wxColour , GetTextForeground() const,
"Gets the current text foreground colour", "");
DocDeclStr(
virtual void , SetTextForeground(const wxColour& colour),
"Sets the current text foreground colour for the DC.", "");
DocDeclStr(
virtual void , SetTextBackground(const wxColour& colour),
"Sets the current text background colour for the DC.", "");
DocDeclStr(
int , GetMapMode() const,
"Gets the current *mapping mode* for the device context ", "");
DocDeclStr(
virtual void , SetMapMode(wxMappingMode mode),
"The *mapping mode* of the device context defines the unit of
measurement used to convert logical units to device units. The
mapping mode can be one of the following:
================ =============================================
wx.MM_TWIPS Each logical unit is 1/20 of a point, or 1/1440
of an inch.
wx.MM_POINTS Each logical unit is a point, or 1/72 of an inch.
wx.MM_METRIC Each logical unit is 1 mm.
wx.MM_LOMETRIC Each logical unit is 1/10 of a mm.
wx.MM_TEXT Each logical unit is 1 pixel.
================ =============================================
","
Note that in X, text drawing isn't handled consistently with the
mapping mode; a font is always specified in point size. However,
setting the user scale (see `SetUserScale`) scales the text
appropriately. In Windows, scalable TrueType fonts are always used; in
X, results depend on availability of fonts, but usually a reasonable
match is found.
The coordinate origin is always at the top left of the screen/printer.
Drawing to a Windows printer device context uses the current mapping
mode, but mapping mode is currently ignored for PostScript output.
");
DocDeclAStr(
virtual void, GetUserScale(double *OUTPUT, double *OUTPUT) const,
"GetUserScale(self) -> (xScale, yScale)",
"Gets the current user scale factor (set by `SetUserScale`).", "");
DocDeclStr(
virtual void , SetUserScale(double x, double y),
"Sets the user scaling factor, useful for applications which require
'zooming'.", "");
DocDeclA(
virtual void, GetLogicalScale(double *OUTPUT, double *OUTPUT),
"GetLogicalScale() -> (xScale, yScale)");
virtual void SetLogicalScale(double x, double y);
wxPoint GetLogicalOrigin() const;
DocDeclAName(
void, GetLogicalOrigin(wxCoord *OUTPUT, wxCoord *OUTPUT) const,
"GetLogicalOriginTuple() -> (x,y)",
GetLogicalOriginTuple);
virtual void SetLogicalOrigin(wxCoord x, wxCoord y);
%extend {
void SetLogicalOriginPoint(const wxPoint& point) {
self->SetLogicalOrigin(point.x, point.y);
}
}
wxPoint GetDeviceOrigin() const;
DocDeclAName(
void, GetDeviceOrigin(wxCoord *OUTPUT, wxCoord *OUTPUT) const,
"GetDeviceOriginTuple() -> (x,y)",
GetDeviceOriginTuple);
virtual void SetDeviceOrigin(wxCoord x, wxCoord y);
%extend {
void SetDeviceOriginPoint(const wxPoint& point) {
self->SetDeviceOrigin(point.x, point.y);
}
}
DocDeclStr(
virtual void , SetAxisOrientation(bool xLeftRight, bool yBottomUp),
"Sets the x and y axis orientation (i.e., the direction from lowest to
highest values on the axis). The default orientation is the natural
orientation, e.g. x axis from left to right and y axis from bottom up.", "");
// TODO
//bool CanUseTransformMatrix() const;
//bool SetTransformMatrix(const wxAffineMatrix2D &matrix);
//wxAffineMatrix2D GetTransformMatrix() const;
//void ResetTransformMatrix();
DocDeclStr(
wxRasterOperationMode , GetLogicalFunction() const,
"Gets the current logical function (set by `SetLogicalFunction`).", "");
DocDeclStr(
virtual void , SetLogicalFunction(wxRasterOperationMode function),
"Sets the current logical function for the device context. This
determines how a source pixel (from a pen or brush colour, or source
device context if using `Blit`) combines with a destination pixel in
the current device context.
The possible values and their meaning in terms of source and
destination pixel values are as follows:
================ ==========================
wx.AND src AND dst
wx.AND_INVERT (NOT src) AND dst
wx.AND_REVERSE src AND (NOT dst)
wx.CLEAR 0
wx.COPY src
wx.EQUIV (NOT src) XOR dst
wx.INVERT NOT dst
wx.NAND (NOT src) OR (NOT dst)
wx.NOR (NOT src) AND (NOT dst)
wx.NO_OP dst
wx.OR src OR dst
wx.OR_INVERT (NOT src) OR dst
wx.OR_REVERSE src OR (NOT dst)
wx.SET 1
wx.SRC_INVERT NOT src
wx.XOR src XOR dst
================ ==========================
The default is wx.COPY, which simply draws with the current
colour. The others combine the current colour and the background using
a logical operation. wx.INVERT is commonly used for drawing rubber
bands or moving outlines, since drawing twice reverts to the original
colour.
", "");
// DocDeclStr(
// void , ComputeScaleAndOrigin(),
// "Performs all necessary computations for given platform and context
// type after each change of scale and origin parameters. Usually called
// automatically internally after such changes.", "");
// DocDeclStr(
// virtual void , SetOptimization(bool optimize),
// "If *optimize* is true this function sets optimization mode on. This
// currently means that under X, the device context will not try to set a
// pen or brush property if it is known to be set already. This approach
// can fall down if non-wxWidgets code is using the same device context
// or window, for example when the window is a panel on which the
// windowing system draws panel items. The wxWidgets device context
// 'memory' will now be out of step with reality.
// Setting optimization off, drawing, then setting it back on again, is a
// trick that must occasionally be employed.", "");
// DocDeclStr(
// virtual bool , GetOptimization(),
// "Returns true if device context optimization is on. See
// `SetOptimization` for details.", "");
%pythoncode {
def SetOptimization(self, optimize):
pass
def GetOptimization(self):
return False
SetOptimization = wx.deprecated(SetOptimization)
GetOptimization = wx.deprecated(GetOptimization)
}
// bounding box
// ------------
DocDeclStr(
virtual void , CalcBoundingBox(wxCoord x, wxCoord y),
"Adds the specified point to the bounding box which can be retrieved
with `MinX`, `MaxX` and `MinY`, `MaxY` or `GetBoundingBox` functions.", "");
%extend {
DocStr(CalcBoundingBoxPoint,
"Adds the specified point to the bounding box which can be retrieved
with `MinX`, `MaxX` and `MinY`, `MaxY` or `GetBoundingBox` functions.","");
void CalcBoundingBoxPoint(const wxPoint& point) {
self->CalcBoundingBox(point.x, point.y);
}
}
DocDeclStr(
void , ResetBoundingBox(),
"Resets the bounding box: after a call to this function, the bounding
box doesn't contain anything.", "");
// Get the final bounding box of the PostScript or Metafile picture.
DocDeclStr(
wxCoord , MinX() const,
"Gets the minimum horizontal extent used in drawing commands so far.", "");
DocDeclStr(
wxCoord , MaxX() const,
"Gets the maximum horizontal extent used in drawing commands so far.", "");
DocDeclStr(
wxCoord , MinY() const,
"Gets the minimum vertical extent used in drawing commands so far.", "");
DocDeclStr(
wxCoord , MaxY() const,
"Gets the maximum vertical extent used in drawing commands so far.", "");
DocAStr(GetBoundingBox,
"GetBoundingBox() -> (x1,y1, x2,y2)",
"Returns the min and max points used in drawing commands so far.", "");
%extend {
void GetBoundingBox(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
// See below for implementation
}
%pythoncode { def __nonzero__(self): return self.IsOk() };
// RTL related functions
// ---------------------
DocDeclStr(
virtual wxLayoutDirection , GetLayoutDirection() const,
"Get the layout direction (LTR or RTL)_ for this dc. On platforms
where RTL layout is supported, the return value will either be
``wx.Layout_LeftToRight`` or ``wx.Layout_RightToLeft``.
``wx.Layout_Default`` is returned if layout direction is not
supported.", "");
DocDeclStr(
virtual void , SetLayoutDirection(wxLayoutDirection dir),
"Change the layout direction for this dc.", "");
void* GetHandle() const;
%extend {
long GetHDC()
{
#ifdef __WXMSW__
return (long)self->GetHandle();
#else
wxPyRaiseNotImplemented();
return 0;
#endif
}
}
#ifdef __WXMAC__
%extend {
void* GetCGContext() { return self->GetHandle(); }
}
#endif
#ifdef __WXGTK__
%extend {
void* GetGdkDrawable() { return self->GetHandle(); }
}
#endif
%extend { // See drawlist.cpp for implementaion of these...
PyObject* _DrawPointList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
{
return wxPyDrawXXXList(*self, wxPyDrawXXXPoint, pyCoords, pyPens, pyBrushes);
}
PyObject* _DrawLineList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
{
return wxPyDrawXXXList(*self, wxPyDrawXXXLine, pyCoords, pyPens, pyBrushes);
}
PyObject* _DrawRectangleList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
{
return wxPyDrawXXXList(*self, wxPyDrawXXXRectangle, pyCoords, pyPens, pyBrushes);
}
PyObject* _DrawEllipseList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
{
return wxPyDrawXXXList(*self, wxPyDrawXXXEllipse, pyCoords, pyPens, pyBrushes);
}
PyObject* _DrawPolygonList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
{
return wxPyDrawXXXList(*self, wxPyDrawXXXPolygon, pyCoords, pyPens, pyBrushes);
}
PyObject* _DrawTextList(PyObject* textList, PyObject* pyPoints,
PyObject* foregroundList, PyObject* backgroundList) {
return wxPyDrawTextList(*self, textList, pyPoints, foregroundList, backgroundList);
}
}
%pythoncode {
def DrawPointList(self, points, pens=None):
"""
Draw a list of points as quickly as possible.
:param points: A sequence of 2-element sequences representing
each point to draw, (x,y).
:param pens: If None, then the current pen is used. If a
single pen then it will be used for all points. If
a list of pens then there should be one for each point
in points.
"""
if pens is None:
pens = []
elif isinstance(pens, wx.Pen):
pens = [pens]
elif len(pens) != len(points):
raise ValueError('points and pens must have same length')
return self._DrawPointList(points, pens, [])
def DrawLineList(self, lines, pens=None):
"""
Draw a list of lines as quickly as possible.
:param lines: A sequence of 4-element sequences representing
each line to draw, (x1,y1, x2,y2).
:param pens: If None, then the current pen is used. If a
single pen then it will be used for all lines. If
a list of pens then there should be one for each line
in lines.
"""
if pens is None:
pens = []
elif isinstance(pens, wx.Pen):
pens = [pens]
elif len(pens) != len(lines):
raise ValueError('lines and pens must have same length')
return self._DrawLineList(lines, pens, [])
def DrawRectangleList(self, rectangles, pens=None, brushes=None):
"""
Draw a list of rectangles as quickly as possible.
:param rectangles: A sequence of 4-element sequences representing
each rectangle to draw, (x,y, w,h).
:param pens: If None, then the current pen is used. If a
single pen then it will be used for all rectangles.
If a list of pens then there should be one for each
rectangle in rectangles.
:param brushes: A brush or brushes to be used to fill the rectagles,
with similar semantics as the pens parameter.
"""
if pens is None:
pens = []
elif isinstance(pens, wx.Pen):
pens = [pens]
elif len(pens) != len(rectangles):
raise ValueError('rectangles and pens must have same length')
if brushes is None:
brushes = []
elif isinstance(brushes, wx.Brush):
brushes = [brushes]
elif len(brushes) != len(rectangles):
raise ValueError('rectangles and brushes must have same length')
return self._DrawRectangleList(rectangles, pens, brushes)
def DrawEllipseList(self, ellipses, pens=None, brushes=None):
"""
Draw a list of ellipses as quickly as possible.
:param ellipses: A sequence of 4-element sequences representing
each ellipse to draw, (x,y, w,h).
:param pens: If None, then the current pen is used. If a
single pen then it will be used for all ellipses.
If a list of pens then there should be one for each
ellipse in ellipses.
:param brushes: A brush or brushes to be used to fill the ellipses,
with similar semantics as the pens parameter.
"""
if pens is None:
pens = []
elif isinstance(pens, wx.Pen):
pens = [pens]
elif len(pens) != len(ellipses):
raise ValueError('ellipses and pens must have same length')
if brushes is None:
brushes = []
elif isinstance(brushes, wx.Brush):
brushes = [brushes]
elif len(brushes) != len(ellipses):
raise ValueError('ellipses and brushes must have same length')
return self._DrawEllipseList(ellipses, pens, brushes)
def DrawPolygonList(self, polygons, pens=None, brushes=None):
"""
Draw a list of polygons, each of which is a list of points.
:param polygons: A sequence of sequences of sequences.
[[(x1,y1),(x2,y2),(x3,y3)...],
[(x1,y1),(x2,y2),(x3,y3)...]]
:param pens: If None, then the current pen is used. If a
single pen then it will be used for all polygons.
If a list of pens then there should be one for each
polygon.
:param brushes: A brush or brushes to be used to fill the polygons,
with similar semantics as the pens parameter.
"""
if pens is None:
pens = []
elif isinstance(pens, wx.Pen):
pens = [pens]
elif len(pens) != len(polygons):
raise ValueError('polygons and pens must have same length')
if brushes is None:
brushes = []
elif isinstance(brushes, wx.Brush):
brushes = [brushes]
elif len(brushes) != len(polygons):
raise ValueError('polygons and brushes must have same length')
return self._DrawPolygonList(polygons, pens, brushes)
def DrawTextList(self, textList, coords, foregrounds = None, backgrounds = None):
"""
Draw a list of strings using a list of coordinants for positioning each string.
:param textList: A list of strings
:param coords: A list of (x,y) positions
:param foregrounds: A list of `wx.Colour` objects to use for the
foregrounds of the strings.
:param backgrounds: A list of `wx.Colour` objects to use for the
backgrounds of the strings.
NOTE: Make sure you set Background mode to wx.Solid (DC.SetBackgroundMode)
If you want backgrounds to do anything.
"""
if type(textList) == type(''):
textList = [textList]
elif len(textList) != len(coords):
raise ValueError('textlist and coords must have same length')
if foregrounds is None:
foregrounds = []
elif isinstance(foregrounds, wx.Colour):
foregrounds = [foregrounds]
elif len(foregrounds) != len(coords):
raise ValueError('foregrounds and coords must have same length')
if backgrounds is None:
backgrounds = []
elif isinstance(backgrounds, wx.Colour):
backgrounds = [backgrounds]
elif len(backgrounds) != len(coords):
raise ValueError('backgrounds and coords must have same length')
return self._DrawTextList(textList, coords, foregrounds, backgrounds)
}
%property(Background, GetBackground, SetBackground, doc="See `GetBackground` and `SetBackground`");
%property(BackgroundMode, GetBackgroundMode, SetBackgroundMode, doc="See `GetBackgroundMode` and `SetBackgroundMode`");
%property(BoundingBox, GetBoundingBox, doc="See `GetBoundingBox`");
%property(Brush, GetBrush, SetBrush, doc="See `GetBrush` and `SetBrush`");
%property(CharHeight, GetCharHeight, doc="See `GetCharHeight`");
%property(CharWidth, GetCharWidth, doc="See `GetCharWidth`");
%property(ClippingBox, GetClippingBox, doc="See `GetClippingBox`");
%property(ClippingRect, GetClippingRect, SetClippingRect, doc="See `GetClippingRect` and `SetClippingRect`");
%property(Depth, GetDepth, doc="See `GetDepth`");
%property(DeviceOrigin, GetDeviceOrigin, SetDeviceOrigin, doc="See `GetDeviceOrigin` and `SetDeviceOrigin`");
%property(Font, GetFont, SetFont, doc="See `GetFont` and `SetFont`");
%property(FullTextExtent, GetFullTextExtent, doc="See `GetFullTextExtent`");
%property(LogicalFunction, GetLogicalFunction, SetLogicalFunction, doc="See `GetLogicalFunction` and `SetLogicalFunction`");
%property(LogicalOrigin, GetLogicalOrigin, SetLogicalOrigin, doc="See `GetLogicalOrigin` and `SetLogicalOrigin`");
%property(LogicalScale, GetLogicalScale, SetLogicalScale, doc="See `GetLogicalScale` and `SetLogicalScale`");
%property(MapMode, GetMapMode, SetMapMode, doc="See `GetMapMode` and `SetMapMode`");
%property(MultiLineTextExtent, GetMultiLineTextExtent, doc="See `GetMultiLineTextExtent`");
%property(Optimization, GetOptimization, SetOptimization, doc="See `GetOptimization` and `SetOptimization`");
%property(PPI, GetPPI, doc="See `GetPPI`");
%property(PartialTextExtents, GetPartialTextExtents, doc="See `GetPartialTextExtents`");
%property(Pen, GetPen, SetPen, doc="See `GetPen` and `SetPen`");
%property(Size, GetSize, doc="See `GetSize`");
%property(SizeMM, GetSizeMM, doc="See `GetSizeMM`");
%property(TextBackground, GetTextBackground, SetTextBackground, doc="See `GetTextBackground` and `SetTextBackground`");
%property(TextExtent, GetTextExtent, doc="See `GetTextExtent`");
%property(TextForeground, GetTextForeground, SetTextForeground, doc="See `GetTextForeground` and `SetTextForeground`");
%property(UserScale, GetUserScale, SetUserScale, doc="See `GetUserScale` and `SetUserScale`");
%property(LayoutDirection, GetLayoutDirection, SetLayoutDirection);
};
%{
static void wxDC_GetBoundingBox(wxDC* dc, int* x1, int* y1, int* x2, int* y2) {
*x1 = dc->MinX();
*y1 = dc->MinY();
*x2 = dc->MaxX();
*y2 = dc->MaxY();
}
%}
//---------------------------------------------------------------------------
%newgroup
DocStr(wxDCTextColourChanger,
"wx.DCTextColourChanger can be used to temporarily change the DC text
colour and restore it automatically when the object goes out of scope", "");
class wxDCTextColourChanger
{
public:
wxDCTextColourChanger(wxDC& dc, const wxColour& col);
~wxDCTextColourChanger();
// for the 'with' statement
%pythoncode {
def __enter__(self):
return self
def __exit__(self, exc_type, exc_val, exc_tb):
return False
}
};
DocStr(wxDCPenChanger,
"wx.DCPenChanger can be used to temporarily change the DC pen and
restore it automatically when the object goes out of scope", "");
class wxDCPenChanger
{
public:
wxDCPenChanger(wxDC& dc, const wxPen& pen);
~wxDCPenChanger();
// for the 'with' statement
%pythoncode {
def __enter__(self):
return self
def __exit__(self, exc_type, exc_val, exc_tb):
return False
}
};
DocStr(wxDCBrushChanger,
"wx.DCBrushChanger can be used to temporarily change the DC brush and
restore it automatically when the object goes out of scope", "");
class wxDCBrushChanger
{
public:
wxDCBrushChanger(wxDC& dc, const wxBrush& brush);
~wxDCBrushChanger();
// for the 'with' statement
%pythoncode {
def __enter__(self):
return self
def __exit__(self, exc_type, exc_val, exc_tb):
return False
}
};
DocStr(wxDCClipper,
"wx.wxDCClipper sets the DC's clipping region when it is constructed,
and then automatically destroys the clipping region when the clipper
goes out of scope.", "");
class wxDCClipper
{
public:
%nokwargs wxDCClipper;
wxDCClipper(wxDC& dc, const wxRegion& r);
wxDCClipper(wxDC& dc, const wxRect& r);
wxDCClipper(wxDC& dc, wxCoord x, wxCoord y, wxCoord w, wxCoord h);
~wxDCClipper();
// for the 'with' statement
%pythoncode {
def __enter__(self):
return self
def __exit__(self, exc_type, exc_val, exc_tb):
return False
}
};
DocStr(wxDCFontChanger,
"wx.wxDCFontChanger sets the DC's font when it is constructed,
and then restores the old font whrn it goes out of scope.", "");
class wxDCFontChanger
{
public:
wxDCFontChanger(wxDC& dc, const wxFont& font);
~wxDCFontChanger();
void Set(const wxFont& font);
};
//---------------------------------------------------------------------------
%newgroup
MustHaveApp(wxScreenDC);
DocStr(wxScreenDC,
"A wxScreenDC can be used to paint anywhere on the screen. This should
normally be constructed as a temporary stack object; don't store a
wxScreenDC object.
", "");
class wxScreenDC : public wxDC {
public:
wxScreenDC();
DocDeclStrName(
bool , StartDrawingOnTop(wxWindow* window),
"Specify that the area of the screen to be drawn upon coincides with
the given window.
:see: `EndDrawingOnTop`", "",
StartDrawingOnTopWin);
DocDeclStr(
bool , StartDrawingOnTop(wxRect* rect = NULL),
"Specify that the area is the given rectangle, or the whole screen if
``None`` is passed.
:see: `EndDrawingOnTop`", "");
DocDeclStr(
bool , EndDrawingOnTop(),
"Use this in conjunction with `StartDrawingOnTop` or
`StartDrawingOnTopWin` to ensure that drawing to the screen occurs on
top of existing windows. Without this, some window systems (such as X)
only allow drawing to take place underneath other windows.
You might use this pair of functions when implementing a drag feature,
for example as in the `wx.SplitterWindow` implementation.
These functions are probably obsolete since the X implementations
allow drawing directly on the screen now. However, the fact that this
function allows the screen to be refreshed afterwards may be useful
to some applications.", "");
};
//---------------------------------------------------------------------------
%newgroup
MustHaveApp(wxWindowDC);
DocStr(wxWindowDC,
"A wx.WindowDC must be constructed if an application wishes to paint on
the whole area of a window (client and decorations). This should
normally be constructed as a temporary stack object; don't store a
wx.WindowDC object.","");
class wxWindowDC : public wxDC {
public:
DocCtorStr(
wxWindowDC(wxWindow* win),
"Constructor. Pass the window on which you wish to paint.","");
};
//---------------------------------------------------------------------------
%newgroup
MustHaveApp(wxClientDC);
DocStr(wxClientDC,
"A wx.ClientDC must be constructed if an application wishes to paint on
the client area of a window from outside an EVT_PAINT event. This should
normally be constructed as a temporary stack object; don't store a
wx.ClientDC object long term.
To draw on a window from within an EVT_PAINT handler, construct a
`wx.PaintDC` object.
To draw on the whole window including decorations, construct a
`wx.WindowDC` object (Windows only).
", "");
class wxClientDC : public wxWindowDC {
public:
DocCtorStr(
wxClientDC(wxWindow* win),
"Constructor. Pass the window on which you wish to paint.", "");
};
//---------------------------------------------------------------------------
%newgroup
MustHaveApp(wxPaintDC);
DocStr(wxPaintDC,
"A wx.PaintDC must be constructed if an application wishes to paint on
the client area of a window from within an EVT_PAINT event
handler. This should normally be constructed as a temporary stack
object; don't store a wx.PaintDC object. If you have an EVT_PAINT
handler, you **must** create a wx.PaintDC object within it even if you
don't actually use it.
Using wx.PaintDC within EVT_PAINT handlers is important because it
automatically sets the clipping area to the damaged area of the
window. Attempts to draw outside this area do not appear.
To draw on a window from outside EVT_PAINT handlers, construct a
`wx.ClientDC` object.
","");
class wxPaintDC : public wxClientDC {
public:
DocCtorStr(
wxPaintDC(wxWindow* win),
"Constructor. Pass the window on which you wish to paint.", "");
};
//---------------------------------------------------------------------------
%newgroup
MustHaveApp(wxMemoryDC);
DocStr(wxMemoryDC,
"A memory device context provides a means to draw graphics onto a
bitmap. A bitmap must be selected into the new memory DC before it may
be used for anything. Typical usage is as follows::
dc = wx.MemoryDC()
dc.SelectObject(bitmap)
# draw on the dc using any of the Draw methods
dc.SelectObject(wx.NullBitmap)
# the bitmap now contains wahtever was drawn upon it
Note that the memory DC *must* be deleted (or the bitmap selected out
of it) before a bitmap can be reselected into another memory DC.
", "");
class wxMemoryDC : public wxWindowDC {
public:
DocCtorStr(
wxMemoryDC(wxBitmap& bitmap = wxNullBitmap),
"Constructs a new memory device context.
Use the Ok member to test whether the constructor was successful in
creating a usable device context. If a bitmap is not given to this
constructor then don't forget to select a bitmap into the DC before
drawing on it.", "
:see: `MemoryDCFromDC`");
DocCtorStrName(
wxMemoryDC(wxDC* oldDC),
"Creates a DC that is compatible with the oldDC.", "",
MemoryDCFromDC);
DocDeclStr(
void , SelectObject(wxBitmap& bitmap),
"Selects the bitmap into the device context, to use as the memory
bitmap. Selecting the bitmap into a memory DC allows you to draw into
the DC, and therefore the bitmap, and also to use Blit to copy the
bitmap to a window.
If the argument is wx.NullBitmap (or some other uninitialised
`wx.Bitmap`) the current bitmap is selected out of the device context,
and the original bitmap restored, allowing the current bitmap to be
destroyed safely.", "");
DocDeclStr(
void , SelectObjectAsSource(const wxBitmap& bmp),
"", "");
};
//---------------------------------------------------------------------------
%newgroup
%{
#include <wx/dcbuffer.h>
%}
enum {
wxBUFFER_VIRTUAL_AREA,
wxBUFFER_CLIENT_AREA,
wxBUFFER_USES_SHARED_BUFFER
};
MustHaveApp(wxBufferedDC);
DocStr(wxBufferedDC,
"This simple class provides a simple way to avoid flicker: when drawing
on it, everything is in fact first drawn on an in-memory buffer (a
`wx.Bitmap`) and then copied to the screen only once, when this object
is destroyed. You can either provide a buffer bitmap yourself, and
reuse it the next time something needs painted, or you can let the
buffered DC create and provide a buffer bitmap itself.
Buffered DCs can be used in the same way as any other device context.
wx.BufferedDC itself typically replaces `wx.ClientDC`, if you want to
use it in your EVT_PAINT handler, you should look at
`wx.BufferedPaintDC`. You can also use a wx.BufferedDC without
providing a target DC. In this case the operations done on the dc
will only be written to the buffer bitmap and *not* to any window, so
you will want to have provided the buffer bitmap and then reuse it
when it needs painted to the window.
Please note that GTK+ 2.0 and OS X provide double buffering themselves
natively. You may want to use `wx.Window.IsDoubleBuffered` to
determine whether you need to use buffering or not, or use
`wx.AutoBufferedPaintDC` to avoid needless double buffering on systems
that already do it automatically.
", "");
class wxBufferedDC : public wxMemoryDC
{
public:
DocStr(
wxBufferedDC,
"Constructs a buffered DC.", "
:param dc: The underlying DC: everything drawn to this object will
be flushed to this DC when this object is destroyed. You may
pass ``None`` in order to just initialize the buffer, and not
flush it.
:param buffer: If a `wx.Size` object is passed as the 2nd arg then
it is the size of the bitmap that will be created internally
and used for an implicit buffer. If the 2nd arg is a
`wx.Bitmap` then it is the explicit buffer that will be
used. Using an explicit buffer is the most efficient solution
as the bitmap doesn't have to be recreated each time but it
also requires more memory as the bitmap is never freed. The
bitmap should have appropriate size, anything drawn outside of
its bounds is clipped. If wx.NullBitmap is used then a new
buffer will be allocated that is the same size as the dc.
:param style: The style parameter indicates whether the supplied buffer is
intended to cover the entire virtual size of a `wx.ScrolledWindow` or
if it only covers the client area. Acceptable values are
``wx.BUFFER_VIRTUAL_AREA`` and ``wx.BUFFER_CLIENT_AREA``.
");
%nokwargs wxBufferedDC;
%pythonAppend wxBufferedDC
"# save a ref so the other dc will not be deleted before self
self.__dc = args[0]
# also save a ref to the bitmap
if len(args) > 1: self.__bmp = args[1]
";
wxBufferedDC( wxDC* dc,
wxBitmap& buffer=wxNullBitmap,
int style = wxBUFFER_CLIENT_AREA );
wxBufferedDC( wxDC* dc,
const wxSize& area,
int style = wxBUFFER_CLIENT_AREA );
// wxBufferedDC(wxWindow* win,
// wxDC *dc,
// const wxSize &area,
// int style = wxBUFFER_CLIENT_AREA);
DocCtorStr(
~wxBufferedDC(),
"Copies everything drawn on the DC so far to the underlying DC
associated with this object, if any.", "");
DocDeclStr(
void , UnMask(),
"Blits the buffer to the dc, and detaches the dc from the buffer (so it
can be effectively used once only). This is usually only called in
the destructor.", "");
// Set and get the style
void SetStyle(int style);
int GetStyle() const;
};
MustHaveApp(wxBufferedPaintDC);
DocStr(wxBufferedPaintDC,
"This is a subclass of `wx.BufferedDC` which can be used inside of an
EVT_PAINT event handler. Just create an object of this class instead
of `wx.PaintDC` and that's all you have to do to (mostly) avoid
flicker. The only thing to watch out for is that if you are using this
class together with `wx.ScrolledWindow`, you probably do **not** want
to call `wx.ScrolledWindow.PrepareDC` on it as it already does this internally
for the real underlying `wx.PaintDC`.
If your window is already fully buffered in a `wx.Bitmap` then your
EVT_PAINT handler can be as simple as just creating a
``wx.BufferedPaintDC`` as it will `Blit` the buffer to the window
automatically when it is destroyed. For example::
def OnPaint(self, event):
dc = wx.BufferedPaintDC(self, self.buffer)
", "");
class wxBufferedPaintDC : public wxBufferedDC
{
public:
%pythonAppend wxBufferedPaintDC "if len(args) > 1: self.__bmp = args[1]";
DocCtorStr(
wxBufferedPaintDC( wxWindow *window,
wxBitmap &buffer = wxNullBitmap,
int style = wxBUFFER_CLIENT_AREA),
"Create a buffered paint DC. As with `wx.BufferedDC`, you may either
provide the bitmap to be used for buffering or let this object create
one internally (in the latter case, the size of the client part of the
window is automatically used).", "");
};
//---------------------------------------------------------------------------
%newgroup
// Epydoc doesn't like this for some strange reason...
// %pythoncode {
// if 'wxMac' in wx.PlatformInfo or 'gtk2' in wx.PlatformInfo or
// 'gtk3' in wx.PlatformInfo:
// _AutoBufferedPaintDCBase = PaintDC
// else:
// _AutoBufferedPaintDCBase = BufferedPaintDC
// class AutoBufferedPaintDC(_AutoBufferedPaintDCBase):
// """
// If the current platform double buffers by default then this DC is the
// same as a plain `wx.PaintDC`, otherwise it is a `wx.BufferedPaintDC`.
// :see: `wx.AutoBufferedPaintDCFactory`
// """
// def __init__(self, window):
// _AutoBufferedPaintDCBase.__init__(self, window)
// }
DocStr(wxAutoBufferedPaintDC,
"If the current platform double buffers by default then this DC is the
same as a plain `wx.PaintDC`, otherwise it is a `wx.BufferedPaintDC`.
:see: `wx.AutoBufferedPaintDCFactory`
", "");
class wxAutoBufferedPaintDC: public wxDC
{
public:
wxAutoBufferedPaintDC(wxWindow* win);
};
%newobject _wxPyAutoBufferedPaintDCFactory;
%rename(AutoBufferedPaintDCFactory) _wxPyAutoBufferedPaintDCFactory;
DocStr(_wxPyAutoBufferedPaintDCFactory,
"Checks if the window is natively double buffered and will return a
`wx.PaintDC` if it is, a `wx.BufferedPaintDC` otherwise. The advantage of
this function over `wx.AutoBufferedPaintDC` is that this function will check
if the the specified window has double-buffering enabled rather than just
going by platform defaults.", "");
%inline %{
wxDC* _wxPyAutoBufferedPaintDCFactory(wxWindow* window)
{
if (window)
return wxAutoBufferedPaintDCFactory(window);
else {
wxPyErr_SetString(PyExc_ValueError, "Valid window required.");
return NULL;
}
}
%}
//---------------------------------------------------------------------------
%newgroup
MustHaveApp(wxMirrorDC);
DocStr(wxMirrorDC,
"wx.MirrorDC is a simple wrapper class which is always associated with a
real `wx.DC` object and either forwards all of its operations to it
without changes (no mirroring takes place) or exchanges x and y
coordinates which makes it possible to reuse the same code to draw a
figure and its mirror -- i.e. reflection related to the diagonal line
x == y.", "");
class wxMirrorDC : public wxDC
{
public:
DocCtorStr(
wxMirrorDC(wxDC& dc, bool mirror),
"Creates a mirrored DC associated with the real *dc*. Everything drawn
on the wx.MirrorDC will appear on the *dc*, and will be mirrored if
*mirror* is True.","");
};
//---------------------------------------------------------------------------
%newgroup
%{
#include <wx/dcps.h>
%}
%{
#if !wxUSE_POSTSCRIPT
class wxPostScriptDC : public wxDC
{
public:
wxPostScriptDC()
: wxDC(NULL)
{
PyErr_SetString(PyExc_NotImplementedError,
"wx.PostScriptDC is not available on this platform.");
};
wxPostScriptDC(const wxPrintData&)
: wxDC(NULL)
{
PyErr_SetString(PyExc_NotImplementedError,
"wx.PostScriptDC is not available on this platform.");
};
};
#endif
%}
MustHaveApp(wxPostScriptDC);
DocStr(wxPostScriptDC,
"This is a `wx.DC` that can write to PostScript files on any platform.","");
class wxPostScriptDC : public wxDC {
public:
DocCtorStr(
wxPostScriptDC(const wxPrintData& printData),
"Constructs a PostScript printer device context from a `wx.PrintData`
object.", "");
};
//---------------------------------------------------------------------------
%newgroup
MustHaveApp(wxMetaFile);
MustHaveApp(wxMetaFileDC);
#if defined(__WXMSW__) || defined(__WXMAC__)
%{
#include <wx/metafile.h>
%}
class wxMetaFile : public wxObject {
public:
wxMetaFile(const wxString& filename = wxPyEmptyString);
~wxMetaFile();
bool Play(wxDC *dc);
bool IsOk();
%pythoncode { Ok = IsOk }
bool SetClipboard(int width = 0, int height = 0);
wxSize GetSize();
int GetWidth();
int GetHeight();
#ifdef __WXMSW__
const wxString& GetFileName() const;
#endif
%pythoncode { def __nonzero__(self): return self.IsOk() }
};
// bool wxMakeMetaFilePlaceable(const wxString& filename,
// int minX, int minY, int maxX, int maxY, float scale=1.0);
class wxMetaFileDC : public wxDC {
public:
wxMetaFileDC(const wxString& filename = wxPyEmptyString,
int width = 0, int height = 0,
const wxString& description = wxPyEmptyString);
%newobject Close;
wxMetaFile* Close();
// wxMetafile *GetMetafile() const
};
#else // Make some dummies for the other platforms
%{
class wxMetaFile : public wxObject {
public:
wxMetaFile(const wxString&)
{ wxPyRaiseNotImplemented(); }
};
class wxMetaFileDC : public wxClientDC {
public:
wxMetaFileDC(const wxString&, int, int, const wxString&)
: wxClientDC((wxWindow*)NULL)
{ wxPyRaiseNotImplemented(); }
wxMetaFile* Close() { return NULL; }
};
%}
class wxMetaFile : public wxObject {
public:
wxMetaFile(const wxString& filename = wxPyEmptyString);
~wxMetaFile();
};
class wxMetaFileDC : public wxDC {
public:
wxMetaFileDC(const wxString& filename = wxPyEmptyString,
int width = 0, int height = 0,
const wxString& description = wxPyEmptyString);
};
#endif
#if defined(__WXMSW__)
class wxEnhMetaFile : public wxGDIObject
{
public:
%nokwargs wxEnhMetaFile;
wxEnhMetaFile(const wxString& file = wxEmptyString);
wxEnhMetaFile(const wxEnhMetaFile& metafile);
virtual ~wxEnhMetaFile();
// display the picture stored in the metafile on the given DC
bool Play(wxDC *dc, wxRect *rectBound = NULL);
// accessors
virtual bool IsOk() const;
wxSize GetSize() const;
int GetWidth() const;
int GetHeight() const;
const wxString& GetFileName() const;
// copy the metafile to the clipboard: the width and height parameters are
// for backwards compatibility (with wxMetaFile) only, they are ignored by
// this method
bool SetClipboard(int width = 0, int height = 0);
};
class wxEnhMetaFileDC : public wxDC
{
public:
%nokwargs wxEnhMetaFileDC;
// the ctor parameters specify the filename (empty for memory metafiles),
// the metafile picture size and the optional description/comment
wxEnhMetaFileDC(const wxString& filename = wxEmptyString,
int width = 0, int height = 0,
const wxString& description = wxEmptyString);
// as above, but takes reference DC as first argument to take resolution,
// size, font metrics etc. from
wxEnhMetaFileDC(const wxDC& referenceDC,
const wxString& filename = wxEmptyString,
int width = 0, int height = 0,
const wxString& description = wxEmptyString);
// obtain a pointer to the new metafile (caller should delete it)
%newobject Close;
wxEnhMetaFile *Close();
};
#else
#endif
//---------------------------------------------------------------------------
MustHaveApp(wxPrinterDC);
class wxPrinterDC : public wxDC {
public:
wxPrinterDC(const wxPrintData& printData);
wxRect GetPaperRect() const;
};
//---------------------------------------------------------------------------
%{
#include <wx/dcsvg.h>
%}
class wxSVGFileDC : public wxDC
{
public:
wxSVGFileDC(wxString filename,
int width=320,
int height=240,
double dpi=72.0);
};
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
|