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
|
unit IpHtmlNodes;
{ Global defines potentially affecting this unit }
{$I IPDEFINE.INC}
interface
uses
// LCL
LCLType, LCLIntf,
// RTL, FCL
Types, Math, Classes, SysUtils,
// LCL
Graphics, GraphUtil,
Controls, StdCtrls, ExtCtrls, Buttons, Dialogs,
// TurboPower_ipro
IpConst, IpCSS, IpHtmlTypes, IpHtmlClasses, IpHtmlProp,
IpHtmlUtils, IpMsg, IpHtml;
type
{ Descendants of TIpHtmlNode }
TIpHtmlNodeText = class(TIpHtmlNode)
private
FEscapedText: string;
FFirstW: Boolean;
function GetAnsiText: string;
procedure SetAnsiText(const Value: string);
procedure SetEscapedText(const Value: string);
procedure AddAWord(StartP: PAnsiChar);
function CutAndAddWord(StartP, EndP: PAnsiChar): PAnsiChar;
procedure DoPreformattedWords(N: PAnsiChar);
procedure DoNormalWords(N: PAnsiChar);
procedure BuildWordList;
protected
PropsR : TIpHtmlProps; {reference}
public
constructor Create(ParentNode : TIpHtmlNode);
destructor Destroy; override;
procedure ReportDrawRects(M : TRectMethod); override;
procedure Enqueue; override;
procedure EnqueueElement(const Entry: PIpHtmlElement); override;
function ElementQueueIsEmpty: Boolean; override;
procedure SetProps(const RenderProps: TIpHtmlProps); override;
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property ANSIText: string read GetAnsiText write SetAnsiText;
property EscapedText: string read FEscapedText write SetEscapedText;
end;
{ Descendants of TIpHtmlNodeNv <- TIpHtmlNode }
TIpHtmlNodeMETA = class(TIpHtmlNodeNv)
private
FScheme: string;
FContent: string;
FHttpEquiv: string;
FName: string;
public
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property Content: string read FContent write FContent;
property HttpEquiv: string read FHttpEquiv write FHttpEquiv;
property Name: string read FName write FName;
property Scheme: string read FScheme write FScheme;
end;
TIpHtmlNodePARAM = class(TIpHtmlNodeNv)
private
FId: string;
FValueType: TIpHtmlObjectValueType;
FValue: string;
FName: string;
public
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property Id: string read FId write FId;
property Name: string read FName write FName;
property Value: string read FValue write FValue;
property ValueType: TIpHtmlObjectValueType read FValueType write FValueType;
end;
TIpHtmlNodeSCRIPT = class(TIpHtmlNodeNv);
{ Descendants of TIpHtmlNodeCore <-- TIpHtmlNodeMulti <-- TIpHtmlNode }
TIpHtmlNodeAREA = class(TIpHtmlNodeCore)
private
FShape: TIpHtmlMapShape;
FTabIndex: Integer;
FTarget: string;
protected
FNoHRef: Boolean;
FHRef: string;
FCoords: string;
FAlt: string;
FRect : TRect;
FRgn : HRgn;
function GetHint: string; override;
public
destructor Destroy; override;
function PtInRects(const P: TPoint): Boolean;
procedure Reset;
property Rect: TRect read FRect write FRect;
property Rgn: HRgn read FRgn write FRgn;
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property Alt : string read FAlt write FAlt;
property Coords : string read FCoords write FCoords;
property HRef : string read FHRef write FHRef;
property NoHRef : Boolean read FNoHRef write FNoHRef;
property Shape : TIpHtmlMapShape read FShape write FShape;
property TabIndex : Integer read FTabIndex write FTabIndex;
property Target: string read FTarget write FTarget;
end;
TIpHtmlNodeCOL = class(TIpHtmlNodeCore)
private
FAlign: TIpHtmlAlign;
FVAlign: TIpHtmlVAlign3;
FSpan: Integer;
FWidth: TIpHtmlMultiLength;
protected
function GetAlign: TIpHtmlAlign; override;
procedure SetAlign(const Value: TIpHtmlAlign); override;
public
destructor Destroy; override;
procedure LoadAndApplyCSSProps; override;
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property Align;
property Span: Integer read FSpan write FSpan;
property VAlign: TIpHtmlVAlign3 read FVAlign write FVAlign;
property Width: TIpHtmlMultiLength read FWidth write FWidth;
end;
TIpHtmlNodeCOLGROUP = class(TIpHtmlNodeCore)
private
FAlign: TIpHtmlAlign;
FSpan: Integer;
FVAlign: TIpHtmlVAlign3;
FWidth: TIpHtmlMultiLength;
protected
function GetAlign: TIpHtmlAlign; override;
procedure SetAlign(const Value: TIpHtmlAlign); override;
public
destructor Destroy; override;
procedure LoadAndApplyCSSProps; override;
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property Align;
property Span: Integer read FSpan write FSpan;
property VAlign: TIpHtmlVAlign3 read FVAlign write FVAlign;
property Width: TIpHtmlMultiLength read FWidth write FWidth;
end;
TIpHtmlNodeFIELDSET = class(TIpHtmlNodeCore);
TIpHtmlNodeFRAME = class(TIpHtmlNodeCore)
private
FFrameBorder: Integer;
FLongDesc: string;
FMarginHeight: Integer;
FMarginWidth: Integer;
FName: string;
FNoResize: Boolean;
FScrolling: TIpHtmlFrameScrolling;
FSrc: string;
procedure SetFrameBorder(const Value: Integer);
procedure SetMarginHeight(const Value: Integer);
procedure SetMarginWidth(const Value: Integer);
procedure SetScrolling(const Value: TIpHtmlFrameScrolling);
public
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property FrameBorder : Integer read FFrameBorder write SetFrameBorder;
property LongDesc : string read FLongDesc write FLongDesc;
property MarginHeight : Integer read FMarginHeight write SetMarginHeight;
property MarginWidth : Integer read FMarginWidth write SetMarginWidth;
property Name : string read FName write FName;
property NoResize : Boolean read FNoResize write FNoResize;
property Scrolling : TIpHtmlFrameScrolling read FScrolling write SetScrolling;
property Src : string read FSrc write FSrc;
end;
TIpHtmlNodeLEGEND = class(TIpHtmlNodeCore)
private
FAlign: TIpHtmlVAlignment2;
public
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property Align : TIpHtmlVAlignment2 read FAlign write FAlign;
end;
TIpHtmlNodeLINK = class(TIpHtmlNodeCore)
private
FHRef: string;
FRev: string;
FRel: string;
FType: string;
public
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property HRef : string read FHRef write FHRef;
property Rel : string read FRel write FRel;
property Rev : string read FRev write FRev;
property Type_ : string read FType write FType;
end;
TIpHtmlNodeMAP = class(TIpHtmlNodeCore)
private
FName : string;
public
constructor Create(ParentNode : TIpHtmlNode);
destructor Destroy; override;
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property Name : string read FName write FName;
end;
TIpHtmlNodeNOFRAMES = class(TIpHtmlNodeCore);
TIpHtmlNodeOPTGROUP = class(TIpHtmlNodeCore)
private
FDisabled: Boolean;
FGroupLabel: string;
public
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property Disabled : Boolean read FDisabled write FDisabled;
property GroupLabel : string read FGroupLabel write FGroupLabel;
end;
TIpHtmlNodeOPTION = class(TIpHtmlNodeCore)
private
FDisabled: Boolean;
FOptionLabel: string;
FSelected: Boolean;
FValue: string;
public
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property Disabled : Boolean read FDisabled write FDisabled;
property OptionLabel : string read FOptionLabel write FOptionLabel;
property Selected : Boolean read FSelected write FSelected;
property Value : string read FValue write FValue;
end;
TIpHtmlNodeTHeadFootBody = class(TIpHtmlNodeCore)
private
FAlign: TIpHtmlAlign;
protected
function GetAlign: TIpHtmlAlign; override;
procedure SetAlign(const Value: TIpHtmlAlign); override;
public
procedure LoadAndApplyCSSProps; override;
end;
TIpHtmlNodeTABLEHEADFOOTBODYClass = class of TIpHtmlNodeTHeadFootBody;
TIpHtmlNodeTR = class(TIpHtmlNodeCore)
private
FAlign: TIpHtmlAlign;
FVAlign: TIpHtmlVAlign;
FBgColor: TColor;
FTextColor: TColor;
procedure SetBgColor(const AValue: TColor);
procedure SetTextColor(const AValue: TColor);
protected
procedure AppendSelection(var S: String; var Completed: Boolean); override;
function GetAlign: TIpHtmlAlign; override;
procedure SetAlign(const Value: TIpHtmlAlign); override;
public
constructor Create(ParentNode : TIpHtmlNode);
procedure LoadAndApplyCSSProps; override;
procedure SetProps(const RenderProps: TIpHtmlProps); override;
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property Align;
property VAlign : TIpHtmlVAlign read FVAlign write FVAlign;
property BgColor: TColor read FBgColor write SetBgColor;
property TextColor: TColor read FTextColor write SetTextColor;
end;
{ Descendants of TIpHtmlNodeHeadFootBody <-- TIpHtmlNodeCore <-- TIpHtmNodeMulti <-- TIpHtmlNode }
TIpHtmlNodeTBODY = class(TIpHtmlNodeTHeadFootBody)
private
FVAlign: TIpHtmlVAlign3;
public
constructor Create(ParentNode : TIpHtmlNode);
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property Align;
property VAlign : TIpHtmlVAlign3 read FVAlign write FVAlign;
end;
TIpHtmlNodeTFOOT = class(TIpHtmlNodeTHeadFootBody)
private
FVAlign: TIpHtmlVAlign3;
public
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property VAlign : TIpHtmlVAlign3 read FVAlign write FVAlign;
end;
TIpHtmlNodeTHEAD = class(TIpHtmlNodeTHeadFootBody)
private
FVAlign: TIpHtmlVAlign3;
protected
public
constructor Create(ParentNode : TIpHtmlNode);
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property Align;
property VAlign : TIpHtmlVAlign3 read FVAlign write FVAlign;
end;
{ Descendants of TIpHtmlNodeBlock <-- TIpHtmlNodeCore <-- TIpHtmNodeMulti <-- TIpHtmlNode }
TIpHtmlNodeCAPTION = class(TIpHtmlNodeBlock)
private
FAlign: TIpHtmlVAlignment2;
public
constructor Create(ParentNode: TIpHtmlNode);
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property Align: TIpHtmlVAlignment2 read FAlign write FAlign;
end;
TIpHtmlNodeTableHeaderOrCell = class(TIpHtmlNodeBlock)
private
FAlign: TIpHtmlAlign;
FCalcWidthMin: Integer;
FCalcWidthMax: Integer;
FColspan: Integer;
FHeight: TIpHtmlPixels;
FNowrap: Boolean;
FRowspan: Integer;
FWidth: TIpHtmlLength;
FVAlign: TIpHtmlVAlign3;
protected
procedure AppendSelection(var S: String; var Completed: Boolean); override;
function GetAlign: TIpHtmlAlign; override;
procedure SetAlign(const Value: TIpHtmlAlign); override;
public
FPadRect : TRect;
constructor Create(ParentNode : TIpHtmlNode);
destructor Destroy; override;
procedure Layout(RenderProps: TIpHtmlProps; const TargetRect : TRect); override;
procedure LoadAndApplyCSSProps; override;
procedure Render(RenderProps: TIpHtmlProps); override;
procedure CalcMinMaxPropWidth(RenderProps: TIpHtmlProps; var Min, Max: Integer); override;
procedure DimChanged(Sender: TObject);
public
property PadRect : TRect read FPadRect write FPadRect;
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property Align;
property BgColor;
property CalcWidthMin: Integer read FCalcWidthMin write FCalcWidthMin;
property CalcWidthMax: Integer read FCalcWidthMax write FCalcWidthMax;
property Colspan : Integer read FColspan write FColspan;
property Height : TIpHtmlPixels{Integer} read FHeight write FHeight;
property Nowrap : Boolean read FNowrap write FNowrap;
property Rowspan : Integer read FRowspan write FRowspan;
property VAlign : TIpHtmlVAlign3 read FVAlign write FVAlign;
property Width : TIpHtmlLength read FWidth write FWidth;
end;
{ Descendants of TIpHtmlNodeTableHeaderOrCell <-- TIpHtmlNodeBlock
<-- TIpHtmlNodeCore <-- TIpHtmNodeMulti <-- TIpHtmlNode }
TIpHtmlNodeTH = class(TIpHtmlNodeTableHeaderOrCell)
public
constructor Create(ParentNode: TIpHtmlNode);
end;
TIpHtmlNodeTD = class(TIpHtmlNodeTableHeaderOrCell)
public
constructor Create(ParentNode: TIpHtmlNode);
end;
{ Descendants of TIpHtmlNodeInline <-- TIpHtmlNodeCore <-- TIpHtmlNodeMulti <-- TIpHtmlNode }
TIpHtmlNodeA = class(TIpHtmlNodeInline)
private
FHRef: string;
FName: string;
FRel: string;
FRev: string;
FShape: TIpHtmlMapShape;
FTabIndex: Integer;
FTarget: string;
procedure SetHRef(const Value: string);
procedure SetName(const Value: string);
protected
FHasRef : Boolean;
FHot: Boolean;
MapAreaList: TFPList;
procedure ClearAreaList; override;
procedure SetHot(const Value: Boolean);
procedure BuildAreaList; override;
procedure AddMapArea(const R: TRect);
function GetHint: string; override;
property HasRef: Boolean read FHasRef;
public
constructor Create(ParentNode: TIpHtmlNode);
destructor Destroy; override;
// procedure MakeVisible; override;
procedure SetProps(const RenderProps: TIpHtmlProps); override;
public
// These were originally protected, but had to be made public for unit IpHtmlNodes.
procedure DoOnBlur;
procedure DoOnFocus;
function PtInRects(const P: TPoint): Boolean;
function RelMapPoint(const P: TPoint): TPoint;
property Hot: Boolean read FHot write SetHot;
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property HRef: string read FHRef write SetHRef;
property Name: string read FName write SetName;
property Rel: string read FRel write FRel;
property Rev: string read FRev write FRev;
property Shape: TIpHtmlMapShape read FShape write FShape;
property TabIndex: Integer read FTabIndex write FTabIndex;
property Target: string read FTarget write FTarget;
end;
TIpHtmlNodeADDRESS = class(TIpHtmlNodeInline);
TIpHtmlNodeAPPLET = class(TIpHtmlNodeInline)
private
FArchive: string;
FObjectCode: string;
FVSpace: Integer;
FHSpace: Integer;
FHeight: Integer;
FWidth: TIpHtmlLength;
FName: string;
FCodebase: string;
FCode: string;
FAlt: string;
FAlignment: TIpHtmlImageAlign;
protected
function GetHint: string; override;
public
destructor Destroy; override;
procedure WidthChanged(Sender: TObject);
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property Align : TIpHtmlImageAlign read FAlignment write FAlignment;
property Archive : string read FArchive write FArchive;
property Alt : string read FAlt write FAlt;
property ClassID;
property Code : string read FCode write FCode;
property Codebase : string read FCodebase write FCodebase;
property Height : Integer read FHeight write FHeight;
property HSpace : Integer read FHSpace write FHSpace;
property Id;
property Name : string read FName write FName;
property ObjectCode : string read FObjectCode write FObjectCode;
property Style;
property Title;
property VSpace : Integer read FVSpace write FVSpace;
property Width : TIpHtmlLength read FWidth write FWidth;
end;
TIpHtmlNodeBLINK = class(TIpHtmlNodeInline);
TIpHtmlNodeBLOCKQUOTE = class(TIpHtmlNodeInline)
public
procedure Enqueue; override;
end;
TIpHtmlNodeBR = class(TIpHtmlNodeInline)
private
FClear: TIpHtmlBreakClear;
FId: string;
protected
procedure SetClear(const Value: TIpHtmlBreakClear);
function GetMargin(AMargin: TIpHtmlElemMargin; ADefault:Integer): Integer; override;
public
constructor Create(ParentNode: TIpHtmlNode);
procedure Enqueue; override;
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property ClassID;
property Clear : TIpHtmlBreakClear read FClear write SetClear;
property Id : string read FId write FId;
property Title;
end;
TIpHtmlNodeDD = class(TIpHtmlNodeInline)
public
constructor Create(ParentNode: TIpHtmlNode);
procedure Enqueue; override;
end;
TIpHtmlNodeDIV = class(TIpHtmlNodeInline)
private
FAlign : TIpHtmlAlign;
protected
function GetAlign: TIpHtmlAlign; override;
procedure SetAlign(const Value: TIpHtmlAlign); override;
public
constructor Create(ParentNode : TIpHtmlNode);
destructor Destroy; override;
procedure Enqueue; override;
procedure LoadAndApplyCSSProps; override;
procedure SetProps(const RenderProps: TIpHtmlProps); override;
(*
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property Align : TIpHtmlAlign read FAlign write FAlign;
*)
end;
TIpHtmlNodeDL = class(TIpHtmlNodeInline)
private
FCompact : Boolean;
public
constructor Create(ParentNode : TIpHtmlNode);
procedure Enqueue; override;
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property Compact : Boolean read FCompact write FCompact;
end;
TIpHtmlNodeDT = class(TIpHtmlNodeInline)
public
constructor Create(ParentNode: TIpHtmlNode);
procedure Enqueue; override;
end;
TIpHtmlNodeFORM = class(TIpHtmlNodeInline)
private
FAccept: string;
FAcceptCharset: string;
FName: string;
FEnctype: string;
FAction: string;
FMethod: TIpHtmlFormMethod;
protected
procedure AddChild(Node: TIpHtmlNode; const UserData: Pointer);
procedure ResetControl(Node: TIpHtmlNode; const UserData: Pointer);
procedure ResetRequest; override;
{$IFNDEF HtmlWithoutHttp}
procedure SubmitRequest; override;
{$ENDIF}
public
constructor Create(ParentNode: TIpHtmlNode);
destructor Destroy; override;
procedure ResetForm;
procedure SubmitForm;
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property Accept : string read FAccept write FAccept;
property AcceptCharset : string read FAcceptCharset write FAcceptCharset;
property Action : string read FAction write FAction;
property Enctype : string read FEnctype write FEnctype;
property Method : TIpHtmlFormMethod read FMethod write FMethod;
property Name : string read FName write FName;
end;
TIpHtmlNodeGenInline = class(TIpHtmlNodeInline)
protected
Props: TIpHtmlProps;
procedure ApplyProps(const RenderProps: TIpHtmlProps); virtual; abstract;
public
constructor Create(ParentNode: TIpHtmlNode);
destructor Destroy; override;
procedure SetProps(const RenderProps: TIpHtmlProps); override;
end;
TIpHtmlNodeLABEL = class(TIpHtmlNodeInline)
private
FLabelFor: string;
public
constructor Create(ParentNode: TIpHtmlNode);
destructor Destroy; override;
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property LabelFor : string read FLabelFor write FLabelFor;
end;
TIpHtmlNodeList = class(TIpHtmlNodeInline)
private
FCompact: Boolean;
FListType: TIpHtmlULType;
procedure SetListType(const Value: TIpHtmlULType);
public
procedure Enqueue; override;
procedure LoadAndApplyCSSProps; override;
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property Compact: Boolean read FCompact write FCompact;
property ListType: TIpHtmlULType read FListType write SetListType;
end;
TIpHtmlNodeNOSCRIPT = class(TIpHtmlNodeInline);
TIpHtmlNodeOBJECT = class(TIpHtmlNodeInline)
private
FAlignment: TIpHtmlImageAlign;
FArchive: string;
FBorder: Integer;
FCodebase: string;
FCodeType: string;
FData: string;
FDeclare: Boolean;
FHeight: Integer;
FHSpace: Integer;
FName: string;
FStandby: string;
FUseMap: string;
FVSpace: Integer;
FWidth: TIpHtmlLength;
protected
public
destructor Destroy; override;
procedure WidthChanged(Sender: TObject);
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property Align : TIpHtmlImageAlign read FAlignment write FAlignment;
property Archive : string read FArchive write FArchive;
property Border : Integer read FBorder write FBorder;
property ClassID;
property Codebase : string read FCodebase write FCodebase;
property CodeType : string read FCodeType write FCodeType;
property Data : string read FData write FData;
property Declare : Boolean read FDeclare write FDeclare;
property Height : Integer read FHeight write FHeight;
property HSpace : Integer read FHSpace write FHSpace;
property Name : string read FName write FName;
property Standby : string read FStandby write FStandby;
property UseMap : string read FUseMap write FUseMap;
property VSpace : Integer read FVSpace write FVSpace;
property Width : TIpHtmlLength read FWidth write FWidth;
end;
TIpHtmlNodePRE = class(TIpHtmlNodeInline)
public
constructor Create(ParentNode : TIpHtmlNode);
destructor Destroy; override;
procedure Enqueue; override;
procedure SetProps(const RenderProps: TIpHtmlProps); override;
end;
TIpHtmlNodeQ = class(TIpHtmlNodeInline);
{ Descendants of TIpHtmlNodeAlignInline <-- TIpHtmlNodeInline
<-- TIpHtmlNodeCore <-- TIpHtmlNodeMulti <-- TIpHtmlNode }
TIpHtmlNodeHR = class(TIpHtmlNodeAlignInline)
private
FColor: TColor;
FNoShade : Boolean;
FSize : TIpHtmlInteger;
FWidth : TIpHtmlLength;
protected
SizeWidth : TIpHtmlPixels;
FDim : TSize;
function GrossDrawRect: TRect;
public
constructor Create(ParentNode: TIpHtmlNode);
destructor Destroy; override;
procedure Draw(Block: TIpHtmlNodeBlock); override;
procedure CalcMinMaxWidth(var Min, Max: Integer); override;
procedure Enqueue; override;
function GetDim(ParentWidth: Integer): TSize; override;
procedure WidthChanged(Sender: TObject);
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property Color : TColor read FColor write FColor;
property NoShade : Boolean read FNoShade write FNoShade;
property Size : TIpHtmlInteger read FSize write FSize;
property Width : TIpHtmlLength read FWidth write FWidth;
end;
TIpHtmlNodeIMG = class(TIpHtmlNodeAlignInline)
private
FAlt: string;
FBorder: Integer;
FHeight: TIpHtmlPixels;
FHSpace: Integer;
FIsMap: Boolean;
FLongDesc: string;
FName: string;
FPicture : TPicture;
FSrc: string;
FUseMap: string;
FVSpace: Integer;
FWidth: TIpHtmlLength;
function GetBorder: Integer;
procedure SetBorder(const Value: Integer);
procedure SetUseMap(const Value: string);
procedure SetHSpace(const Value: Integer);
procedure SetVSpace(const Value: Integer);
protected
FSize: TSize;
NetDrawRect: TRect;
SizeWidth: TIpHtmlPixels;
function GetHint: string; override;
procedure InvalidateSize; override;
public
constructor Create(ParentNode : TIpHtmlNode);
destructor Destroy; override;
procedure Draw(Block: TIpHtmlNodeBlock); override;
procedure SetProps(const RenderProps: TIpHtmlProps); override;
procedure CalcMinMaxWidth(var Min, Max: Integer); override;
function GetDim(ParentWidth: Integer): TSize; override;
procedure ImageChange(NewPicture : TPicture); override;
procedure DimChanged(Sender: TObject);
public
// Were protected initially, but had to be made public for unit IpHtmlNodes
function GrossDrawRect: TRect;
procedure LoadImage;
procedure UnloadImage;
procedure ReportDrawRects(M : TRectMethod); override;
procedure ReportMapRects(M : TRectMethod); override;
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property Alt: string read FAlt write FAlt;
property Border: Integer read GetBorder write SetBorder;
property Height: TIpHtmlPixels read FHeight write FHeight;
property HSpace: Integer read FHSpace write SetHSpace;
property IsMap: Boolean read FIsMap write FIsMap;
property LongDesc: string read FLongDesc write FLongDesc;
property Name: string read FName write FName;
property Picture: TPicture read FPicture;
property Src: string read FSrc write FSrc;
property UseMap: string read FUseMap write SetUseMap;
property VSpace: Integer read FVSpace write SetVSpace;
property Width: TIpHtmlLength read FWidth write FWidth;
end;
TIpHtmlNodeLI = class(TIpHtmlNodeAlignInline)
private
FCompact: Boolean;
FListType : TIpHtmlULType;
FValue : Integer;
procedure SetListType(const Value: TIpHtmlULType);
procedure SetValue(const Value: Integer);
protected
WordEntry : PIpHtmlElement;
function GrossDrawRect: TRect;
public
constructor Create(ParentNode : TIpHtmlNode);
procedure Draw(Block: TIpHtmlNodeBlock); override;
procedure Enqueue; override;
procedure SetProps(const RenderProps: TIpHtmlProps); override;
procedure CalcMinMaxWidth(var Min, Max: Integer); override;
function GetDim(ParentWidth: Integer): TSize; override;
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property Compact : Boolean read FCompact write FCompact;
property ListType : TIpHtmlULType read FListType write SetListType;
property Value : Integer read FValue write SetValue;
end;
TIpHtmlNodeOL = class(TIpHtmlNodeInline)
private
FCompact: Boolean;
FStart: Integer;
FOLStyle: TIpHtmlOLStyle;
procedure SetStart(const Value: Integer);
procedure SetOLStyle(const Value: TIpHtmlOLStyle);
protected
Counter: Integer;
function GetNumString: string;
public
constructor Create(ParentNode: TIpHtmlNode);
procedure Enqueue; override;
procedure LoadAndApplyCSSProps; override;
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property Compact: Boolean read FCompact write FCompact;
property Start: Integer read FStart write SetStart;
property Style: TIpHtmlOLStyle read FOLStyle write SetOLStyle;
end;
{ TIpHtmlNodeTABLE }
TIpHtmlNodeTABLE = class(TIpHtmlNodeAlignInline)
private
FBgColor: TColor;
FBorder: Integer;
FBorderColor: TColor;
FBorderStyle: TCSSBorderStyle;
FFrame: TIpHtmlFrameProp;
FRules: TIpHtmlRules;
FSummary: string;
function GetCellPadding: Integer;
function GetCellSpacing: Integer;
function GetMaxWidth: Integer;
function GetMinWidth: Integer;
function GetTableWidth: Integer;
procedure SetBorder(const Value: Integer);
procedure SetCellPadding(const Value: Integer);
procedure SetCellSpacing(const Value: Integer);
procedure SetFrame(const Value: TIpHtmlFrameProp);
procedure SetRules(const Value: TIpHtmlRules);
protected
FWidth: TIpHtmlLength;
SizeWidth : TIpHtmlPixels; {last computed width of table}
procedure SetRect(TargetRect: TRect); override;
procedure InvalidateSize; override;
function GetColCount: Integer;
public
FCaption: TIpHtmlNodeCAPTION;
FLayouter: TIpHtmlBaseTableLayouter;
BorderRect: TRect;
BorderRect2: TRect; {includes caption if any}
constructor Create(ParentNode : TIpHtmlNode);
destructor Destroy; override;
procedure Draw(Block: TIpHtmlNodeBlock); override;
function ExpParentWidth: Integer; override;
procedure SetProps(const RenderProps: TIpHtmlProps); override;
procedure CalcMinMaxWidth(var Min, Max: Integer); override;
procedure Enqueue; override;
function GetDim(ParentWidth: Integer): TSize; override;
procedure LoadAndApplyCSSProps; override;
procedure WidthChanged(Sender: TObject);
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property BgColor: TColor read FBgColor write FBgColor;
property Border: Integer read FBorder write SetBorder;
property BorderStyle: TCSSBorderStyle read FBorderStyle write FBorderStyle;
property BorderColor: TColor read FBorderColor write FBorderColor;
property CalcMinWidth: Integer read GetMinWidth;
property CalcMaxWidth: Integer read GetMaxWidth;
property CalcTableWidth: Integer read GetTableWidth;
property CellPadding: Integer read GetCellPadding write SetCellPadding;
property CellSpacing: Integer read GetCellSpacing write SetCellSpacing;
property ColCount: Integer read GetColCount;
property Frame: TIpHtmlFrameProp read FFrame write SetFrame;
property Rules: TIpHtmlRules read FRules write SetRules;
property Summary: string read FSummary write FSummary;
property Width: TIpHtmlLength read FWidth write FWidth;
end;
{ Descendants of TIpHtmlNodeGenInline <-- TIpHtmlNodeInline
<-- TIpHtmlNodeCore <-- TIpHtmlNodeMulti <-- TIpHtmlNode}
TIpHtmlNodeBASEFONT = class(TIpHtmlNodeGenInline)
private
FSize: Integer;
protected
procedure ApplyProps(const RenderProps: TIpHtmlProps); override;
public
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property Size : Integer read FSize write FSize;
end;
TIpHtmlNodeDEL = class(TIpHtmlNodeGenInline)
private
FCite: string;
FDateTime: string;
protected
procedure ApplyProps(const RenderProps: TIpHtmlProps); override;
public
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property Cite: string read FCite write FCite;
property DateTime: string read FDateTime write FDateTime;
end;
TIpHtmlNodeFONT = class(TIpHtmlNodeGenInline)
private
FSize: TIpHtmlRelSize;
FFace: string;
FColor: TColor;
procedure SetColor(const Value: TColor);
procedure SetFace(const Value: string);
protected
procedure ApplyProps(const RenderProps: TIpHtmlProps); override;
public
constructor Create(ParentNode : TIpHtmlNode);
destructor Destroy; override;
procedure SizeChanged(Sender: TObject);
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property Color : TColor read FColor write SetColor;
property Face : string read FFace write SetFace;
property Size : TIpHtmlRelSize read FSize write FSize;
end;
TIpHtmlNodeFontStyle = class(TIpHtmlNodeGenInline)
private
FHFStyle: TIpHtmlFontStyles;
protected
procedure ApplyProps(const RenderProps: TIpHtmlProps); override;
public
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property Style: TIpHtmlFontStyles read FHFStyle write FHFStyle;
end;
TIpHtmlNodeINS = class(TIpHtmlNodeGenInline)
private
FCite: string;
FDateTime: string;
protected
procedure ApplyProps(const RenderProps: TIpHtmlProps); override;
public
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property Cite: string read FCite write FCite;
property DateTime: string read FDateTime write FDateTime;
end;
TIpHtmlNodeNOBR = class(TIpHtmlNodeGenInline)
protected
procedure ApplyProps(const RenderProps: TIpHtmlProps); override;
public
end;
TIpHtmlNodePhrase = class(TIpHtmlNodeGenInline)
private
FPhrStyle: TIpHtmlPhraseStyle;
protected
procedure ApplyProps(const RenderProps: TIpHtmlProps); override;
public
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property Style : TIpHtmlPhraseStyle read FPhrStyle write FPhrStyle;
end;
TIpHtmlNodeSPAN = class(TIpHtmlNodeGenInline)
private
FAlign : TIpHtmlAlign;
protected
procedure ApplyProps(const RenderProps: TIpHtmlProps); override;
function GetAlign: TIpHtmlAlign; override;
procedure SetAlign(const Value: TIpHtmlAlign); override;
public
constructor Create(ParentNode: TIpHtmlNode);
procedure LoadAndApplyCSSProps; override;
(*
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property Align : TIpHtmlAlign read FAlign write FAlign;
*)
end;
{ Descendants of TIpHtmlNodeList <-- TIpHtmlNodeInline <-- TIpHtmlNodeCore
<-- TIpHtmlNodeMulti <-- TIpHtmlNode}
TIpHtmlNodeUL = class(TIpHtmlNodeList)
public
constructor Create(ParentNode: TIpHtmlNode);
end;
TIpHtmlNodeDIR = class(TIpHtmlNodeList);
TIpHtmlNodeMENU = class(TIpHtmlNodeList);
{ Descendants of TIpHtmlNodeControl <-- TIpHtmlNodeAlignInline
<-- TIpHtmlNodeInline <-- TIpHtmlNodeCore <-- TIpHtmlNodeMulti
<-- TIpHtmlNode}
TIpHtmlNodeBUTTON = class(TIpHtmlNodeControl)
private
FTabIndex: Integer;
FValue: string;
FName: string;
FInputType: TIpHtmlButtonType;
function GetButtonCaption: String;
procedure SetInputType(const AValue: TIpHtmlButtonType);
procedure SetValue(const AValue: String);
protected
procedure CalcSize;
procedure SubmitClick(Sender: TObject);
procedure ResetClick(Sender: TObject);
procedure ButtonClick(Sender: TObject);
procedure CreateControl(Parent : TWinControl); override;
public
constructor Create(ParentNode : TIpHtmlNode);
destructor Destroy; override;
procedure AddValues(NameList, ValueList : TStringList); override;
procedure Reset; override;
function Successful: Boolean; override;
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property ButtonType : TIpHtmlButtonType read FInputType write SetInputType;
property Disabled;
property Name : string read FName write FName;
property TabIndex : Integer read FTabIndex write FTabIndex;
property Value : string read FValue write SetValue;
end;
TIpHtmlNodeINPUT = class(TIpHtmlNodeControl)
private
FChecked: Boolean;
FInputType: TIpHtmlInputType;
FMaxLength: Integer;
FName: string;
FReadOnly: Boolean;
FTabIndex: Integer;
FSize: Integer;
FSrc: string;
FValue: string;
protected
FPicture : TPicture;
FFileEdit : TEdit;
FFileSelect : TButton;
procedure SubmitClick(Sender: TObject);
procedure ResetClick(Sender: TObject);
procedure FileSelect(Sender: TObject);
procedure getControlValue;
procedure ButtonClick(Sender: TObject);
procedure ControlOnEditingDone(Sender: TObject);
procedure ControlOnChange(Sender: TObject);
function GetHint: string; override;
procedure SetImageGlyph(Picture: TPicture);
procedure CreateControl(Parent : TWinControl); override;
public
constructor Create(ParentNode : TIpHtmlNode);
destructor Destroy; override;
procedure AddValues(NameList, ValueList : TStringList); override;
procedure Draw(Block: TIpHtmlNodeBlock); override;
procedure Reset; override;
function Successful: Boolean; override;
procedure ImageChange(NewPicture : TPicture); override;
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property Alt;
property Checked : Boolean read FChecked write FChecked;
property Disabled;
property InputType : TIpHtmlInputType read FInputType write FInputType;
property MaxLength : Integer read FMaxLength write FMaxLength;
property Name : string read FName write FName;
property ReadOnly : Boolean read FReadOnly write FReadOnly;
property Size : Integer read FSize write FSize;
property Src : string read FSrc write FSrc;
property TabIndex : Integer read FTabIndex write FTabIndex;
property Value : string read FValue write FValue;
end;
TIpHtmlNodeSELECT = class(TIpHtmlNodeControl)
private
FMultiple: Boolean;
FComboBox: Boolean;
FName: string;
FSize: Integer;
FWidth: integer;
FTabIndex: Integer;
protected
procedure CreateControl(Parent : TWinControl); override;
procedure ButtonClick(Sender: TObject);
procedure ControlOnEditingDone(Sender: TObject);
procedure ListBoxSelectionChange(Sender: TObject; User: boolean);
procedure setText(aText: string);
function getText: string;
public
constructor Create(ParentNode : TIpHtmlNode);
destructor Destroy; override;
procedure AddValues(NameList, ValueList : TStringList); override;
procedure Reset; override;
function Successful: Boolean; override;
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property Disabled;
property Multiple : Boolean read FMultiple write FMultiple;
property ComboBox : Boolean read FComboBox write FComboBox;
property Name : string read FName write FName;
property Size : Integer read FSize write FSize;
property Width : Integer read FWidth write FWidth;
property TabIndex : Integer read FTabIndex write FTabIndex;
property Text : string read getText write setText;
end;
TIpHtmlNodeTEXTAREA = class(TIpHtmlNodeControl)
private
FReadOnly: Boolean;
FTabIndex: Integer;
FCols: Integer;
FRows: Integer;
FName: string;
protected
procedure CreateControl(Parent : TWinControl); override;
procedure ControlOnEditingDone(Sender: TObject);
public
constructor Create(ParentNode: TIpHtmlNode);
destructor Destroy; override;
procedure AddValues(NameList, ValueList : TStringList); override;
procedure Reset; override;
function Successful: Boolean; override;
{$IFDEF HTML_RTTI}
published
{$ENDIF}
property Cols : Integer read FCols write FCols;
property Disabled;
property Name : string read FName write FName;
property ReadOnly : Boolean read FReadOnly write FReadOnly;
property Rows : Integer read FRows write FRows;
property TabIndex : Integer read FTabIndex write FTabIndex;
end;
implementation
uses
{$IFDEF UseGifImageUnit} //TODO all of this units not exists
GifImage,
{$ELSE}
IpAnim,
{$IFDEF AndersGIFImage }
IpAnAGif,
{$ENDIF}
{$IFDEF ImageLibGIFImage }
IpAnImgL,
{$ENDIF}
{$ENDIF}
StrUtils, LazStringUtils;
type
THtmlRadioButton = class(TRadioButton)
protected
FChecked: Boolean;
procedure SetChecked(Value: Boolean); override;
function GetChecked: Boolean; override;
procedure CreateWnd; override;
end;
procedure THtmlRadioButton.CreateWnd;
begin
inherited CreateWnd;
//SendMessage(Handle, BM_SETCHECK, Integer(FChecked), 0);
end;
function THtmlRadioButton.GetChecked: Boolean;
begin
Result := FChecked;
end;
procedure THtmlRadioButton.SetChecked(Value: Boolean);
begin
inherited SetChecked(Value);
end;
function CalcBorderColor(AColor: TColor; AStyle: TCSSBorderStyle;
ASide: TIpHtmlFrameProp): TColor;
begin
case AStyle of
cbsRidge,
cbsInset:
if ASide in [hfAbove, hfLhs] then
Result := ColorAdjustLuma(AColor, -60, False)
else
Result := ColorAdjustLuma(AColor, 60, False);
cbsGroove,
cbsOutset:
if ASide in [hfAbove, hfLhs] then
Result := ColorAdjustLuma(AColor, 60, False)
else
Result := ColorAdjustLuma(AColor, -60, False);
else
Result := AColor;
end;
end;
{-------------------------------------------------------------------------------
Descendants of TIpHtmlNodeText
-------------------------------------------------------------------------------}
{ TIpHtmlNodeText }
constructor TIpHtmlNodeText.Create(ParentNode : TIpHtmlNode);
begin
inherited Create(ParentNode);
PropsR := TIpHtmlProps.Create(FOwner.PropACache, FOwner.PropBCache);
end;
destructor TIpHtmlNodeText.Destroy;
begin
inherited;
PropsR.Free;
end;
procedure TIpHtmlNodeText.SetProps(const RenderProps: TIpHtmlProps);
var
bgCol: TColor;
begin
bgCol := PropsR.BgColor;
PropsR.Assign(RenderProps);
if FParentNode = FOwner.Body then
PropsR.BgColor := bgCol;
end;
procedure TIpHtmlNodeText.Enqueue;
begin
BuildWordList;
end;
procedure TIpHtmlNodeText.AddAWord(StartP: PAnsiChar);
begin
if FFirstW then
Owner.AddWord(StartP, PropsR, Self)
else
Owner.AddWord(StartP, nil, Self);
FFirstW := False;
end;
function TIpHtmlNodeText.CutAndAddWord(StartP, EndP: PAnsiChar): PAnsiChar;
var
EndCh: AnsiChar;
begin
EndCh := EndP^;
EndP^ := #0;
AddAWord(StartP);
EndP^ := EndCh;
Result := EndP;
end;
procedure TIpHtmlNodeText.DoPreformattedWords(N: PAnsiChar);
var
N2: PAnsiChar;
ImplicitLF: Boolean;
begin
ImplicitLF := False;
while N^ <> #0 do begin
case N^ of
CR :
ImplicitLF := True;
LF :
begin
EnqueueElement(Owner.HardLF);
Inc(N);
ImplicitLF := False;
end;
else
begin
if ImplicitLF then begin
EnqueueElement(Owner.HardLF);
Inc(N);
ImplicitLF := False;
end;
N2 := StrScan(N, CR);
if N2 <> nil then
N := CutAndAddWord(N, N2)
else begin
N2 := StrScan(N, LF);
if N2 <> nil then
N := CutAndAddWord(N, N2)
else begin
AddAWord(N);
N^ := #0;
end;
end;
end;
end;
end;
end;
procedure TIpHtmlNodeText.DoNormalWords(N: PAnsiChar);
var
NewEntry : PIpHtmlElement;
N2: PAnsiChar;
begin
while N^ <> #0 do begin
case N^ of
LF :
begin
EnqueueElement(Owner.HardLF);
Inc(N);
end;
' ' :
begin
if not ElementQueueIsEmpty then begin
NewEntry := Owner.NewElement(etWord, Self);
NewEntry.AnsiWord := ' ';
NewEntry.IsBlank := 1;
if FFirstW then
NewEntry.Props := PropsR
else
NewEntry.Props := nil;
EnqueueElement(NewEntry);
FFirstW := False;
end;
Inc(N);
end;
else
begin
N2 := N;
while not (N2^ in [#0, ' ', LF]) do
Inc(N2);
if N2^ <> #0 then
N := CutAndAddWord(N, N2)
else begin
AddAWord(N);
N^ := #0;
end;
end;
end;
end;
end;
procedure TIpHtmlNodeText.BuildWordList;
var
l : Integer;
B : PAnsiChar;
begin
FFirstW := True;
l := length(EscapedText);
if l > 0 then begin
Getmem(B, l + 1);
try
TrimFormatting(EscapedText, B, PropsR.Preformatted);
if PropsR.Preformatted then
DoPreformattedWords(B)
else
DoNormalWords(B);
finally
FreeMem(B);
end;
end;
end;
function TIpHtmlNodeText.GetAnsiText: string;
begin
Result := EscapeToAnsi(FEscapedText);
end;
procedure TIpHtmlNodeText.EnqueueElement(const Entry: PIpHtmlElement);
begin
FParentNode.EnqueueElement(Entry);
end;
function FindInnerBlock(Node : TIpHTMLNode): TIpHtmlNodeBlock;
begin
while (Node <> nil) and not (Node is TIpHtmlNodeBlock) do
Node := Node.ParentNode;
Result := TIpHtmlNodeBlock(Node);
end;
procedure TIpHtmlNodeText.SetAnsiText(const Value: string);
begin
EscapedText := AnsiToEscape(Value);
end;
procedure TIpHtmlNodeText.SetEscapedText(const Value: string);
var
Block: TIpHtmlNodeBlock;
begin
FEscapedText := Value;
Block := FindInnerBlock(Self);
if Block = nil then
exit;
{we need to clear the queue so that it will be built again}
Block.Layouter.ClearWordList;
{then, we need to Invalidate the block so that
the rendering logic recalculates everything}
Block.InvalidateSize;
end;
procedure TIpHtmlNodeText.ReportDrawRects(M: TRectMethod);
begin
ReportCurDrawRects(Self, M);
end;
function TIpHtmlNodeText.ElementQueueIsEmpty: Boolean;
begin
Result := FParentNode.ElementQueueIsEmpty;
end;
{-------------------------------------------------------------------------------
Descendants of TIpHtmlNodeCore
-------------------------------------------------------------------------------}
{ TIpHtmlNodeAREA }
destructor TIpHtmlNodeAREA.Destroy;
var
I: Integer;
begin
I := Owner.AreaList.IndexOf(Self);
if I <> -1 then
Owner.AreaList.Delete(I);
inherited;
end;
function TIpHtmlNodeAREA.GetHint: string;
begin
if Alt <> '' then
Result := Alt
else
Result := HRef;
end;
function TIpHtmlNodeAREA.PtInRects(const P: TPoint): Boolean;
begin
if PtInRect(FRect, P) then
Result := True
else
if FRgn <> 0 then
Result := PtInRegion(FRgn, P.x, P.y)
else
Result := False;
end;
procedure TIpHtmlNodeAREA.Reset;
begin
if FRgn <> 0 then
DeleteObject(FRgn);
SetRectEmpty(FRect);
end;
{ TIpHtmlNodeCOL }
destructor TIpHtmlNodeCOL.Destroy;
begin
inherited;
FWidth.Free;
end;
procedure TIpHtmlNodeCOL.LoadAndApplyCSSProps;
begin
inherited;
if not (FCombinedCSSProps.Alignment in [haDefault, haUnknown]) then
Align := FCombinedCSSProps.Alignment;
// wp: what about VAlign?
end;
function TIpHtmlNodeCOL.GetAlign: TIpHtmlAlign;
begin
Result := FAlign;
end;
procedure TIpHtmlNodeCOL.SetAlign(const Value: TIpHtmlAlign);
begin
FAlign := Value;
end;
{ TIpHtmlNodeCOLGROUP }
destructor TIpHtmlNodeCOLGROUP.Destroy;
begin
inherited;
FWidth.Free;
end;
procedure TIpHtmlNodeCOLGROUP.LoadAndApplyCSSProps;
begin
inherited;
if not (FCombinedCSSProps.Alignment in [haDefault, haUnknown]) then
Align := FCombinedCSSProps.Alignment;
// wp: what about VAlign?
end;
function TIpHtmlNodeCOLGROUP.GetAlign: TIpHtmlAlign;
begin
Result := FAlign;
end;
procedure TIpHtmlNodeCOLGROUP.SetAlign(const Value: TIpHtmlAlign);
begin
FAlign := Value;
end;
{ TIpHtmlNodeFRAME }
procedure TIpHtmlNodeFRAME.SetFrameBorder(const Value: Integer);
begin
if Value <> FFrameBorder then begin
FFrameBorder := Value;
InvalidateSize;
end;
end;
procedure TIpHtmlNodeFRAME.SetMarginHeight(const Value: Integer);
begin
if Value <> FMarginHeight then begin
FMarginHeight := Value;
InvalidateSize;
end;
end;
procedure TIpHtmlNodeFRAME.SetMarginWidth(const Value: Integer);
begin
if Value <> FMarginWidth then begin
FMarginWidth := Value;
InvalidateSize;
end;
end;
procedure TIpHtmlNodeFRAME.SetScrolling(const Value: TIpHtmlFrameScrolling);
begin
if Value <> FScrolling then begin
FScrolling := Value;
InvalidateSize;
end;
end;
{ TIpHtmlNodeMAP }
constructor TIpHtmlNodeMAP.Create(ParentNode: TIpHtmlNode);
begin
inherited;
Owner.MapList.Add(Self);
end;
destructor TIpHtmlNodeMAP.Destroy;
begin
Owner.MapList.Remove(Self);
inherited;
end;
{ TIpHtmlNodeTHeadFootBody }
function TIpHtmlNodeTHeadFootBody.GetAlign: TIpHtmlAlign;
begin
Result := FAlign;
end;
procedure TIpHtmlNodeTHeadFootBody.LoadAndApplyCSSProps;
begin
inherited;
if not (FCombinedCSSProps.Alignment in [haDefault, haUnknown]) then
Align := FCombinedCSSProps.Alignment;
// wp: what about VAlign?
end;
procedure TIpHtmlNodeTHeadFootBody.SetAlign(const Value: TIpHtmlAlign);
begin
FAlign := Value;
end;
{ TIpNodeTR }
constructor TIpHtmlNodeTR.Create(ParentNode: TIpHtmlNode);
begin
inherited Create(ParentNode);
ElementName := 'tr';
FAlign := haDefault;
FValign := hvaMiddle;
FBgColor := clNone;
FTextColor := clNone;
end;
function TIpHtmlNodeTR.GetAlign: TIpHtmlAlign;
begin
Result := FAlign;
end;
procedure TIpHtmlNodeTR.LoadAndApplyCSSProps;
begin
inherited;
if Assigned(FCombinedCSSProps) then begin
if not (FCombinedCSSProps.Alignment in [haDefault, haUnknown]) then
Align := FCombinedCSSProps.Alignment;
if FCombinedCSSProps.BgColor <> clNone then
BgColor := FCombinedCSSProps.BGColor;
// wp: what about VAlign?
end;
end;
procedure TIpHtmlNodeTR.SetAlign(const Value: TIpHtmlAlign);
begin
FAlign := Value;
end;
procedure TIpHtmlNodeTR.SetProps(const RenderProps: TIpHtmlProps);
begin
Props.Assign(RenderProps);
Props.FontColor := TextColor;
Props.BgColor := BgColor;
inherited SetProps(Props);
end;
procedure TIpHtmlNodeTR.AppendSelection(var S: String; var Completed: Boolean);
var
prev: TIpHtmlNode;
begin
if Completed then
exit;
prev := GetPrevSiblingNode(Self);
if prev is TIpHtmlNodeTR then S := S + LineEnding;
inherited AppendSelection(S, Completed);
end;
procedure TIpHtmlNodeTR.SetBgColor(const AValue: TColor);
begin
if AValue <> FBgColor then begin
FBgColor := AValue;
InvalidateSize;
end;
end;
procedure TIpHtmlNodeTR.SetTextColor(const AValue: TColor);
begin
if AValue <> FTextColor then begin
FTextColor := AValue;
InvalidateSize;
end;
end;
{-------------------------------------------------------------------------------
Descendants of TIpHtmlNodeTHeadFootBody
-------------------------------------------------------------------------------}
{ TIpHtmlNodeTBODY }
constructor TIpHtmlNodeTBODY.Create(ParentNode: TIpHtmlNode);
begin
inherited;
ElementName := 'tbody';
FVAlign := hva3Middle;
end;
{ TIpHtmlNodeTHEAD }
constructor TIpHtmlNodeTHEAD.Create(ParentNode: TIpHtmlNode);
begin
inherited;
ElementName := 'thead';
FVAlign := hva3Middle;
end;
{-------------------------------------------------------------------------------
Descendants of TIpHtmlNodeBlock
-------------------------------------------------------------------------------}
{ TIpHtmlNodeCAPTION }
constructor TIpHtmlNodeCAPTION.Create(ParentNode: TIpHtmlNode);
begin
inherited Create(ParentNode);
ElementName := 'caption';
end;
{ TIpHtmlNodeTableHeaderOrCell }
constructor TIpHtmlNodeTableHeaderOrCell.Create(ParentNode: TIpHtmlNode);
begin
inherited Create(ParentNode, TableElemLayouterClass);
FRowSpan := 1;
FColSpan := 1;
FAlign := haDefault;
FVAlign := hva3Middle;
BgColor := clNone;
end;
destructor TIpHtmlNodeTableHeaderOrCell.Destroy;
begin
FWidth.Free;
FHeight.Free;
inherited;
end;
procedure TIpHtmlNodeTableHeaderOrCell.AppendSelection(var S: String;
var Completed: Boolean);
var
prev: TIpHtmlNode;
begin
if Completed then
exit;
prev := GetPrevSiblingNode(self);
if prev is TIpHtmlNodeTableHeaderOrCell then S := S + #9;
inherited AppendSelection(S, Completed);
end;
procedure TIpHtmlNodeTableHeaderOrCell.CalcMinMaxPropWidth(RenderProps: TIpHtmlProps;
var Min, Max: Integer);
begin
FLayouter.CalcMinMaxPropWidth(RenderProps, Min, Max);
end;
function TIpHtmlNodeTableHeaderOrCell.GetAlign: TIpHtmlAlign;
begin
Result := FAlign;
end;
procedure TIpHtmlNodeTableHeaderOrCell.Render(RenderProps: TIpHtmlProps);
begin
FLayouter.Render(RenderProps);
end;
procedure TIpHtmlNodeTableHeaderOrCell.SetAlign(const Value: TIpHtmlAlign);
begin
FAlign := Value;
end;
procedure TIpHtmlNodeTableHeaderOrCell.Layout(RenderProps: TIpHtmlProps;
const TargetRect: TRect);
begin
FLayouter.Layout(Props, TargetRect);
end;
procedure TIpHtmlNodeTableHeaderOrCell.LoadAndApplyCSSProps;
begin
inherited;
if Assigned(FCombinedCSSProps) then
begin
if not (FCombinedCSSProps.Alignment in [haDefault, haUnknown]) then
Align := FCombinedCSSProps.Alignment;
// wp: what about VAlign?
if FCombinedCSSProps.Width.LengthType <> cltUndefined then
begin
Width.LengthType := TIpHtmlLengthType(FCombinedCSSProps.Width.LengthType);
Width.LengthValue := FCombinedCSSProps.Width.LengthValue;
end;
end;
end;
procedure TIpHtmlNodeTableHeaderOrCell.DimChanged(Sender: TObject);
begin
InvalidateSize;
end;
{-------------------------------------------------------------------------------
Descendants of TIpHtmlNodeTableHeaderOrCell
-------------------------------------------------------------------------------}
{ TIpHtmlNodeTH }
constructor TIpHtmlNodeTH.Create(ParentNode: TIpHtmlNode);
begin
inherited Create(ParentNode);
ElementName := 'th';
end;
{ TIpHtmlNodeTD }
constructor TIpHtmlNodeTD.Create(ParentNode: TIpHtmlNode);
begin
inherited Create(ParentNode);
ElementName := 'td';
end;
{-------------------------------------------------------------------------------
Descendants of TIpHtmlNodeInline
-------------------------------------------------------------------------------}
{ TIpHtmlNodeA }
constructor TIpHtmlNodeA.Create(ParentNode: TIpHtmlNode);
begin
inherited Create(ParentNode);
ElementName := 'a';
MapAreaList := TFPList.Create;
end;
destructor TIpHtmlNodeA.Destroy;
begin
if HasRef then
Owner.AnchorList.Remove(Self);
inherited;
MapAreaList.Free;
end;
procedure TIpHtmlNodeA.AddMapArea(const R: TRect);
var
RCopy : PRect;
c : Integer;
begin
c := MapAreaList.Count;
if c > 0 then begin
RCopy := PRect(FAreaList[c-1]);
if (R.Left = RCopy.Right)
and (R.Top = RCopy.Top)
and (R.Bottom = RCopy.Bottom) then begin
RCopy.Right := R.Right;
Exit;
end;
end;
New(RCopy);
RCopy^ := R;
MapAreaList.Add(RCopy);
end;
procedure TIpHtmlNodeA.ClearAreaList;
var
m: Pointer;
begin
inherited;
while MapAreaList.Count > 0 do begin
m:=MapAreaList[0];
FreeMem(m);
MapAreaList.Delete(0);
end;
end;
procedure TIpHtmlNodeA.BuildAreaList;
var
i : Integer;
begin
inherited;
for i := 0 to Pred(ChildCount) do
ChildNode[i].ReportMapRects(AddMapArea);
end;
function TIpHtmlNodeA.PtInRects(const P: TPoint): Boolean;
var
i : Integer;
begin
if FAreaList.Count = 0 then
BuildAreaList;
for i := 0 to Pred(FAreaList.Count) do begin
with PRect(FAreaList[i])^ do
if PtInRect(PRect(FAreaList[i])^,P) then begin
Result := True;
Exit;
end;
end;
Result := False;
end;
function TIpHtmlNodeA.RelMapPoint(const P: TPoint): TPoint;
var
i : Integer;
begin
if FAreaList.Count = 0 then
BuildAreaList;
for i := 0 to Pred(MapAreaList.Count) do begin
with PRect(MapAreaList[i])^ do
if PtInRect(PRect(FAreaList[i])^,P) then begin
Result := Point(
P.x - PRect(FAreaList[i])^.Left,
P.y - PRect(FAreaList[i])^.Top);
Exit;
end;
end;
Result := Point(-1, -1);
end;
procedure TIpHtmlNodeA.SetHot(const Value: Boolean);
var
i : Integer;
R : TRect;
begin
FHot := Value;
if FAreaList.Count = 0 then
BuildAreaList;
if FOwner.NeedResize then
SetProps(Props);
for i := 0 to Pred(FAreaList.Count) do
if PageRectToScreen(PRect(FAreaList[i])^, R) then
Owner.InvalidateRect(R);
end;
procedure TIpHtmlNodeA.SetHRef(const Value: string);
var
NewHasRef : Boolean;
begin
FHRef := Value;
NewHasRef := Value <> '';
if NewHasRef <> HasRef then begin
if HasRef then
Owner.AnchorList.Remove(Self)
else
Owner.AnchorList.Add(Self);
FHasRef := NewHasRef;
end;
end;
procedure TIpHtmlNodeA.DoOnBlur;
begin
{FHasFocus := False;}
Hot := False;
end;
procedure TIpHtmlNodeA.DoOnFocus;
begin
{FHasFocus := True;}
MakeVisible;
Hot := True;
end;
procedure TIpHtmlNodeA.SetName(const Value: string);
begin
if FName <> '' then
with Owner.NameList do
Delete(IndexOf(FName));
FName := Value;
if FName <> '' then
Owner.NameList.AddObject(FName, Self);
end;
(*
procedure TIpHtmlNodeA.MakeVisible;
var
i : Integer;
R : TRect;
begin
if AreaList.Count = 0 then
BuildAreaList;
SetRectEmpty(R);
for i := 0 to Pred(AreaList.Count) do
UnionRect(R, R, PRect(AreaList[i])^);
Owner.MakeVisible(R, true );
//Owner.MakeVisible(R, False); // original
end;
*)
procedure TIpHtmlNodeA.SetProps(const RenderProps: TIpHtmlProps);
begin
Props.Assign(RenderProps);
Props.DelayCache:=True;
if FHot then begin
Props.FontColor := Props.LinkColor;
Props.FontStyle := Props.FontStyle + [fsUnderline];
end else
if HasRef then begin
if Owner.LinksUnderlined then
Props.FontStyle := Props.FontStyle + [fsUnderline]
else
Props.FontStyle := Props.FontStyle - [fsUnderline];
if Owner.LinkVisited(HRef) then
Props.FontColor := Props.VLinkColor
else
Props.FontColor := Props.LinkColor;
end;
Props.DelayCache:=False;
inherited SetProps(Props);
end;
function TIpHtmlNodeA.GetHint: string;
begin
if Title = '' then
Result := HRef
else
Result := Title;
end;
{ TIpHtmlNodeAPPLET }
destructor TIpHtmlNodeAPPLET.Destroy;
begin
inherited;
FWidth.Free;
end;
function TIpHtmlNodeAPPLET.GetHint: string;
begin
Result := Alt;
end;
procedure TIpHtmlNodeAPPLET.WidthChanged(Sender: TObject);
begin
InvalidateSize;
end;
{ TIpHtmlNodeBLOCKQUOTE }
procedure TIpHtmlNodeBLOCKQUOTE.Enqueue;
var
hf: Integer;
elem: PIpHtmlElement;
begin
// display: block;
hf := Props.FontSize;
elem := Owner.BuildLinefeedEntry(etHardLF, hf);
EnqueueElement(elem);
EnqueueElement(Owner.LIndent);
inherited;
EnqueueElement(Owner.LOutdent);
// close the block
elem := Owner.BuildLinefeedEntry(etHardLF, hf);
EnqueueElement(elem);
end;
{ TIpHtmlNodeBR }
constructor TIpHtmlNodeBR.Create(ParentNode: TIpHtmlNode);
begin
inherited Create(ParentNode);
ElementName := 'br';
end;
procedure TIpHtmlNodeBR.Enqueue;
var
h: Integer;
elem: PIpHtmlElement;
begin
h := 0;
(* // wp: is there any reason why h should be > 0 for other node types?
if (ParentNode is TIpHtmlNodeP) or
(ParentNode is TIpHtmlNodeDIV) or
(ParentNode is TIpHtmlNodeLI) or
// (ParentNode is TIpHtmlNodePRE) or
(ParentNode is TIpHtmlNodeHeader) or
(ParentNode is TIpHtmlNodeBody)
then
h := 0
else
h := Props.FontSize;
*)
case Clear of
hbcNone :
begin
elem := Owner.BuildLinefeedEntry(etHardLF, h);
EnqueueElement(elem);
end;
hbcLeft :
EnqueueElement(Owner.HardLFClearLeft);
hbcRight :
EnqueueElement(Owner.HardLFClearRight);
hbcAll :
EnqueueElement(Owner.HardLFClearBoth);
end;
end;
function TIpHtmlNodeBR.GetMargin(AMargin: TIpHtmlElemMargin; ADefault: Integer): Integer;
var
default: Integer;
begin
if (ParentNode is TIpHtmlNodeP) then
default := 0
else
default := ADefault;
Result := inherited GetMargin(AMargin, default);
end;
procedure TIpHtmlNodeBR.SetClear(const Value: TIpHtmlBreakClear);
begin
FClear := Value;
InvalidateSize;
end;
{ TIpHtmlNodeDD }
constructor TIpHtmlNodeDD.Create(ParentNode: TIpHtmlNode);
begin
inherited;
ElementName := 'dd';
end;
procedure TIpHtmlNodeDD.Enqueue;
var
elem: PIpHtmlElement;
begin
// avoid top and bottom margins... they're always inherited from DL
if ChildCount > 0 then begin
elem := Owner.BuildLineFeedEntry(etSoftLF, 0);
EnqueueElement(elem);
end;
EnqueueElement(Owner.LIndent);
inherited;
EnqueueElement(Owner.LOutdent);
if ChildCount > 0 then begin
elem := Owner.BuildLineFeedEntry(etSoftLF, 0);
EnqueueElement(elem);
end;
end;
{ TIpHtmlNodeDIV }
constructor TIpHtmlNodeDIV.Create(ParentNode: TIpHtmlNode);
begin
inherited;
ElementName := 'div';
end;
destructor TIpHtmlNodeDIV.Destroy;
begin
inherited;
end;
function TIpHtmlNodeDIV.GetAlign: TIpHtmlAlign;
begin
Result := FAlign;
end;
procedure TIpHtmlNodeDIV.LoadAndApplyCSSProps;
begin
inherited;
if not (FCombinedCSSProps.Alignment in [haDefault, haUnknown]) then
Align := FCombinedCSSProps.Alignment;
end;
procedure TIpHtmlNodeDIV.SetAlign(const Value: TIpHtmlAlign);
begin
FAlign := Value;
end;
procedure TIpHtmlNodeDIV.SetProps(const RenderProps: TIpHtmlProps);
var
bgCol: TColor;
begin
bgCol := Props.BgColor;
Props.Assign(RenderProps);
Props.Alignment := Align;
LoadAndApplyCSSProps;
if FParentNode = FOwner.Body then
Props.BgColor := bgCol;
inherited SetProps(Props);
end;
procedure TIpHtmlNodeDIV.Enqueue;
var
elem: PIpHtmlElement;
h: Integer;
begin
//hf := Props.FontSize;
if ChildCount > 0 then begin
h := GetMargin(Props.ElemMarginTop, 0); //hf div 4);
elem := Owner.BuildLinefeedEntry(etSoftLF, h);
EnqueueElement(elem);
end;
inherited Enqueue;
if ChildCount > 0 then begin
h := GetMargin(Props.ElemMarginBottom, 0); //hf div 4);
elem := Owner.BuildLinefeedEntry(etSoftLF, h);
EnqueueElement(elem);
end;
end;
(* this is the original code
begin
if FChildren.Count > 0 then begin
if Props.ElemMarginTop.Style=hemsAuto then
EnqueueElement(Owner.HardLF)
else begin
// ToDo: Props.ElemMarginTop
EnqueueElement(Owner.HardLFClearBoth);
end;
end;
inherited Enqueue;
if FChildren.Count > 0 then begin
if Props.ElemMarginTop.Style=hemsAuto then
EnqueueElement(Owner.HardLF)
else begin
// ToDo: Props.ElemMarginTop
EnqueueElement(Owner.HardLFClearBoth)
end;
end;
end;
*)
{ TIpHtmlNodeDL }
constructor TIpHtmlNodeDL.Create(ParentNode: TIpHtmlNode);
begin
inherited;
ElementName := 'dl';
end;
procedure TIpHtmlNodeDL.Enqueue;
var
hf, h: Integer;
elem: PIpHtmlElement;
begin
// display block
hf := Props.FontSize;
h := GetMargin(Props.ElemMarginTop, hf);
elem := Owner.BuildLinefeedEntry(etHardLF, h);
EnqueueElement(elem);
// indent not needed here
// EnqueueElement(Owner.LIndent);
inherited;
// outdent not needed here
// EnqueueElement(Owner.LOutdent);
// close the block
h := GetMargin(Props.ElemMarginBottom, hf);
elem := Owner.BuildLinefeedEntry(etHardLF, h);
EnqueueElement(elem);
end;
{ TIpHtmlNodeDT }
constructor TIpHtmlNodeDT.Create(ParentNode: TIpHtmlNode);
begin
inherited;
ElementName := 'dt';
end;
procedure TIpHtmlNodeDT.Enqueue;
var
hf, h: integer;
elem: PIPHtmlElement;
begin
// display inline block
// avoid top margin... it's always inherited from DL
// use fractional font height between DD and DT
if ChildCount > 0 then
begin
hf := Props.FontSize;
h := 3 * (hf div 8);
elem := Owner.BuildLinefeedEntry(etSoftLF, h);
EnqueueElement(elem);
end;
inherited;
// close the inline block
// use fractional font height between DT and DD
if ChildCount > 0 then
begin
hf := Props.FontSize;
h := hf div 8;
elem := Owner.BuildLinefeedEntry(etSoftLF, h);
EnqueueElement(elem);
end;
end;
{ TIpHtmlNodeFORM }
constructor TIpHtmlNodeFORM.Create(ParentNode: TIpHtmlNode);
begin
inherited Create(ParentNode);
ElementName := 'form';
end;
destructor TIpHtmlNodeFORM.Destroy;
begin
inherited;
end;
procedure TIpHtmlNodeFORM.AddChild(Node: TIpHtmlNode; const UserData: Pointer);
begin
if Node is TIpHtmlNodeControl then
if TIpHtmlNodeControl(Node).SuccessFul then
TFPList(UserData).Add(Node);
end;
{$IFNDEF HtmlWithoutHttp}
procedure TIpHtmlNodeFORM.SubmitForm;
var
CList : TFPList;
FList,
VList : TStringList;
URLData: string;
FormData: TIpFormDataEntity;
procedure IndentifySuccessfulControls;
begin
EnumChildren(AddChild, CList);
end;
procedure BuildDataset;
var
i : Integer;
begin
for i := 0 to Pred(CList.Count) do
with TIpHtmlNodeControl(CList[i]) do
AddValues(FList, VList);
end;
procedure URLEncodeDataset;
function Escape(const S: string): string;
var
i : Integer;
begin
Result := '';
for i := 1 to length(S) do
case S[i] of
#0..#31, '+', '&', '%', '=' :
Result := Result + '%'+IntToHex(ord(S[i]),2);
' ' :
Result := Result + '+';
else
Result := Result + S[i];
end;
end;
var
i : Integer;
begin
URLData := '';
for i := 0 to Pred(FList.Count) do begin
if URLData <> '' then
URLData := URLData + '&';
URLData := URLData +
Escape(FList[i]) +
'=' +
Escape(VList[i]);
end;
end;
procedure MimeEncodeDataset;
var
i : Integer;
begin
FormData := TIpFormDataEntity.Create(nil);
for i := 0 to Pred(FList.Count) do
if LazStartsStr('file://', VList[i]) then
FormData.AddFile(copy(VList[i], 8, length(VList[i])),
Accept, 'plain', embinary)
else
FormData.AddFormData(FList[i], VList[i]);
end;
procedure SubmitDataset;
begin
case Method of
hfmGet :
Owner.Get(Action + '?' + URLData);
hfmPost :
begin
Owner.Post(Action, FormData);
{The Formdata object will be freed by the post logic,
which is called asynchroneously via PostMessage.
Clear the pointer to prevent our finalization
section from stepping on it prematurely.}
FormData := nil;
end;
end;
end;
begin
FormData := nil;
CList := nil;
FList := nil;
VList := nil;
try
CList := TFPList.Create;
FList := TStringList.Create;
VList := TStringList.Create;
IndentifySuccessfulControls;
BuildDataset;
case Method of
hfmGet :
URLEncodeDataset;
else
MimeEncodeDataset;
end;
SubmitDataset;
finally
FormData.Free;
CList.Free;
FList.Free;
VList.Free;
end;
end;
procedure TIpHtmlNodeFORM.SubmitRequest;
begin
SubmitForm;
end;
{$ENDIF}
procedure TIpHtmlNodeFORM.ResetRequest;
begin
ResetForm;
end;
procedure TIpHtmlNodeFORM.ResetControl(Node: TIpHtmlNode; const UserData: Pointer);
begin
if Node is TIpHtmlNodeControl then
TIpHtmlNodeControl(Node).Reset;
end;
procedure TIpHtmlNodeFORM.ResetForm;
begin
EnumChildren(ResetControl, nil);
end;
{ TIpHtmlNodeGenInline }
constructor TIpHtmlNodeGenInline.Create(ParentNode: TIpHtmlNode);
begin
inherited Create(ParentNode);
Props := TIpHtmlProps.Create(Owner.PropACache, Owner.PropBCache);
end;
destructor TIpHtmlNodeGenInline.Destroy;
begin
Props.Free;
inherited;
end;
procedure TIpHtmlNodeGenInline.SetProps(const RenderProps: TIpHtmlProps);
begin
ApplyProps(RenderProps);
inherited SetProps(Props);
end;
{ TIpHtmlNodeLABEL }
constructor TIpHtmlNodeLABEL.Create(ParentNode: TIpHtmlNode);
begin
inherited Create(ParentNode);
Owner.ControlList.Add(Self);
end;
destructor TIpHtmlNodeLABEL.Destroy;
begin
Owner.ControlList.Remove(Self);
inherited;
end;
{ TIpHtmlNodeList }
procedure TIpHtmlNodeList.Enqueue;
var
i, hf: Integer;
elem: PIpHtmlElement;
begin
hf := Props.FontSize;
if ChildCount > 0 then begin
// nested list has different first line margin
if (FParentNode is TIpHtmlNodeOL) or
(FParentNode is TIpHtmlNodeList) or
(FParentNode is TIpHtmlNodeLI) then
begin
elem := Owner.BuildLineFeedEntry(etHardLF, 0);
ParentNode.EnqueueElement(elem);
elem := Owner.BuildLineFeedEntry(etSoftLF, 3 * (hf div 16));
ParentNode.EnqueueElement(elem);
ParentNode.EnqueueElement(Owner.LIndent);
end
// start block container and inline block for list items
else
begin
elem := Owner.BuildLineFeedEntry(etHardLF, hf);
EnqueueElement(elem);
elem := Owner.BuildLineFeedEntry(etSoftLF, 3 * (hf div 16));
EnqueueElement(elem);
EnqueueElement(Owner.LIndent);
end;
end;
// render list
for i := 0 to Pred(ChildCount) do
begin
// handle list items
if (ChildNode[i] is TIpHtmlNodeLI) then
begin
TIpHtmlNodeLI(ChildNode[i]).Enqueue;
elem := Owner.BuildLineFeedEntry(etSoftLF, 3 * (hf div 16));
EnqueueElement(elem);
end
// handle a nested list
else
ChildNode[i].Enqueue;
end;
if ChildCount > 0 then begin
// close inline block
ParentNode.EnqueueElement(Owner.LOutdent);
elem := Owner.BuildLineFeedEntry(etSoftLF, 0);
EnqueueElement(elem);
// nested list has different bottom margin
if (FParentNode is TIpHtmlNodeOL) or
(FParentNode is TIpHtmlNodeList) or
(FParentNode is TIpHtmlNodeLI) then
elem := Owner.BuildLineFeedEntry(etSoftLF, hf div 8)
// close the block
else
elem := Owner.BuildLineFeedEntry(etHardLF, 3 * (hf div 8));
EnqueueElement(elem);
end;
end;
procedure TIpHtmlNodeList.LoadAndApplyCSSProps;
var
i: Integer;
begin
inherited;
if FCombinedCSSProps <> nil then
case FCombinedCSSProps.ListType of
ltULCircle: FListType := ulCircle;
ltULDisc: FListType := ulDisc;
ltULSquare: FListType := ulSquare;
end;
for i := 0 to ChildCount-1 do
if ChildNode[i] is TIpHtmlNodeLI then
if TIpHtmlNodeLI(ChildNode[i]).ListType = ulUndefined then
TIpHtmlNodeLI(ChildNode[i]).ListType := FListType
end;
procedure TIpHtmlNodeList.SetListType(const Value: TIpHtmlULType);
begin
if Value <> FListType then begin
FListType := Value;
InvalidateSize;
end;
end;
{ TIpHtmlNodeOBJECT }
destructor TIpHtmlNodeOBJECT.Destroy;
begin
inherited;
FWidth.Free;
end;
procedure TIpHtmlNodeOBJECT.WidthChanged(Sender: TObject);
begin
InvalidateSize;
end;
{ TIpHtmlNodePRE }
constructor TIpHtmlNodePRE.Create(ParentNode: TIpHtmlNode);
begin
inherited Create(ParentNode);
ElementName := 'pre';
end;
destructor TIpHtmlNodePRE.Destroy;
begin
inherited;
end;
procedure TIpHtmlNodePRE.SetProps(const RenderProps: TIpHtmlProps);
begin
Props.Assign(RenderProps);
Props.DelayCache:=True;
Props.Preformatted := True;
Props.FontName := Owner.FixedTypeface;
Props.FontSize := Props.FontSize - 2;
Props.DelayCache:=False;
inherited SetProps(Props);
end;
procedure TIpHtmlNodePRE.Enqueue;
var
hf, h: Integer;
elem: PIpHtmlElement;
begin
hf := Props.FontSize;
// start block with top margin
if (ChildCount > 0) then begin
h := GetMargin(Props.ElemMarginTop, hf);
elem := Owner.BuildLineFeedEntry(etHardLF, h);
EnqueueElement(elem);
end;
inherited Enqueue;
// close block with optional bottom margin
if (ChildCount > 0) then begin
h := GetMargin(Props.ElemMarginBottom, 0);
elem := Owner.BuildLineFeedEntry(etHardLF, h);
EnqueueElement(elem);
end;
end;
{-------------------------------------------------------------------------------
Descendants of TIpHtmlNodeAlignInline
-------------------------------------------------------------------------------}
{ TIpHtmlNodeHR }
constructor TIpHtmlNodeHR.Create(ParentNode: TIpHtmlNode);
begin
inherited Create(ParentNode);
FColor := clNone;
Align := hiaCenter;
SizeWidth := TIpHtmlPixels.Create;
end;
destructor TIpHtmlNodeHR.Destroy;
begin
inherited;
FWidth.Free;
SizeWidth.Free;
FSize.Free;
end;
procedure TIpHtmlNodeHR.CalcMinMaxWidth(var Min, Max: Integer);
begin
Min := 0;
Max := 0;
case Width.LengthType of
hlAbsolute :
begin
Min := Width.LengthValue;
Max := Min;
end;
end;
end;
procedure TIpHtmlNodeHR.Draw;
var
R : TRect;
TopLeft : TPoint;
Dim : TSize;
SaveBrushColor,
SavePenColor : TColor;
aCanvas: TCanvas;
begin
aCanvas := Owner.Target;
TopLeft := GrossDrawRect.TopLeft;
R.TopLeft := TopLeft;
Dim := GetDim(0);
R.Right := TopLeft.x + Dim.cx;
R.Bottom := TopLeft.y + Dim.cy;
if not PageRectToScreen(R, R) then
Exit;
if NoShade or (Color <> clNone) then begin
SavePenColor := aCanvas.Pen.Color;
SaveBrushColor := aCanvas.Brush.Color;
if Color = clNone then begin
aCanvas.Pen.Color := clBlack;
aCanvas.Brush.Color := clBlack;
end else begin
aCanvas.Pen.Color := Color;
aCanvas.Brush.Color := Color;
end;
aCanvas.FillRect(R);
aCanvas.Pen.Color := SavePenColor;
aCanvas.Brush.Color := SaveBrushColor;
end else begin
SavePenColor := aCanvas.Pen.Color;
SaveBrushColor := aCanvas.Brush.Color;
aCanvas.Pen.Color := clGray;
aCanvas.Brush.Color := clGray;
aCanvas.FillRect(R);
aCanvas.Pen.Color := clWhite;
aCanvas.MoveTo(R.Left - 1, R.Bottom + 1);
aCanvas.LineTo(R.Left - 1, R.Top - 1);
aCanvas.LineTo(R.Right + 1, R.Top - 1);
aCanvas.Pen.Color := clBlack;
aCanvas.LineTo(R.Right + 1, R.Bottom + 1);
aCanvas.LineTo(R.Left - 1, R.Bottom + 1);
aCanvas.Pen.Color := SavePenColor;
aCanvas.Brush.Color := SaveBrushColor;
end;
end;
procedure TIpHtmlNodeHR.Enqueue;
begin
EnqueueElement(Owner.SoftLF);
inherited;
EnqueueElement(Owner.SoftLF);
end;
function TIpHtmlNodeHR.GetDim(ParentWidth: Integer): TSize;
begin
if (SizeWidth.PixelsType <> hpAbsolute)
or ((ParentWidth <> 0) and (SizeWidth.Value <> ParentWidth)) then begin
case Width.LengthType of
hlUndefined :
FDim.cx := 0;
hlAbsolute :
FDim.cx := Width.LengthValue;
hlPercent :
FDim.cx := round(ParentWidth * Width.LengthValue / 100);
end;
FDim.cy := Size.Value;
SizeWidth.Value := ParentWidth;
SizeWidth.PixelsType := hpAbsolute;
end;
Result := FDim;
end;
function TIpHtmlNodeHR.GrossDrawRect: TRect;
begin
Result := PIpHtmlElement(Element).WordRect2;
end;
procedure TIpHtmlNodeHR.WidthChanged(Sender: TObject);
begin
InvalidateSize;
end;
{ TIpHtmlNodeIMG }
constructor TIpHtmlNodeIMG.Create;
begin
inherited;
ElementName := 'img';
SizeWidth := TIpHtmlPixels.Create;
end;
destructor TIpHtmlNodeIMG.Destroy;
begin
UnloadImage;
UseMap := '';
inherited;
FWidth.Free;
SizeWidth.Free;
FHeight.Free;
end;
procedure TIpHtmlNodeIMG.LoadImage;
begin
if Src <> '' then begin
if FPicture <> Owner.DefaultImage then begin
FPicture.Free;
FPicture := nil;
end;
Owner.DoGetImage(Self, Owner.BuildPath(Src), FPicture);
if FPicture = nil then
FPicture := Owner.DefaultImage;
{$IFDEF UseGifImageUnit}
if (FPicture <> nil) and (FPicture.Graphic <> nil) and (FPicture.Graphic is TGifImage) then
Owner.GifImages.Add(Self);
{$ELSE}
if (FPicture <> nil) and (FPicture.Graphic <> nil) and (FPicture.Graphic is TIpAnimatedGraphic) then
Owner.AnimationFrames.Add(Self);
{$ENDIF}
end;
end;
procedure TIpHtmlNodeIMG.UnloadImage;
begin
{$IFDEF UseGifImageUnit}
if (FPicture <> nil) and (FPicture.Graphic <> nil) and (FPicture.Graphic is TGifImage) then
Owner.GifImages.Remove(Self);
{$ELSE}
if (FPicture <> nil) and (FPicture.Graphic <> nil) and (FPicture.Graphic is TIpAnimatedGraphic) then
Owner.AnimationFrames.Remove(Self);
{$ENDIF}
if FPicture <> Owner.DefaultImage then begin
FPicture.Free;
FPicture := nil;
end;
end;
function TIpHtmlNodeIMG.GetBorder: Integer;
begin
if (FPicture <> nil) and (FPicture.Graphic = nil) then
Result := 1
else
Result := fBorder;
end;
procedure TIpHtmlNodeIMG.Draw;
var
R: TRect;
TopLeft: TPoint;
Dim: TSize;
begin
if FPicture = nil then
LoadImage;
if (FPicture <> nil) and (FPicture.Graphic = nil) then
LoadImage;
Owner.AddRect(GrossDrawRect, Element, Block);
TopLeft := GrossDrawRect.TopLeft;
R.TopLeft := TopLeft;
Dim := GetDim(0);
R.Right := TopLeft.x + Dim.cx;
R.Bottom := TopLeft.y + Dim.cy;
if Border <> 0 then begin
if Border = 1 then begin
ScreenLine(
R.TopLeft,
Point(R.Right, R.Top),
1,
RGB(220,220,220));
ScreenLine(
R.BottomRight,
Point(R.Left, R.Bottom),
1,
RGB(64,64,64));
ScreenLine(
R.TopLeft,
Point(R.Left, R.Bottom),
1,
RGB(192,192,192));
ScreenLine(
R.BottomRight,
Point(R.Right, R.Top),
1,
RGB(128,128,128));
end else begin
ScreenPolygon(
[R.TopLeft,
Point(R.Right - 1, R.Top),
Point(R.Right - Border, R.Top + Border - 1),
Point(R.Left + Border - 1, R.Top + Border - 1)],
RGB(220,220,220));
ScreenPolygon(
[
Point(R.Right - 1, R.Bottom - 1),
Point(R.Right - Border, R.Bottom - Border),
Point(R.Left + (Border - 1), R.Bottom - Border),
Point(R.Left, R.Bottom - 1)],
RGB(64,64,64));
ScreenPolygon(
[R.TopLeft,
Point(R.Left, R.Bottom - 1),
Point(R.Left + (Border - 1), R.Bottom - Border),
Point(R.Left + (Border - 1), R.Top + (Border - 1))],
RGB(192,192,192));
ScreenPolygon(
[
Point(R.Right - 1, R.Bottom - 1),
Point(R.Right - 1, R.Top),
Point(R.Right - Border, R.Top + (Border - 1)),
Point(R.Right - Border, R.Bottom - Border)],
RGB(128,128,128));
end;
InflateRect(R, -Border, -Border);
end;
InflateRect(R, -HSpace, -VSpace);
if FPicture <> nil then begin
if FPicture.Graphic=nil then begin
if PageRectToScreen(R,R) then
Owner.Target.TextRect(R, R.Left, R.Top, GetHint);
Exit;
end;
FPicture.Graphic.Transparent := True;
NetDrawRect := R;
if PageRectToScreen(R, R) then begin
{$IFDEF UseGifImageUnit}
if (FPicture.Graphic is TGifImage) and (TGifImage(FPicture.Graphic).Images.Count > 1) then
begin
with TGifImage(FPicture.Graphic) do
DrawOptions := DrawOptions + [goDirectDraw];
Owner.AddGifQueue(FPicture.Graphic, R);
end else
{$ELSE}
if (FPicture.Graphic is TIpAnimatedGraphic) and (TIpAnimatedGraphic(FPicture.Graphic).Images.Count > 1) then
begin
TIpAnimatedGraphic(FPicture.Graphic).AggressiveDrawing := True;
Owner.AddGifQueue(FPicture.Graphic, R);
end else
begin
{$ENDIF}
if FPicture = Owner.DefaultImage then begin
if (NetDrawRect.Right - NetDrawRect.Left > FPicture.Graphic.Width) and
(NetDrawRect.Bottom - NetDrawRect.Top > FPicture.Graphic.Height) then
begin
Owner.Target.Brush.Color := Props.FontColor;
Owner.Target.FrameRect(R);
Owner.Target.Draw(R.Left + 1, R.Top + 1, FPicture.Graphic);
end else
Owner.Target.StretchDraw(R, FPicture.Graphic);
end else
Owner.Target.StretchDraw(R, FPicture.Graphic);
end;
end;
end
end;
function TIpHtmlNodeIMG.GrossDrawRect : TRect;
begin
Result := PIpHtmlElement(Element).WordRect2;
end;
procedure TIpHtmlNodeIMG.ReportDrawRects(M: TRectMethod);
begin
M(GrossDrawRect);
end;
procedure TIpHtmlNodeIMG.ReportMapRects(M: TRectMethod);
begin
if IsMap then
M(GrossDrawRect);
end;
procedure TIpHtmlNodeIMG.ImageChange(NewPicture: TPicture);
var
OldDim, Dim: TSize;
begin
{$IFOPT C+}
Owner.CheckImage(NewPicture);
{$ENDIF}
OldDim := GetDim(-1);
{$IFDEF UseGifImageUnit}
if (FPicture <> nil) and (FPicture.Graphic <> nil) and (FPicture.Graphic is TGifImage) then
Owner.GifImages.Remove(Self);
{$ELSE}
if (FPicture <> nil) and (FPicture.Graphic <> nil) and (FPicture.Graphic is TIpAnimatedGraphic) then
Owner.AnimationFrames.Remove(Self);
{$ENDIF}
if FPicture <> Owner.DefaultImage then
FPicture.Free;
FPicture := NewPicture;
{$IFDEF UseGifImageUnit}
if (FPicture <> nil) and (FPicture.Graphic <> nil) and (FPicture.Graphic is TGifImage) then
Owner.GifImages.Add(Self);
{$ELSE}
if (FPicture <> nil) and (FPicture.Graphic <> nil) and (FPicture.Graphic is TIpAnimatedGraphic) then
Owner.AnimationFrames.Add(Self);
{$ENDIF}
SizeWidth.PixelsType := hpUndefined;
Dim := GetDim(0);
if (Dim.cx <> OldDim.cx) or (Dim.cy <> OldDim.cy) then
InvalidateSize
else
Invalidate;
end;
procedure TIpHtmlNodeIMG.SetProps(const RenderProps: TIpHtmlProps);
begin
Props.Assign(RenderProps);
end;
function TIpHtmlNodeIMG.GetDim(ParentWidth: Integer): TSize;
var
DimKnown, NoLoad : Boolean;
begin
if ParentWidth < 0 then begin
NoLoad := True;
ParentWidth := 0;
end else
NoLoad := False;
if (SizeWidth.PixelsType <> hpAbsolute)
or ((ParentWidth <> 0) and (SizeWidth.Value <> ParentWidth)) then begin
DimKnown := True;
if (Height.PixelsType <> hpUndefined)
and (Width.LengthType <> hlUndefined) then begin
case Width.LengthType of
hlUndefined :
DimKnown := False;
hlAbsolute :
begin
FSize := SizeRec(Width.LengthValue, Height.Value);
end;
hlPercent :
begin
FSize := SizeRec(
round(ParentWidth * Width.LengthValue / 100) - 2*HSpace - 2*Border,
Height.Value);
end;
end;
end else
DimKnown := False;
if not DimKnown then begin
if (FPicture <> nil) then begin
if FPicture.Graphic=nil then
// todo: needs to return the "text size" of GetHint
FSize := SizeRec(100,20)
else
if ScaleBitmaps then
FSize := SizeRec(round(FPicture.Width * Aspect), round(FPicture.Height * Aspect))
else
FSize := SizeRec(FPicture.Width, FPicture.Height)
end else begin
if NoLoad then
FSize := SizeRec(0, 0)
else begin
LoadImage;
if FPicture <> nil then begin
if ScaleBitmaps then
FSize := SizeRec(round(FPicture.Width * Aspect), round(FPicture.Height * Aspect))
else
if FPicture.Graphic=nil then
// todo: needs to return the "text size" of GetHint
FSize := SizeRec(100,20)
else
FSize := SizeRec(FPicture.Width, FPicture.Height);
end else
FSize := SizeRec(0, 0);
end;
end;
if FPicture <> nil then begin
case Width.LengthType of
hlUndefined :;
hlAbsolute :
begin
FSize := SizeRec(Width.LengthValue, FSize.cy);
end;
hlPercent :
begin
FSize := SizeRec(
round(ParentWidth * Width.LengthValue / 100) - 2*HSpace - 2*Border,
FSize.cy);
end;
end;
if Height.PixelsType <> hpUndefined then
FSize.cy := Height.Value;
end;
end;
FSize := SizeRec(FSize.cx + 2*HSpace + 2*Border, FSize.cy + 2*VSpace + 2*Border);
SizeWidth.Value := ParentWidth;
SizeWidth.PixelsType := hpAbsolute;
end;
Result := FSize;
end;
procedure TIpHtmlNodeIMG.CalcMinMaxWidth(var Min, Max: Integer);
var
Dim : TSize;
begin
Dim := GetDim(0);
Min := Dim.cx;
Max := Min;
end;
procedure TIpHtmlNodeIMG.SetUseMap(const Value: string);
begin
if FUseMap <> '' then begin
Owner.MapImgList.Remove(Self);
Owner.ClearAreaList;
end;
FUseMap := Value;
if FUseMap <> '' then begin
Owner.MapImgList.Add(Self);
Owner.ClearAreaList;
end;
end;
function TIpHtmlNodeIMG.GetHint: string;
begin
Result := Alt;
end;
procedure TIpHtmlNodeIMG.SetBorder(const Value: Integer);
begin
FBorder := Value;
InvalidateSize;
end;
procedure TIpHtmlNodeIMG.SetHSpace(const Value: Integer);
begin
FHSpace := Value;
InvalidateSize;
end;
procedure TIpHtmlNodeIMG.SetVSpace(const Value: Integer);
begin
FVSpace := Value;
InvalidateSize;
end;
procedure TIpHtmlNodeIMG.DimChanged(Sender: TObject);
begin
InvalidateSize;
end;
procedure TIpHtmlNodeIMG.InvalidateSize;
begin
inherited;
SizeWidth.PixelsType := hpUndefined;
end;
{ TIpHtmlNodeLI }
constructor TIpHtmlNodeLI.Create(ParentNode: TIpHtmlNode);
begin
inherited;
ElementName := 'li';
Align := hiaBottom;
WordEntry := Owner.NewElement(etWord, Self);
WordEntry.Props := Props;
end;
procedure TIpHtmlNodeLI.CalcMinMaxWidth(var Min, Max: Integer);
begin
if ScaleBitmaps then begin
Min := round(8 * Aspect);
Max := round(8 * Aspect);
end else begin
Min := 8;
Max := 8;
end;
end;
procedure TIpHtmlNodeLI.Draw;
var
R : TRect;
SaveColor : Tcolor;
begin
if PageRectToScreen(GrossDrawRect, R) then
begin
SaveColor := Owner.Target.Brush.Color;
case ListType of
ulDisc :
begin
Owner.Target.Brush.Color := Props.FontColor;
if ScaleBitmaps then
Owner.Target.Ellipse(R.Left, R.Top, R.Left + round(7 * Aspect), R.Top + round(7 * Aspect))
else
Owner.Target.Ellipse(R.Left, R.Top, R.Left + 7, R.Top + 7);
Owner.Target.Brush.Color := SaveColor;
end;
ulSquare :
begin
Owner.Target.Brush.Color := Props.FontColor;
if ScaleBitmaps then
Owner.Target.Rectangle(R.Left, R.Top, R.Left + round(7 * Aspect), R.Top + round(7 * Aspect))
else
Owner.Target.Rectangle(R.Left, R.Top, R.Left + 7, R.Top + 7);
Owner.Target.Brush.Color := SaveColor;
end;
ulCircle :
begin
if ScaleBitmaps then
Owner.Target.Ellipse(R.Left, R.Top, R.Left + round(7 * Aspect), R.Top + round(7 * Aspect))
else
Owner.Target.Ellipse(R.Left, R.Top, R.Left + 7, R.Top + 7);
end;
end;
end;
end;
procedure SetRawWordValue(Entry: PIpHtmlElement; const Value: string);
var
L : Integer;
begin
Entry.AnsiWord := EscapeToAnsi(Value);
Entry.IsBlank := 0;
L := length(Entry.AnsiWord);
while Entry.IsBlank < L do
if Entry.AnsiWord[Entry.IsBlank + 1] = ' ' then
Inc(Entry.IsBlank)
else
break;
if Entry.IsBlank < L then
Entry.IsBlank := 0;
end;
procedure TIpHtmlNodeLI.Enqueue;
var
S : string;
i : Integer;
begin
if FParentNode is TIpHtmlNodeOL then begin
S := TIpHtmlNodeOL(FParentNode).GetNumString;
SetRawWordValue(WordEntry, S);
EnqueueElement(WordEntry);
end else
EnqueueElement(Element);
EnqueueElement(Owner.LIndent);
for i := 0 to Pred(ChildCount) do
ChildNode[i].Enqueue;
EnqueueElement(Owner.LOutdent);
end;
function TIpHtmlNodeLI.GetDim(ParentWidth: Integer): TSize;
begin
if ScaleBitmaps then
Result := SizeRec(round(Aspect * 8), round(Aspect * 8))
else
Result := SizeRec(8, 8);
end;
function TIpHtmlNodeLI.GrossDrawRect: TRect;
begin
Result := PIpHtmlElement(Element).WordRect2;
end;
procedure TIpHtmlNodeLI.SetListType(const Value: TIpHtmlULType);
begin
if Value <> FListType then begin
FListType := Value;
InvalidateSize;
end;
end;
procedure TIpHtmlNodeLI.SetProps(const RenderProps: TIpHtmlProps);
begin
Props.Assign(RenderProps);
inherited SetProps(Props);
end;
procedure TIpHtmlNodeLI.SetValue(const Value: Integer);
begin
if Value <> FValue then begin
FValue := Value;
InvalidateSize;
end;
end;
{ TIpHtmlNodeOL }
constructor TIpHtmlNodeOL.Create(ParentNode: TIpHtmlNode);
begin
inherited;
ElementName := 'ol';
end;
procedure TIpHtmlNodeOL.Enqueue;
var
i: Integer;
iVal: Integer;
elem: PIpHtmlElement;
hf: Integer;
begin
// display block
hf := Props.FontSize;
if ChildCount > 0 then begin
// nested list has different top margin
if (FParentNode is TIpHtmlNodeOL) or
(FParentNode is TIpHtmlNodeList) or
(FParentNode is TIpHtmlNodeLI) then
begin
elem := Owner.BuildLineFeedEntry(etHardLF, 0);
ParentNode.EnqueueElement(elem);
elem := Owner.BuildLineFeedEntry(etSoftLF, 3 * (hf div 16));
ParentNode.EnqueueElement(elem);
ParentNode.EnqueueElement(Owner.LIndent);
end
// start block container and inline block for list items
else
begin
elem := Owner.BuildLineFeedEntry(etHardLF, hf);
EnqueueElement(elem);
elem := Owner.BuildLineFeedEntry(etSoftLF, 3 * (hf div 16));
EnqueueElement(elem);
EnqueueElement(Owner.LIndent);
end;
end;
// render list
iVal := -1;
for i := 0 to Pred(ChildCount) do
begin
// handle list items
if (ChildNode[i] is TIpHtmlNodeLI) then
begin
Inc(iVal);
Counter := Start + iVal;
TIpHtmlNodeLI(ChildNode[i]).Enqueue;
elem := Owner.BuildLineFeedEntry(etSoftLF, 3 * (hf div 16));
EnqueueElement(elem);
end
// handle a nested list
else
ChildNode[i].Enqueue;
end;
if ChildCount > 0 then begin
// close inline block
ParentNode.EnqueueElement(Owner.LOutdent);
elem := Owner.BuildLineFeedEntry(etSoftLF, 0);
EnqueueElement(elem);
// nested list has different bottom margin
if (FParentNode is TIpHtmlNodeOL) or
(FParentNode is TIpHtmlNodeList) or
(FParentNode is TIpHtmlNodeLI) then
elem := Owner.BuildLineFeedEntry(etSoftLF, hf div 8)
// close the block
else
elem := Owner.BuildLineFeedEntry(etHardLF, 3 * (hf div 8));
EnqueueElement(elem);
end;
end;
function TIpHtmlNodeOL.GetNumString: string;
begin
Result := ''; // stop warning
case Style of
olArabic :
Str(Counter, Result);
olLowerAlpha :
Result := chr(ord('a') + Counter - 1);
olUpperAlpha :
Result := chr(ord('A') + Counter - 1);
olLowerRoman :
// rtl version... its not buggy
Result := Lowercase(StrUtils.IntToRoman(Counter));
olUpperRoman :
// rtl version... its not buggy
Result := StrUtils.IntToRoman(Counter);
end;
Result := Result + '. ';
// right-align roman counter values
if Style in [olLowerRoman, olUpperRoman] then
Result := PadLeft(Result, 7);
end;
procedure TIpHtmlNodeOL.LoadAndApplyCSSProps;
begin
inherited;
// Override list style by CSS
if FCombinedCSSProps <> nil then
case FCombinedCSSProps.ListType of
ltOLDecimal : FOLStyle := olArabic;
ltOLLowerAlpha: FOLStyle := olLowerAlpha;
ltOLUpperAlpha: FOLStyle := olUpperAlpha;
ltOLLowerRoman: FOLStyle := olLowerRoman;
ltOLUpperRoman: FOLStyle := olUpperRoman;
end;
end;
procedure TIpHtmlNodeOL.SetStart(const Value: Integer);
begin
if Value <> FStart then begin
FStart := Value;
InvalidateSize;
end;
end;
procedure TIpHtmlNodeOL.SetOLStyle(const Value: TIpHtmlOLStyle);
begin
if Value <> FOLStyle then begin
FOLStyle := Value;
InvalidateSize;
end;
end;
{ TIpHtmlNodeTABLE }
constructor TIpHtmlNodeTABLE.Create(ParentNode: TIpHtmlNode);
begin
inherited Create(ParentNode);
ElementName := 'table';
BgColor := clNone;
SizeWidth := TIpHtmlPixels.Create;
SizeWidth.PixelsType := hpUndefined;
FBorderColor := $808080;
FBorderStyle := cbsInset;
FLayouter := TableLayouterClass.Create(Self);
end;
destructor TIpHtmlNodeTABLE.Destroy;
begin
FWidth.Free;
SizeWidth.Free;
FreeAndNil(FLayouter);
inherited;
end;
procedure TIpHtmlNodeTABLE.SetRect(TargetRect: TRect);
var
dx,dy : Integer;
z, i, j : Integer;
R : TRect;
begin
if ColCount = 0 then Exit;
dx := TargetRect.Left - BorderRect2.Left;
dy := TargetRect.Top - BorderRect2.Top;
OffsetRect(BorderRect, dx, dy);
OffsetRect(BorderRect2, dx, dy);
if FCaption <> nil then begin
with FCaption do begin
if not IsRectEmpty(PageRect) then begin
R := PageRect;
OffsetRect(R, dx, dy);
Layout(Props, R);
end;
end;
end;
for z := 0 to Pred(ChildCount) do
if (TIpHtmlNode(ChildNode[z]) is TIpHtmlNodeTHeadFootBody) then
with TIpHtmlNodeCore(ChildNode[z]) do
for i := 0 to Pred(ChildCount) do begin
if TIpHtmlNode(ChildNode[i]) is TIpHtmlNodeTR then
with TIpHtmlNodeTR(ChildNode[i]) do begin
for j := 0 to Pred(ChildCount) do
if TIpHtmlNode(ChildNode[j]) is TIpHtmlNodeTableHeaderOrCell then
with TIpHtmlNodeTableHeaderOrCell(ChildNode[j]) do begin
if not IsRectEmpty(PadRect) then
OffsetRect(FPadRect, dx, dy);
if not IsRectEmpty(PageRect) then begin
R := PageRect;
OffsetRect(R, dx, dy);
Layout(Props, R);
end;
end;
end;
end;
end;
procedure TIpHtmlNodeTABLE.Draw(Block: TIpHtmlNodeBlock);
var
z, i, j : Integer;
R : TRect;
Al : TIpHtmlVAlign3;
TRBgColor, TrTextColor: TColor;
aCanvas : TCanvas;
begin
aCanvas := Owner.Target;
if (FOwner.Body.BgPicture <> nil) or (Props.BGColor = 1) then
aCanvas.Brush.Style := bsClear
else
if (Props.BGColor <> clNone) and PageRectToScreen(BorderRect, R) then begin
aCanvas.Brush.Color :=Props.BGColor;
aCanvas.FillRect(R);
end;
aCanvas.Pen.Color := clBlack;
Al := Props.VAlignment;
for z := 0 to Pred(ColCount) do
FLayouter.RowSp[z] := 0;
for z := 0 to Pred(ChildCount) do
if (TIpHtmlNode(ChildNode[z]) is TIpHtmlNodeTHeadFootBody) then
with TIpHtmlNodeCore(ChildNode[z]) do
for i := 0 to Pred(ChildCount) do begin
if TIpHtmlNode(ChildNode[i]) is TIpHtmlNodeTR then
with TIpHtmlNodeTR(ChildNode[i]) do begin
case VAlign of
hvaTop : Al := hva3Top;
hvaMiddle : Al := hva3Middle;
hvaBottom : Al := hva3Bottom;
end;
TrBgColor := BgColor;
TrTextColor := TextColor;
for j := 0 to Pred(ChildCount) do
if TIpHtmlNode(ChildNode[j]) is TIpHtmlNodeTableHeaderOrCell then
with TIpHtmlNodeTableHeaderOrCell(ChildNode[j]) do begin
if VAlign <> hva3Default then
Al := VAlign;
// set TR color, Render override them anyway if TD/TH have own settings
if FOwner.NeedResize then
begin
Props.BGColor := TrBgColor;
Props.FontColor := TrTextColor;
Props.VAlignment := Al;
end;
Render(Props);
{paint left rule if selected}
case Rules of
hrNone,
hrGroups :;
hrRows :;
hrCols,
hrAll :
begin
if not IsRectEmpty(PadRect) then begin
R := PadRect;
Inflaterect(R, 1, 1);
ScreenFrame(R, False);
end;
end;
end;
end;
end;
end;
{render frames}
// to frame
if Frame in [hfAbove, hfHSides, hfBox, hfBorder] then
if Border = 1 then
ScreenLine(
BorderRect.TopLeft,
Point(BorderRect.Right-1, BorderRect.Top),
1,
CalcBorderColor(BorderColor, BorderStyle, hfAbove))
else
ScreenPolygon(
[BorderRect.TopLeft,
Point(BorderRect.Right, BorderRect.Top),
Point(BorderRect.Right - (Border - 1), BorderRect.Top + Border - 1),
Point(BorderRect.Left + Border - 1, BorderRect.Top + Border - 1)],
CalcBorderColor(BorderColor, BorderStyle, hfAbove));
// bottom frame
if Frame in [hfBelow, hfHSides, hfBox, hfBorder] then
if Border = 1 then
ScreenLine(
Point(BorderRect.Right - 1, BorderRect.Bottom - 1),
Point(BorderRect.Left, BorderRect.Bottom - 1),
1,
CalcBorderColor(BorderColor, BorderStyle, hfBelow))
else
ScreenPolygon(
[
Point(BorderRect.Right - 1, BorderRect.Bottom - 1),
Point(BorderRect.Right - (Border - 1), BorderRect.Bottom - (Border - 1) - 1),
Point(BorderRect.Left + Border, BorderRect.Bottom - (Border - 1) - 1),
Point(BorderRect.Left, BorderRect.Bottom - 1)],
CalcBorderColor(BorderColor, BorderStyle, hfBelow));
// left frame
if Frame in [hfLhs, hfvSides, hfBox, hfBorder] then
if Border = 1 then
ScreenLine(
BorderRect.TopLeft,
Point(BorderRect.Left, BorderRect.Bottom - 1),
1,
CalcBorderColor(BorderColor, BorderStyle, hfLhs))
else
ScreenPolygon(
[BorderRect.TopLeft,
Point(BorderRect.Left, BorderRect.Bottom - 1),
Point(BorderRect.Left + (Border - 1), BorderRect.Bottom - Border),
Point(BorderRect.Left + (Border - 1), BorderRect.Top + (Border - 1))],
CalcBorderColor(BorderColor, BorderStyle, hfLhs));
// right frame
if Frame in [hfRhs, hfvSides, hfBox, hfBorder] then
if Border = 1 then
ScreenLine(
Point(BorderRect.Right - 1, BorderRect.Bottom - 1),
Point(BorderRect.Right - 1, BorderRect.Top),
1,
CalcBorderColor(BorderColor, BorderStyle, hfRhs))
else
ScreenPolygon(
[
Point(BorderRect.Right - 1, BorderRect.Bottom - 1),
Point(BorderRect.Right - 1, BorderRect.Top),
Point(BorderRect.Right - (Border - 1) - 1, BorderRect.Top + (Border - 1)),
Point(BorderRect.Right - (Border - 1) - 1, BorderRect.Bottom - Border)],
CalcBorderColor(BorderColor, BorderStyle, hfRhs));
{render caption}
if assigned(FCaption) then
FCaption.Render(Props);
end;
procedure TIpHtmlNodeTABLE.SetProps(const RenderProps: TIpHtmlProps);
begin
Props.Assign(RenderProps);
Props.NoBreak := False;
inherited SetProps(RenderProps);
//BgColor := Props.BgColor;
end;
function TIpHtmlNodeTABLE.GetDim(ParentWidth: Integer): TSize;
begin
if (SizeWidth.PixelsType <> hpAbsolute) or (SizeWidth.Value <> ParentWidth) then
begin
SizeWidth.PixelsType := hpUndefined;
FLayouter.CalcSize(ParentWidth, Props);
SizeWidth.Value := ParentWidth;
SizeWidth.PixelsType := hpAbsolute;
end;
Result := SizeRec(BorderRect2.Right - BorderRect2.Left,
BorderRect2.Bottom - BorderRect2.Top);
end;
procedure TIpHtmlNodeTABLE.CalcMinMaxWidth(var Min, Max: Integer);
begin
FLayouter.CalcMinMaxColTableWidth(Props, Min, Max);
case Width.LengthType of
hlAbsolute :
begin
Min := MaxI2(Min, Width.LengthValue);
Max := MaxI2(Max, Min);
end;
end;
end;
procedure TIpHtmlNodeTABLE.InvalidateSize;
begin
SizeWidth.PixelsType := hpUndefined;
FLayouter.ResetSize;
inherited;
end;
function TIpHtmlNodeTABLE.GetColCount: Integer;
begin
Result := FLayouter.GetColCount;
end;
procedure TIpHtmlNodeTABLE.Enqueue;
var
h: Integer;
elem: PIpHtmlElement;
begin
// display block
//The commented code below prevents a blank line before the table
{
case Align of
hiaTop,
hiaMiddle,
hiaBottom,
hiaCenter :
EnqueueElement(Owner.SoftLF);
end;
}
// vertical margin: specified in CSS or none
h := GetMargin(Props.ElemMarginTop, 0);
elem := Owner.BuildLinefeedEntry(etSoftLF, h);
EnqueueElement(elem);
// insert element content
EnqueueElement(Element);
// close block
// vertical margin: specified in CSS or none
h := GetMargin(Props.ElemMarginBottom, 0);
elem := Owner.BuildLinefeedEntry(etHardLF, h);
EnqueueElement(elem);
{
case Align of
hiaTop,
hiaMiddle,
hiaBottom,
hiaCenter :
EnqueueElement(Owner.SoftLF);
end;
}
end;
procedure TIpHtmlNodeTABLE.SetBorder(const Value: Integer);
begin
FBorder := Value;
if Border = 0 then begin
Frame := hfVoid;
Rules := hrNone;
end else begin
Frame := hfBorder;
Rules := hrAll;
end;
InvalidateSize;
end;
function TIpHtmlNodeTABLE.GetMaxWidth: Integer;
begin
Result := FLayouter.Max;
end;
function TIpHtmlNodeTABLE.GetMinWidth: Integer;
begin
Result := FLayouter.Min;
end;
function TIpHtmlNodeTABLE.GetTableWidth: Integer;
begin
Result := FLayouter.TableWidth;
end;
function TIpHtmlNodeTABLE.GetCellPadding: Integer;
begin
Result := FLayouter.CellPadding;
end;
function TIpHtmlNodeTABLE.GetCellSpacing: Integer;
begin
Result := FLayouter.CellSpacing;
end;
procedure TIpHtmlNodeTABLE.SetCellPadding(const Value: Integer);
begin
FLayouter.CellPadding := Value;
InvalidateSize;
end;
procedure TIpHtmlNodeTABLE.SetCellSpacing(const Value: Integer);
begin
if not (FLayouter is TIpHtmlBaseTableLayouter) then
raise Exception.Create('TIpHtmlNodeTABLE.FLayouter has wrong type: ' + FLayouter.ClassName);
FLayouter.CellSpacing := Value;
InvalidateSize;
end;
procedure TIpHtmlNodeTABLE.SetFrame(const Value: TIpHtmlFrameProp);
begin
FFrame := Value;
InvalidateSize;
end;
procedure TIpHtmlNodeTABLE.SetRules(const Value: TIpHtmlRules);
begin
FRules := Value;
InvalidateSize;
end;
procedure TIpHtmlNodeTABLE.WidthChanged(Sender: TObject);
begin
InvalidateSize;
end;
function TIpHtmlNodeTABLE.ExpParentWidth: Integer;
begin
case Width.LengthType of
hlAbsolute :
Result := Width.LengthValue;
else
Result := inherited ExpParentWidth;
end;
end;
procedure TIpHtmlNodeTABLE.LoadAndApplyCSSProps;
begin
inherited LoadAndApplyCSSProps;
if FCombinedCSSProps = nil then
exit;
if FCombinedCSSProps.Border.Style <> cbsNone then
begin
FBorder := FCombinedCSSProps.Border.Width;
BorderColor := FCombinedCSSProps.Border.Color;
BorderStyle := FCombinedCSSProps.Border.Style;
if Frame = hfVoid then
begin
Frame := hfBorder;
Rules := hrGroups;
end;
end;
if FCombinedCSSProps.Width.LengthType <> cltUndefined then begin
FWidth.Free;
FWidth := TIpHtmlLength.Create;
FWidth.LengthValue := FCombinedCSSProps.Width.LengthValue;
FWidth.LengthType := TIpHtmlLengthType(ord(FCombinedCSSProps.Width.LengthType));
FWidth.OnChange := WidthChanged;
end;
end;
{-------------------------------------------------------------------------------
Descendants of TIpHtmlNodeGenInline
-------------------------------------------------------------------------------}
{ TIpHtmlNodeBASEFONT }
procedure TIpHtmlNodeBASEFONT.ApplyProps(
const RenderProps: TIpHtmlProps);
begin
Props.Assign(RenderProps);
Props.FontSize := FONTSIZESVALUESARRAY[Size-1];
Props.BaseFontSize := Size;
end;
{ TIpHtmlNodeDEL }
procedure TIpHtmlNodeDEL.ApplyProps(const RenderProps: TIpHtmlProps);
begin
Props.Assign(RenderProps);
Props.FontStyle := Props.FontStyle + [fsStrikeOut];
end;
{ TIpHtmlNodeFONT }
procedure TIpHtmlNodeFONT.ApplyProps(const RenderProps: TIpHtmlProps);
function GetFontSizeValue(aSize: integer): integer;
begin
aSize:=MaxI2(aSize,low(FONTSIZESVALUESARRAY));
aSize:=MinI2(aSize,high(FONTSIZESVALUESARRAY));
Result:=FONTSIZESVALUESARRAY[aSize];
end;
var
TmpSize : Integer;
begin
Props.Assign(RenderProps);
if Face <> '' then
Props.FontName := FindFontName(Face);
case Size.SizeType of
hrsAbsolute :
begin
TmpSize:=Size.Value;
Props.FontSize := GetFontSizeValue(TmpSize);
end;
hrsRelative :
begin
TmpSize := Props.BaseFontSize + Size.Value;
Props.FontSize := GetFontSizeValue(TmpSize);
end;
end;
if Color <> clNone then
Props.FontColor := Color;
end;
constructor TIpHtmlNodeFONT.Create(ParentNode: TIpHtmlNode);
begin
inherited;
FSize := TIpHtmlRelSize.Create;
end;
destructor TIpHtmlNodeFONT.Destroy;
begin
inherited;
FreeAndNil(FSize);
end;
procedure TIpHtmlNodeFONT.SetColor(const Value: TColor);
begin
if Value <> FColor then begin
FColor := Value;
InvalidateSize;
end;
end;
procedure TIpHtmlNodeFONT.SetFace(const Value: string);
begin
if Value <> FFace then begin
FFace := Value;
InvalidateSize;
end;
end;
procedure TIpHtmlNodeFONT.SizeChanged(Sender: TObject);
begin
InvalidateSize;
end;
{ TIpHtmlNodeFontStyle }
procedure TIpHtmlNodeFontStyle.ApplyProps(const RenderProps: TIpHtmlProps);
begin
Props.Assign(RenderProps);
case Style of
hfsTT:
begin
Props.FontName := Owner.FixedTypeface;
ElementName := 'tt';
end;
hfsI:
begin
Props.FontStyle := Props.FontStyle + [fsItalic];
ElementName := 'i';
end;
hfsB:
begin
Props.FontStyle := Props.FontStyle + [fsBold];
ElementName := 'b';
end;
hfsU:
begin
Props.FontStyle := Props.FontStyle + [fsUnderline];
ElementName := 'u';
end;
hfsSTRIKE:
begin
Props.FontStyle := Props.FontStyle + [fsStrikeout];
ElementName := 'strike';
end;
hfsS:
begin
Props.FontStyle := Props.FontStyle + [fsStrikeout];
ElementName := 's';
end;
hfsBIG: begin
Props.FontSize := Props.FontSize + 2;
ElementName := 'big';
end;
hfsSMALL:
begin
Props.FontSize := Max(Props.FontSize - 2, 0);
ElementName := 'small';
end;
hfsSUB:
begin
Props.FontSize := Max(Props.FontSize - 4, 0);
Props.FontBaseline := Props.FontBaseline - 2;
ElementName := 'sub';
end;
hfsSUP:
begin
Props.FontSize := Max(Props.FontSize - 4, 0);
Props.FontBaseline := Props.FontBaseline + 4;
ElementName := 'sup';
end;
end;
end;
{ TIpHtmlNodeINS }
procedure TIpHtmlNodeINS.ApplyProps(const RenderProps: TIpHtmlProps);
begin
Props.Assign(RenderProps);
Props.FontStyle := Props.FontStyle + [fsUnderline];
end;
{ TIpHtmlNodeNOBR }
procedure TIpHtmlNodeNOBR.ApplyProps(const RenderProps: TIpHtmlProps);
begin
Props.Assign(RenderProps);
Props.NoBreak := True;
end;
{ TIpHtmlNodePhrase }
procedure TIpHtmlNodePhrase.ApplyProps(const RenderProps: TIpHtmlProps);
begin
Props.Assign(RenderProps);
case Style of
hpsEM,
hpsVAR,
hpsCITE : Props.FontStyle := Props.FontStyle + [fsItalic];
hpsSTRONG : Props.FontStyle := Props.FontStyle + [fsBold];
hpsCODE,
hpsKBD,
hpsSAMP : Props.FontName := Owner.FixedTypeface;
end;
case Style of
hpsEM : ElementName := 'em';
hpsSTRONG : ElementName := 'strong';
hpsDFN : ElementName := 'dfn';
hpsCODE : ElementName := 'code';
hpsSAMP : ElementName := 'samp';
hpsKBD : ElementName := 'kbd';
hpsVAR : ElementName := 'var';
hpsCITE : ElementName := 'cite';
hpsABBR : ElementName := 'abbr';
hpsACRONYM : ElementName := 'acronym';
end;
end;
{ TIpHtmlNodeSPAN }
constructor TIpHtmlNodeSPAN.Create(ParentNode: TIpHtmlNode);
begin
inherited Create(ParentNode);
ElementName := 'span';
end;
procedure TIpHtmlNodeSPAN.ApplyProps(const RenderProps: TIpHtmlProps);
begin
Props.Assign(RenderProps);
Props.DelayCache:=True;
Props.Alignment := Align;
LoadAndApplyCSSProps;
Props.DelayCache:=False;
end;
function TIpHtmlNodeSPAN.GetAlign: TIpHtmlAlign;
begin
Result := FAlign;
end;
procedure TIpHtmlNodeSPAN.LoadAndApplyCSSProps;
begin
inherited;
if not (FCombinedCSSProps.Alignment in [haDefault, haUnknown]) then
Align := FCombinedCSSProps.Alignment;
end;
procedure TIpHtmlNodeSPAN.SetAlign(const Value: TIpHtmlAlign);
begin
FAlign := Value;
end;
{-------------------------------------------------------------------------------
Descendants of TIpHtmlNodeList
-------------------------------------------------------------------------------}
constructor TIpHtmlNodeUL.Create(ParentNode: TIpHtmlNode);
begin
inherited;
ElementName := 'ul';
end;
{-------------------------------------------------------------------------------
Descendants of TIpHtmlNodeControl
-------------------------------------------------------------------------------}
{ TIpHtmlNodeBUTTON }
procedure TIpHtmlNodeBUTTON.AddValues(NameList, ValueList : TStringList);
begin
end;
constructor TIpHtmlNodeBUTTON.Create(ParentNode: TIpHtmlNode);
begin
inherited Create(ParentNode);
ElementName := 'button';
Owner.ControlList.Add(Self);
if Owner.DoneLoading then
CreateControl(Owner.ControlParent);
end;
destructor TIpHtmlNodeBUTTON.Destroy;
begin
Owner.ControlList.Remove(Self);
inherited;
end;
procedure TIpHtmlNodeBUTTON.CreateControl(Parent: TWinControl);
begin
inherited;
Owner.ControlCreate(Self);
FControl := TButton.Create(Parent);
FControl.Visible := False;
FControl.Parent := Parent;
adjustFromCss;
with TButton(FControl) do begin
Enabled := not Self.Disabled;
Caption := GetButtonCaption;
OnClick := ButtonClick;
CalcSize;
end;
end;
function TIpHtmlNodeBUTTON.GetButtonCaption: String;
begin
if FValue = '' then
case FInputType of
hbtSubmit: Result := SHtmlDefSubmitCaption;
hbtReset: Result := SHtmlDefResetCaption;
hbtButton: Result := '';
end
else
Result := FValue;
end;
procedure TIpHtmlNodeBUTTON.Reset;
begin
end;
procedure TIpHtmlNodeBUTTON.ResetClick(Sender: TObject);
begin
ResetRequest;
end;
procedure TIpHtmlNodeBUTTON.SubmitClick(Sender: TObject);
begin
SubmitRequest;
end;
procedure TIpHtmlNodeBUTTON.ButtonClick(Sender: TObject);
begin
case ButtonType of
hbtSubmit :
begin
SubmitRequest;
end;
hbtReset :
begin
ResetRequest;
end;
hbtButton :
begin
Owner.ControlClick(Self);
end;
end;
end;
function TIpHtmlNodeBUTTON.Successful: Boolean;
begin
Result := False;
end;
procedure TIpHtmlNodeBUTTON.CalcSize;
var
oldFontSize: integer;
lCanvas: TCanvas;
begin
with Control as TButton do
begin
lCanvas := TCustomPanel(Parent).Canvas;
oldFontSize := lCanvas.Font.Size;
Width := lCanvas.TextWidth(Caption) + 40;
Height := lCanvas.TextHeight('Tg') + 10;
lCanvas.Font.Size := oldFontSize;
end;
end;
procedure TIpHtmlNodeBUTTON.SetInputType(const AValue: TIpHtmlButtonType);
begin
if FInputType = AValue then exit;
FInputType := AValue;
if Owner.DoneLoading and (FControl <> nil) and (Self.Value = '') then
SetValue(GetButtonCaption);
end;
procedure TIpHtmlNodeBUTTON.SetValue(const AValue: String);
begin
if FValue = AValue then Exit;
FValue := AValue;
if Owner.DoneLoading and (FControl <> nil) then
begin
(FControl as TButton).Caption := GetButtonCaption;
CalcSize;
end;
end;
{ TIpHtmlNodeINPUT }
constructor TIpHtmlNodeINPUT.Create(ParentNode: TIpHtmlNode);
begin
inherited;
ElementName := 'input';
Props.BgColor := clWhite;
end;
destructor TIpHtmlNodeINPUT.Destroy;
begin
inherited;
FPicture.Free;
end;
procedure TIpHtmlNodeINPUT.SetImageGlyph(Picture: TPicture);
var
FBitmap : TBitmap;
begin
with TBitbtn(FControl) do begin
FBitmap := TBitmap.Create;
try
FBitmap.Width := Picture.Width;
FBitmap.Height := Picture.Height;
Picture.Graphic.Transparent := False;
FBitmap.TransparentMode := tmFixed;
FBitmap.TransparentColor := RGBToColor(254, 254, 254);
FBitmap.Canvas.Draw(0, 0, Picture.Graphic);
Glyph.Assign(FBitmap);
Width := FBitmap.Width + 4;
Height := FBitmap.Height + 4;
finally
FBitmap.Free;
end;
end;
end;
procedure TIpHtmlNodeINPUT.Reset;
begin
case InputType of
hitText :
begin
with TEdit(FControl) do
Text := Value;
end;
hitPassword :
begin
with TEdit(FControl) do
Text := Value;
end;
hitCheckbox :
begin
with TCheckBox(FControl) do
Checked := Self.Checked;
end;
hitRadio :
begin
with THtmlRadioButton(FControl) do
Checked := Self.Checked;
end;
end;
end;
procedure TIpHtmlNodeINPUT.CreateControl(Parent: TWinControl);
var
iCurFontSize: integer;
aCanvas : TCanvas;
function OwnerForm: TIpHtmlNode;
begin
Result := FParentNode;
while (Result <> nil) and not (Result is TIpHtmlNodeFORM) do
Result := Result.ParentNode;
end;
procedure setCommonProperties;
begin
FControl.Parent := Parent;
FControl.Visible := False;
AdjustFromCss;
aCanvas.Font.Size := FControl.Font.Size;
end;
procedure SetWidthHeight(iSize, iTopPlus, iSidePlus: integer);
begin
if iSize <> -1 then
FControl.Width := iSize * aCanvas.TextWidth('0') + iSidePlus
else
FControl.Width := 20 * aCanvas.TextWidth('0') + iSidePlus;
FControl.Height := aCanvas.TextHeight('Wy') + iTopPlus;
end;
begin
inherited;
Owner.ControlCreate(Self);
aCanvas := TCustomPanel(Parent).Canvas;
iCurFontSize := aCanvas.Font.Size;
case InputType of
hitText :
begin
FControl := TEdit.Create(Parent);
setCommonProperties;
with TEdit(FControl) do begin
Color := Brush.Color;
Text := Value;
MaxLength := Self.MaxLength;
SetWidthHeight(Self.Size, 8, 0);
Enabled := not Self.Disabled;
ReadOnly := Self.ReadOnly;
OnChange := ButtonClick;
OnEditingDone := ControlOnEditingDone;
end;
end;
hitPassword :
begin
FControl := TEdit.Create(Parent);
setCommonProperties;
with TEdit(FControl) do begin
Color := Brush.Color;
Text := Value;
MaxLength := Self.MaxLength;
SetWidthHeight(Self.Size, 8, 0);
Enabled := not Self.Disabled;
ReadOnly := Self.ReadOnly;
PasswordChar := '*';
OnChange := ButtonClick;
OnEditingDone := ControlOnEditingDone;
end;
end;
hitCheckbox :
begin
FControl := TCheckBox.Create(Parent);
setCommonProperties;
with TCheckBox(FControl) do begin
Color := Brush.Color;
SetWidthHeight(1, 8, 0);
Checked := Self.Checked;
Enabled := not Self.Disabled and not Self.Readonly;
OnClick := ButtonClick;
OnEditingDone := ControlOnEditingDone;
end;
end;
hitRadio :
begin
FControl := THtmlRadioButton.Create(Parent);
FControl.Tag := PtrInt(OwnerForm);
setCommonProperties;
with THtmlRadioButton(FControl) do begin
Color := Brush.Color;
SetWidthHeight(1, 8, 0);
Checked := Self.Checked;
Enabled := not Self.Disabled and not Self.Readonly;
OnClick := ButtonClick;
OnEditingDone := ControlOnEditingDone;
end;
end;
hitSubmit :
begin
FControl := TButton.Create(Parent);
setCommonProperties;
with TButton(FControl) do begin
if Self.Value <> '' then
Caption := Self.Value
else
Caption := SHtmlDefSubmitCaption;
Color := Brush.Color;
Width := aCanvas.TextWidth(Caption) + 40;
Height := aCanvas.TextHeight(Caption) + 10;
Enabled := not Self.Disabled and not Self.Readonly;
OnClick := SubmitClick;
end;
end;
hitReset :
begin
FControl := TButton.Create(Parent);
setCommonProperties;
with TButton(FControl) do begin
if Self.Value <> '' then
Caption := Self.Value
else
Caption := SHtmlDefResetCaption;
Color := Brush.Color;
Width := aCanvas.TextWidth(Caption) + 40;
Height := aCanvas.TextHeight(Caption) + 10;
Enabled := not Self.Disabled and not Self.Readonly;
OnClick := ResetClick;
end;
end;
hitFile :
begin
FControl := TPanel.Create(Parent);
setCommonProperties;
with TPanel(FControl) do begin
Width := 200;
Height := aCanvas.TextHeight('Wy') + 12;
Enabled := not Self.Disabled and not Self.Readonly;
BevelInner := bvNone;
BevelOuter := bvNone;
BorderStyle := bsNone;
end;
FFileSelect := TButton.Create(Parent);
with FFileSelect do begin
Parent := FControl;
Height := aCanvas.TextHeight(SHtmlDefBrowseCaption) + 10;
Width := aCanvas.TextWidth(SHtmlDefBrowseCaption) + 40;
Left := FControl.Left + FControl.Width - Width;
Top := 1;
Caption := SHtmlDefBrowseCaption;
OnClick := FileSelect;
end;
FFileEdit := TEdit.Create(Parent);
with FFileEdit do begin
Parent := FControl;
Color := Brush.Color;
Left := 1;
Top := 1;
Width := FControl.Width - FFileSelect.Width;
Height := FControl.Height - 2;
end;
end;
hitHidden :
begin
end;
hitImage :
begin
FControl := TBitbtn.Create(Parent);
setCommonProperties;
Owner.DoGetImage(Self, Owner.BuildPath(Src), FPicture);
if FPicture = nil
then FPicture := Owner.DefaultImage;
with TBitbtn(FControl) do begin
Caption := Self.Value;
Enabled := not Self.Disabled and not Self.Readonly;
SetImageGlyph(FPicture);
end;
end;
hitButton :
begin
FControl := TButton.Create(Parent);
setCommonProperties;
with TButton(FControl) do begin
Caption := Self.Value;
Width := aCanvas.TextWidth(Caption) + 40;
Height := aCanvas.TextHeight(Caption) + 10;
Enabled := not Self.Disabled and not Self.Readonly;
OnClick := ButtonClick;
end;
end;
end;
if FControl <> nil then
begin
FControl.Hint := Alt;
FControl.ShowHint:=True;
if (FControl is TEdit) then
FControl.ControlStyle:=FControl.ControlStyle + [csOpaque];
end;
aCanvas.Font.Size := iCurFontSize;
end;
procedure TIpHtmlNodeINPUT.Draw;
begin
{
if Assigned(FInlineCSSProps) then
begin
if FInlineCSSProps.BGColor <> clNone then FControl.Color := FInlineCSSProps.BGColor;
if FInlineCSSProps.Color <> clNone then FControl.Font.Color := FInlineCSSProps.Color;
if FInlineCSSProps.Font.Size <> '' then FControl.Font.size := GetFontSizeFromCSS(FControl.Font.size, FInlineCSSProps.Font.Size);
end;
}
inherited;
if (Props.BgColor <> clNone) and (
(FControl is THtmlRadioButton) or
(FControl is TCustomEdit)) then
FControl.Color := Props.BgColor;
end;
procedure TIpHtmlNodeINPUT.ImageChange(NewPicture: TPicture);
begin
{$IFOPT C+}
Owner.CheckImage(NewPicture);
{$ENDIF}
if FPicture <> Owner.DefaultImage then
FPicture.Free;
FPicture := NewPicture;
SetImageGlyph(FPicture);
InvalidateSize;
end;
procedure TIpHtmlNodeINPUT.AddValues(NameList, ValueList : TStringList);
var
S : string;
begin
S := '';
case InputType of
hitText,
hitPassword :
S := TEdit(FControl).Text;
hitCheckbox :
S := Value;
hitRadio :
S := Value;
hitFile :
S := 'file://'+FFileEdit.Text;
hitHidden :
S := FValue;
end;
if S <> '' then begin
NameList.Add(Name);
ValueList.Add(S);
end;
end;
function TIpHtmlNodeINPUT.Successful: Boolean;
begin
Result :=
(Name <> '')and
( (InputType = hitHidden) or
( (not Disabled) and
(InputType in [hitText, hitPassword, hitCheckbox, hitRadio , hitFile])
)
);
if Result then begin
case InputType of
hitText,
hitPassword :
Result := TEdit(FControl).Text <> '';
hitCheckbox :
Result := TCheckBox(FControl).Checked;
hitRadio :
Result := THtmlRadioButton(FControl).Checked;
hitFile :
Result := FFileEdit.Text <> '';
hitHidden :
Result := FValue <> '';
end;
end;
end;
procedure TIpHtmlNodeINPUT.SubmitClick(Sender: TObject);
var
vCancel: boolean;
begin
vCancel := False;
Owner.ControlClick2(Self, vCancel);
if not vCancel then
SubmitRequest;
end;
procedure TIpHtmlNodeINPUT.ResetClick(Sender: TObject);
begin
ResetRequest;
end;
procedure TIpHtmlNodeINPUT.getControlValue;
begin
case InputType of
hitText,
hitPassword :
Value := TEdit(FControl).Text;
hitCheckbox :
Checked := TCheckBox(FControl).Checked;
hitRadio :
Checked := THtmlRadioButton(FControl).Checked;
end;
end;
procedure TIpHtmlNodeINPUT.ButtonClick(Sender: TObject);
begin
getControlValue;
Owner.ControlClick(Self);
end;
procedure TIpHtmlNodeINPUT.ControlOnEditingDone(Sender: TObject);
begin
getControlValue;
Owner.ControlOnEditingDone(Self);
end;
procedure TIpHtmlNodeINPUT.ControlOnChange(Sender: TObject);
begin
getControlValue;
Owner.ControlOnChange(Self);
end;
function TIpHtmlNodeINPUT.GetHint: string;
begin
Result := Alt;
end;
procedure TIpHtmlNodeINPUT.FileSelect(Sender: TObject);
begin
with TOpenDialog.Create(FControl) do
try
if Execute then
FFileEdit.Text := FileName;
finally
free;
end;
end;
{ TIpHtmlNodeSELECT }
constructor TIpHtmlNodeSELECT.Create(ParentNode: TIpHtmlNode);
begin
inherited;
ElementName := 'select';
FWidth := -1;
FSize := -1;
end;
destructor TIpHtmlNodeSELECT.Destroy;
begin
inherited;
end;
procedure TIpHtmlNodeSELECT.AddValues(NameList, ValueList : TStringList);
var
i : Integer;
begin
if FControl is TListBox then
with TListBox(FControl) do begin
for i := 0 to Pred(Items.Count) do
if Selected[i] then begin
NameList.Add(Self.Name);
ValueList.Add(Items[i]);
end;
end
else with TComboBox(FControl) do begin
NameList.Add(Self.Name);
ValueList.Add(Items[ItemIndex]);
end;
end;
procedure TIpHtmlNodeSELECT.CreateControl(Parent: TWinControl);
var
aCanvas : TCanvas;
SelectedText: string;
MinW: Integer;
procedure AdjustControl;
var
Sz: Integer;
begin
Sz := Size;
if Sz = -1 then Sz:= 1;
FControl.Visible := False;
FControl.Parent := Parent;
FControl.Height := (4 + aCAnvas.TextHeight('Wy')) * Sz;
FControl.Enabled := not Disabled;
FControl.OnClick := ButtonClick;
adjustFromCss;
end;
procedure CreateControlSub(Opt: TIpHtmlNodeOPTION);
var
k: Integer;
B: PAnsiChar;
S: String;
begin
if (Opt.ChildCount > 0) and (TObject(Opt.ChildNode[0]) is TIpHtmlNodeText) then
begin
S := TIpHtmlNodeText(Opt.ChildNode[0]).EscapedText;
Getmem(B, length(S) + 1);
try
TrimFormatting(S, B);
S := Trim(B);
if Multiple then begin
k := TListBox(FControl).Items.Add(S);
TListBox(FControl).Selected[k] := Opt.Selected;
end else begin
TComboBox(FControl).Items.Add(S);
if Opt.Selected then
SelectedText := S;
end;
MinW := MaxI2(MinW, aCanvas.TextWidth(S));
finally
FreeMem(B);
end;
end;
end;
var
i, j, iCurFontSize: integer;
OptGroup: TIpHtmlNodeOPTGROUP;
begin
inherited;
Owner.ControlCreate(Self);
aCanvas := TCustomPanel(Parent).Canvas;
iCurFontSize := aCanvas.Font.Size;
if Multiple then begin
FControl := TListBox.Create(Parent);
AdjustControl;
with TListBox(FControl) do begin
IntegralHeight := True;
MultiSelect := True;
OnSelectionChange := ListBoxSelectionChange;
end;
end else begin
FControl := TComboBox.Create(Parent);
AdjustControl;
with TComboBox(FControl) do begin
Style := csDropDownList;
OnEditingDone := ControlOnEditingdone;
end;
end;
MinW := 50;
SelectedText := '';
for i := 0 to Pred(ChildCount) do
if ChildNode[i] is TIpHtmlNodeOPTION then
CreateControlSub(TIpHtmlNodeOPTION(ChildNode[i]))
else if ChildNode[i] is TIpHtmlNodeOPTGROUP then begin
OptGroup := TIpHtmlNodeOPTGROUP(ChildNode[i]);
for j := 0 to Pred(OptGroup.ChildCount) do
if OptGroup.ChildNode[j] is TIpHtmlNodeOPTION then
CreateControlSub(TIpHtmlNodeOPTION(OptGroup.ChildNode[j]))
end;
if SelectedText <> '' then
with TComboBox(FControl) do
ItemIndex := Items.IndexOf(SelectedText);
if FComboBox and (Width <> -1) then
FControl.Width := Width*aCanvas.TextWidth('0')+ 20
else
FControl.Width := MinW + 40;
FControl.ShowHint:=True;
FControl.Hint:= Alt;
aCanvas.Font.Size := iCurFontSize;
end;
procedure TIpHtmlNodeSELECT.Reset;
var
SelectedText : string;
procedure ResetSub(Opt: TIpHtmlNodeOPTION);
var
k: Integer;
B: PAnsiChar;
S: String;
begin
if (Opt.ChildCount > 0) and (Opt.ChildNode[0] is TIpHtmlNodeText) then
begin
S := TIpHtmlNodeText(Opt.ChildNode[0]).EscapedText;
GetMem(B, length(S) + 1);
try
TrimFormatting(S, B);
if Multiple then begin
k := TListBox(FControl).Items.Add(Trim(B));
TListBox(FControl).Selected[k] := Opt.Selected;
end else begin
TComboBox(FControl).Items.Add(Trim(B));
if Opt.Selected then
SelectedText := Trim(B);
end;
finally
FreeMem(B);
end;
end;
end;
var
i, j: Integer;
OptGroup: TIpHtmlNodeOPTGROUP;
begin
SelectedText := '';
if Multiple then
TListBox(FControl).Clear
else
TComboBox(FControl).Clear;
for i := 0 to Pred(ChildCount) do
if ChildNode[i] is TIpHtmlNodeOPTION then
// Option
ResetSub(TIpHtmlNodeOPTION(ChildNode[i]))
else if ChildNode[i] is TIpHtmlNodeOPTGROUP then begin
// Option Group
OptGroup := TIpHtmlNodeOPTGROUP(ChildNode[i]);
for j := 0 to Pred(OptGroup.ChildCount) do
if OptGroup.ChildNode[j] is TIpHtmlNodeOPTION then
ResetSub(TIpHtmlNodeOPTION(OptGroup.ChildNode[j]));
end;
if not Multiple and (SelectedText <> '') then
with TComboBox(FControl) do
ItemIndex := Items.IndexOf(SelectedText);
end;
function TIpHtmlNodeSELECT.Successful: Boolean;
begin
Result := (Name <> '') and not Disabled;
if Result then
if FControl is TListBox then
Result := TListBox(FControl).SelCount > 0
else
Result := TComboBox(FControl).ItemIndex <> -1;
end;
procedure TIpHtmlNodeSELECT.ButtonClick(Sender: TObject);
begin
Owner.ControlClick(Self);
end;
procedure TIpHtmlNodeSELECT.ControlOnEditingDone(Sender: TObject);
begin
Owner.ControlOnEditingDone(Self);
end;
procedure TIpHtmlNodeSELECT.ListBoxSelectionChange(Sender: TObject; User: boolean);
begin
Owner.ControlOnEditingDone(Self);
end;
procedure TIpHtmlNodeSELECT.SetText(aText: string);
begin
if FComboBox then TComboBox(FControl).Text := aText;
end;
function TIpHtmlNodeSELECT.getText: string;
begin
if FComboBox then
result := TComboBox(FControl).Text
else if FMultiple then
result := IntToStr(TComboBox(FControl).ItemIndex)
else
result := IntToStr(TComboBox(FControl).ItemIndex);
end;
{ TIpHtmlNodeTEXTAREA }
constructor TIpHtmlNodeTEXTAREA.Create(ParentNode: TIpHtmlNode);
begin
inherited;
ElementName := 'textarea';
end;
destructor TIpHtmlNodeTEXTAREA.Destroy;
begin
inherited;
end;
procedure TIpHtmlNodeTEXTAREA.AddValues(NameList, ValueList: TStringList);
begin
NameList.Add(Name);
ValueList.Add(TMemo(FControl).Text);
end;
procedure TIpHtmlNodeTEXTAREA.CreateControl(Parent: TWinControl);
var
i : Integer;
S : string;
B : PAnsiChar;
iCurFontSize: integer;
aCanvas : TCanvas;
begin
inherited;
Owner.ControlCreate(Self);
aCanvas := TCustomPanel(Parent).Canvas;
iCurFontSize := aCanvas.Font.Size;
FControl := TMemo.Create(Parent);
FControl.Visible := False;
FControl.Parent := Parent;
TMemo(FControl).OnEditingDone:= ControlOnEditingDone;
adjustFromCss;
with TMemo(FControl) do begin
Width := Cols * TCustomPanel(Parent).Canvas.TextWidth('0');
Height := Rows * TCustomPanel(Parent).Canvas.TextHeight('Wy');
Enabled := not Self.Disabled;
end;
for i := 0 to Pred(ChildCount) do
if ChildNode[i] is TIpHtmlNodeText then begin
S := TIpHtmlNodeText(ChildNode[i]).EscapedText;
Getmem(B, length(S) + 1);
try
TrimFormatting(S, B);
TMemo(FControl).Lines.Add(B);
finally
FreeMem(B);
end;
end;
aCanvas.Font.Size := iCurFontSize;
end;
procedure TIpHtmlNodeTEXTAREA.Reset;
var
i : Integer;
S : string;
B : PAnsiChar;
begin
TMemo(FControl).Clear;
for i := 0 to Pred(ChildCount) do
if ChildNode[i] is TIpHtmlNodeText then begin
S := TIpHtmlNodeText(ChildNode[i]).EscapedText;
GetMem(B, length(S) + 1);
try
TrimFormatting(S, B);
TMemo(FControl).Lines.Add(B);
finally
Freemem(B);
end;
end;
end;
function TIpHtmlNodeTEXTAREA.Successful: Boolean;
begin
Result := trim(TMemo(FControl).Text) <> '';
end;
procedure TIpHtmlNodeTEXTAREA.ControlOnEditingDone(Sender: TObject);
begin
Owner.ControlOnEditingDone(Self);
end;
end.
|