/usr/share/tcltk/iwidgets4.0.1/scripts/scrolledhtml.itk is in iwidgets4 4.0.1-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | # Scrolledhtml
# ----------------------------------------------------------------------
# Implements a scrolled html text widget by inheritance from scrolledtext
# Import reads from an html file, while export still writes plain text
# Also provides a render command, to display html text passed in as an
# argument.
#
# This widget is HTML3.2 compliant, with the following exceptions:
# a) nothing requiring a connection to an HTTP server is supported
# b) some of the image alignments aren't supported, because they're not
# supported by the text widget
# c) the br attributes that go with the image alignments aren't implemented
# d) background images are not supported, because they're not supported
# by the text widget
# e) automatic table/table cell sizing doesn't work very well.
#
# WISH LIST:
# This section lists possible future enhancements.
#
# 1) size tables better using dlineinfo.
# 2) make images scroll smoothly off top like they do off bottom. (limitation
# of text widget?)
# 3) add ability to get non-local URLs
# a) support forms
# b) support imagemaps
# 4) keep track of visited links
# 5) add tclets support
#
# BUGS:
# Cells in a table can be caused to overlap. ex:
# <table border width="100%">
# <tr><td>cell1</td><td align=right rowspan=2>cell2</td></tr>
# <tr><td colspan=2>cell3 w/ overlap</td>
# </table>
# It hasn't been fixed because 1) it's a pain to fix, 2) the fix would slow
# tables down by a significant amount, and 3) netscape has the same
# bug, as of V3.01, and no one seems to care.
#
# In order to size tables properly, they must be visible, which causes an
# annoying jump from table to table through the document at render time.
#
# ----------------------------------------------------------------------
# AUTHOR: Kris Raney EMAIL: kraney@spd.dsccc.com
#
# @(#) $Id: scrolledhtml.itk,v 1.7 2002/02/16 05:11:08 mgbacke Exp $
# ----------------------------------------------------------------------
# Copyright (c) 1996 DSC Technologies Corporation
# ======================================================================
# Permission to use, copy, modify, distribute and license this software
# and its documentation for any purpose, and without fee or written
# agreement with DSC, is hereby granted, provided that the above copyright
# notice appears in all copies and that both the copyright notice and
# warranty disclaimer below appear in supporting documentation, and that
# the names of DSC Technologies Corporation or DSC Communications
# Corporation not be used in advertising or publicity pertaining to the
# software without specific, written prior permission.
#
# DSC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
# ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, 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. IN NO EVENT SHALL
# DSC BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
# ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTUOUS ACTION,
# ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
# SOFTWARE.
# ======================================================================
# Acknowledgements:
#
# Special thanks go to Sam Shen(SLShen@lbl.gov), as this code is based on his
# tkhtml.tcl code from tk inspect. The original code is copyright 1995
# Lawrence Berkeley Laboratory.
#
# This software is copyright (C) 1995 by the Lawrence Berkeley Laboratory.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that: (1) source code distributions
# retain the above copyright notice and this paragraph in its entirety, (2)
# distributions including binary code include the above copyright notice and
# this paragraph in its entirety in the documentation or other materials
# provided with the distribution, and (3) all advertising materials mentioning
# features or use of this software display the following acknowledgement:
# ``This product includes software developed by the University of California,
# Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
# the University nor the names of its contributors may be used to endorse
# or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
# This code is based on Angel Li's (angel@flipper.rsmas.miami.edu) HTML
#
# Default resources.
#
option add *Scrolledhtml.borderWidth 2 widgetDefault
option add *Scrolledhtml.relief sunken widgetDefault
option add *Scrolledhtml.scrollMargin 3 widgetDefault
option add *Scrolledhtml.width 500 widgetDefault
option add *Scrolledhtml.height 600 widgetDefault
option add *Scrolledhtml.visibleItems 80x24 widgetDefault
option add *Scrolledhtml.vscrollMode static widgetDefault
option add *Scrolledhtml.hscrollMode static widgetDefault
option add *Scrolledhtml.labelPos n widgetDefault
option add *Scrolledhtml.wrap word widgetDefault
#
# Usual options.
#
itk::usual Scrolledhtml {
keep -fontname -fontsize -fixedfont -link -alink -linkhighlight \
-activebackground -activerelief -background -borderwidth -cursor \
-elementborderwidth -foreground -highlightcolor -highlightthickness \
-insertbackground -insertborderwidth -insertofftime -insertontime \
-insertwidth -jump -labelfont -selectbackground -selectborderwidth \
-selectforeground -textbackground -textfont -troughcolor -unknownimage
}
# ------------------------------------------------------------------
# SCROLLEDHTML
# ------------------------------------------------------------------
itcl::class iwidgets::Scrolledhtml {
inherit iwidgets::Scrolledtext
constructor {args} {}
destructor {}
itk_option define -feedback feedBack FeedBack {}
itk_option define -linkcommand linkCommand LinkCommand {}
itk_option define -fontname fontname FontName times
itk_option define -fixedfont fixedFont FixedFont courier
itk_option define -fontsize fontSize FontSize medium
itk_option define -link link Link blue
itk_option define -alink alink ALink red
itk_option define -linkhighlight alink ALink red
itk_option define -unknownimage unknownimage File {}
itk_option define -textbackground textBackground Background {}
itk_option define -update update Update 1
itk_option define -debug debug Debug 0
public method import {args}
public method clear {}
public method render {html {wd .}}
public method title {} {return $_title}
public method pwd {} {return $_cwd}
protected method _setup {}
protected method _set_tag {}
protected method _reconfig_tags {}
protected method _append_text {text}
protected method _do {text}
protected method _definefont {name foundry family weight slant registry}
protected method _peek {instack}
protected method _push {instack value}
protected method _pop {instack}
protected method _parse_fields {array_var string}
protected method _href_click {cmd href}
protected method _set_align {align}
protected method _fixtablewidth {hottext table multiplier}
protected method _header {level args}
protected method _/header {level}
protected method _entity_a {args}
protected method _entity_/a {}
protected method _entity_address {}
protected method _entity_/address {}
protected method _entity_b {}
protected method _entity_/b {}
protected method _entity_base {{args {}}}
protected method _entity_basefont {{args {}}}
protected method _entity_big {}
protected method _entity_/big {}
protected method _entity_blockquote {}
protected method _entity_/blockquote {}
protected method _entity_body {{args {}}}
protected method _entity_/body {}
protected method _entity_br {{args {}}}
protected method _entity_center {}
protected method _entity_/center {}
protected method _entity_cite {}
protected method _entity_/cite {}
protected method _entity_code {}
protected method _entity_/code {}
protected method _entity_dir {{args {}}}
protected method _entity_/dir {}
protected method _entity_div {{args {}}}
protected method _entity_dl {{args {}}}
protected method _entity_/dl {}
protected method _entity_dt {}
protected method _entity_dd {}
protected method _entity_dfn {}
protected method _entity_/dfn {}
protected method _entity_em {}
protected method _entity_/em {}
protected method _entity_font {{args {}}}
protected method _entity_/font {}
protected method _entity_h1 {{args {}}}
protected method _entity_/h1 {}
protected method _entity_h2 {{args {}}}
protected method _entity_/h2 {}
protected method _entity_h3 {{args {}}}
protected method _entity_/h3 {}
protected method _entity_h4 {{args {}}}
protected method _entity_/h4 {}
protected method _entity_h5 {{args {}}}
protected method _entity_/h5 {}
protected method _entity_h6 {{args {}}}
protected method _entity_/h6 {}
protected method _entity_hr {{args {}}}
protected method _entity_i {}
protected method _entity_/i {}
protected method _entity_img {{args {}}}
protected method _entity_kbd {}
protected method _entity_/kbd {}
protected method _entity_li {{args {}}}
protected method _entity_listing {}
protected method _entity_/listing {}
protected method _entity_menu {{args {}}}
protected method _entity_/menu {}
protected method _entity_ol {{args {}}}
protected method _entity_/ol {}
protected method _entity_p {{args {}}}
protected method _entity_pre {{args {}}}
protected method _entity_/pre {}
protected method _entity_samp {}
protected method _entity_/samp {}
protected method _entity_small {}
protected method _entity_/small {}
protected method _entity_sub {}
protected method _entity_/sub {}
protected method _entity_sup {}
protected method _entity_/sup {}
protected method _entity_strong {}
protected method _entity_/strong {}
protected method _entity_table {{args {}}}
protected method _entity_/table {}
protected method _entity_td {{args {}}}
protected method _entity_/td {}
protected method _entity_th {{args {}}}
protected method _entity_/th {}
protected method _entity_title {}
protected method _entity_/title {}
protected method _entity_tr {{args {}}}
protected method _entity_/tr {}
protected method _entity_tt {}
protected method _entity_/tt {}
protected method _entity_u {}
protected method _entity_/u {}
protected method _entity_ul {{args {}}}
protected method _entity_/ul {}
protected method _entity_var {}
protected method _entity_/var {}
protected variable _title {} ;# The title of the html document
protected variable _licount 1 ;# list element count
protected variable _listyle bullet ;# list element style
protected variable _lipic {} ;# picture to use as bullet
protected variable _color black ;# current text color
protected variable _bgcolor #d9d9d9 ;# current background color
protected variable _link blue ;# current link color
protected variable _alink red ;# current highlight link color
protected variable _smallpoints "60 80 100 120 140 180 240" ;# font point
protected variable _mediumpoints "80 100 120 140 180 240 360" ;# sizes for
protected variable _largepoints "100 120 140 180 240 360 480" ;# various
protected variable _hugepoints "120 140 180 240 360 480 640" ;# fontsizes
protected variable _font times ;# name of current font
protected variable _rulerheight 6 ;#
protected variable _indentincr 4 ;# increment to indent by
protected variable _counter -1 ;# counter to give unique numbers
protected variable _left 0 ;# initial left margin
protected variable _left2 0 ;# subsequent left margin
protected variable _right 0 ;# right margin
protected variable _justify L ;# text justification
protected variable _offset 0 ;# text offset (super/subscript)
protected variable _textweight 0 ;# boldness of text
protected variable _textslant 0 ;# whether to use italics
protected variable _underline 0 ;# whether to use underline
protected variable _verbatim 0 ;# whether to skip formatting
protected variable _pre 0 ;# preformatted text
protected variable _intitle 0 ;# in <title>...</title>
protected variable _anchorcount 0 ;# number of anchors
protected variable _stack ;# array of stacks
protected variable _pointsndx 2 ;#
protected variable _fontnames ;# list of accepted font names
protected variable _fontinfo ;# array of font info given font name
protected variable _tag ;#
protected variable _tagl ;#
protected variable _tagfont ;#
protected variable _cwd . ;# base directory of current page
protected variable _anchor ;# array of indexes by anchorname
protected variable _defaulttextbackground;# default text background
protected variable _intable 0 ;# whether we are in a table now
protected variable _hottext ;# widget where text currently goes
protected variable _basefontsize 2 ;# as named
protected variable _unknownimg {} ;# name of unknown image
protected variable _images {} ;# list of images we created
protected variable _prevpos {} ;# temporary used for table updates
protected variable _prevtext {} ;# temporary used for table updates
private variable _initialized 0
private variable _defUnknownImg [::image create photo -data {
R0lGODdhHwAgAPQAAP///wAAAMzMzC9PT76+vvnTogCR/1WRVaoAVf//qvT09OKdcWlcx19f
X9/f339/f8vN/J2d/aq2qoKCggAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
ACwAAAAAHwAgAAAF/iAgjqRDnmiKmqOkqsTaToDjvudTttLjOITJbTQhGI+iQE0xMvZqQIDw
NAEiAcqRVdKAGh0NyVCkuyqZBEmwofgRrFIxSaI0JmuA9KTrthIicWMTAQ8xWHgSe15AVgcJ
eVMjDwECOkome22Mb0cHCzEPOiQPgwGXCjomakedA0VgY1IPDZcuP3l5YkcRDwMHqDQoEzq2
Pz8IQkK7Bw8HDg+xO26PCAgRDcpGswEK2Dh9ItUMDdirPYUKwTKMjwDV1gHlR2oCkSmcI9UE
BabYrGnQoolgBCGckX7yWJWDYaUMAYSRFECAwMXeiU1BHpKTB4CBR4+oBOb5By1UNgUfXj0C
8HaP079sBCCkZIAKWst/OGPOhNBNHQmXOeftJBASRVCcEiIojQDBwIOeRo+SpGXKFFGbP6Xi
nLWxEMsmWpEOC9XDYtigYtKSwsH2xdq2cEfRmFS1rt27eE09CAEAOw==
}]
}
#
# Provide a lowercased access method for the Scrolledhtml class.
#
proc ::iwidgets::scrolledhtml {pathName args} {
uplevel ::iwidgets::Scrolledhtml $pathName $args
}
# ------------------------------------------------------------------
# CONSTRUCTOR
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::constructor {args} {
# define the fonts we're going to use
set _fontnames ""
_definefont helvetica adobe helvetica "medium bold" "r o" iso8859
_definefont courier adobe courier "medium bold" "r o" iso8859
_definefont times adobe times "medium bold" "r i" iso8859
_definefont symbol adobe symbol "medium medium" "r r" adobe
$itk_component(text) configure -state disabled
eval itk_initialize $args
if {[lsearch -exact $args -linkcommand] == -1} {
configure -linkcommand [itcl::code $this import -link]
}
set _initialized 1
}
# ------------------------------------------------------------------
# DESTRUCTOR
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::destructor {} {
foreach x $_images {
::image delete $x
}
if {$_unknownimg != $_defUnknownImg} {
::image delete $_unknownimg
}
}
# ------------------------------------------------------------------
# OPTIONS
# ------------------------------------------------------------------
# ------------------------------------------------------------------
# OPTION: -fontsize
#
# Set the general size of the font.
# ------------------------------------------------------------------
itcl::configbody iwidgets::Scrolledhtml::fontsize {
switch $itk_option(-fontsize) {
small { }
medium { }
large { }
huge { }
default {
error "bad fontsize option\
\"$itk_option(-fontsize)\": should\
be small, medium, large, or huge"
}
}
_reconfig_tags
}
# ------------------------------------------------------------------
# OPTION: -fixedfont
#
# Set the fixed font name
# ------------------------------------------------------------------
itcl::configbody iwidgets::Scrolledhtml::fixedfont {
if {[lsearch -exact $_fontnames $itk_option(-fixedfont)] == -1} {
error "Invalid font name \"$itk_option(-fixedfont)\". Must be one of \
$_fontnames"
}
}
# ------------------------------------------------------------------
# OPTION: -fontname
#
# Set the default font name
# ------------------------------------------------------------------
itcl::configbody iwidgets::Scrolledhtml::fontname {
if {[lsearch -exact $_fontnames $itk_option(-fontname)] == -1} {
error "Invalid font name \"$itk_option(-fontname)\". Must be one of \
$_fontnames"
}
}
# ------------------------------------------------------------------
# OPTION: -textbackground
#
# Set the default text background
# ------------------------------------------------------------------
itcl::configbody iwidgets::Scrolledhtml::textbackground {
set _defaulttextbackground $itk_option(-textbackground)
}
# ------------------------------------------------------------------
# OPTION: -linkhighlight
#
# same as alink
# ------------------------------------------------------------------
itcl::configbody iwidgets::Scrolledhtml::linkhighlight {
configure -alink $itk_option(-linkhighlight)
}
# ------------------------------------------------------------------
# OPTION: -unknownimage
#
# set image to use as substitute for images that aren't found
# ------------------------------------------------------------------
itcl::configbody iwidgets::Scrolledhtml::unknownimage {
set oldimage $_unknownimg
if {$itk_option(-unknownimage) != {}} {
set uki $itk_option(-unknownimage)
if [catch { set _unknownimg [::image create photo -file $uki] } err] {
error "Couldn't create image $uki:\n$err\nUnknown image not found"
}
} else {
set _unknownimg $_defUnknownImg
}
if {$oldimage != {} && $oldimage != $_defUnknownImg} {
::image delete $oldimage
}
}
# ------------------------------------------------------------------
# OPTION: -update
#
# boolean indicating whether to update during rendering
# ------------------------------------------------------------------
itcl::configbody iwidgets::Scrolledhtml::update {
switch -- $itk_option(-update) {
0 {}
1 {}
true {
configure -update 1
}
yes {
configure -update 1
}
false {
configure -update 0
}
yes {
configure -update 0
}
default {
error "invalid -update; must be boolean"
}
}
}
# ------------------------------------------------------------------
# METHODS
# ------------------------------------------------------------------
# ------------------------------------------------------------------
# METHOD: clear
#
# Clears the text out
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::clear {} {
$itk_component(text) config -state normal
$itk_component(text) delete 1.0 end
foreach x $_images {
::image delete $x
}
set _images {}
_setup
$itk_component(text) config -state disabled
}
# ------------------------------------------------------------------
# METHOD import ?-link? filename?#anchorname?
#
# read html text from a file (import filename) if the keyword link is present,
# pathname is relative to last page, otherwise it is relative to current
# directory. This allows the user to use a linkcommand of
# "<widgetname> import -link"
#
# if '#anchorname' is appended to the filename, the page is displayed starting
# at the anchor named 'anchorname' If an anchor is specified without a filename,
# the current page is assumed.
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::import {args} {
update idletasks
set len [llength $args]
if {$len != 1 && $len != 2} {
error "wrong # args: should be \
\"$itk_component(hull) import ?-link? filename\""
}
set linkname [lindex $args [expr {$len - 1}]]
#
# Seperate filename#anchorname
#
if ![regexp {(.*)#(.*)} $linkname dummy filename anchorname] {
set filename $linkname
}
if {$filename!=""} {
#
# Check for -link option
#
switch -- $len {
1 {
#
# open file & set cwd to that file's directory
#
set f [open $filename r]
set _cwd [file dirname $filename]
}
2 {
switch -- [lindex $args 0] {
-link {
#
# got -link, so set path relative to current locale, if path
# is a relative pathname
#
if {[string compare "." [file dirname $filename]] == 0} {
set f [open $_cwd/$filename r]
} else {
if {[string index [file dirname $filename] 0] != "/" &&\
[string index [file dirname $filename] 0] != "~"} {
set f [open $_cwd/$filename r]
append _cwd /
append _cwd [file dirname $filename]
} else {
set f [open $filename r]
set _cwd [file dirname $filename]
}
}
}
default {
# got something other than -link
error "invalid format: should be \
\"$itk_component(hull) import ?-link? filename\""
}
}
}
}
set txt [read $f]
close $f
render $txt $_cwd
}
#
# if an anchor was requested, move that anchor into view
#
if [ info exists anchorname] {
if {$anchorname!=""} {
if [info exists _anchor($anchorname)] {
$itk_component(text) see end
$itk_component(text) see $_anchor($anchorname)
}
} else {
$itk_component(text) see 0.0
}
}
}
# ------------------------------------------------------------------
# METHOD: render text ?wd?
#
# Clear the text, then render html formatted text. Optional wd argument
# sets the base directory for any links or images.
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::render {html {wd .}} {
update idletasks
#
# blank text and reset all state variables
#
clear
set _cwd $wd
#
# make text writable
#
$itk_component(text) config -state normal
set continuerendering 1
_set_tag
while {$continuerendering} {
# normal state
while {[set len [string length $html]]} {
# look for text up to the next <> element
if [regexp -indices "^\[^<\]+" $html match] {
set text [string range $html 0 [lindex $match 1]]
_append_text "$text"
set html \
[string range $html [expr {[lindex $match 1]+1}] end]
}
# we're either at a <>, or at the eot
if [regexp -indices "^<((\[^>\"\]+|(\"\[^\"\]*\"))*)>" $html match entity] {
regsub -all "\n" [string range $html [lindex $entity 0] \
[lindex $entity 1]] "" entity
set cmd [string tolower [lindex $entity 0]]
if {[info command _entity_$cmd]!=""} {
if {[catch {eval _entity_$cmd [lrange $entity 1 end]} bad]} {
if {$itk_option(-debug)} {
global errorInfo
puts stderr "render: _entity_$cmd [lrange $entity 1 end] = Error:$bad\n$errorInfo"
}
}
}
set html \
[string range $html [expr {[lindex $match 1]+1}] end]
}
if {$itk_option(-feedback) != {} } {
eval $itk_option(-feedback) $len
}
if $_verbatim break
}
# we reach here if html is empty, or _verbatim is 1
if !$len break
# _verbatim must be 1
# append text until next tag is reached
if [regexp -indices "<.*>" $html match] {
set text [string range $html 0 [expr {[lindex $match 0]-1}]]
set html [string range $html [expr {[lindex $match 0]}] end]
} else {
set text $html
set html ""
}
_append_text "$text"
}
$itk_component(text) config -state disabled
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _setup
#
# Reset all state variables to prepare for a new page.
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_setup {} {
set _font $itk_option(-fontname)
set _left 0
set _left2 0
set _right 0
set _justify L
set _textweight 0
set _textslant 0
set _underline 0
set _verbatim 0
set _pre 0
set _title {}
set _intitle 0
set _anchorcount 0
set _intable 0
set _hottext $itk_component(text)
set _stack(font) {}
set _stack(color) {}
set _stack(bgcolor) {}
set _stack(link) {}
set _stack(alink) {}
set _stack(justify) {}
set _stack(listyle) {}
set _stack(lipic) {}
set _stack(href) {}
set _stack(pointsndx) {}
set _stack(left) {}
set _stack(left2) {}
set _stack(offset) {}
set _stack(table) {}
set _stack(tablewidth) {}
set _stack(row) {}
set _stack(column) {}
set _stack(hottext) {}
set _stack(tableborder) {}
set _stack(cellpadding) {}
set _stack(cellspacing) {}
set _stack(licount) {}
set _basefontsize 2
set _pointsndx 2
set _counter -1
set _bgcolor $_defaulttextbackground
set _color $itk_option(-foreground)
set _link $itk_option(-link)
set _alink $itk_option(-alink)
config -textbackground $_bgcolor
foreach x [array names _anchor] { unset _anchor($x) }
$itk_component(text) tag config hr -relief sunken -borderwidth 2 \
-font -*-*-*-*-*-*-$_rulerheight-*-*-*-*-*-*-*
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _definefont name foundry family weight slant registry
#
# define font information used to generate font value from font name
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_definefont \
{name foundry family weight slant registry} {
if {[lsearch -exact $_fontnames $name] == -1 } {
lappend _fontnames $name
}
set _fontinfo($name) \
[list $foundry $family $weight $slant $registry]
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _append_text text
#
# append text in the format described by the state variables
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_append_text {text} {
if {!$_intable && $itk_option(-update)} {update}
if {[string first "&" $text] != -1} {
regsub -nocase -all "&" $text {\&} text
regsub -nocase -all "<" $text "<" text
regsub -nocase -all ">" $text ">" text
regsub -nocase -all """ $text "\"" text
}
if !$_verbatim {
if !$_pre {
set text [string trim $text "\n\r"]
regsub -all "\[ \n\r\t\]+" $text " " text
}
if ![string length $text] return
}
if {!$_pre && !$_intitle} {
if {[catch {$_hottext get "end - 2c"} p]} {
set p ""
}
set n [string index $text 0]
if {$n == " " && $p == " "} {
set text [string range $text 1 end]
}
if {[catch {$_hottext insert end $text $_tag}]} {
set pht [winfo parent $_hottext]
catch {$pht insert end $text $_tag}
}
return
}
if {$_pre && !$_intitle} {
if {[catch {$_hottext insert end $text $_tag}]} {
set pht [winfo parent $_hottext]
catch {$pht insert end $text $_tag}
}
return
}
append _title $text
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _set_tag
#
# generate a tag
# ------------------------------------------------------------------
# a tag is constructed as: font?B?I?U?Points-LeftLeft2RightColorJustify
itcl::body iwidgets::Scrolledhtml::_set_tag {} {
set i -1
foreach var {foundry family weight slant registry} {
set $var [lindex $_fontinfo($_font) \
[incr i]]
}
set x_font "-$foundry-$family-"
set _tag $_font
set args {}
if {$_textweight > 0} {
append _tag "B"
append x_font [lindex $weight 1]-
} else {
append x_font [lindex $weight 0]-
}
if {$_textslant > 0} {
append _tag "I"
append x_font [lindex $slant 1]-
} else {
append x_font [lindex $slant 0]-
}
if {$_underline > 0} {
append _tag "U"
append args " -underline 1"
}
switch $_justify {
L { append args " -justify left" }
R { append args " -justify right" }
C { append args " -justify center" }
}
append args " -offset $_offset"
set pts [lindex [set [format "_%spoints" $itk_option(-fontsize)]] \
$_pointsndx]
append _tag $_pointsndx - $_left \
$_left2 $_right \
$_color $_justify
append x_font "normal-*-*-$pts-*-*-*-*-$registry-*"
if $_anchorcount {
set href [_peek href]
set href_tag href[incr _counter]
set tags [list $_tag $href_tag]
if { $itk_option(-linkcommand)!= {} } {
$_hottext tag bind $href_tag <1> \
[list uplevel #0 $itk_option(-linkcommand) $href]
}
$_hottext tag bind $href_tag <Enter> \
[list $_hottext tag configure $href_tag \
-foreground $_alink]
$_hottext tag bind $href_tag <Leave> \
[list $_hottext tag configure $href_tag \
-foreground $_color]
} else {
set tags $_tag
}
if {![info exists _tagl($_tag)]} {
set _tagfont($_tag) 1
eval $_hottext tag configure $_tag \
-foreground ${_color} \
-lmargin1 ${_left}m \
-lmargin2 ${_left2}m $args
if [catch {eval $_hottext tag configure $_tag \
-font $x_font} err] {
_definefont $_font * $family $weight $slant *
regsub \$foundry $x_font * x_font
regsub \$registry $x_font * x_font
catch {eval $_hottext tag configure $_tag -font $x_font}
}
}
if [info exists href_tag] {
$_hottext tag raise $href_tag $_tag
}
set _tag $tags
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _reconfig_tags
#
# reconfigure tags following a configuration change
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_reconfig_tags {} {
if $_initialized {
foreach tag [$itk_component(text) tag names] {
foreach efont $_fontnames {
if [regexp "${efont}(B?)(I?)(U?)(\[1-9\]\[0-9\]*)-" $tag t b i u points] {
set j -1
set _font $efont
foreach var {foundry family weight slant registry} {
set $var [lindex $_fontinfo($_font) [incr j]]
}
set x_font "-$foundry-$family-"
if {$b == "B"} {
append x_font [lindex $weight 1]-
} else {
append x_font [lindex $weight 0]-
}
if {$i == "I"} {
append x_font [lindex $slant 1]-
} else {
append x_font [lindex $slant 0]-
}
set pts [lindex [set [format \
"_%spoints" $itk_option(-fontsize)]] $points]
append x_font "normal-*-*-$pts-*-*-*-*-$registry-*"
$itk_component(text) tag config $tag -font $x_font
break
}
}
}
}
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _push instack value
#
# push value onto stack(instack)
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_push {instack value} {
set _stack($instack) [linsert $_stack($instack) 0 $value]
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _pop instack
#
# pop value from stack(instack)
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_pop {instack} {
if {$_stack($instack) == ""} {
error "popping empty _stack $instack"
}
set val [lindex $_stack($instack) 0]
set _stack($instack) [lrange $_stack($instack) 1 end]
return $val
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _peek instack
#
# peek at top value on stack(instack)
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_peek {instack} {
return [lindex $_stack($instack) 0]
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _parse_fields array_var string
#
# parse fields from a href or image tag. At the moment, doesn't support
# spaces in field values. (e.g. alt="not avaliable")
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_parse_fields {array_var string} {
upvar $array_var array
if {$string != "{}" } {
regsub -all "( *)=( *)" $string = string
regsub -all {\\\"} $string \" string
while {$string != ""} {
if ![regexp "^ *(\[^ \n\r=\]+)=\"(\[^\"\n\r\t\]*)(.*)" $string \
dummy field value newstring] {
if ![regexp "^ *(\[^ \n\r=\]+)=(\[^\n\r\t \]*)(.*)" $string \
dummy field value newstring] {
if ![regexp "^ *(\[^ \n\r\]+)(.*)" $string dummy field newstring] {
error "malformed command field; field = \"$string\""
continue
}
set value ""
}
}
set array([string tolower $field]) $value
set string "$newstring"
}
}
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _href_click
#
# process a click on an href
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_href_click {cmd href} {
uplevel #0 $cmd $href
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _set_align
#
# set text alignment
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_set_align {align} {
switch [string tolower $align] {
center {
set _justify C
}
left {
set _justify L
}
right {
set _justify R
}
default {}
}
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _fixtablewidth
#
# fix table width & height
# essentially, with nested tables the outer table must be configured before
# the inner table, but the idle tasks get queued up in the opposite order,
# so process later idle tasks before sizing yourself.
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_fixtablewidth {hottext table multiplier} {
update idletasks
$hottext see $_anchor($table)
update idletasks
$table configure \
-width [expr {$multiplier * [winfo width $hottext] - \
2* [$hottext cget -padx] - \
2* [$hottext cget -borderwidth]} ] \
-height [winfo height $table]
grid propagate $table 0
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _header level
#
# generic entity to set state for <hn> tag
# Accepts argument of the form ?align=[left,right,center]? ?src=<image pname>?
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_header {level args} {
eval _parse_fields ar $args
_push justify $_justify
if [info exists ar(align)] {
_entity_p align=$ar(align)
} else {
_entity_p
}
if [info exists ar(src)] {
_entity_img src=$ar(src)
}
_push pointsndx $_pointsndx
set _pointsndx [expr {7-$level}]
incr _textweight
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _/header level
#
# generic entity to set state for </hn> tag
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_/header {level} {
set _justify [_pop justify]
set _pointsndx [_pop pointsndx]
incr _textweight -1
_set_tag
_entity_p
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_a
#
# add an anchor. Accepts arguments of the form ?href=filename#anchorpoint?
# ?name=anchorname?
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_a {args} {
_parse_fields ar $args
_push color $_color
if [info exists ar(href)] {
_push href $ar(href)
incr _anchorcount
set _color $_link
_entity_u
} else {
_push href {}
}
if [info exists ar(name)] {
set _anchor($ar(name)) [$itk_component(text) index end]
}
if [info exists ar(id)] {
set _anchor($ar(id)) [$itk_component(text) index end]
}
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/a
#
# End anchor
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/a {} {
set href [_pop href]
if {$href != {}} {
incr _anchorcount -1
set _color [_pop color]
_entity_/u
}
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_address
#
# display an address
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_address {} {
_entity_br
_entity_i
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/address
#
# change state back from address display
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/address {} {
_entity_/i
_entity_br
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_b
#
# Change current font to bold
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_b {} {
incr _textweight
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/b
#
# change current font back from bold
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/b {} {
incr _textweight -1
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_base
#
# set the cwd of the document
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_base {{args {}}} {
_parse_fields ar $args
if [info exists ar(href)] {
set _cwd [file dirname $ar(href)]
}
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_basefont
#
# set base font size
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_basefont {{args {}}} {
_parse_fields ar $args
if {[info exists ar(size)]} {
set _basefontsize $ar(size)
}
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_big
#
# Change current font to a bigger size
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_big {} {
_push pointsndx $_pointsndx
if {[incr _pointsndx 2] > 6} {
set _pointsndx 6
}
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/big
#
# change current font back from bigger size
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/big {} {
set _pointsndx [_pop pointsndx]
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_blockquote
#
# display a block quote
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_blockquote {} {
_entity_p
_push left $_left
incr _left $_indentincr
_push left2 $_left2
set _left2 $_left
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/blockquote
#
# change back from blockquote
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/blockquote {} {
_entity_p
set _left [_pop left]
set _left2 [_pop left2]
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_body
#
# begin body text. Takes argument of the form ?bgcolor=<color>? ?text=<color>?
# ?link=<color>?
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_body {{args {}}} {
_parse_fields ar $args
if [info exists ar(bgcolor)] {
set _bgcolor $ar(bgcolor)
set temp $itk_option(-textbackground)
config -textbackground $_bgcolor
set _defaulttextbackground $temp
}
if [info exists ar(text)] {
set _color $ar(text)
}
if [info exists ar(link)] {
set _link $ar(link)
}
if [info exists ar(alink)] {
set _alink $ar(alink)
}
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/body
#
# end body text
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/body {} {
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_br
#
# line break
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_br {{args {}}} {
$_hottext insert end "\n"
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_center
#
# change justification to center
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_center {} {
_push justify $_justify
set _justify C
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/center
#
# change state back from center
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/center {} {
set _justify [_pop justify]
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_cite
#
# display citation
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_cite {} {
_entity_i
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/cite
#
# change state back from citation
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/cite {} {
_entity_/i
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_code
#
# display code listing
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_code {} {
_entity_pre
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/code
#
# end code listing
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/code {} {
_entity_/pre
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_dir
#
# display dir list
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_dir {{args {}}} {
_entity_ul plain $args
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/dir
#
# end dir list
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/dir {} {
_entity_/ul
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_div
#
# divide text. same as <p>
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_div {{args {}}} {
_entity_p $args
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_dl
#
# begin definition list
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_dl {{args {}}} {
if {$_left == 0} {
_entity_p
}
_push left $_left
_push left2 $_left2
if {$_left2 == $_left } {
incr _left2 [expr {$_indentincr+3}]
} else {
incr _left2 $_indentincr
}
incr _left $_indentincr
_push listyle $_listyle
_push licount $_licount
set _listyle none
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/dl
#
# end definition list
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/dl {} {
set _left [_pop left]
set _left2 [_pop left2]
set _listyle [_pop listyle]
set _licount [_pop licount]
_set_tag
if {$_left == 0} {
_entity_p
}
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_dt
#
# definition term
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_dt {} {
set _left [expr {$_left2 - 3}]
_set_tag
_entity_p
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_dd
#
# definition definition
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_dd {} {
set _left $_left2
_set_tag
_entity_br
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_dfn
#
# display defining instance of a term
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_dfn {} {
_entity_i
_entity_b
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/dfn
#
# change state back from defining instance of term
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/dfn {} {
_entity_/b
_entity_/i
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_em
#
# display emphasized text
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_em {} {
_entity_i
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/em
#
# change state back from emphasized text
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/em {} {
_entity_/i
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_font
#
# set font size and color
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_font {{args {}}} {
_parse_fields ar $args
_push pointsndx $_pointsndx
_push color $_color
if [info exists ar(size)] {
if {![regexp {^[+-].*} $ar(size)]} {
set _pointsndx $ar(size)
} else {
set _pointsndx [expr {$_basefontsize $ar(size)}]
}
if { $_pointsndx > 6 } {
set _pointsndx 6
} else {
if { $_pointsndx < 0 } {
set _pointsndx 0
}
}
}
if {[info exists ar(color)]} {
set _color $ar(color)
}
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/font
#
# close current font size
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/font {} {
set _pointsndx [_pop pointsndx]
set _color [_pop color]
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_h1
#
# display header level 1.
# Accepts argument of the form ?align=[left,right,center]? ?src=<image pname>?
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_h1 {{args {}}} {
_header 1 $args
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/h1
#
# change state back from header 1
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/h1 {} {
_/header 1
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_h2
#
# display header level 2
# Accepts argument of the form ?align=[left,right,center]? ?src=<image pname>?
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_h2 {{args {}}} {
_header 2 $args
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/h2
#
# change state back from header 2
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/h2 {} {
_/header 2
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_h3
#
# display header level 3
# Accepts argument of the form ?align=[left,right,center]? ?src=<image pname>?
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_h3 {{args {}}} {
_header 3 $args
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/h3
#
# change state back from header 3
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/h3 {} {
_/header 3
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_h4
#
# display header level 4
# Accepts argument of the form ?align=[left,right,center]? ?src=<image pname>?
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_h4 {{args {}}} {
_header 4 $args
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/h4
#
# change state back from header 4
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/h4 {} {
_/header 4
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_h5
#
# display header level 5
# Accepts argument of the form ?align=[left,right,center]? ?src=<image pname>?
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_h5 {{args {}}} {
_header 5 $args
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/h5
#
# change state back from header 5
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/h5 {} {
_/header 5
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_h6
#
# display header level 6
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_h6 {{args {}}} {
_header 6 $args
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/h6
#
# change state back from header 6
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/h6 {} {
_/header 6
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_hr
#
# Add a horizontal rule
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_hr {{args {}}} {
_parse_fields ar $args
if [info exists ar(size)] {
set font "-font -*-*-*-*-*-*-$ar(size)-*-*-*-*-*-*-*"
} else {
set font "-font -*-*-*-*-*-*-2-*-*-*-*-*-*-*"
}
if [info exists ar(width)] {
}
if [info exists ar(noshade)] {
set relief "-relief flat"
set background "-background black"
} else {
set relief "-relief sunken"
set background ""
}
# if [info exists ar(align)] {
# $_hottext tag config hr$_counter -justify $ar(align)
# set justify -justify $ar(align)
# } else {
# set justify ""
# }
eval $_hottext tag config hr[incr _counter] $relief $background $font \
-borderwidth 2
_entity_p
$_hottext insert end " \n" hr$_counter
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_i
#
# display italicized text
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_i {} {
incr _textslant
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/i
#
# change state back from italicized text
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/i {} {
incr _textslant -1
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_img
#
# display an image. takes argument of the form img=<filename>
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_img {{args {}}} {
_parse_fields ar $args
set alttext "<image>"
#
# If proper argument exists
#
if [info exists ar(src)] {
set imgframe $_hottext.img[incr _counter]
#
# if this is an anchor
#
if $_anchorcount {
# create link colored border
frame $imgframe -borderwidth 2 -background $_link
bind $imgframe <Enter> \
[list $imgframe configure -background $_alink]
bind $imgframe <Leave> \
[list $imgframe configure -background $_link]
} else {
# create plain frame
frame $imgframe -borderwidth 0 -background $_color
}
#
# try to load image
#
if {[string index $ar(src) 0] == "/" || [string index $ar(src) 0] == "~"} {
set file $ar(src)
} else {
set file $_cwd/$ar(src)
}
if [catch {set img [::image create photo -file $file]} err] {
if {[info exists ar(width)] && [info exists ar(height)] } {
# suggestions exist, so make frame appropriate size and add a border
$imgframe configure -width $ar(width) -height $ar(height) -borderwidth 2
pack propagate $imgframe false
}
#
# If alt text is specified, display that
#
if [info exists ar(alt)] {
# add a border
$imgframe configure -borderwidth 2
set win $imgframe.text
label $win -text "$ar(alt)" -background $_bgcolor \
-foreground $_color
} else {
#
# use 'unknown image'
set win $imgframe.image#auto
#
# make label containing image
#
label $win -image $_unknownimg -borderwidth 0 -background $_bgcolor
}
pack $win -fill both -expand true
} else { ;# no error loading image
lappend _images $img
set win $imgframe.$img
#
# make label containing image
#
label $win -image $img -borderwidth 0
}
pack $win
#
# set alignment
#
set align bottom
if [info exists ar(align)] {
switch $ar(align) {
middle {
set align center
}
right {
set align center
}
default {
set align [string tolower $ar(align)]
}
}
}
#
# create window in text to display image
#
$_hottext window create end -window \
$imgframe -align $align
#
# set tag for window
#
$_hottext tag add $_tag $imgframe
if $_anchorcount {
set href [_peek href]
set href_tag href[incr _counter]
set tags [list $_tag $href_tag]
if { $itk_option(-linkcommand)!= {} } {
bind $win <1> [list uplevel #0 $itk_option(-linkcommand) $href]
}
}
}
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_kbd
#
# Display keyboard input
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_kbd {} {
incr _textweight
_entity_tt
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/kbd
#
# change state back from displaying keyboard input
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/kbd {} {
_entity_/tt
incr _textweight -1
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_li
#
# begin new list entry
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_li {{args {}}} {
_parse_fields ar $args
if [info exists ar(value)] {
set _licount $ar(value)
}
_entity_br
switch -exact $_listyle {
bullet {
set old_font $_font
set _font symbol
_set_tag
$_hottext insert end "\xb7" $_tag
set _font $old_font
_set_tag
}
none {
}
picture {
_entity_img src="$_lipic" width=4 height=4 align=middle
}
A {
_entity_b
$_hottext insert end [format "%c) " [expr {$_licount + 0x40}]] $_tag
_entity_/b
incr _licount
}
a {
_entity_b
$_hottext insert end [format "%c) " [expr {$_licount + 0x60}]] $_tag
_entity_/b
incr _licount
}
I {
_entity_b
$_hottext insert end "[::iwidgets::roman $_licount]) " $_tag
_entity_/b
incr _licount
}
i {
_entity_b
$_hottext insert end "[::iwidgets::roman $_licount lower])] " $_tag
_entity_/b
incr _licount
}
default {
_entity_b
$_hottext insert end "$_licount) " $_tag
_entity_/b
incr _licount
}
}
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_listing
#
# diplay code listing
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_listing {} {
_entity_pre
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/listing
#
# end code listing
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/listing {} {
_entity_/pre
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_menu
#
# diplay menu list
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_menu {{args {}}} {
_entity_ul plain $args
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/menu
#
# end menu list
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/menu {} {
_entity_/ul
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_ol
#
# begin ordered list
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_ol {{args {}}} {
_parse_fields ar $args
if $_left {
_entity_br
} else {
_entity_p
}
if {![info exists ar(type)]} {
set ar(type) 1
}
_push licount $_licount
if [info exists ar(start)] {
set _licount $ar(start)
} else {
set _licount 1
}
_push left $_left
_push left2 $_left2
if {$_left2 == $_left } {
incr _left2 [expr {$_indentincr+3}]
} else {
incr _left2 $_indentincr
}
incr _left $_indentincr
_push listyle $_listyle
set _listyle $ar(type)
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/ol
#
# end ordered list
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/ol {} {
set _left [_pop left]
set _left2 [_pop left2]
set _listyle [_pop listyle]
set _licount [_pop licount]
_set_tag
_entity_p
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_p
#
# paragraph break
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_p {{args {}}} {
_parse_fields ar $args
if [info exists ar(align)] {
_set_align $ar(align)
} else {
set _justify L
}
_set_tag
if [info exists ar(id)] {
set _anchor($ar(id)) [$itk_component(text) index end]
}
set x [$_hottext get end-3c]
set y [$_hottext get end-2c]
if {$x == "" && $y == ""} return
if {$y == ""} {
$_hottext insert end "\n\n"
return
}
if {$x == "\n" && $y == "\n"} return
if {$y == "\n"} {
$_hottext insert end "\n"
return
}
$_hottext insert end "\n\n"
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_pre
#
# display preformatted text
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_pre {{args {}}} {
_entity_tt
_entity_br
incr _pre
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/pre
#
# change state back from preformatted text
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/pre {} {
_entity_/tt
set _pre 0
_entity_p
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_samp
#
# display sample text.
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_samp {} {
_entity_kbd
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/samp
#
# switch back to non-sample text
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/samp {} {
_entity_/kbd
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_small
#
# Change current font to a smaller size
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_small {} {
_push pointsndx $_pointsndx
if {[incr _pointsndx -2] < 0} {
set _pointsndx 0
}
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/small
#
# change current font back from smaller size
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/small {} {
set _pointsndx [_pop pointsndx]
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_sub
#
# display subscript
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_sub {} {
_push offset $_offset
incr _offset -2
_entity_small
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/sub
#
# switch back to non-subscript
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/sub {} {
set _offset [_pop offset]
_entity_/small
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_sup
#
# display superscript
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_sup {} {
_push offset $_offset
incr _offset 4
_entity_small
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/sup
#
# switch back to non-superscript
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/sup {} {
set _offset [_pop offset]
_entity_/small
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_strong
#
# display strong text. (i.e. make font bold)
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_strong {} {
incr _textweight
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/strong
#
# switch back to non-strong text
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/strong {} {
incr _textweight -1
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_table
#
# display a table.
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_table {{args {}}} {
_parse_fields ar $args
_entity_p
set _intable 1
_push row -1
_push column 0
_push hottext $_hottext
_push justify $_justify
_push justify L
# push color information for master of table, then push info for table
_push color $_color
_push bgcolor $_bgcolor
_push link $_link
_push alink $_alink
if [info exists ar(bgcolor)] {
set _bgcolor $ar(bgcolor)
}
if [info exists ar(text)] {
set _color $ar(text)
}
if [info exists ar(link)] {
set _link $ar(link)
}
if [info exists ar(alink)] {
set _alink $ar(alink)
}
_push color $_color
_push bgcolor $_bgcolor
_push link $_link
_push alink $_alink
# push fake first row to avoid using optional /tr tag
# (This needs to set a real color - not the empty string
# becaule later code will try to use those values.)
_push color $_color
_push bgcolor $_bgcolor
_push link {}
_push alink {}
if {[info exists ar(align)]} {
_set_align $ar(align)
_set_tag
_append_text " "
}
set _justify L
if [info exists ar(id)] {
set _anchor($ar(id)) [$itk_component(text) index end]
}
if [info exists ar(cellpadding)] {
_push cellpadding $ar(cellpadding)
} else {
_push cellpadding 0
}
if [info exists ar(cellspacing)] {
_push cellspacing $ar(cellspacing)
} else {
_push cellspacing 0
}
if {[info exists ar(border)]} {
_push tableborder 1
set relief raised
if {$ar(border)==""} {
set ar(border) 2
}
} else {
_push tableborder 0
set relief flat
set ar(border) 2
}
_push table [set table $_hottext.table[incr _counter]]
iwidgets::labeledwidget $table -foreground $_color -background $_bgcolor -labelpos n
if {[info exists ar(title)]} {
$table configure -labeltext $ar(title)
}
#
# create window in text to display table
#
$_hottext window create end -window $table
set table [$table childsite]
set _anchor($table) [$_hottext index "end - 1 line"]
$table configure -borderwidth $ar(border) -relief $relief
if {[info exists ar(width)]} {
_push tablewidth $ar(width)
} else {
_push tablewidth 0
}
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/table
#
# end table
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/table {} {
if {$_intable} {
_pop tableborder
set table [[_pop table] childsite]
_pop row
_pop column
_pop cellspacing
_pop cellpadding
# pop last row's defaults
_pop color
_pop bgcolor
_pop link
_pop alink
# pop table defaults
_pop color
_pop bgcolor
_pop link
_pop alink
# restore table master defaults
set _color [_pop color]
set _bgcolor [_pop bgcolor]
set _link [_pop link]
set _alink [_pop alink]
foreach x [grid slaves $table] {
set text [$x get 1.0 end]
set tl [split $text \n]
set max 0
foreach l $tl {
set len [string length $l]
if {$len > $max} {
set max $len
}
}
if {$max > [$x cget -width]} {
$x configure -width $max
}
if {[$x cget -height] == 1} {
$x configure -height [lindex [split [$x index "end - 1 chars"] "."] 0]
}
}
$_hottext configure -state disabled
set _hottext [_pop hottext]
$_hottext configure -state normal
if {[set tablewidth [_pop tablewidth]]!="0"} {
if {[string index $tablewidth \
[expr {[string length $tablewidth] -1}]] == "%"} {
set multiplier [expr {[string trimright $tablewidth "%"] / 100.0}]
set idletask [after idle [itcl::code "$this _fixtablewidth $_hottext $table $multiplier"]]
} else {
$table configure -width $tablewidth
grid propagate $table 0
}
}
_pop justify
set _justify [_pop justify]
_entity_br
}
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_td
#
# start table data cell
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_td {{args {}}} {
if $_intable {
_parse_fields ar $args
set table [[_peek table] childsite]
if {![info exists ar(colspan)]} {
set ar(colspan) 1
}
if {![info exists ar(rowspan)]} {
set ar(rowspan) 1
}
if {![info exists ar(width)]} {
set ar(width) 10
}
if {![info exists ar(height)]} {
set ar(height) 0
}
if [info exists ar(bgcolor)] {
set _bgcolor $ar(bgcolor)
} else {
set _bgcolor [_peek bgcolor]
}
if [info exists ar(text)] {
set _color $ar(text)
} else {
set _color [_peek color]
}
if [info exists ar(link)] {
set _link $ar(link)
} else {
set _link [_peek link]
}
if [info exists ar(alink)] {
set _alink $ar(alink)
} else {
set _alink [_peek alink]
}
$_hottext configure -state disabled
set cellpadding [_peek cellpadding]
set cellspacing [_peek cellspacing]
set _hottext $table.cell[incr _counter]
text $_hottext -relief flat -width $ar(width) -height $ar(height) \
-highlightthickness 0 -wrap word -cursor $itk_option(-cursor) \
-wrap word -cursor $itk_option(-cursor) \
-padx $cellpadding -pady $cellpadding
if {$_color != ""} {
$_hottext config -foreground $_color
}
if {$_bgcolor != ""} {
$_hottext config -background $_bgcolor
}
if [info exists ar(nowrap)] {
$_hottext configure -wrap none
}
if [_peek tableborder] {
$_hottext configure -relief sunken
}
set row [_peek row]
if {$row < 0} {
set row 0
}
set column [_pop column]
if {$column < 0} {
set column 0
}
while {[grid slaves $table -row $row -column $column] != ""} {
incr column
}
grid $_hottext -sticky nsew -row $row -column $column \
-columnspan $ar(colspan) -rowspan $ar(rowspan) \
-padx $cellspacing -pady $cellspacing
grid columnconfigure $table $column -weight 1
_push column [expr {$column + $ar(colspan)}]
if [info exists ar(align)] {
_set_align $ar(align)
} else {
set _justify [_peek justify]
}
_set_tag
}
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/td
#
# end table data cell
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/td {} {
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_th
#
# start table header
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_th {{args {}}} {
if $_intable {
_parse_fields ar $args
if [info exists ar(align)] {
_entity_td $args
} else {
_entity_td align=center $args
}
_entity_b
}
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/th
#
# end table data cell
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/th {} {
_entity_/td
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_title
#
# begin title of document
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_title {} {
set _intitle 1
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/title
#
# end title
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/title {} {
set _intitle 0
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_tr
#
# start table row
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_tr {{args {}}} {
if $_intable {
_parse_fields ar $args
_pop justify
if [info exists ar(align)] {
_set_align $ar(align)
_push justify $_justify
} else {
_push justify L
}
# pop last row's colors
_pop color
_pop bgcolor
_pop link
_pop alink
if [info exists ar(bgcolor)] {
set _bgcolor $ar(bgcolor)
} else {
set _bgcolor [_peek bgcolor]
}
if [info exists ar(text)] {
set _color $ar(text)
} else {
set _color [_peek color]
}
if [info exists ar(link)] {
set _link $ar(link)
} else {
set _link [_peek link]
}
if [info exists ar(alink)] {
set _alink $ar(alink)
} else {
set _alink [_peek alink]
}
# push this row's defaults
_push color $_color
_push bgcolor $_bgcolor
_push link $_link
_push alink $_alink
$_hottext configure -state disabled
_push row [expr {[_pop row] + 1}]
_pop column
_push column 0
}
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/tr
#
# end table row
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/tr {} {
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_tt
#
# Show typewriter text, using the font given by -fixedfont
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_tt {} {
_push font $_font
set _font $itk_option(-fixedfont)
set _verbatim 1
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/tt
#
# Change back to non-typewriter mode to display text
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/tt {} {
set _font [_pop font]
set _verbatim 0
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_u
#
# display underlined text
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_u {} {
incr _underline
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/u
#
# change back from underlined text
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/u {} {
incr _underline -1
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_ul
#
# begin unordered list
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_ul {{args {}}} {
_parse_fields ar $args
if $_left {
_entity_br
} else {
_entity_p
}
if [info exists ar(id)] {
set _anchor($ar(id)) [$itk_component(text) index end]
}
_push left $_left
_push left2 $_left2
if {$_left2 == $_left } {
incr _left2 [expr {$_indentincr+3}]
} else {
incr _left2 $_indentincr
}
incr _left $_indentincr
_push listyle $_listyle
_push licount $_licount
if [info exists ar(plain)] {
set _listyle none
} {
set _listyle bullet
}
if [info exists ar(dingbat)] {
set ar(src) $ar(dingbat)
}
_push lipic $_lipic
if [info exists ar(src)] {
set _listyle picture
set _lipic $ar(src)
}
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/ul
#
# end unordered list
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/ul {} {
set _left [_pop left]
set _left2 [_pop left2]
set _listyle [_pop listyle]
set _licount [_pop licount]
set _lipic [_pop lipic]
_set_tag
_entity_p
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_var
#
# Display variable
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_var {} {
_entity_i
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/var
#
# change state back from variable display
# ------------------------------------------------------------------
itcl::body iwidgets::Scrolledhtml::_entity_/var {} {
_entity_/i
}
|