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
|
/*
* Motif
*
* Copyright (c) 1987-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these librararies and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <Xm/ColumnP.h>
#include <Xm/RowColumn.h>
#include <Xm/Label.h>
#include <Xm/VaSimpleP.h>
#include "XmI.h"
#define XK_LATIN1
#include <X11/keysymdef.h>
static void ClassInitialize(void);
static void Initialize(Widget, Widget, ArgList, Cardinal*);
static void ClassPartInitialize(WidgetClass w_class);
static Boolean SetValues(Widget, Widget, Widget, ArgList, Cardinal*);
static void Destroy(Widget);
static void Resize(Widget);
static XtGeometryResult QueryGeometry(Widget,
XtWidgetGeometry*, XtWidgetGeometry*);
static XtGeometryResult GeometryManager(Widget,
XtWidgetGeometry*, XtWidgetGeometry*);
static void ChangeManaged(Widget);
static void ConstraintInitialize(Widget, Widget, ArgList, Cardinal*);
static Boolean ConstraintSetValues(Widget, Widget, Widget, ArgList, Cardinal*);
static void ConstraintDestroy(Widget);
static void ConstraintGetValues(Widget, ArgList, Cardinal*);
static Boolean CvtStringToXiAlignment(
Display*, XrmValue*, Cardinal*, XrmValue*, XrmValue*, XtPointer
);
static Boolean CvtStringToFillStyle(
Display*, XrmValue*, Cardinal*, XrmValue*, XrmValue*, XtPointer
);
static Boolean CvtStringToDistribution(
Display*, XrmValue*, Cardinal*, XrmValue*, XrmValue*, XtPointer
);
static void Layout(
XmColumnWidget, Widget, XtWidgetGeometry*, int, int
);
static void HorizontalLayout(
XmColumnWidget, Widget, XtWidgetGeometry*, int, int
);
static void VerticalLayout(
XmColumnWidget, Widget, XtWidgetGeometry*, int, int
);
static void VerifyResources(
XmColumnWidget, XmColumnWidget, XmColumnWidget
);
static void VerifyConstraints(
Widget, Widget, Widget
);
static void CalcSize(
XmColumnWidget, Widget, XtWidgetGeometry*, Boolean, Dimension*, Dimension*
);
static Boolean CompareGeometry(
XtWidgetGeometry*, XtWidgetGeometry*
);
static Boolean CompareGeometryToWidget(
XtWidgetGeometry*, Widget
);
static void CheckSetEntryLabelRenderTable(Widget wid, int offs, XrmValue *value);
static void CheckSetDefaultEntryLabelRenderTable(Widget wid, int offs, XrmValue *value);
static void XmColumnLabelDestroyedCallback(
Widget, XtPointer, XtPointer
);
#if 0 /* POSITION HANDLING */
Note: this code was never finished and has been pulled out. The
public and semi-public traces have been pulled out of the header files.
Everything is marked with the #if used above.
#endif
#define BBPart(w) ((XmBulletinBoardPart*)(&(((XmBulletinBoardWidget)(w))->bulletin_board)))
#define XiC(w) ((XmColumnConstraintPart*)(&((XmColumnConstraintPtr)((w)->core.constraints))->column))
#define XiValidChild(c) (((c)) != NULL && XtIsManaged((c)) && \
!(c)->core.being_destroyed && \
XiC(c)->label_widget != NULL)
#define XmColumn(c) ((XmColumnWidget) XtParent((c)))
#define XiAlignment(c) ((XiC((c))->label_alignment == XmALIGNMENT_UNSPECIFIED) \
? XmColumn_default_label_alignment(XmColumn((c))) \
: XiC(c)->label_alignment)
#if 0 /* POSITION HANDLING */
#define XiPosition(c) ((XiC(c)->label_position == XiLABEL_POSITION_UNSPECIFIED)\
? XmColumn_default_label_position(XmColumn(c)) \
: XiC(c)->label_position)
#endif
#define XiFill(c) ((XiC(c)->fill_style == XmFILL_UNSPECIFIED)\
? XmColumn_default_fill_style(XmColumn(c)) \
: XiC(c)->fill_style)
#define XiWidth(c) (XtWidth(c) + 2 * XtBorderWidth(c))
#define XiHeight(c) (XtHeight(c) + 2 * XtBorderWidth(c))
#if 0 /* POSITION HANDLING */
/* from public .h file */
#define XiLABEL_POSITION_UNSPECIFIED 0
#define XiLABEL_POSITION_CENTER (1L<<0)
#define XiLABEL_POSITION_LEFT (1L<<1)
#define XiLABEL_POSITION_RIGHT (1L<<2)
#define XiLABEL_POSITION_TOP (1L<<3)
#define XiLABEL_POSITION_BOTTOM (1L<<4)
/* structure member elements from private P.h file */
unsigned char default_label_position;
unsigned char label_position;
#define XmColumnC_label_position(w) XmColCField(w, label_position, unsigned char)
#define XmColumn_default_label_position(w) XmColField(w, default_label_position, unsigned char)
#endif
#define DEFAULT_ALIGNMENT XmALIGNMENT_BEGINNING
#if 0 /* POSITION HANDLING */
#define DEFAULT_POSITION XiLABEL_POSITION_LEFT
#endif
#define DEFAULT_ORIENTATION XmVERTICAL
#define DEFAULT_FILL_STYLE XmFILL_RAGGED
static XtResource resources[] =
{
{
"pri.vate", "Pri.vate", XmRBoolean,
sizeof(Boolean), XtOffsetOf(XmColumnRec, column.check_set_render_table),
XmRImmediate, (XtPointer) False
},
{
XmNdefaultEntryLabelFontList, XmCFontList, XmRFontList,
sizeof(XmFontList), XtOffsetOf(XmBulletinBoardRec, bulletin_board.label_font_list),
XmRCallProc, (XtPointer) CheckSetDefaultEntryLabelRenderTable
},
{
XmNdefaultEntryLabelRenderTable, XmCRenderTable, XmRRenderTable,
sizeof(XmRenderTable), XtOffsetOf(XmBulletinBoardRec, bulletin_board.label_font_list),
XmRCallProc, (XtPointer) CheckSetDefaultEntryLabelRenderTable
},
{
XmNdefaultEntryLabelAlignment, XmCAlignment, XmRXmAlignment,
sizeof(unsigned char), XtOffsetOf(XmColumnRec, column.default_label_alignment),
XmRImmediate, (XtPointer) DEFAULT_ALIGNMENT
},
#if 0 /* POSITION HANDLING */
{
XmNdefaultEntryLabelPosition, XmCEntryLabelPosition, XmRLabelPosition,
sizeof(unsigned char), XtOffsetOf(XmColumnRec, column.default_label_position),
XmRImmediate, (XtPointer) DEFAULT_POSITION
},
#endif
{
XmNdefaultFillStyle, XmCFillStyle, XmRFillStyle,
sizeof(unsigned char), XtOffsetOf(XmColumnRec, column.default_fill_style),
XmRImmediate, (XtPointer) DEFAULT_FILL_STYLE
},
{
XmNitemSpacing, XmCItemSpacing, XmRVerticalDimension,
sizeof(Dimension), XtOffsetOf(XmColumnRec, column.item_spacing),
XmRImmediate, (XtPointer) 2
},
{
XmNlabelSpacing, XmCLabelSpacing, XmRHorizontalDimension,
sizeof(Dimension), XtOffsetOf(XmColumnRec, column.label_spacing),
XmRImmediate, (XtPointer) 10
},
{
XmNorientation, XmCOrientation, XmROrientation,
sizeof(unsigned char), XtOffsetOf(XmColumnRec, column.orientation),
XmRImmediate, (XtPointer) DEFAULT_ORIENTATION
},
{
XmNdistribution, XmCDistribution, XmRDistribution,
sizeof(unsigned char), XtOffsetOf(XmColumnRec, column.distribution),
XmRImmediate, (XtPointer) XmDISTRIBUTE_TIGHT
}
};
static XmSyntheticResource get_resources[] =
{
{
XmNlabelSpacing, sizeof(Dimension),
XtOffsetOf(XmColumnRec, column.label_spacing),
XmeFromHorizontalPixels, (XmImportProc) XmeToHorizontalPixels
},
{
XmNitemSpacing, sizeof(Dimension),
XtOffsetOf(XmColumnRec, column.item_spacing),
XmeFromVerticalPixels, (XmImportProc) XmeToVerticalPixels
}
};
static XtResource constraint_resources[] =
{
{
"pri.vate", "Pri.vate", XmRBoolean,
sizeof(Boolean), XtOffsetOf(XmColumnConstraintRec, column.check_set_render_table),
XmRImmediate, (XtPointer) False
},
{
XmNentryLabelFontList, XmCFontList, XmRFontList,
sizeof(XmFontList), XtOffsetOf(XmColumnConstraintRec, column.label_font_list),
XmRCallProc, (XtPointer) CheckSetEntryLabelRenderTable
},
{
XmNentryLabelRenderTable, XmCRenderTable, XmRRenderTable,
sizeof(XmRenderTable), XtOffsetOf(XmColumnConstraintRec, column.label_font_list),
XmRCallProc, (XtPointer) CheckSetEntryLabelRenderTable
},
{
XmNentryLabelAlignment, XmCAlignment, XmRXmAlignment,
sizeof(unsigned char), XtOffsetOf(XmColumnConstraintRec, column.label_alignment),
XmRImmediate, (XtPointer) XmALIGNMENT_UNSPECIFIED
},
#if 0 /* POSITION HANDLING */
{
XmNentryLabelPosition, XmCEntryLabelPosition, XmRLabelPosition,
sizeof(unsigned char), XtOffsetOf(XmColumnConstraintRec, column.label_position),
XmRImmediate, (XtPointer) XiLABEL_POSITION_UNSPECIFIED
},
#endif
{
XmNfillStyle, XmCFillStyle, XmRFillStyle,
sizeof(unsigned char), XtOffsetOf(XmColumnConstraintRec, column.fill_style),
XmRImmediate, (XtPointer) XmFILL_UNSPECIFIED
},
{
XmNentryLabelType, XmCLabelType, XmRLabelType,
sizeof(unsigned char), XtOffsetOf(XmColumnConstraintRec, column.label_type),
XmRImmediate, (XtPointer) XmSTRING
},
{
XmNentryLabelString, XmCLabelString, XmRXmString,
sizeof(XmString), XtOffsetOf(XmColumnConstraintRec, column.label_string),
XmRImmediate, (XtPointer) NULL
},
{
XmNentryLabelPixmap, XmCLabelPixmap, XmRPrimForegroundPixmap,
sizeof(Pixmap), XtOffsetOf(XmColumnConstraintRec, column.label_pixmap),
XmRImmediate, (XtPointer) XmUNSPECIFIED_PIXMAP
},
{
XmNshowEntryLabel, XmCShowLabel, XmRBoolean,
sizeof(Boolean), XtOffsetOf(XmColumnConstraintRec, column.show_label),
XmRImmediate, (XtPointer) True
},
{
XmNstretchable, XmCStretchable, XmRBoolean,
sizeof(Boolean), XtOffsetOf(XmColumnConstraintRec, column.stretchable),
XmRImmediate, (XtPointer) False
}
};
/*
* Synthetic constraints. Note that these are NOT currently used,
* as the constraint get_values_hook method below seems to work where
* synthetic resources don't. Dunno.
*/
static void Get_entryLabelString(Widget, int, XtArgVal *);
static XmSyntheticResource cont_get_resources[] =
{
{
XmNentryLabelString, sizeof(XmString),
XtOffsetOf(XmColumnConstraintRec, column.label_string),
Get_entryLabelString, (XmImportProc) NULL
}
};
ConstraintClassExtensionRec xiColumnConstraintExtension = {
NULL, /* next_extension */
NULLQUARK, /* record_type */
XtConstraintExtensionVersion, /* version */
sizeof(ConstraintClassExtensionRec), /* record_size */
ConstraintGetValues /* get_values_hook */
};
XmColumnClassRec xmColumnClassRec = {
{
/* core_class members */
/* superclass */ (WidgetClass) &xmBulletinBoardClassRec,
/* class_name */ "XmColumn",
/* widget_size */ sizeof(XmColumnRec),
/* class_initialize */ ClassInitialize,
/* class_part_init */ ClassPartInitialize,
/* class_inited */ False,
/* initialize */ Initialize,
/* initialize_hook */ NULL,
/* realize */ XtInheritRealize,
/* actions */ NULL,
/* num_actions */ 0,
/* resources */ (XtResource*)resources,
/* num_resources */ XtNumber(resources),
/* xrm_class */ NULLQUARK,
/* compress_motion */ True,
/* compress_exposure */ True,
/* compress_enterleave*/ True,
/* visible_interest */ False,
/* destroy */ Destroy,
/* resize */ Resize,
/* expose */ XtInheritExpose,
/* set_values */ SetValues,
/* set_values_hook */ NULL,
/* set_values_almost */ XtInheritSetValuesAlmost,
/* get_values_hook */ NULL,
/* accept_focus */ NULL,
/* version */ XtVersion,
/* callback_private */ NULL,
/* tm_table */ XtInheritTranslations,
/* query_geometry */ (XtGeometryHandler) QueryGeometry,
/* display_accelerator*/ NULL,
/* extension */ NULL,
},
{
/* composite_class members */
/* geometry_manager */ GeometryManager,
/* change_managed */ ChangeManaged,
/* insert_child */ XtInheritInsertChild,
/* delete_child */ XtInheritDeleteChild,
/* extension */ NULL,
},
{ /* constraint_class fields */
/* resource list */ (XtResource*)constraint_resources,
/* num resources */ XtNumber(constraint_resources),
/* constraint size */ sizeof(XmColumnConstraintRec),
/* init proc */ ConstraintInitialize,
/* destroy proc */ ConstraintDestroy,
/* set values proc */ ConstraintSetValues,
/* extension */ &xiColumnConstraintExtension,
},
{ /* manager_class fields */
/* default translations */ XtInheritTranslations,
/* syn_resources */ get_resources,
/* num_syn_resources */ XtNumber(get_resources),
/* syn_cont_resources */ NULL, /* cont_get_resources, */
/* num_syn_cont_resources */ 0, /* XtNumber(cont_get_resources),*/
/* parent_process */ XmInheritParentProcess,
/* extension */ NULL,
},
{ /* bulletin board members */
/* always_install_accel */ False,
/* geo_matrix_create */ NULL,
/* focus_moved_proc */ XmInheritFocusMovedProc,
/* extension */ NULL,
},
{
/* column class members */
/* extension */ NULL,
}
};
WidgetClass xmColumnWidgetClass = (WidgetClass) &xmColumnClassRec;
/*
* Function:
* ClassInitialize(void)
* Description:
* This function is called the first time XmColumn or subclass is
* created. This function is used to install all need type
* converters for this widget class.
* Input:
* None.
* Output:
* None.
*/
static void
ClassInitialize(void)
{
XmColumnClassRec* wc = &xmColumnClassRec;
#if 0 /* POSITION HANDLING */
XtSetTypeConverter(XmRString, XmRLabelPosition,
(XtTypeConverter) CvtStringToLabelPosition,
NULL, 0, XtCacheAll, NULL);
#endif
XtSetTypeConverter(XmRString, XmRXmAlignment,
(XtTypeConverter) CvtStringToXiAlignment,
NULL, 0, XtCacheAll, NULL);
XtSetTypeConverter(XmRString, XmRFillStyle,
(XtTypeConverter) CvtStringToFillStyle,
NULL, 0, XtCacheAll, NULL);
XtSetTypeConverter(XmRString, XmRDistribution,
(XtTypeConverter) CvtStringToDistribution,
NULL, 0, XtCacheAll, NULL);
}
/*
* ClassPartInitialize sets up the fast subclassing for the widget.
*/
static void
#ifdef _NO_PROTO
ClassPartInitialize(w_class)
WidgetClass w_class ;
#else
ClassPartInitialize(WidgetClass w_class)
#endif /* _NO_PROTO */
{
_XmFastSubclassInit (w_class, XmCOLUMN_BIT);
}
/*
* Function:
* Initialize(request, set, arg_list, arg_cnt)
* Description:
* This function is called to initialize the resource values for each
* new widget instance. This function verifies the resource values
* and takes the needed actions to initialize the new instance.
* Input:
* request : Widget - user resource requests
* set : Widget - the resource values for the new widget
* arg_list : ArgList - the argument list used to set the resource
* ang_cnt : Cardinal - the number of arguments in the list
* Output:
* None.
*/
/* ARGSUSED */
static void
Initialize(Widget request, Widget set, ArgList arg_list, Cardinal *arg_cnt)
{
XmColumnWidget rc = (XmColumnWidget) request,
sc = (XmColumnWidget) set;
VerifyResources(rc, (XmColumnWidget) NULL, sc);
if( rc->core.width == 0 )
{
sc->core.width = 2 * (rc->manager.shadow_thickness +
BBPart(rc)->margin_width);
}
if( rc->core.height == 0 )
{
sc->core.height = 2 * (rc->manager.shadow_thickness +
BBPart(rc)->margin_height);
}
}
/*
* Function:
* Destroy(widget)
* Description:
* This function is called when an instance of the Column is being
* destroyed. This function deallocates any memory allocated by the
* instance.
* Input:
* widget : Widget - the widget being destroyed
* Output:
* None.
*/
/* ARGSUSED */
static void
Destroy(Widget widget)
{
/* This space intentionally left blank */
}
/*
* Function:
* Resize(widget)
* Description:
* This function is called when an instance changes size. This
* function needs to adjust the childrens sizes and positions
* appropriately for the new size.
* Input:
* widget : Widget - the widget that changed size.
* Output:
* None.
*/
static void
Resize(Widget widget)
{
WidgetClass sc = XtSuperclass(widget);
XmColumnWidget cw = (XmColumnWidget) widget;
XtWidgetProc resize;
_XmProcessLock();
resize = *sc->core_class.resize;
_XmProcessUnlock();
(* resize) (widget);
Layout(cw, NULL, NULL, -1, -1);
XmColumn_resize_done(cw) = True;
}
/*
* Function:
* SetValues(current, request, set, arg_list, arg_cnt)
* Description:
* This function is called when the user changes the resource
* values for the column. This function adjusts the columns
* appearance and behavior based on the new resource settings.
* Input:
* current : Widget - the current resource values for the widget
* request : Widget - the requested resource values for the widget
* set : Widget - the new resource values for the widget
* arg_list : ArgList - the argument list used to change the resource
* values
* arg_cnt :Cardinal - the number of arguments
* Output:
* Boolean - True if the Column needs redisplayed, else False.
*/
/* ARGSUSED */
static Boolean
SetValues(Widget current, Widget request, Widget set, ArgList arg_list,
Cardinal *arg_cnt)
{
XmColumnWidget cc = (XmColumnWidget) current,
cs = (XmColumnWidget) set;
Boolean request_size = False,
relayout = False;
WidgetList kid, kids = cs->composite.children;
Cardinal n, i, kidCnt = cs->composite.num_children;
Arg args[10];
VerifyResources((XmColumnWidget) request, cc, cs);
if( XmColumn_item_spacing(cc) != XmColumn_item_spacing(cs) ||
XmColumn_label_spacing(cc) != XmColumn_label_spacing(cs) ||
XmColumn_distribution(cc) != XmColumn_distribution(cs) ||
XmColumn_orientation(cc) != XmColumn_orientation(cs) ||
cc->manager.shadow_thickness != cs->manager.shadow_thickness ||
BBPart(cc)->margin_width != BBPart(cs)->margin_width ||
BBPart(cc)->margin_height != BBPart(cs)->margin_height)
{
request_size = True;
}
if( XmColumn_default_fill_style(cc) != XmColumn_default_fill_style(cs)
#if 0 /* POSITION HANDLING */
|| XmColumn_default_label_position(cc) != XmColumn_default_label_position(cs)
#endif
)
{
relayout = True;
}
n = 0;
if( cc->core.background_pixel != cs->core.background_pixel )
{
XtSetArg(args[n], XmNbackground, cs->core.background_pixel); n++;
}
if( cc->manager.foreground != cs->manager.foreground )
{
XtSetArg(args[n], XmNforeground, cs->manager.foreground); n++;
}
for( i = 0, kid = kids; i < kidCnt; ++i, ++kid )
{
if( (*kid) == NULL || (*kid)->core.being_destroyed ||
XiC(*kid)->label_widget == NULL ) continue;
XtSetValues(XiC(*kid)->label_widget, args, n);
}
if( BBPart(cc)->label_font_list !=
BBPart(cs)->label_font_list )
{
for( i = 0, kid = kids; i < kidCnt; ++i, ++kid )
{
if( (*kid) == NULL || (*kid)->core.being_destroyed ||
XiC(*kid)->label_widget == NULL ) continue;
if( XiC(*kid)->label_font_list == NULL )
{
XtVaSetValues(XiC(*kid)->label_widget,
XmNrenderTable,
BBPart(cs)->label_font_list,
NULL);
}
}
}
if( XmColumn_default_label_alignment(cc) !=
XmColumn_default_label_alignment(cs) )
{
for( i = 0, kid = kids; i < kidCnt; ++i, ++kid )
{
if( (*kid) == NULL || (*kid)->core.being_destroyed ||
XiC(*kid)->label_widget == NULL ) continue;
if( XiC(*kid)->label_alignment == XmALIGNMENT_UNSPECIFIED )
{
XtVaSetValues(XiC(*kid)->label_widget,
XmNalignment,
XmColumn_default_label_alignment(cs),
NULL);
}
}
}
if( request_size )
{
Dimension width, height;
XmColumn_resize_done(cs) = False;
CalcSize(cs, NULL, NULL, False, &width, &height);
if( XtMakeResizeRequest((Widget) cs, width, height, &width,
&height) == XtGeometryAlmost )
{
XmColumn_resize_done(cs) = False;
XtMakeResizeRequest((Widget) cs, width, height, NULL, NULL);
}
relayout = !XmColumn_resize_done(cs);
}
if( relayout )
{
Resize((Widget) cs);
}
return( False );
}
/*
* Function:
* QueryGeometry(widget, request, allowed)
* Description:
* This function is called when someone wants to know how the Column
* would react to a specific geometry or when someone wants to know
* what size the Column wants to be.
* Input:
* widget : Widget - the column widget
* request : XtWidgetGeometry* - the requested widget geometry
* allowed : XtWidgetGeometry* - the geometry column is will to accept
* Output:
* XtWidgetResult - the columns response to the geometry request
*/
static XtGeometryResult
QueryGeometry(Widget widget, XtWidgetGeometry *request,
XtWidgetGeometry *wanted)
{
XmColumnWidget cw = (XmColumnWidget) widget;
XtGeometryResult result;
Dimension width, height;
/*
* Lets start by calling this handly dandy function to calculate
* the geometry we want to be.
*/
CalcSize(cw, NULL, NULL, False, &width, &height);
/*
* Now lets see if the caller requested anything and if not
* lets give him our prefered geometry.
*/
if( request->request_mode == 0 )
{
wanted->request_mode = CWWidth | CWHeight;
wanted->width = width;
wanted->height = height;
if( width == XtWidth(cw) && height == XtHeight(cw) )
{
return( XtGeometryNo );
}
return( XtGeometryAlmost );
}
*wanted = *request;
if( request->request_mode & CWWidth )
{
if( request->width < width )
{
wanted->width = width;
}
}
if( request->request_mode & CWHeight )
{
if( request->height < height )
{
wanted->height = height;
}
}
/*
* Now we have set everything in our return structure to what we
* want it to be. Now all that is left is to come up with the
* correct return result. The return result is something like.
*
* o request == wanted and wanted != real -> XtGeometryYes
* o request == wanted and wanted == real -> XtGeometryNo
* o request != wanted and wanted != real -> XtGeometryAlmost
* o request != wanted and wanted == real -> XtGeometryNo
*/
/*
* Lets first see if request == wanted
*/
if( CompareGeometryToWidget(wanted, (Widget) cw) )
{
result = XtGeometryNo;
}
else
{
if( CompareGeometry(request, wanted) )
{
result = XtGeometryYes;
}
else
{
result = XtGeometryNo;
}
}
return( result );
}
/*
* Function:
* GeometryManager(widget, request, allowed)
* Description:
* This function is called when a child of the Column would like
* to change size. This function reacts to the child's request.
* Input:
* widget : Widget - the child requesting the change
* request : XtWidgetGeometry* - the requested widget geometry
* allowed : XtWidgetGeometry* - the geometry column is will to accept
* Output:
* XtWidgetResult - the columns response to the geometry request
*/
static XtGeometryResult
GeometryManager(Widget widget, XtWidgetGeometry *request,
XtWidgetGeometry *allowed)
{
XmColumnWidget cw = (XmColumnWidget) XtParent(widget);
Dimension width, height, width_return, height_return;
XtGeometryResult result;
Boolean equal;
/*
* Now being the mean manager that we are, we are only going to
* allow our children to change geometry parts the affect their
* size. i.e. we will not even discuss with them their position,
* this is mainly because we do not want to deal with it.
*/
*allowed = *request;
allowed->request_mode = request->request_mode =
(request->request_mode & ~(CWX | CWY));
/*
* Now lets see what this child wants to change.
*/
if( request->request_mode & CWWidth )
{
allowed->width = request->width;
}
else
{
allowed->width = XiC(widget)->request_width;
}
if( request->request_mode & CWHeight )
{
allowed->height = request->height;
}
else
{
allowed->height = XiC(widget)->request_height;
}
if( request->request_mode & CWBorderWidth )
{
allowed->border_width = request->border_width;
}
else
{
allowed->border_width = XtBorderWidth(widget);
}
/*
* Now that we know what size our child want to be lets see
* how that effects the geometry we want to be.
*/
CalcSize(cw, widget, allowed, False, &width, &height);
/*
* Now that we know that size that we want to be, lets ask our
* parent and see what they have to say.
*/
if( request->request_mode & XtCWQueryOnly )
{
XtWidgetGeometry req, alw;
req.request_mode = CWWidth | CWHeight | XtCWQueryOnly;
req.width = width;
req.height = height;
width = XtWidth(cw);
height = XtHeight(cw);
switch( XtMakeGeometryRequest((Widget) cw, &req, &alw) )
{
case XtGeometryYes:
return( XtGeometryYes );
break;
case XtGeometryAlmost:
if( alw.request_mode & CWWidth ) width = alw.width;
if( alw.request_mode & CWHeight ) height = alw.height;
case XtGeometryNo:
default:
Layout(cw, widget, allowed, width, height);
allowed->width = XiC(widget)->position.width;
allowed->height = XiC(widget)->position.height;
break;
}
}
else
{
Dimension cur_width, cur_height;
XiC(widget)->request_width = allowed->width;
XiC(widget)->request_height = allowed->height;
XmColumn_resize_done(cw) = False;
cur_width = XtWidth(cw);
cur_height = XtHeight(cw);
switch( XtMakeResizeRequest((Widget) cw, width, height,
&width_return, &height_return) )
{
case XtGeometryYes:
/*
* It appears that our parent will has let us change to
* the size that we want to be, so lets see if we need to
* call our resize procedure.
*/
if( !XmColumn_resize_done(cw) ) Resize((Widget) cw);
Layout(cw, widget, allowed, width, height);
allowed->width = XiC(widget)->position.width;
allowed->height = XiC(widget)->position.height;
break;
case XtGeometryAlmost:
cur_width = width_return;
cur_height = height_return;
case XtGeometryNo:
default:
Layout(cw, widget, allowed, cur_width, cur_height);
allowed->width = XiC(widget)->position.width;
allowed->height = XiC(widget)->position.height;
break;
}
}
width = XtWidth(widget);
height = XtHeight(widget);
equal = CompareGeometryToWidget(allowed, widget);
if( equal )
{
result = XtGeometryNo;
}
else
{
if( CompareGeometry(request, allowed) )
{
result = XtGeometryYes;
}
else
{
result = XtGeometryAlmost;
}
}
if( result == XtGeometryYes )
{
Layout(cw, NULL, NULL, -1, -1);
}
return( result );
}
/*
* Function:
* ChangeManaged(widget)
* Description:
* This is called when one of the children of the column changes
* managed state. This routine just takes care of this situation.
* Input:
* widget : Widget - the column widget
* Output:
* None.
*/
static void
ChangeManaged(Widget widget)
{
static Boolean in = False;
XmColumnWidget cw = (XmColumnWidget) widget;
WidgetList kid = cw->composite.children;
Widget label;
Cardinal i;
Dimension width, height;
if( in ) return;
in = True;
for( i = 0; i < cw->composite.num_children; ++i, ++kid )
{
if( !XiValidChild(*kid) )
{
if( (*kid) != NULL && !XtIsManaged(*kid) )
{ /* CR03731 */
if (XiC(*kid)->label_widget) {
XtUnmanageChild(XiC(*kid)->label_widget);
}
XiC(*kid)->request_width = 0;
XiC(*kid)->request_height = 0;
}
continue;
}
label = XiC(*kid)->label_widget;
if( !XiC(*kid)->show_label )
{
if( XtIsManaged(*kid) ) XtUnmanageChild(label);
}
else if( XtIsManaged(*kid) != XtIsManaged(label) )
{
if( XtIsManaged(*kid) )
{
XtManageChild(label);
}
else
{
XtUnmanageChild(label);
}
}
if( XiC(*kid)->request_width == 0 && XtIsManaged(*kid) )
{
XiC(*kid)->request_width = XtWidth(*kid);
XiC(*kid)->request_height = XtHeight(*kid);
}
if( XtIsManaged(label) )
{
if( XiC(label)->request_width == 0 )
{
#if 0
XiC(label)->request_width = XtWidth(label);
XiC(label)->request_height = XtHeight(label);
#else
{
/* Unfortunately, XtWidth() and XtHeight() may not be valid in
** this case. The request_width and request_height values are
** used both to indicate real requested size and also, when 0,
** to indicate a label with particular geometry needs.
** However, if the code goes through ConstraintSetValues (in
** code generated by the Xcessory tools, constraint resources
** are set via set-values after widget creation) first, the
** sizes are 0 and are then set to 1 in VerticalLayout; then
** the code comes through here and updates the request values
** from the real widths -- 1 -- which are then set back on the
** widget as the geometry. The net result is that the labels
** appear with width 1 (and correct height).
**
** Ideally we would cache the real initial requested value and
** update from that value.
**
** For now, rather than storing those values, query the
** label locally for its preferences and use those; the result
** should be that the size is set correctly (going through
** CalcSize and then VerticalLayout).
*/
XtWidgetGeometry wants;
XtQueryGeometry(label, NULL, &wants);
if( wants.request_mode & CWWidth )
{
XiC(label)->request_width = wants.width;
}
else
{
XiC(label)->request_width = XtWidth(label);
}
if( wants.request_mode & CWHeight )
{
XiC(label)->request_height = wants.height;
}
else
{
XiC(label)->request_height = XtHeight(label);
}
}
#endif
}
}
else
{
XiC(label)->request_width = 0;
XiC(label)->request_height = 0;
}
}
CalcSize(cw, NULL, NULL, False, &width, &height);
if( XtMakeResizeRequest(widget, width, height, &width, &height) ==
XtGeometryAlmost )
{
XtMakeResizeRequest(widget, width, height, NULL, NULL);
}
Layout(cw, NULL, NULL, -1, -1);
in = False;
}
/*
* Function:
* ConstraintInitialize(request, new_w, arg_list, arg_cnt)
* Description:
* This function initializes the constraint record for a new child,
* this includes adding a label for each child.
* Input:
* request : Widget - the requested resource values
* new_w : Widget - the new_w resource values (the new widget)
* arg_list : ArgList - the argument used to create the widget
* arg_cnt : Cardinal - the number of arguments
* Output:
* None.
*/
/* ARGSUSED */
static void
ConstraintInitialize(Widget request, Widget new_w, ArgList arg_list,
Cardinal *arg_cnt)
{
static Boolean label_widget = False; /* STATIC DATA */
XmColumnWidget cw = (XmColumnWidget) XtParent(new_w);
XmBulletinBoardPart *bbpart;
/* CR03562 CR02961 When ChangeManaged is bypassed, request width and height
are not set. The 2 line will prevent this assumption which sometimes
will case the widget size to have zero width/height */
#if 1
/* Note! below fix problematic w.r.t. ChangeManaged code, and needs
** revisiting; back out temporarily
*/
/*
** It is possible that the widget will have a constraint resource set
** on it before the XmColumn itself is realized (ChangeManaged is
** bypassed in that case), so that we enter the Layout code without
** having the values request_width and request_height set from the
** code in ChangeManaged. Rather than use 0 here, which gives poor
** results when those values are used in XtConfigureWidget to set
** the size, initialize them to reasonable default values.
*/
XiC(new_w)->request_width = XtWidth(new_w);
XiC(new_w)->request_height = XtHeight(new_w);
#else
XiC(new_w)->request_width = 0;
XiC(new_w)->request_height = 0;
#endif
XiC(new_w)->label_string = XmStringCopy(XiC(new_w)->label_string);
if( label_widget )
{
XiC(new_w)->label_alignment = XmALIGNMENT_UNSPECIFIED;
#if 0 /* POSITION HANDLING */
XiC(new_w)->label_position = XiLABEL_POSITION_UNSPECIFIED;
#endif
XiC(new_w)->label_type = XmSTRING;
XiC(new_w)->label_pixmap = XmUNSPECIFIED_PIXMAP;
XiC(new_w)->label_string = (XmString) NULL;
XiC(new_w)->label_widget = (Widget) NULL;
XiC(new_w)->show_label = False;
}
else
{
Arg args[64];
int nargs;
char buf[256];
Widget label;
XmFontList lfont;
VerifyConstraints(request, NULL, new_w);
if( strlen(XtName(new_w)) > 240 )
{
strncpy(buf, XtName(new_w), 240);
buf[240] = '\0';
strcat(buf, "_label");
}
else
{
strcpy(buf, XtName(new_w));
strcat(buf, "_label");
}
label_widget = True;
lfont = XmColumnC_label_font_list(new_w);
bbpart = BBPart(XtParent(new_w));
if(lfont == NULL)
lfont = bbpart->label_font_list;
nargs = 0;
XtSetArg(args[nargs], XmNmarginWidth, 0); nargs++;
XtSetArg(args[nargs], XmNmarginHeight, 0); nargs++;
XtSetArg(args[nargs], XmNmarginTop, 0); nargs++;
XtSetArg(args[nargs], XmNmarginBottom, 0); nargs++;
XtSetArg(args[nargs], XmNmarginLeft, 0); nargs++;
XtSetArg(args[nargs], XmNmarginRight, 0); nargs++;
XtSetArg(args[nargs], XmNshadowThickness, 0); nargs++;
XtSetArg(args[nargs], XmNhighlightThickness, 0); nargs++;
XtSetArg(args[nargs], XmNtraversalOn, False); nargs++;
XtSetArg(args[nargs], XmNlabelType, XiC(new_w)->label_type); nargs++;
XtSetArg(args[nargs],
XmNlabelString, XiC(new_w)->label_string); nargs++;
XtSetArg(args[nargs],
XmNlabelPixmap, XiC(new_w)->label_pixmap); nargs++;
XtSetArg(args[nargs], XmNalignment, XiAlignment(new_w)); nargs++;
XtSetArg(args[nargs], XmNrenderTable, lfont); nargs++;
XtSetArg(args[nargs], XmNrecomputeSize, True); nargs++;
XtSetArg(args[nargs], XmNforeground, cw->manager.foreground); nargs++;
XtSetArg(args[nargs],
XmNbackground, cw->core.background_pixel); nargs++;
label = XtCreateWidget(buf, xmLabelWidgetClass, (Widget) cw,
args, nargs);
XiC(new_w)->label_widget = label;
XtAddCallback(label, XmNdestroyCallback,
XmColumnLabelDestroyedCallback, (XtPointer) new_w);
XiC(label)->label_alignment = XmALIGNMENT_UNSPECIFIED;
#if 0 /* POSITION HANDLING */
XiC(label)->label_position = XiLABEL_POSITION_UNSPECIFIED;
#endif
XiC(label)->label_type = XmSTRING;
XiC(label)->label_pixmap = XmUNSPECIFIED_PIXMAP;
XiC(label)->label_string = (XmString) NULL;
XiC(label)->label_widget = (Widget) NULL;
XiC(label)->show_label = False;
label_widget = False;
}
}
/*
* Function:
* ConstraintSetValues(current, request, new_w, arg_list, arg_cnt)
* Description:
* This function is called when the user changes an attribute of
* one of the columns children. This routine reacts to the change.
* Input:
* current : Widget - the current state of the child
* request : Widget - the request state of the child
* new_w : Widget - the child with the requested changes
* arg_list : ArgList - the argument that modified the child
* arg_cnt : Cardinal - the number of argument
* Output:
* Boolean - True if the child needs to be redisplayed, else False.
*/
/* ARGSUSED */
static Boolean
ConstraintSetValues(Widget current, Widget request, Widget new_w,
ArgList arg_list, Cardinal *arg_cnt)
{
XmColumnWidget cw = (XmColumnWidget) XtParent(new_w);
XmColumnConstraintPart *cc = XiC(current),
*sc = XiC(new_w);
Boolean relayout = False;
Arg args[10];
Cardinal i = 0;
if( XiC(new_w)->label_widget == NULL ) return( False );
VerifyConstraints(request, current, new_w);
if(
#if 0 /* POSITION HANDLING */
cc->label_position != sc->label_position ||
#endif
cc->fill_style != sc->fill_style ||
cc->show_label != sc->show_label )
{
relayout = True;
}
if( cc->label_font_list != sc->label_font_list )
{
XmFontList lfont = XmColumnC_label_font_list(new_w);
if(lfont == NULL)
lfont = BBPart(XtParent(new_w))->label_font_list;
XtSetArg(args[i], XmNrenderTable, lfont); ++i;
}
if( cc->label_alignment != sc->label_alignment )
{
XtSetArg(args[i], XmNalignment, XiAlignment(new_w)); ++i;
}
if( cc->label_string != sc->label_string )
{
XmStringFree(cc->label_string);
sc->label_string = XmStringCopy(sc->label_string);
XtSetArg(args[i], XmNlabelString, sc->label_string); ++i;
}
if( cc->label_pixmap != sc->label_pixmap )
{
XtSetArg(args[i], XmNlabelPixmap, sc->label_pixmap); ++i;
}
if( cc->label_type != sc->label_type )
{
XtSetArg(args[i], XmNlabelType, sc->label_type); ++i;
}
if( i > 0 ) XtSetValues(sc->label_widget, args, i);
XmColumn_resize_done(cw) = False;
if( cc->show_label != sc->show_label )
{
if( sc->show_label )
{
XtManageChild(sc->label_widget);
}
else
{
XtUnmanageChild(sc->label_widget);
}
}
if( relayout && !XmColumn_resize_done(cw) )
{
Layout(cw, NULL, NULL, -1, -1);
}
return( False );
}
/*
* Function:
* ConstraintDestroy(widget)
* Description:
* This function is called to deallocate any resources allocated by
* the constraint record.
* Input:
* widget : Widget - the widget being destroyed.
* Output:
* None.
*/
static void
ConstraintDestroy(Widget widget)
{
XmStringFree(XiC(widget)->label_string);
if( XiC(widget)->label_widget != NULL )
{
XtRemoveCallback(XiC(widget)->label_widget, XmNdestroyCallback,
XmColumnLabelDestroyedCallback, (XtPointer) widget);
XtDestroyWidget(XiC(widget)->label_widget);
XiC(widget)->label_widget = NULL;
}
}
/*
* Function:
* ConstraintGetValues
* Description:
* The constraint get_values_hook method. It makes copies of the
* XmNentryLabelString values to prevent returning internal
* XmString data.
* Input:
* w - The child widget
* args - Array of Arg structures
* num_args - Number of entries in args
* Output:
* none (other than the silently copies XmString value)
*/
static void
ConstraintGetValues(Widget w, ArgList args, Cardinal *num_args)
{
XrmQuark quark;
int i;
quark = XrmStringToQuark(XmNentryLabelString);
for (i = 0; i < ((int) *num_args); i++)
{
if (quark == XrmStringToQuark(args[i].name))
{
args[i].value =
(XtArgVal) XmStringCopy(XmColumnC_label_string(w));
break;
}
}
}
static int
CompareISOLatin1 (char *first, char *second)
{
register unsigned char *ap, *bp;
for (ap = (unsigned char *) first, bp = (unsigned char *) second;
*ap && *bp; ap++, bp++) {
register unsigned char a, b;
if ((a = *ap) != (b = *bp)) {
/* try lowercasing and try again */
if ((a >= XK_A) && (a <= XK_Z))
a += (XK_a - XK_A);
else if ((a >= XK_Agrave) && (a <= XK_Odiaeresis))
a += (XK_agrave - XK_Agrave);
else if ((a >= XK_Ooblique) && (a <= XK_Thorn))
a += (XK_oslash - XK_Ooblique);
if ((b >= XK_A) && (b <= XK_Z))
b += (XK_a - XK_A);
else if ((b >= XK_Agrave) && (b <= XK_Odiaeresis))
b += (XK_agrave - XK_Agrave);
else if ((b >= XK_Ooblique) && (b <= XK_Thorn))
b += (XK_oslash - XK_Ooblique);
if (a != b) break;
}
}
return (((int) *bp) - ((int) *ap));
}
/*
* Function:
* done
* Description:
* This macro is used by the resource conversion routines and
* simply assigns the value and returns the correct result.
*/
#define done(type, value) \
{ \
if( to->addr != NULL ) \
{ \
if( to->size < sizeof(type) ) \
{ \
to->size = sizeof(type); \
return( False ); \
} \
*(type*)(to->addr) = (value); \
} \
else \
{ \
static type static_val; \
static_val = (value); \
to->addr = (XtPointer) &static_val; \
} \
to->size = sizeof(type); \
return( True ); \
}
#if 0 /* POSITION HANDLING */
/*
* Function:
* CvtStringToLabelPosition(dpy, args, arg_cnt, from, to, data)
* Description:
* This function converts a string representation of the representation
* type XmRLabelPosition to an actual value.
* Input:
* dpy : Display - unused
* args : XrmValue* - unused
* arg_cnt : Cardinal - unused
* from : XrmValue* - contains the string representation of the value
* to : XrmValue* - returns the actual value
* data : XtPointer - unused
* Output:
* Boolean - True if the conversion was successful else False.
*/
static Boolean
CvtStringToLabelPosition(Display *dpy, XrmValue *args, Cardinal *arg_cnt,
XrmValue *from, XrmValue *to, XtPointer data)
{
unsigned char result = XiLABEL_POSITION_LEFT;
String str = (String) (from->addr);
if( CompareISOLatin1(str, "label_position_unspecified") == 0 ||
CompareISOLatin1(str, "unspecified") == 0 )
{
result = XiLABEL_POSITION_UNSPECIFIED;
}
else if( CompareISOLatin1(str, "label_position_left") == 0 ||
CompareISOLatin1(str, "left") == 0 )
{
result = XiLABEL_POSITION_LEFT;
}
else if( CompareISOLatin1(str, "label_position_right") == 0 ||
CompareISOLatin1(str, "right") == 0 )
{
result = XiLABEL_POSITION_RIGHT;
}
else if( CompareISOLatin1(str, "label_position_top") == 0 ||
CompareISOLatin1(str, "top") == 0 )
{
result = XiLABEL_POSITION_TOP;
}
else if( CompareISOLatin1(str, "label_position_bottom") == 0 ||
CompareISOLatin1(str, "bottom") == 0 )
{
result = XiLABEL_POSITION_BOTTOM;
}
else if( CompareISOLatin1(str, "label_position_center") == 0 ||
CompareISOLatin1(str, "CENTER") == 0 )
{
result = XiLABEL_POSITION_CENTER;
}
else
{
XtDisplayStringConversionWarning(dpy, from->addr, XmRLabelPosition);
return( False );
}
done(unsigned char, result);
}
#endif
/*
* Function:
* CvtStringToXiAlignment(dpy, args, arg_cnt, from, to, data)
* Description:
* This function converts a string representation of the representation
* type XmRXnAlignment to an actual value.
* Input:
* dpy : Display - unused
* args : XrmValue* - unused
* arg_cnt : Cardinal - unused
* from : XrmValue* - contains the string representation of the value
* to : XrmValue* - returns the actual value
* data : XtPointer - unused
* Output:
* Boolean - True if the conversion was successful else False.
*/
/* ARGSUSED */
static Boolean
CvtStringToXiAlignment(Display *dpy, XrmValue *args, Cardinal *arg_cnt,
XrmValue *from, XrmValue *to, XtPointer data)
{
unsigned char result = XmALIGNMENT_CENTER;
String str = (String) (from->addr);
if( CompareISOLatin1(str, "alignment_unspecified") == 0 ||
CompareISOLatin1(str, "unspecified") == 0 )
{
result = XmALIGNMENT_UNSPECIFIED;
}
else if( CompareISOLatin1(str, "alignment_beginning") == 0 ||
CompareISOLatin1(str, "beginning") == 0 )
{
result = XmALIGNMENT_BEGINNING;
}
else if( CompareISOLatin1(str, "alignment_center") == 0 ||
CompareISOLatin1(str, "center") == 0 )
{
result = XmALIGNMENT_CENTER;
}
else if( CompareISOLatin1(str, "alignment_end") == 0 ||
CompareISOLatin1(str, "end") == 0 )
{
result = XmALIGNMENT_END;
}
else
{
XtDisplayStringConversionWarning(dpy, from->addr, XmRXmAlignment);
return( False );
}
done(unsigned char, result);
}
/*
* Function:
* CvtStringToFillStyle(dpy, args, arg_cnt, from, to, data)
* Description:
* This function converts a string representation of the representation
* type XmRFillStyle to an actual value.
* Input:
* dpy : Display - unused
* args : XrmValue* - unused
* arg_cnt : Cardinal - unused
* from : XrmValue* - contains the string representation of the value
* to : XrmValue* - returns the actual value
* data : XtPointer - unused
* Output:
* Boolean - True if the conversion was successful else False.
*/
/* ARGSUSED */
static Boolean
CvtStringToFillStyle(Display *dpy, XrmValue *args, Cardinal *arg_cnt,
XrmValue *from, XrmValue *to, XtPointer data)
{
unsigned char result = XmFILL_UNSPECIFIED;
String str = (String) (from->addr);
if( CompareISOLatin1(str, "fill_unspecified") == 0 ||
CompareISOLatin1(str, "unspecified") == 0 )
{
result = XmFILL_UNSPECIFIED;
}
else if( CompareISOLatin1(str, "fill_flush") == 0 ||
CompareISOLatin1(str, "flush") == 0 )
{
result = XmFILL_FLUSH;
}
else if( CompareISOLatin1(str, "fill_ragged") == 0 ||
CompareISOLatin1(str, "ragged") == 0 )
{
result = XmFILL_RAGGED;
}
else
{
XtDisplayStringConversionWarning(dpy, from->addr, XmRFillStyle);
return( False );
}
done(unsigned char, result);
}
/*
* Function:
* CvtStringToDistribution(dpy, args, arg_cnt, from, to, data)
* Description:
* This function converts a string representation of the representation
* type XmRDistribution to an actual value.
* Input:
* dpy : Display - unused
* args : XrmValue* - unused
* arg_cnt : Cardinal - unused
* from : XrmValue* - contains the string representation of the value
* to : XrmValue* - returns the actual value
* data : XtPointer - unused
* Output:
* Boolean - True if the conversion was successful else False.
*/
/* ARGSUSED */
static Boolean
CvtStringToDistribution(Display *dpy, XrmValue *args, Cardinal *arg_cnt,
XrmValue *from, XrmValue *to, XtPointer data)
{
unsigned char result = XmDISTRIBUTE_TIGHT;
String str = (String) (from->addr);
if( CompareISOLatin1(str, "distribute_tight") == 0 ||
CompareISOLatin1(str, "tight") == 0 )
{
result = XmDISTRIBUTE_TIGHT;
}
else if( CompareISOLatin1(str, "distribute_spread") == 0 ||
CompareISOLatin1(str, "spread") == 0 )
{
result = XmDISTRIBUTE_SPREAD;
}
else
{
XtDisplayStringConversionWarning(dpy, from->addr, XmRDistribution);
return( False );
}
done(unsigned char, result);
}
/*
* Function:
* VerifyResources(request, current, new_w)
* Description:
* This function verifies the values for the Column's resource in
* "new_w" resetting them to the previous or default values if an
* invalid resource value was set.
* Input:
* request : XmColumnWidget - the requested setting for the widget
* current : XmColumnWidget - the current setting for the widget
* new_w : XmColumnWidget - the setting for the widget
* Output:
* None.
*/
/* ARGSUSED */
static void
VerifyResources(XmColumnWidget request, XmColumnWidget current,
XmColumnWidget new_w)
{
Boolean reset;
if( BBPart(new_w)->label_font_list == NULL )
{
BBPart(new_w)->label_font_list =
XmeGetDefaultRenderTable((Widget) new_w, XmLABEL_FONTLIST);
}
reset = False;
#if 0 /* POSITION HANDLING */
switch( XmColumn_default_label_position(new_w) )
{
case XiLABEL_POSITION_CENTER:
case XiLABEL_POSITION_LEFT:
case XiLABEL_POSITION_RIGHT:
case XiLABEL_POSITION_TOP:
case XiLABEL_POSITION_BOTTOM:
break;
case XiLABEL_POSITION_UNSPECIFIED:
XmeWarning((Widget) new_w),
"The illegal resource value \"XiLABEL_POSITION_UNSPECIFIED\" was assigned to the resource XmNDefaultLabelPosition");
reset = True;
break;
default:
XmeWarning((Widget) new_w,
"An illegal resource value was assigned to the resource XmNDefaultLabelPosition");
reset = True;
break;
}
if( reset )
{
XmColumn_default_label_position(new_w) =
(current != NULL
? XmColumn_default_label_position(current)
: DEFAULT_POSITION);
}
#endif
reset = False;
switch( XmColumn_default_label_alignment(new_w) )
{
case XmALIGNMENT_BEGINNING:
case XmALIGNMENT_CENTER:
case XmALIGNMENT_END:
break;
case XmALIGNMENT_UNSPECIFIED:
XmeWarning((Widget) new_w,
"The illegal resource value \"XmALIGNMENT_UNSPECIFIED\" was assigned to the resource XmNdefaultEntryLabelAlignment");
reset = True;
break;
default:
XmeWarning((Widget) new_w,
"An illegal resource value was assigned to the resource XmNdefaultEntryLabelAlignment");
reset = True;
break;
}
if( reset )
{
XmColumn_default_label_alignment(new_w) =
(current != NULL
? XmColumn_default_label_alignment(current)
: DEFAULT_ALIGNMENT);
}
reset = False;
switch( XmColumn_orientation(new_w) )
{
case XmHORIZONTAL:
case XmVERTICAL:
break;
default:
XmeWarning((Widget) new_w,
"An illegal resource value was assigned to the resource XmNorientation");
reset = True;
break;
}
if( reset )
{
XmColumn_orientation(new_w) =
(current != NULL
? XmColumn_orientation(current)
: DEFAULT_ORIENTATION);
}
}
/*
* Function:
* Layout(cw, child, child_size, col_width, col_height)
* Description:
* This is simply a launcher routine. This routine passes control
* to the appropriate layout routine depending on the orientation
* of the column.
* Input:
* cw : XmColumnWidget - the column to layout
* child : Widget - A childs whose geometry is specified
* child_size : XtWidgetGeometry* - the specified child geometry
* col_width : int - a specified width for the column
* col_height : int - a specified height for the column
* Output:
* None.
*/
static void
Layout(XmColumnWidget cw, Widget child, XtWidgetGeometry *child_size,
int col_width, int col_height)
{
if (XmColumn_orientation(cw) == XmHORIZONTAL)
{
HorizontalLayout(cw, child, child_size, col_width, col_height);
}
else
{
VerticalLayout(cw, child, child_size, col_width, col_height);
}
}
/*
* Function:
* HorizontalLayout(cw, child, child_size, col_witdh, col_height)
* Description:
* This routine handles the horizontal layout for the column widget
* Input:
* cw : XmColumnWidget - the column to layout
* child : Widget - A childs whose geometry is specified
* child_size : XtWidgetGeometry* - the specified child geometry
* col_width : int - a specified width for the column
* col_height : int - a specified height for the column
* Output:
* None.
*/
static void
HorizontalLayout(XmColumnWidget cw, Widget child,
XtWidgetGeometry *child_size, int col_width, int col_height)
{
/* Do the Horizontal Layout, Baby! */
WidgetList kids = cw->composite.children, kid;
Widget label;
Cardinal i, kidCnt = cw->composite.num_children;
Position x, y;
int cWidth, cBorder, cbWidth, lWidth, valid, space;
Dimension fillHeight;
int ispace = (int)XmColumn_item_spacing(cw);
int kidSpace;
if( col_width < 0 ) col_width = XtWidth(cw);
if( col_height < 0 ) col_height = XtHeight(cw);
fillHeight = col_height - 2 * (cw->manager.shadow_thickness +
BBPart(cw)->margin_height);
for( i = 0, kid = kids, lWidth = 0, cbWidth = 0, valid = 0,
space = 0, kidSpace = 0; i < kidCnt; ++i, ++kid )
{
XiC(*kid)->position.x = XiC(*kid)->position.y = 0;
if( *kid == child )
{
XiC(*kid)->position.width = child_size->width;
XiC(*kid)->position.height = child_size->height;
}
else
{
XiC(*kid)->position.width = XiC(*kid)->request_width;
XiC(*kid)->position.height = XiC(*kid)->request_height;
}
if( !XiValidChild(*kid) ) continue;
valid++;
if( *kid == child )
cbWidth += child_size->width + 2*child_size->border_width;
else
cbWidth += XiC(*kid)->request_width + 2*XtBorderWidth(*kid);
if( !XiC(*kid)->show_label ) continue;
space += XmColumn_label_spacing(cw);
kidSpace++;
label = XiC(*kid)->label_widget;
if( label == child )
lWidth += child_size->width;
else
lWidth += XiC(label)->request_width;
}
x = cw->manager.shadow_thickness + BBPart(cw)->margin_width;
if( valid > 0 && (x + lWidth + space + cbWidth + ispace*(valid-1) + x > col_width ) )
{
/*
* First try to shrink labelSpacing, then itemSpacing, otherwise clip.
*/
int have = (col_width - 2 * x),
want = lWidth + space + ispace*(valid-1) + cbWidth,
diff = want - have;
if ( space - diff > 1)
{
space -= diff;
}
else
{
if (0 != space)
space = kidSpace;
want = lWidth + space + ispace*(valid-1) + cbWidth;
diff = want - have;
if (ispace*(valid-1) - diff > 1)
ispace = (ispace*(valid-1)-diff)/(valid-1);
else
{
if (0 != ispace)
ispace = 1;
}
}
}
if (0==kidSpace) kidSpace = 1;
space /= kidSpace;
/*
* Calculating the widths for the various kids is a one shot, so lets
* first walk through the kids and calculate all the width.
*/
for( kid = kids, i = 0; i < kidCnt; ++i, ++kid )
{
int mySpace;
if( !XiValidChild(*kid) ) continue;
label = XiC(*kid)->label_widget;
XiC(label)->position.width = XtWidth(label);
if( XiC(*kid)->show_label )
{
lWidth = XtWidth(label);
mySpace = space;
}
else
{
lWidth = 0;
mySpace = 0;
}
if (LayoutIsRtoLM(cw))
XiC(label)->position.x = col_width - x - lWidth;
else
XiC(label)->position.x = x;
/* First, let's calculate the kid's X-position */
if( *kid == child )
cWidth = XiC(*kid)->position.width = child_size->width;
else
cWidth = XiC(*kid)->position.width = XiC(*kid)->request_width;
if (LayoutIsRtoLM(cw))
XiC(*kid)->position.x = col_width - (x + lWidth + space) - cWidth;
else
XiC(*kid)->position.x = x + lWidth + space;
if( child == *kid )
cBorder = child_size->border_width;
else
cBorder = XtBorderWidth(*kid);
x += lWidth + mySpace + cWidth + ispace + 2*cBorder;
/* Now, let's calculate the kid's Y-position */
y = cw->manager.shadow_thickness + BBPart(cw)->margin_height;
XiC(label)->position.y += y;
XiC(*kid)->position.y += y;
/* If XmNfillStyle == XmFILL_FLUSH, adjust height to same as column */
if (XiFill(*kid) == XmFILL_FLUSH)
{
XiC(label)->position.height = fillHeight;
XiC(*kid)->position.height = fillHeight;
}
}
if( child == NULL )
{
for( i = 0, kid = kids; i < kidCnt; ++i, ++kid )
{
if( !XiValidChild(*kid) ) continue;
label = XiC(*kid)->label_widget;
if( XiC(*kid)->show_label ) {
XtConfigureWidget(label, XiC(label)->position.x,
XiC(label)->position.y,
XiC(label)->position.width,
XiC(*kid)->position.height, 0);
}
XtConfigureWidget(*kid, XiC(*kid)->position.x,
XiC(*kid)->position.y,
XiC(*kid)->position.width,
XiC(*kid)->position.height,
XtBorderWidth(*kid));
}
}
}
/*
* Function:
* VerticalLayout(cw, child, child_size, col_witdh, col_height)
* Description:
* This routine handles the vertical layout for the column widget
* Input:
* cw : XmColumnWidget - the column to layout
* child : Widget - A childs whose geometry is specified
* child_size : XtWidgetGeometry* - the specified child geometry
* col_width : int - a specified width for the column
* col_height : int - a specified height for the column
* Output:
* None.
*/
static void
VerticalLayout(XmColumnWidget cw, Widget child, XtWidgetGeometry *child_size,
int col_width, int col_height)
{
WidgetList kids = cw->composite.children, kid;
Widget label;
Cardinal i, kidCnt = cw->composite.num_children, j;
Position x, y;
int cWidth, cMaxWidth, cMinWidth, cHeight, cBorder, cbWidth, cbHeight,
lWidth, lHeight, cnt, hExtra, hEach =0 , hLeft = 0, valid, space;
Dimension width, height;
Boolean change, stretch;
if( col_width < 0 ) col_width = XtWidth(cw);
if( col_height < 0 ) col_height = XtHeight(cw);
CalcSize(cw, NULL, NULL, False, &width, &height);
for( i = 0, kid = kids, lWidth = 0, cMinWidth = 0, cMaxWidth = 0, cnt = 0, valid = 0,
space = 0; i < kidCnt; ++i, ++kid )
{
XiC(*kid)->position.x = XiC(*kid)->position.y = 0;
if( *kid == child )
{
XiC(*kid)->position.width = child_size->width;
XiC(*kid)->position.height = child_size->height;
}
else
{
XiC(*kid)->position.width = XiC(*kid)->request_width;
XiC(*kid)->position.height = XiC(*kid)->request_height;
}
if( !XiValidChild(*kid) ) continue;
valid++;
if( *kid == child )
{
cbWidth = child_size->width + 2*child_size->border_width;
}
else
{
cbWidth = XiC(*kid)->request_width + 2*XtBorderWidth(*kid);
}
if( cMinWidth == 0 )
{
cMinWidth = cbWidth;
}
else if( cbWidth < cMinWidth )
{
cMinWidth = cbWidth;
}
if( cMaxWidth == 0 )
{
cMaxWidth = cbWidth;
}
else if( cbWidth > cMaxWidth )
{
cMaxWidth = cbWidth;
}
if( XiC(*kid)->stretchable ) ++cnt;
if( !XiC(*kid)->show_label ) continue;
space = XmColumn_label_spacing(cw);
label = XiC(*kid)->label_widget;
if( child == label )
{
if( (int)child_size->width > lWidth )
{
lWidth = child_size->width;
}
}
else
{
if( (int)XiC(label)->request_width > lWidth )
{
lWidth = XiC(label)->request_width;
}
}
}
x = cw->manager.shadow_thickness + BBPart(cw)->margin_width;
if( valid > 0 && (x + lWidth + space + cMaxWidth + x > col_width ) )
{
int have = (col_width - 2 * x),
want = lWidth + space + cMaxWidth,
diff = want - have;
/* Try to subtract from the label space first; if we can't do it (it
** may be 0 right now),
** then the data fields will shrink until they are the size of the
** smallest field, and after that the labels will shrink.
** The shadow and margin aren't affected.
*/
if ( space - diff > 1)
space -= diff;
else
{
if (0 != space)
space = 1;
want = lWidth + space + cMinWidth;
diff = want - have;
if (diff > 0)
{
if( lWidth - diff > 1 )
lWidth -= diff;
else
lWidth = 1;
}
}
}
/*
* Calculating the widths for the various kids is a one shot, so lets
* first walk through the kids and calculate all the width.
*/
for( kid = kids, i = 0; i < kidCnt; ++i, ++kid )
{
if( !XiValidChild(*kid) ) continue;
label = XiC(*kid)->label_widget;
cBorder = XtBorderWidth(*kid);
if (LayoutIsRtoLM(cw))
XiC(label)->position.x = col_width - x - lWidth;
else
XiC(label)->position.x = x;
XiC(label)->position.width = lWidth;
/* cbWidth is whatever is left over */
cbWidth = col_width -
((int)cw->manager.shadow_thickness +
(int)BBPart(cw)->margin_width +
x + lWidth + space);
if( cbWidth < 1 ) cbWidth = 1;
cWidth = cbWidth - 2*cBorder;
if( cWidth < 1 ) cWidth = 1;
/* cWidth is now the value to use for XmFILL_FLUSH */
if( XiFill(*kid) == XmFILL_RAGGED )
{
if( child == *kid )
{
if( (int) child_size->width < cWidth )
{
cWidth = child_size->width;
}
}
else
{
if( (int) XiC(*kid)->request_width < cWidth )
{
cWidth = XiC(*kid)->request_width;
}
}
}
if (LayoutIsRtoLM(cw))
XiC(*kid)->position.x = col_width - (x + lWidth + space + cWidth);
else
XiC(*kid)->position.x = x + lWidth + space;
XiC(*kid)->position.width = cWidth;
}
/*
* Now that we have calculated the x position and the width of
* each of the children lets now try to calculate the y position
* and the height.
*/
space = XmColumn_item_spacing(cw);
hExtra = col_height - height;
/* but first make a quick check on reducing the itemSpacing */
if (hExtra < 0)
{
if (valid)
{
int totalItemSpacing = (valid - 1) * space;
if (totalItemSpacing + hExtra > 0)
space = (totalItemSpacing + hExtra)/(valid-1);
else
space = 1;
}
hExtra = 0; /* or very close to it */
}
for( j = 0; j < 2; ++j )
{
do {
y = cw->manager.shadow_thickness +
BBPart(cw)->margin_height;
if( j != 0 )
{
cnt = valid;
}
if( cnt > 0 )
{
hEach = hExtra / cnt;
hLeft = hExtra % cnt;
}
else if( cnt == 0 )
{
hEach = 0;
hLeft = hExtra;
}
change = False;
for( kid = kids, i = 0; i < kidCnt; ++i, ++kid )
{
if( !XiValidChild(*kid) ) continue;
label = XiC(*kid)->label_widget;
cHeight = XiC(*kid)->position.height;
if( j == 0 || hExtra > 0 )
{
stretch = XiC(*kid)->stretchable;
}
else
{
stretch = True;
}
if( stretch )
{
if( hExtra < 0 && cHeight > 1 )
{
if( hEach != 0 )
{
int tmp = -hEach;
change = True;
if( tmp < cHeight )
{
hExtra += tmp;
cHeight -= tmp;
}
else
{
tmp = cHeight - 1;
hExtra += tmp;
cHeight = 1;
}
}
if( hLeft != 0 && cHeight > 1 )
{
change = True;
hLeft++;
hExtra++;
cHeight--;
}
}
else if( hExtra > 0 )
{
change = True;
cHeight += hEach;
hExtra -= hEach;
if( hLeft > 0 )
{
cHeight++;
hLeft--;
hExtra--;
}
}
}
if( cHeight < 1 ) cHeight = 1;
if( child == *kid )
{
cBorder = child_size->border_width;
}
else
{
cBorder = XtBorderWidth(*kid);
}
if( XiC(*kid)->show_label )
{
if( child == label )
{
lHeight = child_size->height;
}
else
{
lHeight = XiC(label)->request_height;
}
}
else
{
lHeight = 1;
}
cbHeight = cHeight + 2 * cBorder;
if( cbHeight > lHeight || stretch )
{
lHeight = cbHeight;
}
else
{
cHeight = lHeight - 2*cBorder;
if( cHeight < 1 ) cHeight = 1;
cbHeight = cHeight + 2*cBorder;
}
XiC(label)->position.y = y;
XiC(label)->position.height = lHeight;
XiC(*kid)->position.y = y;
XiC(*kid)->position.height = cHeight;
if( child == *kid )
{
cBorder = child_size->border_width;
}
else
{
cBorder = XtBorderWidth(*kid);
}
y += XiC(*kid)->position.height + (2 * cBorder) + space;
}
} while( hExtra != 0 && change );
}
/*
* If we get here and we still have some extra space we want to see
* if the user wants to distribute the space between children or
* not.
*/
if( XmColumn_distribution(cw) == XmDISTRIBUTE_SPREAD &&
hExtra > 0 )
{
if( valid == 1 )
{
hEach = hExtra / 2;
XiC(*kids)->position.y += hEach;
}
else
{
if( valid > 1 )
{
valid--;
hEach = hExtra / valid;
hLeft = hExtra % valid;
}
else
{
hEach = 0;
hLeft = hExtra;
}
y = cw->manager.shadow_thickness +
BBPart(cw)->margin_height;
for( i = 0, kid = kids; i < kidCnt; ++i, ++kid )
{
if( !XiValidChild(*kid) ) continue;
if( i > 0 )
{
XiC(*kid)->position.y = y;
XiC(XiC(*kid)->label_widget)->position.y = y;
}
space = XmColumn_item_spacing(cw) + hEach;
if( hLeft > 0 ) {
space++;
hLeft--;
}
if( child == *kid )
{
cBorder = child_size->border_width;
}
else
{
cBorder = XtBorderWidth(*kid);
}
y += XiC(*kid)->position.height + (2 * cBorder) +
space;
}
}
}
if( child == NULL )
{
for( i = 0, kid = kids; i < kidCnt; ++i, ++kid )
{
if( !XiValidChild(*kid) ) continue;
label = XiC(*kid)->label_widget;
if( XiC(*kid)->show_label )
{
XtConfigureWidget(label, XiC(label)->position.x,
XiC(label)->position.y,
XiC(label)->position.width,
XiC(*kid)->position.height, 0);
}
XtConfigureWidget(*kid, XiC(*kid)->position.x,
XiC(*kid)->position.y,
XiC(*kid)->position.width,
XiC(*kid)->position.height,
XtBorderWidth(*kid));
}
}
}
/*
* Function:
* VerifyConstraint(request, current, set)
* Description:
* This function verifies the values for the Column child's constraint
* resources in "set" resetting them to the previous or default
* values if an invalid resource value was set.
* Input:
* request : Widget - the requested setting for the widget
* current : Widget - the current setting for the widget
* set : Widget - the setting for the widget
* Output:
* None.
*/
/* ARGSUSED */
static void
VerifyConstraints(Widget request, Widget current, Widget set)
{
Boolean reset;
#if 0 /* POSITION HANDLING */
reset = False;
switch( XiC(set)->label_position )
{
case XiLABEL_POSITION_CENTER:
case XiLABEL_POSITION_LEFT:
case XiLABEL_POSITION_RIGHT:
case XiLABEL_POSITION_TOP:
case XiLABEL_POSITION_BOTTOM:
case XiLABEL_POSITION_UNSPECIFIED:
break;
default:
XmeWarning(set,
"An illegal resource value was assigned to the resource XmNentryLabelPosition");
reset = True;
break;
}
if( reset )
{
XiC(set)->label_position = (current != NULL
? XiC(current)->label_position
: XiLABEL_POSITION_UNSPECIFIED);
}
#endif
reset = False;
switch( XiC(set)->label_alignment )
{
case XmALIGNMENT_BEGINNING:
case XmALIGNMENT_CENTER:
case XmALIGNMENT_END:
case XmALIGNMENT_UNSPECIFIED:
break;
default:
XmeWarning(set,
"An illegal resource value was assigned to the resource XmNentryLabelAlignment");
reset = True;
break;
}
if( reset )
{
XiC(set)->label_alignment = (current != NULL
? XiC(current)->label_alignment
: XmALIGNMENT_UNSPECIFIED);
}
reset = False;
switch( XiC(set)->fill_style )
{
case XmFILL_UNSPECIFIED:
case XmFILL_FLUSH:
case XmFILL_RAGGED:
break;
default:
XmeWarning(set,
"An illegal resource value was assigned to the resource XmNfillStyle");
reset = True;
break;
}
if( reset )
{
XiC(set)->fill_style = (current != NULL
? XiC(current)->fill_style
: XmFILL_UNSPECIFIED);
}
}
/*
* Function:
* CalcSize(cw, child, child_size, query, width, height)
* Description:
* This function calculates and returns the prefered size for the
* column.
* Input:
* cw : XmColumnWidget - the column widget
* child : Widget - a widget whose geometry is specified
* child_size : XtWidgetGeometry* - the specified child's geometry
* query : Boolean - query the kids?
* width : Dimension* - return the desired width
* height : Dimension* - return the desired height
* Output:
* None.
*/
static void
CalcSize(XmColumnWidget cw, Widget child, XtWidgetGeometry *child_size,
Boolean query, Dimension *width, Dimension *height)
{
int _width = 0, _height = 0, cnt = 0;
Cardinal i, kidCnt = cw->composite.num_children;
WidgetList kid, kids = cw->composite.children;
Widget label;
Dimension cWidth, cHeight, cBorder, cSum = 0, lWidth, lHeight;
Dimension lSum = 0, space = 0, hSumSpace = 0;
XtWidgetGeometry wants;
for (i = 0, kid = kids; i < kidCnt; ++i, ++kid)
{
if (!XiValidChild(*kid)) continue;
if (XiC(*kid)->show_label)
{
space = XmColumn_label_spacing(cw);
hSumSpace += XmColumn_label_spacing(cw);
}
/*
* Check for the child widgets preferred geometry.
* if the prefered geometry is greater than the requested
* geometry, then set the query geometry to "True".
* Doing this, column widget will take care of improper
* size settings on the compound children widgets (CR03821)
*/
query = False;
XtQueryGeometry(*kid, NULL, &wants);
if (wants.width > XiC(*kid)->request_width || \
wants.height > XiC(*kid)->request_height)
{
query = True;
}
if (*kid == child && child_size != NULL)
{
cWidth = child_size->width;
cHeight = child_size->height;
cBorder = child_size->border_width;
} else if (query)
{
XtQueryGeometry(*kid, NULL, &wants);
if (wants.request_mode & CWWidth)
{
cWidth = wants.width;
XiC(*kid)->request_width = wants.width;
}
else
{
cWidth = XiC(*kid)->request_width;
}
if (wants.request_mode & CWHeight)
{
cHeight = wants.height;
XiC(*kid)->request_height = wants.height;
}
else
{
cHeight = XiC(*kid)->request_height;
}
if (wants.request_mode & CWBorderWidth)
{
cBorder = wants.border_width;
}
else
{
cBorder = XtBorderWidth(*kid);
}
}
else
{
cWidth = XiC(*kid)->request_width;
cHeight = XiC(*kid)->request_height;
cBorder = XtBorderWidth(*kid);
}
cWidth += (2 * cBorder);
cHeight += (2 * cBorder);
if (XtIsManaged((label = XiC(*kid)->label_widget)))
{
if (label == child && child_size != NULL)
{
lWidth = child_size->width;
lHeight = child_size->height;
}
else if (query)
{
XtQueryGeometry(label, NULL, &wants);
if (wants.request_mode & CWWidth)
{
lWidth = wants.width;
}
else
{
lWidth = XiC(label)->request_width;
}
if (wants.request_mode & CWHeight)
{
lHeight = wants.height;
}
else
{
lHeight = XiC(label)->request_height;
}
}
else
{
lWidth = XiC(label)->request_width;
lHeight = XiC(label)->request_height;
}
}
else
{
lWidth = lHeight = 0;
}
if (XmColumn_orientation(cw) == XmVERTICAL)
{
if (lWidth > lSum) lSum = lWidth;
if (cWidth > cSum) cSum = cWidth;
_height += (lHeight > cHeight ? lHeight : cHeight);
}
else /* XmHORIZONTAL Layout */
{
/* Choose the maximum height */
if (_height < (int)cHeight) _height = cHeight;
if (_height < (int)lHeight) _height = lHeight;
_width += lWidth + cWidth;
}
cnt++;
}
if (cnt > 1) --cnt;
if (XmColumn_orientation(cw) == XmVERTICAL)
{
_width = lSum + cSum + space +
2 * (cw->manager.shadow_thickness +
BBPart(cw)->margin_width);
_height += (cnt * XmColumn_item_spacing(cw) +
2 * (cw->manager.shadow_thickness +
BBPart(cw)->margin_height));
}
else /* XmHORIZONTAL Layout */
{
_width += (hSumSpace +
2 * (cw->manager.shadow_thickness +
BBPart(cw)->margin_width)) + cnt*XmColumn_item_spacing(cw);
_height += 2 * (cw->manager.shadow_thickness +
BBPart(cw)->margin_height);
}
if (_width < 1) _width = 1;
if (_height < 1) _height = 1;
if (width != NULL) *width = _width;
if (height != NULL) *height = _height;
}
/*
* Function:
* CompareGeometry(geom1, geom2)
* Description:
* This function compares to XtWidgetGeometry structure to see if
* the are equal.
* Input:
* geom1 : XtWidgetGeometry* - a geometry spec
* geom2 : XtWidgetGeometry* - another geometry spec
* Output:
* Boolean - True if the geometry structures are equal, else False
*/
static Boolean
CompareGeometry(XtWidgetGeometry *geom1, XtWidgetGeometry *geom2)
{
Boolean result;
result = (geom1 == NULL || geom2 == NULL) ||
(geom1->request_mode != geom2->request_mode) ||
(geom1->request_mode & CWX && geom1->x != geom2->x) ||
(geom1->request_mode & CWY && geom1->y != geom2->y) ||
(geom1->request_mode & CWWidth && geom1->width != geom2->width) ||
(geom1->request_mode & CWHeight && geom1->height != geom2->height) ||
(geom1->request_mode & CWBorderWidth &&
geom1->border_width != geom2->border_width);
return( !result );
}
/*
* Function:
* CompareGeometryToWidget(geom, widget)
* Description:
* Compares a geometry spec to a widget's actual geometry.
* Input:
* geom : XtWidgetGeometry* - the geometry
* widget : Widget - the widget
* Output:
* Boolean - True if the widget equals the geom spec, else False.
*/
static Boolean
CompareGeometryToWidget(XtWidgetGeometry *geom, Widget widget)
{
Boolean result;
result = (geom == NULL || widget == NULL) ||
(geom->request_mode == 0) ||
(geom->request_mode & CWX && geom->x != XtX(widget)) ||
(geom->request_mode & CWY && geom->y != XtY(widget)) ||
(geom->request_mode & CWWidth && geom->width != XtWidth(widget)) ||
(geom->request_mode & CWHeight &&
geom->height != XtHeight(widget)) ||
(geom->request_mode & CWBorderWidth &&
geom->border_width != XtBorderWidth(widget));
return( !result );
}
/*
* XmRCallProc routine for checking label_font_list before setting it to NULL
* If constrainit's "check_set_render_table" is True, then function has
* been called twice on same widget, thus resource needs to be set NULL,
* otherwise leave it alone.
*/
/*ARGSUSED*/
static void
CheckSetEntryLabelRenderTable(Widget wid, int offs, XrmValue *value)
{
XmColumnConstraintPart* cc = XiC(wid);
/* Check if been here before */
if (cc->check_set_render_table)
value->addr = NULL;
else {
cc->check_set_render_table = True;
value->addr = (char*)&(cc->label_font_list);
}
}
/*
* XmRCallProc routine for checking label_font_list before setting it to NULL
* If column's "check_set_render_table" is True, then function has
* been called twice on same widget, thus resource needs to be set NULL,
* otherwise leave it alone.
*/
/*ARGSUSED*/
static void
CheckSetDefaultEntryLabelRenderTable(Widget wid, int offs, XrmValue *value)
{
XmBulletinBoardPart* bb = BBPart(wid);
XmColumnWidget c = (XmColumnWidget)wid;
/* Check if been here before */
if (c->column.check_set_render_table)
value->addr = NULL;
else {
c->column.check_set_render_table = True;
value->addr = (char*)&(bb->label_font_list);
}
}
/*
* Function:
* XmColumnLabelDestroyedCallback(widget, client, cbdata)
* Description:
* This callback is called when a label that is associated with a field
* is destoyed. The purpose of this callback is to inform the column
* when this happens to it does not try to do bad things.
* Input:
* widget : Widget - the widget being destroyed
* client : XtPointer - the widget that this label is associated with
* cbdata : XtPointer - unused.
* Output:
* None.
*/
/* ARGSUSED */
static void
XmColumnLabelDestroyedCallback(Widget widget, XtPointer client,
XtPointer cbdata)
{
Widget field = (Widget) client;
XiC(field)->label_widget = NULL;
}
/* ARGSUSED */
static void Get_entryLabelString (Widget widget, int offset, XtArgVal *value)
{
(*value) = (XtArgVal) XmStringCopy(XiC(widget)->label_string);
}
/*
* Function:
* XmCreateColumn(parent, name, arg_list, arg_cnt);
* Description:
* Creates an unmanaged instance of an XmColumn and returns its
* widget id.
* Input:
* parent : Widget - the parent of the new instance.
* name : String - the name of the new instance.
* arg_list : ArgList - the arguments to create the instance with.
* arg_cnt : Cardinal - the number of arguments in the list
*
* Output:
* Widget - the widget id of the new instance.
*/
Widget
XmCreateColumn(Widget parent, String name, ArgList arg_list, Cardinal arg_cnt)
{
return( XtCreateWidget(name, xmColumnWidgetClass, parent, arg_list,
arg_cnt) );
}
Widget
XmVaCreateColumn(
Widget parent,
char *name,
...)
{
register Widget w;
va_list var;
int count;
Va_start(var,name);
count = XmeCountVaListSimple(var);
va_end(var);
Va_start(var, name);
w = XmeVLCreateWidget(name,
xmColumnWidgetClass,
parent, False,
var, count);
va_end(var);
return w;
}
Widget
XmVaCreateManagedColumn(
Widget parent,
char *name,
...)
{
Widget w = NULL;
va_list var;
int count;
Va_start(var, name);
count = XmeCountVaListSimple(var);
va_end(var);
Va_start(var, name);
w = XmeVLCreateWidget(name,
xmColumnWidgetClass,
parent, True,
var, count);
va_end(var);
return w;
}
|