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
|
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// copyright : (C) 2008 by Eran Ifrah
// file name : frame.cpp
//
// -------------------------------------------------------------------------
// A
// _____ _ _ _ _
// / __ \ | | | | (_) |
// | / \/ ___ __| | ___| | _| |_ ___
// | | / _ \ / _ |/ _ \ | | | __/ _ )
// | \__/\ (_) | (_| | __/ |___| | || __/
// \____/\___/ \__,_|\___\_____/_|\__\___|
//
// F i l e
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
#include "precompiled_header.h"
#include "my_menu_bar.h"
#include "bitmap_loader.h"
#include <wx/wupdlock.h>
#include "file_logger.h"
#include "event_notifier.h"
#include "cl_aui_tb_are.h"
#include "manage_perspective_dlg.h"
#include "save_perspective_as_dlg.h"
#include "open_resource_dialog.h" // New open resource
#include <wx/busyinfo.h>
#include "tags_parser_search_path_dlg.h"
#include "includepathlocator.h"
#include "localstable.h"
#include "console_frame.h"
#include "build_custom_targets_menu_manager.h"
#include "cl_config.h"
#include "cl_aui_dock_art.h"
#include <wx/splash.h>
#include "clsplashscreen.h"
#include "WelcomePage.h"
#include "code_completion_box.h"
#include "cl_aui_tool_stickness.h"
#include "cl_command_event.h"
#include "refactoring_storage.h"
#include "refactorengine.h"
#include "bookmark_manager.h"
#include <wx/richmsgdlg.h>
#include "code_completion_manager.h"
#include "clang_compilation_db_thread.h"
#include "cl_unredo.h"
#include "NewProjectWizard.h"
#include <CompilersDetectorManager.h>
#include "CompilersFoundDlg.h"
#include <wx/stc/stc.h>
#include "cl_standard_paths.h"
#include "ColoursAndFontsManager.h"
#include "fileutils.h"
#ifdef __WXGTK20__
// We need this ugly hack to workaround a gtk2-wxGTK name-clash
// See http://trac.wxwidgets.org/ticket/10883
#define GSocket GlibGSocket
#include <gtk/gtk.h>
#undef GSocket
#endif
#include "imanager.h"
#include "newversiondlg.h"
#include "quickdebugdlg.h"
#include "debugcoredump.h"
#include "syntaxhighlightdlg.h"
#include "dirsaver.h"
#include "batchbuilddlg.h"
#include "detachedpanesinfo.h"
#include "dockablepanemenumanager.h"
#include "dockablepane.h"
#include "webupdatethread.h"
#include "aboutdlg.h"
#include "buildtabsettingsdata.h"
#include "singleinstancethreadjob.h"
#include "refactorindexbuildjob.h"
#include "jobqueue.h"
#include "acceltabledlg.h"
#include "drawingutils.h"
#include "newworkspacedlg.h"
#include "replaceinfilespanel.h"
#include "pluginmgrdlg.h"
#include "environmentconfig.h"
#include "findresultstab.h"
#include "new_build_tab.h"
#include "frame.h"
#include "symbol_tree.h"
#include "cpp_symbol_tree.h"
#include "plugin.h"
#include "language.h"
#include "editor_config.h"
#include "manager.h"
#include "menumanager.h"
#include "search_thread.h"
#include "project.h"
#include "fileview.h"
#include "configuration_manager_dlg.h"
#include "filedroptarget.h"
#include "advanced_settings.h"
#include "build_settings_config.h"
#include "macros.h"
#include "async_executable_cmd.h"
#include "workspace_pane.h"
#include "navigationmanager.h"
#include "debuggermanager.h"
#include "breakpointdlg.h"
#include "generalinfo.h"
#include "debuggersettingsdlg.h"
#include "quickoutlinedlg.h"
#include "debuggerpane.h"
#include "sessionmanager.h"
#include "pluginmanager.h"
#include "exelocator.h"
#include "builder.h"
#include "buildmanager.h"
#include "debuggerconfigtool.h"
#include "openwindowspanel.h"
#include "workspace_pane.h"
#include "globals.h"
#include "workspacetab.h"
#include "fileexplorer.h"
#include "notebook_ex.h"
#include "options_dlg2.h"
#include <wx/msgdlg.h>
#include "tabgroupdlg.h"
#include "tabgroupmanager.h"
#include "tabgroupspane.h"
#include "clang_code_completion.h"
#include "cl_defs.h"
clSplashScreen* clMainFrame::m_splashScreen = NULL;
//////////////////////////////////////////////////
// from auto-generated file svninfo.cpp:
extern wxString CODELITE_VERSION_STR;
extern const wxChar* clGitRevision;
static wxStopWatch gStopWatch;
// from iconsextra.cpp:
extern char* cubes_xpm[];
extern unsigned char cubes_alpha[];
static int FrameTimerId = wxNewId();
const wxEventType wxEVT_UPDATE_STATUS_BAR = XRCID("update_status_bar");
const wxEventType wxEVT_LOAD_PERSPECTIVE = XRCID("load_perspective");
const wxEventType wxEVT_REFRESH_PERSPECTIVE_MENU = XRCID("refresh_perspective_menu");
const wxEventType wxEVT_ACTIVATE_EDITOR = XRCID("activate_editor");
const wxEventType wxEVT_LOAD_SESSION = ::wxNewEventType();
#define CHECK_SHUTDOWN() \
{ \
if(ManagerST::Get()->IsShutdownInProgress()) { \
return; \
} \
}
#ifdef __WXGTK__
#define FACTOR_1 0.0
#define FACTOR_2 0.0
#else
#define FACTOR_1 2.0
#define FACTOR_2 2.0
#endif
#ifdef __WXMAC__
#define TB_SEPARATOR()
#else
#define TB_SEPARATOR() tb->AddSeparator()
#endif
//----------------------------------------------------------------
// Our main frame
//----------------------------------------------------------------
BEGIN_EVENT_TABLE(clMainFrame, wxFrame)
// ATTN: Any item that appears in more than one menu is
// only listed once here, the first time it occurs
//---------------------------------------------------
// System events
//---------------------------------------------------
EVT_IDLE(clMainFrame::OnIdle)
EVT_ACTIVATE(clMainFrame::OnAppActivated)
EVT_CLOSE(clMainFrame::OnClose)
EVT_TIMER(FrameTimerId, clMainFrame::OnTimer)
// EVT_AUI_RENDER(Frame::OnAuiManagerRender)
// EVT_AUI_PANE_CLOSE(Frame::OnDockablePaneClosed)
//---------------------------------------------------
// File menu
//---------------------------------------------------
EVT_MENU(XRCID("new_file"), clMainFrame::OnFileNew)
EVT_MENU(XRCID("open_file"), clMainFrame::OnFileOpen)
EVT_MENU(XRCID("refresh_file"), clMainFrame::OnFileReload)
EVT_MENU(XRCID("load_tab_group"), clMainFrame::OnFileLoadTabGroup)
EVT_MENU(XRCID("save_file"), clMainFrame::OnSave)
EVT_MENU(XRCID("save_file_as"), clMainFrame::OnSaveAs)
EVT_MENU(XRCID("save_all"), clMainFrame::OnFileSaveAll)
EVT_MENU(XRCID("save_tab_group"), clMainFrame::OnFileSaveTabGroup)
EVT_MENU(XRCID("close_file"), clMainFrame::OnFileClose)
EVT_MENU(wxID_CLOSE_ALL, clMainFrame::OnFileCloseAll)
EVT_MENU_RANGE(RecentFilesSubMenuID, RecentFilesSubMenuID + 10, clMainFrame::OnRecentFile)
EVT_MENU_RANGE(RecentWorkspaceSubMenuID, RecentWorkspaceSubMenuID + 10, clMainFrame::OnRecentWorkspace)
EVT_MENU_RANGE(ID_MENU_CUSTOM_TARGET_FIRST, ID_MENU_CUSTOM_TARGET_MAX, clMainFrame::OnBuildCustomTarget)
EVT_MENU(wxID_EXIT, clMainFrame::OnQuit)
EVT_UPDATE_UI(XRCID("refresh_file"), clMainFrame::OnFileExistUpdateUI)
EVT_UPDATE_UI(XRCID("save_file"), clMainFrame::OnFileSaveUI)
EVT_UPDATE_UI(XRCID("save_file_as"), clMainFrame::OnFileExistUpdateUI)
EVT_UPDATE_UI(XRCID("save_all"), clMainFrame::OnFileSaveAllUI)
EVT_UPDATE_UI(XRCID("save_tab_group"), clMainFrame::OnFileExistUpdateUI)
EVT_UPDATE_UI(XRCID("close_file"), clMainFrame::OnFileCloseUI)
//--------------------------------------------------
// Edit menu
//--------------------------------------------------
EVT_MENU(wxID_UNDO, clMainFrame::DispatchCommandEvent)
EVT_MENU(wxID_REDO, clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("label_current_state"), clMainFrame::DispatchCommandEvent)
EVT_MENU(wxID_DUPLICATE, clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("delete_line"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("delete_line_end"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("delete_line_start"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("transpose_lines"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("trim_trailing"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("to_upper"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("to_lower"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("match_brace"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("select_to_brace"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("complete_word"), clMainFrame::OnCompleteWord)
EVT_MENU(XRCID("complete_word_refresh_list"), clMainFrame::OnCompleteWordRefreshList)
EVT_MENU(XRCID("function_call_tip"), clMainFrame::OnFunctionCalltip)
EVT_MENU(XRCID("convert_eol_win"), clMainFrame::OnConvertEol)
EVT_MENU(XRCID("convert_eol_unix"), clMainFrame::OnConvertEol)
EVT_MENU(XRCID("convert_eol_mac"), clMainFrame::OnConvertEol)
EVT_MENU(XRCID("move_line_down"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("move_line_up"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("center_line"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("center_line_roll"), clMainFrame::DispatchCommandEvent)
EVT_UPDATE_UI(wxID_UNDO, clMainFrame::DispatchUpdateUIEvent)
EVT_UPDATE_UI(wxID_REDO, clMainFrame::DispatchUpdateUIEvent)
EVT_UPDATE_UI(wxID_DUPLICATE, clMainFrame::DispatchUpdateUIEvent)
EVT_UPDATE_UI(XRCID("delete_line"), clMainFrame::OnFileExistUpdateUI)
EVT_UPDATE_UI(XRCID("delete_line_end"), clMainFrame::OnFileExistUpdateUI)
EVT_UPDATE_UI(XRCID("delete_line_start"), clMainFrame::OnFileExistUpdateUI)
EVT_UPDATE_UI(XRCID("transpose_lines"), clMainFrame::OnFileExistUpdateUI)
EVT_UPDATE_UI(XRCID("trim_trailing"), clMainFrame::DispatchUpdateUIEvent)
EVT_UPDATE_UI(XRCID("to_upper"), clMainFrame::DispatchUpdateUIEvent)
EVT_UPDATE_UI(XRCID("to_lower"), clMainFrame::DispatchUpdateUIEvent)
EVT_UPDATE_UI(XRCID("match_brace"), clMainFrame::DispatchUpdateUIEvent)
EVT_UPDATE_UI(XRCID("select_to_brace"), clMainFrame::DispatchUpdateUIEvent)
EVT_UPDATE_UI(XRCID("complete_word"), clMainFrame::OnCompleteWordUpdateUI)
EVT_UPDATE_UI(XRCID("function_call_tip"), clMainFrame::OnFunctionCalltipUI)
EVT_UPDATE_UI(XRCID("convert_eol_win"), clMainFrame::OnFileExistUpdateUI)
EVT_UPDATE_UI(XRCID("convert_eol_unix"), clMainFrame::OnFileExistUpdateUI)
EVT_UPDATE_UI(XRCID("convert_eol_mac"), clMainFrame::OnFileExistUpdateUI)
EVT_UPDATE_UI(XRCID("move_line_down"), clMainFrame::OnFileExistUpdateUI)
EVT_UPDATE_UI(XRCID("move_line_up"), clMainFrame::OnFileExistUpdateUI)
EVT_UPDATE_UI(XRCID("center_line"), clMainFrame::OnFileExistUpdateUI)
EVT_UPDATE_UI(XRCID("center_line_roll"), clMainFrame::OnFileExistUpdateUI)
//-------------------------------------------------------
// View menu
//-------------------------------------------------------
EVT_MENU(XRCID("restore_layout"), clMainFrame::OnRestoreDefaultLayout)
EVT_MENU(XRCID("word_wrap"), clMainFrame::OnViewWordWrap)
EVT_MENU(XRCID("toggle_fold"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("fold_all"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("fold_all_in_selection"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("fold_topmost_in_selection"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("display_eol"), clMainFrame::OnViewDisplayEOL)
EVT_MENU(XRCID("whitepsace_invisible"), clMainFrame::OnShowWhitespace)
EVT_MENU(XRCID("whitepsace_always"), clMainFrame::OnShowWhitespace)
EVT_MENU(XRCID("whitespace_visiable_after_indent"), clMainFrame::OnShowWhitespace)
EVT_MENU(XRCID("whitespace_indent_only"), clMainFrame::OnShowWhitespace)
EVT_MENU(XRCID("full_screen"), clMainFrame::OnShowFullScreen)
EVT_MENU(XRCID("view_welcome_page"), clMainFrame::OnShowWelcomePage)
EVT_MENU(XRCID("view_welcome_page_at_startup"), clMainFrame::OnLoadWelcomePage)
EVT_MENU(XRCID("show_nav_toolbar"), clMainFrame::OnShowNavBar)
EVT_MENU(XRCID("toogle_main_toolbars"), clMainFrame::OnToggleMainTBars)
EVT_MENU(XRCID("toogle_plugin_toolbars"), clMainFrame::OnTogglePluginTBars)
EVT_MENU(XRCID("toggle_panes"), clMainFrame::OnTogglePanes)
EVT_MENU(XRCID("hide_status_bar"), clMainFrame::OnShowStatusBar)
EVT_UPDATE_UI(XRCID("hide_status_bar"), clMainFrame::OnShowStatusBarUI)
EVT_MENU(XRCID("hide_tool_bar"), clMainFrame::OnShowToolbar)
EVT_UPDATE_UI(XRCID("hide_tool_bar"), clMainFrame::OnShowToolbarUI)
EVT_MENU_RANGE(viewAsMenuItemID, viewAsMenuItemMaxID, clMainFrame::DispatchCommandEvent)
EVT_UPDATE_UI(XRCID("word_wrap"), clMainFrame::DispatchUpdateUIEvent)
EVT_UPDATE_UI(XRCID("toggle_fold"), clMainFrame::OnFileExistUpdateUI)
EVT_UPDATE_UI(XRCID("fold_all"), clMainFrame::OnFileExistUpdateUI)
EVT_UPDATE_UI(XRCID("fold_all_in_selection"), clMainFrame::DispatchUpdateUIEvent)
EVT_UPDATE_UI(XRCID("fold_topmost_in_selection"), clMainFrame::DispatchUpdateUIEvent)
EVT_UPDATE_UI(XRCID("display_eol"), clMainFrame::OnViewDisplayEOL_UI)
EVT_UPDATE_UI(XRCID("whitepsace_invisible"), clMainFrame::OnShowWhitespaceUI)
EVT_UPDATE_UI(XRCID("whitepsace_always"), clMainFrame::OnShowWhitespaceUI)
EVT_UPDATE_UI(XRCID("whitespace_visiable_after_indent"), clMainFrame::OnShowWhitespaceUI)
EVT_UPDATE_UI(XRCID("whitespace_indent_only"), clMainFrame::OnShowWhitespaceUI)
EVT_UPDATE_UI(XRCID("view_welcome_page"), clMainFrame::OnShowWelcomePageUI)
EVT_UPDATE_UI(XRCID("view_welcome_page_at_startup"), clMainFrame::OnLoadWelcomePageUI)
EVT_UPDATE_UI(XRCID("show_nav_toolbar"), clMainFrame::OnShowNavBarUI)
EVT_UPDATE_UI(viewAsSubMenuID, clMainFrame::OnFileExistUpdateUI)
EVT_UPDATE_UI_RANGE(viewAsMenuItemID, viewAsMenuItemMaxID, clMainFrame::DispatchUpdateUIEvent)
EVT_MENU(XRCID("show_workspace_tab"), clMainFrame::OnViewShowWorkspaceTab)
EVT_MENU(XRCID("show_explorer_tab"), clMainFrame::OnViewShowExplorerTab)
EVT_MENU(XRCID("show_tabs_tab"), clMainFrame::OnViewShowTabs)
EVT_MENU(XRCID("show_tabgroups_tab"), clMainFrame::OnViewShowTabgroups)
EVT_UPDATE_UI(XRCID("show_workspace_tab"), clMainFrame::OnViewShowWorkspaceTabUI)
EVT_UPDATE_UI(XRCID("show_explorer_tab"), clMainFrame::OnViewShowExplorerTabUI)
EVT_UPDATE_UI(XRCID("show_tabs_tab"), clMainFrame::OnViewShowTabsUI)
EVT_UPDATE_UI(XRCID("show_tabgroups_tab"), clMainFrame::OnViewShowTabgroupsUI)
//-------------------------------------------------------
// Search menu
//-------------------------------------------------------
EVT_MENU(wxID_FIND, clMainFrame::DispatchCommandEvent)
EVT_MENU(wxID_REPLACE, clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("find_resource"), clMainFrame::OnFindResourceXXX)
EVT_MENU(XRCID("incremental_search"), clMainFrame::OnIncrementalSearch)
EVT_MENU(XRCID("find_symbol"), clMainFrame::OnQuickOutline)
EVT_MENU(XRCID("goto_definition"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("goto_previous_definition"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("goto_linenumber"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("toggle_bookmark"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("next_bookmark"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("previous_bookmark"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("removeall_current_bookmarks"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("removeall_bookmarks"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("next_fif_match"), clMainFrame::OnNextFiFMatch)
EVT_MENU(XRCID("previous_fif_match"), clMainFrame::OnPreviousFiFMatch)
EVT_MENU(XRCID("grep_current_file"), clMainFrame::OnGrepWord)
EVT_MENU(XRCID("grep_current_workspace"), clMainFrame::OnGrepWord)
EVT_AUITOOLBAR_TOOL_DROPDOWN(XRCID("toggle_bookmark"), clMainFrame::OnShowBookmarkMenu)
EVT_UPDATE_UI(wxID_FIND, clMainFrame::OnIncrementalSearchUI)
EVT_UPDATE_UI(wxID_REPLACE, clMainFrame::OnFileExistUpdateUI)
EVT_UPDATE_UI(XRCID("select_previous"), clMainFrame::OnFileExistUpdateUI)
EVT_UPDATE_UI(XRCID("select_next"), clMainFrame::OnFileExistUpdateUI)
EVT_UPDATE_UI(XRCID("find_next"), clMainFrame::OnFileExistUpdateUI)
EVT_UPDATE_UI(XRCID("find_previous"), clMainFrame::OnFileExistUpdateUI)
EVT_UPDATE_UI(XRCID("find_next_at_caret"), clMainFrame::OnFileExistUpdateUI)
EVT_UPDATE_UI(XRCID("find_previous_at_caret"), clMainFrame::OnFileExistUpdateUI)
EVT_UPDATE_UI(XRCID("incremental_search"), clMainFrame::OnIncrementalSearchUI)
EVT_UPDATE_UI(XRCID("find_resource"), clMainFrame::OnWorkspaceOpen)
EVT_UPDATE_UI(XRCID("find_type"), clMainFrame::OnWorkspaceOpen)
EVT_UPDATE_UI(XRCID("find_function"), clMainFrame::OnWorkspaceOpen)
EVT_UPDATE_UI(XRCID("find_macro"), clMainFrame::OnWorkspaceOpen)
EVT_UPDATE_UI(XRCID("find_typedef"), clMainFrame::OnWorkspaceOpen)
EVT_UPDATE_UI(XRCID("find_symbol"), clMainFrame::OnCompleteWordUpdateUI)
EVT_UPDATE_UI(XRCID("goto_definition"), clMainFrame::DispatchUpdateUIEvent)
EVT_UPDATE_UI(XRCID("goto_previous_definition"), clMainFrame::DispatchUpdateUIEvent)
EVT_UPDATE_UI(XRCID("goto_linenumber"), clMainFrame::OnFileExistUpdateUI)
EVT_UPDATE_UI(XRCID("toggle_bookmark"), clMainFrame::OnFileExistUpdateUI)
EVT_UPDATE_UI(XRCID("next_bookmark"), clMainFrame::OnFileExistUpdateUI)
EVT_UPDATE_UI(XRCID("previous_bookmark"), clMainFrame::OnFileExistUpdateUI)
EVT_UPDATE_UI(XRCID("removeall_bookmarks"), clMainFrame::OnFileExistUpdateUI)
EVT_UPDATE_UI(XRCID("next_fif_match"), clMainFrame::OnNextFiFMatchUI)
EVT_UPDATE_UI(XRCID("previous_fif_match"), clMainFrame::OnPreviousFiFMatchUI)
EVT_UPDATE_UI(XRCID("grep_current_file"), clMainFrame::OnGrepWordUI)
EVT_UPDATE_UI(XRCID("grep_current_workspace"), clMainFrame::OnGrepWordUI)
//-------------------------------------------------------
// Project menu
//-------------------------------------------------------
EVT_MENU(XRCID("local_workspace_prefs"), clMainFrame::OnWorkspaceEditorPreferences)
EVT_MENU(XRCID("local_workspace_settings"), clMainFrame::OnWorkspaceSettings)
EVT_MENU(XRCID("new_workspace"), clMainFrame::OnProjectNewWorkspace)
EVT_MENU(XRCID("switch_to_workspace"), clMainFrame::OnSwitchWorkspace)
EVT_MENU(XRCID("close_workspace"), clMainFrame::OnCloseWorkspace)
EVT_MENU(XRCID("reload_workspace"), clMainFrame::OnReloadWorkspace)
EVT_MENU(XRCID("import_from_msvs"), clMainFrame::OnImportMSVS)
EVT_MENU(XRCID("new_project"), clMainFrame::OnProjectNewProject)
EVT_MENU(XRCID("add_project"), clMainFrame::OnProjectAddProject)
EVT_MENU(XRCID("reconcile_project"), clMainFrame::OnReconcileProject)
EVT_MENU(XRCID("retag_workspace"), clMainFrame::OnRetagWorkspace)
EVT_MENU(XRCID("full_retag_workspace"), clMainFrame::OnRetagWorkspace)
EVT_MENU(XRCID("project_properties"), clMainFrame::OnShowActiveProjectSettings)
EVT_UPDATE_UI(XRCID("local_workspace_prefs"), clMainFrame::OnWorkspaceOpen)
EVT_UPDATE_UI(XRCID("local_workspace_settings"), clMainFrame::OnWorkspaceOpen)
EVT_UPDATE_UI(XRCID("close_workspace"), clMainFrame::OnWorkspaceOpen)
EVT_UPDATE_UI(XRCID("reload_workspace"), clMainFrame::OnWorkspaceOpen)
EVT_UPDATE_UI(XRCID("add_project"), clMainFrame::OnWorkspaceMenuUI)
EVT_UPDATE_UI(XRCID("reconcile_project"), clMainFrame::OnShowActiveProjectSettingsUI)
EVT_UPDATE_UI(XRCID("retag_workspace"), clMainFrame::OnRetagWorkspaceUI)
EVT_UPDATE_UI(XRCID("full_retag_workspace"), clMainFrame::OnRetagWorkspaceUI)
EVT_UPDATE_UI(XRCID("project_properties"), clMainFrame::OnShowActiveProjectSettingsUI)
//-------------------------------------------------------
// Build menu
//-------------------------------------------------------
EVT_MENU(XRCID("execute_no_debug"), clMainFrame::OnExecuteNoDebug)
EVT_MENU(XRCID("stop_executed_program"), clMainFrame::OnStopExecutedProgram)
EVT_MENU(XRCID("build_active_project"), clMainFrame::OnBuildProject)
EVT_MENU(XRCID("build_active_project_only"), clMainFrame::OnBuildProjectOnly)
EVT_AUITOOLBAR_TOOL_DROPDOWN(XRCID("build_active_project"), clMainFrame::OnShowAuiBuildMenu)
EVT_MENU(XRCID("compile_active_file"), clMainFrame::OnCompileFile)
EVT_MENU(XRCID("clean_active_project"), clMainFrame::OnCleanProject)
EVT_MENU(XRCID("clean_active_project_only"), clMainFrame::OnCleanProjectOnly)
EVT_MENU(XRCID("stop_active_project_build"), clMainFrame::OnStopBuild)
EVT_MENU(XRCID("rebuild_active_project"), clMainFrame::OnRebuildProject)
EVT_MENU(XRCID("build_n_run_active_project"), clMainFrame::OnBuildAndRunProject)
EVT_MENU(XRCID("build_workspace"), clMainFrame::OnBuildWorkspace)
EVT_MENU(XRCID("clean_workspace"), clMainFrame::OnCleanWorkspace)
EVT_MENU(XRCID("rebuild_workspace"), clMainFrame::OnReBuildWorkspace)
EVT_MENU(XRCID("batch_build"), clMainFrame::OnBatchBuild)
EVT_UPDATE_UI(XRCID("execute_no_debug"), clMainFrame::OnExecuteNoDebugUI)
EVT_UPDATE_UI(XRCID("stop_executed_program"), clMainFrame::OnStopExecutedProgramUI)
EVT_UPDATE_UI(XRCID("build_active_project"), clMainFrame::OnBuildProjectUI)
EVT_UPDATE_UI(XRCID("compile_active_file"), clMainFrame::OnCompileFileUI)
EVT_UPDATE_UI(XRCID("clean_active_project"), clMainFrame::OnCleanProjectUI)
EVT_UPDATE_UI(XRCID("stop_active_project_build"), clMainFrame::OnStopBuildUI)
EVT_UPDATE_UI(XRCID("rebuild_active_project"), clMainFrame::OnBuildProjectUI)
EVT_UPDATE_UI(XRCID("build_n_run_active_project"), clMainFrame::OnBuildProjectUI)
EVT_UPDATE_UI(XRCID("build_workspace"), clMainFrame::OnBuildWorkspaceUI)
EVT_UPDATE_UI(XRCID("clean_workspace"), clMainFrame::OnCleanWorkspaceUI)
EVT_UPDATE_UI(XRCID("rebuild_workspace"), clMainFrame::OnReBuildWorkspaceUI)
EVT_UPDATE_UI(XRCID("batch_build"), clMainFrame::OnBatchBuildUI)
//-------------------------------------------------------
// Debug menu
//-------------------------------------------------------
EVT_MENU(XRCID("debugger_win_locals"), clMainFrame::OnShowDebuggerWindow)
EVT_MENU(XRCID("debugger_win_watches"), clMainFrame::OnShowDebuggerWindow)
EVT_MENU(XRCID("debugger_win_output"), clMainFrame::OnShowDebuggerWindow)
EVT_MENU(XRCID("debugger_win_threads"), clMainFrame::OnShowDebuggerWindow)
EVT_MENU(XRCID("debugger_win_callstack"), clMainFrame::OnShowDebuggerWindow)
EVT_MENU(XRCID("debugger_win_memory"), clMainFrame::OnShowDebuggerWindow)
EVT_MENU(XRCID("debugger_win_breakpoints"), clMainFrame::OnShowDebuggerWindow)
EVT_MENU(XRCID("debugger_win_asciiview"), clMainFrame::OnShowDebuggerWindow)
EVT_MENU(XRCID("debugger_win_disassemble"), clMainFrame::OnShowDebuggerWindow)
EVT_UPDATE_UI(XRCID("debugger_win_locals"), clMainFrame::OnShowDebuggerWindowUI)
EVT_UPDATE_UI(XRCID("debugger_win_watches"), clMainFrame::OnShowDebuggerWindowUI)
EVT_UPDATE_UI(XRCID("debugger_win_output"), clMainFrame::OnShowDebuggerWindowUI)
EVT_UPDATE_UI(XRCID("debugger_win_threads"), clMainFrame::OnShowDebuggerWindowUI)
EVT_UPDATE_UI(XRCID("debugger_win_callstack"), clMainFrame::OnShowDebuggerWindowUI)
EVT_UPDATE_UI(XRCID("debugger_win_memory"), clMainFrame::OnShowDebuggerWindowUI)
EVT_UPDATE_UI(XRCID("debugger_win_breakpoints"), clMainFrame::OnShowDebuggerWindowUI)
EVT_UPDATE_UI(XRCID("debugger_win_asciiview"), clMainFrame::OnShowDebuggerWindowUI)
EVT_UPDATE_UI(XRCID("debugger_win_disassemble"), clMainFrame::OnShowDebuggerWindowUI)
EVT_MENU(XRCID("start_debugger"), clMainFrame::OnDebug)
EVT_MENU(XRCID("restart_debugger"), clMainFrame::OnDebugRestart)
EVT_MENU(XRCID("attach_debugger"), clMainFrame::OnDebugAttach)
EVT_MENU(XRCID("pause_debugger"), clMainFrame::OnDebugCmd)
EVT_MENU(XRCID("stop_debugger"), clMainFrame::OnDebugStop)
EVT_MENU(XRCID("dbg_stepin"), clMainFrame::OnDebugCmd)
EVT_MENU(XRCID("dbg_stepout"), clMainFrame::OnDebugCmd)
EVT_MENU(XRCID("dbg_next"), clMainFrame::OnDebugCmd)
EVT_MENU(XRCID("dbg_nexti"), clMainFrame::OnDebugCmd)
EVT_MENU(XRCID("show_cursor"), clMainFrame::OnDebugCmd)
EVT_MENU(XRCID("add_breakpoint"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("insert_breakpoint"), clMainFrame::DispatchCommandEvent) // Toggles
EVT_MENU(XRCID("disable_all_breakpoints"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("enable_all_breakpoints"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("delete_all_breakpoints"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("insert_temp_breakpoint"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("insert_disabled_breakpoint"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("insert_cond_breakpoint"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("edit_breakpoint"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("show_breakpoint_dlg"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("insert_watchpoint"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("toggle_breakpoint_enabled_status"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("ignore_breakpoint"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("delete_breakpoint"), clMainFrame::DispatchCommandEvent)
EVT_MENU(XRCID("quick_debug"), clMainFrame::OnQuickDebug)
EVT_MENU(XRCID("debug_core_dump"), clMainFrame::OnDebugCoreDump)
EVT_UPDATE_UI(XRCID("start_debugger"), clMainFrame::OnDebugUI)
EVT_UPDATE_UI(XRCID("restart_debugger"), clMainFrame::OnDebugRestartUI)
EVT_UPDATE_UI(XRCID("pause_debugger"), clMainFrame::OnDebugCmdUI)
EVT_UPDATE_UI(XRCID("stop_debugger"), clMainFrame::OnDebugStopUI)
EVT_UPDATE_UI(XRCID("dbg_stepin"), clMainFrame::OnDebugCmdUI)
EVT_UPDATE_UI(XRCID("dbg_stepout"), clMainFrame::OnDebugCmdUI)
EVT_UPDATE_UI(XRCID("dbg_next"), clMainFrame::OnDebugCmdUI)
EVT_UPDATE_UI(XRCID("dbg_nexti"), clMainFrame::OnDebugCmdUI)
EVT_UPDATE_UI(XRCID("show_cursor"), clMainFrame::OnDebugCmdUI)
EVT_UPDATE_UI(XRCID("insert_breakpoint"), clMainFrame::OnDebugManageBreakpointsUI)
EVT_UPDATE_UI(XRCID("disable_all_breakpoints"), clMainFrame::OnDebugManageBreakpointsUI)
EVT_UPDATE_UI(XRCID("enable_all_breakpoints"), clMainFrame::OnDebugManageBreakpointsUI)
EVT_UPDATE_UI(XRCID("delete_all_breakpoints"), clMainFrame::OnDebugManageBreakpointsUI)
EVT_UPDATE_UI(XRCID("quick_debug"), clMainFrame::OnQuickDebugUI)
EVT_UPDATE_UI(XRCID("debug_core_dump"), clMainFrame::OnQuickDebugUI)
//-------------------------------------------------------
// Plugins menu
//-------------------------------------------------------
EVT_MENU(XRCID("manage_plugins"), clMainFrame::OnManagePlugins)
//-------------------------------------------------------
// Settings menu
//-------------------------------------------------------
EVT_MENU(wxID_PREFERENCES, clMainFrame::OnViewOptions)
EVT_MENU(XRCID("syntax_highlight"), clMainFrame::OnSyntaxHighlight)
EVT_MENU(XRCID("configure_accelerators"), clMainFrame::OnConfigureAccelerators)
EVT_MENU(XRCID("add_envvar"), clMainFrame::OnAddEnvironmentVariable)
EVT_MENU(XRCID("advance_settings"), clMainFrame::OnAdvanceSettings)
EVT_MENU(XRCID("debuger_settings"), clMainFrame::OnDebuggerSettings)
EVT_MENU(XRCID("tags_options"), clMainFrame::OnCtagsOptions)
//-------------------------------------------------------
// Help menu
//-------------------------------------------------------
EVT_MENU(wxID_ABOUT, clMainFrame::OnAbout)
EVT_MENU(XRCID("check_for_update"), clMainFrame::OnCheckForUpdate)
//-------------------------------------------------------
// Perspective menu
//-------------------------------------------------------
EVT_MENU_RANGE(PERSPECTIVE_FIRST_MENU_ID, PERSPECTIVE_LAST_MENU_ID, clMainFrame::OnChangePerspective)
EVT_UPDATE_UI_RANGE(PERSPECTIVE_FIRST_MENU_ID, PERSPECTIVE_LAST_MENU_ID, clMainFrame::OnChangePerspectiveUI)
EVT_MENU(XRCID("manage_perspectives"), clMainFrame::OnManagePerspectives)
EVT_MENU(XRCID("save_current_layout"), clMainFrame::OnSaveLayoutAsPerspective)
//-----------------------------------------------------------------
// Toolbar
//-----------------------------------------------------------------
EVT_MENU(wxID_FORWARD, clMainFrame::OnBackwardForward)
EVT_MENU(wxID_BACKWARD, clMainFrame::OnBackwardForward)
EVT_MENU(XRCID("highlight_word"), clMainFrame::OnHighlightWord)
EVT_UPDATE_UI(wxID_FORWARD, clMainFrame::OnBackwardForwardUI)
EVT_UPDATE_UI(wxID_BACKWARD, clMainFrame::OnBackwardForwardUI)
//-------------------------------------------------------
// Workspace Pane tab context menu
//-------------------------------------------------------
EVT_MENU(XRCID("detach_wv_tab"), clMainFrame::OnDetachWorkspaceViewTab)
//-------------------------------------------------------
// Debugger Pane tab context menu
//-------------------------------------------------------
EVT_MENU(XRCID("detach_debugger_tab"), clMainFrame::OnDetachDebuggerViewTab)
//-------------------------------------------------------
// Editor tab context menu
//-------------------------------------------------------
EVT_MENU(XRCID("close_other_tabs"), clMainFrame::OnCloseAllButThis)
EVT_MENU(XRCID("copy_file_name"), clMainFrame::OnCopyFilePath)
EVT_MENU(XRCID("copy_file_path"), clMainFrame::OnCopyFilePathOnly)
EVT_MENU(XRCID("copy_file_name_only"), clMainFrame::OnCopyFileName)
EVT_MENU(XRCID("open_shell_from_filepath"), clMainFrame::OnOpenShellFromFilePath)
EVT_MENU(XRCID("open_file_explorer"), clMainFrame::OnOpenFileExplorerFromFilePath)
EVT_MENU(XRCID("ID_DETACH_EDITOR"), clMainFrame::OnDetachEditor)
EVT_UPDATE_UI(XRCID("copy_file_name"), clMainFrame::OnFileExistUpdateUI)
EVT_UPDATE_UI(XRCID("copy_file_path"), clMainFrame::OnFileExistUpdateUI)
EVT_UPDATE_UI(XRCID("open_shell_from_filepath"), clMainFrame::OnFileExistUpdateUI)
EVT_UPDATE_UI(XRCID("open_file_explorer"), clMainFrame::OnFileExistUpdateUI)
EVT_UPDATE_UI(XRCID("ID_DETACH_EDITOR"), clMainFrame::OnDetachEditorUI)
//-----------------------------------------------------------------
// Default editor context menu
//-----------------------------------------------------------------
EVT_MENU(wxID_DELETE, clMainFrame::DispatchCommandEvent)
EVT_UPDATE_UI(wxID_DELETE, clMainFrame::DispatchUpdateUIEvent)
//-----------------------------------------------------------------
// C++ editor context menu
//-----------------------------------------------------------------
EVT_MENU(XRCID("open_include_file"), clMainFrame::OnCppContextMenu)
EVT_MENU(XRCID("add_include_file"), clMainFrame::OnCppContextMenu)
EVT_MENU(XRCID("add_forward_decl"), clMainFrame::OnCppContextMenu)
EVT_MENU(XRCID("swap_files"), clMainFrame::OnCppContextMenu)
EVT_MENU(XRCID("find_decl"), clMainFrame::OnCppContextMenu)
EVT_MENU(XRCID("find_impl"), clMainFrame::OnCppContextMenu)
EVT_MENU(XRCID("go_to_function_start"), clMainFrame::OnCppContextMenu)
EVT_MENU(XRCID("go_to_next_function"), clMainFrame::OnCppContextMenu)
EVT_MENU(XRCID("insert_doxy_comment"), clMainFrame::OnCppContextMenu)
EVT_MENU(XRCID("setters_getters"), clMainFrame::OnCppContextMenu)
EVT_MENU(XRCID("move_impl"), clMainFrame::OnCppContextMenu)
EVT_MENU(XRCID("add_impl"), clMainFrame::OnCppContextMenu)
EVT_MENU(XRCID("sync_signatures"), clMainFrame::OnCppContextMenu)
EVT_MENU(XRCID("add_multi_impl"), clMainFrame::OnCppContextMenu)
EVT_MENU(XRCID("add_virtual_impl"), clMainFrame::OnCppContextMenu)
EVT_MENU(XRCID("add_pure_virtual_impl"), clMainFrame::OnCppContextMenu)
EVT_MENU(XRCID("rename_symbol"), clMainFrame::OnCppContextMenu)
EVT_MENU(XRCID("find_references"), clMainFrame::OnCppContextMenu)
EVT_MENU(XRCID("comment_selection"), clMainFrame::OnCppContextMenu)
EVT_MENU(XRCID("comment_line"), clMainFrame::OnCppContextMenu)
EVT_MENU(XRCID("retag_file"), clMainFrame::OnCppContextMenu)
EVT_MENU(XRCID("rename_local_variable"), clMainFrame::OnCppContextMenu)
//-----------------------------------------------------------------
// Hyperlinks
//-----------------------------------------------------------------
EVT_HTML_LINK_CLICKED(wxID_ANY, clMainFrame::OnLinkClicked)
EVT_MENU(XRCID("link_action"), clMainFrame::OnStartPageEvent)
//-----------------------------------------------------------------
// CodeLite-specific events
//-----------------------------------------------------------------
EVT_COMMAND(wxID_ANY, wxEVT_PARSE_THREAD_MESSAGE, clMainFrame::OnParsingThreadMessage)
EVT_COMMAND(wxID_ANY, wxEVT_PARSE_THREAD_CLEAR_TAGS_CACHE, clMainFrame::OnClearTagsCache)
EVT_COMMAND(wxID_ANY, wxEVT_PARSE_THREAD_RETAGGING_COMPLETED, clMainFrame::OnRetaggingCompelted)
EVT_COMMAND(wxID_ANY, wxEVT_PARSE_THREAD_RETAGGING_PROGRESS, clMainFrame::OnRetaggingProgress)
EVT_COMMAND(wxID_ANY, wxEVT_PARSE_THREAD_READY, clMainFrame::OnParserThreadReady)
EVT_COMMAND(wxID_ANY, wxEVT_ACTIVATE_EDITOR, clMainFrame::OnActivateEditor)
EVT_COMMAND(wxID_ANY, wxEVT_UPDATE_STATUS_BAR, clMainFrame::OnSetStatusMessage)
EVT_COMMAND(wxID_ANY, wxEVT_TAGS_DB_UPGRADE, clMainFrame::OnDatabaseUpgrade)
EVT_COMMAND(wxID_ANY, wxEVT_TAGS_DB_UPGRADE_INTER, clMainFrame::OnDatabaseUpgradeInternally)
EVT_COMMAND(wxID_ANY, wxEVT_REFRESH_PERSPECTIVE_MENU, clMainFrame::OnRefreshPerspectiveMenu)
EVT_MENU(XRCID("update_num_builders_count"), clMainFrame::OnUpdateNumberOfBuildProcesses)
EVT_MENU(XRCID("goto_codelite_download_url"), clMainFrame::OnGotoCodeLiteDownloadPage)
EVT_COMMAND(wxID_ANY, wxEVT_CMD_SINGLE_INSTANCE_THREAD_OPEN_FILES, clMainFrame::OnSingleInstanceOpenFiles)
EVT_COMMAND(wxID_ANY, wxEVT_CMD_SINGLE_INSTANCE_THREAD_RAISE_APP, clMainFrame::OnSingleInstanceRaise)
EVT_COMMAND(wxID_ANY, wxEVT_CMD_NEW_VERSION_AVAILABLE, clMainFrame::OnNewVersionAvailable)
EVT_COMMAND(wxID_ANY, wxEVT_CMD_VERSION_UPTODATE, clMainFrame::OnNewVersionAvailable)
EVT_COMMAND(wxID_ANY, wxEVT_CMD_NEW_DOCKPANE, clMainFrame::OnNewDetachedPane)
EVT_COMMAND(wxID_ANY, wxEVT_LOAD_PERSPECTIVE, clMainFrame::OnLoadPerspective)
EVT_COMMAND(wxID_ANY, wxEVT_CMD_DELETE_DOCKPANE, clMainFrame::OnDestroyDetachedPane)
END_EVENT_TABLE()
clMainFrame* clMainFrame::m_theFrame = NULL;
clMainFrame::clMainFrame(wxWindow* pParent,
wxWindowID id,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style)
: wxFrame(pParent, id, title, pos, size, style)
, m_buildAndRun(false)
, m_cppMenu(NULL)
, m_highlightWord(false)
, m_workspaceRetagIsRequired(false)
, m_bookmarksDropDownMenu(NULL)
{
#if defined(__WXGTK20__)
// A rather ugly hack here. GTK V2 insists that F10 should be the
// accelerator for the menu bar. We don't want that. There is
// no sane way to turn this off, but we *can* get the same effect
// by setting the "menu bar accelerator" property to the name of a
// function key that is apparently legal, but doesn't really exist.
// (Or if it does, it certainly isn't a key we use.)
gtk_settings_set_string_property(gtk_settings_get_default(), "gtk-menu-bar-accel", "F15", "foo");
#endif
long value(0);
EditorConfigST::Get()->GetLongValue(wxT("highlight_word"), value);
m_highlightWord = (bool)value;
m_statusbarTimer = new StatusbarTimer(this);
CreateGUIControls();
ManagerST::Get(); // Dummy call
RefactoringEngine::Instance(); // Dummy call
// allow the main frame to receive files by drag and drop
SetDropTarget(new FileDropTarget());
// Start the search thread
SearchThreadST::Get()->SetNotifyWindow(this);
SearchThreadST::Get()->Start(WXTHREAD_MIN_PRIORITY);
// start the job queue
JobQueueSingleton::Instance()->Start(6);
// the single instance job is a presisstent job, so the pool will contain only 4 available threads
JobQueueSingleton::Instance()->PushJob(new SingleInstanceThreadJob(this, ManagerST::Get()->GetStarupDirectory()));
// start the editor creator thread
m_timer = new wxTimer(this, FrameTimerId);
// connect common edit events
wxTheApp->Connect(
wxID_COPY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(clMainFrame::DispatchCommandEvent), NULL, this);
wxTheApp->Connect(
wxID_PASTE, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(clMainFrame::DispatchCommandEvent), NULL, this);
wxTheApp->Connect(wxID_SELECTALL,
wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler(clMainFrame::DispatchCommandEvent),
NULL,
this);
wxTheApp->Connect(
wxID_CUT, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(clMainFrame::DispatchCommandEvent), NULL, this);
wxTheApp->Connect(
wxID_COPY, wxEVT_UPDATE_UI, wxUpdateUIEventHandler(clMainFrame::DispatchUpdateUIEvent), NULL, this);
wxTheApp->Connect(
wxID_PASTE, wxEVT_UPDATE_UI, wxUpdateUIEventHandler(clMainFrame::DispatchUpdateUIEvent), NULL, this);
wxTheApp->Connect(
wxID_SELECTALL, wxEVT_UPDATE_UI, wxUpdateUIEventHandler(clMainFrame::DispatchUpdateUIEvent), NULL, this);
wxTheApp->Connect(
wxID_CUT, wxEVT_UPDATE_UI, wxUpdateUIEventHandler(clMainFrame::DispatchUpdateUIEvent), NULL, this);
EventNotifier::Get()->Connect(wxEVT_LOAD_SESSION, wxCommandEventHandler(clMainFrame::OnLoadSession), NULL, this);
EventNotifier::Get()->Connect(
wxEVT_SHELL_COMMAND_PROCESS_ENDED, clCommandEventHandler(clMainFrame::OnBuildEnded), NULL, this);
EventNotifier::Get()->Connect(wxEVT_ACTIVE_PROJECT_CHANGED,
wxCommandEventHandler(clMainFrame::OnUpdateCustomTargetsDropDownMenu),
NULL,
this);
EventNotifier::Get()->Connect(wxEVT_WORKSPACE_CONFIG_CHANGED,
wxCommandEventHandler(clMainFrame::OnUpdateCustomTargetsDropDownMenu),
NULL,
this);
EventNotifier::Get()->Connect(
wxEVT_WORKSPACE_LOADED, wxCommandEventHandler(clMainFrame::OnUpdateCustomTargetsDropDownMenu), NULL, this);
EventNotifier::Get()->Connect(wxEVT_CMD_PROJ_SETTINGS_SAVED,
wxCommandEventHandler(clMainFrame::OnUpdateCustomTargetsDropDownMenu),
NULL,
this);
EventNotifier::Get()->Connect(
wxEVT_WORKSPACE_CLOSED, wxCommandEventHandler(clMainFrame::OnWorkspaceClosed), NULL, this);
EventNotifier::Get()->Connect(wxEVT_REFACTORING_ENGINE_CACHE_INITIALIZING,
wxCommandEventHandler(clMainFrame::OnRefactoringCacheStatus),
NULL,
this);
EventNotifier::Get()->Connect(
wxEVT_CL_THEME_CHANGED, wxCommandEventHandler(clMainFrame::OnThemeChanged), NULL, this);
EventNotifier::Get()->Connect(
wxEVT_ACTIVE_EDITOR_CHANGED, wxCommandEventHandler(clMainFrame::OnActiveEditorChanged), NULL, this);
EventNotifier::Get()->Bind(
wxEVT_EDITOR_SETTINGS_CHANGED, wxCommandEventHandler(clMainFrame::OnSettingsChanged), this);
EventNotifier::Get()->Bind(wxEVT_CMD_RELOAD_EXTERNALLY_MODIFIED_NOPROMPT,
wxCommandEventHandler(clMainFrame::OnReloadExternallModifiedNoPrompt),
this);
EventNotifier::Get()->Bind(
wxEVT_CMD_RELOAD_EXTERNALLY_MODIFIED, wxCommandEventHandler(clMainFrame::OnReloadExternallModified), this);
Connect(wxID_UNDO,
wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN,
wxAuiToolBarEventHandler(clMainFrame::OnTBUnRedo),
NULL,
this);
Connect(wxID_REDO,
wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN,
wxAuiToolBarEventHandler(clMainFrame::OnTBUnRedo),
NULL,
this);
// Start the code completion manager, we do this by calling it once
CodeCompletionManager::Get();
}
clMainFrame::~clMainFrame(void)
{
#ifndef __WXMSW__
m_zombieReaper.Stop();
#endif
// Free the code completion manager
CodeCompletionManager::Release();
// this will make sure that the main menu bar's member m_widget is freed before the we enter wxMenuBar destructor
// see this wxWidgets bug report for more details:
// http://trac.wxwidgets.org/ticket/14292
#if defined(__WXGTK__) && wxVERSION_NUMBER < 2904
delete m_myMenuBar;
#endif
if(m_splashScreen) {
m_splashScreen->Destroy();
m_splashScreen = NULL;
}
wxTheApp->Disconnect(
wxID_COPY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(clMainFrame::DispatchCommandEvent), NULL, this);
wxTheApp->Disconnect(
wxID_PASTE, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(clMainFrame::DispatchCommandEvent), NULL, this);
wxTheApp->Disconnect(wxID_SELECTALL,
wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler(clMainFrame::DispatchCommandEvent),
NULL,
this);
wxTheApp->Disconnect(
wxID_CUT, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(clMainFrame::DispatchCommandEvent), NULL, this);
wxTheApp->Disconnect(
wxID_COPY, wxEVT_UPDATE_UI, wxUpdateUIEventHandler(clMainFrame::DispatchUpdateUIEvent), NULL, this);
wxTheApp->Disconnect(
wxID_PASTE, wxEVT_UPDATE_UI, wxUpdateUIEventHandler(clMainFrame::DispatchUpdateUIEvent), NULL, this);
wxTheApp->Disconnect(
wxID_SELECTALL, wxEVT_UPDATE_UI, wxUpdateUIEventHandler(clMainFrame::DispatchUpdateUIEvent), NULL, this);
wxTheApp->Disconnect(
wxID_CUT, wxEVT_UPDATE_UI, wxUpdateUIEventHandler(clMainFrame::DispatchUpdateUIEvent), NULL, this);
EventNotifier::Get()->Disconnect(
wxEVT_SHELL_COMMAND_PROCESS_ENDED, clCommandEventHandler(clMainFrame::OnBuildEnded), NULL, this);
EventNotifier::Get()->Disconnect(wxEVT_LOAD_SESSION, wxCommandEventHandler(clMainFrame::OnLoadSession), NULL, this);
EventNotifier::Get()->Disconnect(wxEVT_ACTIVE_PROJECT_CHANGED,
wxCommandEventHandler(clMainFrame::OnUpdateCustomTargetsDropDownMenu),
NULL,
this);
EventNotifier::Get()->Disconnect(
wxEVT_WORKSPACE_LOADED, wxCommandEventHandler(clMainFrame::OnUpdateCustomTargetsDropDownMenu), NULL, this);
EventNotifier::Get()->Disconnect(wxEVT_CMD_PROJ_SETTINGS_SAVED,
wxCommandEventHandler(clMainFrame::OnUpdateCustomTargetsDropDownMenu),
NULL,
this);
EventNotifier::Get()->Disconnect(
wxEVT_WORKSPACE_CLOSED, wxCommandEventHandler(clMainFrame::OnWorkspaceClosed), NULL, this);
EventNotifier::Get()->Disconnect(wxEVT_WORKSPACE_CONFIG_CHANGED,
wxCommandEventHandler(clMainFrame::OnUpdateCustomTargetsDropDownMenu),
NULL,
this);
EventNotifier::Get()->Disconnect(wxEVT_REFACTORING_ENGINE_CACHE_INITIALIZING,
wxCommandEventHandler(clMainFrame::OnRefactoringCacheStatus),
NULL,
this);
EventNotifier::Get()->Disconnect(
wxEVT_CL_THEME_CHANGED, wxCommandEventHandler(clMainFrame::OnThemeChanged), NULL, this);
EventNotifier::Get()->Disconnect(
wxEVT_ACTIVE_EDITOR_CHANGED, wxCommandEventHandler(clMainFrame::OnActiveEditorChanged), NULL, this);
EventNotifier::Get()->Unbind(
wxEVT_EDITOR_SETTINGS_CHANGED, wxCommandEventHandler(clMainFrame::OnSettingsChanged), this);
EventNotifier::Get()->Unbind(wxEVT_CMD_RELOAD_EXTERNALLY_MODIFIED_NOPROMPT,
wxCommandEventHandler(clMainFrame::OnReloadExternallModifiedNoPrompt),
this);
EventNotifier::Get()->Unbind(
wxEVT_CMD_RELOAD_EXTERNALLY_MODIFIED, wxCommandEventHandler(clMainFrame::OnReloadExternallModified), this);
Disconnect(wxID_UNDO,
wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN,
wxAuiToolBarEventHandler(clMainFrame::OnTBUnRedo),
NULL,
this);
Disconnect(wxID_REDO,
wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN,
wxAuiToolBarEventHandler(clMainFrame::OnTBUnRedo),
NULL,
this);
wxDELETE(m_timer);
wxDELETE(m_statusbarTimer);
// GetPerspectiveManager().DisconnectEvents() assumes that m_mgr is still alive (and it should be as it is allocated
// on the stack of clMainFrame)
ManagerST::Get()->GetPerspectiveManager().DisconnectEvents();
ManagerST::Free();
delete m_DPmenuMgr;
// uninitialize AUI manager
m_mgr.UnInit();
}
void clMainFrame::Initialize(bool loadLastSession)
{
// set the revision number in the frame title
wxString title(_("CodeLite "));
title << clGitRevision;
// initialize the environment variable configuration manager
EnvironmentConfig::Instance()->Load();
EditorConfig* cfg = EditorConfigST::Get();
GeneralInfo inf;
cfg->ReadObject(wxT("GeneralInfo"), &inf);
int screenW = wxSystemSettings::GetMetric(wxSYS_SCREEN_X);
int screenH = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y);
// validate the frame loaded pos & size
if(inf.GetFramePosition().x < 0 || inf.GetFramePosition().x > screenW) {
inf.SetFramePosition(wxPoint(30, 3));
}
if(inf.GetFramePosition().y < 0 || inf.GetFramePosition().y > screenH) {
inf.SetFramePosition(wxPoint(30, 3));
}
wxSize frameSize(inf.GetFrameSize());
if(inf.GetFrameSize().x < 400 || inf.GetFrameSize().x > screenW) {
frameSize.SetWidth(400);
}
if(inf.GetFrameSize().y < 400 || inf.GetFrameSize().y > screenH) {
frameSize.SetHeight(400);
}
inf.SetFrameSize(frameSize);
#if defined(NDEBUG) && !defined(__WXMAC__)
// we show splash only when using Release builds of codelite
if(inf.GetFlags() & CL_SHOW_SPLASH) {
wxBitmap bitmap;
wxString splashName(ManagerST::Get()->GetStarupDirectory() + wxT("/images/splashscreen.png"));
if(bitmap.LoadFile(splashName, wxBITMAP_TYPE_PNG)) {
wxString mainTitle = CODELITE_VERSION_STR;
clMainFrame::m_splashScreen = new clSplashScreen(NULL, bitmap);
}
}
#endif
m_theFrame = new clMainFrame(NULL,
wxID_ANY,
title,
inf.GetFramePosition(),
inf.GetFrameSize(),
wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE);
m_theFrame->m_frameGeneralInfo = inf;
m_theFrame->m_loadLastSession = loadLastSession;
m_theFrame->Maximize(m_theFrame->m_frameGeneralInfo.GetFlags() & CL_MAXIMIZE_FRAME ? true : false);
// add the welcome page
if(m_theFrame->m_frameGeneralInfo.GetFlags() & CL_SHOW_WELCOME_PAGE) {
m_theFrame->CreateWelcomePage();
}
// plugins must be loaded before the file explorer
m_theFrame->CompleteInitialization();
// time to create the file explorer
wxCommandEvent e(wxEVT_COMMAND_MENU_SELECTED, XRCID("go_home"));
m_theFrame->GetFileExplorer()->GetEventHandler()->ProcessEvent(e);
m_theFrame->SendSizeEvent();
m_theFrame->StartTimer();
// Keep the current layout before loading the perspective from the disk
m_theFrame->m_defaultLayout = m_theFrame->m_mgr.SavePerspective();
// Save the current layout as the "Default" layout (unless we already got one ...)
ManagerST::Get()->GetPerspectiveManager().SavePerspectiveIfNotExists(NORMAL_LAYOUT);
// After all the plugins / panes have been loaded,
// its time to re-load the perspective
wxCommandEvent evt(wxEVT_LOAD_PERSPECTIVE);
m_theFrame->AddPendingEvent(evt);
}
clMainFrame* clMainFrame::Get() { return m_theFrame; }
void clMainFrame::CreateGUIControls(void)
{
// this->Freeze();
#ifdef __WXMSW__
SetIcon(wxICON(aaaaa));
#else
wxImage img(cubes_xpm);
img.SetAlpha(cubes_alpha, true);
wxBitmap bmp(img);
wxIcon icon;
icon.CopyFromBitmap(bmp);
SetIcon(icon);
#endif
// tell wxAuiManager to manage this frame
m_mgr.SetManagedWindow(this);
m_mgr.SetArtProvider(new clAuiDockArt(PluginManager::Get()));
SetAUIManagerFlags();
m_mgr.GetArtProvider()->SetMetric(wxAUI_DOCKART_GRADIENT_TYPE, wxAUI_GRADIENT_HORIZONTAL);
m_mgr.GetArtProvider()->SetMetric(wxAUI_DOCKART_CAPTION_SIZE, 22);
m_mgr.GetArtProvider()->SetColor(wxAUI_DOCKART_SASH_COLOUR, DrawingUtils::GetPanelBgColour());
m_mgr.GetArtProvider()->SetColor(wxAUI_DOCKART_BACKGROUND_COLOUR, DrawingUtils::GetPanelBgColour());
// initialize debugger configuration tool
DebuggerConfigTool::Get()->Load(wxT("config/debuggers.xml"), wxT("5.4"));
WorkspaceST::Get()->SetStartupDir(ManagerST::Get()->GetStarupDirectory());
#if wxCHECK_VERSION(2, 9, 5)
m_mgr.GetArtProvider()->SetMetric(wxAUI_DOCKART_PANE_BORDER_SIZE, 0);
#else
m_mgr.GetArtProvider()->SetMetric(wxAUI_DOCKART_PANE_BORDER_SIZE, 0);
#endif
m_mgr.GetArtProvider()->SetMetric(wxAUI_DOCKART_SASH_SIZE, 6);
// Load the menubar from XRC and set this frame's menubar to it.
wxMenuBar* mb = wxXmlResource::Get()->LoadMenuBar(wxT("main_menu"));
// Under wxGTK < 2.9.4 we need this wrapper class to avoid warnings on ubuntu when codelite exits
m_myMenuBar = new MyMenuBar();
m_myMenuBar->Set(mb);
SetMenuBar(mb);
// Set up dynamic parts of menu.
CreateViewAsSubMenu();
CreateRecentlyOpenedWorkspacesMenu();
DoUpdatePerspectiveMenu();
// Connect to Edit menu, so that its labelled-state submenu can be added on the fly when necessary
wxMenu* editmenu = NULL;
wxMenuItem* menuitem = GetMenuBar()->FindItem(wxID_UNDO, &editmenu);
if(menuitem && editmenu) {
editmenu->Bind(wxEVT_MENU_OPEN, wxMenuEventHandler(clMainFrame::OnEditMenuOpened), this);
}
m_DPmenuMgr = new DockablePaneMenuManager(GetMenuBar(), &m_mgr);
//---------------------------------------------
// Add docking windows
//---------------------------------------------
// I'm not localising the captions of these Views atm. That's because wxAui uses name+caption to ID a pane
// It also serialises the caption. That means that changing locale will break the layout stored in codelite.layout
// If it's decided to do this in the future, change only the 'Caption(wxT("Output View"))' bits below
// However I'm creating unused strings here, so that the translations remain in the catalogue
const wxString unusedOV(_("Output View"));
const wxString unusedWV(_("Workspace View"));
// Add the explorer pane
m_workspacePane = new WorkspacePane(this, wxT("Workspace View"), &m_mgr);
m_mgr.AddPane(m_workspacePane,
wxAuiPaneInfo()
.CaptionVisible(true)
.MinimizeButton()
.MaximizeButton()
.Name(m_workspacePane->GetCaption())
.Caption(m_workspacePane->GetCaption())
.Left()
.BestSize(250, 300)
.Layer(1)
.Position(0)
.CloseButton(true));
RegisterDockWindow(XRCID("workspace_pane"), wxT("Workspace View"));
// add the debugger locals tree, make it hidden by default
m_debuggerPane = new DebuggerPane(this, wxT("Debugger"), &m_mgr);
m_mgr.AddPane(m_debuggerPane,
wxAuiPaneInfo()
.CaptionVisible(true)
.Name(m_debuggerPane->GetCaption())
.Caption(m_debuggerPane->GetCaption())
.Bottom()
.Layer(1)
.Position(1)
.CloseButton(true)
.MinimizeButton()
.Hide()
.MaximizeButton());
RegisterDockWindow(XRCID("debugger_pane"), wxT("Debugger"));
m_mainBook = new MainBook(this);
m_mgr.AddPane(m_mainBook, wxAuiPaneInfo().Name(wxT("Editor")).CenterPane().PaneBorder(false));
CreateRecentlyOpenedFilesMenu();
m_outputPane = new OutputPane(this, wxT("Output View"));
wxAuiPaneInfo paneInfo;
m_mgr.AddPane(m_outputPane,
paneInfo.CaptionVisible(true)
.Name(wxT("Output View"))
.Caption(wxT("Output View"))
.Bottom()
.Layer(1)
.Position(0)
.MinimizeButton()
.Show()
.BestSize(wxSize(400, 200))
.MaximizeButton());
RegisterDockWindow(XRCID("output_pane"), wxT("Output View"));
long show_nav(1);
EditorConfigST::Get()->GetLongValue(wxT("ShowNavBar"), show_nav);
if(!show_nav) {
m_mainBook->ShowNavBar(false);
}
if(!BuildSettingsConfigST::Get()->Load(wxT("2.1"))) {
CL_ERROR("Could not locate build configuration! CodeLite installation is broken this might cause unwanted "
"behavior!");
}
clConfig ccConfig("code-completion.conf");
ccConfig.ReadItem(&m_tagsOptionsData);
TagsManager* tagsManager = TagsManagerST::Get();
// start ctags process
TagsManagerST::Get()->SetCodeLiteIndexerPath(clStandardPaths::Get().GetBinaryFullPath("codelite_indexer"));
ManagerST::Get()->SetCodeLiteLauncherPath(clStandardPaths::Get().GetBinaryFullPath("codelite_launcher"));
tagsManager->StartCodeLiteIndexer();
//--------------------------------------------------------------------------------------
// Start the parsing thread, the parsing thread and the SymbolTree (or its derived)
// Are connected. The constructor of SymbolTree, calls ParseThreadST::Get()->SetNotifyWindow(this)
// to allows it to receive events for gui changes.
//
// If you wish to connect another object for it, simply call ParseThreadST::Get()->SetNotifyWindow(this)
// with another object as 'this'
//--------------------------------------------------------------------------------------
// Update the parser thread search paths
ParseThreadST::Get()->SetCrawlerEnabeld(m_tagsOptionsData.GetParserEnabled());
ParseThreadST::Get()->SetSearchPaths(m_tagsOptionsData.GetParserSearchPaths(),
m_tagsOptionsData.GetParserExcludePaths());
ParseThreadST::Get()->Start();
ClangCompilationDbThreadST::Get()->Start();
// Connect this tree to the parse thread
ParseThreadST::Get()->SetNotifyWindow(this);
// And finally create a status bar
wxStatusBar* statusBar = new wxStatusBar(this, wxID_ANY);
SetStatusBar(statusBar);
m_status.resize(3);
GetStatusBar()->SetFieldsCount(m_status.size());
SetStatusMessage(_("Ready"), 0);
SetStatusMessage(_("Done"), m_status.size() - 1);
// update ctags options
TagsManagerST::Get()->SetCtagsOptions(m_tagsOptionsData);
// set this frame as the event handler for any events
TagsManagerST::Get()->SetEvtHandler(this);
// We must do Layout() before loading the toolbars, otherwise they're broken in >=wxGTK-2.9
Layout();
// Create the toolbars
// If we requested to create a single toolbar, create a native toolbar
// otherwise, we create a multiple toolbars using wxAUI toolbar if possible
OptionsConfigPtr options = EditorConfigST::Get()->GetOptions();
if(options) {
bool nativeToolbar = !PluginManager::Get()->AllowToolbar();
if(options->GetIconsSize() == 16) {
nativeToolbar ? CreateNativeToolbar16() : CreateToolbars16();
} else {
nativeToolbar ? CreateNativeToolbar24() : CreateToolbars24();
}
Bind(wxEVT_TOOL_DROPDOWN,
wxCommandEventHandler(clMainFrame::OnNativeTBUnRedoDropdown),
this,
wxID_UNDO,
wxID_REDO);
} else {
CreateToolbars24();
}
// Connect the custom build target events range: !USE_AUI_TOOLBAR only
if(GetToolBar()) {
GetToolBar()->Connect(ID_MENU_CUSTOM_TARGET_FIRST,
ID_MENU_CUSTOM_TARGET_MAX,
wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler(clMainFrame::OnBuildCustomTarget),
NULL,
this);
}
Bind(wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler(clMainFrame::OnChangeActiveBookmarkType),
this,
XRCID("BookmarkTypes[start]"),
XRCID("BookmarkTypes[end]"));
GetWorkspacePane()->GetNotebook()->SetRightClickMenu(wxXmlResource::Get()->LoadMenu(wxT("workspace_view_rmenu")));
GetDebuggerPane()->GetNotebook()->SetRightClickMenu(wxXmlResource::Get()->LoadMenu(wxT("debugger_view_rmenu")));
m_mgr.Update();
SetAutoLayout(true);
wxString sessConfFile;
sessConfFile << clStandardPaths::Get().GetUserDataDir() << wxT("/config/sessions.xml");
SessionManager::Get().Load(sessConfFile);
// try to locate the build tools
long fix(1);
EditorConfigST::Get()->GetLongValue(wxT("FixBuildToolOnStartup"), fix);
if(fix) {
UpdateBuildTools();
}
// This is needed in >=wxGTK-2.9, otherwise the auinotebook doesn't fully expand at first
SendSizeEvent(wxSEND_EVENT_POST);
// Ditto the workspace pane auinotebook
GetWorkspacePane()->SendSizeEvent(wxSEND_EVENT_POST);
}
void clMainFrame::CreateViewAsSubMenu()
{
// get the 'View As' menu
wxMenu* menu = NULL;
wxMenuItem* menuitem = GetMenuBar()->FindItem(XRCID("display_eol"), &menu);
if(menuitem && menu) {
wxMenu* submenu = new wxMenu();
// create a view as sub menu and attach it
wxMenuItem* item(NULL);
int minId = viewAsMenuItemID;
// load all lexers
// load generic lexers
wxArrayString lexerNames = ColoursAndFontsManager::Get().GetAllLexersNames();
for(size_t i = 0; i < lexerNames.GetCount(); ++i) {
item = new wxMenuItem(submenu, minId, lexerNames.Item(i), wxEmptyString, wxITEM_CHECK);
m_viewAsMap[minId] = lexerNames.Item(i);
minId++;
submenu->Append(item);
}
menu->Append(viewAsSubMenuID, _("View As"), submenu);
}
}
void clMainFrame::OnEditMenuOpened(wxMenuEvent& event)
{
LEditor* editor = GetMainBook()->GetActiveEditor(true);
wxMenuItem* labelCurrentState = event.GetMenu()->FindChildItem(XRCID("label_current_state"));
if(labelCurrentState) { // Here seems to be the only reliable place to do 'updateui' for this; a real UpdateUI
// handler is only hit when there's no editor :/
labelCurrentState->Enable(editor != NULL);
}
if(editor) {
editor->GetCommandsProcessor().PrepareLabelledStatesMenu(event.GetMenu());
} else {
// There's no active editor, so remove any stale submenu; otherwise it'll display but the contents won't work
wxMenuItem* menuitem = event.GetMenu()->FindChildItem(XRCID("goto_labelled_state"));
if(menuitem) {
event.GetMenu()->Delete(menuitem);
}
event.Skip();
}
}
void clMainFrame::OnNativeTBUnRedoDropdown(wxCommandEvent& event)
{
LEditor* editor = GetMainBook()->GetActiveEditor(true);
if(editor && GetToolBar()) {
bool undoing = event.GetId() == wxID_UNDO;
wxMenu* menu = new wxMenu;
editor->GetCommandsProcessor().DoPopulateUnRedoMenu(*menu, undoing);
if(!menu->GetMenuItemCount()) {
delete menu;
return;
}
if(undoing) {
menu->Bind(wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler(CommandProcessorBase::OnUndoDropdownItem),
&editor->GetCommandsProcessor());
} else {
menu->Bind(wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler(CommandProcessorBase::OnRedoDropdownItem),
&editor->GetCommandsProcessor());
}
GetToolBar()->SetDropdownMenu(event.GetId(), menu);
event.Skip();
}
// Don't skip if there's no active editor/toolbar, otherwise a stale menu will show
}
wxString clMainFrame::GetViewAsLanguageById(int id) const
{
if(m_viewAsMap.find(id) == m_viewAsMap.end()) {
return wxEmptyString;
}
return m_viewAsMap.find(id)->second;
}
void clMainFrame::CreateToolbars24()
{
wxAuiPaneInfo info;
#if !USE_AUI_TOOLBAR
wxWindow* toolbar_parent(this);
if(PluginManager::Get()->AllowToolbar()) {
toolbar_parent = this;
}
#else
wxWindow* toolbar_parent(this);
#endif
//----------------------------------------------
// create the standard toolbar
//----------------------------------------------
clToolBar* tb = new clToolBar(toolbar_parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, clTB_DEFAULT_STYLE);
tb->SetToolBitmapSize(wxSize(24, 24));
#if USE_AUI_TOOLBAR
tb->SetArtProvider(new CLMainAuiTBArt());
#endif
BitmapLoader& bmpLoader = *(PluginManager::Get()->GetStdIcons());
tb->AddTool(XRCID("new_file"), _("New"), bmpLoader.LoadBitmap(wxT("toolbars/24/standard/file_new")), _("New File"));
tb->AddTool(
XRCID("open_file"), _("Open"), bmpLoader.LoadBitmap(wxT("toolbars/24/standard/file_open")), _("Open File"));
tb->AddTool(XRCID("refresh_file"),
_("Reload"),
bmpLoader.LoadBitmap(wxT("toolbars/24/standard/file_reload")),
_("Reload File"));
TB_SEPARATOR();
tb->AddTool(XRCID("save_file"), _("Save"), bmpLoader.LoadBitmap(wxT("toolbars/24/standard/file_save")), _("Save"));
tb->AddTool(XRCID("save_all"),
_("Save All"),
bmpLoader.LoadBitmap(wxT("toolbars/24/standard/file_save_all")),
_("Save All"));
TB_SEPARATOR();
tb->AddTool(
XRCID("close_file"), _("Close"), bmpLoader.LoadBitmap(wxT("toolbars/24/standard/file_close")), _("Close File"));
TB_SEPARATOR();
tb->AddTool(wxID_CUT, _("Cut"), bmpLoader.LoadBitmap(wxT("toolbars/24/standard/cut")), _("Cut"));
tb->AddTool(wxID_COPY, _("Copy"), bmpLoader.LoadBitmap(wxT("toolbars/24/standard/copy")), _("Copy"));
tb->AddTool(wxID_PASTE, _("Paste"), bmpLoader.LoadBitmap(wxT("toolbars/24/standard/paste")), _("Paste"));
TB_SEPARATOR();
tb->AddTool(wxID_UNDO, _("Undo"), bmpLoader.LoadBitmap(wxT("toolbars/24/standard/undo")), _("Undo"));
tb->SetToolDropDown(wxID_UNDO, true);
tb->AddTool(wxID_REDO, _("Redo"), bmpLoader.LoadBitmap(wxT("toolbars/24/standard/redo")), _("Redo"));
tb->SetToolDropDown(wxID_REDO, true);
tb->AddTool(wxID_BACKWARD, _("Backward"), bmpLoader.LoadBitmap(wxT("toolbars/24/standard/back")), _("Backward"));
tb->AddTool(wxID_FORWARD, _("Forward"), bmpLoader.LoadBitmap(wxT("toolbars/24/standard/forward")), _("Forward"));
TB_SEPARATOR();
tb->AddTool(XRCID("toggle_bookmark"),
_("Toggle Bookmark"),
bmpLoader.LoadBitmap(wxT("toolbars/24/standard/bookmark")),
_("Toggle Bookmark"));
tb->SetToolDropDown(XRCID("toggle_bookmark"), true);
if(PluginManager::Get()->AllowToolbar()) {
tb->Realize();
m_mgr.AddPane(tb,
wxAuiPaneInfo()
.Name(wxT("Standard Toolbar"))
.LeftDockable(true)
.RightDockable(true)
.Caption(_("Standard"))
.ToolbarPane()
.Top());
}
//----------------------------------------------
// create the search toolbar
//----------------------------------------------
if(PluginManager::Get()->AllowToolbar()) {
info = wxAuiPaneInfo();
tb = new clToolBar(toolbar_parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, clTB_DEFAULT_STYLE);
#if USE_AUI_TOOLBAR
tb->SetArtProvider(new CLMainAuiTBArt());
#endif
tb->SetToolBitmapSize(wxSize(24, 24));
}
tb->AddTool(wxID_FIND, _("Find"), bmpLoader.LoadBitmap(wxT("toolbars/24/search/find")), _("Find"));
tb->AddTool(
wxID_REPLACE, _("Replace"), bmpLoader.LoadBitmap(wxT("toolbars/24/search/find_and_replace")), _("Replace"));
tb->AddTool(XRCID("find_in_files"),
_("Find In Files"),
bmpLoader.LoadBitmap(wxT("toolbars/24/search/find_in_files")),
_("Find In Files"));
TB_SEPARATOR();
tb->AddTool(XRCID("find_resource"),
_("Find Resource In Workspace"),
bmpLoader.LoadBitmap(wxT("toolbars/24/search/open_resource")),
_("Find Resource In Workspace"));
TB_SEPARATOR();
tb->AddTool(XRCID("highlight_word"),
_("Highlight Word"),
bmpLoader.LoadBitmap(wxT("toolbars/24/search/mark_word")),
_("Highlight Matching Words"),
wxITEM_CHECK);
tb->ToggleTool(XRCID("highlight_word"), m_highlightWord);
TB_SEPARATOR();
if(PluginManager::Get()->AllowToolbar()) {
tb->Realize();
m_mgr.AddPane(tb,
info.Name(wxT("Search Toolbar"))
.LeftDockable(true)
.RightDockable(true)
.Caption(_("Search"))
.ToolbarPane()
.Top());
}
//----------------------------------------------
// create the build toolbar
//----------------------------------------------
if(PluginManager::Get()->AllowToolbar()) {
tb = new clToolBar(toolbar_parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, clTB_DEFAULT_STYLE);
#if USE_AUI_TOOLBAR
tb->SetArtProvider(new CLMainAuiTBArt());
#endif
tb->SetToolBitmapSize(wxSize(24, 24));
}
tb->AddTool(XRCID("build_active_project"),
wxEmptyString,
bmpLoader.LoadBitmap(wxT("toolbars/24/build/build")),
_("Build Active Project"));
tb->SetToolDropDown(XRCID("build_active_project"), true);
tb->AddTool(XRCID("stop_active_project_build"),
wxEmptyString,
bmpLoader.LoadBitmap(wxT("toolbars/24/build/stop")),
_("Stop Current Build"));
tb->AddTool(XRCID("clean_active_project"),
wxEmptyString,
bmpLoader.LoadBitmap(wxT("toolbars/24/build/clean")),
_("Clean Active Project"));
TB_SEPARATOR();
tb->AddTool(XRCID("execute_no_debug"),
wxEmptyString,
bmpLoader.LoadBitmap(wxT("toolbars/24/build/execute")),
_("Run Active Project"));
tb->AddTool(XRCID("stop_executed_program"),
wxEmptyString,
bmpLoader.LoadBitmap(wxT("toolbars/24/build/execute_stop")),
_("Stop Running Program"));
if(PluginManager::Get()->AllowToolbar()) {
tb->Realize();
info = wxAuiPaneInfo();
m_mgr.AddPane(tb,
info.Name(wxT("Build Toolbar"))
.LeftDockable(true)
.RightDockable(true)
.Caption(_("Build"))
.ToolbarPane()
.Top());
}
//----------------------------------------------
// create the debugger toolbar
//----------------------------------------------
if(PluginManager::Get()->AllowToolbar()) {
tb = new clToolBar(toolbar_parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, clTB_DEFAULT_STYLE);
#if USE_AUI_TOOLBAR
tb->SetArtProvider(new CLMainAuiTBArt());
#endif
tb->SetToolBitmapSize(wxSize(24, 24));
}
tb->AddTool(XRCID("start_debugger"),
_("Start or Continue debugger"),
bmpLoader.LoadBitmap(wxT("toolbars/24/debugger/start")),
_("Start or Continue debugger"));
tb->AddTool(XRCID("stop_debugger"),
_("Stop debugger"),
bmpLoader.LoadBitmap(wxT("toolbars/24/debugger/stop")),
_("Stop debugger"));
tb->AddTool(XRCID("pause_debugger"),
_("Pause debugger"),
bmpLoader.LoadBitmap(wxT("toolbars/24/debugger/interrupt")),
_("Pause debugger"));
tb->AddTool(XRCID("restart_debugger"),
_("Restart debugger"),
bmpLoader.LoadBitmap(wxT("toolbars/24/debugger/restart")),
_("Restart debugger"));
TB_SEPARATOR();
tb->AddTool(XRCID("show_cursor"),
_("Show Current Line"),
bmpLoader.LoadBitmap(wxT("toolbars/24/debugger/show_current_line")),
_("Show Current Line"));
TB_SEPARATOR();
tb->AddTool(
XRCID("dbg_stepin"), _("Step Into"), bmpLoader.LoadBitmap(wxT("toolbars/24/debugger/step_in")), _("Step In"));
tb->AddTool(XRCID("dbg_next"), _("Next"), bmpLoader.LoadBitmap(wxT("toolbars/24/debugger/next")), _("Next"));
tb->AddTool(XRCID("dbg_nexti"),
_("Next Instruction"),
bmpLoader.LoadBitmap(wxT("toolbars/24/debugger/nexti")),
_("Next Instruction"));
tb->AddTool(
XRCID("dbg_stepout"), _("Step Out"), bmpLoader.LoadBitmap(wxT("toolbars/24/debugger/step_out")), _("Step Out"));
tb->Realize();
if(PluginManager::Get()->AllowToolbar()) {
info = wxAuiPaneInfo();
m_mgr.AddPane(tb,
info.Name(wxT("Debugger Toolbar"))
.LeftDockable(true)
.RightDockable(true)
.Caption(_("Debug"))
.ToolbarPane()
.Top());
RegisterToolbar(XRCID("show_std_toolbar"), wxT("Standard Toolbar"));
RegisterToolbar(XRCID("show_search_toolbar"), wxT("Search Toolbar"));
RegisterToolbar(XRCID("show_build_toolbar"), wxT("Build Toolbar"));
RegisterToolbar(XRCID("show_debug_toolbar"), wxT("Debugger Toolbar"));
} else {
#if !USE_AUI_TOOLBAR
SetToolBar(tb);
#else
m_mgr.AddPane(tb,
info.Name(wxT("Main Toolbar"))
.LeftDockable(true)
.RightDockable(true)
.Caption(_("Main Toolbar"))
.ToolbarPane()
.Top());
#endif
}
}
void clMainFrame::CreateNativeToolbar16()
{
//----------------------------------------------
// create the standard toolbar
//----------------------------------------------
wxToolBar* tb = new wxToolBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTB_FLAT | wxTB_NODIVIDER);
BitmapLoader& bmpLoader = *(PluginManager::Get()->GetStdIcons());
tb->SetToolBitmapSize(wxSize(16, 16));
tb->AddTool(XRCID("new_file"), _("New"), bmpLoader.LoadBitmap(wxT("toolbars/16/standard/file_new")), _("New File"));
tb->AddTool(
XRCID("open_file"), _("Open"), bmpLoader.LoadBitmap(wxT("toolbars/16/standard/file_open")), _("Open File"));
tb->AddTool(XRCID("refresh_file"),
_("Reload"),
bmpLoader.LoadBitmap(wxT("toolbars/16/standard/file_reload")),
_("Reload File"));
TB_SEPARATOR();
tb->AddTool(XRCID("save_file"), _("Save"), bmpLoader.LoadBitmap(wxT("toolbars/16/standard/file_save")), _("Save"));
tb->AddTool(XRCID("save_all"),
_("Save All"),
bmpLoader.LoadBitmap(wxT("toolbars/16/standard/file_save_all")),
_("Save All"));
TB_SEPARATOR();
tb->AddTool(
XRCID("close_file"), _("Close"), bmpLoader.LoadBitmap(wxT("toolbars/16/standard/file_close")), _("Close File"));
TB_SEPARATOR();
tb->AddTool(wxID_CUT, _("Cut"), bmpLoader.LoadBitmap(wxT("toolbars/16/standard/cut")), _("Cut"));
tb->AddTool(wxID_COPY, _("Copy"), bmpLoader.LoadBitmap(wxT("toolbars/16/standard/copy")), _("Copy"));
tb->AddTool(wxID_PASTE, _("Paste"), bmpLoader.LoadBitmap(wxT("toolbars/16/standard/paste")), _("Paste"));
TB_SEPARATOR();
tb->AddTool(
wxID_UNDO, _("Undo"), bmpLoader.LoadBitmap(wxT("toolbars/16/standard/undo")), _("Undo"), wxITEM_DROPDOWN);
tb->AddTool(
wxID_REDO, _("Redo"), bmpLoader.LoadBitmap(wxT("toolbars/16/standard/redo")), _("Redo"), wxITEM_DROPDOWN);
tb->AddTool(wxID_BACKWARD, _("Backward"), bmpLoader.LoadBitmap(wxT("toolbars/16/standard/back")), _("Backward"));
tb->AddTool(wxID_FORWARD, _("Forward"), bmpLoader.LoadBitmap(wxT("toolbars/16/standard/forward")), _("Forward"));
TB_SEPARATOR();
tb->AddTool(XRCID("toggle_bookmark"),
_("Toggle Bookmark"),
bmpLoader.LoadBitmap(wxT("toolbars/16/standard/bookmark")),
_("Toggle Bookmark"),
wxITEM_DROPDOWN);
tb->SetDropdownMenu(XRCID("toggle_bookmark"), BookmarkManager::Get().CreateBookmarksSubmenu(NULL));
//----------------------------------------------
// create the search toolbar
//----------------------------------------------
TB_SEPARATOR();
tb->AddTool(wxID_FIND, _("Find"), bmpLoader.LoadBitmap(wxT("toolbars/16/search/find")), _("Find"));
tb->AddTool(
wxID_REPLACE, _("Replace"), bmpLoader.LoadBitmap(wxT("toolbars/16/search/find_and_replace")), _("Replace"));
tb->AddTool(XRCID("find_in_files"),
_("Find In Files"),
bmpLoader.LoadBitmap(wxT("toolbars/16/search/find_in_files")),
_("Find In Files"));
TB_SEPARATOR();
tb->AddTool(XRCID("find_resource"),
_("Find Resource In Workspace"),
bmpLoader.LoadBitmap(wxT("toolbars/16/search/open_resource")),
_("Find Resource In Workspace"));
TB_SEPARATOR();
tb->AddTool(XRCID("highlight_word"),
_("Highlight Word"),
bmpLoader.LoadBitmap(wxT("toolbars/16/search/mark_word")),
_("Highlight Matching Words"),
wxITEM_CHECK);
tb->ToggleTool(XRCID("highlight_word"), m_highlightWord);
TB_SEPARATOR();
//----------------------------------------------
// create the build toolbar
//----------------------------------------------
tb->AddTool(XRCID("build_active_project"),
wxEmptyString,
bmpLoader.LoadBitmap(wxT("toolbars/16/build/build")),
_("Build Active Project"),
wxITEM_DROPDOWN);
tb->AddTool(XRCID("stop_active_project_build"),
wxEmptyString,
bmpLoader.LoadBitmap(wxT("toolbars/16/build/stop")),
_("Stop Current Build"));
tb->AddTool(XRCID("clean_active_project"),
wxEmptyString,
bmpLoader.LoadBitmap(wxT("toolbars/16/build/clean")),
_("Clean Active Project"));
TB_SEPARATOR();
tb->AddTool(XRCID("execute_no_debug"),
wxEmptyString,
bmpLoader.LoadBitmap(wxT("toolbars/16/build/execute")),
_("Run Active Project"));
tb->AddTool(XRCID("stop_executed_program"),
wxEmptyString,
bmpLoader.LoadBitmap(wxT("toolbars/16/build/execute_stop")),
_("Stop Running Program"));
TB_SEPARATOR();
//----------------------------------------------
// create the debugger toolbar
//----------------------------------------------
tb->AddTool(XRCID("start_debugger"),
_("Start or Continue debugger"),
bmpLoader.LoadBitmap(wxT("toolbars/16/debugger/start")),
_("Start or Continue debugger"));
tb->AddTool(XRCID("stop_debugger"),
_("Stop debugger"),
bmpLoader.LoadBitmap(wxT("toolbars/16/debugger/stop")),
_("Stop debugger"));
tb->AddTool(XRCID("pause_debugger"),
_("Pause debugger"),
bmpLoader.LoadBitmap(wxT("toolbars/16/debugger/interrupt")),
_("Pause debugger"));
tb->AddTool(XRCID("restart_debugger"),
_("Restart debugger"),
bmpLoader.LoadBitmap(wxT("toolbars/16/debugger/restart")),
_("Restart debugger"));
TB_SEPARATOR();
tb->AddTool(XRCID("show_cursor"),
_("Show Current Line"),
bmpLoader.LoadBitmap(wxT("toolbars/16/debugger/show_current_line")),
_("Show Current Line"));
TB_SEPARATOR();
tb->AddTool(
XRCID("dbg_stepin"), _("Step Into"), bmpLoader.LoadBitmap(wxT("toolbars/16/debugger/step_in")), _("Step In"));
tb->AddTool(XRCID("dbg_next"), _("Next"), bmpLoader.LoadBitmap(wxT("toolbars/16/debugger/next")), _("Next"));
tb->AddTool(XRCID("dbg_nexti"),
_("Next Instruction"),
bmpLoader.LoadBitmap(wxT("toolbars/16/debugger/nexti")),
_("Next Instruction"));
tb->AddTool(
XRCID("dbg_stepout"), _("Step Out"), bmpLoader.LoadBitmap(wxT("toolbars/16/debugger/step_out")), _("Step Out"));
SetToolBar(tb);
tb->Realize();
}
void clMainFrame::CreateNativeToolbar24()
{
//----------------------------------------------
// create the standard toolbar
//----------------------------------------------
wxToolBar* tb =
new wxToolBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTB_FLAT | wxTB_NODIVIDER | wxTB_HORIZONTAL);
BitmapLoader& bmpLoader = *(PluginManager::Get()->GetStdIcons());
tb->SetToolBitmapSize(wxSize(24, 24));
tb->AddTool(XRCID("new_file"), _("New"), bmpLoader.LoadBitmap(wxT("toolbars/24/standard/file_new")), _("New File"));
tb->AddTool(
XRCID("open_file"), _("Open"), bmpLoader.LoadBitmap(wxT("toolbars/24/standard/file_open")), _("Open File"));
tb->AddTool(XRCID("refresh_file"),
_("Reload"),
bmpLoader.LoadBitmap(wxT("toolbars/24/standard/file_reload")),
_("Reload File"));
TB_SEPARATOR();
tb->AddTool(XRCID("save_file"), _("Save"), bmpLoader.LoadBitmap(wxT("toolbars/24/standard/file_save")), _("Save"));
tb->AddTool(XRCID("save_all"),
_("Save All"),
bmpLoader.LoadBitmap(wxT("toolbars/24/standard/file_save_all")),
_("Save All"));
TB_SEPARATOR();
tb->AddTool(
XRCID("close_file"), _("Close"), bmpLoader.LoadBitmap(wxT("toolbars/24/standard/file_close")), _("Close File"));
TB_SEPARATOR();
tb->AddTool(wxID_CUT, _("Cut"), bmpLoader.LoadBitmap(wxT("toolbars/24/standard/cut")), _("Cut"));
tb->AddTool(wxID_COPY, _("Copy"), bmpLoader.LoadBitmap(wxT("toolbars/24/standard/copy")), _("Copy"));
tb->AddTool(wxID_PASTE, _("Paste"), bmpLoader.LoadBitmap(wxT("toolbars/24/standard/paste")), _("Paste"));
TB_SEPARATOR();
tb->AddTool(
wxID_UNDO, _("Undo"), bmpLoader.LoadBitmap(wxT("toolbars/24/standard/undo")), _("Undo"), wxITEM_DROPDOWN);
tb->AddTool(
wxID_REDO, _("Redo"), bmpLoader.LoadBitmap(wxT("toolbars/24/standard/redo")), _("Redo"), wxITEM_DROPDOWN);
tb->AddTool(wxID_BACKWARD, _("Backward"), bmpLoader.LoadBitmap(wxT("toolbars/24/standard/back")), _("Backward"));
tb->AddTool(wxID_FORWARD, _("Forward"), bmpLoader.LoadBitmap(wxT("toolbars/24/standard/forward")), _("Forward"));
TB_SEPARATOR();
tb->AddTool(XRCID("toggle_bookmark"),
_("Toggle Bookmark"),
bmpLoader.LoadBitmap(wxT("toolbars/24/standard/bookmark")),
_("Toggle Bookmark"),
wxITEM_DROPDOWN);
tb->SetDropdownMenu(XRCID("toggle_bookmark"), BookmarkManager::Get().CreateBookmarksSubmenu(NULL));
//----------------------------------------------
// create the search toolbar
//----------------------------------------------
TB_SEPARATOR();
tb->AddTool(wxID_FIND, _("Find"), bmpLoader.LoadBitmap(wxT("toolbars/24/search/find")), _("Find"));
tb->AddTool(
wxID_REPLACE, _("Replace"), bmpLoader.LoadBitmap(wxT("toolbars/24/search/find_and_replace")), _("Replace"));
tb->AddTool(XRCID("find_in_files"),
_("Find In Files"),
bmpLoader.LoadBitmap(wxT("toolbars/24/search/find_in_files")),
_("Find In Files"));
TB_SEPARATOR();
tb->AddTool(XRCID("find_resource"),
_("Find Resource In Workspace"),
bmpLoader.LoadBitmap(wxT("toolbars/24/search/open_resource")),
_("Find Resource In Workspace"));
TB_SEPARATOR();
tb->AddTool(XRCID("highlight_word"),
_("Highlight Word"),
bmpLoader.LoadBitmap(wxT("toolbars/24/search/mark_word")),
_("Highlight Matching Words"),
wxITEM_CHECK);
tb->ToggleTool(XRCID("highlight_word"), m_highlightWord);
TB_SEPARATOR();
//----------------------------------------------
// create the build toolbar
//----------------------------------------------
tb->AddTool(XRCID("build_active_project"),
wxEmptyString,
bmpLoader.LoadBitmap(wxT("toolbars/24/build/build")),
_("Build Active Project"),
wxITEM_DROPDOWN);
tb->AddTool(XRCID("stop_active_project_build"),
wxEmptyString,
bmpLoader.LoadBitmap(wxT("toolbars/24/build/stop")),
_("Stop Current Build"));
tb->AddTool(XRCID("clean_active_project"),
wxEmptyString,
bmpLoader.LoadBitmap(wxT("toolbars/24/build/clean")),
_("Clean Active Project"));
TB_SEPARATOR();
tb->AddTool(XRCID("execute_no_debug"),
wxEmptyString,
bmpLoader.LoadBitmap(wxT("toolbars/24/build/execute")),
_("Run Active Project"));
tb->AddTool(XRCID("stop_executed_program"),
wxEmptyString,
bmpLoader.LoadBitmap(wxT("toolbars/24/build/execute_stop")),
_("Stop Running Program"));
TB_SEPARATOR();
//----------------------------------------------
// create the debugger toolbar
//----------------------------------------------
tb->AddTool(XRCID("start_debugger"),
_("Start or Continue debugger"),
bmpLoader.LoadBitmap(wxT("toolbars/24/debugger/start")),
_("Start or Continue debugger"));
tb->AddTool(XRCID("stop_debugger"),
_("Stop debugger"),
bmpLoader.LoadBitmap(wxT("toolbars/24/debugger/stop")),
_("Stop debugger"));
tb->AddTool(XRCID("pause_debugger"),
_("Pause debugger"),
bmpLoader.LoadBitmap(wxT("toolbars/24/debugger/interrupt")),
_("Pause debugger"));
tb->AddTool(XRCID("restart_debugger"),
_("Restart debugger"),
bmpLoader.LoadBitmap(wxT("toolbars/24/debugger/restart")),
_("Restart debugger"));
TB_SEPARATOR();
tb->AddTool(XRCID("show_cursor"),
_("Show Current Line"),
bmpLoader.LoadBitmap(wxT("toolbars/24/debugger/show_current_line")),
_("Show Current Line"));
TB_SEPARATOR();
tb->AddTool(
XRCID("dbg_stepin"), _("Step Into"), bmpLoader.LoadBitmap(wxT("toolbars/24/debugger/step_in")), _("Step In"));
tb->AddTool(XRCID("dbg_next"), _("Next"), bmpLoader.LoadBitmap(wxT("toolbars/24/debugger/next")), _("Next"));
tb->AddTool(XRCID("dbg_nexti"),
_("Next Instruction"),
bmpLoader.LoadBitmap(wxT("toolbars/24/debugger/nexti")),
_("Next Instruction"));
tb->AddTool(
XRCID("dbg_stepout"), _("Step Out"), bmpLoader.LoadBitmap(wxT("toolbars/24/debugger/step_out")), _("Step Out"));
SetToolBar(tb);
tb->Realize();
}
void clMainFrame::CreateToolbars16()
{
//----------------------------------------------
// create the standard toolbar
//----------------------------------------------
#if !USE_AUI_TOOLBAR
wxWindow* toolbar_parent(this);
if(PluginManager::Get()->AllowToolbar()) {
toolbar_parent = this;
}
#else
wxWindow* toolbar_parent(this);
#endif
clToolBar* tb = new clToolBar(toolbar_parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, clTB_DEFAULT_STYLE);
#if USE_AUI_TOOLBAR
tb->SetArtProvider(new CLMainAuiTBArt());
#endif
wxAuiPaneInfo info;
BitmapLoader& bmpLoader = *(PluginManager::Get()->GetStdIcons());
tb->SetToolBitmapSize(wxSize(16, 16));
tb->AddTool(XRCID("new_file"), _("New"), bmpLoader.LoadBitmap(wxT("toolbars/16/standard/file_new")), _("New File"));
tb->AddTool(
XRCID("open_file"), _("Open"), bmpLoader.LoadBitmap(wxT("toolbars/16/standard/file_open")), _("Open File"));
tb->AddTool(XRCID("refresh_file"),
_("Reload"),
bmpLoader.LoadBitmap(wxT("toolbars/16/standard/file_reload")),
_("Reload File"));
TB_SEPARATOR();
tb->AddTool(XRCID("save_file"), _("Save"), bmpLoader.LoadBitmap(wxT("toolbars/16/standard/file_save")), _("Save"));
tb->AddTool(XRCID("save_all"),
_("Save All"),
bmpLoader.LoadBitmap(wxT("toolbars/16/standard/file_save_all")),
_("Save All"));
TB_SEPARATOR();
tb->AddTool(
XRCID("close_file"), _("Close"), bmpLoader.LoadBitmap(wxT("toolbars/16/standard/file_close")), _("Close File"));
TB_SEPARATOR();
tb->AddTool(wxID_CUT, _("Cut"), bmpLoader.LoadBitmap(wxT("toolbars/16/standard/cut")), _("Cut"));
tb->AddTool(wxID_COPY, _("Copy"), bmpLoader.LoadBitmap(wxT("toolbars/16/standard/copy")), _("Copy"));
tb->AddTool(wxID_PASTE, _("Paste"), bmpLoader.LoadBitmap(wxT("toolbars/16/standard/paste")), _("Paste"));
TB_SEPARATOR();
tb->AddTool(wxID_UNDO, _("Undo"), bmpLoader.LoadBitmap(wxT("toolbars/16/standard/undo")), _("Undo"));
tb->SetToolDropDown(wxID_UNDO, true);
tb->AddTool(wxID_REDO, _("Redo"), bmpLoader.LoadBitmap(wxT("toolbars/16/standard/redo")), _("Redo"));
tb->SetToolDropDown(wxID_REDO, true);
tb->AddTool(wxID_BACKWARD, _("Backward"), bmpLoader.LoadBitmap(wxT("toolbars/16/standard/back")), _("Backward"));
tb->AddTool(wxID_FORWARD, _("Forward"), bmpLoader.LoadBitmap(wxT("toolbars/16/standard/forward")), _("Forward"));
TB_SEPARATOR();
tb->AddTool(XRCID("toggle_bookmark"),
_("Toggle Bookmark"),
bmpLoader.LoadBitmap(wxT("toolbars/16/standard/bookmark")),
_("Toggle Bookmark"));
tb->SetToolDropDown(XRCID("toggle_bookmark"), true);
if(PluginManager::Get()->AllowToolbar()) {
tb->Realize();
m_mgr.AddPane(tb,
wxAuiPaneInfo()
.Name(wxT("Standard Toolbar"))
.LeftDockable(true)
.RightDockable(true)
.Caption(_("Standard"))
.ToolbarPane()
.Top());
}
//----------------------------------------------
// create the search toolbar
//----------------------------------------------
info = wxAuiPaneInfo();
if(PluginManager::Get()->AllowToolbar()) {
tb = new clToolBar(toolbar_parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, clTB_DEFAULT_STYLE);
#if USE_AUI_TOOLBAR
tb->SetArtProvider(new CLMainAuiTBArt());
#endif
tb->SetToolBitmapSize(wxSize(16, 16));
}
tb->AddTool(wxID_FIND, _("Find"), bmpLoader.LoadBitmap(wxT("toolbars/16/search/find")), _("Find"));
tb->AddTool(
wxID_REPLACE, _("Replace"), bmpLoader.LoadBitmap(wxT("toolbars/16/search/find_and_replace")), _("Replace"));
tb->AddTool(XRCID("find_in_files"),
_("Find In Files"),
bmpLoader.LoadBitmap(wxT("toolbars/16/search/find_in_files")),
_("Find In Files"));
TB_SEPARATOR();
tb->AddTool(XRCID("find_resource"),
_("Find Resource In Workspace"),
bmpLoader.LoadBitmap(wxT("toolbars/16/search/open_resource")),
_("Find Resource In Workspace"));
TB_SEPARATOR();
tb->AddTool(XRCID("highlight_word"),
_("Highlight Word"),
bmpLoader.LoadBitmap(wxT("toolbars/16/search/mark_word")),
_("Highlight Matching Words"),
wxITEM_CHECK);
tb->ToggleTool(XRCID("highlight_word"), m_highlightWord);
TB_SEPARATOR();
if(PluginManager::Get()->AllowToolbar()) {
tb->Realize();
m_mgr.AddPane(tb,
info.Name(wxT("Search Toolbar"))
.LeftDockable(true)
.RightDockable(true)
.Caption(_("Search"))
.ToolbarPane()
.Top());
//----------------------------------------------
// create the build toolbar
//----------------------------------------------
tb = new clToolBar(toolbar_parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, clTB_DEFAULT_STYLE);
#if USE_AUI_TOOLBAR
tb->SetArtProvider(new CLMainAuiTBArt());
#endif
tb->SetToolBitmapSize(wxSize(16, 16));
}
tb->AddTool(XRCID("build_active_project"),
wxEmptyString,
bmpLoader.LoadBitmap(wxT("toolbars/16/build/build")),
_("Build Active Project"));
tb->SetToolDropDown(XRCID("build_active_project"), true);
tb->AddTool(XRCID("stop_active_project_build"),
wxEmptyString,
bmpLoader.LoadBitmap(wxT("toolbars/16/build/stop")),
_("Stop Current Build"));
tb->AddTool(XRCID("clean_active_project"),
wxEmptyString,
bmpLoader.LoadBitmap(wxT("toolbars/16/build/clean")),
_("Clean Active Project"));
TB_SEPARATOR();
tb->AddTool(XRCID("execute_no_debug"),
wxEmptyString,
bmpLoader.LoadBitmap(wxT("toolbars/16/build/execute")),
_("Run Active Project"));
tb->AddTool(XRCID("stop_executed_program"),
wxEmptyString,
bmpLoader.LoadBitmap(wxT("toolbars/16/build/execute_stop")),
_("Stop Running Program"));
if(PluginManager::Get()->AllowToolbar()) {
tb->Realize();
info = wxAuiPaneInfo();
m_mgr.AddPane(tb,
info.Name(wxT("Build Toolbar"))
.LeftDockable(true)
.RightDockable(true)
.Caption(_("Build"))
.ToolbarPane()
.Top());
}
//----------------------------------------------
// create the debugger toolbar
//----------------------------------------------
if(PluginManager::Get()->AllowToolbar()) {
tb = new clToolBar(toolbar_parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, clTB_DEFAULT_STYLE);
#if USE_AUI_TOOLBAR
tb->SetArtProvider(new CLMainAuiTBArt());
#endif
tb->SetToolBitmapSize(wxSize(16, 16));
}
tb->AddTool(XRCID("start_debugger"),
_("Start / Continue debugger"),
bmpLoader.LoadBitmap(wxT("toolbars/16/debugger/start")),
_("Start / Continue debugger"));
tb->AddTool(XRCID("stop_debugger"),
_("Stop debugger"),
bmpLoader.LoadBitmap(wxT("toolbars/16/debugger/stop")),
_("Stop debugger"));
tb->AddTool(XRCID("pause_debugger"),
_("Pause debugger"),
bmpLoader.LoadBitmap(wxT("toolbars/16/debugger/interrupt")),
_("Pause debugger"));
tb->AddTool(XRCID("restart_debugger"),
_("Restart debugger"),
bmpLoader.LoadBitmap(wxT("toolbars/16/debugger/restart")),
_("Restart debugger"));
TB_SEPARATOR();
tb->AddTool(XRCID("show_cursor"),
_("Show Current Line"),
bmpLoader.LoadBitmap(wxT("toolbars/16/debugger/show_current_line")),
_("Show Current Line"));
TB_SEPARATOR();
tb->AddTool(
XRCID("dbg_stepin"), _("Step Into"), bmpLoader.LoadBitmap(wxT("toolbars/16/debugger/step_in")), _("Step In"));
tb->AddTool(XRCID("dbg_next"), _("Next"), bmpLoader.LoadBitmap(wxT("toolbars/16/debugger/next")), _("Next"));
tb->AddTool(XRCID("dbg_nexti"),
_("Next Instruction"),
bmpLoader.LoadBitmap(wxT("toolbars/16/debugger/nexti")),
_("Next Instruction"));
tb->AddTool(
XRCID("dbg_stepout"), _("Step Out"), bmpLoader.LoadBitmap(wxT("toolbars/16/debugger/step_out")), _("Step Out"));
tb->Realize();
if(PluginManager::Get()->AllowToolbar()) {
info = wxAuiPaneInfo();
m_mgr.AddPane(tb,
info.Name(wxT("Debugger Toolbar"))
.LeftDockable(true)
.RightDockable(true)
.Caption(_("Debug"))
.ToolbarPane()
.Top());
RegisterToolbar(XRCID("show_std_toolbar"), wxT("Standard Toolbar"));
RegisterToolbar(XRCID("show_search_toolbar"), wxT("Search Toolbar"));
RegisterToolbar(XRCID("show_build_toolbar"), wxT("Build Toolbar"));
RegisterToolbar(XRCID("show_debug_toolbar"), wxT("Debugger Toolbar"));
} else {
#if !USE_AUI_TOOLBAR
SetToolBar(tb);
#else
m_mgr.AddPane(tb,
info.Name(wxT("Main Toolbar"))
.LeftDockable(true)
.RightDockable(true)
.Caption(_("Main Toolbar"))
.ToolbarPane()
.Top());
#endif
}
}
void clMainFrame::LocateCompilersIfNeeded()
{
bool bAutoDetectCompilers = clConfig::Get().Read("AutoDetectCompilerOnStartup", true);
if(bAutoDetectCompilers) {
// Unset the flag so next time we won't get this
clConfig::Get().Write("AutoDetectCompilerOnStartup", false);
// First time, trigger the auto-compiler detection code
CompilersDetectorManager detector;
if(detector.Locate()) {
const ICompilerLocator::CompilerVec_t& compilersFound = detector.GetCompilersFound();
CompilersFoundDlg dlg(this, compilersFound);
if(dlg.ShowModal() == wxID_OK) {
// Replace the current compilers with a new one
BuildSettingsConfigST::Get()->SetCompilers(compilersFound);
CallAfter(&clMainFrame::UpdateParserSearchPathsFromDefaultCompiler);
}
}
}
}
void clMainFrame::UpdateBuildTools() {}
void clMainFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) { Close(); }
void clMainFrame::OnTBUnRedo(wxAuiToolBarEvent& event)
{
if(event.IsDropDownClicked()) {
LEditor* editor = GetMainBook()->GetActiveEditor(true);
if(editor) {
editor->GetCommandsProcessor().ProcessEvent(event);
} else if(GetMainBook()->GetCurrentPage()) {
event.StopPropagation(); // Otherwise we'll infinitely loop if the active page doesn't handle this event
GetMainBook()->GetCurrentPage()->GetEventHandler()->ProcessEvent(event); // Let the active plugin have a go
}
}
else {
DispatchCommandEvent(event); // Revert to standard processing
}
}
//----------------------------------------------------
// Helper method for the event handling
//----------------------------------------------------
bool clMainFrame::IsEditorEvent(wxEvent& event)
{
#ifdef __WXGTK__
MainBook* mainBook = GetMainBook();
if(!mainBook || !mainBook->GetActiveEditor(true)) {
if(event.GetId() == wxID_FIND)
return true;
else
return false;
}
switch(event.GetId()) {
case wxID_CUT:
case wxID_SELECTALL:
case wxID_COPY:
case wxID_PASTE:
case wxID_UNDO:
case wxID_REDO: {
bool isFocused;
LEditor* editor = dynamic_cast<LEditor*>(event.GetEventObject());
if(editor) {
isFocused = true;
} else {
isFocused = mainBook->GetActiveEditor(true)->IsFocused();
}
return isFocused;
}
default:
break;
}
#else
// Handle common edit events
// if the focused window is *not* LEditor,
// and the focused windows is of type
// wxTextCtrl or wxScintilla, let the focused
// Window handle the event
wxWindow* focusWin = wxWindow::FindFocus();
if(focusWin) {
switch(event.GetId()) {
case wxID_CUT:
case wxID_SELECTALL:
case wxID_COPY:
case wxID_PASTE:
case wxID_UNDO:
case wxID_REDO: {
LEditor* ed = dynamic_cast<LEditor*>(focusWin);
if(!ed) {
// let other controls handle it
return false;
}
break;
}
default:
break;
}
}
#endif
return true;
}
void clMainFrame::DispatchCommandEvent(wxCommandEvent& event)
{
if(!IsEditorEvent(event)) {
event.Skip();
return;
}
// Do the default and pass this event to the Editor
LEditor* editor = GetMainBook()->GetActiveEditor(true);
if(!editor && event.GetId() != wxID_FIND) {
return;
}
if(event.GetId() >= viewAsMenuItemID && event.GetId() <= viewAsMenuItemMaxID) {
// keep the old id as int and override the value set in the event object
// to trick the event system
event.SetInt(event.GetId());
event.SetId(viewAsMenuItemID);
}
editor->OnMenuCommand(event);
}
void clMainFrame::DispatchUpdateUIEvent(wxUpdateUIEvent& event)
{
CHECK_SHUTDOWN();
if(!IsEditorEvent(event)) {
event.Skip();
return;
}
LEditor* editor = GetMainBook()->GetActiveEditor(true);
if(!editor) {
event.Enable(false);
return;
}
if(event.GetId() >= viewAsMenuItemID && event.GetId() <= viewAsMenuItemMaxID) {
// keep the old id as int and override the value set in the event object
// to trick the event system
event.SetInt(event.GetId());
event.SetId(viewAsMenuItemID);
}
editor->OnUpdateUI(event);
}
void clMainFrame::OnFileExistUpdateUI(wxUpdateUIEvent& event)
{
CHECK_SHUTDOWN();
LEditor* editor = GetMainBook()->GetActiveEditor(true);
if(!editor) {
event.Enable(false);
} else {
event.Enable(true);
}
}
void clMainFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
wxString mainTitle;
mainTitle = CODELITE_VERSION_STR;
AboutDlg dlg(this, mainTitle);
dlg.SetInfo(mainTitle);
dlg.ShowModal();
}
void clMainFrame::OnClose(wxCloseEvent& event)
{
wxString msg;
bool boDoNotClose = false;
if(!boDoNotClose) {
ManagerST::Get()->SetShutdownInProgress(true);
// Stop the retag thread
ParseThreadST::Get()->Stop();
// Stop the search thread
ManagerST::Get()->KillProgram();
SearchThreadST::Get()->StopSearch();
// Stop any debugging session if any
IDebugger* debugger = DebuggerMgr::Get().GetActiveDebugger();
if(debugger && debugger->IsRunning()) ManagerST::Get()->DbgStop();
SaveLayoutAndSession();
// In case we got some data in the clipboard, flush it so it will be available
// after our process exits
wxTheClipboard->Flush();
event.Skip();
}
}
void clMainFrame::LoadSession(const wxString& sessionName)
{
SessionEntry session;
if(SessionManager::Get().GetSession(sessionName, session)) {
wxString wspFile = session.GetWorkspaceName();
if(wspFile.IsEmpty() == false && wspFile != wxT("Default")) {
// Load the workspace only if it exists
wxFileName fnWorkspace(wspFile);
if(fnWorkspace.Exists()) {
ManagerST::Get()->OpenWorkspace(wspFile);
}
} else {
// no workspace to open, so just restore any previously open editors
GetMainBook()->RestoreSession(session);
}
}
}
void clMainFrame::OnSave(wxCommandEvent& event)
{
LEditor* editor = GetMainBook()->GetActiveEditor(true);
if(editor) {
editor->SaveFile();
} else {
// delegate it to the plugins
wxCommandEvent saveEvent(XRCID("save_file"));
EventNotifier::Get()->ProcessEvent(saveEvent);
}
}
void clMainFrame::OnSaveAs(wxCommandEvent& WXUNUSED(event))
{
LEditor* editor = GetMainBook()->GetActiveEditor();
if(editor) {
editor->SaveFileAs();
}
}
void clMainFrame::OnFileLoadTabGroup(wxCommandEvent& WXUNUSED(event))
{
wxArrayString previousgroups;
EditorConfigST::Get()->GetRecentItems(previousgroups, wxT("RecentTabgroups"));
// Check the previous items still exist
for(int n = (int)previousgroups.GetCount() - 1; n >= 0; --n) {
if(!wxFileName::FileExists(previousgroups.Item(n))) {
previousgroups.RemoveAt(n);
}
}
EditorConfigST::Get()->SetRecentItems(previousgroups, wxT("RecentTabgroups")); // In case any were deleted
wxString path =
ManagerST::Get()->IsWorkspaceOpen() ? WorkspaceST::Get()->GetWorkspaceFileName().GetPath() : wxGetHomeDir();
LoadTabGroupDlg dlg(this, path, previousgroups);
// Disable the 'Replace' checkbox if there aren't any editors to replace
std::vector<LEditor*> editors;
GetMainBook()->GetAllEditors(editors, MainBook::kGetAll_Default);
dlg.EnableReplaceCheck(editors.size());
if(dlg.ShowModal() != wxID_OK) {
return;
}
wxString filepath = dlg.GetListBox()->GetStringSelection();
wxString sessionFilepath = filepath.BeforeLast(wxT('.'));
clWindowUpdateLocker locker(this);
TabGroupEntry session;
if(SessionManager::Get().GetSession(sessionFilepath, session, wxString(wxT(".tabgroup")), tabgroupTag)) {
// We've 'loaded' the requested tabs. If required, delete any current ones
if(dlg.GetReplaceCheck()) {
GetMainBook()->CloseAll(true);
}
GetMainBook()->RestoreSession(session);
// Remove any previous instance of this group from the history, then prepend it and save
int index = previousgroups.Index(filepath);
if(index != wxNOT_FOUND) {
previousgroups.RemoveAt(index);
}
previousgroups.Insert(filepath, 0);
EditorConfigST::Get()->SetRecentItems(previousgroups, wxT("RecentTabgroups"));
}
}
void clMainFrame::OnFileReload(wxCommandEvent& event)
{
wxUnusedVar(event);
LEditor* editor = GetMainBook()->GetActiveEditor(true);
if(editor) {
if(editor->GetModify()) {
// Ask user if he really wants to lose all changes
wxString msg;
msg << _("The file") << wxT(" '") << editor->GetFileName().GetFullName() << wxT(" '")
<< _("has been altered.") << wxT("\n");
msg << _("Are you sure you want to lose all changes?");
if(wxMessageBox(msg, _("Confirm"), wxYES_NO, ::wxGetTopLevelParent(editor)) != wxYES) {
return;
}
}
editor->ReloadFile();
}
}
void clMainFrame::OnCloseWorkspace(wxCommandEvent& event)
{
wxUnusedVar(event);
// let the plugins close any custom workspace
clCommandEvent e(wxEVT_CMD_CLOSE_WORKSPACE, GetId());
e.SetEventObject(this);
EventNotifier::Get()->ProcessEvent(e);
// In any case, make sure that we dont have a workspace opened
if(ManagerST::Get()->IsWorkspaceOpen()) {
ManagerST::Get()->CloseWorkspace();
}
ShowWelcomePage();
}
void clMainFrame::OnSwitchWorkspace(wxCommandEvent& event)
{
wxUnusedVar(event);
bool promptUser = true;
wxString wspFile;
const wxString WSP_EXT = "workspace";
// Is it an internal command? (usually the workspace file name to load is set in the
// event.SetString() )
if(event.GetString().IsEmpty() || wxFileName(event.GetString()).GetExt() != WSP_EXT) {
clCommandEvent e(wxEVT_CMD_OPEN_WORKSPACE, GetId());
e.SetEventObject(this);
e.SetFileName(event.GetString());
if(EventNotifier::Get()->ProcessEvent(e)) {
// the plugin processed it by itself
return;
}
if(e.GetFileName().IsEmpty() == false) {
// the plugin processed it by itself and the user already selected a file
// don't bother to prompt the user again just use what he already selected
promptUser = false;
wspFile = e.GetFileName();
}
} else if(!event.GetString().IsEmpty()) {
promptUser = false;
wspFile = event.GetString();
}
if(promptUser) {
// now it is time to prompt user for new workspace to open
const wxString ALL(wxT("CodeLite Workspace files (*.workspace)|*.workspace|") wxT("All Files (*)|*"));
wxFileDialog dlg(this,
_("Open Workspace"),
wxEmptyString,
wxEmptyString,
ALL,
wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE,
wxDefaultPosition);
if(dlg.ShowModal() == wxID_OK) {
wspFile = dlg.GetPath();
}
}
if(!wspFile.IsEmpty()) {
// Make sure that the 'Workspace' tab is visible
wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, XRCID("show_workspace_tab"));
event.SetEventObject(this);
event.SetInt(1);
GetEventHandler()->ProcessEvent(event);
// Open the workspace
ManagerST::Get()->OpenWorkspace(wspFile);
}
}
void clMainFrame::OnCompleteWordRefreshList(wxCommandEvent& event)
{
wxUnusedVar(event);
LEditor* editor = GetMainBook()->GetActiveEditor(true);
if(editor) {
editor->CompleteWord(true);
}
}
void clMainFrame::OnCompleteWord(wxCommandEvent& event)
{
wxUnusedVar(event);
LEditor* editor = GetMainBook()->GetActiveEditor(true);
if(editor) {
editor->CompleteWord();
}
}
void clMainFrame::OnFunctionCalltip(wxCommandEvent& event)
{
wxUnusedVar(event);
LEditor* editor = GetMainBook()->GetActiveEditor(true);
if(editor) {
editor->ShowFunctionTipFromCurrentPos();
}
}
// Open new file
void clMainFrame::OnFileNew(wxCommandEvent& event)
{
wxUnusedVar(event);
GetMainBook()->NewEditor();
}
void clMainFrame::OnFileOpen(wxCommandEvent& WXUNUSED(event))
{
const wxString ALL(wxT("All Files (*)|*"));
// Open a file using the current editor's path
LEditor* editor = GetMainBook()->GetActiveEditor();
wxString open_path;
if(editor) {
open_path = editor->GetFileName().GetPath();
} else {
// Could not locate the active editor, use the project
ProjectPtr project = ManagerST::Get()->GetProject(ManagerST::Get()->GetActiveProjectName());
if(project) {
open_path = project->GetFileName().GetPath();
}
}
wxFileDialog* dlg = new wxFileDialog(this,
_("Open File"),
open_path,
wxEmptyString,
ALL,
wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE,
wxDefaultPosition);
if(dlg->ShowModal() == wxID_OK) {
wxArrayString paths;
dlg->GetPaths(paths);
for(size_t i = 0; i < paths.GetCount(); i++) {
GetMainBook()->OpenFile(paths.Item(i));
}
}
dlg->Destroy();
}
void clMainFrame::OnFileClose(wxCommandEvent& event)
{
wxUnusedVar(event);
if(GetMainBook()->GetCurrentPage()) {
wxWindow* winToClose = GetMainBook()->GetCurrentPage();
GetMainBook()->CallAfter(&MainBook::ClosePageVoid, winToClose);
}
}
void clMainFrame::OnFileSaveAll(wxCommandEvent& event)
{
wxUnusedVar(event);
GetMainBook()->SaveAll(false, true);
}
void clMainFrame::OnFileSaveTabGroup(wxCommandEvent& WXUNUSED(event))
{
wxArrayString previousgroups;
EditorConfigST::Get()->GetRecentItems(previousgroups, wxT("RecentTabgroups"));
SaveTabGroupDlg dlg(this, previousgroups);
std::vector<LEditor*> editors;
wxArrayString filepaths;
GetMainBook()->GetAllEditors(
editors, MainBook::kGetAll_RetainOrder | MainBook::kGetAll_IncludeDetached); // We'll want the order of intArr
// to match the order in
// MainBook::SaveSession
for(size_t i = 0; i < editors.size(); ++i) {
filepaths.Add(editors[i]->GetFileName().GetFullPath());
}
dlg.SetListTabs(filepaths);
while(true) {
if(dlg.ShowModal() != wxID_OK) {
return;
}
wxString sessionName = dlg.GetTabgroupName();
if(sessionName.IsEmpty()) {
if(wxMessageBox(
_("Please enter a name for the tab group"), _("CodeLite"), wxICON_ERROR | wxOK | wxCANCEL, this) !=
wxOK) {
return;
} else {
continue;
}
}
wxString path = TabGroupsManager::Get()->GetTabgroupDirectory();
if(path.Right(1) != wxFileName::GetPathSeparator()) {
path << wxFileName::GetPathSeparator();
}
wxString filepath(path + sessionName + wxT(".tabgroup"));
if(wxFileName::FileExists(filepath)) {
if(wxMessageBox(_("There is already a file with this name. Do you want to overwrite it?"),
_("Are you sure?"),
wxICON_EXCLAMATION | wxOK | wxCANCEL,
this) != wxOK) {
return;
}
}
wxArrayInt intArr;
if(dlg.GetChoices(intArr)) { // Don't bother to save if no tabs were selected
TabGroupEntry session;
session.SetTabgroupName(path + sessionName);
GetMainBook()->SaveSession(session, intArr);
SessionManager::Get().Save(session.GetTabgroupName(), session, "tabgroup", tabgroupTag);
// Add the new tabgroup to the tabgroup manager and pane
GetWorkspacePane()->GetTabgroupsTab()->AddNewTabgroupToTree(filepath);
// Remove any previous instance of this group from the history, then prepend it and save
int index = previousgroups.Index(filepath);
if(index != wxNOT_FOUND) {
previousgroups.RemoveAt(index);
}
previousgroups.Insert(filepath, 0);
EditorConfigST::Get()->SetRecentItems(previousgroups, wxT("RecentTabgroups"));
SetStatusMessage(_("Tab group saved"), 0);
}
return;
}
}
void clMainFrame::OnCompleteWordUpdateUI(wxUpdateUIEvent& event)
{
CHECK_SHUTDOWN();
LEditor* editor = GetMainBook()->GetActiveEditor(true);
// This menu item is enabled only if the current editor belongs to a project
event.Enable(editor);
}
void clMainFrame::OnWorkspaceOpen(wxUpdateUIEvent& event)
{
CHECK_SHUTDOWN();
clCommandEvent e(wxEVT_CMD_IS_WORKSPACE_OPEN, GetId());
e.SetEventObject(this);
e.SetAnswer(false);
EventNotifier::Get()->ProcessEvent(e);
event.Enable(ManagerST::Get()->IsWorkspaceOpen() || e.IsAnswer());
}
// Project->New Workspace
void clMainFrame::OnProjectNewWorkspace(wxCommandEvent& event)
{
// let the plugins handle this event first
wxCommandEvent e(wxEVT_CMD_CREATE_NEW_WORKSPACE, GetId());
e.SetEventObject(this);
if(EventNotifier::Get()->ProcessEvent(e)) return;
wxUnusedVar(event);
NewWorkspaceDlg* dlg = new NewWorkspaceDlg(this);
if(dlg->ShowModal() == wxID_OK) {
wxString fullname = dlg->GetFilePath();
wxFileName fn(fullname);
ManagerST::Get()->CreateWorkspace(fn.GetName(), fn.GetPath());
}
dlg->Destroy();
}
// Project->New Project
void clMainFrame::OnProjectNewProject(wxCommandEvent& event)
{
// Let the plugin process this request first
clNewProjectEvent newProjectEvent(wxEVT_NEW_PROJECT_WIZARD_SHOWING);
newProjectEvent.SetEventObject(this);
if(EventNotifier::Get()->ProcessEvent(newProjectEvent)) {
return;
}
wxUnusedVar(event);
NewProjectWizard wiz(this, newProjectEvent.GetTemplates());
if(wiz.RunWizard(wiz.GetFirstPage())) {
ProjectData data = wiz.GetProjectData();
// Try the plugins first
clNewProjectEvent finishEvent(wxEVT_NEW_PROJECT_WIZARD_FINISHED);
finishEvent.SetEventObject(this);
finishEvent.SetToolchain(data.m_cmpType);
finishEvent.SetDebugger(data.m_debuggerType);
finishEvent.SetProjectName(data.m_name);
finishEvent.SetProjectFolder(data.m_path);
finishEvent.SetTemplateName(data.m_sourceTemplate);
if(EventNotifier::Get()->ProcessEvent(finishEvent)) {
return;
}
// Carry on with the default behaviour
ManagerST::Get()->CreateProject(data);
}
}
void clMainFrame::OnProjectAddProject(wxCommandEvent& event)
{
wxUnusedVar(event);
// Prompt user for project path
const wxString ALL(wxT("CodeLite Projects (*.project)|*.project|") wxT("All Files (*)|*"));
wxFileDialog* dlg = new wxFileDialog(this,
_("Open Project"),
wxEmptyString,
wxEmptyString,
ALL,
wxFD_OPEN | wxFD_FILE_MUST_EXIST,
wxDefaultPosition);
if(dlg->ShowModal() == wxID_OK) {
// Open it
ManagerST::Get()->AddProject(dlg->GetPath());
}
dlg->Destroy();
}
void clMainFrame::OnReconcileProject(wxCommandEvent& event)
{
wxUnusedVar(event);
ManagerST::Get()->ReconcileProject();
}
void clMainFrame::OnCtagsOptions(wxCommandEvent& event)
{
wxUnusedVar(event);
bool colVars(false);
bool colTags(false);
bool newColVars(false);
bool newColTags(false);
bool caseSensitive(false);
size_t colourTypes(0);
colVars = (m_tagsOptionsData.GetFlags() & CC_COLOUR_VARS ? true : false);
colTags = (m_tagsOptionsData.GetFlags() & CC_COLOUR_WORKSPACE_TAGS ? true : false);
colourTypes = m_tagsOptionsData.GetCcColourFlags();
wxArrayString pathsBefore = m_tagsOptionsData.GetParserSearchPaths();
TagsOptionsDlg dlg(this, m_tagsOptionsData);
if(dlg.ShowModal() == wxID_OK) {
m_tagsOptionsData = dlg.GetData();
// We call here to ToString() only because ToString() internally
// writes the content into the ctags.replacements file (used by
// codelite_indexer)
m_tagsOptionsData.ToString();
wxArrayString pathsAfter = m_tagsOptionsData.GetParserSearchPaths();
wxArrayString removedPaths;
// Compare the paths
for(size_t i = 0; i < pathsBefore.GetCount(); i++) {
int where = pathsAfter.Index(pathsBefore.Item(i));
if(where == wxNOT_FOUND) {
removedPaths.Add(pathsBefore.Item(i));
} else {
pathsAfter.RemoveAt((size_t)where);
}
}
if(removedPaths.IsEmpty() == false) {
wxWindowDisabler disableAll;
wxBusyInfo info(_T("Updating tags database, please wait..."), this);
wxTheApp->Yield();
// Remove all tags from the database which starts with the paths which were
// removed from the parser include path
ITagsStoragePtr db = TagsManagerST::Get()->GetDatabase();
db->Begin();
for(size_t i = 0; i < removedPaths.GetCount(); i++) {
db->DeleteByFilePrefix(wxFileName(), removedPaths.Item(i));
db->DeleteFromFilesByPrefix(wxFileName(), removedPaths.Item(i));
wxTheApp->Yield();
}
db->Commit();
}
newColVars = (m_tagsOptionsData.GetFlags() & CC_COLOUR_VARS ? true : false);
newColTags = (m_tagsOptionsData.GetFlags() & CC_COLOUR_WORKSPACE_TAGS ? true : false);
caseSensitive = (m_tagsOptionsData.GetFlags() & CC_IS_CASE_SENSITIVE);
TagsManagerST::Get()->SetCtagsOptions(m_tagsOptionsData);
TagsManagerST::Get()->GetDatabase()->SetEnableCaseInsensitive(!caseSensitive);
clConfig ccConfig("code-completion.conf");
ccConfig.WriteItem(&m_tagsOptionsData);
// We use this method 'UpdateParserPaths' since it will also update the parser
// thread with any workspace search/exclude paths related
ManagerST::Get()->UpdateParserPaths();
TagsManagerST::Get()->GetDatabase()->SetMaxWorkspaceTagToColour(m_tagsOptionsData.GetMaxItemToColour());
// do we need to colourise?
if(newColTags != colTags || newColVars != colVars || colourTypes != m_tagsOptionsData.GetCcColourFlags()) {
GetMainBook()->UpdateColours();
}
if(pathsAfter.IsEmpty() == false) {
// a retagg is needed
wxCommandEvent e(wxEVT_COMMAND_MENU_SELECTED, XRCID("retag_workspace"));
AddPendingEvent(e);
}
#if HAS_LIBCLANG
// Clear clang's cache
ClangCodeCompletion::Instance()->ClearCache();
#endif
}
}
void clMainFrame::RegisterToolbar(int menuItemId, const wxString& name)
{
m_toolbars[menuItemId] = name;
Connect(menuItemId, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(clMainFrame::OnViewToolbar), NULL, this);
Connect(menuItemId, wxEVT_UPDATE_UI, wxUpdateUIEventHandler(clMainFrame::OnViewToolbarUI), NULL, this);
}
void clMainFrame::RegisterDockWindow(int menuItemId, const wxString& name)
{
m_panes[menuItemId] = name;
Connect(menuItemId, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(clMainFrame::OnViewPane), NULL, this);
Connect(menuItemId, wxEVT_UPDATE_UI, wxUpdateUIEventHandler(clMainFrame::OnViewPaneUI), NULL, this);
}
void clMainFrame::OnViewToolbar(wxCommandEvent& event)
{
std::map<int, wxString>::iterator iter = m_toolbars.find(event.GetId());
if(iter != m_toolbars.end()) {
ViewPane(iter->second, event.IsChecked());
}
}
void clMainFrame::OnViewToolbarUI(wxUpdateUIEvent& event)
{
CHECK_SHUTDOWN();
std::map<int, wxString>::iterator iter = m_toolbars.find(event.GetId());
if(iter != m_toolbars.end()) {
ViewPaneUI(iter->second, event);
}
}
void clMainFrame::OnToggleMainTBars(wxCommandEvent& event)
{
wxUnusedVar(event);
ToggleToolBars(true);
}
void clMainFrame::OnTogglePluginTBars(wxCommandEvent& event)
{
wxUnusedVar(event);
ToggleToolBars(false);
}
void clMainFrame::ToggleToolBars(bool std)
{
wxMenu* menu;
wxMenuItem* item = GetMenuBar()->FindItem(XRCID("show_std_toolbar"), &menu);
if(!item || !item->IsCheckable()) {
CL_DEBUG1(wxT("In clMainFrame::ToggleToolBars: menuitem not found"));
return;
}
if(std) {
// The standard items are the first 4
// Use the first menuitem's state to decide whether to show or hide them all
bool checked = item->IsChecked();
if(!menu || (menu->GetMenuItemCount() < 4)) {
CL_DEBUG1(wxT("In clMainFrame::ToggleToolBars: menu not found, or has too few items"));
return;
}
for(size_t n = 0; n < 4; ++n) {
wxMenuItem* item = menu->FindItemByPosition(n);
if(!item || !item->IsCheckable()) {
CL_DEBUG1(
wxT("In clMainFrame::ToggleToolBars: standard menuitem not found, or is no longer checkable :/"));
continue;
}
std::map<int, wxString>::iterator iter = m_toolbars.find(item->GetId());
if(iter != m_toolbars.end()) {
ViewPane(iter->second, !checked);
}
}
return;
}
// We don't know in advance the number of plugin toolbars, but we do know that they are at the end, following a
// separator
// So show/hide them backwards until we hit something uncheckable
size_t count = menu->GetMenuItemCount();
if(count < 8) {
CL_DEBUG1(wxT("In clMainFrame::ToggleToolBars: An implausibly small number of non-plugin menuitem found"));
return;
}
bool checked = true;
for(size_t n = count; n; --n) {
wxMenuItem* item = menu->FindItemByPosition(n - 1);
if(!item || !item->IsCheckable()) {
return;
}
// Arbitrarily use the last menuitem's state to decide whether to show or hide them all
if(n == count) {
checked = item->IsChecked();
}
std::map<int, wxString>::iterator iter = m_toolbars.find(item->GetId());
if(iter != m_toolbars.end()) {
ViewPane(iter->second, !checked);
}
}
}
void clMainFrame::OnViewPane(wxCommandEvent& event)
{
std::map<int, wxString>::iterator iter = m_panes.find(event.GetId());
if(iter != m_panes.end()) {
// In >wxGTK-2.9.4 event.GetChecked() is invalid when coming from an accelerator; instead examine the actual
// state
wxAuiPaneInfo& info = m_mgr.GetPane(iter->second);
if(info.IsOk()) {
ViewPane(iter->second, !info.IsShown());
}
}
}
void clMainFrame::OnViewPaneUI(wxUpdateUIEvent& event)
{
CHECK_SHUTDOWN();
std::map<int, wxString>::iterator iter = m_panes.find(event.GetId());
if(iter != m_panes.end()) {
ViewPaneUI(iter->second, event);
}
}
void clMainFrame::ViewPane(const wxString& paneName, bool checked)
{
wxAuiPaneInfo& info = m_mgr.GetPane(paneName);
if(info.IsOk()) {
if(checked) {
DockablePaneMenuManager::HackShowPane(info, &m_mgr);
} else {
DockablePaneMenuManager::HackHidePane(true, info, &m_mgr);
}
}
#if wxVERSION_NUMBER >= 2900
// This is needed in >=wxGTK-2.9, otherwise output pane doesn't fully expand, or on closing the auinotebook doesn't
// occupy its space
SendSizeEvent(wxSEND_EVENT_POST);
#endif
}
void clMainFrame::ViewPaneUI(const wxString& paneName, wxUpdateUIEvent& event)
{
CHECK_SHUTDOWN();
wxAuiPaneInfo& info = m_mgr.GetPane(paneName);
if(info.IsOk()) {
event.Check(info.IsShown());
}
}
void clMainFrame::OnViewOptions(wxCommandEvent& WXUNUSED(event))
{
OptionsDlg2 dlg(this);
dlg.ShowModal();
if(dlg.restartRquired) {
DoSuggestRestart();
}
}
void clMainFrame::OnTogglePanes(wxCommandEvent& event)
{
wxUnusedVar(event);
ManagerST::Get()->TogglePanes();
}
void clMainFrame::OnAddEnvironmentVariable(wxCommandEvent& event)
{
wxUnusedVar(event);
EnvVarsTableDlg dlg(this);
dlg.ShowModal();
SelectBestEnvSet();
if(ManagerST::Get()->IsWorkspaceOpen()) {
// mark all the projects as dirty
wxArrayString projects;
WorkspaceST::Get()->GetProjectList(projects);
for(size_t i = 0; i < projects.size(); i++) {
ProjectPtr proj = ManagerST::Get()->GetProject(projects.Item(i));
if(proj) {
proj->SetModified(true);
}
}
}
}
void clMainFrame::OnAdvanceSettings(wxCommandEvent& event)
{
size_t selected_page(0);
if(event.GetInt() == 1) {
selected_page = 1;
}
AdvancedDlg dlg(this, selected_page);
if(dlg.ShowModal() == wxID_OK) {
// mark the whole workspace as dirty so makefile generation will take place
// force makefile generation upon configuration change
if(ManagerST::Get()->IsWorkspaceOpen()) {
wxArrayString projs;
ManagerST::Get()->GetProjectList(projs);
for(size_t i = 0; i < projs.GetCount(); i++) {
ProjectPtr proj = ManagerST::Get()->GetProject(projs.Item(i));
if(proj) {
proj->SetModified(true);
}
}
}
}
SelectBestEnvSet();
}
void clMainFrame::OnBuildEnded(clCommandEvent& event)
{
event.Skip();
if(m_buildAndRun) {
// If the build process was part of a 'Build and Run' command, check whether an erros
// occured during build process, if non, launch the output
m_buildAndRun = false;
if(ManagerST::Get()->IsBuildEndedSuccessfully() ||
wxMessageBox(_("Build ended with errors. Continue?"), _("Confirm"), wxYES_NO | wxICON_QUESTION, this) ==
wxYES) {
ManagerST::Get()->ExecuteNoDebug(ManagerST::Get()->GetActiveProjectName());
}
}
// Process next command from the queue
ManagerST::Get()->ProcessCommandQueue();
}
// Build operations
void clMainFrame::OnBuildProject(wxCommandEvent& event)
{
wxUnusedVar(event);
bool enable = !ManagerST::Get()->IsBuildInProgress() && !ManagerST::Get()->GetActiveProjectName().IsEmpty();
if(enable) {
// Make sure that the working folder is set to the correct path
wxString workspacePath = WorkspaceST::Get()->GetWorkspaceFileName().GetPath();
::wxSetWorkingDirectory(workspacePath);
wxLogMessage("Setting working directory to: %s", workspacePath);
SetStatusMessage(_("Build starting..."), 0);
wxString conf, projectName;
projectName = ManagerST::Get()->GetActiveProjectName();
// get the selected configuration to be built
BuildConfigPtr bldConf = WorkspaceST::Get()->GetProjBuildConf(projectName, wxEmptyString);
if(bldConf) {
conf = bldConf->GetName();
}
QueueCommand info(projectName, conf, false, QueueCommand::kBuild);
if(bldConf && bldConf->IsCustomBuild()) {
info.SetKind(QueueCommand::kCustomBuild);
info.SetCustomBuildTarget(wxT("Build"));
}
ManagerST::Get()->PushQueueCommand(info);
ManagerST::Get()->ProcessCommandQueue();
SetStatusMessage(_("Done"), 0);
}
}
void clMainFrame::OnBuildCustomTarget(wxCommandEvent& event)
{
bool enable = !ManagerST::Get()->IsBuildInProgress() && !ManagerST::Get()->GetActiveProjectName().IsEmpty();
if(enable) {
// get the selected configuration to be built
BuildConfigPtr bldConf =
WorkspaceST::Get()->GetProjBuildConf(CustomTargetsMgr::Get().GetProjectName(), wxEmptyString);
if(bldConf) {
CustomTargetsMgr::Pair_t target = CustomTargetsMgr::Get().GetTarget(event.GetId());
if(target.second.IsEmpty()) {
wxLogMessage(wxString::Format(
wxT("%s=%d"), _("Failed to find Custom Build Target for event ID"), event.GetId()));
return;
}
QueueCommand info(
CustomTargetsMgr::Get().GetProjectName(), bldConf->GetName(), false, QueueCommand::kCustomBuild);
info.SetCustomBuildTarget(target.first);
ManagerST::Get()->PushQueueCommand(info);
ManagerST::Get()->ProcessCommandQueue();
}
}
}
void clMainFrame::OnBuildAndRunProject(wxCommandEvent& event)
{
wxUnusedVar(event);
bool enable = !ManagerST::Get()->IsBuildInProgress() && !ManagerST::Get()->GetActiveProjectName().IsEmpty();
if(enable) {
m_buildAndRun = true;
wxString projectName = ManagerST::Get()->GetActiveProjectName();
wxString conf;
// get the selected configuration to be built
BuildConfigPtr bldConf = WorkspaceST::Get()->GetProjBuildConf(projectName, wxEmptyString);
if(bldConf) {
conf = bldConf->GetName();
}
QueueCommand info(projectName, conf, false, QueueCommand::kBuild);
if(bldConf && bldConf->IsCustomBuild()) {
info.SetKind(QueueCommand::kCustomBuild);
info.SetCustomBuildTarget(wxT("Build"));
}
ManagerST::Get()->PushQueueCommand(info);
ManagerST::Get()->ProcessCommandQueue();
}
}
void clMainFrame::OnRebuildProject(wxCommandEvent& event)
{
wxUnusedVar(event);
RebuildProject(ManagerST::Get()->GetActiveProjectName());
}
void clMainFrame::OnBuildProjectUI(wxUpdateUIEvent& event)
{
CHECK_SHUTDOWN();
bool enable = !ManagerST::Get()->IsBuildInProgress() && !ManagerST::Get()->GetActiveProjectName().IsEmpty();
event.Enable(enable);
}
void clMainFrame::OnStopExecutedProgramUI(wxUpdateUIEvent& event)
{
CHECK_SHUTDOWN();
wxCommandEvent e(wxEVT_CMD_IS_PROGRAM_RUNNING, GetId());
e.SetEventObject(this);
e.SetInt(0);
EventNotifier::Get()->ProcessEvent(e);
Manager* mgr = ManagerST::Get();
bool enable = mgr->IsProgramRunning();
event.Enable(enable || e.GetInt());
}
void clMainFrame::OnStopBuildUI(wxUpdateUIEvent& event)
{
CHECK_SHUTDOWN();
Manager* mgr = ManagerST::Get();
bool enable = mgr->IsBuildInProgress();
event.Enable(enable);
}
void clMainFrame::OnStopBuild(wxCommandEvent& event)
{
wxUnusedVar(event);
Manager* mgr = ManagerST::Get();
if(mgr->IsBuildInProgress()) {
mgr->StopBuild();
}
}
void clMainFrame::OnStopExecutedProgram(wxCommandEvent& event)
{
wxCommandEvent evtExecute(wxEVT_CMD_STOP_EXECUTED_PROGRAM);
if(EventNotifier::Get()->ProcessEvent(evtExecute)) return;
wxUnusedVar(event);
Manager* mgr = ManagerST::Get();
if(mgr->IsProgramRunning()) {
mgr->KillProgram();
}
}
void clMainFrame::OnCleanProject(wxCommandEvent& event)
{
wxUnusedVar(event);
wxString conf, projectName;
projectName = ManagerST::Get()->GetActiveProjectName();
QueueCommand buildInfo(QueueCommand::kClean);
ManagerST::Get()->PushQueueCommand(buildInfo);
ManagerST::Get()->ProcessCommandQueue();
}
void clMainFrame::OnCleanProjectUI(wxUpdateUIEvent& event)
{
CHECK_SHUTDOWN();
bool enable = !ManagerST::Get()->IsBuildInProgress() && !ManagerST::Get()->GetActiveProjectName().IsEmpty();
event.Enable(enable);
}
void clMainFrame::OnExecuteNoDebug(wxCommandEvent& event)
{
// Test to see if any plugin wants to execute it
wxCommandEvent evtExecute(wxEVT_CMD_EXECUTE_ACTIVE_PROJECT);
if(EventNotifier::Get()->ProcessEvent(evtExecute)) return;
if(!WorkspaceST::Get()->IsOpen()) {
return;
}
// Prepare the commands to execute
QueueCommand commandExecute(QueueCommand::kExecuteNoDebug);
wxStandardID res =
::PromptForYesNoDialogWithCheckbox(_("Would you like to build the active project\nbefore executing it?"),
"PromptForBuildBeforeExecute",
_("Build and Execute"),
_("Execute"));
// Don't do anything if "X" is pressed
if(res != wxID_CANCEL) {
if(res == wxID_YES) {
QueueCommand buildCommand(QueueCommand::kBuild);
ManagerST::Get()->PushQueueCommand(buildCommand);
commandExecute.SetCheckBuildSuccess(true); // execute only if build was successfull
}
ManagerST::Get()->PushQueueCommand(commandExecute);
ManagerST::Get()->ProcessCommandQueue();
}
}
void clMainFrame::OnExecuteNoDebugUI(wxUpdateUIEvent& event)
{
CHECK_SHUTDOWN();
wxCommandEvent e(wxEVT_CMD_IS_PROGRAM_RUNNING, GetId());
e.SetEventObject(this);
e.SetInt(0);
EventNotifier::Get()->ProcessEvent(e);
bool normalCondition = ManagerST::Get()->GetActiveProjectName().IsEmpty() == false &&
!ManagerST::Get()->IsBuildInProgress() && !ManagerST::Get()->IsProgramRunning();
event.Enable(normalCondition || !e.GetInt());
}
void clMainFrame::OnTimer(wxTimerEvent& event)
{
// since there is a bug in wxURL, which it can not be used while constucting a wxFrame,
// it must be called *after* the frame constuction
// add new version notification updater
long updatePaths(1);
wxLogMessage(wxString::Format(wxT("Install path: %s"), ManagerST::Get()->GetInstallDir().c_str()));
wxLogMessage(wxString::Format(wxT("Startup Path: %s"), ManagerST::Get()->GetStarupDirectory().c_str()));
wxLogMessage("Using " + wxStyledTextCtrl::GetLibraryVersionInfo().ToString());
if(::clIsCygwinEnvironment()) {
wxLogMessage("Running under Cygwin environment");
}
EditorConfigST::Get()->GetLongValue(wxT("UpdateParserPaths"), updatePaths);
if(clConfig::Get().Read("CheckForNewVersion", true)) {
JobQueueSingleton::Instance()->PushJob(new WebUpdateJob(this, false));
}
// enable/disable plugins toolbar functionality
PluginManager::Get()->EnableToolbars();
UpdateParserSearchPathsFromDefaultCompiler();
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
// clear navigation queue
if(GetMainBook()->GetCurrentPage() == 0) {
NavMgr::Get()->Clear();
}
// Load last session?
if(clConfig::Get().Read("RestoreLastSession", true) && m_loadLastSession) {
wxCommandEvent loadSessionEvent(wxEVT_LOAD_SESSION);
EventNotifier::Get()->AddPendingEvent(loadSessionEvent);
}
// ReTag workspace database if needed (this can happen due to schema version changes)
// It is important to place the retag code here since the retag workspace should take place after
// the parser search patha have been updated (if needed)
if(m_workspaceRetagIsRequired) {
m_workspaceRetagIsRequired = false;
wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED, XRCID("full_retag_workspace"));
this->AddPendingEvent(evt);
GetMainBook()->ShowMessage(_("Your workspace symbols file does not match the current version of CodeLite. "
"CodeLite will perform a full retag of the workspace"));
}
// For some reason, under Linux we need to force the menu accelerator again
// otherwise some shortcuts are getting lose (e.g. Ctrl-/ to comment line)
ManagerST::Get()->UpdateMenuAccelerators();
wxModule::InitializeModules();
// Send initialization end event
EventNotifier::Get()->PostCommandEvent(wxEVT_INIT_DONE, NULL);
CallAfter(&clMainFrame::LocateCompilersIfNeeded);
event.Skip();
}
void clMainFrame::UpdateParserSearchPathsFromDefaultCompiler()
{
// Check that the user has some paths set in the parser
clConfig ccConfig("code-completion.conf");
ccConfig.ReadItem(&m_tagsOptionsData);
// Since the version numbers aren't the same
// we should merge the new settings with the old ones
TagsOptionsData tmp;
m_tagsOptionsData.Merge(tmp);
// Try to locate the paths automatically
CompilerPtr pCompiler = BuildSettingsConfigST::Get()->GetDefaultCompiler(wxEmptyString);
if(!pCompiler) return;
wxArrayString paths;
paths = pCompiler->GetDefaultIncludePaths();
wxArrayString curExcludePaths = m_tagsOptionsData.GetParserExcludePaths();
wxArrayString curIncluePaths = m_tagsOptionsData.GetParserSearchPaths();
wxArrayString mergedPaths = ccConfig.MergeArrays(curIncluePaths, paths);
m_tagsOptionsData.SetParserExcludePaths(curExcludePaths);
m_tagsOptionsData.SetParserSearchPaths(mergedPaths);
m_tagsOptionsData.SetVersion(TagsOptionsData::CURRENT_VERSION);
//-----------------------
// clang
//-----------------------
wxArrayString clangSearchPaths = m_tagsOptionsData.GetClangSearchPathsArray();
mergedPaths = ccConfig.MergeArrays(paths, clangSearchPaths);
m_tagsOptionsData.SetClangSearchPathsArray(mergedPaths);
ccConfig.WriteItem(&m_tagsOptionsData);
}
void clMainFrame::OnFileCloseAll(wxCommandEvent& event)
{
wxUnusedVar(event);
GetMainBook()->CallAfter(&MainBook::CloseAllVoid, true);
}
void clMainFrame::OnQuickOutline(wxCommandEvent& event)
{
// Sanity
LEditor* activeEditor = GetMainBook()->GetActiveEditor(true);
CHECK_PTR_RET(activeEditor);
// let the plugins process this first
clCodeCompletionEvent evt(wxEVT_CC_SHOW_QUICK_OUTLINE, GetId());
evt.SetEventObject(this);
evt.SetEditor(activeEditor);
if(EventNotifier::Get()->ProcessEvent(evt)) return;
wxUnusedVar(event);
if(ManagerST::Get()->IsWorkspaceOpen() == false) return;
if(activeEditor->GetProject().IsEmpty()) return;
QuickOutlineDlg dlg(::wxGetTopLevelParent(activeEditor),
activeEditor->GetFileName().GetFullPath(),
wxID_ANY,
wxT(""),
wxDefaultPosition,
wxSize(400, 400),
wxDEFAULT_DIALOG_STYLE);
dlg.ShowModal();
activeEditor->SetActive();
}
wxString clMainFrame::CreateWorkspaceTable()
{
wxString html;
wxArrayString files;
Manager* mgr = ManagerST::Get();
mgr->GetRecentlyOpenedWorkspaces(files);
wxColour bgclr = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
bgclr = DrawingUtils::LightColour(bgclr, 7);
html << wxT("<table width=100% border=0 bgcolor=\"") << bgclr.GetAsString(wxC2S_HTML_SYNTAX) << wxT("\">");
if(files.GetCount() == 0) {
html << wxT("<tr><td><font size=2 face=\"Verdana\">");
html << _("No workspaces found.") << wxT("</font></td></tr>");
} else {
wxColour baseColour(232, 166, 101);
wxColour firstColour = DrawingUtils::LightColour(baseColour, 6);
wxColour secondColour = DrawingUtils::LightColour(baseColour, 8);
for(int i = (int)files.GetCount(); i > 0; --i) {
wxFileName fn(files.Item(i - 1));
wxColour lineCol;
if(i % 2) {
lineCol = firstColour;
} else {
lineCol = secondColour;
}
html << wxT("<tr bgcolor=\"") << lineCol.GetAsString(wxC2S_HTML_SYNTAX) << wxT("\">")
<< wxT("<td><font size=2 face=\"Verdana\">") << wxT("<a href=\"action:open-file:") << fn.GetFullPath()
<< wxT("\" >") << fn.GetName() << wxT("</a></font></td>") << wxT("<td><font size=2 face=\"Verdana\">")
<< fn.GetFullPath() << wxT("</font></td>") << wxT("</tr>");
}
}
html << wxT("</table>");
return html;
}
wxString clMainFrame::CreateFilesTable()
{
wxString html;
wxArrayString files;
GetMainBook()->GetRecentlyOpenedFiles(files);
wxColour bgclr = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
bgclr = DrawingUtils::LightColour(bgclr, 10.0);
html << wxT("<table width=100% border=0 bgcolor=\"") << bgclr.GetAsString(wxC2S_HTML_SYNTAX) << wxT("\">");
if(files.GetCount() == 0) {
html << wxT("<tr><td><font size=2 face=\"Verdana\">");
html << _("No files found.") << wxT("</font></td></tr>");
} else {
wxColour baseColour(232, 166, 101);
wxColour firstColour = DrawingUtils::LightColour(baseColour, 6);
wxColour secondColour = DrawingUtils::LightColour(baseColour, 8);
for(int i = (int)files.GetCount(); i > 0; --i) {
wxFileName fn(files.Item(i - 1));
wxColour lineCol;
if(i % 2) {
lineCol = firstColour;
} else {
lineCol = secondColour;
}
html << wxT("<tr bgcolor=\"") << lineCol.GetAsString(wxC2S_HTML_SYNTAX) << wxT("\">")
<< wxT("<td><font size=2 face=\"Verdana\">") << wxT("<a href=\"action:open-file:") << fn.GetFullPath()
<< wxT("\" >") << fn.GetFullName() << wxT("</a></font></td>")
<< wxT("<td><font size=2 face=\"Verdana\">") << fn.GetFullPath() << wxT("</font></td>")
<< wxT("</tr>");
}
}
html << wxT("</table>");
return html;
}
void clMainFrame::CreateRecentlyOpenedFilesMenu()
{
wxArrayString files;
FileHistory& hs = GetMainBook()->GetRecentlyOpenedFilesClass();
GetMainBook()->GetRecentlyOpenedFiles(files);
wxMenu* menu = NULL;
wxMenuItem* item = GetMenuBar()->FindItem(XRCID("recent_files"), &menu);
if(item && menu) {
wxMenu* submenu = item->GetSubMenu();
if(submenu) {
for(size_t i = 0; i < files.GetCount(); i++) {
hs.AddFileToHistory(files.Item(i));
}
// set this menu as the recent file menu
hs.SetBaseId(RecentFilesSubMenuID + 1);
hs.UseMenu(submenu);
hs.AddFilesToMenu();
}
}
}
void clMainFrame::CreateRecentlyOpenedWorkspacesMenu()
{
wxArrayString files;
FileHistory& hs = ManagerST::Get()->GetRecentlyOpenedWorkspacesClass();
ManagerST::Get()->GetRecentlyOpenedWorkspaces(files);
wxMenu* menu = NULL;
wxMenuItem* item = GetMenuBar()->FindItem(XRCID("recent_workspaces"), &menu);
if(item && menu) {
wxMenu* submenu = item->GetSubMenu();
if(submenu) {
for(size_t i = 0; i < files.GetCount(); i++) {
hs.AddFileToHistory(files.Item(i));
}
// set this menu as the recent file menu
hs.SetBaseId(RecentWorkspaceSubMenuID + 1);
hs.UseMenu(submenu);
// Clear any stale items
wxMenuItemList items = submenu->GetMenuItems();
wxMenuItemList::reverse_iterator lriter = items.rbegin();
for(; lriter != items.rend(); ++lriter) {
submenu->Delete(*lriter);
}
// Add entries without their .workspace extension
hs.AddFilesToMenuWithoutExt();
}
}
}
void clMainFrame::OnRecentFile(wxCommandEvent& event)
{
size_t idx = event.GetId() - (RecentFilesSubMenuID + 1);
FileHistory& fh = GetMainBook()->GetRecentlyOpenedFilesClass();
wxArrayString files;
fh.GetFiles(files);
if(idx < files.GetCount()) {
wxString projectName = ManagerST::Get()->GetProjectNameByFile(files.Item(idx));
clMainFrame::Get()->GetMainBook()->OpenFile(files.Item(idx), projectName);
}
}
void clMainFrame::OnRecentWorkspace(wxCommandEvent& event)
{
size_t idx = event.GetId() - (RecentWorkspaceSubMenuID + 1);
FileHistory& fh = ManagerST::Get()->GetRecentlyOpenedWorkspacesClass();
wxArrayString files;
fh.GetFiles(files);
if(idx < files.GetCount()) {
wxString file_name(files.Item(idx));
wxCommandEvent open_workspace_event(wxEVT_COMMAND_MENU_SELECTED, XRCID("switch_to_workspace"));
open_workspace_event.SetEventObject(this);
open_workspace_event.SetString(file_name);
GetEventHandler()->AddPendingEvent(open_workspace_event);
}
}
void clMainFrame::OnBackwardForward(wxCommandEvent& event)
{
switch(event.GetId()) {
case wxID_FORWARD:
NavMgr::Get()->NavigateForward(PluginManager::Get());
break;
case wxID_BACKWARD:
NavMgr::Get()->NavigateBackward(PluginManager::Get());
break;
}
}
void clMainFrame::OnBackwardForwardUI(wxUpdateUIEvent& event)
{
CHECK_SHUTDOWN();
if(event.GetId() == wxID_FORWARD) {
event.Enable(NavMgr::Get()->CanNext());
} else if(event.GetId() == wxID_BACKWARD) {
event.Enable(NavMgr::Get()->CanPrev());
} else {
event.Skip();
}
}
void clMainFrame::CreateWelcomePage()
{
/*
Manager *mgr = ManagerST::Get();
//load the template
wxFileName fn(mgr->GetStarupDirectory(), wxT("index.html"));
wxFFile file(fn.GetFullPath(), wxT("r"));
if (!file.IsOpened()) {
return;
}
wxHtmlWindow *welcomePage = new wxHtmlWindow(GetMainBook(), wxID_ANY);
wxString content;
file.ReadAll(&content);
file.Close();
//replace $(InstallPath)
content.Replace(wxT("$(InstallPath)"), mgr->GetStarupDirectory());
//replace the $(FilesTable) & $(WorkspaceTable)
wxString workspaceTable = CreateWorkspaceTable();
wxString filesTable = CreateFilesTable();
content.Replace(wxT("$(WorkspaceTable)"), workspaceTable);
content.Replace(wxT("$(FilesTable)"), filesTable);
//replace the HTML colours with platfroms correct colours
wxColour active_caption = wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION);
wxColour active_caption_txt = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
active_caption = DrawingUtils::LightColour(active_caption, 11.0);
content.Replace(wxT("$(ACTIVE_CAPTION)"), active_caption.GetAsString());
content.Replace(wxT("$(ACTIVE_CAPTION_TEXT)"), active_caption_txt.GetAsString());
content.Replace(wxT("$(QuickLinks)"), _("Quick Links:"));
content.Replace(wxT("$(CodeLiteWiki)"), _("CodeLite Wiki"));
content.Replace(wxT("$(CodeLiteForums)"), _("CodeLite Forums"));
content.Replace(wxT("$(CreateNewWorkspace)"), _("Create a New Workspace"));
content.Replace(wxT("$(OpenWorkspace)"), _("Open a Workspace"));
content.Replace(wxT("$(RecentWorkspaces)"), _("Recently opened workspaces:"));
content.Replace(wxT("$(RecentFiles)"), _("Recently opened files:"));
welcomePage->SetPage(content);*/
WelcomePage* welcomePage = new WelcomePage(GetMainBook());
GetMainBook()->AddPage(welcomePage, _("Welcome!"), wxNullBitmap, true);
GetMainBook()->Layout();
// This is needed in >=wxGTK-2.9, otherwise the auinotebook doesn't fully expand at first
SendSizeEvent(wxSEND_EVENT_POST);
// Ditto the workspace pane auinotebook
GetWorkspacePane()->SendSizeEvent(wxSEND_EVENT_POST);
}
void clMainFrame::OnImportMSVS(wxCommandEvent& e)
{
wxUnusedVar(e);
const wxString ALL(wxT("MS Visual Studio Solution File (*.sln)|*.sln|") wxT("All Files (*)|*"));
wxFileDialog dlg(this,
_("Open MS Solution File"),
wxEmptyString,
wxEmptyString,
ALL,
wxFD_OPEN | wxFD_FILE_MUST_EXIST,
wxDefaultPosition);
if(dlg.ShowModal() == wxID_OK) {
wxArrayString cmps;
BuildSettingsConfigCookie cookie;
CompilerPtr cmp = BuildSettingsConfigST::Get()->GetFirstCompiler(cookie);
while(cmp) {
cmps.Add(cmp->GetName());
cmp = BuildSettingsConfigST::Get()->GetNextCompiler(cookie);
}
// Get the prefered compiler type
wxString compilerName = wxGetSingleChoice(_("Select the compiler to use:"), _("Choose compiler"), cmps);
ManagerST::Get()->ImportMSVSSolution(dlg.GetPath(), compilerName);
}
}
void clMainFrame::OnDebug(wxCommandEvent& e)
{
wxUnusedVar(e);
bool isBuiltinDebuggerRunning =
DebuggerMgr::Get().GetActiveDebugger() && DebuggerMgr::Get().GetActiveDebugger()->IsRunning();
if(!WorkspaceST::Get()->IsOpen()) {
// We hae no workspace opened and yet we got here.
// this can mean one of two:
// 1. A non C++ workspace is opened - so we initiate the debugger start command
// 2. User wishes to run QuickDebug// Let the plugin know that we are about to start debugging
clDebugEvent dbgEvent(wxEVT_DBG_UI_START);
if(EventNotifier::Get()->ProcessEvent(dbgEvent))
// the event was processed by one of the plugins, there is nothing left to
// be done here
return;
// Note:
// The second scenario (launch QuickDebug) is handled later on this function
}
if(!isBuiltinDebuggerRunning) {
// Let the plugin know that we are about to start debugging
clDebugEvent dbgEvent(wxEVT_DBG_UI_CONTINUE);
ProjectPtr activeProject = WorkspaceST::Get()->GetActiveProject();
if(activeProject) {
BuildConfigPtr buildConfig = activeProject->GetBuildConfiguration();
if(buildConfig) {
dbgEvent.SetDebuggerName(buildConfig->GetDebuggerType());
}
}
if(EventNotifier::Get()->ProcessEvent(dbgEvent)) return;
}
Manager* mgr = ManagerST::Get();
if(isBuiltinDebuggerRunning) {
// Debugger is already running -> continue command
mgr->DbgContinue();
} else if(mgr->IsWorkspaceOpen()) {
if(WorkspaceST::Get()->GetActiveProjectName().IsEmpty()) {
wxLogMessage(_("Attempting to debug workspace with no active project? Ignoring."));
return;
}
// Debugger is not running, but workspace is opened -> start debug session
QueueCommand dbgCmd(QueueCommand::kDebug);
wxStandardID res =
::PromptForYesNoDialogWithCheckbox(_("Would you like to build the project before debugging it?"),
"BuildBeforeDebug",
_("Build and Debug"),
_("Debug"));
// Don't do anything if "X" is pressed
if(res != wxID_CANCEL) {
if(res == wxID_YES) {
QueueCommand bldCmd(QueueCommand::kBuild);
ManagerST::Get()->PushQueueCommand(bldCmd);
dbgCmd.SetCheckBuildSuccess(true);
}
// place a debug command
ManagerST::Get()->PushQueueCommand(dbgCmd);
// trigger the commands queue
ManagerST::Get()->ProcessCommandQueue();
}
} else if(!mgr->IsWorkspaceOpen()) {
// Run the 'Quick Debug'
OnQuickDebug(e);
}
}
void clMainFrame::OnDebugUI(wxUpdateUIEvent& e)
{
CHECK_SHUTDOWN();
e.Enable(!ManagerST::Get()->IsBuildInProgress());
}
void clMainFrame::OnDebugRestart(wxCommandEvent& e)
{
clDebugEvent event(wxEVT_DBG_UI_RESTART);
if(EventNotifier::Get()->ProcessEvent(event)) return;
IDebugger* dbgr = DebuggerMgr::Get().GetActiveDebugger();
if(dbgr && dbgr->IsRunning() && ManagerST::Get()->DbgCanInteract()) {
GetDebuggerPane()->GetLocalsTable()->Clear();
dbgr->Restart();
}
}
void clMainFrame::OnDebugRestartUI(wxUpdateUIEvent& e)
{
CHECK_SHUTDOWN();
clDebugEvent event(wxEVT_DBG_IS_RUNNING);
EventNotifier::Get()->ProcessEvent(event);
IDebugger* dbgr = DebuggerMgr::Get().GetActiveDebugger();
e.Enable(event.IsAnswer() || (dbgr && dbgr->IsRunning() && ManagerST::Get()->DbgCanInteract()));
}
void clMainFrame::OnDebugStop(wxCommandEvent& e)
{
wxUnusedVar(e);
clDebugEvent debugEvent(wxEVT_DBG_UI_STOP);
if(EventNotifier::Get()->ProcessEvent(debugEvent)) {
return;
}
ManagerST::Get()->DbgStop();
}
void clMainFrame::OnDebugStopUI(wxUpdateUIEvent& e)
{
CHECK_SHUTDOWN();
clDebugEvent eventIsRunning(wxEVT_DBG_IS_RUNNING);
EventNotifier::Get()->ProcessEvent(eventIsRunning);
IDebugger* dbgr = DebuggerMgr::Get().GetActiveDebugger();
e.Enable(eventIsRunning.IsAnswer() || (dbgr && dbgr->IsRunning()));
}
void clMainFrame::OnDebugManageBreakpointsUI(wxUpdateUIEvent& e)
{
if(e.GetId() == XRCID("delete_all_breakpoints")) {
std::vector<BreakpointInfo> bps;
ManagerST::Get()->GetBreakpointsMgr()->GetBreakpoints(bps);
e.Enable(bps.size());
} else if(e.GetId() == XRCID("disable_all_breakpoints")) {
e.Enable(ManagerST::Get()->GetBreakpointsMgr()->AreThereEnabledBreakpoints());
} else if(e.GetId() == XRCID("enable_all_breakpoints")) {
e.Enable(ManagerST::Get()->GetBreakpointsMgr()->AreThereDisabledBreakpoints());
} else {
e.Enable(true);
}
}
void clMainFrame::OnDebugCmd(wxCommandEvent& e)
{
int cmd(wxNOT_FOUND);
int eventId(wxNOT_FOUND);
if(e.GetId() == XRCID("pause_debugger")) {
cmd = DBG_PAUSE;
eventId = wxEVT_DBG_UI_INTERRUPT;
} else if(e.GetId() == XRCID("dbg_stepin")) {
cmd = DBG_STEPIN;
eventId = wxEVT_DBG_UI_STEP_IN;
} else if(e.GetId() == XRCID("dbg_stepout")) {
cmd = DBG_STEPOUT;
eventId = wxEVT_DBG_UI_STEP_OUT;
} else if(e.GetId() == XRCID("dbg_next")) {
cmd = DBG_NEXT;
eventId = wxEVT_DBG_UI_NEXT;
} else if(e.GetId() == XRCID("show_cursor")) {
cmd = DBG_SHOW_CURSOR;
eventId = wxEVT_DBG_UI_SHOW_CURSOR;
} else if(e.GetId() == XRCID("dbg_nexti")) {
cmd = DBG_NEXTI;
eventId = wxEVT_DBG_UI_NEXT_INST;
}
// ALlow the plugins to handle this command first
clDebugEvent evnt(eventId);
if(EventNotifier::Get()->ProcessEvent(evnt)) {
return;
}
if(cmd != wxNOT_FOUND) {
ManagerST::Get()->DbgDoSimpleCommand(cmd);
}
}
void clMainFrame::OnDebugCmdUI(wxUpdateUIEvent& e)
{
CHECK_SHUTDOWN();
clDebugEvent eventIsRunning(wxEVT_DBG_IS_RUNNING);
EventNotifier::Get()->ProcessEvent(eventIsRunning);
if(e.GetId() == XRCID("pause_debugger") || e.GetId() == XRCID("dbg_stepin") || e.GetId() == XRCID("dbg_stepout") ||
e.GetId() == XRCID("dbg_next") || e.GetId() == XRCID("dbg_nexti") || e.GetId() == XRCID("show_cursor")) {
IDebugger* dbgr = DebuggerMgr::Get().GetActiveDebugger();
e.Enable(eventIsRunning.IsAnswer() || (dbgr && dbgr->IsRunning()));
}
}
void clMainFrame::OnDebuggerSettings(wxCommandEvent& e)
{
wxUnusedVar(e);
DebuggerSettingsDlg* dlg = new DebuggerSettingsDlg(this);
dlg->ShowModal();
dlg->Destroy();
}
void clMainFrame::OnIdle(wxIdleEvent& e)
{
e.Skip();
// make sure that we are always set to the working directory of the workspace
if(WorkspaceST::Get()->IsOpen()) {
// Check that current working directory is set to the workspace folder
wxString path = WorkspaceST::Get()->GetWorkspaceFileName().GetPath();
wxString curdir = ::wxGetCwd();
if(path != curdir) {
// Check that it really *is* different, not just a symlink issue: see bug #942
if(CLRealPath(path) != CLRealPath(curdir)) {
wxLogMessage("Current working directory is reset to %s", path);
::wxSetWorkingDirectory(path);
}
}
}
}
void clMainFrame::OnLinkClicked(wxHtmlLinkEvent& e)
{
wxString action = e.GetLinkInfo().GetHref();
if(!action.StartsWith(wxT("action:"), &action)) {
wxLaunchDefaultBrowser(e.GetLinkInfo().GetHref());
return;
}
wxString command = action.BeforeFirst(wxT(':'));
wxString filename = action.AfterFirst(wxT(':'));
if(command != wxT("switch-workspace") && command != wxT("open-file") && command != wxT("create-workspace") &&
command != wxT("import-msvs-solution") && command != wxT("open-workspace")) {
e.Skip();
return;
}
wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, XRCID("link_action"));
event.SetEventObject(this);
StartPageData* data = new StartPageData;
data->action = command;
data->file_path = filename;
if(wxFileName(filename).GetExt() == wxT("workspace")) {
data->action = wxT("switch-workspace");
}
event.SetClientData(data);
wxPostEvent(this, event);
}
void clMainFrame::OnStartPageEvent(wxCommandEvent& e)
{
StartPageData* data = (StartPageData*)e.GetClientData();
if(data->action == wxT("switch-workspace")) {
clWindowUpdateLocker locker(this);
ManagerST::Get()->OpenWorkspace(data->file_path);
} else if(data->action == wxT("open-file")) {
clMainFrame::Get()->GetMainBook()->OpenFile(data->file_path, wxEmptyString);
} else if(data->action == wxT("create-workspace")) {
OnProjectNewWorkspace(e);
} else if(data->action == wxT("import-msvs-solution")) {
OnImportMSVS(e);
} else if(data->action == wxT("open-workspace")) {
OnSwitchWorkspace(e);
}
delete data;
}
void clMainFrame::SetFrameFlag(bool set, int flag)
{
if(set) {
m_frameGeneralInfo.SetFlags(m_frameGeneralInfo.GetFlags() | flag);
} else {
m_frameGeneralInfo.SetFlags(m_frameGeneralInfo.GetFlags() & ~(flag));
}
}
void clMainFrame::OnShowWelcomePageUI(wxUpdateUIEvent& event)
{
CHECK_SHUTDOWN();
event.Enable(GetMainBook()->FindPage(_("Welcome!")) == NULL);
}
void clMainFrame::OnShowWelcomePage(wxCommandEvent& event) { ShowWelcomePage(); }
void clMainFrame::CompleteInitialization()
{
// Load the plugins
PluginManager::Get()->Load();
// Load debuggers (*must* be after the plugins)
DebuggerMgr::Get().Initialize(this, EnvironmentConfig::Instance(), ManagerST::Get()->GetInstallDir());
DebuggerMgr::Get().LoadDebuggers();
// Connect some system events
m_mgr.Connect(wxEVT_AUI_PANE_CLOSE, wxAuiManagerEventHandler(clMainFrame::OnDockablePaneClosed), NULL, this);
// m_mgr.Connect(wxEVT_AUI_RENDER, wxAuiManagerEventHandler(clMainFrame::OnAuiManagerRender), NULL, this);
Layout();
SelectBestEnvSet();
// Now everything is loaded, set the saved tab-order in the workspace pane
GetWorkspacePane()->ApplySavedTabOrder();
ManagerST::Get()->GetPerspectiveManager().ConnectEvents(&m_mgr);
wxCommandEvent evt(wxEVT_CL_THEME_CHANGED);
EventNotifier::Get()->AddPendingEvent(evt);
#ifndef __WXMSW__
sigset_t child_set;
sigemptyset(&child_set);
sigaddset(&child_set, SIGCHLD);
// make sure SIGCHILD is not blocked
sigprocmask(SIG_UNBLOCK, &child_set, NULL);
// Start the Zombie Reaper thread
m_zombieReaper.Start();
#endif
// Hide / Show status/tool bar
if(GetToolBar() && !clConfig::Get().Read("ShowToolBar", true)) {
GetToolBar()->Hide();
}
if(!clConfig::Get().Read("ShowStatusBar", true)) {
GetStatusBar()->Hide();
}
ShowOrHideCaptions();
}
void clMainFrame::OnAppActivated(wxActivateEvent& e)
{
#ifndef __WXMAC__
CodeCompletionBox::Get().CancelTip();
#endif
if(m_theFrame && e.GetActive()) {
// if workspace or project was modified, don't prompt for
// file(s) reload
if(!m_theFrame->ReloadExternallyModifiedProjectFiles()) {
m_theFrame->GetMainBook()->CallAfter(&MainBook::ReloadExternallyModified, true);
}
// Notify plugins that we got the focus.
// Some plugins want to hide some frames etc
wxCommandEvent evtGotFocus(wxEVT_CODELITE_MAINFRAME_GOT_FOCUS);
EventNotifier::Get()->AddPendingEvent(evtGotFocus);
} else if(m_theFrame) {
#ifndef __WXMAC__
/// this code causes crash on Mac, since it destorys an active CCBox
LEditor* editor = GetMainBook()->GetActiveEditor();
if(editor) {
// we are loosing the focus
editor->CallTipCancel();
editor->HideCompletionBox();
}
#endif
}
e.Skip();
}
void clMainFrame::OnCompileFile(wxCommandEvent& e)
{
wxUnusedVar(e);
Manager* mgr = ManagerST::Get();
if(mgr->IsWorkspaceOpen() && !mgr->IsBuildInProgress()) {
LEditor* editor = GetMainBook()->GetActiveEditor();
if(editor && !editor->GetProject().IsEmpty()) {
mgr->CompileFile(editor->GetProject(), editor->GetFileName().GetFullPath());
}
}
}
void clMainFrame::OnCompileFileUI(wxUpdateUIEvent& e)
{
CHECK_SHUTDOWN();
e.Enable(false);
Manager* mgr = ManagerST::Get();
if(mgr->IsWorkspaceOpen() && !mgr->IsBuildInProgress()) {
LEditor* editor = GetMainBook()->GetActiveEditor();
if(editor && !editor->GetProject().IsEmpty()) {
e.Enable(true);
}
}
}
void clMainFrame::OnDebugAttach(wxCommandEvent& event)
{
wxUnusedVar(event);
// Start the debugger
Manager* mgr = ManagerST::Get();
mgr->DbgStart(1);
}
void clMainFrame::OnCloseAllButThis(wxCommandEvent& e)
{
wxUnusedVar(e);
wxWindow* win = GetMainBook()->GetCurrentPage();
if(win != NULL) {
GetMainBook()->CallAfter(&MainBook::CloseAllButThisVoid, win);
}
}
WorkspaceTab* clMainFrame::GetWorkspaceTab() { return GetWorkspacePane()->GetWorkspaceTab(); }
FileExplorer* clMainFrame::GetFileExplorer() { return GetWorkspacePane()->GetFileExplorer(); }
void clMainFrame::OnLoadWelcomePage(wxCommandEvent& event) { SetFrameFlag(event.IsChecked(), CL_SHOW_WELCOME_PAGE); }
void clMainFrame::OnLoadWelcomePageUI(wxUpdateUIEvent& event)
{
CHECK_SHUTDOWN();
event.Check(m_frameGeneralInfo.GetFlags() & CL_SHOW_WELCOME_PAGE ? true : false);
}
void clMainFrame::OnFileCloseUI(wxUpdateUIEvent& event)
{
CHECK_SHUTDOWN();
event.Enable(GetMainBook()->GetCurrentPage() != NULL);
}
void clMainFrame::OnConvertEol(wxCommandEvent& e)
{
LEditor* editor = GetMainBook()->GetActiveEditor();
if(editor) {
int eol(wxSTC_EOL_LF);
if(e.GetId() == XRCID("convert_eol_win")) {
eol = wxSTC_EOL_CRLF;
} else if(e.GetId() == XRCID("convert_eol_mac")) {
eol = wxSTC_EOL_CR;
}
editor->ConvertEOLs(eol);
editor->SetEOLMode(eol);
}
}
void clMainFrame::OnViewDisplayEOL(wxCommandEvent& e)
{
bool visible;
size_t frame_flags = m_frameGeneralInfo.GetFlags();
if(e.IsChecked()) {
frame_flags |= CL_SHOW_EOL;
visible = true;
} else {
frame_flags &= ~CL_SHOW_EOL;
visible = false;
}
m_frameGeneralInfo.SetFlags(frame_flags);
GetMainBook()->SetViewEOL(visible);
}
void clMainFrame::OnViewDisplayEOL_UI(wxUpdateUIEvent& e)
{
CHECK_SHUTDOWN();
LEditor* editor = GetMainBook()->GetActiveEditor();
bool hasEditor = editor ? true : false;
if(!hasEditor) {
e.Enable(false);
return;
}
e.Enable(true);
e.Check(m_frameGeneralInfo.GetFlags() & CL_SHOW_EOL ? true : false);
}
void clMainFrame::OnCopyFileName(wxCommandEvent& event)
{
LEditor* editor = GetMainBook()->GetActiveEditor();
if(editor) {
wxString fileName = editor->GetFileName().GetFullName();
#if wxUSE_CLIPBOARD
if(wxTheClipboard->Open()) {
wxTheClipboard->UsePrimarySelection(false);
if(!wxTheClipboard->SetData(new wxTextDataObject(fileName))) {
// wxPrintf(wxT("Failed to insert data %s to clipboard"), textToCopy.GetData());
}
wxTheClipboard->Close();
} else {
wxPrintf(wxT("Failed to open the clipboard"));
}
#endif
}
}
void clMainFrame::OnCopyFilePath(wxCommandEvent& event)
{
LEditor* editor = GetMainBook()->GetActiveEditor();
if(editor) {
wxString fileName = editor->GetFileName().GetFullPath();
#if wxUSE_CLIPBOARD
if(wxTheClipboard->Open()) {
wxTheClipboard->UsePrimarySelection(false);
if(!wxTheClipboard->SetData(new wxTextDataObject(fileName))) {
// wxPrintf(wxT("Failed to insert data %s to clipboard"), textToCopy.GetData());
}
wxTheClipboard->Close();
} else {
wxPrintf(wxT("Failed to open the clipboard"));
}
#endif
}
}
void clMainFrame::OnCopyFilePathOnly(wxCommandEvent& event)
{
LEditor* editor = GetMainBook()->GetActiveEditor();
if(editor) {
wxString fileName = editor->GetFileName().GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
#if wxUSE_CLIPBOARD
if(wxTheClipboard->Open()) {
wxTheClipboard->UsePrimarySelection(false);
if(!wxTheClipboard->SetData(new wxTextDataObject(fileName))) {
// wxPrintf(wxT("Failed to insert data %s to clipboard"), textToCopy.GetData());
}
wxTheClipboard->Close();
} else {
wxPrintf(wxT("Failed to open the clipboard"));
}
#endif
}
}
void clMainFrame::OnWorkspaceMenuUI(wxUpdateUIEvent& e)
{
CHECK_SHUTDOWN();
if(ManagerST::Get()->IsWorkspaceOpen() == false) {
e.Enable(false);
return;
}
if(ManagerST::Get()->IsBuildInProgress()) {
e.Enable(false);
return;
}
e.Enable(true);
}
void clMainFrame::OnManagePlugins(wxCommandEvent& e)
{
PluginMgrDlg dlg(this);
if(dlg.ShowModal() == wxID_OK) {
DoSuggestRestart();
}
}
void clMainFrame::OnCppContextMenu(wxCommandEvent& e)
{
wxUnusedVar(e);
LEditor* editor = GetMainBook()->GetActiveEditor(true);
if(editor) {
editor->GetContext()->ProcessEvent(e);
}
}
void clMainFrame::OnConfigureAccelerators(wxCommandEvent& e)
{
AccelTableDlg dlg(this);
dlg.ShowModal();
}
void clMainFrame::OnUpdateBuildRefactorIndexBar(wxCommandEvent& e) { wxUnusedVar(e); }
void clMainFrame::OnHighlightWord(wxCommandEvent& event)
{
long highlightWord(1);
EditorConfigST::Get()->GetLongValue(wxT("highlight_word"), highlightWord);
// Notify all open editors that word hight is checked
wxCommandEvent evtEnable(wxCMD_EVENT_ENABLE_WORD_HIGHLIGHT);
if(!highlightWord) {
GetMainBook()->HighlightWord(true);
EditorConfigST::Get()->SaveLongValue(wxT("highlight_word"), 1);
evtEnable.SetInt(1);
} else {
GetMainBook()->HighlightWord(false);
EditorConfigST::Get()->SaveLongValue(wxT("highlight_word"), 0);
evtEnable.SetInt(0);
}
EventNotifier::Get()->AddPendingEvent(evtEnable);
}
void clMainFrame::OnShowNavBar(wxCommandEvent& e)
{
GetMainBook()->ShowNavBar(e.IsChecked());
m_mgr.Update();
}
void clMainFrame::OnShowNavBarUI(wxUpdateUIEvent& e)
{
CHECK_SHUTDOWN();
e.Check(GetMainBook()->IsNavBarShown());
}
void clMainFrame::OnSingleInstanceOpenFiles(wxCommandEvent& e)
{
wxArrayString* arr = reinterpret_cast<wxArrayString*>(e.GetClientData());
if(arr) {
for(size_t i = 0; i < arr->GetCount(); i++) {
wxFileName fn(arr->Item(i));
// if file is workspace, load it
if(fn.GetExt() == wxT("workspace")) {
if(ManagerST::Get()->IsWorkspaceOpen()) {
if(wxMessageBox(_("Close this workspace, and load workspace '") + fn.GetFullName() + wxT("'"),
_("CodeLite"),
wxICON_QUESTION | wxYES_NO,
this) == wxNO) {
continue;
}
}
ManagerST::Get()->OpenWorkspace(arr->Item(i));
} else {
clMainFrame::Get()->GetMainBook()->OpenFile(arr->Item(i), wxEmptyString);
}
}
delete arr;
}
Raise();
}
void clMainFrame::OnSingleInstanceRaise(wxCommandEvent& e)
{
wxUnusedVar(e);
Raise();
}
void clMainFrame::OnNewVersionAvailable(wxCommandEvent& e)
{
WebUpdateJobData* data = reinterpret_cast<WebUpdateJobData*>(e.GetClientData());
if(data) {
if(data->IsUpToDate() == false) {
m_codeliteDownloadPageURL = data->GetUrl();
ButtonDetails btn;
btn.buttonLabel = _("Download Now!");
btn.commandId = XRCID("goto_codelite_download_url");
btn.isDefault = true;
btn.window = this;
GetMainBook()->ShowMessage(
_("A new version of codelite is available"),
true,
PluginManager::Get()->GetStdIcons()->LoadBitmap(wxT("messages/48/software_upgrade")),
btn);
} else {
if(!data->GetShowMessage()) {
wxLogMessage(wxString() << "Info: codelite is up-to-date (or newer), version used: "
<< data->GetCurVersion() << ", version on site: " << data->GetNewVersion());
} else {
// User initiated the version check request
GetMainBook()->ShowMessage(_("CodeLite is up-to-date"));
}
}
delete data;
}
}
void clMainFrame::OnDetachWorkspaceViewTab(wxCommandEvent& e)
{
size_t sel = GetWorkspacePane()->GetNotebook()->GetSelection();
wxWindow* page = GetWorkspacePane()->GetNotebook()->GetCurrentPage();
wxString text = GetWorkspacePane()->GetNotebook()->GetPageText(sel);
wxBitmap bmp = GetWorkspacePane()->GetNotebook()->GetPageBitmap(
sel); // We might have a bitmap on the tab, make sure we restore it
#if !CL_USE_NATIVEBOOK
DockablePane* pane = new DockablePane(this, GetWorkspacePane()->GetNotebook(), text, bmp, wxSize(200, 200));
page->Reparent(pane);
// remove the page from the notebook
GetWorkspacePane()->GetNotebook()->RemovePage(sel, false);
pane->SetChildNoReparent(page);
#else
DockablePane* pane = new DockablePane(this, GetWorkspacePane()->GetNotebook(), text, bmp, wxSize(200, 200));
GetWorkspacePane()->GetNotebook()->RemovePage(sel, false);
#if wxVERSION_NUMBER < 2903
// HACK: since Reparent will remove the widget from the parent, we need to place it back... (This was fixed in
// wxGTK-2.9.3)
gtk_container_add(GTK_CONTAINER(GetWorkspacePane()->GetNotebook()->m_widget), page->m_widget);
#endif
page->Reparent(pane);
pane->SetChildNoReparent(page);
#endif
wxUnusedVar(e);
}
void clMainFrame::OnNewDetachedPane(wxCommandEvent& e)
{
DockablePane* pane = (DockablePane*)(e.GetClientData());
if(pane) {
wxString text = pane->GetName();
m_DPmenuMgr->AddMenu(text);
// keep list of all detached panes
wxArrayString panes = m_DPmenuMgr->GetDeatchedPanesList();
DetachedPanesInfo dpi(panes);
EditorConfigST::Get()->WriteObject(wxT("DetachedPanesList"), &dpi);
m_mgr.AddPane(pane, wxAuiPaneInfo().Name(text).Caption(text).Float());
m_mgr.Update();
}
}
void clMainFrame::OnDestroyDetachedPane(wxCommandEvent& e)
{
DockablePane* pane = (DockablePane*)(e.GetClientData());
if(pane) {
m_mgr.DetachPane(pane);
// remove any menu entries for this pane
m_DPmenuMgr->RemoveMenu(pane->GetName());
// keep list of all detached panes
wxArrayString panes = m_DPmenuMgr->GetDeatchedPanesList();
DetachedPanesInfo dpi(panes);
EditorConfigST::Get()->WriteObject(wxT("DetachedPanesList"), &dpi);
pane->Destroy();
m_mgr.Update();
}
}
void clMainFrame::OnAuiManagerRender(wxAuiManagerEvent& e)
{
wxAuiManager* mgr = e.GetManager();
wxAuiPaneInfoArray& panes = mgr->GetAllPanes();
wxAcceleratorTable* accelTable = GetAcceleratorTable();
if(accelTable != NULL) {
for(size_t i = 0; i < panes.GetCount(); i++) {
if(panes[i].frame != NULL) {
panes[i].frame->SetAcceleratorTable(*accelTable);
}
}
}
e.Skip();
}
void clMainFrame::OnDockablePaneClosed(wxAuiManagerEvent& e)
{
DockablePane* pane = dynamic_cast<DockablePane*>(e.GetPane()->window);
wxAuiPaneInfo* pInfo = e.GetPane();
if(pInfo->IsOk()) {
DockablePaneMenuManager::HackHidePane(false, *pInfo, &m_mgr);
}
if(pane) {
wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED, XRCID("close_pane"));
pane->GetEventHandler()->ProcessEvent(evt);
} else {
e.Skip();
}
}
void clMainFrame::SetStatusMessage(const wxString& msg, int col, int seconds_to_live /*=wxID_ANY*/)
{
SetStatusText(msg, col);
// if ((col > 0) // We only auto-delete in column 0
// || (seconds_to_live == 0) // which means keep forever
// || msg.empty()) { // not much point deleting an empty string
// return;
// }
//
// int seconds = (seconds_to_live > 0 ? seconds_to_live : 30);
// m_statusbarTimer->Start(seconds * 1000, wxTIMER_ONE_SHOT);
}
void clMainFrame::OnFunctionCalltipUI(wxUpdateUIEvent& event)
{
CHECK_SHUTDOWN();
LEditor* editor = GetMainBook()->GetActiveEditor();
event.Enable(editor ? true : false);
}
void clMainFrame::OnReloadWorkspace(wxCommandEvent& event)
{
wxUnusedVar(event);
// let the plugins close any custom workspace
clCommandEvent e(wxEVT_CMD_RELOAD_WORKSPACE, GetId());
e.SetEventObject(this);
if(EventNotifier::Get()->ProcessEvent(e)) return; // this event was handled by a plugin
IDebugger* dbgr = DebuggerMgr::Get().GetActiveDebugger();
if(dbgr && dbgr->IsRunning()) {
return;
}
SaveLayoutAndSession();
ManagerST::Get()->ReloadWorkspace();
}
void clMainFrame::OnReloadWorkspaceUI(wxUpdateUIEvent& event)
{
CHECK_SHUTDOWN();
event.Enable(ManagerST::Get()->IsWorkspaceOpen());
}
void clMainFrame::RebuildProject(const wxString& projectName)
{
bool enable = !ManagerST::Get()->IsBuildInProgress() && !ManagerST::Get()->GetActiveProjectName().IsEmpty();
if(enable) {
wxString conf;
// get the selected configuration to be built
BuildConfigPtr bldConf = WorkspaceST::Get()->GetProjBuildConf(projectName, wxEmptyString);
if(bldConf) {
conf = bldConf->GetName();
}
// first we place a clean command
QueueCommand buildInfo(projectName, conf, false, QueueCommand::kClean);
if(bldConf && bldConf->IsCustomBuild()) {
buildInfo.SetKind(QueueCommand::kCustomBuild);
buildInfo.SetCustomBuildTarget(wxT("Clean"));
}
ManagerST::Get()->PushQueueCommand(buildInfo);
// now we place a build command
buildInfo = QueueCommand(projectName, conf, false, QueueCommand::kBuild);
if(bldConf && bldConf->IsCustomBuild()) {
buildInfo.SetKind(QueueCommand::kCustomBuild);
buildInfo.SetCustomBuildTarget(wxT("Build"));
}
ManagerST::Get()->PushQueueCommand(buildInfo);
// process the queue
ManagerST::Get()->ProcessCommandQueue();
}
}
void clMainFrame::OnBatchBuildUI(wxUpdateUIEvent& e)
{
CHECK_SHUTDOWN();
bool enable = !ManagerST::Get()->IsBuildInProgress() && ManagerST::Get()->IsWorkspaceOpen();
e.Enable(enable);
}
void clMainFrame::OnBatchBuild(wxCommandEvent& e)
{
BatchBuildDlg* batchBuild = new BatchBuildDlg(this);
if(batchBuild->ShowModal() == wxID_OK) {
// build the projects
std::list<QueueCommand> buildInfoList;
batchBuild->GetBuildInfoList(buildInfoList);
if(buildInfoList.empty() == false) {
std::list<QueueCommand>::iterator iter = buildInfoList.begin();
// add all build items to queue
for(; iter != buildInfoList.end(); iter++) {
ManagerST::Get()->PushQueueCommand(*iter);
}
}
}
batchBuild->Destroy();
// start the build process
ManagerST::Get()->ProcessCommandQueue();
}
void clMainFrame::SetFrameTitle(LEditor* editor)
{
wxString title;
if(editor && editor->GetModify()) {
title << wxT("*");
}
wxString pattern = clConfig::Get().Read("FrameTitlePattern", wxString("$workspace $fullpath"));
wxString username = ::wxGetUserId();
username.Prepend("[ ").Append(" ]");
wxString workspace = WorkspaceST::Get()->GetName();
if(!workspace.IsEmpty()) {
workspace.Prepend("[ ").Append(" ]");
}
wxString fullname, fullpath;
// We support the following macros:
if(editor) {
fullname = editor->GetFileName().GetFullName();
fullpath = editor->GetFileName().GetFullPath();
}
pattern.Replace("$workspace", workspace);
pattern.Replace("$user", username);
pattern.Replace("$filename", fullname);
pattern.Replace("$fullpath", fullpath);
pattern.Trim().Trim(false);
if(pattern.IsEmpty()) {
pattern << "CodeLite";
}
title << pattern;
SetTitle(title);
}
void clMainFrame::OnBuildWorkspace(wxCommandEvent& e)
{
// start the build process
wxUnusedVar(e);
ManagerST::Get()->BuildWorkspace();
}
void clMainFrame::OnBuildWorkspaceUI(wxUpdateUIEvent& e)
{
CHECK_SHUTDOWN();
e.Enable(ManagerST::Get()->IsWorkspaceOpen() && !ManagerST::Get()->IsBuildInProgress());
}
void clMainFrame::OnDetachDebuggerViewTab(wxCommandEvent& e)
{
size_t sel = GetDebuggerPane()->GetNotebook()->GetSelection();
wxWindow* page = GetDebuggerPane()->GetNotebook()->GetCurrentPage();
wxString text = GetDebuggerPane()->GetNotebook()->GetPageText(sel);
wxBitmap bmp = GetDebuggerPane()->GetNotebook()->GetPageBitmap(sel);
#if !CL_USE_NATIVEBOOK
DockablePane* pane = new DockablePane(this, GetDebuggerPane()->GetNotebook(), text, bmp, wxSize(200, 200));
page->Reparent(pane);
// remove the page from the notebook
GetDebuggerPane()->GetNotebook()->RemovePage(sel, false);
pane->SetChildNoReparent(page);
#else
DockablePane* pane = new DockablePane(this, GetDebuggerPane()->GetNotebook(), text, bmp, wxSize(200, 200));
GetDebuggerPane()->GetNotebook()->RemovePage(sel, false);
// HACK: since Reparent will remove the widget from the parent, we need to place it back...
gtk_container_add(GTK_CONTAINER(GetDebuggerPane()->GetNotebook()->m_widget), page->m_widget);
page->Reparent(pane);
pane->SetChildNoReparent(page);
#endif
wxUnusedVar(e);
}
void clMainFrame::OnCleanWorkspace(wxCommandEvent& e)
{
wxUnusedVar(e);
ManagerST::Get()->CleanWorkspace();
}
void clMainFrame::OnCleanWorkspaceUI(wxUpdateUIEvent& e)
{
CHECK_SHUTDOWN();
e.Enable(ManagerST::Get()->IsWorkspaceOpen() && !ManagerST::Get()->IsBuildInProgress());
}
void clMainFrame::OnReBuildWorkspace(wxCommandEvent& e)
{
wxUnusedVar(e);
ManagerST::Get()->RebuildWorkspace();
}
void clMainFrame::OnReBuildWorkspaceUI(wxUpdateUIEvent& e)
{
CHECK_SHUTDOWN();
e.Enable(ManagerST::Get()->IsWorkspaceOpen() && !ManagerST::Get()->IsBuildInProgress());
}
void clMainFrame::OnOpenShellFromFilePath(wxCommandEvent& e)
{
// get the file path
LEditor* editor = GetMainBook()->GetActiveEditor();
if(editor) {
wxString filepath = editor->GetFileName().GetPath();
DirSaver ds;
wxSetWorkingDirectory(filepath);
// Apply the environment variabels before opening the shell
EnvSetter setter;
FileUtils::OpenTerminal(filepath);
}
}
void clMainFrame::ShowWelcomePage()
{
wxWindow* win = GetMainBook()->FindPage(_("Welcome!"));
if(win) {
GetMainBook()->SelectPage(win);
} else {
CreateWelcomePage();
}
}
void clMainFrame::OnSyntaxHighlight(wxCommandEvent& e)
{
SyntaxHighlightDlg dlg(this);
dlg.ShowModal();
}
void clMainFrame::OnQuickDebug(wxCommandEvent& e)
{
// launch the debugger
QuickDebugDlg dlg(this);
if(dlg.ShowModal() == wxID_OK) {
DebuggerMgr::Get().SetActiveDebugger(dlg.GetDebuggerName());
IDebugger* dbgr = DebuggerMgr::Get().GetActiveDebugger();
if(dbgr && !dbgr->IsRunning()) {
std::vector<BreakpointInfo> bpList;
wxString exepath = dlg.GetExe();
wxString wd = dlg.GetWorkingDirectory();
wxArrayString cmds = dlg.GetStartupCmds();
// update the debugger information
DebuggerInformation dinfo;
DebuggerMgr::Get().GetDebuggerInformation(dlg.GetDebuggerName(), dinfo);
dinfo.breakAtWinMain = true;
// read the console command
dinfo.consoleCommand = EditorConfigST::Get()->GetOptions()->GetProgramConsoleCommand();
// ManagerST::Get()->GetBreakpointsMgr()->DelAllBreakpoints(); TODO: Reimplement this when
// UpdateBreakpoints() updates only alterations, rather than delete/re-enter
wxString dbgname = dinfo.path;
dbgname = EnvironmentConfig::Instance()->ExpandVariables(dbgname, true);
// launch the debugger
dbgr->SetObserver(ManagerST::Get());
dbgr->SetDebuggerInformation(dinfo);
// TODO: Reimplement this when UpdateBreakpoints() updates only alterations, rather than delete/re-enter
// GetMainBook()->UpdateBreakpoints();
// get an updated list of breakpoints
ManagerST::Get()->GetBreakpointsMgr()->GetBreakpoints(bpList);
DebuggerStartupInfo startup_info;
startup_info.debugger = dbgr;
// notify plugins that we're about to start debugging
if(SendCmdEvent(wxEVT_DEBUG_STARTING, &startup_info))
// plugin stopped debugging
return;
wxString tty;
#ifndef __WXMSW__
wxString title;
title << _("Debugging: ") << exepath << wxT(" ") << dlg.GetArguments();
if(!ManagerST::Get()->StartTTY(title, tty)) {
wxMessageBox(
_("Could not start TTY console for debugger!"), _("codelite"), wxOK | wxCENTER | wxICON_ERROR);
}
#endif
dbgr->SetIsRemoteDebugging(false);
// Start the debugger
DebugSessionInfo si;
si.debuggerPath = dbgname;
si.exeName = exepath;
si.cwd = wd;
si.cmds = cmds;
si.bpList = bpList;
si.ttyName = tty;
dbgr->Start(si);
// notify plugins that the debugger just started
SendCmdEvent(wxEVT_DEBUG_STARTED, &startup_info);
dbgr->Run(dlg.GetArguments(), wxEmptyString);
// Now the debugger has been fed the breakpoints, re-Initialise the breakpt view,
// so that it uses debugger_ids instead of internal_ids
clMainFrame::Get()->GetDebuggerPane()->GetBreakpointView()->Initialize();
// Layout management
ManagerST::Get()->GetPerspectiveManager().SavePerspective(NORMAL_LAYOUT);
ManagerST::Get()->GetPerspectiveManager().LoadPerspective(DEBUG_LAYOUT);
} else if(!dbgr) {
// Fire an event, maybe a plugin wants to process this
clDebugEvent event(wxEVT_DBG_UI_QUICK_DEBUG);
event.SetDebuggerName(dlg.GetDebuggerName());
event.SetExecutableName(dlg.GetExe());
event.SetWorkingDirectory(dlg.GetWorkingDirectory());
event.SetStartupCommands(wxJoin(dlg.GetStartupCmds(), '\n'));
event.SetArguments(dlg.GetArguments());
EventNotifier::Get()->AddPendingEvent(event);
}
}
}
void clMainFrame::OnDebugCoreDump(wxCommandEvent& e)
{
// launch the debugger
DebugCoreDumpDlg* dlg = new DebugCoreDumpDlg(this);
if(dlg->ShowModal() == wxID_OK) {
DebuggerMgr::Get().SetActiveDebugger(dlg->GetDebuggerName());
IDebugger* dbgr = DebuggerMgr::Get().GetActiveDebugger();
if(dbgr && !dbgr->IsRunning()) {
wxString debuggingcommand;
debuggingcommand << wxT("-c ") << dlg->GetCore() << wxT(" ") << dlg->GetExe();
wxString wd = dlg->GetWorkingDirectory();
// update the debugger information
DebuggerInformation dinfo;
DebuggerMgr::Get().GetDebuggerInformation(dlg->GetDebuggerName(), dinfo);
dinfo.breakAtWinMain = false;
// read the console command
dinfo.consoleCommand = EditorConfigST::Get()->GetOptions()->GetProgramConsoleCommand();
wxString dbgname = dinfo.path;
dbgname = EnvironmentConfig::Instance()->ExpandVariables(dbgname, true);
// launch the debugger
dbgr->SetObserver(ManagerST::Get());
dbgr->SetDebuggerInformation(dinfo);
DebuggerStartupInfo startup_info;
startup_info.debugger = dbgr;
// notify plugins that we're about to start debugging
if(SendCmdEvent(wxEVT_DEBUG_STARTING, &startup_info)) {
dlg->Destroy();
// plugin stopped debugging
return;
}
wxString tty;
wxString title;
title << "Debugging core: " << dlg->GetCore();
#ifndef __WXMSW__
if(!ManagerST::Get()->StartTTY(title, tty)) {
wxMessageBox(
_("Could not start TTY console for debugger!"), _("codelite"), wxOK | wxCENTER | wxICON_ERROR);
}
#endif
dbgr->SetIsRemoteDebugging(false);
// The next two are empty, but are required as parameters
std::vector<BreakpointInfo> bpList;
wxArrayString cmds;
DebugSessionInfo si;
si.debuggerPath = dbgname;
si.exeName = debuggingcommand;
si.cwd = wd;
si.bpList = bpList;
si.cmds = cmds;
si.ttyName = tty;
dbgr->Start(si);
// notify plugins that the debugger just started
SendCmdEvent(wxEVT_DEBUG_STARTED, &startup_info);
// Coredump debugging doesn't use breakpoints, but probably we should do this here anyway...
clMainFrame::Get()->GetDebuggerPane()->GetBreakpointView()->Initialize();
ManagerST::Get()->GetPerspectiveManager().SavePerspective(NORMAL_LAYOUT);
ManagerST::Get()->GetPerspectiveManager().LoadPerspective(DEBUG_LAYOUT);
// Make sure that the debugger pane is visible, and select the stack trace tab
wxAuiPaneInfo& info = GetDockingManager().GetPane(wxT("Debugger"));
if(info.IsOk() && !info.IsShown()) {
ManagerST::Get()->ShowDebuggerPane();
}
clMainFrame::Get()->GetDebuggerPane()->SelectTab(DebuggerPane::FRAMES);
ManagerST::Get()->UpdateDebuggerPane();
// Finally, get the call-stack and 'continue' gdb (which seems to be necessary for things to work...)
dbgr->ListFrames();
dbgr->Continue();
} else if(!dbgr) {
clDebugEvent event(wxEVT_DBG_UI_CORE_FILE);
event.SetDebuggerName(dlg->GetDebuggerName());
event.SetExecutableName(dlg->GetExe());
event.SetCoreFile(dlg->GetCore());
event.SetWorkingDirectory(dlg->GetWorkingDirectory());
EventNotifier::Get()->AddPendingEvent(event);
}
}
dlg->Destroy();
}
void clMainFrame::OnQuickDebugUI(wxUpdateUIEvent& e) // (Also used by DebugCoreDump)
{
CHECK_SHUTDOWN();
e.Enable(true);
}
void clMainFrame::OnShowWhitespaceUI(wxUpdateUIEvent& e)
{
CHECK_SHUTDOWN();
OptionsConfigPtr options = EditorConfigST::Get()->GetOptions();
if(e.GetId() == XRCID("whitepsace_invisible")) {
e.Check(options->GetShowWhitspaces() == 0);
} else if(e.GetId() == XRCID("whitepsace_always")) {
e.Check(options->GetShowWhitspaces() == 1);
} else if(e.GetId() == XRCID("whitespace_visiable_after_indent")) {
e.Check(options->GetShowWhitspaces() == 2);
} else if(e.GetId() == XRCID("whitespace_indent_only")) {
e.Check(options->GetShowWhitspaces() == 3);
}
}
void clMainFrame::OnShowWhitespace(wxCommandEvent& e)
{
OptionsConfigPtr options = EditorConfigST::Get()->GetOptions();
if(e.GetId() == XRCID("whitepsace_invisible")) {
options->SetShowWhitspaces(0);
} else if(e.GetId() == XRCID("whitepsace_always")) {
options->SetShowWhitspaces(1);
} else if(e.GetId() == XRCID("whitespace_visiable_after_indent")) {
options->SetShowWhitspaces(2);
} else if(e.GetId() == XRCID("whitespace_indent_only")) {
options->SetShowWhitspaces(3);
}
GetMainBook()->ShowWhitespace(options->GetShowWhitspaces());
// save the settings
EditorConfigST::Get()->SetOptions(options);
}
void clMainFrame::OnIncrementalSearch(wxCommandEvent& event)
{
wxUnusedVar(event);
GetMainBook()->ShowQuickBar(true);
}
void clMainFrame::OnRetagWorkspace(wxCommandEvent& event)
{
// See if any of the plugins want to handle this event by itself
bool fullRetag = !(event.GetId() == XRCID("retag_workspace"));
wxCommandEvent e(fullRetag ? wxEVT_CMD_RETAG_WORKSPACE_FULL : wxEVT_CMD_RETAG_WORKSPACE, GetId());
e.SetEventObject(this);
if(EventNotifier::Get()->ProcessEvent(e)) return;
TagsManager::RetagType type = TagsManager::Retag_Quick_No_Scan;
if(event.GetId() == XRCID("retag_workspace"))
type = TagsManager::Retag_Quick;
else if(event.GetId() == XRCID("full_retag_workspace"))
type = TagsManager::Retag_Full;
else if(event.GetId() == XRCID("retag_workspace_no_includes"))
type = TagsManager::Retag_Quick_No_Scan;
wxMenu* menu = dynamic_cast<wxMenu*>(event.GetEventObject());
if(menu) {
// the event was fired from the menu bar, trigger a compile_commands.json file generation
// Generate the compile_commands files (needed for Clang)
ManagerST::Get()->GenerateCompileCommands();
}
ManagerST::Get()->RetagWorkspace(type);
}
void clMainFrame::OnShowFullScreen(wxCommandEvent& e)
{
wxUnusedVar(e);
if(IsFullScreen()) {
ShowFullScreen(false);
} else {
ShowFullScreen(true, wxFULLSCREEN_NOCAPTION | wxFULLSCREEN_NOBORDER);
// Re-apply the menu accelerators
ManagerST::Get()->UpdateMenuAccelerators();
}
}
void clMainFrame::OnSetStatusMessage(wxCommandEvent& e)
{
CHECK_SHUTDOWN();
wxString msg = e.GetString();
int col = e.GetInt();
int seconds_to_live = e.GetId();
SetStatusMessage(msg, col, seconds_to_live);
}
void clMainFrame::OnReloadExternallModified(wxCommandEvent& e)
{
wxUnusedVar(e);
ReloadExternallyModifiedProjectFiles();
GetMainBook()->ReloadExternallyModified(true);
}
void clMainFrame::OnReloadExternallModifiedNoPrompt(wxCommandEvent& e)
{
wxUnusedVar(e);
GetMainBook()->ReloadExternallyModified(false);
}
bool clMainFrame::ReloadExternallyModifiedProjectFiles()
{
if(ManagerST::Get()->IsWorkspaceOpen() == false) {
return false;
}
Workspace* workspace = WorkspaceST::Get();
bool workspace_modified = false, project_modified = false;
// check if the workspace needs reloading and ask the user for confirmation
// if it does
if(workspace->GetWorkspaceLastModifiedTime() < workspace->GetFileLastModifiedTime()) {
// always update last modification time: if the user chooses to reload it
// will not matter, and it avoids the program prompting the user repeatedly
// if he chooses not to reload the workspace
workspace->SetWorkspaceLastModifiedTime(workspace->GetFileLastModifiedTime());
workspace_modified = true;
}
// check if any of the projects in the workspace needs reloading
wxArrayString projects;
workspace->GetProjectList(projects);
for(size_t i = 0; i < projects.GetCount(); ++i) {
wxString errStr;
ProjectPtr proj = workspace->FindProjectByName(projects[i], errStr);
if(proj->GetProjectLastModifiedTime() < proj->GetFileLastModifiedTime()) {
// always update last modification time: if the user chooses to reload it
// will not matter, and it avoids the program prompting the user repeatedly
// if he chooses not to reload some of the projects
proj->SetProjectLastModifiedTime(proj->GetFileLastModifiedTime());
project_modified = true;
}
}
if(!project_modified && !workspace_modified) return false;
// Make sure we don't have the mouse captured in any editor or we might get a crash somewhere
wxStandardID res = ::PromptForYesNoDialogWithCheckbox(_("Workspace or project settings have been modified outside "
"of CodeLite\nWould you like to reload the workspace?"),
"ReloadWorkspaceWhenAltered",
_("Reload workspace"),
_("Not now"));
// Don't do anything if "X" is pressed
if(res != wxID_CANCEL) {
if(res == wxID_YES) {
wxCommandEvent evtReload(wxEVT_COMMAND_MENU_SELECTED, XRCID("reload_workspace"));
GetEventHandler()->ProcessEvent(evtReload);
} else {
// user cancelled the dialog or chosed not to reload the workspace
if(GetMainBook()->GetActiveEditor()) {
GetMainBook()->GetActiveEditor()->CallAfter(&LEditor::SetActive);
}
}
}
return true;
}
void clMainFrame::SaveLayoutAndSession()
{
EditorConfigST::Get()->SaveLexers();
// save general information
if(IsMaximized()) {
m_frameGeneralInfo.SetFrameSize(wxSize(800, 600));
} else {
m_frameGeneralInfo.SetFrameSize(this->GetSize());
}
#ifdef __WXMAC__
m_frameGeneralInfo.SetFramePosition(wxPoint(50, 50));
#else
m_frameGeneralInfo.SetFramePosition(this->GetScreenPosition());
#endif
EditorConfigST::Get()->Begin();
SetFrameFlag(IsMaximized(), CL_MAXIMIZE_FRAME);
EditorConfigST::Get()->WriteObject(wxT("GeneralInfo"), &m_frameGeneralInfo);
EditorConfigST::Get()->SaveLongValue(wxT("ShowNavBar"), m_mainBook->IsNavBarShown() ? 1 : 0);
GetWorkspacePane()->SaveWorkspaceViewTabOrder();
// save the current session before closing
wxString sessionName = ManagerST::Get()->IsWorkspaceOpen() ?
WorkspaceST::Get()->GetWorkspaceFileName().GetFullPath() :
wxString(wxT("Default"));
SessionEntry session;
session.SetWorkspaceName(sessionName);
wxArrayInt unused;
GetMainBook()->SaveSession(session, unused);
ManagerST::Get()->GetBreakpointsMgr()->SaveSession(session);
SessionManager::Get().Save(sessionName, session);
SessionManager::Get().SetLastWorkspaceName(sessionName);
// make sure there are no 'unsaved documents'
GetMainBook()->CloseAll(false);
// keep list of all detached panes
wxArrayString panes = m_DPmenuMgr->GetDeatchedPanesList();
DetachedPanesInfo dpi(panes);
EditorConfigST::Get()->WriteObject(wxT("DetachedPanesList"), &dpi);
// Update the current perspective - but only if it is the default perspective
if(ManagerST::Get()->GetPerspectiveManager().IsDefaultActive()) {
ManagerST::Get()->GetPerspectiveManager().SavePerspective();
}
// save the notebooks styles
EditorConfigST::Get()->SaveLongValue(wxT("MainBook"), GetMainBook()->GetBookStyle());
EditorConfigST::Get()->SaveLongValue(wxT("FindResults"), GetOutputPane()->GetFindResultsTab()->GetBookStyle());
EditorConfigST::Get()->Save();
}
void clMainFrame::OnNextFiFMatch(wxCommandEvent& e)
{
wxUnusedVar(e);
GetOutputPane()->GetFindResultsTab()->NextMatch();
}
void clMainFrame::OnPreviousFiFMatch(wxCommandEvent& e)
{
wxUnusedVar(e);
GetOutputPane()->GetFindResultsTab()->PrevMatch();
}
void clMainFrame::OnNextFiFMatchUI(wxUpdateUIEvent& e)
{
CHECK_SHUTDOWN();
e.Enable(GetOutputPane()->GetFindResultsTab()->GetPageCount() > 0);
}
void clMainFrame::OnPreviousFiFMatchUI(wxUpdateUIEvent& e)
{
CHECK_SHUTDOWN();
e.Enable(GetOutputPane()->GetFindResultsTab()->GetPageCount() > 0);
}
void clMainFrame::OnFindResourceXXX(wxCommandEvent& e)
{
// Determine the search type
// Let the plugins a chance before we handle this event
wxCommandEvent eventOpenResource(wxEVT_CMD_OPEN_RESOURCE, GetId());
eventOpenResource.SetEventObject(this);
if(EventNotifier::Get()->ProcessEvent(eventOpenResource)) return;
OpenResourceDialog dlg(this, PluginManager::Get());
if(dlg.ShowModal() == wxID_OK) {
OpenResourceDialog::OpenSelection(dlg.GetSelection(), PluginManager::Get());
}
}
void clMainFrame::OnParsingThreadMessage(wxCommandEvent& e)
{
wxString* msg = (wxString*)e.GetClientData();
if(msg) {
wxLogMessage(*msg);
delete msg;
}
}
void clMainFrame::OnDatabaseUpgradeInternally(wxCommandEvent& e)
{
wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED, XRCID("full_retag_workspace"));
this->AddPendingEvent(evt);
// GetMainBook()->ShowMessage(_("Your workspace symbols file does not match the current version of CodeLite.
// CodeLite will perform a full retag of the workspace"));
}
// Due to differnet schema versions, the database was truncated by the
// TagsManager, prompt the user
void clMainFrame::OnDatabaseUpgrade(wxCommandEvent& e)
{
wxUnusedVar(e);
// turn ON the retag-required flag and perform it in the OnTimer() callback
// this is to allow codelite to update paths if needed *before* the retag is taking place
// (CC paths will be updated if needed in the OnTimer() callback)
m_workspaceRetagIsRequired = true;
}
void clMainFrame::UpdateTagsOptions(const TagsOptionsData& tod)
{
m_tagsOptionsData = tod;
TagsManagerST::Get()->SetCtagsOptions(m_tagsOptionsData);
clConfig ccConfig("code-completion.conf");
ccConfig.WriteItem(&m_tagsOptionsData);
ParseThreadST::Get()->SetSearchPaths(tod.GetParserSearchPaths(), tod.GetParserExcludePaths());
}
void clMainFrame::OnCheckForUpdate(wxCommandEvent& e)
{
JobQueueSingleton::Instance()->PushJob(new WebUpdateJob(this, true));
}
void clMainFrame::OnShowActiveProjectSettings(wxCommandEvent& e)
{
wxUnusedVar(e);
if(!WorkspaceST::Get()->IsOpen()) {
return;
}
GetWorkspaceTab()->OpenProjectSettings();
}
void clMainFrame::OnShowActiveProjectSettingsUI(wxUpdateUIEvent& e)
{
CHECK_SHUTDOWN();
wxArrayString projectList;
WorkspaceST::Get()->GetProjectList(projectList);
e.Enable(ManagerST::Get()->IsWorkspaceOpen() && (projectList.IsEmpty() == false));
}
void clMainFrame::StartTimer() { m_timer->Start(1000, true); }
void clMainFrame::OnLoadPerspective(wxCommandEvent& e)
{
wxString file;
file << clStandardPaths::Get().GetUserDataDir() << wxT("/config/codelite.layout");
wxFileName oldLayoutFile(file);
if(oldLayoutFile.FileExists(file)) {
wxRemoveFile(oldLayoutFile.GetFullPath());
wxCommandEvent eventRestoreLayout(wxEVT_COMMAND_MENU_SELECTED, XRCID("restore_layout"));
eventRestoreLayout.SetEventObject(this);
GetEventHandler()->ProcessEvent(eventRestoreLayout);
} else {
ManagerST::Get()->GetPerspectiveManager().LoadPerspective(NORMAL_LAYOUT);
// Update the current perspective
if(ManagerST::Get()->GetPerspectiveManager().IsDefaultActive()) {
ManagerST::Get()->GetPerspectiveManager().SavePerspective();
}
}
}
void clMainFrame::SelectBestEnvSet()
{
///////////////////////////////////////////////////
// Select the environment variables set to use
///////////////////////////////////////////////////
// Set the workspace's environment variable set to the active one
wxString projectSetName;
wxString projectDbgSetName;
// First, if the project has an environment which is not '<Use Defaults>' use it
if(ManagerST::Get()->IsWorkspaceOpen()) {
wxString activeProj = WorkspaceST::Get()->GetActiveProjectName();
ProjectPtr p = ManagerST::Get()->GetProject(activeProj);
if(p) {
BuildConfigPtr buildConf = WorkspaceST::Get()->GetProjBuildConf(activeProj, wxEmptyString);
if(buildConf) {
if(buildConf->GetEnvVarSet() != USE_WORKSPACE_ENV_VAR_SET &&
buildConf->GetEnvVarSet() != wxT("<Use Workspace Settings>") /* backward support */) {
projectSetName = buildConf->GetEnvVarSet();
}
if(buildConf->GetDbgEnvSet() != USE_GLOBAL_SETTINGS) {
projectDbgSetName = buildConf->GetDbgEnvSet();
}
}
}
}
wxString workspaceSetName = LocalWorkspaceST::Get()->GetActiveEnvironmentSet();
wxString globalActiveSet = wxT("Default");
wxString activeSetName;
EvnVarList vars = EnvironmentConfig::Instance()->GetSettings();
// By default, use the global one
activeSetName = globalActiveSet;
if(!projectSetName.IsEmpty() && vars.IsSetExist(projectSetName)) {
activeSetName = projectSetName;
} else if(!workspaceSetName.IsEmpty() && vars.IsSetExist(workspaceSetName)) {
activeSetName = workspaceSetName;
}
vars.SetActiveSet(activeSetName);
EnvironmentConfig::Instance()->SetSettings(vars);
///////////////////////////////////////////////////
// Select the debugger PreDefined Types settings
///////////////////////////////////////////////////
DebuggerSettingsPreDefMap preDefTypeMap;
DebuggerConfigTool::Get()->ReadObject(wxT("DebuggerCommands"), &preDefTypeMap);
wxString dbgSetName = wxT("Default");
if(!projectDbgSetName.IsEmpty() && preDefTypeMap.IsSetExist(projectDbgSetName)) {
dbgSetName = projectDbgSetName;
}
preDefTypeMap.SetActive(dbgSetName);
DebuggerConfigTool::Get()->WriteObject(wxT("DebuggerCommands"), &preDefTypeMap);
wxString displayString = wxString::Format(
wxT("Env: %s, Dbg: %s"), activeSetName.c_str(), preDefTypeMap.GetActiveSet().GetName().c_str());
SetStatusMessage(displayString, 2);
}
void clMainFrame::OnClearTagsCache(wxCommandEvent& e)
{
e.Skip();
TagsManagerST::Get()->ClearTagsCache();
SetStatusMessage(_("Tags cache cleared"), 0);
}
void clMainFrame::OnUpdateNumberOfBuildProcesses(wxCommandEvent& e)
{
int cpus = wxThread::GetCPUCount();
BuilderConfigPtr bs = BuildSettingsConfigST::Get()->GetBuilderConfig(wxT("GNU makefile for g++/gcc"));
if(bs && cpus != wxNOT_FOUND) {
wxString jobs;
jobs << cpus;
bs->SetToolJobs(jobs);
BuildSettingsConfigST::Get()->SetBuildSystem(bs);
wxLogMessage(wxT("Info: setting number of concurrent builder jobs to ") + jobs);
}
}
void clMainFrame::OnWorkspaceEditorPreferences(wxCommandEvent& e)
{
GetWorkspaceTab()->GetFileView()->GetEventHandler()->ProcessEvent(e);
}
void clMainFrame::OnWorkspaceSettings(wxCommandEvent& e)
{
GetWorkspaceTab()->GetFileView()->GetEventHandler()->ProcessEvent(e);
}
void clMainFrame::OnGotoCodeLiteDownloadPage(wxCommandEvent& e)
{
wxUnusedVar(e);
wxLaunchDefaultBrowser(m_codeliteDownloadPageURL);
m_codeliteDownloadPageURL.Clear();
}
void clMainFrame::DoSuggestRestart()
{
#ifdef __WXMAC__
GetMainBook()->ShowMessage(_("Some of the changes made requires restart of CodeLite"));
#else
// On Winodws & GTK we offer auto-restart
ButtonDetails btn1, btn2;
btn1.buttonLabel = _("Restart Now!");
btn1.commandId = wxEVT_CMD_RESTART_CODELITE;
btn1.menuCommand = false;
btn1.isDefault = true;
btn1.window = ManagerST::Get();
// set button window to NULL
btn2.buttonLabel = _("Not now");
btn2.window = NULL;
GetMainBook()->ShowMessage(_("Some of the changes made require a restart of CodeLite. Restart now?"),
false,
PluginManager::Get()->GetStdIcons()->LoadBitmap(wxT("messages/48/restart")),
btn1,
btn2);
#endif
}
void clMainFrame::OnRestoreDefaultLayout(wxCommandEvent& e)
{
e.Skip();
#ifndef __WXMAC__
clWindowUpdateLocker locker(this);
#endif
wxLogMessage(wxT("Restoring layout"));
// Close all docking panes
wxAuiPaneInfoArray& panes = m_mgr.GetAllPanes();
for(size_t i = 0; i < panes.GetCount(); i++) {
// make sure that the caption is visible
panes.Item(i).CaptionVisible(true);
wxAuiPaneInfo &p = panes.Item(i);
if(p.window) {
DockablePane* d = dynamic_cast<DockablePane*>(p.window);
if(d) {
wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED, XRCID("close_pane"));
p.window->GetEventHandler()->AddPendingEvent(evt);
}
}
}
ManagerST::Get()->GetPerspectiveManager().DeleteAllPerspectives();
m_mgr.LoadPerspective(m_defaultLayout, false);
UpdateAUI();
// Save the current layout as the 'Default' layout
ManagerST::Get()->GetPerspectiveManager().SavePerspective(NORMAL_LAYOUT);
}
void clMainFrame::SetAUIManagerFlags()
{
// Set the manager flags
unsigned int auiMgrFlags = wxAUI_MGR_ALLOW_FLOATING;
int dockingStyle = EditorConfigST::Get()->GetOptions()->GetDockingStyle();
switch(dockingStyle) {
case 0: // Transparent hint
auiMgrFlags |= wxAUI_MGR_TRANSPARENT_HINT;
break;
case 1: // Rectangle
auiMgrFlags |= wxAUI_MGR_RECTANGLE_HINT;
break;
case 2: // Venetians blinds hint
auiMgrFlags |= wxAUI_MGR_VENETIAN_BLINDS_HINT;
break;
}
auiMgrFlags |= wxAUI_MGR_ALLOW_ACTIVE_PANE;
#if defined(__WXMAC__) || defined(__WXMSW__)
auiMgrFlags |= wxAUI_MGR_LIVE_RESIZE;
#endif
m_mgr.SetFlags(auiMgrFlags);
}
void clMainFrame::UpdateAUI()
{
SetAUIManagerFlags();
m_mgr.Update();
}
void clMainFrame::OnRetaggingCompelted(wxCommandEvent& e)
{
e.Skip();
SetStatusMessage(_("Done"), 0);
GetWorkspacePane()->ClearProgress();
// Clear all cached tags now that we got our database updated
TagsManagerST::Get()->ClearAllCaches();
// Send event notifying parsing completed
std::vector<std::string>* files = (std::vector<std::string>*)e.GetClientData();
if(files) {
// Print the parsing end time
wxLogMessage(_("INFO: Retag workspace completed in %ld seconds (%lu files were scanned)"),
gStopWatch.Time() / 1000,
(unsigned long)files->size());
std::vector<wxFileName> taggedFiles;
for(size_t i = 0; i < files->size(); i++) {
taggedFiles.push_back(wxFileName(wxString(files->at(i).c_str(), wxConvUTF8)));
}
SendCmdEvent(wxEVT_FILE_RETAGGED, (void*)&taggedFiles);
delete files;
} else {
wxLogMessage(_("INFO: Retag workspace completed in 0 seconds (No files were retagged)"));
}
wxCommandEvent tagEndEvent(wxEVT_CMD_RETAG_COMPLETED);
tagEndEvent.SetClientData(e.GetClientData()); // pass the pointer to the original caller
EventNotifier::Get()->AddPendingEvent(tagEndEvent);
}
void clMainFrame::OnRetaggingProgress(wxCommandEvent& e)
{
e.Skip();
if(e.GetInt() == 1) {
// parsing started
gStopWatch.Start();
}
GetWorkspacePane()->UpdateProgress(e.GetInt());
}
void clMainFrame::OnRetagWorkspaceUI(wxUpdateUIEvent& event)
{
CHECK_SHUTDOWN();
// See whether we got a custom workspace open in one of the plugins
clCommandEvent e(wxEVT_CMD_IS_WORKSPACE_OPEN, GetId());
e.SetEventObject(this);
e.SetAnswer(false);
EventNotifier::Get()->ProcessEvent(e);
event.Enable((ManagerST::Get()->IsWorkspaceOpen() && !ManagerST::Get()->GetRetagInProgress()) || e.IsAnswer());
}
wxString clMainFrame::StartTTY(const wxString& title)
{
#ifndef __WXMSW__
// Create a new TTY Console and place it in the AUI
ConsoleFrame* console = new ConsoleFrame(this, PluginManager::Get());
wxAuiPaneInfo paneInfo;
paneInfo.Name(wxT("Debugger Console")).Caption(title).Dockable().FloatingSize(300, 200).CloseButton(false);
m_mgr.AddPane(console, paneInfo);
// Re-set the title (it might be modified by 'LoadPerspective'
wxAuiPaneInfo& pi = m_mgr.GetPane(wxT("Debugger Console"));
if(pi.IsOk()) {
pi.Caption(title);
}
wxAuiPaneInfo& info = m_mgr.GetPane(wxT("Debugger Console"));
if(info.IsShown() == false) {
info.Show();
m_mgr.Update();
}
return console->StartTTY();
#else
return wxT("");
#endif
}
void clMainFrame::OnViewWordWrap(wxCommandEvent& e)
{
CHECK_SHUTDOWN();
OptionsConfigPtr opts = EditorConfigST::Get()->GetOptions();
opts->SetWordWrap(e.IsChecked());
EditorConfigST::Get()->SetOptions(opts);
GetMainBook()->SetViewWordWrap(e.IsChecked());
}
void clMainFrame::OnViewWordWrapUI(wxUpdateUIEvent& e)
{
CHECK_SHUTDOWN();
LEditor* editor = GetMainBook()->GetActiveEditor();
bool hasEditor = editor ? true : false;
if(!hasEditor) {
e.Enable(false);
return;
}
OptionsConfigPtr opts = EditorConfigST::Get()->GetOptions();
e.Enable(true);
e.Check(opts->GetWordWrap());
}
void clMainFrame::OnGrepWord(wxCommandEvent& e)
{
CHECK_SHUTDOWN();
LEditor* editor = GetMainBook()->GetActiveEditor();
if(!editor || editor->GetSelectedText().IsEmpty()) return;
// Prepare the search data
bool singleFileSearch(true);
if(e.GetId() == XRCID("grep_current_workspace")) singleFileSearch = false;
SearchData data;
data.SetFindString(editor->GetSelectedText());
data.SetMatchCase(true);
data.SetMatchWholeWord(true);
data.SetRegularExpression(false);
data.SetDisplayScope(false);
data.SetEncoding(wxFontMapper::GetEncodingName(editor->GetOptions()->GetFileFontEncoding()));
data.SetSkipComments(false);
data.SetSkipStrings(false);
data.SetColourComments(false);
wxArrayString files;
wxArrayString rootDirs;
if(singleFileSearch) {
rootDirs.Add(wxGetTranslation(SEARCH_IN_CURRENT_FILE));
files.Add(editor->GetFileName().GetFullPath());
} else {
rootDirs.Add(wxGetTranslation(SEARCH_IN_WORKSPACE));
ManagerST::Get()->GetWorkspaceFiles(files);
}
data.SetRootDirs(rootDirs);
data.SetFiles(files);
data.UseNewTab(true);
data.SetOwner(GetOutputPane()->GetFindResultsTab());
SearchThreadST::Get()->PerformSearch(data);
}
void clMainFrame::OnGrepWordUI(wxUpdateUIEvent& e)
{
CHECK_SHUTDOWN();
LEditor* editor = GetMainBook()->GetActiveEditor();
e.Enable(editor && !editor->GetSelectedText().IsEmpty());
}
void clMainFrame::OnPchCacheEnded(wxCommandEvent& e)
{
e.Skip();
// SetStatusMessage(wxString::Format(wxT("Generating PCH completed")), 0);
}
void clMainFrame::OnPchCacheStarted(wxCommandEvent& e)
{
e.Skip();
// wxString *filename = (wxString*)e.GetClientData();
// wxFileName fn(*filename);
// delete filename;
//
// SetStatusMessage(wxString::Format(wxT("Generating PCH for file: %s"), fn.GetFullName().c_str()), 0);
}
////////////////// View -> Workspace View -> /////////////////////////////////////
void clMainFrame::OnViewShowExplorerTab(wxCommandEvent& e)
{
DoEnableWorkspaceViewFlag(e.IsChecked(), View_Show_Explorer_Tab);
GetWorkspacePane()->UpdateTabs();
}
void clMainFrame::OnViewShowExplorerTabUI(wxUpdateUIEvent& event)
{
event.Check(GetWorkspacePane()->IsTabVisible(View_Show_Explorer_Tab));
}
void clMainFrame::OnViewShowTabgroups(wxCommandEvent& e)
{
DoEnableWorkspaceViewFlag(e.IsChecked(), View_Show_Tabgroups_Tab);
GetWorkspacePane()->UpdateTabs();
}
void clMainFrame::OnViewShowTabgroupsUI(wxUpdateUIEvent& event)
{
event.Check(GetWorkspacePane()->IsTabVisible(View_Show_Tabgroups_Tab));
}
void clMainFrame::OnViewShowTabs(wxCommandEvent& e)
{
DoEnableWorkspaceViewFlag(e.IsChecked(), View_Show_Tabs_Tab);
GetWorkspacePane()->UpdateTabs();
}
void clMainFrame::OnViewShowTabsUI(wxUpdateUIEvent& event)
{
event.Check(GetWorkspacePane()->IsTabVisible(View_Show_Tabs_Tab));
}
void clMainFrame::OnViewShowWorkspaceTab(wxCommandEvent& e)
{
DoEnableWorkspaceViewFlag(e.IsChecked(), View_Show_Workspace_Tab);
GetWorkspacePane()->UpdateTabs();
}
void clMainFrame::OnViewShowWorkspaceTabUI(wxUpdateUIEvent& event)
{
event.Check(GetWorkspacePane()->IsTabVisible(View_Show_Workspace_Tab));
}
///////////////////// Helper methods /////////////////////////////
void clMainFrame::DoEnableWorkspaceViewFlag(bool enable, int flag)
{
long flags = View_Show_Default;
EditorConfigST::Get()->GetLongValue(wxT("view_workspace_view"), flags);
if(enable) {
flags |= flag;
} else {
flags &= ~flag;
}
EditorConfigST::Get()->SaveLongValue(wxT("view_workspace_view"), flags);
}
bool clMainFrame::IsWorkspaceViewFlagEnabled(int flag)
{
long flags = View_Show_Default;
EditorConfigST::Get()->GetLongValue(wxT("view_workspace_view"), flags);
return (flags & flag);
}
void clMainFrame::DoUpdatePerspectiveMenu()
{
// Locate the "perspective_menu"
wxMenu* menu = NULL;
GetMenuBar()->FindItem(XRCID("manage_perspectives"), &menu);
if(!menu) {
return;
}
std::vector<int> menuItemIds;
const wxMenuItemList& items = menu->GetMenuItems();
wxMenuItemList::const_iterator iter = items.begin();
for(; iter != items.end(); iter++) {
wxMenuItem* menuItem = *iter;
if(menuItem->GetId() == wxID_SEPARATOR || menuItem->GetId() == XRCID("save_current_layout") ||
menuItem->GetId() == XRCID("manage_perspectives") || menuItem->GetId() == XRCID("restore_layout"))
continue;
menuItemIds.push_back(menuItem->GetId());
}
for(size_t i = 0; i < menuItemIds.size(); i++) {
menu->Delete(menuItemIds.at(i));
}
wxArrayString perspectives = ManagerST::Get()->GetPerspectiveManager().GetAllPerspectives();
for(size_t i = 0; i < perspectives.GetCount(); i++) {
wxString name = perspectives.Item(i);
menu->Prepend(ManagerST::Get()->GetPerspectiveManager().MenuIdFromName(name), name, wxT(""), true);
}
}
// Perspective management
void clMainFrame::OnChangePerspective(wxCommandEvent& e)
{
ManagerST::Get()->GetPerspectiveManager().LoadPerspectiveByMenuId(e.GetId());
}
void clMainFrame::OnManagePerspectives(wxCommandEvent& e)
{
ManagePerspectivesDlg dlg(this);
dlg.ShowModal();
DoUpdatePerspectiveMenu();
}
void clMainFrame::OnSaveLayoutAsPerspective(wxCommandEvent& e)
{
SavePerspectiveDlg dlg(this);
if(dlg.ShowModal() == wxID_OK && !dlg.GetPerspectiveName().IsEmpty()) {
ManagerST::Get()->GetPerspectiveManager().SavePerspective(dlg.GetPerspectiveName());
}
}
void clMainFrame::OnRefreshPerspectiveMenu(wxCommandEvent& e) { DoUpdatePerspectiveMenu(); }
void clMainFrame::OnChangePerspectiveUI(wxUpdateUIEvent& e)
{
wxString active = ManagerST::Get()->GetPerspectiveManager().GetActive();
wxString itemName = ManagerST::Get()->GetPerspectiveManager().NameFromMenuId(e.GetId());
e.Check(active.CmpNoCase(itemName) == 0);
}
void clMainFrame::OnParserThreadReady(wxCommandEvent& e)
{
e.Skip();
ManagerST::Get()->SetRetagInProgress(false);
if(ManagerST::Get()->IsShutdownInProgress()) {
// we are in shutdown progress, dont do anything
return;
}
wxUnusedVar(e);
SetStatusMessage(wxEmptyString, 0);
if(e.GetInt() == ParseRequest::PR_SUGGEST_HIGHLIGHT_WORDS)
// no need to trigger another UpdateColour
return;
LEditor* editor = GetMainBook()->GetActiveEditor();
if(editor) {
editor->UpdateColours();
}
}
void clMainFrame::OnFileSaveUI(wxUpdateUIEvent& event)
{
CHECK_SHUTDOWN();
LEditor* editor = GetMainBook()->GetActiveEditor(true);
if(editor) {
event.Enable(editor->IsModified());
} else {
wxWindow* page = GetMainBook()->GetCurrentPage();
if(page) {
event.Skip();
} else {
event.Enable(false);
}
}
}
void clMainFrame::OnActivateEditor(wxCommandEvent& e)
{
LEditor* editor = dynamic_cast<LEditor*>(e.GetEventObject());
if(editor) editor->SetActive();
}
void clMainFrame::OnActiveEditorChanged(wxCommandEvent& e)
{
e.Skip();
SelectBestEnvSet(); // Updates the statusbar bookmark display
}
void clMainFrame::OnLoadSession(wxCommandEvent& e)
{
wxUnusedVar(e);
LoadSession(SessionManager::Get().GetLastSession());
}
void clMainFrame::OnShowBookmarkMenu(wxAuiToolBarEvent& e)
{
if(e.IsDropDownClicked()) {
wxMenu* menu = BookmarkManager::Get().CreateBookmarksSubmenu(
NULL); // Despite the name, this provides almost all the bookmark menuitems
if(!menu) {
e.Skip();
return;
}
menu->Append(XRCID("removeall_bookmarks"), _("Remove All Bookmarks")); // This missing one
wxAuiToolBar* auibar = dynamic_cast<wxAuiToolBar*>(e.GetEventObject());
if(auibar) {
clAuiToolStickness ts(auibar, e.GetToolId());
wxRect rect = auibar->GetToolRect(e.GetId());
wxPoint pt = auibar->ClientToScreen(rect.GetBottomLeft());
pt = ScreenToClient(pt);
PopupMenu(menu, pt);
}
delete menu;
} else {
e.Skip();
}
}
void clMainFrame::OnShowAuiBuildMenu(wxAuiToolBarEvent& e)
{
if(e.IsDropDownClicked()) {
wxMenu menu;
DoCreateBuildDropDownMenu(&menu);
wxAuiToolBar* auibar = dynamic_cast<wxAuiToolBar*>(e.GetEventObject());
if(auibar) {
clAuiToolStickness ts(auibar, e.GetToolId());
wxRect rect = auibar->GetToolRect(e.GetId());
wxPoint pt = auibar->ClientToScreen(rect.GetBottomLeft());
pt = ScreenToClient(pt);
PopupMenu(&menu, pt);
}
} else {
e.Skip();
}
}
void clMainFrame::OnUpdateCustomTargetsDropDownMenu(wxCommandEvent& e)
{
e.Skip();
wxMenu* buildDropDownMenu = new wxMenu;
DoCreateBuildDropDownMenu(buildDropDownMenu);
if(GetToolBar() && GetToolBar()->FindById(XRCID("build_active_project"))) {
GetToolBar()->SetDropdownMenu(XRCID("build_active_project"), buildDropDownMenu);
}
}
void clMainFrame::DoCreateBuildDropDownMenu(wxMenu* menu)
{
menu->Append(XRCID("build_active_project_only"), wxT("Project Only » Build"));
menu->Append(XRCID("clean_active_project_only"), wxT("Project Only » Clean"));
// build the menu and show it
BuildConfigPtr bldcfg = WorkspaceST::Get()->GetProjBuildConf(WorkspaceST::Get()->GetActiveProjectName(), "");
if(bldcfg && bldcfg->IsCustomBuild()) {
// Update teh custom targets
CustomTargetsMgr::Get().SetTargets(WorkspaceST::Get()->GetActiveProjectName(), bldcfg->GetCustomTargets());
if(!CustomTargetsMgr::Get().GetTargets().empty()) {
menu->AppendSeparator();
}
const CustomTargetsMgr::Map_t& targets = CustomTargetsMgr::Get().GetTargets();
CustomTargetsMgr::Map_t::const_iterator iter = targets.begin();
for(; iter != targets.end(); ++iter) {
int winid = iter->first; // contains the menu ID
menu->Append(winid, iter->second.first);
}
} else {
wxLogMessage("Could not locate build configuration for project: " + WorkspaceST::Get()->GetActiveProjectName());
}
}
void clMainFrame::OnWorkspaceClosed(wxCommandEvent& e)
{
e.Skip();
CustomTargetsMgr::Get().Clear();
// Reset the menu
wxMenu* buildDropDownMenu = new wxMenu;
if(GetToolBar() && GetToolBar()->FindById(XRCID("build_active_project"))) {
GetToolBar()->SetDropdownMenu(XRCID("build_active_project"), buildDropDownMenu);
}
}
void clMainFrame::OnIncrementalSearchUI(wxUpdateUIEvent& event)
{
CHECK_SHUTDOWN();
event.Enable(m_mainBook->GetCurrentPage() != NULL);
}
void clMainFrame::OnBuildProjectOnly(wxCommandEvent& event)
{
wxCommandEvent e(wxEVT_CMD_BUILD_PROJECT_ONLY);
EventNotifier::Get()->AddPendingEvent(e);
}
void clMainFrame::OnCleanProjectOnly(wxCommandEvent& event)
{
wxCommandEvent e(wxEVT_CMD_CLEAN_PROJECT_ONLY);
EventNotifier::Get()->AddPendingEvent(e);
}
void clMainFrame::OnFileSaveAllUI(wxUpdateUIEvent& event)
{
bool hasModifiedEditor = false;
std::vector<LEditor*> editors;
GetMainBook()->GetAllEditors(editors, MainBook::kGetAll_IncludeDetached);
for(size_t i = 0; i < editors.size(); ++i) {
if(editors.at(i)->IsModified()) {
hasModifiedEditor = true;
break;
}
}
event.Enable(hasModifiedEditor);
}
void clMainFrame::OnShowDebuggerWindow(wxCommandEvent& e)
{
// load the debugger configuration
clConfig conf("debugger-view.conf");
DebuggerPaneConfig item;
conf.ReadItem(&item);
bool show = e.IsChecked();
if(e.GetId() == XRCID("debugger_win_locals")) item.ShowDebuggerWindow(DebuggerPaneConfig::Locals, show);
if(e.GetId() == XRCID("debugger_win_watches")) item.ShowDebuggerWindow(DebuggerPaneConfig::Watches, show);
if(e.GetId() == XRCID("debugger_win_output")) item.ShowDebuggerWindow(DebuggerPaneConfig::Output, show);
if(e.GetId() == XRCID("debugger_win_threads")) item.ShowDebuggerWindow(DebuggerPaneConfig::Threads, show);
if(e.GetId() == XRCID("debugger_win_callstack")) item.ShowDebuggerWindow(DebuggerPaneConfig::Callstack, show);
if(e.GetId() == XRCID("debugger_win_memory")) item.ShowDebuggerWindow(DebuggerPaneConfig::Memory, show);
if(e.GetId() == XRCID("debugger_win_breakpoints")) item.ShowDebuggerWindow(DebuggerPaneConfig::Breakpoints, show);
if(e.GetId() == XRCID("debugger_win_asciiview")) item.ShowDebuggerWindow(DebuggerPaneConfig::AsciiViewer, show);
if(e.GetId() == XRCID("debugger_win_disassemble")) item.ShowDebuggerWindow(DebuggerPaneConfig::Disassemble, show);
conf.WriteItem(&item);
// Reload the perspective
ManagerST::Get()->GetPerspectiveManager().LoadPerspective();
}
void clMainFrame::OnShowDebuggerWindowUI(wxUpdateUIEvent& e)
{
// load the debugger configuration
// clConfig conf("debugger-view.conf");
DebuggerPaneConfig item;
// conf.ReadItem( &item );
DebuggerPaneConfig::eDebuggerWindows winid = DebuggerPaneConfig::None;
if(e.GetId() == XRCID("debugger_win_locals")) winid = DebuggerPaneConfig::Locals;
if(e.GetId() == XRCID("debugger_win_watches")) winid = DebuggerPaneConfig::Watches;
if(e.GetId() == XRCID("debugger_win_output")) winid = DebuggerPaneConfig::Output;
if(e.GetId() == XRCID("debugger_win_threads")) winid = DebuggerPaneConfig::Threads;
if(e.GetId() == XRCID("debugger_win_callstack")) winid = DebuggerPaneConfig::Callstack;
if(e.GetId() == XRCID("debugger_win_memory")) winid = DebuggerPaneConfig::Memory;
if(e.GetId() == XRCID("debugger_win_breakpoints")) winid = DebuggerPaneConfig::Breakpoints;
if(e.GetId() == XRCID("debugger_win_asciiview")) winid = DebuggerPaneConfig::AsciiViewer;
if(winid != DebuggerPaneConfig::None) {
e.Check(item.IsDebuggerWindowShown(winid));
}
}
void clMainFrame::OnRefactoringCacheStatus(wxCommandEvent& e)
{
e.Skip();
if(e.GetInt() == 0) {
// start
wxLogMessage(
wxString() << "Initializing refactoring database for workspace: " << WorkspaceST::Get()->GetName());
} else {
wxLogMessage(wxString() << "Initializing refactoring database for workspace: " << WorkspaceST::Get()->GetName()
<< "... done");
}
}
void clMainFrame::OnThemeChanged(wxCommandEvent& e) { e.Skip(); }
void clMainFrame::OnChangeActiveBookmarkType(wxCommandEvent& e)
{
LEditor* editor = GetMainBook()->GetActiveEditor();
if(editor) {
editor->OnChangeActiveBookmarkType(e);
}
}
void clMainFrame::OnSettingsChanged(wxCommandEvent& e)
{
e.Skip();
SetFrameTitle(GetMainBook()->GetActiveEditor());
}
void clMainFrame::OnDetachEditor(wxCommandEvent& e) { GetMainBook()->DetachActiveEditor(); }
void clMainFrame::OnDetachEditorUI(wxUpdateUIEvent& e) { e.Enable(GetMainBook()->GetActiveEditor() != NULL); }
void clMainFrame::OnShowStatusBar(wxCommandEvent& event)
{
GetStatusBar()->Show(event.IsChecked());
SendSizeEvent();
clConfig::Get().Write("ShowStatusBar", event.IsChecked());
}
void clMainFrame::OnShowStatusBarUI(wxUpdateUIEvent& event) { event.Check(GetStatusBar()->IsShown()); }
void clMainFrame::OnShowToolbar(wxCommandEvent& event)
{
// Hide the _native_ toolbar
if(GetToolBar()) {
GetToolBar()->Show(event.IsChecked());
} else {
wxAuiPaneInfoArray& panes = m_mgr.GetAllPanes();
for(size_t i = 0; i < panes.GetCount(); ++i) {
if(panes.Item(i).IsOk() && panes.Item(i).IsToolbar()) {
panes.Item(i).Show(event.IsChecked());
}
}
m_mgr.Update();
}
SendSizeEvent();
clConfig::Get().Write("ShowToolBar", event.IsChecked());
}
void clMainFrame::OnShowToolbarUI(wxUpdateUIEvent& event)
{
if(GetToolBar()) {
event.Check(GetToolBar()->IsShown());
} else {
bool atLeastOneTBIsVisible = false;
wxAuiPaneInfoArray& panes = m_mgr.GetAllPanes();
for(size_t i = 0; i < panes.GetCount(); ++i) {
if(panes.Item(i).IsOk() && panes.Item(i).IsToolbar() && panes.Item(i).IsShown()) {
atLeastOneTBIsVisible = true;
break;
}
}
event.Check(atLeastOneTBIsVisible);
}
}
void clMainFrame::ShowOrHideCaptions()
{
// load the current state
bool showCaptions = EditorConfigST::Get()->GetOptions()->IsShowDockingWindowCaption();
if(!showCaptions) {
wxAuiPaneInfoArray& panes = m_mgr.GetAllPanes();
for(size_t i = 0; i < panes.GetCount(); ++i) {
if(panes.Item(i).IsOk() && !panes.Item(i).IsToolbar()) {
panes.Item(i).CaptionVisible(false);
}
}
} else {
wxAuiPaneInfoArray& panes = m_mgr.GetAllPanes();
for(size_t i = 0; i < panes.GetCount(); ++i) {
// Editor is the center pane - don't add it a caption
if(panes.Item(i).IsOk() && !panes.Item(i).IsToolbar() && panes.Item(i).name != "Editor") {
panes.Item(i).CaptionVisible(true);
}
}
}
m_mgr.Update();
PostSizeEvent();
}
void clMainFrame::OnOpenFileExplorerFromFilePath(wxCommandEvent& e)
{
LEditor* editor = GetMainBook()->GetActiveEditor();
if(editor) {
wxString path = editor->GetFileName().GetPath();
FileUtils::OpenFileExplorer(path);
}
}
|