1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 8444 8445 8446 8447 8448
|
#!/bin/sh
# the next line restarts using the interpreter \
exec wish "$0" "$@"
set rcsId {$Id: utility.tcl,v 1.4 1998/09/18 21:18:30 jfontain Exp $}
proc minimum {a b} {return [expr {$a<$b?$a:$b}]}
proc maximum {a b} {return [expr {$a>$b?$a:$b}]}
proc ldelete {listName value} {
upvar $listName list
set index [lsearch -exact $list $value]
if {$index<0} {
error "\"$value\" is not in list"
}
set list [lreplace $list $index $index]
}
proc startGatheringRCSIds {} {
trace variable ::rcsId w recordRCSId
}
proc recordRCSId {variableName empty operation} {
foreach {header file version} $::rcsId break
regsub {,v$} $file {} file
set ::sourceVersion($file) $version
}
startGatheringRCSIds
set rcsId {$Id: moodss.tcl,v 1.108 1998/10/17 20:39:24 jfontain Exp $}
set applicationVersion 5.0
set rcsId {$Id: getopt.tcl,v 1.3 1998/05/24 19:24:43 jfontain Exp $}
proc parseCommandLineArguments {switches arguments arrayName} {
upvar $arrayName data
if {[llength $switches]==0} {
return $arguments
}
foreach {value flag} $switches {
if {![string match {[-+]*} $value]||![string match {[01]} $flag]} {
error "invalid switches: $switches"
}
}
unset flag
array set flag $switches
set index 0
foreach value $arguments {
set argument($index) $value
incr index
}
set maximum $index
for {set index 0} {$index<$maximum} {incr index} {
set switch $argument($index)
if {![info exists flag($switch)]} break
if {[string compare $switch --]==0} {
incr index
break
}
if {$flag($switch)} {
if {[catch {set value $argument([incr index])}]||[string match {[-+]*} $value]} {
error "no value for switch $switch"
}
set data($switch) $value
} else {
set data($switch) {}
}
}
return [lrange $arguments $index end]
}
proc printUsage {exitCode} {
puts stderr "Usage: $::argv0 \[OPTION\]... \[MODULE\] \[MODULE\]..."
puts stderr { -f, --file configuration file name (implies no modules)}
puts stderr { -h, --help display this help and exit}
puts stderr { -p, --poll-time poll time in seconds}
puts stderr { -r, --read-only disable viewer creation, editing, ...}
puts stderr { -S, --static disable internal window manager sizing and moving}
puts stderr { --version output version information and exit}
exit $exitCode
}
if {[catch\
{\
set argv [parseCommandLineArguments\
{-f 1 --file 1 -h 0 --help 0 -p 1 --poll-time 1 -r 0 --read-only 0 -S 0 --static 0 --version 0} $argv arguments\
]\
}\
message\
]} {
puts stderr $message
printUsage 1
}
foreach {short long} {-f --file -h --help -p --poll-time -r --read-only -S --static} {
catch {set arguments($short) $arguments($long)}
}
if {[info exists arguments(--version)]} {
puts "moodss (a Modular Object Oriented Dynamic SpreadSheet) version $applicationVersion"
exit
}
if {\
([info exists arguments(-f)]&&([llength $argv]>0))||(![info exists arguments(-f)]&&([llength $argv]==0))||\
[info exists arguments(-h)]\
} {
printUsage 1
}
proc loadModules {modules} {
foreach module $modules {
if {[info exists loaded($module)]} {
puts stderr "$::argv0: module \"$module\" was specified more than once"
exit 1
}
if {[catch {package require $module}]} {
puts stderr "$::argv0: could not load package \"$module\""
exit 1
}
set loaded($module) {}
if {![info exists ${module}::data(indexColumns)]} {
set ${module}::data(indexColumns) 0
}
}
}
proc setPollTimes {modules {commandLineTime {}}} {
global pollTimes pollTime
set default 0
set minimum 0
foreach module $modules {
set times [set ${module}::data(pollTimes)]
if {[llength $times]==0} {
error "module $module poll times list is empty"
}
set time [lindex $times 0]
if {$time<0} {
set intervals($time) {}
continue
}
if {$time>$default} {
set default $time
}
set times [lsort -integer $times]
set time [lindex $times 0]
if {$time>$minimum} {
set minimum $time
set minimumModule $module
}
foreach time $times {
set data($time) {}
}
}
set pollTimes [lsort -integer [array names data]]
set pollTimes [lrange $pollTimes [lsearch -exact $pollTimes $minimum] end]
set pollTime $default
if {[string length $commandLineTime]>0} {
if {$commandLineTime<$minimum} {
puts stderr "$::argv0: minimum poll time is $minimum seconds for module $minimumModule"
exit 1
}
set pollTime $commandLineTime
}
if {$pollTime==0} {
set sum 0
set number 0
foreach interval [array names intervals] {
incr sum $interval
incr number
}
set pollTime [expr {round(double($sum)/-$number)}]
}
}
proc commaSeparatedString {words} {
for {set index 0} {$index<([llength $words]-1)} {incr index} {
append string "[lindex $words $index], "
}
append string [lindex $words $index]
return $string
}
if 1 {
set rcsId {$Id: stooop.tcl,v 3.63 1998/09/05 20:21:54 jfontain Exp $}
package provide stooop 3.6.1
catch {rename proc _proc}
namespace eval ::stooop {
variable checkCode
variable traceProcedureChannel
variable traceProcedureFormat
variable traceDataChannel
variable traceDataFormat
variable traceDataOperations
set checkCode {}
if {[info exists ::env(STOOOPCHECKALL)]} {
array set ::env {STOOOPCHECKPROCEDURES {} STOOOPCHECKDATA {}}
}
if {[info exists ::env(STOOOPCHECKPROCEDURES)]} {
append checkCode {::stooop::checkProcedure;}
}
if {[info exists ::env(STOOOPTRACEALL)]} {
set ::env(STOOOPTRACEPROCEDURES) $::env(STOOOPTRACEALL)
set ::env(STOOOPTRACEDATA) $::env(STOOOPTRACEALL)
}
if {[info exists ::env(STOOOPTRACEPROCEDURES)]} {
set traceProcedureChannel $::env(STOOOPTRACEPROCEDURES)
if {![regexp {^stdout|stderr$} $traceProcedureChannel]} {
set traceProcedureChannel [open $::env(STOOOPTRACEPROCEDURES) w+]
}
set traceProcedureFormat {class: %C, procedure: %p, object: %O, arguments: %a}
catch {set traceProcedureFormat $::env(STOOOPTRACEPROCEDURESFORMAT)}
append checkCode {::stooop::traceProcedure;}
}
if {[info exists ::env(STOOOPTRACEDATA)]} {
set traceDataChannel $::env(STOOOPTRACEDATA)
if {![regexp {^stdout|stderr$} $traceDataChannel]} {
set traceDataChannel [open $::env(STOOOPTRACEDATA) w+]
}
set traceDataFormat {class: %C, procedure: %p, array: %A, object: %O, member: %m, operation: %o, value: %v}
catch {set traceDataFormat $::env(STOOOPTRACEDATAFORMAT)}
set traceDataOperations rwu
catch {set traceDataOperations $::env(STOOOPTRACEDATAOPERATIONS)}
}
namespace export class virtual new delete classof
if {![info exists newId]} {
variable newId 0
}
_proc new {classOrId args} {
variable newId
variable fullClass
if {[scan $classOrId %u dummy]==0} {
set constructor ${classOrId}::[namespace tail $classOrId]
uplevel $constructor [set id [incr newId]] $args
set fullClass($id) [namespace qualifiers [uplevel namespace which -command $constructor]]
} else {
if {[catch {set fullClass([set id [incr newId]]) $fullClass($classOrId)}]} {
error "invalid object identifier $classOrId"
}
uplevel $fullClass($classOrId)::_copy $id $classOrId
}
return $id
}
_proc delete {args} {
variable fullClass
foreach id $args {
uplevel ::stooop::deleteObject $fullClass($id) $id
unset fullClass($id)
}
}
_proc deleteObject {fullClass id} {
uplevel ${fullClass}::~[namespace tail $fullClass] $id
foreach name [array names ${fullClass}:: $id,*] {
unset ${fullClass}::($name)
}
}
_proc classof {id} {
variable fullClass
return $fullClass($id)
}
_proc copy {fullClass from to} {
set index [string length $from]
foreach name [array names ${fullClass}:: $from,*] {
set ${fullClass}::($to[string range $name $index end]) [set ${fullClass}::($name)]
}
}
}
_proc ::stooop::class {args} {
variable declared
set class [lindex $args 0]
set declared([uplevel namespace eval $class {namespace current}]) {}
uplevel namespace eval $class [list "::variable {}\n[lindex $args end]"]
}
_proc ::stooop::parseProcedureName {namespace name fullClassVariable procedureVariable messageVariable} {
variable declared
upvar $fullClassVariable fullClass $procedureVariable procedure $messageVariable message
if {[info exists declared($namespace)]&&([string length [namespace qualifiers $name]]==0)} {
set fullClass $namespace
set procedure $name
return 1
} else {
if {![string match ::* $name]} {
if {[string compare $namespace ::]==0} {
set name ::$name
} else {
set name ${namespace}::$name
}
}
set fullClass [namespace qualifiers $name]
if {[info exists declared($fullClass)]} {
set procedure [namespace tail $name]
return 1
} else {
if {[string length $fullClass]==0} {
set message "procedure $name class name is empty"
} else {
set message "procedure $name class $fullClass is unknown"
}
return 0
}
}
}
_proc ::stooop::virtual {keyword name arguments args} {
variable pureVirtual
if {[string compare [uplevel namespace which -command $keyword] ::proc]!=0} {
error "virtual operator works only on proc, not $keyword"
}
if {![parseProcedureName [uplevel namespace current] $name fullClass procedure message]} {
error $message
}
set class [namespace tail $fullClass]
if {[string compare $class $procedure]==0} {
error "cannot make class $fullClass constructor virtual"
}
if {[string compare ~$class $procedure]==0} {
error "cannot make class $fullClass destructor virtual"
}
if {[string compare [lindex $arguments 0] this]!=0} {
error "cannot make static procedure $procedure of class $fullClass virtual"
}
set pureVirtual [expr {[llength $args]==0}]
uplevel ::proc [list $name $arguments [lindex $args 0]]
unset pureVirtual
}
_proc proc {name arguments args} {
if {![::stooop::parseProcedureName [uplevel namespace current] $name fullClass procedure message]} {
uplevel _proc [list $name $arguments] $args
return
}
if {[llength $args]==0} {
error "missing body for ${fullClass}::$procedure"
}
set class [namespace tail $fullClass]
if {[string compare $class $procedure]==0} {
if {[string compare [lindex $arguments 0] this]!=0} {
error "class $fullClass constructor first argument must be this"
}
if {[string compare [lindex $arguments 1] copy]==0} {
if {[llength $arguments]!=2} {
error "class $fullClass copy constructor must have 2 arguments exactly"
}
if {[catch {info body ::${fullClass}::$class}]} {
error "class $fullClass copy constructor defined before constructor"
}
eval ::stooop::constructorDeclaration $fullClass $class 1 \{$arguments\} $args
} else {
eval ::stooop::constructorDeclaration $fullClass $class 0 \{$arguments\} $args
::stooop::generateDefaultCopyConstructor $fullClass
}
} elseif {[string compare ~$class $procedure]==0} {
if {[llength $arguments]!=1} {
error "class $fullClass destructor must have 1 argument exactly"
}
if {[string compare [lindex $arguments 0] this]!=0} {
error "class $fullClass destructor argument must be this"
}
if {[catch {info body ::${fullClass}::$class}]} {
error "class $fullClass destructor defined before constructor"
}
::stooop::destructorDeclaration $fullClass $class $arguments [lindex $args 0]
} else {
if {[catch {info body ::${fullClass}::$class}]} {
error "class $fullClass member procedure $procedure defined before constructor"
}
::stooop::memberProcedureDeclaration $fullClass $class $procedure $arguments [lindex $args 0]
}
}
_proc ::stooop::constructorDeclaration {fullClass class copy arguments args} {
variable checkCode
variable fullBases
variable variable
set number [llength $args]
if {($number%2)==0} {
error "bad class $fullClass constructor declaration, a base class, contructor arguments or body may be missing"
}
if {[string compare [lindex $arguments end] args]==0} {
set variable($fullClass) {}
}
if {!$copy} {
set fullBases($fullClass) {}
}
foreach {base baseArguments} [lrange $args 0 [expr {$number-2}]] {
set constructor ${base}::[namespace tail $base]
catch {$constructor}
set fullBase [namespace qualifiers [uplevel 2 namespace which -command $constructor]]
if {[string length $fullBase]==0} {
if {[string match *$base $fullClass]} {
error "class $fullClass cannot be derived from itself"
} else {
error "class $fullClass constructor defined before base class $base constructor"
}
}
if {!$copy} {
if {[lsearch -exact $fullBases($fullClass) $fullBase]>=0} {
error "class $fullClass directly inherits from class $fullBase more than once"
}
lappend fullBases($fullClass) $fullBase
}
regsub -all \n $baseArguments {} constructorArguments($fullBase)
}
set constructorBody \
"::variable {}
$checkCode
"
if {[llength $fullBases($fullClass)]>0} {
if {[info exists variable($fullClass)]} {
foreach fullBase $fullBases($fullClass) {
if {![info exists constructorArguments($fullBase)]} {
error "missing base class $fullBase constructor arguments from class $fullClass constructor"
}
set baseConstructor ${fullBase}::[namespace tail $fullBase]
if {[info exists variable($fullBase)]&&([string first {$args} $constructorArguments($fullBase)]>=0)} {
append constructorBody \
"::set _list \[::list $constructorArguments($fullBase)\]
::eval $baseConstructor \$this \[::lrange \$_list 0 \[::expr {\[::llength \$_list\]-2}\]\] \[::lindex \$_list end\]
::unset _list
::set ${fullBase}::(\$this,_derived) $fullClass
"
} else {
append constructorBody \
"$baseConstructor \$this $constructorArguments($fullBase)
::set ${fullBase}::(\$this,_derived) $fullClass
"
}
}
} else {
foreach fullBase $fullBases($fullClass) {
if {![info exists constructorArguments($fullBase)]} {
error "missing base class $fullBase constructor arguments from class $fullClass constructor"
}
set baseConstructor ${fullBase}::[namespace tail $fullBase]
append constructorBody \
"$baseConstructor \$this $constructorArguments($fullBase)
::set ${fullBase}::(\$this,_derived) $fullClass
"
}
}
}
if {$copy} {
append constructorBody \
"::catch {::set ${fullClass}::(\$this,_derived) \[::set ${fullClass}::(\$[::lindex $arguments 1],_derived)\]}
"
}
append constructorBody [lindex $args end]
if {$copy} {
_proc ${fullClass}::_copy $arguments $constructorBody
} else {
_proc ${fullClass}::$class $arguments $constructorBody
}
}
_proc ::stooop::destructorDeclaration {fullClass class arguments body} {
variable checkCode
variable fullBases
set body \
"::variable {}
$checkCode
$body
"
for {set index [expr {[llength $fullBases($fullClass)]-1}]} {$index>=0} {incr index -1} {
set fullBase [lindex $fullBases($fullClass) $index]
append body \
"::stooop::deleteObject $fullBase \$this
"
}
_proc ${fullClass}::~$class $arguments $body
}
_proc ::stooop::memberProcedureDeclaration {fullClass class procedure arguments body} {
variable checkCode
variable pureVirtual
if {[info exists pureVirtual]} {
if {$pureVirtual} {
_proc ${fullClass}::$procedure $arguments \
"::variable {}
$checkCode
::uplevel \$${fullClass}::(\$this,_derived)::$procedure \[::lrange \[::info level 0\] 1 end\]
"
} else {
_proc ${fullClass}::_$procedure $arguments \
"::variable {}
$checkCode
$body
"
_proc ${fullClass}::$procedure $arguments \
"::variable {}
$checkCode
if {!\[::catch {::info body \$${fullClass}::(\$this,_derived)::$procedure}\]} {
::return \[::uplevel \$${fullClass}::(\$this,_derived)::$procedure \[::lrange \[::info level 0\] 1 end\]\]
}
::uplevel ${fullClass}::_$procedure \[::lrange \[::info level 0\] 1 end\]
"
}
} else {
_proc ${fullClass}::$procedure $arguments \
"::variable {}
$checkCode
$body
"
}
}
_proc ::stooop::generateDefaultCopyConstructor {fullClass} {
variable fullBases
foreach fullBase $fullBases($fullClass) {
append body \
"${fullBase}::_copy \$this \$sibling
"
}
append body \
"::stooop::copy $fullClass \$sibling \$this
"
_proc ${fullClass}::_copy {this sibling} $body
}
if {[llength [array names ::env STOOOP*]]>0} {
catch {rename ::stooop::class ::stooop::_class}
_proc ::stooop::class {args} {
variable traceDataOperations
set class [lindex $args 0]
if {[info exists ::env(STOOOPCHECKDATA)]} {
uplevel namespace eval $class [list {::trace variable {} wu ::stooop::checkData}]
}
if {[info exists ::env(STOOOPTRACEDATA)]} {
uplevel namespace eval $class [list "::trace variable {} $traceDataOperations ::stooop::traceData"]
}
uplevel ::stooop::_class $args
}
if {[info exists ::env(STOOOPCHECKPROCEDURES)]} {
catch {rename ::stooop::virtual ::stooop::_virtual}
_proc ::stooop::virtual {keyword name arguments args} {
variable interface
uplevel ::stooop::_virtual [list $keyword $name $arguments] $args
parseProcedureName [uplevel namespace current] $name fullClass procedure message
if {[llength $args]==0} {
set interface($fullClass) {}
}
}
catch {rename ::stooop::new ::stooop::_new}
_proc ::stooop::new {classOrId args} {
variable newId
variable fullClass
variable interface
if {[scan $classOrId %u dummy]==0} {
set constructor ${classOrId}::[namespace tail $classOrId]
catch {$constructor}
set fullName [namespace qualifiers [uplevel namespace which -command $constructor]]
set fullClass([expr {$newId+1}]) $fullName
} else {
set fullName $fullClass($classOrId)
}
if {[info exists interface($fullName)]} {
error "class $fullName with pure virtual procedures should not be instanciated"
}
return [uplevel ::stooop::_new $classOrId $args]
}
}
_proc ::stooop::ancestors {fullClass} {
variable ancestors
variable fullBases
if {[info exists ancestors($fullClass)]} {
return $ancestors($fullClass)
}
set list {}
foreach class $fullBases($fullClass) {
set list [concat $list [list $class] [ancestors $class]]
}
set ancestors($fullClass) $list
return $list
}
_proc ::stooop::debugInformation {className fullClassName procedureName fullProcedureName thisParameterName} {
upvar $className class $fullClassName fullClass $procedureName procedure $fullProcedureName fullProcedure\
$thisParameterName thisParameter
variable declared
set namespace [uplevel 2 namespace current]
if {[lsearch -exact [array names declared] $namespace]<0} return
set fullClass [string trimleft $namespace :]
set class [namespace tail $fullClass]
set list [info level -2]
if {[llength $list]==0} return
set procedure [lindex $list 0]
set fullProcedure [uplevel 3 namespace which -command $procedure]
set procedure [namespace tail $procedure]
if {[string compare $class $procedure]==0} {
set procedure constructor
} elseif {[string compare ~$class $procedure]==0} {
set procedure destructor
}
if {[string compare [lindex [info args $fullProcedure] 0] this]==0} {
set thisParameter [lindex $list 1]
}
}
_proc ::stooop::checkProcedure {} {
variable fullClass
debugInformation class qualifiedClass procedure qualifiedProcedure this
if {![info exists this]} return
if {[string compare $procedure constructor]==0} return
if {![info exists fullClass($this)]} {
error "$this is not a valid object identifier"
}
set fullName [string trimleft $fullClass($this) :]
if {[string compare $fullName $qualifiedClass]==0} return
if {[lsearch -exact [ancestors ::$fullName] ::$qualifiedClass]<0} {
error "class $qualifiedClass of $qualifiedProcedure procedure not an ancestor of object $this class $fullName"
}
}
_proc ::stooop::traceProcedure {} {
variable traceProcedureChannel
variable traceProcedureFormat
debugInformation class qualifiedClass procedure qualifiedProcedure this
set text $traceProcedureFormat
regsub -all %C $text $qualifiedClass text
regsub -all %c $text $class text
regsub -all %P $text $qualifiedProcedure text
regsub -all %p $text $procedure text
if {[info exists this]} {
regsub -all %O $text $this text
regsub -all %a $text [lrange [info level -1] 2 end] text
} else {
regsub -all %O $text {} text
regsub -all %a $text [lrange [info level -1] 1 end] text
}
puts $traceProcedureChannel $text
}
_proc ::stooop::checkData {array name operation} {
scan $name %u,%s identifier member
if {[info exists member]&&([string compare $member _derived]==0)} return
debugInformation class qualifiedClass procedure qualifiedProcedure this
if {![info exists class]} return
set array [uplevel [list namespace which -variable $array]]
if {![info exists procedure]} {
if {[string compare $array ::${qualifiedClass}::]!=0} {
error "class access violation in class $qualifiedClass namespace"
}
return
}
if {[string compare $qualifiedProcedure ::stooop::copy]==0} return
if {[string compare $array ::${qualifiedClass}::]!=0} {
error "class access violation in procedure $qualifiedProcedure"
}
if {![info exists this]} return
if {![info exists identifier]} return
if {$this!=$identifier} {
error "object $identifier access violation in procedure $qualifiedProcedure acting on object $this"
}
}
_proc ::stooop::traceData {array name operation} {
variable traceDataChannel
variable traceDataFormat
scan $name %u,%s identifier member
if {[info exists member]&&([string compare $member _derived]==0)} return
if {![catch {lindex [info level -1] 0} procedure]&&([string compare ::stooop::deleteObject $procedure]==0)} return
set class {}
set qualifiedClass {}
set procedure {}
set qualifiedProcedure {}
debugInformation class qualifiedClass procedure qualifiedProcedure this
set text $traceDataFormat
regsub -all %C $text $qualifiedClass text
regsub -all %c $text $class text
if {[info exists member]} {
regsub -all %m $text $member text
} else {
regsub -all %m $text $name text
}
regsub -all %P $text $qualifiedProcedure text
regsub -all %p $text $procedure text
regsub -all %A $text [string trimleft [uplevel [list namespace which -variable $array]] :] text
if {[info exists this]} {
regsub -all %O $text $this text
} else {
regsub -all %O $text {} text
}
array set string {r read w write u unset}
regsub -all %o $text $string($operation) text
if {[string compare $operation u]==0} {
regsub -all %v $text {} text
} else {
regsub -all %v $text [uplevel set ${array}($name)] text
}
puts $traceDataChannel $text
}
}
}
namespace import stooop::*
if 1 {
set rcsId {$Id: switched.tcl,v 1.4 1998/03/30 08:26:05 jfontain Exp $}
package provide switched [lindex {$Revision: 1.4 $} 1]
class switched {
proc switched {this args} {
if {([llength $args]%2)!=0} {
error "value for \"[lindex $args end]\" missing"
}
set switched::($this,complete) 0
set switched::($this,arguments) $args
}
proc ~switched {this} {}
virtual proc options {this}
proc complete {this} {
foreach description [options $this] {
set option [lindex $description 0]
set switched::($this,$option) [set default [lindex $description 1]]
if {[llength $description]<3} {
set initialize($option) {}
} elseif {[string compare $default [lindex $description 2]]!=0} {
set switched::($this,$option) [lindex $description 2]
set initialize($option) {}
}
}
foreach {option value} $switched::($this,arguments) {
if {[catch {string compare $switched::($this,$option) $value} different]} {
error "$switched::($this,_derived): unknown option \"$option\""
}
if {$different} {
set switched::($this,$option) $value
set initialize($option) {}
}
}
unset switched::($this,arguments)
foreach option [array names initialize] {
$switched::($this,_derived)::set$option $this $switched::($this,$option)
}
set switched::($this,complete) 1
}
proc configure {this args} {
if {[llength $args]==0} {
return [descriptions $this]
}
foreach {option value} $args {
if {![info exists switched::($this,$option)]} {
error "$switched::($this,_derived): unknown option \"$option\""
}
}
if {[llength $args]==1} {
return [description $this [lindex $args 0]]
}
if {([llength $args]%2)!=0} {
error "value for \"[lindex $args end]\" missing"
}
foreach {option value} $args {
if {[string compare $switched::($this,$option) $value]!=0} {
$switched::($this,_derived)::set$option $this [set switched::($this,$option) $value]
}
}
}
proc cget {this option} {
if {[catch {set value $switched::($this,$option)}]} {
error "$switched::($this,_derived): unknown option \"$option\""
}
return $value
}
proc description {this option} {
foreach description [options $this] {
if {[string compare [lindex $description 0] $option]==0} {
if {[llength $description]<3} {
lappend description $switched::($this,$option)
return $description
} else {
return [lreplace $description 2 2 $switched::($this,$option)]
}
}
}
}
proc descriptions {this} {
set descriptions {}
foreach description [options $this] {
if {[llength $description]<3} {
lappend description $switched::($this,[lindex $description 0])
lappend descriptions $description
} else {
lappend descriptions [lreplace $description 2 2 $switched::($this,[lindex $description 0])]
}
}
return $descriptions
}
}
}
if 1 {
set rcsId {$Id: scwoutil.tcl,v 1.1 1998/09/15 21:17:14 jfontain Exp $}
if {[string compare $::tcl_platform(platform) windows]==0} {
proc showTopLevel {path geometry} {
wm deiconify $path
wm geometry $path $geometry
}
} else {
proc showTopLevel {path geometry} {
wm geometry $path $geometry
wm deiconify $path
}
}
set rcsId {$Id: scwoop.tcl,v 2.20 1998/10/09 21:02:15 jfontain Exp $}
package provide scwoop 2.5
class widget {}
switch $tcl_platform(platform) {
macintosh {
array set widget:: {default,ButtonAnchor center default,ButtonActiveBackgroundColor systemButtonText default,ButtonActiveBackgroundMono Black default,ButtonActiveForegroundColor systemButtonFace default,ChkradActiveForegroundColor DEF_BUTTON_ACTIVE_FG_COLOR default,ButtonActiveForegroundMono White default,ButtonBackgroundColor systemButtonFace default,ButtonBackgroundMono White default,ButtonBitmap {} default,ButtonBorderWidth 2 default,ButtonCursor {} default,ButtonCommand {} default,ButtonDefault disabled default,ButtonDisabledForegroundColor #a3a3a3 default,ButtonDisabledForegroundMono {} default,ButtonForeground systemButtonText default,ChkradForeground DEF_BUTTON_FG default,ButtonFont system default,ButtonHeight 0 default,ButtonHighlightBackground systemWindowBody default,ButtonHighlight systemButtonFrame default,LabelHighlightWidth 0 default,ButtonHighlightWidth 4 default,ButtonImage {} default,ButtonIndicator 1 default,ButtonJustify center default,ButtonOffValue 0 default,ButtonOnValue 1 default,ButtonPadX 7 default,LabelCheckRadiusPadX 1 default,ButtonPadY 3 default,LabelCheckRadiusPadY 1 default,ButtonRelief flat default,LabelCheckRadiusRelief flat default,ButtonSelectColor #b03060 default,ButtonSelectMono Black default,ButtonSelectImage {} default,ButtonState normal default,LabelTakeFocus 0 default,ButtonTakeFocus {} default,ButtonText {} default,ButtonTextVariable {} default,ButtonUnderline -1 default,ButtonValue {} default,ButtonWidth 0 default,ButtonWrapLength 0 default,RadiobuttonVariable selectedButton default,CheckbuttonVariable {} default,CanvasBackgroundColor systemWindowBody default,CanvasBackgroundMono White default,CanvasBorderWidth 0 default,CanvasCloseEnough 1 default,CanvasConfine 1 default,CanvasCursor {} default,CanvasHeight 7c default,CanvasHighlightBackground systemWindowBody default,CanvasHighlight Black default,CanvasHighlightWidth 3 default,CanvasInsertBackground Black default,CanvasInsertBorderColor 0 default,CanvasInsertBorderMono 0 default,CanvasInsertOffTime 300 default,CanvasInsertOnTime 600 default,CanvasInsertWidth 2 default,CanvasRelief flat default,CanvasScrollRegion {} default,CanvasSelectColor systemHighlight default,CanvasSelectMono Black default,CanvasSelectBorderColor 1 default,CanvasSelectBorderMono 0 default,CanvasSelectForegroundColor Black default,CanvasSelectForegroundMono White default,CanvasTakeFocus {} default,CanvasWidth 10c default,CanvasXScrollCommand {} default,CanvasXScrollIncrement 0 default,CanvasYScrollCommand {} default,CanvasYScrollIncrement 0 default,EntryBackgroundColor systemWindowBody default,EntryBackgroundMono White default,EntryBorderWidth 1 default,EntryCursor xterm default,EntryExportSelection 1 default,EntryFont "Helvetica 12" default,EntryForeground Black default,EntryHighlightBackground systemWindowBody default,EntryHighlight Black default,EntryHighlightWidth 0 default,EntryInsertBackground Black default,EntryInsertBorderColor 0 default,EntryInsertBorderMono 0 default,EntryInsertOffTime 300 default,EntryInsertOnTime 600 default,EntryInsertWidth 1 default,EntryJustify left default,EntryRelief solid default,EntryScrollCommand {} default,EntrySelectColor systemHighlight default,EntrySelectMono Black default,EntrySelectBorderColor 1 default,EntrySelectBorderMono 0 default,EntrySelectForegroundColor systemHighlightText default,EntrySelectForegroundMono White default,EntryShow {} default,EntryState normal default,EntryTakeFocus {} default,EntryTextVariable {} default,EntryWidth 20 default,FrameBackgroundColor systemWindowBody default,FrameBackgroundMono White default,FrameBorderWidth 0 default,FrameClass Frame default,FrameColormap {} default,FrameContainer 0 default,FrameCursor {} default,FrameHeight 0 default,FrameHighlightBackground systemWindowBody default,FrameHighlight Black default,FrameHighlightWidth 0 default,FrameRelief flat default,FrameTakeFocus 0 default,FrameUse {} default,FrameVisual {} default,FrameWidth 0 default,ListboxBackgroundColor systemWindowBody default,ListboxBackgroundMono White default,ListboxBorderWidth 1 default,ListboxCursor {} default,ListboxExportSelection 1 default,ListboxFont application default,ListboxForeground Black default,ListboxHeight 10 default,ListboxHighlightBackground systemWindowBody default,ListboxHighlight Black default,ListboxHighlightWidth 0 default,ListboxRelief solid default,ListboxScrollCommand {} default,ListboxSelectColor systemHighlight default,ListboxSelectMono Black default,ListboxSelectBorder 0 default,ListboxSelectForegroundColor systemHighlightText default,ListboxSelectForegroundMono White default,ListboxSelectMode browse default,ListboxSetGrid 0 default,ListboxTakeFocus {} default,ListboxWidth 20 default,MenuEntryActiveBackground {} default,MenuEntryActiveForeground {} default,MenuEntryAccelerator {} default,MenuEntryBackground {} default,MenuEntryBitmap None default,MenuEntryColumnBreak 0 default,MenuEntryCommand {} default,MenuEntryForeground {} default,MenuEntryFont {} default,MenuEntryHideMargin 0 default,MenuEntryImage {} default,MenuEntryIndicator 1 default,MenuEntryLabel {} default,MenuEntryMenu {} default,MenuEntryOffValue 0 default,MenuEntryOnValue 1 default,MenuEntrySelectImage {} default,MenuEntryState normal default,MenuEntryValue {} default,MenuEntryCheckVariable {} default,MenuEntryRadioVariable selectedButton default,MenuEntrySelect {} default,MenuEntryUnderline -1 default,MenuActiveBackgroundColor SystemMenuActive default,MenuActiveBackgroundMono Black default,MenuActiveBorderWidth 0 default,MenuActiveForegroundColor SystemMenuActiveText default,MenuActiveForegroundMono White default,MenuBackgroundColor SystemMenu default,MenuBackgroundMono White default,MenuBorderWidth 0 default,MenuCursor arrow default,MenuDisabledForegroundColor SystemMenuDisabled default,MenuDisabledForegroundMono {} default,MenuFont system default,MenuForeground SystemMenuText default,MenuPostCommand {} default,MenuRelief flat default,MenuSelectColor SystemMenuActive default,MenuSelectMono Black default,MenuTakeFocus 0 default,MenuTearoff 1 default,MenuTearoffCommand {} default,MenuTitle {} default,MenuType normal default,MenubuttonAnchor center default,MenubuttonActiveBackgroundColor #ececec default,MenubuttonActiveBackgroundMono Black default,MenubuttonActiveForegroundColor Black default,MenubuttonActiveForegroundMono White default,MenubuttonBackgroundColor systemWindowBody default,MenubuttonBackgroundMono White default,MenubuttonBitmap {} default,MenubuttonBorderWidth 2 default,MenubuttonCursor {} default,MenubuttonDirection below default,MenubuttonDisabledForegroundColor #a3a3a3 default,MenubuttonDisabledForegroundMono {} default,MenubuttonFont system default,MenubuttonForeground Black default,MenubuttonHeight 0 default,MenubuttonHighlightBackground systemWindowBody default,MenubuttonHighlight Black default,MenubuttonHighlightWidth 0 default,MenubuttonImage {} default,MenubuttonIndicator 0 default,MenubuttonJustify left default,MenubuttonMenu {} default,MenubuttonPadX 4p default,MenubuttonPadY 3p default,MenubuttonRelief flat default,MenubuttonState normal default,MenubuttonTakeFocus 0 default,MenubuttonText {} default,MenubuttonTextVariable {} default,MenubuttonUnderline -1 default,MenubuttonWidth 0 default,MenubuttonWrapLength 0 default,MessageAnchor center default,MessageAspect 150 default,MessageBackgroundColor systemWindowBody default,MessageBackgroundMono White default,MessageBorderWidth 2 default,MessageCursor {} default,MessageForeground Black default,MessageFont system default,MessageHighlightBackground systemWindowBody default,MessageHighlight Black default,MessageHighlightWidth 0 default,MessageJustify left default,MessagePadX -1 default,MessagePadY -1 default,MessageRelief flat default,MessageTakeFocus 0 default,MessageText {} default,MessageTextVariable {} default,MessageWidth 0 default,ScaleActiveBackgroundColor #ececec default,ScaleActiveBackgroundMono Black default,ScaleBackgroundColor systemWindowBody default,ScaleBackgroundMono White default,ScaleBigIncrement 0 default,ScaleBorderWidth 2 default,ScaleCommand {} default,ScaleCursor {} default,ScaleDigits 0 default,ScaleFont system default,ScaleForegroundColor Black default,ScaleForegroundMono Black default,ScaleFrom 0 default,ScaleHighlightBackground systemWindowBody default,ScaleHighlight Black default,ScaleHighlightWidth 0 default,ScaleLabel {} default,ScaleLength 100 default,ScaleOrient vertical default,ScaleRelief flat default,ScaleRepeatDelay 300 default,ScaleRepeatInterval 100 default,ScaleResolution 1 default,ScaleTroughColor #c3c3c3 default,ScaleTroughMono White default,ScaleShowValue 1 default,ScaleSliderLength 30 default,ScaleSliderRelief raised default,ScaleState normal default,ScaleTakeFocus {} default,ScaleTickInterval 0 default,ScaleTo 100 default,ScaleVariable {} default,ScaleWidth 15 default,ScrollbarActiveBackgroundColor #ececec default,ScrollbarActiveBackgroundMono Black default,ScrollbarActiveRelief raised default,ScrollbarBackgroundColor systemWindowBody default,ScrollbarBackgroundMono White default,ScrollbarBorderWidth 0 default,ScrollbarCommand {} default,ScrollbarCursor {} default,ScrollbarElementBorderWidth -1 default,ScrollbarHighlightBackground systemWindowBody default,ScrollbarHighlight Black default,ScrollbarHighlightWidth 0 default,ScrollbarJump 0 default,ScrollbarOrient vertical default,ScrollbarRelief flat default,ScrollbarRepeatDelay 300 default,ScrollbarRepeatInterval 100 default,ScrollbarTakeFocus {} default,ScrollbarTroughColor #c3c3c3 default,ScrollbarTroughMono White default,ScrollbarWidth 16 default,TextBackgroundColor systemWindowBody default,TextBackgroundMono White default,TextBorderWidth 0 default,TextCursor xterm default,TextForeground Black default,TextExportSelection 1 default,TextFont "Courier 12" default,TextHeight 24 default,TextHighlightBackground systemWindowBody default,TextHighlight Black default,TextHighlightWidth 3 default,TextInsertBackground Black default,TextInsertBorderColor 0 default,TextInsertBorderMono 0 default,TextInsertOffTime 300 default,TextInsertOnTime 600 default,TextInsertWidth 1 default,TextPadX 1 default,TextPadY 1 default,TextRelief flat default,TextSelectColor systemHighlight default,TextSelectMono Black default,TextSelectBorderColor 1 default,TextSelectBorderMono 0 default,TextSelectForegroundColor systemHighlightText default,TextSelectForegroundMono White default,TextSelectRelief solid default,TextSetGrid 0 default,TextSpacing1 0 default,TextSpacing2 0 default,TextSpacing3 0 default,TextState normal default,TextTabs {} default,TextTakeFocus {} default,TextWidth 80 default,TextWrap char default,TextXScrollCommand {} default,TextYScrollCommand {} default,ToplevelClass Toplevel default,ToplevelMenu {} default,ToplevelScreen {}}
}
unix {
array set widget:: {default,ButtonAnchor center default,ButtonActiveBackgroundColor #ececec default,ButtonActiveBackgroundMono Black default,ButtonActiveForegroundColor Black default,ChkradActiveForegroundColor DEF_BUTTON_ACTIVE_FG_COLOR default,ButtonActiveForegroundMono White default,ButtonBackgroundColor #d9d9d9 default,ButtonBackgroundMono White default,ButtonBitmap {} default,ButtonBorderWidth 2 default,ButtonCursor {} default,ButtonCommand {} default,ButtonDefault disabled default,ButtonDisabledForegroundColor #a3a3a3 default,ButtonDisabledForegroundMono {} default,ButtonForeground Black default,ChkradForeground DEF_BUTTON_FG default,ButtonFont "Helvetica -12 bold" default,ButtonHeight 0 default,ButtonHighlightBackground #d9d9d9 default,ButtonHighlight Black default,LabelHighlightWidth 0 default,ButtonHighlightWidth 1 default,ButtonImage {} default,ButtonIndicator 1 default,ButtonJustify center default,ButtonOffValue 0 default,ButtonOnValue 1 default,ButtonPadX 3m default,LabelCheckRadiusPadX 1 default,ButtonPadY 1m default,LabelCheckRadiusPadY 1 default,ButtonRelief raised default,LabelCheckRadiusRelief flat default,ButtonSelectColor #b03060 default,ButtonSelectMono Black default,ButtonSelectImage {} default,ButtonState normal default,LabelTakeFocus 0 default,ButtonTakeFocus {} default,ButtonText {} default,ButtonTextVariable {} default,ButtonUnderline -1 default,ButtonValue {} default,ButtonWidth 0 default,ButtonWrapLength 0 default,RadiobuttonVariable selectedButton default,CheckbuttonVariable {} default,CanvasBackgroundColor #d9d9d9 default,CanvasBackgroundMono White default,CanvasBorderWidth 0 default,CanvasCloseEnough 1 default,CanvasConfine 1 default,CanvasCursor {} default,CanvasHeight 7c default,CanvasHighlightBackground #d9d9d9 default,CanvasHighlight Black default,CanvasHighlightWidth 1 default,CanvasInsertBackground Black default,CanvasInsertBorderColor 0 default,CanvasInsertBorderMono 0 default,CanvasInsertOffTime 300 default,CanvasInsertOnTime 600 default,CanvasInsertWidth 2 default,CanvasRelief flat default,CanvasScrollRegion {} default,CanvasSelectColor #c3c3c3 default,CanvasSelectMono Black default,CanvasSelectBorderColor 1 default,CanvasSelectBorderMono 0 default,CanvasSelectForegroundColor Black default,CanvasSelectForegroundMono White default,CanvasTakeFocus {} default,CanvasWidth 10c default,CanvasXScrollCommand {} default,CanvasXScrollIncrement 0 default,CanvasYScrollCommand {} default,CanvasYScrollIncrement 0 default,EntryBackgroundColor #d9d9d9 default,EntryBackgroundMono White default,EntryBorderWidth 2 default,EntryCursor xterm default,EntryExportSelection 1 default,EntryFont "Helvetica -12" default,EntryForeground Black default,EntryHighlightBackground #d9d9d9 default,EntryHighlight Black default,EntryHighlightWidth 1 default,EntryInsertBackground Black default,EntryInsertBorderColor 0 default,EntryInsertBorderMono 0 default,EntryInsertOffTime 300 default,EntryInsertOnTime 600 default,EntryInsertWidth 2 default,EntryJustify left default,EntryRelief sunken default,EntryScrollCommand {} default,EntrySelectColor #c3c3c3 default,EntrySelectMono Black default,EntrySelectBorderColor 1 default,EntrySelectBorderMono 0 default,EntrySelectForegroundColor Black default,EntrySelectForegroundMono White default,EntryShow {} default,EntryState normal default,EntryTakeFocus {} default,EntryTextVariable {} default,EntryWidth 20 default,FrameBackgroundColor #d9d9d9 default,FrameBackgroundMono White default,FrameBorderWidth 0 default,FrameClass Frame default,FrameColormap {} default,FrameContainer 0 default,FrameCursor {} default,FrameHeight 0 default,FrameHighlightBackground #d9d9d9 default,FrameHighlight Black default,FrameHighlightWidth 0 default,FrameRelief flat default,FrameTakeFocus 0 default,FrameUse {} default,FrameVisual {} default,FrameWidth 0 default,ListboxBackgroundColor #d9d9d9 default,ListboxBackgroundMono White default,ListboxBorderWidth 2 default,ListboxCursor {} default,ListboxExportSelection 1 default,ListboxFont "Helvetica -12 bold" default,ListboxForeground Black default,ListboxHeight 10 default,ListboxHighlightBackground #d9d9d9 default,ListboxHighlight Black default,ListboxHighlightWidth 1 default,ListboxRelief sunken default,ListboxScrollCommand {} default,ListboxSelectColor #c3c3c3 default,ListboxSelectMono Black default,ListboxSelectBorder 1 default,ListboxSelectForegroundColor Black default,ListboxSelectForegroundMono White default,ListboxSelectMode browse default,ListboxSetGrid 0 default,ListboxTakeFocus {} default,ListboxWidth 20 default,MenuEntryActiveBackground {} default,MenuEntryActiveForeground {} default,MenuEntryAccelerator {} default,MenuEntryBackground {} default,MenuEntryBitmap None default,MenuEntryColumnBreak 0 default,MenuEntryCommand {} default,MenuEntryForeground {} default,MenuEntryFont {} default,MenuEntryHideMargin 0 default,MenuEntryImage {} default,MenuEntryIndicator 1 default,MenuEntryLabel {} default,MenuEntryMenu {} default,MenuEntryOffValue 0 default,MenuEntryOnValue 1 default,MenuEntrySelectImage {} default,MenuEntryState normal default,MenuEntryValue {} default,MenuEntryCheckVariable {} default,MenuEntryRadioVariable selectedButton default,MenuEntrySelect {} default,MenuEntryUnderline -1 default,MenuActiveBackgroundColor #ececec default,MenuActiveBackgroundMono Black default,MenuActiveBorderWidth 2 default,MenuActiveForegroundColor Black default,MenuActiveForegroundMono White default,MenuBackgroundColor #d9d9d9 default,MenuBackgroundMono White default,MenuBorderWidth 2 default,MenuCursor arrow default,MenuDisabledForegroundColor #a3a3a3 default,MenuDisabledForegroundMono {} default,MenuFont "Helvetica -12 bold" default,MenuForeground Black default,MenuPostCommand {} default,MenuRelief raised default,MenuSelectColor #b03060 default,MenuSelectMono Black default,MenuTakeFocus 0 default,MenuTearoff 1 default,MenuTearoffCommand {} default,MenuTitle {} default,MenuType normal default,MenubuttonAnchor center default,MenubuttonActiveBackgroundColor #ececec default,MenubuttonActiveBackgroundMono Black default,MenubuttonActiveForegroundColor Black default,MenubuttonActiveForegroundMono White default,MenubuttonBackgroundColor #d9d9d9 default,MenubuttonBackgroundMono White default,MenubuttonBitmap {} default,MenubuttonBorderWidth 2 default,MenubuttonCursor {} default,MenubuttonDirection below default,MenubuttonDisabledForegroundColor #a3a3a3 default,MenubuttonDisabledForegroundMono {} default,MenubuttonFont "Helvetica -12 bold" default,MenubuttonForeground Black default,MenubuttonHeight 0 default,MenubuttonHighlightBackground #d9d9d9 default,MenubuttonHighlight Black default,MenubuttonHighlightWidth 0 default,MenubuttonImage {} default,MenubuttonIndicator 0 default,MenubuttonJustify center default,MenubuttonMenu {} default,MenubuttonPadX 4p default,MenubuttonPadY 3p default,MenubuttonRelief flat default,MenubuttonState normal default,MenubuttonTakeFocus 0 default,MenubuttonText {} default,MenubuttonTextVariable {} default,MenubuttonUnderline -1 default,MenubuttonWidth 0 default,MenubuttonWrapLength 0 default,MessageAnchor center default,MessageAspect 150 default,MessageBackgroundColor #d9d9d9 default,MessageBackgroundMono White default,MessageBorderWidth 2 default,MessageCursor {} default,MessageForeground Black default,MessageFont "Helvetica -12 bold" default,MessageHighlightBackground #d9d9d9 default,MessageHighlight Black default,MessageHighlightWidth 0 default,MessageJustify left default,MessagePadX -1 default,MessagePadY -1 default,MessageRelief flat default,MessageTakeFocus 0 default,MessageText {} default,MessageTextVariable {} default,MessageWidth 0 default,ScaleActiveBackgroundColor #ececec default,ScaleActiveBackgroundMono Black default,ScaleBackgroundColor #d9d9d9 default,ScaleBackgroundMono White default,ScaleBigIncrement 0 default,ScaleBorderWidth 2 default,ScaleCommand {} default,ScaleCursor {} default,ScaleDigits 0 default,ScaleFont "Helvetica -12 bold" default,ScaleForegroundColor Black default,ScaleForegroundMono Black default,ScaleFrom 0 default,ScaleHighlightBackground #d9d9d9 default,ScaleHighlight Black default,ScaleHighlightWidth 1 default,ScaleLabel {} default,ScaleLength 100 default,ScaleOrient vertical default,ScaleRelief flat default,ScaleRepeatDelay 300 default,ScaleRepeatInterval 100 default,ScaleResolution 1 default,ScaleTroughColor #c3c3c3 default,ScaleTroughMono White default,ScaleShowValue 1 default,ScaleSliderLength 30 default,ScaleSliderRelief raised default,ScaleState normal default,ScaleTakeFocus {} default,ScaleTickInterval 0 default,ScaleTo 100 default,ScaleVariable {} default,ScaleWidth 15 default,ScrollbarActiveBackgroundColor #ececec default,ScrollbarActiveBackgroundMono Black default,ScrollbarActiveRelief raised default,ScrollbarBackgroundColor #d9d9d9 default,ScrollbarBackgroundMono White default,ScrollbarBorderWidth 2 default,ScrollbarCommand {} default,ScrollbarCursor {} default,ScrollbarElementBorderWidth -1 default,ScrollbarHighlightBackground #d9d9d9 default,ScrollbarHighlight Black default,ScrollbarHighlightWidth 1 default,ScrollbarJump 0 default,ScrollbarOrient vertical default,ScrollbarRelief sunken default,ScrollbarRepeatDelay 300 default,ScrollbarRepeatInterval 100 default,ScrollbarTakeFocus {} default,ScrollbarTroughColor #c3c3c3 default,ScrollbarTroughMono White default,ScrollbarWidth 15 default,TextBackgroundColor #d9d9d9 default,TextBackgroundMono White default,TextBorderWidth 2 default,TextCursor xterm default,TextForeground Black default,TextExportSelection 1 default,TextFont "Courier -12" default,TextHeight 24 default,TextHighlightBackground #d9d9d9 default,TextHighlight Black default,TextHighlightWidth 1 default,TextInsertBackground Black default,TextInsertBorderColor 0 default,TextInsertBorderMono 0 default,TextInsertOffTime 300 default,TextInsertOnTime 600 default,TextInsertWidth 2 default,TextPadX 1 default,TextPadY 1 default,TextRelief sunken default,TextSelectColor #c3c3c3 default,TextSelectMono Black default,TextSelectBorderColor 1 default,TextSelectBorderMono 0 default,TextSelectForegroundColor Black default,TextSelectForegroundMono White default,TextSelectRelief raised default,TextSetGrid 0 default,TextSpacing1 0 default,TextSpacing2 0 default,TextSpacing3 0 default,TextState normal default,TextTabs {} default,TextTakeFocus {} default,TextWidth 80 default,TextWrap char default,TextXScrollCommand {} default,TextYScrollCommand {} default,ToplevelClass Toplevel default,ToplevelMenu {} default,ToplevelScreen {}}
}
windows {
array set widget:: {default,ButtonAnchor center default,ButtonActiveBackgroundColor SystemButtonFace default,ButtonActiveBackgroundMono Black default,ButtonActiveForegroundColor SystemButtonText default,ChkradActiveForegroundColor SystemWindowText default,ButtonActiveForegroundMono White default,ButtonBackgroundColor SystemButtonFace default,ButtonBackgroundMono White default,ButtonBitmap {} default,ButtonBorderWidth 2 default,ButtonCursor {} default,ButtonCommand {} default,ButtonDefault disabled default,ButtonDisabledForegroundColor SystemDisabledText default,ButtonDisabledForegroundMono {} default,ButtonForeground SystemButtonText default,ChkradForeground SystemWindowText default,ButtonFont "{MS Sans Serif} 8" default,ButtonHeight 0 default,ButtonHighlightBackground SystemButtonFace default,ButtonHighlight SystemWindowFrame default,LabelHighlightWidth 0 default,ButtonHighlightWidth 1 default,ButtonImage {} default,ButtonIndicator 1 default,ButtonJustify center default,ButtonOffValue 0 default,ButtonOnValue 1 default,ButtonPadX 1 default,LabelCheckRadiusPadX 1 default,ButtonPadY 1 default,LabelCheckRadiusPadY 1 default,ButtonRelief raised default,LabelCheckRadiusRelief flat default,ButtonSelectColor SystemWindow default,ButtonSelectMono Black default,ButtonSelectImage {} default,ButtonState normal default,LabelTakeFocus 0 default,ButtonTakeFocus {} default,ButtonText {} default,ButtonTextVariable {} default,ButtonUnderline -1 default,ButtonValue {} default,ButtonWidth 0 default,ButtonWrapLength 0 default,RadiobuttonVariable selectedButton default,CheckbuttonVariable {} default,CanvasBackgroundColor SystemButtonFace default,CanvasBackgroundMono White default,CanvasBorderWidth 0 default,CanvasCloseEnough 1 default,CanvasConfine 1 default,CanvasCursor {} default,CanvasHeight 7c default,CanvasHighlightBackground SystemButtonFace default,CanvasHighlight SystemWindowFrame default,CanvasHighlightWidth 2 default,CanvasInsertBackground SystemButtonText default,CanvasInsertBorderColor 0 default,CanvasInsertBorderMono 0 default,CanvasInsertOffTime 300 default,CanvasInsertOnTime 600 default,CanvasInsertWidth 2 default,CanvasRelief flat default,CanvasScrollRegion {} default,CanvasSelectColor SystemHighlight default,CanvasSelectMono Black default,CanvasSelectBorderColor 1 default,CanvasSelectBorderMono 0 default,CanvasSelectForegroundColor SystemHighlightText default,CanvasSelectForegroundMono White default,CanvasTakeFocus {} default,CanvasWidth 10c default,CanvasXScrollCommand {} default,CanvasXScrollIncrement 0 default,CanvasYScrollCommand {} default,CanvasYScrollIncrement 0 default,EntryBackgroundColor SystemWindow default,EntryBackgroundMono White default,EntryBorderWidth 2 default,EntryCursor xterm default,EntryExportSelection 1 default,EntryFont "{MS Sans Serif} 8" default,EntryForeground SystemWindowText default,EntryHighlightBackground SystemButtonFace default,EntryHighlight SystemWindowFrame default,EntryHighlightWidth 0 default,EntryInsertBackground SystemWindowText default,EntryInsertBorderColor 0 default,EntryInsertBorderMono 0 default,EntryInsertOffTime 300 default,EntryInsertOnTime 600 default,EntryInsertWidth 2 default,EntryJustify left default,EntryRelief sunken default,EntryScrollCommand {} default,EntrySelectColor SystemHighlight default,EntrySelectMono Black default,EntrySelectBorderColor 0 default,EntrySelectBorderMono 0 default,EntrySelectForegroundColor SystemHighlightText default,EntrySelectForegroundMono White default,EntryShow {} default,EntryState normal default,EntryTakeFocus {} default,EntryTextVariable {} default,EntryWidth 20 default,FrameBackgroundColor SystemButtonFace default,FrameBackgroundMono White default,FrameBorderWidth 0 default,FrameClass Frame default,FrameColormap {} default,FrameContainer 0 default,FrameCursor {} default,FrameHeight 0 default,FrameHighlightBackground SystemButtonFace default,FrameHighlight SystemWindowFrame default,FrameHighlightWidth 0 default,FrameRelief flat default,FrameTakeFocus 0 default,FrameUse {} default,FrameVisual {} default,FrameWidth 0 default,ListboxBackgroundColor SystemButtonFace default,ListboxBackgroundMono White default,ListboxBorderWidth 2 default,ListboxCursor {} default,ListboxExportSelection 1 default,ListboxFont "{MS Sans Serif} 8" default,ListboxForeground SystemButtonText default,ListboxHeight 10 default,ListboxHighlightBackground SystemButtonFace default,ListboxHighlight SystemWindowFrame default,ListboxHighlightWidth 1 default,ListboxRelief sunken default,ListboxScrollCommand {} default,ListboxSelectColor SystemHighlight default,ListboxSelectMono Black default,ListboxSelectBorder 1 default,ListboxSelectForegroundColor SystemHighlightText default,ListboxSelectForegroundMono White default,ListboxSelectMode browse default,ListboxSetGrid 0 default,ListboxTakeFocus {} default,ListboxWidth 20 default,MenuEntryActiveBackground {} default,MenuEntryActiveForeground {} default,MenuEntryAccelerator {} default,MenuEntryBackground {} default,MenuEntryBitmap None default,MenuEntryColumnBreak 0 default,MenuEntryCommand {} default,MenuEntryForeground {} default,MenuEntryFont {} default,MenuEntryHideMargin 0 default,MenuEntryImage {} default,MenuEntryIndicator 1 default,MenuEntryLabel {} default,MenuEntryMenu {} default,MenuEntryOffValue 0 default,MenuEntryOnValue 1 default,MenuEntrySelectImage {} default,MenuEntryState normal default,MenuEntryValue {} default,MenuEntryCheckVariable {} default,MenuEntryRadioVariable selectedButton default,MenuEntrySelect {} default,MenuEntryUnderline -1 default,MenuActiveBackgroundColor SystemHighlight default,MenuActiveBackgroundMono Black default,MenuActiveBorderWidth 0 default,MenuActiveForegroundColor SystemHighlightText default,MenuActiveForegroundMono White default,MenuBackgroundColor SystemMenu default,MenuBackgroundMono White default,MenuBorderWidth 0 default,MenuCursor arrow default,MenuDisabledForegroundColor SystemDisabledText default,MenuDisabledForegroundMono {} default,MenuFont "{MS Sans Serif} 8" default,MenuForeground SystemMenuText default,MenuPostCommand {} default,MenuRelief flat default,MenuSelectColor SystemMenuText default,MenuSelectMono Black default,MenuTakeFocus 0 default,MenuTearoff 1 default,MenuTearoffCommand {} default,MenuTitle {} default,MenuType normal default,MenubuttonAnchor center default,MenubuttonActiveBackgroundColor SystemButtonFace default,MenubuttonActiveBackgroundMono Black default,MenubuttonActiveForegroundColor SystemButtonText default,MenubuttonActiveForegroundMono White default,MenubuttonBackgroundColor SystemButtonFace default,MenubuttonBackgroundMono White default,MenubuttonBitmap {} default,MenubuttonBorderWidth 2 default,MenubuttonCursor {} default,MenubuttonDirection below default,MenubuttonDisabledForegroundColor SystemDisabledText default,MenubuttonDisabledForegroundMono {} default,MenubuttonFont "{MS Sans Serif} 8" default,MenubuttonForeground SystemButtonText default,MenubuttonHeight 0 default,MenubuttonHighlightBackground SystemButtonFace default,MenubuttonHighlight SystemWindowFrame default,MenubuttonHighlightWidth 0 default,MenubuttonImage {} default,MenubuttonIndicator 0 default,MenubuttonJustify center default,MenubuttonMenu {} default,MenubuttonPadX 4p default,MenubuttonPadY 3p default,MenubuttonRelief flat default,MenubuttonState normal default,MenubuttonTakeFocus 0 default,MenubuttonText {} default,MenubuttonTextVariable {} default,MenubuttonUnderline -1 default,MenubuttonWidth 0 default,MenubuttonWrapLength 0 default,MessageAnchor center default,MessageAspect 150 default,MessageBackgroundColor SystemButtonFace default,MessageBackgroundMono White default,MessageBorderWidth 2 default,MessageCursor {} default,MessageForeground SystemButtonText default,MessageFont "{MS Sans Serif} 8" default,MessageHighlightBackground SystemButtonFace default,MessageHighlight SystemWindowFrame default,MessageHighlightWidth 0 default,MessageJustify left default,MessagePadX -1 default,MessagePadY -1 default,MessageRelief flat default,MessageTakeFocus 0 default,MessageText {} default,MessageTextVariable {} default,MessageWidth 0 default,ScaleActiveBackgroundColor SystemButtonFace default,ScaleActiveBackgroundMono Black default,ScaleBackgroundColor SystemButtonFace default,ScaleBackgroundMono White default,ScaleBigIncrement 0 default,ScaleBorderWidth 2 default,ScaleCommand {} default,ScaleCursor {} default,ScaleDigits 0 default,ScaleFont "{MS Sans Serif} 8" default,ScaleForegroundColor SystemButtonText default,ScaleForegroundMono Black default,ScaleFrom 0 default,ScaleHighlightBackground SystemButtonFace default,ScaleHighlight SystemWindowFrame default,ScaleHighlightWidth 2 default,ScaleLabel {} default,ScaleLength 100 default,ScaleOrient vertical default,ScaleRelief flat default,ScaleRepeatDelay 300 default,ScaleRepeatInterval 100 default,ScaleResolution 1 default,ScaleTroughColor SystemScrollbar default,ScaleTroughMono White default,ScaleShowValue 1 default,ScaleSliderLength 30 default,ScaleSliderRelief raised default,ScaleState normal default,ScaleTakeFocus {} default,ScaleTickInterval 0 default,ScaleTo 100 default,ScaleVariable {} default,ScaleWidth 15 default,ScrollbarActiveBackgroundColor SystemButtonFace default,ScrollbarActiveBackgroundMono Black default,ScrollbarActiveRelief raised default,ScrollbarBackgroundColor SystemButtonFace default,ScrollbarBackgroundMono White default,ScrollbarBorderWidth 0 default,ScrollbarCommand {} default,ScrollbarCursor {} default,ScrollbarElementBorderWidth -1 default,ScrollbarHighlightBackground SystemButtonFace default,ScrollbarHighlight SystemWindowFrame default,ScrollbarHighlightWidth 0 default,ScrollbarJump 0 default,ScrollbarOrient vertical default,ScrollbarRelief sunken default,ScrollbarRepeatDelay 300 default,ScrollbarRepeatInterval 100 default,ScrollbarTakeFocus {} default,ScrollbarTroughColor SystemScrollbar default,ScrollbarTroughMono White default,ScrollbarWidth 10 default,TextBackgroundColor SystemWindow default,TextBackgroundMono White default,TextBorderWidth 2 default,TextCursor xterm default,TextForeground SystemWindowText default,TextExportSelection 1 default,TextFont "{MS Sans Serif} 8" default,TextHeight 24 default,TextHighlightBackground SystemButtonFace default,TextHighlight SystemWindowFrame default,TextHighlightWidth 0 default,TextInsertBackground SystemWindowText default,TextInsertBorderColor 0 default,TextInsertBorderMono 0 default,TextInsertOffTime 300 default,TextInsertOnTime 600 default,TextInsertWidth 2 default,TextPadX 1 default,TextPadY 1 default,TextRelief sunken default,TextSelectColor SystemHighlight default,TextSelectMono Black default,TextSelectBorderColor 0 default,TextSelectBorderMono 0 default,TextSelectForegroundColor SystemHighlightText default,TextSelectForegroundMono White default,TextSelectRelief flat default,TextSetGrid 0 default,TextSpacing1 0 default,TextSpacing2 0 default,TextSpacing3 0 default,TextState normal default,TextTabs {} default,TextTakeFocus {} default,TextWidth 80 default,TextWrap char default,TextXScrollCommand {} default,TextYScrollCommand {} default,ToplevelClass Toplevel default,ToplevelMenu {} default,ToplevelScreen {}}
}
}
class widget {
proc widget {this path} {
set widget::($this,path) $path
}
proc ~widget {this} {}
virtual proc configure {this args} {
return [eval $widget::($this,path) configure $args]
}
virtual proc cget {this args} {
return [$widget::($this,path) cget $args]
}
}
foreach class {button canvas entry frame label listbox menu menubutton message radiobutton scale scrollbar text toplevel} {
class $class {
proc $class {this parentPath args} widget "\[eval ::$class \$parentPath.\$this \$args\]" {}
proc ~$class {this} {
destroy $widget::($this,path)
}
}
}
class table {
proc table {this parentPath args} widget {[eval ::table $parentPath.$this $args]} {}
proc ~table {this} {
destroy $widget::($this,path)
}
}
foreach class {barchart graph hierbox htext stripchart tabset} {
class $class {
proc $class {this parentPath args} widget "\[eval ::blt::$class .\[string trimleft \$parentPath.\$this .\] \$args\]" {}
proc ~$class {this} {
destroy $widget::($this,path)
}
}
}
class composite {}
proc composite::composite {this base args} widget {$widget::($base,path)} {
if {([llength $args]%2)!=0} {
error "value for \"[lindex $args end]\" missing"
}
set composite::($this,base) $base
set composite::($this,base,path) $widget::($base,path)
set composite::($this,_children) {}
set composite::($this,complete) 0
set composite::($this,initialArguments) $args
}
proc composite::~composite {this} {
eval delete [lsort -integer -decreasing $composite::($this,_children)] $composite::($this,base)
}
virtual proc composite::options {this}
proc composite::configure {this args} {
if {[llength $args]==0} {
return [descriptions $this]
}
if {![string match -* $args]} {
return [eval widget::configure $composite::($this,[lindex $args 0]) [lrange $args 1 end]]
}
foreach {option value} $args {
if {![info exists composite::($this,$option)]} {
error "$composite::($this,_derived): unknown option \"$option\""
}
}
if {[llength $args]==1} {
return [description $this [lindex $args 0]]
}
if {([llength $args]%2)!=0} {
error "value for \"[lindex $args end]\" missing"
}
foreach {option value} $args {
if {[string compare $composite::($this,$option) $value]!=0} {
$composite::($this,_derived)::set$option $this [set composite::($this,$option) $value]
}
}
}
proc composite::manage {this args} {
foreach {child name} $args {
if {[string length $name]==0} {
error "widget $child has no name"
}
if {[string match -* $name]} {
error "widget $child name \"$name\" must not start with a dash character"
}
if {[info exists composite::($this,$name)]} {
error "\"$name\" member name already exists in composite layer"
}
set composite::($this,$name) $child
set composite::($this,$name,path) $widget::($child,path)
lappend composite::($this,_children) $child
}
}
proc composite::complete {this} {
set path $widget::($this,path)
foreach description [options $this] {
set option [lindex $description 0]
set composite::($this,$option) [set default [lindex $description 3]]
if {[llength $description]<5} {
set initialize($option) {}
} elseif {[string compare $default [lindex $description 4]]!=0} {
set composite::($this,$option) [lindex $description 4]
set initialize($option) {}
}
set value [option get $path [lindex $description 1] [lindex $description 2]]
if {([string length $value]>0)&&([string compare $value $default]!=0)} {
set composite::($this,$option) $value
set initialize($option) {}
}
}
foreach {option value} $composite::($this,initialArguments) {
if {[catch {string compare $composite::($this,$option) $value} different]} {
error "$composite::($this,_derived): unknown option \"$option\""
}
if {$different} {
set composite::($this,$option) $value
set initialize($option) {}
}
}
unset composite::($this,initialArguments)
foreach option [array names initialize] {
$composite::($this,_derived)::set$option $this $composite::($this,$option)
}
set composite::($this,complete) 1
}
proc composite::cget {this args} {
switch [llength $args] {
0 {
error "wrong # args: should be \"cget $this ?child? ?child? ... option\""
}
1 {
if {![string match -* $args]||![info exists composite::($this,$args)]} {
error "$composite::($this,_derived): unknown option \"$args\""
}
return $composite::($this,$args)
}
default {
return [eval widget::cget $composite::($this,[lindex $args 0]) [lrange $args 1 end]]
}
}
}
proc composite::try {this args} {
if {([llength $args]%2)!=0} {
error "value for \"[lindex $args end]\" missing"
}
foreach {option value} $args {
catch {widget::configure $composite::($this,base) $option $value}
foreach child $composite::($this,_children) {
catch {widget::configure $child $option $value}
}
}
}
proc composite::description {this option} {
foreach description [options $this] {
if {[string compare [lindex $description 0] $option]==0} {
if {[llength $description]<5} {
lappend description $composite::($this,$option)
return $description
} else {
return [lreplace $description 4 4 $composite::($this,$option)]
}
}
}
}
proc composite::descriptions {this} {
set descriptions {}
foreach description [options $this] {
if {[llength $description]<5} {
lappend description $composite::($this,[lindex $description 0])
lappend descriptions $description
} else {
lappend descriptions [lreplace $description 4 4 $composite::($this,[lindex $description 0])]
}
}
return $descriptions
}
proc composite::managingOrder {this name1 name2} {
return [expr {$composite::($this,$name1)-$composite::($this,$name2)}]
}
proc composite::componentNames {this} {
set names {}
foreach index [array names composite:: $this,*,path] {
if {[regexp {,(.+),path} $index dummy name]} {
lappend names $name
}
}
return [lsort -command "managingOrder $this" $names]
}
set rcsId {$Id: bindings.tcl,v 1.4 1997/12/30 15:02:13 jfontain Exp $}
class bindings {
proc bindings {this widget index} {
::set bindings::($this,widget) $widget
bindtags $widget [linsert [bindtags $widget] $index bindings($this)]
}
proc ~bindings {this} {
::set tags [bindtags $bindings::($this,widget)]
::set index [lsearch -exact $tags bindings($this)]
bindtags $bindings::($this,widget) [lreplace $tags $index $index]
foreach tag [bind bindings($this)] {
bind bindings($this) $tag {}
}
}
proc set {this tag sequence} {
bind bindings($this) $tag $sequence
}
}
set rcsId {$Id: widgetip.tcl,v 1.32 1998/09/19 19:38:46 jfontain Exp $}
class widgetTip {
class topLabel {
proc topLabel {this parentPath args} composite {
[new toplevel $parentPath -highlightbackground black -highlightthickness 1] $args
} {
composite::manage $this [new label $widget::($this,path)] label
composite::complete $this
pack $composite::($this,label,path)
wm overrideredirect $widget::($this,path) 1
}
proc ~topLabel {this} {}
proc options {this} {
return [list\
[list -bordercolor borderColor BorderColor Black Black]\
[list -borderwidth borderWidth BorderWidth 1 1]\
[list\
-background background Background\
$widget::(default,ButtonBackgroundColor) $widget::(default,ButtonBackgroundColor)\
]\
[list -font font Font $widget::(default,ButtonFont) $widget::(default,ButtonFont)]\
[list -foreground foreground Foreground $widget::(default,ButtonForeground) $widget::(default,ButtonForeground)]\
[list -text text Text {} {}]\
]
}
foreach option {-background -font -foreground -text} {
proc set$option {this value} "\$composite::(\$this,label,path) configure $option \$value"
}
proc set-bordercolor {this value} {
$widget::($this,path) configure -highlightbackground $value
}
proc set-borderwidth {this value} {
$widget::($this,path) configure -highlightthickness $value
}
}
if {![info exists widgetTip::(label)]} {
set widgetTip::(label) [new topLabel . -font $widget::(default,EntryFont) -background #FFFFBF]
set widgetTip::(path) $widget::($widgetTip::(label),path)
wm withdraw $widgetTip::(path)
bind all <ButtonPress> {widgetTip::globalEvent %W}
bind all <KeyPress> {widgetTip::globalEvent %W}
set widgetTip::(xLast) -1
set widgetTip::(yLast) -1
}
proc widgetTip {this args} switched {$args} {
switched::complete $this
}
proc ~widgetTip {this} {
disable $this
catch {delete $widgetTip::($this,bindings)}
}
proc options {this} {
return [list\
[list -font $widget::(default,EntryFont) $widget::(default,EntryFont)]\
[list -path {} {}]\
[list -text {} {}]\
]
}
proc set-path {this value} {
if {$switched::($this,complete)} {
error {option -path cannot be set dynamically}
}
if {![winfo exists $value]} {
error "invalid widget: \"$value\""
}
set bindings [new bindings $value 0]
bindings::set $bindings <Enter> "widgetTip::enable $this"
bindings::set $bindings <Leave> "widgetTip::disable $this"
bindings::set $bindings <Destroy> "delete $this"
set widgetTip::($this,bindings) $bindings
}
proc set-font {this value} {}
proc set-text {this value} {}
proc globalEvent {widget} {
if {![catch {string first $switched::($widgetTip::(active),-path) $widget} value]&&($value==0)} {
disable $widgetTip::(active)
}
}
proc show {this x y} {
set path $widgetTip::(path)
widget::configure $widgetTip::(label) -font $switched::($this,-font) -text $switched::($this,-text)
showTopLevel $path +$x+$y
update idletasks
raise $path
}
proc enable {this} {
set x [winfo pointerx $widgetTip::(path)]
set y [winfo pointery $widgetTip::(path)]
if {($x==$widgetTip::(xLast))&&($y==$widgetTip::(yLast))} {
widgetTip::show $this [expr {$x+7}] [expr {$y+10}]
} else {
set widgetTip::(xLast) $x
set widgetTip::(yLast) $y
set widgetTip::(event) [after 300 "widgetTip::enable $this"]
}
set widgetTip::(active) $this
}
proc disable {this} {
catch {after cancel $widgetTip::(event)}
catch {unset widgetTip::(active)}
wm withdraw $widgetTip::(path)
}
}
set rcsId {$Id: arrowbut.tcl,v 1.31 1997/09/19 09:50:23 jfontain Exp $}
proc maximum {a b} {return [expr {$a>$b?$a:$b}]}
class arrowButton {}
proc arrowButton::arrowButton {this parentPath args} composite {
[new canvas $parentPath\
-relief raised -background $widget::(default,ButtonBackgroundColor)\
-borderwidth $widget::(default,ButtonBorderWidth) -height $widget::(default,ScrollbarWidth)\
-highlightbackground $widget::(default,ButtonHighlightBackground) -highlightcolor $widget::(default,ButtonHighlight)\
-highlightthickness $widget::(default,ButtonHighlightWidth) -width $widget::(default,ScrollbarWidth)\
] $args
} {
set path $widget::($this,path)
set arrowButton::($this,triangle) [$path create polygon 0 0 0 0 0 0]
bind $path <Configure> "arrowButton::redraw $this %w %h"
set arrowButton::($this,active) 0
composite::complete $this
}
proc arrowButton::~arrowButton {this} {}
proc arrowButton::options {this} {
return [list\
[list\
-activebackground activeBackground Foreground\
$widget::(default,ButtonActiveBackgroundColor) $widget::(default,ButtonActiveBackgroundColor)\
]\
[list -background background Background $widget::(default,ButtonBackgroundColor) $widget::(default,ButtonBackgroundColor)]\
[list -borderwidth borderWidth BorderWidth $widget::(default,ButtonBorderWidth) $widget::(default,ButtonBorderWidth)]\
[list -command command Command {} {}]\
[list -direction direction Direction down]\
[list\
-disabledforeground disabledForeground DisabledForeground\
$widget::(default,ButtonDisabledForegroundColor) $widget::(default,ButtonDisabledForegroundColor)\
]\
[list -foreground foreground Foreground $widget::(default,ButtonForeground) $widget::(default,ButtonForeground)]\
[list -height height Height $widget::(default,ScrollbarWidth) $widget::(default,ScrollbarWidth)]\
[list\
-highlightbackground highlightBackground HighlightBackground\
$widget::(default,ButtonHighlightBackground) $widget::(default,ButtonHighlightBackground)\
]\
[list -highlightcolor highlightColor HighlightColor $widget::(default,ButtonHighlight) $widget::(default,ButtonHighlight)]\
[list\
-highlightthickness highlightThickness HighlightThickness\
$widget::(default,ButtonHighlightWidth) $widget::(default,ButtonHighlightWidth)\
]\
[list -repeatdelay repeatDelay RepeatDelay 0 0]\
[list -state state State normal]\
[list -takefocus takeFocus TakeFocus 1]\
[list -width width Width $widget::(default,ScrollbarWidth) $widget::(default,ScrollbarWidth)]\
]
}
proc arrowButton::set-activebackground {this value} {}
proc arrowButton::set-state {this value} {
set path $widget::($this,path)
switch $value {
normal {
$path itemconfigure $arrowButton::($this,triangle)\
-fill $composite::($this,-foreground) -outline $composite::($this,-foreground)
bind $path <Enter> "arrowButton::activate $this"
bind $path <Leave> "arrowButton::deactivate $this; arrowButton::raise $this"
bind $path <ButtonPress-1>\
"set arrowButton::($this,buttonPressed) 1; arrowButton::sink $this; arrowButton::startTimer $this"
bind $path <ButtonRelease-1>\
"arrowButton::raise $this; arrowButton::invoke $this 0; set arrowButton::($this,buttonPressed) 0"
if {$composite::($this,-takefocus)} {
bind $path <KeyPress-space> "arrowButton::sink $this"
bind $path <KeyRelease-space> "arrowButton::raise $this; arrowButton::invoke $this 1"
} else {
bind $path <KeyPress-space> {}
bind $path <KeyRelease-space> {}
}
}
disabled {
$widget::($this,path) itemconfigure $arrowButton::($this,triangle)\
-fill $composite::($this,-disabledforeground) -outline $composite::($this,-disabledforeground)
bind $path <Enter> {}
bind $path <Leave> {}
bind $path <ButtonPress-1> {}
bind $path <ButtonRelease-1> {}
bind $path <KeyPress-space> {}
bind $path <KeyRelease-space> {}
}
default {
error "bad state value \"$value\": must be normal or disabled"
}
}
}
foreach option {-background -borderwidth -height -highlightbackground -highlightcolor -highlightthickness -width} {
proc arrowButton::set$option {this value} "\$widget::(\$this,path) configure $option \$value"
}
foreach option {-disabledforeground -foreground} {
proc arrowButton::set$option {this value} {set-state $this $composite::($this,-state)}
}
proc arrowButton::set-command {this value} {}
proc arrowButton::set-direction {this value} {
if {\
([string first $value down]!=0)&&([string first $value up]!=0)&&\
([string first $value left]!=0)&&([string first $value right]!=0)\
} {
error "bad direction value \"$value\": must be down, up, left or right (or any abbreviation)"
}
redraw $this [winfo width $widget::($this,path)] [winfo height $widget::($this,path)]
}
proc arrowButton::set-takefocus {this value} {
if {![regexp {^0|1$} $value]} {
error "bad takefocus value \"$value\": must be 0 or 1"
}
$widget::($this,path) configure -takefocus $value
set-state $this $composite::($this,-state)
}
proc arrowButton::set-repeatdelay {this value} {}
proc arrowButton::redraw {this width height} {
set insideWidth [expr {$width-2*($composite::($this,-borderwidth)+$composite::($this,-highlightthickness))}]
set insideHeight [expr {$height-2*($composite::($this,-borderwidth)+$composite::($this,-highlightthickness))}]
switch -glob $composite::($this,-direction) {
d* {
set insideWidth [maximum [expr {$insideWidth/4}] 1]
$widget::($this,path) coords $arrowButton::($this,triangle) 0 0 [expr {2*$insideWidth}] 0 $insideWidth $insideWidth
}
u* {
set insideWidth [maximum [expr {$insideWidth/4}] 1]
$widget::($this,path) coords $arrowButton::($this,triangle) 0 0 [expr {2*$insideWidth}] 0 $insideWidth -$insideWidth
}
l* {
set insideHeight [maximum [expr {$insideHeight/4}] 1]
$widget::($this,path) coords $arrowButton::($this,triangle) 0 0 0 [expr {2*$insideHeight}] -$insideHeight $insideHeight
}
r* {
set insideHeight [maximum [expr {$insideHeight/4}] 1]
$widget::($this,path) coords $arrowButton::($this,triangle) 0 0 0 [expr {2*$insideHeight}] $insideHeight $insideHeight
}
}
centerTriangle $this $width $height
}
proc arrowButton::centerTriangle {this width height} {
set box [$widget::($this,path) bbox $arrowButton::($this,triangle)]
$widget::($this,path) move $arrowButton::($this,triangle)\
[expr {($width-[lindex $box 2]-[lindex $box 0])/2}] [expr {($height-[lindex $box 3]-[lindex $box 1])/2}]
}
proc arrowButton::activate {this} {
$widget::($this,path) configure -background $composite::($this,-activebackground)
set arrowButton::($this,active) 1
}
proc arrowButton::deactivate {this} {
$widget::($this,path) configure -background $composite::($this,-background)
set arrowButton::($this,active) 0
}
proc arrowButton::sink {this} {
set path $widget::($this,path)
$path configure -relief sunken
centerTriangle $this [winfo width $path] [winfo height $path]
$path move $arrowButton::($this,triangle) 1 1
}
proc arrowButton::raise {this} {
set path $widget::($this,path)
$path configure -relief raised
centerTriangle $this [winfo width $path] [winfo height $path]
if {[info exists arrowButton::($this,event)]} {
after cancel $arrowButton::($this,event)
unset arrowButton::($this,event)
}
}
proc arrowButton::invoke {this fromKey} {
if {([string length $composite::($this,-command)]>0)&&($arrowButton::($this,active)||$fromKey)} {
uplevel #0 $composite::($this,-command)
}
}
proc arrowButton::startTimer {this} {
if {$composite::($this,-repeatdelay)>0} {
set arrowButton::($this,event) [after $composite::($this,-repeatdelay) "arrowButton::processTimer $this"]
}
}
proc arrowButton::processTimer {this} {
if {$arrowButton::($this,buttonPressed)} {
startTimer $this
invoke $this 0
} else {
unset arrowButton::($this,event)
}
}
set rcsId {$Id: spinent.tcl,v 1.38 1998/10/01 20:07:02 jfontain Exp $}
class spinEntry {}
proc spinEntry::spinEntry {this parentPath args} composite {
[new frame $parentPath -highlightthickness $widget::(default,ButtonHighlightWidth)] $args
} {
::set path $widget::($this,path)
composite::manage $this [new entry $path -highlightthickness 0] entry\
[new arrowButton $path\
-takefocus 0 -command "spinEntry::decrease $this" -height 4 -highlightthickness 0\
-repeatdelay $widget::(default,ScrollbarRepeatDelay)\
] decrease\
[new arrowButton $path\
-direction up -takefocus 0 -command "spinEntry::increase $this" -height 4 -highlightthickness 0\
-repeatdelay $widget::(default,ScrollbarRepeatDelay)\
] increase
bind $path <Return> "spinEntry::invoke $this"
bind $path <KP_Enter> "spinEntry::invoke $this"
bind $composite::($this,entry,path) <Return> "spinEntry::invoke $this"
bind $composite::($this,entry,path) <KP_Enter> "spinEntry::invoke $this"
spinEntry::setupUpAndDownKeysBindings $this $path
spinEntry::setupUpAndDownKeysBindings $this $composite::($this,entry,path)
composite::complete $this
}
proc spinEntry::~spinEntry {this} {}
proc spinEntry::options {this} {
return [list\
[list -command command Command {} {}]\
[list -editable editable editable 1 1]\
[list -font font Font $widget::(default,ButtonFont)]\
[list -justify justify Justify $widget::(default,EntryJustify) $widget::(default,EntryJustify)]\
[list -list list List {} {}]\
[list -range range Range {} {}]\
[list -repeatdelay repeatDelay RepeatDelay $widget::(default,ScrollbarRepeatDelay) $widget::(default,ScrollbarRepeatDelay)]\
[list -side side Side left]\
[list -state state State normal]\
[list -width width Width $widget::(default,EntryWidth) $widget::(default,EntryWidth)]\
]
}
proc spinEntry::set-command {this value} {}
proc spinEntry::set-editable {this value} {
setStatesAndBindings $this
}
proc spinEntry::set-list {this value} {
if {$composite::($this,complete)} {
error {option -orient cannot be set dynamically}
}
if {[string length [$composite::($this,entry,path) get]]==0} {
set $this [lindex $value 0]
}
}
proc spinEntry::set-range {this value} {
if {$composite::($this,complete)} {
error {option -range cannot be set dynamically}
}
if {[llength $value]!=3} {
error {option -range argument format must be {minimum maximum increment}}
}
::set spinEntry::($this,minimum) [lindex $composite::($this,-range) 0]
::set spinEntry::($this,maximum) [lindex $composite::($this,-range) 1]
::set spinEntry::($this,increment) [lindex $composite::($this,-range) 2]
if {[catch {expr {$spinEntry::($this,maximum)-$spinEntry::($this,minimum)+$spinEntry::($this,increment)}}]} {
error {option -range arguments must be numeric values}
}
if {[string length [$composite::($this,entry,path) get]]==0} {
set $this $spinEntry::($this,minimum)
}
}
proc spinEntry::set-repeatdelay {this value} {
widget::configure $composite::($this,decrease) -repeatdelay $value
widget::configure $composite::($this,increase) -repeatdelay $value
}
proc spinEntry::set-state {this value} {
if {![regexp {^disabled|normal$} $value]} {
error "bad state value \"$value\": must be normal or disabled"
}
setStatesAndBindings $this
}
foreach option {-font -justify -width} {
proc spinEntry::set$option {this value} "\$composite::(\$this,entry,path) configure $option \$value"
}
proc spinEntry::set-side {this value} {
if {![regexp {^left|right$} $value]} {
error "bad side value \"$value\": must be left or right"
}
pack forget $composite::($this,entry,path) $composite::($this,increase,path) $composite::($this,decrease,path)
pack $composite::($this,entry,path) -side $value -fill both -expand 1
pack $composite::($this,increase,path) $composite::($this,decrease,path) -fill y -expand 1
}
proc spinEntry::decrease {this} {
set $this [spinEntry::next $this -1]
invoke $this
}
proc spinEntry::increase {this} {
set $this [spinEntry::next $this 1]
invoke $this
}
proc spinEntry::next {this direction} {
::set value [$composite::($this,entry,path) get]
if {[catch {::set spinEntry::($this,increment)} increment]} {
::set index [lsearch -exact $composite::($this,-list) $value]
incr index $direction
if {$index<0} {
return [lindex $composite::($this,-list) 0]
} elseif {$index>=[llength $composite::($this,-list)]} {
return [lindex $composite::($this,-list) end]
} else {
return [lindex $composite::($this,-list) $index]
}
} else {
::set minimum $spinEntry::($this,minimum)
::set maximum $spinEntry::($this,maximum)
if {[catch {expr {$value+0}}]} {
return [expr {$direction<0?$minimum:$maximum}]
} else {
::set value [expr {$value+($direction*$increment)}]
if {$value<=$minimum} {
return $minimum
} elseif {$value>=$maximum} {
return $maximum
} else {
return $value
}
}
}
}
proc spinEntry::setStatesAndBindings {this} {
if {[string compare $composite::($this,-state) normal]==0} {
widget::configure $composite::($this,decrease) -state normal
widget::configure $composite::($this,increase) -state normal
if {$composite::($this,-editable)} {
$widget::($this,path) configure -takefocus 0
$composite::($this,entry,path) configure -state normal
} else {
$widget::($this,path) configure -takefocus 1
$composite::($this,entry,path) configure -state disabled
}
} else {
$widget::($this,path) configure -takefocus 0
widget::configure $composite::($this,decrease) -state disabled
widget::configure $composite::($this,increase) -state disabled
widget::configure $composite::($this,entry) -state disabled
}
}
proc spinEntry::setupUpAndDownKeysBindings {this path} {
bind $path <KeyPress-Down> "arrowButton::sink $composite::($this,decrease); spinEntry::decrease $this"
bind $path <KeyRelease-Down> "arrowButton::raise $composite::($this,decrease)"
bind $path <KeyPress-Up> "arrowButton::sink $composite::($this,increase); spinEntry::increase $this"
bind $path <KeyRelease-Up> "arrowButton::raise $composite::($this,increase)"
}
proc spinEntry::invoke {this} {
if {[string length $composite::($this,-command)]>0} {
uplevel #0 $composite::($this,-command) [list [$composite::($this,entry,path) get]]
}
}
proc spinEntry::set {this text} {
::set path $composite::($this,entry,path)
$path configure -state normal
$path delete 0 end
$path insert 0 $text
if {!$composite::($this,-editable)} {
$path configure -state disabled
}
}
proc spinEntry::get {this} {
return [$composite::($this,entry,path) get]
}
set rcsId {$Id: panner.tcl,v 1.20 1998/10/04 14:43:02 jfontain Exp $}
class panner {
set panner::(default,HandleSize) 8
}
proc panner::panner {this parentPath args} composite {[new frame $parentPath] $args} {
set panner::($this,handles) {}
set panner::($this,lastManagerSize) 0
set panner::($this,handleSize) $panner::(default,HandleSize)
composite::complete $this
}
proc panner::~panner {this} {}
proc panner::options {this} {
return [list\
[list -handlesize handleSize HandleSize $panner::(default,HandleSize)]\
[list -handleplacement handlePlacement HandlePlacement 0.9 0.9]\
[list -orient orient Orient vertical]\
[list -panes panes Panes 2 3]\
]
}
proc panner::try {this option value} {
set path $widget::($this,path)
catch {$path configure $option $value}
set lastIndex [expr {(2*$composite::($this,-panes))-2}]
for {set itemIndex 0} {$itemIndex<=$lastIndex} {incr itemIndex} {
set frame $path.$itemIndex
catch {$frame configure $option $value}
if {($itemIndex%2)!=0} {
catch {$frame.separator configure $option $value}
catch {$frame.handle configure $option $value}
}
}
}
proc panner::set-handlesize {this value} {
set panner::($this,handleSize) [expr {(([winfo pixels $widget::($this,path) $value]+1)/2)*2}]
if {$composite::($this,complete)} {
updateHandleSize $this
}
}
proc panner::set-orient {this value} {
if {$composite::($this,complete)} {
error {option -orient cannot be set dynamically}
}
if {([string first $value vertical]!=0)&&([string first $value horizontal]!=0)} {
error "bad orientation value \"$value\": must be horizontal or vertical (or any abbreviation)"
}
if {[string match v* $composite::($this,-orient)]} {
bind $widget::($this,path) <Configure> "panner::resize $this %h"
} else {
bind $widget::($this,path) <Configure> "panner::resize $this %w"
}
}
proc panner::set-panes {this value} {
if {$composite::($this,complete)} {
error {option -panes cannot be set dynamically}
}
set path $widget::($this,path)
if {[string match v* $composite::($this,-orient)]} {
set vertical 1
grid columnconfigure $path 0 -weight 1
set sticky ew
set cursor sb_v_double_arrow
} else {
set vertical 0
grid rowconfigure $path 0 -weight 1
set sticky ns
set cursor sb_h_double_arrow
}
set paneIndex 0
set itemIndex 0
while {1} {
set frame [frame $path.$itemIndex]
if {$vertical} {
grid $frame -sticky nsew -row $itemIndex -column 0
grid rowconfigure $path $itemIndex -weight 1000000
} else {
grid $frame -sticky nsew -column $itemIndex -row 0
grid columnconfigure $path $itemIndex -weight 1000000
}
incr paneIndex
set panner::($this,frame$paneIndex) $frame
if {$paneIndex==$value} {
break
}
incr itemIndex
set frame [frame $path.$itemIndex]
if {$vertical} {
grid $frame -sticky $sticky -row $itemIndex -column 0
grid rowconfigure $path $itemIndex -weight 1
} else {
grid $frame -sticky $sticky -column $itemIndex -row 0
grid columnconfigure $path $itemIndex -weight 1
}
frame $frame.separator -borderwidth 1 -relief ridge
if {$vertical} {
$frame.separator configure -height 2
} else {
$frame.separator configure -width 2
}
place $frame.separator -anchor center -relx 0.5 -rely 0.5
if {$vertical} {
place $frame.separator -relwidth 1
} else {
place $frame.separator -relheight 1
}
button $frame.handle -borderwidth 1 -highlightthickness 0 -cursor $cursor -takefocus 0
bind $frame.handle <ButtonPress-1> "panner::startMotion $this %W"
if {$vertical} {
bind $frame.handle <ButtonRelease-1> "panner::endMotion $this %W $itemIndex %Y"
place $frame.handle -rely 0.5 -anchor center
} else {
bind $frame.handle <ButtonRelease-1> "panner::endMotion $this %W $itemIndex %X"
place $frame.handle -relx 0.5 -anchor center
}
incr itemIndex
}
updateHandleSize $this
set-handleplacement $this $composite::($this,-handleplacement)
}
proc panner::set-handleplacement {this value} {
set path $widget::($this,path)
set lastIndex [expr {(2*$composite::($this,-panes))-2}]
if {[string first $composite::($this,-orient) vertical]==0} {
for {set itemIndex 1} {$itemIndex<=$lastIndex} {incr itemIndex 2} {
place $path.$itemIndex.handle -relx $value
}
} else {
for {set itemIndex 1} {$itemIndex<=$lastIndex} {incr itemIndex 2} {
place $path.$itemIndex.handle -rely $value
}
}
}
proc panner::startMotion {this handle} {
set path $widget::($this,path)
if {[string first $composite::($this,-orient) vertical]==0} {
bind $handle <Motion> "panner::verticalMotion $this %Y"
set panner::(line) [frame $path.line -background black -height 1 -width [winfo width $path]]
set panner::(minimum) [winfo rooty $path]
set panner::(maximum) [expr {$panner::(minimum)+[winfo height $path]-1}]
} else {
bind $handle <Motion> "panner::horizontalMotion $this %X"
set panner::(line) [frame $path.line -background black -width 1 -height [winfo height $path]]
set panner::(minimum) [winfo rootx $path]
set panner::(maximum) [expr {$panner::(minimum)+[winfo width $path]-1}]
}
}
proc panner::clip {coordinate} {
if {$coordinate<$panner::(minimum)} {
return $panner::(minimum)
} elseif {$coordinate>$panner::(maximum)} {
return $panner::(maximum)
} else {
return $coordinate
}
}
proc panner::endMotion {this handle row rootCoordinate} {
set visible [expr {[llength [place info $panner::(line)]]>0}]
destroy $panner::(line)
bind $handle <Motion> {}
if {$visible} {
split $this $row [expr {[clip $rootCoordinate]-$panner::(minimum)}]
}
unset panner::(line) panner::(minimum) panner::(maximum)
}
proc panner::verticalMotion {this yRoot} {
place $panner::(line) -y [expr {[clip $yRoot]-$panner::(minimum)}]
}
proc panner::horizontalMotion {this xRoot} {
place $panner::(line) -x [expr {[clip $xRoot]-$panner::(minimum)}]
}
proc panner::split {this handleIndex coordinate} {
if {[string match v* $composite::($this,-orient)]} {
set vertical 1
set itemName row
set sizeName height
} else {
set vertical 0
set itemName column
set sizeName width
}
set path $widget::($this,path)
set lastIndex [expr {(2*$composite::($this,-panes))-2}]
if {[grid propagate $path]} {
grid propagate $path 0
for {set itemIndex 0} {$itemIndex<=$lastIndex} {incr itemIndex} {
grid ${itemName}configure $path $itemIndex -minsize [winfo $sizeName $path.$itemIndex]
}
}
set separatorsSize 0
set framesSize 0
set beforeIndex [expr {$handleIndex-1}]
set afterIndex [expr {$handleIndex+1}]
if {$vertical} {
set lastCoordinate [lindex [grid bbox $path 0 $handleIndex] 1]
set masterSize [lindex [grid bbox $path] 3]
set frameStart [lindex [grid bbox $path 0 $beforeIndex] 1]
set box [grid bbox $path 0 $afterIndex]
set frameEnd [expr {[lindex $box 1]+[lindex $box 3]}]
} else {
set lastCoordinate [lindex [grid bbox $path $handleIndex 0] 0]
set masterSize [lindex [grid bbox $path] 2]
set frameStart [lindex [grid bbox $path $beforeIndex 0] 0]
set box [grid bbox $path $afterIndex 0]
set frameEnd [expr {[lindex $box 0]+[lindex $box 2]}]
}
if {$coordinate>$lastCoordinate} {
incr coordinate -[expr {$panner::($this,handleSize)/2}]
for {set itemIndex $handleIndex} {$itemIndex<=$lastIndex} {incr itemIndex} {
if {($itemIndex%2)==0} {
incr framesSize [grid ${itemName}configure $path $itemIndex -minsize]
} else {
incr separatorsSize $panner::($this,handleSize)
}
}
set remaining [expr {$masterSize-$coordinate-$separatorsSize}]
if {$remaining<0} {
set size [expr {$masterSize-$frameStart-$separatorsSize}]
set remaining 0
} else {
set size [expr {$coordinate-$frameStart}]
}
grid ${itemName}configure $path $beforeIndex -minsize $size
for {set itemIndex $lastIndex} {$itemIndex>=$afterIndex} {incr itemIndex -2} {
if {$remaining>[grid ${itemName}configure $path $itemIndex -minsize]} {
incr remaining -[grid ${itemName}configure $path $itemIndex -minsize]
} elseif {$remaining>0} {
grid ${itemName}configure $path $itemIndex -minsize $remaining
set remaining 0
} else {
grid ${itemName}configure $path $itemIndex -minsize 0
}
}
} elseif {$coordinate<$lastCoordinate} {
incr coordinate [expr {$panner::($this,handleSize)/2}]
for {set itemIndex $handleIndex} {$itemIndex>=0} {incr itemIndex -1} {
if {($itemIndex%2)==0} {
incr framesSize [grid ${itemName}configure $path $itemIndex -minsize]
} else {
incr separatorsSize $panner::($this,handleSize)
}
}
set remaining [expr {$coordinate-$separatorsSize}]
if {$remaining<0} {
set size [expr {$frameEnd-$separatorsSize}]
set remaining 0
} else {
set size [expr {$frameEnd-$coordinate}]
}
grid ${itemName}configure $path $afterIndex -minsize $size
for {set itemIndex 0} {$itemIndex<=$beforeIndex} {incr itemIndex 2} {
if {$remaining>[grid ${itemName}configure $path $itemIndex -minsize]} {
incr remaining -[grid ${itemName}configure $path $itemIndex -minsize]
} elseif {$remaining>0} {
grid ${itemName}configure $path $itemIndex -minsize $remaining
set remaining 0
} else {
grid ${itemName}configure $path $itemIndex -minsize 0
}
}
}
}
proc panner::updateHandleSize {this} {
set size $panner::($this,handleSize)
set path $widget::($this,path)
set lastIndex [expr {(2*$composite::($this,-panes))-2}]
if {[string match v* $composite::($this,-orient)]} {
for {set row 1} {$row<$lastIndex} {incr row 2} {
set frame $path.$row
place $frame.handle -width $size -height $size
$frame configure -height $size
grid rowconfigure $path $row -minsize $size
}
} else {
for {set column 1} {$column<$lastIndex} {incr column 2} {
set frame $path.$column
place $frame.handle -width $size -height $size
$frame configure -width $size
grid columnconfigure $path $column -minsize $size
}
}
}
proc panner::resize {this size} {
if {$size==$panner::($this,lastManagerSize)} {
return
}
set panner::($this,lastManagerSize) $size
set path $widget::($this,path)
if {[grid propagate $path]} {
return
}
set lastIndex [expr {(2*$composite::($this,-panes))-2}]
set lastSize 0
set newSize $size
if {[string match v* $composite::($this,-orient)]} {
set itemName row
} else {
set itemName column
}
for {set itemIndex 0} {$itemIndex<=$lastIndex} {incr itemIndex} {
if {($itemIndex%2)==0} {
incr lastSize [grid ${itemName}configure $path $itemIndex -minsize]
} else {
incr newSize -$panner::($this,handleSize)
}
}
set ratio [expr {double($newSize)/$lastSize}]
for {set itemIndex 0} {$itemIndex<$lastIndex} {incr itemIndex 2} {
set size [expr {round($ratio*[grid ${itemName}configure $path $itemIndex -minsize])}]
grid ${itemName}configure $path $itemIndex -minsize $size
incr newSize -$size
}
grid ${itemName}configure $path $itemIndex -minsize $newSize
}
}
set rcsId {$Id: record.tcl,v 1.8 1998/10/17 20:40:52 jfontain Exp $}
class record {
proc record {this args} switched {$args} {
switched::complete $this
}
proc ~record {this} {
variable ${this}data
catch {unset ${this}data}
}
proc options {this} {
return [list\
[list -file {} {}]\
]
}
proc set-file {this value} {}
proc write {this} {
if {[string length $switched::($this,-file)]==0} {
error {-file option undefined}
}
set file [open $switched::($this,-file) w+]
puts $file "version $::applicationVersion"
set seconds [clock seconds]
puts $file "date [clock format $seconds -format %D] time [clock format $seconds -format %T]"
puts $file "configuration {}"
puts $file "width [winfo width .] height [winfo height .]"
puts $file "pollTime $::pollTime"
puts $file "modules \{"
foreach module $::modules(all) {
puts $file " $module \{"
puts $file " arguments {}"
puts $file " tables \{"
set index 0
foreach table $dataTable::(list) {
if {[string compare $module [namespace qualifiers [composite::cget $table -data]]]!=0} continue
foreach {x y width height} [canvasWindowManager::getGeometry $::windowManager $widget::($table,path)] {}
puts $file " $index \{"
puts $file " x $x y $y width $width height $height"
puts $file " \}"
incr index
}
puts $file " \}"
puts $file " \}"
}
puts $file \}
puts $file "viewers \{"
set index 0
foreach viewer $viewer::(list) {
puts $file " $index \{"
puts $file " class [classof $viewer]"
foreach {x y width height} [canvasWindowManager::getGeometry $::windowManager $widget::($viewer,path)] {}
puts $file " x $x y $y width $width height $height"
puts $file " cells {[viewer::cells $viewer]}"
set options [viewer::initializationConfiguration $viewer]
if {[llength $options]>0} {
puts $file " $options"
}
puts $file " \}"
incr index
}
puts $file \}
close $file
}
proc read {this} {
variable ${this}data
if {[string length $switched::($this,-file)]==0} {
error {-file option undefined}
}
set file [open $switched::($this,-file)]
array set ${this}data [::read $file]
close $file
}
proc modules {this} {
variable ${this}data
array set data [set ${this}data(modules)]
return [array names data]
}
proc pollTime {this} {
variable ${this}data
return [set ${this}data(pollTime)]
}
proc sizes {this} {
variable ${this}data
return "[set ${this}data(width)] [set ${this}data(height)]"
}
proc viewersData {this} {
variable ${this}data
array set data [set ${this}data(viewers)]
set list {}
foreach index [lsort -integer [array names data]] {
array set viewer $data($index)
set options {}
foreach name [array names viewer -*] {
lappend options $name $viewer($name)
}
lappend list $viewer(class) $viewer(cells) $viewer(x) $viewer(y) $viewer(width) $viewer(height) $options
}
return $list
}
proc tableGeometry {this module {index 0}} {
variable ${this}data
array set data [set ${this}data(modules)]
array set moduleData $data($module)
unset data
array set tablesData $moduleData(tables)
unset moduleData
array set data $tablesData($index)
unset tablesData
return "$data(x) $data(y) $data(width) $data(height)"
}
}
if {[info exists arguments(-f)]} {
set saveFile $arguments(-f)
set initializer [new record -file $saveFile]
record::read $initializer
set modules(all) [record::modules $initializer]
} else {
set saveFile {}
set modules(all) $argv
}
set modules(all,string) [commaSeparatedString $modules(all)]
set readOnly [info exists arguments(-r)]
set static [info exists arguments(-S)]
lappend auto_path /usr/lib/moodss .
loadModules $modules(all)
set modules(synchronous) {}
foreach module $modules(all) {
if {[lindex [set ${module}::data(pollTimes)] 0]>0} {
lappend modules(synchronous) $module
}
}
set modules(synchronous,string) [commaSeparatedString $modules(synchronous)]
if {[info exists arguments(-p)]} {
setPollTimes $modules(all) $arguments(-p)
} elseif {[info exists initializer]} {
setPollTimes $modules(all) [record::pollTime $initializer]
} else {
setPollTimes $modules(all)
}
if {[catch {package require Tktable 2}]} {
switch $tcl_platform(platform) {
unix {
load ./Tktable.so.2.3
}
windows {
load ./tktable.dll
}
}
}
if {[catch {package require BLT}]} {
switch $tcl_platform(platform) {
unix {
load ./libBLT.so.2.4f
}
windows {
load ./blt80.dll
}
}
}
set officialBLT [expr {$blt_version!=8.0}]
if 1 {
set rcsId {$Id: pielabel.tcl,v 1.40 1998/06/07 10:07:30 jfontain Exp $}
class pieLabeler {
set pieLabeler::(default,font) {Helvetica -12}
proc pieLabeler {this canvas args} {
::set pieLabeler::($this,canvas) $canvas
}
proc ~pieLabeler {this} {}
virtual proc new {this slice args}
virtual proc delete {this label}
virtual proc set {this label value}
virtual proc selectState {this label {state {}}}
virtual proc update {this left top right bottom}
virtual proc room {this arrayName}
}
set rcsId {$Id: boxlabel.tcl,v 1.39 1998/06/07 10:20:43 jfontain Exp $}
class pieBoxLabeler {
proc pieBoxLabeler {this canvas args} pieLabeler {$canvas $args} switched {$args} {
::set pieBoxLabeler::($this,array) [::new canvasLabelsArray $canvas]
switched::complete $this
}
proc ~pieBoxLabeler {this} {
catch {::delete $pieBoxLabeler::($this,array)}
}
proc options {this} {
return [list\
[list -font $pieLabeler::(default,font) $pieLabeler::(default,font)]\
[list -justify left left]\
[list -offset 5 5]\
[list -xoffset 0 0]\
]
}
foreach option {-font -justify -offset -xoffset} {
proc set$option {this value} "
if {\$switched::(\$this,complete)} {
error {option $option cannot be set dynamically}
}
"
}
proc new {this slice args} {
::set label [eval ::new canvasLabel $pieLabeler::($this,canvas)\
$args [list -justify $switched::($this,-justify) -font $switched::($this,-font)]\
]
canvasLabelsArray::manage $pieBoxLabeler::($this,array) $label
$pieLabeler::($this,canvas) addtag pieLabeler($this) withtag canvasLabelsArray($pieBoxLabeler::($this,array))
switched::configure $label -text [switched::cget $label -text]:
::set pieBoxLabeler::($this,selected,$label) 0
return $label
}
proc delete {this label} {
canvasLabelsArray::delete $pieBoxLabeler::($this,array) $label
unset pieBoxLabeler::($this,selected,$label)
}
proc set {this label value} {
regsub {:.*$} [switched::cget $label -text] ": $value" text
switched::configure $label -text $text
}
proc selectState {this label {selected {}}} {
if {[string length $selected]==0} {
return $pieBoxLabeler::($this,selected,$label)
}
if {$selected} {
switched::configure $label -borderwidth 2
} else {
switched::configure $label -borderwidth 1
}
::set pieBoxLabeler::($this,selected,$label) $selected
}
proc update {this left top right bottom} {
::set canvas $pieLabeler::($this,canvas)
::set array $pieBoxLabeler::($this,array)
foreach {x y} [$canvas coords canvasLabelsArray($array)] {}
$canvas move canvasLabelsArray($array) [expr {$left-$x}] [expr {$bottom-[canvasLabelsArray::height $array]-$y}]
switched::configure $array -width [expr {$right-$left}]
}
proc room {this arrayName} {
upvar $arrayName data
::set data(left) 0
::set data(right) 0
::set data(top) 0
::set box [$pieLabeler::($this,canvas) bbox canvasLabelsArray($pieBoxLabeler::($this,array))]
if {[llength $box]==0} {
::set data(bottom) 0
} else {
::set data(bottom) [expr {[lindex $box 3]-[lindex $box 1]+$switched::($this,-offset)}]
}
}
}
set rcsId {$Id: canlabel.tcl,v 1.22 1998/06/07 10:08:13 jfontain Exp $}
class canvasLabel {
proc canvasLabel {this canvas args} switched {$args} {
set canvasLabel::($this,canvas) $canvas
set canvasLabel::($this,origin) [$canvas create image 0 0 -tags canvasLabel($this)]
set canvasLabel::($this,rectangle) [$canvas create rectangle 0 0 0 0 -tags canvasLabel($this)]
set canvasLabel::($this,text) [$canvas create text 0 0 -tags canvasLabel($this)]
switched::complete $this
}
proc ~canvasLabel {this} {
$canvasLabel::($this,canvas) delete canvasLabel($this)
}
proc options {this} {
return [list\
[list -anchor center center]\
[list -background {} {}]\
[list -bordercolor black black]\
[list -borderwidth 1 1]\
[list -bulletwidth 20 20]\
[list -font {Helvetica -12}]\
[list -foreground black black]\
[list -justify left left]\
[list -padding 2 2]\
[list -scale {1 1} {1 1}]\
[list -stipple {} {}]\
[list -style box box]\
[list -text {} {}]\
[list -width 0 0]\
]
}
proc set-background {this value} {
$canvasLabel::($this,canvas) itemconfigure $canvasLabel::($this,rectangle) -fill $value
}
proc set-bordercolor {this value} {
$canvasLabel::($this,canvas) itemconfigure $canvasLabel::($this,rectangle) -outline $value
}
proc set-borderwidth {this value} {
$canvasLabel::($this,canvas) itemconfigure $canvasLabel::($this,rectangle) -width $value
update $this
}
proc set-foreground {this value} {
$canvasLabel::($this,canvas) itemconfigure $canvasLabel::($this,text) -fill $value
}
proc set-scale {this value} {
update $this
}
proc set-stipple {this value} {
$canvasLabel::($this,canvas) itemconfigure $canvasLabel::($this,rectangle) -stipple $value
}
proc set-style {this value} {
if {![regexp {^box|split$} $value]} {
error "bad style value \"$value\": must be box or split"
}
update $this
}
foreach option {-anchor -bulletwidth -padding} {
proc set$option {this value} {update $this}
}
foreach option {-font -justify -text -width} {
proc set$option {this value} "
\$canvasLabel::(\$this,canvas) itemconfigure \$canvasLabel::(\$this,text) $option \$value
update \$this
"
}
proc update {this} {
set canvas $canvasLabel::($this,canvas)
set rectangle $canvasLabel::($this,rectangle)
set text $canvasLabel::($this,text)
foreach {x y} [$canvas coords $canvasLabel::($this,origin)] {}
set border [$canvas itemcget $rectangle -width]
set textBox [$canvas bbox $text]
set padding [winfo fpixels $canvas $switched::($this,-padding)]
if {[string compare $switched::($this,-style) split]==0} {
set textHeight [expr {[lindex $textBox 3]-[lindex $textBox 1]}]
set rectangleWidth [winfo fpixels $canvas $switched::($this,-bulletwidth)]
set halfWidth [expr {($rectangleWidth+$padding+([lindex $textBox 2]-[lindex $textBox 0]))/2.0}]
set halfHeight [expr {($textHeight/2.0)+$border}]
$canvas coords $rectangle\
[expr {$x-$halfWidth}] [expr {$y-$halfHeight}] [expr {$x-$halfWidth+$rectangleWidth}] [expr {$y+$halfHeight}]
$canvas coords $text [expr {$x+(($rectangleWidth+$padding)/2.0)}] $y
} else {
set width [expr {$switched::($this,-width)==0?[lindex $textBox 2]-[lindex $textBox 0]:$switched::($this,-width)}]
set halfWidth [expr {$border+$padding+($width/2.0)}]
set halfHeight [expr {$border+$padding+(([lindex $textBox 3]-[lindex $textBox 1])/2.0)}]
$canvas coords $rectangle [expr {$x-$halfWidth}] [expr {$y-$halfHeight}] [expr {$x+$halfWidth}] [expr {$y+$halfHeight}]
$canvas coords $text $x $y
}
set anchor $switched::($this,-anchor)
set xDelta [expr {([string match *w $anchor]-[string match *e $anchor])*$halfWidth}]
set yDelta [expr {([string match n* $anchor]-[string match s* $anchor])*$halfHeight}]
$canvas move $rectangle $xDelta $yDelta
$canvas move $text $xDelta $yDelta
eval $canvas scale canvasLabel($this) $x $y $switched::($this,-scale)
}
}
set rcsId {$Id: labarray.tcl,v 1.20 1998/06/07 13:47:02 jfontain Exp $}
class canvasLabelsArray {
proc canvasLabelsArray {this canvas args} switched {$args} {
set canvasLabelsArray::($this,canvas) $canvas
set canvasLabelsArray::($this,origin) [$canvas create image 0 0 -tags canvasLabelsArray($this)]
set canvasLabelsArray::($this,labels) {}
switched::complete $this
}
proc ~canvasLabelsArray {this} {
eval ::delete $canvasLabelsArray::($this,labels)
$canvasLabelsArray::($this,canvas) delete canvasLabelsArray($this)
}
proc options {this} {
return [list\
[list -justify left left]\
[list -width 100]\
]
}
proc set-justify {this value} {
if {$switched::($this,complete)} {
error {option -justify cannot be set dynamically}
}
}
proc set-width {this value} {
set canvasLabelsArray::($this,width) [winfo fpixels $canvasLabelsArray::($this,canvas) $value]
update $this
}
proc update {this} {
set index 0
foreach label $canvasLabelsArray::($this,labels) {
position $this $label $index
incr index
}
}
proc manage {this label} {
$canvasLabelsArray::($this,canvas) addtag canvasLabelsArray($this) withtag canvasLabel($label)
set index [llength $canvasLabelsArray::($this,labels)]
lappend canvasLabelsArray::($this,labels) $label
position $this $label $index
}
proc delete {this label} {
set index [lsearch -exact $canvasLabelsArray::($this,labels) $label]
if {$index<0} {
error "invalid label $label for canvas labels array $this"
}
set canvasLabelsArray::($this,labels) [lreplace $canvasLabelsArray::($this,labels) $index $index]
::delete $label
foreach label [lrange $canvasLabelsArray::($this,labels) $index end] {
position $this $label $index
incr index
}
}
proc position {this label index} {
set canvas $canvasLabelsArray::($this,canvas)
foreach {x y} [$canvas coords $canvasLabelsArray::($this,origin)] {}
set coordinates [$canvas bbox canvasLabel($label)]
set y [expr {$y+(($index/2)*([lindex $coordinates 3]-[lindex $coordinates 1]))}]
switch $switched::($this,-justify) {
left {
set x [expr {$x+(($index%2)*($canvasLabelsArray::($this,width)/2.0))}]
set anchor nw
}
right {
set x [expr {$x+((($index%2)+1)*($canvasLabelsArray::($this,width)/2.0))}]
set anchor ne
}
default {
set x [expr {$x+((1.0+(2*($index%2)))*$canvasLabelsArray::($this,width)/4)}]
set anchor n
}
}
switched::configure $label -anchor $anchor
foreach {xDelta yDelta} [$canvas coords canvasLabel($label)] {}
$canvas move canvasLabel($label) [expr {$x-$xDelta}] [expr {$y-$yDelta}]
}
proc labels {this} {
return $canvasLabelsArray::($this,labels)
}
proc height {this} {
set number [llength $canvasLabelsArray::($this,labels)]
if {$number==0} {
return 0
}
set coordinates [$canvasLabelsArray::($this,canvas) bbox canvasLabel([lindex $canvasLabelsArray::($this,labels) 0])]
return [expr {(($number+1)/2)*([lindex $coordinates 3]-[lindex $coordinates 1])}]
}
}
set rcsId {$Id: perilabel.tcl,v 1.45 1998/06/09 21:17:52 jfontain Exp $}
class piePeripheralLabeler {
variable PI 3.14159265358979323846
proc piePeripheralLabeler {this canvas args} pieLabeler {$canvas $args} switched {$args} {
switched::complete $this
::set piePeripheralLabeler::($this,array) [::new canvasLabelsArray $canvas -justify $switched::($this,-justify)]
::set piePeripheralLabeler::($this,valueWidth)\
[font measure $switched::($this,-smallfont) $switched::($this,-widestvaluetext)]
::set piePeripheralLabeler::($this,valueHeight) [font metrics $switched::($this,-smallfont) -ascent]
}
proc ~piePeripheralLabeler {this} {
catch {delete $piePeripheralLabeler::($this,array)}
$pieLabeler::($this,canvas) delete pieLabeler($this)
}
proc options {this} {
return [list\
[list -bulletwidth 20 20]\
[list -font $pieLabeler::(default,font) $pieLabeler::(default,font)]\
[list -justify left left]\
[list -offset 5 5]\
[list -smallfont {Helvetica -10} {Helvetica -10}]\
[list -widestvaluetext 0.00 0.00]\
]
}
foreach option {-bulletwidth -font -justify -offset -smallfont -widestvaluetext} {
proc set$option {this value} "
if {\$switched::(\$this,complete)} {
error {option $option cannot be set dynamically}
}
"
}
proc set-smallfont {this value} {
if {$switched::($this,complete)} {
error {option -smallfont cannot be set dynamically}
}
}
proc new {this slice args} {
::set canvas $pieLabeler::($this,canvas)
::set text [$canvas create text 0 0 -font $switched::($this,-smallfont) -tags pieLabeler($this)]
::set label [eval ::new canvasLabel $pieLabeler::($this,canvas) $args\
[list\
-style split -justify $switched::($this,-justify) -bulletwidth $switched::($this,-bulletwidth)\
-font $switched::($this,-font)\
]\
]
canvasLabelsArray::manage $piePeripheralLabeler::($this,array) $label
$canvas addtag pieLabeler($this) withtag canvasLabelsArray($piePeripheralLabeler::($this,array))
::set piePeripheralLabeler::($this,textItem,$label) $text
::set piePeripheralLabeler::($this,slice,$label) $slice
::set piePeripheralLabeler::($this,selected,$label) 0
return $label
}
proc anglePosition {degrees} {
return [expr {(2*($degrees/90))+(($degrees%90)!=0)}]
}
::set index 0
foreach anchor {w sw s se e ne n nw} {
::set piePeripheralLabeler::(anchor,[anglePosition [expr {$index*45}]]) $anchor
incr index
}
unset index anchor
proc set {this label value} {
::set text $piePeripheralLabeler::($this,textItem,$label)
position $this $text $piePeripheralLabeler::($this,slice,$label)
$pieLabeler::($this,canvas) itemconfigure $text -text $value
}
proc position {this text slice} {
variable PI
slice::data $slice data
::set midAngle [expr {$data(start)+($data(extent)/2.0)}]
::set radians [expr {$midAngle*$PI/180}]
::set x [expr {($data(xRadius)+$switched::($this,-offset))*cos($radians)}]
::set y [expr {($data(yRadius)+$switched::($this,-offset))*sin($radians)}]
::set angle [expr {round($midAngle)%360}]
if {$angle>180} {
::set y [expr {$y-$data(height)}]
}
::set canvas $pieLabeler::($this,canvas)
::set coordinates [$canvas coords $text]
$canvas move $text [expr {$data(xCenter)+$x-[lindex $coordinates 0]}] [expr {$data(yCenter)-$y-[lindex $coordinates 1]}]
$canvas itemconfigure $text -anchor $piePeripheralLabeler::(anchor,[anglePosition $angle])
}
proc delete {this label} {
canvasLabelsArray::delete $piePeripheralLabeler::($this,array) $label
$pieLabeler::($this,canvas) delete $piePeripheralLabeler::($this,textItem,$label)
unset piePeripheralLabeler::($this,textItem,$label) piePeripheralLabeler::($this,slice,$label)\
piePeripheralLabeler::($this,selected,$label)
foreach label [canvasLabelsArray::labels $piePeripheralLabeler::($this,array)] {
position $this $piePeripheralLabeler::($this,textItem,$label) $piePeripheralLabeler::($this,slice,$label)
}
}
proc selectState {this label {selected {}}} {
if {[string length $selected]==0} {
return $piePeripheralLabeler::($this,selected,$label)
}
if {$selected} {
switched::configure $label -borderwidth 2
} else {
switched::configure $label -borderwidth 1
}
::set piePeripheralLabeler::($this,selected,$label) $selected
}
proc update {this left top right bottom} {
::set canvas $pieLabeler::($this,canvas)
::set array $piePeripheralLabeler::($this,array)
foreach {x y} [$canvas coords canvasLabelsArray($array)] {}
$canvas move canvasLabelsArray($array) [expr {$left-$x}] [expr {$bottom-[canvasLabelsArray::height $array]-$y}]
switched::configure $array -width [expr {$right-$left}]
foreach label [canvasLabelsArray::labels $array] {
position $this $piePeripheralLabeler::($this,textItem,$label) $piePeripheralLabeler::($this,slice,$label)
}
}
proc room {this arrayName} {
upvar $arrayName data
::set data(left) [expr {$piePeripheralLabeler::($this,valueWidth)+$switched::($this,-offset)}]
::set data(right) $data(left)
::set data(top) [expr {$switched::($this,-offset)+$piePeripheralLabeler::($this,valueHeight)}]
::set box [$pieLabeler::($this,canvas) bbox canvasLabelsArray($piePeripheralLabeler::($this,array))]
if {[llength $box]==0} {
::set data(bottom) $data(top)
} else {
::set data(bottom) [expr {$data(top)+[lindex $box 3]-[lindex $box 1]}]
}
}
}
set rcsId {$Id: slice.tcl,v 1.39 1998/06/07 10:19:25 jfontain Exp $}
class slice {
variable PI 3.14159265358979323846
}
proc slice::slice {this canvas xRadius yRadius args} switched {$args} {
set slice::($this,canvas) $canvas
set slice::($this,xRadius) $xRadius
set slice::($this,yRadius) $yRadius
switched::complete $this
complete $this
update $this
}
proc slice::~slice {this} {
if {[string length $switched::($this,-deletecommand)]>0} {
uplevel $switched::($this,-deletecommand)
}
$slice::($this,canvas) delete slice($this)
}
proc slice::options {this} {
return [list\
[list -bottomcolor {} {}]\
[list -deletecommand {} {}]\
[list -height 0 0]\
[list -scale {1 1} {1 1}]\
[list -startandextent {0 0} {0 0}]\
[list -topcolor {} {}]\
]
}
foreach option {-bottomcolor -height -topcolor} {
proc slice::set$option {this value} "
if {\$switched::(\$this,complete)} {
error {option $option cannot be set dynamically}
}
"
}
proc slice::set-deletecommand {this value} {}
proc slice::set-scale {this value} {
if {$switched::($this,complete)} {
update $this
}
}
proc slice::set-startandextent {this value} {
foreach {start extent} $value {}
set slice::($this,start) [normalizedAngle $start]
if {$extent<0} {
set slice::($this,extent) 0
} elseif {$extent>=360} {
set slice::($this,extent) [expr {360-pow(10,-$::tcl_precision+3)}]
} else {
set slice::($this,extent) $extent
}
if {$switched::($this,complete)} {
update $this
}
}
proc slice::normalizedAngle {value} {
while {$value>=180} {
set value [expr {$value-360}]
}
while {$value<-180} {
set value [expr {$value+360}]
}
return $value
}
proc slice::complete {this} {
set canvas $slice::($this,canvas)
set xRadius $slice::($this,xRadius)
set yRadius $slice::($this,yRadius)
set bottomColor $switched::($this,-bottomcolor)
set slice::($this,origin) [$canvas create image -$xRadius -$yRadius -tags slice($this)]
if {$switched::($this,-height)>0} {
set slice::($this,startBottomArcFill) [$canvas create arc\
0 0 0 0 -style chord -extent 0 -fill $bottomColor -outline $bottomColor -tags slice($this)\
]
set slice::($this,startPolygon) [$canvas create polygon 0 0 0 0 0 0 -fill $bottomColor -tags slice($this)]
set slice::($this,startBottomArc) [$canvas create arc 0 0 0 0 -style arc -extent 0 -fill black -tags slice($this)]
set slice::($this,endBottomArcFill) [$canvas create arc\
0 0 0 0 -style chord -extent 0 -fill $bottomColor -outline $bottomColor -tags slice($this)\
]
set slice::($this,endPolygon) [$canvas create polygon 0 0 0 0 0 0 -fill $bottomColor -tags slice($this)]
set slice::($this,endBottomArc) [$canvas create arc 0 0 0 0 -style arc -extent 0 -fill black -tags slice($this)]
set slice::($this,startLeftLine) [$canvas create line 0 0 0 0 -tags slice($this)]
set slice::($this,startRightLine) [$canvas create line 0 0 0 0 -tags slice($this)]
set slice::($this,endLeftLine) [$canvas create line 0 0 0 0 -tags slice($this)]
set slice::($this,endRightLine) [$canvas create line 0 0 0 0 -tags slice($this)]
}
set slice::($this,topArc) [$canvas create arc\
-$xRadius -$yRadius $xRadius $yRadius -fill $switched::($this,-topcolor) -tags slice($this)\
]
$canvas move slice($this) $xRadius $yRadius
}
proc slice::update {this} {
set canvas $slice::($this,canvas)
set coordinates [$canvas coords $slice::($this,origin)]
set xRadius $slice::($this,xRadius)
set yRadius $slice::($this,yRadius)
$canvas coords $slice::($this,origin) -$xRadius -$yRadius
$canvas coords $slice::($this,topArc) -$xRadius -$yRadius $xRadius $yRadius
$canvas itemconfigure $slice::($this,topArc) -start $slice::($this,start) -extent $slice::($this,extent)
if {$switched::($this,-height)>0} {
updateBottom $this
}
$canvas move slice($this) [expr {[lindex $coordinates 0]+$xRadius}] [expr {[lindex $coordinates 1]+$yRadius}]
eval $canvas scale slice($this) $coordinates $switched::($this,-scale)
}
proc slice::updateBottom {this} {
variable PI
set start $slice::($this,start)
set extent $slice::($this,extent)
set canvas $slice::($this,canvas)
set xRadius $slice::($this,xRadius)
set yRadius $slice::($this,yRadius)
set height $switched::($this,-height)
$canvas itemconfigure $slice::($this,startBottomArcFill) -extent 0
$canvas coords $slice::($this,startBottomArcFill) -$xRadius -$yRadius $xRadius $yRadius
$canvas move $slice::($this,startBottomArcFill) 0 $height
$canvas itemconfigure $slice::($this,startBottomArc) -extent 0
$canvas coords $slice::($this,startBottomArc) -$xRadius -$yRadius $xRadius $yRadius
$canvas move $slice::($this,startBottomArc) 0 $height
$canvas coords $slice::($this,startLeftLine) 0 0 0 0
$canvas coords $slice::($this,startRightLine) 0 0 0 0
$canvas itemconfigure $slice::($this,endBottomArcFill) -extent 0
$canvas coords $slice::($this,endBottomArcFill) -$xRadius -$yRadius $xRadius $yRadius
$canvas move $slice::($this,endBottomArcFill) 0 $height
$canvas itemconfigure $slice::($this,endBottomArc) -extent 0
$canvas coords $slice::($this,endBottomArc) -$xRadius -$yRadius $xRadius $yRadius
$canvas move $slice::($this,endBottomArc) 0 $height
$canvas coords $slice::($this,endLeftLine) 0 0 0 0
$canvas coords $slice::($this,endRightLine) 0 0 0 0
$canvas coords $slice::($this,startPolygon) 0 0 0 0 0 0 0 0
$canvas coords $slice::($this,endPolygon) 0 0 0 0 0 0 0 0
set startX [expr {$xRadius*cos($start*$PI/180)}]
set startY [expr {-$yRadius*sin($start*$PI/180)}]
set end [normalizedAngle [expr {$start+$extent}]]
set endX [expr {$xRadius*cos($end*$PI/180)}]
set endY [expr {-$yRadius*sin($end*$PI/180)}]
set startBottom [expr {$startY+$height}]
set endBottom [expr {$endY+$height}]
if {(($start>=0)&&($end>=0))||(($start<0)&&($end<0))} {
if {$extent<=180} {
if {$start<0} {
$canvas itemconfigure $slice::($this,startBottomArcFill) -start $start -extent $extent
$canvas itemconfigure $slice::($this,startBottomArc) -start $start -extent $extent
$canvas coords $slice::($this,startPolygon) $startX $startY $endX $endY $endX $endBottom $startX $startBottom
$canvas coords $slice::($this,startLeftLine) $startX $startY $startX $startBottom
$canvas coords $slice::($this,startRightLine) $endX $endY $endX $endBottom
}
} else {
if {$start<0} {
$canvas itemconfigure $slice::($this,startBottomArcFill) -start 0 -extent $start
$canvas itemconfigure $slice::($this,startBottomArc) -start 0 -extent $start
$canvas coords $slice::($this,startPolygon) $startX $startY $xRadius 0 $xRadius $height $startX $startBottom
$canvas coords $slice::($this,startLeftLine) $startX $startY $startX $startBottom
$canvas coords $slice::($this,startRightLine) $xRadius 0 $xRadius $height
set bottomArcExtent [expr {$end+180}]
$canvas itemconfigure $slice::($this,endBottomArcFill) -start -180 -extent $bottomArcExtent
$canvas itemconfigure $slice::($this,endBottomArc) -start -180 -extent $bottomArcExtent
$canvas coords $slice::($this,endPolygon) -$xRadius 0 $endX $endY $endX $endBottom -$xRadius $height
$canvas coords $slice::($this,endLeftLine) -$xRadius 0 -$xRadius $height
$canvas coords $slice::($this,endRightLine) $endX $endY $endX $endBottom
} else {
$canvas itemconfigure $slice::($this,startBottomArcFill) -start 0 -extent -180
$canvas itemconfigure $slice::($this,startBottomArc) -start 0 -extent -180
$canvas coords $slice::($this,startPolygon) -$xRadius 0 $xRadius 0 $xRadius $height -$xRadius $height
$canvas coords $slice::($this,startLeftLine) -$xRadius 0 -$xRadius $height
$canvas coords $slice::($this,startRightLine) $xRadius 0 $xRadius $height
}
}
} else {
if {$start<0} {
$canvas itemconfigure $slice::($this,startBottomArcFill) -start 0 -extent $start
$canvas itemconfigure $slice::($this,startBottomArc) -start 0 -extent $start
$canvas coords $slice::($this,startPolygon) $startX $startY $xRadius 0 $xRadius $height $startX $startBottom
$canvas coords $slice::($this,startLeftLine) $startX $startY $startX $startBottom
$canvas coords $slice::($this,startRightLine) $xRadius 0 $xRadius $height
} else {
set bottomArcExtent [expr {$end+180}]
$canvas itemconfigure $slice::($this,endBottomArcFill) -start -180 -extent $bottomArcExtent
$canvas itemconfigure $slice::($this,endBottomArc) -start -180 -extent $bottomArcExtent
$canvas coords $slice::($this,endPolygon) -$xRadius 0 $endX $endY $endX $endBottom -$xRadius $height
$canvas coords $slice::($this,startLeftLine) -$xRadius 0 -$xRadius $height
$canvas coords $slice::($this,startRightLine) $endX $endY $endX $endBottom
}
}
}
proc slice::rotate {this angle} {
if {$angle==0} return
set slice::($this,start) [normalizedAngle [expr {$slice::($this,start)+$angle}]]
update $this
}
proc slice::data {this arrayName} {
upvar $arrayName data
set data(start) $slice::($this,start)
set data(extent) $slice::($this,extent)
foreach {x y} $switched::($this,-scale) {}
set data(xRadius) [expr {$x*$slice::($this,xRadius)}]
set data(yRadius) [expr {$y*$slice::($this,yRadius)}]
set data(height) [expr {$y*$switched::($this,-height)}]
foreach {x y} [$slice::($this,canvas) coords $slice::($this,origin)] {}
set data(xCenter) [expr {$x+$data(xRadius)}]
set data(yCenter) [expr {$y+$data(yRadius)}]
}
set rcsId {$Id: selector.tcl,v 1.2 1998/05/24 19:18:21 jfontain Exp $}
class selector {
proc selector {this args} switched {$args} {
switched::complete $this
}
proc ~selector {this} {
variable ${this}selected
catch {::unset ${this}selected}
}
proc options {this} {
return [::list\
[::list -selectcommand {} {}]\
]
}
proc set-selectcommand {this value} {}
proc set {this indices selected} {
variable ${this}selected
::set select {}
::set deselect {}
foreach index $indices {
if {[info exists ${this}selected($index)]&&($selected==[::set ${this}selected($index)])} continue
if {$selected} {
lappend select $index
::set ${this}selected($index) 1
} else {
lappend deselect $index
::set ${this}selected($index) 0
}
}
update $this $select $deselect
}
proc update {this selected deselected} {
if {[string length $switched::($this,-selectcommand)]==0} return
if {[llength $selected]>0} {
uplevel #0 $switched::($this,-selectcommand) [::list $selected] 1
}
if {[llength $deselected]>0} {
uplevel #0 $switched::($this,-selectcommand) [::list $deselected] 0
}
}
proc unset {this indices} {
variable ${this}selected
foreach index $indices {
::unset ${this}selected($index)
}
}
proc add {this indices} {
set $this $indices 0
}
proc remove {this indices} {
unset $this $indices
}
proc select {this indices} {
clear $this
set $this $indices 1
::set selector::($this,lastSelected) [lindex $indices end]
}
proc deselect {this indices} {
set $this $indices 0
}
proc toggle {this indices} {
variable ${this}selected
::set select {}
::set deselect {}
foreach index $indices {
if {[::set ${this}selected($index)]} {
lappend deselect $index
::set ${this}selected($index) 0
} else {
lappend select $index
::set ${this}selected($index) 1
::set selector::($this,lastSelected) $index
}
}
update $this $select $deselect
}
virtual proc extend {this index} {}
proc clear {this} {
variable ${this}selected
set $this [array names ${this}selected] 0
}
virtual proc selected {this} {
variable ${this}selected
::set list {}
foreach index [array names ${this}selected] {
if {[::set ${this}selected($index)]} {
lappend list $index
}
}
return $list
}
virtual proc list {this} {
variable ${this}selected
return [array names ${this}selected]
}
}
set rcsId {$Id: objselec.tcl,v 1.5 1998/05/24 19:24:43 jfontain Exp $}
class objectSelector {
proc objectSelector {this args} selector {$args} {}
proc ~objectSelector {this} {}
proc extend {this id} {
if {[info exists selector::($this,lastSelected)]} {
set list [list $this]
set last [lsearch -exact $list $selector::($this,lastSelected)]
set index [lsearch -exact $list $id]
selector::clear $this
if {$index>$last} {
selector::set $this [lrange $list $last $index] 1
} else {
selector::set $this [lrange $list $index $last] 1
}
} else {
selector::select $this $id
}
}
proc selected {this} {
return [lsort -integer [selector::_selected $this]]
}
proc list {this} {
return [lsort -integer [selector::_list $this]]
}
}
set rcsId {$Id: pie.tcl,v 1.80 1998/06/09 21:20:45 jfontain Exp $}
package provide tkpiechart 5.2
class pie {
set pie::(colors) {#7FFFFF #7FFF7F #FF7F7F #FFFF7F #7F7FFF #FFBF00 #BFBFBF #FF7FFF #FFFFFF}
}
proc pie::pie {this canvas x y args} switched {$args} {
set pie::($this,canvas) $canvas
set pie::($this,colorIndex) 0
set pie::($this,slices) {}
set pie::($this,origin) [$canvas create image $x $y -tags pie($this)]
switched::complete $this
complete $this
}
proc pie::~pie {this} {
catch {$pie::($this,canvas) delete $pie::($this,title)}
delete $pie::($this,labeler)
eval delete $pie::($this,slices) $pie::($this,backgroundSlice)
catch {delete $pie::($this,selector)}
$pie::($this,canvas) delete $pie::($this,origin)
}
proc pie::options {this} {
return [list\
[list -background {} {}]\
[list -colors $pie::(colors) $pie::(colors)]\
[list -height 200]\
[list -labeler 0 0]\
[list -selectable 0 0]\
[list -thickness 0]\
[list -title {} {}]\
[list -titlefont {Helvetica -12 bold} {Helvetica -12 bold}]\
[list -titleoffset 2 2]\
[list -width 200]\
]
}
foreach option {-background -colors -labeler -selectable -title -titlefont -titleoffset} {
proc pie::set$option {this value} "
if {\$switched::(\$this,complete)} {
error {option $option cannot be set dynamically}
}
"
}
proc pie::set-thickness {this value} {
if {$switched::($this,complete)} {
error {option -thickness cannot be set dynamically}
}
set pie::($this,thickness) [winfo fpixels $pie::($this,canvas) $value]
}
proc pie::set-height {this value} {
set pie::($this,height) [expr {[winfo fpixels $pie::($this,canvas) $value]-1}]
if {$switched::($this,complete)} {
update $this
} else {
set pie::($this,initialHeight) $pie::($this,height)
}
}
proc pie::set-width {this value} {
set pie::($this,width) [expr {[winfo fpixels $pie::($this,canvas) $value]-1}]
if {$switched::($this,complete)} {
update $this
} else {
set pie::($this,initialWidth) $pie::($this,width)
}
}
proc pie::complete {this} {
set canvas $pie::($this,canvas)
if {$switched::($this,-labeler)==0} {
set pie::($this,labeler) [new pieBoxLabeler $canvas]
} else {
set pie::($this,labeler) $switched::($this,-labeler)
}
$canvas addtag pie($this) withtag pieLabeler($pie::($this,labeler))
if {[string length $switched::($this,-background)]==0} {
set bottomColor {}
} else {
set bottomColor [tkDarken $switched::($this,-background) 60]
}
set slice [new slice\
$canvas [expr {$pie::($this,initialWidth)/2}] [expr {$pie::($this,initialHeight)/2}]\
-startandextent {90 360} -height $pie::($this,thickness) -topcolor $switched::($this,-background) -bottomcolor $bottomColor\
]
$canvas addtag pie($this) withtag slice($slice)
$canvas addtag pieSlices($this) withtag slice($slice)
set pie::($this,backgroundSlice) $slice
if {[string length $switched::($this,-title)]==0} {
set pie::($this,titleRoom) 0
} else {
set pie::($this,title) [$canvas create text 0 0\
-anchor n -text $switched::($this,-title) -font $switched::($this,-titlefont) -tags pie($this)\
]
set pie::($this,titleRoom) [expr {\
[font metrics $switched::($this,-titlefont) -ascent]+[winfo fpixels $canvas $switched::($this,-titleoffset)]\
}]
}
update $this
}
proc pie::newSlice {this {text {}}} {
set canvas $pie::($this,canvas)
set start 90
foreach slice $pie::($this,slices) {
set start [expr {$start-$slice::($slice,extent)}]
}
set color [lindex $switched::($this,-colors) $pie::($this,colorIndex)]
set pie::($this,colorIndex) [expr {($pie::($this,colorIndex)+1)%[llength $switched::($this,-colors)]}]
set slice [new slice\
$canvas [expr {$pie::($this,initialWidth)/2}] [expr {$pie::($this,initialHeight)/2}] -startandextent "$start 0"\
-height $pie::($this,thickness) -topcolor $color -bottomcolor [tkDarken $color 60]\
]
eval $canvas move slice($slice) [$canvas coords pieSlices($this)]
$canvas addtag pie($this) withtag slice($slice)
$canvas addtag pieSlices($this) withtag slice($slice)
lappend pie::($this,slices) $slice
if {[string length $text]==0} {
set text "slice [llength $pie::($this,slices)]"
}
set labeler $pie::($this,labeler)
set label [pieLabeler::new $labeler $slice -text $text -background $color]
set pie::($this,sliceLabel,$slice) $label
$canvas addtag pie($this) withtag pieLabeler($labeler)
update $this
if {$switched::($this,-selectable)} {
if {![info exists pie::($this,selector)]} {
set pie::($this,selector) [new objectSelector -selectcommand "pie::setLabelsState $this"]
}
set selector $pie::($this,selector)
selector::add $selector $label
$canvas bind canvasLabel($label) <ButtonRelease-1> "selector::select $selector $label"
$canvas bind slice($slice) <ButtonRelease-1> "selector::select $selector $label"
$canvas bind canvasLabel($label) <Control-ButtonRelease-1> "selector::toggle $selector $label"
$canvas bind slice($slice) <Control-ButtonRelease-1> "selector::toggle $selector $label"
$canvas bind canvasLabel($label) <Shift-ButtonRelease-1> "selector::extend $selector $label"
$canvas bind slice($slice) <Shift-ButtonRelease-1> "selector::extend $selector $label"
}
return $slice
}
proc pie::deleteSlice {this slice} {
set index [lsearch -exact $pie::($this,slices) $slice]
if {$index<0} {
error "invalid slice $slice for pie $this"
}
set pie::($this,slices) [lreplace $pie::($this,slices) $index $index]
set extent $slice::($slice,extent)
delete $slice
foreach following [lrange $pie::($this,slices) $index end] {
slice::rotate $following $extent
}
pieLabeler::delete $pie::($this,labeler) $pie::($this,sliceLabel,$slice)
if {$switched::($this,-selectable)} {
selector::remove $pie::($this,selector) $pie::($this,sliceLabel,$slice)
}
unset pie::($this,sliceLabel,$slice)
update $this
}
proc pie::sizeSlice {this slice unitShare {valueToDisplay {}}} {
set index [lsearch -exact $pie::($this,slices) $slice]
if {$index<0} {
error "invalid slice $slice for pie $this"
}
set newExtent [expr {[maximum [minimum $unitShare 1] 0]*360}]
set growth [expr {$newExtent-$slice::($slice,extent)}]
switched::configure $slice -startandextent "[expr {$slice::($slice,start)-$growth}] $newExtent"
if {[string length $valueToDisplay]>0} {
pieLabeler::set $pie::($this,labeler) $pie::($this,sliceLabel,$slice) $valueToDisplay
} else {
pieLabeler::set $pie::($this,labeler) $pie::($this,sliceLabel,$slice) $unitShare
}
set value [expr {-1*$growth}]
foreach slice [lrange $pie::($this,slices) [incr index] end] {
slice::rotate $slice $value
}
}
proc pie::selectedSlices {this} {
set list {}
foreach slice $pie::($this,slices) {
if {[pieLabeler::selectState $pie::($this,labeler) $pie::($this,sliceLabel,$slice)]} {
lappend list $slice
}
}
return $list
}
proc pie::setLabelsState {this labels selected} {
set labeler $pie::($this,labeler)
foreach label $labels {
pieLabeler::selectState $labeler $label $selected
}
}
proc pie::currentSlice {this} {
set tags [$pie::($this,canvas) gettags current]
if {[scan $tags slice(%u) slice]>0} {
return $slice
}
if {[scan $tags canvasLabel(%u) label]>0} {
foreach slice $pie::($this,slices) {
if {$pie::($this,sliceLabel,$slice)==$label} {
return $slice
}
}
}
return 0
}
proc pie::update {this} {
set canvas $pie::($this,canvas)
pieLabeler::room $pie::($this,labeler) room
foreach {x y} [$canvas coords $pie::($this,origin)] {}
foreach {xSlices ySlices} [$canvas coords pieSlices($this)] {}
$canvas move pieSlices($this) [expr {$x+$room(left)-$xSlices}] [expr {$y+$room(top)+$pie::($this,titleRoom)-$ySlices}]
set scale [list\
[expr {($pie::($this,width)-$room(left)-$room(right))/$pie::($this,initialWidth)}]\
[expr {\
($pie::($this,height)-$room(top)-$room(bottom)-$pie::($this,titleRoom))/\
($pie::($this,initialHeight)+$pie::($this,thickness))\
}]\
]
switched::configure $pie::($this,backgroundSlice) -scale $scale
foreach slice $pie::($this,slices) {
switched::configure $slice -scale $scale
}
if {$pie::($this,titleRoom)>0} {
$canvas coords $pie::($this,title) [expr {$x+($pie::($this,width)/2)}] $y
}
pieLabeler::update $pie::($this,labeler) $x $y [expr {$x+$pie::($this,width)}] [expr {$y+$pie::($this,height)}]
}
class pie {
proc maximum {a b} {return [expr {$a>$b?$a:$b}]}
proc minimum {a b} {return [expr {$a<$b?$a:$b}]}
}
}
set rcsId {$Id: config.tcl,v 1.3 1998/05/24 19:24:43 jfontain Exp $}
class configuration {
set (xWindowManagerInitialOffset) 30
set (yWindowManagerInitialOffset) 20
set (graphNumberOfIntervals) 100
}
set rcsId {$Id: font.tcl,v 1.4 1998/07/29 20:45:07 jfontain Exp $}
class font {
catch {widget::widget}
set font::(mediumBold) [eval font create [font actual $widget::(default,ButtonFont)]]
font configure $font::(mediumBold) -weight bold
set font::(mediumNormal) [eval font create [font actual $font::(mediumBold)]]
font configure $font::(mediumNormal) -weight normal
set font::(smallNormal) [eval font create [font actual $font::(mediumNormal)]]
font configure $font::(smallNormal) -size [expr {round(0.8*[font actual $font::(mediumNormal) -size])}]
}
set rcsId {$Id: scroll.tcl,v 1.9 1998/10/04 14:57:52 jfontain Exp $}
class scroll {
proc scroll {this scrollableClass parentPath args} composite {[new frame $parentPath] $args} {
set path $widget::($this,path)
composite::manage $this [new $scrollableClass $path] scrolled\
[new scrollbar $path -orient horizontal] horizontal [new scrollbar $path] vertical [new frame $path] filler
widget::configure $composite::($this,scrolled)\
-xscrollcommand "scroll::update $this 1 0" -yscrollcommand "scroll::update $this 0 1"
widget::configure $composite::($this,horizontal) -command "$composite::($this,scrolled,path) xview"
widget::configure $composite::($this,vertical) -command "$composite::($this,scrolled,path) yview"
grid propagate $widget::($this,path) 0
grid $composite::($this,scrolled,path) -sticky nsew
grid rowconfigure $path 0 -weight 1
grid columnconfigure $path 0 -weight 1
set scroll::($this,0,1,path) $composite::($this,vertical,path)
set scroll::($this,1,0,path) $composite::($this,horizontal,path)
composite::complete $this
}
proc ~scroll {this} {}
proc options {this} {
return [list\
[list -automatic automatic Automatic 1 1]\
[list\
-scrollbarborderwidth scrollbarBorderWidth ScrollbarBorderWidth\
$widget::(default,ScrollbarBorderWidth) $widget::(default,ScrollbarBorderWidth)\
]\
[list\
-scrollbarelementborderwidth scrollbarElementBorderWidth ScrollbarElementBorderWidth\
$widget::(default,ScrollbarElementBorderWidth) $widget::(default,ScrollbarElementBorderWidth)\
]\
[list\
-scrollbarwidth scrollbarWidth ScrollbarWidth $widget::(default,ScrollbarWidth) $widget::(default,ScrollbarWidth)\
]\
[list -height height Height $widget::(default,CanvasHeight)]\
[list -horizontal horizontal Horizontal 1 1]\
[list -vertical vertical Vertical 1 1]\
[list -width width Width $widget::(default,CanvasWidth)]\
]
}
foreach option {-automatic -horizontal -vertical} {
proc set$option {this value} "
if {\$composite::(\$this,complete)} {
error {option $option cannot be set dynamically}
}
"
}
foreach option {borderwidth elementborderwidth width} {
proc set-scrollbar$option {this value} "
\$composite::(\$this,vertical,path) configure -$option \$value
\$composite::(\$this,horizontal,path) configure -$option \$value
"
}
proc set-height {this value} {
$widget::($this,path) configure -height $value
}
proc set-width {this value} {
$widget::($this,path) configure -width $value
}
proc update {this row column first last} {
set path $scroll::($this,$row,$column,path)
foreach {previousFirst previousLast} [$path get] {}
if {($first!=$previousFirst)||($last!=$previousLast)} {
$path set $first $last
}
set visible [llength [grid info $path]]
if {!$composite::($this,-automatic)||(($last-$first)<1)} {
if {!$visible} {
if {$composite::($this,-vertical)} {
grid $composite::($this,vertical,path) -row 0 -column 1 -sticky nsew
}
if {$composite::($this,-horizontal)} {
grid $composite::($this,horizontal,path) -row 1 -column 0 -sticky nsew
}
grid $composite::($this,filler,path) -sticky nsew -column 1 -row 1
}
} else {
foreach {first last} [$scroll::($this,$column,$row,path) get] {}
if {$visible&&(($last-$first)>=1)} {
grid remove $scroll::($this,0,1,path)
grid remove $scroll::($this,1,0,path)
grid remove $composite::($this,filler,path)
}
}
}
}
set rcsId {$Id: lifolbl.tcl,v 1.11 1998/10/09 19:36:40 jfontain Exp $}
set rcsId {$Id: xifo.tcl,v 1.15 1998/04/08 21:24:07 jfontain Exp $}
class xifo {
proc xifo {this size} {
set xifo::($this,size) $size
empty $this
}
proc ~xifo {this} {
variable ${this}data
catch {unset ${this}data}
}
proc in {this data} {
variable ${this}data
tidyUp $this
if {[array size ${this}data]>=$xifo::($this,size)} {
unset ${this}data($xifo::($this,first))
incr xifo::($this,first)
}
set ${this}data([incr xifo::($this,last)]) $data
}
proc tidyUp {this} {
variable ${this}data
catch {
unset ${this}data($xifo::($this,unset))
unset xifo::($this,unset)
}
}
proc empty {this} {
variable ${this}data
catch {unset ${this}data}
catch {unset xifo::($this,unset)}
set xifo::($this,first) 0
set xifo::($this,last) -1
}
proc isEmpty {this} {
variable ${this}data
return [expr {[array size ${this}data]==0}]
}
virtual proc out {this}
virtual proc data {this}
}
class lifo {
proc lifo {this {size 2147483647}} xifo {$size} {}
proc ~lifo {this} {}
proc out {this} {
xifo::tidyUp $this
if {[array size xifo::${this}data]==0} {
error "lifo $this out error, empty"
}
set xifo::($this,unset) $xifo::($this,last)
incr xifo::($this,last) -1
return [set xifo::${this}data($xifo::($this,unset))]
}
proc data {this} {
set list {}
set first $xifo::($this,first)
for {set index $xifo::($this,last)} {$index>=$first} {incr index -1} {
lappend list [set xifo::${this}data($index)]
}
return $list
}
}
class fifo {
proc fifo {this {size 2147483647}} xifo {$size} {}
proc ~fifo {this} {}
proc out {this} {
xifo::tidyUp $this
if {[array size xifo::${this}data]==0} {
error "fifo $this out error, empty"
}
set xifo::($this,unset) $xifo::($this,first)
incr xifo::($this,first)
return [set xifo::${this}data($xifo::($this,unset))]
}
proc data {this} {
set list {}
set last $xifo::($this,last)
for {set index $xifo::($this,first)} {$index<=$last} {incr index} {
lappend list [set xifo::${this}data($index)]
}
return $list
}
}
class lifoLabel {}
proc lifoLabel::lifoLabel {this parentPath args} composite {
[new frame $parentPath -relief sunken -borderwidth $widget::(default,ButtonBorderWidth)] $args
} {
set path $widget::($this,path)
composite::manage $this [new label $path -font {helvetica -12 bold} -text Message:] header [new frame $path] separator\
[new label $path -font {helvetica -12} -anchor w] body
pack $composite::($this,header,path) $composite::($this,separator,path) -side left
pack $composite::($this,body,path) -fill x -expand 1
set lifoLabel::($this,lifo) [new lifo]
composite::complete $this
}
proc lifoLabel::~lifoLabel {this} {
delete $lifoLabel::($this,lifo)
}
proc lifoLabel::options {this} {
return [list\
[list -borderwidth borderWidth BorderWidth $widget::(default,ButtonBorderWidth) $widget::(default,ButtonBorderWidth)]\
[list -font font Font {helvetica -12} {helvetica -12}]\
[list -header header Text Message: Message:]\
[list -headerfont headerFont Font {helvetica -12 bold} {helvetica -12 bold}]\
[list -relief relief Relief sunken sunken]\
[list -spacing spacing Spacing 0 0]\
]
}
foreach option {-borderwidth -relief} {
proc lifoLabel::set$option {this value} "\$widget::(\$this,path) configure $option \$value"
}
proc lifoLabel::set-font {this value} {
$composite::($this,body,path) configure -font $value
}
proc lifoLabel::set-headerfont {this value} {
$composite::($this,header,path) configure -font $value
}
proc lifoLabel::set-header {this value} {
$composite::($this,header,path) configure -text $value
}
proc lifoLabel::set-spacing {this value} {
$composite::($this,separator,path) configure -width $value
}
proc lifoLabel::push {this string} {
if {[string length [set current [$composite::($this,body,path) cget -text]]]>0} {
xifo::in $lifoLabel::($this,lifo) $current
}
$composite::($this,body,path) configure -text $string
}
proc lifoLabel::pop {this} {
set string {}
catch {set string [lifo::out $lifoLabel::($this,lifo)]}
$composite::($this,body,path) configure -text $string
return $string
}
proc lifoLabel::flash {this string {seconds 1}} {
after [expr {1000*$seconds}] lifoLabel::pop $this
push $this $string
}
set rcsId {$Id: keyslink.tcl,v 1.5 1998/05/24 19:24:43 jfontain Exp $}
class buttonKeysLink {
proc buttonKeysLink {this buttonPath keySymbols {bindPath {}}} {
if {[string length $bindPath]==0} {
set bindings [new bindings $buttonPath 0]
} else {
set bindings [new bindings $bindPath 0]
}
foreach key $keySymbols {
bindings::set $bindings <KeyPress-$key> "$buttonPath configure -relief sunken"
bindings::set $bindings <KeyRelease-$key> "$buttonPath configure -relief raised"
}
bindings::set $bindings <Destroy> "delete $this"
set buttonKeysLink::($this,bindings) $bindings
}
proc ~buttonKeysLink {this} {
delete $buttonKeysLink::($this,bindings)
}
}
set rcsId {$Id: dialog.tcl,v 1.12 1998/05/24 19:24:43 jfontain Exp $}
class dialogBox {}
proc dialogBox::dialogBox {this parentPath args} composite {[new toplevel $parentPath] $args} {
set path $widget::($this,path)
wm withdraw $path
composite::manage $this [new frame $path -relief sunken -borderwidth 1 -height 2] separator [new frame $path] buttons
set buttons $composite::($this,buttons,path)
composite::manage $this [new button $buttons -text OK -command "dialogBox::done $this"] ok\
[new button $buttons -text Cancel -command "catch {delete $this}"] cancel
grid $composite::($this,separator,path) -column 0 -row 1 -sticky ew
grid $buttons -column 0 -row 2 -sticky nsew
grid rowconfigure $path 0 -weight 1
grid columnconfigure $path 0 -weight 1
wm protocol $path WM_DELETE_WINDOW "delete $this"
bind $path <KeyRelease-Escape> "catch {delete $this}"
bind $path <KeyRelease-Return> "dialogBox::done $this"
bind $path <KeyRelease-KP_Enter> "dialogBox::done $this"
composite::complete $this
}
proc dialogBox::~dialogBox {this} {}
proc dialogBox::options {this} {
return [list\
[list -buttons buttons Buttons o]\
[list -command command Command {} {}]\
[list -default default Default {} {}]\
[list -die die Die 1 1]\
[list -grab grab Grab local]\
[list -title title Title {Dialog box}]\
[list -transient transient Transient 1]\
[list -x x Coordinate 0]\
[list -y y Coordinate 0]
]
}
proc dialogBox::set-buttons {this value} {
if {$composite::($this,complete)} {
error {option -buttons cannot be set dynamically}
}
if {![regexp {^(o|c|oc)$} $value]} {
error "bad buttons value \"$value\": must be o, c or oc"
}
pack forget $composite::($this,ok,path) $composite::($this,cancel,path)
set ok [expr {[string first o $value]>=0}]
set cancel [expr {[string first c $value]>=0}]
if {$ok} {
pack $composite::($this,ok,path) -side left -expand 1 -pady 3
new buttonKeysLink $composite::($this,ok,path) {Return KP_Enter} $widget::($this,path)
}
if {$cancel} {
pack $composite::($this,cancel,path) -side left -expand 1 -pady 3
new buttonKeysLink $composite::($this,cancel,path) Escape $widget::($this,path)
}
}
proc dialogBox::set-default {this value} {
if {$composite::($this,complete)} {
error {option -default cannot be set dynamically}
}
switch $composite::($this,-default) {
o {
$composite::($this,ok,path) configure -default active
}
c {
$composite::($this,cancel,path) configure -default active
}
default {
error "bad default value \"$value\": must be o or c"
}
}
}
proc dialogBox::set-command {this value} {}
proc dialogBox::set-die {this value} {}
proc dialogBox::set-grab {this value} {
switch $value {
global {
grab -global $widget::($this,path)
}
local {
grab $widget::($this,path)
}
release {
grab release $widget::($this,path)
}
default {
error "bad grab value \"$value\": must be global, local or release"
}
}
}
proc dialogBox::set-title {this value} {
wm title $widget::($this,path) $value
}
foreach option {-x -y} {
proc dialogBox::set$option {this value} {
if {[winfo ismapped $widget::($this,path)]} {
place $this
}
}
}
proc dialogBox::set-transient {this value} {
if {$value} {
wm transient $widget::($this,path) [winfo toplevel $widget::($this,path)]
} else {
wm transient $widget::($this,path) {}
}
}
proc dialogBox::display {this path} {
if {[string length $path]==0} {
if {[info exists dialogBox::($this,displayed)]} {
grid forget $dialogBox::($this,displayed)
unset dialogBox::($this,displayed)
}
return
}
if {[info exists dialogBox::($this,displayed)]} {
error "a widget ($dialogBox::($this,displayed)) is already displayed"
}
set dialogBox::($this,displayed) $path
grid $path -in $widget::($this,path) -column 0 -row 0 -sticky nsew -pady 3
place $this
}
proc dialogBox::done {this} {
if {[string length $composite::($this,-command)]>0} {
uplevel #0 $composite::($this,-command)
}
if {[info exists composite::($this,-die)]&&$composite::($this,-die)} {
delete $this
}
}
proc dialogBox::place {this} {
update idletasks
set path $widget::($this,path)
set x [minimum $composite::($this,-x) [expr {[winfo screenwidth $path]-[winfo reqwidth $path]}]]
set y [minimum $composite::($this,-y) [expr {[winfo screenheight $path]-[winfo reqheight $path]}]]
wm geometry $path +$x+$y
wm deiconify $path
}
set rcsId {$Id: viewer.tcl,v 1.14 1998/10/17 20:40:31 jfontain Exp $}
class viewer {
set viewer::(list) {}
proc viewer {this} {
lappend viewer::(list) $this
}
proc ~viewer {this} {
variable ${this}traces
foreach array [array names ${this}traces] {
trace vdelete ${array}(updates) w "viewer::update $this $array"
}
catch {unset ${this}traces}
ldelete viewer::(list) $this
}
virtual proc supportedTypes {this}
proc view {this cells} {
foreach cell [parseCells $this $cells] {
eval monitorCell $this $cell
set arrays([lindex $cell 0]) {}
}
foreach array [array names arrays] {
update $this $array
}
}
virtual proc monitorCell {this array row column}
proc parseCells {this cells} {
if {[llength $cells]==0} return
set parsed {}
foreach cell $cells {
parse $cell array row column type
if {[lsearch -exact [supportedTypes $this] $type]<0} {
lifoLabel::flash $::messenger "cannot display data of type $type"
bell
return
}
lappend parsed [list $array $row $column]
}
return $parsed
}
proc parse {dataCell arrayName rowName columnName typeName} {
upvar $arrayName array $rowName row $columnName column $typeName type
if {![regexp {^(.*)\(([0-9]+),([0-9]+)\)$} $dataCell dummy array row column]||($row<0)||($column<0)} {
error "\"$dataCell\" is not a valid array cell"
}
set type [set ${array}($column,type)]
}
proc updateInterval {value} {
foreach viewer $viewer::(list) {
catch {composite::configure $viewer -interval $value}
}
}
proc label {array row column} {
set label {}
foreach index [set ${array}(indexColumns)] {
if {[catch {set ${array}($row,$index)} value]} {
append label {? }
} else {
append label "$value "
}
}
append label [set ${array}($column,label)]
return $label
}
virtual proc update {this array args}
proc registerTrace {this array} {
variable ${this}traces
if {![info exists ${this}traces($array)]} {
trace variable ${array}(updates) w "viewer::update $this $array"
set ${this}traces($array) 0
}
incr ${this}traces($array)
}
proc unregisterTrace {this array} {
variable ${this}traces
if {[incr ${this}traces($array) -1]<=0} {
trace vdelete ${array}(updates) w "viewer::update $this $array"
unset ${this}traces($array)
}
}
virtual proc cells {this}
virtual proc initializationConfiguration {this} {
return {}
}
}
set rcsId {$Id: blt2d.tcl,v 1.25 1998/10/10 20:58:19 jfontain Exp $}
class blt2DViewer {
set blt2DViewer::(colors) {#7FFFFF #7FFF7F #FF7F7F #FFFF7F #7F7FFF #FFBF00 #BFBFBF #FF7FFF #FFFFFF}
proc blt2DViewer {this path} viewer {} {
$path configure -cursor {}
if {$::officialBLT} {
$path configure -plotpadx 2 -plotpady 2
$path yaxis configure -tickshadow {}
}
$path yaxis configure -title {} -tickfont $font::(smallNormal)
$path legend configure -borderwidth 1 -font $font::(mediumNormal) -activebackground white
set blt2DViewer::($this,drop) [new dropSite\
-path $path -formats DATACELLS -command "viewer::view $this \$dragSite::data(DATACELLS)"\
]
set blt2DViewer::($this,elements) {}
set blt2DViewer::($this,colorIndex) 0
set blt2DViewer::($this,path) $path
}
proc ~blt2DViewer {this} {
catch {delete $blt2DViewer::($this,drag)}
delete $blt2DViewer::($this,drop)
catch {delete $blt2DViewer::($this,selector)}
eval delete $blt2DViewer::($this,elements)
}
proc supportedTypes {this} {
return {integer real}
}
proc dragData {this format} {
set selectedElements [selector::selected $blt2DViewer::($this,selector)]
switch $format {
OBJECTS {
if {[llength $selectedElements]>0} {
return $selectedElements
} elseif {[llength $blt2DViewer::($this,elements)]==0} {
return $this
} else {
return {}
}
}
DATACELLS {
return [cellsFromElements $this $selectedElements]
}
}
}
proc validateDrag {this x y} {
if {[llength $blt2DViewer::($this,elements)]==0} {
return 1
}
return [expr {\
[lsearch -exact [selector::selected $blt2DViewer::($this,selector)] [$blt2DViewer::($this,path) legend get @$x,$y]]>=0\
}]
}
proc monitorCell {this array row column} {
viewer::registerTrace $this $array
set cell ${array}($row,$column)
if {[lsearch -exact [cellsFromElements $this $blt2DViewer::($this,elements)] $cell]>=0} return
set element [newElement $this $blt2DViewer::($this,path) -label [viewer::label $array $row $column]]
switched::configure $element -color [lindex $blt2DViewer::(colors) $blt2DViewer::($this,colorIndex)]
switched::configure $element -deletecommand "blt2DViewer::deletedElement $this $array $element"
set blt2DViewer::($this,colorIndex) [expr {($blt2DViewer::($this,colorIndex)+1)%[llength $blt2DViewer::(colors)]}]
lappend blt2DViewer::($this,elements) $element
set blt2DViewer::($this,cell,$element) $cell
catch {selector::add $blt2DViewer::($this,selector) $element}
}
proc cells {this} {
return [cellsFromElements $this $blt2DViewer::($this,elements)]
}
proc deletedElement {this array element} {
viewer::unregisterTrace $this $array
ldelete blt2DViewer::($this,elements) $element
catch {selector::remove $blt2DViewer::($this,selector) $element}
unset blt2DViewer::($this,cell,$element)
if {[llength $blt2DViewer::($this,elements)]==0} {
delete $this
}
}
proc update {this array args} {
updateTimeDisplay $this [set seconds [clock seconds]]
foreach element $blt2DViewer::($this,elements) {
set cell $blt2DViewer::($this,cell,$element)
if {[string first $array $cell]<0} continue
set value {}
catch {set value [set $cell]}
updateElement $this $element $seconds $value
}
}
virtual proc newElement {this path args}
virtual proc updateElement {this element seconds value}
virtual proc updateTimeDisplay {this seconds} {}
proc cellsFromElements {this elements} {
set cells {}
foreach element $elements {
lappend cells $blt2DViewer::($this,cell,$element)
}
return $cells
}
proc setElementsState {this elements select} {
if {$select} {
set action activate
} else {
set action deactivate
}
set path $blt2DViewer::($this,path)
foreach element $elements {
$path legend $action $element
}
}
proc setSelection {this x y} {
if {[string length [set element [$blt2DViewer::($this,path) legend get @$x,$y]]]>0} {
selector::select $blt2DViewer::($this,selector) $element
}
}
proc toggleSelection {this x y} {
if {[string length [set element [$blt2DViewer::($this,path) legend get @$x,$y]]]>0} {
selector::toggle $blt2DViewer::($this,selector) $element
}
}
proc extendSelection {this x y} {
if {[string length [set element [$blt2DViewer::($this,path) legend get @$x,$y]]]>0} {
selector::extend $blt2DViewer::($this,selector) $element
}
}
proc allowDrag {this} {
set path $blt2DViewer::($this,path)
set blt2DViewer::($this,drag) [new dragSite -path $path -validcommand "blt2DViewer::validateDrag $this"]
dragSite::provide $blt2DViewer::($this,drag) OBJECTS "blt2DViewer::dragData $this"
dragSite::provide $blt2DViewer::($this,drag) DATACELLS "blt2DViewer::dragData $this"
set blt2DViewer::($this,selector) [new objectSelector -selectcommand "blt2DViewer::setElementsState $this"]
bind $path <ButtonRelease-1> "blt2DViewer::setSelection $this %x %y"
bind $path <Control-ButtonRelease-1> "blt2DViewer::toggleSelection $this %x %y"
bind $path <Shift-ButtonRelease-1> "blt2DViewer::extendSelection $this %x %y"
}
}
set rcsId {$Id: tablesel.tcl,v 1.2 1998/05/24 19:24:43 jfontain Exp $}
class tableSelector {
proc tableSelector {this args} selector {$args} {}
proc ~tableSelector {this} {}
proc extend {this cell} {
if {[info exists selector::($this,lastSelected)]} {
scan $selector::($this,lastSelected) %d,%d startRow startColumn
scan $cell %d,%d lastRow lastColumn
if {$lastRow<$startRow} {
set last $startRow
set startRow $lastRow
set lastRow $last
}
if {$lastColumn<$startColumn} {
set last $startColumn
set startColumn $lastColumn
set lastColumn $last
}
set list {}
for {set row $startRow} {$row<=$lastRow} {incr row} {
for {set column $startColumn} {$column<=$lastColumn} {incr column} {
lappend list $row,$column
}
}
selector::clear $this
selector::set $this $list 1
} else {
selector::select $this $cell
}
}
proc list {this} {
return [lsort -integer [selector::_list $this]]
}
}
set rcsId {$Id: datatab.tcl,v 1.45 1998/10/10 20:56:43 jfontain Exp $}
class dataTable {
set dataTable::(list) {}
set dataTable::(scrollbarBorderWidth) [expr {$widget::(default,ScrollbarBorderWidth)==0?0:1}]
set dataTable::(scrollbarWidth) [expr {2*$widget::(default,ScrollbarWidth)/3}]
proc dataTable {this parentPath args} composite {
[new scroll table $parentPath\
-scrollbarwidth $dataTable::(scrollbarWidth) -scrollbarelementborderwidth $dataTable::(scrollbarBorderWidth)\
]
$args
} {
set path $composite::($composite::($this,base),scrolled,path)
$path configure -font $font::(mediumNormal) -rows 2 -state disabled -titlerows 1 -roworigin -1 -colstretchmode unset\
-variable dataTable::${this}data -resizeborders col -cursor {} -bordercursor sb_h_double_arrow -highlightthickness 0\
-takefocus 0
$path tag configure select -background white
bindtags $path "$path . all"
bind $path <ButtonPress-1> "dataTable::buttonPress $this %x %y"
bind $path <Button1-Motion> {%W border dragto %x %y}
set dataTable::($this,sortOrder) increasing
set dataTable::($this,tablePath) $path
lappend dataTable::(list) $this
composite::complete $this
setupDataView $this
}
proc ~dataTable {this} {
variable ${this}data
catch {unset ${this}data}
catch {eval delete $dataTable::($this,arrow) $dataTable::($this,tips)}
catch {delete $dataTable::($this,drag)}
catch {delete $dataTable::($this,selector)}
ldelete dataTable::(list) $this
}
proc options {this} {
return [list\
[list -columns columns Columns 0 0]\
[list -data data Data {} {}]\
[list -draggable draggable Draggable 0 0]\
[list -titlefont titleFont TitleFont $font::(mediumBold) $font::(mediumBold)]\
[list -view view View {} {}]\
]
}
proc set-columns {this value} {
$dataTable::($this,tablePath) configure -cols $value
}
proc set-titlefont {this value} {
if {[string length $composite::($this,-data)]==0} return
set path $dataTable::($this,tablePath)
for {set column 0} {$column<[llength $dataTable::($this,dataColumns)]} {incr column} {
$path.$column.label configure -font $value
}
}
proc set-data {this value} {
if {$composite::($this,complete)} {
error {option -data cannot be set dynamically}
}
if {![array exists $value]} {
error "\"$value\" argument is not an existing array"
}
}
proc set-draggable {this value} {
if {$composite::($this,complete)} {
error {option -draggable cannot be set dynamically}
}
if {!$value} return
set path $dataTable::($this,tablePath)
set dataTable::($this,drag) [new dragSite -path $path -validcommand "dataTable::validateDrag $this"]
dragSite::provide $dataTable::($this,drag) DATACELLS "dataTable::dragData $this"
set dataTable::($this,selector) [new tableSelector -selectcommand "dataTable::setCellsState $this"]
bind $path <ButtonRelease-1> "dataTable::buttonRelease $this %x %y"
bind $path <Control-ButtonRelease-1> "dataTable::toggleSelection $this %x %y"
bind $path <Shift-ButtonRelease-1> "dataTable::extendSelection $this %x %y"
}
proc set-view {this value} {
if {$composite::($this,complete)} {
error {option -view cannot be set dynamically}
}
if {![array exists $value]} {
error "\"$value\" argument is not an existing array"
}
}
proc buttonRelease {this x y} {
if {!$dataTable::($this,columnBorderHit)} {
set number [expr {[$dataTable::($this,tablePath) cget -rows]-1}]
if {$number==0} return
scan [$dataTable::($this,tablePath) index @$x,$y] %d,%d row column
if {$row<0} return
catch {selector::select $dataTable::($this,selector) $row,$column}
}
unset dataTable::($this,columnBorderHit)
}
proc columnSort {this column} {
if {$column==$dataTable::($this,sortColumn)} {
if {[string compare $dataTable::($this,sortOrder) increasing]==0} {
set dataTable::($this,sortOrder) decreasing
} else {
set dataTable::($this,sortOrder) increasing
}
} else {
set dataTable::($this,sortColumn) $column
set dataTable::($this,sortOrder) increasing
}
catch {selector::clear $dataTable::($this,selector)}
update $this
}
proc update {this args} {
variable ${this}data
upvar #0 $composite::($this,-data) data
set path $dataTable::($this,tablePath)
set cursor [$path cget -cursor]
$path configure -cursor watch
::update idletasks
set sortColumn $dataTable::($this,sortColumn)
set lists {}
if {[regexp {^integer|real$} $data($sortColumn,type)]} {
foreach name [array names data *,$sortColumn] {
scan $name %u dataRow
if {[catch {expr {double($data($dataRow,$sortColumn))}}]} {
lappend lists [list $dataRow 0]
} else {
lappend lists [list $dataRow $data($dataRow,$sortColumn)]
}
}
} else {
foreach name [array names data *,$sortColumn] {
scan $name %u dataRow
lappend lists [list $dataRow $data($dataRow,$sortColumn)]
}
}
set lists [lsort -$dataTable::($this,sortOrder) -$data($sortColumn,type) -index 1 $lists]
catch {set selector $dataTable::($this,selector)}
set changed 0
set row 0
set rows {}
foreach pair $lists {
set dataRow [lindex $pair 0]
if {![info exists ${this}data($row,dataRow)]} {
lappend rows $row
}
set ${this}data($row,dataRow) $dataRow
set column 0
foreach dataColumn $dataTable::($this,dataColumns) {
set ${this}data($row,$column) $data($dataRow,$dataColumn)
incr column
}
incr row
}
$path configure -rows [expr {$row+1}]
set columns [llength $dataTable::($this,dataColumns)]
if {[llength $rows]>0} {
set changed 1
set cells {}
foreach new $rows {
for {set column 0} {$column<$columns} {incr column} {
lappend cells $new,$column
}
}
catch {selector::add $selector $cells}
}
set rows {}
while {[info exists ${this}data($row,dataRow)]} {
lappend rows $row
incr row
}
if {[llength $rows]>0} {
set changed 1
set cells {}
foreach old $rows {
unset ${this}data($old,dataRow)
for {set column 0} {$column<$columns} {incr column} {
lappend cells $old,$column
unset ${this}data($old,$column)
}
}
catch {selector::remove $selector $cells}
}
if {$changed} {
catch {selector::clear $selector}
}
$path configure -cursor $cursor
::update idletasks
}
proc dragData {this format} {
variable ${this}data
set data $composite::($this,-data)
set list {}
foreach cell [selector::selected $dataTable::($this,selector)] {
scan $cell %d,%d row column
lappend list ${data}([set ${this}data($row,dataRow)],[set ${this}data($column,dataColumn)])
}
return $list
}
proc validateDrag {this x y} {
if {$dataTable::($this,columnBorderHit)} {
return 0
}
return [expr\
{[lsearch -exact [selector::selected $dataTable::($this,selector)] [$dataTable::($this,tablePath) index @$x,$y]]>=0}\
]
}
proc setCellsState {this cells select} {
if {$select} {
eval $dataTable::($this,tablePath) tag cell select $cells
} else {
eval $dataTable::($this,tablePath) tag cell {{}} $cells
}
}
proc toggleSelection {this x y} {
set cell [$dataTable::($this,tablePath) index @$x,$y]
scan $cell %d row
if {$row<0} return
selector::toggle $dataTable::($this,selector) $cell
}
proc extendSelection {this x y} {
set cell [$dataTable::($this,tablePath) index @$x,$y]
scan $cell %d row
if {$row<0} return
selector::extend $dataTable::($this,selector) $cell
}
proc updateSortingArrow {this column} {
set path $widget::($dataTable::($this,arrow),path)
set label $dataTable::($this,tablePath).$column.label
foreach event {<Enter> <Leave> <ButtonRelease-1>} {
bind $path $event [bind $label $event]
}
if {[string compare $dataTable::($this,sortOrder) increasing]==0} {
widget::configure $dataTable::($this,arrow) -direction down
} else {
widget::configure $dataTable::($this,arrow) -direction up
}
place $path -in $dataTable::($this,tablePath).$column -anchor e -relx 1 -rely 0.5 -relheight 1
}
proc createTitles {this} {
variable ${this}data
upvar #0 $composite::($this,-data) data
set path $dataTable::($this,tablePath)
set font $composite::($this,-titlefont)
set column 0
foreach dataColumn $dataTable::($this,dataColumns) {
set frame [frame $path.$column]
set label [label $path.$column.label -font $font -text $data($dataColumn,label) -cursor top_left_arrow]
place $label -relwidth 1 -relheight 1
$path window configure -1,$column -window $frame -padx 2 -pady 2 -sticky nsew
bind $label <ButtonRelease-1> "dataTable::columnSort $this $dataColumn; dataTable::updateSortingArrow $this $column"
bind $label <Enter> "lifoLabel::push $::messenger [list $data($dataColumn,message)]"
bind $label <Leave> "lifoLabel::pop $::messenger"
lappend dataTable::($this,tips) [new widgetTip -path $label -text {click to toggle sort}]
incr column
}
$path configure -cols $column
if {![info exists dataTable::($this,arrow)]} {
set arrow [new arrowButton $path -state disabled -borderwidth 0 -highlightthickness 0 -width 12]
widget::configure $arrow -disabledforeground [widget::cget $arrow -foreground]
$widget::($arrow,path) configure -cursor top_left_arrow
lappend dataTable::($this,tips) [new widgetTip -path $widget::($arrow,path) -text {click to toggle sort}]
set dataTable::($this,arrow) $arrow
}
}
proc buttonPress {this x y} {
foreach {row column} [$dataTable::($this,tablePath) border mark $x $y] {}
set dataTable::($this,columnBorderHit) [expr {[info exists column]&&([string length $column]>0)}]
}
proc setupDataView {this} {
if {[string length $composite::($this,-data)]==0} return
variable ${this}data
if {[string length $composite::($this,-view)]>0} {
upvar #0 $composite::($this,-view) data
} else {
upvar #0 $composite::($this,-data) data
}
if {[catch {set columns $data(visibleColumns)}]} {
set columns {}
foreach name [array names data *,label] {
if {[scan $name %u column]>0} {
lappend columns $column
}
}
}
set dataTable::($this,dataColumns) [lsort -integer $columns]
set dataTable::($this,sortColumn) [lindex $data(sort) 0]
if {[lsearch -exact $columns $dataTable::($this,sortColumn)]<0} {
error "sort column $dataTable::($this,sortColumn) is not visible"
}
set dataTable::($this,sortOrder) [lindex $data(sort) 1]
set column 0
foreach dataColumn $dataTable::($this,dataColumns) {
set ${this}data($column,dataColumn) $dataColumn
if {$dataColumn==$dataTable::($this,sortColumn)} {
set sortColumnIndex $column
}
incr column
}
createTitles $this
updateSortingArrow $this $sortColumnIndex
trace variable $composite::($this,-data)(updates) w "dataTable::update $this"
}
}
set rcsId {$Id: datagraf.tcl,v 1.44 1998/10/11 09:27:20 jfontain Exp $}
class dataGraph {
if {$::officialBLT} {
set (widget) stripchart
} else {
set (widget) graph
}
proc dataGraph {this parentPath args} composite {
[new $dataGraph::(widget) $parentPath -title {} -topmargin 3 -bufferelements 0 -plotborderwidth 1 -plotbackground black]
$args
} blt2DViewer {$widget::($this,path)} {
set path $widget::($this,path)
$path xaxis configure -tickfont $font::(smallNormal) -title {} -rotate 90 -command dataGraph::axisTime
if {$::officialBLT} {
$path xaxis configure -tickshadow {}
$path pen create void -linewidth 0 -symbol none
}
bind $path <Visibility> "dataGraph::resized $this"
set dataGraph::($this,plotWidth) 0
composite::complete $this
}
proc ~dataGraph {this} {
if {[string length $composite::($this,-deletecommand)]>0} {
uplevel #0 $composite::($this,-deletecommand)
}
}
proc iconData {} {
return {
R0lGODdhKAAoAKUAAHt5e87PzgAAANbX1v///zFhITFhGJTXa633e6X3e5znc6Xvc3u+Wpznazk4OZTfa4zPY3NJAPffSufHOda2Mc6mKVIIY2sYexBhe4wQ
pa3X54S+zr0o1qUYvbUYzrUg1lKWrb0Y3t44/60Yzt5B/+dJ/+dR/9YY984Y7+dZ/+dh/94o/+9x/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAKAAoAAAG/kCAcEgsGo/IYQAgaDqf0Kh02lwKAthsYIDlbrVer3Y8ZgYI6DQaoG6z2+n3Gm09wwlyeN6t
flsHd3iBgoF5fmZDBYpJAIoGBUaPj0Z1aAUHmAWEapeYB5ppBQgICQqghwKABJ2ZeYoLCwoLpYqKpbAMkISVqwyeC6CrsAoKDAzDCg3FC8aQbKhLQgW+BwsN
tdUNzdMMxb7bDuFEf5zGyp4H2osOisbbAA5y0G3cD98QuUPxjbX6fXRMVHHi5s7ZHCNz4gC8gqTWIkYQAfCCs2/Iv0IXyd2JwJEjH4wKCUxMw1GCSZMRLt4x
tDDakAgmJ8iUKSGCkY42GY2EKZNC/oWfFCbUTAmg5EmPLEUGJCmhZ4WOFYKihNl05tSMZtDwnOAzZ9GfNJv6/BlVaM2Qf4REoMD2abi3HKOy7Qo1aNeKErMS
iEDWpgM3fPsSCfzT5i69ezkK+Qu4oyGcQg5f6ROZsZ54K/cltEKls2cpViyIvoCh9IXTqFOXNp2a9OrWF6xkmI1Bg20Ms3Pnrm1bA+7dvTdguMChOAcrHTx8
wLChue8P0KGX1tDc+era1UEMDxFChAgrIzyMwACi+nPptpuDKL+hN/UN64dfCEGiPvgR0tm3X/0+Pnn98GknH3clFAgeByEg+J9z6cHHWmnr+Ycad/XZxwR3
GIawYHUOXsJ23YQYmiCiCVZwhyCCGv4X4YAYwjbiiyOWeAIKM6KAQgiuvXZBCjz26OOPQFpRo41E4phaBiGooOSSTDbppJAoOCnllFQ2acUKK7Cg5ZZcdunl
l18uQcaYZJZZZhAAOw==
}
}
proc options {this} {
set samples [expr {$configuration::(graphNumberOfIntervals)+1}]
return [list\
[list -deletecommand {} {}]\
[list -draggable draggable Draggable 0 0]\
[list -height height Height 200]\
[list -interval interval Interval 5]\
[list -samples samples Samples $samples $samples]\
[list -width width Width 300]\
]
}
proc set-deletecommand {this value} {}
foreach option {-height -width} {
proc set$option {this value} "\$widget::(\$this,path) configure $option \$value"
}
proc set-draggable {this value} {
if {$composite::($this,complete)} {
error {option -draggable cannot be set dynamically}
}
if {$value} {
blt2DViewer::allowDrag $this
}
}
proc set-interval {this value} {
set dataGraph::($this,range) [expr {($composite::($this,-samples)-1)*$value}]
updateGraduations $this
}
proc set-samples {this value} {
if {$composite::($this,complete)} {
error {option -samples cannot be set dynamically}
}
set dataGraph::($this,range) [expr {($value-1)*$composite::($this,-interval)}]
}
proc xAxisUpdate {this currentTime} {
$widget::($this,path) xaxis configure -min [expr {$currentTime-$dataGraph::($this,range)}] -max $currentTime
}
proc axisTime {path value} {
set value [expr {int($value)}]
if {($value%60)==0} {
return [clock format $value -format %H:%M]
} else {
return [clock format $value -format %T]
}
}
proc newElement {this path args} {
return [eval new element $path $args]
}
proc updateTimeDisplay {this seconds} {
xAxisUpdate $this $seconds
}
proc updateElement {this element seconds value} {
element::update $element $seconds $value
}
proc updateGraduations {this} {
if {$dataGraph::($this,plotWidth)==0} return
set minimum [expr {(2*6*$dataGraph::($this,range))/$dataGraph::($this,plotWidth)}]
foreach step {10 60 300 600 1800 3600 18000 36000 86400} division {5 6 5 5 5 6 5 5 4} {
if {$step>$minimum} break
}
$widget::($this,path) xaxis configure -stepsize $step -subdivisions $division
xAxisUpdate $this [clock seconds]
}
proc resized {this} {
set width [$widget::($this,path) extents plotwidth]
if {$width!=$dataGraph::($this,plotWidth)} {
set dataGraph::($this,plotWidth) $width
updateGraduations $this
}
}
}
class dataGraph {
class element {
set (vectorIndex) 0
proc element {this path args} switched {$args} {
global [set ($this,xVector) vector[incr (vectorIndex)]] [set ($this,yVector) vector[incr (vectorIndex)]]
$path element create $this -label {} -symbol none
set dots [expr {$configuration::(graphNumberOfIntervals)+1}]
if {$::officialBLT} {
global [set ($this,weights) vector[incr (vectorIndex)]]
blt::vector create [set ($this,xVector)]($dots)
blt::vector create [set ($this,yVector)]($dots)
blt::vector create [set ($this,weights)]($dots)
$path element configure $this -weight [set ($this,weights)] -styles {{void 0 0}}
} else {
blt::vector [set ($this,xVector)]($dots)
blt::vector [set ($this,yVector)]($dots)
}
$path element configure $this -xdata [set ($this,xVector)] -ydata [set ($this,yVector)]
set ($this,path) $path
switched::complete $this
}
proc ~element {this} {
global [set ($this,xVector)] [set ($this,yVector)]
if {$::officialBLT} {
global [set ($this,weights)]
blt::vector destroy [set ($this,xVector)] [set ($this,yVector)] [set ($this,weights)]
} else {
unset [set ($this,xVector)] [set ($this,yVector)]
}
[set ($this,path)] element delete $this
if {[string length $switched::($this,-deletecommand)]>0} {
uplevel #0 $switched::($this,-deletecommand)
}
}
proc options {this} {
return [list\
[list -color black black]\
[list -deletecommand {} {}]\
[list -label {} {}]\
]
}
foreach option {-color -label} {
proc set$option {this value} "\[set (\$this,path)\] element configure \$this $option \$value"
}
proc set-deletecommand {this value} {}
if {$::officialBLT} {
proc update {this x y} {
global [set ($this,xVector)] [set ($this,yVector)] [set ($this,weights)]
if {[set [set ($this,xVector)](end)]==0} {
if {[string length $y]==0} return
set [set ($this,xVector)](end) $x
set [set ($this,yVector)](end) $y
}
[set ($this,xVector)] delete 0
[set ($this,yVector)] delete 0
[set ($this,weights)] delete 0
[set ($this,xVector)] append $x
if {[string length $y]==0} {
[set ($this,yVector)] append [set [set ($this,yVector)](end)]
[set ($this,weights)] append 0
[set ($this,path)] element configure $this -label "$switched::($this,-label): ?"
} else {
[set ($this,yVector)] append $y
[set ($this,weights)] append 1
[set ($this,path)] element configure $this -label "$switched::($this,-label): $y"
}
}
} else {
proc update {this x y} {
global [set ($this,xVector)] [set ($this,yVector)]
if {[string length $y]==0} {
set y 0
[set ($this,path)] element configure $this -label "$switched::($this,-label): ?"
} else {
[set ($this,path)] element configure $this -label "$switched::($this,-label): $y"
}
if {[set [set ($this,xVector)](end)]==0} {
set [set ($this,xVector)](:) $x
set [set ($this,yVector)](:) $y
}
[set ($this,xVector)] delete 0
[set ($this,yVector)] delete 0
[set ($this,xVector)] append $x
[set ($this,yVector)] append $y
}
}
}
}
set rcsId {$Id: databar.tcl,v 1.15 1998/10/11 09:27:20 jfontain Exp $}
class dataBarChart {
proc dataBarChart {this parentPath args} composite {
[new barchart $parentPath\
-title {} -bottommargin 6 -topmargin 3 -bufferelements 0 -plotborderwidth 1\
-plotbackground $widget::(default,ButtonBackgroundColor)\
] $args
} blt2DViewer {$widget::($this,path)} {
if {$::officialBLT} {
$widget::($this,path) grid off
$widget::($this,path) xaxis configure -hide 1
} else {
$widget::($this,path) xaxis configure -mapped 0
}
composite::complete $this
}
proc ~dataBarChart {this} {
if {[string length $composite::($this,-deletecommand)]>0} {
uplevel #0 $composite::($this,-deletecommand)
}
}
proc options {this} {
return [list\
[list -deletecommand {} {}]\
[list -draggable draggable Draggable 0 0]\
[list -height height Height 200]\
[list -mode mode Mode normal normal]\
[list -width width Width 300]\
]
}
proc set-deletecommand {this value} {}
foreach option {-height -width} {
proc set$option {this value} "\$widget::(\$this,path) configure $option \$value"
}
proc set-draggable {this value} {
if {$composite::($this,complete)} {
error {option -draggable cannot be set dynamically}
}
if {$value} {
blt2DViewer::allowDrag $this
}
}
proc set-mode {this value} {
$widget::($this,path) configure -barmode $value
}
proc newElement {this path args} {
set element [eval new element $path $args]
element::update $element {}
return $element
}
proc updateElement {this element seconds value} {
element::update $element $value
}
}
class dataBarChart {
class element {
proc element {this path args} switched {$args} {
$path element create $this -label {} -borderwidth 1 -xdata 0
set ($this,path) $path
switched::complete $this
}
proc ~element {this} {
[set ($this,path)] element delete $this
if {[string length $switched::($this,-deletecommand)]>0} {
uplevel #0 $switched::($this,-deletecommand)
}
}
proc options {this} {
return [list\
[list -color black black]\
[list -deletecommand {} {}]\
[list -label {} {}]\
]
}
proc set-label {this value} {
[set ($this,path)] element configure $this -label $value
}
proc set-color {this value} {
[set ($this,path)] element configure $this -foreground $value
}
proc set-deletecommand {this value} {}
proc update {this y} {
if {[string length $y]==0} {
[set ($this,path)] element configure $this -ydata 0 -label "$switched::($this,-label): ?"
} else {
[set ($this,path)] element configure $this -ydata $y -label "$switched::($this,-label): $y"
}
}
}
}
class dataSideBarChart {
proc dataSideBarChart {this parentPath args} dataBarChart {$parentPath $args} {
composite::configure $this -mode aligned
}
proc ~dataSideBarChart {this} {}
proc iconData {} {
return {
R0lGODdhKAAoAMYAAHt5e87PzgAAANbX1v///wAIADFhITFhGAAQAK33e6X3e5znc6Xvc5zna5TXa5Tfazk4OUJJQozPY4THWnvHWoTPY3u+Wnu+UqWupQAY
AHO2UhgQADEgAHNJAGuuShAIACkgAPffSu/XQiEYAGOmSu/PQufHOWOeQue+OVqWOda2MQAgAN6+MVKOOd62MUqGMc6mKVIIYzEIOXMQhGsQe2sYe0J5KTko
AK0YzrUg1r0o1owQpQAoADlxKc6eIQAQEBBphBBhe944/6UYvbUYzkIoAMaWIa3X57Xf76XP594w/95B/zlpIb2OGMaeIedJ/0owAAAQGJTH3r0Y3iFREFI4
AAAYIYy+1oS+znMoe+dR/ylZGLWGEGumvXOuxudZ/7V5EAAgKWsge+dh/9YY984Y761xCFKWrXMwe2NBAAAwQkKOpd4o/wAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAKAAoAAAH/oAAgoOEhYaHiIMBAAKNjo+QkZKTjYsCAZiZAQOYnJuanp6ao6OMAQSo
qagAqq2sramvq6iWp7AEsrC5rqqvlgOoBQUGB8TFxbq3s7G0poIFCAnSCgoLDAeJ2YW1wQXVDODWBsnKub6MwATQ4QsLDQsH5LfmzZfdDO8N7w4Ggr3KuP4R
qPUMwb4HCPlBiKBN2y9UCAo4eOCgogMJ/eiVE8iNAAIEFCWIFJlR4DyO6CAWGClyAoWSzDbGJAjgYwUKEyrcnGBgYcNsHSO6nGChqAWYy07OTOkRAQWjRS8g
JYABoMaOGRBc2MpVg4ENHDqIHStWXsCBzmoi0KDBA1u3/gY+gAhBl64IER1+AsBaoG1btx4MjOAQ4q5hvGbPCUiXFfBbEl853C0xuUSHxPVsZShAorNnyINL
iDZhooSJvBqX/RKU9YTr1ycEcyhN2gSK0z4dmkLVOsWJFL5TyLZtQoUKFChQmzzbcQUC4NCBG+DAAYUKFtivK4+pejeBFQV+twDeosV0DtddqDe+PSlzRo6y
lp/f4sV5F8bzw+hACZKlGAA698KABNoHAgcwGAfDgip0IIMMM0RIwww0TEhDDRj+B2BWL9jg4YcG3ADCgiQu2AGAOKSIQw4stqiDDpbsICMPBXjYg402hIjg
gj74YOIPBQARxJBEBiHEkUJY/jIEETk4Z0MPUEZpQBE7GmElDEZ08MMPRyBxxJdHJBGEEkIssYQlOBCBAw8IQMmEm0xMCYKVTTjhhBFNaMmll2CKWeYST6C5
Io1MFGqoAQZAwYGVeDZhZQdRRBGmFJRSGoSZT5zJCA46TOEcoqAiSkUVHDRh6ql5WhEFpVe0igUWQWSRhRZaWDLFrWwiWgwxW1ChaBNcBCtsB1ZYccWrXSTr
RaxZfPGFrVPo4NwBW1RbLRWjcsAFGNuCwW0HYUThRRfjJttFEGJkMcYYtpJRBo3YxhsvFCBsa4a3YJgBbhTmJnvGGbGisa4l7r6LgLzypsHBvfd6q68aUfwr
8RprGgQ8MCMFF8zGxhx37PHHIHO8CCkkl2yyyYEAADs=
}
}
}
class dataStackedBarChart {
proc dataStackedBarChart {this parentPath args} dataBarChart {$parentPath $args} {
composite::configure $this -mode stacked
}
proc ~dataStackedBarChart {this} {}
proc iconData {} {
return {
R0lGODdhKAAoAMYAAHt5e87PzgAAANbX1v///xAoCAAIADFhITFhGAAQAK33e6X3e5znc6Xvc5zna5TXa5Tfazk4OUJJQozPY4THWnvHWoTPY3u+Wnu+UlI4
ABAIABgQADEgAHNJACkgAO/XQvffSiEYAO/PQufHOee+Oda2MSEQAN6+Md62MVIIY86mKWsQe2sYe4wQpTkoAHMoe70o1qUYvbUYzrUg1gAYIQAQEBBphBBh
e2sge944/60Yzq3X57Xf76XP53Mwe95B/+dJ/70Y3gAQGJTH3oy+1oS+zudR/2umvXOuxudZ/9YY984Y7wAgKedh/wAoOVKWrQAwQkKOpd4o/wAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAKAAoAAAH/oAAgoOEhYaHiIMBAAKNjo+QkZKTjYsCAZiZAQOYnJuanp6ao6OMAQSo
qagAqq2sramvq6iWp7AEsrC5rqqvlgOoBQIGxAcIxsjHysnMy7i0poLDxAkK1gsMDdYK2NrX2dvdCIS1qMTn3Q3Z6evZ6g3sDQfPBL/m5wkN6gwO7gz8/gDq
+9cPAb1yBM4Ra9Cv3wOGAB82ZCAx4oFB9aIBUJjAIQQIDzyCFBmS4scHByJIiADAXsIEMA08APngwYSZNW3irHmTps2LgjJeQpXAAMwEICconZB0aVOlTycA
ZeXSaMylEyhUwKqV69alWqcKXQTgKEwLFSigVZt2rdu2/nAppJQgoaUpokcNaKVwoe/evhf++k0LWGxVsxUAX8CQGDBjxY8dG75LIIMGDRs4dNjMubPnz50x
1hK04bIGDx9AqAaRWnVr1q0/vJbdIYJtu0MJmA7BQbbv38CD/+4gmhEwAiGSZxbxgXnz58yji5AOXQTxoAiTJ+cwYvqI7967i+hOfrz38depGheknTf57+/f
k4A/f/yI+bVX4rbVngOJ+SWU8N8IAgI4YIEGkpDeWKiYwMGDHJxQwgkUSljhhBZSOCGGEy6IEIQPTojCiCKiUGKAJJ5YgoeMOOIBiCYGWEKMM8ooI400dvCI
JSn0COGLKgSowpBCBlkCkUQe/mmkCh2swMKTlrQgJYQueDDklVhmqSWWHbzgJQyWxCDDDDQMU4MBNtygpppprnlDm2vCuSYOXuZgiQ4y6EBMDXzuwMMOgPbg
J6A7CPpnoIMGesMLPvjww506zLBnn4cWmqillRpKaA+LNgrEnTAEwWcNQghR6BCoDnFqqqui2uoQN9D5wqOMBGFrqTTQIASqRBBRRBG8+grsEL3+Guyvnfpg
hCW2wpDrs8IecQQS0U5bLbW/SotEskkwq8QSTITLhBBITCutueVqa6666R4Rq5dNWPItuEw4Me65RzzxBL768rvvufomGy8j8zIBxcFC6KtvFFEo/ATDDkOs
MMMCFlsixcUYZ6zxxhx3LMUipIQs8sgjBwIAOw==
}
}
}
if {$officialBLT} {
class dataOverlapBarChart {
proc dataOverlapBarChart {this parentPath args} dataBarChart {$parentPath $args} {
composite::configure $this -mode overlap
}
proc ~dataOverlapBarChart {this} {}
proc iconData {} {
return {
R0lGODdhKAAoAMYAAHt5e87PzgAAANbX1v///xAoCAAIADFhITFhGAAQAK33e6X3e5znc6Xvc5zna5TXa5Tfazk4OUJJQozPY4THWnvHWoTPY3u+Wnu+UqWu
pQAYAHO2UlI4ABAIABgQADEgAHNJAGuuSikgAPffSu/XQiEYAGOmSu/PQufHOWOeQue+OVqWOda2MQAgACEQAN6+MVKOOd62MUqGMc6mKVIIYzEIOXMQhGsQ
e2sYe4wQpUJ5KTkoAK0YzrUg1r0o1qUYvbUYzgAoADlxKUIoAM6eIQAYIQAQEBBphBBhe944/8aWIa3X57Xf76XP594w/95B/zlpIb2OGMaeIedJ/70Y3kow
AAAQGJTH3oy+1oS+znMoe+dR/ylZGLWGEGumvXOuxudZ/9YY984Y7yFRELV5EAAgKWsge+dh/61xCAAoOVKWrXMwe2NBAAAwQkKOpd4o/wAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAKAAoAAAH/oAAgoOEhYaHiIMBAAKNjo+QkZKTjYsCAZiZAQOYnJuanp6ao6OMAQSo
qagAqq2sramvq6iWp7AEsrC5rqqvlgOoBQIGxAcIxsi9t7OxtKaCw8QJCtQLDA0IidqKpqjE39YNDdcHysu5vozABN8GCeIMDA4MCOa36M6X3u0N8/MPBwbh
WjawGYFagtol+AcBAsAIEiJsQ/TLW4KLBh44fPBgQkBBBe+Zq4UqgbuLDieo9Chwl72CFdldNLlyAoUKH1m5NMgMIYCZFy1UoCCUwgGIEiYeIkkAqIGbFC5I
zRlS10h1FmdWkCoVA9UMBPEd7EZAQwINZjGo3cChQwcP/h9AyJ0LgpdBn2jNJtiwIcQGD247iBhBeAQJEiCUMj2L1kDfvoFLfDB8+HDdl+kErGNs1m8IEyVC
wz18gsSJE5d5wiSbV4MBE7BBh5Z8+gQK24lBVs08QFDrBCmCp5gt+TYKFCpQgIAoMdHivMBXpFhB/ANyFCxUqMj9SixTDS3AJ1hBfoWLD+g/qGDx4gV77sx6
kk3Qor6B6TBgpEfPPkYMFizAt1s+jqAVXgL5wSCDCPv9ByALM4BAySOW0GAhePUlIMOGMqTH4AwAzgAiCDWUaMMNJ6J4Aw4sWpLDixiaJYMONKa3gwgi5hih
hTTwwEMPQAbpgw+W/ABEDxgG/mEAjULo8MEOQ+zwQY5EFDGMEQYcgcSWXCbhZRKW8AAED+AF0UICOgih5gdRDjHlDEooQYwRdC7BxBJ4NoGEE0k88USYP2pg
ZhAJqAkFFGwOMYQIcUYhxZx13pknEn0+MUWYPlAhaAtKHgrFAYlW8UGcSkRBpxFWWLFEE1e0egUSfk7xJyNU1CqomQkcoCuoVVTBwQdRBBtFqkUUYUWrWGCR
RRZIaOHsFpbU6sOthOqKABcf+CpqFF10W+y3ymbhhRdfNOssGNGGIcatZ17LxRgfcCDvB12QUW8Z+JZhxRfkjusFEmY4e4Yl6q4bxMEGjKEwvNqKUC8aZOCb
hr7+OXqhhhrNrrHGwIwUTG0CC8PLxsgfQAxxGW2kbMXFF7vhRsYbW/LGzDTXbPPNOOf8xiKk9Ozzzz8HAgA7
}
}
}
}
set rcsId {$Id: datapie.tcl,v 1.26 1998/10/11 09:27:20 jfontain Exp $}
class dataPieChart {
proc dataPieChart {this parentPath thickness args} composite {
[new canvas $parentPath -highlightthickness 0 -borderwidth 2] $args
} viewer {} {
set path $widget::($this,path)
set dataPieChart::($this,slices) {}
set dataPieChart::($this,drop) [new dropSite\
-path $path -formats DATACELLS -command "viewer::view $this \$dragSite::data(DATACELLS)"\
]
composite::complete $this
set padding [$path cget -borderwidth]
set dataPieChart::($this,pie) [new pie $path $padding $padding\
-title {} -thickness $thickness -selectable $composite::($this,-draggable)\
-labeler [new piePeripheralLabeler $path\
-font $font::(mediumNormal) -smallfont $font::(smallNormal) -widestvaluetext {00.0 %}\
]\
]
set padding [expr {2*$padding}]
bind $path <Configure>\
"switched::configure $dataPieChart::($this,pie) -width \[expr {%w-$padding}\] -height \[expr {%h-$padding}\]"
}
proc ~dataPieChart {this} {
delete $dataPieChart::($this,pie) $dataPieChart::($this,drop)
catch {delete $dataPieChart::($this,drag)}
if {[string length $composite::($this,-deletecommand)]>0} {
uplevel #0 $composite::($this,-deletecommand)
}
}
proc options {this} {
return [list\
[list -deletecommand {} {}]\
[list -draggable draggable Draggable 0 0]\
[list -height height Height 200]\
[list -width width Width 300]\
]
}
proc set-deletecommand {this value} {}
proc set-draggable {this value} {
if {$composite::($this,complete)} {
error {option -draggable cannot be set dynamically}
}
if {!$value} return
set dataPieChart::($this,drag) [new dragSite -path $widget::($this,path) -validcommand "dataPieChart::validateDrag $this"]
dragSite::provide $dataPieChart::($this,drag) OBJECTS "dataPieChart::dragData $this"
dragSite::provide $dataPieChart::($this,drag) DATACELLS "dataPieChart::dragData $this"
}
foreach option {-height -width} {
proc set$option {this value} "\$widget::(\$this,path) configure $option \$value"
}
proc dragData {this format} {
set slices [slice::selected $dataPieChart::($this,pie)]
switch $format {
OBJECTS {
if {[llength $slices]>0} {
return $slices
} elseif {[llength $dataPieChart::($this,slices)]==0} {
return $this
} else {
return {}
}
}
DATACELLS {
return [cellsFromSlices $this $slices]
}
}
}
proc validateDrag {this x y} {
if {[llength $dataPieChart::($this,slices)]==0} {
return 1
}
return [expr {\
[lsearch -exact [slice::selected $dataPieChart::($this,pie)] [slice::current $dataPieChart::($this,pie)]]>=0\
}]
}
proc supportedTypes {this} {
return {integer real}
}
proc monitorCell {this array row column} {
viewer::registerTrace $this $array
set cell ${array}($row,$column)
if {[lsearch -exact [cellsFromSlices $this $dataPieChart::($this,slices)] $cell]>=0} return
set slice [new slice $dataPieChart::($this,pie) [viewer::label $array $row $column]]
lappend dataPieChart::($this,slices) $slice
switched::configure $slice -deletecommand "dataPieChart::deletedSlice $this $array $slice"
set dataPieChart::($this,cell,$slice) $cell
}
proc update {this array args} {
set cells [cellsFromSlices $this $dataPieChart::($this,slices)]
set sum 0.0
foreach cell $cells {
catch {set sum [expr {$sum+[set $cell]}]}
}
foreach slice $dataPieChart::($this,slices) cell $cells {
if {[catch {set $cell} value]||($sum==0)} {
slice::update $slice 0 ?
} else {
set value [expr {[set $cell]/$sum}]
slice::update $slice $value "[format %.1f [expr {$value*100}]] %"
}
}
}
proc deletedSlice {this array slice} {
viewer::unregisterTrace $this $array
ldelete dataPieChart::($this,slices) $slice
unset dataPieChart::($this,cell,$slice)
if {[llength $dataPieChart::($this,slices)]==0} {
delete $this
}
}
proc cellsFromSlices {this slices} {
set cells {}
foreach slice $slices {
lappend cells $dataPieChart::($this,cell,$slice)
}
return $cells
}
proc cells {this} {
return [cellsFromSlices $this $dataPieChart::($this,slices)]
}
}
class dataPieChart {
class slice {
proc slice {this pie label args} switched {$args} {
set ($this,pie) $pie
set slice [pie::newSlice $pie $label]
set ($this,slice) $slice
set (this,$slice) $this
switched::complete $this
}
proc ~slice {this} {
pie::deleteSlice [set ($this,pie)] [set ($this,slice)]
unset (this,[set ($this,slice)])
if {[string length $switched::($this,-deletecommand)]>0} {
uplevel #0 $switched::($this,-deletecommand)
}
}
proc options {this} {
return [list\
[list -deletecommand {} {}]\
]
}
proc set-deletecommand {this value} {}
proc update {this value string} {
pie::sizeSlice [set ($this,pie)] [set ($this,slice)] $value $string
}
proc selected {pie} {
set list {}
foreach slice [pie::selectedSlices $pie] {
lappend list [set (this,$slice)]
}
return $list
}
proc current {pie} {
set slice [pie::currentSlice $pie]
if {$slice==0} {
return 0
} else {
return [set (this,$slice)]
}
}
}
}
class data2DPieChart {
proc data2DPieChart {this parentPath args} dataPieChart {$parentPath 0 -width 200 -height 220 $args} {}
proc ~data2DPieChart {this} {}
proc iconData {} {
return {
R0lGODdhKAAoAKUAAHt5e87PzgAAANbX1v///zFhIXNJAKX3e/ffSpznc+/XQozPY+fHOXvHWta2Mc6mKUJJQhBhe63X54y+1pTH3lKWrWumvVIIY2sYe4wQ
pb0o1qUYvbUYzq0Yzr0Y3t44/95B/+dJ/+dR/+dZ/9YY9+dh/94o/+9x/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAKAAoAAAG/kCAcEgsGo/IYQAgaDqf0Kh02lwKAthsYIDlbrVer3Y8ZgYI6DQaoG6z2+n3Gm09wwlyeN6t
flsHd3iBgoF5fmZJRAWLBQaOiUZ1hWiLB5YFCJkIjnxxdEyAdwCVlpeampxzngSSdwWlBwkJB5inCrcGqqp1R6+wsgu1t8MMDAZJf3C+lsALwcO3xdLHfZ9X
bcuxCc4JDQXR0g7i4rmryWq+stsL698K0uHk1ayIQ8vq3c7e8PEODw/l8AhpRSmWtgYN9O0rNq7hv4CHBIQikK7ZOoQFGDb09+/hLjNpXqljl3ABQm8OO6oE
+PGKvVj6TCpEubImQAhECL7iNvNk/iNHQIMGZRNxYgGeJk+ejCChadMJEqBSmDChQgSi1uxQPJBQqVKmTqE2nUrVglWs9CTaQ9jNK0KwTqNGpTrBbAScSkCG
bOsWrty5dO0KIUSQotulT5/SLSsYbWHDff8uDty4ZZQCh+FOZlzBqhQrFy5gGD0as1emmzlbJc0ag5UMsGPDNv12AtnFFnJ3jsBag2/fVjZwEE6cQwfaESbn
Xr6bdAcPHz5A/2Clg/Hr1jscLxBhuXfdVnmP7gCivHkQ1bWrX689QoTO8OG7Z00eRIj7+Ktr6LC/P4jnHniAgXsEEkhffeeZZ0WAIHjQoAggiCDhhB205px2
E2aY4YIiQHgA4YcaasheiCSKsOAIKKao4oostuiiFSSUIOOMNNZo4404wojjjjzuaIUJJpwg5JBEFmnkkUcuQcaSTDbZZBAAOw==
}
}
}
class data3DPieChart {
proc data3DPieChart {this parentPath args} dataPieChart {$parentPath 20 -width 250 -height 180 $args} {}
proc ~data3DPieChart {this} {}
proc iconData {} {
return {
R0lGODdhKAAoAKUAAHt5e87PzgAAANbX1v///zFhIXNJAKX3e/ffSu/XQufHOZznc9a2MY7PYc6mKRBhe63X55TH3oy+1lKWrUJJQk2SMDF5lFIIY2sYe4wQ
pb0o1qUYvbUYzr0Y3t44/60Yzt5B/+dJ/+dR/+dZ/9YY9+dh/94o/+9x/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAKAAoAAAG/kCAcEgsGo/IYQAgaDqf0Kh02lwKAthsYIDlbrVer3Y8ZgYI6DQaoG6z2+n3Gm09wwlyeN6t
flsHd3iBgoF5fmZJRAWLBQaOBolFdYMEjAeXBQiaCI99ngR/gYuXpAeZmwgJCo5zcXRmdwWlpAunmqoKCgwGhK11RrKzCwsNtrm6DMmQR6FqwbTDDbWpx8jJ
u5+Tac8H0sQN4Jm51+QMDry+TIDb0N/fBdblDvPohL9Cz9HE+8Xy8//0JMFCEwwcP34FzAFcSC+dgHWVLumTBi7co4sYWdkbWCkaRXfgHkAYSXJkhAgQJEx4
4HAJvo8wQ5YkeTKChJsrKRDR1tFb/sWfImfWvKlSwgM2hx5uK/DzW8WgKYcSnaDy6MYrSyn+lGny5E2bRVdaTTpgSIEKTLfKlOo17AMLD3Qq4XgWrdoGIonq
pUr1LVykr7ASrEA4LVC9YYv6/XvVzuDChh8k5qvYguWjgEExgVIX8qIHlPk+GL0YbhQrFy5gWI2hM2HCpGOXtgyXtW0rGXLrzuAaNu3fwGuv1kCcuJUNHJAr
57DodYXZwYVj6ODBA3UPVj5w0M6dA/PO0H+PZt0BhPnz2T+oX7++A6PwpG2fD0GffnYNH/Dr78CfPwbZ8dlW3nkEgmAFfyCU14EIIIjg4IO2sfYBeQ9WWOGB
IizYYIMWPlYIAnsfcNihhQeOYOKJKKao4oosWkFCCTDGKOOMNNZoo4s25qhjjlaYYMIJQAYp5JBEFlnkEmQkqeSSSwYBADs=
}
}
}
set rcsId {$Id: lastwish.tcl,v 1.1 1998/07/16 20:21:57 jfontain Exp $}
class lastWish {
proc lastWish {this command} {
set lastWish::($this,command) $command
}
proc ~lastWish {this} {
uplevel #0 $lastWish::($this,command)
}
}
set rcsId {$Id: sumtable.tcl,v 1.9 1998/10/11 09:27:20 jfontain Exp $}
class summaryTable {
proc summaryTable {this parentPath args} composite {[new frame $parentPath] $args} viewer {} {
variable ${this}data
array set ${this}data {
updates 0
0,label data 0,type ascii 0,message {data cell description}
1,label current 1,type real 1,message {current value}
2,label average 2,type real 2,message {average value since viewer creation}
3,label minimum 3,type real 3,message {minimum value since viewer creation}
4,label maximum 4,type real 4,message {maximum value since viewer creation}
sort {0 increasing}
indexColumns 0
}
set summaryTable::($this,nextRow) 0
composite::complete $this
set table [new dataTable $widget::($this,path)\
-data summaryTable::${this}data -draggable $composite::($this,-draggable) -titlefont $composite::($this,-titlefont)\
]
set summaryTable::($this,drop) [new dropSite\
-path $dataTable::($table,tablePath) -formats DATACELLS -command "viewer::view $this \$dragSite::data(DATACELLS)"\
]
if {$composite::($this,-draggable)} {
dragSite::provide $dataTable::($table,drag) OBJECTS "summaryTable::dragData $this"
}
pack $widget::($table,path) -fill both -expand 1
set summaryTable::($this,dataTable) $table
}
proc ~summaryTable {this} {
variable ${this}data
variable ${this}cellRow
delete $summaryTable::($this,dataTable) $summaryTable::($this,drop)
unset ${this}data
catch {unset ${this}cellRow}
if {[string length $composite::($this,-deletecommand)]>0} {
uplevel #0 $composite::($this,-deletecommand)
}
}
proc iconData {} {
return {
R0lGODdhKAAoAIQAAHt5e87PzgAAANbX1v///9/f339/fzk4OUJJQlIIY2sQe2sYe4wQpXMoe70o1qUYvbUYzrUg1msge944/60YznMwe95B/+dJ/70Y3udR
/9YY984Y794o/wAAAAAAAAAAACwAAAAAKAAoAAAF/iAgjmRpnugYAELrvnAsz+0qBHgeDDi/6z6fbjhkBQjIJBKgbDKbyecSaTtCCVJo1ql82gZImniMpRpF
sELBoG672e53QUCqhl9qeDy/b7MFZQRfdy58fWuHiIBeRoQtBpCRkpOUkXQigmcsLwSInZ8FnWygoH8HCAcAgwRpBAakoaGvsaSvl0x2rJyetLGjvaJzI5kC
YLoulcnKt8Qrm4WIh3p7pggIqo3HLYZ903F/w6tp0d2J4Ji5MMrrk8xVaLu/sPK9pgep6XiusJ+z/LbhWBiDEYwfr3nC0GVTx66hO4HwoHmTI23OKXwL8ZCj
Zi4hrowSO1Z8eMORgIYOlgPSKAjsYL05L2wkmNnKHzCbtVgpWMDTBoOfBF2WahlMQIOjDmw8gBCBIcplEo5OsEEBAoVxE/10NFqhggWqFJpqzMqNI9cKF6g6
wIBVZDkBURt8ZYGh7pi7Mhp0zWCjrl8MXQMLHky4cGAMff8CNsy4cVfELDRs4ECZg+PLhTnYqMy5s+fPoDlvDk26tOcVRFKrXr06BAA7
}
}
proc options {this} {
return [list\
[list -deletecommand {} {}]\
[list -draggable draggable Draggable 0 0]\
[list -titlefont titleFont TitleFont $font::(mediumBold) $font::(mediumBold)]\
]
}
proc set-deletecommand {this value} {}
foreach option {-draggable -titlefont} {
proc set$option {this value} "
if {\$composite::(\$this,complete)} {
error {option $option cannot be set dynamically}
}
"
}
proc supportedTypes {this} {
return {integer real}
}
proc monitorCell {this array row column} {
variable ${this}data
variable ${this}cellRow
viewer::registerTrace $this $array
set cell ${array}($row,$column)
if {[info exists ${this}cellRow($cell)]} return
set label [viewer::label $array $row $column]
set row $summaryTable::($this,nextRow)
set ${this}data($row,0) $label
array set ${this}data "$row,2 {} $row,3 {} $row,4 {}"
set ${this}data($row,sum) 0.0
set ${this}cellRow($cell) $row
set summaryTable::($this,rowLastWish,$row) [new lastWish "summaryTable::deleteRow $this $cell"]
incr summaryTable::($this,nextRow)
}
proc update {this array args} {
variable ${this}data
variable ${this}cellRow
foreach cell [array names ${this}cellRow] {
set row [set ${this}cellRow($cell)]
if {[catch {set $cell} current]} {
set ${this}data($row,1) ?
} else {
set ${this}data($row,1) $current
set ${this}data($row,2) [format %.2f\
[expr\
{[set ${this}data($row,sum) [expr {[set ${this}data($row,sum)]+$current}]]/([set ${this}data(updates)]+1)}\
]\
]
set value [set ${this}data($row,3)]
if {([string length $value]==0)||($current<$value)} {
set ${this}data($row,3) $current
}
set value [set ${this}data($row,4)]
if {([string length $value]==0)||($current>$value)} {
set ${this}data($row,4) $current
}
}
}
incr ${this}data(updates)
}
proc cells {this} {
variable ${this}cellRow
return [array names ${this}cellRow]
}
proc dragData {this format} {
variable ${this}cellRow
foreach cell [dataTable::dragData $summaryTable::($this,dataTable) $format] {
regexp {\(([^,]+)} $cell dummy row
set selected($row) {}
}
set lastWishes {}
foreach row [array names selected] {
lappend lastWishes $summaryTable::($this,rowLastWish,$row)
}
if {([llength $lastWishes]==[array size ${this}cellRow])||([llength $lastWishes]==0)} {
return $this
} else {
return $lastWishes
}
}
proc deleteRow {this cell} {
variable ${this}data
variable ${this}cellRow
set row [set ${this}cellRow($cell)]
unset ${this}data($row,0) ${this}data($row,1) ${this}data($row,2) ${this}data($row,3) ${this}data($row,4)\
${this}data($row,sum) summaryTable::($this,rowLastWish,$row)
unset ${this}cellRow($cell)
dataTable::update $summaryTable::($this,dataTable)
}
}
set rcsId {$Id: freetext.tcl,v 1.9 1998/10/18 21:17:53 jfontain Exp $}
class freeText {
proc freeText {this parentPath args} composite {
[new text $parentPath -font $font::(mediumNormal) -wrap word -borderwidth 0 -highlightthickness 0] $args
} viewer {} {
set freeText::($this,drop) [new dropSite\
-path $widget::($this,path) -formats DATACELLS -command "viewer::view $this \$dragSite::data(DATACELLS)"\
]
set freeText::($this,labels) {}
composite::complete $this
}
proc ~freeText {this} {
delete $freeText::($this,drop)
catch {delete $freeText::($this,drag)}
catch {delete $dataTable::($this,selector)}
eval delete $freeText::($this,labels)
if {[string length $composite::($this,-deletecommand)]>0} {
uplevel #0 $composite::($this,-deletecommand)
}
}
proc iconData {} {
return {
R0lGODdhKAAoAIQAAHh4eMjMyAAAANDU0Pj8+Hh8eDg4OEBIQLi8uFAIYHAoeHAweGgYeIgQoLgo0KAYuLAYyLAg0GggeNg4+KgYyNhA+LgY2OBI+OBQ+Ngo
+AAAAAAAAAAAAAAAAAAAAAAAACwAAAAAKAAoAAAF/iAgjmRpnugYAELrvnAsz+0qBHgeDDi/6z6fbjhkBQjIJBKgbDKbyecSaTtCCVJo1ql82gZXQiEsJo+j
VKOowG673/B4W2UMn693aN7LAuPNgGgEVUg0hodYaTciMGSOTQJzX4Uvj5YEAmWDdZiVl46ZZ5OdLp+gI5uLLJ6mVwIGBwcAhKQtZLaWAqijjWEtCLm7nL21
lAi4xYXCqr2/x5mlts64rwYGs8OsCMC/0wLPwATbmMt+xDDgnelKuiKpVs3f4L/q9OzljJ703dLf+5mYYF2jda4fv3EvEC6Dx0rcuG0PwzkcR84dwYat7llc
JSOjqxc2Eogk5jGJAAULcxYwsNGgJcmSmFAucGDjAYQIL0sKkKBAwQQbFCBQOERUhswKQClEsMA0pdOnUKNKdXoBqAOmTadq3ZoSKQusWLmKlYrBBtizaNOq
RetVwNq3cMFWmGsjg927ePPq3at3boa6fAMLDgx4sGHDK4goXsyYcQgAOw==
}
}
proc options {this} {
return [list\
[list -cellindices cellIndices CellIndices {} {}]\
[list -deletecommand {} {}]\
[list -draggable draggable Draggable 0 0]\
[list -endtext endText EndText {} {}]\
[list -height height Height 1]\
[list -width width Width 40]\
]
}
proc set-cellindices {this value} {
if {$composite::($this,complete)} {
error {option -cellindices cannot be set dynamically}
}
set freeText::($this,nextCellIndex) 0
}
proc set-endtext {this value} {
$widget::($this,path) insert end $value
}
proc set-deletecommand {this value} {}
proc set-draggable {this value} {
if {$composite::($this,complete)} {
error {option -draggable cannot be set dynamically}
}
if {!$value} return
set freeText::($this,drag) [new dragSite -path $widget::($this,path) -validcommand "freeText::validateDrag $this 0"]
dragSite::provide $freeText::($this,drag) OBJECTS "freeText::dragData $this"
set freeText::($this,selector) [new selector -selectcommand "freeText::setLabelsState $this"]
}
foreach option {-height -width} {
proc set$option {this value} "\$widget::(\$this,path) configure $option \$value"
}
proc dragData {this format} {
switch $format {
OBJECTS {
set list [selector::selected $freeText::($this,selector)]
if {[llength $list]>0} {
return $list
} elseif {[empty $this]} {
return $this
} else {
return {}
}
}
DATACELLS {
return [cellsFromLabels $this [selector::selected $freeText::($this,selector)]]
}
}
}
proc validateDrag {this label x y} {
if {($label==0)&&[empty $this]} {
return 1
} elseif {[lsearch -exact [selector::selected $freeText::($this,selector)] $label]>=0} {
return 1
} else {
return 0
}
}
proc supportedTypes {this} {
return {ascii dictionary integer real}
}
proc monitorCell {this array row column} {
viewer::registerTrace $this $array
set cell ${array}($row,$column)
if {[lsearch -exact [cellsFromLabels $this $freeText::($this,labels)] $cell]>=0} return
set path $widget::($this,path)
if {[info exists freeText::($this,nextCellIndex)]} {
set index [lindex $composite::($this,-cellindices) $freeText::($this,nextCellIndex)]
if {[string length $index]==0} {
unset freeText::($this,nextCellIndex)
set index insert
} else {
incr freeText::($this,nextCellIndex)
}
} else {
set index insert
$path insert $index "[viewer::label $array $row $column]: "
}
set label [new label $path $cell]
set labelPath $label::($label,path)
switched::configure $label -deletecommand "freeText::deletedLabel $this $array $label"
if {$composite::($this,-draggable)} {
set drag [new dragSite -path $labelPath -validcommand "freeText::validateDrag $this $label"]
dragSite::provide $drag OBJECTS "freeText::dragData $this"
dragSite::provide $drag DATACELLS "freeText::dragData $this"
set freeText::($this,drag,$label) $drag
set selector $freeText::($this,selector)
selector::add $selector $label
bind $labelPath <ButtonRelease-1> "selector::select $selector $label"
bind $labelPath <Control-ButtonRelease-1> "selector::toggle $selector $label"
bind $labelPath <Shift-ButtonRelease-1> "freeText::extendSelection $this $label"
}
lappend freeText::($this,labels) $label
$path window create $index -window $labelPath
set freeText::($this,cell,$label) $cell
}
proc update {this array args} {
foreach label $freeText::($this,labels) {
if {[catch {set $freeText::($this,cell,$label)} value]} {
switched::configure $label -text ?
} else {
switched::configure $label -text $value
}
}
}
proc deletedLabel {this array label} {
if {$composite::($this,-draggable)} {
delete $freeText::($this,drag,$label)
selector::remove $freeText::($this,selector) $label
}
viewer::unregisterTrace $this $array
ldelete freeText::($this,labels) $label
unset freeText::($this,cell,$label)
}
proc cellsFromLabels {this labels} {
set cells {}
foreach label $labels {
lappend cells $freeText::($this,cell,$label)
}
return $cells
}
proc cells {this} {
return [cellsFromLabels $this $freeText::($this,labels)]
}
proc setLabelsState {this labels select} {
foreach label $labels {
label::select $label $select
}
}
proc extendSelection {this endLabel} {
set selector $freeText::($this,selector)
if {[info exists selector::($selector,lastSelected)]} {
foreach label $freeText::($this,labels) {
set labelFromPath($label::($label,path)) $label
}
set list {}
foreach {key path index} [$widget::($this,path) dump -window 1.0 end] {
if {[string length $path]==0} continue
lappend list $labelFromPath($path)
}
set start [lsearch -exact $list $selector::($selector,lastSelected)]
set end [lsearch -exact $list $endLabel]
if {$end<$start} {
set index $start
set start $end
set end $index
}
selector::clear $selector
selector::set $selector [lrange $list $start $end] 1
} else {
selector::select $selector $endLabel
}
}
proc empty {this} {
return [expr\
{([llength $freeText::($this,labels)]==0)&&([string length [string trim [$widget::($this,path) get 1.0 end]]]==0)}\
]
}
proc initializationConfiguration {this} {
set options {}
set text {}
foreach {key string index} [$widget::($this,path) dump -text 1.0 end] {
append text $string
}
lappend options -endtext $text
set indices {}
foreach {key path index} [$widget::($this,path) dump -window 1.0 end] {
if {[string length $path]==0} continue
lappend indices $index
}
if {[llength $indices]>0} {
lappend options -cellindices $indices
}
return $options
}
}
class freeText {
class label {
proc label {this parentPath cell args} switched {$args} {
set label [new label $parentPath\
-font $font::(mediumBold) -relief sunken -padx 0 -pady 0 -borderwidth 1 -cursor top_left_arrow\
]
bind $widget::($label,path) <Destroy> "delete $this"
set ($this,path) $widget::($label,path)
set ($this,label) $label
set ($this,cell) $cell
switched::complete $this
}
proc ~label {this} {
bind [set ($this,path)] <Destroy> {}
delete [set ($this,label)]
if {[string length $switched::($this,-deletecommand)]>0} {
uplevel #0 $switched::($this,-deletecommand)
}
}
proc options {this} {
return [list\
[list -deletecommand {} {}]\
[list -text {} {}]\
]
}
proc set-deletecommand {this value} {}
proc set-text {this value} {
[set ($this,path)] configure -text $value
}
proc select {this select} {
if {$select} {
[set ($this,path)] configure -background white
} else {
[set ($this,path)] configure -background $widget::(default,ButtonBackgroundColor)
}
}
}
}
array set HMtag_map {
b {weight bold}
blockquote {style i indent 1 Trindent rindent}
bq {style i indent 1 Trindent rindent}
cite {style i}
code {family courier}
dfn {style i}
dir {indent 1}
dl {indent 1}
em {style i}
h1 {size 24 weight bold}
h2 {size 22}
h3 {size 20}
h4 {size 18}
h5 {size 16}
h6 {style i}
i {style i}
kbd {family courier weight bold}
menu {indent 1}
ol {indent 1}
pre {fill 0 family courier Tnowrap nowrap}
samp {family courier}
strong {weight bold}
tt {family courier}
u {Tunderline underline}
ul {indent 1}
var {style i}
}
array set HMtag_map {
center {Tcenter center}
strike {Tstrike strike}
u {Tunderline underline}
}
set HMtag_map(hmstart) {
family times weight medium style r size 14
Tcenter "" Tlink "" Tnowrap "" Tunderline "" list list
fill 1 indent "" counter 0 adjust 0
}
array set HMinsert_map {
blockquote "\n\n" /blockquote "\n"
br "\n"
dd "\n" /dd "\n"
dl "\n" /dl "\n"
dt "\n"
form "\n" /form "\n"
h1 "\n\n" /h1 "\n"
h2 "\n\n" /h2 "\n"
h3 "\n\n" /h3 "\n"
h4 "\n" /h4 "\n"
h5 "\n" /h5 "\n"
h6 "\n" /h6 "\n"
li "\n"
/dir "\n"
/ul "\n"
/ol "\n"
/menu "\n"
p "\n\n"
pre "\n" /pre "\n"
}
array set HMlist_elements {
ol 1 ul 1 menu 1 dl 1 dir 1
}
proc HMinit_win {win} {
upvar #0 HM$win var
HMinit_state $win
$win tag configure underline -underline 1
$win tag configure center -justify center
$win tag configure nowrap -wrap none
$win tag configure rindent -rmargin $var(S_tab)c
$win tag configure strike -overstrike 1
$win tag configure mark -foreground red
$win tag configure list -spacing1 3p -spacing3 3p
$win tag configure compact -spacing1 0p
$win tag configure link -borderwidth 2 -foreground blue
HMset_indent $win $var(S_tab)
$win configure -wrap word
$win mark set $var(S_insert) 1.0
$win tag configure thin -font [HMx_font times 2 medium r]
$win tag configure hr -relief sunken -borderwidth 2 -wrap none \
-tabs [winfo width $win]
bind $win <Configure> {
%W tag configure hr -tabs %w
%W tag configure last -spacing3 %h
}
$win tag bind link <1> "HMlink_hit $win %x %y"
}
proc HMset_indent {win cm} {
set tabs [expr {$cm/2.0}]
$win configure -tabs ${tabs}c
foreach i {1 2 3 4 5 6 7 8 9} {
set tab [expr {$i*$cm}]
$win tag configure indent$i -lmargin1 ${tab}c -lmargin2 ${tab}c \
-tabs "[expr {$tab+$tabs}]c [expr {$tab+2*$tabs}]c"
}
}
proc HMreset_win {win} {
upvar #0 HM$win var
regsub -all { +[^L ][^ ]*} " [$win tag names] " {} tags
catch "$win tag delete $tags"
eval $win mark unset [$win mark names]
$win delete 0.0 end
$win tag configure hr -tabs [winfo width $win]
$win mark set $var(S_insert) 1.0
catch unset [info globals HM$win.form*]
HMinit_state $win
return HM$win
}
proc HMinit_state {win} {
upvar #0 HM$win var
array set tmp [array get var S_*]
catch {unset var}
array set var {
stop 0
tags 0
fill 0
list list
S_adjust_size 0
S_tab 1.0
S_unknown \xb7
S_update 10
S_symbols O*=+-o\xd7\xb0>:\xb7
S_insert Insert
}
array set var [array get tmp]
}
array set HMparam_map {
-update S_update
-tab S_tab
-unknown S_unknown
-stop S_stop
-size S_adjust_size
-symbols S_symbols
-insert S_insert
}
proc HMset_state {win args} {
upvar #0 HM$win var
global HMparam_map
set bad 0
if {[catch {array set params $args}]} {return 0}
foreach i [array names params] {
incr bad [catch {set var($HMparam_map($i)) $params($i)}]
}
return [expr {$bad==0}]
}
proc HMrender {win tag not param text} {
upvar #0 HM$win var
if {$var(stop)} return
global HMtag_map HMinsert_map HMlist_elements
set tag [string tolower $tag]
set text [HMmap_esc $text]
if {[info exists HMlist_elements($tag)]} {
set list "list [expr {[HMextract_param $param compact] ? "compact" : "list"}]"
} else {
set list ""
}
if {[info exists var(divert)]} {
set win $var(divert)
upvar #0 HM$win var
}
catch {HMstack $win $not "$HMtag_map($tag) $list"}
set bad [catch {$win insert $var(S_insert) $HMinsert_map($not$tag) "space $var(font)"}]
if {!$bad && [lindex $var(fill) end]} {
set text [string trimleft $text]
}
if {[lindex $var(fill) end]} {
set text [HMzap_white $text]
}
catch {HMmark $not$tag $win $param text} err
catch {HMtag_$not$tag $win $param text} msg
set tags [HMcurrent_tags $win]
$win insert $var(S_insert) $text $tags
if {!([incr var(tags)] % $var(S_update))} {
update
}
}
proc HMtag_hmstart {win param text} {
upvar #0 HM$win var
$win mark gravity $var(S_insert) left
$win insert end "\n " last
$win mark gravity $var(S_insert) right
}
proc HMtag_/hmstart {win param text} {
$win delete last.first end
}
proc HMtag_title {win param text} {
upvar $text data
wm title [winfo toplevel $win] $data
set data ""
}
proc HMtag_hr {win param text} {
upvar #0 HM$win var
$win insert $var(S_insert) "\n" space "\n" thin "\t" "thin hr" "\n" thin
}
proc HMtag_ol {win param text} {
upvar #0 HM$win var
set var(count$var(level)) 0
}
proc HMtag_ul {win param text} {
upvar #0 HM$win var
catch {unset var(count$var(level))}
}
proc HMtag_menu {win param text} {
upvar #0 HM$win var
set var(menu) ->
set var(compact) 1
}
proc HMtag_/menu {win param text} {
upvar #0 HM$win var
catch {unset var(menu)}
catch {unset var(compact)}
}
proc HMtag_dt {win param text} {
upvar #0 HM$win var
upvar $text data
set level $var(level)
incr level -1
$win insert $var(S_insert) "$data" \
"hi [lindex $var(list) end] indent$level $var(font)"
set data {}
}
proc HMtag_li {win param text} {
upvar #0 HM$win var
set level $var(level)
incr level -1
set x [string index $var(S_symbols)+-+-+-+-" $level]
catch {set x [incr var(count$level)]}
catch {set x $var(menu)}
$win insert $var(S_insert) \t$x\t "mark [lindex $var(list) end] indent$level $var(font)"
}
proc HMtag_a {win param text} {
upvar #0 HM$win var
if {[HMextract_param $param href]} {
set var(Tref) [list L:$href]
HMstack $win "" "Tlink link"
HMlink_setup $win $href
}
if {[HMextract_param $param name]} {
set var(Tname) [list N:$name]
HMstack $win "" "Tanchor anchor"
$win mark set N:$name "$var(S_insert) - 1 chars"
$win mark gravity N:$name left
if {[info exists var(goto)] && $var(goto) == $name} {
unset var(goto)
set var(going) $name
}
}
}
proc HMgoto {win where {callback HMwent_to}} {
upvar #0 HM$win var
if {[regexp N:$where [$win mark names]]} {
$win see N:$where
update
eval $callback $win [list $where]
return 1
} else {
set var(goto) $where
return 0
}
}
proc HMwent_to {win where {count 0} {color orange}} {
upvar #0 HM$win var
if {$count > 5} return
catch {$win tag configure N:$where -foreground $color}
update
after 200 [list HMwent_to $win $where [incr count] \
[expr {$color=="orange" ? "" : "orange"}]]
}
proc HMtag_/a {win param text} {
upvar #0 HM$win var
if {[info exists var(Tref)]} {
unset var(Tref)
HMstack $win / "Tlink link"
}
if {[info exists var(going)]} {
$win yview N:$var(going)
update
HMwent_to $win $var(going)
unset var(going)
}
if {[info exists var(Tname)]} {
unset var(Tname)
HMstack $win / "Tanchor anchor"
}
}
proc HMtag_img {win param text} {
upvar #0 HM$win var
array set align_map {top top middle center bottom bottom}
set align bottom
HMextract_param $param align
catch {set align $align_map([string tolower $align])}
set alt "<image>"
HMextract_param $param alt
set alt [HMmap_esc $alt]
set border 1
HMextract_param $param border
set item $win.$var(tags)
if {[HMextract_param $param width] && [HMextract_param $param height]} {
frame $item -width $width -height $height
pack propagate $item 0
set label $item.label
label $label
pack $label -expand 1 -fill both
} else {
set label $item
label $label
}
$label configure -relief ridge -fg orange -text $alt
catch {$label configure -bd $border}
$win window create $var(S_insert) -align $align -window $item -pady 2 -padx 2
set tags [HMcurrent_tags $win]
foreach tag $tags {
$win tag add $tag $item
}
if {[HMextract_param $param ismap]} {
set link [lindex $tags [lsearch -glob $tags L:*]]
regsub L: $link {} link
global HMevents
regsub -all {%} $link {%%} link2
foreach i [array names HMevents] {
bind $label <$i> "catch \{%W configure $HMevents($i)\}"
}
bind $label <1> "+HMlink_callback $win $link2?%x,%y"
}
set src ""
HMextract_param $param src
HMset_image $win $label $src
return $label
}
proc HMset_image {win handle src} {
HMgot_image $handle "can't get\n$src"
}
proc HMgot_image {win image_error} {
if {[winfo name $win] == "label"} {
pack propagate [winfo parent $win] 1
}
if {[catch {$win configure -image $image_error}]} {
$win configure -image {}
$win configure -text $image_error
}
}
array set HMevents {
Enter {-borderwidth 2 -relief raised }
Leave {-borderwidth 2 -relief flat }
1 {-borderwidth 2 -relief sunken}
ButtonRelease-1 {-borderwidth 2 -relief raised}
}
proc HMlink_setup {win href} {
global HMevents
regsub -all {%} $href {%%} href2
foreach i [array names HMevents] {
eval {$win tag bind L:$href <$i>} \
\{$win tag configure \{L:$href2\} $HMevents($i)\}
}
}
proc HMlink_hit {win x y} {
set tags [$win tag names @$x,$y]
set link [lindex $tags [lsearch -glob $tags L:*]]
regsub L: $link {} link
HMlink_callback $win $link
}
proc HMlink_callback {win href} {
puts "Got hit on $win, link $href"
}
proc HMextract_param {param key {val ""}} {
if {$val == ""} {
upvar $key result
} else {
upvar $val result
}
set ws " \n\r"
if {
[regsub -nocase [format {.*%s[%s]*=[%s]*"([^"]*).*} $key $ws $ws] $param {\1} value] ||
[regsub -nocase [format {.*%s[%s]*=[%s]*'([^']*).*} $key $ws $ws] $param {\1} value] ||
[regsub -nocase [format {.*%s[%s]*=[%s]*([^%s]+).*} $key $ws $ws $ws] $param {\1} value] } {
set result $value
return 1
}
set bad \[^a-zA-Z\]+
if {[regexp -nocase "$bad$key$bad" -$param-]} {
return 1
} else {
return 0
}
}
proc HMstack {win push list} {
upvar #0 HM$win var
array set tags $list
if {$push == ""} {
foreach tag [array names tags] {
lappend var($tag) $tags($tag)
}
} else {
foreach tag [array names tags] {
set var($tag) [lreplace $var($tag) end end]
}
}
}
proc HMcurrent_tags {win} {
upvar #0 HM$win var
set font font
foreach i {family size weight style} {
set $i [lindex $var($i) end]
append font :[set $i]
}
set xfont [HMx_font $family $size $weight $style $var(S_adjust_size)]
HMset_font $win $font $xfont
set indent [llength $var(indent)]
incr indent -1
lappend tags $font indent$indent
foreach tag [array names var T*] {
lappend tags [lindex $var($tag) end]
}
set var(font) $font
set var(xfont) [$win tag cget $font -font]
set var(level) $indent
return $tags
}
proc HMset_font {win tag font} {
catch {$win tag configure $tag -font $font} msg
}
proc HMx_font {family size weight style {adjust_size 0}} {
catch {incr size $adjust_size}
return "-*-$family-$weight-$style-normal-*-*-${size}0-*-*-*-*-*-*"
}
proc HMoptimize {} {
regsub -all "\n\[ \]*#\[^\n\]*" [info body HMrender] {} body
regsub -all ";\[ \]*#\[^\n]*" $body {} body
regsub -all "\n\n+" $body \n body
proc HMrender {win tag not param text} $body
}
proc HMparse_html {html {cmd HMtest_parse} {start hmstart}} {
regsub -all \{ $html {\&ob;} html
regsub -all \} $html {\&cb;} html
set w " \t\r\n"
proc HMcl x {return "\[$x\]"}
set exp <(/?)([HMcl ^$w>]+)[HMcl $w]*([HMcl ^>]*)>
set sub "\}\n$cmd {\\2} {\\1} {\\3} \{"
regsub -all $exp $html $sub html
eval "$cmd {$start} {} {} \{ $html \}"
eval "$cmd {$start} / {} {}"
}
proc HMtest_parse {command tag slash text_after_tag} {
puts "==> $command $tag $slash $text_after_tag"
}
proc HMzap_white {data} {
regsub -all "\[ \t\r\n\]+" $data " " data
return $data
}
proc HMmap_esc {text} {
if {![regexp & $text]} {return $text}
regsub -all {([][$\\])} $text {\\\1} new
regsub -all {&#([0-9][0-9]?[0-9]?);?} \
$new {[format %c [scan \1 %d tmp;set tmp]]} new
regsub -all {&([a-zA-Z]+);?} $new {[HMdo_map \1]} new
return [subst $new]
}
proc HMdo_map {text {unknown ?}} {
global HMesc_map
set result $unknown
catch {set result $HMesc_map($text)}
return $result
}
array set HMesc_map {
lt < gt > amp & quot \" copy \xa9
reg \xae ob \x7b cb \x7d nbsp \xa0
}
array set HMesc_map {
nbsp \xa0 iexcl \xa1 cent \xa2 pound \xa3 curren \xa4
yen \xa5 brvbar \xa6 sect \xa7 uml \xa8 copy \xa9
ordf \xaa laquo \xab not \xac shy \xad reg \xae
hibar \xaf deg \xb0 plusmn \xb1 sup2 \xb2 sup3 \xb3
acute \xb4 micro \xb5 para \xb6 middot \xb7 cedil \xb8
sup1 \xb9 ordm \xba raquo \xbb frac14 \xbc frac12 \xbd
frac34 \xbe iquest \xbf Agrave \xc0 Aacute \xc1 Acirc \xc2
Atilde \xc3 Auml \xc4 Aring \xc5 AElig \xc6 Ccedil \xc7
Egrave \xc8 Eacute \xc9 Ecirc \xca Euml \xcb Igrave \xcc
Iacute \xcd Icirc \xce Iuml \xcf ETH \xd0 Ntilde \xd1
Ograve \xd2 Oacute \xd3 Ocirc \xd4 Otilde \xd5 Ouml \xd6
times \xd7 Oslash \xd8 Ugrave \xd9 Uacute \xda Ucirc \xdb
Uuml \xdc Yacute \xdd THORN \xde szlig \xdf agrave \xe0
aacute \xe1 acirc \xe2 atilde \xe3 auml \xe4 aring \xe5
aelig \xe6 ccedil \xe7 egrave \xe8 eacute \xe9 ecirc \xea
euml \xeb igrave \xec iacute \xed icirc \xee iuml \xef
eth \xf0 ntilde \xf1 ograve \xf2 oacute \xf3 ocirc \xf4
otilde \xf5 ouml \xf6 divide \xf7 oslash \xf8 ugrave \xf9
uacute \xfa ucirc \xfb uuml \xfc yacute \xfd thorn \xfe
yuml \xff
}
array set HMtag_map {
textarea {fill 0}
}
proc HMtag_isindex {win param text} {
upvar #0 HM$win var
set item $win.$var(tags)
if {[winfo exists $item]} {
destroy $item
}
frame $item -relief ridge -bd 3
set prompt "Enter search keywords here"
HMextract_param $param prompt
label $item.label -text [HMmap_esc $prompt] -font $var(xfont)
entry $item.entry
bind $item.entry <Return> "$item.submit invoke"
button $item.submit -text search -font $var(xfont) -command \
[format {HMsubmit_index %s {%s} [HMmap_reply [%s get]]} \
$win $param $item.entry]
pack $item.label -side top
pack $item.entry $item.submit -side left
$win insert $var(S_insert) \n isindex
HMwin_install $win $item
$win insert $var(S_insert) \n isindex
bind $item <Visibility> {focus %W.entry}
}
proc HMsubmit_index {win param text} {
HMlink_callback $win ?$text
}
proc HMtag_form {win param text} {
upvar #0 HM$win var
set id HM$win.form$var(tags)
upvar #0 $id form
if {[info exists var(form_id)]} {
puts "Missing end-form tag !!!! $var(form_id)"
HMtag_/form $win {} {}
}
catch {unset form}
set var(form_id) $id
set form(param) $param
set form(reset) ""
set form(reset_button) ""
set form(submit) ""
set form(submit_button) ""
}
proc HMtag_/form {win param text} {
upvar #0 HM$win var
upvar #0 $var(form_id) form
foreach name [array names form radio_*] {
regsub radio_ $name {} name
lappend form(submit) [list $name \$form(radio_$name)]
}
foreach item $form(reset_button) {
$item configure -command $form(reset)
}
if {$form(submit_button) == ""} {
HMinput_submit $win {}
}
foreach item $form(submit_button) {
set submit $form(submit)
catch {lappend submit $form(submit_$item)}
$item configure -command \
[list HMsubmit_button $win $var(form_id) $form(param) \
$submit]
}
unset form(reset) form(submit) form(reset_button) form(submit_button)
unset var(form_id)
}
proc HMtag_input {win param text} {
upvar #0 HM$win var
set type text
HMextract_param $param type
set type [string tolower $type]
if {[catch {HMinput_$type $win $param} err]} {
puts stderr $err
}
}
proc HMinput_text {win param {show {}}} {
upvar #0 HM$win var
upvar #0 $var(form_id) form
HMextract_param $param name
set item $win.input_text,$var(tags)
set size 20; HMextract_param $param size
set maxlength 0; HMextract_param $param maxlength
entry $item -width $size -show $show
set value ""; HMextract_param $param value
$item insert 0 $value
HMwin_install $win $item
append form(reset) ";$item delete 0 end;$item insert 0 [list $value]"
lappend form(submit) [list $name "\[$item get]"]
if {$maxlength} {
bindtags $item "[bindtags $item] max$maxlength"
bind max$maxlength <KeyPress> "%W delete $maxlength end"
}
}
proc HMinput_password {win param} {
HMinput_text $win $param *
}
proc HMinput_checkbox {win param} {
upvar #0 HM$win var
upvar #0 $var(form_id) form
HMextract_param $param name
HMextract_param $param value
set variable $var(form_id)(check_$var(tags))
set item $win.input_checkbutton,$var(tags)
checkbutton $item -variable $variable -off {} -on $value -text " "
if {[HMextract_param $param checked]} {
$item select
append form(reset) ";$item select"
} else {
append form(reset) ";$item deselect"
}
HMwin_install $win $item
lappend form(submit) [list $name \$form(check_$var(tags))]
}
proc HMinput_radio {win param} {
upvar #0 HM$win var
upvar #0 $var(form_id) form
HMextract_param $param name
HMextract_param $param value
set first [expr {![info exists form(radio_$name)]}]
set variable $var(form_id)(radio_$name)
set variable $var(form_id)(radio_$name)
set item $win.input_radiobutton,$var(tags)
radiobutton $item -variable $variable -value $value -text " "
HMwin_install $win $item
if {$first || [HMextract_param $param checked]} {
$item select
append form(reset) ";$item select"
} else {
append form(reset) ";$item deselect"
}
}
proc HMinput_hidden {win param} {
upvar #0 HM$win var
upvar #0 $var(form_id) form
HMextract_param $param name
HMextract_param $param value
lappend form(submit) [list $name $value]
}
proc HMinput_image {win param} {
upvar #0 HM$win var
upvar #0 $var(form_id) form
HMextract_param $param name
set name
set item [HMtag_img $win $param {}]
$item configure -relief raised -bd 2 -bg blue
set submit $win.dummy_submit,$var(tags)
if {[winfo exists $submit]} {
destroy $submit
}
button $submit -takefocus 0
lappend form(submit_button) $submit
set form(submit_$submit) [list $name $name.\$form(X).\$form(Y)]
$item configure -takefocus 1
bind $item <FocusIn> "catch \{$win see $item\}"
bind $item <1> "$item configure -relief sunken"
bind $item <Return> "
set $var(form_id)(X) 0
set $var(form_id)(Y) 0
$submit invoke
"
bind $item <ButtonRelease-1> "
set $var(form_id)(X) %x
set $var(form_id)(Y) %y
$item configure -relief raised
$submit invoke
"
}
proc HMinput_reset {win param} {
upvar #0 HM$win var
upvar #0 $var(form_id) form
set value reset
HMextract_param $param value
set item $win.input_reset,$var(tags)
button $item -text [HMmap_esc $value]
HMwin_install $win $item
lappend form(reset_button) $item
}
proc HMinput_submit {win param} {
upvar #0 HM$win var
upvar #0 $var(form_id) form
HMextract_param $param name
set value submit
HMextract_param $param value
set item $win.input_submit,$var(tags)
button $item -text [HMmap_esc $value] -fg blue
HMwin_install $win $item
lappend form(submit_button) $item
catch {set form(submit_$item) [list $name $value]}
}
proc HMtag_select {win param text} {
upvar #0 HM$win var
upvar #0 $var(form_id) form
HMextract_param $param name
set size 5; HMextract_param $param size
set form(select_size) $size
set form(select_name) $name
set form(select_values) ""
if {[HMextract_param $param multiple]} {
set mode multiple
} else {
set mode single
}
set item $win.select,$var(tags)
frame $item
set form(select_frame) $item
listbox $item.list -selectmode $mode -width 0 -exportselection 0
HMwin_install $win $item
}
proc HMtag_option {win param text} {
upvar #0 HM$win var
upvar #0 $var(form_id) form
upvar $text data
set frame $form(select_frame)
if {[HMextract_param $param selected]} {
lappend form(select_default) [$form(select_frame).list size]
}
set value [string trimright $data " \n"]
$frame.list insert end $value
HMextract_param $param value
lappend form(select_values) $value
set data ""
}
proc HMtag_/select {win param text} {
upvar #0 HM$win var
upvar #0 $var(form_id) form
set frame $form(select_frame)
set size $form(select_size)
set items [$frame.list size]
append form(reset) ";$frame.list selection clear 0 $items"
if {[info exists form(select_default)]} {
foreach i $form(select_default) {
$frame.list selection set $i
append form(reset) ";$frame.list selection set $i"
}
} else {
$frame.list selection set 0
append form(reset) ";$frame.list selection set 0"
}
for {set i 0} {$i < $size} {incr i} {
set value [format {[expr {[%s selection includes %s] ? {%s} : {}}]} \
$frame.list $i [lindex $form(select_values) $i]]
lappend form(submit) [list $form(select_name) $value]
}
if {$size > 1 && $items <= $size} {
$frame.list configure -height $items
pack $frame.list
} elseif {$size > 1} {
scrollbar $frame.scroll -command "$frame.list yview" \
-orient v -takefocus 0
$frame.list configure -height $size \
-yscrollcommand "$frame.scroll set"
pack $frame.list $frame.scroll -side right -fill y
} else {
scrollbar $frame.scroll -command "$frame.list yview" \
-orient h -takefocus 0
$frame.list configure -height 1 \
-yscrollcommand "$frame.scroll set"
pack $frame.list $frame.scroll -side top -fill x
}
foreach i [array names form select_*] {
unset form($i)
}
}
proc HMtag_textarea {win param text} {
upvar #0 HM$win var
upvar #0 $var(form_id) form
upvar $text data
set rows 5; HMextract_param $param rows
set cols 30; HMextract_param $param cols
HMextract_param $param name
set item $win.textarea,$var(tags)
frame $item
text $item.text -width $cols -height $rows -wrap none \
-yscrollcommand "$item.scroll set" -padx 3 -pady 3
scrollbar $item.scroll -command "$item.text yview" -orient v
$item.text insert 1.0 $data
HMwin_install $win $item
pack $item.text $item.scroll -side right -fill y
lappend form(submit) [list $name "\[$item.text get 0.0 end]"]
append form(reset) ";$item.text delete 1.0 end; \
$item.text insert 1.0 [list $data]"
set data ""
}
proc HMwin_install {win item} {
upvar #0 HM$win var
$win window create $var(S_insert) -window $item -align bottom
$win tag add indent$var(level) $item
set focus [expr {[winfo class $item] != "Frame"}]
$item configure -takefocus $focus
bind $item <FocusIn> "$win see $item"
}
proc HMsubmit_button {win form_id param stuff} {
upvar #0 HM$win var
upvar #0 $form_id form
set query ""
foreach pair $stuff {
set value [subst [lindex $pair 1]]
if {$value != ""} {
set item [lindex $pair 0]
lappend query $item $value
}
}
HMsubmit_form $win $param $query
}
proc HMsubmit_form {win param query} {
set result ""
set sep ""
foreach i $query {
append result $sep [HMmap_reply $i]
if {$sep != "="} {set sep =} else {set sep &}
}
puts $result
}
set HMalphanumeric a-zA-Z0-9
for {set i 1} {$i <= 256} {incr i} {
set c [format %c $i]
if {![string match \[$HMalphanumeric\] $c]} {
set HMform_map($c) %[format %.2x $i]
}
}
array set HMform_map {
" " + \n %0d%0a
}
proc HMmap_reply {string} {
global HMform_map HMalphanumeric
regsub -all \[^$HMalphanumeric\] $string {$HMform_map(&)} string
regsub -all \n $string {\\n} string
regsub -all \t $string {\\t} string
regsub -all {[][{})\\]\)} $string {\\&} string
return [subst $string]
}
proc HMcgiDecode {data} {
set data [split $data "&="]
foreach i $data {
lappend result [cgiMap $i]
}
return $result
}
proc HMcgiMap {data} {
regsub -all {\+} $data " " data
if {[regexp % $data]} {
regsub -all {([][$\\])} $data {\\\1} data
regsub -all {%([0-9a-fA-F][0-9a-fA-F])} $data {[format %c 0x\1]} data
return [subst $data]
} else {
return $data
}
}
auto_load tkFocusOK
proc tkFocusOK w {
set code [catch {$w cget -takefocus} value]
if {($code == 0) && ($value != "")} {
if {$value == 0} {
return 0
} elseif {$value == 1} {
return 1
} else {
set value [uplevel #0 $value $w]
if {$value != ""} {
return $value
}
}
}
set code [catch {$w cget -state} value]
if {($code == 0) && ($value == "disabled")} {
return 0
}
regexp Key|Focus "[bind $w] [bind [winfo class $w]]"
}
set htmlHelpContents {
<UL>
<LI>
<A HREF="#about">1. About this document</A></LI>
<LI>
<A HREF="#introduction">2. Introduction</A></LI>
<LI>
<A HREF="#required">3. Required software</A></LI>
<LI>
<A HREF="#architecture">4. Architecture</A></LI>
<LI>
<A HREF="#core">5. Core</A></LI>
<UL>
<LI>
<A HREF="#userinterface">5.1. User interface</A></LI>
<UL>
<LI>
<A HREF="#draganddrop">5.1.1. Drag and drop</A></LI>
<UL>
<LI>
<A HREF="#dropsites">5.1.1.1. Drop sites</A></LI>
<LI>
<A HREF="#dragsites">5.1.1.2. Drag sites</A></LI>
</UL>
<LI>
<A HREF="#saving">5.1.2. Saving</A></LI>
</UL>
<LI>
<A HREF="#commandline">5.2. Command line</A></LI>
</UL>
<LI>
<A HREF="#modules">6. Modules</A></LI>
<UL>
<LI>
<A HREF="#source">6.1. Source</A></LI>
<UL>
<LI>
<A HREF="#namespace">6.1.1. Namespace</A></LI>
<LI>
<A HREF="#configuration">6.1.2. Configuration</A></LI>
<LI>
<A HREF="#variabledata">6.1.3. Variable data</A></LI>
</UL>
<LI>
<A HREF="#installation">6.2. Installation</A></LI>
</UL>
<LI>
<A HREF="#future">7. Future developments</A></LI>
<LI>
<A HREF="#misc">8. Miscellaneous information</A></LI>
</UL>
</BODY>
</HTML>
}
set htmlHelpData {
<BODY>
<HTML>
<H3>
<A NAME="about"></A>1. About this document</H3>
This document contains general information, reference information and examples
designed to help the user understand the moodss application and the programmer
write modules for it.
<H3>
<A NAME="introduction"></A>2. Introduction</H3>
Quite often, one needs to monitor changing data, whether it might come
from a system, such as the different processes running on a Unix server,
or from a network, such as the kind and volume of traffic that runs through
it.
<P>Most often, such data can be organized in a table with rows of information,
each column representing a different type of data. For example, in the
case of processes running on a system, rows might be sorted according to
their unique process identifier, and columns might represent such values
as CPU usage, memory usage, owner's name, time of creation, ...
<P>The software used to view this type of information comes in different
forms and shapes. Unix users might be familiar with the "top" application
which presents rows of process data as lines of text, whereas RMON (Remote
MONitoring) SNMP software usually uses multiple windows with graphical
displays, curves, pie charts, multiple configuration dialog boxes, even
3D visualization modules to present network traffic, connection matrices,
...
<P>In most cases, data comes from one or several tables. A common interface,
graphical with menus, drag'n'drop capability, table widgets, textual and
graphical data viewers such as multiple line graphs, bar and pie charts,
could be used. The user could then sort table rows, select one or more
cells, rows, columns, to launch viewers such as other tables, charts, ...
best suited to the way data should be presented. In effect, what is needed
is a spreadsheet that is capable of dealing with dynamically changing data.
<P>Moodss (Modular Object Oriented Dynamic SpreadSheet) is an attempt at
answering these needs. It is composed of a main part (the core) and an
unlimited number of modules, loaded as the application is launched, each
module interfacing to a specific type of data. The core is written in the
great Tcl language (at <A HREF="http://www.scriptics.com/">http://www.scriptics.com/</A>)
using object oriented techniques thanks to the stooop and scwoop packages
(at <A HREF="http://www.mygale.org/~jfontain/">http://www.mygale.org/~jfontain/</A>).
The module function is to describe the type of data that it is also in
charge of retrieving and formatting. Modules can be written in plain Tcl
or C and optionally use dynamically linked libraries written in the C language
(modules are packages in the Tcl sense).
<P>Modules are loaded when moodss is started. One or more modules can be
handled concurrently (starting with moodss version 3.0). This way, you
may monitor data coming from any number of heterogeneous sources. Module
names are specified in the command line and cannot be dynamically unloaded.
<P>Versions 4.0 and up add a dashboard functionality: the current configuration
(modules, viewers, poll time, windows sizes and placement, ...) can be
saved in a file at any time, for later reuse (see the -f (--file) command
line switch documentation).
<P>Versions 4.3 and up support asynchronous modules (no polling needed
as module data may change on its own). Note that any number of asynchronous
and regular (synchronous) modules can be simultaneously loaded.
<P>Since module data access is entirely customizable (through C code, Tcl,
HTTP, ...) and since several modules can be loaded at once, applications
for moodss become limitless. For example, comparing a remote database server
CPU load and a network load from a probe on the same graph becomes possible.
<P>As features are added to moodss, different ways of viewing data will
be made available while the modules will stay the same. The goal of moodss
is to become a nice feature packed generic way of viewing data. Moodss
can be used to monitor any type of data, since the simplest cases can fit
in a table with a single row.
<P>As moodss is written in Tcl and uses well supported extensions (Tktable
and BLT), it will run on most Tcl/Tk supported platforms: UNIX and Windows
(I do not know if Tktable and BLT are available for the MacIntosh). Some
modules may be specific to a platform, but the core is guaranteed to run
on them all.
<P>After reading and understanding this document, you should be able to
write your own modules in order to monitor the data that you are interested
in.
<P>Moodss is free software. You can redistribute it and/or modify it under
the terms described in the COPYRIGHT file or use the main window Help Copyright
menu for more information.
<H3>
<A NAME="required"></A>3. Required software</H3>
If you are using a Linux Redhat system (5.1 or above), then use the moodss
rpm file (available (starting with 4.4) at <A HREF="http://www.mygale.org/~jfontain/">http://www.mygale.org/~jfontain/</A>)
for installation. It includes all the required software (except Tcl/Tk
8.x, of course). If you want to work on the moodss source code, see below,
otherwise you can skip the rest of this section.
<P>For the current version (5.0), the following packages must be installed
before attempting to install moodss (make sure to check the INSTALL file
for the latest information):
<UL>
<LI>
Tcl/Tk version 8.0 or above (at <A HREF="http://sunscript.sun.com/">http://sunscript.sun.com/</A>)</LI>
<LI>
tkTable version 2.0 or above (at <A HREF="http://oprs.mchh.siemens.de/tcl/capp/tkTable/">http://oprs.mchh.siemens.de/tcl/capp/tkTable/</A>)<B>*</B></LI>
<LI>
the BLT library version 2.4 (at <A HREF="ftp://ftp.tcltk.com/pub/blt/">ftp://ftp.tcltk.com/pub/blt/</A>)<B>*</B></LI>
</UL>
<DIV ALIGN=right><B>*</B><I> many thanks to the authors for these great
packages</I></DIV>
<P><BR>The pie widgets, stooop and scwoop libraries are included in the
self contained <I>moodss</I> application file. Therefore, it is not required
to install the stooop, scwoop and tkpiechart packages, unless you want
to work on the moodss source code itself. However, should you want to get
more information on those extensions, you could find the latest versions:
<UL>
<LI>
stooop version 3.6.1 or above</LI>
<LI>
switched version 1.4 or above (included in the stooop distribution)</LI>
<LI>
scwoop version 2.5 or above</LI>
<LI>
tkpiechart version 5.2 or above</LI>
</UL>
all at <A HREF="http://www.mygale.org/~jfontain/">http://www.mygale.org/~jfontain/</A>.
<H3>
<A NAME="architecture"></A>4. Architecture</H3>
The moodss application is composed of the core software and one or several
modules. Modules are implemented as Tcl packages and thus usually comprise
a Tcl source file and a pkgIndex.tcl file as required by the Tcl package
implementation.
<P>The core will load one or more modules, whose names were passed as command
line parameters or come from a save file, and will start displaying module
data in one or more tables. The tables are then updated at the frequency
defined by the poll time, which the user may change, or asynchronously
for the relevant modules. For example, to launch moodss with the random
module, just type:
<PRE>$ wish moodss random</PRE>
All the module code and data are kept in a separate namespace. The module
data is stored is a single array including some configuration data used
when the module is loaded by the core, and variable data (displayed in
the application table and eventual graphical viewers). If a module is synchronous,
it must start updating its data when requested by the core. If a module
is asynchronous, its data may be updated at any time. The synchronous or
asynchronous nature is specified in the configuration data for the module.
<P>The initial data tables represent the first data views, from which cells
can be selected and when dropped through a drag'n'drop operation into a
graph, bar chart, pie chart, summary table or free text iconic site, result
in the creation of data viewers. In turn, these viewers can display more
table cells, which when dropped into the viewer, result in the creation
of corresponding data graph lines, chart bars, pie slices, table rows or
text cells.
<P>Any draggable data can be dropped in valid drop sites at any time. It
is thus possible to drag several data cells from any table or any viewer
into other ones, the trash, ... even if the data comes from different modules.
<P>All data viewers can be moved and resized at will with the help of a
simple internal window manager.
<P>The current configuration (loaded modules, tables and viewers coordinates
and sizes, poll time, main window size, ...) can be saved in a file at
any time, so that an identical dashboard can be relaunched at a later time.
<H3>
<A NAME="core"></A>5. Core</H3>
<H4>
<A NAME="userinterface"></A>5.1. User interface</H4>
Soon after the application launch, tabular data is displayed in one or
more tkTable widgets with automatic scroll bars, between the menu bar,
the drop sites with graphical viewers, summary table, free text and trash
icons and a message area, as one can see below:
<CENTER>
<P><IMG SRC="moodss1.jpg" ALT="moodss initial main window view" HEIGHT=358 WIDTH=408></CENTER>
<P>The message area is used to display status information, such as when
the data is being updated, and help information, as the user moves the
mouse pointer over sensitive areas, such as table column headers. Further
help is provided through widget tips (also known as balloons) when appropriate,
and of course the Help menu.
<P>The window title shows the name of the loaded module(s) along with the
poll time.
<P>The <I>File</I> menu contains the <I>Save</I>, <I>Save As</I> and <I>Exit</I>
menu entries, used to save the current configuration (modules and viewers),
or gracefully quit the moodss application.
<P>The <I>Options</I> menu (may not exist, see below) contains the <I>Poll
time</I> entry which when selected launches the corresponding dialog box,
as shown below:
<CENTER>
<P><IMG SRC="moodss2.jpg" ALT="poll time dialog box" HEIGHT=238 WIDTH=226></CENTER>
<P>The user can select a new poll time among the module choices from a
spin entry widget, or directly type in a new value, as long as it is not
smaller than the module minimum poll time, in which case a message dialog
box warns the user.
<P>When several modules are used, the minimum poll time is the greater
of the minimum poll times of all modules. The default poll time (used when
moodss is started) is the greater of the default poll times of all modules.
The available choices in the poll time dialog box is the combination of
all modules poll times.
<P>The <I>Poll time</I> menu entry is available only when needed, which
is not the case if all the loaded modules are asynchronous. If this case,
the <I>Options</I> menu itself is not displayed.
<P>Any data displayed in a table can be sorted at any time by simply clicking
on a column title. Clicking on the same column title again sorts the data
in opposite order, thus toggling between increasing and decreasing orders.
<BR>When sorting, the selected column is used as a reference, meaning that
all rows will be rearranged so that the selected column appears sorted,
with values either increasing or decreasing.
<BR>A little arrow indicator is placed to the right of the reference column
title label, pointing up or down depending on whether the sorting order
is decreasing or increasing.
<BR>Table columns can be interactively resized by holding the first mouse
button down on a column border. The mouse cursor is changed to an horizontal
double arrow on column borders to show this capability.
<P>Aside from the main tables, graphical and textual viewers can be created
for viewing table cell data behavior over time. Viewers can also be deleted,
data views (such as pie slices, curves, ...) can be added or removed from
existing viewers, ... These functions are all implemented using the drag
and drop functionality described below.
<P>Graphical viewers available at this time are BLT graph viewers (such
as can be seen below), side-by-side bars charts, overlapped bars charts
(only available when the BLT version 2.4 library is used), stacked bars
charts, 2D pie charts and 3D pie charts*.
<P>*<I>note: if you know of any other nice viewers (like 3D graphs) that
work with Tcl, please let me know so I can integrate them. Many thanks
in advance...</I>
<BR> 
<CENTER><TABLE COLS=2 WIDTH="100%" NOSAVE >
<TR ALIGN=CENTER VALIGN=CENTER NOSAVE>
<TD NOSAVE><IMG SRC="graph.jpg" ALT="graph viewer sample" HEIGHT=200 WIDTH=300></TD>
<TD><IMG SRC="overbar.jpg" ALT="overlap bar chart viewer sample" HEIGHT=200 WIDTH=300></TD>
</TR>
<TR ALIGN=CENTER VALIGN=CENTER NOSAVE>
<TD NOSAVE><IMG SRC="sidebar.jpg" ALT="side bar chart viewer sample" HEIGHT=200 WIDTH=300></TD>
<TD><IMG SRC="stackbar.jpg" ALT="stacked bar chart viewer sample" HEIGHT=200 WIDTH=300></TD>
</TR>
<TR ALIGN=CENTER VALIGN=CENTER NOSAVE>
<TD NOSAVE><IMG SRC="2dpie.jpg" ALT="2D pie chart viewer sample" HEIGHT=200 WIDTH=300></TD>
<TD><IMG SRC="3dpie.jpg" ALT="3D pie chart viewer sample" HEIGHT=200 WIDTH=300></TD>
</TR>
</TABLE></CENTER>
<CENTER><TABLE WIDTH="100%" NOSAVE >
<TR ALIGN=CENTER VALIGN=CENTER NOSAVE>
<TD WIDTH="58%" NOSAVE><IMG SRC="sumtable.jpg" ALT="summary table viewer sample" HEIGHT=200 WIDTH=350></TD>
<TD WIDTH="42%" NOSAVE><IMG SRC="freetext.jpg" ALT="free text viewer sample" HEIGHT=200 WIDTH=250></TD>
</TR>
</TABLE></CENTER>
<P>There are 2 textual viewers.
<BR>The summary table displays for each row the cell label, the current,
average, minimum and maximum values since the row was created.
<BR>The free text viewer is an editable Tcl text widget with any number
(including zero) of embedded data cell windows. Data cells can be inserted
one or several at a time through a simple drop, as with the other viewers.
New data cell windows are inserted at the current insertion cursor position.
Data cells can be deleted by selecting then dropping any number of them
into the trash drop site. They can also be deleted using the keyboard Delete
and Backspace keys, which also work on the regular text, as well as the
expected other key bindings. When dropping data cells, each data cell window
is preceded by a relevant label text for the cell, which can later be edited
at any time.
<P>Here is a screen shot of loaded <I>ps</I> and <I>cpustats</I> modules
with several graphical viewers:
<BR> 
<CENTER>
<H5>
<IMG SRC="moodss3.jpg" ALT="moodss window with graph data viewers" HEIGHT=611 WIDTH=578></H5></CENTER>
All data viewers can be moved and resized thanks to handling areas in the
data viewer borders. When moving the mouse pointer over these areas, the
mouse cursor changes to indicate the possible action. Corner handles allow
resizing in both X and Y axis. Handles in the middle of the sides allow
resizing in either the X or Y axis direction. All other areas can be used
for moving the data viewer as shown by the quadruple arrow cursor. Clicking
on any part of the border changes the stacking order: the viewer being
clicked on either goes below (eventually becomes hidden) the other viewers,
or becomes fully visible (on top, eventually hiding other viewers). When
moving or resizing, the message area displays the current coordinates or
size in real time as the mouse is being moved. Further description of this
small window manager functionality is useless, as it behaves like a basic
window manager (let me know if it does not).
<P>Here is another shot featuring a free text viewer with loaded <I>cpustats</I>
and <I>memstats</I> modules:
<CENTER>
<P><IMG SRC="moodss4.jpg" HEIGHT=475 WIDTH=467></CENTER>
<P>The <I>Help</I> menu contains <I>Global</I> help (actually launches
an embedded HTML viewer with this very document), <I>Modules</I> help which
displays all the loaded modules help texts, <I>Copyright</I> which displays
the GPL (Gnu General Public License) document, <I>Source Versions </I>which
display all the source code file names with their versions and <I>About</I>
general information entries.
<H5>
<A NAME="draganddrop"></A>5.1.1 Drag and drop</H5>
Drag and drop in moodss tries to behave as the now familiar Windows functionality
(no, it doesn't mean I am a Bill Gates fan, as they probably stole the
idea from somebody else anyway :^). For example, to create a graphical
plot, one must first select one or more data cells in a data table, hold
down the first mouse button (the left one for a right handed user) while
dragging over to the left-most icon below the menu bar (when dragging an
object, as the mouse pointer passes over possible drop sites, they are
highlighted with a thin black border for user feedback). Releasing the
mouse button at this time results in the creation of a BLT graph viewer.
<P>Only valid drop sites for the data being dragged are highlighted when
the mouse cursor passes over them, thus guaranteeing error free operations
(if there are no bugs, that is :).
<P>In summary, data cells can be dragged from any table or any viewer into
any viewer drop site icon, any viewer or the trash can.
<H6>
<A NAME="dropsites"></A>5.1.1.1. Drop sites</H6>
All icons right below the menu bar are valid drop sites for data cells
(several may be dropped at the same time). From left to right:
<UL>
<LI>
graph viewer with one or more data curves created at once</LI>
<LI>
side by side bar chart with one or more data bars created at once</LI>
<LI>
stacked bar chart with one or more data bars created at once</LI>
<LI>
2D pie chart with one or more data slices created at once</LI>
<LI>
3D pie chart with one or more data slices created at once</LI>
<LI>
summary table with one or more data rows created at once</LI>
<LI>
free text with one or more labelled data cell windows created at once</LI>
<LI>
object trash with one or more data viewer elements deleted at once</LI>
</UL>
For example, a graph viewer with 1 curve is created by dropping 1 data
cell into the graph viewer icon.
<P>Once a viewer exists, it also acts as a drop site for data cells, which
may be dragged from any table or other viewers. Dropping one or more cells
directly in the viewer results in corresponding lines, bars, slices or
rows being created and automatically updated. Each new graphical element
is assigned a new and different color.
<P>You may delete one or more viewer elements (graph lines, bar chart bars,
pie charts slices, summary table rows or free text cell window) from a
viewer by selecting them (using the first mouse button) through their labels.
Several elements can be selected by depressing the control key as the first
mouse button is pressed. The selection can also be extended by depressing
the shift key along with the first mouse button. The pie slices can also
be directly selected by clicking on the slices themselves.
<BR>Then dragging from the viewer to the trash drop site (the bullet hole)
on the upper right side of the main window and releasing the first mouse
button result in the corresponding viewer elements to be destroyed. If
there are no remaining elements, the viewer itself (graph, bar chart, pie
or summary table) is destroyed. The free text viewer can only be deleted
when completely emptied of any text and data cell window: it can then
be dropped into the trash.
<H6>
<A NAME="dragsites"></A>5.1.1.2. Drag sites</H6>
A table is obviously a drag site. One or more cells can be dragged at once
after selection, using the traditional single/shift/control mouse click
technique.
<P>Any viewer is also a drag site. It requires selecting one or more viewer
elements before initiating the drag operation from any selected element
in the viewer. If there are no selected elements, dragging is impossible:
the mouse cursor is not changed into the drag circular cursor.
<P>If a viewer contains no elements, then the viewer itself can be dragged
and dropped into the trash.
<H5>
<A NAME="saving"></A>5.1.2 Saving</H5>
The current application configuration (including existing data viewers)
can be saved in a file, which achieves a dashboard functionality.
<P>Once moodss has been launched with one or several modules and tables
have been moved, resized, viewers created, moved and resized, the current
configuration can be saved in a .moo file, and later reused by passing
the corresponding file name with the -f (--file) command line switch.
<P>For moodss version 4.0 and above, the following information is saved
in the file (which is human readable):
<UL>
<LI>
moodss version</LI>
<LI>
date and time</LI>
<LI>
application window size</LI>
<LI>
poll time</LI>
<LI>
modules</LI>
<LI>
tables positions and sizes</LI>
<LI>
viewers types, positions, sizes and specific data</LI>
</UL>
When using the <I>File Save</I> menu for the first time, and if a file
name was not specified in the command line, the file selector dialog box
appears so that the user may choose a file name (with a .moo extension).
<P>The <I>File Save As</I> menu behaves as expected, with the user always
having to choose a file name.
<P>Once a file name has been specified (either through the command line
or the file selector dialog box), that file name is reused whenever the
<I>File Save</I> menu is used. The <I>File Save As</I> menu may be used
at any time to change the file name.
<H4>
<A NAME="commandline"></A>5.2. Command line</H4>
Launching moodss is very simple: just pass one or more data module names
as parameters, as in:
<PRE>$ wish moodss random</PRE>
or, for 2 modules at once:
<PRE>$ wish moodss ps cpustats</PRE>
You may not specify the same module more than once in the command line.
<P>You may eventually specify a poll time in seconds using:
<PRE>$ wish moodss -p 25 random</PRE>
Note that when all the specified modules are asynchronous, the poll time
option specifies the preferred interval for graph viewers.
<P>Once saved through the File Save menus (for example in save.moo) , the
configuration can be retrieved using:
<PRE>$ wish moodss -f save.moo</PRE>
which would result in the same modules being loaded, the same viewers displayed
at the same positions and sizes, the same poll time being used, as well
at the same application window size.
<P>Command line options include:
<UL>
<LI>
<B>-f</B> (or <B>--file</B>): specifies a configuration file name (incompatible
with modules)</LI>
<LI>
<B>-h</B> (or <B>--help</B>): displays some help text and exits</LI>
<LI>
<B>-p</B> (or <B>--poll-time</B>): specifies a poll time in seconds</LI>
<LI>
<B>-r</B> (or <B>--read-only</B>): disable viewer creation, editing, ...</LI>
<LI>
<B>-S</B> (or <B>--static</B>): disable internal window manager sizing
and moving</LI>
<LI>
<B>--version</B>: outputs version information and exits</LI>
</UL>
<H3>
<A NAME="modules"></A>6. Modules</H3>
All examples are drawn from the <I>random</I> sample module.
<H4>
<A NAME="source"></A>6.1. source</H4>
Since a module is a package, it must have a name in the Tcl sense. For
example, at the beginning of the <I>random.tcl</I> file, one can find the
following statement:
<PRE>package provide random 1.1</PRE>
This line simply states that this is the <I>1.1</I> version of the <I>random</I>
package. Please note that the package name must also be used as the module
namespace name (see below).
<H5>
<A NAME="namespace"></A>6.1.1. namespace</H5>
All module procedures and data are kept in a specific namespace bearing
the module name. For example (from the <I>random.tcl</I> source file):
<PRE>namespace eval random {
array set data {
...
}
proc update {} {
...
}
}</PRE>
The update procedure is not needed when the module is asynchronous.
<H5>
<A NAME="configuration"></A>6.1.2. configuration</H5>
The module configuration defines the data table column headers, help information,
... This data never changes during the lifetime of the application.
<P>All the module configuration data is stored as array members of the
array named <I>data</I> within the module namespace. For example:
<PRE>namespace eval random {
array set data {
updates 0
0,label name 0,type ascii 0,message {user name}
1,label cpu 1,type real 1,message {cpu usage in percent}
2,label disk 2,type integer 2,message {disk usage in megabytes}
3,label command 3,type dictionary 3,message {most time consuming command}
pollTimes {10 5 20 30 60 120 300}
sort {1 decreasing}
indexColumns {0 3}
helpText {
This is a simple demonstration module ...
}
}
...
}</PRE>
The <I>updates</I> member is a counter used to keep track of the number
of times that the module data was updated, and is also used by the core
to detect when module data display should be updated (see <A HREF="#variabledata">variable
data</A> for more information).
<P>The <I>columns</I> member is obsolete and no longer used after and including
moodss version 3.5.
<P>The <I>n,label</I> members define the text to be displayed as column
titles. There must be as many <I>n,label</I> members as they are columns.
<BR>The <I>n,type</I> members define the type of the corresponding column
data. Valid types are simply those that the Tcl <I>lsort</I> command can
handle: <I>ascii</I>, <I>dictionary</I>, <I>integer</I> and <I>real</I>.
There must be as many <I>n,type</I> members as they are columns.
<BR>The <I>n,message</I> members define the text of the help message to
be displayed in the message area (see <A HREF="#architecture">User Interface</A>)
as the user moves the mouse pointer over column titles. It should be composed
of only a few words, just enough to actually help the user understand what
the column data means. There must be as many <I>n,message</I> members as
they are columns.
<BR>Note that column numbers start at 0.
<P>The <I>pollTimes</I> member is a list of valid poll times (in seconds)
for the module. The list is not ordered, as its first element represents
the default poll time value to be used when the moodss application starts.
This value may be overridden by a command line argument. The smallest value
in the list is used by the core as the lowest possible poll time and checked
against when the user enters a new value through the poll time dialog box.
The list must not be empty.
<BR>Note that the list is also used by moodss as a set of possible choices
in the dialog box used to set the new poll time. The user may still directly
input any value as long as it is greater than or equal to the minimum value.
<P>If the module is asynchronous (data can be updated at any time and not
in response to update procedure invocations (no polling required)), the
pollTimes member must be a single negative integer value representing the
preferred time interval for viewers that require one (only graphs at this
point). For example, if you wish graph viewers to have a display interval
of 10 seconds, use:
<PRE>namespace eval random {
array set data {
...
pollTimes -10
...
}
...
}</PRE>
In this case, the graph viewers time range (knowing that they feature 100
time points) would be 1000 seconds. I guess that the value that you should
specify as the pollTimes member should be the expected average update interval
for your asynchronous data. Note that the graphical viewers x axis always
display properly labelled absolute time ticks in any case.
<P>When several asynchronous modules are loaded with no synchronous modules,
the interval used for all relevant viewers is the average (in absolute
value) of all module intervals. For example, if you load 2 asynchronous
modules, one with a pollTimes member of -10 and the other of -20, then
a 15 seconds interval value is retained. Note that the interval can be
forced through the --poll-time command line argument.
<P>If at least one synchronous module is loaded concurrently with any number
of asynchronous modules, the actual application poll time (the one that
can be set with the then available poll time dialog box) is used.
<P>The <I>visibleColumns</I> member is an optional list that specifies
the table columns that should be displayed. If not specified, all the table
columns are visible.
<P>The <I>sort</I> list defines the index of the column which should be
initially used as a reference for sorting the data table rows, and in which
order (<I>increasing</I> or <I>decreasing</I>) the rows should be sorted.
The column index for sorting works like the <I>-index</I> Tcl <I>lsort</I>
command option, that is rows are sorted so that that specific column appears
sorted in the specified order. The specified column must be visible (see
<I>visibleColumns</I>
member documentation above).
<P>The <I>indexColumns</I> list specifies the columns required to uniquely
identify a row in the table. In database talk, it represents the table
key. To maintain backward compatibility, it is optional and defaults to
0, the leftmost column. The index columns are used when creating data viewer
elements: their label is built by concatenating the key value for the cell
row with the cell column title. The key value is the concatenation of the
index column values for the cell. When specified, all the columns in the
list must be visible (see <I>visibleColumns</I> member documentation above).
<P>The <I>helpText</I> member specifies a text of any length, to be displayed
when the user requests help information on the current module from within
the help menu.
<P>The views member is optional. If specified, it defines one or more views
to be used in place of the default view. One table will be displayed per
view. Each view is a list of array members, suitable as an argument to
an "array set" command. For each view, 2 members must be defined: <I>visibleColumns</I>
and <I>sort</I> (syntax and usage are identical to the default table members).
<P>For example, a recent <I>random</I> module configuration is as follows:
<PRE>array set data {
updates 0
0,label name 0,type ascii 0,message {user name}
1,label cpu 1,type real 1,message {cpu usage in percent}
2,label disk 2,type integer 2,message {disk usage in megabytes}
3,label memory 3,type integer 3,message {memory usage in kilobytes}
4,label command 4,type dictionary 4,message {command name}
pollTimes {10 5 20 30 60 120 300}
sort {1 decreasing}
indexColumns {0 4}
helpText {...}
views {
{visibleColumns {0 1 3 4} sort {1 decreasing}}
{visibleColumns {0 2 4} sort {2 decreasing}}
}
}</PRE>
In this case, data is presented in 2 tables: one for the CPU and memory
usage, the other for disk usage.
<H5>
<A NAME="variabledata"></A>6.1.3. variable data</H5>
The tabular data (variable data) that the module code must update is stored
in the same <I>data</I> array as the module configuration data.
<P>In case of a synchronous module, the core invokes the module <I>update</I>
procedure (which obviously must exist) when it is time to refresh the data
display (tables and eventually graphical viewers). At this time, the update
procedure may update the tabular data straight away (synchronous operation)
or launch a request for later data update (asynchronous operation).
<P>In case of an asynchronous module, variable data may be updated at any
time. The <I>update</I> procedure may not exist.
<P>For all module types, it actually does not matter when the data is updated.
The core will know that fresh data is available when the <I>updates</I>
array member is set (actually incremented as it also serves as a counter
for the number of updates so far).
<BR>It is the module programmer's responsibility to increment this counter
right after all tabular data has been updated.
<P>For example, retrieving information for the processes running on a machine
is a local operation that can be achieved in a reasonably small amount
of time. In such a case, data would be updated immediately and the <I>updates</I>
variable incremented at the same time.
<BR>But if the data has to be retrieved from across a network, waiting
for it to come back would cause a delay that the user would certainly notice,
as the application would not respond to mouse or keyboard input during
the whole time that it would take to fetch the whole data. In such cases,
it is easier to let the update procedure return immediately without setting
the <I>updates</I> variable, which would be incremented at a later time,
only when the data would become available. For example, when waiting for
data to come across a network connection, the Tcl <I>fileevent</I> command
could be used on a non blocking channel, where the script to be evaluated
when the channel becomes readable would increment the <I>updates</I> array
member.
<P>For example:
<PRE>namespace eval random {
...
proc update {} {
variable data
array set data "
0,0 john 0,1 1234 0,2 4567 0,3 cc
1,0 william 1,1 8901 1,2 2345 1,3 xedit
2,0 anny 2,1 6789 2,2 0123 2,3 ps
4,0 peter 4,1 4567 4,2 8901 4,3 ls
6,0 laura 6,1 2345 6,2 6789 6,3 emacs
3,0 robert 3,1 1234 3,2 5678 3,3 top
"
incr data(updates)
}
}</PRE>
The tabular data array index is the <I>row</I> number followed by the <I>column</I>
number separated by a <I>comma</I>. The column number must start from 0
up to the total number of columns minus 1 (no holes are allowed in the
column sequence).
<BR>The row number can take any integer value and be defined in any order,
as long as it is unique during the lifetime of the module data. If a new
row is created, it must take a value that was never used: the index of
a row that has disappeared cannot be reused. Row numbers need not be consecutive.
<P>When all rows (or only those table cells that have changed) have been
updated, the <I>updates</I> member array must be incremented so that the
core knows that it can update the table data display.
<P>The random module source code can be made to function asynchronously:
please look into the random.tcl file.
<H4>
<A NAME="installation"></A>6.2. installation</H4>
A module is a package in the Tcl sense. When writing a module, you must
then provide a <I>pkgIndex.tcl</I> file along with the module code file.
The <I>pkgIndex.tcl</I> file is very simple, as the following example shows:
<PRE>package ifneeded random 1.1 "source [file join $dir random.tcl]"</PRE>
The line above says that if the <I>random</I> package is needed, the Tcl
core should source the <I>random.tcl</I> module source code from the directory
where it was installed. <I>1.1</I> is the version number for the package.
<P>Modules can be installed at any valid place that the Tcl core allows
(look at the <I>pkg_mkIndex</I> manual page for more information).
<P>When you unpack moodss, you will find the sample modules in sub directories.
The current directory (.) is appended to the <I>auto_load</I> global list
variable so that sample modules can be found when moodss is run from the
unpacking directory.
<P>For example, if you unpacked moodss in <I>/home/joe/moodss-5.x/</I>,
you will find the random module package in <I>/home/joe/moodss-5.x/random/</I>
so that the following will work:
<PRE>$ cd /home/joe/moodss-5.x/
$ wish moodss random</PRE>
You can install your new modules in the default location: <I>/usr/local/lib/</I>
on Unix. For example, if you move the files in <I>/home/joe/moodss-4.x/random/</I>
to <I>/usr/local/lib/random/</I>, moodss (actually Tcl :) will still be
able to find the <I>random</I> module (again, look at the <I>pkg_mkIndex</I>
manual page for more information).
<P>Please take a look at the INSTALL file for the latest information on
how to install the moodss application itself.
<H3>
<A NAME="future"></A>7. Future developments</H3>
The following features will eventually be added to the core (also look
at the TODO file):
<UL>
<LI>
more Linux modules</LI>
<LI>
more data viewers</LI>
<LI>
table row and column selection</LI>
<LI>
writable table cells?</LI>
</UL>
I welcome any suggestion for new features that you may need in your specific
use of moodss.
<H3>
<A NAME="misc"></A>8. Miscellaneous information</H3>
For downloading Tcl software (such as stooop, scwoop, tkpiechart, ...),
visit my <A HREF="http://www.mygale.org/~jfontain/">web page</A>.
<P>Send your comments, complaints, ... to <A HREF="mailto:jfontain@mygale.org">Jean-Luc
Fontaine</A>.
</BODY>
</HTML>
}
set rcsId {$Id: html.tcl,v 1.15 1998/10/11 09:36:58 jfontain Exp $}
array set HMtag_map {
h1 {size 22 weight bold}
h2 {size 20 weight bold}
h3 {size 18 weight bold}
h4 {size 16 weight bold}
h5 {size 14 weight bold}
h6 {weight bold}
}
set HMtag_map(hmstart) {
family Helvetica weight medium style r size 12
Tcenter "" Tlink "" Tnowrap "" Tunderline "" list list
fill 1 indent "" counter 0 adjust 0
}
array set HMinsert_map {
h1 "\n\n" /h1 "\n\n" h2 "\n\n" /h2 "\n\n" h3 "\n\n" /h3 "\n\n" h4 "\n\n" /h4 "\n\n" h5 "\n\n" /h5 "\n\n" h6 "\n\n" /h6 "\n\n"
pre "\n\n" /pre "\n\n"
}
proc helpWindow {} {
global htmlHelpDataText
if {[winfo exists .topHelp]} {
wm deiconify .topHelp
raise .topHelp
return
}
toplevel .topHelp
wm title .topHelp {moodss: Global Help}
frame .topHelp.bound
set panes [new panner .topHelp -panes 2]
pack $widget::($panes,path) -fill both -expand 1
set contents [new scroll text $panner::($panes,frame1) -horizontal 0 -height 100 -width 400]
pack $widget::($contents,path) -fill both -expand 1
set widget [new scroll text $panner::($panes,frame2) -horizontal 0 -height 400]
pack $widget::($widget,path) -fill both -expand 1
bind .topHelp.bound <Destroy> "delete $widget $contents $panes"
set contentsText $composite::($contents,scrolled,path)
$contentsText configure -cursor watch
update idletasks
HMinit_win $contentsText
$contentsText configure -state normal
HMparse_html $::htmlHelpContents "HMrender $contentsText"
$contentsText configure -state disabled
HMset_state $contentsText -stop 1
set htmlHelpDataText $composite::($widget,scrolled,path)
$htmlHelpDataText configure -cursor watch
update idletasks
HMinit_win $htmlHelpDataText
$htmlHelpDataText configure -state normal
HMparse_html $::htmlHelpData "HMrender $htmlHelpDataText"
$htmlHelpDataText configure -state disabled
HMset_state $htmlHelpDataText -stop 1
focus $htmlHelpDataText
$htmlHelpDataText configure -cursor {}
$contentsText configure -cursor {}
update idletasks
}
proc HMlink_callback {widget reference} {
global htmlHelpDataText
if {![string match #* $reference]} return
HMgoto $htmlHelpDataText [string trimleft $reference #]
}
proc HMset_image {widget label source} {
pack propagate [winfo parent $label] 1
}
set rcsId {$Id: help.tcl,v 1.25 1998/10/11 09:32:49 jfontain Exp $}
namespace eval help {
variable nameAndVersion "
moodss: a Modular Object Oriented Dynamic SpreadSheet
version $::applicationVersion
"
variable description {
Copyright (C) 1997-98 Jean-Luc Fontaine. All rights reserved.
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.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
(see Copyright under the Help menu for more details)
jfontain@mygale.org
This software includes the Tcl HTML library developped by Sun Microsystems and made available under the following license terms:
Sun Microsystems, Inc. The following terms apply to all files associated with the software unless explicitly disclaimed in individual files.
The authors hereby grant permission to use, copy, modify, distribute, and license this software and its documentation for any purpose, provided that existing copyright notices are retained in all copies and that this notice is included verbatim in any distributions. No written agreement, license, or royalty fee is required for any of the authorized uses. Modifications to this software may be copyrighted by their authors and need not follow the licensing terms described here, provided that the new terms are clearly indicated on the first page of each file where they apply.
IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
RESTRICTED RIGHTS: Use, duplication or disclosure by the government is subject to the restrictions as set forth in subparagraph (c) (1) (ii) of the Rights in Technical Data and Computer Software Clause as DFARS 252.227-7013 and FAR 52.227-19.
}
variable copyright {
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.
You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
a. You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
b. You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
c. If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.
In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
a. Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
b. Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
c. Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.
10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
}
}
proc simpleTextDialogBox {title text} {
set dialog [new dialogBox . -buttons o -default o -title $title -x [winfo pointerx .] -y [winfo pointery .]]
set widget [new scroll text $widget::($dialog,path) -horizontal 0]
$composite::($widget,scrolled,path) insert end $text
$composite::($widget,scrolled,path) configure\
-state disabled -borderwidth 0 -font $font::(mediumNormal) -wrap word -height 20 -padx 10
bind $widget::($dialog,path) <Destroy> "catch {delete $widget}"
dialogBox::display $dialog $widget::($widget,path)
}
proc aboutDialogBox {} {
set dialog [new dialogBox . -buttons o -default o -title {moodss: About} -x [winfo pointerx .] -y [winfo pointery .]]
set frame [frame $widget::($dialog,path).frame]
set text [new scroll text $frame -horizontal 0]
$composite::($text,scrolled,path) insert end $help::description
$composite::($text,scrolled,path) configure\
-state disabled -borderwidth 0 -font $font::(mediumNormal) -wrap word -height 20 -padx 10
grid rowconfigure $frame 1 -weight 1
grid columnconfigure $frame 0 -weight 1
grid columnconfigure $frame 1 -weight 1
grid $widget::($text,path) -row 1 -column 0 -columnspan 2 -sticky nsew
grid [label $frame.icon -image [image create photo -data [dataGraph::iconData]]] -row 0 -column 0
grid [label $frame.name -text $help::nameAndVersion] -row 0 -column 1
bind $widget::($dialog,path) <Destroy> "catch {delete $text}"
dialogBox::display $dialog $frame
}
proc modulesHelpDialogBox {args} {
foreach module $args {
append text "$module module (version [package provide $module]):\n"
if {[catch {append text [set ${module}::data(helpText)]}]} {
append text "\nno help available\n"
}
append text \n
}
simpleTextDialogBox {moodss: Modules Help} $text
}
proc versionsDialogBox {} {
array set ::versionsData {
updates 0
0,label file 0,type ascii 0,message {source file name}
1,label version 1,type dictionary 1,message {version}
sort {0 increasing}
indexColumns 0
}
set row 0
foreach name [array names ::sourceVersion] {
set ::versionsData($row,0) $name
set ::versionsData($row,1) $::sourceVersion($name)
incr row
}
set dialog [new dialogBox .\
-buttons o -default o -title {moodss: Source Versions} -command {unset ::versionsData}\
-x [winfo pointerx .] -y [winfo pointery .]\
]
set table [new dataTable $widget::($dialog,path) -data ::versionsData]
incr ::versionsData(updates)
dialogBox::display $dialog $widget::($table,path)
}
set rcsId {$Id: drag.tcl,v 1.22 1998/10/11 20:40:42 jfontain Exp $}
class dragSite {
if {![info exists dragSite::(grabber)]} {
set dragSite::(grabber) $widget::([new frame . -background {} -width 0 -height 0 -cursor circle],path)
place $dragSite::(grabber) -x -32768 -y -32768
}
proc dragSite {this args} switched {$args} {
switched::complete $this
}
proc ~dragSite {this} {
variable ${this}provider
variable draggable
unset ${this}provider
catch {delete $dragSite::($this,bindings)}
catch {unset draggable($switched::($this,-path))}
}
proc options {this} {
return [list\
[list -data {} {}]\
[list -path {} {}]\
[list -validcommand {} {}]\
]
}
proc set-data {this value} {
proc unformatted {this format} {return $switched::($this,-data)}
provide $this {} "dragSite::unformatted $this"
}
proc set-path {this value} {
variable draggable
if {$switched::($this,complete)} {
error {option -path cannot be set dynamically}
}
if {![winfo exists $value]} {
error "invalid path: \"$value\""
}
if {[info exists draggable($value)]} {
error "path \"$value\" is already a drag site"
}
set draggable($value) {}
set dragSite::($this,bindings) [new bindings $value end]
bindings::set $dragSite::($this,bindings) <ButtonPress-1> "dragSite::hit $this %x %y %X %Y"
}
proc set-validcommand {this value} {}
proc provide {this format {command 0}} {
variable ${this}provider
switch $command {
0 {
return [set ${this}provider($format)]
}
{} {
unset ${this}provider($format)
}
default {
set ${this}provider($format) $command
}
}
}
proc hit {this xWidget yWidget xRoot yRoot} {
bindings::set $dragSite::($this,bindings) <Button1-Motion> {}
set command $switched::($this,-validcommand)
if {([string length $command]>0)&&![uplevel #0 $command $xWidget $yWidget]} return
set dragSite::(x) $xWidget
set dragSite::(y) $yWidget
set dragSite::(X) $xRoot
set dragSite::(Y) $yRoot
bindings::set $dragSite::($this,bindings) <Button1-Motion> "dragSite::start $this %X %Y"
}
proc start {this xRoot yRoot} {
variable ${this}provider
if {(abs($xRoot-$dragSite::(X))+abs($yRoot-$dragSite::(Y)))<5} return
grab $dragSite::(grabber)
update idletasks
set dragSite::(highlightFrame) [new toplevel . -background {} -highlightthickness 1 -highlightbackground black]
wm withdraw $widget::($dragSite::(highlightFrame),path)
wm overrideredirect $widget::($dragSite::(highlightFrame),path) 1
set dragSite::(dropRegions) [dropSite::regions [array names ${this}provider]]
set dragSite::(lastSite) 0
bind $dragSite::(grabber) <ButtonRelease-1> "dragSite::drop $this %X %Y"
bind $dragSite::(grabber) <Button1-Motion> "dragSite::track $this %X %Y"
}
proc framed {x y left top right bottom} {
return [expr {($x>=$left)&&($x<=$right)&&($y>=$top)&&($y<=$bottom)}]
}
proc dropSite {xRoot yRoot} {
foreach region $dragSite::(dropRegions) {
if {[framed $xRoot $yRoot [lindex $region 1] [lindex $region 2] [lindex $region 3] [lindex $region 4]]} {
return [lindex $region 0]
}
}
return 0
}
proc track {this xRoot yRoot} {
set site [dropSite $xRoot $yRoot]
if {$site==$dragSite::(lastSite)} {
return
} elseif {($site==0)||([string compare $switched::($site,-path) $switched::($this,-path)]==0)} {
wm withdraw $widget::($dragSite::(highlightFrame),path)
} else {
set frame $widget::($dragSite::(highlightFrame),path)
wm withdraw $frame
set path $switched::($site,-path)
$frame configure -width [expr {[winfo width $path]+2}] -height [expr {[winfo height $path]+2}]
showTopLevel $frame +[expr {[winfo rootx $path]-1}]+[expr {[winfo rooty $path]-1}]
}
set dragSite::(lastSite) $site
}
proc drop {this xRoot yRoot} {
variable ${this}provider
variable data
bind $dragSite::(grabber) <ButtonRelease-1> {}
bind $dragSite::(grabber) <Button1-Motion> {}
grab release $dragSite::(grabber)
update idletasks
delete $dragSite::(highlightFrame)
unset dragSite::(lastSite)
set site [dropSite $xRoot $yRoot]
unset dragSite::(dropRegions)
if {($site==0)||($site==$this)} return
foreach format [switched::cget $site -formats] {
if {[catch {set command [set ${this}provider($format)]}]} continue
set data($format) [uplevel #0 $command [list $format]]
}
unset dragSite::(x) dragSite::(y) dragSite::(X) dragSite::(Y)
dropSite::dropped $site
unset data
}
}
set rcsId {$Id: drop.tcl,v 1.11 1998/10/09 19:35:44 jfontain Exp $}
class dropSite {
set dropSite::(list) {}
proc dropSite {this args} switched {$args} {
lappend dropSite::(list) $this
switched::complete $this
}
proc ~dropSite {this} {
set index [lsearch -exact $dropSite::(list) $this]
set dropSite::(list) [lreplace $dropSite::(list) $index $index]
catch {delete $dropSite::($this,bindings)}
}
proc options {this} {
return [list\
[list -command {} {}]\
[list -formats {{}} {{}}]\
[list -path {} {}]\
]
}
proc set-command {this value} {}
proc set-formats {this value} {}
proc set-path {this value} {
if {$switched::($this,complete)} {
error {option -path cannot be set dynamically}
}
if {![winfo exists $value]} {
error "invalid widget: \"$value\""
}
set dropSite::($this,bindings) [new bindings $value end]
set dropSite::($this,visible) 1
bindings::set $dropSite::($this,bindings) <Visibility>\
"set dropSite::($this,visible) \[string compare %s VisibilityFullyObscured\]"
}
proc dropped {this} {
if {[string length $switched::($this,-command)]>0} {
uplevel #0 $switched::($this,-command)
}
}
proc regions {formats} {
set regions {}
foreach site $dropSite::(list) {
if {[catch {winfo viewable $switched::($site,-path)} viewable]} continue
if {!$viewable||!$dropSite::($site,visible)} continue
foreach format $switched::($site,-formats) {
if {[lsearch -exact $formats $format]>=0} {
set path $switched::($site,-path)
set x [winfo rootx $path]; set y [winfo rooty $path]
lappend regions [list $site $x $y [expr {$x+[winfo width $path]}] [expr {$y+[winfo height $path]}]]
break
}
}
}
return $regions
}
}
set rcsId {$Id: canvhand.tcl,v 1.18 1998/07/11 09:56:54 jfontain Exp $}
class canvasWindowManager {
class handles {
proc handles {this parentPath args} composite {[new frame $parentPath] $args} {
if {[string compare [winfo class $parentPath] Canvas]!=0} {
error "parent must be the manager canvas"
}
set ($this,item) [$parentPath create window 0 0 -window $widget::($this,path) -anchor nw]
set ($this,canvas) $parentPath
composite::complete $this
}
proc ~handles {this} {
[set ($this,canvas)] delete [set ($this,item)] outline
catch {delete [set ($this,bindings)]}
}
proc options {this} {
return [list\
[list\
-background background Background\
$widget::(default,ButtonBackgroundColor) $widget::(default,ButtonBackgroundColor)\
]\
[list -borderwidth borderWidth BorderWidth 3]\
[list -handlesize handleSize HandleSize 7 7]\
[list -path path Path {} {}]\
[list -relief relief Relief ridge]\
[list -setheight setHeight SetHeight {} {}]\
[list -setwidth setWidth SetWidth {} {}]\
[list -setx setX SetX 0 0]\
[list -sety setY SetY 0 0]\
[list -static static Static 0]\
]
}
proc set-handlesize {this value} {
resize $this [winfo width $widget::($this,path)] [winfo height $widget::($this,path)]
}
proc set-path {this value} {
if {![winfo exists $value]} {
error "invalid widget: \"$value\""
}
set path $widget::($this,path)
catch {eval pack forget [pack slaves $path]}
catch {delete [set ($this,bindings)]}
set ($this,bindings) [new bindings $value end]
bindings::set [set ($this,bindings)] <Visibility>\
"set canvasWindowManager::handles::($this,partiallyObscured) \[string compare %s VisibilityUnobscured\]"
raise $value $path
pack $value -in $path -fill both -expand 1
}
foreach option {-background -relief -borderwidth} {
proc set$option {this value} "\$widget::(\$this,path) configure $option \$value"
}
proc set-setheight {this value} {
[set ($this,canvas)] itemconfigure [set ($this,item)] -height $value
}
proc set-setwidth {this value} {
[set ($this,canvas)] itemconfigure [set ($this,item)] -width $value
}
proc set-setx {this value} {
[set ($this,canvas)] coords [set ($this,item)] $value [lindex [[set ($this,canvas)] coords [set ($this,item)]] end]
}
proc set-sety {this value} {
[set ($this,canvas)] coords [set ($this,item)] [lindex [[set ($this,canvas)] coords [set ($this,item)]] 0] $value
}
proc set-static {this value} {
set path $widget::($this,path)
if {$value} {
bind $path <Configure> {}
bind $path <Motion> {}
bind $path <Enter> {}
bind $path <Button1-Motion> {}
bind $path <ButtonPress-1> {}
bind $path <ButtonRelease-1> "canvasWindowManager::handles::toggleVisibility $this"
$path configure -cursor arrow
} else {
bind $path <Configure> "canvasWindowManager::handles::resize $this %w %h"
bind $path <Motion> "canvasWindowManager::handles::setCursor $this %x %y"
bind $path <Enter> "canvasWindowManager::handles::setCursor $this %x %y"
bind $path <Button1-Motion> "canvasWindowManager::handles::buttonMotion $this %x %y"
bind $path <ButtonPress-1> "canvasWindowManager::handles::buttonPress $this %x %y"
bind $path <ButtonRelease-1> "canvasWindowManager::handles::buttonRelease $this"
}
}
proc buttonMotion {this x y} {
set (motion) {}
updateOutline $this $x $y
}
proc buttonPress {this x y} {
set canvasWindowManager::handles::(xLast) $x
set canvasWindowManager::handles::(yLast) $y
lifoLabel::push $::messenger {}
createOutline $this
}
proc toggleVisibility {this} {
if {[set ($this,partiallyObscured)]} {
raise $widget::($this,path)
} else {
lower $widget::($this,path)
}
catch {raise $composite::($this,-path) $widget::($this,path)}
}
proc buttonRelease {this} {
lifoLabel::pop $::messenger
if {[info exists (motion)]} {
updateGeometry $this
raise $widget::($this,path)
catch {raise $composite::($this,-path) $widget::($this,path)}
unset (motion)
} else {
toggleVisibility $this
}
destroyOutline $this
unset (xLast) (yLast) (hidden)
}
proc resize {this width height} {
set size [maximum $composite::($this,-handlesize) $composite::($this,-borderwidth)]
set halfHeight [expr {($height/2)}]
set ($this,topHandleBottom) [minimum $size $halfHeight]
set ($this,bottomHandleTop) [expr {$height-[set ($this,topHandleBottom)]}]
set ($this,midHandleTop) [maximum [expr {$height/3}] [expr {[set ($this,topHandleBottom)]+$size}]]
set ($this,midHandleBottom) [minimum [expr {(2*$height)/3}] [expr {[set ($this,bottomHandleTop)]-$size}]]
set halfWidth [expr {($width/2)}]
set ($this,leftHandleRight) [minimum $size $halfWidth]
set ($this,rightHandleLeft) [expr {$width-[set ($this,leftHandleRight)]}]
set ($this,midHandleLeft) [maximum [expr {$width/3}] [expr {[set ($this,leftHandleRight)]+$size}]]
set ($this,midHandleRight) [minimum [expr {(2*$width)/3}] [expr {[set ($this,rightHandleLeft)]-$size}]]
}
proc setCursor {this x y} {
if {[info exists (motion)]} {
return
}
set border $composite::($this,-borderwidth)
set path $widget::($this,path)
set cursor fleur
set direction {}
if {$x<$border} {
set side left
set direction w
} elseif {$x>=([winfo width $path]-$border)} {
set side right
set direction e
}
if {[info exists side]} {
if {$y<[set ($this,topHandleBottom)]} {
set cursor top_${side}_corner
append direction n
} elseif {$y>[set ($this,bottomHandleTop)]} {
set cursor bottom_${side}_corner
append direction s
} elseif {($y>[set ($this,midHandleTop)])&&($y<[set ($this,midHandleBottom)])} {
set cursor ${side}_side
} else {
set cursor fleur
set direction {}
}
} else {
if {$y<$border} {
set side top
set direction n
} elseif {$y>=([winfo height $path]-$border)} {
set side bottom
set direction s
}
if {[info exists side]} {
if {$x<[set ($this,leftHandleRight)]} {
set cursor ${side}_left_corner
append direction w
} elseif {$x>[set ($this,rightHandleLeft)]} {
set cursor ${side}_right_corner
append direction e
} elseif {($x>[set ($this,midHandleLeft)])&&($x<[set ($this,midHandleRight)])} {
set cursor ${side}_side
} else {
set cursor fleur
set direction {}
}
}
}
if {[string compare $cursor [$widget::($this,path) cget -cursor]]!=0} {
$widget::($this,path) configure -cursor $cursor
update idletasks
}
set ($this,direction) $direction
}
proc updateOutline {this x y} {
lifoLabel::pop $::messenger
if {[set (hidden)]} {
positionOutlineInStackingOrder $this raise
}
set canvas [set ($this,canvas)]
set coordinates [$canvas coords [set ($this,item)]]
set xFrame [lindex $coordinates 0]
set yFrame [lindex $coordinates 1]
if {($xFrame+$x)<0} {
set x [expr {-$xFrame}]
}
if {($yFrame+$y)<0} {
set y [expr {-$yFrame}]
}
set width [winfo width $canvas]
if {($xFrame+$x)>=$width} {
set x [expr {$width-$xFrame-1}]
}
set height [winfo height $canvas]
if {($yFrame+$y)>=$height} {
set y [expr {$height-$yFrame-1}]
}
if {[string length [set ($this,direction)]]==0} {
$canvas move outline [expr {$x-[set (xLast)]}] [expr {$y-[set (yLast)]}]
lifoLabel::push $::messenger [$canvas coords outline]
set canvasWindowManager::handles::(xLast) $x
set canvasWindowManager::handles::(yLast) $y
return
}
set width [winfo width $widget::($this,path)]
set height [winfo height $widget::($this,path)]
switch [set ($this,direction)] {
nw - wn {
displayOutline $this [expr {$xFrame+$x}] [expr {$yFrame+$y}] [expr {$width-$x}] [expr {$height-$y}]
}
n {
displayOutline $this $xFrame [expr {$yFrame+$y}] $width [expr {$height-$y}]
}
ne - en {
displayOutline $this $xFrame [expr {$yFrame+$y}] $x [expr {$height-$y}]
}
e {
displayOutline $this $xFrame $yFrame $x $height
}
se - es {
displayOutline $this $xFrame $yFrame $x $y
}
s {
displayOutline $this $xFrame $yFrame $width $y
}
sw - ws {
displayOutline $this [expr {$xFrame+$x}] $yFrame [expr {$width-$x}] $y
}
w {
displayOutline $this [expr {$xFrame+$x}] $yFrame [expr {$width-$x}] $height
}
}
}
proc createOutline {this} {
set canvas [set ($this,canvas)]
foreach side {top bottom left right} {
set frame $widget::([new frame $canvas -background black],path)
set ($side,item) [$canvas create window 0 0 -window $frame -width 0 -height 0 -anchor nw -tags outline]
}
positionOutlineInStackingOrder $this lower
eval displayOutline $this [$canvas coords [set ($this,item)]]\
[winfo width $widget::($this,path)] [winfo height $widget::($this,path)]
}
proc positionOutlineInStackingOrder {this order} {
set canvas [set ($this,canvas)]
foreach side {top bottom left right} {
$order [$canvas itemcget [set ($side,item)] -window]
}
set (hidden) [string compare $order raise]
}
proc displayOutline {this x y width height} {
lifoLabel::push $::messenger "$width x $height"
set minimum [expr {(2*$composite::($this,-borderwidth))+1}]
set width [maximum $minimum $width]
set height [maximum $minimum $height]
set canvas [set ($this,canvas)]
$canvas coords [set (top,item)] $x $y
$canvas coords [set (bottom,item)] $x [expr {$y+$height-1}]
$canvas coords [set (left,item)] $x $y
$canvas coords [set (right,item)] [expr {$x+$width-1}] $y
$canvas itemconfigure [set (top,item)] -width $width
$canvas itemconfigure [set (bottom,item)] -width $width
$canvas itemconfigure [set (left,item)] -height $height
$canvas itemconfigure [set (right,item)] -height $height
}
proc destroyOutline {this} {
set canvas [set ($this,canvas)]
foreach side {top bottom left right} {
destroy [$canvas itemcget [set ($side,item)] -window]
unset ($side,item)
}
$canvas delete outline
}
proc updateGeometry {this} {
set canvas [set ($this,canvas)]
eval $canvas coords [set ($this,item)] [$canvas coords outline]
$canvas itemconfigure [set ($this,item)] -width [$canvas itemcget [set (top,item)] -width]\
-height [$canvas itemcget [set (left,item)] -height]
}
proc getGeometry {this} {
set canvas [set ($this,canvas)]
return [concat\
[[set ($this,canvas)] coords [set ($this,item)]]\
[winfo width $widget::($this,path)] [winfo height $widget::($this,path)]\
]
}
}
}
set rcsId {$Id: canvaswm.tcl,v 1.2 1998/07/11 19:06:36 jfontain Exp $}
class canvasWindowManager {
proc canvasWindowManager {this canvas} {
set canvasWindowManager::($this,canvas) $canvas
}
proc ~canvasWindowManager {this} {
variable ${this}handle
foreach path [array names ${this}handle] {
delete [set ${this}handle($path)]
}
catch {unset ${this}handle}
}
proc manage {this path} {
variable ${this}handle
set ${this}handle($path) [new handles $canvasWindowManager::($this,canvas) -path $path]
}
proc unmanage {this path} {
variable ${this}handle
delete [set ${this}handle($path)]
unset ${this}handle($path)
}
proc configure {this path args} {
variable ${this}handle
eval composite::configure [set ${this}handle($path)] $args
}
proc getGeometry {this path} {
variable ${this}handle
return [handles::getGeometry [set ${this}handle($path)]]
}
}
proc updateTitle {} {
global pollTimes pollTime modules
if {[llength $pollTimes]==0} {
wm title . "moodss: $modules(all,string) data (asynchronous)"
} else {
wm title . "moodss: $modules(all,string) data (every $pollTime seconds)"
}
}
proc createMenuWidget {parentPath readOnly includePollTime} {
global modules
set menu [menu $parentPath.menu -tearoff 0]
$menu add cascade -label File -menu [menu $menu.file -tearoff 0] -underline 0
if {!$readOnly} {
$menu.file add command -label Save -command {save 0} -underline 1 -accelerator Alt+S
bind $parentPath <Alt-s> {save 0}
$menu.file add command -label {Save As...} -command {save 1} -underline 6 -accelerator Alt+A
bind $parentPath <Alt-a> {save 1}
}
$menu.file add command -label Exit -command exit -underline 1 -accelerator Alt+X
bind $parentPath <Alt-x> exit
if {!$readOnly&&$includePollTime} {
$menu add cascade -label Options -menu [menu $menu.options -tearoff 0] -underline 0
$menu.options add command -label {Poll Time...} -command inquirePollTime -underline 0
}
$menu add cascade -label Help -menu [menu $menu.help -tearoff 0] -underline 0
$menu.help add command -label Global... -underline 0 -accelerator F1 -command helpWindow
bind $parentPath <F1> helpWindow
$menu.help add command -label Modules... -underline 0 -command "modulesHelpDialogBox $modules(all)"
$menu.help add command -label Copyright... -underline 0 -command {simpleTextDialogBox {moodss: Copyright} $help::copyright}
$menu.help add command -label {Source Versions...} -underline 0 -command versionsDialogBox
$menu.help add command -label About... -underline 0 -command aboutDialogBox
$parentPath configure -menu $menu
}
proc createMessageWidget {parentPath} {
global messenger
set messenger [new lifoLabel $parentPath -headerfont $font::(mediumBold) -font $font::(mediumNormal)]
return $widget::($messenger,path)
}
proc createCellsViewer {class cells draggable static {pollTime {}}} {
global canvas windowManager
set viewer [new $class $canvas -draggable $draggable]
set path $widget::($viewer,path)
if {[string length $pollTime]>0} {
composite::configure $viewer -interval $pollTime
}
canvasWindowManager::manage $windowManager $path
composite::configure $viewer -deletecommand "canvasWindowManager::unmanage $windowManager $path"
canvasWindowManager::configure $windowManager $path -static $static
viewer::view $viewer $cells
return $viewer
}
proc createDragAndDropZone {parentPath} {
global canvas pollTime static
set frame [frame $parentPath.drops]
set label [label $frame.graph -image [image create photo -data [dataGraph::iconData]]]
pack $label -pady 1 -side left
new dropSite -path $label -formats DATACELLS\
-command "createCellsViewer dataGraph \$dragSite::data(DATACELLS) 1 $static \$pollTime"
new widgetTip -path $label -text {graph drop site}
if {$::officialBLT} {
set label [label $frame.overlapBarChart -image [image create photo -data [dataOverlapBarChart::iconData]]]
pack $label -pady 1 -side left
new dropSite -path $label -formats DATACELLS\
-command "createCellsViewer dataOverlapBarChart \$dragSite::data(DATACELLS) 1 $static"
new widgetTip -path $label -text {overlap bar chart drop site}
}
set label [label $frame.sideBarChart -image [image create photo -data [dataSideBarChart::iconData]]]
pack $label -pady 1 -side left
new dropSite -path $label -formats DATACELLS -command "createCellsViewer dataSideBarChart \$dragSite::data(DATACELLS) 1 $static"
new widgetTip -path $label -text {side bar chart drop site}
set label [label $frame.stackedBarChart -image [image create photo -data [dataStackedBarChart::iconData]]]
pack $label -pady 1 -side left
new dropSite -path $label -formats DATACELLS\
-command "createCellsViewer dataStackedBarChart \$dragSite::data(DATACELLS) 1 $static"
new widgetTip -path $label -text {stacked bar chart drop site}
set label [label $frame.2DPieChart -image [image create photo -data [data2DPieChart::iconData]]]
pack $label -pady 1 -side left
new dropSite -path $label -formats DATACELLS -command "createCellsViewer data2DPieChart \$dragSite::data(DATACELLS) 1 $static"
new widgetTip -path $label -text {2D pie chart drop site}
set label [label $frame.3DPieChart -image [image create photo -data [data3DPieChart::iconData]]]
pack $label -pady 1 -side left
new dropSite -path $label -formats DATACELLS -command "createCellsViewer data3DPieChart \$dragSite::data(DATACELLS) 1 $static"
new widgetTip -path $label -text {3D pie chart drop site}
set label [label $frame.summaryTable -image [image create photo -data [summaryTable::iconData]]]
pack $label -pady 1 -side left
new dropSite -path $label -formats DATACELLS -command "createCellsViewer summaryTable \$dragSite::data(DATACELLS) 1 $static"
new widgetTip -path $label -text {summary table drop site}
set label [label $frame.freeText -image [image create photo -data [freeText::iconData]]]
pack $label -pady 1 -side left
new dropSite -path $label -formats DATACELLS -command "createCellsViewer freeText \$dragSite::data(DATACELLS) 1 $static"
new widgetTip -path $label -text {free text drop site}
set trashData {
R0lGODlhKAAoAKUAAP8A/8/Lz+/r71FRUZ6anpaSlv/7/wgICL66vkFBQYaChtfT17LA3LaytjAwMFlZWZaant/b3/fz96aipnFxcWlpaWFhYTAoKCAgICgo
KOfj576yvklJSRAQEBAQCI6Slq6yrp6SnhgYGAAAAI6KjoaKhnl5ecfDx66ipiAoIOfr5ygwMJ6Slnlxce/j5zg4OL7Dx6aint/T38fLz4Z5hvf7/8/Tz66q
tqairv/z939/f/fz79fLz0lRUXmChllRUSH5BAEAAAAALAAAAAAoACgAAAb+QIBwSBwGisikckkUDAhMYiEaNQwO06ggS00iDIXEQcFcLA5dpUDAaCgch8GD
DIVEDJJJIp2URBQUFQoWCRcYGRkGihoBCnt8RQYbDxwZhx0eBwcYHyAMIRMDDpBEEwYPGBgiHSOtrh0PJCVhGaRDCw0JHq68vAkDJh0cfBIEHAoNGb3LvR0O
DlBDJwsTSHcnBRaszNytAxMaa4oGJyRCAn4LBggMBAfd8BwQCxL1AiiPAOrjDRMU8PBSUDghIJyKFcOEBDAQIMKJCQqUAeQW54QEDREKjOACQIOGAhQ4iJgY
0KIAFgcoFFlIgoKDXSS7UZAggIKIJAJCtFjxLib+NwcuNLwYkARGDAovevpchkFGhBFLEJhIupTbDA2jlBho8K/qsg400CzJ80Cp11Ydhi6JEIBEgm1nW2Hg
kBDJFwQVHGCI6wqRWGs1ClRIMJLviAQmoCbBY4LDi1R8LUSwYSJJAAE3OhzogDBuBgISYNRCouFEhgHmAFCAWbUCugkvcKLCMYREA7MxNRjQMCFrkRMYog0x
UCGFzwMcDORYMImYBhYJJHbTgUPGDow8eORKI2AHAkeqzB54QYG6ABkCFgSYESDACOFM0GGr8MCCBQo9FJgowAAHjjUCGODCAjxE0EAHFnSh2wkfkOADDSGw
oIA/CTgwgH8MKKCAAC5S8MBAASLkw8QJBsgwAQEk0PBDYX4dgAMCrfg2AUqjUaGCAQsgQMIKRCHxT4K2EEEAOjZYIAJHRKQWJBEgCJCDkUtCgoJRHkQJCQkW
bGTllrYEAQA7
}
set label [label $frame.trash -image [image create photo -data $trashData]]
pack $label -pady 1 -side right
new dropSite -path $label -formats OBJECTS -command "eval delete \$dragSite::data(OBJECTS)"
new widgetTip -path $label -text {objects trash drop site}
return $frame
}
proc inquirePollTime {} {
global pollTimes pollTime
set dialog\
[new dialogBox . -buttons oc -default o -title {moodss: Poll Time} -die 0 -x [winfo pointerx .] -y [winfo pointery .]]
set frame [frame $widget::($dialog,path).frame]
set minimum [lindex $pollTimes 0]
set message [message $frame.message\
-width [winfo screenwidth .] -font $font::(mediumNormal) -justify center\
-text "Please enter new poll time\n(greater than $minimum):"\
]
pack $message
set entry [new spinEntry $frame -width 4 -list $pollTimes -side right]
spinEntry::set $entry $pollTime
pack $widget::($entry,path) -anchor e -side left -expand 1 -padx 2
pack [label $frame.label -text seconds] -anchor w -side right -expand 1 -padx 2
dialogBox::display $dialog $frame
widget::configure $dialog -command "
set time \[spinEntry::get $entry\]
if {\$time<$minimum} {
bell
$message configure -text {Please enter new poll time\n(must be greater than $minimum):}
} else {
if {\$time!=\$pollTime} {
set pollTime \$time
viewer::updateInterval \$time
updateTitle
refresh
}
delete $dialog
}
"
bind $frame <Destroy> "delete $entry"
}
proc save {ask} {
global saveFile messenger
if {$ask||([string length $saveFile]==0)} {
set file [tk_getSaveFile\
-title {moodss: Save} -initialdir [pwd] -defaultextension .moo -filetypes {{{moodss data} .moo}} -initialfile $saveFile
]
if {[string length $file]==0} return
set saveFile $file
}
lifoLabel::flash $messenger "saving in $saveFile..."
set record [new record -file $saveFile]
record::write $record
delete $record
}
proc refresh {} {
global modules updateEvent messenger pollTime
catch {after cancel $updateEvent}
if {[llength $modules(synchronous)]==0} return
lifoLabel::push $messenger "launching $modules(synchronous,string) data update..."
update idletasks
foreach module $modules(synchronous) {
${module}::update
}
lifoLabel::pop $messenger
set updateEvent [after [expr {1000*$pollTime}] refresh]
}
createMenuWidget . $readOnly [llength $pollTimes]
pack [createMessageWidget .] -side bottom -fill x
updateTitle
set scroll [new scroll canvas .]
set canvas $composite::($scroll,scrolled,path)
set width [winfo screenwidth .]
set height [winfo screenheight .]
$canvas configure -background white -width $width -height $height -scrollregion [list 0 0 $width $height] -highlightthickness 0\
-takefocus 0
set windowManager [new canvasWindowManager $canvas]
if {[info exists initializer]} {
foreach {width height} [record::sizes $initializer] {}
} else {
set width 400
set height 300
}
wm geometry . ${width}x$height
if {!$readOnly} {
pack [createDragAndDropZone .] -fill x
}
pack $widget::($scroll,path) -fill both -expand 1
set draggable [expr {!$readOnly}]
set x 0
set y 0
foreach module $modules(all) {
upvar #0 ${module}::data data
if {[info exists data(views)]} {
set index 0
foreach members $data(views) {
array set view $members
set table [new dataTable $canvas -data ${module}::data -view ::view -draggable $draggable]
canvasWindowManager::manage $windowManager $widget::($table,path)
unset view
if {[info exists initializer]} {
foreach {x y width height} [record::tableGeometry $initializer $module $index] {}
canvasWindowManager::configure $windowManager $widget::($table,path)\
-setx $x -sety $y -setwidth $width -setheight $height
} else {
canvasWindowManager::configure $windowManager $widget::($table,path) -setx $x -sety $y
incr x $configuration::(xWindowManagerInitialOffset)
incr y $configuration::(yWindowManagerInitialOffset)
}
canvasWindowManager::configure $windowManager $widget::($table,path) -static $static
incr index
}
} else {
set table [new dataTable $canvas -data ${module}::data -draggable $draggable]
canvasWindowManager::manage $windowManager $widget::($table,path)
if {[info exists initializer]} {
foreach {x y width height} [record::tableGeometry $initializer $module] {}
canvasWindowManager::configure $windowManager $widget::($table,path)\
-setx $x -sety $y -setwidth $width -setheight $height
} else {
canvasWindowManager::configure $windowManager $widget::($table,path) -setx $x -sety $y
incr x $configuration::(xWindowManagerInitialOffset)
incr y $configuration::(yWindowManagerInitialOffset)
}
canvasWindowManager::configure $windowManager $widget::($table,path) -static $static
}
}
refresh
if {[info exists initializer]} {
foreach {class cells x y width height switchedOptions} [record::viewersData $initializer] {
set viewer [eval new $class $canvas $switchedOptions -draggable $draggable]
canvasWindowManager::manage $windowManager $widget::($viewer,path)
viewer::view $viewer $cells
canvasWindowManager::configure $windowManager $widget::($viewer,path)\
-setx $x -sety $y -setwidth $width -setheight $height -static $static
}
}
|