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 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278
|
/////////////////////////////////////////////////////////////////////////////
// Name: wx/propgrid/propgrid.h
// Purpose: wxPropertyGrid
// Author: Jaakko Salli
// Modified by:
// Created: 2004-09-25
// Copyright: (c) Jaakko Salli
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_PROPGRID_PROPGRID_H_
#define _WX_PROPGRID_PROPGRID_H_
#include "wx/defs.h"
#if wxUSE_PROPGRID
#include "wx/scrolwin.h"
#include "wx/recguard.h"
#include "wx/time.h" // needed for wxMilliClock_t
#include "wx/propgrid/property.h"
#include "wx/propgrid/propgridiface.h"
#ifndef SWIG
extern WXDLLIMPEXP_DATA_PROPGRID(const char) wxPropertyGridNameStr[];
#endif
class wxPGComboBox;
#if wxUSE_STATUSBAR
class WXDLLIMPEXP_FWD_CORE wxStatusBar;
#endif
// -----------------------------------------------------------------------
// Global variables
// -----------------------------------------------------------------------
// This is required for sharing common global variables.
class WXDLLIMPEXP_PROPGRID wxPGGlobalVarsClass
{
public:
wxPGGlobalVarsClass();
~wxPGGlobalVarsClass();
#if wxUSE_THREADS
// Critical section for handling the globals. Generally it is not needed
// since GUI code is supposed to be in single thread. However,
// we do want the user to be able to convey wxPropertyGridEvents to other
// threads.
wxCriticalSection m_critSect;
#endif
// Used by advprops, but here to make things easier.
wxString m_pDefaultImageWildcard;
// Map of editor class instances (keys are name string).
wxPGHashMapS2P m_mapEditorClasses;
#if wxUSE_VALIDATORS
wxVector<wxValidator*> m_arrValidators; // These wxValidators need to be freed
#endif
wxPGHashMapS2P m_dictPropertyClassInfo; // PropertyName -> ClassInfo
wxPGChoices* m_fontFamilyChoices;
// Replace with your own to affect all properties using default renderer.
wxPGCellRenderer* m_defaultRenderer;
wxPGChoices m_boolChoices;
// Some shared variants
#if WXWIN_COMPATIBILITY_3_0
wxVariant m_vEmptyString;
wxVariant m_vZero;
wxVariant m_vMinusOne;
wxVariant m_vTrue;
wxVariant m_vFalse;
#else
const wxVariant m_vEmptyString;
const wxVariant m_vZero;
const wxVariant m_vMinusOne;
const wxVariant m_vTrue;
const wxVariant m_vFalse;
#endif // WXWIN_COMPATIBILITY_3_0
// Cached constant strings
#if WXWIN_COMPATIBILITY_3_0
wxPGCachedString m_strstring;
wxPGCachedString m_strlong;
wxPGCachedString m_strbool;
wxPGCachedString m_strlist;
wxPGCachedString m_strDefaultValue;
wxPGCachedString m_strMin;
wxPGCachedString m_strMax;
wxPGCachedString m_strUnits;
wxPGCachedString m_strHint;
#else
const wxString m_strstring;
const wxString m_strlong;
const wxString m_strbool;
const wxString m_strlist;
const wxString m_strDefaultValue;
const wxString m_strMin;
const wxString m_strMax;
const wxString m_strUnits;
const wxString m_strHint;
#endif // WXWIN_COMPATIBILITY_3_0
#if wxPG_COMPATIBILITY_1_4
wxPGCachedString m_strInlineHelp;
#endif
// If true then some things are automatically translated
bool m_autoGetTranslation;
// > 0 if errors cannot or should not be shown in statusbar etc.
int m_offline;
int m_extraStyle; // global extra style
int m_warnings;
int HasExtraStyle( int style ) const { return (m_extraStyle & style); }
};
extern WXDLLIMPEXP_DATA_PROPGRID(wxPGGlobalVarsClass*) wxPGGlobalVars;
#define wxPGVariant_EmptyString (wxPGGlobalVars->m_vEmptyString)
#define wxPGVariant_Zero (wxPGGlobalVars->m_vZero)
#define wxPGVariant_MinusOne (wxPGGlobalVars->m_vMinusOne)
#define wxPGVariant_True (wxPGGlobalVars->m_vTrue)
#define wxPGVariant_False (wxPGGlobalVars->m_vFalse)
#define wxPGVariant_Bool(A) (A?wxPGVariant_True:wxPGVariant_False)
// When wxPG is loaded dynamically after the application is already running
// then the built-in module system won't pick this one up. Add it manually.
WXDLLIMPEXP_PROPGRID void wxPGInitResourceModule();
// -----------------------------------------------------------------------
// SetWindowStyleFlag method can be used to modify some of these at run-time.
enum wxPG_WINDOW_STYLES
{
// This will cause Sort() automatically after an item is added.
// When inserting a lot of items in this mode, it may make sense to
// use Freeze() before operations and Thaw() afterwards to increase
// performance.
wxPG_AUTO_SORT = 0x00000010,
// Categories are not initially shown (even if added).
// IMPORTANT NOTE: If you do not plan to use categories, then this
// style will waste resources.
// This flag can also be changed using wxPropertyGrid::EnableCategories method.
wxPG_HIDE_CATEGORIES = 0x00000020,
// This style combines non-categoric mode and automatic sorting.
wxPG_ALPHABETIC_MODE = (wxPG_HIDE_CATEGORIES|wxPG_AUTO_SORT),
// Modified values are shown in bold font. Changing this requires Refresh()
// to show changes.
wxPG_BOLD_MODIFIED = 0x00000040,
// When wxPropertyGrid is resized, splitter moves to the center. This
// behaviour stops once the user manually moves the splitter.
wxPG_SPLITTER_AUTO_CENTER = 0x00000080,
// Display tooltips for cell text that cannot be shown completely. If
// wxUSE_TOOLTIPS is 0, then this doesn't have any effect.
wxPG_TOOLTIPS = 0x00000100,
// Disables margin and hides all expand/collapse buttons that would appear
// outside the margin (for sub-properties). Toggling this style automatically
// expands all collapsed items.
wxPG_HIDE_MARGIN = 0x00000200,
// This style prevents user from moving the splitter.
wxPG_STATIC_SPLITTER = 0x00000400,
// Combination of other styles that make it impossible for user to modify
// the layout.
wxPG_STATIC_LAYOUT = (wxPG_HIDE_MARGIN|wxPG_STATIC_SPLITTER),
// Disables wxTextCtrl based editors for properties which
// can be edited in another way.
// Equals calling wxPropertyGrid::LimitPropertyEditing for all added
// properties.
wxPG_LIMITED_EDITING = 0x00000800,
// wxPropertyGridManager only: Show toolbar for mode and page selection.
wxPG_TOOLBAR = 0x00001000,
// wxPropertyGridManager only: Show adjustable text box showing description
// or help text, if available, for currently selected property.
wxPG_DESCRIPTION = 0x00002000,
// wxPropertyGridManager only: don't show an internal border around the
// property grid. Recommended if you use a header.
wxPG_NO_INTERNAL_BORDER = 0x00004000,
// A mask which can be used to filter (out) all styles.
wxPG_WINDOW_STYLE_MASK = wxPG_AUTO_SORT|wxPG_HIDE_CATEGORIES|wxPG_BOLD_MODIFIED|
wxPG_SPLITTER_AUTO_CENTER|wxPG_TOOLTIPS|wxPG_HIDE_MARGIN|
wxPG_STATIC_SPLITTER|wxPG_LIMITED_EDITING|wxPG_TOOLBAR|
wxPG_DESCRIPTION|wxPG_NO_INTERNAL_BORDER
};
#if wxPG_COMPATIBILITY_1_4
// In wxPG 1.4 this was used to enable now-default theme border support
// in wxPropertyGridManager.
#define wxPG_THEME_BORDER 0x00000000
#endif
// NOTE: wxPG_EX_xxx are extra window styles and must be set using
// SetExtraStyle() member function.
enum wxPG_EX_WINDOW_STYLES
{
// Speeds up switching to wxPG_HIDE_CATEGORIES mode. Initially, if
// wxPG_HIDE_CATEGORIES is not defined, the non-categorized data storage is
// not activated, and switching the mode first time becomes somewhat slower.
// wxPG_EX_INIT_NOCAT activates the non-categorized data storage right away.
// NOTE: If you do plan not switching to non-categoric mode, or if
// you don't plan to use categories at all, then using this style will result
// in waste of resources.
wxPG_EX_INIT_NOCAT = 0x00001000,
// Extended window style that sets wxPropertyGridManager toolbar to not
// use flat style.
wxPG_EX_NO_FLAT_TOOLBAR = 0x00002000,
// Shows alphabetic/categoric mode buttons from toolbar.
wxPG_EX_MODE_BUTTONS = 0x00008000,
// Show property help strings as tool tips instead as text on the status bar.
// You can set the help strings using SetPropertyHelpString member function.
wxPG_EX_HELP_AS_TOOLTIPS = 0x00010000,
// Prevent TAB from focusing to wxButtons. This behaviour was default
// in version 1.2.0 and earlier.
// NOTE! Tabbing to button doesn't work yet. Problem seems to be that on wxMSW
// at least the button doesn't properly propagate key events (yes, I'm using
// wxWANTS_CHARS).
//wxPG_EX_NO_TAB_TO_BUTTON = 0x00020000,
// Allows relying on native double-buffering.
wxPG_EX_NATIVE_DOUBLE_BUFFERING = 0x00080000,
// Set this style to let user have ability to set values of properties to
// unspecified state. Same as setting wxPG_PROP_AUTO_UNSPECIFIED for
// all properties.
wxPG_EX_AUTO_UNSPECIFIED_VALUES = 0x00200000,
// If this style is used, built-in attributes (such as wxPG_FLOAT_PRECISION
// and wxPG_STRING_PASSWORD) are not stored into property's attribute storage
// (thus they are not readable).
// Note that this option is global, and applies to all wxPG property
// containers.
wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES = 0x00400000,
// Hides page selection buttons from toolbar.
wxPG_EX_HIDE_PAGE_BUTTONS = 0x01000000,
// Allows multiple properties to be selected by user (by pressing SHIFT
// when clicking on a property, or by dragging with left mouse button
// down).
// You can get array of selected properties with
// wxPropertyGridInterface::GetSelectedProperties(). In multiple selection
// mode wxPropertyGridInterface::GetSelection() returns
// property which has editor active (usually the first one
// selected). Other useful member functions are ClearSelection(),
// AddToSelection() and RemoveFromSelection().
wxPG_EX_MULTIPLE_SELECTION = 0x02000000,
// This enables top-level window tracking which allows wxPropertyGrid to
// notify the application of last-minute property value changes by user.
// This style is not enabled by default because it may cause crashes when
// wxPropertyGrid is used in with wxAUI or similar system.
// Note: If you are not in fact using any system that may change
// wxPropertyGrid's top-level parent window on its own, then you
// are recommended to enable this style.
wxPG_EX_ENABLE_TLP_TRACKING = 0x04000000,
// Don't show divider above toolbar, on Windows.
wxPG_EX_NO_TOOLBAR_DIVIDER = 0x08000000,
// Show a separator below the toolbar.
wxPG_EX_TOOLBAR_SEPARATOR = 0x10000000,
// Allows to take focus on the entire area (on canvas)
// even if wxPropertyGrid is not a standalone control.
wxPG_EX_ALWAYS_ALLOW_FOCUS = 0x00100000,
// A mask which can be used to filter (out) all extra styles applicable to wxPropertyGrid.
wxPG_EX_WINDOW_PG_STYLE_MASK = wxPG_EX_INIT_NOCAT|wxPG_EX_HELP_AS_TOOLTIPS|wxPG_EX_NATIVE_DOUBLE_BUFFERING|
wxPG_EX_AUTO_UNSPECIFIED_VALUES|wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES|
wxPG_EX_MULTIPLE_SELECTION|wxPG_EX_ENABLE_TLP_TRACKING|wxPG_EX_ALWAYS_ALLOW_FOCUS,
// A mask which can be used to filter (out) all extra styles applicable to wxPropertyGridManager.
wxPG_EX_WINDOW_PGMAN_STYLE_MASK = wxPG_EX_NO_FLAT_TOOLBAR|wxPG_EX_MODE_BUTTONS|wxPG_EX_HIDE_PAGE_BUTTONS|
wxPG_EX_NO_TOOLBAR_DIVIDER|wxPG_EX_TOOLBAR_SEPARATOR,
// A mask which can be used to filter (out) all extra styles.
wxPG_EX_WINDOW_STYLE_MASK = wxPG_EX_WINDOW_PG_STYLE_MASK|wxPG_EX_WINDOW_PGMAN_STYLE_MASK
};
#if wxPG_COMPATIBILITY_1_4
#define wxPG_EX_DISABLE_TLP_TRACKING 0x00000000
#endif
// Combines various styles.
#define wxPG_DEFAULT_STYLE (0)
// Combines various styles.
#define wxPGMAN_DEFAULT_STYLE (0)
// -----------------------------------------------------------------------
// wxPropertyGrid stores information about common values in these
// records.
// NB: Common value feature is not complete, and thus not mentioned in
// documentation.
class WXDLLIMPEXP_PROPGRID wxPGCommonValue
{
public:
wxPGCommonValue( const wxString& label, wxPGCellRenderer* renderer )
: m_label(label)
, m_renderer(renderer)
{
renderer->IncRef();
}
virtual ~wxPGCommonValue()
{
m_renderer->DecRef();
}
virtual wxString GetEditableText() const { return m_label; }
const wxString& GetLabel() const { return m_label; }
wxPGCellRenderer* GetRenderer() const { return m_renderer; }
protected:
wxString m_label;
wxPGCellRenderer* m_renderer;
};
// -----------------------------------------------------------------------
// wxPropertyGrid Validation Failure behaviour Flags
enum wxPG_VALIDATION_FAILURE_BEHAVIOR_FLAGS
{
// Prevents user from leaving property unless value is valid. If this
// behaviour flag is not used, then value change is instead cancelled.
wxPG_VFB_STAY_IN_PROPERTY = 0x01,
// Calls wxBell() on validation failure.
wxPG_VFB_BEEP = 0x02,
// Cell with invalid value will be marked (with red colour).
wxPG_VFB_MARK_CELL = 0x04,
// Display a text message explaining the situation.
// To customize the way the message is displayed, you need to
// reimplement wxPropertyGrid::DoShowPropertyError() in a
// derived class. Default behaviour is to display the text on
// the top-level frame's status bar, if present, and otherwise
// using wxMessageBox.
wxPG_VFB_SHOW_MESSAGE = 0x08,
// Similar to wxPG_VFB_SHOW_MESSAGE, except always displays the
// message using wxMessageBox.
wxPG_VFB_SHOW_MESSAGEBOX = 0x10,
// Similar to wxPG_VFB_SHOW_MESSAGE, except always displays the
// message on the status bar (when present - you can reimplement
// wxPropertyGrid::GetStatusBar() in a derived class to specify
// this yourself).
wxPG_VFB_SHOW_MESSAGE_ON_STATUSBAR = 0x20,
// Defaults.
wxPG_VFB_DEFAULT = wxPG_VFB_MARK_CELL |
wxPG_VFB_SHOW_MESSAGEBOX,
// Only used internally.
wxPG_VFB_UNDEFINED = 0x80
};
// Having this as define instead of wxByte typedef makes things easier for
// wxPython bindings (ignoring and redefining it in SWIG interface file
// seemed rather tricky)
#define wxPGVFBFlags unsigned char
// Used to convey validation information to and from functions that
// actually perform validation. Mostly used in custom property
// classes.
class WXDLLIMPEXP_PROPGRID wxPGValidationInfo
{
friend class wxPropertyGrid;
public:
wxPGValidationInfo()
: m_failureBehavior(0)
, m_isFailing(false)
{
}
~wxPGValidationInfo()
{
}
// Returns failure behaviour which is a combination of
// wxPG_VFB_XXX flags.
wxPGVFBFlags GetFailureBehavior() const
{ return m_failureBehavior; }
// Returns current failure message.
const wxString& GetFailureMessage() const
{ return m_failureMessage; }
// Returns reference to pending value.
wxVariant& GetValue()
{
wxASSERT(m_pValue);
return *m_pValue;
}
// Set validation failure behaviour
// failureBehavior - Mixture of wxPG_VFB_XXX flags.
void SetFailureBehavior(wxPGVFBFlags failureBehavior)
{ m_failureBehavior = failureBehavior; }
// Set current failure message.
void SetFailureMessage(const wxString& message)
{ m_failureMessage = message; }
private:
// Value to be validated.
wxVariant* m_pValue;
// Message displayed on validation failure.
wxString m_failureMessage;
// Validation failure behaviour. Use wxPG_VFB_XXX flags.
wxPGVFBFlags m_failureBehavior;
// True when validation is currently failing.
bool m_isFailing;
};
// -----------------------------------------------------------------------
// These are used with wxPropertyGrid::AddActionTrigger() and
// wxPropertyGrid::ClearActionTriggers().
enum wxPG_KEYBOARD_ACTIONS
{
wxPG_ACTION_INVALID = 0,
// Select the next property.
wxPG_ACTION_NEXT_PROPERTY,
// Select the previous property.
wxPG_ACTION_PREV_PROPERTY,
// Expand the selected property, if it has child items.
wxPG_ACTION_EXPAND_PROPERTY,
// Collapse the selected property, if it has child items.
wxPG_ACTION_COLLAPSE_PROPERTY,
// Cancel and undo any editing done in the currently active property
// editor.
wxPG_ACTION_CANCEL_EDIT,
// Move focus to the editor control of the currently selected
// property.
wxPG_ACTION_EDIT,
// Causes editor's button (if any) to be pressed.
wxPG_ACTION_PRESS_BUTTON,
wxPG_ACTION_MAX
};
// -----------------------------------------------------------------------
// wxPropertyGrid::DoSelectProperty flags (selFlags)
enum wxPG_SELECT_PROPERTY_FLAGS
{
// Focuses to created editor
wxPG_SEL_FOCUS = 0x0001,
// Forces deletion and recreation of editor
wxPG_SEL_FORCE = 0x0002,
// For example, doesn't cause EnsureVisible
wxPG_SEL_NONVISIBLE = 0x0004,
// Do not validate editor's value before selecting
wxPG_SEL_NOVALIDATE = 0x0008,
// Property being deselected is about to be deleted
wxPG_SEL_DELETING = 0x0010,
// Property's values was set to unspecified by the user
wxPG_SEL_SETUNSPEC = 0x0020,
// Property's event handler changed the value
wxPG_SEL_DIALOGVAL = 0x0040,
// Set to disable sending of wxEVT_PG_SELECTED event
wxPG_SEL_DONT_SEND_EVENT = 0x0080,
// Don't make any graphics updates
wxPG_SEL_NO_REFRESH = 0x0100
};
// -----------------------------------------------------------------------
// DoSetSplitterPosition() flags
enum wxPG_SET_SPLITTER_POSITION_SPLITTER_FLAGS
{
wxPG_SPLITTER_REFRESH = 0x0001,
wxPG_SPLITTER_ALL_PAGES = 0x0002,
wxPG_SPLITTER_FROM_EVENT = 0x0004,
wxPG_SPLITTER_FROM_AUTO_CENTER = 0x0008
};
// -----------------------------------------------------------------------
// Internal flags
enum wxPG_INTERNAL_FLAGS
{
wxPG_FL_INITIALIZED = 0x0001,
// Set when creating editor controls if it was clicked on.
wxPG_FL_ACTIVATION_BY_CLICK = 0x0002,
wxPG_FL_DONT_CENTER_SPLITTER = 0x0004,
wxPG_FL_FOCUSED = 0x0008,
wxPG_FL_MOUSE_CAPTURED = 0x0010,
wxPG_FL_MOUSE_INSIDE = 0x0020,
wxPG_FL_VALUE_MODIFIED = 0x0040,
// don't clear background of m_wndEditor
wxPG_FL_PRIMARY_FILLS_ENTIRE = 0x0080,
// currently active editor uses custom image
wxPG_FL_CUR_USES_CUSTOM_IMAGE = 0x0100,
// cell colours override selection colours for selected cell
wxPG_FL_CELL_OVERRIDES_SEL = 0x0200,
wxPG_FL_SCROLLED = 0x0400,
// set when all added/inserted properties get hideable flag
wxPG_FL_ADDING_HIDEABLES = 0x0800,
// Disables showing help strings on statusbar.
wxPG_FL_NOSTATUSBARHELP = 0x1000,
// Marks that we created the state, so we have to destroy it too.
wxPG_FL_CREATEDSTATE = 0x2000,
// Set if wxPGMan requires redrawing of description text box.
wxPG_FL_DESC_REFRESH_REQUIRED = 0x8000,
// Set if contained in wxPropertyGridManager
wxPG_FL_IN_MANAGER = 0x00020000,
// Set after wxPropertyGrid is shown in its initial good size
wxPG_FL_GOOD_SIZE_SET = 0x00040000,
// Set when in SelectProperty.
wxPG_FL_IN_SELECT_PROPERTY = 0x00100000,
// Set when help string is shown in status bar
wxPG_FL_STRING_IN_STATUSBAR = 0x00200000,
// Auto sort is enabled (for categorized mode)
wxPG_FL_CATMODE_AUTO_SORT = 0x01000000,
// Set after page has been inserted to manager
wxPG_MAN_FL_PAGE_INSERTED = 0x02000000,
// Active editor control is abnormally large
wxPG_FL_ABNORMAL_EDITOR = 0x04000000,
// Recursion guard for HandleCustomEditorEvent
wxPG_FL_IN_HANDLECUSTOMEDITOREVENT = 0x08000000,
wxPG_FL_VALUE_CHANGE_IN_EVENT = 0x10000000,
// Editor control width should not change on resize
wxPG_FL_FIXED_WIDTH_EDITOR = 0x20000000,
// Width of panel can be different from width of grid
wxPG_FL_HAS_VIRTUAL_WIDTH = 0x40000000,
// Prevents RecalculateVirtualSize re-entrancy
wxPG_FL_RECALCULATING_VIRTUAL_SIZE = 0x80000000
};
#if !defined(__wxPG_SOURCE_FILE__)
// Reduce compile time, but still include in user app
#include "wx/propgrid/props.h"
#endif
// -----------------------------------------------------------------------
// wxPropertyGrid is a specialized grid for editing properties
// such as strings, numbers, flagsets, fonts, and colours. wxPropertySheet
// used to do the very same thing, but it hasn't been updated for a while
// and it is currently deprecated.
// Please note that most member functions are inherited and as such not
// documented here. This means you will probably also want to read
// wxPropertyGridInterface class reference.
// To process input from a propertygrid control, use these event handler
// macros to direct input to member functions that take a wxPropertyGridEvent
// argument.
// EVT_PG_SELECTED (id, func)
// Respond to wxEVT_PG_SELECTED event, generated when a property selection
// has been changed, either by user action or by indirect program
// function. For instance, collapsing a parent property programmatically
// causes any selected child property to become unselected, and may
// therefore cause this event to be generated.
// EVT_PG_CHANGING(id, func)
// Respond to wxEVT_PG_CHANGING event, generated when property value
// is about to be changed by user. Use wxPropertyGridEvent::GetValue()
// to take a peek at the pending value, and wxPropertyGridEvent::Veto()
// to prevent change from taking place, if necessary.
// EVT_PG_HIGHLIGHTED(id, func)
// Respond to wxEVT_PG_HIGHLIGHTED event, which occurs when mouse
// moves over a property. Event's property is NULL if hovered area does
// not belong to any property.
// EVT_PG_RIGHT_CLICK(id, func)
// Respond to wxEVT_PG_RIGHT_CLICK event, which occurs when property is
// clicked on with right mouse button.
// EVT_PG_DOUBLE_CLICK(id, func)
// Respond to wxEVT_PG_DOUBLE_CLICK event, which occurs when property is
// double-clicked onwith left mouse button.
// EVT_PG_ITEM_COLLAPSED(id, func)
// Respond to wxEVT_PG_ITEM_COLLAPSED event, generated when user collapses
// a property or category..
// EVT_PG_ITEM_EXPANDED(id, func)
// Respond to wxEVT_PG_ITEM_EXPANDED event, generated when user expands
// a property or category..
// EVT_PG_LABEL_EDIT_BEGIN(id, func)
// Respond to wxEVT_PG_LABEL_EDIT_BEGIN event, generated when is about to
// begin editing a property label. You can veto this event to prevent the
// action.
// EVT_PG_LABEL_EDIT_ENDING(id, func)
// Respond to wxEVT_PG_LABEL_EDIT_ENDING event, generated when is about to
// end editing of a property label. You can veto this event to prevent the
// action.
// EVT_PG_COL_BEGIN_DRAG(id, func)
// Respond to wxEVT_PG_COL_BEGIN_DRAG event, generated when user
// starts resizing a column - can be vetoed.
// EVT_PG_COL_DRAGGING,(id, func)
// Respond to wxEVT_PG_COL_DRAGGING, event, generated when a
// column resize by user is in progress. This event is also generated
// when user double-clicks the splitter in order to recenter
// it.
// EVT_PG_COL_END_DRAG(id, func)
// Respond to wxEVT_PG_COL_END_DRAG event, generated after column
// resize by user has finished.
// Use Freeze() and Thaw() respectively to disable and enable drawing. This
// will also delay sorting etc. miscellaneous calculations to the last
// possible moment.
class WXDLLIMPEXP_PROPGRID wxPropertyGrid : public wxScrolled<wxControl>,
public wxPropertyGridInterface
{
friend class wxPropertyGridEvent;
friend class wxPropertyGridPageState;
friend class wxPropertyGridInterface;
friend class wxPropertyGridManager;
friend class wxPGHeaderCtrl;
wxDECLARE_DYNAMIC_CLASS(wxPropertyGrid);
public:
#ifndef SWIG
// Two step constructor.
// Call Create when this constructor is called to build up the
// wxPropertyGrid
wxPropertyGrid();
#endif
// The default constructor. The styles to be used are styles valid for
// the wxWindow.
wxPropertyGrid( wxWindow *parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxPG_DEFAULT_STYLE,
const wxString& name = wxASCII_STR(wxPropertyGridNameStr) );
// Destructor
virtual ~wxPropertyGrid();
// Adds given key combination to trigger given action.
// Here is a sample code to make Enter key press move focus to
// the next property.
// propGrid->AddActionTrigger(wxPG_ACTION_NEXT_PROPERTY, WXK_RETURN);
// propGrid->DedicateKey(WXK_RETURN);
// action - Which action to trigger. See @ref propgrid_keyboard_actions.
// keycode - Which keycode triggers the action.
// modifiers - Which key event modifiers, in addition to keycode, are needed to
// trigger the action.
void AddActionTrigger( int action, int keycode, int modifiers = 0 );
// Dedicates a specific keycode to wxPropertyGrid. This means that such
// key presses will not be redirected to editor controls.
// Using this function allows, for example, navigation between
// properties using arrow keys even when the focus is in the editor
// control.
void DedicateKey( int keycode )
{
#if WXWIN_COMPATIBILITY_3_0
// Deprecated: use a hash set instead.
m_dedicatedKeys.push_back(keycode);
#else
m_dedicatedKeys.insert(keycode);
#endif
}
// This static function enables or disables automatic use of
// wxGetTranslation for following strings: wxEnumProperty list labels,
// wxFlagsProperty child property labels.
// Default is false.
static void AutoGetTranslation( bool enable );
// Changes value of a property, as if from an editor.
// Use this instead of SetPropertyValue() if you need the value to run
// through validation process, and also send the property change event.
// Returns true if value was successfully changed.
bool ChangePropertyValue( wxPGPropArg id, wxVariant newValue );
// Centers the splitter.
// enableAutoResizing - If true, automatic column resizing is enabled
// (only applicable if window style wxPG_SPLITTER_AUTO_CENTER is used).
void CenterSplitter( bool enableAutoResizing = false );
// Deletes all properties.
virtual void Clear() wxOVERRIDE;
// Clears action triggers for given action.
// action - Which action to trigger.
void ClearActionTriggers( int action );
// Forces updating the value of property from the editor control.
// Note that wxEVT_PG_CHANGING and wxEVT_PG_CHANGED are dispatched using
// ProcessEvent, meaning your event handlers will be called immediately.
// Returns true if anything was changed.
virtual bool CommitChangesFromEditor( wxUint32 flags = 0 );
// Two step creation.
// Whenever the control is created without any parameters, use Create to
// actually create it. Don't access the control's public methods before
// this is called @see @link wndflags Additional Window Styles@endlink
bool Create( wxWindow *parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxPG_DEFAULT_STYLE,
const wxString& name = wxASCII_STR(wxPropertyGridNameStr) );
// Call when editor widget's contents is modified.
// For example, this is called when changes text in wxTextCtrl (used in
// wxStringProperty and wxIntProperty).
// This function should only be called by custom properties.
void EditorsValueWasModified() { m_iFlags |= wxPG_FL_VALUE_MODIFIED; }
// Reverse of EditorsValueWasModified().
// This function should only be called by custom properties.
void EditorsValueWasNotModified()
{
m_iFlags &= ~(wxPG_FL_VALUE_MODIFIED);
}
// Enables or disables (shows/hides) categories according to parameter
// enable.
bool EnableCategories( bool enable );
// Scrolls and/or expands items to ensure that the given item is visible.
// Returns true if something was actually done.
bool EnsureVisible( wxPGPropArg id );
// Reduces column sizes to minimum possible that contents are still
// visibly (naturally some margin space will be applied as well).
// Returns minimum size for the grid to still display everything.
// Does not work well with wxPG_SPLITTER_AUTO_CENTER window style.
// This function only works properly if grid size prior to call was already
// fairly large.
// Note that you can also get calculated column widths by calling
// GetState->GetColumnWidth() immediately after this function returns.
wxSize FitColumns()
{
wxSize sz = m_pState->DoFitColumns();
return sz;
}
// Returns wxWindow that the properties are painted on, and which should
// be used as the parent for editor controls.
wxWindow* GetPanel()
{
return this;
}
// Returns current category caption background colour.
wxColour GetCaptionBackgroundColour() const { return m_colCapBack; }
wxFont& GetCaptionFont() { return m_captionFont; }
// Returns current category caption font.
const wxFont& GetCaptionFont() const { return m_captionFont; }
// Returns current category caption text colour.
wxColour GetCaptionForegroundColour() const { return m_colCapFore; }
// Returns current cell background colour.
wxColour GetCellBackgroundColour() const { return m_colPropBack; }
// Returns current cell text colour when disabled.
wxColour GetCellDisabledTextColour() const { return m_colDisPropFore; }
// Returns current cell text colour.
wxColour GetCellTextColour() const { return m_colPropFore; }
// Returns number of columns currently on grid.
unsigned int GetColumnCount() const
{
return m_pState->GetColumnCount();
}
// Returns colour of empty space below properties.
wxColour GetEmptySpaceColour() const { return m_colEmptySpace; }
// Returns height of highest characters of used font.
int GetFontHeight() const { return m_fontHeight; }
// Returns pointer to itself. Dummy function that enables same kind
// of code to use wxPropertyGrid and wxPropertyGridManager.
wxPropertyGrid* GetGrid() { return this; }
// Returns rectangle of custom paint image.
wxRect GetImageRect( wxPGProperty* p, int item ) const;
// Returns size of the custom paint image in front of property.
// If no argument is given (p is NULL), returns preferred size.
wxSize GetImageSize( wxPGProperty* p = NULL, int item = -1 ) const;
// Returns last item which could be iterated using given flags.
wxPGProperty* GetLastItem( int flags = wxPG_ITERATE_DEFAULT )
{
return m_pState->GetLastItem(flags);
}
const wxPGProperty* GetLastItem( int flags = wxPG_ITERATE_DEFAULT ) const
{
return m_pState->GetLastItem(flags);
}
// Returns colour of lines between cells.
wxColour GetLineColour() const { return m_colLine; }
// Returns background colour of margin.
wxColour GetMarginColour() const { return m_colMargin; }
// Returns margin width.
int GetMarginWidth() const { return m_marginWidth; }
// Returns most up-to-date value of selected property. This will return
// value different from GetSelectedProperty()->GetValue() only when text
// editor is activate and string edited by user represents valid,
// uncommitted property value.
wxVariant GetUncommittedPropertyValue();
// Returns "root property". It does not have name, etc. and it is not
// visible. It is only useful for accessing its children.
wxPGProperty* GetRoot() const { return m_pState->m_properties; }
// Returns height of a single grid row (in pixels).
int GetRowHeight() const { return m_lineHeight; }
// Returns currently selected property.
wxPGProperty* GetSelectedProperty() const { return GetSelection(); }
// Returns current selection background colour.
wxColour GetSelectionBackgroundColour() const { return m_colSelBack; }
// Returns current selection text colour.
wxColour GetSelectionForegroundColour() const { return m_colSelFore; }
// Returns current splitter x position.
int GetSplitterPosition( unsigned int splitterIndex = 0 ) const
{
return m_pState->DoGetSplitterPosition(splitterIndex);
}
// Returns wxTextCtrl active in currently selected property, if any. Takes
// into account wxOwnerDrawnComboBox.
wxTextCtrl* GetEditorTextCtrl() const;
wxPGValidationInfo& GetValidationInfo()
{
return m_validationInfo;
}
// Returns current vertical spacing.
int GetVerticalSpacing() const { return (int)m_vspacing; }
// Returns true if a property editor control has focus.
bool IsEditorFocused() const;
// Returns true if editor's value was marked modified.
bool IsEditorsValueModified() const
{ return ( m_iFlags & wxPG_FL_VALUE_MODIFIED ) ? true : false; }
// Returns information about arbitrary position in the grid.
// pt - Coordinates in the virtual grid space. You may need to use
// wxScrolled<T>::CalcScrolledPosition() for translating
// wxPropertyGrid client coordinates into something this member
// function can use.
wxPropertyGridHitTestResult HitTest( const wxPoint& pt ) const;
// Returns true if any property has been modified by the user.
bool IsAnyModified() const
#if WXWIN_COMPATIBILITY_3_0
{ return m_pState->m_anyModified != (unsigned char)false; }
#else
{ return m_pState->m_anyModified; }
#endif
// It is recommended that you call this function any time your code causes
// wxPropertyGrid's top-level parent to change. wxPropertyGrid's OnIdle()
// handler should be able to detect most changes, but it is not perfect.
// newTLP - New top-level parent that is about to be set. Old top-level parent
// window should still exist as the current one.
// This function is automatically called from wxPropertyGrid::
// Reparent() and wxPropertyGridManager::Reparent(). You only
// need to use it if you reparent wxPropertyGrid indirectly.
void OnTLPChanging( wxWindow* newTLP );
// Redraws given property.
virtual void RefreshProperty( wxPGProperty* p ) wxOVERRIDE;
// Registers a new editor class.
// Returns pointer to the editor class instance that should be used.
static wxPGEditor* RegisterEditorClass( wxPGEditor* editor,
bool noDefCheck = false )
{
return DoRegisterEditorClass(editor, wxEmptyString, noDefCheck);
}
static wxPGEditor* DoRegisterEditorClass( wxPGEditor* editorClass,
const wxString& editorName,
bool noDefCheck = false );
// Resets all colours to the original system values.
void ResetColours();
// Resets column sizes and splitter positions, based on proportions.
// enableAutoResizing - If true, automatic column resizing is enabled
// (only applicable if window style wxPG_SPLITTER_AUTO_CENTER is used).
void ResetColumnSizes( bool enableAutoResizing = false );
// Selects a property.
// Editor widget is automatically created, but not focused unless focus is
// true.
// id - Property to select.
// Returns true if selection finished successfully. Usually only fails if
// current value in editor is not valid.
// This function clears any previous selection.
bool SelectProperty( wxPGPropArg id, bool focus = false );
// Set entire new selection from given list of properties.
void SetSelection( const wxArrayPGProperty& newSelection )
{
DoSetSelection( newSelection, wxPG_SEL_DONT_SEND_EVENT );
}
// Adds given property into selection. If wxPG_EX_MULTIPLE_SELECTION
// extra style is not used, then this has same effect as
// calling SelectProperty().
// Multiple selection is not supported for categories. This
// means that if you have properties selected, you cannot
// add category to selection, and also if you have category
// selected, you cannot add other properties to selection.
// This member function will fail silently in these cases,
// even returning true.
bool AddToSelection( wxPGPropArg id )
{
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
return DoAddToSelection(p, wxPG_SEL_DONT_SEND_EVENT);
}
// Removes given property from selection. If property is not selected,
// an assertion failure will occur.
bool RemoveFromSelection( wxPGPropArg id )
{
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
return DoRemoveFromSelection(p, wxPG_SEL_DONT_SEND_EVENT);
}
// Makes given column editable by user.
// editable - Using false here will disable column from being editable.
void MakeColumnEditable( unsigned int column, bool editable = true );
// Creates label editor wxTextCtrl for given column, for property
// that is currently selected. When multiple selection is
// enabled, this applies to whatever property GetSelection()
// returns.
// colIndex - Which column's label to edit. Note that you should not
// use value 1, which is reserved for property value
// column.
void BeginLabelEdit( unsigned int column = 0 )
{
DoBeginLabelEdit(column, wxPG_SEL_DONT_SEND_EVENT);
}
// Destroys label editor wxTextCtrl, if any.
// commit - Use true (default) to store edited label text in
// property cell data.
void EndLabelEdit( bool commit = true )
{
DoEndLabelEdit(commit, wxPG_SEL_DONT_SEND_EVENT);
}
// Returns currently active label editor, NULL if none.
wxTextCtrl* GetLabelEditor() const
{
return m_labelEditor;
}
// Sets category caption background colour.
void SetCaptionBackgroundColour(const wxColour& col);
// Sets category caption text colour.
void SetCaptionTextColour(const wxColour& col);
// Sets default cell background colour - applies to property cells.
// Note that appearance of editor widgets may not be affected.
void SetCellBackgroundColour(const wxColour& col);
// Sets cell text colour for disabled properties.
void SetCellDisabledTextColour(const wxColour& col);
// Sets default cell text colour - applies to property name and value text.
// Note that appearance of editor widgets may not be affected.
void SetCellTextColour(const wxColour& col);
// Set number of columns (2 or more).
void SetColumnCount( int colCount )
{
m_pState->SetColumnCount(colCount);
Refresh();
}
// Sets the 'current' category - Append will add non-category properties
// under it.
void SetCurrentCategory( wxPGPropArg id )
{
wxPG_PROP_ARG_CALL_PROLOG()
wxPropertyCategory* pc = wxDynamicCast(p, wxPropertyCategory);
wxASSERT(pc);
m_pState->m_currentCategory = pc;
}
// Sets colour of empty space below properties.
void SetEmptySpaceColour(const wxColour& col);
// Sets colour of lines between cells.
void SetLineColour(const wxColour& col);
// Sets background colour of margin.
void SetMarginColour(const wxColour& col);
// Sets selection background colour - applies to selected property name
// background.
void SetSelectionBackgroundColour(const wxColour& col);
// Sets selection foreground colour - applies to selected property name
// text.
void SetSelectionTextColour(const wxColour& col);
// Sets x coordinate of the splitter.
// Splitter position cannot exceed grid size, and therefore setting it
// during form creation may fail as initial grid size is often smaller
// than desired splitter position, especially when sizers are being used.
void SetSplitterPosition( int newXPos, int col = 0 )
{
DoSetSplitterPosition(newXPos, col, wxPG_SPLITTER_REFRESH);
}
// Sets the property sorting function.
// sortFunction - The sorting function to be used. It should return a value greater
// than 0 if position of p1 is after p2. So, for instance, when
// comparing property names, you can use following implementation:
// int MyPropertySortFunction(wxPropertyGrid* propGrid,
// wxPGProperty* p1,
// wxPGProperty* p2)
// {
// return p1->GetBaseName().compare( p2->GetBaseName() );
// }
// Default property sort function sorts properties by their labels
// (case-insensitively).
void SetSortFunction( wxPGSortCallback sortFunction )
{
m_sortFunction = sortFunction;
}
// Returns the property sort function (default is NULL).
wxPGSortCallback GetSortFunction() const
{
return m_sortFunction;
}
// Sets appearance of value cells representing an unspecified property
// value. Default appearance is blank.
// If you set the unspecified value to have any
// textual representation, then that will override
// "InlineHelp" attribute.
void SetUnspecifiedValueAppearance( const wxPGCell& cell )
{
m_unspecifiedAppearance = m_propertyDefaultCell;
m_unspecifiedAppearance.MergeFrom(cell);
}
// Returns current appearance of unspecified value cells.
const wxPGCell& GetUnspecifiedValueAppearance() const
{
return m_unspecifiedAppearance;
}
// Returns (visual) text representation of the unspecified
// property value.
// argFlags - For internal use only.
wxString GetUnspecifiedValueText( int argFlags = 0 ) const;
// Set virtual width for this particular page. Width -1 indicates that the
// virtual width should be disabled.
void SetVirtualWidth( int width );
// Moves splitter as left as possible, while still allowing all
// labels to be shown in full.
// privateChildrenToo - If false, will still allow private children to be cropped.
void SetSplitterLeft( bool privateChildrenToo = false )
{
m_pState->SetSplitterLeft(privateChildrenToo);
}
// Sets vertical spacing. Can be 1, 2, or 3 - a value relative to font
// height. Value of 2 should be default on most platforms.
void SetVerticalSpacing( int vspacing )
{
m_vspacing = (unsigned char)vspacing;
CalculateFontAndBitmapStuff( vspacing );
if ( !m_pState->m_itemsAdded ) Refresh();
}
// Shows an brief error message that is related to a property.
void ShowPropertyError( wxPGPropArg id, const wxString& msg )
{
wxPG_PROP_ARG_CALL_PROLOG()
DoShowPropertyError(p, msg);
}
/////////////////////////////////////////////////////////////////
//
// Following methods do not need to be (currently) documented
//
/////////////////////////////////////////////////////////////////
bool HasVirtualWidth() const
{ return (m_iFlags & wxPG_FL_HAS_VIRTUAL_WIDTH) ? true : false; }
const wxPGCommonValue* GetCommonValue( unsigned int i ) const
{
wxCHECK_MSG( i < m_commonValues.size(), NULL, "Invalid item index" );
return m_commonValues[i];
}
// Returns number of common values.
unsigned int GetCommonValueCount() const
{
return (unsigned int) m_commonValues.size();
}
// Returns label of given common value.
wxString GetCommonValueLabel( unsigned int i ) const
{
wxCHECK_MSG( i < m_commonValues.size(), wxString(), "Invalid item index" );
return GetCommonValue(i)->GetLabel();
}
// Returns index of common value that will truly change value to
// unspecified.
int GetUnspecifiedCommonValue() const { return m_cvUnspecified; }
// Set index of common value that will truly change value to unspecified.
// Using -1 will set none to have such effect.
// Default is 0.
void SetUnspecifiedCommonValue( int index ) { m_cvUnspecified = index; }
// Shortcut for creating dialog-caller button. Used, for example, by
// wxFontProperty.
// This should only be called by properties.
wxWindow* GenerateEditorButton( const wxPoint& pos, const wxSize& sz );
// Fixes position of wxTextCtrl-like control (wxSpinCtrl usually
// fits as one). Call after control has been created (but before
// shown).
void FixPosForTextCtrl( wxWindow* ctrl,
unsigned int forColumn = 1,
const wxPoint& offset = wxPoint(0, 0) );
// Shortcut for creating text editor widget.
// pos - Same as pos given for CreateEditor.
// sz - Same as sz given for CreateEditor.
// value - Initial text for wxTextCtrl.
// secondary - If right-side control, such as button, also created,
// then create it first and pass it as this parameter.
// extraStyle - Extra style flags to pass for wxTextCtrl.
// Note that this should generally be called only by new classes derived
// from wxPGProperty.
wxWindow* GenerateEditorTextCtrl( const wxPoint& pos,
const wxSize& sz,
const wxString& value,
wxWindow* secondary,
int extraStyle = 0,
int maxLen = 0,
unsigned int forColumn = 1 );
// Generates both textctrl and button.
wxWindow* GenerateEditorTextCtrlAndButton( const wxPoint& pos,
const wxSize& sz, wxWindow** psecondary, int limited_editing,
wxPGProperty* property );
// Generates position for a widget editor dialog box.
// p - Property for which dialog is positioned.
// sz - Known or over-approximated size of the dialog.
// Returns position for dialog.
wxPoint GetGoodEditorDialogPosition( wxPGProperty* p,
const wxSize& sz );
// Converts escape sequences in src_str to newlines,
// tabs, etc. and copies result to dst_str.
static wxString& ExpandEscapeSequences( wxString& dst_str,
const wxString& src_str );
// Converts newlines, tabs, etc. in src_str to escape
// sequences, and copies result to dst_str.
static wxString& CreateEscapeSequences( wxString& dst_str,
const wxString& src_str );
// Checks system screen design used for laying out various dialogs.
static bool IsSmallScreen();
// Returns rescaled bitmap
static wxBitmap RescaleBitmap(const wxBitmap& srcBmp, double scaleX, double scaleY);
// Returns rectangle that fully contains properties between and including
// p1 and p2. Rectangle is in virtual scrolled window coordinates.
wxRect GetPropertyRect( const wxPGProperty* p1,
const wxPGProperty* p2 ) const;
// Returns pointer to current active primary editor control (NULL if none).
wxWindow* GetEditorControl() const;
wxWindow* GetPrimaryEditor() const
{
return GetEditorControl();
}
// Returns pointer to current active secondary editor control (NULL if
// none).
wxWindow* GetEditorControlSecondary() const
{
return m_wndEditor2;
}
// Refreshes any active editor control.
void RefreshEditor();
// Events from editor controls are forward to this function
bool HandleCustomEditorEvent( wxEvent &event );
// Mostly useful for page switching.
void SwitchState( wxPropertyGridPageState* pNewState );
long GetInternalFlags() const { return m_iFlags; }
bool HasInternalFlag( long flag ) const
{ return (m_iFlags & flag) ? true : false; }
void SetInternalFlag( long flag ) { m_iFlags |= flag; }
void ClearInternalFlag( long flag ) { m_iFlags &= ~(flag); }
void OnComboItemPaint( const wxPGComboBox* pCb,
int item,
wxDC* pDc,
wxRect& rect,
int flags );
#if WXWIN_COMPATIBILITY_3_0
// Standardized double-to-string conversion.
static const wxString& DoubleToString( wxString& target,
double value,
int precision,
bool removeZeroes,
wxString* precTemplate = NULL );
#endif // WXWIN_COMPATIBILITY_3_0
// Call this from wxPGProperty::OnEvent() to cause property value to be
// changed after the function returns (with true as return value).
// ValueChangeInEvent() must be used if you wish the application to be
// able to use wxEVT_PG_CHANGING to potentially veto the given value.
void ValueChangeInEvent( const wxVariant& variant )
{
m_changeInEventValue = variant;
m_iFlags |= wxPG_FL_VALUE_CHANGE_IN_EVENT;
}
// You can use this member function, for instance, to detect in
// wxPGProperty::OnEvent() if wxPGProperty::SetValueInEvent() was
// already called in wxPGEditor::OnEvent(). It really only detects
// if was value was changed using wxPGProperty::SetValueInEvent(), which
// is usually used when a 'picker' dialog is displayed. If value was
// written by "normal means" in wxPGProperty::StringToValue() or
// IntToValue(), then this function will return false (on the other hand,
// wxPGProperty::OnEvent() is not even called in those cases).
bool WasValueChangedInEvent() const
{
return (m_iFlags & wxPG_FL_VALUE_CHANGE_IN_EVENT) ? true : false;
}
// Returns true if given event is from first of an array of buttons
// (as can be in case when wxPGMultiButton is used).
bool IsMainButtonEvent( const wxEvent& event ) const
{
return (event.GetEventType() == wxEVT_BUTTON)
&& (m_wndSecId == event.GetId());
}
// Pending value is expected to be passed in PerformValidation().
virtual bool DoPropertyChanged( wxPGProperty* p,
unsigned int selFlags = 0 );
// Called when validation for given property fails.
// invalidValue - Value which failed in validation.
// Returns true if user is allowed to change to another property even
// if current has invalid value.
// To add your own validation failure behaviour, override
// wxPropertyGrid::DoOnValidationFailure().
bool OnValidationFailure( wxPGProperty* property,
wxVariant& invalidValue );
// Called to indicate property and editor has valid value now.
void OnValidationFailureReset( wxPGProperty* property )
{
if ( property && property->HasFlag(wxPG_PROP_INVALID_VALUE) )
{
DoOnValidationFailureReset(property);
property->ClearFlag(wxPG_PROP_INVALID_VALUE);
}
m_validationInfo.m_failureMessage.clear();
}
// Override in derived class to display error messages in custom manner
// (these message usually only result from validation failure).
// If you implement this, then you also need to implement
// DoHidePropertyError() - possibly to do nothing, if error
// does not need hiding (e.g. it was logged or shown in a
// message box).
virtual void DoShowPropertyError( wxPGProperty* property,
const wxString& msg );
// Override in derived class to hide an error displayed by
// DoShowPropertyError().
virtual void DoHidePropertyError( wxPGProperty* property );
#if wxUSE_STATUSBAR
// Return wxStatusBar that is used by this wxPropertyGrid. You can
// reimplement this member function in derived class to override
// the default behaviour of using the top-level wxFrame's status
// bar, if any.
virtual wxStatusBar* GetStatusBar();
#endif
// Override to customize property validation failure behaviour.
// invalidValue - Value which failed in validation.
// Returns true if user is allowed to change to another property even
// if current has invalid value.
virtual bool DoOnValidationFailure( wxPGProperty* property,
wxVariant& invalidValue );
// Override to customize resetting of property validation failure status.
// Property is guaranteed to have flag wxPG_PROP_INVALID_VALUE set.
virtual void DoOnValidationFailureReset( wxPGProperty* property );
int GetSpacingY() const { return m_spacingy; }
// Must be called in wxPGEditor::CreateControls() if primary editor window
// is wxTextCtrl, just before textctrl is created.
// text - Initial text value of created wxTextCtrl.
void SetupTextCtrlValue( const wxString& text ) { m_prevTcValue = text; }
// Unfocuses or closes editor if one was open, but does not deselect
// property.
bool UnfocusEditor();
virtual void SetWindowStyleFlag( long style ) wxOVERRIDE;
void DrawItems( const wxPGProperty* p1, const wxPGProperty* p2 );
void DrawItem( wxPGProperty* p )
{
DrawItems(p,p);
}
virtual void DrawItemAndChildren( wxPGProperty* p );
// Draws item, children, and consecutive parents as long as category is
// not met.
void DrawItemAndValueRelated( wxPGProperty* p );
protected:
// wxPropertyGridPageState used by the grid is created here.
// If grid is used in wxPropertyGridManager, there is no point overriding
// this - instead, set custom wxPropertyGridPage classes.
virtual wxPropertyGridPageState* CreateState() const;
enum PerformValidationFlags
{
SendEvtChanging = 0x0001,
IsStandaloneValidation = 0x0002 // Not called in response to event
};
// Runs all validation functionality (includes sending wxEVT_PG_CHANGING).
// Returns true if all tests passed. Implement in derived class to
// add additional validation behaviour.
virtual bool PerformValidation( wxPGProperty* p,
wxVariant& pendingValue,
int flags = SendEvtChanging );
public:
// Control font changer helper.
void SetCurControlBoldFont();
wxPGCell& GetPropertyDefaultCell()
{
return m_propertyDefaultCell;
}
wxPGCell& GetCategoryDefaultCell()
{
return m_categoryDefaultCell;
}
// Public methods for semi-public use
bool DoSelectProperty( wxPGProperty* p, unsigned int flags = 0 );
// Overridden functions.
virtual bool Destroy() wxOVERRIDE;
// Returns property at given y coordinate (relative to grid's top left).
wxPGProperty* GetItemAtY( int y ) const { return DoGetItemAtY(y); }
virtual void Refresh( bool eraseBackground = true,
const wxRect *rect = (const wxRect *) NULL ) wxOVERRIDE;
virtual bool SetFont( const wxFont& font ) wxOVERRIDE;
virtual void SetExtraStyle( long exStyle ) wxOVERRIDE;
virtual bool Reparent( wxWindowBase *newParent ) wxOVERRIDE;
virtual void ScrollWindow(int dx, int dy, const wxRect* rect) wxOVERRIDE;
virtual void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
int noUnitsX, int noUnitsY,
int xPos, int yPos, bool noRefresh) wxOVERRIDE;
protected:
virtual void DoThaw() wxOVERRIDE;
virtual wxSize DoGetBestSize() const wxOVERRIDE;
virtual void DoEnable(bool enable) wxOVERRIDE;
#ifndef wxPG_ICON_WIDTH
wxBitmap m_expandbmp, m_collbmp;
#endif
wxCursor m_cursorSizeWE;
// wxWindow pointers to editor control(s).
wxWindow *m_wndEditor;
wxWindow *m_wndEditor2;
// Actual positions of the editors within the cell.
wxPoint m_wndEditorPosRel;
wxPoint m_wndEditor2PosRel;
wxBitmap *m_doubleBuffer;
// Local time ms when control was created.
wxMilliClock_t m_timeCreated;
// wxPGProperty::OnEvent can change value by setting this.
wxVariant m_changeInEventValue;
// Id of m_wndEditor2, or its first child, if any.
int m_wndSecId;
// Extra Y spacing between the items.
int m_spacingy;
// Control client area width; updated on resize.
int m_width;
// Control client area height; updated on resize.
int m_height;
// Current non-client width (needed when auto-centering).
int m_ncWidth;
// The gutter spacing in front and back of the image.
// This determines the amount of spacing in front of each item
int m_gutterWidth;
// Includes separator line.
int m_lineHeight;
// Gutter*2 + image width.
int m_marginWidth;
// y spacing for expand/collapse button.
int m_buttonSpacingY;
// Extra margin for expanded sub-group items.
int m_subgroup_extramargin;
// The image width of the [+] icon.
// This is also calculated in the gutter
int m_iconWidth;
#ifndef wxPG_ICON_WIDTH
// The image height of the [+] icon.
// This is calculated as minimal size and to align
int m_iconHeight;
#endif
// Current cursor id.
int m_curcursor;
// Caption font. Same as normal font plus bold style.
wxFont m_captionFont;
int m_fontHeight; // Height of the font.
// m_splitterx when drag began.
int m_startingSplitterX;
// Index to splitter currently being dragged (0=one after the first
// column).
int m_draggedSplitter;
// Changed property, calculated in PerformValidation().
wxPGProperty* m_chgInfo_changedProperty;
// Lowest property for which editing happened, but which does not have
// aggregate parent
wxPGProperty* m_chgInfo_baseChangedProperty;
// Changed property value, calculated in PerformValidation().
wxVariant m_chgInfo_pendingValue;
// Passed to SetValue.
wxVariant m_chgInfo_valueList;
// Validation information.
wxPGValidationInfo m_validationInfo;
// Actions and keys that trigger them.
wxPGHashMapI2I m_actionTriggers;
// Appearance of currently active editor.
wxPGCell m_editorAppearance;
// Appearance of a unspecified value cell.
wxPGCell m_unspecifiedAppearance;
// List of properties to be deleted/removed in idle event handler.
wxVector<wxPGProperty*> m_deletedProperties;
wxVector<wxPGProperty*> m_removedProperties;
#if !WXWIN_COMPATIBILITY_3_0
// List of editors and their event handlers to be deleted in idle event handler.
wxVector<wxObject*> m_deletedEditorObjects;
#endif
// List of key codes that will not be handed over to editor controls.
#if WXWIN_COMPATIBILITY_3_0
// Deprecated: use a hash set instead.
wxVector<int> m_dedicatedKeys;
#else
wxPGHashSetInt m_dedicatedKeys;
#endif
//
// Temporary values
//
// Bits are used to indicate which colours are customized.
unsigned short m_coloursCustomized;
// x - m_splitterx.
signed char m_dragOffset;
// 0 = not dragging, 1 = drag just started, 2 = drag in progress
unsigned char m_dragStatus;
#if WXWIN_COMPATIBILITY_3_0
// Unused variable.
// 0 = margin, 1 = label, 2 = value.
unsigned char m_mouseSide;
// True when editor control is focused.
unsigned char m_editorFocused;
#else
bool m_editorFocused;
#endif
unsigned char m_vspacing;
#if WXWIN_COMPATIBILITY_3_0
// Unused variable.
// Used to track when Alt/Ctrl+Key was consumed.
unsigned char m_keyComboConsumed;
#endif
// 1 if in DoPropertyChanged()
bool m_inDoPropertyChanged;
// 1 if in CommitChangesFromEditor()
bool m_inCommitChangesFromEditor;
// 1 if in DoSelectProperty()
bool m_inDoSelectProperty;
bool m_inOnValidationFailure;
wxPGVFBFlags m_permanentValidationFailureBehavior; // Set by app
// DoEditorValidate() recursion guard
wxRecursionGuardFlag m_validatingEditor;
// Internal flags - see wxPG_FL_XXX constants.
wxUint32 m_iFlags;
#if WXWIN_COMPATIBILITY_3_0
// Unused variable.
// When drawing next time, clear this many item slots at the end.
int m_clearThisMany;
#endif
// Mouse is hovering over this column (index), -1 for margin
int m_colHover;
// pointer to property that has mouse hovering
wxPGProperty* m_propHover;
// Active label editor and its actual position within the cell
wxTextCtrl* m_labelEditor;
wxPoint m_labelEditorPosRel;
// For which property the label editor is active
wxPGProperty* m_labelEditorProperty;
// EventObject for wxPropertyGridEvents
wxWindow* m_eventObject;
// What (global) window is currently focused (needed to resolve event
// handling mess).
wxWindow* m_curFocused;
// Event currently being sent - NULL if none at the moment
wxPropertyGridEvent* m_processedEvent;
// Last known top-level parent
wxWindow* m_tlp;
// Last closed top-level parent
wxWindow* m_tlpClosed;
// Local time ms when tlp was closed.
wxMilliClock_t m_tlpClosedTime;
// Sort function
wxPGSortCallback m_sortFunction;
// y coordinate of property that mouse hovering
int m_propHoverY;
// Which column's editor is selected (usually 1)?
unsigned int m_selColumn;
// x relative to splitter (needed for resize).
int m_ctrlXAdjust;
// lines between cells
wxColour m_colLine;
// property labels and values are written in this colour
wxColour m_colPropFore;
// or with this colour when disabled
wxColour m_colDisPropFore;
// background for m_colPropFore
wxColour m_colPropBack;
// text color for captions
wxColour m_colCapFore;
// background color for captions
wxColour m_colCapBack;
// foreground for selected property
wxColour m_colSelFore;
// background for selected property (actually use background color when
// control out-of-focus)
wxColour m_colSelBack;
// background colour for margin
wxColour m_colMargin;
// background colour for empty space below the grid
wxColour m_colEmptySpace;
// Default property colours
wxPGCell m_propertyDefaultCell;
// Default property category
wxPGCell m_categoryDefaultCell;
// Backup of selected property's cells
wxVector<wxPGCell> m_propCellsBackup;
// NB: These *cannot* be moved to globals.
// labels when properties use common values
wxVector<wxPGCommonValue*> m_commonValues;
// array of live events
wxVector<wxPropertyGridEvent*> m_liveEvents;
// Which cv selection really sets value to unspecified?
int m_cvUnspecified;
// Used to skip excess text editor events
wxString m_prevTcValue;
protected:
// Sets some members to defaults (called constructors).
void Init1();
// Initializes some members (called by Create and complex constructor).
void Init2();
void OnPaint(wxPaintEvent &event );
// main event receivers
void OnMouseMove( wxMouseEvent &event );
void OnMouseClick( wxMouseEvent &event );
void OnMouseRightClick( wxMouseEvent &event );
void OnMouseDoubleClick( wxMouseEvent &event );
void OnMouseUp( wxMouseEvent &event );
void OnKey( wxKeyEvent &event );
void OnResize( wxSizeEvent &event );
// event handlers
bool HandleMouseMove( int x, unsigned int y, wxMouseEvent &event );
bool HandleMouseClick( int x, unsigned int y, wxMouseEvent &event );
bool HandleMouseRightClick( int x, unsigned int y, wxMouseEvent &event );
bool HandleMouseDoubleClick( int x, unsigned int y, wxMouseEvent &event );
bool HandleMouseUp( int x, unsigned int y, wxMouseEvent &event );
void HandleKeyEvent( wxKeyEvent &event, bool fromChild );
void OnMouseEntry( wxMouseEvent &event );
void OnIdle( wxIdleEvent &event );
void OnFocusEvent( wxFocusEvent &event );
void OnChildFocusEvent( wxChildFocusEvent& event );
bool OnMouseCommon( wxMouseEvent &event, int* px, int *py );
bool OnMouseChildCommon( wxMouseEvent &event, int* px, int *py );
// sub-control event handlers
void OnMouseClickChild( wxMouseEvent &event );
void OnMouseRightClickChild( wxMouseEvent &event );
void OnMouseMoveChild( wxMouseEvent &event );
void OnMouseUpChild( wxMouseEvent &event );
void OnChildKeyDown( wxKeyEvent &event );
void OnCaptureChange( wxMouseCaptureChangedEvent &event );
void OnScrollEvent( wxScrollWinEvent &event );
void OnSysColourChanged( wxSysColourChangedEvent &event );
void OnDPIChanged(wxDPIChangedEvent& event);
void OnTLPClose( wxCloseEvent& event );
protected:
bool AddToSelectionFromInputEvent( wxPGProperty* prop,
unsigned int colIndex,
wxMouseEvent* event = NULL,
int selFlags = 0 );
// Adjust the centering of the bitmap icons (collapse / expand) when the
// caption font changes.
// They need to be centered in the middle of the font, so a bit of deltaY
// adjustment is needed. On entry, m_captionFont must be set to window
// font. It will be modified properly.
void CalculateFontAndBitmapStuff( int vspacing );
wxRect GetEditorWidgetRect( wxPGProperty* p, int column ) const;
void CorrectEditorWidgetSizeX();
// Called in RecalculateVirtualSize() to reposition control
// on virtual height changes.
void CorrectEditorWidgetPosY();
#if WXWIN_COMPATIBILITY_3_0
wxDEPRECATED_MSG("use two-argument function DoDrawItems(dc,rect)")
int DoDrawItems( wxDC& dc,
const wxRect* itemsRect,
bool isBuffered ) const
{
return DoDrawItemsBase(dc, itemsRect, isBuffered);
}
int DoDrawItems( wxDC& dc,
const wxRect* itemsRect ) const
{
return DoDrawItemsBase(dc, itemsRect, true);
}
int DoDrawItemsBase( wxDC& dc,
const wxRect* itemsRect,
bool isBuffered ) const;
#else
int DoDrawItems( wxDC& dc,
const wxRect* itemsRect ) const;
#endif
// Draws an expand/collapse (ie. +/-) button.
virtual void DrawExpanderButton( wxDC& dc, const wxRect& rect,
wxPGProperty* property ) const;
// Draws items from topItemY to bottomItemY
void DrawItems( wxDC& dc,
unsigned int topItemY,
unsigned int bottomItemY,
const wxRect* itemsRect = NULL );
// Translate wxKeyEvent to wxPG_ACTION_XXX
int KeyEventToActions(wxKeyEvent &event, int* pSecond) const;
int KeyEventToAction(wxKeyEvent &event) const
{
return KeyEventToActions(event, NULL);
}
void ImprovedClientToScreen( int* px, int* py ) const;
// Called by focus event handlers. newFocused is the window that becomes
// focused.
void HandleFocusChange( wxWindow* newFocused );
// Reloads all non-customized colours from system settings.
void RegainColours();
virtual bool DoEditorValidate();
// Similar to DoSelectProperty() but also works on columns
// other than 1. Does not active editor if column is not
// editable.
bool DoSelectAndEdit( wxPGProperty* prop,
unsigned int colIndex,
unsigned int selFlags );
void DoSetSelection( const wxArrayPGProperty& newSelection,
int selFlags = 0 );
void DoSetSplitterPosition( int newxpos,
int splitterIndex = 0,
int flags = wxPG_SPLITTER_REFRESH );
bool DoAddToSelection( wxPGProperty* prop,
int selFlags = 0 );
bool DoRemoveFromSelection( wxPGProperty* prop,
int selFlags = 0 );
void DoBeginLabelEdit( unsigned int colIndex, int selFlags = 0 );
void DoEndLabelEdit( bool commit, int selFlags = 0 );
void OnLabelEditorEnterPress( wxCommandEvent& event );
void OnLabelEditorKeyPress( wxKeyEvent& event );
wxPGProperty* DoGetItemAtY( int y ) const;
void DestroyEditorWnd( wxWindow* wnd );
void FreeEditors();
virtual bool DoExpand( wxPGProperty* p, bool sendEvent = false );
virtual bool DoCollapse( wxPGProperty* p, bool sendEvent = false );
// Returns nearest paint visible property (such that will be painted unless
// window is scrolled or resized). If given property is paint visible, then
// it itself will be returned.
wxPGProperty* GetNearestPaintVisible( wxPGProperty* p ) const;
static void RegisterDefaultEditors();
// Sets up basic event handling for child control
void SetupChildEventHandling( wxWindow* wnd );
void CustomSetCursor( int type, bool override = false );
// Repositions scrollbar and underlying panel according
// to changed virtual size.
void RecalculateVirtualSize( int forceXPos = -1 );
void SetEditorAppearance( const wxPGCell& cell,
bool unspecified = false );
void ResetEditorAppearance()
{
wxPGCell cell;
cell.SetEmptyData();
SetEditorAppearance(cell, false);
}
void PrepareAfterItemsAdded();
// Send event from the property grid.
// Omit the wxPG_SEL_NOVALIDATE flag to allow vetoing the event
bool SendEvent( wxEventType eventType, wxPGProperty* p,
wxVariant* pValue = NULL,
unsigned int selFlags = wxPG_SEL_NOVALIDATE,
unsigned int column = 1 );
void SendEvent(wxEventType eventType, int intVal);
// This function only moves focus to the wxPropertyGrid if it already
// was on one of its child controls.
void SetFocusOnCanvas();
bool DoHideProperty( wxPGProperty* p, bool hide, int flags );
void DeletePendingObjects();
private:
bool ButtonTriggerKeyTest( int action, wxKeyEvent& event );
wxDECLARE_EVENT_TABLE();
};
// -----------------------------------------------------------------------
#define wxPG_BASE_EVT_PRE_ID 1775
#ifndef SWIG
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID, wxEVT_PG_SELECTED, wxPropertyGridEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID, wxEVT_PG_CHANGING, wxPropertyGridEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID, wxEVT_PG_CHANGED, wxPropertyGridEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID, wxEVT_PG_HIGHLIGHTED, wxPropertyGridEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID, wxEVT_PG_RIGHT_CLICK, wxPropertyGridEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID, wxEVT_PG_PAGE_CHANGED, wxPropertyGridEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID, wxEVT_PG_ITEM_COLLAPSED, wxPropertyGridEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID, wxEVT_PG_ITEM_EXPANDED, wxPropertyGridEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID, wxEVT_PG_DOUBLE_CLICK, wxPropertyGridEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID,
wxEVT_PG_LABEL_EDIT_BEGIN, wxPropertyGridEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID,
wxEVT_PG_LABEL_EDIT_ENDING, wxPropertyGridEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID,
wxEVT_PG_COL_BEGIN_DRAG, wxPropertyGridEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID,
wxEVT_PG_COL_DRAGGING, wxPropertyGridEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID,
wxEVT_PG_COL_END_DRAG, wxPropertyGridEvent );
// Events used only internally
wxDECLARE_EVENT(wxEVT_PG_HSCROLL, wxPropertyGridEvent);
wxDECLARE_EVENT(wxEVT_PG_COLS_RESIZED, wxPropertyGridEvent);
#else
enum {
wxEVT_PG_SELECTED = wxPG_BASE_EVT_PRE_ID,
wxEVT_PG_CHANGING,
wxEVT_PG_CHANGED,
wxEVT_PG_HIGHLIGHTED,
wxEVT_PG_RIGHT_CLICK,
wxEVT_PG_PAGE_CHANGED,
wxEVT_PG_ITEM_COLLAPSED,
wxEVT_PG_ITEM_EXPANDED,
wxEVT_PG_DOUBLE_CLICK,
wxEVT_PG_LABEL_EDIT_BEGIN,
wxEVT_PG_LABEL_EDIT_ENDING,
wxEVT_PG_COL_BEGIN_DRAG,
wxEVT_PG_COL_DRAGGING,
wxEVT_PG_COL_END_DRAG
};
#endif
#define wxPG_BASE_EVT_TYPE wxEVT_PG_SELECTED
#define wxPG_MAX_EVT_TYPE (wxPG_BASE_EVT_TYPE+30)
#ifndef SWIG
typedef void (wxEvtHandler::*wxPropertyGridEventFunction)(wxPropertyGridEvent&);
#define EVT_PG_SELECTED(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_SELECTED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
#define EVT_PG_CHANGING(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_CHANGING, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
#define EVT_PG_CHANGED(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_CHANGED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
#define EVT_PG_HIGHLIGHTED(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_HIGHLIGHTED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
#define EVT_PG_RIGHT_CLICK(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_RIGHT_CLICK, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
#define EVT_PG_DOUBLE_CLICK(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_DOUBLE_CLICK, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
#define EVT_PG_PAGE_CHANGED(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_PAGE_CHANGED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
#define EVT_PG_ITEM_COLLAPSED(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_ITEM_COLLAPSED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
#define EVT_PG_ITEM_EXPANDED(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_ITEM_EXPANDED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
#define EVT_PG_LABEL_EDIT_BEGIN(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_LABEL_EDIT_BEGIN, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
#define EVT_PG_LABEL_EDIT_ENDING(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_LABEL_EDIT_ENDING, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
#define EVT_PG_COL_BEGIN_DRAG(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_COL_BEGIN_DRAG, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
#define EVT_PG_COL_DRAGGING(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_COL_DRAGGING, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
#define EVT_PG_COL_END_DRAG(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_COL_END_DRAG, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
#define wxPropertyGridEventHandler(fn) \
wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn )
#endif
// A propertygrid event holds information about events associated with
// wxPropertyGrid objects.
class WXDLLIMPEXP_PROPGRID wxPropertyGridEvent : public wxCommandEvent
{
public:
// Constructor.
wxPropertyGridEvent(wxEventType commandType=0, int id=0);
// Copy constructor.
wxPropertyGridEvent(const wxPropertyGridEvent& event);
// Destructor.
~wxPropertyGridEvent();
// Copyer.
virtual wxEvent* Clone() const wxOVERRIDE;
// Returns the column index associated with this event.
// For the column dragging events, it is the column to the left
// of the splitter being dragged
unsigned int GetColumn() const
{
return m_column;
}
wxPGProperty* GetMainParent() const
{
wxCHECK_MSG(m_property, NULL, "Property cannot be NULL");
return m_property->GetMainParent();
}
// Returns property associated with this event.
wxPGProperty* GetProperty() const
{
return m_property;
}
wxPGValidationInfo& GetValidationInfo()
{
wxASSERT(m_validationInfo);
return *m_validationInfo;
}
// Returns true if you can veto the action that the event is signaling.
bool CanVeto() const { return m_canVeto; }
// Call this from your event handler to veto action that the event is
// signaling.
// You can only veto a shutdown if wxPropertyGridEvent::CanVeto returns
// true.
// Currently only wxEVT_PG_CHANGING supports vetoing.
void Veto( bool veto = true ) { m_wasVetoed = veto; }
// Returns name of the associated property.
// Property name is stored in event, so it remains
// accessible even after the associated property or
// the property grid has been deleted.
wxString GetPropertyName() const
{
return m_propertyName;
}
// Returns value of the associated property. Works for all event
// types, but for wxEVT_PG_CHANGING this member function returns
// the value that is pending, so you can call Veto() if the
// value is not satisfactory.
// Property value is stored in event, so it remains
// accessible even after the associated property or
// the property grid has been deleted.
wxVariant GetPropertyValue() const
{
return m_validationInfo ? m_validationInfo->GetValue() : m_value;
}
// Returns value of the associated property.
// See GetPropertyValue()
wxVariant GetValue() const
{
return GetPropertyValue();
}
// Set override validation failure behaviour.
// Only effective if Veto was also called, and only allowed if event type
// is wxEVT_PG_CHANGING.
void SetValidationFailureBehavior( wxPGVFBFlags flags )
{
wxASSERT( GetEventType() == wxEVT_PG_CHANGING );
m_validationInfo->SetFailureBehavior( flags );
}
// Sets custom failure message for this time only. Only applies if
// wxPG_VFB_SHOW_MESSAGE is set in validation failure flags.
void SetValidationFailureMessage( const wxString& message )
{
wxASSERT( GetEventType() == wxEVT_PG_CHANGING );
m_validationInfo->SetFailureMessage( message );
}
wxPGVFBFlags GetValidationFailureBehavior() const
{
wxASSERT( GetEventType() == wxEVT_PG_CHANGING );
return m_validationInfo->GetFailureBehavior();
}
void SetColumn( unsigned int column )
{
m_column = column;
}
void SetCanVeto( bool canVeto ) { m_canVeto = canVeto; }
bool WasVetoed() const { return m_wasVetoed; }
// Changes the property associated with this event.
void SetProperty( wxPGProperty* p )
{
m_property = p;
if ( p )
m_propertyName = p->GetName();
}
void SetPropertyValue( const wxVariant& value )
{
m_value = value;
}
void SetPropertyGrid( wxPropertyGrid* pg )
{
m_pg = pg;
OnPropertyGridSet();
}
void SetupValidationInfo()
{
wxASSERT(m_pg);
wxASSERT( GetEventType() == wxEVT_PG_CHANGING );
m_validationInfo = &m_pg->GetValidationInfo();
m_value = m_validationInfo->GetValue();
}
private:
void OnPropertyGridSet();
wxDECLARE_DYNAMIC_CLASS(wxPropertyGridEvent);
wxPGProperty* m_property;
wxPropertyGrid* m_pg;
wxPGValidationInfo* m_validationInfo;
wxString m_propertyName;
wxVariant m_value;
unsigned int m_column;
bool m_canVeto;
bool m_wasVetoed;
};
// -----------------------------------------------------------------------
// Allows populating wxPropertyGrid from arbitrary text source.
class WXDLLIMPEXP_PROPGRID wxPropertyGridPopulator
{
public:
// Default constructor.
wxPropertyGridPopulator();
// Destructor.
virtual ~wxPropertyGridPopulator();
void SetState( wxPropertyGridPageState* state );
void SetGrid( wxPropertyGrid* pg );
// Appends a new property under bottommost parent.
// propClass - Property class as string.
wxPGProperty* Add( const wxString& propClass,
const wxString& propLabel,
const wxString& propName,
const wxString* propValue,
wxPGChoices* pChoices = NULL );
// Pushes property to the back of parent array (ie it becomes bottommost
// parent), and starts scanning/adding children for it.
// When finished, parent array is returned to the original state.
void AddChildren( wxPGProperty* property );
// Adds attribute to the bottommost property.
// type - Allowed values: "string", (same as string), "int", "bool".
// Empty string mean autodetect.
bool AddAttribute( const wxString& name,
const wxString& type,
const wxString& value );
// Called once in AddChildren.
virtual void DoScanForChildren() = 0;
// Returns id of parent property for which children can currently be
// added.
wxPGProperty* GetCurParent() const
{
return m_propHierarchy.back();
}
wxPropertyGridPageState* GetState() { return m_state; }
const wxPropertyGridPageState* GetState() const { return m_state; }
// Like wxString::ToLong, except allows N% in addition of N.
static bool ToLongPCT( const wxString& s, long* pval, long max );
// Parses strings of format "choice1"[=value1] ... "choiceN"[=valueN] into
// wxPGChoices. Registers parsed result using idString (if not empty).
// Also, if choices with given id already registered, then don't parse but
// return those choices instead.
wxPGChoices ParseChoices( const wxString& choicesString,
const wxString& idString );
// Implement in derived class to do custom process when an error occurs.
// Default implementation uses wxLogError.
virtual void ProcessError( const wxString& msg );
protected:
// Used property grid.
wxPropertyGrid* m_pg;
// Used property grid state.
wxPropertyGridPageState* m_state;
// Tree-hierarchy of added properties (that can have children).
wxVector<wxPGProperty*> m_propHierarchy;
// Hashmap for string-id to wxPGChoicesData mapping.
wxPGHashMapS2P m_dictIdChoices;
};
// -----------------------------------------------------------------------
//
// Undefine macros that are not needed outside propertygrid sources
//
#ifndef __wxPG_SOURCE_FILE__
#undef wxPG_FL_DESC_REFRESH_REQUIRED
#undef wxPG_FL_CREATEDSTATE
#undef wxPG_FL_NOSTATUSBARHELP
#undef wxPG_FL_SCROLLED
#undef wxPG_FL_CUR_USES_CUSTOM_IMAGE
#undef wxPG_FL_PRIMARY_FILLS_ENTIRE
#undef wxPG_FL_VALUE_MODIFIED
#undef wxPG_FL_MOUSE_INSIDE
#undef wxPG_FL_FOCUSED
#undef wxPG_FL_MOUSE_CAPTURED
#undef wxPG_FL_INITIALIZED
#undef wxPG_FL_ACTIVATION_BY_CLICK
#undef wxPG_ICON_WIDTH
#undef wxPG_USE_RENDERER_NATIVE
#endif
// -----------------------------------------------------------------------
#endif
#endif // _WX_PROPGRID_PROPGRID_H_
|