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 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 8444 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 8590 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610 8611 8612 8613 8614 8615 8616 8617 8618 8619 8620 8621 8622 8623 8624 8625 8626 8627 8628 8629 8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 8641 8642 8643 8644 8645 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 8696 8697 8698 8699 8700 8701 8702 8703 8704 8705 8706 8707 8708 8709 8710 8711 8712 8713 8714 8715 8716 8717 8718 8719 8720 8721 8722 8723 8724 8725 8726 8727 8728 8729 8730 8731 8732 8733 8734 8735 8736 8737 8738 8739 8740 8741 8742 8743 8744 8745 8746 8747 8748 8749 8750 8751 8752 8753 8754 8755 8756 8757 8758 8759 8760 8761 8762 8763 8764 8765 8766 8767 8768 8769 8770 8771 8772 8773 8774 8775 8776 8777 8778 8779 8780 8781 8782 8783 8784 8785 8786 8787 8788 8789 8790 8791 8792 8793 8794 8795 8796 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 8820 8821 8822 8823 8824 8825 8826 8827 8828 8829 8830 8831 8832 8833 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 8846 8847 8848 8849 8850 8851 8852 8853 8854 8855 8856 8857 8858 8859 8860 8861 8862 8863 8864 8865 8866 8867 8868 8869 8870 8871 8872 8873 8874 8875 8876 8877 8878 8879 8880 8881 8882 8883 8884 8885 8886 8887 8888 8889 8890 8891 8892 8893 8894 8895 8896 8897 8898 8899 8900 8901 8902 8903 8904 8905 8906 8907 8908 8909 8910 8911 8912 8913 8914 8915 8916 8917 8918 8919 8920 8921 8922 8923 8924 8925 8926 8927 8928 8929 8930 8931 8932 8933 8934 8935 8936 8937 8938 8939 8940 8941 8942 8943 8944 8945 8946 8947 8948 8949 8950 8951 8952 8953 8954 8955 8956 8957 8958 8959 8960 8961 8962 8963 8964 8965 8966 8967 8968 8969 8970 8971 8972 8973 8974 8975 8976 8977 8978 8979 8980 8981 8982 8983 8984 8985 8986 8987 8988 8989 8990 8991 8992 8993 8994 8995 8996 8997 8998 8999 9000 9001 9002 9003 9004 9005 9006 9007 9008 9009 9010 9011 9012 9013 9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 9061 9062 9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 9080 9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 9130 9131 9132 9133 9134 9135 9136 9137 9138 9139 9140 9141 9142 9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 9188 9189 9190 9191 9192 9193 9194 9195 9196 9197 9198 9199 9200 9201 9202 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 9223 9224 9225 9226 9227 9228 9229 9230 9231 9232 9233 9234 9235 9236 9237 9238 9239 9240 9241 9242 9243 9244 9245 9246 9247 9248 9249 9250 9251 9252 9253 9254 9255 9256 9257 9258 9259 9260 9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 9272 9273 9274 9275 9276 9277 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 9303 9304 9305 9306 9307 9308 9309 9310 9311 9312 9313 9314 9315 9316 9317 9318 9319 9320 9321 9322 9323 9324 9325 9326 9327 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 9343 9344 9345 9346 9347 9348 9349 9350 9351 9352 9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 9367 9368 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 9382 9383 9384 9385 9386 9387 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 9439 9440 9441 9442 9443 9444 9445 9446 9447 9448 9449 9450 9451 9452 9453 9454 9455 9456 9457 9458 9459 9460 9461 9462 9463 9464 9465 9466 9467 9468 9469 9470 9471 9472 9473 9474 9475 9476 9477 9478 9479 9480 9481 9482 9483 9484 9485 9486 9487 9488 9489 9490 9491 9492 9493 9494 9495 9496 9497 9498 9499 9500 9501 9502 9503 9504 9505 9506 9507 9508 9509 9510 9511 9512 9513 9514 9515 9516 9517 9518 9519 9520 9521 9522 9523 9524 9525 9526 9527 9528 9529 9530 9531 9532 9533 9534 9535 9536 9537 9538 9539 9540 9541 9542 9543 9544 9545 9546 9547 9548 9549 9550 9551 9552 9553 9554 9555 9556 9557 9558 9559 9560 9561 9562 9563 9564 9565 9566 9567 9568 9569 9570 9571 9572 9573 9574 9575 9576 9577 9578 9579 9580 9581 9582 9583 9584 9585 9586 9587 9588 9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 9601 9602 9603 9604 9605 9606 9607 9608 9609 9610 9611 9612 9613 9614 9615 9616 9617 9618 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 9629 9630 9631 9632 9633 9634 9635 9636 9637 9638 9639 9640 9641 9642 9643 9644 9645 9646 9647 9648 9649 9650 9651 9652 9653 9654 9655 9656 9657 9658 9659 9660 9661 9662 9663 9664 9665 9666 9667 9668 9669 9670 9671 9672 9673 9674 9675 9676 9677 9678 9679 9680 9681 9682 9683 9684 9685 9686 9687 9688 9689 9690 9691 9692 9693 9694 9695 9696 9697 9698 9699 9700 9701 9702 9703 9704 9705 9706 9707 9708 9709 9710 9711 9712 9713 9714 9715 9716 9717 9718 9719 9720 9721 9722 9723 9724 9725 9726 9727 9728 9729 9730 9731 9732 9733 9734 9735 9736 9737 9738 9739 9740 9741 9742 9743 9744 9745 9746 9747 9748 9749 9750 9751 9752 9753 9754 9755 9756 9757 9758 9759 9760 9761 9762 9763 9764 9765 9766 9767 9768 9769 9770 9771 9772 9773 9774 9775 9776 9777 9778 9779 9780 9781 9782 9783 9784 9785 9786 9787 9788 9789 9790 9791 9792 9793 9794 9795 9796 9797 9798 9799 9800 9801 9802 9803 9804 9805 9806 9807 9808 9809 9810 9811 9812 9813 9814 9815 9816 9817 9818 9819 9820 9821 9822 9823 9824 9825 9826 9827 9828 9829 9830 9831 9832 9833 9834 9835 9836 9837 9838 9839 9840 9841 9842 9843 9844 9845 9846 9847 9848 9849 9850 9851 9852 9853 9854 9855 9856 9857 9858 9859 9860 9861 9862 9863 9864 9865 9866 9867 9868 9869 9870 9871 9872 9873 9874 9875 9876 9877 9878 9879 9880 9881 9882 9883 9884 9885 9886 9887 9888 9889 9890 9891 9892 9893 9894 9895 9896 9897 9898 9899 9900 9901 9902 9903 9904 9905 9906 9907 9908 9909 9910 9911 9912 9913 9914 9915 9916 9917 9918 9919 9920 9921 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9954 9955 9956 9957 9958 9959 9960 9961 9962 9963 9964 9965 9966 9967 9968 9969 9970 9971 9972 9973 9974 9975 9976 9977 9978 9979 9980 9981 9982 9983 9984 9985 9986 9987 9988 9989 9990 9991 9992 9993 9994 9995 9996 9997 9998 9999 10000 10001 10002 10003 10004 10005 10006 10007 10008 10009 10010 10011 10012 10013 10014 10015 10016 10017 10018 10019 10020 10021 10022 10023 10024 10025 10026 10027 10028 10029 10030 10031 10032 10033 10034 10035 10036 10037 10038 10039 10040 10041 10042 10043 10044 10045 10046 10047 10048 10049 10050 10051 10052 10053 10054 10055 10056 10057 10058 10059 10060 10061 10062 10063 10064 10065 10066 10067 10068 10069 10070 10071 10072 10073 10074 10075 10076 10077 10078 10079 10080 10081 10082 10083 10084 10085 10086 10087 10088 10089 10090 10091 10092 10093 10094 10095 10096 10097 10098 10099 10100 10101 10102 10103 10104 10105 10106 10107 10108 10109 10110 10111 10112 10113 10114 10115 10116 10117 10118 10119 10120 10121 10122 10123 10124 10125 10126 10127 10128 10129 10130 10131 10132 10133 10134 10135 10136 10137 10138 10139 10140 10141 10142 10143 10144 10145 10146 10147 10148 10149 10150 10151 10152 10153 10154 10155 10156 10157 10158 10159 10160 10161 10162 10163 10164 10165 10166 10167 10168 10169 10170 10171 10172 10173 10174 10175 10176 10177 10178 10179 10180 10181 10182 10183 10184 10185 10186 10187 10188 10189 10190 10191 10192 10193 10194 10195 10196 10197 10198 10199 10200 10201 10202 10203 10204 10205 10206 10207 10208 10209 10210 10211 10212 10213 10214 10215 10216 10217 10218 10219 10220 10221 10222 10223 10224 10225 10226 10227 10228 10229 10230 10231 10232 10233 10234 10235 10236 10237 10238 10239 10240 10241 10242 10243 10244 10245 10246 10247 10248 10249 10250 10251 10252 10253 10254 10255 10256 10257 10258 10259 10260 10261 10262 10263 10264 10265 10266 10267 10268 10269 10270 10271 10272 10273 10274 10275 10276 10277 10278 10279 10280 10281 10282 10283 10284 10285 10286 10287 10288 10289 10290 10291 10292 10293 10294 10295 10296 10297 10298 10299 10300 10301 10302 10303 10304 10305 10306 10307 10308 10309 10310 10311 10312 10313 10314 10315 10316 10317 10318 10319 10320 10321 10322 10323 10324 10325 10326 10327 10328 10329 10330 10331 10332 10333 10334 10335 10336 10337 10338 10339 10340 10341 10342 10343 10344 10345 10346 10347 10348 10349 10350 10351 10352 10353 10354 10355 10356 10357 10358 10359 10360 10361 10362 10363 10364 10365 10366 10367 10368 10369 10370 10371 10372 10373 10374 10375 10376 10377 10378 10379 10380 10381 10382 10383 10384 10385 10386 10387 10388 10389 10390 10391 10392 10393 10394 10395 10396 10397 10398 10399 10400 10401 10402 10403 10404 10405 10406 10407 10408 10409 10410 10411 10412 10413 10414 10415 10416 10417 10418 10419 10420 10421 10422 10423 10424 10425 10426 10427 10428 10429 10430 10431 10432 10433 10434 10435 10436 10437 10438 10439 10440 10441 10442 10443 10444 10445 10446 10447 10448 10449 10450 10451 10452 10453 10454 10455 10456 10457 10458 10459 10460 10461 10462 10463 10464 10465 10466 10467 10468 10469 10470 10471 10472 10473 10474 10475 10476 10477 10478 10479 10480 10481 10482 10483 10484 10485 10486 10487 10488 10489 10490 10491 10492 10493 10494 10495 10496 10497 10498 10499 10500 10501 10502 10503 10504 10505 10506 10507 10508 10509 10510 10511 10512 10513 10514 10515 10516 10517 10518 10519 10520 10521 10522 10523 10524 10525 10526 10527 10528 10529 10530 10531 10532 10533 10534 10535 10536 10537 10538 10539 10540 10541 10542 10543 10544 10545 10546 10547 10548 10549 10550 10551 10552 10553 10554 10555 10556 10557 10558 10559 10560 10561 10562 10563 10564 10565 10566 10567 10568 10569 10570 10571 10572 10573 10574 10575 10576 10577 10578 10579 10580 10581 10582 10583 10584 10585 10586 10587 10588 10589 10590 10591 10592 10593 10594 10595 10596 10597 10598 10599 10600 10601 10602 10603 10604 10605 10606 10607 10608 10609 10610 10611 10612 10613 10614 10615 10616 10617 10618 10619 10620 10621 10622 10623 10624 10625 10626 10627 10628 10629 10630 10631 10632 10633 10634 10635 10636 10637 10638 10639 10640 10641 10642 10643 10644 10645 10646 10647 10648 10649 10650 10651 10652 10653 10654 10655 10656 10657 10658 10659 10660 10661 10662 10663 10664 10665 10666 10667 10668 10669 10670 10671 10672 10673 10674 10675 10676 10677 10678 10679 10680 10681 10682 10683 10684 10685 10686 10687 10688 10689 10690 10691 10692 10693 10694 10695 10696 10697
|
# --------------------------------------------------------------------------- #
# AUI Library wxPython IMPLEMENTATION
#
# Original C++ Code From Kirix (wxAUI). You Can Find It At:
#
# License: wxWidgets license
#
# http:#www.kirix.com/en/community/opensource/wxaui/about_wxaui.html
#
# Current wxAUI Version Tracked: wxWidgets 2.9.4 SVN HEAD
#
#
# Python Code By:
#
# Andrea Gavana, @ 23 Dec 2005
# Latest Revision: 09 Jan 2014, 23.00 GMT
#
# For All Kind Of Problems, Requests Of Enhancements And Bug Reports, Please
# Write To Me At:
#
# andrea.gavana@gmail.com
# andrea.gavana@maerskoil.com
#
# Or, Obviously, To The wxPython Mailing List!!!
#
# End Of Comments
# --------------------------------------------------------------------------- #
"""
Description
===========
`framemanager.py` is the central module of the AUI class framework.
:class:`AuiManager` manages the panes associated with it for a particular :class:`Frame`, using
a pane's :class:`AuiPaneInfo` information to determine each pane's docking and floating
behavior. AuiManager uses wxPython' sizer mechanism to plan the layout of each frame.
It uses a replaceable dock art class to do all drawing, so all drawing is localized
in one area, and may be customized depending on an application's specific needs.
AuiManager works as follows: the programmer adds panes to the class, or makes
changes to existing pane properties (dock position, floating state, show state, etc...).
To apply these changes, AuiManager's :meth:`AuiManager.Update() <AuiManager.Update>` function is called. This batch
processing can be used to avoid flicker, by modifying more than one pane at a time,
and then "committing" all of the changes at once by calling `Update()`.
Panes can be added quite easily::
text1 = wx.TextCtrl(self, -1)
text2 = wx.TextCtrl(self, -1)
self._mgr.AddPane(text1, AuiPaneInfo().Left().Caption("Pane Number One"))
self._mgr.AddPane(text2, AuiPaneInfo().Bottom().Caption("Pane Number Two"))
self._mgr.Update()
Later on, the positions can be modified easily. The following will float an
existing pane in a tool window::
self._mgr.GetPane(text1).Float()
Layers, Rows and Directions, Positions
======================================
Inside AUI, the docking layout is figured out by checking several pane parameters.
Four of these are important for determining where a pane will end up.
**Direction** - Each docked pane has a direction, `Top`, `Bottom`, `Left`, `Right`, or `Center`.
This is fairly self-explanatory. The pane will be placed in the location specified
by this variable.
**Position** - More than one pane can be placed inside of a "dock". Imagine two panes
being docked on the left side of a window. One pane can be placed over another.
In proportionally managed docks, the pane position indicates it's sequential position,
starting with zero. So, in our scenario with two panes docked on the left side, the
top pane in the dock would have position 0, and the second one would occupy position 1.
**Row** - A row can allow for two docks to be placed next to each other. One of the most
common places for this to happen is in the toolbar. Multiple toolbar rows are allowed,
the first row being in row 0, and the second in row 1. Rows can also be used on
vertically docked panes.
**Layer** - A layer is akin to an onion. Layer 0 is the very center of the managed pane.
Thus, if a pane is in layer 0, it will be closest to the center window (also sometimes
known as the "content window"). Increasing layers "swallow up" all layers of a lower
value. This can look very similar to multiple rows, but is different because all panes
in a lower level yield to panes in higher levels. The best way to understand layers
is by running the AUI sample (`AUI.py`).
"""
__author__ = "Andrea Gavana <andrea.gavana@gmail.com>"
__date__ = "31 March 2009"
import wx
# just for isinstance
import wx.lib.sized_controls as sc
import time
import types
import warnings
import auibar
import auibook
import tabmdi
import dockart
import tabart
from aui_utilities import Clip, PaneCreateStippleBitmap, GetDockingImage, GetSlidingPoints
from aui_constants import *
# Define this as a translation function
_ = wx.GetTranslation
_winxptheme = False
if wx.Platform == "__WXMSW__":
try:
import winxptheme
_winxptheme = True
except ImportError:
pass
# wxPython version string
_VERSION_STRING = wx.VERSION_STRING
# AUI Events
wxEVT_AUI_PANE_BUTTON = wx.NewEventType()
wxEVT_AUI_PANE_CLOSE = wx.NewEventType()
wxEVT_AUI_PANE_MAXIMIZE = wx.NewEventType()
wxEVT_AUI_PANE_RESTORE = wx.NewEventType()
wxEVT_AUI_RENDER = wx.NewEventType()
wxEVT_AUI_FIND_MANAGER = wx.NewEventType()
wxEVT_AUI_PANE_MINIMIZE = wx.NewEventType()
wxEVT_AUI_PANE_MIN_RESTORE = wx.NewEventType()
wxEVT_AUI_PANE_FLOATING = wx.NewEventType()
wxEVT_AUI_PANE_FLOATED = wx.NewEventType()
wxEVT_AUI_PANE_DOCKING = wx.NewEventType()
wxEVT_AUI_PANE_DOCKED = wx.NewEventType()
wxEVT_AUI_PANE_ACTIVATED = wx.NewEventType()
wxEVT_AUI_PERSPECTIVE_CHANGED = wx.NewEventType()
EVT_AUI_PANE_BUTTON = wx.PyEventBinder(wxEVT_AUI_PANE_BUTTON, 0)
""" Fires an event when the user left-clicks on a pane button. """
EVT_AUI_PANE_CLOSE = wx.PyEventBinder(wxEVT_AUI_PANE_CLOSE, 0)
""" A pane in `AuiManager` has been closed. """
EVT_AUI_PANE_MAXIMIZE = wx.PyEventBinder(wxEVT_AUI_PANE_MAXIMIZE, 0)
""" A pane in `AuiManager` has been maximized. """
EVT_AUI_PANE_RESTORE = wx.PyEventBinder(wxEVT_AUI_PANE_RESTORE, 0)
""" A pane in `AuiManager` has been restored from a maximized state. """
EVT_AUI_RENDER = wx.PyEventBinder(wxEVT_AUI_RENDER, 0)
""" Fires an event every time the AUI frame is being repainted. """
EVT_AUI_FIND_MANAGER = wx.PyEventBinder(wxEVT_AUI_FIND_MANAGER, 0)
""" Used to find which AUI manager is controlling a certain pane. """
EVT_AUI_PANE_MINIMIZE = wx.PyEventBinder(wxEVT_AUI_PANE_MINIMIZE, 0)
""" A pane in `AuiManager` has been minimized. """
EVT_AUI_PANE_MIN_RESTORE = wx.PyEventBinder(wxEVT_AUI_PANE_MIN_RESTORE, 0)
""" A pane in `AuiManager` has been restored from a minimized state. """
EVT_AUI_PANE_FLOATING = wx.PyEventBinder(wxEVT_AUI_PANE_FLOATING, 0)
""" A pane in `AuiManager` is about to be floated. """
EVT_AUI_PANE_FLOATED = wx.PyEventBinder(wxEVT_AUI_PANE_FLOATED, 0)
""" A pane in `AuiManager` has been floated. """
EVT_AUI_PANE_DOCKING = wx.PyEventBinder(wxEVT_AUI_PANE_DOCKING, 0)
""" A pane in `AuiManager` is about to be docked. """
EVT_AUI_PANE_DOCKED = wx.PyEventBinder(wxEVT_AUI_PANE_DOCKED, 0)
""" A pane in `AuiManager` has been docked. """
EVT_AUI_PANE_ACTIVATED = wx.PyEventBinder(wxEVT_AUI_PANE_ACTIVATED, 0)
""" A pane in `AuiManager` has been activated. """
EVT_AUI_PERSPECTIVE_CHANGED = wx.PyEventBinder(wxEVT_AUI_PERSPECTIVE_CHANGED, 0)
""" The layout in `AuiManager` has been changed. """
# ---------------------------------------------------------------------------- #
class AuiDockInfo(object):
""" A class to store all properties of a dock. """
def __init__(self):
"""
Default class constructor.
Used internally, do not call it in your code!
"""
object.__init__(self)
self.dock_direction = 0
self.dock_layer = 0
self.dock_row = 0
self.size = 0
self.min_size = 0
self.resizable = True
self.fixed = False
self.toolbar = False
self.rect = wx.Rect()
self.panes = []
def IsOk(self):
"""
Returns whether a dock is valid or not.
In order to be valid, a dock needs to have a non-zero `dock_direction`.
"""
return self.dock_direction != 0
def IsHorizontal(self):
""" Returns whether the dock is horizontal or not. """
return self.dock_direction in [AUI_DOCK_TOP, AUI_DOCK_BOTTOM]
def IsVertical(self):
""" Returns whether the dock is vertical or not. """
return self.dock_direction in [AUI_DOCK_LEFT, AUI_DOCK_RIGHT, AUI_DOCK_CENTER]
# ---------------------------------------------------------------------------- #
class AuiDockingGuideInfo(object):
""" A class which holds information about VS2005 docking guide windows. """
def __init__(self, other=None):
"""
Default class constructor.
Used internally, do not call it in your code!
:param `other`: another instance of :class:`AuiDockingGuideInfo`.
"""
if other:
self.Assign(other)
else:
# window representing the docking target
self.host = None
# dock direction (top, bottom, left, right, center)
self.dock_direction = AUI_DOCK_NONE
def Assign(self, other):
"""
Assigns the properties of the `other` :class:`AuiDockingGuideInfo` to `self`.
:param `other`: another instance of :class:`AuiDockingGuideInfo`.
"""
self.host = other.host
self.dock_direction = other.dock_direction
def Host(self, h):
"""
Hosts a docking guide window.
:param `h`: an instance of :class:`AuiDockingGuideWindow` or :class:`AuiDockingHintWindow`.
"""
self.host = h
return self
def Left(self):
""" Sets the guide window to left docking. """
self.dock_direction = AUI_DOCK_LEFT
return self
def Right(self):
""" Sets the guide window to right docking. """
self.dock_direction = AUI_DOCK_RIGHT
return self
def Top(self):
""" Sets the guide window to top docking. """
self.dock_direction = AUI_DOCK_TOP
return self
def Bottom(self):
""" Sets the guide window to bottom docking. """
self.dock_direction = AUI_DOCK_BOTTOM
return self
def Center(self):
""" Sets the guide window to center docking. """
self.dock_direction = AUI_DOCK_CENTER
return self
def Centre(self):
""" Sets the guide window to centre docking. """
self.dock_direction = AUI_DOCK_CENTRE
return self
# ---------------------------------------------------------------------------- #
class AuiDockUIPart(object):
""" A class which holds attributes for a UI part in the interface. """
typeCaption = 0
typeGripper = 1
typeDock = 2
typeDockSizer = 3
typePane = 4
typePaneSizer = 5
typeBackground = 6
typePaneBorder = 7
typePaneButton = 8
def __init__(self):
"""
Default class constructor.
Used internally, do not call it in your code!
"""
self.orientation = wx.VERTICAL
self.type = 0
self.rect = wx.Rect()
# ---------------------------------------------------------------------------- #
class AuiPaneButton(object):
""" A simple class which describes the caption pane button attributes. """
def __init__(self, button_id):
"""
Default class constructor.
Used internally, do not call it in your code!
:param integer `button_id`: the pane button identifier.
"""
self.button_id = button_id
# ---------------------------------------------------------------------------- #
# event declarations/classes
class AuiManagerEvent(wx.PyCommandEvent):
""" A specialized command event class for events sent by :class:`AuiManager`. """
def __init__(self, eventType, id=1):
"""
Default class constructor.
:param integer `eventType`: the event kind;
:param integer `id`: the event identification number.
"""
wx.PyCommandEvent.__init__(self, eventType, id)
self.manager = None
self.pane = None
self.button = 0
self.veto_flag = False
self.canveto_flag = True
self.dc = None
def SetManager(self, mgr):
"""
Associates a :class:`AuiManager` to the current event.
:param `mgr`: an instance of :class:`AuiManager`.
"""
self.manager = mgr
def SetDC(self, pdc):
"""
Associates a :class:`DC` device context to this event.
:param `pdc`: a :class:`DC` device context object.
"""
self.dc = pdc
def SetPane(self, p):
"""
Associates a :class:`AuiPaneInfo` instance to this event.
:param `p`: a :class:`AuiPaneInfo` instance.
"""
self.pane = p
def SetButton(self, b):
"""
Associates a :class:`AuiPaneButton` instance to this event.
:param `b`: a :class:`AuiPaneButton` instance.
"""
self.button = b
def GetManager(self):
""" Returns the associated :class:`AuiManager` (if any). """
return self.manager
def GetDC(self):
""" Returns the associated :class:`DC` device context (if any). """
return self.dc
def GetPane(self):
""" Returns the associated :class:`AuiPaneInfo` structure (if any). """
return self.pane
def GetButton(self):
""" Returns the associated :class:`AuiPaneButton` instance (if any). """
return self.button
def Veto(self, veto=True):
"""
Prevents the change announced by this event from happening.
It is in general a good idea to notify the user about the reasons for
vetoing the change because otherwise the applications behaviour (which
just refuses to do what the user wants) might be quite surprising.
:param bool `veto`: ``True`` to veto the event, ``False`` otherwise.
"""
self.veto_flag = veto
def GetVeto(self):
""" Returns whether the event has been vetoed or not. """
return self.veto_flag
def SetCanVeto(self, can_veto):
"""
Sets whether the event can be vetoed or not.
:param bool `can_veto`: ``True`` if the event can be vetoed, ``False`` otherwise.
"""
self.canveto_flag = can_veto
def CanVeto(self):
""" Returns whether the event can be vetoed and has been vetoed. """
return self.canveto_flag and self.veto_flag
# ---------------------------------------------------------------------------- #
class AuiPaneInfo(object):
"""
AuiPaneInfo specifies all the parameters for a pane. These parameters specify where
the pane is on the screen, whether it is docked or floating, or hidden. In addition,
these parameters specify the pane's docked position, floating position, preferred
size, minimum size, caption text among many other parameters.
"""
optionFloating = 2**0
optionHidden = 2**1
optionLeftDockable = 2**2
optionRightDockable = 2**3
optionTopDockable = 2**4
optionBottomDockable = 2**5
optionFloatable = 2**6
optionMovable = 2**7
optionResizable = 2**8
optionPaneBorder = 2**9
optionCaption = 2**10
optionGripper = 2**11
optionDestroyOnClose = 2**12
optionToolbar = 2**13
optionActive = 2**14
optionGripperTop = 2**15
optionMaximized = 2**16
optionDockFixed = 2**17
optionNotebookDockable = 2**18
optionMinimized = 2**19
optionLeftSnapped = 2**20
optionRightSnapped = 2**21
optionTopSnapped = 2**22
optionBottomSnapped = 2**23
optionFlyOut = 2**24
optionCaptionLeft = 2**25
buttonClose = 2**26
buttonMaximize = 2**27
buttonMinimize = 2**28
buttonPin = 2**29
buttonCustom1 = 2**30
buttonCustom2 = 2**31
buttonCustom3 = 2**32
savedHiddenState = 2**33 # used internally
actionPane = 2**34 # used internally
wasMaximized = 2**35 # used internally
needsRestore = 2**36 # used internally
def __init__(self):
""" Default class constructor. """
self.window = None
self.frame = None
self.state = 0
self.dock_direction = AUI_DOCK_LEFT
self.dock_layer = 0
self.dock_row = 0
self.dock_pos = 0
self.minimize_mode = AUI_MINIMIZE_POS_SMART
self.floating_pos = wx.Point(-1, -1)
self.floating_size = wx.Size(-1, -1)
self.best_size = wx.Size(-1, -1)
self.min_size = wx.Size(-1, -1)
self.max_size = wx.Size(-1, -1)
self.dock_proportion = 0
self.caption = ""
self.buttons = []
self.name = ""
self.icon = wx.NullIcon
self.rect = wx.Rect()
self.notebook_id = -1
self.transparent = 255
self.needsTransparency = False
self.previousDockPos = None
self.previousDockSize = 0
self.snapped = 0
self.minimize_target = None
self.DefaultPane()
def dock_direction_get(self):
"""
Getter for the `dock_direction`.
:see: :meth:`~AuiPaneInfo.dock_direction_set` for a set of valid docking directions.
"""
if self.IsMaximized():
return AUI_DOCK_CENTER
else:
return self._dock_direction
def dock_direction_set(self, value):
"""
Setter for the `dock_direction`.
:param integer `value`: the docking direction. This can be one of the following bits:
============================ ======= =============================================
Dock Flag Value Description
============================ ======= =============================================
``AUI_DOCK_NONE`` 0 No docking direction.
``AUI_DOCK_TOP`` 1 Top docking direction.
``AUI_DOCK_RIGHT`` 2 Right docking direction.
``AUI_DOCK_BOTTOM`` 3 Bottom docking direction.
``AUI_DOCK_LEFT`` 4 Left docking direction.
``AUI_DOCK_CENTER`` 5 Center docking direction.
``AUI_DOCK_CENTRE`` 5 Centre docking direction.
``AUI_DOCK_NOTEBOOK_PAGE`` 6 Automatic AuiNotebooks docking style.
============================ ======= =============================================
"""
self._dock_direction = value
dock_direction = property(dock_direction_get, dock_direction_set)
def IsOk(self):
"""
Returns ``True`` if the :class:`AuiPaneInfo` structure is valid.
:note: A pane structure is valid if it has an associated window.
"""
return self.window != None
def IsMaximized(self):
""" Returns ``True`` if the pane is maximized. """
return self.HasFlag(self.optionMaximized)
def IsMinimized(self):
""" Returns ``True`` if the pane is minimized. """
return self.HasFlag(self.optionMinimized)
def IsFixed(self):
""" Returns ``True`` if the pane cannot be resized. """
return not self.HasFlag(self.optionResizable)
def IsResizeable(self):
""" Returns ``True`` if the pane can be resized. """
return self.HasFlag(self.optionResizable)
def IsShown(self):
""" Returns ``True`` if the pane is currently shown. """
return not self.HasFlag(self.optionHidden)
def IsFloating(self):
""" Returns ``True`` if the pane is floating. """
return self.HasFlag(self.optionFloating)
def IsDocked(self):
""" Returns ``True`` if the pane is docked. """
return not self.HasFlag(self.optionFloating)
def IsToolbar(self):
""" Returns ``True`` if the pane contains a toolbar. """
return self.HasFlag(self.optionToolbar)
def IsTopDockable(self):
"""
Returns ``True`` if the pane can be docked at the top
of the managed frame.
"""
return self.HasFlag(self.optionTopDockable)
def IsBottomDockable(self):
"""
Returns ``True`` if the pane can be docked at the bottom
of the managed frame.
"""
return self.HasFlag(self.optionBottomDockable)
def IsLeftDockable(self):
"""
Returns ``True`` if the pane can be docked at the left
of the managed frame.
"""
return self.HasFlag(self.optionLeftDockable)
def IsRightDockable(self):
"""
Returns ``True`` if the pane can be docked at the right
of the managed frame.
"""
return self.HasFlag(self.optionRightDockable)
def IsDockable(self):
""" Returns ``True`` if the pane can be docked. """
return self.IsTopDockable() or self.IsBottomDockable() or self.IsLeftDockable() or \
self.IsRightDockable() or self.IsNotebookDockable()
def IsFloatable(self):
"""
Returns ``True`` if the pane can be undocked and displayed as a
floating window.
"""
return self.HasFlag(self.optionFloatable)
def IsMovable(self):
"""
Returns ``True`` if the docked frame can be undocked or moved to
another dock position.
"""
return self.HasFlag(self.optionMovable)
def IsDestroyOnClose(self):
"""
Returns ``True`` if the pane should be destroyed when it is closed.
Normally a pane is simply hidden when the close button is clicked. Calling :meth:`~AuiPaneInfo.DestroyOnClose`
with a ``True`` input parameter will cause the window to be destroyed when the user clicks
the pane's close button.
"""
return self.HasFlag(self.optionDestroyOnClose)
def IsNotebookDockable(self):
"""
Returns ``True`` if a pane can be docked on top to another to create a
:class:`~lib.agw.aui.auibook.AuiNotebook`.
"""
return self.HasFlag(self.optionNotebookDockable)
def IsTopSnappable(self):
""" Returns ``True`` if the pane can be snapped at the top of the managed frame. """
return self.HasFlag(self.optionTopSnapped)
def IsBottomSnappable(self):
""" Returns ``True`` if the pane can be snapped at the bottom of the managed frame. """
return self.HasFlag(self.optionBottomSnapped)
def IsLeftSnappable(self):
""" Returns ``True`` if the pane can be snapped on the left of the managed frame. """
return self.HasFlag(self.optionLeftSnapped)
def IsRightSnappable(self):
""" Returns ``True`` if the pane can be snapped on the right of the managed frame. """
return self.HasFlag(self.optionRightSnapped)
def IsSnappable(self):
""" Returns ``True`` if the pane can be snapped. """
return self.IsTopSnappable() or self.IsBottomSnappable() or self.IsLeftSnappable() or \
self.IsRightSnappable()
def IsFlyOut(self):
""" Returns ``True`` if the floating pane has a "fly-out" effect. """
return self.HasFlag(self.optionFlyOut)
def HasCaption(self):
""" Returns ``True`` if the pane displays a caption. """
return self.HasFlag(self.optionCaption)
def HasCaptionLeft(self):
""" Returns ``True`` if the pane displays a caption on the left (rotated by 90 degrees). """
return self.HasFlag(self.optionCaptionLeft)
def HasGripper(self):
""" Returns ``True`` if the pane displays a gripper. """
return self.HasFlag(self.optionGripper)
def HasBorder(self):
""" Returns ``True`` if the pane displays a border. """
return self.HasFlag(self.optionPaneBorder)
def HasCloseButton(self):
""" Returns ``True`` if the pane displays a button to close the pane. """
return self.HasFlag(self.buttonClose)
def HasMaximizeButton(self):
""" Returns ``True`` if the pane displays a button to maximize the pane. """
return self.HasFlag(self.buttonMaximize)
def HasMinimizeButton(self):
""" Returns ``True`` if the pane displays a button to minimize the pane. """
return self.HasFlag(self.buttonMinimize)
def GetMinimizeMode(self):
"""
Returns the minimization style for this pane.
Possible return values are:
============================== ========= ==============================
Minimize Mode Flag Hex Value Description
============================== ========= ==============================
``AUI_MINIMIZE_POS_SMART`` 0x01 Minimizes the pane on the closest tool bar
``AUI_MINIMIZE_POS_TOP`` 0x02 Minimizes the pane on the top tool bar
``AUI_MINIMIZE_POS_LEFT`` 0x03 Minimizes the pane on its left tool bar
``AUI_MINIMIZE_POS_RIGHT`` 0x04 Minimizes the pane on its right tool bar
``AUI_MINIMIZE_POS_BOTTOM`` 0x05 Minimizes the pane on its bottom tool bar
``AUI_MINIMIZE_POS_TOOLBAR`` 0x06 Minimizes the pane on a target :class:`~lib.agw.aui.auibar.AuiToolBar`
``AUI_MINIMIZE_POS_MASK`` 0x17 Mask to filter the position flags
``AUI_MINIMIZE_CAPT_HIDE`` 0x0 Hides the caption of the minimized pane
``AUI_MINIMIZE_CAPT_SMART`` 0x08 Displays the caption in the best rotation (horizontal or clockwise)
``AUI_MINIMIZE_CAPT_HORZ`` 0x10 Displays the caption horizontally
``AUI_MINIMIZE_CAPT_MASK`` 0x18 Mask to filter the caption flags
============================== ========= ==============================
The flags can be filtered with the following masks:
============================== ========= ==============================
Minimize Mask Flag Hex Value Description
============================== ========= ==============================
``AUI_MINIMIZE_POS_MASK`` 0x17 Filters the position flags
``AUI_MINIMIZE_CAPT_MASK`` 0x18 Filters the caption flags
============================== ========= ==============================
"""
return self.minimize_mode
def HasPinButton(self):
""" Returns ``True`` if the pane displays a button to float the pane. """
return self.HasFlag(self.buttonPin)
def HasGripperTop(self):
""" Returns ``True`` if the pane displays a gripper at the top. """
return self.HasFlag(self.optionGripperTop)
def Window(self, w):
"""
Associate a :class:`Window` derived window to this pane.
This normally does not need to be specified, as the window pointer is
automatically assigned to the :class:`AuiPaneInfo` structure as soon as it is
added to the manager.
:param `w`: a :class:`Window` derived window.
"""
self.window = w
return self
def Name(self, name):
"""
Sets the name of the pane so it can be referenced in lookup functions.
If a name is not specified by the user, a random name is assigned to the pane
when it is added to the manager.
:param `name`: a string specifying the pane name.
.. warning::
If you are using :meth:`AuiManager.SavePerspective` and :meth:`AuiManager.LoadPerspective`,
you will have to specify a name for your pane using :meth:`~AuiPaneInfo.Name`, as perspectives
containing randomly generated names can not be properly restored.
"""
self.name = name
return self
def Caption(self, caption):
"""
Sets the caption of the pane.
:param string `caption`: a string specifying the pane caption.
"""
self.caption = caption
return self
def Left(self):
"""
Sets the pane dock position to the left side of the frame.
:note: This is the same thing as calling :meth:`~AuiPaneInfo.Direction` with ``AUI_DOCK_LEFT`` as
parameter.
"""
self.dock_direction = AUI_DOCK_LEFT
return self
def Right(self):
"""
Sets the pane dock position to the right side of the frame.
:note: This is the same thing as calling :meth:`~AuiPaneInfo.Direction` with ``AUI_DOCK_RIGHT`` as
parameter.
"""
self.dock_direction = AUI_DOCK_RIGHT
return self
def Top(self):
"""
Sets the pane dock position to the top of the frame.
:note: This is the same thing as calling :meth:`~AuiPaneInfo.Direction` with ``AUI_DOCK_TOP`` as
parameter.
"""
self.dock_direction = AUI_DOCK_TOP
return self
def Bottom(self):
"""
Sets the pane dock position to the bottom of the frame.
:note: This is the same thing as calling :meth:`~AuiPaneInfo.Direction` with ``AUI_DOCK_BOTTOM`` as
parameter.
"""
self.dock_direction = AUI_DOCK_BOTTOM
return self
def Center(self):
"""
Sets the pane to the center position of the frame.
The centre pane is the space in the middle after all border panes (left, top,
right, bottom) are subtracted from the layout.
:note: This is the same thing as calling :meth:`~AuiPaneInfo.Direction` with ``AUI_DOCK_CENTER`` as
parameter.
"""
self.dock_direction = AUI_DOCK_CENTER
return self
def Centre(self):
"""
Sets the pane to the center position of the frame.
The centre pane is the space in the middle after all border panes (left, top,
right, bottom) are subtracted from the layout.
:note: This is the same thing as calling :meth:`~AuiPaneInfo.Direction` with ``AUI_DOCK_CENTRE`` as
parameter.
"""
self.dock_direction = AUI_DOCK_CENTRE
return self
def Direction(self, direction):
"""
Determines the direction of the docked pane. It is functionally the
same as calling :meth:`Left`, :meth:`Right`, :meth:`Top` or :meth:`Bottom`,
except that docking direction may be specified programmatically via the parameter `direction`.
:param integer `direction`: the direction of the docked pane.
:see: :meth:`dock_direction_set` for a list of valid docking directions.
"""
self.dock_direction = direction
return self
def Layer(self, layer):
"""
Determines the layer of the docked pane.
The dock layer is similar to an onion, the inner-most layer being layer 0. Each
shell moving in the outward direction has a higher layer number. This allows for
more complex docking layout formation.
:param integer `layer`: the layer of the docked pane.
"""
self.dock_layer = layer
return self
def Row(self, row):
"""
Determines the row of the docked pane.
:param integer `row`: the row of the docked pane.
"""
self.dock_row = row
return self
def Position(self, pos):
"""
Determines the position of the docked pane.
:param integer `pos`: the position of the docked pane.
"""
self.dock_pos = pos
return self
def MinSize(self, arg1=None, arg2=None):
"""
Sets the minimum size of the pane.
This method is split in 2 versions depending on the input type. If `arg1` is
a :class:`Size` object, then :meth:`~AuiPaneInfo.MinSize1` is called. Otherwise, :meth:`~AuiPaneInfo.MinSize2` is called.
:param `arg1`: a :class:`Size` object, a (x, y) tuple or or a `x` coordinate.
:param `arg2`: a `y` coordinate (only if `arg1` is a `x` coordinate, otherwise unused).
"""
if isinstance(arg1, wx.Size):
ret = self.MinSize1(arg1)
elif isinstance(arg1, types.TupleType):
ret = self.MinSize1(wx.Size(*arg1))
elif isinstance(arg1, types.IntType) and arg2 is not None:
ret = self.MinSize2(arg1, arg2)
else:
raise Exception("Invalid argument passed to `MinSize`: arg1=%s, arg2=%s"%(repr(arg1), repr(arg2)))
return ret
def MinSize1(self, size):
"""
Sets the minimum size of the pane.
:see: :meth:`MinSize` for an explanation of input parameters.
"""
self.min_size = size
return self
def MinSize2(self, x, y):
"""
Sets the minimum size of the pane.
:see: :meth:`MinSize` for an explanation of input parameters.
"""
self.min_size = wx.Size(x, y)
return self
def MaxSize(self, arg1=None, arg2=None):
"""
Sets the maximum size of the pane.
This method is split in 2 versions depending on the input type. If `arg1` is
a :class:`Size` object, then :meth:`~AuiPaneInfo.MaxSize1` is called. Otherwise, :meth:`~AuiPaneInfo.MaxSize2` is called.
:param `arg1`: a :class:`Size` object, a (x, y) tuple or a `x` coordinate.
:param `arg2`: a `y` coordinate (only if `arg1` is a `x` coordinate, otherwise unused).
"""
if isinstance(arg1, wx.Size):
ret = self.MaxSize1(arg1)
elif isinstance(arg1, types.TupleType):
ret = self.MaxSize1(wx.Size(*arg1))
elif isinstance(arg1, types.IntType) and arg2 is not None:
ret = self.MaxSize2(arg1, arg2)
else:
raise Exception("Invalid argument passed to `MaxSize`: arg1=%s, arg2=%s"%(repr(arg1), repr(arg2)))
return ret
def MaxSize1(self, size):
"""
Sets the maximum size of the pane.
:see: :meth:`MaxSize` for an explanation of input parameters.
"""
self.max_size = size
return self
def MaxSize2(self, x, y):
"""
Sets the maximum size of the pane.
:see: :meth:`MaxSize` for an explanation of input parameters.
"""
self.max_size.Set(x,y)
return self
def BestSize(self, arg1=None, arg2=None):
"""
Sets the ideal size for the pane. The docking manager will attempt to use
this size as much as possible when docking or floating the pane.
This method is split in 2 versions depending on the input type. If `arg1` is
a :class:`Size` object, then :meth:`BestSize1` is called. Otherwise, :meth:`BestSize2` is called.
:param `arg1`: a :class:`Size` object, a (x, y) tuple or a `x` coordinate.
:param `arg2`: a `y` coordinate (only if `arg1` is a `x` coordinate, otherwise unused).
"""
if isinstance(arg1, wx.Size):
ret = self.BestSize1(arg1)
elif isinstance(arg1, types.TupleType):
ret = self.BestSize1(wx.Size(*arg1))
elif isinstance(arg1, types.IntType) and arg2 is not None:
ret = self.BestSize2(arg1, arg2)
else:
raise Exception("Invalid argument passed to `BestSize`: arg1=%s, arg2=%s"%(repr(arg1), repr(arg2)))
return ret
def BestSize1(self, size):
"""
Sets the best size of the pane.
:see: :meth:`BestSize` for an explanation of input parameters.
"""
self.best_size = size
return self
def BestSize2(self, x, y):
"""
Sets the best size of the pane.
:see: :meth:`BestSize` for an explanation of input parameters.
"""
self.best_size.Set(x,y)
return self
def FloatingPosition(self, pos):
"""
Sets the position of the floating pane.
:param `pos`: a :class:`Point` or a tuple indicating the pane floating position.
"""
self.floating_pos = wx.Point(*pos)
return self
def FloatingSize(self, size):
"""
Sets the size of the floating pane.
:param `size`: a :class:`Size` or a tuple indicating the pane floating size.
"""
self.floating_size = wx.Size(*size)
return self
def Maximize(self):
""" Makes the pane take up the full area."""
return self.SetFlag(self.optionMaximized, True)
def Minimize(self):
"""
Makes the pane minimized in a :class:`~lib.agw.aui.auibar.AuiToolBar`.
Clicking on the minimize button causes a new :class:`~lib.agw.aui.auibar.AuiToolBar` to be created
and added to the frame manager, (currently the implementation is such that
panes at West will have a toolbar at the right, panes at South will have
toolbars at the bottom etc...) and the pane is hidden in the manager.
Clicking on the restore button on the newly created toolbar will result in the
toolbar being removed and the original pane being restored.
"""
return self.SetFlag(self.optionMinimized, True)
def MinimizeMode(self, mode):
"""
Sets the expected minimized mode if the minimize button is visible.
:param integer `mode`: the minimized pane can have a specific position in the work space:
============================== ========= ==============================
Minimize Mode Flag Hex Value Description
============================== ========= ==============================
``AUI_MINIMIZE_POS_SMART`` 0x01 Minimizes the pane on the closest tool bar
``AUI_MINIMIZE_POS_TOP`` 0x02 Minimizes the pane on the top tool bar
``AUI_MINIMIZE_POS_LEFT`` 0x03 Minimizes the pane on its left tool bar
``AUI_MINIMIZE_POS_RIGHT`` 0x04 Minimizes the pane on its right tool bar
``AUI_MINIMIZE_POS_BOTTOM`` 0x05 Minimizes the pane on its bottom tool bar
``AUI_MINIMIZE_POS_TOOLBAR`` 0x06 Minimizes the pane on a target :class:`~lib.agw.aui.auibar.AuiToolBar`
============================== ========= ==============================
The caption of the minimized pane can be displayed in different modes:
============================== ========= ==============================
Caption Mode Flag Hex Value Description
============================== ========= ==============================
``AUI_MINIMIZE_CAPT_HIDE`` 0x0 Hides the caption of the minimized pane
``AUI_MINIMIZE_CAPT_SMART`` 0x08 Displays the caption in the best rotation (horizontal in the top and in
the bottom tool bar or clockwise in the right and in the left tool bar)
``AUI_MINIMIZE_CAPT_HORZ`` 0x10 Displays the caption horizontally
============================== ========= ==============================
.. note::
In order to use the ``AUI_MINIMIZE_POS_TOOLBAR`` flag, the instance of :class:`AuiManager`
you pass as an input for :meth:`MinimizeTarget` **must** have a real name and not the randomly
generated one. Remember to set the :meth:`Name` property of the toolbar pane before calling this method.
"""
self.minimize_mode = mode
return self
def MinimizeTarget(self, toolbarPane):
"""
Minimizes the panes using a :class:`AuiPaneInfo` as a target. As :class:`AuiPaneInfo` properties
need to be copied back and forth every time the perspective has changed, we
only store the toobar **name**.
:param `toolbarPane`: an instance of :class:`AuiPaneInfo`, containing a :class:`~lib.agw.aui.auibar.AuiToolBar`.
.. note::
In order to use this functionality (and with the ``AUI_MINIMIZE_POS_TOOLBAR``
flag set), the instance of :class:`AuiPaneInfo` you pass as an input **must** have a real
name and not the randomly generated one. Remember to set the :meth:`Name` property of
the toolbar pane before calling this method.
"""
self.minimize_target = toolbarPane.name
return self
def Restore(self):
""" Is the reverse of :meth:`Maximize` and :meth:`Minimize`."""
return self.SetFlag(self.optionMaximized or self.optionMinimized, False)
def Fixed(self):
"""
Forces a pane to be fixed size so that it cannot be resized.
After calling :meth:`Fixed`, :meth:`IsFixed` will return ``True``.
"""
return self.SetFlag(self.optionResizable, False)
def Resizable(self, resizable=True):
"""
Allows a pane to be resizable if `resizable` is ``True``, and forces
it to be a fixed size if `resizeable` is ``False``.
If `resizable` is ``False``, this is simply an antonym for :meth:`Fixed`.
:param bool `resizable`: whether the pane will be resizeable or not.
"""
return self.SetFlag(self.optionResizable, resizable)
def Transparent(self, alpha):
"""
Makes the pane transparent when floating.
:param integer `alpha`: a value between 0 and 255 for pane transparency.
"""
if alpha < 0 or alpha > 255:
raise Exception("Invalid transparency value (%s)"%repr(alpha))
self.transparent = alpha
self.needsTransparency = True
def Dock(self):
""" Indicates that a pane should be docked. It is the opposite of :meth:`Float`. """
if self.IsNotebookPage():
self.notebook_id = -1
self.dock_direction = AUI_DOCK_NONE
return self.SetFlag(self.optionFloating, False)
def Float(self):
""" Indicates that a pane should be floated. It is the opposite of :meth:`Dock`. """
if self.IsNotebookPage():
self.notebook_id = -1
self.dock_direction = AUI_DOCK_NONE
return self.SetFlag(self.optionFloating, True)
def Hide(self):
"""
Indicates that a pane should be hidden.
Calling :meth:`Show(False) <Show>` achieve the same effect.
"""
return self.SetFlag(self.optionHidden, True)
def Show(self, show=True):
"""
Indicates that a pane should be shown.
:param bool `show`: whether the pane should be shown or not.
"""
return self.SetFlag(self.optionHidden, not show)
# By defaulting to 1000, the tab will get placed at the end
def NotebookPage(self, id, tab_position=1000):
"""
Forces a pane to be a notebook page, so that the pane can be
docked on top to another to create a :class:`~lib.agw.aui.auibook.AuiNotebook`.
:param integer `id`: the notebook id;
:param integer `tab_position`: the tab number of the pane once docked in a notebook.
"""
# Remove any floating frame
self.Dock()
self.notebook_id = id
self.dock_pos = tab_position
self.dock_row = 0
self.dock_layer = 0
self.dock_direction = AUI_DOCK_NOTEBOOK_PAGE
return self
def NotebookControl(self, id):
"""
Forces a pane to be a notebook control (:class:`~lib.agw.aui.auibook.AuiNotebook`).
:param integer `id`: the notebook id.
"""
self.notebook_id = id
self.window = None
self.buttons = []
if self.dock_direction == AUI_DOCK_NOTEBOOK_PAGE:
self.dock_direction = AUI_DOCK_NONE
return self
def HasNotebook(self):
""" Returns whether a pane has a :class:`~lib.agw.aui.auibook.AuiNotebook` or not. """
return self.notebook_id >= 0
def IsNotebookPage(self):
""" Returns whether the pane is a notebook page in a :class:`~lib.agw.aui.auibook.AuiNotebook`. """
return self.notebook_id >= 0 and self.dock_direction == AUI_DOCK_NOTEBOOK_PAGE
def IsNotebookControl(self):
""" Returns whether the pane is a notebook control (:class:`~lib.agw.aui.auibook.AuiNotebook`). """
return not self.IsNotebookPage() and self.HasNotebook()
def SetNameFromNotebookId(self):
""" Sets the pane name once docked in a :class:`~lib.agw.aui.auibook.AuiNotebook` using the notebook id. """
if self.notebook_id >= 0:
self.name = "__notebook_%d"%self.notebook_id
return self
def CaptionVisible(self, visible=True, left=False):
"""
Indicates that a pane caption should be visible. If `visible` is ``False``, no pane
caption is drawn.
:param bool `visible`: whether the caption should be visible or not;
:param bool `left`: whether the caption should be drawn on the left (rotated by 90 degrees) or not.
"""
if left:
self.SetFlag(self.optionCaption, False)
return self.SetFlag(self.optionCaptionLeft, visible)
self.SetFlag(self.optionCaptionLeft, False)
return self.SetFlag(self.optionCaption, visible)
def PaneBorder(self, visible=True):
"""
Indicates that a border should be drawn for the pane.
:param bool `visible`: whether the pane border should be visible or not.
"""
return self.SetFlag(self.optionPaneBorder, visible)
def Gripper(self, visible=True):
"""
Indicates that a gripper should be drawn for the pane.
:param bool `visible`: whether the gripper should be visible or not.
"""
return self.SetFlag(self.optionGripper, visible)
def GripperTop(self, attop=True):
"""
Indicates that a gripper should be drawn at the top of the pane.
:param bool `attop`: whether the gripper should be drawn at the top or not.
"""
return self.SetFlag(self.optionGripperTop, attop)
def CloseButton(self, visible=True):
"""
Indicates that a close button should be drawn for the pane.
:param bool `visible`: whether the close button should be visible or not.
"""
return self.SetFlag(self.buttonClose, visible)
def MaximizeButton(self, visible=True):
"""
Indicates that a maximize button should be drawn for the pane.
:param bool `visible`: whether the maximize button should be visible or not.
"""
return self.SetFlag(self.buttonMaximize, visible)
def MinimizeButton(self, visible=True):
"""
Indicates that a minimize button should be drawn for the pane.
:param bool `visible`: whether the minimize button should be visible or not.
"""
return self.SetFlag(self.buttonMinimize, visible)
def PinButton(self, visible=True):
"""
Indicates that a pin button should be drawn for the pane.
:param bool `visible`: whether the pin button should be visible or not.
"""
return self.SetFlag(self.buttonPin, visible)
def DestroyOnClose(self, b=True):
"""
Indicates whether a pane should be destroyed when it is closed.
Normally a pane is simply hidden when the close button is clicked. Setting
`b` to ``True`` will cause the window to be destroyed when the user clicks
the pane's close button.
:param bool `b`: whether the pane should be destroyed when it is closed or not.
"""
return self.SetFlag(self.optionDestroyOnClose, b)
def TopDockable(self, b=True):
"""
Indicates whether a pane can be docked at the top of the frame.
:param bool `b`: whether the pane can be docked at the top or not.
"""
return self.SetFlag(self.optionTopDockable, b)
def BottomDockable(self, b=True):
"""
Indicates whether a pane can be docked at the bottom of the frame.
:param bool `b`: whether the pane can be docked at the bottom or not.
"""
return self.SetFlag(self.optionBottomDockable, b)
def LeftDockable(self, b=True):
"""
Indicates whether a pane can be docked on the left of the frame.
:param bool `b`: whether the pane can be docked at the left or not.
"""
return self.SetFlag(self.optionLeftDockable, b)
def RightDockable(self, b=True):
"""
Indicates whether a pane can be docked on the right of the frame.
:param bool `b`: whether the pane can be docked at the right or not.
"""
return self.SetFlag(self.optionRightDockable, b)
def Floatable(self, b=True):
"""
Sets whether the user will be able to undock a pane and turn it
into a floating window.
:param bool `b`: whether the pane can be floated or not.
"""
return self.SetFlag(self.optionFloatable, b)
def Movable(self, b=True):
"""
Indicates whether a pane can be moved.
:param bool `b`: whether the pane can be moved or not.
"""
return self.SetFlag(self.optionMovable, b)
def NotebookDockable(self, b=True):
"""
Indicates whether a pane can be docked in an automatic :class:`~lib.agw.aui.auibook.AuiNotebook`.
:param bool `b`: whether the pane can be docked in a notebook or not.
"""
return self.SetFlag(self.optionNotebookDockable, b)
def DockFixed(self, b=True):
"""
Causes the containing dock to have no resize sash. This is useful
for creating panes that span the entire width or height of a dock, but should
not be resizable in the other direction.
:param bool `b`: whether the pane will have a resize sash or not.
"""
return self.SetFlag(self.optionDockFixed, b)
def Dockable(self, b=True):
"""
Specifies whether a frame can be docked or not. It is the same as specifying
:meth:`TopDockable` . :meth:`BottomDockable` . :meth:`LeftDockable` . :meth:`RightDockable` .
:param bool `b`: whether the frame can be docked or not.
"""
return self.TopDockable(b).BottomDockable(b).LeftDockable(b).RightDockable(b)
def TopSnappable(self, b=True):
"""
Indicates whether a pane can be snapped at the top of the main frame.
:param bool `b`: whether the pane can be snapped at the top of the main frame or not.
"""
return self.SetFlag(self.optionTopSnapped, b)
def BottomSnappable(self, b=True):
"""
Indicates whether a pane can be snapped at the bottom of the main frame.
:param bool `b`: whether the pane can be snapped at the bottom of the main frame or not.
"""
return self.SetFlag(self.optionBottomSnapped, b)
def LeftSnappable(self, b=True):
"""
Indicates whether a pane can be snapped on the left of the main frame.
:param bool `b`: whether the pane can be snapped at the left of the main frame or not.
"""
return self.SetFlag(self.optionLeftSnapped, b)
def RightSnappable(self, b=True):
"""
Indicates whether a pane can be snapped on the right of the main frame.
:param bool `b`: whether the pane can be snapped at the right of the main frame or not.
"""
return self.SetFlag(self.optionRightSnapped, b)
def Snappable(self, b=True):
"""
Indicates whether a pane can be snapped on the main frame. This is
equivalent as calling :meth:`TopSnappable` . :meth:`BottomSnappable` . :meth:`LeftSnappable` . :meth:`RightSnappable` .
:param bool `b`: whether the pane can be snapped on the main frame or not.
"""
return self.TopSnappable(b).BottomSnappable(b).LeftSnappable(b).RightSnappable(b)
def FlyOut(self, b=True):
"""
Indicates whether a pane, when floating, has a "fly-out" effect
(i.e., floating panes which only show themselves when moused over).
:param bool `b`: whether the pane can be snapped on the main frame or not.
"""
return self.SetFlag(self.optionFlyOut, b)
# Copy over the members that pertain to docking position
def SetDockPos(self, source):
"""
Copies the `source` pane members that pertain to docking position to `self`.
:param AuiPaneInfo `source`: the source pane from where to copy the attributes.
"""
self.dock_direction = source.dock_direction
self.dock_layer = source.dock_layer
self.dock_row = source.dock_row
self.dock_pos = source.dock_pos
self.dock_proportion = source.dock_proportion
self.floating_pos = wx.Point(*source.floating_pos)
self.floating_size = wx.Size(*source.floating_size)
self.rect = wx.Rect(*source.rect)
return self
def DefaultPane(self):
""" Specifies that the pane should adopt the default pane settings. """
state = self.state
state |= self.optionTopDockable | self.optionBottomDockable | \
self.optionLeftDockable | self.optionRightDockable | \
self.optionNotebookDockable | \
self.optionFloatable | self.optionMovable | self.optionResizable | \
self.optionCaption | self.optionPaneBorder | self.buttonClose
self.state = state
return self
def CentrePane(self):
"""
Specifies that the pane should adopt the default center pane settings.
Centre panes usually do not have caption bars. This function provides an easy way of
preparing a pane to be displayed in the center dock position.
"""
return self.CenterPane()
def CenterPane(self):
"""
Specifies that the pane should adopt the default center pane settings.
Centre panes usually do not have caption bars. This function provides an easy way of
preparing a pane to be displayed in the center dock position.
"""
self.state = 0
return self.Center().PaneBorder().Resizable()
def ToolbarPane(self):
""" Specifies that the pane should adopt the default toolbar pane settings. """
self.DefaultPane()
state = self.state
state |= (self.optionToolbar | self.optionGripper)
state &= ~(self.optionResizable | self.optionCaption | self.optionCaptionLeft)
if self.dock_layer == 0:
self.dock_layer = 10
self.state = state
return self
def Icon(self, icon):
"""
Specifies whether an icon is drawn on the left of the caption text when
the pane is docked. If `icon` is ``None`` or :class:`NullIcon`, no icon is drawn on
the caption space.
:param icon: an icon to draw on the caption space, or ``None``.
:type `icon`: :class:`Icon` or ``None``
"""
if icon is None:
icon = wx.NullIcon
self.icon = icon
return self
def SetFlag(self, flag, option_state):
"""
Turns the property given by `flag` on or off with the `option_state`
parameter.
:param integer `flag`: the property to set;
:param bool `option_state`: either ``True`` or ``False``.
"""
state = self.state
if option_state:
state |= flag
else:
state &= ~flag
self.state = state
if flag in [self.buttonClose, self.buttonMaximize, self.buttonMinimize, self.buttonPin]:
self.ResetButtons()
return self
def HasFlag(self, flag):
"""
Returns ``True`` if the the property specified by flag is active for the pane.
:param integer `flag`: the property to check for activity.
"""
return (self.state & flag and [True] or [False])[0]
def ResetButtons(self):
"""
Resets all the buttons and recreates them from scratch depending on the
:class:`AuiManager` flags.
"""
floating = self.HasFlag(self.optionFloating)
self.buttons = []
if not floating and self.HasMinimizeButton():
button = AuiPaneButton(AUI_BUTTON_MINIMIZE)
self.buttons.append(button)
if not floating and self.HasMaximizeButton():
button = AuiPaneButton(AUI_BUTTON_MAXIMIZE_RESTORE)
self.buttons.append(button)
if not floating and self.HasPinButton():
button = AuiPaneButton(AUI_BUTTON_PIN)
self.buttons.append(button)
if self.HasCloseButton():
button = AuiPaneButton(AUI_BUTTON_CLOSE)
self.buttons.append(button)
def CountButtons(self):
""" Returns the number of visible buttons in the docked pane. """
n = 0
if self.HasCaption() or self.HasCaptionLeft():
if isinstance(wx.GetTopLevelParent(self.window), AuiFloatingFrame):
return 1
if self.HasCloseButton():
n += 1
if self.HasMaximizeButton():
n += 1
if self.HasMinimizeButton():
n += 1
if self.HasPinButton():
n += 1
return n
def IsHorizontal(self):
""" Returns ``True`` if the pane `dock_direction` is horizontal. """
return self.dock_direction in [AUI_DOCK_TOP, AUI_DOCK_BOTTOM]
def IsVertical(self):
""" Returns ``True`` if the pane `dock_direction` is vertical. """
return self.dock_direction in [AUI_DOCK_LEFT, AUI_DOCK_RIGHT]
# Null AuiPaneInfo reference
NonePaneInfo = AuiPaneInfo()
""" Null :class:`AuiPaneInfo` reference, an invalid instance of :class:`AuiPaneInfo`. """
# ---------------------------------------------------------------------------- #
class AuiDockingGuide(wx.Frame):
""" Base class for :class:`AuiSingleDockingGuide` and :class:`AuiCenterDockingGuide`."""
def __init__(self, parent, id=wx.ID_ANY, title="", pos=wx.DefaultPosition,
size=wx.DefaultSize, style=wx.FRAME_TOOL_WINDOW | wx.STAY_ON_TOP |
wx.FRAME_NO_TASKBAR | wx.NO_BORDER, name="AuiDockingGuide"):
"""
Default class constructor. Used internally, do not call it in your code!
:param `parent`: the :class:`AuiManager` parent;
:param integer `id`: the window identifier. It may take a value of -1 to indicate a default value.
:param string `title`: the caption to be displayed on the frame's title bar.
:param Point `pos`: the window position. A value of (-1, -1) indicates a default position,
chosen by either the windowing system or wxPython, depending on platform.
:param Size `size`: the window size. A value of (-1, -1) indicates a default size, chosen by
either the windowing system or wxPython, depending on platform.
:param integer `style`: the window style.
:param string `name`: the name of the window. This parameter is used to associate a name with the
item, allowing the application user to set Motif resource values for individual windows.
"""
wx.Frame.__init__(self, parent, id, title, pos, size, style, name=name)
def HitTest(self, x, y):
"""
To be overridden by parent classes.
:param integer `x`: the `x` mouse position;
:param integer `y`: the `y` mouse position.
"""
return 0
def ValidateNotebookDocking(self, valid):
"""
To be overridden by parent classes.
:param bool `valid`: whether a pane can be docked on top to another to form an automatic
:class:`~lib.agw.aui.auibook.AuiNotebook`.
"""
return 0
# ============================================================================
# implementation
# ============================================================================
# ---------------------------------------------------------------------------
# AuiDockingGuideWindow
# ---------------------------------------------------------------------------
class AuiDockingGuideWindow(wx.Window):
""" Target class for :class:`AuiDockingGuide` and :class:`AuiCenterDockingGuide`. """
def __init__(self, parent, rect, direction=0, center=False, useAero=False):
"""
Default class constructor. Used internally, do not call it in your code!
:param `parent`: the :class:`AuiManager` parent;
:param Rect `rect`: the window rect;
:param integer `direction`: one of ``wx.TOP``, ``wx.BOTTOM``, ``wx.LEFT``, ``wx.RIGHT``,
``wx.CENTER``;
:param bool `center`: whether the calling class is a :class:`AuiCenterDockingGuide`;
:param bool `useAero`: whether to use the new Aero-style bitmaps or Whidbey-style bitmaps
for the docking guide.
"""
wx.Window.__init__(self, parent, -1, rect.GetPosition(), rect.GetSize(), wx.NO_BORDER)
self._direction = direction
self._center = center
self._valid = True
self._useAero = useAero
self._bmp_unfocus, self._bmp_focus = GetDockingImage(direction, useAero, center)
self._currentImage = self._bmp_unfocus
self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
self.Bind(wx.EVT_PAINT, self.OnPaint)
def SetValid(self, valid):
"""
Sets the docking direction as valid or invalid.
:param bool `valid`: whether the docking direction is allowed or not.
"""
self._valid = valid
def IsValid(self):
""" Returns whether the docking direction is valid. """
return self._valid
def OnEraseBackground(self, event):
"""
Handles the ``wx.EVT_ERASE_BACKGROUND`` event for :class:`AuiDockingGuideWindow`.
:param `event`: a :class:`EraseEvent` to be processed.
:note: This is intentionally empty to reduce flickering while drawing.
"""
pass
def DrawBackground(self, dc):
"""
Draws the docking guide background.
:param `dc`: a :class:`DC` device context object.
"""
rect = self.GetClientRect()
dc.SetPen(wx.TRANSPARENT_PEN)
dc.SetBrush(wx.Brush(colourTargetBackground))
dc.DrawRectangleRect(rect)
dc.SetPen(wx.Pen(colourTargetBorder))
left = rect.GetLeft()
top = rect.GetTop()
right = rect.GetRight()
bottom = rect.GetBottom()
if self._direction != wx.CENTER:
if not self._center or self._direction != wx.BOTTOM:
dc.DrawLine(left, top, right+1, top)
if not self._center or self._direction != wx.RIGHT:
dc.DrawLine(left, top, left, bottom+1)
if not self._center or self._direction != wx.LEFT:
dc.DrawLine(right, top, right, bottom+1)
if not self._center or self._direction != wx.TOP:
dc.DrawLine(left, bottom, right+1, bottom)
dc.SetPen(wx.Pen(colourTargetShade))
if self._direction != wx.RIGHT:
dc.DrawLine(left + 1, top + 1, left + 1, bottom)
if self._direction != wx.BOTTOM:
dc.DrawLine(left + 1, top + 1, right, top + 1)
def DrawDottedLine(self, dc, point, length, vertical):
"""
Draws a dotted line (not used if the docking guide images are ok).
:param `dc`: a :class:`DC` device context object;
:param `point`: a :class:`Point` where to start drawing the dotted line;
:param integer `length`: the length of the dotted line;
:param bool `vertical`: whether it is a vertical docking guide window or not.
"""
for i in xrange(0, length, 2):
dc.DrawPoint(point.x, point.y)
if vertical:
point.y += 2
else:
point.x += 2
def DrawIcon(self, dc):
"""
Draws the docking guide icon (not used if the docking guide images are ok).
:param `dc`: a :class:`DC` device context object.
"""
rect = wx.Rect(*self.GetClientRect())
point = wx.Point()
length = 0
rect.Deflate(4, 4)
dc.SetPen(wx.Pen(colourIconBorder))
dc.SetBrush(wx.Brush(colourIconBackground))
dc.DrawRectangleRect(rect)
right1 = rect.GetRight() + 1
bottom1 = rect.GetBottom() + 1
dc.SetPen(wx.Pen(colourIconShadow))
dc.DrawLine(rect.x + 1, bottom1, right1 + 1, bottom1)
dc.DrawLine(right1, rect.y + 1, right1, bottom1 + 1)
rect.Deflate(1, 1)
if self._direction == wx.TOP:
rect.height -= rect.height / 2
point = rect.GetBottomLeft()
length = rect.width
elif self._direction == wx.LEFT:
rect.width -= rect.width / 2
point = rect.GetTopRight()
length = rect.height
elif self._direction == wx.RIGHT:
rect.x += rect.width / 2
rect.width -= rect.width / 2
point = rect.GetTopLeft()
length = rect.height
elif self._direction == wx.BOTTOM:
rect.y += rect.height / 2
rect.height -= rect.height / 2
point = rect.GetTopLeft()
length = rect.width
elif self._direction == wx.CENTER:
rect.Deflate(1, 1)
point = rect.GetTopLeft()
length = rect.width
dc.GradientFillLinear(rect, colourIconDockingPart1,
colourIconDockingPart2, self._direction)
dc.SetPen(wx.Pen(colourIconBorder))
if self._direction == wx.CENTER:
self.DrawDottedLine(dc, rect.GetTopLeft(), rect.width, False)
self.DrawDottedLine(dc, rect.GetTopLeft(), rect.height, True)
self.DrawDottedLine(dc, rect.GetBottomLeft(), rect.width, False)
self.DrawDottedLine(dc, rect.GetTopRight(), rect.height, True)
elif self._direction in [wx.TOP, wx.BOTTOM]:
self.DrawDottedLine(dc, point, length, False)
else:
self.DrawDottedLine(dc, point, length, True)
def DrawArrow(self, dc):
"""
Draws the docking guide arrow icon (not used if the docking guide images are ok).
:param `dc`: a :class:`DC` device context object.
"""
rect = self.GetClientRect()
point = wx.Point()
point.x = (rect.GetLeft() + rect.GetRight()) / 2
point.y = (rect.GetTop() + rect.GetBottom()) / 2
rx, ry = wx.Size(), wx.Size()
if self._direction == wx.TOP:
rx = wx.Size(1, 0)
ry = wx.Size(0, 1)
elif self._direction == wx.LEFT:
rx = wx.Size(0, -1)
ry = wx.Size(1, 0)
elif self._direction == wx.RIGHT:
rx = wx.Size(0, 1)
ry = wx.Size(-1, 0)
elif self._direction == wx.BOTTOM:
rx = wx.Size(-1, 0)
ry = wx.Size(0, -1)
point.x += ry.x*3
point.y += ry.y*3
dc.SetPen(wx.Pen(colourIconArrow))
for i in xrange(4):
pt1 = wx.Point(point.x - rx.x*i, point.y - rx.y*i)
pt2 = wx.Point(point.x + rx.x*(i+1), point.y + rx.y*(i+1))
dc.DrawLinePoint(pt1, pt2)
point.x += ry.x
point.y += ry.y
def OnPaint(self, event):
"""
Handles the ``wx.EVT_PAINT`` event for :class:`AuiDockingGuideWindow`.
:param `event`: a :class:`PaintEvent` to be processed.
"""
dc = wx.AutoBufferedPaintDC(self)
if self._currentImage.IsOk() and self._valid:
dc.DrawBitmap(self._currentImage, 0, 0, True)
else:
self.Draw(dc)
def Draw(self, dc):
"""
Draws the whole docking guide window (not used if the docking guide images are ok).
:param `dc`: a :class:`DC` device context object.
"""
self.DrawBackground(dc)
if self._valid:
self.DrawIcon(dc)
self.DrawArrow(dc)
def UpdateDockGuide(self, pos):
"""
Updates the docking guide images depending on the mouse position, using focused
images if the mouse is inside the docking guide or unfocused images if it is
outside.
:param `pos`: a :class:`Point` mouse position.
"""
inside = self.GetScreenRect().Contains(pos)
if inside:
image = self._bmp_focus
else:
image = self._bmp_unfocus
if image != self._currentImage:
self._currentImage = image
self.Refresh()
self.Update()
# ---------------------------------------------------------------------------
# AuiSingleDockingGuide
# ---------------------------------------------------------------------------
class AuiSingleDockingGuide(AuiDockingGuide):
""" A docking guide window for single docking hint (not diamond-shaped HUD). """
def __init__(self, parent, direction=0):
"""
Default class constructor. Used internally, do not call it in your code!
:param `parent`: the :class:`AuiManager` parent;
:param integer `direction`: one of ``wx.TOP``, ``wx.BOTTOM``, ``wx.LEFT``, ``wx.RIGHT``.
"""
self._direction = direction
style = wx.FRAME_TOOL_WINDOW | wx.STAY_ON_TOP | \
wx.FRAME_NO_TASKBAR | wx.NO_BORDER
# Use of FRAME_SHAPED on wxMac causes the frame to be visible
# breaking the docking hints.
if wx.Platform != '__WXMAC__':
style |= wx.FRAME_SHAPED
AuiDockingGuide.__init__(self, parent, style=style, name="auiSingleDockTarget")
self.Hide()
useAero = GetManager(self.GetParent()).GetAGWFlags() & AUI_MGR_AERO_DOCKING_GUIDES
useWhidbey = GetManager(self.GetParent()).GetAGWFlags() & AUI_MGR_WHIDBEY_DOCKING_GUIDES
self._useAero = useAero or useWhidbey
self._valid = True
if useAero:
sizeX, sizeY = aeroguideSizeX, aeroguideSizeY
elif useWhidbey:
sizeX, sizeY = whidbeySizeX, whidbeySizeY
else:
sizeX, sizeY = guideSizeX, guideSizeY
if direction not in [wx.TOP, wx.BOTTOM]:
sizeX, sizeY = sizeY, sizeX
if self._useAero:
self.CreateShapesWithStyle(useWhidbey)
if wx.Platform == "__WXGTK__":
self.Bind(wx.EVT_WINDOW_CREATE, self.SetGuideShape)
else:
self.SetGuideShape()
self.SetSize(self.region.GetBox().GetSize())
else:
self.SetSize((sizeX, sizeY))
self.rect = wx.Rect(0, 0, sizeX, sizeY)
if self._useAero:
useAero = (useWhidbey and [2] or [1])[0]
else:
useAero = 0
self.target = AuiDockingGuideWindow(self, self.rect, direction, False, useAero)
def CreateShapesWithStyle(self, useWhidbey):
"""
Creates the docking guide window shape based on which docking bitmaps are used.
:param bool `useWhidbey`: if ``True``, use Whidbey-style bitmaps; if ``False``, use the
Aero-style bitmaps.
"""
sizeX, sizeY = aeroguideSizeX, aeroguideSizeY
if useWhidbey:
sizeX, sizeY = whidbeySizeX, whidbeySizeY
if self._direction not in [wx.TOP, wx.BOTTOM]:
sizeX, sizeY = sizeY, sizeX
useAero = (useWhidbey and [2] or [1])[0]
bmp, dummy = GetDockingImage(self._direction, useAero, False)
region = wx.RegionFromBitmap(bmp)
self.region = region
def AeroMove(self, pos):
"""
Moves the docking window to the new position. Overridden in children classes.
:param Point `pos`: the new docking guide position.
"""
pass
def SetGuideShape(self, event=None):
"""
Sets the correct shape for the docking guide window.
:param `event`: on wxGTK, a :class:`WindowCreateEvent` event to process.
"""
self.SetShape(self.region)
if event is not None:
# Skip the event on wxGTK
event.Skip()
wx.CallAfter(wx.SafeYield, self, True)
def SetShape(self, region):
"""
If the platform supports it, sets the shape of the window to that depicted by `region`.
The system will not display or respond to any mouse event for the pixels that lie
outside of the region. To reset the window to the normal rectangular shape simply call
:meth:`SetShape` again with an empty region.
:param Region `region`: the shape of the frame.
:note: Overridden for wxMAC.
"""
if wx.Platform == '__WXMAC__':
# HACK so we don't crash when SetShape is called
return
else:
super(AuiSingleDockingGuide, self).SetShape(region)
def SetValid(self, valid):
"""
Sets the docking direction as valid or invalid.
:param bool `valid`: whether the docking direction is allowed or not.
"""
self._valid = valid
def IsValid(self):
""" Returns whether the docking direction is valid. """
return self._valid
def UpdateDockGuide(self, pos):
"""
Updates the docking guide images depending on the mouse position, using focused
images if the mouse is inside the docking guide or unfocused images if it is
outside.
:param Point `pos`: the mouse position.
"""
self.target.UpdateDockGuide(pos)
def HitTest(self, x, y):
"""
Checks if the mouse position is inside the target window rect.
:param integer `x`: the `x` mouse position;
:param integer `y`: the `y` mouse position.
"""
if self.target.GetScreenRect().Contains((x, y)):
return wx.ALL
return -1
# ---------------------------------------------------------------------------
# AuiCenterDockingGuide
# ---------------------------------------------------------------------------
class AuiCenterDockingGuide(AuiDockingGuide):
""" A docking guide window for multiple docking hint (diamond-shaped HUD). """
def __init__(self, parent):
"""
Default class constructor.
Used internally, do not call it in your code!
:param `parent`: the :class:`AuiManager` parent.
"""
AuiDockingGuide.__init__(self, parent, style=wx.FRAME_TOOL_WINDOW | wx.STAY_ON_TOP |
wx.FRAME_NO_TASKBAR | wx.NO_BORDER | wx.FRAME_SHAPED,
name="auiCenterDockTarget")
self.Hide()
self.CreateShapesWithStyle()
self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
if wx.Platform == "__WXGTK__":
self.Bind(wx.EVT_WINDOW_CREATE, self.SetGuideShape)
else:
self.SetGuideShape()
self.SetSize(self.region.GetBox().GetSize())
self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
self.Bind(wx.EVT_PAINT, self.OnPaint)
def CreateShapesWithStyle(self):
""" Creates the docking guide window shape based on which docking bitmaps are used. """
useAero = (GetManager(self.GetParent()).GetAGWFlags() & AUI_MGR_AERO_DOCKING_GUIDES) != 0
useWhidbey = (GetManager(self.GetParent()).GetAGWFlags() & AUI_MGR_WHIDBEY_DOCKING_GUIDES) != 0
self._useAero = 0
if useAero:
self._useAero = 1
elif useWhidbey:
self._useAero = 2
if useAero:
sizeX, sizeY = aeroguideSizeX, aeroguideSizeY
elif useWhidbey:
sizeX, sizeY = whidbeySizeX, whidbeySizeY
else:
sizeX, sizeY = guideSizeX, guideSizeY
rectLeft = wx.Rect(0, sizeY, sizeY, sizeX)
rectTop = wx.Rect(sizeY, 0, sizeX, sizeY)
rectRight = wx.Rect(sizeY+sizeX, sizeY, sizeY, sizeX)
rectBottom = wx.Rect(sizeY, sizeX + sizeY, sizeX, sizeY)
rectCenter = wx.Rect(sizeY, sizeY, sizeX, sizeX)
if not self._useAero:
self.targetLeft = AuiDockingGuideWindow(self, rectLeft, wx.LEFT, True, useAero)
self.targetTop = AuiDockingGuideWindow(self, rectTop, wx.TOP, True, useAero)
self.targetRight = AuiDockingGuideWindow(self, rectRight, wx.RIGHT, True, useAero)
self.targetBottom = AuiDockingGuideWindow(self, rectBottom, wx.BOTTOM, True, useAero)
self.targetCenter = AuiDockingGuideWindow(self, rectCenter, wx.CENTER, True, useAero)
# top-left diamond
tld = [wx.Point(rectTop.x, rectTop.y+rectTop.height-8),
wx.Point(rectLeft.x+rectLeft.width-8, rectLeft.y),
rectTop.GetBottomLeft()]
# bottom-left diamond
bld = [wx.Point(rectLeft.x+rectLeft.width-8, rectLeft.y+rectLeft.height),
wx.Point(rectBottom.x, rectBottom.y+8),
rectBottom.GetTopLeft()]
# top-right diamond
trd = [wx.Point(rectTop.x+rectTop.width, rectTop.y+rectTop.height-8),
wx.Point(rectRight.x+8, rectRight.y),
rectRight.GetTopLeft()]
# bottom-right diamond
brd = [wx.Point(rectRight.x+8, rectRight.y+rectRight.height),
wx.Point(rectBottom.x+rectBottom.width, rectBottom.y+8),
rectBottom.GetTopRight()]
self._triangles = [tld[0:2], bld[0:2],
[wx.Point(rectTop.x+rectTop.width-1, rectTop.y+rectTop.height-8),
wx.Point(rectRight.x+7, rectRight.y)],
[wx.Point(rectRight.x+7, rectRight.y+rectRight.height),
wx.Point(rectBottom.x+rectBottom.width-1, rectBottom.y+8)]]
region = wx.Region()
region.UnionRect(rectLeft)
region.UnionRect(rectTop)
region.UnionRect(rectRight)
region.UnionRect(rectBottom)
region.UnionRect(rectCenter)
region.UnionRegion(wx.RegionFromPoints(tld))
region.UnionRegion(wx.RegionFromPoints(bld))
region.UnionRegion(wx.RegionFromPoints(trd))
region.UnionRegion(wx.RegionFromPoints(brd))
elif useAero:
self._aeroBmp = aero_dock_pane.GetBitmap()
region = wx.RegionFromBitmap(self._aeroBmp)
self._allAeroBmps = [aero_dock_pane_left.GetBitmap(), aero_dock_pane_top.GetBitmap(),
aero_dock_pane_right.GetBitmap(), aero_dock_pane_bottom.GetBitmap(),
aero_dock_pane_center.GetBitmap(), aero_dock_pane.GetBitmap()]
self._deniedBitmap = aero_denied.GetBitmap()
self._aeroRects = [rectLeft, rectTop, rectRight, rectBottom, rectCenter]
self._valid = True
elif useWhidbey:
self._aeroBmp = whidbey_dock_pane.GetBitmap()
region = wx.RegionFromBitmap(self._aeroBmp)
self._allAeroBmps = [whidbey_dock_pane_left.GetBitmap(), whidbey_dock_pane_top.GetBitmap(),
whidbey_dock_pane_right.GetBitmap(), whidbey_dock_pane_bottom.GetBitmap(),
whidbey_dock_pane_center.GetBitmap(), whidbey_dock_pane.GetBitmap()]
self._deniedBitmap = whidbey_denied.GetBitmap()
self._aeroRects = [rectLeft, rectTop, rectRight, rectBottom, rectCenter]
self._valid = True
self.region = region
def SetGuideShape(self, event=None):
"""
Sets the correct shape for the docking guide window.
:param `event`: on wxGTK, a :class:`WindowCreateEvent` event to process.
"""
self.SetShape(self.region)
if event is not None:
# Skip the event on wxGTK
event.Skip()
wx.CallAfter(wx.SafeYield, self, True)
def UpdateDockGuide(self, pos):
"""
Updates the docking guides images depending on the mouse position, using focused
images if the mouse is inside the docking guide or unfocused images if it is
outside.
:param Point `pos`: the mouse position.
"""
if not self._useAero:
for target in self.GetChildren():
target.UpdateDockGuide(pos)
else:
lenRects = len(self._aeroRects)
for indx, rect in enumerate(self._aeroRects):
if rect.Contains(pos):
if self._allAeroBmps[indx] != self._aeroBmp:
if indx < lenRects - 1 or (indx == lenRects - 1 and self._valid):
self._aeroBmp = self._allAeroBmps[indx]
self.Refresh()
else:
self._aeroBmp = self._allAeroBmps[-1]
self.Refresh()
return
if self._aeroBmp != self._allAeroBmps[-1]:
self._aeroBmp = self._allAeroBmps[-1]
self.Refresh()
def HitTest(self, x, y):
"""
Checks if the mouse position is inside the target windows rect.
:param integer `x`: the `x` mouse position;
:param integer `y`: the `y` mouse position.
"""
if not self._useAero:
if self.targetLeft.GetScreenRect().Contains((x, y)):
return wx.LEFT
if self.targetTop.GetScreenRect().Contains((x, y)):
return wx.UP
if self.targetRight.GetScreenRect().Contains((x, y)):
return wx.RIGHT
if self.targetBottom.GetScreenRect().Contains((x, y)):
return wx.DOWN
if self.targetCenter.IsValid() and self.targetCenter.GetScreenRect().Contains((x, y)):
return wx.CENTER
else:
constants = [wx.LEFT, wx.UP, wx.RIGHT, wx.DOWN, wx.CENTER]
lenRects = len(self._aeroRects)
for indx, rect in enumerate(self._aeroRects):
if rect.Contains((x, y)):
if indx < lenRects or (indx == lenRects-1 and self._valid):
return constants[indx]
return -1
def ValidateNotebookDocking(self, valid):
"""
Sets whether a pane can be docked on top of another to create an automatic
:class:`~lib.agw.aui.auibook.AuiNotebook`.
:param bool `valid`: whether a pane can be docked on top to another to form an automatic
:class:`~lib.agw.aui.auibook.AuiNotebook`.
"""
if not self._useAero:
if self.targetCenter.IsValid() != valid:
self.targetCenter.SetValid(valid)
self.targetCenter.Refresh()
else:
if self._valid != valid:
self._valid = valid
self.Refresh()
def AeroMove(self, pos):
"""
Moves the docking guide window to the new position.
:param Point `pos`: the new docking guide position.
"""
if not self._useAero:
return
useWhidbey = (GetManager(self.GetParent()).GetAGWFlags() & AUI_MGR_WHIDBEY_DOCKING_GUIDES) != 0
if useWhidbey:
sizeX, sizeY = whidbeySizeX, whidbeySizeY
else:
sizeX, sizeY = aeroguideSizeX, aeroguideSizeY
size = self.GetSize()
leftRect, topRect, rightRect, bottomRect, centerRect = self._aeroRects
thePos = pos + wx.Point((size.x-sizeY)/2, (size.y-sizeX)/2)
centerRect.SetPosition(thePos)
leftRect.SetPosition(thePos + wx.Point(-sizeY, 0))
topRect.SetPosition(thePos + wx.Point(0, -sizeY))
rightRect.SetPosition(thePos + wx.Point(sizeX, 0))
bottomRect.SetPosition(thePos + wx.Point(0, sizeX))
def OnEraseBackground(self, event):
"""
Handles the ``wx.EVT_ERASE_BACKGROUND`` event for :class:`AuiCenterDockingGuide`.
:param `event`: :class:`EraseEvent` to be processed.
:note: This is intentionally empty to reduce flickering while drawing.
"""
pass
def OnPaint(self, event):
"""
Handles the ``wx.EVT_PAINT`` event for :class:`AuiCenterDockingGuide`.
:param `event`: a :class:`PaintEvent` to be processed.
"""
dc = wx.AutoBufferedPaintDC(self)
if self._useAero:
dc.SetBrush(wx.TRANSPARENT_BRUSH)
dc.SetPen(wx.TRANSPARENT_PEN)
else:
dc.SetBrush(wx.Brush(colourTargetBackground))
dc.SetPen(wx.Pen(colourTargetBorder))
rect = self.GetClientRect()
dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height)
if self._useAero:
dc.DrawBitmap(self._aeroBmp, 0, 0, True)
if not self._valid:
diff = (self._useAero == 2 and [1] or [0])[0]
bmpX, bmpY = self._deniedBitmap.GetWidth(), self._deniedBitmap.GetHeight()
xPos, yPos = (rect.x + (rect.width)/2 - bmpX/2), (rect.y + (rect.height)/2 - bmpY/2)
dc.DrawBitmap(self._deniedBitmap, xPos+1, yPos+diff, True)
return
dc.SetPen(wx.Pen(colourTargetBorder, 2))
for pts in self._triangles:
dc.DrawLinePoint(pts[0], pts[1])
# ----------------------------------------------------------------------------
# AuiDockingHintWindow
# ----------------------------------------------------------------------------
class AuiDockingHintWindow(wx.Frame):
""" The original wxAUI docking window hint. """
def __init__(self, parent, id=wx.ID_ANY, title="", pos=wx.DefaultPosition,
size=wx.Size(1, 1), style=wx.FRAME_TOOL_WINDOW | wx.FRAME_FLOAT_ON_PARENT |
wx.FRAME_NO_TASKBAR | wx.NO_BORDER | wx.FRAME_SHAPED,
name="auiHintWindow"):
"""
Default class constructor. Used internally, do not call it in your code!
:param `parent`: the :class:`AuiManager` parent;
:param integer `id`: the window identifier. It may take a value of -1 to indicate a default value.
:param string `title`: the caption to be displayed on the frame's title bar;
:param Point `pos`: the window position. A value of (-1, -1) indicates a default position,
chosen by either the windowing system or wxPython, depending on platform;
:param Size `size`: the window size. A value of (-1, -1) indicates a default size, chosen by
either the windowing system or wxPython, depending on platform;
:param integer `style`: the window style;
:param string `name`: the name of the window. This parameter is used to associate a name with the
item, allowing the application user to set Motif resource values for individual windows.
"""
if wx.Platform == '__WXMAC__' and style & wx.FRAME_SHAPED:
# Having the shaped frame causes the frame to not be visible
# with the transparent style hints.
style -= wx.FRAME_SHAPED
wx.Frame.__init__(self, parent, id, title, pos, size, style, name=name)
self._blindMode = False
self._art = parent.GetEventHandler().GetArtProvider()
background = self._art.GetColour(AUI_DOCKART_HINT_WINDOW_COLOUR)
self.SetBackgroundColour(background)
# Can't set background colour on a frame on wxMac
# so add a panel to set the colour on.
if wx.Platform == '__WXMAC__':
sizer = wx.BoxSizer(wx.HORIZONTAL)
self.panel = wx.Panel(self)
sizer.Add(self.panel, 1, wx.EXPAND)
self.SetSizer(sizer)
self.panel.SetBackgroundColour(background)
else:
self.Bind(wx.EVT_PAINT, self.OnPaint)
self.Bind(wx.EVT_SIZE, self.OnSize)
def MakeVenetianBlinds(self):
"""
Creates the "venetian blind" effect if :class:`AuiManager` has the ``AUI_MGR_VENETIAN_BLINDS_HINT``
flag set.
"""
amount = 128
size = self.GetClientSize()
region = wx.Region(0, 0, size.x, 1)
for y in xrange(size.y):
# Reverse the order of the bottom 4 bits
j = (y & 8 and [1] or [0])[0] | (y & 4 and [2] or [0])[0] | \
(y & 2 and [4] or [0])[0] | (y & 1 and [8] or [0])[0]
if 16*j+8 < amount:
region.Union(0, y, size.x, 1)
self.SetShape(region)
def SetBlindMode(self, agwFlags):
"""
Sets whether venetian blinds or transparent hints will be shown as docking hint.
This depends on the :class:`AuiManager` flags.
:param integer `agwFlags`: the :class:`AuiManager` flags.
"""
self._blindMode = (agwFlags & AUI_MGR_VENETIAN_BLINDS_HINT) != 0
if self._blindMode or not self.CanSetTransparent():
self.MakeVenetianBlinds()
self.SetTransparent(255)
else:
self.SetShape(wx.Region())
if agwFlags & AUI_MGR_HINT_FADE == 0:
self.SetTransparent(80)
else:
self.SetTransparent(0)
def SetShape(self, region):
"""
If the platform supports it, sets the shape of the window to that depicted by `region`.
The system will not display or respond to any mouse event for the pixels that lie
outside of the region. To reset the window to the normal rectangular shape simply call
:meth:`SetShape` again with an empty region.
:param Region `region`: the shape of the frame.
:note: Overridden for wxMAC.
"""
if wx.Platform == '__WXMAC__':
# HACK so we don't crash when SetShape is called
return
else:
super(AuiDockingHintWindow, self).SetShape(region)
def Show(self, show=True):
"""
Show the hint window.
:param bool `show`: whether to show or hide the hint docking window.
"""
background = self._art.GetColour(AUI_DOCKART_HINT_WINDOW_COLOUR)
if wx.Platform == '__WXMAC__':
self.panel.SetBackgroundColour(background)
else:
self.SetBackgroundColour(background)
super(AuiDockingHintWindow, self).Show(show)
self.Refresh()
if wx.Platform == '__WXMAC__':
# Need to manually do layout since its a borderless frame.
self.Layout()
def OnSize(self, event):
"""
Handles the ``wx.EVT_SIZE`` event for :class:`AuiDockingHintWindow`.
:param `event`: a :class:`SizeEvent` to be processed.
"""
if self._blindMode or not self.CanSetTransparent():
self.MakeVenetianBlinds()
self.Refresh()
def OnPaint(self, event):
"""
Handles the ``wx.EVT_PAINT`` event for :class:`AuiDockingHintWindow`.
:param `event`: an instance of :class:`PaintEvent` to be processed.
"""
rect = wx.RectPS(wx.Point(0, 0), self.GetSize())
dc = wx.PaintDC(self)
event.Skip()
dc.SetBrush(wx.TRANSPARENT_BRUSH)
dc.SetPen(wx.Pen(wx.Colour(60, 60, 60), 5))
rect.Deflate(1, 1)
dc.DrawRectangleRect(rect)
# ---------------------------------------------------------------------------- #
# -- AuiFloatingFrame class implementation --
class AuiFloatingFrame(wx.MiniFrame):
""" AuiFloatingFrame is the frame class that holds floating panes. """
def __init__(self, parent, owner_mgr, pane=None, id=wx.ID_ANY, title="",
style=wx.FRAME_TOOL_WINDOW | wx.FRAME_FLOAT_ON_PARENT |
wx.FRAME_NO_TASKBAR | wx.CLIP_CHILDREN):
"""
Default class constructor. Used internally, do not call it in your code!
:param `parent`: the :class:`AuiManager` parent;
:param `owner_mgr`: the :class:`AuiManager` that manages the floating pane;
:param `pane`: the :class:`AuiPaneInfo` pane that is about to float;
:param integer `id`: the window identifier. It may take a value of -1 to indicate a default value.
:param string `title`: the caption to be displayed on the frame's title bar.
:param integer `style`: the window style.
"""
if pane and pane.IsResizeable():
style += wx.RESIZE_BORDER
if pane:
self._is_toolbar = pane.IsToolbar()
self._useNativeMiniframes = False
if AuiManager_UseNativeMiniframes(owner_mgr):
# On wxMac we always use native miniframes
self._useNativeMiniframes = True
style += wx.CAPTION + wx.SYSTEM_MENU
if pane.HasCloseButton():
style += wx.CLOSE_BOX
if pane.HasMaximizeButton():
style += wx.MAXIMIZE_BOX
if pane.HasMinimizeButton():
style += wx.MINIMIZE_BOX
wx.MiniFrame.__init__(self, parent, id, title, pos=pane.floating_pos,
size=pane.floating_size, style=style, name="auiFloatingFrame")
self._fly_timer = wx.Timer(self, wx.ID_ANY)
self._check_fly_timer = wx.Timer(self, wx.ID_ANY)
self.Bind(wx.EVT_CLOSE, self.OnClose)
self.Bind(wx.EVT_SIZE, self.OnSize)
self.Bind(wx.EVT_ACTIVATE, self.OnActivate)
self.Bind(wx.EVT_TIMER, self.OnCheckFlyTimer, self._check_fly_timer)
self.Bind(wx.EVT_TIMER, self.OnFlyTimer, self._fly_timer)
self.Bind(EVT_AUI_FIND_MANAGER, self.OnFindManager)
if self._useNativeMiniframes:
self.Bind(wx.EVT_MOVE, self.OnMoveEvent)
self.Bind(wx.EVT_MOVING, self.OnMoveEvent)
self.Bind(wx.EVT_IDLE, self.OnIdle)
self._useNativeMiniframes = True
self.SetExtraStyle(wx.WS_EX_PROCESS_IDLE)
else:
self.Bind(wx.EVT_MOVE, self.OnMove)
self._fly = False
self._send_size = True
self._alpha_amount = 255
self._owner_mgr = owner_mgr
self._moving = False
self._lastDirection = None
self._transparent = 255
self._last_rect = wx.Rect()
self._last2_rect = wx.Rect()
self._last3_rect = wx.Rect()
self._mgr = AuiManager()
self._mgr.SetManagedWindow(self)
self._mgr.SetArtProvider(owner_mgr.GetArtProvider())
self._mgr.SetAGWFlags(owner_mgr.GetAGWFlags())
def CopyAttributes(self, pane):
"""
Copies all the attributes of the input `pane` into another :class:`AuiPaneInfo`.
:param `pane`: the source :class:`AuiPaneInfo` from where to copy attributes.
"""
contained_pane = AuiPaneInfo()
contained_pane.name = pane.name
contained_pane.caption = pane.caption
contained_pane.window = pane.window
contained_pane.frame = pane.frame
contained_pane.state = pane.state
contained_pane.dock_direction = pane.dock_direction
contained_pane.dock_layer = pane.dock_layer
contained_pane.dock_row = pane.dock_row
contained_pane.dock_pos = pane.dock_pos
contained_pane.best_size = wx.Size(*pane.best_size)
contained_pane.min_size = wx.Size(*pane.min_size)
contained_pane.max_size = wx.Size(*pane.max_size)
contained_pane.floating_pos = wx.Point(*pane.floating_pos)
contained_pane.floating_size = wx.Size(*pane.floating_size)
contained_pane.dock_proportion = pane.dock_proportion
contained_pane.buttons = pane.buttons
contained_pane.rect = wx.Rect(*pane.rect)
contained_pane.icon = pane.icon
contained_pane.notebook_id = pane.notebook_id
contained_pane.transparent = pane.transparent
contained_pane.snapped = pane.snapped
contained_pane.minimize_mode = pane.minimize_mode
contained_pane.minimize_target = pane.minimize_target
return contained_pane
def SetPaneWindow(self, pane):
"""
Sets all the properties of a pane.
:param `pane`: the :class:`AuiPaneInfo` to analyze.
"""
self._is_toolbar = pane.IsToolbar()
self._pane_window = pane.window
if isinstance(pane.window, auibar.AuiToolBar):
pane.window.SetAuiManager(self._mgr)
self._pane_window.Reparent(self)
contained_pane = self.CopyAttributes(pane)
contained_pane.Dock().Center().Show(). \
CaptionVisible(False). \
PaneBorder(False). \
Layer(0).Row(0).Position(0)
if not contained_pane.HasGripper() and not self._useNativeMiniframes:
contained_pane.CaptionVisible(True)
indx = self._owner_mgr._panes.index(pane)
# Carry over the minimum size
pane_min_size = pane.window.GetMinSize()
# if the best size is smaller than the min size
# then set the min size to the best size as well
pane_best_size = contained_pane.best_size
if pane_best_size.IsFullySpecified() and (pane_best_size.x < pane_min_size.x or \
pane_best_size.y < pane_min_size.y):
pane_min_size = pane_best_size
self._pane_window.SetMinSize(pane_min_size)
# if the frame window's max size is greater than the min size
# then set the max size to the min size as well
cur_max_size = self.GetMaxSize()
if cur_max_size.IsFullySpecified() and (cur_max_size.x < pane_min_size.x or \
cur_max_size.y < pane_min_size.y):
self.SetMaxSize(pane_min_size)
art_provider = self._mgr.GetArtProvider()
caption_size = art_provider.GetMetric(AUI_DOCKART_CAPTION_SIZE)
button_size = art_provider.GetMetric(AUI_DOCKART_PANE_BUTTON_SIZE) + \
4*art_provider.GetMetric(AUI_DOCKART_PANE_BORDER_SIZE)
min_size = pane.window.GetMinSize()
if min_size.y < caption_size or min_size.x < button_size:
new_x, new_y = min_size.x, min_size.y
if min_size.y < caption_size:
new_y = (pane.IsResizeable() and [2*wx.SystemSettings.GetMetric(wx.SYS_EDGE_Y)+caption_size] or [1])[0]
if min_size.x < button_size:
new_x = (pane.IsResizeable() and [2*wx.SystemSettings.GetMetric(wx.SYS_EDGE_X)+button_size] or [1])[0]
self.SetMinSize((new_x, new_y))
else:
self.SetMinSize(min_size)
self._mgr.AddPane(self._pane_window, contained_pane)
self._mgr.Update()
if pane.min_size.IsFullySpecified():
# because SetSizeHints() calls Fit() too (which sets the window
# size to its minimum allowed), we keep the size before calling
# SetSizeHints() and reset it afterwards...
tmp = self.GetSize()
self.GetSizer().SetSizeHints(self)
self.SetSize(tmp)
self.SetTitle(pane.caption)
if pane.floating_size != wx.Size(-1, -1):
self.SetSize(pane.floating_size)
else:
size = pane.best_size
if size == wx.Size(-1, -1):
size = pane.min_size
if size == wx.Size(-1, -1):
size = self._pane_window.GetSize()
if self._owner_mgr and pane.HasGripper():
if pane.HasGripperTop():
size.y += self._owner_mgr._art.GetMetric(AUI_DOCKART_GRIPPER_SIZE)
else:
size.x += self._owner_mgr._art.GetMetric(AUI_DOCKART_GRIPPER_SIZE)
if not self._useNativeMiniframes:
size.y += self._owner_mgr._art.GetMetric(AUI_DOCKART_CAPTION_SIZE)
pane.floating_size = size
self.SetClientSize(size)
self._owner_mgr._panes[indx] = pane
self._fly_step = abs(pane.floating_size.y - \
(caption_size + 2*wx.SystemSettings.GetMetric(wx.SYS_EDGE_Y)))/10
self._floating_size = wx.Size(*self.GetSize())
if pane.IsFlyOut():
self._check_fly_timer.Start(50)
def GetOwnerManager(self):
""" Returns the :class:`AuiManager` that manages the pane. """
return self._owner_mgr
def OnSize(self, event):
"""
Handles the ``wx.EVT_SIZE`` event for :class:`AuiFloatingFrame`.
:param `event`: a :class:`SizeEvent` to be processed.
"""
if self._owner_mgr and self._send_size:
self._owner_mgr.OnFloatingPaneResized(self._pane_window, event.GetSize())
def OnClose(self, event):
"""
Handles the ``wx.EVT_CLOSE`` event for :class:`AuiFloatingFrame`.
:param `event`: a :class:`CloseEvent` to be processed.
"""
if self._owner_mgr:
self._owner_mgr.OnFloatingPaneClosed(self._pane_window, event)
if not event.GetVeto():
self._mgr.DetachPane(self._pane_window)
if isinstance(self._pane_window, auibar.AuiToolBar):
self._pane_window.SetAuiManager(self._owner_mgr)
# if we do not do this, then we can crash...
if self._owner_mgr and self._owner_mgr._action_window == self:
self._owner_mgr._action_window = None
self._mgr.UnInit()
self.Destroy()
def OnActivate(self, event):
"""
Handles the ``wx.EVT_ACTIVATE`` event for :class:`AuiFloatingFrame`.
:param `event`: a :class:`ActivateEvent` to be processed.
"""
if self._owner_mgr and event.GetActive():
self._owner_mgr.OnFloatingPaneActivated(self._pane_window)
def OnMove(self, event):
"""
Handles the ``wx.EVT_MOVE`` event for :class:`AuiFloatingFrame`.
:param `event`: a :class:`MoveEvent` to be processed.
.. note::
This event is not processed on wxMAC or if :class:`AuiManager` is not using the
``AUI_MGR_USE_NATIVE_MINIFRAMES`` style.
"""
if self._owner_mgr:
self._owner_mgr.OnFloatingPaneMoved(self._pane_window, event)
def OnMoveEvent(self, event):
"""
Handles the ``wx.EVT_MOVE`` and ``wx.EVT_MOVING`` events for :class:`AuiFloatingFrame`.
:param `event`: a :class:`MoveEvent` to be processed.
.. note::
This event is only processed on wxMAC or if :class:`AuiManager` is using the
``AUI_MGR_USE_NATIVE_MINIFRAMES`` style.
"""
win_rect = self.GetRect()
if win_rect == self._last_rect:
return
# skip the first move event
if self._last_rect.IsEmpty():
self._last_rect = wx.Rect(*win_rect)
return
# As on OSX moving windows are not getting all move events, only sporadically, this difference
# is almost always big on OSX, so avoid this early exit opportunity
if wx.Platform != '__WXMAC__':
# skip if moving too fast to avoid massive redraws and
# jumping hint windows
if abs(win_rect.x - self._last_rect.x) > 3 or abs(win_rect.y - self._last_rect.y) > 3:
self._last3_rect = wx.Rect(*self._last2_rect)
self._last2_rect = wx.Rect(*self._last_rect)
self._last_rect = wx.Rect(*win_rect)
# However still update the internally stored position to avoid
# snapping back to the old one later.
if self._owner_mgr:
self._owner_mgr.GetPane(self._pane_window).floating_pos = win_rect.GetPosition()
return
# prevent frame redocking during resize
if self._last_rect.GetSize() != win_rect.GetSize():
self._last3_rect = wx.Rect(*self._last2_rect)
self._last2_rect = wx.Rect(*self._last_rect)
self._last_rect = wx.Rect(*win_rect)
return
dir = wx.ALL
horiz_dist = abs(win_rect.x - self._last3_rect.x)
vert_dist = abs(win_rect.y - self._last3_rect.y)
if vert_dist >= horiz_dist:
if win_rect.y < self._last3_rect.y:
dir = wx.NORTH
else:
dir = wx.SOUTH
else:
if win_rect.x < self._last3_rect.x:
dir = wx.WEST
else:
dir = wx.EAST
self._last3_rect = wx.Rect(*self._last2_rect)
self._last2_rect = wx.Rect(*self._last_rect)
self._last_rect = wx.Rect(*win_rect)
if _VERSION_STRING < "2.9":
leftDown = wx.GetMouseState().LeftDown()
else:
leftDown = wx.GetMouseState().LeftIsDown()
if not leftDown:
return
if not self._moving:
self.OnMoveStart(event)
self._moving = True
if self._last3_rect.IsEmpty():
return
if event.GetEventType() == wx.wxEVT_MOVING:
self.OnMoving(event.GetRect(), dir)
else:
self.OnMoving(wx.RectPS(event.GetPosition(), self.GetSize()), dir)
def OnIdle(self, event):
"""
Handles the ``wx.EVT_IDLE`` event for :class:`AuiFloatingFrame`.
:param `event`: a :class:`IdleEvent` event to be processed.
.. note::
This event is only processed on wxMAC if :class:`AuiManager` is using the
``AUI_MGR_USE_NATIVE_MINIFRAMES`` style.
"""
if self._moving:
if _VERSION_STRING < "2.9":
leftDown = wx.GetMouseState().LeftDown()
else:
leftDown = wx.GetMouseState().LeftIsDown()
if not leftDown:
self._moving = False
self.OnMoveFinished()
else:
event.RequestMore()
def OnMoveStart(self, event):
"""
The user has just started moving the floating pane.
:param `event`: an instance of :class:`MouseEvent`.
.. note::
This event is only processed on wxMAC if :class:`AuiManager` is using the
``AUI_MGR_USE_NATIVE_MINIFRAMES`` style.
"""
# notify the owner manager that the pane has started to move
if self._owner_mgr:
if self._owner_mgr._from_move:
return
self._owner_mgr._action_window = self._pane_window
point = wx.GetMousePosition()
action_offset = point - self.GetPosition()
if self._is_toolbar:
self._owner_mgr._toolbar_action_offset = action_offset
self._owner_mgr.OnMotion_DragToolbarPane(point)
else:
self._owner_mgr._action_offset = action_offset
self._owner_mgr.OnMotion_DragFloatingPane(point)
def OnMoving(self, rect, direction):
"""
The user is moving the floating pane.
:param Rect `rect`: the pane client rectangle;
:param integer `direction`: the direction in which the pane is moving, can be one of
``wx.NORTH``, ``wx.SOUTH``, ``wx.EAST`` or ``wx.WEST``.
.. note::
This event is only processed on wxMAC if :class:`AuiManager` is using the
``AUI_MGR_USE_NATIVE_MINIFRAMES`` style.
"""
# notify the owner manager that the pane is moving
self.OnMoveStart(None)
self._lastDirection = direction
def OnMoveFinished(self):
"""
The user has just finished moving the floating pane.
.. note::
This method is used only on wxMAC if :class:`AuiManager` is using the
``AUI_MGR_USE_NATIVE_MINIFRAMES`` style.
"""
# notify the owner manager that the pane has finished moving
if self._owner_mgr:
self._owner_mgr._action_window = self._pane_window
point = wx.GetMousePosition()
if self._is_toolbar:
self._owner_mgr.OnLeftUp_DragToolbarPane(point)
else:
self._owner_mgr.OnLeftUp_DragFloatingPane(point)
self._owner_mgr.OnFloatingPaneMoved(self._pane_window, point)
def OnCheckFlyTimer(self, event):
"""
Handles the ``wx.EVT_TIMER`` event for :class:`AuiFloatingFrame`.
:param `event`: a :class:`TimerEvent` to be processed.
:note: This is used solely for "fly-out" panes.
"""
if self._owner_mgr:
pane = self._mgr.GetPane(self._pane_window)
if pane.IsFlyOut():
if self.IsShownOnScreen():
self.FlyOut()
def OnFindManager(self, event):
"""
Handles the ``EVT_AUI_FIND_MANAGER`` event for :class:`AuiFloatingFrame`.
:param `event`: a :class:`AuiManagerEvent` event to be processed.
"""
event.SetManager(self._owner_mgr)
def FlyOut(self):
""" Starts the flying in and out of a floating pane. """
if self._fly_timer.IsRunning():
return
if _VERSION_STRING < "2.9":
leftDown = wx.GetMouseState().LeftDown()
else:
leftDown = wx.GetMouseState().LeftIsDown()
if leftDown:
return
rect = wx.Rect(*self.GetScreenRect())
rect.Inflate(10, 10)
if rect.Contains(wx.GetMousePosition()):
if not self._fly:
return
self._send_size = False
self._fly_timer.Start(5)
else:
if self._fly:
return
self._send_size = False
self._fly_timer.Start(5)
def OnFlyTimer(self, event):
"""
Handles the ``wx.EVT_TIMER`` event for :class:`AuiFloatingFrame`.
:param `event`: a :class:`TimerEvent` to be processed.
"""
current_size = self.GetClientSize()
floating_size = wx.Size(*self._owner_mgr.GetPane(self._pane_window).floating_size)
if floating_size.y == -1:
floating_size = self._floating_size
if not self._fly:
min_size = self._mgr.GetArtProvider().GetMetric(AUI_DOCKART_CAPTION_SIZE)
if wx.Platform != "__WXMSW__":
min_size += 2*wx.SystemSettings.GetMetric(wx.SYS_EDGE_Y)
if current_size.y - self._fly_step <= min_size:
self.SetClientSize((current_size.x, min_size))
self._fly = True
self._fly_timer.Stop()
self._send_size = True
else:
self.SetClientSize((current_size.x, current_size.y-self._fly_step))
else:
if current_size.y + self._fly_step >= floating_size.y:
self.SetClientSize((current_size.x, floating_size.y))
self._fly = False
self._fly_timer.Stop()
self._send_size = True
else:
self.SetClientSize((current_size.x, current_size.y+self._fly_step))
self.Update()
self.Refresh()
def FadeOut(self):
""" Actually starts the fading out of the floating pane. """
while 1:
self._alpha_amount -= 10
if self._alpha_amount <= 0:
self._alpha_amount = 255
return
self.SetTransparent(self._alpha_amount)
wx.SafeYield()
wx.MilliSleep(15)
# -- static utility functions --
def DrawResizeHint(dc, rect):
"""
Draws a resize hint while a sash is dragged.
:param Rect `rect`: a rectangle which specifies the sash dimensions.
"""
if wx.Platform == "__WXMSW__" and wx.App.GetComCtl32Version() >= 600:
if wx.GetOsVersion()[1] > 5:
# Windows Vista
dc.SetPen(wx.Pen("black", 2, wx.SOLID))
dc.SetBrush(wx.TRANSPARENT_BRUSH)
else:
# Draw the nice XP style splitter
dc.SetPen(wx.TRANSPARENT_PEN)
dc.SetBrush(wx.BLACK_BRUSH)
dc.SetLogicalFunction(wx.INVERT)
dc.DrawRectangleRect(rect)
dc.SetLogicalFunction(wx.COPY)
else:
stipple = PaneCreateStippleBitmap()
brush = wx.BrushFromBitmap(stipple)
dc.SetBrush(brush)
dc.SetPen(wx.TRANSPARENT_PEN)
dc.SetLogicalFunction(wx.XOR)
dc.DrawRectangleRect(rect)
def CopyDocksAndPanes(src_docks, src_panes):
"""
This utility function creates shallow copies of
the dock and pane info. :class:`AuiManager` usually contain pointers
to :class:`AuiPaneInfo` classes, thus this function is necessary to reliably
reconstruct that relationship in the new dock info and pane info arrays.
:param `src_docks`: a list of :class:`AuiDockInfo` classes;
:param `src_panes`: a list of :class:`AuiPaneInfo` classes.
"""
dest_docks = src_docks
dest_panes = src_panes
for ii in xrange(len(dest_docks)):
dock = dest_docks[ii]
for jj in xrange(len(dock.panes)):
for kk in xrange(len(src_panes)):
if dock.panes[jj] == src_panes[kk]:
dock.panes[jj] = dest_panes[kk]
return dest_docks, dest_panes
def CopyDocksAndPanes2(src_docks, src_panes):
"""
This utility function creates full copies of
the dock and pane info. :class:`AuiManager` usually contain pointers
to :class:`AuiPaneInfo` classes, thus this function is necessary to reliably
reconstruct that relationship in the new dock info and pane info arrays.
:param `src_docks`: a list of :class:`AuiDockInfo` classes;
:param `src_panes`: a list of :class:`AuiPaneInfo` classes.
"""
dest_docks = []
for ii in xrange(len(src_docks)):
dest_docks.append(AuiDockInfo())
dest_docks[ii].dock_direction = src_docks[ii].dock_direction
dest_docks[ii].dock_layer = src_docks[ii].dock_layer
dest_docks[ii].dock_row = src_docks[ii].dock_row
dest_docks[ii].size = src_docks[ii].size
dest_docks[ii].min_size = src_docks[ii].min_size
dest_docks[ii].resizable = src_docks[ii].resizable
dest_docks[ii].fixed = src_docks[ii].fixed
dest_docks[ii].toolbar = src_docks[ii].toolbar
dest_docks[ii].panes = src_docks[ii].panes
dest_docks[ii].rect = wx.Rect(*src_docks[ii].rect)
dest_panes = []
for ii in xrange(len(src_panes)):
dest_panes.append(AuiPaneInfo())
dest_panes[ii].name = src_panes[ii].name
dest_panes[ii].caption = src_panes[ii].caption
dest_panes[ii].window = src_panes[ii].window
dest_panes[ii].frame = src_panes[ii].frame
dest_panes[ii].state = src_panes[ii].state
dest_panes[ii].dock_direction = src_panes[ii].dock_direction
dest_panes[ii].dock_layer = src_panes[ii].dock_layer
dest_panes[ii].dock_row = src_panes[ii].dock_row
dest_panes[ii].dock_pos = src_panes[ii].dock_pos
dest_panes[ii].best_size = wx.Size(*src_panes[ii].best_size)
dest_panes[ii].min_size = wx.Size(*src_panes[ii].min_size)
dest_panes[ii].max_size = wx.Size(*src_panes[ii].max_size)
dest_panes[ii].floating_pos = wx.Point(*src_panes[ii].floating_pos)
dest_panes[ii].floating_size = wx.Size(*src_panes[ii].floating_size)
dest_panes[ii].dock_proportion = src_panes[ii].dock_proportion
dest_panes[ii].buttons = src_panes[ii].buttons
dest_panes[ii].rect = wx.Rect(*src_panes[ii].rect)
dest_panes[ii].icon = src_panes[ii].icon
dest_panes[ii].notebook_id = src_panes[ii].notebook_id
dest_panes[ii].transparent = src_panes[ii].transparent
dest_panes[ii].snapped = src_panes[ii].snapped
dest_panes[ii].minimize_mode = src_panes[ii].minimize_mode
dest_panes[ii].minimize_target = src_panes[ii].minimize_target
for ii in xrange(len(dest_docks)):
dock = dest_docks[ii]
for jj in xrange(len(dock.panes)):
for kk in xrange(len(src_panes)):
if dock.panes[jj] == src_panes[kk]:
dock.panes[jj] = dest_panes[kk]
dest_docks[ii] = dock
return dest_docks, dest_panes
def GetMaxLayer(docks, dock_direction):
"""
This is an internal function which returns
the highest layer inside the specified dock.
:param `docks`: a list of :class:`AuiDockInfo`;
:param `dock_direction`: the :class:`AuiDockInfo` docking direction to analyze.
"""
max_layer = 0
for dock in docks:
if dock.dock_direction == dock_direction and dock.dock_layer > max_layer and not dock.fixed:
max_layer = dock.dock_layer
return max_layer
def GetMaxRow(panes, dock_direction, dock_layer):
"""
This is an internal function which returns
the highest layer inside the specified dock.
:param `panes`: a list of :class:`AuiPaneInfo`;
:param integer `dock_direction`: the :class:`AuiDockInfo` docking direction to analyze;
:param integer `dock_layer`: the :class:`AuiDockInfo` layer to analyze.
"""
max_row = 0
for pane in panes:
if pane.dock_direction == dock_direction and pane.dock_layer == dock_layer and \
pane.dock_row > max_row:
max_row = pane.dock_row
return max_row
def DoInsertDockLayer(panes, dock_direction, dock_layer):
"""
This is an internal function that inserts a new dock
layer by incrementing all existing dock layer values by one.
:param `panes`: a list of :class:`AuiPaneInfo`;
:param integer `dock_direction`: the :class:`AuiDockInfo` docking direction to analyze;
:param integer `dock_layer`: the :class:`AuiDockInfo` layer to analyze.
"""
for ii in xrange(len(panes)):
pane = panes[ii]
if not pane.IsFloating() and pane.dock_direction == dock_direction and pane.dock_layer >= dock_layer:
pane.dock_layer = pane.dock_layer + 1
panes[ii] = pane
return panes
def DoInsertDockRow(panes, dock_direction, dock_layer, dock_row):
"""
This is an internal function that inserts a new dock
row by incrementing all existing dock row values by one.
:param `panes`: a list of :class:`AuiPaneInfo`;
:param integer `dock_direction`: the :class:`AuiDockInfo` docking direction to analyze;
:param integer `dock_layer`: the :class:`AuiDockInfo` layer to analyze;
:param integer `dock_row`: the :class:`AuiDockInfo` row to analyze.
"""
for pane in panes:
if not pane.IsFloating() and pane.dock_direction == dock_direction and \
pane.dock_layer == dock_layer and pane.dock_row >= dock_row:
pane.dock_row += 1
return panes
def DoInsertPane(panes, dock_direction, dock_layer, dock_row, dock_pos):
"""
This is an internal function that inserts a new pane
by incrementing all existing dock position values by one.
:param `panes`: a list of :class:`AuiPaneInfo`;
:param integer `dock_direction`: the :class:`AuiDockInfo` docking direction to analyze;
:param integer `dock_layer`: the :class:`AuiDockInfo` layer to analyze.
:param integer `dock_row`: the :class:`AuiDockInfo` row to analyze;
:param integer `dock_pos`: the :class:`AuiDockInfo` position to analyze.
"""
for ii in xrange(len(panes)):
pane = panes[ii]
if not pane.IsFloating() and pane.dock_direction == dock_direction and \
pane.dock_layer == dock_layer and pane.dock_row == dock_row and \
pane.dock_pos >= dock_pos:
pane.dock_pos = pane.dock_pos + 1
panes[ii] = pane
return panes
def FindDocks(docks, dock_direction, dock_layer=-1, dock_row=-1, reverse=False):
"""
This is an internal function that returns a list of docks which meet
the specified conditions in the parameters and returns a sorted array
(sorted by layer and then row).
:param `docks`: a list of :class:`AuiDockInfo`;
:param integer `dock_direction`: the :class:`AuiDockInfo` docking direction to analyze;
:param integer `dock_layer`: the :class:`AuiDockInfo` layer to analyze.
:param integer `dock_row`: the :class:`AuiDockInfo` row to analyze;
"""
matchDocks = [(d.dock_layer, d.dock_row, d.dock_direction, d) for d in docks if \
(dock_direction == -1 or dock_direction == d.dock_direction) and \
((dock_layer == -1 or dock_layer == d.dock_layer) and \
(dock_row == -1 or dock_row == d.dock_row))]
arr = [x[-1] for x in sorted(matchDocks, reverse=reverse)]
return arr
def FindOppositeDocks(docks, dock_direction):
"""
This is an internal function that returns a list of docks
which is related to the opposite direction.
:param `docks`: a list of :class:`AuiDockInfo`;
:param integer `dock_direction`: the :class:`AuiDockInfo` docking direction to analyze;
"""
if dock_direction == AUI_DOCK_LEFT:
arr = FindDocks(docks, AUI_DOCK_RIGHT, -1, -1)
elif dock_direction == AUI_DOCK_TOP:
arr = FindDocks(docks, AUI_DOCK_BOTTOM, -1, -1)
elif dock_direction == AUI_DOCK_RIGHT:
arr = FindDocks(docks, AUI_DOCK_LEFT, -1, -1)
elif dock_direction == AUI_DOCK_BOTTOM:
arr = FindDocks(docks, AUI_DOCK_TOP, -1, -1)
return arr
def FindPaneInDock(dock, window):
"""
This method looks up a specified window pointer inside a dock.
If found, the corresponding :class:`AuiDockInfo` pointer is returned, otherwise ``None``.
:param `dock`: a :class:`AuiDockInfo` structure;
:param Window `window`: the window associated to the pane we are seeking.
"""
for p in dock.panes:
if p.window == window:
return p
return None
def GetToolBarDockOffsets(docks):
"""
Returns the toolbar dock offsets (top-left and bottom-right).
:param `docks`: a list of :class:`AuiDockInfo` to analyze.
"""
top_left = wx.Size(0, 0)
bottom_right = wx.Size(0, 0)
for dock in docks:
if dock.toolbar:
dock_direction = dock.dock_direction
if dock_direction == AUI_DOCK_LEFT:
top_left.x += dock.rect.width
bottom_right.x += dock.rect.width
elif dock_direction == AUI_DOCK_TOP:
top_left.y += dock.rect.height
bottom_right.y += dock.rect.height
elif dock_direction == AUI_DOCK_RIGHT:
bottom_right.x += dock.rect.width
elif dock_direction == AUI_DOCK_BOTTOM:
bottom_right.y += dock.rect.height
return top_left, bottom_right
def GetInternalFrameRect(window, docks):
"""
Returns the window rectangle excluding toolbars.
:param `window`: a :class:`Window` derived window;
:param `docks`: a list of :class:`AuiDockInfo` structures.
"""
frameRect = wx.Rect()
frameRect.SetTopLeft(window.ClientToScreen(window.GetClientAreaOrigin()))
frameRect.SetSize(window.GetClientSize())
top_left, bottom_right = GetToolBarDockOffsets(docks)
# make adjustments for toolbars
frameRect.x += top_left.x
frameRect.y += top_left.y
frameRect.width -= bottom_right.x
frameRect.height -= bottom_right.y
return frameRect
def CheckOutOfWindow(window, pt):
"""
Checks if a point is outside the window rectangle.
:param `window`: a :class:`Window` derived window;
:param `pt`: a :class:`Point` object.
"""
auiWindowMargin = 30
marginRect = wx.Rect(*window.GetClientRect())
marginRect.Inflate(auiWindowMargin, auiWindowMargin)
return not marginRect.Contains(pt)
def CheckEdgeDrop(window, docks, pt):
"""
Checks on which edge of a window the drop action has taken place.
:param `window`: a :class:`Window` derived window;
:param `docks`: a list of :class:`AuiDockInfo` structures;
:param `pt`: a :class:`Point` object.
"""
screenPt = window.ClientToScreen(pt)
clientSize = window.GetClientSize()
frameRect = GetInternalFrameRect(window, docks)
if screenPt.y >= frameRect.GetTop() and screenPt.y < frameRect.GetBottom():
if pt.x < auiLayerInsertOffset and pt.x > auiLayerInsertOffset - auiLayerInsertPixels:
return wx.LEFT
if pt.x >= clientSize.x - auiLayerInsertOffset and \
pt.x < clientSize.x - auiLayerInsertOffset + auiLayerInsertPixels:
return wx.RIGHT
if screenPt.x >= frameRect.GetLeft() and screenPt.x < frameRect.GetRight():
if pt.y < auiLayerInsertOffset and pt.y > auiLayerInsertOffset - auiLayerInsertPixels:
return wx.TOP
if pt.y >= clientSize.y - auiLayerInsertOffset and \
pt.y < clientSize.y - auiLayerInsertOffset + auiLayerInsertPixels:
return wx.BOTTOM
return -1
def RemovePaneFromDocks(docks, pane, exc=None):
"""
Removes a pane window from all docks
with a possible exception specified by parameter `exc`.
:param `docks`: a list of :class:`AuiDockInfo` structures;
:param AuiPaneInfo `pane`: the pane to be removed;
:param AuiPaneInfo `exc`: the possible pane exception.
"""
for ii in xrange(len(docks)):
d = docks[ii]
if d == exc:
continue
pi = FindPaneInDock(d, pane.window)
if pi:
d.panes.remove(pi)
docks[ii] = d
return docks
def RenumberDockRows(docks):
"""
Takes a dock and assigns sequential numbers
to existing rows. Basically it takes out the gaps so if a
dock has rows with numbers 0, 2, 5, they will become 0, 1, 2.
:param `docks`: a list of :class:`AuiDockInfo` structures.
"""
for ii in xrange(len(docks)):
dock = docks[ii]
dock.dock_row = ii
for jj in xrange(len(dock.panes)):
dock.panes[jj].dock_row = ii
docks[ii] = dock
return docks
def SetActivePane(panes, active_pane):
"""
Sets the active pane, as well as cycles through
every other pane and makes sure that all others' active flags
are turned off.
:param `panes`: a list of :class:`AuiPaneInfo` structures;
:param AuiPaneInfo `active_pane`: the pane to be made active (if found).
"""
for pane in panes:
pane.state &= ~AuiPaneInfo.optionActive
for pane in panes:
if pane.window == active_pane and not pane.IsNotebookPage():
pane.state |= AuiPaneInfo.optionActive
return True, panes
return False, panes
def ShowDockingGuides(guides, show):
"""
Shows or hide the docking guide windows.
:param `guides`: a list of :class:`AuiDockingGuide` classes;
:param bool `show`: whether to show or hide the docking guide windows.
"""
for target in guides:
if show and not target.host.IsShown():
target.host.Show()
target.host.Update()
elif not show and target.host.IsShown():
target.host.Hide()
def RefreshDockingGuides(guides):
"""
Refreshes the docking guide windows.
:param `guides`: a list of :class:`AuiDockingGuide` classes;
"""
for target in guides:
if target.host.IsShown():
target.host.Refresh()
def PaneSortFunc(p1, p2):
"""
This function is used to sort panes by dock position.
:param AuiPaneInfo `p1`: the first pane instance to compare;
:param AuiPaneInfo `p2`: the second pane instance to compare.
"""
return (p1.dock_pos < p2.dock_pos and [-1] or [1])[0]
def GetNotebookRoot(panes, notebook_id):
"""
Returns the :class:`~lib.agw.aui.auibook.AuiNotebook` which has the specified `notebook_id`.
:param `panes`: a list of :class:`AuiPaneInfo` instances;
:param integer `notebook_id`: the target notebook id.
"""
for paneInfo in panes:
if paneInfo.IsNotebookControl() and paneInfo.notebook_id == notebook_id:
return paneInfo
return None
def EscapeDelimiters(s):
"""
Changes ``;`` into ``\`` and ``|`` into ``\|`` in the input string.
:param string `s`: the string to be analyzed.
:note: This is an internal functions which is used for saving perspectives.
"""
result = s.replace(";", "\\")
result = result.replace("|", "|\\")
return result
def IsDifferentDockingPosition(pane1, pane2):
"""
Returns whether `pane1` and `pane2` are in a different docking position
based on pane status, docking direction, docking layer and docking row.
:param `pane1`: a :class:`AuiPaneInfo` instance;
:param `pane2`: another :class:`AuiPaneInfo` instance.
"""
return pane1.IsFloating() != pane2.IsFloating() or \
pane1.dock_direction != pane2.dock_direction or \
pane1.dock_layer != pane2.dock_layer or \
pane1.dock_row != pane2.dock_row
# Convenience function
def AuiManager_HasLiveResize(manager):
"""
Static function which returns if the input `manager` should have "live resize"
behaviour.
:param `manager`: an instance of :class:`AuiManager`.
.. note::
This method always returns ``True`` on wxMAC as this platform doesn't have
the ability to use :class:`ScreenDC` to draw sashes.
"""
# With Core Graphics on Mac, it's not possible to show sash feedback,
# so we'll always use live update instead.
if wx.Platform == "__WXMAC__":
return True
else:
return (manager.GetAGWFlags() & AUI_MGR_LIVE_RESIZE) == AUI_MGR_LIVE_RESIZE
# Convenience function
def AuiManager_UseNativeMiniframes(manager):
"""
Static function which returns if the input `manager` should use native :class:`MiniFrame` as
floating panes.
:param `manager`: an instance of :class:`AuiManager`.
.. note::
This method always returns ``True`` on wxMAC as this platform doesn't have
the ability to use custom drawn miniframes.
"""
# With Core Graphics on Mac, it's not possible to show sash feedback,
# so we'll always use live update instead.
if wx.Platform == "__WXMAC__":
return True
else:
return (manager.GetAGWFlags() & AUI_MGR_USE_NATIVE_MINIFRAMES) == AUI_MGR_USE_NATIVE_MINIFRAMES
def GetManager(window):
"""
This function will return the aui manager for a given window.
:param Window `window`: this parameter should be any child window or grand-child
window (and so on) of the frame/window managed by :class:`AuiManager`. The window
does not need to be managed by the manager itself, nor does it even need
to be a child or sub-child of a managed window. It must however be inside
the window hierarchy underneath the managed window.
"""
if not isinstance(wx.GetTopLevelParent(window), AuiFloatingFrame):
if isinstance(window, auibar.AuiToolBar):
return window.GetAuiManager()
evt = AuiManagerEvent(wxEVT_AUI_FIND_MANAGER)
evt.SetManager(None)
evt.ResumePropagation(wx.EVENT_PROPAGATE_MAX)
if not window.GetEventHandler().ProcessEvent(evt):
return None
return evt.GetManager()
# ---------------------------------------------------------------------------- #
class AuiManager(wx.EvtHandler):
"""
AuiManager manages the panes associated with it for a particular :class:`Frame`,
using a pane's :class:`AuiManager` information to determine each pane's docking and
floating behavior. :class:`AuiManager` uses wxPython's sizer mechanism to plan the
layout of each frame. It uses a replaceable dock art class to do all drawing,
so all drawing is localized in one area, and may be customized depending on an
applications' specific needs.
:class:`AuiManager` works as follows: the programmer adds panes to the class, or makes
changes to existing pane properties (dock position, floating state, show state, etc...).
To apply these changes, the :meth:`AuiManager.Update() <AuiManager.Update>` function is called. This batch
processing can be used to avoid flicker, by modifying more than one pane at a time,
and then "committing" all of the changes at once by calling `Update()`.
Panes can be added quite easily::
text1 = wx.TextCtrl(self, -1)
text2 = wx.TextCtrl(self, -1)
self._mgr.AddPane(text1, AuiPaneInfo().Left().Caption("Pane Number One"))
self._mgr.AddPane(text2, AuiPaneInfo().Bottom().Caption("Pane Number Two"))
self._mgr.Update()
Later on, the positions can be modified easily. The following will float an
existing pane in a tool window::
self._mgr.GetPane(text1).Float()
**Layers, Rows and Directions, Positions:**
Inside AUI, the docking layout is figured out by checking several pane parameters.
Four of these are important for determining where a pane will end up.
**Direction** - Each docked pane has a direction, `Top`, `Bottom`, `Left`, `Right`, or `Center`.
This is fairly self-explanatory. The pane will be placed in the location specified
by this variable.
**Position** - More than one pane can be placed inside of a "dock". Imagine two panes
being docked on the left side of a window. One pane can be placed over another.
In proportionally managed docks, the pane position indicates it's sequential position,
starting with zero. So, in our scenario with two panes docked on the left side, the
top pane in the dock would have position 0, and the second one would occupy position 1.
**Row** - A row can allow for two docks to be placed next to each other. One of the most
common places for this to happen is in the toolbar. Multiple toolbar rows are allowed,
the first row being in row 0, and the second in row 1. Rows can also be used on
vertically docked panes.
**Layer** - A layer is akin to an onion. Layer 0 is the very center of the managed pane.
Thus, if a pane is in layer 0, it will be closest to the center window (also sometimes
known as the "content window"). Increasing layers "swallow up" all layers of a lower
value. This can look very similar to multiple rows, but is different because all panes
in a lower level yield to panes in higher levels. The best way to understand layers
is by running the AUI sample (`AUI.py`).
"""
def __init__(self, managed_window=None, agwFlags=None):
"""
Default class constructor.
:param Window `managed_window`: specifies the window which should be managed;
:param integer `agwFlags`: specifies options which allow the frame management behavior to be
modified. `agwFlags` can be a combination of the following style bits:
==================================== ==================================
Flag name Description
==================================== ==================================
``AUI_MGR_ALLOW_FLOATING`` Allow floating of panes
``AUI_MGR_ALLOW_ACTIVE_PANE`` If a pane becomes active, "highlight" it in the interface
``AUI_MGR_TRANSPARENT_DRAG`` If the platform supports it, set transparency on a floating pane while it is dragged by the user
``AUI_MGR_TRANSPARENT_HINT`` If the platform supports it, show a transparent hint window when the user is about to dock a floating pane
``AUI_MGR_VENETIAN_BLINDS_HINT`` Show a "venetian blind" effect when the user is about to dock a floating pane
``AUI_MGR_RECTANGLE_HINT`` Show a rectangle hint effect when the user is about to dock a floating pane
``AUI_MGR_HINT_FADE`` If the platform supports it, the hint window will fade in and out
``AUI_MGR_NO_VENETIAN_BLINDS_FADE`` Disables the "venetian blind" fade in and out
``AUI_MGR_LIVE_RESIZE`` Live resize when the user drag a sash
``AUI_MGR_ANIMATE_FRAMES`` Fade-out floating panes when they are closed (all platforms which support frames transparency)
and show a moving rectangle when they are docked (Windows < Vista and GTK only)
``AUI_MGR_AERO_DOCKING_GUIDES`` Use the new Aero-style bitmaps as docking guides
``AUI_MGR_PREVIEW_MINIMIZED_PANES`` Slide in and out minimized panes to preview them
``AUI_MGR_WHIDBEY_DOCKING_GUIDES`` Use the new Whidbey-style bitmaps as docking guides
``AUI_MGR_SMOOTH_DOCKING`` Performs a "smooth" docking of panes (a la PyQT)
``AUI_MGR_USE_NATIVE_MINIFRAMES`` Use miniframes with native caption bar as floating panes instead or custom drawn caption bars (forced on wxMAC)
``AUI_MGR_AUTONB_NO_CAPTION`` Panes that merge into an automatic notebook will not have the pane caption visible
==================================== ==================================
Default value for `agwFlags` is:
``AUI_MGR_DEFAULT`` = ``AUI_MGR_ALLOW_FLOATING`` | ``AUI_MGR_TRANSPARENT_HINT`` | ``AUI_MGR_HINT_FADE`` | ``AUI_MGR_NO_VENETIAN_BLINDS_FADE``
.. note::
If using the ``AUI_MGR_USE_NATIVE_MINIFRAMES``, double-clicking on a
floating pane caption will not re-dock the pane, but simply maximize it (if
:meth:`AuiPaneInfo.MaximizeButton` has been set to ``True``) or do nothing.
"""
wx.EvtHandler.__init__(self)
self._action = actionNone
self._action_window = None
self._hover_button = None
self._art = dockart.AuiDefaultDockArt()
self._hint_window = None
self._active_pane = None
self._has_maximized = False
self._has_minimized = False
self._frame = None
self._dock_constraint_x = 0.3
self._dock_constraint_y = 0.3
self._reserved = None
self._panes = []
self._docks = []
self._uiparts = []
self._guides = []
self._notebooks = []
self._masterManager = None
self._currentDragItem = -1
self._lastknowndocks = {}
self._hint_fadetimer = wx.Timer(self, wx.ID_ANY)
self._hint_fademax = 50
self._last_hint = wx.Rect()
self._from_move = False
self._last_rect = wx.Rect()
if agwFlags is None:
agwFlags = AUI_MGR_DEFAULT
self._agwFlags = agwFlags
self._is_docked = (False, wx.RIGHT, wx.TOP, 0)
self._snap_limits = (15, 15)
if wx.Platform == "__WXMSW__":
self._animation_step = 30.0
else:
self._animation_step = 5.0
self._hint_rect = wx.Rect()
self._preview_timer = wx.Timer(self, wx.ID_ANY)
self._sliding_frame = None
self._autoNBTabArt = tabart.AuiDefaultTabArt()
self._autoNBStyle = AUI_NB_DEFAULT_STYLE | AUI_NB_BOTTOM | \
AUI_NB_SUB_NOTEBOOK | AUI_NB_TAB_EXTERNAL_MOVE
self._autoNBStyle -= AUI_NB_DRAW_DND_TAB
if managed_window:
self.SetManagedWindow(managed_window)
self.Bind(wx.EVT_PAINT, self.OnPaint)
self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
self.Bind(wx.EVT_SIZE, self.OnSize)
self.Bind(wx.EVT_SET_CURSOR, self.OnSetCursor)
self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
self.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDClick)
self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
self.Bind(wx.EVT_MOTION, self.OnMotion)
self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeaveWindow)
self.Bind(wx.EVT_CHILD_FOCUS, self.OnChildFocus)
self.Bind(wx.EVT_MOUSE_CAPTURE_LOST, self.OnCaptureLost)
self.Bind(wx.EVT_TIMER, self.OnHintFadeTimer, self._hint_fadetimer)
self.Bind(wx.EVT_TIMER, self.SlideIn, self._preview_timer)
self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy)
self.Bind(wx.EVT_MOVE, self.OnMove)
self.Bind(wx.EVT_SYS_COLOUR_CHANGED, self.OnSysColourChanged)
self.Bind(EVT_AUI_PANE_BUTTON, self.OnPaneButton)
self.Bind(EVT_AUI_RENDER, self.OnRender)
self.Bind(EVT_AUI_FIND_MANAGER, self.OnFindManager)
self.Bind(EVT_AUI_PANE_MIN_RESTORE, self.OnRestoreMinimizedPane)
self.Bind(EVT_AUI_PANE_DOCKED, self.OnPaneDocked)
self.Bind(auibook.EVT_AUINOTEBOOK_BEGIN_DRAG, self.OnTabBeginDrag)
self.Bind(auibook.EVT_AUINOTEBOOK_PAGE_CLOSE, self.OnTabPageClose)
self.Bind(auibook.EVT_AUINOTEBOOK_PAGE_CHANGED, self.OnTabSelected)
def CreateFloatingFrame(self, parent, pane_info):
"""
Creates a floating frame for the windows.
:param Window `parent`: the floating frame parent;
:param `pane_info`: the :class:`AuiPaneInfo` class with all the pane's information.
"""
return AuiFloatingFrame(parent, self, pane_info)
def CanDockPanel(self, p):
"""
Returns whether a pane can be docked or not.
:param `p`: the :class:`AuiPaneInfo` class with all the pane's information.
"""
# is the pane dockable?
if not p.IsDockable():
return False
# if a key modifier is pressed while dragging the frame,
# don't dock the window
return not (wx.GetKeyState(wx.WXK_CONTROL) or wx.GetKeyState(wx.WXK_ALT))
def GetPaneByWidget(self, window):
"""
This version of :meth:`GetPane` looks up a pane based on a 'pane window'.
:param `window`: a :class:`Window` derived window.
:see: :meth:`~AuiManager.GetPane`
"""
for p in self._panes:
if p.window == window:
return p
return NonePaneInfo
def GetPaneByName(self, name):
"""
This version of :meth:`GetPane` looks up a pane based on a 'pane name'.
:param string `name`: the pane name.
:see: :meth:`GetPane`
"""
for p in self._panes:
if p.name == name:
return p
return NonePaneInfo
def GetPane(self, item):
"""
Looks up a :class:`AuiPaneInfo` structure based on the supplied window pointer. Upon failure,
:meth:`GetPane` returns an empty :class:`AuiPaneInfo`, a condition which can be checked
by calling :meth:`AuiPaneInfo.IsOk() <AuiPaneInfo.IsOk>`.
The pane info's structure may then be modified. Once a pane's info is modified, :meth:`Update`
must be called to realize the changes in the UI.
:param `item`: either a pane name or a :class:`Window`.
"""
if isinstance(item, basestring):
return self.GetPaneByName(item)
else:
return self.GetPaneByWidget(item)
def GetAllPanes(self):
""" Returns a reference to all the pane info structures. """
return self._panes
def ShowPane(self, window, show):
"""
Shows or hides a pane based on the window passed as input.
:param Window `window`: any subclass or derivation of :class:`Window`;
:param bool `show`: ``True`` to show the pane, ``False`` otherwise.
"""
p = self.GetPane(window)
if p.IsOk():
if p.IsNotebookPage():
if show:
notebook = self._notebooks[p.notebook_id]
id = notebook.GetPageIndex(p.window)
if id >= 0:
notebook.SetSelection(id)
self.ShowPane(notebook, True)
else:
p.Show(show)
if p.frame:
p.frame.Raise()
self.Update()
def HitTest(self, x, y):
"""
This is an internal function which determines
which UI item the specified coordinates are over.
:param integer `x`: specifies a x position in client coordinates;
:param integer `y`: specifies a y position in client coordinates.
"""
result = None
for item in self._uiparts:
# we are not interested in typeDock, because this space
# isn't used to draw anything, just for measurements
# besides, the entire dock area is covered with other
# rectangles, which we are interested in.
if item.type == AuiDockUIPart.typeDock:
continue
# if we already have a hit on a more specific item, we are not
# interested in a pane hit. If, however, we don't already have
# a hit, returning a pane hit is necessary for some operations
if item.type in [AuiDockUIPart.typePane, AuiDockUIPart.typePaneBorder] and result:
continue
# if the point is inside the rectangle, we have a hit
if item.rect.Contains((x, y)):
result = item
return result
def PaneHitTest(self, panes, pt):
"""
Similar to :meth:`HitTest`, but it checks in which :class:`AuiManager` rectangle the
input point belongs to.
:param `panes`: a list of :class:`AuiPaneInfo` instances;
:param Point `pt`: the mouse position.
"""
for paneInfo in panes:
if paneInfo.IsDocked() and paneInfo.IsShown() and paneInfo.rect.Contains(pt):
return paneInfo
return NonePaneInfo
# SetAGWFlags() and GetAGWFlags() allow the owner to set various
# options which are global to AuiManager
def SetAGWFlags(self, agwFlags):
"""
This method is used to specify :class:`AuiManager` 's settings flags.
:param integer `agwFlags`: specifies options which allow the frame management behavior
to be modified. `agwFlags` can be one of the following style bits:
==================================== ==================================
Flag name Description
==================================== ==================================
``AUI_MGR_ALLOW_FLOATING`` Allow floating of panes
``AUI_MGR_ALLOW_ACTIVE_PANE`` If a pane becomes active, "highlight" it in the interface
``AUI_MGR_TRANSPARENT_DRAG`` If the platform supports it, set transparency on a floating pane while it is dragged by the user
``AUI_MGR_TRANSPARENT_HINT`` If the platform supports it, show a transparent hint window when the user is about to dock a floating pane
``AUI_MGR_VENETIAN_BLINDS_HINT`` Show a "venetian blind" effect when the user is about to dock a floating pane
``AUI_MGR_RECTANGLE_HINT`` Show a rectangle hint effect when the user is about to dock a floating pane
``AUI_MGR_HINT_FADE`` If the platform supports it, the hint window will fade in and out
``AUI_MGR_NO_VENETIAN_BLINDS_FADE`` Disables the "venetian blind" fade in and out
``AUI_MGR_LIVE_RESIZE`` Live resize when the user drag a sash
``AUI_MGR_ANIMATE_FRAMES`` Fade-out floating panes when they are closed (all platforms which support frames transparency)
and show a moving rectangle when they are docked (Windows < Vista and GTK only)
``AUI_MGR_AERO_DOCKING_GUIDES`` Use the new Aero-style bitmaps as docking guides
``AUI_MGR_PREVIEW_MINIMIZED_PANES`` Slide in and out minimized panes to preview them
``AUI_MGR_WHIDBEY_DOCKING_GUIDES`` Use the new Whidbey-style bitmaps as docking guides
``AUI_MGR_SMOOTH_DOCKING`` Performs a "smooth" docking of panes (a la PyQT)
``AUI_MGR_USE_NATIVE_MINIFRAMES`` Use miniframes with native caption bar as floating panes instead or custom drawn caption bars (forced on wxMAC)
``AUI_MGR_AUTONB_NO_CAPTION`` Panes that merge into an automatic notebook will not have the pane caption visible
==================================== ==================================
.. note::
If using the ``AUI_MGR_USE_NATIVE_MINIFRAMES``, double-clicking on a
floating pane caption will not re-dock the pane, but simply maximize it (if
:meth:`AuiPaneInfo.MaximizeButton` has been set to ``True``) or do nothing.
"""
self._agwFlags = agwFlags
if len(self._guides) > 0:
self.CreateGuideWindows()
if self._hint_window and agwFlags & AUI_MGR_RECTANGLE_HINT == 0:
self.CreateHintWindow()
def GetAGWFlags(self):
"""
Returns the current manager's flags.
:see: :meth:`SetAGWFlags` for a list of possible :class:`AuiManager` flags.
"""
return self._agwFlags
def SetManagedWindow(self, managed_window):
"""
Called to specify the frame or window which is to be managed by :class:`AuiManager`.
Frame management is not restricted to just frames. Child windows or custom
controls are also allowed.
:param Window `managed_window`: specifies the window which should be managed by
the AUI manager.
"""
if not managed_window:
raise Exception("Specified managed window must be non-null. ")
if isinstance(managed_window, sc.SizedParent):
raise Exception("Do not use wx.lib.sized_control for managed window. ")
self.UnInit()
self._frame = managed_window
self._frame.PushEventHandler(self)
# if the owner is going to manage an MDI parent frame,
# we need to add the MDI client window as the default
# center pane
if isinstance(self._frame, wx.MDIParentFrame):
mdi_frame = self._frame
client_window = mdi_frame.GetClientWindow()
if not client_window:
raise Exception("Client window is None!")
self.AddPane(client_window, AuiPaneInfo().Name("mdiclient").
CenterPane().PaneBorder(False))
elif isinstance(self._frame, tabmdi.AuiMDIParentFrame):
mdi_frame = self._frame
client_window = mdi_frame.GetClientWindow()
if not client_window:
raise Exception("Client window is None!")
self.AddPane(client_window, AuiPaneInfo().Name("mdiclient").
CenterPane().PaneBorder(False))
def GetManagedWindow(self):
""" Returns the window being managed by :class:`AuiManager`. """
return self._frame
def SetFrame(self, managed_window):
"""
Called to specify the frame or window which is to be managed by :class:`AuiManager`.
Frame management is not restricted to just frames. Child windows or custom
controls are also allowed.
:param Window `managed_window`: specifies the window which should be managed by
the AUI manager.
.. deprecated:: 0.6
This method is now deprecated, use :meth:`SetManagedWindow` instead.
"""
DeprecationWarning("This method is deprecated, use SetManagedWindow instead.")
return self.SetManagedWindow(managed_window)
def GetFrame(self):
"""
Returns the window being managed by :class:`AuiManager`.
.. deprecated:: 0.6
This method is now deprecated, use :meth:`GetManagedWindow` instead.
"""
DeprecationWarning("This method is deprecated, use GetManagedWindow instead.")
return self._frame
def CreateGuideWindows(self):
""" Creates the VS2005 HUD guide windows. """
self.DestroyGuideWindows()
self._guides.append(AuiDockingGuideInfo().Left().
Host(AuiSingleDockingGuide(self._frame, wx.LEFT)))
self._guides.append(AuiDockingGuideInfo().Top().
Host(AuiSingleDockingGuide(self._frame, wx.TOP)))
self._guides.append(AuiDockingGuideInfo().Right().
Host(AuiSingleDockingGuide(self._frame, wx.RIGHT)))
self._guides.append(AuiDockingGuideInfo().Bottom().
Host(AuiSingleDockingGuide(self._frame, wx.BOTTOM)))
self._guides.append(AuiDockingGuideInfo().Centre().
Host(AuiCenterDockingGuide(self._frame)))
def DestroyGuideWindows(self):
""" Destroys the VS2005 HUD guide windows. """
for guide in self._guides:
if guide.host:
guide.host.Destroy()
self._guides = []
def CreateHintWindow(self):
""" Creates the standard wxAUI hint window. """
self.DestroyHintWindow()
self._hint_window = AuiDockingHintWindow(self._frame)
self._hint_window.SetBlindMode(self._agwFlags)
def DestroyHintWindow(self):
""" Destroys the standard wxAUI hint window. """
if self._hint_window:
self._hint_window.Destroy()
self._hint_window = None
def UnInit(self):
"""
Uninitializes the framework and should be called before a managed frame or
window is destroyed. :meth:`UnInit` is usually called in the managed :class:`Frame` / :class:`Window`
destructor.
It is necessary to call this function before the managed frame or window is
destroyed, otherwise the manager cannot remove its custom event handlers
from a window.
"""
if not self._frame:
return
for klass in [self._frame] + list(self._frame.GetChildren()):
handler = klass.GetEventHandler()
if klass is not handler:
if isinstance(handler, AuiManager):
klass.RemoveEventHandler(handler)
def OnDestroy(self, event) :
if self._frame == event.GetEventObject():
self.UnInit();
def GetArtProvider(self):
""" Returns the current art provider being used. """
return self._art
def ProcessMgrEvent(self, event):
"""
Process the AUI events sent to the manager.
:param `event`: the event to process, an instance of :class:`AuiManagerEvent`.
"""
# first, give the owner frame a chance to override
if self._frame:
if self._frame.GetEventHandler().ProcessEvent(event):
return
self.ProcessEvent(event)
def FireEvent(self, evtType, pane, canVeto=False):
"""
Fires one of the ``EVT_AUI_PANE_FLOATED`` / ``FLOATING`` / ``DOCKING`` / ``DOCKED`` / ``ACTIVATED`` event.
:param integer `evtType`: one of the aforementioned events;
:param `pane`: the :class:`AuiPaneInfo` instance associated to this event;
:param bool `canVeto`: whether the event can be vetoed or not.
"""
event = AuiManagerEvent(evtType)
event.SetPane(pane)
event.SetCanVeto(canVeto)
self.ProcessMgrEvent(event)
return event
def CanUseModernDockArt(self):
"""
Returns whether :class:`dockart` can be used (Windows XP / Vista / 7 only,
requires Mark Hammonds's `pywin32 <http://sourceforge.net/projects/pywin32/>`_ package).
"""
if not _winxptheme:
return False
# Get the size of a small close button (themed)
hwnd = self._frame.GetHandle()
hTheme = winxptheme.OpenThemeData(hwnd, "Window")
if not hTheme:
return False
return True
def SetArtProvider(self, art_provider):
"""
Instructs :class:`AuiManager` to use art provider specified by the parameter
`art_provider` for all drawing calls. This allows plugable look-and-feel
features.
:param `art_provider`: a AUI dock art provider.
:note: The previous art provider object, if any, will be deleted by :class:`AuiManager`.
"""
# delete the last art provider, if any
del self._art
# assign the new art provider
self._art = art_provider
for pane in self.GetAllPanes():
if pane.IsFloating() and pane.frame:
pane.frame._mgr.SetArtProvider(art_provider)
pane.frame._mgr.Update()
def AddPane(self, window, arg1=None, arg2=None, target=None):
"""
Tells the frame manager to start managing a child window. There
are four versions of this function. The first verison allows the full spectrum
of pane parameter possibilities (:meth:`AddPane1`). The second version is used for
simpler user interfaces which do not require as much configuration (:meth:`AddPane2`).
The :meth:`AddPane3` version allows a drop position to be specified, which will determine
where the pane will be added. The :meth:`AddPane4` version allows to turn the target
:class:`AuiPaneInfo` pane into a notebook and the added pane into a page.
In your code, simply call :meth:`AddPane`.
:param Window `window`: the child window to manage;
:param `arg1`: a :class:`AuiPaneInfo` or an integer value (direction);
:param `arg2`: a :class:`AuiPaneInfo` or a :class:`Point` (drop position);
:param `target`: a :class:`AuiPaneInfo` to be turned into a notebook
and new pane added to it as a page. (additionally, target can be any pane in
an existing notebook)
"""
if target in self._panes:
return self.AddPane4(window, arg1, target)
if type(arg1) == type(1):
# This Is Addpane2
if arg1 is None:
arg1 = wx.LEFT
if arg2 is None:
arg2 = ""
return self.AddPane2(window, arg1, arg2)
else:
if isinstance(arg2, wx.Point):
return self.AddPane3(window, arg1, arg2)
else:
return self.AddPane1(window, arg1)
def AddPane1(self, window, pane_info):
""" See comments on :meth:`AddPane`. """
# check if the pane has a valid window
if not window:
return False
# check if the pane already exists
if self.GetPane(pane_info.window).IsOk():
return False
# check if the pane name already exists, this could reveal a
# bug in the library user's application
already_exists = False
if pane_info.name != "" and self.GetPane(pane_info.name).IsOk():
warnings.warn("A pane with the name '%s' already exists in the manager!"%pane_info.name)
already_exists = True
# if the new pane is docked then we should undo maximize
if pane_info.IsDocked():
self.RestoreMaximizedPane()
self._panes.append(pane_info)
pinfo = self._panes[-1]
# set the pane window
pinfo.window = window
# if the pane's name identifier is blank, create a random string
if pinfo.name == "" or already_exists:
pinfo.name = ("%s%08x%08x%08x")%(pinfo.window.GetName(), time.time(),
time.clock(), len(self._panes))
# set initial proportion (if not already set)
if pinfo.dock_proportion == 0:
pinfo.dock_proportion = 100000
floating = isinstance(self._frame, AuiFloatingFrame)
pinfo.buttons = []
if not floating and pinfo.HasMinimizeButton():
button = AuiPaneButton(AUI_BUTTON_MINIMIZE)
pinfo.buttons.append(button)
if not floating and pinfo.HasMaximizeButton():
button = AuiPaneButton(AUI_BUTTON_MAXIMIZE_RESTORE)
pinfo.buttons.append(button)
if not floating and pinfo.HasPinButton():
button = AuiPaneButton(AUI_BUTTON_PIN)
pinfo.buttons.append(button)
if pinfo.HasCloseButton():
button = AuiPaneButton(AUI_BUTTON_CLOSE)
pinfo.buttons.append(button)
if pinfo.HasGripper():
if isinstance(pinfo.window, auibar.AuiToolBar):
# prevent duplicate gripper -- both AuiManager and AuiToolBar
# have a gripper control. The toolbar's built-in gripper
# meshes better with the look and feel of the control than ours,
# so turn AuiManager's gripper off, and the toolbar's on.
tb = pinfo.window
pinfo.SetFlag(AuiPaneInfo.optionGripper, False)
tb.SetGripperVisible(True)
if pinfo.window:
if pinfo.best_size == wx.Size(-1, -1):
pinfo.best_size = pinfo.window.GetClientSize()
if isinstance(pinfo.window, wx.ToolBar):
# GetClientSize() doesn't get the best size for
# a toolbar under some newer versions of wxWidgets,
# so use GetBestSize()
pinfo.best_size = pinfo.window.GetBestSize()
# this is needed for Win2000 to correctly fill toolbar backround
# it should probably be repeated once system colour change happens
if wx.Platform == "__WXMSW__" and pinfo.window.UseBgCol():
pinfo.window.SetBackgroundColour(self.GetArtProvider().GetColour(AUI_DOCKART_BACKGROUND_COLOUR))
if pinfo.min_size != wx.Size(-1, -1):
if pinfo.best_size.x < pinfo.min_size.x:
pinfo.best_size.x = pinfo.min_size.x
if pinfo.best_size.y < pinfo.min_size.y:
pinfo.best_size.y = pinfo.min_size.y
self._panes[-1] = pinfo
if isinstance(window, auibar.AuiToolBar):
window.SetAuiManager(self)
return True
def AddPane2(self, window, direction, caption):
""" See comments on :meth:`AddPane`. """
pinfo = AuiPaneInfo()
pinfo.Caption(caption)
if direction == wx.TOP:
pinfo.Top()
elif direction == wx.BOTTOM:
pinfo.Bottom()
elif direction == wx.LEFT:
pinfo.Left()
elif direction == wx.RIGHT:
pinfo.Right()
elif direction == wx.CENTER:
pinfo.CenterPane()
return self.AddPane(window, pinfo)
def AddPane3(self, window, pane_info, drop_pos):
""" See comments on :meth:`AddPane`. """
if not self.AddPane(window, pane_info):
return False
pane = self.GetPane(window)
indx = self._panes.index(pane)
ret, pane = self.DoDrop(self._docks, self._panes, pane, drop_pos, wx.Point(0, 0))
self._panes[indx] = pane
return True
def AddPane4(self, window, pane_info, target):
""" See comments on :meth:`AddPane`. """
if not self.AddPane(window, pane_info):
return False
paneInfo = self.GetPane(window)
if not paneInfo.IsNotebookDockable():
return self.AddPane1(window, pane_info)
if not target.IsNotebookDockable() and not target.IsNotebookControl():
return self.AddPane1(window, pane_info)
if not target.HasNotebook():
self.CreateNotebookBase(self._panes, target)
# Add new item to notebook
paneInfo.NotebookPage(target.notebook_id)
# we also want to remove our captions sometimes
self.RemoveAutoNBCaption(paneInfo)
self.UpdateNotebook()
return True
def InsertPane(self, window, pane_info, insert_level=AUI_INSERT_PANE):
"""
This method is used to insert either a previously unmanaged pane window
into the frame manager, or to insert a currently managed pane somewhere else.
:meth:`InsertPane` will push all panes, rows, or docks aside and insert the window
into the position specified by `pane_info`.
Because `pane_info` can specify either a pane, dock row, or dock layer, the
`insert_level` parameter is used to disambiguate this. The parameter `insert_level`
can take a value of ``AUI_INSERT_PANE``, ``AUI_INSERT_ROW`` or ``AUI_INSERT_DOCK``.
:param Window `window`: the window to be inserted and managed;
:param `pane_info`: the insert location for the new window;
:param integer `insert_level`: the insertion level of the new pane.
"""
if not window:
raise Exception("Invalid window passed to InsertPane.")
# shift the panes around, depending on the insert level
if insert_level == AUI_INSERT_PANE:
self._panes = DoInsertPane(self._panes, pane_info.dock_direction,
pane_info.dock_layer, pane_info.dock_row,
pane_info.dock_pos)
elif insert_level == AUI_INSERT_ROW:
self._panes = DoInsertDockRow(self._panes, pane_info.dock_direction,
pane_info.dock_layer, pane_info.dock_row)
elif insert_level == AUI_INSERT_DOCK:
self._panes = DoInsertDockLayer(self._panes, pane_info.dock_direction,
pane_info.dock_layer)
# if the window already exists, we are basically just moving/inserting the
# existing window. If it doesn't exist, we need to add it and insert it
existing_pane = self.GetPane(window)
indx = self._panes.index(existing_pane)
if not existing_pane.IsOk():
return self.AddPane(window, pane_info)
else:
if pane_info.IsFloating():
existing_pane.Float()
if pane_info.floating_pos != wx.Point(-1, -1):
existing_pane.FloatingPosition(pane_info.floating_pos)
if pane_info.floating_size != wx.Size(-1, -1):
existing_pane.FloatingSize(pane_info.floating_size)
else:
# if the new pane is docked then we should undo maximize
self.RestoreMaximizedPane()
existing_pane.Direction(pane_info.dock_direction)
existing_pane.Layer(pane_info.dock_layer)
existing_pane.Row(pane_info.dock_row)
existing_pane.Position(pane_info.dock_pos)
self._panes[indx] = existing_pane
return True
def DetachPane(self, window):
"""
Tells the :class:`AuiManager` to stop managing the pane specified
by `window`. The window, if in a floated frame, is reparented to the frame
managed by :class:`AuiManager`.
:param Window `window`: the window to be un-managed.
"""
for p in self._panes:
if p.window == window:
if p.frame:
# we have a floating frame which is being detached. We need to
# reparent it to self._frame and destroy the floating frame
# reduce flicker
p.window.SetSize((1, 1))
if p.frame.IsShown():
p.frame.Show(False)
if self._action_window == p.frame:
self._action_window = None
# reparent to self._frame and destroy the pane
p.window.Reparent(self._frame)
p.frame.SetSizer(None)
p.frame.Destroy()
p.frame = None
elif p.IsNotebookPage():
notebook = self._notebooks[p.notebook_id]
id = notebook.GetPageIndex(p.window)
notebook.RemovePage(id)
p.window.Reparent(self._frame)
# make sure there are no references to this pane in our uiparts,
# just in case the caller doesn't call Update() immediately after
# the DetachPane() call. This prevets obscure crashes which would
# happen at window repaint if the caller forgets to call Update()
counter = 0
for pi in xrange(len(self._uiparts)):
part = self._uiparts[counter]
if part.pane == p:
self._uiparts.pop(counter)
counter -= 1
counter += 1
self._panes.remove(p)
return True
return False
def ClosePane(self, pane_info):
"""
Destroys or hides the pane depending on its flags.
:param `pane_info`: a :class:`AuiPaneInfo` instance.
"""
# if we were maximized, restore
if pane_info.IsMaximized():
self.RestorePane(pane_info)
if pane_info.frame:
if self._agwFlags & AUI_MGR_ANIMATE_FRAMES:
pane_info.frame.FadeOut()
# first, hide the window
if pane_info.window and pane_info.window.IsShown():
pane_info.window.Show(False)
# make sure that we are the parent of this window
if pane_info.window and pane_info.window.GetParent() != self._frame:
pane_info.window.Reparent(self._frame)
# if we have a frame, destroy it
if pane_info.frame:
pane_info.frame.Destroy()
pane_info.frame = None
elif pane_info.IsNotebookPage():
# if we are a notebook page, remove ourselves...
# the code would index out of bounds
# if the last page of a sub-notebook was closed
# because the notebook would be deleted, before this
# code is executed.
# This code just prevents an out-of bounds error.
if self._notebooks:
nid = pane_info.notebook_id
if nid >= 0 and nid < len(self._notebooks):
notebook = self._notebooks[nid]
page_idx = notebook.GetPageIndex(pane_info.window)
if page_idx >= 0:
notebook.RemovePage(page_idx)
# now we need to either destroy or hide the pane
to_destroy = 0
if pane_info.IsDestroyOnClose():
to_destroy = pane_info.window
self.DetachPane(to_destroy)
else:
if isinstance(pane_info.window, auibar.AuiToolBar) and pane_info.IsFloating():
tb = pane_info.window
if pane_info.dock_direction in [AUI_DOCK_LEFT, AUI_DOCK_RIGHT]:
tb.SetAGWWindowStyleFlag(tb.GetAGWWindowStyleFlag() | AUI_TB_VERTICAL)
pane_info.Dock().Hide()
if pane_info.IsNotebookControl():
notebook = self._notebooks[pane_info.notebook_id]
while notebook.GetPageCount():
window = notebook.GetPage(0)
notebook.RemovePage(0)
info = self.GetPane(window)
if info.IsOk():
info.notebook_id = -1
info.dock_direction = AUI_DOCK_NONE
# Note: this could change our paneInfo reference ...
self.ClosePane(info)
if to_destroy:
to_destroy.Destroy()
def MaximizePane(self, pane_info, savesizes=True):
"""
Maximizes the input pane.
:param `pane_info`: a :class:`AuiPaneInfo` instance.
:param bool `savesizes`: whether to save previous dock sizes.
"""
if savesizes:
self.SavePreviousDockSizes(pane_info)
for p in self._panes:
# save hidden state
p.SetFlag(p.savedHiddenState, p.HasFlag(p.optionHidden))
if not p.IsToolbar() and not p.IsFloating():
p.Restore()
# hide the pane, because only the newly
# maximized pane should show
p.Hide()
pane_info.previousDockPos = pane_info.dock_pos
# mark ourselves maximized
pane_info.Maximize()
pane_info.Show()
self._has_maximized = True
# last, show the window
if pane_info.window and not pane_info.window.IsShown():
pane_info.window.Show(True)
def SavePreviousDockSizes(self, pane_info):
"""
Stores the previous dock sizes, to be used in a "restore" action later.
:param `pane_info`: a :class:`AuiPaneInfo` instance.
"""
for d in self._docks:
if not d.toolbar:
for p in d.panes:
p.previousDockSize = d.size
if pane_info is not p:
p.SetFlag(p.needsRestore, True)
def RestorePane(self, pane_info):
"""
Restores the input pane from a previous maximized or minimized state.
:param `pane_info`: a :class:`AuiPaneInfo` instance.
"""
# restore all the panes
for p in self._panes:
if not p.IsToolbar():
p.SetFlag(p.optionHidden, p.HasFlag(p.savedHiddenState))
pane_info.SetFlag(pane_info.needsRestore, True)
# mark ourselves non-maximized
pane_info.Restore()
self._has_maximized = False
self._has_minimized = False
# last, show the window
if pane_info.window and not pane_info.window.IsShown():
pane_info.window.Show(True)
def RestoreMaximizedPane(self):
""" Restores the current maximized pane (if any). """
# restore all the panes
for p in self._panes:
if p.IsMaximized():
self.RestorePane(p)
break
def ActivatePane(self, window):
"""
Activates the pane to which `window` is associated.
:param `window`: a :class:`Window` derived window.
"""
if self.GetAGWFlags() & AUI_MGR_ALLOW_ACTIVE_PANE:
while window:
ret, self._panes = SetActivePane(self._panes, window)
if ret:
break
window = window.GetParent()
self.RefreshCaptions()
self.FireEvent(wxEVT_AUI_PANE_ACTIVATED, window, canVeto=False)
def CreateNotebook(self):
"""
Creates an automatic :class:`~lib.agw.aui.auibook.AuiNotebook` when a pane is docked on
top of another pane.
"""
notebook = auibook.AuiNotebook(self._frame, -1, wx.Point(0, 0), wx.Size(0, 0), agwStyle=self._autoNBStyle)
# This is so we can get the tab-drag event.
notebook.GetAuiManager().SetMasterManager(self)
notebook.SetArtProvider(self._autoNBTabArt.Clone())
self._notebooks.append(notebook)
return notebook
def SetAutoNotebookTabArt(self, art):
"""
Sets the default tab art provider for automatic notebooks.
:param `art`: a tab art provider.
"""
for nb in self._notebooks:
nb.SetArtProvider(art.Clone())
nb.Refresh()
nb.Update()
self._autoNBTabArt = art
def GetAutoNotebookTabArt(self):
""" Returns the default tab art provider for automatic notebooks. """
return self._autoNBTabArt
def SetAutoNotebookStyle(self, agwStyle):
"""
Sets the default AGW-specific window style for automatic notebooks.
:param integer `agwStyle`: the underlying :class:`~lib.agw.aui.auibook.AuiNotebook` window style.
This can be a combination of the following bits:
==================================== ==================================
Flag name Description
==================================== ==================================
``AUI_NB_TOP`` With this style, tabs are drawn along the top of the notebook
``AUI_NB_LEFT`` With this style, tabs are drawn along the left of the notebook. Not implemented yet.
``AUI_NB_RIGHT`` With this style, tabs are drawn along the right of the notebook. Not implemented yet.
``AUI_NB_BOTTOM`` With this style, tabs are drawn along the bottom of the notebook
``AUI_NB_TAB_SPLIT`` Allows the tab control to be split by dragging a tab
``AUI_NB_TAB_MOVE`` Allows a tab to be moved horizontally by dragging
``AUI_NB_TAB_EXTERNAL_MOVE`` Allows a tab to be moved to another tab control
``AUI_NB_TAB_FIXED_WIDTH`` With this style, all tabs have the same width
``AUI_NB_SCROLL_BUTTONS`` With this style, left and right scroll buttons are displayed
``AUI_NB_WINDOWLIST_BUTTON`` With this style, a drop-down list of windows is available
``AUI_NB_CLOSE_BUTTON`` With this style, a close button is available on the tab bar
``AUI_NB_CLOSE_ON_ACTIVE_TAB`` With this style, a close button is available on the active tab
``AUI_NB_CLOSE_ON_ALL_TABS`` With this style, a close button is available on all tabs
``AUI_NB_MIDDLE_CLICK_CLOSE`` Allows to close :class:`~lib.agw.aui.auibook.AuiNotebook` tabs by mouse middle button click
``AUI_NB_SUB_NOTEBOOK`` This style is used by :class:`AuiManager` to create automatic AuiNotebooks
``AUI_NB_HIDE_ON_SINGLE_TAB`` Hides the tab window if only one tab is present
``AUI_NB_SMART_TABS`` Use Smart Tabbing, like ``Alt`` + ``Tab`` on Windows
``AUI_NB_USE_IMAGES_DROPDOWN`` Uses images on dropdown window list menu instead of check items
``AUI_NB_CLOSE_ON_TAB_LEFT`` Draws the tab close button on the left instead of on the right (a la Camino browser)
``AUI_NB_TAB_FLOAT`` Allows the floating of single tabs. Known limitation: when the notebook is more or less
full screen, tabs cannot be dragged far enough outside of the notebook to become floating pages
``AUI_NB_DRAW_DND_TAB`` Draws an image representation of a tab while dragging (on by default)
``AUI_NB_ORDER_BY_ACCESS`` Tab navigation order by last access time for the tabs
``AUI_NB_NO_TAB_FOCUS`` Don't draw tab focus rectangle
==================================== ==================================
"""
for nb in self._notebooks:
nb.SetAGWWindowStyleFlag(agwStyle)
nb.Refresh()
nb.Update()
self._autoNBStyle = agwStyle
def GetAutoNotebookStyle(self):
"""
Returns the default AGW-specific window style for automatic notebooks.
:see: :meth:`SetAutoNotebookStyle` method for a list of possible styles.
"""
return self._autoNBStyle
def SavePaneInfo(self, pane):
"""
This method is similar to :meth:`SavePerspective`, with the exception
that it only saves information about a single pane. It is used in
combination with :meth:`LoadPaneInfo`.
:param `pane`: a :class:`AuiPaneInfo` instance to save.
"""
result = "name=" + EscapeDelimiters(pane.name) + ";"
result += "caption=" + EscapeDelimiters(pane.caption) + ";"
result += "state=%u;"%pane.state
result += "dir=%d;"%pane.dock_direction
result += "layer=%d;"%pane.dock_layer
result += "row=%d;"%pane.dock_row
result += "pos=%d;"%pane.dock_pos
result += "prop=%d;"%pane.dock_proportion
result += "bestw=%d;"%pane.best_size.x
result += "besth=%d;"%pane.best_size.y
result += "minw=%d;"%pane.min_size.x
result += "minh=%d;"%pane.min_size.y
result += "maxw=%d;"%pane.max_size.x
result += "maxh=%d;"%pane.max_size.y
result += "floatx=%d;"%pane.floating_pos.x
result += "floaty=%d;"%pane.floating_pos.y
result += "floatw=%d;"%pane.floating_size.x
result += "floath=%d;"%pane.floating_size.y
result += "notebookid=%d;"%pane.notebook_id
result += "transparent=%d"%pane.transparent
return result
def LoadPaneInfo(self, pane_part, pane):
"""
This method is similar to to :meth:`LoadPerspective`, with the exception that
it only loads information about a single pane. It is used in combination
with :meth:`SavePaneInfo`.
:param string `pane_part`: the string to analyze;
:param `pane`: the :class:`AuiPaneInfo` structure in which to load `pane_part`.
"""
# replace escaped characters so we can
# split up the string easily
pane_part = pane_part.replace("\\|", "\a")
pane_part = pane_part.replace("\\;", "\b")
options = pane_part.split(";")
for items in options:
val_name, value = items.split("=")
val_name = val_name.strip()
if val_name == "name":
pane.name = value
elif val_name == "caption":
pane.caption = value
elif val_name == "state":
pane.state = int(value)
elif val_name == "dir":
pane.dock_direction = int(value)
elif val_name == "layer":
pane.dock_layer = int(value)
elif val_name == "row":
pane.dock_row = int(value)
elif val_name == "pos":
pane.dock_pos = int(value)
elif val_name == "prop":
pane.dock_proportion = int(value)
elif val_name == "bestw":
pane.best_size.x = int(value)
elif val_name == "besth":
pane.best_size.y = int(value)
pane.best_size = wx.Size(pane.best_size.x, pane.best_size.y)
elif val_name == "minw":
pane.min_size.x = int(value)
elif val_name == "minh":
pane.min_size.y = int(value)
pane.min_size = wx.Size(pane.min_size.x, pane.min_size.y)
elif val_name == "maxw":
pane.max_size.x = int(value)
elif val_name == "maxh":
pane.max_size.y = int(value)
pane.max_size = wx.Size(pane.max_size.x, pane.max_size.y)
elif val_name == "floatx":
pane.floating_pos.x = int(value)
elif val_name == "floaty":
pane.floating_pos.y = int(value)
pane.floating_pos = wx.Point(pane.floating_pos.x, pane.floating_pos.y)
elif val_name == "floatw":
pane.floating_size.x = int(value)
elif val_name == "floath":
pane.floating_size.y = int(value)
pane.floating_size = wx.Size(pane.floating_size.x, pane.floating_size.y)
elif val_name == "notebookid":
pane.notebook_id = int(value)
elif val_name == "transparent":
pane.transparent = int(value)
else:
raise Exception("Bad perspective string")
# replace escaped characters so we can
# split up the string easily
pane.name = pane.name.replace("\a", "|")
pane.name = pane.name.replace("\b", ";")
pane.caption = pane.caption.replace("\a", "|")
pane.caption = pane.caption.replace("\b", ";")
pane_part = pane_part.replace("\a", "|")
pane_part = pane_part.replace("\b", ";")
return pane
def SavePerspective(self):
"""
Saves the entire user interface layout into an encoded string, which can then
be stored by the application (probably using :class:`Config`).
When a perspective is restored using :meth:`LoadPerspective`, the entire user
interface will return to the state it was when the perspective was saved.
"""
result = "layout2|"
for pane in self._panes:
result += self.SavePaneInfo(pane) + "|"
for dock in self._docks:
result = result + ("dock_size(%d,%d,%d)=%d|")%(dock.dock_direction,
dock.dock_layer,
dock.dock_row,
dock.size)
return result
def LoadPerspective(self, layout, update=True, restorecaption=False):
"""
Loads a layout which was saved with :meth:`SavePerspective`.
If the `update` flag parameter is ``True``, :meth:`Update` will be
automatically invoked, thus realizing the saved perspective on screen.
:param string `layout`: a string which contains a saved AUI layout;
:param bool `update`: whether to update immediately the window or not;
:param bool `restorecaption`: ``False``, restore from persist storage,
otherwise use the caption defined in code.
"""
input = layout
# check layout string version
# 'layout1' = wxAUI 0.9.0 - wxAUI 0.9.2
# 'layout2' = wxAUI 0.9.2 (wxWidgets 2.8)
index = input.find("|")
part = input[0:index].strip()
input = input[index+1:]
if part != "layout2":
return False
# mark all panes currently managed as docked and hidden
saveCapt = {} # see restorecaption param
for pane in self._panes:
pane.Dock().Hide()
saveCapt[pane.name] = pane.caption
# clear out the dock array; this will be reconstructed
self._docks = []
# replace escaped characters so we can
# split up the string easily
input = input.replace("\\|", "\a")
input = input.replace("\\;", "\b")
while 1:
pane = AuiPaneInfo()
index = input.find("|")
pane_part = input[0:index].strip()
input = input[index+1:]
# if the string is empty, we're done parsing
if pane_part == "":
break
if pane_part[0:9] == "dock_size":
index = pane_part.find("=")
val_name = pane_part[0:index]
value = pane_part[index+1:]
index = val_name.find("(")
piece = val_name[index+1:]
index = piece.find(")")
piece = piece[0:index]
vals = piece.split(",")
dir = int(vals[0])
layer = int(vals[1])
row = int(vals[2])
size = int(value)
dock = AuiDockInfo()
dock.dock_direction = dir
dock.dock_layer = layer
dock.dock_row = row
dock.size = size
self._docks.append(dock)
continue
# Undo our escaping as LoadPaneInfo needs to take an unescaped
# name so it can be called by external callers
pane_part = pane_part.replace("\a", "|")
pane_part = pane_part.replace("\b", ";")
pane = self.LoadPaneInfo(pane_part, pane)
p = self.GetPane(pane.name)
# restore pane caption from code
if restorecaption:
if pane.name in saveCapt:
pane.Caption(saveCapt[pane.name])
if not p.IsOk():
if pane.IsNotebookControl():
# notebook controls - auto add...
self._panes.append(pane)
indx = self._panes.index(pane)
else:
# the pane window couldn't be found
# in the existing layout -- skip it
continue
else:
indx = self._panes.index(p)
pane.window = p.window
pane.frame = p.frame
pane.buttons = p.buttons
self._panes[indx] = pane
if isinstance(pane.window, auibar.AuiToolBar) and (pane.IsFloatable() or pane.IsDockable()):
pane.window.SetGripperVisible(True)
for p in self._panes:
if p.IsMinimized():
self.MinimizePane(p, False)
if update:
self.Update()
return True
def GetPanePositionsAndSizes(self, dock):
"""
Returns all the panes positions and sizes in a dock.
:param `dock`: a :class:`AuiDockInfo` instance.
"""
caption_size = self._art.GetMetric(AUI_DOCKART_CAPTION_SIZE)
pane_border_size = self._art.GetMetric(AUI_DOCKART_PANE_BORDER_SIZE)
gripper_size = self._art.GetMetric(AUI_DOCKART_GRIPPER_SIZE)
positions = []
sizes = []
action_pane = -1
pane_count = len(dock.panes)
# find the pane marked as our action pane
for pane_i in xrange(pane_count):
pane = dock.panes[pane_i]
if pane.HasFlag(AuiPaneInfo.actionPane):
if action_pane != -1:
raise Exception("Too many action panes!")
action_pane = pane_i
# set up each panes default position, and
# determine the size (width or height, depending
# on the dock's orientation) of each pane
for pane in dock.panes:
positions.append(pane.dock_pos)
size = 0
if pane.HasBorder():
size += pane_border_size*2
if dock.IsHorizontal():
if pane.HasGripper() and not pane.HasGripperTop():
size += gripper_size
if pane.HasCaptionLeft():
size += caption_size
size += pane.best_size.x
else:
if pane.HasGripper() and pane.HasGripperTop():
size += gripper_size
if pane.HasCaption() and not pane.HasCaptionLeft():
size += caption_size
size += pane.best_size.y
sizes.append(size)
# if there is no action pane, just return the default
# positions (as specified in pane.pane_pos)
if action_pane == -1:
return positions, sizes
offset = 0
for pane_i in xrange(action_pane-1, -1, -1):
amount = positions[pane_i+1] - (positions[pane_i] + sizes[pane_i])
if amount >= 0:
offset += amount
else:
positions[pane_i] -= -amount
offset += sizes[pane_i]
# if the dock mode is fixed, make sure none of the panes
# overlap we will bump panes that overlap
offset = 0
for pane_i in xrange(action_pane, pane_count):
amount = positions[pane_i] - offset
if amount >= 0:
offset += amount
else:
positions[pane_i] += -amount
offset += sizes[pane_i]
return positions, sizes
def LayoutAddPane(self, cont, dock, pane, uiparts, spacer_only):
"""
Adds a pane into the existing layout (in an existing dock).
:param `cont`: a :class:`Sizer` object;
:param `dock`: the :class:`AuiDockInfo` structure in which to add the pane;
:param `pane`: the :class:`AuiPaneInfo` instance to add to the dock;
:param `uiparts`: a list of UI parts in the interface;
:param bool `spacer_only`: whether to add a simple spacer or a real window.
"""
sizer_item = wx.SizerItem()
caption_size = self._art.GetMetric(AUI_DOCKART_CAPTION_SIZE)
gripper_size = self._art.GetMetric(AUI_DOCKART_GRIPPER_SIZE)
pane_border_size = self._art.GetMetric(AUI_DOCKART_PANE_BORDER_SIZE)
pane_button_size = self._art.GetMetric(AUI_DOCKART_PANE_BUTTON_SIZE)
# find out the orientation of the item (orientation for panes
# is the same as the dock's orientation)
if dock.IsHorizontal():
orientation = wx.HORIZONTAL
else:
orientation = wx.VERTICAL
# this variable will store the proportion
# value that the pane will receive
pane_proportion = pane.dock_proportion
horz_pane_sizer = wx.BoxSizer(wx.HORIZONTAL)
vert_pane_sizer = wx.BoxSizer(wx.VERTICAL)
if pane.HasGripper():
part = AuiDockUIPart()
if pane.HasGripperTop():
sizer_item = vert_pane_sizer.Add((1, gripper_size), 0, wx.EXPAND)
else:
sizer_item = horz_pane_sizer.Add((gripper_size, 1), 0, wx.EXPAND)
part.type = AuiDockUIPart.typeGripper
part.dock = dock
part.pane = pane
part.button = None
part.orientation = orientation
part.cont_sizer = horz_pane_sizer
part.sizer_item = sizer_item
uiparts.append(part)
button_count = len(pane.buttons)
button_width_total = button_count*pane_button_size
if button_count >= 1:
button_width_total += 3
caption, captionLeft = pane.HasCaption(), pane.HasCaptionLeft()
button_count = len(pane.buttons)
if captionLeft:
caption_sizer = wx.BoxSizer(wx.VERTICAL)
# add pane buttons to the caption
dummy_parts = []
for btn_id in xrange(len(pane.buttons)-1, -1, -1):
sizer_item = caption_sizer.Add((caption_size, pane_button_size), 0, wx.EXPAND)
part = AuiDockUIPart()
part.type = AuiDockUIPart.typePaneButton
part.dock = dock
part.pane = pane
part.button = pane.buttons[btn_id]
part.orientation = orientation
part.cont_sizer = caption_sizer
part.sizer_item = sizer_item
dummy_parts.append(part)
sizer_item = caption_sizer.Add((caption_size, 1), 1, wx.EXPAND)
vert_pane_sizer = wx.BoxSizer(wx.HORIZONTAL)
# create the caption sizer
part = AuiDockUIPart()
part.type = AuiDockUIPart.typeCaption
part.dock = dock
part.pane = pane
part.button = None
part.orientation = orientation
part.cont_sizer = vert_pane_sizer
part.sizer_item = sizer_item
caption_part_idx = len(uiparts)
uiparts.append(part)
uiparts.extend(dummy_parts)
elif caption:
caption_sizer = wx.BoxSizer(wx.HORIZONTAL)
sizer_item = caption_sizer.Add((1, caption_size), 1, wx.EXPAND)
# create the caption sizer
part = AuiDockUIPart()
part.type = AuiDockUIPart.typeCaption
part.dock = dock
part.pane = pane
part.button = None
part.orientation = orientation
part.cont_sizer = vert_pane_sizer
part.sizer_item = sizer_item
caption_part_idx = len(uiparts)
uiparts.append(part)
# add pane buttons to the caption
for button in pane.buttons:
sizer_item = caption_sizer.Add((pane_button_size, caption_size), 0, wx.EXPAND)
part = AuiDockUIPart()
part.type = AuiDockUIPart.typePaneButton
part.dock = dock
part.pane = pane
part.button = button
part.orientation = orientation
part.cont_sizer = caption_sizer
part.sizer_item = sizer_item
uiparts.append(part)
if caption or captionLeft:
# if we have buttons, add a little space to the right
# of them to ease visual crowding
if button_count >= 1:
if captionLeft:
caption_sizer.Add((caption_size, 3), 0, wx.EXPAND)
else:
caption_sizer.Add((3, caption_size), 0, wx.EXPAND)
# add the caption sizer
sizer_item = vert_pane_sizer.Add(caption_sizer, 0, wx.EXPAND)
uiparts[caption_part_idx].sizer_item = sizer_item
# add the pane window itself
if spacer_only or not pane.window:
sizer_item = vert_pane_sizer.Add((1, 1), 1, wx.EXPAND)
else:
sizer_item = vert_pane_sizer.Add(pane.window, 1, wx.EXPAND)
vert_pane_sizer.SetItemMinSize(pane.window, (1, 1))
part = AuiDockUIPart()
part.type = AuiDockUIPart.typePane
part.dock = dock
part.pane = pane
part.button = None
part.orientation = orientation
part.cont_sizer = vert_pane_sizer
part.sizer_item = sizer_item
uiparts.append(part)
# determine if the pane should have a minimum size if the pane is
# non-resizable (fixed) then we must set a minimum size. Alternatively,
# if the pane.min_size is set, we must use that value as well
min_size = pane.min_size
if pane.IsFixed():
if min_size == wx.Size(-1, -1):
min_size = pane.best_size
pane_proportion = 0
if min_size != wx.Size(-1, -1):
vert_pane_sizer.SetItemMinSize(len(vert_pane_sizer.GetChildren())-1, (min_size.x, min_size.y))
# add the vertical/horizontal sizer (caption, pane window) to the
# horizontal sizer (gripper, vertical sizer)
horz_pane_sizer.Add(vert_pane_sizer, 1, wx.EXPAND)
# finally, add the pane sizer to the dock sizer
if pane.HasBorder():
# allowing space for the pane's border
sizer_item = cont.Add(horz_pane_sizer, pane_proportion,
wx.EXPAND | wx.ALL, pane_border_size)
part = AuiDockUIPart()
part.type = AuiDockUIPart.typePaneBorder
part.dock = dock
part.pane = pane
part.button = None
part.orientation = orientation
part.cont_sizer = cont
part.sizer_item = sizer_item
uiparts.append(part)
else:
sizer_item = cont.Add(horz_pane_sizer, pane_proportion, wx.EXPAND)
return uiparts
def LayoutAddDock(self, cont, dock, uiparts, spacer_only):
"""
Adds a dock into the existing layout.
:param `cont`: a :class:`Sizer` object;
:param `dock`: the :class:`AuiDockInfo` structure to add to the layout;
:param `uiparts`: a list of UI parts in the interface;
:param bool `spacer_only`: whether to add a simple spacer or a real window.
"""
sizer_item = wx.SizerItem()
part = AuiDockUIPart()
sash_size = self._art.GetMetric(AUI_DOCKART_SASH_SIZE)
orientation = (dock.IsHorizontal() and [wx.HORIZONTAL] or [wx.VERTICAL])[0]
# resizable bottom and right docks have a sash before them
if not self._has_maximized and not dock.fixed and \
dock.dock_direction in [AUI_DOCK_BOTTOM, AUI_DOCK_RIGHT]:
sizer_item = cont.Add((sash_size, sash_size), 0, wx.EXPAND)
part.type = AuiDockUIPart.typeDockSizer
part.orientation = orientation
part.dock = dock
part.pane = None
part.button = None
part.cont_sizer = cont
part.sizer_item = sizer_item
uiparts.append(part)
# create the sizer for the dock
dock_sizer = wx.BoxSizer(orientation)
# add each pane to the dock
has_maximized_pane = False
pane_count = len(dock.panes)
if dock.fixed:
# figure out the real pane positions we will
# use, without modifying the each pane's pane_pos member
pane_positions, pane_sizes = self.GetPanePositionsAndSizes(dock)
offset = 0
for pane_i in xrange(pane_count):
pane = dock.panes[pane_i]
pane_pos = pane_positions[pane_i]
if pane.IsMaximized():
has_maximized_pane = True
amount = pane_pos - offset
if amount > 0:
if dock.IsVertical():
sizer_item = dock_sizer.Add((1, amount), 0, wx.EXPAND)
else:
sizer_item = dock_sizer.Add((amount, 1), 0, wx.EXPAND)
part = AuiDockUIPart()
part.type = AuiDockUIPart.typeBackground
part.dock = dock
part.pane = None
part.button = None
part.orientation = (orientation==wx.HORIZONTAL and \
[wx.VERTICAL] or [wx.HORIZONTAL])[0]
part.cont_sizer = dock_sizer
part.sizer_item = sizer_item
uiparts.append(part)
offset = offset + amount
uiparts = self.LayoutAddPane(dock_sizer, dock, pane, uiparts, spacer_only)
offset = offset + pane_sizes[pane_i]
# at the end add a very small stretchable background area
sizer_item = dock_sizer.Add((0, 0), 1, wx.EXPAND)
part = AuiDockUIPart()
part.type = AuiDockUIPart.typeBackground
part.dock = dock
part.pane = None
part.button = None
part.orientation = orientation
part.cont_sizer = dock_sizer
part.sizer_item = sizer_item
uiparts.append(part)
else:
for pane_i in xrange(pane_count):
pane = dock.panes[pane_i]
if pane.IsMaximized():
has_maximized_pane = True
# if this is not the first pane being added,
# we need to add a pane sizer
if not self._has_maximized and pane_i > 0:
sizer_item = dock_sizer.Add((sash_size, sash_size), 0, wx.EXPAND)
part = AuiDockUIPart()
part.type = AuiDockUIPart.typePaneSizer
part.dock = dock
part.pane = dock.panes[pane_i-1]
part.button = None
part.orientation = (orientation==wx.HORIZONTAL and \
[wx.VERTICAL] or [wx.HORIZONTAL])[0]
part.cont_sizer = dock_sizer
part.sizer_item = sizer_item
uiparts.append(part)
uiparts = self.LayoutAddPane(dock_sizer, dock, pane, uiparts, spacer_only)
if dock.dock_direction == AUI_DOCK_CENTER or has_maximized_pane:
sizer_item = cont.Add(dock_sizer, 1, wx.EXPAND)
else:
sizer_item = cont.Add(dock_sizer, 0, wx.EXPAND)
part = AuiDockUIPart()
part.type = AuiDockUIPart.typeDock
part.dock = dock
part.pane = None
part.button = None
part.orientation = orientation
part.cont_sizer = cont
part.sizer_item = sizer_item
uiparts.append(part)
if dock.IsHorizontal():
cont.SetItemMinSize(dock_sizer, (0, dock.size))
else:
cont.SetItemMinSize(dock_sizer, (dock.size, 0))
# top and left docks have a sash after them
if not self._has_maximized and not dock.fixed and \
dock.dock_direction in [AUI_DOCK_TOP, AUI_DOCK_LEFT]:
sizer_item = cont.Add((sash_size, sash_size), 0, wx.EXPAND)
part = AuiDockUIPart()
part.type = AuiDockUIPart.typeDockSizer
part.dock = dock
part.pane = None
part.button = None
part.orientation = orientation
part.cont_sizer = cont
part.sizer_item = sizer_item
uiparts.append(part)
return uiparts
def LayoutAll(self, panes, docks, uiparts, spacer_only=False, oncheck=True):
"""
Layouts all the UI structures in the interface.
:param `panes`: a list of :class:`AuiPaneInfo` instances;
:param `docks`: a list of :class:`AuiDockInfo` classes;
:param `uiparts`: a list of UI parts in the interface;
:param bool `spacer_only`: whether to add a simple spacer or a real window;
:param bool `oncheck`: whether to store the results in a class member or not.
"""
container = wx.BoxSizer(wx.VERTICAL)
pane_border_size = self._art.GetMetric(AUI_DOCKART_PANE_BORDER_SIZE)
caption_size = self._art.GetMetric(AUI_DOCKART_CAPTION_SIZE)
cli_size = self._frame.GetClientSize()
# empty all docks out
for dock in docks:
dock.panes = []
if dock.fixed:
# always reset fixed docks' sizes, because
# the contained windows may have been resized
dock.size = 0
dock_count = len(docks)
# iterate through all known panes, filing each
# of them into the appropriate dock. If the
# pane does not exist in the dock, add it
for p in panes:
# don't layout hidden panes.
if p.IsShown():
# find any docks with the same dock direction, dock layer, and
# dock row as the pane we are working on
arr = FindDocks(docks, p.dock_direction, p.dock_layer, p.dock_row)
if arr:
dock = arr[0]
else:
# dock was not found, so we need to create a new one
d = AuiDockInfo()
d.dock_direction = p.dock_direction
d.dock_layer = p.dock_layer
d.dock_row = p.dock_row
docks.append(d)
dock = docks[-1]
if p.HasFlag(p.needsRestore) and not p.HasFlag(p.wasMaximized):
isHor = dock.IsHorizontal()
sashSize = self._art.GetMetric(AUI_DOCKART_SASH_SIZE)
# get the sizes of any docks that might
# overlap with our restored dock
# make list of widths or heights from the size in the dock rects
sizes = [d.rect[2:][isHor] for \
d in docks if d.IsOk() and \
(d.IsHorizontal() == isHor) and \
not d.toolbar and \
d.dock_direction != AUI_DOCK_CENTER]
frameRect = GetInternalFrameRect(self._frame, self._docks)
# set max size allowing for sashes and absolute minimum
maxsize = frameRect[2:][isHor] - sum(sizes) - (len(sizes)*10) - (sashSize*len(sizes))
dock.size = min(p.previousDockSize,maxsize)
else:
dock.size = 0
if p.HasFlag(p.wasMaximized):
self.MaximizePane(p, savesizes=False)
p.SetFlag(p.wasMaximized, False)
if p.HasFlag(p.needsRestore):
if p.previousDockPos is not None:
DoInsertPane(dock.panes, dock.dock_direction, dock.dock_layer, dock.dock_row, p.previousDockPos)
p.dock_pos = p.previousDockPos
p.previousDockPos = None
p.SetFlag(p.needsRestore, False)
if p.IsDocked():
# remove the pane from any existing docks except this one
docks = RemovePaneFromDocks(docks, p, dock)
# pane needs to be added to the dock,
# if it doesn't already exist
if not FindPaneInDock(dock, p.window):
dock.panes.append(p)
else:
# remove the pane from any existing docks
docks = RemovePaneFromDocks(docks, p)
# remove any empty docks
docks = [dock for dock in docks if dock.panes]
dock_count = len(docks)
# configure the docks further
for ii, dock in enumerate(docks):
# sort the dock pane array by the pane's
# dock position (dock_pos), in ascending order
dock.panes.sort(PaneSortFunc)
dock_pane_count = len(dock.panes)
# for newly created docks, set up their initial size
if dock.size == 0:
size = 0
for pane in dock.panes:
pane_size = pane.best_size
if pane_size == wx.Size(-1, -1):
pane_size = pane.min_size
if pane_size == wx.Size(-1, -1) and pane.window:
pane_size = pane.window.GetSize()
if dock.IsHorizontal():
size = max(pane_size.y, size)
else:
size = max(pane_size.x, size)
# add space for the border (two times), but only
# if at least one pane inside the dock has a pane border
for pane in dock.panes:
if pane.HasBorder():
size = size + pane_border_size*2
break
# if pane is on the top or bottom, add the caption height,
# but only if at least one pane inside the dock has a caption
if dock.IsHorizontal():
for pane in dock.panes:
if pane.HasCaption() and not pane.HasCaptionLeft():
size = size + caption_size
break
else:
for pane in dock.panes:
if pane.HasCaptionLeft() and not pane.HasCaption():
size = size + caption_size
break
# new dock's size may not be more than the dock constraint
# parameter specifies. See SetDockSizeConstraint()
max_dock_x_size = int(self._dock_constraint_x*float(cli_size.x))
max_dock_y_size = int(self._dock_constraint_y*float(cli_size.y))
if cli_size <= wx.Size(20, 20):
max_dock_x_size = 10000
max_dock_y_size = 10000
if dock.IsHorizontal():
size = min(size, max_dock_y_size)
else:
size = min(size, max_dock_x_size)
# absolute minimum size for a dock is 10 pixels
if size < 10:
size = 10
dock.size = size
# determine the dock's minimum size
plus_border = False
plus_caption = False
plus_caption_left = False
dock_min_size = 0
for pane in dock.panes:
if pane.min_size != wx.Size(-1, -1):
if pane.HasBorder():
plus_border = True
if pane.HasCaption():
plus_caption = True
if pane.HasCaptionLeft():
plus_caption_left = True
if dock.IsHorizontal():
if pane.min_size.y > dock_min_size:
dock_min_size = pane.min_size.y
else:
if pane.min_size.x > dock_min_size:
dock_min_size = pane.min_size.x
if plus_border:
dock_min_size += pane_border_size*2
if plus_caption and dock.IsHorizontal():
dock_min_size += caption_size
if plus_caption_left and dock.IsVertical():
dock_min_size += caption_size
dock.min_size = dock_min_size
# if the pane's current size is less than it's
# minimum, increase the dock's size to it's minimum
if dock.size < dock.min_size:
dock.size = dock.min_size
# determine the dock's mode (fixed or proportional)
# determine whether the dock has only toolbars
action_pane_marked = False
dock.fixed = True
dock.toolbar = True
for pane in dock.panes:
if not pane.IsFixed():
dock.fixed = False
if not pane.IsToolbar():
dock.toolbar = False
if pane.HasFlag(AuiPaneInfo.optionDockFixed):
dock.fixed = True
if pane.HasFlag(AuiPaneInfo.actionPane):
action_pane_marked = True
# if the dock mode is proportional and not fixed-pixel,
# reassign the dock_pos to the sequential 0, 1, 2, 3
# e.g. remove gaps like 1, 2, 30, 500
if not dock.fixed:
for jj in xrange(dock_pane_count):
pane = dock.panes[jj]
pane.dock_pos = jj
# if the dock mode is fixed, and none of the panes
# are being moved right now, make sure the panes
# do not overlap each other. If they do, we will
# adjust the panes' positions
if dock.fixed and not action_pane_marked:
pane_positions, pane_sizes = self.GetPanePositionsAndSizes(dock)
offset = 0
for jj in xrange(dock_pane_count):
pane = dock.panes[jj]
pane.dock_pos = pane_positions[jj]
amount = pane.dock_pos - offset
if amount >= 0:
offset += amount
else:
pane.dock_pos += -amount
offset += pane_sizes[jj]
dock.panes[jj] = pane
if oncheck:
self._docks[ii] = dock
# shrink docks if needed
## docks = self.SmartShrink(docks, AUI_DOCK_TOP)
## docks = self.SmartShrink(docks, AUI_DOCK_LEFT)
if oncheck:
self._docks = docks
# discover the maximum dock layer
max_layer = 0
dock_count = len(docks)
for ii in xrange(dock_count):
max_layer = max(max_layer, docks[ii].dock_layer)
# clear out uiparts
uiparts = []
# create a bunch of box sizers,
# from the innermost level outwards.
cont = None
middle = None
if oncheck:
docks = self._docks
for layer in xrange(max_layer+1):
# find any docks in this layer
arr = FindDocks(docks, -1, layer, -1)
# if there aren't any, skip to the next layer
if not arr:
continue
old_cont = cont
# create a container which will hold this layer's
# docks (top, bottom, left, right)
cont = wx.BoxSizer(wx.VERTICAL)
# find any top docks in this layer
arr = FindDocks(docks, AUI_DOCK_TOP, layer, -1)
for row in arr:
uiparts = self.LayoutAddDock(cont, row, uiparts, spacer_only)
# fill out the middle layer (which consists
# of left docks, content area and right docks)
middle = wx.BoxSizer(wx.HORIZONTAL)
# find any left docks in this layer
arr = FindDocks(docks, AUI_DOCK_LEFT, layer, -1)
for row in arr:
uiparts = self.LayoutAddDock(middle, row, uiparts, spacer_only)
# add content dock (or previous layer's sizer
# to the middle
if not old_cont:
# find any center docks
arr = FindDocks(docks, AUI_DOCK_CENTER, -1, -1)
if arr:
for row in arr:
uiparts = self.LayoutAddDock(middle, row, uiparts, spacer_only)
elif not self._has_maximized:
# there are no center docks, add a background area
sizer_item = middle.Add((1, 1), 1, wx.EXPAND)
part = AuiDockUIPart()
part.type = AuiDockUIPart.typeBackground
part.pane = None
part.dock = None
part.button = None
part.cont_sizer = middle
part.sizer_item = sizer_item
uiparts.append(part)
else:
middle.Add(old_cont, 1, wx.EXPAND)
# find any right docks in this layer
arr = FindDocks(docks, AUI_DOCK_RIGHT, layer, -1, reverse=True)
for row in arr:
uiparts = self.LayoutAddDock(middle, row, uiparts, spacer_only)
if len(middle.GetChildren()) > 0:
cont.Add(middle, 1, wx.EXPAND)
# find any bottom docks in this layer
arr = FindDocks(docks, AUI_DOCK_BOTTOM, layer, -1, reverse=True)
for row in arr:
uiparts = self.LayoutAddDock(cont, row, uiparts, spacer_only)
if not cont:
# no sizer available, because there are no docks,
# therefore we will create a simple background area
cont = wx.BoxSizer(wx.VERTICAL)
sizer_item = cont.Add((1, 1), 1, wx.EXPAND)
part = AuiDockUIPart()
part.type = AuiDockUIPart.typeBackground
part.pane = None
part.dock = None
part.button = None
part.cont_sizer = middle
part.sizer_item = sizer_item
uiparts.append(part)
if oncheck:
self._uiparts = uiparts
self._docks = docks
container.Add(cont, 1, wx.EXPAND)
if oncheck:
return container
else:
return container, panes, docks, uiparts
def SetDockSizeConstraint(self, width_pct, height_pct):
"""
When a user creates a new dock by dragging a window into a docked position,
often times the large size of the window will create a dock that is unwieldly
large.
:class:`AuiManager` by default limits the size of any new dock to 1/3 of the window
size. For horizontal docks, this would be 1/3 of the window height. For vertical
docks, 1/3 of the width. Calling this function will adjust this constraint value.
The numbers must be between 0.0 and 1.0. For instance, calling :meth:`SetDockSizeConstraint`
with (0.5, 0.5) will cause new docks to be limited to half of the size of the entire
managed window.
:param float `width_pct`: a number representing the `x` dock size constraint;
:param float `width_pct`: a number representing the `y` dock size constraint.
"""
self._dock_constraint_x = max(0.0, min(1.0, width_pct))
self._dock_constraint_y = max(0.0, min(1.0, height_pct))
def GetDockSizeConstraint(self):
"""
Returns the current dock constraint values.
:see: :meth:`SetDockSizeConstraint`
"""
return self._dock_constraint_x, self._dock_constraint_y
def Update(self):
"""
This method is called after any number of changes are made to any of the
managed panes. :meth:`Update` must be invoked after :meth:`AddPane`
or :meth:`InsertPane` are called in order to "realize" or "commit" the changes.
In addition, any number of changes may be made to :class:`AuiManager` structures
(retrieved with :meth:`GetPane`), but to realize the changes, :meth:`Update`
must be called. This construction allows pane flicker to be avoided by updating
the whole layout at one time.
"""
self._hover_button = None
self._action_part = None
# destroy floating panes which have been
# redocked or are becoming non-floating
for p in self._panes:
if p.IsFloating() or not p.frame:
continue
# because the pane is no longer in a floating, we need to
# reparent it to self._frame and destroy the floating frame
# reduce flicker
p.window.SetSize((1, 1))
# the following block is a workaround for bug #1531361
# (see wxWidgets sourceforge page). On wxGTK (only), when
# a frame is shown/hidden, a move event unfortunately
# also gets fired. Because we may be dragging around
# a pane, we need to cancel that action here to prevent
# a spurious crash.
if self._action_window == p.frame:
if self._frame.HasCapture():
self._frame.ReleaseMouse()
self._action = actionNone
self._action_window = None
# hide the frame
if p.frame.IsShown():
p.frame.Show(False)
if self._action_window == p.frame:
self._action_window = None
# reparent to self._frame and destroy the pane
p.window.Reparent(self._frame)
if isinstance(p.window, auibar.AuiToolBar):
p.window.SetAuiManager(self)
if p.frame:
p.frame.SetSizer(None)
p.frame.Destroy()
p.frame = None
# Only the master manager should create/destroy notebooks...
if not self._masterManager:
self.UpdateNotebook()
# delete old sizer first
self._frame.SetSizer(None)
# create a layout for all of the panes
sizer = self.LayoutAll(self._panes, self._docks, self._uiparts, False)
# hide or show panes as necessary,
# and float panes as necessary
pane_count = len(self._panes)
for ii in xrange(pane_count):
p = self._panes[ii]
pFrame = p.frame
if p.IsFloating():
if pFrame is None:
# we need to create a frame for this
# pane, which has recently been floated
frame = self.CreateFloatingFrame(self._frame, p)
# on MSW and Mac, if the owner desires transparent dragging, and
# the dragging is happening right now, then the floating
# window should have this style by default
if self._action in [actionDragFloatingPane, actionDragToolbarPane] and \
self._agwFlags & AUI_MGR_TRANSPARENT_DRAG:
frame.SetTransparent(150)
if p.IsToolbar():
bar = p.window
if isinstance(bar, auibar.AuiToolBar):
bar.SetGripperVisible(False)
agwStyle = bar.GetAGWWindowStyleFlag()
bar.SetAGWWindowStyleFlag(agwStyle & ~AUI_TB_VERTICAL)
bar.Realize()
s = p.window.GetMinSize()
p.BestSize(s)
p.FloatingSize(wx.DefaultSize)
frame.SetPaneWindow(p)
p.needsTransparency = True
p.frame = pFrame = frame
if p.IsShown() and not frame.IsShown():
frame.Show()
frame.Update()
else:
# frame already exists, make sure it's position
# and size reflect the information in AuiPaneInfo
if pFrame.GetPosition() != p.floating_pos or pFrame.GetSize() != p.floating_size:
pFrame.SetDimensions(p.floating_pos.x, p.floating_pos.y,
p.floating_size.x, p.floating_size.y, wx.SIZE_USE_EXISTING)
# update whether the pane is resizable or not
style = p.frame.GetWindowStyleFlag()
if p.IsFixed():
style &= ~wx.RESIZE_BORDER
else:
style |= wx.RESIZE_BORDER
p.frame.SetWindowStyleFlag(style)
if pFrame.IsShown() != p.IsShown():
p.needsTransparency = True
pFrame.Show(p.IsShown())
if pFrame.GetTitle() != p.caption:
pFrame.SetTitle(p.caption)
if p.icon.IsOk():
pFrame.SetIcon(wx.IconFromBitmap(p.icon))
else:
if p.IsToolbar():
# self.SwitchToolBarOrientation(p)
p.best_size = p.window.GetBestSize()
if p.window and not p.IsNotebookPage() and p.window.IsShown() != p.IsShown():
p.window.Show(p.IsShown())
if pFrame and p.needsTransparency:
if pFrame.IsShown() and pFrame._transparent != p.transparent:
pFrame.SetTransparent(p.transparent)
pFrame._transparent = p.transparent
p.needsTransparency = False
# if "active panes" are no longer allowed, clear
# any optionActive values from the pane states
if self._agwFlags & AUI_MGR_ALLOW_ACTIVE_PANE == 0:
p.state &= ~AuiPaneInfo.optionActive
self._panes[ii] = p
old_pane_rects = []
pane_count = len(self._panes)
for p in self._panes:
r = wx.Rect()
if p.window and p.IsShown() and p.IsDocked():
r = p.rect
old_pane_rects.append(r)
# apply the new sizer
self._frame.SetSizer(sizer)
self._frame.SetAutoLayout(False)
self.DoFrameLayout()
# now that the frame layout is done, we need to check
# the new pane rectangles against the old rectangles that
# we saved a few lines above here. If the rectangles have
# changed, the corresponding panes must also be updated
for ii in xrange(pane_count):
p = self._panes[ii]
if p.window and p.IsShown() and p.IsDocked():
if p.rect != old_pane_rects[ii]:
p.window.Refresh()
p.window.Update()
if wx.Platform == "__WXMAC__":
self._frame.Refresh()
else:
self.Repaint()
if not self._masterManager:
e = self.FireEvent(wxEVT_AUI_PERSPECTIVE_CHANGED, None, canVeto=False)
def UpdateNotebook(self):
""" Updates the automatic :class:`~lib.agw.aui.auibook.AuiNotebook` in the layout (if any exists). """
# Workout how many notebooks we need.
max_notebook = -1
# destroy floating panes which have been
# redocked or are becoming non-floating
for paneInfo in self._panes:
if max_notebook < paneInfo.notebook_id:
max_notebook = paneInfo.notebook_id
# We are the master of our domain
extra_notebook = len(self._notebooks)
max_notebook += 1
for i in xrange(extra_notebook, max_notebook):
self.CreateNotebook()
# Remove pages from notebooks that no-longer belong there ...
for nb, notebook in enumerate(self._notebooks):
pages = notebook.GetPageCount()
pageCounter, allPages = 0, pages
# Check each tab ...
for page in xrange(pages):
if page >= allPages:
break
window = notebook.GetPage(pageCounter)
paneInfo = self.GetPane(window)
if paneInfo.IsOk() and paneInfo.notebook_id != nb:
notebook.RemovePage(pageCounter)
window.Hide()
window.Reparent(self._frame)
pageCounter -= 1
allPages -= 1
pageCounter += 1
notebook.DoSizing()
# Add notebook pages that aren't there already...
for paneInfo in self._panes:
if paneInfo.IsNotebookPage():
title = (paneInfo.caption == "" and [paneInfo.name] or [paneInfo.caption])[0]
notebook = self._notebooks[paneInfo.notebook_id]
page_id = notebook.GetPageIndex(paneInfo.window)
if page_id < 0:
paneInfo.window.Reparent(notebook)
notebook.AddPage(paneInfo.window, title, True, paneInfo.icon)
# Update title and icon ...
else:
notebook.SetPageText(page_id, title)
notebook.SetPageBitmap(page_id, paneInfo.icon)
notebook.DoSizing()
# Wire-up newly created notebooks
elif paneInfo.IsNotebookControl() and not paneInfo.window:
paneInfo.window = self._notebooks[paneInfo.notebook_id]
# Delete empty notebooks, and convert notebooks with 1 page to
# normal panes...
remap_ids = [-1]*len(self._notebooks)
nb_idx = 0
for nb, notebook in enumerate(self._notebooks):
if notebook.GetPageCount() == 1:
# Convert notebook page to pane...
window = notebook.GetPage(0)
child_pane = self.GetPane(window)
notebook_pane = self.GetPane(notebook)
if child_pane.IsOk() and notebook_pane.IsOk():
child_pane.SetDockPos(notebook_pane)
child_pane.window.Hide()
child_pane.window.Reparent(self._frame)
child_pane.frame = None
child_pane.notebook_id = -1
if notebook_pane.IsFloating():
child_pane.Float()
self.DetachPane(notebook)
notebook.RemovePage(0)
notebook.Destroy()
else:
raise Exception("Odd notebook docking")
elif notebook.GetPageCount() == 0:
self.DetachPane(notebook)
notebook.Destroy()
else:
# Correct page ordering. The original wxPython code
# for this did not work properly, and would misplace
# windows causing errors.
notebook.Freeze()
self._notebooks[nb_idx] = notebook
pages = notebook.GetPageCount()
selected = notebook.GetPage(notebook.GetSelection())
# Take each page out of the notebook, group it with
# its current pane, and sort the list by pane.dock_pos
# order
pages_and_panes = []
for idx in reversed(range(pages)):
page = notebook.GetPage(idx)
pane = self.GetPane(page)
pages_and_panes.append((page, pane))
notebook.RemovePage(idx)
sorted_pnp = sorted(pages_and_panes, key=lambda tup: tup[1].dock_pos)
# Grab the attributes from the panes which are ordered
# correctly, and copy those attributes to the original
# panes. (This avoids having to change the ordering
# of self._panes) Then, add the page back into the notebook
sorted_attributes = [self.GetAttributes(tup[1])
for tup in sorted_pnp]
for attrs, tup in zip(sorted_attributes, pages_and_panes):
pane = tup[1]
self.SetAttributes(pane, attrs)
notebook.AddPage(pane.window, pane.caption)
notebook.SetSelection(notebook.GetPageIndex(selected), True)
notebook.DoSizing()
notebook.Thaw()
# It's a keeper.
remap_ids[nb] = nb_idx
nb_idx += 1
# Apply remap...
nb_count = len(self._notebooks)
if nb_count != nb_idx:
self._notebooks = self._notebooks[0:nb_idx]
for p in self._panes:
if p.notebook_id >= 0:
p.notebook_id = remap_ids[p.notebook_id]
if p.IsNotebookControl():
p.SetNameFromNotebookId()
# Make sure buttons are correct ...
for notebook in self._notebooks:
want_max = True
want_min = True
want_close = True
pages = notebook.GetPageCount()
for page in xrange(pages):
win = notebook.GetPage(page)
pane = self.GetPane(win)
if pane.IsOk():
if not pane.HasCloseButton():
want_close = False
if not pane.HasMaximizeButton():
want_max = False
if not pane.HasMinimizeButton():
want_min = False
notebook_pane = self.GetPane(notebook)
if notebook_pane.IsOk():
if notebook_pane.HasMinimizeButton() != want_min:
if want_min:
button = AuiPaneButton(AUI_BUTTON_MINIMIZE)
notebook_pane.state |= AuiPaneInfo.buttonMinimize
notebook_pane.buttons.append(button)
# todo: remove min/max
if notebook_pane.HasMaximizeButton() != want_max:
if want_max:
button = AuiPaneButton(AUI_BUTTON_MAXIMIZE_RESTORE)
notebook_pane.state |= AuiPaneInfo.buttonMaximize
notebook_pane.buttons.append(button)
# todo: remove min/max
if notebook_pane.HasCloseButton() != want_close:
if want_close:
button = AuiPaneButton(AUI_BUTTON_CLOSE)
notebook_pane.state |= AuiPaneInfo.buttonClose
notebook_pane.buttons.append(button)
# todo: remove close
def SmartShrink(self, docks, direction):
"""
Used to intelligently shrink the docks' size (if needed).
:param `docks`: a list of :class:`AuiDockInfo` instances;
:param integer `direction`: the direction in which to shrink.
"""
sashSize = self._art.GetMetric(AUI_DOCKART_SASH_SIZE)
caption_size = self._art.GetMetric(AUI_DOCKART_CAPTION_SIZE)
clientSize = self._frame.GetClientSize()
ourDocks = FindDocks(docks, direction, -1, -1)
oppositeDocks = FindOppositeDocks(docks, direction)
oppositeSize = self.GetOppositeDockTotalSize(docks, direction)
ourSize = 0
for dock in ourDocks:
ourSize += dock.size
if not dock.toolbar:
ourSize += sashSize
shrinkSize = ourSize + oppositeSize
if direction == AUI_DOCK_TOP or direction == AUI_DOCK_BOTTOM:
shrinkSize -= clientSize.y
else:
shrinkSize -= clientSize.x
if shrinkSize <= 0:
return docks
# Combine arrays
for dock in oppositeDocks:
ourDocks.append(dock)
oppositeDocks = []
for dock in ourDocks:
if dock.toolbar or not dock.resizable:
continue
dockRange = dock.size - dock.min_size
if dock.min_size == 0:
dockRange -= sashSize
if direction == AUI_DOCK_TOP or direction == AUI_DOCK_BOTTOM:
dockRange -= caption_size
if dockRange >= shrinkSize:
dock.size -= shrinkSize
return docks
else:
dock.size -= dockRange
shrinkSize -= dockRange
return docks
def UpdateDockingGuides(self, paneInfo):
"""
Updates the docking guide windows positions and appearance.
:param `paneInfo`: a :class:`AuiPaneInfo` instance.
"""
if len(self._guides) == 0:
self.CreateGuideWindows()
captionSize = self._art.GetMetric(AUI_DOCKART_CAPTION_SIZE)
frameRect = GetInternalFrameRect(self._frame, self._docks)
mousePos = wx.GetMousePosition()
for indx, guide in enumerate(self._guides):
pt = wx.Point()
guide_size = guide.host.GetSize()
if not guide.host:
raise Exception("Invalid docking host")
direction = guide.dock_direction
if direction == AUI_DOCK_LEFT:
pt.x = frameRect.x + guide_size.x / 2 + 16
pt.y = frameRect.y + frameRect.height / 2
elif direction == AUI_DOCK_TOP:
pt.x = frameRect.x + frameRect.width / 2
pt.y = frameRect.y + guide_size.y / 2 + 16
elif direction == AUI_DOCK_RIGHT:
pt.x = frameRect.x + frameRect.width - guide_size.x / 2 - 16
pt.y = frameRect.y + frameRect.height / 2
elif direction == AUI_DOCK_BOTTOM:
pt.x = frameRect.x + frameRect.width / 2
pt.y = frameRect.y + frameRect.height - guide_size.y / 2 - 16
elif direction == AUI_DOCK_CENTER:
rc = paneInfo.window.GetScreenRect()
pt.x = rc.x + rc.width / 2
pt.y = rc.y + rc.height / 2
if paneInfo.HasCaption():
pt.y -= captionSize / 2
elif paneInfo.HasCaptionLeft():
pt.x -= captionSize / 2
# guide will be centered around point 'pt'
targetPosition = wx.Point(pt.x - guide_size.x / 2, pt.y - guide_size.y / 2)
if guide.host.GetPosition() != targetPosition:
guide.host.Move(targetPosition)
guide.host.AeroMove(targetPosition)
if guide.dock_direction == AUI_DOCK_CENTER:
guide.host.ValidateNotebookDocking(paneInfo.IsNotebookDockable())
guide.host.UpdateDockGuide(mousePos)
paneInfo.window.Lower()
def DoFrameLayout(self):
"""
This is an internal function which invokes :meth:`Sizer.Layout() <Sizer.Layout>`
on the frame's main sizer, then measures all the various UI items
and updates their internal rectangles.
:note: This should always be called instead of calling
`self._managed_window.Layout()` directly.
"""
self._frame.Layout()
for part in self._uiparts:
# get the rectangle of the UI part
# originally, this code looked like this:
# part.rect = wx.Rect(part.sizer_item.GetPosition(),
# part.sizer_item.GetSize())
# this worked quite well, with one exception: the mdi
# client window had a "deferred" size variable
# that returned the wrong size. It looks like
# a bug in wx, because the former size of the window
# was being returned. So, we will retrieve the part's
# rectangle via other means
part.rect = part.sizer_item.GetRect()
flag = part.sizer_item.GetFlag()
border = part.sizer_item.GetBorder()
if flag & wx.TOP:
part.rect.y -= border
part.rect.height += border
if flag & wx.LEFT:
part.rect.x -= border
part.rect.width += border
if flag & wx.BOTTOM:
part.rect.height += border
if flag & wx.RIGHT:
part.rect.width += border
if part.type == AuiDockUIPart.typeDock:
part.dock.rect = part.rect
if part.type == AuiDockUIPart.typePane:
part.pane.rect = part.rect
def GetPanePart(self, wnd):
"""
Looks up the pane border UI part of the
pane specified. This allows the caller to get the exact rectangle
of the pane in question, including decorations like caption and border.
:param Window `wnd`: the window to which the pane border belongs to.
"""
for part in self._uiparts:
if part.type == AuiDockUIPart.typePaneBorder and \
part.pane and part.pane.window == wnd:
return part
for part in self._uiparts:
if part.type == AuiDockUIPart.typePane and \
part.pane and part.pane.window == wnd:
return part
return None
def GetDockPixelOffset(self, test):
"""
This is an internal function which returns a dock's offset in pixels from
the left side of the window (for horizontal docks) or from the top of the
window (for vertical docks).
This value is necessary for calculating fixed-pane/toolbar offsets
when they are dragged.
:param `test`: a fake :class:`AuiPaneInfo` for testing purposes.
"""
# the only way to accurately calculate the dock's
# offset is to actually run a theoretical layout
docks, panes = CopyDocksAndPanes2(self._docks, self._panes)
panes.append(test)
sizer, panes, docks, uiparts = self.LayoutAll(panes, docks, [], True, False)
client_size = self._frame.GetClientSize()
sizer.SetDimension(0, 0, client_size.x, client_size.y)
sizer.Layout()
for part in uiparts:
pos = part.sizer_item.GetPosition()
size = part.sizer_item.GetSize()
part.rect = wx.RectPS(pos, size)
if part.type == AuiDockUIPart.typeDock:
part.dock.rect = part.rect
sizer.Destroy()
for dock in docks:
if test.dock_direction == dock.dock_direction and \
test.dock_layer == dock.dock_layer and \
test.dock_row == dock.dock_row:
if dock.IsVertical():
return dock.rect.y
else:
return dock.rect.x
return 0
def GetPartnerDock(self, dock):
"""
Returns the partner dock for the input dock.
:param `dock`: a :class:`AuiDockInfo` instance.
"""
for layer in xrange(dock.dock_layer, -1, -1):
bestDock = None
for tmpDock in self._docks:
if tmpDock.dock_layer != layer:
continue
if tmpDock.dock_direction != dock.dock_direction:
continue
if tmpDock.dock_layer < dock.dock_layer:
if not bestDock or tmpDock.dock_row < bestDock.dock_row:
bestDock = tmpDock
elif tmpDock.dock_row > dock.dock_row:
if not bestDock or tmpDock.dock_row > bestDock.dock_row:
bestDock = tmpDock
if bestDock:
return bestDock
return None
def GetPartnerPane(self, dock, pane):
"""
Returns the partner pane for the input pane. They both need to live
in the same :class:`AuiDockInfo`.
:param `dock`: a :class:`AuiDockInfo` instance;
:param `pane`: a :class:`AuiPaneInfo` class.
"""
panePosition = -1
for i, tmpPane in enumerate(dock.panes):
if tmpPane.window == pane.window:
panePosition = i
elif not tmpPane.IsFixed() and panePosition != -1:
return tmpPane
return None
def GetTotalPixSizeAndProportion(self, dock):
"""
Returns the dimensions and proportion of the input dock.
:param `dock`: the :class:`AuiDockInfo` structure to analyze.
"""
totalPixsize = 0
totalProportion = 0
# determine the total proportion of all resizable panes,
# and the total size of the dock minus the size of all
# the fixed panes
for tmpPane in dock.panes:
if tmpPane.IsFixed():
continue
totalProportion += tmpPane.dock_proportion
if dock.IsHorizontal():
totalPixsize += tmpPane.rect.width
else:
totalPixsize += tmpPane.rect.height
## if tmpPane.min_size.IsFullySpecified():
##
## if dock.IsHorizontal():
## totalPixsize -= tmpPane.min_size.x
## else:
## totalPixsize -= tmpPane.min_size.y
return totalPixsize, totalProportion
def GetOppositeDockTotalSize(self, docks, direction):
"""
Returns the dimensions of the dock which lives opposite of the input dock.
:param `docks`: a list of :class:`AuiDockInfo` structures to analyze;
:param integer `direction`: the direction in which to look for the opposite dock.
"""
sash_size = self._art.GetMetric(AUI_DOCKART_SASH_SIZE)
caption_size = self._art.GetMetric(AUI_DOCKART_CAPTION_SIZE)
pane_border_size = self._art.GetMetric(AUI_DOCKART_PANE_BORDER_SIZE)
minSizeMax = 0
result = sash_size
vertical = False
if direction in [AUI_DOCK_TOP, AUI_DOCK_BOTTOM]:
vertical = True
# Get minimum size of the most inner area
for tmpDock in docks:
if tmpDock.dock_layer != 0:
continue
if tmpDock.dock_direction != AUI_DOCK_CENTER and tmpDock.IsVertical() != vertical:
continue
for tmpPane in tmpDock.panes:
minSize = pane_border_size*2 - sash_size
if vertical:
minSize += tmpPane.min_size.y + caption_size
else:
minSize += tmpPane.min_size.x
if minSize > minSizeMax:
minSizeMax = minSize
result += minSizeMax
# Get opposite docks
oppositeDocks = FindOppositeDocks(docks, direction)
# Sum size of the opposite docks and their sashes
for dock in oppositeDocks:
result += dock.size
# if it's not a toolbar add the sash_size too
if not dock.toolbar:
result += sash_size
return result
def CalculateDockSizerLimits(self, dock):
"""
Calculates the minimum and maximum sizes allowed for the input dock.
:param `dock`: the :class:`AuiDockInfo` structure to analyze.
"""
docks, panes = CopyDocksAndPanes2(self._docks, self._panes)
sash_size = self._art.GetMetric(AUI_DOCKART_SASH_SIZE)
caption_size = self._art.GetMetric(AUI_DOCKART_CAPTION_SIZE)
opposite_size = self.GetOppositeDockTotalSize(docks, dock.dock_direction)
for tmpDock in docks:
if tmpDock.dock_direction == dock.dock_direction and \
tmpDock.dock_layer == dock.dock_layer and \
tmpDock.dock_row == dock.dock_row:
tmpDock.size = 1
break
sizer, panes, docks, uiparts = self.LayoutAll(panes, docks, [], True, False)
client_size = self._frame.GetClientSize()
sizer.SetDimension(0, 0, client_size.x, client_size.y)
sizer.Layout()
for part in uiparts:
part.rect = wx.RectPS(part.sizer_item.GetPosition(), part.sizer_item.GetSize())
if part.type == AuiDockUIPart.typeDock:
part.dock.rect = part.rect
sizer.Destroy()
new_dock = None
for tmpDock in docks:
if tmpDock.dock_direction == dock.dock_direction and \
tmpDock.dock_layer == dock.dock_layer and \
tmpDock.dock_row == dock.dock_row:
new_dock = tmpDock
break
partnerDock = self.GetPartnerDock(dock)
if partnerDock:
partnerRange = partnerDock.size - partnerDock.min_size
if partnerDock.min_size == 0:
partnerRange -= sash_size
if dock.IsHorizontal():
partnerRange -= caption_size
direction = dock.dock_direction
if direction == AUI_DOCK_LEFT:
minPix = new_dock.rect.x + new_dock.rect.width
maxPix = dock.rect.x + dock.rect.width
maxPix += partnerRange
elif direction == AUI_DOCK_TOP:
minPix = new_dock.rect.y + new_dock.rect.height
maxPix = dock.rect.y + dock.rect.height
maxPix += partnerRange
elif direction == AUI_DOCK_RIGHT:
minPix = dock.rect.x - partnerRange - sash_size
maxPix = new_dock.rect.x - sash_size
elif direction == AUI_DOCK_BOTTOM:
minPix = dock.rect.y - partnerRange - sash_size
maxPix = new_dock.rect.y - sash_size
return minPix, maxPix
direction = new_dock.dock_direction
if direction == AUI_DOCK_LEFT:
minPix = new_dock.rect.x + new_dock.rect.width
maxPix = client_size.x - opposite_size - sash_size
elif direction == AUI_DOCK_TOP:
minPix = new_dock.rect.y + new_dock.rect.height
maxPix = client_size.y - opposite_size - sash_size
elif direction == AUI_DOCK_RIGHT:
minPix = opposite_size
maxPix = new_dock.rect.x - sash_size
elif direction == AUI_DOCK_BOTTOM:
minPix = opposite_size
maxPix = new_dock.rect.y - sash_size
return minPix, maxPix
def CalculatePaneSizerLimits(self, dock, pane):
"""
Calculates the minimum and maximum sizes allowed for the input pane.
:param `dock`: the :class:`AuiDockInfo` structure to which `pane` belongs to;
:param `pane`: a :class:`AuiPaneInfo` class for which calculation are requested.
"""
if pane.IsFixed():
if dock.IsHorizontal():
minPix = maxPix = pane.rect.x + 1 + pane.rect.width
else:
minPix = maxPix = pane.rect.y + 1 + pane.rect.height
return minPix, maxPix
totalPixsize, totalProportion = self.GetTotalPixSizeAndProportion(dock)
partnerPane = self.GetPartnerPane(dock, pane)
if dock.IsHorizontal():
minPix = pane.rect.x + 1
maxPix = pane.rect.x + 1 + pane.rect.width
if pane.min_size.IsFullySpecified():
minPix += pane.min_size.x
else:
minPix += 1
if partnerPane:
maxPix += partnerPane.rect.width
if partnerPane.min_size.IsFullySpecified():
maxPix -= partnerPane.min_size.x - 1
else:
minPix = maxPix
else:
minPix = pane.rect.y + 1
maxPix = pane.rect.y + 1 + pane.rect.height
if pane.min_size.IsFullySpecified():
minPix += pane.min_size.y
else:
minPix += 1
if partnerPane:
maxPix += partnerPane.rect.height
if partnerPane.min_size.IsFullySpecified():
maxPix -= partnerPane.min_size.y - 1
else:
minPix = maxPix
return minPix, maxPix
def CheckMovableSizer(self, part):
"""
Checks if a UI part can be actually resized.
:param AuiDockUIPart `part`: a UI part.
"""
# a dock may not be resized if it has a single
# pane which is not resizable
if part.type == AuiDockUIPart.typeDockSizer and part.dock and \
len(part.dock.panes) == 1 and part.dock.panes[0].IsFixed():
return False
if part.pane:
# panes that may not be resized should be ignored here
minPix, maxPix = self.CalculatePaneSizerLimits(part.dock, part.pane)
if minPix == maxPix:
return False
return True
def PaneFromTabEvent(self, event):
"""
Returns a :class:`AuiPaneInfo` from a :class:`~lib.agw.aui.auibook.AuiNotebook` event.
:param `event`: a :class:`~lib.agw.aui.auibook.AuiNotebookEvent` event.
"""
obj = event.GetEventObject()
if obj and isinstance(obj, auibook.AuiTabCtrl):
page_idx = obj.GetActivePage()
if page_idx >= 0:
page = obj.GetPage(page_idx)
window = page.window
if window:
return self.GetPane(window)
elif obj and isinstance(obj, auibook.AuiNotebook):
page_idx = event.GetSelection()
if page_idx >= 0:
window = obj.GetPage(page_idx)
if window:
return self.GetPane(window)
return NonePaneInfo
def OnTabBeginDrag(self, event):
"""
Handles the ``EVT_AUINOTEBOOK_BEGIN_DRAG`` event.
:param `event`: a :class:`~lib.agw.aui.auibook.AuiNotebookEvent` event to be processed.
"""
if self._masterManager:
self._masterManager.OnTabBeginDrag(event)
else:
paneInfo = self.PaneFromTabEvent(event)
if paneInfo.IsOk():
# It's one of ours!
self._action = actionDragFloatingPane
mouse = wx.GetMousePosition()
# set initial float position - may have to think about this
# offset a bit more later ...
self._action_offset = wx.Point(20, 10)
self._toolbar_action_offset = wx.Point(20, 10)
paneInfo.floating_pos = mouse - self._action_offset
paneInfo.dock_pos = AUI_DOCK_NONE
paneInfo.notebook_id = -1
tab = event.GetEventObject()
if tab.HasCapture():
tab.ReleaseMouse()
# float the window
if paneInfo.IsMaximized():
self.RestorePane(paneInfo)
paneInfo.Float()
self.Update()
self._action_window = paneInfo.window
self._frame.CaptureMouse()
event.SetDispatched(True)
else:
# not our window
event.Skip()
def OnTabPageClose(self, event):
"""
Handles the ``EVT_AUINOTEBOOK_PAGE_CLOSE`` event.
:param `event`: a :class:`~lib.agw.aui.auibook.AuiNotebookEvent` event to be processed.
"""
if self._masterManager:
self._masterManager.OnTabPageClose(event)
else:
p = self.PaneFromTabEvent(event)
if p.IsOk():
# veto it because we will call "RemovePage" ourselves
event.Veto()
# Now ask the app if they really want to close...
# fire pane close event
e = AuiManagerEvent(wxEVT_AUI_PANE_CLOSE)
e.SetPane(p)
e.SetCanVeto(True)
self.ProcessMgrEvent(e)
if e.GetVeto():
return
self.ClosePane(p)
self.Update()
else:
event.Skip()
def OnTabSelected(self, event):
"""
Handles the ``EVT_AUINOTEBOOK_PAGE_CHANGED`` event.
:param `event`: a :class:`~lib.agw.aui.auibook.AuiNotebookEvent` event to be processed.
"""
if self._masterManager:
self._masterManager.OnTabSelected(event)
return
obj = event.GetEventObject()
if obj and isinstance(obj, auibook.AuiNotebook):
notebook = obj
page = notebook.GetPage(event.GetSelection())
paneInfo = self.GetPane(page)
if paneInfo.IsOk():
notebookRoot = GetNotebookRoot(self._panes, paneInfo.notebook_id)
if notebookRoot:
notebookRoot.Caption(paneInfo.caption)
self.RefreshCaptions()
event.Skip()
def GetNotebooks(self):
""" Returns all the automatic :class:`~lib.agw.aui.auibook.AuiNotebook` in the :class:`AuiManager`. """
if self._masterManager:
return self._masterManager.GetNotebooks()
return self._notebooks
def SetMasterManager(self, manager):
"""
Sets the master manager for an automatic :class:`~lib.agw.aui.auibook.AuiNotebook`.
:param `manager`: an instance of :class:`AuiManager`.
"""
self._masterManager = manager
def ProcessDockResult(self, target, new_pos):
"""
This is a utility function used by :meth:`DoDrop` - it checks
if a dock operation is allowed, the new dock position is copied into
the target info. If the operation was allowed, the function returns ``True``.
:param `target`: the :class:`AuiPaneInfo` instance to be docked;
:param integer `new_pos`: the new docking position if the docking operation is allowed.
"""
allowed = False
direction = new_pos.dock_direction
if direction == AUI_DOCK_TOP:
allowed = target.IsTopDockable()
elif direction == AUI_DOCK_BOTTOM:
allowed = target.IsBottomDockable()
elif direction == AUI_DOCK_LEFT:
allowed = target.IsLeftDockable()
elif direction == AUI_DOCK_RIGHT:
allowed = target.IsRightDockable()
if allowed:
target = new_pos
if target.IsToolbar():
self.SwitchToolBarOrientation(target)
return allowed, target
def SwitchToolBarOrientation(self, pane):
"""
Switches the toolbar orientation from vertical to horizontal and vice-versa.
This is especially useful for vertical docked toolbars once they float.
:param `pane`: an instance of :class:`AuiPaneInfo`, which may have a :class:`~lib.agw.aui.auibar.AuiToolBar`
window associated with it.
"""
if not isinstance(pane.window, auibar.AuiToolBar):
return pane
if pane.IsFloating():
return pane
toolBar = pane.window
direction = pane.dock_direction
vertical = direction in [AUI_DOCK_LEFT, AUI_DOCK_RIGHT]
agwStyle = toolBar.GetAGWWindowStyleFlag()
new_agwStyle = agwStyle
if vertical:
new_agwStyle |= AUI_TB_VERTICAL
else:
new_agwStyle &= ~(AUI_TB_VERTICAL)
if agwStyle != new_agwStyle:
toolBar.SetAGWWindowStyleFlag(new_agwStyle)
if not toolBar.GetGripperVisible():
toolBar.SetGripperVisible(True)
s = pane.window.GetMinSize()
pane.BestSize(s)
if new_agwStyle != agwStyle:
toolBar.Realize()
return pane
def DoDrop(self, docks, panes, target, pt, offset=wx.Point(0, 0)):
"""
This is an important function. It basically takes a mouse position,
and determines where the panes new position would be. If the pane is to be
dropped, it performs the drop operation using the specified dock and pane
arrays. By specifying copy dock and pane arrays when calling, a "what-if"
scenario can be performed, giving precise coordinates for drop hints.
:param `docks`: a list of :class:`AuiDockInfo` classes;
:param `panes`: a list of :class:`AuiPaneInfo` instances;
:param Point `pt`: a mouse position to check for a drop operation;
:param Point `offset`: a possible offset from the input point `pt`.
"""
if target.IsToolbar():
return self.DoDropToolbar(docks, panes, target, pt, offset)
elif target.IsFloating():
return self.DoDropFloatingPane(docks, panes, target, pt)
else:
return self.DoDropNonFloatingPane(docks, panes, target, pt)
def CopyTarget(self, target):
"""
Copies all the attributes of the input `target` into another :class:`AuiPaneInfo`.
:param `target`: the source :class:`AuiPaneInfo` from where to copy attributes.
"""
drop = AuiPaneInfo()
drop.name = target.name
drop.caption = target.caption
drop.window = target.window
drop.frame = target.frame
drop.state = target.state
drop.dock_direction = target.dock_direction
drop.dock_layer = target.dock_layer
drop.dock_row = target.dock_row
drop.dock_pos = target.dock_pos
drop.best_size = wx.Size(*target.best_size)
drop.min_size = wx.Size(*target.min_size)
drop.max_size = wx.Size(*target.max_size)
drop.floating_pos = wx.Point(*target.floating_pos)
drop.floating_size = wx.Size(*target.floating_size)
drop.dock_proportion = target.dock_proportion
drop.buttons = target.buttons
drop.rect = wx.Rect(*target.rect)
drop.icon = target.icon
drop.notebook_id = target.notebook_id
drop.transparent = target.transparent
drop.snapped = target.snapped
drop.minimize_mode = target.minimize_mode
drop.minimize_target = target.minimize_target
return drop
def DoDropToolbar(self, docks, panes, target, pt, offset):
"""
Handles the situation in which the dropped pane contains a toolbar.
:param `docks`: a list of :class:`AuiDockInfo` classes;
:param `panes`: a list of :class:`AuiPaneInfo` instances;
:param AuiPaneInfo `target`: the target pane containing the toolbar;
:param Point `pt`: a mouse position to check for a drop operation;
:param Point `offset`: a possible offset from the input point `pt`.
"""
drop = self.CopyTarget(target)
# The result should always be shown
drop.Show()
# Check to see if the toolbar has been dragged out of the window
if CheckOutOfWindow(self._frame, pt):
if self._agwFlags & AUI_MGR_ALLOW_FLOATING and drop.IsFloatable():
drop.Float()
return self.ProcessDockResult(target, drop)
# Allow directional change when the cursor leaves this rect
safeRect = wx.Rect(*target.rect)
if target.IsHorizontal():
safeRect.Inflate(100, 50)
else:
safeRect.Inflate(50, 100)
# Check to see if the toolbar has been dragged to edge of the frame
dropDir = CheckEdgeDrop(self._frame, docks, pt)
if dropDir != -1:
if dropDir == wx.LEFT:
drop.Dock().Left().Layer(auiToolBarLayer).Row(0). \
Position(pt.y - self.GetDockPixelOffset(drop) - offset.y)
elif dropDir == wx.RIGHT:
drop.Dock().Right().Layer(auiToolBarLayer).Row(0). \
Position(pt.y - self.GetDockPixelOffset(drop) - offset.y)
elif dropDir == wx.TOP:
drop.Dock().Top().Layer(auiToolBarLayer).Row(0). \
Position(pt.x - self.GetDockPixelOffset(drop) - offset.x)
elif dropDir == wx.BOTTOM:
drop.Dock().Bottom().Layer(auiToolBarLayer).Row(0). \
Position(pt.x - self.GetDockPixelOffset(drop) - offset.x)
if not target.IsFloating() and safeRect.Contains(pt) and \
target.dock_direction != drop.dock_direction:
return False, target
return self.ProcessDockResult(target, drop)
# If the windows is floating and out of the client area, do nothing
if drop.IsFloating() and not self._frame.GetClientRect().Contains(pt):
return False, target
# Ok, can't drop on edge - check internals ...
clientSize = self._frame.GetClientSize()
x = Clip(pt.x, 0, clientSize.x - 1)
y = Clip(pt.y, 0, clientSize.y - 1)
part = self.HitTest(x, y)
if not part or not part.dock:
return False, target
dock = part.dock
# toolbars may only be moved in and to fixed-pane docks,
# otherwise we will try to float the pane. Also, the pane
# should float if being dragged over center pane windows
if not dock.fixed or dock.dock_direction == AUI_DOCK_CENTER:
if (self._agwFlags & AUI_MGR_ALLOW_FLOATING and drop.IsFloatable()) or \
dock.dock_direction not in [AUI_DOCK_CENTER, AUI_DOCK_NONE]:
if drop.IsFloatable():
drop.Float()
return self.ProcessDockResult(target, drop)
# calculate the offset from where the dock begins
# to the point where the user dropped the pane
dockDropOffset = 0
if dock.IsHorizontal():
dockDropOffset = pt.x - dock.rect.x - offset.x
else:
dockDropOffset = pt.y - dock.rect.y - offset.y
drop.Dock().Direction(dock.dock_direction).Layer(dock.dock_layer). \
Row(dock.dock_row).Position(dockDropOffset)
if (pt.y <= dock.rect.GetTop() + 2 and dock.IsHorizontal()) or \
(pt.x <= dock.rect.GetLeft() + 2 and dock.IsVertical()):
if dock.dock_direction in [AUI_DOCK_TOP, AUI_DOCK_LEFT]:
row = drop.dock_row
panes = DoInsertDockRow(panes, dock.dock_direction, dock.dock_layer, dock.dock_row)
drop.dock_row = row
else:
panes = DoInsertDockRow(panes, dock.dock_direction, dock.dock_layer, dock.dock_row+1)
drop.dock_row = dock.dock_row + 1
if (pt.y >= dock.rect.GetBottom() - 2 and dock.IsHorizontal()) or \
(pt.x >= dock.rect.GetRight() - 2 and dock.IsVertical()):
if dock.dock_direction in [AUI_DOCK_TOP, AUI_DOCK_LEFT]:
panes = DoInsertDockRow(panes, dock.dock_direction, dock.dock_layer, dock.dock_row+1)
drop.dock_row = dock.dock_row+1
else:
row = drop.dock_row
panes = DoInsertDockRow(panes, dock.dock_direction, dock.dock_layer, dock.dock_row)
drop.dock_row = row
if not target.IsFloating() and safeRect.Contains(pt) and \
target.dock_direction != drop.dock_direction:
return False, target
return self.ProcessDockResult(target, drop)
def DoDropFloatingPane(self, docks, panes, target, pt):
"""
Handles the situation in which the dropped pane contains a normal window.
:param `docks`: a list of :class:`AuiDockInfo` classes;
:param `panes`: a list of :class:`AuiPaneInfo` instances;
:param AuiPaneInfo `target`: the target pane containing the window;
:param Point `pt`: a mouse position to check for a drop operation.
"""
screenPt = self._frame.ClientToScreen(pt)
paneInfo = self.PaneHitTest(panes, pt)
if paneInfo.IsMaximized():
return False, target
if paneInfo.window is None:
return False, target
# search the dock guides.
# reverse order to handle the center first.
for i in xrange(len(self._guides)-1, -1, -1):
guide = self._guides[i]
# do hit testing on the guide
dir = guide.host.HitTest(screenPt.x, screenPt.y)
if dir == -1: # point was outside of the dock guide
continue
if dir == wx.ALL: # target is a single dock guide
return self.DoDropLayer(docks, target, guide.dock_direction)
elif dir == wx.CENTER:
if not target.IsNotebookDockable():
continue
if not paneInfo.IsNotebookDockable() and not paneInfo.IsNotebookControl():
continue
if not paneInfo.HasNotebook():
# Add a new notebook pane with the original as a tab...
self.CreateNotebookBase(panes, paneInfo)
# Add new item to notebook
target.NotebookPage(paneInfo.notebook_id)
else:
drop_pane = False
drop_row = False
insert_dir = paneInfo.dock_direction
insert_layer = paneInfo.dock_layer
insert_row = paneInfo.dock_row
insert_pos = paneInfo.dock_pos
if insert_dir == AUI_DOCK_CENTER:
insert_layer = 0
if dir == wx.LEFT:
insert_dir = AUI_DOCK_LEFT
elif dir == wx.UP:
insert_dir = AUI_DOCK_TOP
elif dir == wx.RIGHT:
insert_dir = AUI_DOCK_RIGHT
elif dir == wx.DOWN:
insert_dir = AUI_DOCK_BOTTOM
if insert_dir == AUI_DOCK_LEFT:
drop_pane = (dir == wx.UP or dir == wx.DOWN)
drop_row = (dir == wx.LEFT or dir == wx.RIGHT)
if dir == wx.RIGHT:
insert_row += 1
elif dir == wx.DOWN:
insert_pos += 1
elif insert_dir == AUI_DOCK_RIGHT:
drop_pane = (dir == wx.UP or dir == wx.DOWN)
drop_row = (dir == wx.LEFT or dir == wx.RIGHT)
if dir == wx.LEFT:
insert_row += 1
elif dir == wx.DOWN:
insert_pos += 1
elif insert_dir == AUI_DOCK_TOP:
drop_pane = (dir == wx.LEFT or dir == wx.RIGHT)
drop_row = (dir == wx.UP or dir == wx.DOWN)
if dir == wx.DOWN:
insert_row += 1
elif dir == wx.RIGHT:
insert_pos += 1
elif insert_dir == AUI_DOCK_BOTTOM:
drop_pane = (dir == wx.LEFT or dir == wx.RIGHT)
drop_row = (dir == wx.UP or dir == wx.DOWN)
if dir == wx.UP:
insert_row += 1
elif dir == wx.RIGHT:
insert_pos += 1
if paneInfo.dock_direction == AUI_DOCK_CENTER:
insert_row = GetMaxRow(panes, insert_dir, insert_layer) + 1
if drop_pane:
return self.DoDropPane(panes, target, insert_dir, insert_layer, insert_row, insert_pos)
if drop_row:
return self.DoDropRow(panes, target, insert_dir, insert_layer, insert_row)
return True, target
return False, target
def DoDropNonFloatingPane(self, docks, panes, target, pt):
"""
Handles the situation in which the dropped pane is not floating.
:param `docks`: a list of :class:`AuiDockInfo` classes;
:param `panes`: a list of :class:`AuiPaneInfo` instances;
:param AuiPaneInfo `target`: the target pane containing the toolbar;
:param Point `pt`: a mouse position to check for a drop operation.
"""
screenPt = self._frame.ClientToScreen(pt)
clientSize = self._frame.GetClientSize()
frameRect = GetInternalFrameRect(self._frame, self._docks)
drop = self.CopyTarget(target)
# The result should always be shown
drop.Show()
part = self.HitTest(pt.x, pt.y)
if not part:
return False, target
if part.type == AuiDockUIPart.typeDockSizer:
if len(part.dock.panes) != 1:
return False, target
part = self.GetPanePart(part.dock.panes[0].window)
if not part:
return False, target
if not part.pane:
return False, target
part = self.GetPanePart(part.pane.window)
if not part:
return False, target
insert_dock_row = False
insert_row = part.pane.dock_row
insert_dir = part.pane.dock_direction
insert_layer = part.pane.dock_layer
direction = part.pane.dock_direction
if direction == AUI_DOCK_TOP:
if pt.y >= part.rect.y and pt.y < part.rect.y+auiInsertRowPixels:
insert_dock_row = True
elif direction == AUI_DOCK_BOTTOM:
if pt.y > part.rect.y+part.rect.height-auiInsertRowPixels and \
pt.y <= part.rect.y + part.rect.height:
insert_dock_row = True
elif direction == AUI_DOCK_LEFT:
if pt.x >= part.rect.x and pt.x < part.rect.x+auiInsertRowPixels:
insert_dock_row = True
elif direction == AUI_DOCK_RIGHT:
if pt.x > part.rect.x+part.rect.width-auiInsertRowPixels and \
pt.x <= part.rect.x+part.rect.width:
insert_dock_row = True
elif direction == AUI_DOCK_CENTER:
# "new row pixels" will be set to the default, but
# must never exceed 20% of the window size
new_row_pixels_x = auiNewRowPixels
new_row_pixels_y = auiNewRowPixels
if new_row_pixels_x > (part.rect.width*20)/100:
new_row_pixels_x = (part.rect.width*20)/100
if new_row_pixels_y > (part.rect.height*20)/100:
new_row_pixels_y = (part.rect.height*20)/100
# determine if the mouse pointer is in a location that
# will cause a new row to be inserted. The hot spot positions
# are along the borders of the center pane
insert_layer = 0
insert_dock_row = True
pr = part.rect
if pt.x >= pr.x and pt.x < pr.x + new_row_pixels_x:
insert_dir = AUI_DOCK_LEFT
elif pt.y >= pr.y and pt.y < pr.y + new_row_pixels_y:
insert_dir = AUI_DOCK_TOP
elif pt.x >= pr.x + pr.width - new_row_pixels_x and pt.x < pr.x + pr.width:
insert_dir = AUI_DOCK_RIGHT
elif pt.y >= pr.y+ pr.height - new_row_pixels_y and pt.y < pr.y + pr.height:
insert_dir = AUI_DOCK_BOTTOM
else:
return False, target
insert_row = GetMaxRow(panes, insert_dir, insert_layer) + 1
if insert_dock_row:
panes = DoInsertDockRow(panes, insert_dir, insert_layer, insert_row)
drop.Dock().Direction(insert_dir).Layer(insert_layer). \
Row(insert_row).Position(0)
return self.ProcessDockResult(target, drop)
# determine the mouse offset and the pane size, both in the
# direction of the dock itself, and perpendicular to the dock
if part.orientation == wx.VERTICAL:
offset = pt.y - part.rect.y
size = part.rect.GetHeight()
else:
offset = pt.x - part.rect.x
size = part.rect.GetWidth()
drop_position = part.pane.dock_pos
# if we are in the top/left part of the pane,
# insert the pane before the pane being hovered over
if offset <= size/2:
drop_position = part.pane.dock_pos
panes = DoInsertPane(panes,
part.pane.dock_direction,
part.pane.dock_layer,
part.pane.dock_row,
part.pane.dock_pos)
# if we are in the bottom/right part of the pane,
# insert the pane before the pane being hovered over
if offset > size/2:
drop_position = part.pane.dock_pos+1
panes = DoInsertPane(panes,
part.pane.dock_direction,
part.pane.dock_layer,
part.pane.dock_row,
part.pane.dock_pos+1)
drop.Dock(). \
Direction(part.dock.dock_direction). \
Layer(part.dock.dock_layer).Row(part.dock.dock_row). \
Position(drop_position)
return self.ProcessDockResult(target, drop)
def DoDropLayer(self, docks, target, dock_direction):
"""
Handles the situation in which `target` is a single dock guide.
:param `docks`: a list of :class:`AuiDockInfo` classes;
:param AuiPaneInfo `target`: the target pane;
:param integer `dock_direction`: the docking direction.
"""
drop = self.CopyTarget(target)
if dock_direction == AUI_DOCK_LEFT:
drop.Dock().Left()
drop_new_layer = max(max(GetMaxLayer(docks, AUI_DOCK_LEFT),
GetMaxLayer(docks, AUI_DOCK_BOTTOM)),
GetMaxLayer(docks, AUI_DOCK_TOP)) + 1
elif dock_direction == AUI_DOCK_TOP:
drop.Dock().Top()
drop_new_layer = max(max(GetMaxLayer(docks, AUI_DOCK_TOP),
GetMaxLayer(docks, AUI_DOCK_LEFT)),
GetMaxLayer(docks, AUI_DOCK_RIGHT)) + 1
elif dock_direction == AUI_DOCK_RIGHT:
drop.Dock().Right()
drop_new_layer = max(max(GetMaxLayer(docks, AUI_DOCK_RIGHT),
GetMaxLayer(docks, AUI_DOCK_TOP)),
GetMaxLayer(docks, AUI_DOCK_BOTTOM)) + 1
elif dock_direction == AUI_DOCK_BOTTOM:
drop.Dock().Bottom()
drop_new_layer = max(max(GetMaxLayer(docks, AUI_DOCK_BOTTOM),
GetMaxLayer(docks, AUI_DOCK_LEFT)),
GetMaxLayer(docks, AUI_DOCK_RIGHT)) + 1
else:
return False, target
drop.Dock().Layer(drop_new_layer)
return self.ProcessDockResult(target, drop)
def DoDropPane(self, panes, target, dock_direction, dock_layer, dock_row, dock_pos):
"""
Drop a pane in the interface.
:param `panes`: a list of :class:`AuiPaneInfo` classes;
:param AuiPaneInfo `target`: the target pane;
:param integer `dock_direction`: the docking direction;
:param integer `dock_layer`: the docking layer;
:param integer `dock_row`: the docking row;
:param integer `dock_pos`: the docking position.
"""
drop = self.CopyTarget(target)
panes = DoInsertPane(panes, dock_direction, dock_layer, dock_row, dock_pos)
drop.Dock().Direction(dock_direction).Layer(dock_layer).Row(dock_row).Position(dock_pos)
return self.ProcessDockResult(target, drop)
def DoDropRow(self, panes, target, dock_direction, dock_layer, dock_row):
"""
Insert a row in the interface before dropping.
:param `panes`: a list of :class:`AuiPaneInfo` classes;
:param AuiPaneInfo `target`: the target pane;
:param integer `dock_direction`: the docking direction;
:param integer `dock_layer`: the docking layer;
:param integer `dock_row`: the docking row.
"""
drop = self.CopyTarget(target)
panes = DoInsertDockRow(panes, dock_direction, dock_layer, dock_row)
drop.Dock().Direction(dock_direction).Layer(dock_layer).Row(dock_row).Position(0)
return self.ProcessDockResult(target, drop)
def ShowHint(self, rect):
"""
Shows the AUI hint window.
:param Rect `rect`: the hint rect calculated in advance.
"""
if rect == self._last_hint:
return
if self._agwFlags & AUI_MGR_RECTANGLE_HINT and wx.Platform != "__WXMAC__":
if self._last_hint != rect:
# remove the last hint rectangle
self._last_hint = wx.Rect(*rect)
self._frame.Refresh()
self._frame.Update()
screendc = wx.ScreenDC()
clip = wx.Region(1, 1, 10000, 10000)
# clip all floating windows, so we don't draw over them
for pane in self._panes:
if pane.IsFloating() and pane.frame.IsShown():
rect2 = wx.Rect(*pane.frame.GetRect())
if wx.Platform == "__WXGTK__":
# wxGTK returns the client size, not the whole frame size
rect2.width += 15
rect2.height += 35
rect2.Inflate(5, 5)
clip.SubtractRect(rect2)
# As we can only hide the hint by redrawing the managed window, we
# need to clip the region to the managed window too or we get
# nasty redrawn problems.
clip.IntersectRect(self._frame.GetRect())
screendc.SetClippingRegionAsRegion(clip)
stipple = PaneCreateStippleBitmap()
brush = wx.BrushFromBitmap(stipple)
screendc.SetBrush(brush)
screendc.SetPen(wx.TRANSPARENT_PEN)
screendc.DrawRectangle(rect.x, rect.y, 5, rect.height)
screendc.DrawRectangle(rect.x+5, rect.y, rect.width-10, 5)
screendc.DrawRectangle(rect.x+rect.width-5, rect.y, 5, rect.height)
screendc.DrawRectangle(rect.x+5, rect.y+rect.height-5, rect.width-10, 5)
RefreshDockingGuides(self._guides)
return
if not self._hint_window:
self.CreateHintWindow()
if self._hint_window:
self._hint_window.SetRect(rect)
self._hint_window.Show()
self._hint_fadeamt = self._hint_fademax
if self._agwFlags & AUI_MGR_HINT_FADE:
self._hint_fadeamt = 0
self._hint_window.SetTransparent(self._hint_fadeamt)
if self._action == actionDragFloatingPane and self._action_window:
self._action_window.SetFocus()
if self._hint_fadeamt != self._hint_fademax: # Only fade if we need to
# start fade in timer
self._hint_fadetimer.Start(5)
self._last_hint = wx.Rect(*rect)
def HideHint(self):
""" Hides a transparent window hint if there is one. """
# hides a transparent window hint if there is one
if self._hint_window:
self._hint_window.Hide()
self._hint_fadetimer.Stop()
self._last_hint = wx.Rect()
def IsPaneButtonVisible(self, part):
"""
Returns whether a pane button in the pane caption is visible.
:param AuiDockUIPart `part`: the UI part to analyze.
"""
captionRect = wx.Rect()
for temp_part in self._uiparts:
if temp_part.pane == part.pane and \
temp_part.type == AuiDockUIPart.typeCaption:
captionRect = temp_part.rect
break
return captionRect.ContainsRect(part.rect)
def DrawPaneButton(self, dc, part, pt):
"""
Draws a pane button in the caption (convenience function).
:param `dc`: a :class:`DC` device context object;
:param AuiDockUIPart `part`: the UI part to analyze;
:param Point `pt`: the mouse location.
"""
if not self.IsPaneButtonVisible(part):
return
state = AUI_BUTTON_STATE_NORMAL
if part.rect.Contains(pt):
if _VERSION_STRING < "2.9":
leftDown = wx.GetMouseState().LeftDown()
else:
leftDown = wx.GetMouseState().LeftIsDown()
if leftDown:
state = AUI_BUTTON_STATE_PRESSED
else:
state = AUI_BUTTON_STATE_HOVER
self._art.DrawPaneButton(dc, self._frame, part.button.button_id,
state, part.rect, part.pane)
def RefreshButton(self, part):
"""
Refreshes a pane button in the caption.
:param AuiDockUIPart `part`: the UI part to analyze.
"""
rect = wx.Rect(*part.rect)
rect.Inflate(2, 2)
self._frame.Refresh(True, rect)
self._frame.Update()
def RefreshCaptions(self):
""" Refreshes all pane captions. """
for part in self._uiparts:
if part.type == AuiDockUIPart.typeCaption:
self._frame.Refresh(True, part.rect)
self._frame.Update()
def CalculateHintRect(self, pane_window, pt, offset):
"""
Calculates the drop hint rectangle.
The method first calls :meth:`DoDrop` to determine the exact position the pane would
be at were if dropped. If the pane would indeed become docked at the
specified drop point, the the rectangle hint will be returned in
screen coordinates. Otherwise, an empty rectangle is returned.
:param Window `pane_window`: it is the window pointer of the pane being dragged;
:param Point `pt`: is the mouse position, in client coordinates;
:param Point `offset`: describes the offset that the mouse is from the upper-left
corner of the item being dragged.
"""
# we need to paint a hint rectangle to find out the exact hint rectangle,
# we will create a new temporary layout and then measure the resulting
# rectangle we will create a copy of the docking structures (self._docks)
# so that we don't modify the real thing on screen
rect = wx.Rect()
pane = self.GetPane(pane_window)
attrs = self.GetAttributes(pane)
hint = AuiPaneInfo()
hint = self.SetAttributes(hint, attrs)
if hint.name != "__HINT__":
self._oldname = hint.name
hint.name = "__HINT__"
hint.PaneBorder(True)
hint.Show()
if not hint.IsOk():
hint.name = self._oldname
return rect
docks, panes = CopyDocksAndPanes2(self._docks, self._panes)
# remove any pane already there which bears the same window
# this happens when you are moving a pane around in a dock
for ii in xrange(len(panes)):
if panes[ii].window == pane_window:
docks = RemovePaneFromDocks(docks, panes[ii])
panes.pop(ii)
break
# find out where the new pane would be
allow, hint = self.DoDrop(docks, panes, hint, pt, offset)
if not allow:
return rect
panes.append(hint)
sizer, panes, docks, uiparts = self.LayoutAll(panes, docks, [], True, False)
client_size = self._frame.GetClientSize()
sizer.SetDimension(0, 0, client_size.x, client_size.y)
sizer.Layout()
sought = "__HINT__"
# For a notebook page, actually look for the notebook itself.
if hint.IsNotebookPage():
id = hint.notebook_id
for pane in panes:
if pane.IsNotebookControl() and pane.notebook_id==id:
sought = pane.name
break
for part in uiparts:
if part.pane and part.pane.name == sought:
rect.Union(wx.RectPS(part.sizer_item.GetPosition(),
part.sizer_item.GetSize()))
sizer.Destroy()
# check for floating frame ...
if rect.IsEmpty():
for p in panes:
if p.name == sought and p.IsFloating():
return wx.RectPS(p.floating_pos, p.floating_size)
if rect.IsEmpty():
return rect
# actually show the hint rectangle on the screen
rect.x, rect.y = self._frame.ClientToScreen((rect.x, rect.y))
if self._frame.GetLayoutDirection() == wx.Layout_RightToLeft:
# Mirror rectangle in RTL mode
rect.x -= rect.GetWidth()
return rect
def DrawHintRect(self, pane_window, pt, offset):
"""
Calculates the hint rectangle by calling :meth:`CalculateHintRect`. If there is a
rectangle, it shows it by calling :meth:`ShowHint`, otherwise it hides any hint
rectangle currently shown.
:param Window `pane_window`: it is the window pointer of the pane being dragged;
:param Point `pt`: is the mouse position, in client coordinates;
:param Point `offset`: describes the offset that the mouse is from the upper-left
corner of the item being dragged.
"""
rect = self.CalculateHintRect(pane_window, pt, offset)
if rect.IsEmpty():
self.HideHint()
self._hint_rect = wx.Rect()
else:
self.ShowHint(rect)
self._hint_rect = wx.Rect(*rect)
def GetPartSizerRect(self, uiparts):
"""
Returns the rectangle surrounding the specified UI parts.
:param list `uiparts`: list of :class:`AuiDockUIPart` parts.
"""
rect = wx.Rect()
for part in self._uiparts:
if part.pane and part.pane.name == "__HINT__":
rect.Union(wx.RectPS(part.sizer_item.GetPosition(),
part.sizer_item.GetSize()))
return rect
def GetAttributes(self, pane):
"""
Returns all the attributes of a :class:`AuiPaneInfo`.
:param `pane`: a :class:`AuiPaneInfo` instance.
"""
attrs = []
attrs.extend([pane.window, pane.frame, pane.state, pane.dock_direction,
pane.dock_layer, pane.dock_pos, pane.dock_row, pane.dock_proportion,
pane.floating_pos, pane.floating_size, pane.best_size,
pane.min_size, pane.max_size, pane.caption, pane.name,
pane.buttons, pane.rect, pane.icon, pane.notebook_id,
pane.transparent, pane.snapped, pane.minimize_mode, pane.minimize_target])
return attrs
def SetAttributes(self, pane, attrs):
"""
Sets all the attributes contained in `attrs` to a :class:`AuiPaneInfo`.
:param `pane`: a :class:`AuiPaneInfo` instance;
:param list `attrs`: a list of attributes.
"""
pane.window = attrs[0]
pane.frame = attrs[1]
pane.state = attrs[2]
pane.dock_direction = attrs[3]
pane.dock_layer = attrs[4]
pane.dock_pos = attrs[5]
pane.dock_row = attrs[6]
pane.dock_proportion = attrs[7]
pane.floating_pos = attrs[8]
pane.floating_size = attrs[9]
pane.best_size = attrs[10]
pane.min_size = attrs[11]
pane.max_size = attrs[12]
pane.caption = attrs[13]
pane.name = attrs[14]
pane.buttons = attrs[15]
pane.rect = attrs[16]
pane.icon = attrs[17]
pane.notebook_id = attrs[18]
pane.transparent = attrs[19]
pane.snapped = attrs[20]
pane.minimize_mode = attrs[21]
pane.minimize_target = attrs[22]
return pane
def OnFloatingPaneResized(self, wnd, size):
"""
Handles the resizing of a floating pane.
:param Window `wnd`: the window managed by the pane;
:param Size `size`: the new pane floating size.
"""
# try to find the pane
pane = self.GetPane(wnd)
if not pane.IsOk():
raise Exception("Pane window not found")
if pane.frame:
indx = self._panes.index(pane)
pane.floating_pos = pane.frame.GetPosition()
pane.floating_size = size
self._panes[indx] = pane
if pane.IsSnappable():
self.SnapPane(pane, pane.floating_pos, pane.floating_size, True)
def OnFloatingPaneClosed(self, wnd, event):
"""
Handles the close event of a floating pane.
:param Window `wnd`: the window managed by the pane;
:param `event`: a :class:`CloseEvent` to be processed.
"""
# try to find the pane
pane = self.GetPane(wnd)
if not pane.IsOk():
raise Exception("Pane window not found")
# fire pane close event
e = AuiManagerEvent(wxEVT_AUI_PANE_CLOSE)
e.SetPane(pane)
e.SetCanVeto(event.CanVeto())
self.ProcessMgrEvent(e)
if e.GetVeto():
event.Veto()
return
else:
# close the pane, but check that it
# still exists in our pane array first
# (the event handler above might have removed it)
check = self.GetPane(wnd)
if check.IsOk():
self.ClosePane(pane)
def OnFloatingPaneActivated(self, wnd):
"""
Handles the activation event of a floating pane.
:param Window `wnd`: the window managed by the pane.
"""
pane = self.GetPane(wnd)
if not pane.IsOk():
raise Exception("Pane window not found")
if self.GetAGWFlags() & AUI_MGR_ALLOW_ACTIVE_PANE:
ret, self._panes = SetActivePane(self._panes, wnd)
self.RefreshCaptions()
self.FireEvent(wxEVT_AUI_PANE_ACTIVATED, wnd, canVeto=False)
def OnFloatingPaneMoved(self, wnd, eventOrPt):
"""
Handles the move event of a floating pane.
:param Window `wnd`: the window managed by the pane;
:param `eventOrPt`: a :class:`MoveEvent` to be processed or an instance of :class:`Point`.
"""
pane = self.GetPane(wnd)
if not pane.IsOk():
raise Exception("Pane window not found")
if not pane.IsSnappable():
return
if isinstance(eventOrPt, wx.Point):
pane_pos = wx.Point(*eventOrPt)
else:
pane_pos = eventOrPt.GetPosition()
pane_size = pane.floating_size
self.SnapPane(pane, pane_pos, pane_size, False)
def SnapPane(self, pane, pane_pos, pane_size, toSnap=False):
"""
Snaps a floating pane to one of the main frame sides.
:param `pane`: a :class:`AuiPaneInfo` instance;
:param Point `pane_pos`: the new pane floating position;
:param Size `pane_size`: the new pane floating size;
:param bool `toSnap`: a bool variable to check if :meth:`SnapPane` was called from
a move event.
"""
if self._from_move:
return
managed_window = self.GetManagedWindow()
wnd_pos = managed_window.GetPosition()
wnd_size = managed_window.GetSize()
snapX, snapY = self._snap_limits
if not toSnap:
pane.snapped = 0
if pane.IsLeftSnappable():
# Check if we can snap to the left
diff = wnd_pos.x - (pane_pos.x + pane_size.x)
if -snapX <= diff <= snapX:
pane.snapped = wx.LEFT
pane.floating_pos = wx.Point(wnd_pos.x-pane_size.x, pane_pos.y)
elif pane.IsTopSnappable():
# Check if we can snap to the top
diff = wnd_pos.y - (pane_pos.y + pane_size.y)
if -snapY <= diff <= snapY:
pane.snapped = wx.TOP
pane.floating_pos = wx.Point(pane_pos.x, wnd_pos.y-pane_size.y)
elif pane.IsRightSnappable():
# Check if we can snap to the right
diff = pane_pos.x - (wnd_pos.x + wnd_size.x)
if -snapX <= diff <= snapX:
pane.snapped = wx.RIGHT
pane.floating_pos = wx.Point(wnd_pos.x + wnd_size.x, pane_pos.y)
elif pane.IsBottomSnappable():
# Check if we can snap to the bottom
diff = pane_pos.y - (wnd_pos.y + wnd_size.y)
if -snapY <= diff <= snapY:
pane.snapped = wx.BOTTOM
pane.floating_pos = wx.Point(pane_pos.x, wnd_pos.y + wnd_size.y)
self.RepositionPane(pane, wnd_pos, wnd_size)
def RepositionPane(self, pane, wnd_pos, wnd_size):
"""
Repositions a pane after the main frame has been moved/resized.
:param `pane`: a :class:`AuiPaneInfo` instance;
:param Point `wnd_pos`: the main frame position;
:param Size `wnd_size`: the main frame size.
"""
pane_pos = pane.floating_pos
pane_size = pane.floating_size
snap = pane.snapped
if snap == wx.LEFT:
floating_pos = wx.Point(wnd_pos.x - pane_size.x, pane_pos.y)
elif snap == wx.TOP:
floating_pos = wx.Point(pane_pos.x, wnd_pos.y - pane_size.y)
elif snap == wx.RIGHT:
floating_pos = wx.Point(wnd_pos.x + wnd_size.x, pane_pos.y)
elif snap == wx.BOTTOM:
floating_pos = wx.Point(pane_pos.x, wnd_pos.y + wnd_size.y)
if snap:
if pane_pos != floating_pos:
pane.floating_pos = floating_pos
self._from_move = True
pane.frame.SetPosition(pane.floating_pos)
self._from_move = False
def OnGripperClicked(self, pane_window, start, offset):
"""
Handles the mouse click on the pane gripper.
:param Window `pane_window`: the window managed by the pane;
:param Point `start`: the mouse-click position;
:param Point `offset`: an offset point from the `start` position.
"""
# try to find the pane
paneInfo = self.GetPane(pane_window)
if not paneInfo.IsOk():
raise Exception("Pane window not found")
if self.GetAGWFlags() & AUI_MGR_ALLOW_ACTIVE_PANE:
# set the caption as active
ret, self._panes = SetActivePane(self._panes, pane_window)
self.RefreshCaptions()
self.FireEvent(wxEVT_AUI_PANE_ACTIVATED, pane_window, canVeto=False)
self._action_part = None
self._action_pane = paneInfo
self._action_window = pane_window
self._action_start = start
self._action_offset = offset
self._toolbar_action_offset = wx.Point(*self._action_offset)
self._frame.CaptureMouse()
if paneInfo.IsDocked():
self._action = actionClickCaption
else:
if paneInfo.IsToolbar():
self._action = actionDragToolbarPane
else:
self._action = actionDragFloatingPane
if paneInfo.frame:
windowPt = paneInfo.frame.GetRect().GetTopLeft()
originPt = paneInfo.frame.ClientToScreen(wx.Point())
self._action_offset += originPt - windowPt
self._toolbar_action_offset = wx.Point(*self._action_offset)
if self._agwFlags & AUI_MGR_TRANSPARENT_DRAG:
paneInfo.frame.SetTransparent(150)
if paneInfo.IsToolbar():
self._frame.SetCursor(wx.StockCursor(wx.CURSOR_SIZING))
def OnRender(self, event):
"""
Draws all of the pane captions, sashes, backgrounds, captions, grippers, pane borders and buttons.
It renders the entire user interface. It binds the ``EVT_AUI_RENDER`` event.
:param `event`: an instance of :class:`AuiManagerEvent`.
"""
# if the frame is about to be deleted, don't bother
if not self._frame or self._frame.IsBeingDeleted():
return
if not self._frame.GetSizer():
return
mouse = wx.GetMouseState()
mousePos = wx.Point(mouse.GetX(), mouse.GetY())
point = self._frame.ScreenToClient(mousePos)
art = self._art
dc = event.GetDC()
for part in self._uiparts:
# don't draw hidden pane items or items that aren't windows
if part.sizer_item and ((not part.sizer_item.IsWindow() and \
not part.sizer_item.IsSpacer() and \
not part.sizer_item.IsSizer()) or \
not part.sizer_item.IsShown()):
continue
ptype = part.type
if ptype in [AuiDockUIPart.typeDockSizer, AuiDockUIPart.typePaneSizer]:
art.DrawSash(dc, self._frame, part.orientation, part.rect)
elif ptype == AuiDockUIPart.typeBackground:
art.DrawBackground(dc, self._frame, part.orientation, part.rect)
elif ptype == AuiDockUIPart.typeCaption:
art.DrawCaption(dc, self._frame, part.pane.caption, part.rect, part.pane)
elif ptype == AuiDockUIPart.typeGripper:
art.DrawGripper(dc, self._frame, part.rect, part.pane)
elif ptype == AuiDockUIPart.typePaneBorder:
art.DrawBorder(dc, self._frame, part.rect, part.pane)
elif ptype == AuiDockUIPart.typePaneButton:
self.DrawPaneButton(dc, part, point)
def Repaint(self, dc=None):
"""
Repaints the entire frame decorations (sashes, borders, buttons and so on).
It renders the entire user interface.
:param `dc`: if not ``None``, an instance of :class:`PaintDC`.
"""
w, h = self._frame.GetClientSize()
# Figure out which dc to use; if one
# has been specified, use it, otherwise
# make a client dc
if dc is None:
client_dc = wx.ClientDC(self._frame)
dc = client_dc
# If the frame has a toolbar, the client area
# origin will not be (0, 0).
pt = self._frame.GetClientAreaOrigin()
if pt.x != 0 or pt.y != 0:
dc.SetDeviceOrigin(pt.x, pt.y)
# Render all the items
self.Render(dc)
def Render(self, dc):
"""
Fires a render event, which is normally handled by :meth:`OnRender`. This allows the
render function to be overridden via the render event.
This can be useful for painting custom graphics in the main window.
Default behavior can be invoked in the overridden function by calling
:meth:`OnRender`.
:param `dc`: a :class:`DC` device context object.
"""
e = AuiManagerEvent(wxEVT_AUI_RENDER)
e.SetManager(self)
e.SetDC(dc)
self.ProcessMgrEvent(e)
def OnCaptionDoubleClicked(self, pane_window):
"""
Handles the mouse double click on the pane caption.
:param Window `pane_window`: the window managed by the pane.
"""
# try to find the pane
paneInfo = self.GetPane(pane_window)
if not paneInfo.IsOk():
raise Exception("Pane window not found")
if not paneInfo.IsFloatable() or not paneInfo.IsDockable() or \
self._agwFlags & AUI_MGR_ALLOW_FLOATING == 0:
return
indx = self._panes.index(paneInfo)
win_rect = None
if paneInfo.IsFloating():
if paneInfo.name.startswith("__floating__"):
# It's a floating tab from a AuiNotebook
notebook = paneInfo.window.__aui_notebook__
notebook.ReDockPage(paneInfo)
self.Update()
return
else:
e = self.FireEvent(wxEVT_AUI_PANE_DOCKING, paneInfo, canVeto=True)
if e.GetVeto():
self.HideHint()
ShowDockingGuides(self._guides, False)
return
win_rect = paneInfo.frame.GetRect()
paneInfo.Dock()
if paneInfo.IsToolbar():
paneInfo = self.SwitchToolBarOrientation(paneInfo)
e = self.FireEvent(wxEVT_AUI_PANE_DOCKED, paneInfo, canVeto=False)
else:
e = self.FireEvent(wxEVT_AUI_PANE_FLOATING, paneInfo, canVeto=True)
if e.GetVeto():
return
# float the window
if paneInfo.IsMaximized():
self.RestorePane(paneInfo)
if paneInfo.floating_pos == wx.Point(-1, -1):
captionSize = self._art.GetMetric(AUI_DOCKART_CAPTION_SIZE)
paneInfo.floating_pos = pane_window.GetScreenPosition()
paneInfo.floating_pos.y -= captionSize
paneInfo.Float()
e = self.FireEvent(wxEVT_AUI_PANE_FLOATED, paneInfo, canVeto=False)
self._panes[indx] = paneInfo
self.Update()
if win_rect and self._agwFlags & AUI_MGR_ANIMATE_FRAMES:
paneInfo = self.GetPane(pane_window)
pane_rect = paneInfo.window.GetScreenRect()
self.AnimateDocking(win_rect, pane_rect)
def OnPaint(self, event):
"""
Handles the ``wx.EVT_PAINT`` event for :class:`AuiManager`.
:param `event`: an instance of :class:`PaintEvent` to be processed.
"""
dc = wx.PaintDC(self._frame)
self.Repaint(dc)
def OnEraseBackground(self, event):
"""
Handles the ``wx.EVT_ERASE_BACKGROUND`` event for :class:`AuiManager`.
:param `event`: :class:`EraseEvent` to be processed.
:note: This is intentionally empty (excluding wxMAC) to reduce
flickering while drawing.
"""
if wx.Platform == "__WXMAC__":
event.Skip()
def OnSize(self, event):
"""
Handles the ``wx.EVT_SIZE`` event for :class:`AuiManager`.
:param `event`: a :class:`SizeEvent` to be processed.
"""
skipped = False
if isinstance(self._frame, AuiFloatingFrame) and self._frame.IsShownOnScreen():
skipped = True
event.Skip()
if self._frame:
self.DoFrameLayout()
if wx.Platform == "__WXMAC__":
self._frame.Refresh()
else:
self.Repaint()
if isinstance(self._frame, wx.MDIParentFrame) or isinstance(self._frame, tabmdi.AuiMDIClientWindow) \
or isinstance(self._frame, tabmdi.AuiMDIParentFrame):
# for MDI parent frames, this event must not
# be "skipped". In other words, the parent frame
# must not be allowed to resize the client window
# after we are finished processing sizing changes
return
if not skipped:
event.Skip()
# For the snap to screen...
self.OnMove(None)
def OnFindManager(self, event):
"""
Handles the ``EVT_AUI_FIND_MANAGER`` event for :class:`AuiManager`.
:param `event`: a :class:`AuiManagerEvent` event to be processed.
"""
# Initialize to None
event.SetManager(None)
if not self._frame:
return
# See it this window wants to overwrite
self._frame.ProcessEvent(event)
# if no, it must be us
if not event.GetManager():
event.SetManager(self)
def OnSetCursor(self, event):
"""
Handles the ``wx.EVT_SET_CURSOR`` event for :class:`AuiManager`.
:param `event`: a :class:`SetCursorEvent` to be processed.
"""
# determine cursor
part = self.HitTest(event.GetX(), event.GetY())
cursor = wx.NullCursor
if part:
if part.type in [AuiDockUIPart.typeDockSizer, AuiDockUIPart.typePaneSizer]:
if not self.CheckMovableSizer(part):
return
if part.orientation == wx.VERTICAL:
cursor = wx.StockCursor(wx.CURSOR_SIZEWE)
else:
cursor = wx.StockCursor(wx.CURSOR_SIZENS)
elif part.type == AuiDockUIPart.typeGripper:
cursor = wx.StockCursor(wx.CURSOR_SIZING)
event.SetCursor(cursor)
def UpdateButtonOnScreen(self, button_ui_part, event):
"""
Updates/redraws the UI part containing a pane button.
:param AuiDockUIPart `button_ui_part`: the UI part the button belongs to;
:param `event`: a :class:`MouseEvent` to be processed.
"""
hit_test = self.HitTest(*event.GetPosition())
if not hit_test or not button_ui_part:
return
state = AUI_BUTTON_STATE_NORMAL
if hit_test == button_ui_part:
if event.LeftDown():
state = AUI_BUTTON_STATE_PRESSED
else:
state = AUI_BUTTON_STATE_HOVER
else:
if event.LeftDown():
state = AUI_BUTTON_STATE_HOVER
# now repaint the button with hover state
cdc = wx.ClientDC(self._frame)
# if the frame has a toolbar, the client area
# origin will not be (0,0).
pt = self._frame.GetClientAreaOrigin()
if pt.x != 0 or pt.y != 0:
cdc.SetDeviceOrigin(pt.x, pt.y)
if hit_test.pane:
self._art.DrawPaneButton(cdc, self._frame,
button_ui_part.button.button_id,
state,
button_ui_part.rect, hit_test.pane)
def OnLeftDown(self, event):
"""
Handles the ``wx.EVT_LEFT_DOWN`` event for :class:`AuiManager`.
:param `event`: a :class:`MouseEvent` to be processed.
"""
part = self.HitTest(*event.GetPosition())
if not part:
event.Skip()
return
self._currentDragItem = -1
if part.type in [AuiDockUIPart.typeDockSizer, AuiDockUIPart.typePaneSizer]:
if not self.CheckMovableSizer(part):
return
self._action = actionResize
self._action_part = part
self._action_pane = None
self._action_rect = wx.Rect()
self._action_start = wx.Point(event.GetX(), event.GetY())
self._action_offset = wx.Point(event.GetX() - part.rect.x,
event.GetY() - part.rect.y)
# draw the resize hint
rect = wx.RectPS(self._frame.ClientToScreen(part.rect.GetPosition()),
part.rect.GetSize())
self._action_rect = wx.Rect(*rect)
if not AuiManager_HasLiveResize(self):
if wx.Platform == "__WXMAC__":
dc = wx.ClientDC(self._frame)
else:
dc = wx.ScreenDC()
DrawResizeHint(dc, rect)
self._frame.CaptureMouse()
elif part.type == AuiDockUIPart.typePaneButton:
if self.IsPaneButtonVisible(part):
self._action = actionClickButton
self._action_part = part
self._action_pane = None
self._action_start = wx.Point(*event.GetPosition())
self._frame.CaptureMouse()
self.RefreshButton(part)
elif part.type in [AuiDockUIPart.typeCaption, AuiDockUIPart.typeGripper]:
# if we are managing a AuiFloatingFrame window, then
# we are an embedded AuiManager inside the AuiFloatingFrame.
# We want to initiate a toolbar drag in our owner manager
if isinstance(part.pane.window.GetParent(), AuiFloatingFrame):
rootManager = GetManager(part.pane.window)
else:
rootManager = self
offset = wx.Point(event.GetX() - part.rect.x, event.GetY() - part.rect.y)
rootManager.OnGripperClicked(part.pane.window, event.GetPosition(), offset)
if wx.Platform != "__WXMAC__":
event.Skip()
def OnLeftDClick(self, event):
"""
Handles the ``wx.EVT_LEFT_DCLICK`` event for :class:`AuiManager`.
:param `event`: a :class:`MouseEvent` to be processed.
"""
part = self.HitTest(event.GetX(), event.GetY())
if part and part.type == AuiDockUIPart.typeCaption:
if isinstance(part.pane.window.GetParent(), AuiFloatingFrame):
rootManager = GetManager(part.pane.window)
else:
rootManager = self
rootManager.OnCaptionDoubleClicked(part.pane.window)
elif part and part.type in [AuiDockUIPart.typeDockSizer, AuiDockUIPart.typePaneSizer]:
# Handles double click on AuiNotebook sashes to unsplit
sash_size = self._art.GetMetric(AUI_DOCKART_SASH_SIZE)
for child in part.cont_sizer.GetChildren():
if child.IsSizer():
win = child.GetSizer().GetContainingWindow()
if isinstance(win, auibook.AuiNotebook):
win.UnsplitDClick(part, sash_size, event.GetPosition())
break
event.Skip()
def DoEndResizeAction(self, event):
"""
Ends a resize action, or for live update, resizes the sash.
:param `event`: a :class:`MouseEvent` to be processed.
"""
clientPt = event.GetPosition()
screenPt = self._frame.ClientToScreen(clientPt)
return self.RestrictResize(clientPt, screenPt, createDC=False)
def RestrictResize(self, clientPt, screenPt, createDC):
""" Common method between :meth:`DoEndResizeAction` and :meth:`OnLeftUp_Resize`. """
dock = self._action_part.dock
pane = self._action_part.pane
if createDC:
if wx.Platform == "__WXMAC__":
dc = wx.ClientDC(self._frame)
else:
dc = wx.ScreenDC()
DrawResizeHint(dc, self._action_rect)
self._action_rect = wx.Rect()
newPos = clientPt - self._action_offset
if self._action_part.type == AuiDockUIPart.typeDockSizer:
minPix, maxPix = self.CalculateDockSizerLimits(dock)
else:
if not self._action_part.pane:
return
minPix, maxPix = self.CalculatePaneSizerLimits(dock, pane)
if self._action_part.orientation == wx.HORIZONTAL:
newPos.y = Clip(newPos.y, minPix, maxPix)
else:
newPos.x = Clip(newPos.x, minPix, maxPix)
if self._action_part.type == AuiDockUIPart.typeDockSizer:
partnerDock = self.GetPartnerDock(dock)
sash_size = self._art.GetMetric(AUI_DOCKART_SASH_SIZE)
new_dock_size = 0
direction = dock.dock_direction
if direction == AUI_DOCK_LEFT:
new_dock_size = newPos.x - dock.rect.x
elif direction == AUI_DOCK_TOP:
new_dock_size = newPos.y - dock.rect.y
elif direction == AUI_DOCK_RIGHT:
new_dock_size = dock.rect.x + dock.rect.width - newPos.x - sash_size
elif direction == AUI_DOCK_BOTTOM:
new_dock_size = dock.rect.y + dock.rect.height - newPos.y - sash_size
deltaDockSize = new_dock_size - dock.size
if partnerDock:
if deltaDockSize > partnerDock.size - sash_size:
deltaDockSize = partnerDock.size - sash_size
partnerDock.size -= deltaDockSize
dock.size += deltaDockSize
self.Update()
else:
# determine the new pixel size that the user wants
# this will help us recalculate the pane's proportion
if dock.IsHorizontal():
oldPixsize = pane.rect.width
newPixsize = oldPixsize + newPos.x - self._action_part.rect.x
else:
oldPixsize = pane.rect.height
newPixsize = oldPixsize + newPos.y - self._action_part.rect.y
totalPixsize, totalProportion = self.GetTotalPixSizeAndProportion(dock)
partnerPane = self.GetPartnerPane(dock, pane)
# prevent division by zero
if totalPixsize <= 0 or totalProportion <= 0 or not partnerPane:
return
# adjust for the surplus
while (oldPixsize > 0 and totalPixsize > 10 and \
oldPixsize*totalProportion/totalPixsize < pane.dock_proportion):
totalPixsize -= 1
# calculate the new proportion of the pane
newProportion = newPixsize*totalProportion/totalPixsize
newProportion = Clip(newProportion, 1, totalProportion)
deltaProp = newProportion - pane.dock_proportion
if partnerPane.dock_proportion - deltaProp < 1:
deltaProp = partnerPane.dock_proportion - 1
newProportion = pane.dock_proportion + deltaProp
# borrow the space from our neighbor pane to the
# right or bottom (depending on orientation)
partnerPane.dock_proportion -= deltaProp
pane.dock_proportion = newProportion
self.Update()
return True
def OnLeftUp(self, event):
"""
Handles the ``wx.EVT_LEFT_UP`` event for :class:`AuiManager`.
:param `event`: a :class:`MouseEvent` to be processed.
"""
if self._action == actionResize:
## self._frame.Freeze()
self.OnLeftUp_Resize(event)
## self._frame.Thaw()
elif self._action == actionClickButton:
self.OnLeftUp_ClickButton(event)
elif self._action == actionDragFloatingPane:
self.OnLeftUp_DragFloatingPane(event)
elif self._action == actionDragToolbarPane:
self.OnLeftUp_DragToolbarPane(event)
elif self._action == actionDragMovablePane:
self.OnLeftUp_DragMovablePane(event)
else:
event.Skip()
try:
if self._frame.HasCapture():
self._frame.ReleaseMouse()
except wx.PyDeadObjectError:
pass
self._action = actionNone
def OnMotion(self, event):
"""
Handles the ``wx.EVT_MOTION`` event for :class:`AuiManager`.
:param `event`: a :class:`MouseEvent` to be processed.
"""
if self._action == actionResize:
self.OnMotion_Resize(event)
elif self._action == actionClickCaption:
self.OnMotion_ClickCaption(event)
elif self._action == actionDragFloatingPane:
self.OnMotion_DragFloatingPane(event)
elif self._action == actionDragToolbarPane:
self.OnMotion_DragToolbarPane(event)
elif self._action == actionDragMovablePane:
self.OnMotion_DragMovablePane(event)
else:
self.OnMotion_Other(event)
def OnLeaveWindow(self, event):
"""
Handles the ``wx.EVT_LEAVE_WINDOW`` event for :class:`AuiManager`.
:param `event`: a :class:`MouseEvent` to be processed.
"""
if self._hover_button:
self.RefreshButton(self._hover_button)
self._hover_button = None
def OnCaptureLost(self, event):
"""
Handles the ``wx.EVT_MOUSE_CAPTURE_LOST`` event for :class:`AuiManager`.
:param `event`: a :class:`MouseCaptureLostEvent` to be processed.
"""
# cancel the operation in progress, if any
if self._action != actionNone:
self._action = actionNone
self.HideHint()
def OnHintFadeTimer(self, event):
"""
Handles the ``wx.EVT_TIMER`` event for :class:`AuiManager`.
:param `event`: a :class:`TimerEvent` to be processed.
"""
if not self._hint_window or self._hint_fadeamt >= self._hint_fademax:
self._hint_fadetimer.Stop()
return
self._hint_fadeamt += 4
self._hint_window.SetTransparent(self._hint_fadeamt)
def OnMove(self, event):
"""
Handles the ``wx.EVT_MOVE`` event for :class:`AuiManager`.
:param `event`: a :class:`MoveEvent` to be processed.
"""
if event is not None:
event.Skip()
if isinstance(self._frame, AuiFloatingFrame) and self._frame.IsShownOnScreen():
return
docked, hAlign, vAlign, monitor = self._is_docked
if docked:
self.Snap()
for pane in self._panes:
if pane.IsSnappable():
if pane.IsFloating() and pane.IsShown():
self.SnapPane(pane, pane.floating_pos, pane.floating_size, True)
def OnSysColourChanged(self, event):
"""
Handles the ``wx.EVT_SYS_COLOUR_CHANGED`` event for :class:`AuiManager`.
:param `event`: a :class:`SysColourChangedEvent` to be processed.
"""
# This event is probably triggered by a theme change
# so we have to re-init the art provider.
if self._art:
self._art.Init()
if self._frame:
self.Update()
self._frame.Refresh()
def OnChildFocus(self, event):
"""
Handles the ``wx.EVT_CHILD_FOCUS`` event for :class:`AuiManager`.
:param `event`: a :class:`ChildFocusEvent` to be processed.
"""
# when a child pane has it's focus set, we should change the
# pane's active state to reflect this. (this is only true if
# active panes are allowed by the owner)
window = event.GetWindow()
if isinstance(window, wx.Dialog):
# Ignore EVT_CHILD_FOCUS events originating from dialogs not
# managed by AUI
rootManager = None
elif isinstance(window.GetParent(), AuiFloatingFrame):
rootManager = GetManager(window)
else:
rootManager = self
if rootManager:
rootManager.ActivatePane(window)
event.Skip()
def OnMotion_ClickCaption(self, event):
"""
Sub-handler for the :meth:`OnMotion` event.
:param `event`: a :class:`MouseEvent` to be processed.
"""
clientPt = event.GetPosition()
screenPt = self._frame.ClientToScreen(clientPt)
drag_x_threshold = wx.SystemSettings.GetMetric(wx.SYS_DRAG_X)
drag_y_threshold = wx.SystemSettings.GetMetric(wx.SYS_DRAG_Y)
if not self._action_pane:
return
# we need to check if the mouse is now being dragged
if not (abs(clientPt.x - self._action_start.x) > drag_x_threshold or \
abs(clientPt.y - self._action_start.y) > drag_y_threshold):
return
# dragged -- we need to change the mouse action to 'drag'
if self._action_pane.IsToolbar():
self._action = actionDragToolbarPane
self._action_window = self._action_pane.window
elif self._action_pane.IsFloatable() and self._agwFlags & AUI_MGR_ALLOW_FLOATING:
e = self.FireEvent(wxEVT_AUI_PANE_FLOATING, self._action_pane, canVeto=True)
if e.GetVeto():
return
self._action = actionDragFloatingPane
# set initial float position
self._action_pane.floating_pos = screenPt - self._action_offset
# float the window
if self._action_pane.IsMaximized():
self.RestorePane(self._action_pane)
self._action_pane.Hide()
self._action_pane.Float()
if wx.Platform == "__WXGTK__":
self._action_pane.Show()
e = self.FireEvent(wxEVT_AUI_PANE_FLOATED, self._action_pane, canVeto=False)
if not self._action_pane.frame:
self.Update()
self._action_window = self._action_pane.window
# adjust action offset for window frame
windowPt = self._action_pane.frame.GetRect().GetTopLeft()
originPt = self._action_pane.frame.ClientToScreen(wx.Point())
self._toolbar_action_offset = originPt - windowPt
if self._agwFlags & AUI_MGR_USE_NATIVE_MINIFRAMES:
originPt = windowPt + wx.Point(3, 3)
self._action_offset += originPt - windowPt
# action offset is used here to make it feel "natural" to the user
# to drag a docked pane and suddenly have it become a floating frame.
# Sometimes, however, the offset where the user clicked on the docked
# caption is bigger than the width of the floating frame itself, so
# in that case we need to set the action offset to a sensible value
frame_size = self._action_pane.frame.GetSize()
if self._action_offset.x > frame_size.x * 2 / 3:
self._action_offset.x = frame_size.x / 2
if self._action_offset.y > frame_size.y * 2 / 3:
self._action_offset.y = frame_size.y / 2
self.OnMotion_DragFloatingPane(event)
if wx.Platform != "__WXGTK__":
self._action_pane.Show()
self.Update()
elif self._action_pane.IsMovable():
self._action = actionDragMovablePane
self._action_window = self._action_pane.window
def OnMotion_Resize(self, event):
"""
Sub-handler for the :meth:`OnMotion` event.
:param `event`: a :class:`MouseEvent` to be processed.
"""
if AuiManager_HasLiveResize(self):
if self._currentDragItem != -1:
self._action_part = self._uiparts[self._currentDragItem]
else:
self._currentDragItem = self._uiparts.index(self._action_part)
if self._frame.HasCapture():
self._frame.ReleaseMouse()
self.DoEndResizeAction(event)
self._frame.CaptureMouse()
return
if not self._action_part or not self._action_part.dock or not self._action_part.orientation:
return
clientPt = event.GetPosition()
screenPt = self._frame.ClientToScreen(clientPt)
dock = self._action_part.dock
pos = self._action_part.rect.GetPosition()
if self._action_part.type == AuiDockUIPart.typeDockSizer:
minPix, maxPix = self.CalculateDockSizerLimits(dock)
else:
if not self._action_part.pane:
return
pane = self._action_part.pane
minPix, maxPix = self.CalculatePaneSizerLimits(dock, pane)
if self._action_part.orientation == wx.HORIZONTAL:
pos.y = Clip(clientPt.y - self._action_offset.y, minPix, maxPix)
else:
pos.x = Clip(clientPt.x - self._action_offset.x, minPix, maxPix)
hintrect = wx.RectPS(self._frame.ClientToScreen(pos), self._action_part.rect.GetSize())
if hintrect != self._action_rect:
if wx.Platform == "__WXMAC__":
dc = wx.ClientDC(self._frame)
else:
dc = wx.ScreenDC()
DrawResizeHint(dc, self._action_rect)
DrawResizeHint(dc, hintrect)
self._action_rect = wx.Rect(*hintrect)
def OnLeftUp_Resize(self, event):
"""
Sub-handler for the :meth:`OnLeftUp` event.
:param `event`: a :class:`MouseEvent` to be processed.
"""
if self._currentDragItem != -1 and AuiManager_HasLiveResize(self):
self._action_part = self._uiparts[self._currentDragItem]
if self._frame.HasCapture():
self._frame.ReleaseMouse()
self.DoEndResizeAction(event)
self._currentDragItem = -1
return
if not self._action_part or not self._action_part.dock:
return
clientPt = event.GetPosition()
screenPt = self._frame.ClientToScreen(clientPt)
return self.RestrictResize(clientPt, screenPt, createDC=True)
def OnLeftUp_ClickButton(self, event):
"""
Sub-handler for the :meth:`OnLeftUp` event.
:param `event`: a :class:`MouseEvent` to be processed.
"""
self._hover_button = None
if self._action_part:
self.RefreshButton(self._action_part)
# make sure we're still over the item that was originally clicked
if self._action_part == self.HitTest(*event.GetPosition()):
# fire button-click event
e = AuiManagerEvent(wxEVT_AUI_PANE_BUTTON)
e.SetManager(self)
e.SetPane(self._action_part.pane)
e.SetButton(self._action_part.button.button_id)
self.ProcessMgrEvent(e)
def CheckPaneMove(self, pane):
"""
Checks if a pane has moved by a visible amount.
:param `pane`: an instance of :class:`AuiPaneInfo`.
"""
win_rect = pane.frame.GetRect()
win_rect.x, win_rect.y = pane.floating_pos
if win_rect == self._last_rect:
return False
# skip the first move event
if self._last_rect.IsEmpty():
self._last_rect = wx.Rect(*win_rect)
return False
# skip if moving too fast to avoid massive redraws and
# jumping hint windows
if abs(win_rect.x - self._last_rect.x) > 10 or \
abs(win_rect.y - self._last_rect.y) > 10:
self._last_rect = wx.Rect(*win_rect)
return False
return True
def OnMotion_DragFloatingPane(self, eventOrPt):
"""
Sub-handler for the :meth:`OnMotion` event.
:param `event`: a :class:`MouseEvent` to be processed.
"""
isPoint = False
if isinstance(eventOrPt, wx.Point):
clientPt = self._frame.ScreenToClient(eventOrPt)
screenPt = wx.Point(*eventOrPt)
isPoint = True
else:
clientPt = eventOrPt.GetPosition()
screenPt = self._frame.ClientToScreen(clientPt)
framePos = wx.Point()
# try to find the pane
pane = self.GetPane(self._action_window)
if not pane.IsOk():
raise Exception("Pane window not found")
# update floating position
if pane.IsFloating():
diff = pane.floating_pos - (screenPt - self._action_offset)
pane.floating_pos = screenPt - self._action_offset
framePos = pane.floating_pos
# Move the pane window
if pane.frame:
if diff.x != 0 or diff.y != 0:
if wx.Platform == "__WXMSW__" and (self._agwFlags & AUI_MGR_TRANSPARENT_DRAG) == 0: # and not self.CheckPaneMove(pane):
# return
# HACK: Terrible hack on wxMSW (!)
pane.frame.SetTransparent(254)
self._from_move = True
pane.frame.Move(pane.floating_pos)
self._from_move = False
if self._agwFlags & AUI_MGR_TRANSPARENT_DRAG:
pane.frame.SetTransparent(150)
# calculate the offset from the upper left-hand corner
# of the frame to the mouse pointer
action_offset = screenPt - framePos
# is the pane dockable?
if not self.CanDockPanel(pane):
self.HideHint()
ShowDockingGuides(self._guides, False)
return
for paneInfo in self._panes:
if not paneInfo.IsDocked() or not paneInfo.IsShown():
continue
if paneInfo.IsToolbar() or paneInfo.IsNotebookControl():
continue
if paneInfo.IsMaximized():
continue
if paneInfo.IsNotebookPage():
notebookRoot = GetNotebookRoot(self._panes, paneInfo.notebook_id)
if not notebookRoot or not notebookRoot.IsDocked():
continue
rc = paneInfo.window.GetScreenRect()
if rc.Contains(screenPt):
if rc.height < 20 or rc.width < 20:
return
self.UpdateDockingGuides(paneInfo)
ShowDockingGuides(self._guides, True)
break
self.DrawHintRect(pane.window, clientPt, action_offset)
def OnMotion_DragMovablePane(self, eventOrPt):
"""
Sub-handler for the :meth:`OnMotion` event.
:param `event`: a :class:`MouseEvent` to be processed.
"""
# Try to find the pane.
pane = self.GetPane(self._action_window)
if not pane.IsOk():
raise Exception("Pane window not found")
# Draw a hint for where the window will be moved.
if isinstance(eventOrPt, wx.Point):
pt = wx.Point(*eventOrPt)
else:
pt = eventOrPt.GetPosition()
self.DrawHintRect(self._action_window, pt, wx.Point(0, 0))
# Reduces flicker.
self._frame.Update()
def OnLeftUp_DragFloatingPane(self, eventOrPt):
"""
Sub-handler for the :meth:`OnLeftUp` event.
:param `event`: a :class:`MouseEvent` to be processed.
"""
if isinstance(eventOrPt, wx.Point):
clientPt = self._frame.ScreenToClient(eventOrPt)
screenPt = wx.Point(*eventOrPt)
else:
clientPt = eventOrPt.GetPosition()
screenPt = self._frame.ClientToScreen(clientPt)
# try to find the pane
paneInfo = self.GetPane(self._action_window)
if not paneInfo.IsOk():
raise Exception("Pane window not found")
ret = False
if paneInfo.frame:
# calculate the offset from the upper left-hand corner
# of the frame to the mouse pointer
framePos = paneInfo.frame.GetPosition()
action_offset = screenPt - framePos
# is the pane dockable?
if self.CanDockPanel(paneInfo):
# do the drop calculation
indx = self._panes.index(paneInfo)
ret, paneInfo = self.DoDrop(self._docks, self._panes, paneInfo, clientPt, action_offset)
if ret:
e = self.FireEvent(wxEVT_AUI_PANE_DOCKING, paneInfo, canVeto=True)
if e.GetVeto():
self.HideHint()
ShowDockingGuides(self._guides, False)
return
e = self.FireEvent(wxEVT_AUI_PANE_DOCKED, paneInfo, canVeto=False)
if self._agwFlags & AUI_MGR_SMOOTH_DOCKING:
self.SmoothDock(paneInfo)
self._panes[indx] = paneInfo
# if the pane is still floating, update it's floating
# position (that we store)
if paneInfo.IsFloating():
paneInfo.floating_pos = paneInfo.frame.GetPosition()
if paneInfo.frame._transparent != paneInfo.transparent or self._agwFlags & AUI_MGR_TRANSPARENT_DRAG:
paneInfo.frame.SetTransparent(paneInfo.transparent)
paneInfo.frame._transparent = paneInfo.transparent
elif self._has_maximized:
self.RestoreMaximizedPane()
# reorder for dropping to a new notebook
# (caution: this code breaks the reference!)
tempPaneInfo = self.CopyTarget(paneInfo)
self._panes.remove(paneInfo)
self._panes.append(tempPaneInfo)
if ret:
self.Update()
if tempPaneInfo.IsFloating():
self.SnapPane(tempPaneInfo, tempPaneInfo.floating_pos, tempPaneInfo.floating_size, False)
self.HideHint()
ShowDockingGuides(self._guides, False)
def OnLeftUp_DragMovablePane(self, event):
"""
Sub-handler for the :meth:`OnLeftUp` event.
:param `event`: a :class:`MouseEvent` to be processed.
"""
# Try to find the pane.
paneInfo = self.GetPane(self._action_window)
if not paneInfo.IsOk():
raise Exception("Pane window not found")
# Hide the hint as it is no longer needed.
self.HideHint()
# is the pane dockable?
if self.CanDockPanel(paneInfo):
# Move the pane to new position.
pt = event.GetPosition()
# do the drop calculation
indx = self._panes.index(paneInfo)
ret, paneInfo = self.DoDrop(self._docks, self._panes, paneInfo, pt, wx.Point(0,0))
if ret:
e = self.FireEvent(wxEVT_AUI_PANE_DOCKING, paneInfo, canVeto=True)
if e.GetVeto():
self.HideHint()
ShowDockingGuides(self._guides, False)
return
e = self.FireEvent(wxEVT_AUI_PANE_DOCKED, paneInfo, canVeto=False)
if self._agwFlags & AUI_MGR_SMOOTH_DOCKING:
self.SmoothDock(paneInfo)
self._panes[indx] = paneInfo
if ret:
# Update the layout to realize new position and e.g. form notebooks if needed.
self.Update()
if self.GetAGWFlags() & AUI_MGR_ALLOW_ACTIVE_PANE:
# Ensure active before doing actual display.
ret, self._panes = SetActivePane(self._panes, paneInfo.window)
# Make changes visible to user.
self.Repaint()
# Cancel the action and release the mouse.
self._action = actionNone
self._frame.ReleaseMouse()
self._action_window = None
def OnMotion_DragToolbarPane(self, eventOrPt):
"""
Sub-handler for the :meth:`OnMotion` event.
:param `event`: a :class:`MouseEvent` to be processed.
"""
isPoint = False
if isinstance(eventOrPt, wx.Point):
clientPt = self._frame.ScreenToClient(eventOrPt)
screenPt = wx.Point(*eventOrPt)
isPoint = True
else:
clientPt = eventOrPt.GetPosition()
screenPt = self._frame.ClientToScreen(clientPt)
pane = self.GetPane(self._action_window)
if not pane.IsOk():
raise Exception("Pane window not found")
pane.state |= AuiPaneInfo.actionPane
indx = self._panes.index(pane)
ret = False
wasFloating = pane.IsFloating()
# is the pane dockable?
if self.CanDockPanel(pane):
# do the drop calculation
ret, pane = self.DoDrop(self._docks, self._panes, pane, clientPt, self._action_offset)
# update floating position
if pane.IsFloating():
pane.floating_pos = screenPt - self._toolbar_action_offset
# move the pane window
if pane.frame:
if wx.Platform == "__WXMSW__" and (self._agwFlags & AUI_MGR_TRANSPARENT_DRAG) == 0: # and not self.CheckPaneMove(pane):
# return
# HACK: Terrible hack on wxMSW (!)
pane.frame.SetTransparent(254)
self._from_move = True
pane.frame.Move(pane.floating_pos)
self._from_move = False
if self._agwFlags & AUI_MGR_TRANSPARENT_DRAG:
pane.frame.SetTransparent(150)
self._panes[indx] = pane
if ret and wasFloating != pane.IsFloating() or (ret and not wasFloating):
wx.CallAfter(self.Update)
# when release the button out of the window.
# TODO: a better fix is needed.
if _VERSION_STRING < "2.9":
leftDown = wx.GetMouseState().LeftDown()
else:
leftDown = wx.GetMouseState().LeftIsDown()
if not leftDown:
self._action = actionNone
self.OnLeftUp_DragToolbarPane(eventOrPt)
def OnMotion_Other(self, event):
"""
Sub-handler for the :meth:`OnMotion` event.
:param `event`: a :class:`MouseEvent` to be processed.
"""
part = self.HitTest(*event.GetPosition())
if part and part.type == AuiDockUIPart.typePaneButton \
and self.IsPaneButtonVisible(part):
if part != self._hover_button:
if self._hover_button:
self.RefreshButton(self._hover_button)
self._hover_button = part
self.RefreshButton(part)
else:
if self._hover_button:
self.RefreshButton(self._hover_button)
else:
event.Skip()
self._hover_button = None
def OnLeftUp_DragToolbarPane(self, eventOrPt):
"""
Sub-handler for the :meth:`OnLeftUp` event.
:param `event`: a :class:`MouseEvent` to be processed.
"""
isPoint = False
if isinstance(eventOrPt, wx.Point):
clientPt = self._frame.ScreenToClient(eventOrPt)
screenPt = wx.Point(*eventOrPt)
isPoint = True
else:
clientPt = eventOrPt.GetPosition()
screenPt = self._frame.ClientToScreen(clientPt)
# try to find the pane
pane = self.GetPane(self._action_window)
if not pane.IsOk():
raise Exception("Pane window not found")
if pane.IsFloating():
pane.floating_pos = pane.frame.GetPosition()
if pane.frame._transparent != pane.transparent or self._agwFlags & AUI_MGR_TRANSPARENT_DRAG:
pane.frame.SetTransparent(pane.transparent)
pane.frame._transparent = pane.transparent
# save the new positions
docks = FindDocks(self._docks, pane.dock_direction, pane.dock_layer, pane.dock_row)
if len(docks) == 1:
dock = docks[0]
pane_positions, pane_sizes = self.GetPanePositionsAndSizes(dock)
for i in xrange(len(dock.panes)):
dock.panes[i].dock_pos = pane_positions[i]
pane.state &= ~AuiPaneInfo.actionPane
self.Update()
def OnPaneButton(self, event):
"""
Handles the ``EVT_AUI_PANE_BUTTON`` event for :class:`AuiManager`.
:param `event`: a :class:`AuiManagerEvent` event to be processed.
"""
if not event.pane:
raise Exception("Pane Info passed to AuiManager.OnPaneButton must be non-null")
pane = event.pane
if event.button == AUI_BUTTON_CLOSE:
if isinstance(pane.window.GetParent(), AuiFloatingFrame):
rootManager = GetManager(pane.window)
else:
rootManager = self
if rootManager != self:
self._frame.Close()
return
# fire pane close event
e = AuiManagerEvent(wxEVT_AUI_PANE_CLOSE)
e.SetManager(self)
e.SetPane(event.pane)
self.ProcessMgrEvent(e)
if not e.GetVeto():
# close the pane, but check that it
# still exists in our pane array first
# (the event handler above might have removed it)
check = self.GetPane(pane.window)
if check.IsOk():
self.ClosePane(pane)
self.Update()
# mn this performs the minimizing of a pane
elif event.button == AUI_BUTTON_MINIMIZE:
e = AuiManagerEvent(wxEVT_AUI_PANE_MINIMIZE)
e.SetManager(self)
e.SetPane(event.pane)
self.ProcessMgrEvent(e)
if not e.GetVeto():
self.MinimizePane(pane)
elif event.button == AUI_BUTTON_MAXIMIZE_RESTORE and not pane.IsMaximized():
# fire pane close event
e = AuiManagerEvent(wxEVT_AUI_PANE_MAXIMIZE)
e.SetManager(self)
e.SetPane(event.pane)
self.ProcessMgrEvent(e)
if not e.GetVeto():
self.MaximizePane(pane)
self.Update()
elif event.button == AUI_BUTTON_MAXIMIZE_RESTORE and pane.IsMaximized():
# fire pane close event
e = AuiManagerEvent(wxEVT_AUI_PANE_RESTORE)
e.SetManager(self)
e.SetPane(event.pane)
self.ProcessMgrEvent(e)
if not e.GetVeto():
self.RestorePane(pane)
self.Update()
elif event.button == AUI_BUTTON_PIN:
if self._agwFlags & AUI_MGR_ALLOW_FLOATING and pane.IsFloatable():
e = self.FireEvent(wxEVT_AUI_PANE_FLOATING, pane, canVeto=True)
if e.GetVeto():
return
pane.Float()
e = self.FireEvent(wxEVT_AUI_PANE_FLOATED, pane, canVeto=False)
self.Update()
def MinimizePane(self, paneInfo, mgrUpdate=True):
"""
Minimizes a pane in a newly and automatically created :class:`~lib.agw.aui.auibar.AuiToolBar`.
Clicking on the minimize button causes a new :class:`~lib.agw.aui.auibar.AuiToolBar` to be created
and added to the frame manager (currently the implementation is such that
panes at West will have a toolbar at the right, panes at South will have
toolbars at the bottom etc...) and the pane is hidden in the manager.
Clicking on the restore button on the newly created toolbar will result in the
toolbar being removed and the original pane being restored.
:param `paneInfo`: a :class:`AuiPaneInfo` instance for the pane to be minimized;
:param bool `mgrUpdate`: ``True`` to call :meth:`Update` to realize the new layout,
``False`` otherwise.
.. note::
The `mgrUpdate` parameter is currently only used while loading perspectives using
:meth:`LoadPerspective`, as minimized panes were not correctly taken into account before.
"""
if not paneInfo.IsToolbar():
if paneInfo.IsMinimized() and mgrUpdate:
# We are already minimized
return
# Basically the idea is this.
#
# 1) create a toolbar, with a restore button
#
# 2) place the new toolbar in the toolbar area representative of the location of the pane
# (NORTH/SOUTH/EAST/WEST, central area always to the right)
#
# 3) Hide the minimizing pane
# personalize the toolbar style
tbStyle = AUI_TB_DEFAULT_STYLE
posMask = paneInfo.minimize_mode & AUI_MINIMIZE_POS_MASK
captMask = paneInfo.minimize_mode & AUI_MINIMIZE_CAPT_MASK
dockDirection = paneInfo.dock_direction
if captMask != 0:
tbStyle |= AUI_TB_TEXT
if posMask == AUI_MINIMIZE_POS_TOOLBAR:
minimize_toolbar = self.GetPane(paneInfo.minimize_target)
if not minimize_toolbar.IsOk():
posMask = AUI_MINIMIZE_POS_SMART
if paneInfo.dock_direction in [AUI_DOCK_TOP, AUI_DOCK_BOTTOM]:
tbStyle |= AUI_TB_HORZ_LAYOUT
elif paneInfo.dock_direction in [AUI_DOCK_LEFT, AUI_DOCK_RIGHT, AUI_DOCK_CENTER]:
tbStyle |= AUI_TB_VERTICAL
if captMask == AUI_MINIMIZE_CAPT_SMART:
tbStyle |= AUI_TB_CLOCKWISE
else:
minimize_toolbar = minimize_toolbar.window
elif posMask == AUI_MINIMIZE_POS_SMART:
if paneInfo.dock_direction in [AUI_DOCK_TOP, AUI_DOCK_BOTTOM]:
tbStyle |= AUI_TB_HORZ_LAYOUT
elif paneInfo.dock_direction in [AUI_DOCK_LEFT, AUI_DOCK_RIGHT, AUI_DOCK_CENTER]:
tbStyle |= AUI_TB_VERTICAL
if captMask == AUI_MINIMIZE_CAPT_SMART:
tbStyle |= AUI_TB_CLOCKWISE
elif posMask in [AUI_MINIMIZE_POS_TOP, AUI_MINIMIZE_POS_BOTTOM]:
tbStyle |= AUI_TB_HORZ_LAYOUT
if posMask == AUI_MINIMIZE_POS_TOP:
dockDirection = AUI_DOCK_TOP
else:
dockDirection = AUI_DOCK_BOTTOM
else:
tbStyle |= AUI_TB_VERTICAL
if captMask == AUI_MINIMIZE_CAPT_SMART:
tbStyle |= AUI_TB_CLOCKWISE
if posMask == AUI_MINIMIZE_POS_LEFT:
dockDirection = AUI_DOCK_LEFT
elif posMask == AUI_MINIMIZE_POS_RIGHT:
dockDirection = AUI_DOCK_RIGHT
elif posMask == AUI_MINIMIZE_POS_BOTTOM:
dockDirection = AUI_DOCK_BOTTOM
# Create a new toolbar
# give it the same name as the minimized pane with _min appended
win_rect = paneInfo.window.GetScreenRect()
if posMask != AUI_MINIMIZE_POS_TOOLBAR:
minimize_toolbar = auibar.AuiToolBar(self.GetManagedWindow(), agwStyle=tbStyle)
minimize_toolbar.Hide()
minimize_toolbar.SetToolBitmapSize(wx.Size(16, 16))
if paneInfo.icon and paneInfo.icon.IsOk():
restore_bitmap = paneInfo.icon
else:
restore_bitmap = self._art._restore_bitmap
if posMask == AUI_MINIMIZE_POS_TOOLBAR:
xsize, ysize = minimize_toolbar.GetToolBitmapSize()
if xsize != restore_bitmap.GetWidth():
img = restore_bitmap.ConvertToImage()
img.Rescale(xsize, ysize, wx.IMAGE_QUALITY_HIGH)
restore_bitmap = img.ConvertToBitmap()
target = None
if posMask == AUI_MINIMIZE_POS_TOOLBAR:
target = paneInfo.name
minimize_toolbar.AddSimpleTool(ID_RESTORE_FRAME, paneInfo.caption, restore_bitmap,
_(u"Restore %s")%paneInfo.caption, target=target)
minimize_toolbar.SetAuiManager(self)
minimize_toolbar.Realize()
toolpanelname = paneInfo.name + "_min"
if paneInfo.IsMaximized():
paneInfo.SetFlag(paneInfo.wasMaximized, True)
if posMask != AUI_MINIMIZE_POS_TOOLBAR:
if dockDirection == AUI_DOCK_TOP:
self.AddPane(minimize_toolbar, AuiPaneInfo(). \
Name(toolpanelname).Caption(paneInfo.caption). \
ToolbarPane().Top().BottomDockable(False). \
LeftDockable(False).RightDockable(False).DestroyOnClose())
elif dockDirection == AUI_DOCK_BOTTOM:
self.AddPane(minimize_toolbar, AuiPaneInfo(). \
Name(toolpanelname).Caption(paneInfo.caption). \
ToolbarPane().Bottom().TopDockable(False). \
LeftDockable(False).RightDockable(False).DestroyOnClose())
elif dockDirection == AUI_DOCK_LEFT:
self.AddPane(minimize_toolbar, AuiPaneInfo(). \
Name(toolpanelname).Caption(paneInfo.caption). \
ToolbarPane().Left().TopDockable(False). \
BottomDockable(False).RightDockable(False).DestroyOnClose())
elif dockDirection in [AUI_DOCK_RIGHT, AUI_DOCK_CENTER]:
self.AddPane(minimize_toolbar, AuiPaneInfo(). \
Name(toolpanelname).Caption(paneInfo.caption). \
ToolbarPane().Right().TopDockable(False). \
LeftDockable(False).BottomDockable(False).DestroyOnClose())
arr = FindDocks(self._docks, paneInfo.dock_direction, paneInfo.dock_layer, paneInfo.dock_row)
if arr:
dock = arr[0]
paneInfo.previousDockSize = dock.size
paneInfo.previousDockPos = paneInfo.dock_pos
# mark ourselves minimized
paneInfo.Minimize()
paneInfo.Show(False)
self._has_minimized = True
# last, hide the window
if paneInfo.window and paneInfo.window.IsShown():
paneInfo.window.Show(False)
minimize_toolbar.Show()
if mgrUpdate:
self.Update()
if self._agwFlags & AUI_MGR_ANIMATE_FRAMES:
self.AnimateDocking(win_rect, minimize_toolbar.GetScreenRect())
def OnRestoreMinimizedPane(self, event):
"""
Handles the ``EVT_AUI_PANE_MIN_RESTORE`` event for :class:`AuiManager`.
:param `event`: an instance of :class:`AuiManagerEvent` to be processed.
"""
self.RestoreMinimizedPane(event.pane)
def OnPaneDocked(self, event):
"""
Handles the ``EVT_AUI_PANE_DOCKED`` event for :class:`AuiManager`.
:param `event`: an instance of :class:`AuiManagerEvent` to be processed.
"""
event.Skip()
self.RemoveAutoNBCaption(event.GetPane())
def CreateNotebookBase(self, panes, paneInfo):
"""
Creates an auto-notebook base from a pane, and then add that pane as a page.
:param list `panes`: set of panes to append new notebook base pane to
:param AuiPaneInfo `paneInfo`: the pane to be converted to a new notebook.
"""
# Create base notebook pane ...
nbid = len(self._notebooks)
baseInfo = AuiPaneInfo()
baseInfo.SetDockPos(paneInfo).NotebookControl(nbid). \
CloseButton(False).SetNameFromNotebookId(). \
NotebookDockable(False).Floatable(paneInfo.IsFloatable())
baseInfo.best_size = paneInfo.best_size
panes.append(baseInfo)
# add original pane as tab ...
paneInfo.NotebookPage(nbid)
def RemoveAutoNBCaption(self, pane):
"""
Removes the caption on newly created automatic notebooks.
:param `pane`: an instance of :class:`AuiPaneInfo` (the target notebook).
"""
if self._agwFlags & AUI_MGR_AUTONB_NO_CAPTION == 0:
return False
def RemoveCaption():
""" Sub-function used to remove the pane caption on automatic notebooks. """
if pane.HasNotebook():
notebook = self._notebooks[pane.notebook_id]
self.GetPane(notebook).CaptionVisible(False).PaneBorder(False)
self.Update()
# it seems the notebook isnt created by this stage, so remove
# the caption a moment later
wx.CallAfter(RemoveCaption)
return True
def RestoreMinimizedPane(self, paneInfo):
"""
Restores a previously minimized pane.
:param `paneInfo`: a :class:`AuiPaneInfo` instance for the pane to be restored.
"""
panename = paneInfo.name
if paneInfo.minimize_mode & AUI_MINIMIZE_POS_TOOLBAR:
pane = self.GetPane(panename)
hasTarget = True
else:
panename = panename[0:-4]
hasTarget = False
pane = self.GetPane(panename)
pane.SetFlag(pane.needsRestore, True)
if not pane.IsOk():
panename = paneInfo.name
pane = self.GetPane(panename)
paneInfo = self.GetPane(panename + "_min")
if not paneInfo.IsOk():
# Already minimized
return
if pane.IsOk():
if not pane.IsMinimized():
return
if pane.HasFlag(pane.wasMaximized):
self.SavePreviousDockSizes(pane)
self.ShowPane(pane.window, True)
pane.Show(True)
self._has_minimized = False
pane.SetFlag(pane.optionMinimized, False)
if hasTarget:
targetName = pane.minimize_target
toolbarPane = self.GetPane(targetName)
toolbar = toolbarPane.window
item = toolbar.FindToolByLabel(pane.caption)
toolbar.DeleteTool(item.id)
else:
paneInfo.window.Show(False)
self.DetachPane(paneInfo.window)
paneInfo.Show(False)
paneInfo.Hide()
self.Update()
def AnimateDocking(self, win_rect, pane_rect):
"""
Animates the minimization/docking of a pane a la Eclipse, using a :class:`ScreenDC`
to draw a "moving docking rectangle" on the screen.
:param Rect `win_rect`: the original pane screen rectangle;
:param Rect `pane_rect`: the newly created toolbar/pane screen rectangle.
:note: This functionality is not available on wxMAC as this platform doesn't have
the ability to use :class:`ScreenDC` to draw on-screen and on Windows > Vista.
"""
if wx.Platform == "__WXMAC__":
# No wx.ScreenDC on the Mac...
return
if wx.Platform == "__WXMSW__" and wx.GetOsVersion()[1] > 5:
# No easy way to handle this on Vista...
return
xstart, ystart = win_rect.x, win_rect.y
xend, yend = pane_rect.x, pane_rect.y
step = self.GetAnimationStep()
wstep = int(abs(win_rect.width - pane_rect.width)/step)
hstep = int(abs(win_rect.height - pane_rect.height)/step)
xstep = int(win_rect.x - pane_rect.x)/step
ystep = int(win_rect.y - pane_rect.y)/step
dc = wx.ScreenDC()
dc.SetLogicalFunction(wx.INVERT)
dc.SetBrush(wx.TRANSPARENT_BRUSH)
dc.SetPen(wx.LIGHT_GREY_PEN)
for i in xrange(int(step)):
width, height = win_rect.width - i*wstep, win_rect.height - i*hstep
x, y = xstart - i*xstep, ystart - i*ystep
new_rect = wx.Rect(x, y, width, height)
dc.DrawRoundedRectangleRect(new_rect, 3)
wx.SafeYield()
wx.MilliSleep(10)
dc.DrawRoundedRectangleRect(new_rect, 3)
def SmoothDock(self, paneInfo):
"""
This method implements a smooth docking effect for floating panes, similar to
what the PyQT library does with its floating windows.
:param `paneInfo`: an instance of :class:`AuiPaneInfo`.
:note: The smooth docking effect can only be used if you set the ``AUI_MGR_SMOOTH_DOCKING``
style to :class:`AuiManager`.
"""
if paneInfo.IsToolbar():
return
if not paneInfo.frame or self._hint_rect.IsEmpty():
return
hint_rect = self._hint_rect
win_rect = paneInfo.frame.GetScreenRect()
xstart, ystart = win_rect.x, win_rect.y
xend, yend = hint_rect.x, hint_rect.y
step = self.GetAnimationStep()/3
wstep = int((win_rect.width - hint_rect.width)/step)
hstep = int((win_rect.height - hint_rect.height)/step)
xstep = int((win_rect.x - hint_rect.x))/step
ystep = int((win_rect.y - hint_rect.y))/step
for i in xrange(int(step)):
width, height = win_rect.width - i*wstep, win_rect.height - i*hstep
x, y = xstart - i*xstep, ystart - i*ystep
new_rect = wx.Rect(x, y, width, height)
paneInfo.frame.SetRect(new_rect)
wx.MilliSleep(10)
def SetSnapLimits(self, x, y):
"""
Modifies the snap limits used when snapping the `managed_window` to the screen
(using :meth:`SnapToScreen`) or when snapping the floating panes to one side of the
`managed_window` (using :meth:`SnapPane`).
To change the limit after which the `managed_window` or the floating panes are
automatically stickled to the screen border (or to the `managed_window` side),
set these two variables. Default values are 15 pixels.
:param integer `x`: the minimum horizontal distance below which the snap occurs;
:param integer `y`: the minimum vertical distance below which the snap occurs.
"""
self._snap_limits = (x, y)
self.Snap()
def Snap(self):
"""
Snaps the main frame to specified position on the screen.
:see: :meth:`SnapToScreen`
"""
snap, hAlign, vAlign, monitor = self._is_docked
if not snap:
return
managed_window = self.GetManagedWindow()
snap_pos = self.GetSnapPosition()
wnd_pos = managed_window.GetPosition()
snapX, snapY = self._snap_limits
if abs(snap_pos.x - wnd_pos.x) < snapX and abs(snap_pos.y - wnd_pos.y) < snapY:
managed_window.SetPosition(snap_pos)
def SnapToScreen(self, snap=True, monitor=0, hAlign=wx.RIGHT, vAlign=wx.TOP):
"""
Snaps the main frame to specified position on the screen.
:param bool `snap`: whether to snap the main frame or not;
:param integer `monitor`: the monitor display in which snapping the window;
:param integer `hAlign`: the horizontal alignment of the snapping position;
:param integer `vAlign`: the vertical alignment of the snapping position.
"""
if not snap:
self._is_docked = (False, wx.RIGHT, wx.TOP, 0)
return
displayCount = wx.Display.GetCount()
if monitor > displayCount:
raise Exception("Invalid monitor selected: you only have %d monitors"%displayCount)
self._is_docked = (True, hAlign, vAlign, monitor)
self.GetManagedWindow().SetPosition(self.GetSnapPosition())
def GetSnapPosition(self):
""" Returns the main frame snapping position. """
snap, hAlign, vAlign, monitor = self._is_docked
display = wx.Display(monitor)
area = display.GetClientArea()
size = self.GetManagedWindow().GetSize()
pos = wx.Point()
if hAlign == wx.LEFT:
pos.x = area.x
elif hAlign == wx.CENTER:
pos.x = area.x + (area.width - size.x)/2
else:
pos.x = area.x + area.width - size.x
if vAlign == wx.TOP:
pos.y = area.y
elif vAlign == wx.CENTER:
pos.y = area.y + (area.height - size.y)/2
else:
pos.y = area.y + area.height - size.y
return pos
def GetAnimationStep(self):
""" Returns the animation step speed (a float) to use in :meth:`AnimateDocking`. """
return self._animation_step
def SetAnimationStep(self, step):
"""
Sets the animation step speed (a float) to use in :meth:`AnimateDocking`.
:param float `step`: the animation speed.
"""
self._animation_step = float(step)
def RequestUserAttention(self, pane_window):
"""
Requests the user attention by intermittently highlighting the pane caption.
:param Window `pane_window`: the window managed by the pane;
"""
# try to find the pane
paneInfo = self.GetPane(pane_window)
if not paneInfo.IsOk():
raise Exception("Pane window not found")
dc = wx.ClientDC(self._frame)
# if the frame is about to be deleted, don't bother
if not self._frame or self._frame.IsBeingDeleted():
return
if not self._frame.GetSizer():
return
for part in self._uiparts:
if part.pane == paneInfo:
self._art.RequestUserAttention(dc, self._frame, part.pane.caption, part.rect, part.pane)
self._frame.RefreshRect(part.rect, True)
break
def StartPreviewTimer(self, toolbar):
"""
Starts a timer for sliding in and out a minimized pane.
:param `toolbar`: the :class:`~lib.agw.aui.auibar.AuiToolBar` containing the minimized pane tool.
"""
toolbar_pane = self.GetPane(toolbar)
toolbar_name = toolbar_pane.name
pane_name = toolbar_name[0:-4]
self._sliding_pane = self.GetPane(pane_name)
self._sliding_rect = toolbar.GetScreenRect()
self._sliding_direction = toolbar_pane.dock_direction
self._sliding_frame = None
self._preview_timer.Start(1000, wx.TIMER_ONE_SHOT)
def StopPreviewTimer(self):
""" Stops a timer for sliding in and out a minimized pane. """
if self._preview_timer.IsRunning():
self._preview_timer.Stop()
self.SlideOut()
self._sliding_pane = None
def SlideIn(self, event):
"""
Handles the ``wx.EVT_TIMER`` event for :class:`AuiManager`.
:param `event`: a :class:`TimerEvent` to be processed.
:note: This is used solely for sliding in and out minimized panes.
"""
window = self._sliding_pane.window
self._sliding_frame = wx.MiniFrame(None, -1, title=_("Pane Preview"),
style=wx.FRAME_TOOL_WINDOW | wx.STAY_ON_TOP |
wx.FRAME_NO_TASKBAR | wx.CAPTION)
window.Reparent(self._sliding_frame)
self._sliding_frame.SetSize((0, 0))
window.Show()
self._sliding_frame.Show()
size = window.GetBestSize()
startX, startY, stopX, stopY = GetSlidingPoints(self._sliding_rect, size, self._sliding_direction)
step = stopX/10
window_size = 0
for i in xrange(0, stopX, step):
window_size = i
self._sliding_frame.SetDimensions(startX, startY, window_size, stopY)
self._sliding_frame.Refresh()
self._sliding_frame.Update()
wx.MilliSleep(10)
self._sliding_frame.SetDimensions(startX, startY, stopX, stopY)
self._sliding_frame.Refresh()
self._sliding_frame.Update()
def SlideOut(self):
"""
Slides out a preview of a minimized pane.
:note: This is used solely for sliding in and out minimized panes.
"""
if not self._sliding_frame:
return
window = self._sliding_frame.GetChildren()[0]
size = window.GetBestSize()
startX, startY, stopX, stopY = GetSlidingPoints(self._sliding_rect, size, self._sliding_direction)
step = stopX/10
window_size = 0
for i in xrange(stopX, 0, -step):
window_size = i
self._sliding_frame.SetDimensions(startX, startY, window_size, stopY)
self._sliding_frame.Refresh()
self._sliding_frame.Update()
self._frame.RefreshRect(wx.Rect(startX+window_size, startY, step, stopY))
self._frame.Update()
wx.MilliSleep(10)
self._sliding_frame.SetDimensions(startX, startY, 0, stopY)
window.Hide()
window.Reparent(self._frame)
self._sliding_frame.Hide()
self._sliding_frame.Destroy()
self._sliding_frame = None
self._sliding_pane = None
class AuiManager_DCP(AuiManager):
"""
A class similar to :class:`AuiManager` but with a Dummy Center Pane (**DCP**).
The code for this class is still flickery due to the call to :func:`CallAfter`
and the double-update call.
"""
def __init__(self, *args, **keys):
""" See :meth:`AuiManager.__init__` for the class construction. """
AuiManager.__init__(self, *args, **keys)
self.hasDummyPane = False
def _createDummyPane(self):
""" Creates a Dummy Center Pane (**DCP**). """
if self.hasDummyPane:
return
self.hasDummyPane = True
dummy = wx.Panel(self.GetManagedWindow())
info = AuiPaneInfo().CenterPane().NotebookDockable(True).Name('dummyCenterPane').DestroyOnClose(True)
self.AddPane(dummy, info)
def _destroyDummyPane(self):
""" Destroys the Dummy Center Pane (**DCP**). """
if not self.hasDummyPane:
return
self.hasDummyPane = False
self.ClosePane(self.GetPane('dummyCenterPane'))
def Update(self):
"""
This method is called after any number of changes are made to any of the
managed panes. :meth:`Update` must be invoked after :meth:`AuiManager.AddPane` or
:meth:`AuiManager.InsertPane` are called in order to "realize" or "commit" the changes.
In addition, any number of changes may be made to :class:`AuiManager` structures
(retrieved with :meth:`AuiManager.GetPane`), but to realize the changes,
:meth:`Update` must be called. This construction allows pane flicker to
be avoided by updating the whole layout at one time.
"""
AuiManager.Update(self)
# check if there's already a center pane (except our dummy pane)
dummyCenterPane = self.GetPane('dummyCenterPane')
haveCenterPane = any((pane != dummyCenterPane) and (pane.dock_direction == AUI_DOCK_CENTER) and
not pane.IsFloating() and pane.IsShown() for pane in self.GetAllPanes())
if haveCenterPane:
if self.hasDummyPane:
# there's our dummy pane and also another center pane, therefor let's remove our dummy
def do():
self._destroyDummyPane()
self.Update()
wx.CallAfter(do)
else:
# if we get here, there's no center pane, create our dummy
if not self.hasDummyPane:
self._createDummyPane()
|