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 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719
|
/////////////////////////////////////////////////////////////////////////////
// Name: grid.h
// Purpose: interface of wxGrid and related classes
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/// Magic constant which tells (to some functions) to automatically calculate
/// the appropriate size
#define wxGRID_AUTOSIZE (-1)
/**
@class wxGridCellRenderer
This class is responsible for actually drawing the cell in the grid. You
may pass it to the wxGridCellAttr (below) to change the format of one given
cell or to wxGrid::SetDefaultRenderer() to change the view of all cells.
This is an abstract class, and you will normally use one of the predefined
derived classes or derive your own class from it.
@library{wxcore}
@category{grid}
@see wxGridCellAutoWrapStringRenderer, wxGridCellBoolRenderer,
wxGridCellDateTimeRenderer, wxGridCellEnumRenderer,
wxGridCellFloatRenderer, wxGridCellNumberRenderer,
wxGridCellStringRenderer
*/
class wxGridCellRenderer : public wxSharedClientDataContainer, public wxRefCounter
{
public:
wxGridCellRenderer();
/**
This function must be implemented in derived classes to return a copy
of itself.
*/
virtual wxGridCellRenderer* Clone() const = 0;
/**
Draw the given cell on the provided DC inside the given rectangle using
the style specified by the attribute and the default or selected state
corresponding to the isSelected value.
This pure virtual function has a default implementation which will
prepare the DC using the given attribute: it will draw the rectangle
with the background colour from attr and set the text colour and font.
*/
virtual void Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc,
const wxRect& rect, int row, int col,
bool isSelected) = 0;
/**
Get the preferred size of the cell for its contents.
This method must be overridden in the derived classes to return the
minimal fitting size for displaying the content of the given grid cell.
@see GetBestHeight(), GetBestWidth()
*/
virtual wxSize GetBestSize(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc,
int row, int col) = 0;
/**
Get the preferred height of the cell at the given width.
Some renderers may not have a well-defined best size, but only be able
to provide the best height at the given width, e.g. this is the case of
the standard wxGridCellAutoWrapStringRenderer. In this case, they
should override this method, in addition to GetBestSize().
@see GetBestWidth()
@since 3.1.0
*/
virtual int GetBestHeight(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc,
int row, int col, int width);
/**
Get the preferred width of the cell at the given height.
See GetBestHeight(), this method is symmetric to it.
@since 3.1.0
*/
virtual int GetBestWidth(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc,
int row, int col, int height);
/**
Get the maximum possible size for a cell using this renderer, if
possible.
This function may be overridden in the derived class if it can return
the maximum size needed for displaying the cells rendered it without
iterating over all cells. The base class version simply returns
::wxDefaultSize, indicating that this is infeasible and that
GetBestSize() should be called for each cell individually.
Note that this method will only be used if
wxGridTableBase::CanMeasureColUsingSameAttr() is overridden to return
@true.
@since 3.1.4
*/
virtual wxSize GetMaxBestSize(wxGrid& grid,
wxGridCellAttr& attr,
wxDC& dc);
protected:
/**
Helper function setting the correct colours and font.
This function can be useful in the derived classes Draw()
implementation as it takes care of setting the appropriate colours and
font for @a dc depending on the global @a grid attributes, cell
attributions specified in @a attr and whether @a isSelected is @true.
Simply call it before doing any drawing in the derived class version to
use consistent colours and font for all cells.
@since 3.1.5
*/
void SetTextColoursAndFont(const wxGrid& grid,
const wxGridCellAttr& attr,
wxDC& dc,
bool isSelected);
/**
The destructor is private because only DecRef() can delete us.
*/
virtual ~wxGridCellRenderer();
};
/**
Smart pointer wrapping wxGridCellRenderer.
wxGridCellRendererPtr takes ownership of wxGridCellRenderer passed to it on
construction and calls DecRef() on it automatically when it is destroyed.
It also provides transparent access to wxGridCellRenderer methods by allowing
to use objects of this class as if they were wxGridCellRenderer pointers.
@since 3.1.4
@category{grid}
*/
typedef wxObjectDataPtr<wxGridCellRenderer> wxGridCellRendererPtr;
/**
@class wxGridCellAutoWrapStringRenderer
This class may be used to format string data in a cell. The too
long lines are wrapped to be shown entirely at word boundaries.
@library{wxcore}
@category{grid}
@see wxGridCellRenderer, wxGridCellBoolRenderer,
wxGridCellDateTimeRenderer, wxGridCellEnumRenderer,
wxGridCellFloatRenderer, wxGridCellNumberRenderer,
wxGridCellStringRenderer
*/
class wxGridCellAutoWrapStringRenderer : public wxGridCellStringRenderer
{
public:
/**
Default constructor.
*/
wxGridCellAutoWrapStringRenderer();
};
/**
@class wxGridCellBoolRenderer
This class may be used to format boolean data in a cell.
@library{wxcore}
@category{grid}
@see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer,
wxGridCellDateTimeRenderer, wxGridCellEnumRenderer,
wxGridCellFloatRenderer, wxGridCellNumberRenderer,
wxGridCellStringRenderer
*/
class wxGridCellBoolRenderer : public wxGridCellRenderer
{
public:
/**
Default constructor.
*/
wxGridCellBoolRenderer();
};
/**
@class wxGridCellDateRenderer
This class may be used to show a date, without time, in a cell.
See @ref wxGridCellDateTimeRenderer for a date/time version.
wxDateTime::Format() is used internally to render the date
representation. wxDateTime::ParseDate() is used to parse the string
data entered in the cell.
@library{wxcore}
@category{grid}
@see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer,
wxGridCellBoolRenderer, wxGridCellEnumRenderer,
wxGridCellFloatRenderer, wxGridCellNumberRenderer,
wxGridCellStringRenderer, wxGridCellDateTimeRenderer
@since 3.1.3
*/
class wxGridCellDateRenderer : public wxGridCellStringRenderer
{
public:
/**
Date renderer constructor.
@param outformat
strftime()-like format string used to render the output date.
By default (or if provided format string is empty) localized
date representation ("%x") is used.
*/
wxGridCellDateRenderer(const wxString& outformat = wxString());
/**
Sets the strftime()-like format string which will be used to render
the date.
@param params
strftime()-like format string used to render the date.
*/
virtual void SetParameters(const wxString& params);
};
/**
@class wxGridCellDateTimeRenderer
This class may be used to format a date/time data in a cell.
The class wxDateTime is used internally to display the local date/time
or to parse the string date entered in the cell thanks to the defined format.
@library{wxcore}
@category{grid}
@see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer,
wxGridCellBoolRenderer, wxGridCellEnumRenderer,
wxGridCellFloatRenderer, wxGridCellNumberRenderer,
wxGridCellStringRenderer, wxGridCellDateRenderer
*/
class wxGridCellDateTimeRenderer : public wxGridCellDateRenderer
{
public:
/**
Date/time renderer constructor.
@param outformat
strptime()-like format string used the parse the output date/time.
@param informat
strptime()-like format string used to parse the string entered in the cell.
*/
wxGridCellDateTimeRenderer(const wxString& outformat = wxDefaultDateTimeFormat,
const wxString& informat = wxDefaultDateTimeFormat);
};
/**
@class wxGridCellEnumRenderer
This class may be used to render in a cell a number as a textual
equivalent.
The corresponding text strings are specified as comma-separated items in
the string passed to this renderer ctor or SetParameters() method. For
example, if this string is @c "John,Fred,Bob" the cell will be rendered as
"John", "Fred" or "Bob" if its contents is 0, 1 or 2 respectively.
@library{wxcore}
@category{grid}
@see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer,
wxGridCellBoolRenderer, wxGridCellDateTimeRenderer,
wxGridCellFloatRenderer, wxGridCellNumberRenderer,
wxGridCellStringRenderer
*/
class wxGridCellEnumRenderer : public wxGridCellStringRenderer
{
public:
/**
Enum renderer ctor.
@param choices
Comma separated string parameters "item1[,item2[...,itemN]]".
*/
wxGridCellEnumRenderer( const wxString& choices = wxEmptyString );
/**
Sets the comma separated string content of the enum.
@param params
Comma separated string parameters "item1[,item2[...,itemN]]".
*/
virtual void SetParameters(const wxString& params);
};
/**
Specifier used to format the data to string for the numbers handled by
wxGridCellFloatRenderer and wxGridCellFloatEditor.
@since 2.9.3
*/
enum wxGridCellFloatFormat
{
/// Decimal floating point (%f).
wxGRID_FLOAT_FORMAT_FIXED = 0x0010,
/// Scientific notation (mantissa/exponent) using e character (%e).
wxGRID_FLOAT_FORMAT_SCIENTIFIC = 0x0020,
/// Use the shorter of %e or %f (%g).
wxGRID_FLOAT_FORMAT_COMPACT = 0x0040,
/// To use in combination with one of the above formats for the upper
/// case version (%F/%E/%G)
wxGRID_FLOAT_FORMAT_UPPER = 0x0080,
/// The format used by default (wxGRID_FLOAT_FORMAT_FIXED).
wxGRID_FLOAT_FORMAT_DEFAULT = wxGRID_FLOAT_FORMAT_FIXED
};
/**
@class wxGridCellFloatRenderer
This class may be used to format floating point data in a cell.
@library{wxcore}
@category{grid}
@see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer,
wxGridCellBoolRenderer, wxGridCellDateTimeRenderer,
wxGridCellEnumRenderer, wxGridCellNumberRenderer,
wxGridCellStringRenderer
*/
class wxGridCellFloatRenderer : public wxGridCellStringRenderer
{
public:
/**
Float cell renderer ctor.
@param width
Minimum number of characters to be shown.
@param precision
Number of digits after the decimal dot.
@param format
The format used to display the string, must be a combination of
::wxGridCellFloatFormat enum elements. This parameter is only
available since wxWidgets 2.9.3.
*/
wxGridCellFloatRenderer(int width = -1, int precision = -1,
int format = wxGRID_FLOAT_FORMAT_DEFAULT);
/**
Returns the specifier used to format the data to string.
The returned value is a combination of ::wxGridCellFloatFormat elements.
@since 2.9.3
*/
int GetFormat() const;
/**
Returns the precision.
*/
int GetPrecision() const;
/**
Returns the width.
*/
int GetWidth() const;
/**
Set the format to use for display the number.
@param format
Must be a combination of ::wxGridCellFloatFormat enum elements.
@since 2.9.3
*/
void SetFormat(int format);
/**
The parameters string format is "width[,precision[,format]]" where
@c format should be chosen between f|e|g|E|G (f is used by default)
*/
virtual void SetParameters(const wxString& params);
/**
Sets the precision.
*/
void SetPrecision(int precision);
/**
Sets the width.
*/
void SetWidth(int width);
};
/**
@class wxGridCellNumberRenderer
This class may be used to format integer data in a cell.
@library{wxcore}
@category{grid}
@see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer,
wxGridCellBoolRenderer, wxGridCellDateTimeRenderer,
wxGridCellEnumRenderer, wxGridCellFloatRenderer,
wxGridCellStringRenderer
*/
class wxGridCellNumberRenderer : public wxGridCellStringRenderer
{
public:
/**
Default constructor.
*/
wxGridCellNumberRenderer();
};
/**
@class wxGridCellStringRenderer
This class may be used to format string data in a cell; it is the default
for string cells.
@library{wxcore}
@category{grid}
@see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer,
wxGridCellBoolRenderer, wxGridCellDateTimeRenderer,
wxGridCellEnumRenderer, wxGridCellFloatRenderer,
wxGridCellNumberRenderer
*/
class wxGridCellStringRenderer : public wxGridCellRenderer
{
public:
/**
Default constructor.
*/
wxGridCellStringRenderer();
};
/**
Represents a source of cell activation, which may be either a user event
(mouse or keyboard) or the program itself.
An object of this class is passed to wxGridCellEditor::TryActivate() by the
library and the code overriding this method may use its GetOrigin() method
to determine how exactly the cell is being activated.
@since 3.1.4
*/
class wxGridActivationSource
{
public:
/// Result of GetOrigin().
enum Origin
{
/// Activated due to an explicit wxGrid::EnableCellEditControl() call.
Program,
/// Activated due to the user pressing a key, see GetKeyEvent().
Key,
/// Activated due to the user clicking on a cell, see GetMouseEvent().
Mouse
};
/// Get the origin of the activation.
Origin GetOrigin() const;
/**
Get the key event corresponding to the key press activating the cell.
This method can be called for objects with Key origin only, use
GetOrigin() to check for this first.
*/
const wxKeyEvent& GetKeyEvent() const;
/**
Get the mouse event corresponding to the click activating the cell.
This method can be called for objects with Mouse origin only, use
GetOrigin() to check for this first.
*/
const wxMouseEvent& GetMouseEvent() const;
};
/**
Represents the result of wxGridCellEditor::TryActivate().
Editors overriding wxGridCellEditor::TryActivate() must use one of
DoNothing(), DoChange() or DoEdit() methods to return an object of this
type corresponding to the desired action.
@since 3.1.4
*/
class wxGridActivationResult
{
public:
/**
Indicate that nothing should be done and the cell shouldn't be edited
at all.
Note that this is different from DoEdit() and may be useful when the
value of the cell wouldn't change if it were activated anyhow, e.g.
because the key or mouse event carried by wxGridActivationSource would
leave the cell value unchanged.
*/
static wxGridActivationResult DoNothing();
/**
Indicate that activating the cell is possible and would change its
value to the given one.
This is the method to call for activatable editors, using it will
result in changing the value of the cell to @a newval without showing
the editor control at all.
Note that the change may still be vetoed by wxEVT_GRID_CELL_CHANGING
handler.
*/
static wxGridActivationResult DoChange(const wxString& newval);
/**
Indicate that the editor control should be shown and the cell should be
edited normally.
This is the default return value of wxGridCellEditor::TryActivate().
*/
static wxGridActivationResult DoEdit();
};
/**
@class wxGridCellEditor
This class is responsible for providing and manipulating the in-place edit
controls for the grid. Instances of wxGridCellEditor (actually, instances
of derived classes since it is an abstract class) can be associated with
the cell attributes for individual cells, rows, columns, or even for the
entire grid.
Normally wxGridCellEditor shows some UI control allowing the user to edit
the cell, but starting with wxWidgets 3.1.4 it's also possible to define
"activatable" cell editors, that change the value of the cell directly when
it's activated (typically by pressing Space key or clicking on it), see
TryActivate() method. Note that when implementing an editor which is always
activatable, i.e. never shows any in-place editor, it is more convenient to
derive its class from wxGridCellActivatableEditor than from wxGridCellEditor
itself.
@library{wxcore}
@category{grid}
@see wxGridCellAutoWrapStringEditor, wxGridCellBoolEditor,
wxGridCellChoiceEditor, wxGridCellEnumEditor,
wxGridCellFloatEditor, wxGridCellNumberEditor,
wxGridCellTextEditor, wxGridCellDateEditor
*/
class wxGridCellEditor : public wxSharedClientDataContainer, public wxRefCounter
{
public:
/**
Default constructor.
*/
wxGridCellEditor();
/**
Fetch the value from the table and prepare the edit control to begin
editing.
This function should save the original value of the grid cell at the
given @a row and @a col and show the control allowing the user to
change it.
@see EndEdit()
*/
virtual void BeginEdit(int row, int col, wxGrid* grid) = 0;
/**
Create a new object which is the copy of this one.
*/
virtual wxGridCellEditor* Clone() const = 0;
/**
Creates the actual edit control.
*/
virtual void Create(wxWindow* parent, wxWindowID id,
wxEvtHandler* evtHandler) = 0;
/**
Final cleanup.
*/
virtual void Destroy();
/**
End editing the cell.
This function must check if the current value of the editing control is
valid and different from the original value (available as @a oldval in
its string form and possibly saved internally using its real type by
BeginEdit()). If it isn't, it just returns @false, otherwise it must do
the following:
- Save the new value internally so that ApplyEdit() could apply it.
- Fill @a newval (which is never @NULL) with the string
representation of the new value.
- Return @true
Notice that it must @em not modify the grid as the change could still
be vetoed.
If the user-defined wxEVT_GRID_CELL_CHANGING event handler doesn't veto
this change, ApplyEdit() will be called next.
*/
virtual bool EndEdit(int row, int col, const wxGrid* grid,
const wxString& oldval, wxString* newval) = 0;
/**
Effectively save the changes in the grid.
This function should save the value of the control in the grid. It is
called only after EndEdit() returns @true.
*/
virtual void ApplyEdit(int row, int col, wxGrid* grid) = 0;
/**
Some types of controls on some platforms may need some help with the
Return key.
*/
virtual void HandleReturn(wxKeyEvent& event);
/**
Returns @true if the edit control has been created.
*/
bool IsCreated();
/**
Draws the part of the cell not occupied by the control: the base class
version just fills it with background colour from the attribute.
*/
virtual void PaintBackground(wxDC& dc, const wxRect& rectCell, const wxGridCellAttr& attr);
/**
Reset the value in the control back to its starting value.
*/
virtual void Reset() = 0;
/**
Size and position the edit control.
*/
virtual void SetSize(const wxRect& rect);
/**
Show or hide the edit control, use the specified attributes to set
colours/fonts for it.
*/
virtual void Show(bool show, wxGridCellAttr* attr = NULL);
/**
If the editor is enabled by clicking on the cell, this method will be
called.
*/
virtual void StartingClick();
/**
If the editor is enabled by pressing keys on the grid, this will be
called to let the editor do something about that first key if desired.
*/
virtual void StartingKey(wxKeyEvent& event);
/**
Return @true to allow the given key to start editing: the base class
version only checks that the event has no modifiers.
If the key is F2 (special), editing will always start and this
method will not be called at all (but StartingKey() will)
*/
virtual bool IsAcceptedKey(wxKeyEvent& event);
/**
Returns the value currently in the editor control.
*/
virtual wxString GetValue() const = 0;
/**
Get the edit window used by this editor.
@since 3.1.3
*/
wxWindow* GetWindow() const;
/**
Set the wxWindow that will be used by this cell editor for editing the
value.
@since 3.1.3
*/
void SetWindow(wxWindow* window);
/**
Get the wxControl used by this editor.
This function is preserved for compatibility, but GetWindow() should be
preferred in the new code as the associated window doesn't need to be of
a wxControl-derived class.
Note that if SetWindow() had been called with an object not deriving
from wxControl, this method will return @NULL.
*/
wxControl* GetControl();
/**
Set the wxControl that will be used by this cell editor for editing the
value.
This function is preserved for compatibility, but SetWindow() should be
preferred in the new code, see GetControl().
*/
void SetControl(wxControl* control);
/**
Function allowing to create an "activatable" editor.
As explained in this class description, activatable editors don't show
any edit control but change the cell value directly, when it is
activated (by any way described by wxGridActivationSource).
To create such editor, this method must be overridden to return
wxGridActivationResult::DoChange() passing it the new value of the
cell. If the change is not vetoed by wxEVT_GRID_CELL_CHANGING handler,
DoActivate() will be called to actually change the value, so it must be
overridden as well if TryActivate() is overridden.
By default, wxGridActivationResult::DoEdit() is returned, meaning that
this is a normal editor, using an edit control for changing the cell
value.
@since 3.1.4
*/
virtual wxGridActivationResult
TryActivate(int row, int col, wxGrid* grid,
const wxGridActivationSource& actSource);
/**
Function which must be overridden for "activatable" editors.
If TryActivate() is overridden to return "change" action, this function
will be called to actually apply this change. Note that it is not
passed the value to apply, as it is assumed that the editor class
stores this value as a member variable anyhow.
@since 3.1.4
*/
virtual void DoActivate(int row, int col, wxGrid* grid);
protected:
/**
The destructor is private because only DecRef() can delete us.
*/
virtual ~wxGridCellEditor();
};
/**
Base class for activatable editors.
Inheriting from this class makes it simpler to implement editors that
support only activation, but not in-place editing, as they only need to
implement TryActivate(), DoActivate() and Clone() methods, but not all the
other pure virtual methods of wxGridCellEditor.
@since 3.1.4
*/
class wxGridCellActivatableEditor : public wxGridCellEditor
{
public:
/**
Same method as in wxGridCellEditor, but pure virtual.
Note that the implementation of this method must never return
wxGridActivationResult::DoEdit() for the editors inheriting from this
class, as it doesn't support normal editing.
*/
virtual wxGridActivationResult
TryActivate(int row, int col, wxGrid* grid,
const wxGridActivationSource& actSource) = 0;
/// Same method as in wxGridCellEditor, but pure virtual.
virtual void DoActivate(int row, int col, wxGrid* grid) = 0;
};
/**
Smart pointer wrapping wxGridCellEditor.
wxGridCellEditorPtr takes ownership of wxGridCellEditor passed to it on
construction and calls DecRef() on it automatically when it is destroyed.
It also provides transparent access to wxGridCellEditor methods by allowing
to use objects of this class as if they were wxGridCellEditor pointers.
@since 3.1.4
@category{grid}
*/
typedef wxObjectDataPtr<wxGridCellEditor> wxGridCellEditorPtr;
/**
@class wxGridCellAutoWrapStringEditor
Grid cell editor for wrappable string/text data.
@library{wxcore}
@category{grid}
@see wxGridCellEditor, wxGridCellBoolEditor, wxGridCellChoiceEditor,
wxGridCellEnumEditor, wxGridCellFloatEditor,
wxGridCellNumberEditor, wxGridCellTextEditor,
wxGridCellDateEditor
*/
class wxGridCellAutoWrapStringEditor : public wxGridCellTextEditor
{
public:
wxGridCellAutoWrapStringEditor();
};
/**
@class wxGridCellBoolEditor
Grid cell editor for boolean data.
@library{wxcore}
@category{grid}
@see wxGridCellEditor, wxGridCellAutoWrapStringEditor,
wxGridCellChoiceEditor, wxGridCellEnumEditor,
wxGridCellFloatEditor, wxGridCellNumberEditor,
wxGridCellTextEditor, wxGridCellDateEditor
*/
class wxGridCellBoolEditor : public wxGridCellEditor
{
public:
/**
Default constructor.
*/
wxGridCellBoolEditor();
/**
Returns @true if the given @a value is equal to the string
representation of the truth value we currently use (see
UseStringValues()).
*/
static bool IsTrueValue(const wxString& value);
/**
This method allows you to customize the values returned by GetValue()
for the cell using this editor. By default, the default values of the
arguments are used, i.e. @c "1" is returned if the cell is checked and
an empty string otherwise.
*/
static void UseStringValues(const wxString& valueTrue = "1",
const wxString& valueFalse = wxEmptyString);
};
/**
@class wxGridCellChoiceEditor
Grid cell editor for string data providing the user a choice from a list of
strings.
@library{wxcore}
@category{grid}
@see wxGridCellEditor, wxGridCellAutoWrapStringEditor,
wxGridCellBoolEditor, wxGridCellEnumEditor,
wxGridCellFloatEditor, wxGridCellNumberEditor,
wxGridCellTextEditor, wxGridCellDateEditor
*/
class wxGridCellChoiceEditor : public wxGridCellEditor
{
public:
/**
Choice cell renderer ctor.
@param count
Number of strings from which the user can choose.
@param choices
An array of strings from which the user can choose.
@param allowOthers
If allowOthers is @true, the user can type a string not in choices
array.
*/
wxGridCellChoiceEditor(size_t count = 0,
const wxString choices[] = NULL,
bool allowOthers = false);
/**
Choice cell renderer ctor.
@param choices
An array of strings from which the user can choose.
@param allowOthers
If allowOthers is @true, the user can type a string not in choices
array.
*/
wxGridCellChoiceEditor(const wxArrayString& choices,
bool allowOthers = false);
/**
Parameters string format is "item1[,item2[...,itemN]]".
This method can be called before the editor is used for the first time,
or later, in which case it replaces the previously specified strings
with the new ones.
*/
virtual void SetParameters(const wxString& params);
};
/**
@class wxGridCellEnumEditor
Grid cell editor which displays an enum number as a textual equivalent
(e.g. data in cell is 0,1,2 ... n the cell could be displayed as
"John","Fred"..."Bob" in the combo choice box).
@library{wxcore}
@category{grid}
@see wxGridCellEditor, wxGridCellAutoWrapStringEditor,
wxGridCellBoolEditor, wxGridCellChoiceEditor,
wxGridCellTextEditor, wxGridCellFloatEditor,
wxGridCellNumberEditor, wxGridCellDateEditor
*/
class wxGridCellEnumEditor : public wxGridCellChoiceEditor
{
public:
/**
Enum cell editor ctor.
@param choices
Comma separated choice parameters "item1[,item2[...,itemN]]".
*/
wxGridCellEnumEditor( const wxString& choices = wxEmptyString );
};
/**
@class wxGridCellTextEditor
Grid cell editor for string/text data.
@library{wxcore}
@category{grid}
@see wxGridCellEditor, wxGridCellAutoWrapStringEditor,
wxGridCellBoolEditor, wxGridCellChoiceEditor,
wxGridCellEnumEditor, wxGridCellFloatEditor,
wxGridCellNumberEditor, wxGridCellDateEditor
*/
class wxGridCellTextEditor : public wxGridCellEditor
{
public:
/**
Text cell editor constructor.
@param maxChars
Maximum width of text (this parameter is supported starting since
wxWidgets 2.9.5).
*/
explicit wxGridCellTextEditor(size_t maxChars = 0);
/**
The parameters string format is "n" where n is a number representing
the maximum width.
*/
virtual void SetParameters(const wxString& params);
/**
Set validator to validate user input.
@since 2.9.5
*/
virtual void SetValidator(const wxValidator& validator);
};
/**
@class wxGridCellFloatEditor
The editor for floating point numbers data.
@library{wxcore}
@category{grid}
@see wxGridCellEditor, wxGridCellAutoWrapStringEditor,
wxGridCellBoolEditor, wxGridCellChoiceEditor,
wxGridCellEnumEditor, wxGridCellNumberEditor,
wxGridCellTextEditor, wxGridCellDateEditor
*/
class wxGridCellFloatEditor : public wxGridCellTextEditor
{
public:
/**
Float cell editor ctor.
@param width
Minimum number of characters to be shown.
@param precision
Number of digits after the decimal dot.
@param format
The format to use for displaying the number, a combination of
::wxGridCellFloatFormat enum elements. This parameter is only
available since wxWidgets 2.9.3.
*/
wxGridCellFloatEditor(int width = -1, int precision = -1,
int format = wxGRID_FLOAT_FORMAT_DEFAULT);
/**
The parameters string format is "width[,precision[,format]]" where
@c format should be chosen between f|e|g|E|G (f is used by default)
*/
virtual void SetParameters(const wxString& params);
};
/**
@class wxGridCellNumberEditor
Grid cell editor for numeric integer data.
@library{wxcore}
@category{grid}
@see wxGridCellEditor, wxGridCellAutoWrapStringEditor,
wxGridCellBoolEditor, wxGridCellChoiceEditor,
wxGridCellEnumEditor, wxGridCellFloatEditor,
wxGridCellTextEditor, wxGridCellDateEditor
*/
class wxGridCellNumberEditor : public wxGridCellTextEditor
{
public:
/**
Allows you to specify the range for acceptable data. Values equal to
-1 for both @a min and @a max indicate that no range checking should be
done.
*/
wxGridCellNumberEditor(int min = -1, int max = -1);
/**
Parameters string format is "min,max".
*/
virtual void SetParameters(const wxString& params);
protected:
/**
If the return value is @true, the editor uses a wxSpinCtrl to get user
input, otherwise it uses a wxTextCtrl.
*/
bool HasRange() const;
/**
String representation of the value.
*/
wxString GetString() const;
};
/**
@class wxGridCellDateEditor
Grid cell editor for dates.
Uses @ref wxDatePickerCtrl as actual edit control.
@library{wxcore}
@category{grid}
@see wxGridCellEditor, wxGridCellAutoWrapStringEditor,
wxGridCellBoolEditor, wxGridCellChoiceEditor,
wxGridCellEnumEditor, wxGridCellFloatEditor,
wxGridCellTextEditor
@since 3.1.3
*/
class wxGridCellDateEditor : public wxGridCellEditor
{
public:
/**
Date editor constructor.
@param format Optional format for the date displayed in the associated
cell. By default, the locale-specific date format ("%x") is assumed.
You would typically want to specify the same format as the one
used with the cell renderer, if a non-default one is used.
Note that this parameter is only available since wxWidgets 3.1.5.
*/
explicit wxGridCellDateEditor(const wxString& format = wxString());
};
/**
@class wxGridFitMode
Allows to specify the behaviour when the cell contents doesn't fit into its
allotted space.
Objects of this class are used with wxGridCellAttr::SetFitMode() and
wxGrid::SetDefaultCellFitMode() and wxGrid::SetCellFitMode() functions and
allow to specify what should happen if the cell contents doesn't fit into
the available space. The possibilities are:
- Overflow into the cell to the right if it is empty, or possibly several
cells, if the cell contents still doesn't fit after overflowing into the
immediately neighbouring cell.
- Clip the cell contents, discarding the part which doesn't fit.
- Ellipsize the cell contents, i.e. replace the non-fitting part with
ellipsis (@c ...), putting the ellipsis at the end by default, but possibly
at the beginning or in the middle.
The default behaviour is to overflow, use wxGrid::SetDefaultCellFitMode()
to change this, for example:
@code
grid->SetDefaultCellFitMode(wxGridFitMode::Clip());
@endcode
Objects of this class are created using static functions instead of
constructors for better readability and can't be changed after creating
them except by using the assignment operator.
@library{wxcore}
@category{grid}
@since 3.1.4
*/
class wxGridFitMode
{
public:
/**
Default constructor creates an object not specifying any behaviour.
This constructor is not very useful, use static methods Clip() and
Overflow() below to create objects of this class instead.
*/
wxGridFitMode();
/**
Pseudo-constructor for object specifying clipping behaviour.
*/
static wxGridFitMode Clip();
/**
Pseudo-constructor for object specifying overflow behaviour.
*/
static wxGridFitMode Overflow();
/**
Pseudo-constructor for object specifying ellipsize behaviour.
*/
static wxGridFitMode Ellipsize(wxEllipsizeMode ellipsize = wxELLIPSIZE_END);
/**
Return true if the object specifies some particular behaviour.
This method returns @false for default-constructed objects of this
type only.
*/
bool IsSpecified() const;
/**
Return true if the object specifies clipping behaviour.
This method returns @true only for the objects returned by Clip().
*/
bool IsClip() const;
/**
Return true if the object specifies overflow behaviour.
This method returns @true only for the objects returned by Overflow().
*/
bool IsOverflow() const;
/**
Return ellipsize mode, possibly @c wxELLIPSIZE_NONE.
For the objects constructed using Ellipsize(), the same ellipsization
mode as was passed to it is returned. For all the other objects,
::wxELLIPSIZE_NONE is.
*/
wxEllipsizeMode GetEllipsizeMode() const;
};
/**
@class wxGridCellAttr
This class can be used to alter the cells' appearance in the grid by
changing their attributes from the defaults. An object of this class may be
returned by wxGridTableBase::GetAttr().
Note that objects of this class are reference-counted and it's recommended
to use wxGridCellAttrPtr smart pointer class when working with them to
avoid memory leaks.
@library{wxcore}
@category{grid}
*/
class wxGridCellAttr : public wxSharedClientDataContainer, public wxRefCounter
{
public:
/**
Kind of the attribute to retrieve.
@see wxGridCellAttrProvider::GetAttr(), wxGridTableBase::GetAttr()
*/
enum wxAttrKind
{
/// Return the combined effective attribute for the cell.
Any,
/// Return the attribute explicitly set for this cell.
Cell,
/// Return the attribute set for this cells row.
Row,
/// Return the attribute set for this cells column.
Col,
Default,
Merged
};
/**
Default constructor.
*/
explicit wxGridCellAttr(wxGridCellAttr* attrDefault = NULL);
/**
Constructor specifying some of the often used attributes.
*/
wxGridCellAttr(const wxColour& colText, const wxColour& colBack,
const wxFont& font, int hAlign, int vAlign);
/**
Creates a new copy of this object.
*/
wxGridCellAttr* Clone() const;
/**
This class is reference counted: it is created with ref count of 1, so
calling DecRef() once will delete it. Calling IncRef() allows locking
it until the matching DecRef() is called.
*/
void DecRef();
/**
Get the alignment to use for the cell with the given attribute.
If this attribute doesn't specify any alignment, the default attribute
alignment is used (which can be changed using
wxGrid::SetDefaultCellAlignment() but is left and top by default).
Notice that @a hAlign and @a vAlign values are always overwritten by
this function, use GetNonDefaultAlignment() if this is not desirable.
@param hAlign
Horizontal alignment is returned here if this argument is non-@NULL.
It is one of wxALIGN_LEFT, wxALIGN_CENTRE or wxALIGN_RIGHT.
@param vAlign
Vertical alignment is returned here if this argument is non-@NULL.
It is one of wxALIGN_TOP, wxALIGN_CENTRE or wxALIGN_BOTTOM.
*/
void GetAlignment(int* hAlign, int* vAlign) const;
/**
Returns the background colour.
*/
const wxColour& GetBackgroundColour() const;
/**
Returns the cell editor.
The caller is responsible for calling DecRef() on the returned pointer,
use GetEditorPtr() to do it automatically.
*/
wxGridCellEditor* GetEditor(const wxGrid* grid, int row, int col) const;
/**
Returns the cell editor.
This method is identical to GetEditor(), but returns a smart pointer,
which frees the caller from the need to call DecRef() manually.
@since 3.1.4
*/
wxGridCellEditorPtr GetEditorPtr(const wxGrid* grid, int row, int col) const;
/**
Returns the font.
*/
const wxFont& GetFont() const;
/**
Get the alignment defined by this attribute.
Unlike GetAlignment() this function only modifies @a hAlign and @a
vAlign if this attribute does define a non-default alignment. This
means that they must be initialized before calling this function and
that their values will be preserved unchanged if they are different
from wxALIGN_INVALID.
For example, the following fragment can be used to use the cell
alignment if one is defined but right-align its contents by default
(instead of left-aligning it by default) while still using the default
vertical alignment:
@code
int hAlign = wxALIGN_RIGHT,
vAlign = wxALIGN_INVALID;
attr.GetNonDefaultAlignment(&hAlign, &vAlign);
@endcode
@since 2.9.1
*/
void GetNonDefaultAlignment(int *hAlign, int *vAlign) const;
/**
Returns the cell renderer.
The caller is responsible for calling DecRef() on the returned pointer,
use GetRendererPtr() to do it automatically.
*/
wxGridCellRenderer* GetRenderer(const wxGrid* grid, int row, int col) const;
/**
Returns the cell editor.
This method is identical to GetRenderer(), but returns a smart pointer,
which frees the caller from the need to call DecRef() manually.
@since 3.1.4
*/
wxGridCellRendererPtr GetRendererPtr(const wxGrid* grid, int row, int col) const;
/**
Returns the text colour.
*/
const wxColour& GetTextColour() const;
/**
Returns @true if this attribute has a valid alignment set.
*/
bool HasAlignment() const;
/**
Returns @true if this attribute has a valid background colour set.
*/
bool HasBackgroundColour() const;
/**
Returns @true if this attribute has a valid cell editor set.
*/
bool HasEditor() const;
/**
Returns @true if this attribute has a valid font set.
*/
bool HasFont() const;
/**
Returns @true if this attribute has a valid cell renderer set.
*/
bool HasRenderer() const;
/**
Returns @true if this attribute has a valid text colour set.
*/
bool HasTextColour() const;
/**
This class is reference counted: it is created with ref count of 1, so
calling DecRef() once will delete it. Calling IncRef() allows locking
it until the matching DecRef() is called.
*/
void IncRef();
/**
Returns @true if this cell is set as read-only.
*/
bool IsReadOnly() const;
/**
Sets the alignment. @a hAlign can be one of @c wxALIGN_LEFT,
@c wxALIGN_CENTRE or @c wxALIGN_RIGHT and @a vAlign can be one of
@c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM.
*/
void SetAlignment(int hAlign, int vAlign);
/**
Sets the background colour.
*/
void SetBackgroundColour(const wxColour& colBack);
/**
@todo Needs documentation.
*/
void SetDefAttr(wxGridCellAttr* defAttr);
/**
Sets the editor to be used with the cells with this attribute.
*/
void SetEditor(wxGridCellEditor* editor);
/**
Sets the font.
*/
void SetFont(const wxFont& font);
/**
Sets the cell as read-only.
*/
void SetReadOnly(bool isReadOnly = true);
/**
Sets the renderer to be used for cells with this attribute. Takes
ownership of the pointer.
*/
void SetRenderer(wxGridCellRenderer* renderer);
/**
Sets the text colour.
*/
void SetTextColour(const wxColour& colText);
void MergeWith(wxGridCellAttr *mergefrom);
void SetSize(int num_rows, int num_cols);
/**
Specifies the behaviour of the cell contents if it doesn't fit into the
available space.
@see wxGridFitMode
@since 3.1.4
*/
void SetFitMode(wxGridFitMode fitMode);
/**
Specifies if cells using this attribute should overflow or clip their
contents.
This is the same as calling SetFitMode() with either
wxGridFitMode::Overflow() or wxGridFitMode::Clip() argument depending
on whether @a allow is @true or @false.
Prefer using SetFitMode() directly instead in the new code.
*/
void SetOverflow(bool allow = true);
void SetKind(wxAttrKind kind);
bool HasReadWriteMode() const;
bool HasOverflowMode() const;
bool HasSize() const;
void GetSize(int *num_rows, int *num_cols) const;
/**
Returns the fitting mode for the cells using this attribute.
The returned wxGridFitMode is always specified, i.e.
wxGridFitMode::IsSpecified() always returns @true. The default value,
if SetFitMode() hadn't been called before, is "overflow".
@since 3.1.4
*/
wxGridFitMode GetFitMode() const;
/**
Returns true if the cells using this attribute overflow into the
neighbouring cells.
Prefer using GetFitMode() in the new code.
*/
bool GetOverflow() const;
/**
Returns @true if the cell will draw an overflowed text into the
neighbouring cells.
Note that only left aligned cells currently can overflow. It means that
GetFitMode().IsOverflow() should returns true and GetAlignment should
returns wxALIGN_LEFT for hAlign parameter.
@since 3.1.4
*/
bool CanOverflow() const;
wxAttrKind GetKind();
protected:
/**
The destructor is private because only DecRef() can delete us.
*/
virtual ~wxGridCellAttr();
};
/**
Smart pointer wrapping wxGridCellAttr.
wxGridCellAttrPtr takes ownership of wxGridCellAttr passed to it on
construction and calls DecRef() on it automatically when it is destroyed.
It also provides transparent access to wxGridCellAttr methods by allowing
to use objects of this class as if they were wxGridCellAttr pointers.
@since 3.1.4
@category{grid}
*/
typedef wxObjectDataPtr<wxGridCellAttr> wxGridCellAttrPtr;
/**
Base class for header cells renderers.
A cell renderer can be used to draw the text of a cell's label, and/or
the border around it.
@since 2.9.1
*/
class wxGridHeaderLabelsRenderer
{
public:
/**
Called by the grid to draw the border around the cell header.
This method is responsible for drawing the border inside the given @a
rect and adjusting the rectangle size to correspond to the area inside
the border, i.e. usually call wxRect::Deflate() to account for the
border width.
@param grid
The grid whose header cell window is being drawn.
@param dc
The device context to use for drawing.
@param rect
Input/output parameter which contains the border rectangle on input
and should be updated to contain the area inside the border on
function return.
*/
virtual void DrawBorder(const wxGrid& grid,
wxDC& dc,
wxRect& rect) const = 0;
/**
Called by the grid to draw the specified label.
Notice that the DrawBorder() method is called before this one.
The default implementation uses wxGrid::GetLabelTextColour() and
wxGrid::GetLabelFont() to draw the label.
*/
virtual void DrawLabel(const wxGrid& grid,
wxDC& dc,
const wxString& value,
const wxRect& rect,
int horizAlign,
int vertAlign,
int textOrientation) const;
};
/**
Base class for row headers renderer.
This is the same as wxGridHeaderLabelsRenderer currently but we still use a
separate class for it to distinguish it from wxGridColumnHeaderRenderer
and wxGridCornerHeaderRenderer.
@see wxGridRowHeaderRendererDefault
@see wxGridCellAttrProvider::GetRowHeaderRenderer()
@since 2.9.1
*/
class wxGridRowHeaderRenderer : public wxGridHeaderLabelsRenderer
{
};
/**
Base class for column headers renderer.
This is the same as wxGridHeaderLabelsRenderer currently but we still use a
separate class for it to distinguish it from wxGridRowHeaderRenderer and
wxGridCornerHeaderRenderer.
@see wxGridColumnHeaderRendererDefault
@see wxGridCellAttrProvider::GetColumnHeaderRenderer()
@since 2.9.1
*/
class wxGridColumnHeaderRenderer : public wxGridHeaderLabelsRenderer
{
};
/**
Base class for corner header renderer.
This is the same as wxGridHeaderLabelsRenderer currently but we still use a
separate class for it to distinguish it from wxGridRowHeaderRenderer and
wxGridColumnHeaderRenderer.
@see wxGridCornerHeaderRendererDefault
@see wxGridCellAttrProvider::GetCornerRenderer()
@since 2.9.1
*/
class wxGridCornerHeaderRenderer : public wxGridHeaderLabelsRenderer
{
};
/**
Default row header renderer.
You may derive from this class if you need to only override one of its
methods (i.e. either DrawLabel() or DrawBorder()) but continue to use the
default implementation for the other one.
@see wxGridColumnHeaderRendererDefault, wxGridCornerHeaderRendererDefault
@since 2.9.1
*/
class wxGridRowHeaderRendererDefault : public wxGridRowHeaderRenderer
{
public:
/// Implement border drawing for the row labels.
virtual void DrawBorder(const wxGrid& grid,
wxDC& dc,
wxRect& rect) const;
};
/**
Default column header renderer.
@see wxGridRowHeaderRendererDefault, wxGridCornerHeaderRendererDefault
@since 2.9.1
*/
class wxGridColumnHeaderRendererDefault : public wxGridColumnHeaderRenderer
{
public:
/// Implement border drawing for the column labels.
virtual void DrawBorder(const wxGrid& grid,
wxDC& dc,
wxRect& rect) const;
};
/**
Default corner window renderer.
@see wxGridColumnHeaderRendererDefault, wxGridRowHeaderRendererDefault
@since 2.9.1
*/
class wxGridCornerHeaderRendererDefault : public wxGridCornerHeaderRenderer
{
public:
/// Implement border drawing for the corner window.
virtual void DrawBorder(const wxGrid& grid,
wxDC& dc,
wxRect& rect) const;
};
/**
Class providing attributes to be used for the grid cells.
This class both defines an interface which grid cell attributes providers
should implement -- and which can be implemented differently in derived
classes -- and a default implementation of this interface which is often
good enough to be used without modification, especially with not very large
grids for which the efficiency of attributes storage hardly matters (see
the discussion below).
An object of this class can be associated with a wxGrid using
wxGridTableBase::SetAttrProvider() but it's not necessary to call it if you
intend to use the default provider as it is used by wxGridTableBase by
default anyhow.
Notice that while attributes provided by this class can be set for
individual cells using SetAttr() or the entire rows or columns using
SetRowAttr() and SetColAttr() they are always retrieved using GetAttr()
function.
The default implementation of this class stores the attributes passed to
its SetAttr(), SetRowAttr() and SetColAttr() in a straightforward way. A
derived class may use its knowledge about how the attributes are used in
your program to implement it much more efficiently: for example, using a
special background colour for all even-numbered rows can be implemented by
simply returning the same attribute from GetAttr() if the row number is
even instead of having to store N/2 row attributes where N is the total
number of rows in the grid.
Notice that objects of this class can't be copied.
*/
class wxGridCellAttrProvider : public wxClientDataContainer
{
public:
/// Trivial default constructor.
wxGridCellAttrProvider();
/// Destructor releases any attributes held by this class.
virtual ~wxGridCellAttrProvider();
/**
Get the attribute to use for the specified cell.
If wxGridCellAttr::Any is used as @a kind value, this function combines
the attributes set for this cell using SetAttr() and those for its row
or column (set with SetRowAttr() or SetColAttr() respectively), with
the cell attribute having the highest precedence.
Notice that the caller must call DecRef() on the returned pointer if it
is non-@NULL. GetAttrPtr() method can be used to do this automatically.
@param row
The row of the cell.
@param col
The column of the cell.
@param kind
The kind of the attribute to return.
@return
The attribute to use which should be DecRef()'d by caller or @NULL
if no attributes are defined for this cell.
*/
virtual wxGridCellAttr *GetAttr(int row, int col,
wxGridCellAttr::wxAttrKind kind) const;
/**
Get the attribute to use for the specified cell.
This method is identical to GetAttr(), but returns a smart pointer,
which frees the caller from the need to call DecRef() manually.
@since 3.1.4
*/
wxGridCellAttrPtr GetAttrPtr(int row, int col,
wxGridCellAttr::wxAttrKind kind) const;
/*!
@name Setting attributes.
All these functions take ownership of the attribute passed to them,
i.e. will call DecRef() on it themselves later and so it should not be
destroyed by the caller. The attribute can be @NULL to reset a
previously set value.
*/
///@{
/// Set attribute for the specified cell.
virtual void SetAttr(wxGridCellAttr *attr, int row, int col);
/// Set attribute for the specified row.
virtual void SetRowAttr(wxGridCellAttr *attr, int row);
/// Set attribute for the specified column.
virtual void SetColAttr(wxGridCellAttr *attr, int col);
///@}
/**
@name Getting header renderers.
These functions return the renderers for the given row or column header
label and the corner window. Unlike cell attributes, these objects are
not reference counted and are never @NULL so they are returned by
reference and not pointer and DecRef() shouldn't (and can't) be called
for them.
All these functions were added in wxWidgets 2.9.1.
*/
///@{
/**
Return the renderer used for drawing column headers.
By default wxGridColumnHeaderRendererDefault is returned.
@see wxGrid::SetUseNativeColLabels(), wxGrid::UseNativeColHeader()
@since 2.9.1
*/
virtual const wxGridColumnHeaderRenderer& GetColumnHeaderRenderer(int col);
/**
Return the renderer used for drawing row headers.
By default wxGridRowHeaderRendererDefault is returned.
@since 2.9.1
*/
virtual const wxGridRowHeaderRenderer& GetRowHeaderRenderer(int row);
/**
Return the renderer used for drawing the corner window.
By default wxGridCornerHeaderRendererDefault is returned.
@since 2.9.1
*/
virtual const wxGridCornerHeaderRenderer& GetCornerRenderer();
///@}
};
/**
Message class used by the grid table to send requests and notifications to
the grid view.
A message object of this class must be sent to the grid using
wxGrid::ProcessTableMessage() every time the table changes, e.g. rows are
added/deleted. The messages are just notifications and don't result in any
actual changes but just allow the view to react to changes to the model.
*/
class wxGridTableMessage
{
public:
/**
Default constructor initializes the object to invalid state.
*/
wxGridTableMessage();
/**
Constructor really initialize the message.
@param table Pointer to the grid table
@param id One of wxGridTableRequest enum elements.
@param comInt1 For the insert/delete messages, position after which the
rows or columns are inserted/deleted. For the append messages, the
number of rows or columns that were appended.
@param comInt2 For the insert/deleted messages, number of rows or
columns to be inserted/deleted. For the append messages, this
parameter is not used.
*/
wxGridTableMessage(wxGridTableBase *table, int id, int comInt1 = -1, int comInt2 = -1);
/**
Sets the table object
*/
void SetTableObject( wxGridTableBase *table );
/**
Gets the table object
*/
wxGridTableBase * GetTableObject() const;
/**
Sets an id
*/
void SetId( int id );
/**
Gets an id
*/
int GetId() const;
/**
Set the position after which the insertion/deletion occur
*/
void SetCommandInt( int comInt1 );
/**
Get the position after which the insertion/deletion occur
*/
int GetCommandInt() const;
/**
Set the number of rows to be inserted/deleted
*/
void SetCommandInt2( int comInt2 );
/**
Get the number of rows to be inserted/deleted
*/
int GetCommandInt2() const;
};
/**
Simplest type of data table for a grid for small tables of strings that are
stored in memory.
The number of rows and columns in the table can be specified initially but
may also be changed later dynamically.
*/
class wxGridStringTable : public wxGridTableBase
{
public:
/**
Default constructor creates an empty table.
*/
wxGridStringTable();
/**
Constructor taking number of rows and columns.
*/
wxGridStringTable( int numRows, int numCols );
virtual int GetNumberRows();
virtual int GetNumberCols();
virtual wxString GetValue( int row, int col );
virtual void SetValue( int row, int col, const wxString& s );
void Clear();
bool InsertRows( size_t pos = 0, size_t numRows = 1 );
bool AppendRows( size_t numRows = 1 );
bool DeleteRows( size_t pos = 0, size_t numRows = 1 );
bool InsertCols( size_t pos = 0, size_t numCols = 1 );
bool AppendCols( size_t numCols = 1 );
bool DeleteCols( size_t pos = 0, size_t numCols = 1 );
void SetRowLabelValue( int row, const wxString& );
void SetColLabelValue( int col, const wxString& );
void SetCornerLabelValue( const wxString& );
wxString GetRowLabelValue( int row );
wxString GetColLabelValue( int col );
wxString GetCornerLabelValue() const;
};
/**
Represents coordinates of a grid cell.
An object of this class is simply a (row, column) pair.
*/
class wxGridCellCoords
{
public:
/**
Default constructor initializes the object to invalid state.
Initially the row and column are both invalid (-1) and so operator!()
for an uninitialized wxGridCellCoords returns false.
*/
wxGridCellCoords();
/**
Constructor taking a row and a column.
*/
wxGridCellCoords(int row, int col);
/**
Return the row of the coordinate.
*/
int GetRow() const;
/**
Set the row of the coordinate.
*/
void SetRow(int n);
/**
Return the column of the coordinate.
*/
int GetCol() const;
/**
Set the column of the coordinate.
*/
void SetCol(int n);
/**
Set the row and column of the coordinate.
*/
void Set(int row, int col);
/**
Assignment operator for coordinate types.
*/
wxGridCellCoords& operator=(const wxGridCellCoords& other);
/**
Equality operator.
*/
bool operator==(const wxGridCellCoords& other) const;
/**
Inequality operator.
*/
bool operator!=(const wxGridCellCoords& other) const;
/**
Checks whether the coordinates are invalid.
Returns false only if both row and column are -1. Notice that if either
row or column (but not both) are -1, this method returns true even if
the object is invalid. This is done because objects in such state
should actually never exist, i.e. either both coordinates should be -1
or none of them should be -1.
*/
bool operator!() const;
};
/**
Represents coordinates of a block of cells in the grid.
An object of this class contains coordinates of the left top and the bottom right
corners of a block.
@since 3.1.4
*/
class wxGridBlockCoords
{
public:
/**
Default constructor initializes the object to invalid state.
Initially the coordinates are invalid (-1) and so operator!() for an
uninitialized wxGridBlockCoords returns @true.
*/
wxGridBlockCoords();
/**
Constructor taking a coordinates of the left top and the bottom right
corners.
*/
wxGridBlockCoords(int topRow, int leftCol, int bottomRow, int rightCol);
/**
Return the row of the left top corner.
*/
int GetTopRow() const;
/**
Set the row of the left top corner.
*/
void SetTopRow(int row);
/**
Return the column of the left top corner.
*/
int GetLeftCol() const;
/**
Set the column of the left top corner.
*/
void SetLeftCol(int col);
/**
Return the row of the bottom right corner.
*/
int GetBottomRow() const;
/**
Set the row of the bottom right corner.
*/
void SetBottomRow(int row);
/**
Return the column of the bottom right corner.
*/
int GetRightCol() const;
/**
Set the column of the bottom right corner.
*/
void SetRightCol(int col);
/**
Return the coordinates of the top left corner.
*/
wxGridCellCoords GetTopLeft() const
{
return wxGridCellCoords(m_topRow, m_leftCol);
}
/**
Return the coordinates of the bottom right corner.
*/
wxGridCellCoords GetBottomRight() const
{
return wxGridCellCoords(m_bottomRow, m_rightCol);
}
/**
Return the canonicalized block where top left coordinates is less
then bottom right coordinates.
*/
wxGridBlockCoords Canonicalize() const;
/**
Whether the blocks intersect.
@return
@true, if the block intersects with the other, @false, otherwise.
*/
bool Intersects(const wxGridBlockCoords& other) const
{
return m_topRow <= other.m_bottomRow && m_bottomRow >= other.m_topRow &&
m_leftCol <= other.m_rightCol && m_rightCol >= other.m_leftCol;
}
/**
Check whether this block contains the given cell.
@return
@true, if the block contains the cell, @false otherwise.
*/
bool Contains(const wxGridCellCoords& cell) const;
/**
Check whether this block contains another one.
@return
@true if @a other is entirely contained within this block.
*/
bool Contains(const wxGridBlockCoords& other) const;
/**
Calculates the result blocks by subtracting the other block from this
block.
@param other
The block to subtract from this block.
@param splitOrientation
The block splitting orientation (either @c wxHORIZONTAL or
@c wxVERTICAL).
@return
Up to 4 blocks. If block doesn't exist in the result, it has value
of @c wxGridNoBlockCoords.
*/
wxGridBlockDiffResult
Difference(const wxGridBlockCoords& other, int splitOrientation) const;
/**
Calculates the symmetric difference of the blocks.
@param other
The block to subtract from this block.
@return
Up to 4 blocks. If block doesn't exist in the result, it has value
of @c wxGridNoBlockCoords.
*/
wxGridBlockDiffResult
SymDifference(const wxGridBlockCoords& other) const;
/**
Equality operator.
*/
bool operator==(const wxGridBlockCoords& other) const;
/**
Inequality operator.
*/
bool operator!=(const wxGridBlockCoords& other) const;
/**
Checks whether the cells block is invalid.
Returns @true only if all components are -1. Notice that if one
of the components (but not all) is -1, this method returns @false even
if the object is invalid. This is done because objects in such state
should actually never exist, i.e. either all components should be -1
or none of them should be -1.
*/
bool operator!() const;
private:
int m_topRow;
int m_leftCol;
int m_bottomRow;
int m_rightCol;
};
/**
@class wxGridBlockDiffResult
The helper struct uses as a result type for difference functions of
@c wxGridBlockCoords class.
Parts can be uninitialized (equals to @c wxGridNoBlockCoords), that means
that the corresponding part doesn't exists in the result.
@since 3.1.4
*/
struct wxGridBlockDiffResult
{
wxGridBlockCoords m_parts[4];
};
/**
Represents a collection of grid blocks that can be iterated over.
This class provides read-only access to the blocks making up the grid
selection in the most general case.
Note that objects of this class can only be returned by wxGrid, but not
constructed in the application code.
The preferable way to iterate over it is using C++11 range-for loop:
@code
for ( const auto& block: grid->GetSelectedBlocks() ) {
... do something with block ...
}
@endcode
When not using C++11, iteration has to be done manually:
@code
wxGridBlocks range = grid->GetSelectedBlocks();
for ( wxGridBlocks::iterator it = range.begin();
it != range.end();
++it ) {
... do something with *it ...
}
@endcode
@since 3.1.4
*/
class wxGridBlocks
{
public:
/**
Read-only forward iterator type.
This is an opaque type, which satisfies the forward iterator
requirements, i.e. provides all the expected operations, such as
comparison, dereference and pre- and post-increment.
*/
class iterator
{
iterator();
const wxGridBlockCoords& operator*() const;
const wxGridBlockCoords* operator->() const;
iterator& operator++();
iterator operator++(int);
bool operator==(const iterator& it) const;
bool operator!=(const iterator& it) const;
};
/// Return iterator corresponding to the beginning of the range.
iterator begin() const;
/// Return iterator corresponding to the end of the range.
iterator end() const;
};
/**
@class wxGridTableBase
The almost abstract base class for grid tables.
A grid table is responsible for storing the grid data and, indirectly, grid
cell attributes. The data can be stored in the way most convenient for the
application but has to be provided in string form to wxGrid. It is also
possible to provide cells values in other formats if appropriate, e.g. as
numbers.
This base class is not quite abstract as it implements a trivial strategy
for storing the attributes by forwarding it to wxGridCellAttrProvider and
also provides stubs for some other functions. However it does have a number
of pure virtual methods which must be implemented in the derived classes.
@see wxGridStringTable
@library{wxcore}
@category{grid}
*/
class wxGridTableBase : public wxObject
{
public:
/**
Default constructor.
*/
wxGridTableBase();
/**
Destructor frees the attribute provider if it was created.
*/
virtual ~wxGridTableBase();
/**
Must be overridden to return the number of rows in the table.
For backwards compatibility reasons, this method is not const.
Use GetRowsCount() instead of it in const methods of derived table
classes.
*/
virtual int GetNumberRows() = 0;
/**
Must be overridden to return the number of columns in the table.
For backwards compatibility reasons, this method is not const.
Use GetColsCount() instead of it in const methods of derived table
classes,
*/
virtual int GetNumberCols() = 0;
/**
Return the number of rows in the table.
This method is not virtual and is only provided as a convenience for
the derived classes which can't call GetNumberRows() without a
@c const_cast from their const methods.
*/
int GetRowsCount() const;
/**
Return the number of columns in the table.
This method is not virtual and is only provided as a convenience for
the derived classes which can't call GetNumberCols() without a
@c const_cast from their const methods.
*/
int GetColsCount() const;
/**
@name Table Cell Accessors
*/
///@{
/**
May be overridden to implement testing for empty cells.
This method is used by the grid to test if the given cell is not used
and so whether a neighbouring cell may overflow into it. By default it
only returns true if the value of the given cell, as returned by
GetValue(), is empty.
*/
virtual bool IsEmptyCell(int row, int col);
/**
Same as IsEmptyCell() but taking wxGridCellCoords.
Notice that this method is not virtual, only IsEmptyCell() should be
overridden.
*/
bool IsEmpty(const wxGridCellCoords& coords);
/**
Must be overridden to implement accessing the table values as text.
*/
virtual wxString GetValue(int row, int col) = 0;
/**
Must be overridden to implement setting the table values as text.
*/
virtual void SetValue(int row, int col, const wxString& value) = 0;
/**
Returns the type of the value in the given cell.
By default all cells are strings and this method returns
@c wxGRID_VALUE_STRING.
*/
virtual wxString GetTypeName(int row, int col);
/**
Returns true if the value of the given cell can be accessed as if it
were of the specified type.
By default the cells can only be accessed as strings. Note that a cell
could be accessible in different ways, e.g. a numeric cell may return
@true for @c wxGRID_VALUE_NUMBER but also for @c wxGRID_VALUE_STRING
indicating that the value can be coerced to a string form.
*/
virtual bool CanGetValueAs(int row, int col, const wxString& typeName);
/**
Returns true if the value of the given cell can be set as if it were of
the specified type.
@see CanGetValueAs()
*/
virtual bool CanSetValueAs(int row, int col, const wxString& typeName);
/**
Returns the value of the given cell as a long.
This should only be called if CanGetValueAs() returns @true when called
with @c wxGRID_VALUE_NUMBER argument. Default implementation always
return 0.
*/
virtual long GetValueAsLong(int row, int col);
/**
Returns the value of the given cell as a double.
This should only be called if CanGetValueAs() returns @true when called
with @c wxGRID_VALUE_FLOAT argument. Default implementation always
return 0.0.
*/
virtual double GetValueAsDouble(int row, int col);
/**
Returns the value of the given cell as a boolean.
This should only be called if CanGetValueAs() returns @true when called
with @c wxGRID_VALUE_BOOL argument. Default implementation always
return false.
*/
virtual bool GetValueAsBool(int row, int col);
/**
Returns the value of the given cell as a user-defined type.
This should only be called if CanGetValueAs() returns @true when called
with @a typeName. Default implementation always return @NULL.
Note that if the pointer is not null, it will be deleted by the caller,
so it must be allocated on the heap by any class overriding this
method. In practice, it means that the value stored internally must be
cloned on every call.
*/
virtual void *GetValueAsCustom(int row, int col, const wxString& typeName);
/**
Sets the value of the given cell as a long.
This should only be called if CanSetValueAs() returns @true when called
with @c wxGRID_VALUE_NUMBER argument. Default implementation doesn't do
anything.
*/
virtual void SetValueAsLong(int row, int col, long value);
/**
Sets the value of the given cell as a double.
This should only be called if CanSetValueAs() returns @true when called
with @c wxGRID_VALUE_FLOAT argument. Default implementation doesn't do
anything.
*/
virtual void SetValueAsDouble(int row, int col, double value);
/**
Sets the value of the given cell as a boolean.
This should only be called if CanSetValueAs() returns @true when called
with @c wxGRID_VALUE_BOOL argument. Default implementation doesn't do
anything.
*/
virtual void SetValueAsBool( int row, int col, bool value );
/**
Sets the value of the given cell as a user-defined type.
This should only be called if CanSetValueAs() returns @true when called
with @a typeName. Default implementation doesn't do anything.
*/
virtual void SetValueAsCustom(int row, int col, const wxString& typeName,
void *value);
///@}
/**
Called by the grid when the table is associated with it.
The default implementation stores the pointer and returns it from its
GetView() and so only makes sense if the table cannot be associated
with more than one grid at a time.
*/
virtual void SetView(wxGrid *grid);
/**
Returns the last grid passed to SetView().
*/
virtual wxGrid *GetView() const;
/*!
@name Table Structure Modifiers
Note that none of these functions are pure virtual as they don't have
to be implemented if the table structure is never modified after
creation, i.e. neither rows nor columns are ever added or deleted.
Also note that you do need to implement them if they are called, i.e. if your
code either calls them directly or uses the matching wxGrid methods, as
by default they simply do nothing which is definitely inappropriate.
*/
///@{
/**
Clear the table contents.
This method is used by wxGrid::ClearGrid().
*/
virtual void Clear();
/**
Insert additional rows into the table.
@param pos
The position of the first new row.
@param numRows
The number of rows to insert.
*/
virtual bool InsertRows(size_t pos = 0, size_t numRows = 1);
/**
Append additional rows at the end of the table.
This method is provided in addition to InsertRows() as some data models
may only support appending rows to them but not inserting them at
arbitrary locations. In such case you may implement this method only
and leave InsertRows() unimplemented.
@param numRows
The number of rows to add.
*/
virtual bool AppendRows(size_t numRows = 1);
/**
Delete rows from the table.
@param pos
The first row to delete.
@param numRows
The number of rows to delete.
*/
virtual bool DeleteRows(size_t pos = 0, size_t numRows = 1);
/**
Exactly the same as InsertRows() but for columns.
*/
virtual bool InsertCols(size_t pos = 0, size_t numCols = 1);
/**
Exactly the same as AppendRows() but for columns.
*/
virtual bool AppendCols(size_t numCols = 1);
/**
Exactly the same as DeleteRows() but for columns.
*/
virtual bool DeleteCols(size_t pos = 0, size_t numCols = 1);
///@}
/*!
@name Table Row, Column and Corner Labels
By default the numbers are used for labelling rows and Latin letters for
labelling columns. If the table has more than 26 columns, the pairs of
letters are used starting from the 27-th one and so on, i.e. the
sequence of labels is A, B, ..., Z, AA, AB, ..., AZ, BA, ..., ..., ZZ,
AAA, ...
A cell in the top-left corner of a grid can also have a label. It is
empty by default. Use wxGrid::SetCornerLabelValue() to set it and
wxGrid::GetCornerLabelValue() to get its' current value.
@see wxGridTableBase::GetCornerLabelValue, wxGridTableBase::SetCornerLabelValue
*/
///@{
/**
Return the label of the specified row.
*/
virtual wxString GetRowLabelValue(int row);
/**
Return the label of the specified column.
*/
virtual wxString GetColLabelValue(int col);
/**
Return the label of the grid's corner.
@since 3.1.2
*/
virtual wxString GetCornerLabelValue() const;
/**
Set the given label for the specified row.
The default version does nothing, i.e. the label is not stored. You
must override this method in your derived class if you wish
wxGrid::SetRowLabelValue() to work.
*/
virtual void SetRowLabelValue(int row, const wxString& label);
/**
Exactly the same as SetRowLabelValue() but for columns.
*/
virtual void SetColLabelValue(int col, const wxString& label);
/**
Set the given label for the grid's corner.
The default version does nothing, i.e. the label is not stored. You
must override this method in your derived class if you wish
wxGrid::GetCornerLabelValue() to work.
@since 3.1.2
*/
virtual void SetCornerLabelValue( const wxString& );
///@}
/**
@name Attributes Management
By default the attributes management is delegated to
wxGridCellAttrProvider class. You may override the methods in this
section to handle the attributes directly if, for example, they can be
computed from the cell values.
*/
///@{
/**
Associate this attributes provider with the table.
The table takes ownership of @a attrProvider pointer and will delete it
when it doesn't need it any more. The pointer can be @NULL, however
this won't disable attributes management in the table but will just
result in a default attributes being recreated the next time any of the
other functions in this section is called. To completely disable the
attributes support, should this be needed, you need to override
CanHaveAttributes() to return @false.
*/
void SetAttrProvider(wxGridCellAttrProvider *attrProvider);
/**
Returns the attribute provider currently being used.
This function may return @NULL if the attribute provider hasn't been
either associated with this table by SetAttrProvider() nor created on
demand by any other methods.
*/
wxGridCellAttrProvider *GetAttrProvider() const;
/**
Return the attribute for the given cell.
By default this function is simply forwarded to
wxGridCellAttrProvider::GetAttr() but it may be overridden to handle
attributes directly in the table.
Prefer to use GetAttrPtr() to avoid the need to call DecRef() on the
returned pointer manually.
*/
virtual wxGridCellAttr *GetAttr(int row, int col,
wxGridCellAttr::wxAttrKind kind);
/**
Return the attribute for the given cell.
This method is identical to GetAttr(), but returns a smart pointer,
which frees the caller from the need to call DecRef() manually.
@since 3.1.4
*/
wxGridCellAttrPtr GetAttrPtr(int row, int col,
wxGridCellAttr::wxAttrKind kind);
/**
Set attribute of the specified cell.
By default this function is simply forwarded to
wxGridCellAttrProvider::SetAttr().
The table takes ownership of @a attr, i.e. will call DecRef() on it.
*/
virtual void SetAttr(wxGridCellAttr* attr, int row, int col);
/**
Set attribute of the specified row.
By default this function is simply forwarded to
wxGridCellAttrProvider::SetRowAttr().
The table takes ownership of @a attr, i.e. will call DecRef() on it.
*/
virtual void SetRowAttr(wxGridCellAttr *attr, int row);
/**
Set attribute of the specified column.
By default this function is simply forwarded to
wxGridCellAttrProvider::SetColAttr().
The table takes ownership of @a attr, i.e. will call DecRef() on it.
*/
virtual void SetColAttr(wxGridCellAttr *attr, int col);
///@}
/**
Returns true if this table supports attributes or false otherwise.
By default, the table automatically creates a wxGridCellAttrProvider
when this function is called if it had no attribute provider before and
returns @true.
*/
virtual bool CanHaveAttributes();
/**
Override to return true if the same attribute can be used for measuring
all cells in the given column.
This function is provided for optimization purposes: it returns @false
by default, but can be overridden to return @true when all the cells in
the same grid column use sensibly the same attribute, i.e. they use the
same renderer (either explicitly, or implicitly, due to their type as
returned by GetTypeName()) and the font of the same size.
Returning @true from this function allows AutoSizeColumns() to skip
looking up the attribute and the renderer for each individual cell,
which results in very noticeable performance improvements for the grids
with many rows.
@since 3.1.4
*/
virtual bool CanMeasureColUsingSameAttr(int col) const;
};
/**
Possible types for grid table notifications.
*/
enum wxGridTableRequest
{
/// New rows have been inserted into the table.
wxGRIDTABLE_NOTIFY_ROWS_INSERTED,
/// New rows have been append to the table.
wxGRIDTABLE_NOTIFY_ROWS_APPENDED,
/// Rows have been deleted from the table.
wxGRIDTABLE_NOTIFY_ROWS_DELETED,
/// New columns have been inserted into the table.
wxGRIDTABLE_NOTIFY_COLS_INSERTED,
/// New columns have been append to the table.
wxGRIDTABLE_NOTIFY_COLS_APPENDED,
/// Columns have been deleted from the table.
wxGRIDTABLE_NOTIFY_COLS_DELETED
};
/**
@class wxGridSizesInfo
wxGridSizesInfo stores information about sizes of all wxGrid rows or
columns.
It assumes that most of the rows or columns (which are both called elements
here as the difference between them doesn't matter at this class level)
have the default size and so stores it separately. And it uses a wxHashMap
to store the sizes of all elements which have the non-default size.
This structure is particularly useful for serializing the sizes of all
wxGrid elements at once.
@library{wxcore}
@category{grid}
*/
struct wxGridSizesInfo
{
/**
Default constructor.
m_sizeDefault and m_customSizes must be initialized later.
*/
wxGridSizesInfo();
/**
Constructor.
This constructor is used by wxGrid::GetRowSizes() and GetColSizes()
methods. User code will usually use the default constructor instead.
@param defSize
The default element size.
@param allSizes
Array containing the sizes of @em all elements, including those
which have the default size.
*/
wxGridSizesInfo(int defSize, const wxArrayInt& allSizes);
/**
Get the element size.
@param pos
The index of the element.
@return
The size for this element, using m_customSizes if @a pos is in it
or m_sizeDefault otherwise.
*/
int GetSize(unsigned pos) const;
/// Default size
int m_sizeDefault;
/**
Map with element indices as keys and their sizes as values.
This map only contains the elements with non-default size.
*/
wxUnsignedToIntHashMap m_customSizes;
};
/**
Rendering styles supported by wxGrid::Render() method.
@since 2.9.4
*/
enum wxGridRenderStyle
{
/// Draw grid row header labels.
wxGRID_DRAW_ROWS_HEADER = 0x001,
/// Draw grid column header labels.
wxGRID_DRAW_COLS_HEADER = 0x002,
/// Draw grid cell border lines.
wxGRID_DRAW_CELL_LINES = 0x004,
/**
Draw a bounding rectangle around the rendered cell area.
Useful where row or column headers are not drawn or where there is
multi row or column cell clipping and therefore no cell border at
the rendered outer boundary.
*/
wxGRID_DRAW_BOX_RECT = 0x008,
/**
Draw the grid cell selection highlight if a selection is present.
At present the highlight colour drawn depends on whether the grid
window loses focus before drawing begins.
*/
wxGRID_DRAW_SELECTION = 0x010,
/**
The default render style.
Includes all except wxGRID_DRAW_SELECTION.
*/
wxGRID_DRAW_DEFAULT = wxGRID_DRAW_ROWS_HEADER |
wxGRID_DRAW_COLS_HEADER |
wxGRID_DRAW_CELL_LINES |
wxGRID_DRAW_BOX_RECT
};
/**
@class wxGrid
wxGrid and its related classes are used for displaying and editing tabular
data. They provide a rich set of features for display, editing, and
interacting with a variety of data sources. For simple applications, and to
help you get started, wxGrid is the only class you need to refer to
directly. It will set up default instances of the other classes and manage
them for you. For more complex applications you can derive your own classes
for custom grid views, grid data tables, cell editors and renderers. The
@ref overview_grid has examples of simple and more complex applications,
explains the relationship between the various grid classes and has a
summary of the keyboard shortcuts and mouse functions provided by wxGrid.
A wxGridTableBase class holds the actual data to be displayed by a wxGrid
class. One or more wxGrid classes may act as a view for one table class.
The default table class is called wxGridStringTable and holds an array of
strings. An instance of such a class is created by CreateGrid().
wxGridCellRenderer is the abstract base class for rendering contents in a
cell. The following renderers are predefined:
- wxGridCellBoolRenderer
- wxGridCellFloatRenderer
- wxGridCellNumberRenderer
- wxGridCellStringRenderer
- wxGridCellDateRenderer
- wxGridCellDateTimeRenderer
The look of a cell can be further defined using wxGridCellAttr. An object
of this type may be returned by wxGridTableBase::GetAttr().
wxGridCellEditor is the abstract base class for editing the value of a
cell. The following editors are predefined:
- wxGridCellBoolEditor
- wxGridCellChoiceEditor
- wxGridCellFloatEditor
- wxGridCellNumberEditor
- wxGridCellTextEditor
- wxGridCellDateEditor
Please see wxGridEvent, wxGridSizeEvent, wxGridRangeSelectEvent, and
wxGridEditorCreatedEvent for the documentation of all event types you can
use with wxGrid.
@library{wxcore}
@category{grid}
@see @ref overview_grid, wxGridUpdateLocker
*/
class wxGrid : public wxScrolledCanvas
{
public:
/**
Different selection modes supported by the grid.
*/
enum wxGridSelectionModes
{
/**
The default selection mode allowing selection of the individual
cells as well as of the entire rows and columns.
*/
wxGridSelectCells,
/**
The selection mode allowing the selection of the entire rows only.
The user won't be able to select any cells or columns in this mode.
*/
wxGridSelectRows,
/**
The selection mode allowing the selection of the entire columns only.
The user won't be able to select any cells or rows in this mode.
*/
wxGridSelectColumns,
/**
The selection mode allowing the user to select either the entire
columns or the entire rows but not individual cells nor blocks.
Notice that while this constant is defined as @code
wxGridSelectColumns | wxGridSelectRows @endcode this doesn't mean
that all the other combinations are valid -- at least currently
they are not.
@since 2.9.1
*/
wxGridSelectRowsOrColumns,
/**
The selection mode allowing no selections to be made at all.
The user won't be able to select any cells in this mode.
@since 3.1.5
*/
wxGridSelectNone
};
/**
Return values for GetCellSize().
@since 2.9.1
*/
enum CellSpan
{
/// This cell is inside a span covered by another cell.
CellSpan_Inside = -1,
/// This is a normal, non-spanning cell.
CellSpan_None = 0,
/// This cell spans several physical wxGrid cells.
CellSpan_Main
};
/**
Constants defining different support built-in TAB handling behaviours.
The elements of this enum determine what happens when TAB is pressed
when the cursor is in the rightmost column (or Shift-TAB is pressed
when the cursor is in the leftmost one).
@see SetTabBehaviour(), @c wxEVT_GRID_TABBING
@since 2.9.5
*/
enum TabBehaviour
{
/// Do nothing, this is default.
Tab_Stop,
/// Move to the beginning of the next (or the end of the previous) row.
Tab_Wrap,
/// Move to the next (or the previous) control after the grid.
Tab_Leave
};
/**
@name Constructors and Initialization
*/
///@{
/**
Default constructor.
You must call Create() to really create the grid window and also call
CreateGrid() or SetTable() or AssignTable() to initialize its contents.
*/
wxGrid();
/**
Constructor creating the grid window.
You must call either CreateGrid() or SetTable() or AssignTable() to
initialize the grid contents before using it.
*/
wxGrid(wxWindow* parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxWANTS_CHARS,
const wxString& name = wxGridNameStr);
/**
Destructor.
This will also destroy the associated grid table unless you passed a
table object to the grid and specified that the grid should not take
ownership of the table (see SetTable()).
*/
virtual ~wxGrid();
/**
Creates the grid window for an object initialized using the default
constructor.
You must call either CreateGrid() or SetTable() or AssignTable() to
initialize the grid contents before using it.
*/
bool Create(wxWindow* parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxWANTS_CHARS,
const wxString& name = wxGridNameStr);
/**
Creates a grid with the specified initial number of rows and columns.
Call this directly after the grid constructor. When you use this
function wxGrid will create and manage a simple table of string values
for you. All of the grid data will be stored in memory.
For applications with more complex data types or relationships, or for
dealing with very large datasets, you should derive your own grid table
class and pass a table object to the grid with SetTable() or
AssignTable().
*/
bool CreateGrid(int numRows, int numCols,
wxGridSelectionModes selmode = wxGridSelectCells);
/**
Passes a pointer to a custom grid table to be used by the grid.
This should be called after the grid constructor and before using the
grid object. If @a takeOwnership is set to @true then the table will be
deleted by the wxGrid destructor.
Use this function instead of CreateGrid() when your application
involves complex or non-string data or data sets that are too large to
fit wholly in memory.
When the custom table should be owned by the grid, consider using the
simpler AssignTable() function instead of this one with @true value of
@a takeOwnership parameter.
*/
bool SetTable(wxGridTableBase* table, bool takeOwnership = false,
wxGridSelectionModes selmode = wxGridSelectCells);
/**
Assigns a pointer to a custom grid table to be used by the grid.
This function is identical to SetTable() with @c takeOwnership
parameter set to @true, i.e. it simply always takes the ownership of
the passed in pointer. This makes it simpler to use than SetTable() in
the common case when the table should be owned by the grid object.
Note that this function should be called at most once and can't be used
to change the table used by the grid later on or reset it: if such
extra flexibility is needed, use SetTable() directly.
@since 3.1.4
@param table The heap-allocated pointer to the table.
@param selmode Selection mode to use.
*/
void AssignTable( wxGridTableBase *table,
wxGridSelectionModes selmode = wxGridSelectCells);
/**
Receive and handle a message from the table.
*/
bool ProcessTableMessage(wxGridTableMessage& msg);
///@}
/**
@name Grid Line Formatting
*/
///@{
/**
Turns the drawing of grid lines on or off.
*/
void EnableGridLines(bool enable = true);
/**
Returns the pen used for vertical grid lines.
This virtual function may be overridden in derived classes in order to
change the appearance of individual grid lines for the given column
@a col.
See GetRowGridLinePen() for an example.
*/
virtual wxPen GetColGridLinePen(int col);
/**
Returns the pen used for grid lines.
This virtual function may be overridden in derived classes in order to
change the appearance of grid lines. Note that currently the pen width
must be 1.
@see GetColGridLinePen(), GetRowGridLinePen()
*/
virtual wxPen GetDefaultGridLinePen();
/**
Returns the colour used for grid lines.
@see GetDefaultGridLinePen()
*/
wxColour GetGridLineColour() const;
/**
Returns the pen used for horizontal grid lines.
This virtual function may be overridden in derived classes in order to
change the appearance of individual grid line for the given @a row.
Example:
@code
// in a grid displaying music notation, use a solid black pen between
// octaves (C0=row 127, C1=row 115 etc.)
wxPen MidiGrid::GetRowGridLinePen(int row)
{
if ( row % 12 == 7 )
return wxPen(*wxBLACK, 1, wxPENSTYLE_SOLID);
else
return GetDefaultGridLinePen();
}
@endcode
*/
virtual wxPen GetRowGridLinePen(int row);
/**
Returns @true if drawing of grid lines is turned on, @false otherwise.
*/
bool GridLinesEnabled() const;
/**
Sets the colour used to draw grid lines.
*/
void SetGridLineColour(const wxColour& colour);
///@}
/**
@name Label Values and Formatting
*/
///@{
/**
Sets the arguments to the current column label alignment values.
Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE
or @c wxALIGN_RIGHT.
Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or
@c wxALIGN_BOTTOM.
*/
void GetColLabelAlignment(int* horiz, int* vert) const;
/**
Returns the orientation of the column labels (either @c wxHORIZONTAL or
@c wxVERTICAL).
*/
int GetColLabelTextOrientation() const;
/**
Returns the specified column label.
The default grid table class provides column labels of the form
A,B...Z,AA,AB...ZZ,AAA... If you are using a custom grid table you can
override wxGridTableBase::GetColLabelValue() to provide your own
labels.
*/
wxString GetColLabelValue(int col) const;
/**
Sets the arguments to the current corner label alignment values.
Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE
or @c wxALIGN_RIGHT.
Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or
@c wxALIGN_BOTTOM.
@since 3.1.2
*/
void GetCornerLabelAlignment( int *horiz, int *vert ) const;
/**
Returns the orientation of the corner label (either @c wxHORIZONTAL or
@c wxVERTICAL).
@since 3.1.2
*/
int GetCornerLabelTextOrientation() const;
/**
Returns the (top-left) corner label.
@since 3.1.2
*/
wxString GetCornerLabelValue() const;
/**
Returns the colour used for the background of row and column labels.
*/
wxColour GetLabelBackgroundColour() const;
/**
Returns the font used for row and column labels.
*/
wxFont GetLabelFont() const;
/**
Returns the colour used for row and column label text.
*/
wxColour GetLabelTextColour() const;
/**
Returns the alignment used for row labels.
Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE
or @c wxALIGN_RIGHT.
Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or
@c wxALIGN_BOTTOM.
*/
void GetRowLabelAlignment(int* horiz, int* vert) const;
/**
Returns the specified row label.
The default grid table class provides numeric row labels. If you are
using a custom grid table you can override
wxGridTableBase::GetRowLabelValue() to provide your own labels.
*/
wxString GetRowLabelValue(int row) const;
/**
Hides the column labels by calling SetColLabelSize() with a size of 0.
The labels can be shown again by calling SetColLabelSize() with a
height greater than 0.
Note that when the column labels are hidden, the grid won't have any
visible border on the top side, which may result in a less than ideal
appearance. Because of this, you may want to create the grid window
with a border style, such as @c wxBORDER_SIMPLE, when you don't plan to
show the column labels for it.
@see HideRowLabels()
*/
void HideColLabels();
/**
Hides the row labels by calling SetRowLabelSize() with a size of 0.
The labels can be shown again by calling SetRowLabelSize() with a width
greater than 0.
See HideColLabels() for a note explaining why you may want to use a
border with a grid without the row labels.
*/
void HideRowLabels();
/**
Sets the horizontal and vertical alignment of column label text.
Horizontal alignment should be one of @c wxALIGN_LEFT,
@c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment should be one
of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM.
*/
void SetColLabelAlignment(int horiz, int vert);
/**
Sets the orientation of the column labels (either @c wxHORIZONTAL or
@c wxVERTICAL).
*/
void SetColLabelTextOrientation(int textOrientation);
/**
Set the value for the given column label.
If you are using a custom grid table you must override
wxGridTableBase::SetColLabelValue() for this to have any effect.
*/
void SetColLabelValue(int col, const wxString& value);
/**
Sets the horizontal and vertical alignment of the (top-left) corner label text.
Horizontal alignment should be one of @c wxALIGN_LEFT,
@c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment should be one
of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM.
@since 3.1.2
*/
void SetCornerLabelAlignment( int horiz, int vert );
/**
Sets the orientation of the (top-left) corner label (either @c wxHORIZONTAL or
@c wxVERTICAL).
@since 3.1.2
*/
void SetCornerLabelTextOrientation( int textOrientation );
/**
Set the value for the (top-left) corner label.
If you are using a custom grid table you must override
wxGridTableBase::SetCornerLabelValue() for this to have any effect.
@since 3.1.2
*/
void SetCornerLabelValue( const wxString& );
/**
Sets the background colour for row and column labels.
*/
void SetLabelBackgroundColour(const wxColour& colour);
/**
Sets the font for row and column labels.
*/
void SetLabelFont(const wxFont& font);
/**
Sets the colour for row and column label text.
*/
void SetLabelTextColour(const wxColour& colour);
/**
Sets the horizontal and vertical alignment of row label text.
Horizontal alignment should be one of @c wxALIGN_LEFT,
@c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment should be one
of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM.
*/
void SetRowLabelAlignment(int horiz, int vert);
/**
Sets the value for the given row label.
If you are using a derived grid table you must override
wxGridTableBase::SetRowLabelValue() for this to have any effect.
*/
void SetRowLabelValue(int row, const wxString& value);
/**
Call this in order to make the column labels use a native look by using
wxRendererNative::DrawHeaderButton() internally.
There is no equivalent method for drawing row columns as there is not
native look for that. This option is useful when using wxGrid for
displaying tables and not as a spread-sheet.
@see UseNativeColHeader()
*/
void SetUseNativeColLabels(bool native = true);
/**
Enable the use of native header window for column labels.
If this function is called with @true argument, a wxHeaderCtrl is used
instead to display the column labels instead of drawing them in wxGrid
code itself. This has the advantage of making the grid look and feel
perfectly the same as native applications (using SetUseNativeColLabels()
the grid can be made to look more natively but it still doesn't feel
natively, notably the column resizing and dragging still works slightly
differently as it is implemented in wxWidgets itself) but results in
different behaviour for column and row headers, for which there is no
equivalent function, and, most importantly, is unsuitable for grids
with huge numbers of columns as wxHeaderCtrl doesn't support virtual
mode. Because of this, by default the grid does not use the native
header control but you should call this function to enable it if you
are using the grid to display tabular data and don't have thousands of
columns in it.
Another difference between the default behaviour and the native header
behaviour is that the latter provides the user with a context menu
(which appears on right clicking the header) allowing to rearrange the
grid columns if CanDragColMove() returns @true. If you want to prevent
this from happening for some reason, you need to define a handler for
@c wxEVT_GRID_LABEL_RIGHT_CLICK event which simply does nothing (in
particular doesn't skip the event) as this will prevent the default
right click handling from working.
Also note that currently @c wxEVT_GRID_LABEL_RIGHT_DCLICK event is not
generated for the column labels if the native columns header is used
(but this limitation could possibly be lifted in the future).
Finally, please note that using the native control is currently
incompatible with freezing columns in the grid (see FreezeTo()) and
this function will return @false, without doing anything, if it's
called on a grid in which any columns are frozen.
*/
bool UseNativeColHeader(bool native = true);
///@}
/*!
@name Cell Formatting
Note that wxGridCellAttr can be used alternatively to most of these
methods. See the "Attributes Management" of wxGridTableBase.
*/
///@{
/**
Sets the arguments to the horizontal and vertical text alignment values
for the grid cell at the specified location.
Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE
or @c wxALIGN_RIGHT.
Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or
@c wxALIGN_BOTTOM.
*/
void GetCellAlignment(int row, int col, int* horiz, int* vert) const;
/**
Returns the background colour of the cell at the specified location.
*/
wxColour GetCellBackgroundColour(int row, int col) const;
/**
Returns the font for text in the grid cell at the specified location.
*/
wxFont GetCellFont(int row, int col) const;
/**
Returns the text colour for the grid cell at the specified location.
*/
wxColour GetCellTextColour(int row, int col) const;
/**
Returns the default cell alignment.
Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE
or @c wxALIGN_RIGHT.
Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or
@c wxALIGN_BOTTOM.
@see SetDefaultCellAlignment()
*/
void GetDefaultCellAlignment(int* horiz, int* vert) const;
/**
Returns the current default background colour for grid cells.
*/
wxColour GetDefaultCellBackgroundColour() const;
/**
Returns the current default font for grid cell text.
*/
wxFont GetDefaultCellFont() const;
/**
Returns the current default colour for grid cell text.
*/
wxColour GetDefaultCellTextColour() const;
/**
Sets the horizontal and vertical alignment for grid cell text at the
specified location.
Horizontal alignment should be one of @c wxALIGN_LEFT,
@c wxALIGN_CENTRE or @c wxALIGN_RIGHT.
Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE
or @c wxALIGN_BOTTOM.
*/
void SetCellAlignment(int row, int col, int horiz, int vert);
/**
Sets the horizontal and vertical alignment for grid cell text at the
specified location.
Horizontal alignment should be one of @c wxALIGN_LEFT,
@c wxALIGN_CENTRE or @c wxALIGN_RIGHT.
Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE
or @c wxALIGN_BOTTOM.
@deprecated Please use SetCellAlignment(row, col, horiz, vert) instead.
*/
void SetCellAlignment(int align, int row, int col);
/**
Set the background colour for the given cell or all cells by default.
*/
void SetCellBackgroundColour(int row, int col, const wxColour& colour);
/**
Sets the font for text in the grid cell at the specified location.
*/
void SetCellFont(int row, int col, const wxFont& font);
/**
Sets the text colour for the given cell.
*/
void SetCellTextColour(int row, int col, const wxColour& colour);
/**
Sets the text colour for the given cell.
@deprecated Please use SetCellTextColour(row, col, colour)
*/
void SetCellTextColour(const wxColour& val, int row, int col);
/**
Sets the text colour for all cells by default.
@deprecated Please use SetDefaultCellTextColour(colour) instead.
*/
void SetCellTextColour(const wxColour& colour);
/**
Sets the default horizontal and vertical alignment for grid cell text.
Horizontal alignment should be one of @c wxALIGN_LEFT,
@c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment should be one
of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM.
*/
void SetDefaultCellAlignment(int horiz, int vert);
/**
Sets the default background colour for grid cells.
*/
void SetDefaultCellBackgroundColour(const wxColour& colour);
/**
Sets the default font to be used for grid cell text.
*/
void SetDefaultCellFont(const wxFont& font);
/**
Sets the current default colour for grid cell text.
*/
void SetDefaultCellTextColour(const wxColour& colour);
///@}
/*!
@name Cell Values, Editors, and Renderers
Note that wxGridCellAttr can be used alternatively to most of these
methods. See the "Attributes Management" of wxGridTableBase.
*/
///@{
/**
Returns @true if the in-place edit control for the current grid cell
can be used and @false otherwise.
This function always returns @false for the read-only cells.
*/
bool CanEnableCellControl() const;
/**
Disables in-place editing of grid cells.
Equivalent to calling EnableCellEditControl(@false).
*/
void DisableCellEditControl();
/**
Enables or disables in-place editing of grid cell data.
Enabling in-place editing generates @c wxEVT_GRID_EDITOR_SHOWN and, if
it isn't vetoed by the application, shows the in-place editor which
allows the user to change the cell value.
Disabling in-place editing does nothing if the in-place editor isn't
currently shown, otherwise the @c wxEVT_GRID_EDITOR_HIDDEN event is
generated but, unlike the "shown" event, it can't be vetoed and the
in-place editor is dismissed unconditionally.
Note that it is an error to call this function if the current cell is
read-only, use CanEnableCellControl() to check for this precondition.
*/
void EnableCellEditControl(bool enable = true);
/**
Makes the grid globally editable or read-only.
If the edit argument is @false this function sets the whole grid as
read-only. If the argument is @true the grid is set to the default
state where cells may be editable. In the default state you can set
single grid cells and whole rows and columns to be editable or
read-only via wxGridCellAttr::SetReadOnly(). For single cells you
can also use the shortcut function SetReadOnly().
For more information about controlling grid cell attributes see the
wxGridCellAttr class and the @ref overview_grid.
*/
void EnableEditing(bool edit);
/**
Returns a pointer to the editor for the cell at the specified location.
See wxGridCellEditor and the @ref overview_grid for more information
about cell editors and renderers.
The caller must call DecRef() on the returned pointer.
*/
wxGridCellEditor* GetCellEditor(int row, int col) const;
/**
Returns a pointer to the renderer for the grid cell at the specified
location.
See wxGridCellRenderer and the @ref overview_grid for more information
about cell editors and renderers.
The caller must call DecRef() on the returned pointer.
*/
wxGridCellRenderer* GetCellRenderer(int row, int col) const;
/**
Returns the string contained in the cell at the specified location.
For simple applications where a grid object automatically uses a
default grid table of string values you use this function together with
SetCellValue() to access cell values. For more complex applications
where you have derived your own grid table class that contains various
data types (e.g. numeric, boolean or user-defined custom types) then
you only use this function for those cells that contain string values.
See wxGridTableBase::CanGetValueAs() and the @ref overview_grid for
more information.
*/
wxString GetCellValue(int row, int col) const;
/**
Returns the string contained in the cell at the specified location.
For simple applications where a grid object automatically uses a
default grid table of string values you use this function together with
SetCellValue() to access cell values. For more complex applications
where you have derived your own grid table class that contains various
data types (e.g. numeric, boolean or user-defined custom types) then
you only use this function for those cells that contain string values.
See wxGridTableBase::CanGetValueAs() and the @ref overview_grid for
more information.
*/
wxString GetCellValue(const wxGridCellCoords& coords) const;
/**
Returns a pointer to the current default grid cell editor.
See wxGridCellEditor and the @ref overview_grid for more information
about cell editors and renderers.
*/
wxGridCellEditor* GetDefaultEditor() const;
/**
Returns the default editor for the specified cell.
The base class version returns the editor appropriate for the current
cell type but this method may be overridden in the derived classes to
use custom editors for some cells by default.
Notice that the same may be achieved in a usually simpler way by
associating a custom editor with the given cell or cells.
The caller must call DecRef() on the returned pointer.
*/
virtual wxGridCellEditor* GetDefaultEditorForCell(int row, int col) const;
/**
Returns the default editor for the specified cell.
The base class version returns the editor appropriate for the current
cell type but this method may be overridden in the derived classes to
use custom editors for some cells by default.
Notice that the same may be achieved in a usually simpler way by
associating a custom editor with the given cell or cells.
The caller must call DecRef() on the returned pointer.
*/
wxGridCellEditor* GetDefaultEditorForCell(const wxGridCellCoords& c) const;
/**
Returns the default editor for the cells containing values of the given
type.
The base class version returns the editor which was associated with the
specified @a typeName when it was registered RegisterDataType() but
this function may be overridden to return something different. This
allows overriding an editor used for one of the standard types.
The caller must call DecRef() on the returned pointer.
*/
virtual wxGridCellEditor* GetDefaultEditorForType(const wxString& typeName) const;
/**
Returns a pointer to the current default grid cell renderer.
See wxGridCellRenderer and the @ref overview_grid for more information
about cell editors and renderers.
The caller must call DecRef() on the returned pointer.
*/
wxGridCellRenderer* GetDefaultRenderer() const;
/**
Returns the default renderer for the given cell.
The base class version returns the renderer appropriate for the current
cell type but this method may be overridden in the derived classes to
use custom renderers for some cells by default.
The caller must call DecRef() on the returned pointer.
*/
virtual wxGridCellRenderer* GetDefaultRendererForCell(int row, int col) const;
/**
Returns the default renderer for the cell containing values of the
given type.
@see GetDefaultEditorForType()
*/
virtual wxGridCellRenderer* GetDefaultRendererForType(const wxString& typeName) const;
/**
Hides the in-place cell edit control.
*/
void HideCellEditControl();
/**
Returns @true if the in-place edit control is currently enabled.
*/
bool IsCellEditControlEnabled() const;
/**
Returns @true if the in-place edit control is currently shown.
@see HideCellEditControl()
*/
bool IsCellEditControlShown() const;
/**
Returns @true if the current cell is read-only.
@see SetReadOnly(), IsReadOnly()
*/
bool IsCurrentCellReadOnly() const;
/**
Returns @false if the whole grid has been set as read-only or @true
otherwise.
See EnableEditing() for more information about controlling the editing
status of grid cells.
*/
bool IsEditable() const;
/**
Returns @true if the cell at the specified location can't be edited.
@see SetReadOnly(), IsCurrentCellReadOnly()
*/
bool IsReadOnly(int row, int col) const;
/**
Register a new data type.
The data types allow to naturally associate specific renderers and
editors to the cells containing values of the given type. For example,
the grid automatically registers a data type with the name
@c wxGRID_VALUE_STRING which uses wxGridCellStringRenderer and
wxGridCellTextEditor as its renderer and editor respectively -- this is
the data type used by all the cells of the default wxGridStringTable,
so this renderer and editor are used by default for all grid cells.
However if a custom table returns @c wxGRID_VALUE_BOOL from its
wxGridTableBase::GetTypeName() method, then wxGridCellBoolRenderer and
wxGridCellBoolEditor are used for it because the grid also registers a
boolean data type with this name.
And as this mechanism is completely generic, you may register your own
data types using your own custom renderers and editors. Just remember
that the table must identify a cell as being of the given type for them
to be used for this cell.
@param typeName
Name of the new type. May be any string, but if the type name is
the same as the name of an already registered type, including one
of the standard ones (which are @c wxGRID_VALUE_STRING, @c
wxGRID_VALUE_BOOL, @c wxGRID_VALUE_NUMBER, @c wxGRID_VALUE_FLOAT,
@c wxGRID_VALUE_CHOICE and @c wxGRID_VALUE_DATE), then the new
registration information replaces the previously used renderer and
editor.
@param renderer
The renderer to use for the cells of this type. Its ownership is
taken by the grid, i.e. it will call DecRef() on this pointer when
it doesn't need it any longer.
@param editor
The editor to use for the cells of this type. Its ownership is also
taken by the grid.
*/
void RegisterDataType(const wxString& typeName,
wxGridCellRenderer* renderer,
wxGridCellEditor* editor);
/**
Sets the value of the current grid cell to the current in-place edit
control value.
This is called automatically when the grid cursor moves from the
current cell to a new cell. It is also a good idea to call this
function when closing a grid since any edits to the final cell location
will not be saved otherwise.
*/
void SaveEditControlValue();
/**
Sets the editor for the grid cell at the specified location.
The grid will take ownership of the pointer.
See wxGridCellEditor and the @ref overview_grid for more information
about cell editors and renderers.
*/
void SetCellEditor(int row, int col, wxGridCellEditor* editor);
/**
Sets the renderer for the grid cell at the specified location.
The grid will take ownership of the pointer.
See wxGridCellRenderer and the @ref overview_grid for more information
about cell editors and renderers.
*/
void SetCellRenderer(int row, int col, wxGridCellRenderer* renderer);
/**
Sets the string value for the cell at the specified location.
For simple applications where a grid object automatically uses a
default grid table of string values you use this function together with
GetCellValue() to access cell values. For more complex applications
where you have derived your own grid table class that contains various
data types (e.g. numeric, boolean or user-defined custom types) then
you only use this function for those cells that contain string values.
See wxGridTableBase::CanSetValueAs() and the @ref overview_grid for
more information.
*/
void SetCellValue(int row, int col, const wxString& s);
/**
Sets the string value for the cell at the specified location.
For simple applications where a grid object automatically uses a
default grid table of string values you use this function together with
GetCellValue() to access cell values. For more complex applications
where you have derived your own grid table class that contains various
data types (e.g. numeric, boolean or user-defined custom types) then
you only use this function for those cells that contain string values.
See wxGridTableBase::CanSetValueAs() and the @ref overview_grid for
more information.
*/
void SetCellValue(const wxGridCellCoords& coords, const wxString& s);
/**
@deprecated Please use SetCellValue(int,int,const wxString&) or
SetCellValue(const wxGridCellCoords&,const wxString&)
instead.
Sets the string value for the cell at the specified location.
For simple applications where a grid object automatically uses a
default grid table of string values you use this function together with
GetCellValue() to access cell values. For more complex applications
where you have derived your own grid table class that contains various
data types (e.g. numeric, boolean or user-defined custom types) then
you only use this function for those cells that contain string values.
See wxGridTableBase::CanSetValueAs() and the @ref overview_grid for
more information.
*/
void SetCellValue(const wxString& val, int row, int col);
/**
Sets the specified column to display boolean values.
@see SetColFormatCustom()
*/
void SetColFormatBool(int col);
/**
Sets the specified column to display data in a custom format.
This method provides an alternative to defining a custom grid table
which would return @a typeName from its GetTypeName() method for the
cells in this column: while it doesn't really change the type of the
cells in this column, it does associate the renderer and editor used
for the cells of the specified type with them.
See the @ref overview_grid for more information on working with custom
data types.
*/
void SetColFormatCustom(int col, const wxString& typeName);
/**
Sets the specified column to display floating point values with the
given width and precision.
@see SetColFormatCustom()
*/
void SetColFormatFloat(int col, int width = -1, int precision = -1);
/**
Sets the specified column to display integer values.
@see SetColFormatCustom()
*/
void SetColFormatNumber(int col);
/**
Sets the specified column to display date values.
The @a format argument is used with wxGridCellDateRenderer and allows
to specify the strftime-like format string to use for displaying the
dates in this column.
@see SetColFormatCustom()
@since 3.1.3
*/
void SetColFormatDate(int col, const wxString& format = wxString());
/**
Sets the default editor for grid cells.
The grid will take ownership of the pointer.
See wxGridCellEditor and the @ref overview_grid for more information
about cell editors and renderers.
*/
void SetDefaultEditor(wxGridCellEditor* editor);
/**
Sets the default renderer for grid cells.
The grid will take ownership of the pointer.
See wxGridCellRenderer and the @ref overview_grid for more information
about cell editors and renderers.
*/
void SetDefaultRenderer(wxGridCellRenderer* renderer);
/**
Makes the cell at the specified location read-only or editable.
@see IsReadOnly()
*/
void SetReadOnly(int row, int col, bool isReadOnly = true);
/**
Displays the active in-place cell edit control for the current cell
after it was hidden.
This method should only be called after calling HideCellEditControl(),
to start editing the current grid cell use EnableCellEditControl()
instead.
*/
void ShowCellEditControl();
///@}
/**
@name Column and Row Sizes
@see @ref overview_grid_resizing
*/
///@{
/**
Automatically sets the height and width of all rows and columns to fit
their contents.
*/
void AutoSize();
/**
Automatically adjusts width of the column to fit its label.
*/
void AutoSizeColLabelSize(int col);
/**
Automatically sizes the column to fit its contents. If @a setAsMin is
@true the calculated width will also be set as the minimal width for
the column.
*/
void AutoSizeColumn(int col, bool setAsMin = true);
/**
Automatically sizes all columns to fit their contents. If @a setAsMin
is @true the calculated widths will also be set as the minimal widths
for the columns.
*/
void AutoSizeColumns(bool setAsMin = true);
/**
Automatically sizes the row to fit its contents. If @a setAsMin is
@true the calculated height will also be set as the minimal height for
the row.
*/
void AutoSizeRow(int row, bool setAsMin = true);
/**
Automatically adjusts height of the row to fit its label.
*/
void AutoSizeRowLabelSize(int col);
/**
Automatically sizes all rows to fit their contents. If @a setAsMin is
@true the calculated heights will also be set as the minimal heights
for the rows.
*/
void AutoSizeRows(bool setAsMin = true);
/**
Returns the cell fitting mode.
@see wxGridFitMode
@since 3.1.4
*/
wxGridFitMode GetCellFitMode(int row, int col) const;
/**
Returns @true if the cell value can overflow.
This is identical to calling GetCellFitMode() and using
wxGridFitMode::IsOverflow() on the returned value.
Prefer using GetCellFitMode() directly in the new code.
*/
bool GetCellOverflow(int row, int col) const;
/**
Returns the current height of the column labels.
*/
int GetColLabelSize() const;
/**
Returns the minimal width to which a column may be resized.
Use SetColMinimalAcceptableWidth() to change this value globally or
SetColMinimalWidth() to do it for individual columns.
@see GetRowMinimalAcceptableHeight()
*/
int GetColMinimalAcceptableWidth() const;
/**
Returns the width of the specified column.
*/
int GetColSize(int col) const;
/**
Returns @true if the specified column is not currently hidden.
*/
bool IsColShown(int col) const;
/**
Returns the default cell fitting mode.
The default mode is "overflow", but can be modified using
SetDefaultCellFitMode().
@see wxGridFitMode
@since 3.1.4
*/
wxGridFitMode GetDefaultCellFitMode() const;
/**
Returns @true if the cells can overflow by default.
This is identical to calling GetDefaultCellFitMode() and using
wxGridFitMode::IsOverflow() on the returned value.
Prefer using GetDefaultCellFitMode() directly in the new code.
*/
bool GetDefaultCellOverflow() const;
/**
Returns the default height for column labels.
*/
int GetDefaultColLabelSize() const;
/**
Returns the current default width for grid columns.
*/
int GetDefaultColSize() const;
/**
Returns the default width for the row labels.
*/
int GetDefaultRowLabelSize() const;
/**
Returns the current default height for grid rows.
*/
int GetDefaultRowSize() const;
/**
Returns the minimal size to which rows can be resized.
Use SetRowMinimalAcceptableHeight() to change this value globally or
SetRowMinimalHeight() to do it for individual cells.
@see GetColMinimalAcceptableWidth()
*/
int GetRowMinimalAcceptableHeight() const;
/**
Returns the current width of the row labels.
*/
int GetRowLabelSize() const;
/**
Returns the height of the specified row.
*/
int GetRowSize(int row) const;
/**
Returns @true if the specified row is not currently hidden.
*/
bool IsRowShown(int row) const;
/**
Specifies the behaviour of the cell contents if it doesn't fit into the
available space.
@see wxGridFitMode
@since 3.1.4
*/
void SetCellFitMode(int row, int col, wxGridFitMode fitMode);
/**
Sets the overflow permission of the cell.
Prefer using SetCellFitMode() in the new code.
*/
void SetCellOverflow(int row, int col, bool allow);
/**
Sets the height of the column labels.
If @a height equals to @c wxGRID_AUTOSIZE then height is calculated
automatically so that no label is truncated. Note that this could be
slow for a large table.
*/
void SetColLabelSize(int height);
/**
Sets the minimal @a width to which the user can resize columns.
@see GetColMinimalAcceptableWidth()
*/
void SetColMinimalAcceptableWidth(int width);
/**
Sets the minimal @a width for the specified column @a col.
It is usually best to call this method during grid creation as calling
it later will not resize the column to the given minimal width even if
it is currently narrower than it.
@a width must be greater than the minimal acceptable column width as
returned by GetColMinimalAcceptableWidth().
*/
void SetColMinimalWidth(int col, int width);
/**
Sets the width of the specified column.
@param col
The column index.
@param width
The new column width in pixels, 0 to hide the column or -1 to fit
the column width to its label width.
*/
void SetColSize(int col, int width);
/**
Hides the specified column.
To show the column later you need to call SetColSize() with non-0
width or ShowCol() to restore the previous column width.
If the column is already hidden, this method doesn't do anything.
@param col
The column index.
*/
void HideCol(int col);
/**
Shows the previously hidden column by resizing it to non-0 size.
The column is shown again with the same width that it had before
HideCol() call.
If the column is currently shown, this method doesn't do anything.
@see HideCol(), SetColSize()
*/
void ShowCol(int col);
/**
Specifies the default behaviour of the cell contents if it doesn't fit
into the available space.
@see wxGridFitMode
@since 3.1.4
*/
void SetDefaultCellFitMode(wxGridFitMode fitMode);
/**
Sets the default overflow permission of the cells.
Prefer using SetDefaultCellFitMode() in the new code.
*/
void SetDefaultCellOverflow( bool allow );
/**
Sets the default width for columns in the grid.
This will only affect columns subsequently added to the grid unless
@a resizeExistingCols is @true.
If @a width is less than GetColMinimalAcceptableWidth(), then the
minimal acceptable width is used instead of it.
*/
void SetDefaultColSize(int width, bool resizeExistingCols = false);
/**
Sets the default height for rows in the grid.
This will only affect rows subsequently added to the grid unless
@a resizeExistingRows is @true.
If @a height is less than GetRowMinimalAcceptableHeight(), then the
minimal acceptable height is used instead of it.
*/
void SetDefaultRowSize(int height, bool resizeExistingRows = false);
/**
Sets the width of the row labels.
If @a width equals @c wxGRID_AUTOSIZE then width is calculated
automatically so that no label is truncated. Note that this could be
slow for a large table.
*/
void SetRowLabelSize(int width);
/**
Sets the minimal row @a height used by default.
See SetColMinimalAcceptableWidth() for more information.
*/
void SetRowMinimalAcceptableHeight(int height);
/**
Sets the minimal @a height for the specified @a row.
See SetColMinimalWidth() for more information.
*/
void SetRowMinimalHeight(int row, int height);
/**
Sets the height of the specified row.
See SetColSize() for more information.
*/
void SetRowSize(int row, int height);
/**
Hides the specified row.
To show the row later you need to call SetRowSize() with non-0
width or ShowRow() to restore its original height.
If the row is already hidden, this method doesn't do anything.
@param col
The row index.
*/
void HideRow(int col);
/**
Shows the previously hidden row.
The row is shown again with the same height that it had before
HideRow() call.
If the row is currently shown, this method doesn't do anything.
@see HideRow(), SetRowSize()
*/
void ShowRow(int col);
/**
Get size information for all columns at once.
This method is useful when the information about all column widths
needs to be saved. The widths can be later restored using
SetColSizes().
@sa wxGridSizesInfo, GetRowSizes()
*/
wxGridSizesInfo GetColSizes() const;
/**
Get size information for all row at once.
@sa wxGridSizesInfo, GetColSizes()
*/
wxGridSizesInfo GetRowSizes() const;
/**
Restore all columns sizes.
This is usually called with wxGridSizesInfo object previously returned
by GetColSizes().
@sa SetRowSizes()
*/
void SetColSizes(const wxGridSizesInfo& sizeInfo);
/**
Restore all rows sizes.
@sa SetColSizes()
*/
void SetRowSizes(const wxGridSizesInfo& sizeInfo);
/**
Set the size of the cell.
Specifying a value of more than 1 in @a num_rows or @a num_cols will
make the cell at (@a row, @a col) span the block of the specified size,
covering the other cells which would be normally shown in it. Passing 1
for both arguments resets the cell to normal appearance.
@see GetCellSize()
@param row
The row of the cell.
@param col
The column of the cell.
@param num_rows
Number of rows to be occupied by this cell, must be >= 1.
@param num_cols
Number of columns to be occupied by this cell, must be >= 1.
*/
void SetCellSize(int row, int col, int num_rows, int num_cols);
/**
Get the size of the cell in number of cells covered by it.
For normal cells, the function fills both @a num_rows and @a num_cols
with 1 and returns CellSpan_None. For cells which span multiple cells, i.e.
for which SetCellSize() had been called, the returned values are the
same ones as were passed to SetCellSize() call and the function return
value is CellSpan_Main.
More unexpectedly, perhaps, the returned values may be @em negative for
the cells which are inside a span covered by a cell occupying multiple
rows or columns. They correspond to the offset of the main cell of the
span from the cell passed to this functions and the function returns
CellSpan_Inside value to indicate this.
As an example, consider a 3*3 grid with the cell (1, 1) (the one in the
middle) having a span of 2 rows and 2 columns, i.e. the grid looks like
@code
+----+----+----+
| | | |
+----+----+----+
| | |
+----+ |
| | |
+----+----+----+
@endcode
Then the function returns 2 and 2 in @a num_rows and @a num_cols for
the cell (1, 1) itself and -1 and -1 for the cell (2, 2) as well as -1
and 0 for the cell (2, 1).
@param row
The row of the cell.
@param col
The column of the cell.
@param num_rows
Pointer to variable receiving the number of rows, must not be @NULL.
@param num_cols
Pointer to variable receiving the number of columns, must not be
@NULL.
@return
The kind of this cell span (the return value is new in wxWidgets
2.9.1, this function was void in previous wxWidgets versions).
*/
CellSpan GetCellSize( int row, int col, int *num_rows, int *num_cols ) const;
/**
Get the number of rows and columns allocated for this cell.
This overload doesn't return a CellSpan value but the values returned
may still be negative, see GetCellSize(int, int, int *, int *) for
details.
*/
wxSize GetCellSize(const wxGridCellCoords& coords) const;
///@}
/**
@name User-Resizing and Dragging
Functions controlling various interactive mouse operations.
By default, columns and rows can be resized by dragging the edges of
their labels (this can be disabled using DisableDragColSize() and
DisableDragRowSize() methods). And if grid line dragging is enabled with
EnableDragGridSize() they can also be resized by dragging the right or
bottom edge of the grid cells.
Columns and rows can also be moved to interactively change their order
but this needs to be explicitly enabled with EnableDragColMove() and
EnableDragColMove().
*/
///@{
/**
Return @true if the dragging of cells is enabled or @false otherwise.
*/
bool CanDragCell() const;
/**
Returns @true if columns can be moved by dragging with the mouse.
Columns can be moved by dragging on their labels.
*/
bool CanDragColMove() const;
/**
Returns @true if the given column can be resized by dragging with the
mouse.
This function returns @true if resizing the columns interactively is
globally enabled, i.e. if DisableDragColSize() hadn't been called, and
if this column wasn't explicitly marked as non-resizable with
DisableColResize().
*/
bool CanDragColSize(int col) const;
/**
Return @true if column edges inside the grid can be dragged to resize
the rows.
@see CanDragGridSize(), CanDragColSize()
@since 3.1.4
*/
bool CanDragGridColEdges() const;
/**
Return @true if row edges inside the grid can be dragged to resize the
rows.
@see CanDragGridSize(), CanDragRowSize()
@since 3.1.4
*/
bool CanDragGridRowEdges() const;
/**
Return @true if the dragging of grid lines to resize rows and columns
is enabled or @false otherwise.
*/
bool CanDragGridSize() const;
/**
Returns @true if rows can be moved by dragging with the mouse.
Rows can be moved by dragging on their labels.
@since 3.1.7
*/
bool CanDragRowMove() const;
/**
Returns @true if the given row can be resized by dragging with the
mouse.
This is the same as CanDragColSize() but for rows.
*/
bool CanDragRowSize(int row) const;
/**
Returns @true if columns can be hidden from the popup menu of the native header.
@since 3.1.3
*/
bool CanHideColumns() const;
/**
Disable interactive resizing of the specified column.
This method allows one to disable resizing of an individual column in a
grid where the columns are otherwise resizable (which is the case by
default).
Notice that currently there is no way to make some columns resizable in
a grid where columns can't be resized by default as there doesn't seem
to be any need for this in practice. There is also no way to make the
column marked as fixed using this method resizable again because it is
supposed that fixed columns are used for static parts of the grid and
so should remain fixed during the entire grid lifetime.
Also notice that disabling interactive column resizing will not prevent
the program from changing the column size.
@see EnableDragColSize()
*/
void DisableColResize(int col);
/**
Disable interactive resizing of the specified row.
This is the same as DisableColResize() but for rows.
@see EnableDragRowSize()
*/
void DisableRowResize(int row);
/**
Disables column moving by dragging with the mouse.
Equivalent to passing @false to EnableDragColMove().
*/
void DisableDragColMove();
/**
Disables row moving by dragging with the mouse.
Equivalent to passing @false to EnableDragRowMove().
@since 3.1.7
*/
void DisableDragRowMove();
/**
Disables column sizing by dragging with the mouse.
Equivalent to passing @false to EnableDragColSize().
*/
void DisableDragColSize();
/**
Disable mouse dragging of grid lines to resize rows and columns.
Equivalent to passing @false to EnableDragGridSize()
*/
void DisableDragGridSize();
/**
Disables row sizing by dragging with the mouse.
Equivalent to passing @false to EnableDragRowSize().
*/
void DisableDragRowSize();
/**
Disables column hiding from the header popup menu.
Equivalent to passing @false to EnableHidingColumns().
@since 3.1.3
*/
void DisableHidingColumns();
/**
Enables or disables cell dragging with the mouse.
*/
void EnableDragCell(bool enable = true);
/**
Enables or disables column moving by dragging with the mouse.
Note that reordering columns by dragging them is currently not
supported when the grid has any frozen columns (see FreezeTo()) and if
this method is called with @a enable equal to @true in this situation,
it returns @false without doing anything. Otherwise it returns @true to
indicate that it was successful.
*/
bool EnableDragColMove(bool enable = true);
/**
Enables or disables row moving by dragging with the mouse.
Note that reordering rows by dragging them is currently not
supported when the grid has any frozen columns (see FreezeTo()) and if
this method is called with @a enable equal to @true in this situation,
it returns @false without doing anything. Otherwise it returns @true to
indicate that it was successful.
@since 3.1.7
*/
bool EnableDragRowMove(bool enable = true);
/**
Enables or disables column sizing by dragging with the mouse.
@see DisableColResize()
*/
void EnableDragColSize(bool enable = true);
/**
Enables or disables row and column resizing by dragging gridlines with
the mouse.
*/
void EnableDragGridSize(bool enable = true);
/**
Enables or disables row sizing by dragging with the mouse.
@see DisableRowResize()
*/
void EnableDragRowSize(bool enable = true);
/**
Enables or disables column hiding from the header popup menu.
Note that currently the popup menu can only be shown when using
wxHeaderCtrl, i.e. if UseNativeColHeader() had been called.
If the native header is not used, this method always simply returns
@false without doing anything, as hiding columns is not supported
anyhow. If @a enable value is the same as CanHideColumns(), it also
returns @false to indicate that nothing was done. Otherwise, it returns
@true to indicate that the value of this option was successfully
changed.
The main use case for this method is to disallow hiding the columns
interactively when using the native header.
@since 3.1.3
@see DisableHidingColumns()
*/
bool EnableHidingColumns(bool enable = true);
/**
Returns the column ID of the specified column position.
*/
int GetColAt(int colPos) const;
/**
Returns the position of the specified column.
*/
int GetColPos(int colID) const;
/**
Sets the position of the specified column.
*/
void SetColPos(int colID, int newPos);
/**
Sets the positions of all columns at once.
This method takes an array containing the indices of the columns in
their display order, i.e. uses the same convention as
wxHeaderCtrl::SetColumnsOrder().
*/
void SetColumnsOrder(const wxArrayInt& order);
/**
Resets the position of the columns to the default.
*/
void ResetColPos();
/**
Returns the row ID of the specified row position.
@since 3.1.7
*/
int GetRowAt(int rowPos) const;
/**
Returns the position of the specified row.
@since 3.1.7
*/
int GetRowPos(int rowID) const;
/**
Sets the position of the specified row.
@since 3.1.7
*/
void SetRowPos(int rowID, int newPos);
/**
Sets the positions of all rows at once.
This method takes an array containing the indices of the rows in
their display order.
@since 3.1.7
*/
void SetRowsOrder(const wxArrayInt& order);
/**
Resets the position of the rows to the default.
@since 3.1.7
*/
void ResetRowPos();
///@}
/**
@name Cursor Movement
*/
///@{
/**
Returns the current grid cursor position.
If grid cursor doesn't have any valid position (e.g. if the grid is
completely empty and doesn't have any rows or columns), returns
@c wxGridNoCellCoords which has both row and columns set to @c -1.
@since 3.1.3
*/
const wxGridCellCoords& GetGridCursorCoords() const;
/**
Returns the current grid cell column position.
@see GetGridCursorCoords()
*/
int GetGridCursorCol() const;
/**
Returns the current grid cell row position.
@see GetGridCursorCoords()
*/
int GetGridCursorRow() const;
/**
Make the given cell current and ensure it is visible.
This method is equivalent to calling MakeCellVisible() and
SetGridCursor() and so, as with the latter, a @c wxEVT_GRID_SELECT_CELL
event is generated by it and the selected cell doesn't change if the
event is vetoed.
*/
void GoToCell(int row, int col);
/**
Make the given cell current and ensure it is visible.
This method is equivalent to calling MakeCellVisible() and
SetGridCursor() and so, as with the latter, a @c wxEVT_GRID_SELECT_CELL
event is generated by it and the selected cell doesn't change if the
event is vetoed.
*/
void GoToCell(const wxGridCellCoords& coords);
/**
Moves the grid cursor down by one row.
If a block of cells was previously selected it will expand if the
argument is @true or be cleared if the argument is @false.
*/
bool MoveCursorDown(bool expandSelection);
/**
Moves the grid cursor down in the current column such that it skips to
the beginning or end of a block of non-empty cells.
If a block of cells was previously selected it will expand if the
argument is @true or be cleared if the argument is @false.
*/
bool MoveCursorDownBlock(bool expandSelection);
/**
Moves the grid cursor left by one column.
If a block of cells was previously selected it will expand if the
argument is @true or be cleared if the argument is @false.
*/
bool MoveCursorLeft(bool expandSelection);
/**
Moves the grid cursor left in the current row such that it skips to the
beginning or end of a block of non-empty cells.
If a block of cells was previously selected it will expand if the
argument is @true or be cleared if the argument is @false.
*/
bool MoveCursorLeftBlock(bool expandSelection);
/**
Moves the grid cursor right by one column.
If a block of cells was previously selected it will expand if the
argument is @true or be cleared if the argument is @false.
*/
bool MoveCursorRight(bool expandSelection);
/**
Moves the grid cursor right in the current row such that it skips to
the beginning or end of a block of non-empty cells.
If a block of cells was previously selected it will expand if the
argument is @true or be cleared if the argument is @false.
*/
bool MoveCursorRightBlock(bool expandSelection);
/**
Moves the grid cursor up by one row.
If a block of cells was previously selected it will expand if the
argument is @true or be cleared if the argument is @false.
*/
bool MoveCursorUp(bool expandSelection);
/**
Moves the grid cursor up in the current column such that it skips to
the beginning or end of a block of non-empty cells.
If a block of cells was previously selected it will expand if the
argument is @true or be cleared if the argument is @false.
*/
bool MoveCursorUpBlock(bool expandSelection);
/**
Moves the grid cursor down by some number of rows so that the previous
bottom visible row becomes the top visible row.
*/
bool MovePageDown();
/**
Moves the grid cursor up by some number of rows so that the previous
top visible row becomes the bottom visible row.
*/
bool MovePageUp();
/**
Set the grid cursor to the specified cell.
The grid cursor indicates the current cell and can be moved by the user
using the arrow keys or the mouse.
Calling this function generates a @c wxEVT_GRID_SELECT_CELL event and
if the event handler vetoes this event, the cursor is not moved.
This function doesn't make the target call visible, use GoToCell() to
do this.
*/
void SetGridCursor(int row, int col);
/**
Set the grid cursor to the specified cell.
The grid cursor indicates the current cell and can be moved by the user
using the arrow keys or the mouse.
Calling this function generates a @c wxEVT_GRID_SELECT_CELL event and
if the event handler vetoes this event, the cursor is not moved.
This function doesn't make the target call visible, use GoToCell() to
do this.
*/
void SetGridCursor(const wxGridCellCoords& coords);
/**
Set the grid's behaviour when the user presses the TAB key.
Pressing the TAB key moves the grid cursor right in the current row, if
there is a cell at the right and, similarly, Shift-TAB moves the cursor
to the left in the current row if it's not in the first column.
What happens if the cursor can't be moved because it it's already at
the beginning or end of the row can be configured using this function,
see wxGrid::TabBehaviour documentation for the detailed description.
IF none of the standard behaviours is appropriate, you can always
handle @c wxEVT_GRID_TABBING event directly to implement a custom
TAB-handling logic.
@since 2.9.5
*/
void SetTabBehaviour(TabBehaviour behaviour);
///@}
/**
@name User Selection
*/
///@{
/**
Deselects all cells that are currently selected.
*/
void ClearSelection();
/**
Deselects a row of cells.
*/
void DeselectRow( int row );
/**
Deselects a column of cells.
*/
void DeselectCol( int col );
/**
Deselects a cell.
*/
void DeselectCell( int row, int col );
/**
Returns a range of grid selection blocks.
The returned range can be iterated over, e.g. with C++11 range-for loop:
@code
for ( const auto block: grid->GetSelectedBlocks() ) {
if ( block.Intersects(myBlock) )
break;
}
@endcode
Notice that the blocks returned by this method are not ordered in any
particular way and may overlap. For grids using rows or columns-only
selection modes, GetSelectedRowBlocks() or GetSelectedColBlocks() can
be more convenient, as they return ordered and non-overlapping blocks.
@since 3.1.4
*/
wxGridBlocks GetSelectedBlocks() const;
/**
Returns an ordered range of non-overlapping selected rows.
For the grids using wxGridSelectRows selection mode, returns the
possibly empty vector containing the coordinates of non-overlapping
selected row blocks in the natural order, i.e. from smallest to the
biggest row indices.
To see the difference between this method and GetSelectedBlocks(),
consider the case when the user selects rows 2..4 in the grid and then
also selects (using Ctrl/Shift keys) the rows 1..3. Iterating over the
result of GetSelectedBlocks() would yield two blocks directly
corresponding to the users selection, while this method returns a
vector with a single element corresponding to the rows 1..4.
This method returns empty vector for the other selection modes.
@see GetSelectedBlocks(), GetSelectedColBlocks()
@since 3.1.4
*/
wxGridBlockCoordsVector GetSelectedRowBlocks() const;
/**
Returns an ordered range of non-overlapping selected columns.
This method is symmetric to GetSelectedRowBlocks(), but is useful only
in wxGridSelectColumns selection mode.
@see GetSelectedBlocks()
@since 3.1.4
*/
wxGridBlockCoordsVector GetSelectedColBlocks() const;
/**
Returns an array of individually selected cells.
Notice that this array does @em not contain all the selected cells in
general as it doesn't include the cells selected as part of column, row
or block selection. You must use this method, GetSelectedCols(),
GetSelectedRows() and GetSelectionBlockTopLeft() and
GetSelectionBlockBottomRight() methods to obtain the entire selection
in general.
Please notice this behaviour is by design and is needed in order to
support grids of arbitrary size (when an entire column is selected in
a grid with a million of columns, we don't want to create an array with
a million of entries in this function, instead it returns an empty
array and GetSelectedCols() returns an array containing one element).
The function can be slow for the big grids, use GetSelectedBlocks()
in the new code.
*/
wxGridCellCoordsArray GetSelectedCells() const;
/**
Returns an array of selected columns.
Please notice that this method alone is not sufficient to find all the
selected columns as it contains only the columns which were
individually selected but not those being part of the block selection
or being selected in virtue of all of their cells being selected
individually, please see GetSelectedCells() for more details.
The function can be slow for the big grids, use GetSelectedBlocks()
in the new code.
*/
wxArrayInt GetSelectedCols() const;
/**
Returns an array of selected rows.
Please notice that this method alone is not sufficient to find all the
selected rows as it contains only the rows which were individually
selected but not those being part of the block selection or being
selected in virtue of all of their cells being selected individually,
please see GetSelectedCells() for more details.
The function can be slow for the big grids, use GetSelectedBlocks()
in the new code.
*/
wxArrayInt GetSelectedRows() const;
/**
Returns the colour used for drawing the selection background.
*/
wxColour GetSelectionBackground() const;
/**
Returns an array of the bottom right corners of blocks of selected
cells.
Please see GetSelectedCells() for more information about the selection
representation in wxGrid.
The function can be slow for the big grids, use GetSelectedBlocks()
in the new code.
@see GetSelectionBlockTopLeft()
*/
wxGridCellCoordsArray GetSelectionBlockBottomRight() const;
/**
Returns an array of the top left corners of blocks of selected cells.
Please see GetSelectedCells() for more information about the selection
representation in wxGrid.
The function can be slow for the big grids, use GetSelectedBlocks()
in the new code.
@see GetSelectionBlockBottomRight()
*/
wxGridCellCoordsArray GetSelectionBlockTopLeft() const;
/**
Returns the colour used for drawing the selection foreground.
*/
wxColour GetSelectionForeground() const;
/**
Returns the current selection mode.
@see SetSelectionMode().
*/
wxGridSelectionModes GetSelectionMode() const;
/**
Returns @true if the given cell is selected.
*/
bool IsInSelection(int row, int col) const;
/**
Returns @true if the given cell is selected.
*/
bool IsInSelection(const wxGridCellCoords& coords) const;
/**
Returns @true if there are currently any selected cells, rows, columns
or blocks.
*/
bool IsSelection() const;
/**
Selects all cells in the grid.
*/
void SelectAll();
/**
Selects a rectangular block of cells.
If @a addToSelected is @false then any existing selection will be
deselected; if @true the column will be added to the existing
selection.
*/
void SelectBlock(int topRow, int leftCol, int bottomRow, int rightCol,
bool addToSelected = false);
/**
Selects a rectangular block of cells.
If @a addToSelected is @false then any existing selection will be
deselected; if @true the column will be added to the existing
selection.
*/
void SelectBlock(const wxGridCellCoords& topLeft,
const wxGridCellCoords& bottomRight,
bool addToSelected = false);
/**
Selects the specified column.
If @a addToSelected is @false then any existing selection will be
deselected; if @true the column will be added to the existing
selection.
This method won't select anything if the current selection mode is
wxGridSelectRows.
*/
void SelectCol(int col, bool addToSelected = false);
/**
Selects the specified row.
If @a addToSelected is @false then any existing selection will be
deselected; if @true the row will be added to the existing selection.
This method won't select anything if the current selection mode is
wxGridSelectColumns.
*/
void SelectRow(int row, bool addToSelected = false);
/**
Set the colour to be used for drawing the selection background.
*/
void SetSelectionBackground(const wxColour& c);
/**
Set the colour to be used for drawing the selection foreground.
*/
void SetSelectionForeground(const wxColour& c);
/**
Set the selection behaviour of the grid.
The existing selection is converted to conform to the new mode if
possible and discarded otherwise (e.g. any individual selected cells
are deselected if the new mode allows only the selection of the entire
rows or columns).
*/
void SetSelectionMode(wxGridSelectionModes selmode);
///@}
/**
@name Scrolling
*/
///@{
/**
Returns the number of pixels per horizontal scroll increment.
The default is 15.
@see GetScrollLineY(), SetScrollLineX(), SetScrollLineY()
*/
int GetScrollLineX() const;
/**
Returns the number of pixels per vertical scroll increment.
The default is 15.
@see GetScrollLineX(), SetScrollLineX(), SetScrollLineY()
*/
int GetScrollLineY() const;
/**
Returns @true if a cell is either entirely or at least partially
visible in the grid window.
By default, the cell must be entirely visible for this function to
return @true but if @a wholeCellVisible is @false, the function returns
@true even if the cell is only partially visible.
*/
bool IsVisible(int row, int col, bool wholeCellVisible = true) const;
/**
Returns @true if a cell is either entirely or at least partially
visible in the grid window.
By default, the cell must be entirely visible for this function to
return @true but if @a wholeCellVisible is @false, the function returns
@true even if the cell is only partially visible.
*/
bool IsVisible(const wxGridCellCoords& coords,
bool wholeCellVisible = true) const;
/**
Brings the specified cell into the visible grid cell area with minimal
scrolling.
Does nothing if the cell is already visible.
*/
void MakeCellVisible(int row, int col);
/**
Brings the specified cell into the visible grid cell area with minimal
scrolling.
Does nothing if the cell is already visible.
*/
void MakeCellVisible(const wxGridCellCoords& coords);
/**
Returns the topmost row of the current visible area.
Returns -1 if the grid doesn't have any rows.
*/
int GetFirstFullyVisibleRow() const;
/**
Returns the leftmost column of the current visible area.
Returns -1 if the grid doesn't have any columns.
*/
int GetFirstFullyVisibleColumn() const;
/**
Sets the number of pixels per horizontal scroll increment.
The default is 15.
@see GetScrollLineX(), GetScrollLineY(), SetScrollLineY()
*/
void SetScrollLineX(int x);
/**
Sets the number of pixels per vertical scroll increment.
The default is 15.
@see GetScrollLineX(), GetScrollLineY(), SetScrollLineX()
*/
void SetScrollLineY(int y);
///@}
/**
@name Cell and Device Coordinate Translation
*/
///@{
/**
Convert grid cell coordinates to grid window pixel coordinates.
This function returns the rectangle that encloses the block of cells
limited by @a topLeft and @a bottomRight cell in device coords and
clipped to the client size of the grid window.
@since 3.1.3 Parameter @a gridWindow has been added.
@see CellToRect()
*/
wxRect BlockToDeviceRect(const wxGridCellCoords& topLeft,
const wxGridCellCoords& bottomRight,
const wxGridWindow *gridWindow = NULL) const;
/**
Return the rectangle corresponding to the grid cell's size and position
in logical coordinates.
@see BlockToDeviceRect()
*/
wxRect CellToRect(int row, int col) const;
/**
Return the rectangle corresponding to the grid cell's size and position
in logical coordinates.
@see BlockToDeviceRect()
*/
wxRect CellToRect(const wxGridCellCoords& coords) const;
/**
Returns the grid window that contains the cell.
In a grid without frozen rows or columns (see FreezeTo()), this will
always return the same window as GetGridWindow(), however if some parts
of the grid are frozen, this function returns the window containing the
given cell.
@since 3.1.3
*/
wxGridWindow* CellToGridWindow( int row, int col ) const;
/// @overload
wxGridWindow* CellToGridWindow( const wxGridCellCoords& coords ) const;
/**
Returns the grid window that includes the input coordinates.
@since 3.1.3
*/
wxGridWindow* DevicePosToGridWindow(wxPoint pos) const;
/// @overload
wxGridWindow* DevicePosToGridWindow(int x, int y) const;
/**
Returns the grid window's offset from the grid starting position taking
into account the frozen cells.
If there are no frozen cells, returns (0, 0).
@since 3.1.3
@see FreezeTo()
*/
void GetGridWindowOffset(const wxGridWindow *gridWindow, int &x, int &y) const;
/// @overload
wxPoint GetGridWindowOffset(const wxGridWindow *gridWindow) const;
/**
Translates the device coordinates to the logical ones, taking into
account the grid window type.
@since 3.1.3
@see wxScrolled::CalcUnscrolledPosition()
*/
void CalcGridWindowUnscrolledPosition(int x, int y,
int *xx, int *yy,
const wxGridWindow *gridWindow) const;
/// @overload
wxPoint CalcGridWindowUnscrolledPosition(const wxPoint& pt,
const wxGridWindow *gridWindow) const;
/**
Translates the logical coordinates to the device ones, taking into
account the grid window type.
@since 3.1.3
@see wxScrolled::CalcScrolledPosition()
*/
void CalcGridWindowScrolledPosition(int x, int y,
int *xx, int *yy,
const wxGridWindow *gridWindow) const;
/// @overload
wxPoint CalcGridWindowScrolledPosition(const wxPoint& pt,
const wxGridWindow *gridWindow) const;
/**
Returns the column at the given pixel position depending on the window.
@param x
The x position to evaluate.
@param clipToMinMax
If @true, rather than returning @c wxNOT_FOUND, it returns either
the first or last column depending on whether @a x is too far to
the left or right respectively.
@param gridWindow
The associated grid window that limits the search (note that this
parameter is only available since wxWidgets 3.1.3).
If @a gridWindow is @NULL, it will consider all the cells, no matter
which grid they belong to.
@return
The column index or @c wxNOT_FOUND.
*/
int XToCol(int x, bool clipToMinMax = false, wxGridWindow *gridWindow = NULL) const;
/**
Returns the column whose right hand edge is close to the given logical
@a x position.
If no column edge is near to this position @c wxNOT_FOUND is returned.
*/
int XToEdgeOfCol(int x) const;
/**
Translates logical pixel coordinates to the grid cell coordinates.
Notice that this function expects logical coordinates on input so if
you use this function in a mouse event handler you need to translate
the mouse position, which is expressed in device coordinates, to
logical ones.
The parameter @a gridWindow is new since wxWidgets 3.1.3. If it is
specified, i.e. non-@NULL, the coordinates must be in this window
coordinate system and only the cells of this window are considered,
i.e. the function returns @c wxNOT_FOUND if the coordinates are out of
bounds.
If @a gridWindow is @NULL, coordinates are relative to the main grid
window and all cells are considered.
@see XToCol(), YToRow()
*/
wxGridCellCoords XYToCell(int x, int y, wxGridWindow *gridWindow = NULL) const;
/// @overload
wxGridCellCoords XYToCell(const wxPoint& pos, wxGridWindow *gridWindow = NULL) const;
// XYToCell(int, int, wxGridCellCoords&) overload is intentionally
// undocumented, using it is ugly and non-const reference parameters are
// not used in wxWidgets API
/**
Returns the row whose bottom edge is close to the given logical @a y
position.
If no row edge is near to this position @c wxNOT_FOUND is returned.
*/
int YToEdgeOfRow(int y) const;
/**
Returns the grid row that corresponds to the logical @a y coordinate.
The parameter @a gridWindow is new since wxWidgets 3.1.3. If it is
specified, i.e. non-@NULL, only the cells of this window are
considered, i.e. the function returns @c wxNOT_FOUND if @a y is out of
bounds.
If @a gridWindow is @NULL, the function returns @c wxNOT_FOUND only if
there is no row at all at the @a y position.
*/
int YToRow(int y, bool clipToMinMax = false, wxGridWindow *gridWindow = NULL) const;
///@}
/**
@name Miscellaneous Functions
*/
///@{
/**
Appends one or more new columns to the right of the grid.
The @a updateLabels argument is not used at present. If you are using a
derived grid table class you will need to override
wxGridTableBase::AppendCols(). See InsertCols() for further
information.
@return @true on success or @false if appending columns failed.
*/
bool AppendCols(int numCols = 1, bool updateLabels = true);
/**
Appends one or more new rows to the bottom of the grid.
The @a updateLabels argument is not used at present. If you are using a
derived grid table class you will need to override
wxGridTableBase::AppendRows(). See InsertRows() for further
information.
@return @true on success or @false if appending rows failed.
*/
bool AppendRows(int numRows = 1, bool updateLabels = true);
/**
Return @true if the horizontal grid lines stop at the last column
boundary or @false if they continue to the end of the window.
The default is to clip grid lines.
@see ClipHorzGridLines(), AreVertGridLinesClipped()
*/
bool AreHorzGridLinesClipped() const;
/**
Return @true if the vertical grid lines stop at the last row
boundary or @false if they continue to the end of the window.
The default is to clip grid lines.
@see ClipVertGridLines(), AreHorzGridLinesClipped()
*/
bool AreVertGridLinesClipped() const;
/**
Increments the grid's batch count.
When the count is greater than zero repainting of the grid is
suppressed. Each call to BeginBatch must be matched by a later call to
EndBatch(). Code that does a lot of grid modification can be enclosed
between BeginBatch() and EndBatch() calls to avoid screen flicker. The
final EndBatch() call will cause the grid to be repainted.
Notice that you should use wxGridUpdateLocker which ensures that there
is always a matching EndBatch() call for this BeginBatch() if possible
instead of calling this method directly.
*/
void BeginBatch();
/**
Clears all data in the underlying grid table and repaints the grid.
The table is not deleted by this function. If you are using a derived
table class then you need to override wxGridTableBase::Clear() for this
function to have any effect.
*/
void ClearGrid();
/**
Change whether the horizontal grid lines are clipped by the end of the
last column.
By default the grid lines are not drawn beyond the end of the last
column but after calling this function with @a clip set to @false they
will be drawn across the entire grid window.
@see AreHorzGridLinesClipped(), ClipVertGridLines()
*/
void ClipHorzGridLines(bool clip);
/**
Change whether the vertical grid lines are clipped by the end of the
last row.
By default the grid lines are not drawn beyond the end of the last
row but after calling this function with @a clip set to @false they
will be drawn across the entire grid window.
@see AreVertGridLinesClipped(), ClipHorzGridLines()
*/
void ClipVertGridLines(bool clip);
/**
Deletes one or more columns from a grid starting at the specified
position.
The @a updateLabels argument is not used at present. If you are using a
derived grid table class you will need to override
wxGridTableBase::DeleteCols(). See InsertCols() for further
information.
@return @true on success or @false if deleting columns failed.
*/
bool DeleteCols(int pos = 0, int numCols = 1, bool updateLabels = true);
/**
Deletes one or more rows from a grid starting at the specified
position.
The @a updateLabels argument is not used at present. If you are using a
derived grid table class you will need to override
wxGridTableBase::DeleteRows(). See InsertRows() for further
information.
@return @true on success or @false if deleting rows failed.
*/
bool DeleteRows(int pos = 0, int numRows = 1, bool updateLabels = true);
/**
Sets or resets the frozen columns and rows.
@param row
The number of rows to freeze, 0 means to unfreeze all rows.
@param col
The number of columns to freeze, 0 means to unfreeze all columns.
@return @true on success or @false if it failed.
Note that this method doesn't do anything, and returns @false, if any
of the following conditions are true:
- Either @a row or @a col are out of range
- Size of the frozen area would be bigger than the current viewing area
- There are any merged cells in the area to be frozen
- Grid uses a native header control (see UseNativeColHeader())
(some of these limitations could be lifted in the future).
@since 3.1.3
*/
bool FreezeTo(unsigned row, unsigned col);
/// @overload
bool FreezeTo(const wxGridCellCoords& coords);
/**
Decrements the grid's batch count.
When the count is greater than zero repainting of the grid is
suppressed. Each previous call to BeginBatch() must be matched by a
later call to EndBatch(). Code that does a lot of grid modification can
be enclosed between BeginBatch() and EndBatch() calls to avoid screen
flicker. The final EndBatch() will cause the grid to be repainted.
@see wxGridUpdateLocker
*/
void EndBatch();
/**
Overridden wxWindow method.
*/
virtual void Fit();
/**
Causes immediate repainting of the grid.
Use this instead of the usual wxWindow::Refresh().
*/
void ForceRefresh();
/**
Returns the number of times that BeginBatch() has been called without
(yet) matching calls to EndBatch(). While the grid's batch count is
greater than zero the display will not be updated.
*/
int GetBatchCount() const;
/**
Returns the total number of grid columns.
This is the same as the number of columns in the underlying grid table.
*/
int GetNumberCols() const;
/**
Returns the total number of grid rows.
This is the same as the number of rows in the underlying grid table.
*/
int GetNumberRows() const;
/**
Returns the number of frozen grid columns.
If there are no frozen columns, returns 0.
@since 3.1.3
@see FreezeTo()
*/
int GetNumberFrozenCols() const;
/**
Returns the number of frozen grid rows.
If there are no frozen rows, returns 0.
@since 3.1.3
@see FreezeTo()
*/
int GetNumberFrozenRows() const;
/**
Returns the attribute for the given cell creating one if necessary.
If the cell already has an attribute, it is returned. Otherwise a new
attribute is created, associated with the cell and returned. In any
case the caller must call DecRef() on the returned pointer.
Prefer to use GetOrCreateCellAttrPtr() to avoid the need to call
DecRef() on the returned pointer.
This function may only be called if CanHaveAttributes() returns @true.
*/
wxGridCellAttr *GetOrCreateCellAttr(int row, int col) const;
/**
Returns the attribute for the given cell creating one if necessary.
This method is identical to GetOrCreateCellAttr(), but returns a smart
pointer, which frees the caller from the need to call DecRef()
manually.
@since 3.1.4
*/
wxGridCellAttrPtr GetOrCreateCellAttrPtr(int row, int col) const;
/**
Returns a base pointer to the current table object.
The returned pointer is still owned by the grid.
*/
wxGridTableBase *GetTable() const;
/**
Inserts one or more new columns into a grid with the first new column
at the specified position.
Notice that inserting the columns in the grid requires grid table
cooperation: when this method is called, grid object begins by
requesting the underlying grid table to insert new columns. If this is
successful the table notifies the grid and the grid updates the
display. For a default grid (one where you have called CreateGrid())
this process is automatic. If you are using a custom grid table
(specified with SetTable() or AssignTable()) then you must override
wxGridTableBase::InsertCols() in your derived table class.
@param pos
The position which the first newly inserted column will have.
@param numCols
The number of columns to insert.
@param updateLabels
Currently not used.
@return
@true if the columns were successfully inserted, @false if an error
occurred (most likely the table couldn't be updated).
*/
bool InsertCols(int pos = 0, int numCols = 1, bool updateLabels = true);
/**
Inserts one or more new rows into a grid with the first new row at the
specified position.
Notice that you must implement wxGridTableBase::InsertRows() if you use
a grid with a custom table, please see InsertCols() for more
information.
@param pos
The position which the first newly inserted row will have.
@param numRows
The number of rows to insert.
@param updateLabels
Currently not used.
@return
@true if the rows were successfully inserted, @false if an error
occurred (most likely the table couldn't be updated).
*/
bool InsertRows(int pos = 0, int numRows = 1, bool updateLabels = true);
/**
Invalidates the cached attribute for the given cell.
For efficiency reasons, wxGrid may cache the recently used attributes
(currently it caches only the single most recently used one, in fact)
which can result in the cell appearance not being refreshed even when
the attribute returned by your custom wxGridCellAttrProvider-derived
class has changed. To force the grid to refresh the cell attribute,
this function may be used. Notice that calling it will not result in
actually redrawing the cell, you still need to call
wxWindow::RefreshRect() to invalidate the area occupied by the cell in
the window to do this. Also note that you don't need to call this
function if you store the attributes in wxGrid itself, i.e. use its
SetAttr() and similar methods, it is only useful when using a separate
custom attributes provider.
@param row
The row of the cell whose attribute needs to be queried again.
@param col
The column of the cell whose attribute needs to be queried again.
@since 2.9.2
*/
void RefreshAttr(int row, int col);
/**
Redraw all the cells in the given block.
Refresh the block of cells with the given corners.
If the bottom right corner coordinates are invalid, i.e. set to `-1`,
the top left corner coordinates are used for it, i.e. just a single
cell is refreshed. If the top left corner coordinates are invalid as
well, the function simply returns without doing anything. Note,
however, that both coordinates need to be valid or invalid
simultaneously, i.e. setting the top row to `-1` but using a valid
value for the left column is unsupported and would result in an
assertion failure.
@since 3.1.3
*/
void RefreshBlock(const wxGridCellCoords& topLeft,
const wxGridCellCoords& bottomRight);
/// @overload
void RefreshBlock(int topRow, int leftCol,
int bottomRow, int rightCol);
/**
Draws part or all of a wxGrid on a wxDC for printing or display.
Pagination can be accomplished by using sequential Render() calls
with appropriate values in wxGridCellCoords topLeft and bottomRight.
@param dc
The wxDC to be drawn on.
@param pos
The position on the wxDC where rendering should begin. If not
specified drawing will begin at the wxDC MaxX() and MaxY().
@param size
The size of the area on the wxDC that the rendered wxGrid should
occupy. If not specified the drawing will be scaled to fit the
available dc width or height. The wxGrid's aspect ratio is
maintained whether or not size is specified.
@param topLeft
The top left cell of the block to be drawn. Defaults to ( 0, 0 ).
@param bottomRight
The bottom right cell of the block to be drawn. Defaults to row and
column counts.
@param style
A combination of values from wxGridRenderStyle.
@since 2.9.4
*/
void Render( wxDC& dc,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
const wxGridCellCoords& topLeft = wxGridCellCoords( -1, -1 ),
const wxGridCellCoords& bottomRight = wxGridCellCoords( -1, -1 ),
int style = wxGRID_DRAW_DEFAULT );
/**
Sets the cell attributes for the specified cell.
The grid takes ownership of the attribute pointer.
See the wxGridCellAttr class for more information about controlling
cell attributes.
*/
void SetAttr(int row, int col, wxGridCellAttr *attr);
/**
Sets the cell attributes for all cells in the specified column.
For more information about controlling grid cell attributes see the
wxGridCellAttr cell attribute class and the @ref overview_grid.
*/
void SetColAttr(int col, wxGridCellAttr* attr);
/**
Sets the extra margins used around the grid area.
A grid may occupy more space than needed for its data display and
this function allows setting how big this extra space is
*/
void SetMargins(int extraWidth, int extraHeight);
/**
Sets the cell attributes for all cells in the specified row.
The grid takes ownership of the attribute pointer.
See the wxGridCellAttr class for more information about controlling
cell attributes.
*/
void SetRowAttr(int row, wxGridCellAttr* attr);
/**
Returns an array of row labels within the given region.
*/
wxArrayInt CalcRowLabelsExposed( const wxRegion& reg,
wxGridWindow *gridWindow = NULL) const;
/**
Returns an array of column labels within the given region.
*/
wxArrayInt CalcColLabelsExposed( const wxRegion& reg,
wxGridWindow *gridWindow = NULL) const;
/**
Returns an array of (visible) cells within the given region.
*/
wxGridCellCoordsArray CalcCellsExposed( const wxRegion& reg,
wxGridWindow *gridWindow = NULL) const;
///@}
/**
@name Sorting support.
wxGrid doesn't provide any support for sorting the data but it does
generate events allowing the user code to sort it and supports
displaying the sort indicator in the column used for sorting.
To use wxGrid sorting support you need to handle wxEVT_GRID_COL_SORT
event (and not veto it) and resort the data displayed in the grid. The
grid will automatically update the sorting indicator on the column
which was clicked.
You can also call the functions in this section directly to update the
sorting indicator. Once again, they don't do anything with the grid
data, it remains your responsibility to actually sort it appropriately.
*/
///@{
/**
Return the column in which the sorting indicator is currently
displayed.
Returns @c wxNOT_FOUND if sorting indicator is not currently displayed
at all.
@see SetSortingColumn()
*/
int GetSortingColumn() const;
/**
Return @true if this column is currently used for sorting.
@see GetSortingColumn()
*/
bool IsSortingBy(int col) const;
/**
Return @true if the current sorting order is ascending or @false if it
is descending.
It only makes sense to call this function if GetSortingColumn() returns
a valid column index and not @c wxNOT_FOUND.
@see SetSortingColumn()
*/
bool IsSortOrderAscending() const;
/**
Set the column to display the sorting indicator in and its direction.
@param col
The column to display the sorting indicator in or @c wxNOT_FOUND to
remove any currently displayed sorting indicator.
@param ascending
If @true, display the ascending sort indicator, otherwise display
the descending sort indicator.
@see GetSortingColumn(), IsSortOrderAscending()
*/
void SetSortingColumn(int col, bool ascending = true);
/**
Remove any currently shown sorting indicator.
This is equivalent to calling SetSortingColumn() with @c wxNOT_FOUND
first argument.
*/
void UnsetSortingColumn();
///@}
/**
@name Accessors for component windows.
Return the various child windows of wxGrid.
wxGrid is an empty parent window for at least 4 children representing
the column labels window (top), the row labels window (left), the
corner window (top left) and the main grid window. It may be necessary
to use these individual windows and not the wxGrid window itself if you
need to handle events for them (using wxEvtHandler::Bind()) or do
something else requiring the use of the correct window pointer. Notice
that you should not, however, change these windows (e.g. reposition
them or draw over them) because they are managed by wxGrid itself.
When parts of the grid are frozen using FreezeTo() function, the main
grid window contains only the unfrozen part and additional windows are
used for the parts containing frozen rows and/or columns and the corner
window if both some rows and some columns are frozen.
*/
///@{
/**
Return the main grid window containing the grid cells.
This window is always shown.
*/
wxWindow *GetGridWindow() const;
/**
Return the corner grid window containing frozen cells.
This window is shown only when there are frozen rows and columns.
@since 3.1.3
*/
wxWindow* GetFrozenCornerGridWindow() const;
/**
Return the rows grid window containing row frozen cells.
This window is shown only when there are frozen rows.
@since 3.1.3
*/
wxWindow* GetFrozenRowGridWindow() const;
/**
Return the columns grid window containing column frozen cells.
This window is shown only when there are frozen columns.
@since 3.1.3
*/
wxWindow* GetFrozenColGridWindow() const;
/**
Return the row labels window.
This window is not shown if the row labels were hidden using
HideRowLabels().
*/
wxWindow *GetGridRowLabelWindow() const;
/**
Return the column labels window.
This window is not shown if the columns labels were hidden using
HideColLabels().
Depending on whether UseNativeColHeader() was called or not this can be
either a wxHeaderCtrl or a plain wxWindow. This function returns a valid
window pointer in either case but in the former case you can also use
GetGridColHeader() to access it if you need wxHeaderCtrl-specific
functionality.
*/
wxWindow *GetGridColLabelWindow() const;
/**
Return the window in the top left grid corner.
This window is shown only of both columns and row labels are shown and
normally doesn't contain anything. Clicking on it is handled by wxGrid
however and can be used to select the entire grid.
*/
wxWindow *GetGridCornerLabelWindow() const;
/**
Return the header control used for column labels display.
This function can only be called if UseNativeColHeader() had been
called.
@see IsUsingNativeHeader()
*/
wxHeaderCtrl *GetGridColHeader() const;
/**
Return true if native header control is currently being used.
@since 3.1.4
*/
bool IsUsingNativeHeader() const;
///@}
virtual void DrawCellHighlight( wxDC& dc, const wxGridCellAttr *attr );
virtual void DrawRowLabels( wxDC& dc, const wxArrayInt& rows );
virtual void DrawRowLabel( wxDC& dc, int row );
virtual void DrawColLabels( wxDC& dc, const wxArrayInt& cols );
virtual void DrawColLabel( wxDC& dc, int col );
virtual void DrawCornerLabel(wxDC& dc);
void DrawTextRectangle( wxDC& dc, const wxString& text, const wxRect& rect,
int horizontalAlignment = wxALIGN_LEFT,
int verticalAlignment = wxALIGN_TOP,
int textOrientation = wxHORIZONTAL ) const;
void DrawTextRectangle( wxDC& dc, const wxArrayString& lines, const wxRect& rect,
int horizontalAlignment = wxALIGN_LEFT,
int verticalAlignment = wxALIGN_TOP,
int textOrientation = wxHORIZONTAL ) const;
wxColour GetCellHighlightColour() const;
int GetCellHighlightPenWidth() const;
int GetCellHighlightROPenWidth() const;
void SetCellHighlightColour( const wxColour& );
void SetCellHighlightPenWidth(int width);
void SetCellHighlightROPenWidth(int width);
void SetGridFrozenBorderColour( const wxColour& );
void SetGridFrozenBorderPenWidth( int width );
protected:
/**
Returns @true if this grid has support for cell attributes.
The grid supports attributes if it has the associated table which, in
turn, has attributes support, i.e. wxGridTableBase::CanHaveAttributes()
returns @true.
*/
bool CanHaveAttributes() const;
/**
Get the minimal width of the given column/row.
The value returned by this function may be different from that returned
by GetColMinimalAcceptableWidth() if SetColMinimalWidth() had been
called for this column.
*/
int GetColMinimalWidth(int col) const;
/**
Returns the coordinate of the right border specified column.
*/
int GetColRight(int col) const;
/**
Returns the coordinate of the left border specified column.
*/
int GetColLeft(int col) const;
/**
Returns the minimal size for the given column.
The value returned by this function may be different from that returned
by GetRowMinimalAcceptableHeight() if SetRowMinimalHeight() had been
called for this row.
*/
int GetRowMinimalHeight(int col) const;
};
/**
@class wxGridUpdateLocker
This small class can be used to prevent wxGrid from redrawing during its
lifetime by calling wxGrid::BeginBatch() in its constructor and
wxGrid::EndBatch() in its destructor. It is typically used in a function
performing several operations with a grid which would otherwise result in
flicker. For example:
@code
void MyFrame::Foo()
{
m_grid = new wxGrid(this, ...);
wxGridUpdateLocker noUpdates(m_grid);
m_grid-AppendColumn();
// ... many other operations with m_grid ...
m_grid-AppendRow();
// destructor called, grid refreshed
}
@endcode
Using this class is easier and safer than calling wxGrid::BeginBatch() and
wxGrid::EndBatch() because you don't risk missing the call the latter (due
to an exception for example).
@library{wxcore}
@category{grid}
*/
class wxGridUpdateLocker
{
public:
/**
Creates an object preventing the updates of the specified @a grid. The
parameter could be @NULL in which case nothing is done. If @a grid is
non-@NULL then the grid must exist for longer than this
wxGridUpdateLocker object itself.
The default constructor could be followed by a call to Create() to set
the grid object later.
*/
wxGridUpdateLocker(wxGrid* grid = NULL);
/**
Destructor reenables updates for the grid this object is associated
with.
*/
~wxGridUpdateLocker();
/**
This method can be called if the object had been constructed using the
default constructor. It must not be called more than once.
*/
void Create(wxGrid* grid);
};
/**
@class wxGridEvent
This event class contains information about various grid events.
Notice that all grid event table macros are available in two versions:
@c EVT_GRID_XXX and @c EVT_GRID_CMD_XXX. The only difference between the
two is that the former doesn't allow to specify the grid window identifier
and so takes a single parameter, the event handler, but is not suitable if
there is more than one grid control in the window where the event table is
used (as it would catch the events from all the grids). The version with @c
CMD takes the id as first argument and the event handler as the second one
and so can be used with multiple grids as well. Otherwise there are no
difference between the two and only the versions without the id are
documented below for brevity.
@beginEventTable{wxGridEvent}
@event{EVT_GRID_CELL_CHANGING(func)}
The user is about to change the data in a cell. The new cell value as
string is available from GetString() event object method. This event
can be vetoed if the change is not allowed.
Processes a @c wxEVT_GRID_CELL_CHANGING event type.
@event{EVT_GRID_CELL_CHANGED(func)}
The user changed the data in a cell. The old cell value as string is
available from GetString() event object method. Notice that vetoing
this event still works for backwards compatibility reasons but any new
code should only veto EVT_GRID_CELL_CHANGING event and not this one.
Processes a @c wxEVT_GRID_CELL_CHANGED event type.
@event{EVT_GRID_CELL_LEFT_CLICK(func)}
The user clicked a cell with the left mouse button. Processes a
@c wxEVT_GRID_CELL_LEFT_CLICK event type.
@event{EVT_GRID_CELL_LEFT_DCLICK(func)}
The user double-clicked a cell with the left mouse button. Processes a
@c wxEVT_GRID_CELL_LEFT_DCLICK event type.
@event{EVT_GRID_CELL_RIGHT_CLICK(func)}
The user clicked a cell with the right mouse button. Processes a
@c wxEVT_GRID_CELL_RIGHT_CLICK event type.
@event{EVT_GRID_CELL_RIGHT_DCLICK(func)}
The user double-clicked a cell with the right mouse button. Processes a
@c wxEVT_GRID_CELL_RIGHT_DCLICK event type.
@event{EVT_GRID_EDITOR_HIDDEN(func)}
The editor for a cell was hidden. Processes a
@c wxEVT_GRID_EDITOR_HIDDEN event type.
@event{EVT_GRID_EDITOR_SHOWN(func)}
The editor for a cell was shown. Processes a
@c wxEVT_GRID_EDITOR_SHOWN event type.
@event{EVT_GRID_LABEL_LEFT_CLICK(func)}
The user clicked a label with the left mouse button. Processes a
@c wxEVT_GRID_LABEL_LEFT_CLICK event type.
@event{EVT_GRID_LABEL_LEFT_DCLICK(func)}
The user double-clicked a label with the left mouse button. Processes a
@c wxEVT_GRID_LABEL_LEFT_DCLICK event type.
@event{EVT_GRID_LABEL_RIGHT_CLICK(func)}
The user clicked a label with the right mouse button. Processes a
@c wxEVT_GRID_LABEL_RIGHT_CLICK event type.
@event{EVT_GRID_LABEL_RIGHT_DCLICK(func)}
The user double-clicked a label with the right mouse button. Processes
a @c wxEVT_GRID_LABEL_RIGHT_DCLICK event type.
@event{EVT_GRID_SELECT_CELL(func)}
The given cell is about to be made current, either by user or by the
program via a call to wxGrid::SetGridCursor() or wxGrid::GoToCell().
The event can be vetoed to prevent this from happening and
wxGrid::GetGridCursorCoords() still returns the previous current cell
coordinates during the event handler execution, while the new ones are
available via the event object GetRow() and GetCol() functions.
Processes a @c wxEVT_GRID_SELECT_CELL event type.
@event{EVT_GRID_ROW_MOVE(func)}
The user tries to change the order of the rows in the grid by
dragging the row specified by GetRow(). This event can be vetoed to
either prevent the user from reordering the row change completely
(but notice that if you don't want to allow it at all, you simply
shouldn't call wxGrid::EnableDragRowMove() in the first place), vetoed
but handled in some way in the handler, e.g. by really moving the
row to the new position at the associated table level, or allowed to
proceed in which case wxGrid::SetRowPos() is used to reorder the
rows display order without affecting the use of the row indices
otherwise.
This event macro corresponds to @c wxEVT_GRID_ROW_MOVE event type.
It is only available since wxWidgets 3.1.7.
@event{EVT_GRID_COL_MOVE(func)}
The user tries to change the order of the columns in the grid by
dragging the column specified by GetCol(). This event can be vetoed to
either prevent the user from reordering the column change completely
(but notice that if you don't want to allow it at all, you simply
shouldn't call wxGrid::EnableDragColMove() in the first place), vetoed
but handled in some way in the handler, e.g. by really moving the
column to the new position at the associated table level, or allowed to
proceed in which case wxGrid::SetColPos() is used to reorder the
columns display order without affecting the use of the column indices
otherwise.
This event macro corresponds to @c wxEVT_GRID_COL_MOVE event type.
@event{EVT_GRID_COL_SORT(func)}
This event is generated when a column is clicked by the user and its
name is explained by the fact that the custom reaction to a click on a
column is to sort the grid contents by this column. However the grid
itself has no special support for sorting and it's up to the handler of
this event to update the associated table. But if the event is handled
(and not vetoed) the grid supposes that the table was indeed resorted
and updates the column to indicate the new sort order and refreshes
itself.
This event macro corresponds to @c wxEVT_GRID_COL_SORT event type.
@event{EVT_GRID_TABBING(func)}
This event is generated when the user presses TAB or Shift-TAB in the
grid. It can be used to customize the simple default TAB handling
logic, e.g. to go to the next non-empty cell instead of just the next
cell. See also wxGrid::SetTabBehaviour(). This event is new since
wxWidgets 2.9.5.
@endEventTable
@library{wxcore}
@category{grid,events}
*/
class wxGridEvent : public wxNotifyEvent
{
public:
/**
Default constructor.
*/
wxGridEvent();
/**
Constructor for initializing all event attributes.
*/
wxGridEvent(int id, wxEventType type, wxObject* obj,
int row = -1, int col = -1, int x = -1, int y = -1,
bool sel = true, const wxKeyboardState& kbd = wxKeyboardState());
/**
Returns @true if the Alt key was down at the time of the event.
*/
bool AltDown() const;
/**
Returns @true if the Control key was down at the time of the event.
*/
bool ControlDown() const;
/**
Column at which the event occurred.
Notice that for a @c wxEVT_GRID_SELECT_CELL event this column is the
column of the newly selected cell while the previously selected cell
can be retrieved using wxGrid::GetGridCursorCol().
*/
int GetCol() const;
/**
Position in pixels at which the event occurred.
*/
wxPoint GetPosition() const;
/**
Row at which the event occurred.
Notice that for a @c wxEVT_GRID_SELECT_CELL event this row is the row
of the newly selected cell while the previously selected cell can be
retrieved using wxGrid::GetGridCursorRow().
*/
int GetRow() const;
/**
Returns @true if the Meta key was down at the time of the event.
*/
bool MetaDown() const;
/**
Returns @true if the user is selecting grid cells, or @false if
deselecting.
*/
bool Selecting() const;
/**
Returns @true if the Shift key was down at the time of the event.
*/
bool ShiftDown() const;
};
/**
@class wxGridSizeEvent
This event class contains information about a row/column resize event.
@beginEventTable{wxGridSizeEvent}
@event{EVT_GRID_CMD_COL_SIZE(id, func)}
The user resized a column, corresponds to @c wxEVT_GRID_COL_SIZE event
type.
@event{EVT_GRID_CMD_ROW_SIZE(id, func)}
The user resized a row, corresponds to @c wxEVT_GRID_ROW_SIZE event
type.
@event{EVT_GRID_ROW_AUTO_SIZE(func)}
This event is sent when a row must be resized to its best size, e.g.
when the user double clicks the row divider. The default
implementation simply resizes the row to fit the row label (but
not its contents as this could be too slow for big grids). This macro
corresponds to @c wxEVT_GRID_ROW_AUTO_SIZE event type and is new since
wxWidgets 3.1.7.
@event{EVT_GRID_COL_SIZE(func)}
Same as EVT_GRID_CMD_COL_SIZE() but uses `wxID_ANY` id.
@event{EVT_GRID_COL_AUTO_SIZE(func)}
This event is sent when a column must be resized to its best size, e.g.
when the user double clicks the column divider. The default
implementation simply resizes the column to fit the column label (but
not its contents as this could be too slow for big grids). This macro
corresponds to @c wxEVT_GRID_COL_AUTO_SIZE event type and is new since
wxWidgets 2.9.5.
@event{EVT_GRID_ROW_SIZE(func)}
Same as EVT_GRID_CMD_ROW_SIZE() but uses `wxID_ANY` id.
@endEventTable
@library{wxcore}
@category{grid,events}
*/
class wxGridSizeEvent : public wxNotifyEvent
{
public:
/**
Default constructor.
*/
wxGridSizeEvent();
/**
Constructor for initializing all event attributes.
*/
wxGridSizeEvent(int id, wxEventType type, wxObject* obj,
int rowOrCol = -1, int x = -1, int y = -1,
const wxKeyboardState& kbd = wxKeyboardState());
/**
Returns @true if the Alt key was down at the time of the event.
*/
bool AltDown() const;
/**
Returns @true if the Control key was down at the time of the event.
*/
bool ControlDown() const;
/**
Position in pixels at which the event occurred.
*/
wxPoint GetPosition() const;
/**
Row or column at that was resized.
*/
int GetRowOrCol() const;
/**
Returns @true if the Meta key was down at the time of the event.
*/
bool MetaDown() const;
/**
Returns @true if the Shift key was down at the time of the event.
*/
bool ShiftDown() const;
};
/**
@class wxGridRangeSelectEvent
Events of this class notify about a range of cells being selected.
When the user uses the mouse for selection, one or more @c SELECTING events
are generated first, with @c SELECTED event generated at the end, when
selection is final. This allows the application to handle either the @c
SELECTING events if it needs to update its state in real-time, as the
selection changes, or just the final @c SELECTED event, if updating its
state on every selection change would be too time-consuming.
Note that if the user performs the selection from keyboard, @c SELECTING
events are not generated at all, so @c SELECTED event still must be
handled.
Finally, contrary to most of the other events with the name ending in
"ing", @c SELECTING event can @e not be vetoed.
@beginEventTable{wxGridRangeSelectEvent}
@event{EVT_GRID_RANGE_SELECTING(func)}
The user is selecting a group of contiguous cells. Processes a
@c wxEVT_GRID_RANGE_SELECTING event type.
This event is available in wxWidgets 3.1.5 and later only.
@event{EVT_GRID_CMD_RANGE_SELECTING(id, func)}
The user is selecting a group of contiguous cells; variant taking a window
identifier. Processes a @c wxEVT_GRID_RANGE_SELECTING event type.
This event is available in wxWidgets 3.1.5 and later only.
@event{EVT_GRID_RANGE_SELECTED(func)}
The user selected a group of contiguous cells. Processes a
@c wxEVT_GRID_RANGE_SELECTED event type.
This event is available in wxWidgets 3.1.5 and later only and was
called @c wxEVT_GRID_RANGE_SELECT in the previous versions.
@event{EVT_GRID_CMD_RANGE_SELECTED(id, func)}
The user selected a group of contiguous cells; variant taking a window
identifier. Processes a @c wxEVT_GRID_RANGE_SELECTED event type.
This event is available in wxWidgets 3.1.5 and later only and was
called @c wxEVT_GRID_CMD_RANGE_SELECT in the previous versions.
@endEventTable
@library{wxcore}
@category{grid,events}
*/
class wxGridRangeSelectEvent : public wxNotifyEvent
{
public:
/**
Default constructor.
*/
wxGridRangeSelectEvent();
/**
Constructor for initializing all event attributes.
*/
wxGridRangeSelectEvent(int id, wxEventType type,
wxObject* obj,
const wxGridCellCoords& topLeft,
const wxGridCellCoords& bottomRight,
bool sel = true, const wxKeyboardState& kbd = wxKeyboardState());
/**
Returns @true if the Alt key was down at the time of the event.
*/
bool AltDown() const;
/**
Returns @true if the Control key was down at the time of the event.
*/
bool ControlDown() const;
/**
Top left corner of the rectangular area that was (de)selected.
*/
wxGridCellCoords GetBottomRightCoords() const;
/**
Bottom row of the rectangular area that was (de)selected.
*/
int GetBottomRow() const;
/**
Left column of the rectangular area that was (de)selected.
*/
int GetLeftCol() const;
/**
Right column of the rectangular area that was (de)selected.
*/
int GetRightCol() const;
/**
Top left corner of the rectangular area that was (de)selected.
*/
wxGridCellCoords GetTopLeftCoords() const;
/**
Top row of the rectangular area that was (de)selected.
*/
int GetTopRow() const;
/**
Returns @true if the Meta key was down at the time of the event.
*/
bool MetaDown() const;
/**
Returns @true if the area was selected, @false otherwise.
*/
bool Selecting() const;
/**
Returns @true if the Shift key was down at the time of the event.
*/
bool ShiftDown() const;
};
/**
@class wxGridEditorCreatedEvent
@beginEventTable{wxGridEditorCreatedEvent}
@event{EVT_GRID_EDITOR_CREATED(func)}
The editor for a cell was created. Processes a
@c wxEVT_GRID_EDITOR_CREATED event type.
@event{EVT_GRID_CMD_EDITOR_CREATED(id, func)}
The editor for a cell was created; variant taking a window identifier.
Processes a @c wxEVT_GRID_EDITOR_CREATED event type.
@endEventTable
@library{wxcore}
@category{grid,events}
*/
class wxGridEditorCreatedEvent : public wxCommandEvent
{
public:
/**
Default constructor.
*/
wxGridEditorCreatedEvent();
/**
Constructor for initializing all event attributes.
*/
wxGridEditorCreatedEvent(int id, wxEventType type, wxObject* obj,
int row, int col, wxControl* ctrl);
/**
Returns the column at which the event occurred.
*/
int GetCol() const;
/**
Returns the edit control.
This function is preserved for compatibility, but GetWindow() should be
preferred in the new code as the associated window doesn't need to be of
a wxControl-derived class.
Note that if SetWindow() had been called with an object not deriving
from wxControl, this method will return @NULL.
*/
wxControl* GetControl();
/**
Returns the row at which the event occurred.
*/
int GetRow() const;
/**
Returns the edit window.
@since 3.1.3
*/
wxWindow* GetWindow() const;
/**
Sets the column at which the event occurred.
*/
void SetCol(int col);
/**
Sets the edit control.
This function is preserved for compatibility, but SetWindow() should be
preferred in the new code, see GetControl().
*/
void SetControl(wxControl* ctrl);
/**
Sets the row at which the event occurred.
*/
void SetRow(int row);
/**
Sets the edit window.
@since 3.1.3
*/
void SetWindow(wxWindow* window);
};
wxEventType wxEVT_GRID_CELL_LEFT_CLICK;
wxEventType wxEVT_GRID_CELL_RIGHT_CLICK;
wxEventType wxEVT_GRID_CELL_LEFT_DCLICK;
wxEventType wxEVT_GRID_CELL_RIGHT_DCLICK;
wxEventType wxEVT_GRID_LABEL_LEFT_CLICK;
wxEventType wxEVT_GRID_LABEL_RIGHT_CLICK;
wxEventType wxEVT_GRID_LABEL_LEFT_DCLICK;
wxEventType wxEVT_GRID_LABEL_RIGHT_DCLICK;
wxEventType wxEVT_GRID_ROW_SIZE;
wxEventType wxEVT_GRID_ROW_AUTO_SIZE;
wxEventType wxEVT_GRID_COL_SIZE;
wxEventType wxEVT_GRID_COL_AUTO_SIZE;
wxEventType wxEVT_GRID_RANGE_SELECTING;
wxEventType wxEVT_GRID_RANGE_SELECTED;
wxEventType wxEVT_GRID_CELL_CHANGING;
wxEventType wxEVT_GRID_CELL_CHANGED;
wxEventType wxEVT_GRID_SELECT_CELL;
wxEventType wxEVT_GRID_EDITOR_SHOWN;
wxEventType wxEVT_GRID_EDITOR_HIDDEN;
wxEventType wxEVT_GRID_EDITOR_CREATED;
wxEventType wxEVT_GRID_CELL_BEGIN_DRAG;
wxEventType wxEVT_GRID_ROW_MOVE;
wxEventType wxEVT_GRID_COL_MOVE;
wxEventType wxEVT_GRID_COL_SORT;
wxEventType wxEVT_GRID_TABBING;
|