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
|
{-# LANGUAGE CPP #-}
-- -*-haskell-*-
-- GIMP Toolkit (GTK) Widget Widget
--
-- Author : Axel Simon
--
-- Created: 27 April 2001
--
-- Copyright (C) 2001-2008 Axel Simon
--
-- This library is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public
-- License as published by the Free Software Foundation; either
-- version 2.1 of the License, or (at your option) any later version.
--
-- This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- Lesser General Public License for more details.
--
--
-- |
-- Maintainer : gtk2hs-users@lists.sourceforge.net
-- Stability : provisional
-- Portability : portable (depends on GHC)
--
-- The base class for all widgets.
--
module Graphics.UI.Gtk.Abstract.Widget (
-- * Detail
--
-- | The base class for all widgets. While a widget cannot be created directly,
-- this module contains many useful methods common to all widgets. In
-- particular, these functions are needed to add functionality to
-- blank widgets such as 'DrawingArea' or 'Layout'.
--
-- 'Widget' introduces style properties - these are basically object
-- properties that are stored not on the object, but in the style object
-- associated to the widget. Style properties are set in resource files. This
-- mechanism is used for configuring such things as the location of the
-- scrollbar arrows through the theme, giving theme authors more control over
-- the look of applications without the need to write a theme engine in C.
--
-- Widgets receive events, that is, signals that indicate some low-level
-- user iteraction. The signal handlers for all these events have to
-- return @True@ if the signal has been dealt with and @False@ if other
-- signal handlers should be run.
-- * Class Hierarchy
--
-- |
-- @
-- | 'GObject'
-- | +----'Object'
-- | +----Widget
-- | +----/too many to list/
-- @
-- * Types
Widget,
WidgetClass,
castToWidget, gTypeWidget,
toWidget,
EventMask(..),
#if GTK_MAJOR_VERSION < 3
ExtensionMode(..),
#endif
GType,
KeyVal,
#if GTK_MAJOR_VERSION < 3
Region,
Bitmap,
#endif
Requisition(..),
Rectangle(..),
Color,
IconSize(..),
StateType(..),
TextDirection(..),
AccelFlags(..),
DirectionType(..),
StockId,
WidgetHelpType(..),
Allocation,
-- * Methods
widgetShow,
widgetShowNow,
widgetHide,
widgetShowAll,
#if GTK_MAJOR_VERSION < 3
widgetHideAll,
#endif
widgetDestroy,
#if GTK_CHECK_VERSION(3,0,0)
widgetDraw,
#endif
widgetQueueDraw,
widgetQueueResize,
#if GTK_CHECK_VERSION(2,4,0)
widgetQueueResizeNoRedraw,
#endif
#if GTK_CHECK_VERSION(3,8,0)
widgetGetFrameClock,
#endif
#if GTK_CHECK_VERSION(3,10,0)
widgetGetScaleFactor,
#endif
widgetSizeRequest,
widgetGetChildRequisition,
widgetSizeAllocate,
#if GTK_CHECK_VERSION(3,10,0)
widgetSizeAllocateWithBaseline,
#endif
widgetAddAccelerator,
widgetRemoveAccelerator,
widgetSetAccelPath,
#if GTK_CHECK_VERSION(2,4,0)
widgetCanActivateAccel,
#endif
widgetActivate,
widgetIntersect,
widgetHasIntersection,
widgetGetIsFocus,
widgetGrabFocus,
widgetGrabDefault,
widgetSetName,
widgetGetName,
widgetSetSensitive,
widgetSetSensitivity,
widgetGetParentWindow,
#if GTK_MAJOR_VERSION < 3
widgetGetDrawWindow,
#endif
widgetDelEvents,
widgetAddEvents,
widgetGetEvents,
widgetSetEvents,
#if GTK_MAJOR_VERSION < 3
widgetSetExtensionEvents,
widgetGetExtensionEvents,
#endif
widgetGetToplevel,
widgetGetAncestor,
#if GTK_MAJOR_VERSION < 3
widgetGetColormap,
widgetSetColormap,
#endif
widgetGetPointer,
widgetIsAncestor,
widgetTranslateCoordinates,
widgetSetStyle,
widgetGetStyle,
#if GTK_MAJOR_VERSION < 3
widgetPushColormap,
widgetPopColormap,
widgetSetDefaultColormap,
widgetGetDefaultColormap,
#endif
widgetGetDefaultStyle,
widgetSetDirection,
widgetGetDirection,
widgetSetDefaultDirection,
widgetGetDefaultDirection,
#if GTK_MAJOR_VERSION < 3
widgetShapeCombineMask,
#if GTK_CHECK_VERSION(2,10,0)
widgetInputShapeCombineMask,
#endif
#endif
#if GTK_CHECK_VERSION(3,0,0)
widgetShapeCombineRegion,
widgetInputShapeCombineRegion,
#endif
#if GTK_MAJOR_VERSION < 3
#if GTK_CHECK_VERSION(2,14,0)
widgetGetSnapshot,
#endif
#endif
widgetPath,
widgetClassPath,
widgetGetCompositeName,
#if GTK_CHECK_VERSION(3,0,0)
widgetOverrideBackgroundColor,
widgetOverrideColor,
widgetOverrideFont,
widgetOverrideSymbolicColor,
widgetOverrideCursor,
#endif
widgetModifyStyle,
widgetGetModifierStyle,
widgetModifyFg,
widgetModifyBg,
widgetModifyText,
widgetModifyBase,
widgetModifyFont,
widgetRestoreFg,
widgetRestoreBg,
widgetRestoreText,
widgetRestoreBase,
widgetCreatePangoContext,
widgetGetPangoContext,
widgetCreateLayout,
widgetRenderIcon,
widgetQueueDrawArea,
#if GTK_CHECK_VERSION(3,0,0)
widgetQueueDrawRegion,
#endif
#if GTK_MAJOR_VERSION < 3
widgetResetShapes,
#endif
widgetSetAppPaintable,
widgetSetDoubleBuffered,
widgetSetRedrawOnAllocate,
widgetSetCompositeName,
widgetMnemonicActivate,
#if GTK_MAJOR_VERSION < 3
widgetSetScrollAdjustments,
widgetRegionIntersect,
#endif
widgetGetAccessible,
widgetChildFocus,
widgetGetChildVisible,
widgetGetParent,
widgetGetSettings,
#if GTK_CHECK_VERSION(2,2,0)
widgetGetClipboard,
widgetGetDisplay,
widgetGetRootWindow,
widgetGetScreen,
widgetHasScreen,
#endif
widgetGetSizeRequest,
#if GTK_CHECK_VERSION(3,0,0)
widgetGetPreferredSize,
#endif
widgetSetChildVisible,
widgetSetSizeRequest,
#if GTK_CHECK_VERSION(2,4,0)
widgetSetNoShowAll,
widgetGetNoShowAll,
widgetListMnemonicLabels,
widgetAddMnemonicLabel,
widgetRemoveMnemonicLabel,
#if GTK_CHECK_VERSION(2,10,0)
#if GTK_MAJOR_VERSION < 3
widgetGetAction,
#endif
widgetIsComposited,
#endif
#endif
#if GTK_CHECK_VERSION(2,12,0)
widgetErrorBell,
widgetKeynavFailed,
widgetGetTooltipMarkup,
widgetSetTooltipMarkup,
widgetGetTooltipText,
widgetSetTooltipText,
widgetGetTooltipWindow,
widgetSetTooltipWindow,
widgetGetHasTooltip,
widgetSetHasTooltip,
widgetTriggerTooltipQuery,
#endif
#if GTK_CHECK_VERSION(2,14,0)
widgetGetWindow,
#endif
#if GTK_CHECK_VERSION(3,8,0)
widgetRegisterWindow,
widgetUnregisterWindow,
#endif
#if GTK_CHECK_VERSION(3,0,0)
cairoShouldDrawWindow,
cairoTransformToWindow,
#endif
widgetReparent,
#if GTK_CHECK_VERSION(2,18,0)
widgetGetCanFocus,
widgetSetCanFocus,
widgetGetAllocation,
#endif
#if GTK_CHECK_VERSION(3,0,0)
widgetGetAllocatedWidth,
widgetGetAllocatedHeight,
#endif
#if GTK_CHECK_VERSION(3,10,0)
widgetGetAllocatedBaseline,
#endif
#if GTK_CHECK_VERSION(3,14,0)
widgetGetClip,
widgetSetClip,
#endif
#if GTK_CHECK_VERSION(2,18,0)
widgetGetAppPaintable,
widgetGetCanDefault,
widgetSetCanDefault,
widgetGetHasWindow,
widgetSetHasWindow,
widgetGetSensitive,
widgetIsSensitive,
widgetGetState,
widgetGetVisible,
#endif
#if GTK_CHECK_VERSION(3,8,0)
widgetIsVisible,
#endif
#if GTK_CHECK_VERSION(3,0,0)
widgetSetStateFlags,
widgetUnsetStateFlags,
widgetGetStateFlags,
#endif
#if GTK_CHECK_VERSION(2,18,0)
widgetGetHasDefault,
widgetGetHasFocus,
#endif
#if GTK_CHECK_VERSION(3,2,0)
widgetHasVisibleFocus,
#endif
#if GTK_CHECK_VERSION(2,18,0)
widgetHasGrab,
widgetIsDrawable,
widgetIsToplevel,
widgetSetWindow,
widgetSetReceivesDefault,
widgetGetReceivesDefault,
#endif
#if GTK_CHECK_VERSION(3,0,0)
widgetDeviceIsShadowed,
#endif
#if GTK_CHECK_VERSION(3,4,0)
widgetGetModifierMask,
#endif
#if GTK_CHECK_VERSION(3,0,0)
widgetSetSupportMultidevice,
widgetGetSupportMultidevice,
#endif
widgetSetState,
#if GTK_MAJOR_VERSION < 3
widgetGetSavedState,
widgetGetSize,
#endif
widgetEvent,
#if GTK_CHECK_VERSION(3,0,0)
widgetGetHAlign,
widgetSetHAlign,
widgetGetVAlign,
#if GTK_CHECK_VERSION(3,10,0)
widgetGetVAlignWithBaseline,
#endif
widgetSetVAlign,
#endif
-- * Attributes
widgetName,
widgetParent,
widgetWidthRequest,
widgetHeightRequest,
widgetMarginLeft,
widgetMarginRight,
#if GTK_CHECK_VERSION(3,12,0)
widgetMarginStart,
widgetMarginEnd,
#endif
widgetMarginTop,
widgetMarginBottom,
widgetVisible,
widgetOpacity,
widgetSensitive,
widgetAppPaintable,
widgetCanFocus,
widgetHasFocus,
widgetIsFocus,
widgetCanDefault,
widgetHasDefault,
widgetReceivesDefault,
widgetCompositeChild,
widgetStyle,
widgetState,
widgetEvents,
#if GTK_MAJOR_VERSION < 3
widgetExtensionEvents,
#endif
widgetExpand,
widgetHExpand,
widgetHExpandSet,
widgetVExpand,
widgetVExpandSet,
widgetNoShowAll,
widgetChildVisible,
#if GTK_MAJOR_VERSION < 3
widgetColormap,
#endif
widgetCompositeName,
widgetDirection,
widgetTooltipMarkup,
widgetTooltipText,
widgetHasTooltip,
#if GTK_CHECK_VERSION(2,20,0)
widgetHasRcStyle,
widgetGetRealized,
widgetGetMapped,
widgetSetRealized,
widgetSetMapped,
#endif
#if GTK_CHECK_VERSION(3,0,0)
widgetGetStyleContext,
#endif
-- * Signals
realize,
unrealize,
mapSignal,
unmapSignal,
sizeRequest,
sizeAllocate,
showSignal,
hideSignal,
focus,
stateChanged,
#if GTK_CHECK_VERSION(3,0,0)
stateFlagsChanged,
#endif
parentSet,
hierarchyChanged,
styleSet,
directionChanged,
grabNotify,
popupMenuSignal,
showHelp,
accelClosuresChanged,
screenChanged,
queryTooltip,
#if GTK_CHECK_VERSION(3,0,0)
draw,
#endif
-- * Events
buttonPressEvent,
buttonReleaseEvent,
configureEvent,
deleteEvent,
destroyEvent,
enterNotifyEvent,
exposeEvent,
focusInEvent,
focusOutEvent,
#if GTK_CHECK_VERSION(2,8,0)
grabBrokenEvent,
#endif
keyPressEvent,
keyReleaseEvent,
leaveNotifyEvent,
mapEvent,
motionNotifyEvent,
noExposeEvent,
proximityInEvent,
proximityOutEvent,
scrollEvent,
unmapEvent,
visibilityNotifyEvent,
windowStateEvent,
-- * Deprecated
#ifndef DISABLE_DEPRECATED
onButtonPress,
afterButtonPress,
onButtonRelease,
afterButtonRelease,
onClient,
afterClient,
onConfigure,
afterConfigure,
onDelete,
afterDelete,
onDestroyEvent, -- you probably want onDestroy
afterDestroyEvent,
onDirectionChanged,
afterDirectionChanged,
onEnterNotify,
afterEnterNotify,
onLeaveNotify,
afterLeaveNotify,
onExpose,
afterExpose,
onExposeRect,
afterExposeRect,
onFocus,
afterFocus,
onFocusIn,
afterFocusIn,
onFocusOut,
afterFocusOut,
onGrabFocus,
afterGrabFocus,
onDestroy,
afterDestroy,
onHide,
afterHide,
onHierarchyChanged,
afterHierarchyChanged,
onKeyPress,
afterKeyPress,
onKeyRelease,
afterKeyRelease,
onMnemonicActivate,
afterMnemonicActivate,
onMotionNotify,
afterMotionNotify,
onParentSet,
afterParentSet,
onPopupMenu,
afterPopupMenu,
onProximityIn,
afterProximityIn,
onProximityOut,
afterProximityOut,
onRealize,
afterRealize,
onScroll,
afterScroll,
onShow,
afterShow,
onSizeAllocate,
afterSizeAllocate,
onSizeRequest,
afterSizeRequest,
onStateChanged,
afterStateChanged,
onUnmap,
afterUnmap,
onUnrealize,
afterUnrealize,
onVisibilityNotify,
afterVisibilityNotify,
onWindowState,
afterWindowState
#endif
) where
import Control.Monad (liftM, unless)
import Data.Maybe (fromMaybe)
import Control.Monad.Reader (ask)
import Control.Monad.Trans (liftIO)
import System.Glib.FFI
import System.Glib.Flags (fromFlags, toFlags)
#if GTK_CHECK_VERSION(3,0,0)
import System.Glib.GError (failOnGError)
import System.Glib.Flags (Flags)
#endif
import System.Glib.UTFString
import System.Glib.Attributes
import System.Glib.Properties
import System.Glib.GType (GType)
import System.Glib.GList (fromGList)
import Graphics.UI.Gtk.Abstract.Object (makeNewObject)
import Graphics.UI.Gtk.General.DNDTypes (Atom (Atom), SelectionTag)
{#import Graphics.UI.Gtk.Types#}
{#import Graphics.UI.Gtk.Signals#}
import Graphics.UI.Gtk.Gdk.Enums (EventMask(..)
#if GTK_MAJOR_VERSION < 3
, ExtensionMode(..)
#endif
)
import Graphics.UI.Gtk.Gdk.Keys (KeyVal)
#if GTK_MAJOR_VERSION < 3
{#import Graphics.UI.Gtk.Gdk.Region#} (Region(..), makeNewRegion)
{#import Graphics.UI.Gtk.Gdk.Pixmap#} (Bitmap)
#endif
import Graphics.UI.Gtk.General.Structs (Allocation, Rectangle(..)
,Requisition(..), Color, IconSize(..)
,Point
#if !GTK_CHECK_VERSION(2,18,0)
,widgetGetState
#endif
#if GTK_MAJOR_VERSION < 3
,widgetGetSavedState
,widgetGetDrawWindow, widgetGetSize
#endif
)
#ifndef DISABLE_DEPRECATED
import Graphics.UI.Gtk.Gdk.Events (Event(..), marshalEvent, marshExposeRect)
#endif
import Graphics.UI.Gtk.Gdk.EventM (EventM,
EventM,
EAny,
EKey,
EButton,
EScroll,
EMotion,
EExpose,
EVisibility,
ECrossing,
EFocus,
EConfigure,
EProperty,
EProximity,
EWindowState,
#if GTK_CHECK_VERSION(2,8,0)
EGrabBroken,
#endif
)
import Graphics.UI.Gtk.General.Enums (StateType(..), TextDirection(..),
AccelFlags(..), DirectionType(..), Modifier
#if GTK_CHECK_VERSION(3,0,0)
,StateFlags(..), Align(..)
#endif
#if GTK_CHECK_VERSION(3,4,0)
,ModifierIntent(..)
#endif
)
{#import Graphics.Rendering.Pango.Types#}
{#import Graphics.Rendering.Pango.BasicTypes#} (FontDescription(FontDescription),
PangoLayout(PangoLayout), makeNewPangoString )
import Graphics.UI.Gtk.General.StockItems (StockId)
import Data.IORef ( newIORef )
import Control.Monad.Reader ( runReaderT )
#if GTK_CHECK_VERSION(3,0,0)
import Graphics.Rendering.Cairo.Types (Cairo(..), unCairo, Region(..), withRegion)
import Graphics.Rendering.Cairo.Internal (Render(..))
#endif
{# context lib="gtk" prefix="gtk" #}
--------------------
-- Methods
-- | Flags a widget to be displayed. Any widget that isn't shown will not
-- appear on the screen. If you want to show all the widgets in a container,
-- it's easier to call 'widgetShowAll' on the container, instead of
-- individually showing the widgets.
--
-- Remember that you have to show the containers containing a widget, in
-- addition to the widget itself, before it will appear onscreen.
--
-- When a toplevel container is shown, it is immediately realized and
-- mapped; other shown widgets are realized and mapped when their toplevel
-- container is realized and mapped.
--
widgetShow :: WidgetClass self => self -> IO ()
widgetShow self =
{# call widget_show #}
(toWidget self)
-- | Shows a widget. If the widget is an unmapped toplevel widget (i.e. a
-- 'Window' that has not yet been shown), enter the main loop and wait for the
-- window to actually be mapped. Be careful; because the main loop is running,
-- anything can happen during this function.
--
widgetShowNow :: WidgetClass self => self -> IO ()
widgetShowNow self =
{# call widget_show_now #}
(toWidget self)
-- | Reverses the effects of 'widgetShow', causing the widget to be hidden
-- (invisible to the user).
--
widgetHide :: WidgetClass self => self -> IO ()
widgetHide self =
{# call widget_hide #}
(toWidget self)
-- | Recursively shows a widget, and any child widgets (if the widget is a
-- container).
--
widgetShowAll :: WidgetClass self => self -> IO ()
widgetShowAll self =
{# call widget_show_all #}
(toWidget self)
#if GTK_MAJOR_VERSION < 3
-- | Recursively hides a widget and any child widgets.
--
-- Removed in Gtk3.
widgetHideAll :: WidgetClass self => self -> IO ()
widgetHideAll self =
{# call widget_hide_all #}
(toWidget self)
#endif
-- | Destroys a widget. Equivalent to
-- 'Graphics.UI.Gtk.Abstract.Object.objectDestroy'.
--
-- When a widget is destroyed it will be removed from the screen and
-- unrealized. When a widget is destroyed, it will break any references it
-- holds to other objects.If the widget is inside a container, the widget will
-- be removed from the container. The widget will be garbage collected
-- (finalized) time after your last reference to the widget dissapears.
--
-- In most cases, only toplevel widgets (windows) require explicit
-- destruction, because when you destroy a toplevel its children will be
-- destroyed as well.
--
widgetDestroy :: WidgetClass self => self -> IO ()
widgetDestroy self =
{# call widget_destroy #}
(toWidget self)
#if GTK_CHECK_VERSION(3,0,0)
-- | Draws widget to @cr@. The top left corner of the widget will be drawn
-- to the currently set origin point of @cr@.
--
-- You should pass a cairo context as cr argument that is in an original
-- state. Otherwise the resulting drawing is undefined. For example changing
-- the operator using 'Graphics.Rendering.Cairo.setOperator' or the line
-- width using 'Graphics.Rendering.Cairo.setLineWidth' might have unwanted
-- side effects. You may however change the context’s transform matrix - like
-- with 'Graphics.Rendering.Cairo.scale', 'Graphics.Rendering.Cairo.translate'
-- or 'Graphics.Rendering.Cairo.setMatrix' and clip region with
-- 'Graphics.Rendering.Cairo.clip' prior to calling this function. Also, it
-- is fine to modify the context with 'Graphics.Rendering.Cairo.save' and
-- 'Graphics.Rendering.Cairo.pushGroup' prior to calling this function.
--
-- Note that special-purpose widgets may contain special code for rendering
-- to the screen and might appear differently on screen and when rendered
-- using 'widgetDraw'.
--
widgetDraw :: WidgetClass self
=> self -- ^ the widget to draw. It must be drawable (see 'widgetIsDrawable')
-- and a size must have been allocated.
-> Cairo -- ^ a cairo context to draw to
-> IO ()
widgetDraw self cr =
{# call widget_draw #}
(toWidget self)
(castPtr $ unCairo cr)
#endif
-- * Functions to be used with 'Graphics.UI.Gtk.Misc.DrawingArea' or
-- container implementations.
-- | Send a redraw request to a widget. Equivalent to calling
-- 'widgetQueueDrawArea' for the entire area of a widget.
--
widgetQueueDraw :: WidgetClass self => self -> IO ()
widgetQueueDraw self =
{# call widget_queue_draw #}
(toWidget self)
-- | This function is only for use in widget implementations. Flags a widget
-- to have its size renegotiated; should be called when a widget for some
-- reason has a new size request. For example, when you change the text in a
-- 'Graphics.UI.Gtk.Display.Label.Label',
-- 'Graphics.UI.Gtk.Display.Label.Label' queues a resize to ensure there's
-- enough space for the new text.
--
widgetQueueResize :: WidgetClass self => self -> IO ()
widgetQueueResize self =
{# call widget_queue_resize #}
(toWidget self)
#if GTK_CHECK_VERSION(2,4,0)
-- | This function works like 'widgetQueueResize', except that the widget is
-- not invalidated.
--
-- * Available since Gtk+ version 2.4
--
widgetQueueResizeNoRedraw :: WidgetClass self => self -> IO ()
widgetQueueResizeNoRedraw self =
{# call widget_queue_resize_no_redraw #}
(toWidget self)
#endif
#if GTK_CHECK_VERSION(3,8,0)
-- | Obtains the frame clock for a widget. The frame clock is a global “ticker”
-- that can be used to drive animations and repaints. The most common reason to
-- get the frame clock is to call 'frameClockGetFrameTime', in order to get a
-- time to use for animating. For example you might record the start of the
-- animation with an initial value from 'frameClockGetFrameTime', and then
-- update the animation by calling 'frameClockGetFrameTime' again during each
-- repaint.
--
-- 'frameClockRequestPhase' will result in a new frame on the clock, but won’t
-- necessarily repaint any widgets. To repaint a widget, you have to use
-- 'widgetQueueDraw' which invalidates the widget (thus scheduling it to
-- receive a draw on the next frame). 'widgetQueueDraw' will also end up
-- requesting a frame on the appropriate frame clock.
--
-- A widget’s frame clock will not change while the widget is mapped.
-- Reparenting a widget (which implies a temporary unmap) can change the
-- widget’s frame clock.
--
-- Unrealized widgets do not have a frame clock.
--
widgetGetFrameClock :: WidgetClass self => self -> IO FrameClock
widgetGetFrameClock self =
makeNewGObject mkFrameClock $
{# call widget_get_frame_clock #}
(toWidget self)
#endif
#if GTK_CHECK_VERSION(3,10,0)
-- | Retrieves the internal scale factor that maps from window coordinates to
-- the actual device pixels. On traditional systems this is 1, on high density
-- outputs, it can be a higher value (typically 2).
--
-- See 'drawWindowGetScaleFactor'.
--
widgetGetScaleFactor :: WidgetClass self => self -> IO Int
widgetGetScaleFactor self =
liftM fromIntegral $
{# call widget_get_scale_factor #}
(toWidget self)
#endif
-- | This function is typically used when implementing a
-- 'Graphics.UI.Gtk.Abstract.Container.Container' subclass. Obtains the preferred size
-- of a widget. The container uses this information to arrange its child
-- widgets and decide what size allocations to give them with
-- 'widgetSizeAllocate'.
--
-- You can also call this function from an application, with some caveats.
-- Most notably, getting a size request requires the widget to be associated
-- with a screen, because font information may be needed. Multihead-aware
-- applications should keep this in mind.
--
-- Also remember that the size request is not necessarily the size a widget
-- will actually be allocated.
--
widgetSizeRequest :: WidgetClass self => self -> IO Requisition
widgetSizeRequest self = alloca $ \reqPtr -> do
{#call widget_size_request #} (toWidget self) (castPtr reqPtr)
peek reqPtr
-- | This function is only for use in widget implementations. Obtains the
-- chached requisition information in the widget, unless someone has forced a
-- particular geometry on the widget (e.g. with 'widgetSetSizeRequest'), in which
-- case it returns that geometry instead of the widget's requisition.
--
-- This function differs from 'widgetSizeRequest' in that it retrieves the
-- last size request value stored in the widget, while 'widgetSizeRequest'
-- actually emits the 'sizeRequest' signal on the widget to compute the size
-- request (which updates the widget's requisition information).
--
-- Since this function does not emit the 'sizeRequest' signal, it can only be
-- used when you know that the widget's requisition is up-to-date, that is,
-- 'widgetSizeRequest' has been called since the last time a resize was
-- queued. In general, only container implementations have this information;
-- applications should use 'widgetSizeRequest'.
--
widgetGetChildRequisition :: WidgetClass self => self -> IO Requisition
widgetGetChildRequisition self = alloca $ \reqPtr -> do
{#call widget_get_child_requisition #} (toWidget self) (castPtr reqPtr)
peek reqPtr
-- | This function is only used by
-- 'Graphics.UI.Gtk.Abstract.Container.Container' subclasses, to assign a
-- size and position to their child widgets.
--
widgetSizeAllocate :: WidgetClass self => self
-> Allocation -- ^ The @x@ and @y@ values of the rectangle determine the
-- the position of the widget's area relative to its parent
-- allocation.
-> IO ()
widgetSizeAllocate self rect = with rect $ \rectPtr ->
{#call widget_size_allocate#} (toWidget self) (castPtr rectPtr)
#if GTK_CHECK_VERSION(3,10,0)
-- | This function is only used by
-- 'Graphics.UI.Gtk.Abstract.Container.Container' subclasses, to assign a
-- size, position and (optionally) baseline to their child widgets.
--
-- In this function, the allocation and baseline may be adjusted. It will
-- be forced to a 1x1 minimum size, and the adjust_size_allocation virtual
-- and adjust_baseline_allocation methods on the child will be used to adjust
-- the allocation and baseline. Standard adjustments include removing the
-- widget's margins, and applying the widget’s 'widgetHAlign' and
-- 'widgetVAlign' properties.
--
-- If the child widget does not have a valign of AlignBaseline the baseline
-- argument is ignored and -1 is used instead.
--
widgetSizeAllocateWithBaseline :: WidgetClass self => self
-> Allocation -- ^ The @x@ and @y@ values of the rectangle determine the
-- the position of the widget's area relative to its parent
-- allocation.
-> Int -- ^ The baseline of the child, or -1
-> IO ()
widgetSizeAllocateWithBaseline self rect baseline = with rect $ \rectPtr ->
{#call widget_size_allocate_with_baseline#} (toWidget self) (castPtr rectPtr) (fromIntegral baseline)
#endif
-- %hash c:1e14 d:53c5
-- | Installs an accelerator for this @widget@ in @accelGroup@ that causes
-- @accelSignal@ to be emitted if the accelerator is activated. The
-- @accelGroup@ needs to be added to the widget's toplevel via
-- 'windowAddAccelGroup', and the signal must be of type @G_RUN_ACTION@.
-- Accelerators added through this function are not user changeable during
-- runtime. If you want to support accelerators that can be changed by the
-- user, use 'accelMapAddEntry' and 'widgetSetAccelPath' or
-- 'menuItemSetAccelPath' instead.
--
widgetAddAccelerator :: (WidgetClass self, GlibString string) => self
-> string -- ^ @accelSignal@ - widget signal to emit on accelerator
-- activation
-> AccelGroup -- ^ @accelGroup@ - accel group for this widget, added to
-- its toplevel
-> KeyVal -- ^ @accelKey@ - the key of the accelerator
-> [Modifier] -- ^ @accelMods@ - modifier key combination of the
-- accelerator
-> [AccelFlags] -- ^ @accelFlags@ - flag accelerators, e.g. 'AccelVisible'
-> IO ()
widgetAddAccelerator self accelSignal accelGroup accelKey accelMods accelFlags =
withUTFString accelSignal $ \accelSignalPtr ->
{# call gtk_widget_add_accelerator #}
(toWidget self)
accelSignalPtr
accelGroup
(fromIntegral accelKey)
((fromIntegral . fromFlags) accelMods)
((fromIntegral . fromFlags) accelFlags)
-- %hash c:3442 d:dfe8
-- | Removes an accelerator from @widget@, previously installed with
-- 'widgetAddAccelerator'.
--
widgetRemoveAccelerator :: WidgetClass self => self
-> AccelGroup -- ^ @accelGroup@ - accel group for this widget
-> KeyVal -- ^ @accelKey@ - the key of the accelerator
-> [Modifier] -- ^ @accelMods@ - modifier key combination of the
-- accelerator
-> IO Bool -- ^ returns whether an accelerator was installed and could
-- be removed
widgetRemoveAccelerator self accelGroup accelKey accelMods =
liftM toBool $
{# call gtk_widget_remove_accelerator #}
(toWidget self)
accelGroup
(fromIntegral accelKey)
((fromIntegral . fromFlags) accelMods)
-- %hash c:f8d4 d:bd7f
-- | Given an accelerator group, @accelGroup@, and an accelerator path,
-- @accelPath@, sets up an accelerator in @accelGroup@ so whenever the key
-- binding that is defined for @accelPath@ is pressed, @widget@ will be
-- activated. This removes any accelerators (for any accelerator group)
-- installed by previous calls to 'widgetSetAccelPath'. Associating
-- accelerators with paths allows them to be modified by the user and the
-- modifications to be saved for future use. (See 'accelMapSave'.)
--
-- This function is a low level function that would most likely be used by a
-- menu creation system like 'ItemFactory'. If you use 'ItemFactory', setting
-- up accelerator paths will be done automatically.
--
-- Even when you you aren't using 'ItemFactory', if you only want to set up
-- accelerators on menu items 'menuItemSetAccelPath' provides a somewhat more
-- convenient interface.
--
widgetSetAccelPath :: (WidgetClass self, GlibString string) => self
-> string -- ^ @accelPath@ - path used to look up the accelerator
-> AccelGroup -- ^ @accelGroup@ - a 'AccelGroup'.
-> IO ()
widgetSetAccelPath self accelPath accelGroup =
withUTFString accelPath $ \accelPathPtr ->
{# call gtk_widget_set_accel_path #}
(toWidget self)
accelPathPtr
accelGroup
#if GTK_CHECK_VERSION(2,4,0)
-- %hash c:157e d:82ae
-- | Determines whether an accelerator that activates the signal identified by
-- @signalId@ can currently be activated. This is done by emitting the
-- 'canActivateAccel' signal on the widget the signal is attached to; if the
-- signal isn't overridden by a handler or in a derived widget, then the
-- default check is that the widget must be sensitive, and the widget and all
-- its ancestors mapped.
--
-- * Available since Gtk+ version 2.4
--
widgetCanActivateAccel :: WidgetClass self =>
(ConnectId self) -- ^ @signalId@ - the ID of a signal installed on @widget@
-> IO Bool -- ^ returns @True@ if the accelerator can be activated.
widgetCanActivateAccel (ConnectId signalId self) =
liftM toBool $
{# call gtk_widget_can_activate_accel #}
(toWidget self)
(fromIntegral signalId)
#endif
-- | For widgets that can be \"activated\" (buttons, menu items, etc.) this
-- function activates them. Activation is what happens when you press Enter on
-- a widget during key navigation. If @widget@ isn't activatable, the function
-- returns @False@.
--
widgetActivate :: WidgetClass self => self
-> IO Bool -- ^ returns @True@ if the widget was activatable
widgetActivate self =
liftM toBool $
{# call widget_activate #}
(toWidget self)
-- | Computes the intersection of a widget's area and @area@, returning the
-- intersection, and returns @Nothing@ if there was no intersection.
--
widgetIntersect :: WidgetClass self => self
-> Rectangle -- ^ @area@ - a rectangle
-> IO (Maybe Rectangle) -- ^ returns the intersection or @Nothing@
widgetIntersect self area =
with area $ \areaPtr ->
alloca $ \intersectionPtr -> do
hasIntersection <- {# call unsafe widget_intersect #}
(toWidget self)
(castPtr areaPtr)
(castPtr intersectionPtr)
if (toBool hasIntersection)
then liftM Just $ peek intersectionPtr
else return Nothing
-- | Check if the widget intersects with a given area.
--
widgetHasIntersection :: WidgetClass self => self
-> Rectangle -- ^ @area@ - a rectangle
-> IO Bool -- ^ returns @True@ if there was an intersection
widgetHasIntersection self area =
liftM toBool $
with area $ \areaPtr ->
{# call unsafe widget_intersect #}
(toWidget self)
(castPtr areaPtr)
(castPtr nullPtr)
-- %hash d:1cab
-- | Determines if the widget is the focus widget within its toplevel. (This
-- does not mean that the 'widgetHasFocus' attribute is necessarily set;
-- 'widgetHasFocus' will only be set if the toplevel widget additionally has
-- the global input focus.)
--
widgetGetIsFocus :: WidgetClass self => self
-> IO Bool -- ^ returns @True@ if the widget is the focus widget.
widgetGetIsFocus self =
liftM toBool $
{# call unsafe widget_is_focus #}
(toWidget self)
-- %hash d:e1e
-- | Causes @widget@ to have the keyboard focus for the 'Window' it's inside.
-- @widget@ must be a focusable widget, such as a
-- 'Graphics.UI.Gtk.Entry.Entry'; something like
-- 'Graphics.UI.Gtk.Ornaments.Frame' won't work. (More precisely, it must have
-- the 'widgetCanFocus' flag set.)
--
widgetGrabFocus :: WidgetClass self => self -> IO ()
widgetGrabFocus self =
{# call widget_grab_focus #}
(toWidget self)
-- %hash c:e5e9 d:412a
-- | Causes @widget@ to become the default widget. @widget@ must have the
-- 'canDefault' flag set. The default widget is
-- activated when the user presses Enter in a window. Default widgets must be
-- activatable, that is, 'widgetActivate' should affect them.
--
widgetGrabDefault :: WidgetClass self => self -> IO ()
widgetGrabDefault self =
{# call gtk_widget_grab_default #}
(toWidget self)
-- %hash c:4f62 d:d05a
-- | Widgets can be named, which allows you to refer to them from a gtkrc
-- file. You can apply a style to widgets with a particular name in the gtkrc
-- file. See the documentation for gtkrc files.
--
-- Note that widget names are separated by periods in paths (see
-- 'widgetPath'), so names with embedded periods may cause confusion.
--
widgetSetName :: (WidgetClass self, GlibString string) => self
-> string -- ^ @name@ - name for the widget
-> IO ()
widgetSetName self name =
withUTFString name $ \namePtr ->
{# call widget_set_name #}
(toWidget self)
namePtr
-- | Retrieves the name of a widget. See 'widgetSetName' for the significance
-- of widget names.
--
widgetGetName :: (WidgetClass self, GlibString string) => self -> IO string
widgetGetName self =
{# call unsafe widget_get_name #}
(toWidget self)
>>= peekUTFString
-- %hash c:25b1 d:f898
-- | Sets the sensitivity of a widget. A widget is sensitive if the user can
-- interact with it. Insensitive widgets are \"grayed out\" and the user can't
-- interact with them. Insensitive widgets are known as \"inactive\",
-- \"disabled\", or \"ghosted\" in some other toolkits.
--
widgetSetSensitive :: WidgetClass self => self
-> Bool -- ^ @sensitive@ - @True@ to make the widget sensitive
-> IO ()
widgetSetSensitive self sensitive =
{# call gtk_widget_set_sensitive #}
(toWidget self)
(fromBool sensitive)
-- bad spelling backwards compatability definition
widgetSetSensitivity :: WidgetClass self => self -> Bool -> IO ()
widgetSetSensitivity = widgetSetSensitive
-- | Gets the widget's parent window.
--
widgetGetParentWindow :: WidgetClass self => self -> IO DrawWindow
widgetGetParentWindow self =
makeNewGObject mkDrawWindow $
{# call gtk_widget_get_parent_window #}
(toWidget self)
-- | Disable event signals.
--
-- * Remove events from the 'EventMask' of this widget. The event mask
-- determines which events a widget will receive. Events are signals
-- that return an 'Event' data type. On connecting to a such a signal,
-- the event mask is automatically adjusted so that he signal is emitted.
-- This function is useful to disable the reception of the signal. It
-- should be called whenever all signals receiving an 'Event'
-- have been disconnected.
--
widgetDelEvents :: WidgetClass self => self -> [EventMask] -> IO ()
widgetDelEvents self events = do
mask <- {#call unsafe widget_get_events#} (toWidget self)
let mask' = mask .&. (complement (fromIntegral $ fromFlags events))
{#call unsafe widget_set_events#} (toWidget self) mask'
-- | Enable event signals.
--
-- * See 'widgetDelEvents'.
--
widgetAddEvents :: WidgetClass self => self -> [EventMask] -> IO ()
widgetAddEvents self [] = return ()
-- special [] case to work around a GTK+ bug, see:
-- http://bugzilla.gnome.org/show_bug.cgi?id=316702
widgetAddEvents self events =
{# call unsafe widget_add_events #}
(toWidget self)
(fromIntegral $ fromFlags events)
-- | Get enabled event signals.
--
-- * See 'widgetDelEvents'.
--
widgetGetEvents :: WidgetClass self => self -> IO [EventMask]
widgetGetEvents self =
liftM (toFlags . fromIntegral) $
{# call unsafe widget_get_events #}
(toWidget self)
-- %hash c:468a d:49a0
-- | Sets the event mask (see 'EventMask') for a widget. The event mask
-- determines which events a widget will receive. Keep in mind that different
-- widgets have different default event masks, and by changing the event mask
-- you may disrupt a widget's functionality, so be careful. This function must
-- be called while a widget is unrealized. Consider 'widgetAddEvents' for
-- widgets that are already realized, or if you want to preserve the existing
-- event mask. This function can't be used with 'NoWindow' widgets; to get
-- events on those widgets, place them inside a
-- 'Graphics.UI.Gtk.Misc.EventBox' and receive events on the event box.
--
widgetSetEvents :: WidgetClass self => self
-> [EventMask] -- ^ @events@ - event mask
-> IO ()
widgetSetEvents self events =
{# call unsafe widget_set_events #}
(toWidget self)
(fromIntegral $ fromFlags events)
#if GTK_MAJOR_VERSION < 3
-- %hash c:4f2c d:781
-- | Sets the extension events mask to @mode@. See 'ExtensionMode' and
-- 'inputSetExtensionEvents'.
--
widgetSetExtensionEvents :: WidgetClass self => self
-> [ExtensionMode]
-> IO ()
widgetSetExtensionEvents self mode =
{# call widget_set_extension_events #}
(toWidget self)
((fromIntegral . fromFlags) mode)
-- %hash c:c824 d:e611
-- | Retrieves the extension events the widget will receive; see
-- 'widgetSetExtensionEvents'.
--
widgetGetExtensionEvents :: WidgetClass self => self
-> IO [ExtensionMode]
widgetGetExtensionEvents self =
liftM (toFlags . fromIntegral) $
{# call widget_get_extension_events #}
(toWidget self)
#endif
-- %hash c:270b d:8877
-- | This function returns the topmost widget in the container hierarchy
-- @widget@ is a part of. If @widget@ has no parent widgets, it will be
-- returned as the topmost widget.
--
widgetGetToplevel :: WidgetClass self =>
self -- ^ @widget@ - the widget in question
-> IO Widget -- ^ returns the topmost ancestor of @widget@, or @widget@
-- itself if there's no ancestor.
widgetGetToplevel self =
makeNewObject mkWidget $
{# call unsafe widget_get_toplevel #}
(toWidget self)
-- %hash c:17bc d:f8f9
-- | Gets the first ancestor of @widget@ with type @widgetType@. For example,
-- @widgetGetAncestor widget gTypeBox@ gets the first 'Box' that's
-- an ancestor of @widget@. See note about checking for a toplevel
-- 'Window' in the docs for 'widgetGetToplevel'.
--
-- Note that unlike 'widgetIsAncestor', 'widgetGetAncestor' considers
-- @widget@ to be an ancestor of itself.
--
widgetGetAncestor :: WidgetClass self => self
-> GType -- ^ @widgetType@ - ancestor type
-> IO (Maybe Widget) -- ^ returns the ancestor widget, or @Nothing@ if not found
widgetGetAncestor self widgetType = do
ptr <- {# call gtk_widget_get_ancestor #}
(toWidget self)
widgetType
if ptr==nullPtr then return Nothing else
liftM Just $ makeNewObject mkWidget (return ptr)
#if GTK_MAJOR_VERSION < 3
-- %hash c:bd95 d:eb94
-- | Gets the colormap that will be used to render @widget@.
--
widgetGetColormap :: WidgetClass self => self
-> IO Colormap -- ^ returns the colormap used by @widget@
widgetGetColormap self =
makeNewGObject mkColormap $
{# call gtk_widget_get_colormap #}
(toWidget self)
-- %hash c:cba1 d:ffeb
-- | Sets the colormap for the widget to the given value. Widget must not have
-- been previously realized. This probably should only be used from an 'init'
-- function (i.e. from the constructor for the widget).
--
widgetSetColormap :: WidgetClass self => self
-> Colormap -- ^ @colormap@ - a colormap
-> IO ()
widgetSetColormap self colormap =
{# call gtk_widget_set_colormap #}
(toWidget self)
colormap
#endif
-- %hash c:3522 d:5637
-- | Obtains the location of the mouse pointer in widget coordinates. Widget
-- coordinates are a bit odd; for historical reasons, they are defined as
-- 'widgetGetParentWindow' coordinates for widgets that are not 'NoWindow' widgets,
-- and are relative to the widget's allocation's (x,y) for
-- widgets that are 'NoWindow' widgets.
--
widgetGetPointer :: WidgetClass self => self
-> IO (Int, Int) -- ^ @(x, y)@ - X Y coordinate
widgetGetPointer self =
alloca $ \xPtr ->
alloca $ \yPtr ->
{# call gtk_widget_get_pointer #}
(toWidget self)
xPtr
yPtr
>>
peek xPtr >>= \x ->
peek yPtr >>= \y ->
return (fromIntegral x, fromIntegral y)
-- %hash c:499d
-- | Determines whether @widget@ is somewhere inside @ancestor@, possibly with
-- intermediate containers.
--
widgetIsAncestor :: (WidgetClass self, WidgetClass ancestor) =>
self -- ^ @widget@ - the widget in question
-> ancestor -- ^ @ancestor@ - another 'Widget'
-> IO Bool -- ^ returns @True@ if @ancestor@ contains @widget@ as a child,
-- grandchild, great grandchild, etc.
widgetIsAncestor self ancestor =
liftM toBool $
{# call unsafe widget_is_ancestor #}
(toWidget self)
(toWidget ancestor)
-- %hash c:8661
-- | Translate coordinates relative to @srcWidget@'s allocation to coordinates
-- relative to @destWidget@'s allocations. In order to perform this operation,
-- both widgets must be realized, and must share a common toplevel.
--
widgetTranslateCoordinates :: (WidgetClass self, WidgetClass destWidget) =>
self -- ^ @srcWidget@ - a 'Widget'
-> destWidget -- ^ @destWidget@ - a 'Widget'
-> Int -- ^ @srcX@ - X position relative to @srcWidget@
-> Int -- ^ @srcY@ - Y position relative to @srcWidget@
-> IO (Maybe (Int, Int)) -- ^ @Just (destX, destY)@ - X and Y position
-- relative to @destWidget@. Returns @Nothing@ if
-- either widget was not realized, or there was no
-- common ancestor.
widgetTranslateCoordinates self destWidget srcX srcY =
alloca $ \destXPtr ->
alloca $ \destYPtr -> do
worked <- {# call gtk_widget_translate_coordinates #}
(toWidget self)
(toWidget destWidget)
(fromIntegral srcX)
(fromIntegral srcY)
destXPtr
destYPtr
if (toBool worked)
then do destX <- peek destXPtr
destY <- peek destYPtr
return (Just (fromIntegral destX, fromIntegral destY))
else return Nothing
-- %hash c:596c d:b7e5
-- | Sets the 'Style' for a widget. You probably don't want
-- to use this function; it interacts badly with themes, because themes work by
-- replacing the 'Style'. Instead, use 'widgetModifyStyle'.
--
widgetSetStyle :: WidgetClass self => self
-> Maybe Style -- ^ @style@ - a 'Style', or @Nothing@ to remove the effect of a previous
-- 'widgetSetStyle' and go back to the default style
-> IO ()
widgetSetStyle self style =
{# call gtk_widget_set_style #}
(toWidget self)
(fromMaybe (Style nullForeignPtr) style)
-- | Retrieve the 'Style' associated with the widget.
--
widgetGetStyle :: WidgetClass widget => widget -> IO Style
widgetGetStyle widget = do
{# call gtk_widget_ensure_style #} (toWidget widget)
makeNewGObject mkStyle $ {# call gtk_widget_get_style #} (toWidget widget)
#if GTK_MAJOR_VERSION < 3
-- %hash c:d5ed d:dc10
-- | Pushes @cmap@ onto a global stack of colormaps; the topmost colormap on
-- the stack will be used to create all widgets. Remove @cmap@ with
-- 'widgetPopColormap'. There's little reason to use this function.
--
widgetPushColormap ::
Colormap -- ^ @cmap@ - a 'Colormap'
-> IO ()
widgetPushColormap cmap =
{# call gtk_widget_push_colormap #}
cmap
-- %hash c:7300 d:2920
-- | Removes a colormap pushed with 'widgetPushColormap'.
--
widgetPopColormap :: IO ()
widgetPopColormap =
{# call gtk_widget_pop_colormap #}
-- %hash c:1f73 d:590e
-- | Sets the default colormap to use when creating widgets.
-- 'widgetPushColormap' is a better function to use if you only want to affect
-- a few widgets, rather than all widgets.
--
widgetSetDefaultColormap ::
Colormap -- ^ @colormap@ - a 'Colormap'
-> IO ()
widgetSetDefaultColormap colormap =
{# call gtk_widget_set_default_colormap #}
colormap
#endif
-- %hash c:e71b d:72c2
-- | Returns the default style used by all widgets initially.
--
widgetGetDefaultStyle ::
IO Style -- ^ returns the default style. This 'Style' object is owned by
-- Gtk and should not be modified.
widgetGetDefaultStyle =
makeNewGObject mkStyle $
{# call gtk_widget_get_default_style #}
#if GTK_MAJOR_VERSION < 3
-- %hash c:d731 d:52bf
-- | Obtains the default colormap used to create widgets.
--
widgetGetDefaultColormap ::
IO Colormap -- ^ returns default widget colormap
widgetGetDefaultColormap =
makeNewGObject mkColormap $
{# call gtk_widget_get_default_colormap #}
#endif
-- | Sets the reading direction on a particular widget. This direction
-- controls the primary direction for widgets containing text, and also the
-- direction in which the children of a container are packed. The ability to
-- set the direction is present in order so that correct localization into
-- languages with right-to-left reading directions can be done. Generally,
-- applications will let the default reading direction present, except for
-- containers where the containers are arranged in an order that is explicitely
-- visual rather than logical (such as buttons for text justification).
--
-- If the direction is set to 'TextDirNone', then the value set by
-- 'widgetSetDefaultDirection' will be used.
--
widgetSetDirection :: WidgetClass self => self -> TextDirection -> IO ()
widgetSetDirection self dir =
{# call widget_set_direction #}
(toWidget self)
((fromIntegral . fromEnum) dir)
-- | Gets the reading direction for a particular widget. See
-- 'widgetSetDirection'.
--
widgetGetDirection :: WidgetClass self => self -> IO TextDirection
widgetGetDirection self =
liftM (toEnum . fromIntegral) $
{# call widget_get_direction #}
(toWidget self)
-- %hash c:ff9a
-- | Sets the default reading direction for widgets where the direction has
-- not been explicitly set by 'widgetSetDirection'.
--
widgetSetDefaultDirection ::
TextDirection -- ^ @dir@ - the new default direction. This cannot be
-- 'TextDirNone'.
-> IO ()
widgetSetDefaultDirection dir =
{# call gtk_widget_set_default_direction #}
((fromIntegral . fromEnum) dir)
-- | Obtains the current default reading direction. See
-- 'widgetSetDefaultDirection'.
--
widgetGetDefaultDirection :: IO TextDirection
widgetGetDefaultDirection =
liftM (toEnum . fromIntegral) $
{# call gtk_widget_get_default_direction #}
#if GTK_MAJOR_VERSION < 3
-- %hash c:c7ba d:3a9c
-- | Sets a shape for this widget's 'DrawWindow'. This allows for transparent
-- windows etc., see 'windowShapeCombineMask' for more information.
--
widgetShapeCombineMask :: WidgetClass self => self
-> Maybe Bitmap -- ^ @shapeMask@ - shape to be added, or @Nothint@ to remove an
-- existing shape.
-> Int -- ^ @offsetX@ - X position of shape mask with respect to @window@.
-> Int -- ^ @offsetY@ - Y position of shape mask with respect to @window@.
-> IO ()
widgetShapeCombineMask self shapeMask offsetX offsetY =
case (fromMaybe (Pixmap nullForeignPtr) shapeMask) of
Pixmap fPtr -> withForeignPtr fPtr $ \bitmapPtr ->
{# call gtk_widget_shape_combine_mask #}
(toWidget self)
(castPtr bitmapPtr)
(fromIntegral offsetX)
(fromIntegral offsetY)
#endif
#if GTK_MAJOR_VERSION < 3
#if GTK_CHECK_VERSION(2,10,0)
-- %hash c:3c29 d:68e2
-- | Sets an input shape for this widget's GDK window. This allows for windows
-- which react to mouse click in a nonrectangular region, see
-- 'windowInputShapeCombineMask' for more information.
--
-- * Available since Gtk+ version 2.10
--
widgetInputShapeCombineMask :: WidgetClass self => self
-> Maybe Bitmap -- ^ @shapeMask@ - shape to be added, or @Nothint@ to remove an
-- existing shape.
-> Int -- ^ @offsetX@ - X position of shape mask with respect to @window@.
-> Int -- ^ @offsetY@ - Y position of shape mask with respect to @window@.
-> IO ()
widgetInputShapeCombineMask self shapeMask offsetX offsetY =
case (fromMaybe (Pixmap nullForeignPtr) shapeMask) of
Pixmap fPtr -> withForeignPtr fPtr $ \bitmapPtr ->
{# call gtk_widget_input_shape_combine_mask #}
(toWidget self)
(castPtr bitmapPtr)
(fromIntegral offsetX)
(fromIntegral offsetY)
#endif
#endif
#if GTK_CHECK_VERSION(3,0,0)
-- | Sets a shape for this widget’s GDK window. This allows for transparent
-- windows etc., see 'drawWindowShapeCombineRegion' for more information.
widgetShapeCombineRegion :: WidgetClass self => self
-> Maybe Region
-> IO ()
widgetShapeCombineRegion self region =
withRegion (fromMaybe (Region nullForeignPtr) region) $ \ptrRegion ->
{# call gtk_widget_shape_combine_region #}
(toWidget self)
(castPtr ptrRegion)
-- | Sets an input shape for this widget’s GDK window. This allows for windows
-- which react to mouse click in a nonrectangular region,
-- see 'drawWindowInputShapeCombineRegion' for more information.
widgetInputShapeCombineRegion :: WidgetClass self => self
-> Maybe Region
-> IO ()
widgetInputShapeCombineRegion self region =
withRegion (fromMaybe (Region nullForeignPtr) region) $ \ptrRegion ->
{# call gtk_widget_input_shape_combine_region #}
(toWidget self)
(castPtr ptrRegion)
#endif
#if GTK_MAJOR_VERSION < 3
#if GTK_CHECK_VERSION(2,14,0)
-- | Create a 'Pixmap' of the contents of the widget and its children.
--
-- Works even if the widget is obscured. The depth and visual of the resulting pixmap is dependent on
-- the widget being snapshot and likely differs from those of a target widget displaying the
-- pixmap. The function 'pixbufGetFromDrawable' can be used to convert the pixmap to a visual
-- independant representation.
--
-- The snapshot area used by this function is the widget's allocation plus any extra space occupied by
-- additional windows belonging to this widget (such as the arrows of a spin button). Thus, the
-- resulting snapshot pixmap is possibly larger than the allocation.
--
-- The resulting pixmap is shrunken to match the specified @clipRect@. The
-- (x,y) coordinates of @clipRect@ are interpreted widget relative. If width or height of @clipRect@ are
-- 0 or negative, the width or height of the resulting pixmap will be shrunken by the respective
-- amount. For instance a @clipRect@ { +5, +5, -10, -10 } will chop off 5 pixels at each side of the
-- snapshot pixmap. @clipRect@ will contain the exact widget-relative snapshot coordinates
-- upon return. A @clipRect@ of { -1, -1, 0, 0 } can be used to preserve the auto-grown snapshot area
-- and use @clipRect@ as a pure output parameter.
--
-- The returned pixmap can be 'Nothing', if the resulting @clipArea@ was empty.
widgetGetSnapshot :: WidgetClass self => self
-> Rectangle
-> IO (Maybe Pixmap) -- ^ returns 'Pixmap' snapshot of the widget
widgetGetSnapshot widget clipRect =
maybeNull (wrapNewGObject mkPixmap) $
with clipRect $ \ clipRectPtr ->
{#call gtk_widget_get_snapshot #}
(toWidget widget)
(castPtr clipRectPtr)
#endif
#endif
-- %hash c:7e36 d:616f
-- | Obtains the full path to @widget@. The path is simply the name of a
-- widget and all its parents in the container hierarchy, separated by periods.
-- The name of a widget comes from 'widgetGetName'. Paths are used to apply
-- styles to a widget in gtkrc configuration files. Widget names are the type
-- of the widget by default (e.g. \"GtkButton\") or can be set to an
-- application-specific value with 'widgetSetName'. By setting the name of a
-- widget, you allow users or theme authors to apply styles to that specific
-- widget in their gtkrc file. Also returns the path in reverse
-- order, i.e. starting with the widget's name instead of starting with the
-- name of the widget's outermost ancestor.
--
widgetPath :: (WidgetClass self, GlibString string) => self
-> IO (Int, string, string) -- ^ @(pathLength, path, pathReversed)@ - length
-- of the path, path string and reverse path
-- string
widgetPath self =
alloca $ \pathLengthPtr ->
alloca $ \pathPtr ->
alloca $ \pathReversedPtr ->
{# call gtk_widget_path #}
(toWidget self)
pathLengthPtr
pathPtr
pathReversedPtr
>>
peek pathLengthPtr >>= \pathLength ->
peek pathPtr >>= readUTFString >>= \path ->
peek pathReversedPtr >>= readUTFString >>= \pathReversed ->
return (fromIntegral pathLength, path, pathReversed)
-- %hash c:d4a6
-- | Same as 'widgetPath', but always uses the name of a widget's type, never
-- uses a custom name set with 'widgetSetName'.
--
widgetClassPath :: (WidgetClass self, GlibString string) => self
-> IO (Int, string, string) -- ^ @(pathLength, path, pathReversed)@ - length
-- of the path, path string and reverse path
-- string
widgetClassPath self =
alloca $ \pathLengthPtr ->
alloca $ \pathPtr ->
alloca $ \pathReversedPtr ->
{# call gtk_widget_class_path #}
(toWidget self)
pathLengthPtr
pathPtr
pathReversedPtr
>>
peek pathLengthPtr >>= \pathLength ->
peek pathPtr >>= readUTFString >>= \path ->
peek pathReversedPtr >>= readUTFString >>= \pathReversed ->
return (fromIntegral pathLength, path, pathReversed)
-- %hash c:769e
-- | Obtains the composite name of a widget.
--
widgetGetCompositeName :: (WidgetClass self, GlibString string) => self
-> IO (Maybe string) -- ^ returns the composite name of @widget@, or
-- @Nothing@ if @widget@ is not a composite child.
widgetGetCompositeName self =
{# call gtk_widget_get_composite_name #}
(toWidget self)
>>= maybePeek peekUTFString
#if GTK_CHECK_VERSION(3,0,0)
-- | Sets the background color to use for a widget.
--
-- All other style values are left untouched. See 'widgetOverrideColor'.
widgetOverrideBackgroundColor :: WidgetClass self => self
-> StateType -- ^ @state@ - the state for which to set the background color.
-> Maybe Color -- ^ @color@ - the color to assign, or Nothing to undo the
-- effect of previous calls to 'widgetOverrideBackgroundColor'
-> IO ()
widgetOverrideBackgroundColor self state color =
maybeWith with color $ \colorPtr ->
{# call widget_override_background_color #}
(toWidget self)
((fromIntegral . fromEnum) state)
(castPtr colorPtr)
-- | Sets the color to use for a widget.
--
-- All other style values are left untouched.
--
-- This function does not act recursively. Setting the color of a container
-- does not affect its children. Note that some widgets that you may not think
-- of as containers, for instance 'Button's, are actually containers.
--
-- This API is mostly meant as a quick way for applications to change a
-- widget appearance. If you are developing a widgets library and intend this
-- change to be themeable, it is better done by setting meaningful CSS classes
-- and regions in your widget/container implementation through
-- 'styleContextAddClass' and 'styleContextAddRegion'.
--
-- This way, your widget library can install a 'CssProvider' with the
-- GTK_STYLE_PROVIDER_PRIORITY_FALLBACK priority in order to provide a default
-- styling for those widgets that need so, and this theming may fully overridden
-- by the user’s theme.
--
-- Note that for complex widgets this may bring in undesired results (such as
-- uniform background color everywhere), in these cases it is better to fully
-- style such widgets through a CssProvider with the
-- GTK_STYLE_PROVIDER_PRIORITY_APPLICATION priority.
widgetOverrideColor :: WidgetClass self => self
-> StateType -- ^ @state@ - the state for which to set the color.
-> Maybe Color -- ^ @color@ - the color to assign, or @Nothing@ to undo the
-- effect of previous calls to 'widgetOverrideColor'
-> IO ()
widgetOverrideColor self state color =
maybeWith with color $ \colorPtr ->
{# call widget_override_color #}
(toWidget self)
((fromIntegral . fromEnum) state)
(castPtr colorPtr)
-- | Sets the font to use for a widget. All other style values are left untouched.
-- See 'widgetOverrideColor'.
widgetOverrideFont :: WidgetClass self => self
-> Maybe FontDescription -- ^ @fontDesc@ - the font description to use, or
-- @Nothing@ to undo the effect of previous calls to
-- 'widgetOverrideFont'.
-> IO ()
widgetOverrideFont self fontDesc =
{# call widget_override_font #}
(toWidget self)
(fromMaybe (FontDescription nullForeignPtr) fontDesc)
-- | Sets the symbolic color to use for a widget.
--
-- All other style values are left untouched. See 'widgetOverrideColor'.
widgetOverrideSymbolicColor :: (WidgetClass self, GlibString string) => self
-> string -- ^ @name@ - the name of the symbolic color to modify.
-> Maybe Color -- ^ @color@ - the color to assign, or @Nothing@ to undo the
-- effect of previous calls to 'widgetOverrideSymbolicColor'
-> IO ()
widgetOverrideSymbolicColor self name color =
withUTFString name $ \namePtr ->
maybeWith with color $ \colorPtr ->
{# call widget_override_symbolic_color #}
(toWidget self)
namePtr
(castPtr colorPtr)
-- | Sets the cursor color to use in a widget, overriding the cursor-color
-- and secondary-cursor-color style properties. All other style values are
-- left untouched. See also 'widgetModifyStyle'.
--
-- Note that the alpha values will be ignored.
widgetOverrideCursor :: WidgetClass self => self
-> Maybe Color -- ^ @cursor@ - the color to use for primary cursor, or @Nothing@
-- to undo the effect of previous calls to of 'widgetOverrideCursor'.
-> Maybe Color -- ^ @secondaryCursor@ - the color to use for secondary cursor, or @Nothing@
-- to undo the effect of previous calls to of 'widgetOverrideCursor'.
-> IO ()
widgetOverrideCursor self cursor secondaryCursor =
maybeWith with cursor $ \cursorPtr ->
maybeWith with secondaryCursor $ \secondaryCursorPtr ->
{# call widget_override_cursor #}
(toWidget self)
(castPtr cursorPtr)
(castPtr secondaryCursorPtr)
#endif
-- | Modifies style values on the widget. Modifications made using this
-- technique take precedence over style values set via an RC file, however,
-- they will be overriden if a style is explicitely set on the widget using
-- 'widgetSetStyle'. The 'RcStyle' structure is designed so each field can
-- either be set or unset, so it is possible, using this function, to modify
-- some style values and leave the others unchanged.
--
-- Note that modifications made with this function are not cumulative with
-- previous calls to 'widgetModifyStyle' or with such functions as
-- 'widgetModifyFg'. If you wish to retain previous values, you must first call
-- 'widgetGetModifierStyle', make your modifications to the returned style,
-- then call 'widgetModifyStyle' with that style. On the other hand, if you
-- first call 'widgetModifyStyle', subsequent calls to such functions
-- 'widgetModifyFg' will have a cumulative effect with the initial
-- modifications.
--
widgetModifyStyle :: (WidgetClass self, RcStyleClass style) => self
-> style -- ^ @style@ - the 'RcStyle' holding the style modifications
-> IO ()
widgetModifyStyle self style =
{# call gtk_widget_modify_style #}
(toWidget self)
(toRcStyle style)
-- | Returns the current modifier style for the widget. (As set by
-- 'widgetModifyStyle'.) If no style has previously set, a new 'RcStyle' will
-- be created with all values unset, and set as the modifier style for the
-- widget. If you make changes to this rc style, you must call
-- 'widgetModifyStyle', passing in the returned rc style, to make sure that
-- your changes take effect.
--
-- Caution: passing the style back to 'widgetModifyStyle' will normally end
-- up destroying it, because 'widgetModifyStyle' copies the passed-in style and
-- sets the copy as the new modifier style, thus dropping any reference to the
-- old modifier styl e. Add a reference to the modifier style if you want to
-- keep it alive.
--
widgetGetModifierStyle :: WidgetClass self => self -> IO RcStyle
widgetGetModifierStyle self =
makeNewGObject mkRcStyle $
{# call gtk_widget_get_modifier_style #}
(toWidget self)
-- %hash c:5550
-- | Sets the foreground color for a widget in a particular state. All other
-- style values are left untouched. See also 'widgetModifyStyle'.
--
widgetModifyFg :: WidgetClass self => self
-> StateType -- ^ @state@ - the state for which to set the foreground color.
-> Color -- ^ @color@ - the color to assign (does not need to be
-- allocated)
-> IO ()
widgetModifyFg self state color =
with color $ \colorPtr ->
{# call gtk_widget_modify_fg #}
(toWidget self)
((fromIntegral . fromEnum) state)
(castPtr colorPtr)
-- | Restores the foreground color for a widget in a particular state. This
-- undoes the effects of previous calls to `widgetModifyFg'.
--
widgetRestoreFg :: WidgetClass self => self
-> StateType -- ^ @state@ - the state for which to restore the foreground color.
-> IO ()
widgetRestoreFg self state =
{# call gtk_widget_modify_fg #}
(toWidget self)
((fromIntegral . fromEnum) state)
nullPtr
-- %hash c:2c5
-- | Sets the background color for a widget in a particular state. All other
-- style values are left untouched. See also 'widgetModifyStyle'.
--
-- Note that \"no window\" widgets (which have the 'NoWindow' flag set) draw
-- on their parent container's window and thus may not draw any background
-- themselves. This is the case for e.g. 'Label'. To modify the background of
-- such widgets, you have to set the background color on their parent; if you
-- want to set the background of a rectangular area around a label, try placing
-- the label in a 'EventBox' widget and setting the background color on that.
--
widgetModifyBg :: WidgetClass self => self
-> StateType -- ^ @state@ - the state for which to set the background color.
-> Color -- ^ @color@ - the color to assign (does not need to be
-- allocated).
-> IO ()
widgetModifyBg self state color =
with color $ \colorPtr ->
{# call gtk_widget_modify_bg #}
(toWidget self)
((fromIntegral . fromEnum) state)
(castPtr colorPtr)
-- | Restores the background color for a widget in a particular state. This
-- undoes the effects of previous calls to `widgetModifyBg'.
--
widgetRestoreBg :: WidgetClass self => self
-> StateType -- ^ @state@ - the state for which to restore the background color.
-> IO ()
widgetRestoreBg self state =
{# call gtk_widget_modify_bg #}
(toWidget self)
((fromIntegral . fromEnum) state)
nullPtr
-- %hash c:d2ba
-- | Sets the text color for a widget in a particular state. All other style
-- values are left untouched. The text color is the foreground color used along
-- with the base color (see 'widgetModifyBase') for widgets such as 'Entry' and
-- 'TextView'. See also 'widgetModifyStyle'.
--
widgetModifyText :: WidgetClass self => self
-> StateType -- ^ @state@ - the state for which to set the text color.
-> Color -- ^ @color@ - the color to assign (does not need to be
-- allocated).
-> IO ()
widgetModifyText self state color =
with color $ \colorPtr ->
{# call gtk_widget_modify_text #}
(toWidget self)
((fromIntegral . fromEnum) state)
(castPtr colorPtr)
-- | Restores the text color for a widget in a particular state. This
-- undoes the effects of previous calls to `widgetModifyText'.
--
widgetRestoreText :: WidgetClass self => self
-> StateType -- ^ @state@ - the state for which to restore the text color.
-> IO ()
widgetRestoreText self state =
{# call gtk_widget_modify_text #}
(toWidget self)
((fromIntegral . fromEnum) state)
nullPtr
-- %hash c:ac08
-- | Sets the base color for a widget in a particular state. All other style
-- values are left untouched. The base color is the background color used along
-- with the text color (see 'widgetModifyText') for widgets such as 'Entry' and
-- 'TextView'. See also 'widgetModifyStyle'.
--
-- Note that \"no window\" widgets (which have the 'NoWindow' flag set) draw
-- on their parent container's window and thus may not draw any background
-- themselves. This is the case for e.g. 'Label'. To modify the background of
-- such widgets, you have to set the base color on their parent; if you want to
-- set the background of a rectangular area around a label, try placing the
-- label in a 'EventBox' widget and setting the base color on that.
--
widgetModifyBase :: WidgetClass self => self
-> StateType -- ^ @state@ - the state for which to set the base color.
-> Color -- ^ @color@ - the color to assign (does not need to be
-- allocated).
-> IO ()
widgetModifyBase self state color =
with color $ \colorPtr ->
{# call gtk_widget_modify_base #}
(toWidget self)
((fromIntegral . fromEnum) state)
(castPtr colorPtr)
-- | Restores the base color for a widget in a particular state. This undoes
-- the effects of previous calls to widgetModifyBase.
--
widgetRestoreBase :: WidgetClass self => self
-> StateType -- ^ @state@ - the state for which to restore the base color.
-> IO ()
widgetRestoreBase self state =
{# call gtk_widget_modify_base #}
(toWidget self)
((fromIntegral . fromEnum) state)
nullPtr
-- %hash c:38d7
-- | Sets the font to use for a widget. All other style values are left
-- untouched. See also 'widgetModifyStyle'.
--
widgetModifyFont :: WidgetClass self => self
-> Maybe FontDescription -- ^ @fontDesc@ - the font description to use, or
-- @Nothing@ to undo the effect of previous calls to
-- 'widgetModifyFont'.
-> IO ()
widgetModifyFont self fontDesc =
{# call gtk_widget_modify_font #}
(toWidget self)
(fromMaybe (FontDescription nullForeignPtr) fontDesc)
-- | Creates a new 'PangoContext' with the appropriate colormap, font description,
-- and base direction for drawing text for this widget. See also
-- 'widgetGetPangoContext'.
--
widgetCreatePangoContext :: WidgetClass self => self
-> IO PangoContext -- ^ returns the new 'PangoContext'
widgetCreatePangoContext self =
wrapNewGObject mkPangoContext $
{# call gtk_widget_create_pango_context #}
(toWidget self)
-- | Gets a 'PangoContext' with the appropriate font description and base
-- direction for this widget. Unlike the context returned by
-- 'widgetCreatePangoContext', this context is owned by the widget (it can be
-- used until the screen for the widget changes or the widget is removed from
-- its toplevel), and will be updated to match any changes to the widget's
-- attributes.
--
-- If you create and keep a 'PangoLayout' using this context, you must deal
-- with changes to the context by calling
-- 'layoutContextChanged' on the layout
-- in response to the 'onStyleChanged' and 'onDirectionChanged' signals for the
-- widget.
--
widgetGetPangoContext :: WidgetClass self => self
-> IO PangoContext -- ^ returns the 'PangoContext' for the widget.
widgetGetPangoContext self =
makeNewGObject mkPangoContext $
{# call gtk_widget_get_pango_context #}
(toWidget self)
-- | Prepare text for display.
--
-- The 'PangoLayout' represents the rendered text. It can be shown on screen
-- by calling 'drawLayout'.
--
-- The returned 'PangoLayout' shares the same font information ('PangoContext') as this
-- widget. If this information changes, the 'PangoLayout' should change. The
-- following code ensures that the displayed text always reflects the widget's
-- settings:
--
-- > l <- widgetCreateLayout w "My Text."
-- > let update = do
-- > layoutContextChanged l
-- > -- update the Drawables which show this layout
-- > w `onDirectionChanged` update
-- > w `onStyleChanged` update
--
widgetCreateLayout :: (WidgetClass self, GlibString string) => self
-> string -- ^ @text@ - text to set on the layout
-> IO PangoLayout
widgetCreateLayout self text = do
pl <- wrapNewGObject mkPangoLayoutRaw $
withUTFString text $ \textPtr ->
{# call unsafe widget_create_pango_layout #}
(toWidget self)
textPtr
ps <- makeNewPangoString text
psRef <- newIORef ps
return (PangoLayout psRef pl)
-- %hash c:cee d:1d29
-- | A convenience function that uses the theme engine and RC file settings
-- for @widget@ to look up the stock icon and render it to a
-- 'Graphics.UI.Gtk.Gdk.Pixbuf.Pixbuf'.
-- The icon should be one of the stock id constants such as
-- 'Graphics.UI.Gtk.General.StockItems.stockOpen'. @size@ should be a
-- size such as 'Graphics.UI.Gtk.General.IconFactory.IconSizeMenu'.
-- @detail@ should be a string that identifies the
-- widget or code doing the rendering, so that theme engines can special-case
-- rendering for that widget or code.
--
-- The pixels in the returned 'Graphics.UI.Gtk.Gdk.Pixbuf.Pixbuf' are
-- shared with the rest of the
-- application and should not be modified.
--
widgetRenderIcon :: (WidgetClass self, GlibString string) => self
-> string -- ^ @stockId@ - a stock ID
-> IconSize -- ^ @size@ - a stock size
-> string -- ^ @detail@ - render detail to pass to theme engine
-> IO (Maybe Pixbuf) -- ^ returns a new pixbuf, or @Nothing@ if the stock ID
-- wasn't known
widgetRenderIcon self stockId size detail =
maybeNull (wrapNewGObject mkPixbuf) $
withUTFString detail $ \detailPtr ->
withUTFString stockId $ \stockIdPtr ->
{# call gtk_widget_render_icon #}
(toWidget self)
stockIdPtr
((fromIntegral . fromEnum) size)
detailPtr
-- %hash c:62f d:1863
-- | Invalidates the rectangular area of @widget@ defined by @x@, @y@, @width@
-- and @height@ by calling
-- 'Graphics.UI.Gtk.Gdk.DrawWindow.drawWindowInvalidateRect' on the widget's
-- 'Graphics.UI.Gtk.Gdk.DrawWindow.DrawWindow' and all its child windows. Once
-- the main loop becomes idle (after the current batch of events has been
-- processed, roughly), the window will receive expose events for the union of
-- all regions that have been invalidated.
--
-- Normally you would only use this function in widget implementations. In
-- particular, you might use it, or
-- 'Graphics.UI.Gtk.Gdk.DrawWindow.drawWindowInvalidateRect' directly, to
-- schedule a redraw of a 'Graphics.UI.Gtk.Gdk.DrawWindow.DrawingArea' or some
-- portion thereof.
--
-- Frequently you can just call
-- 'Graphics.UI.Gtk.Gdk.DrawWindow.windowInvalidateRect' or
-- 'Graphics.UI.Gtk.Gdk.DrawWindow.windowInvalidateRegion' instead of this
-- function. Those functions will invalidate only a single window, instead of
-- the widget and all its children.
--
-- The advantage of adding to the invalidated region compared to simply
-- drawing immediately is efficiency; using an invalid region ensures that you
-- only have to redraw one time.
--
widgetQueueDrawArea :: WidgetClass self => self
-> Int -- ^ @x@ - x coordinate of upper-left corner of rectangle to redraw
-> Int -- ^ @y@ - y coordinate of upper-left corner of rectangle to redraw
-> Int -- ^ @width@ - width of region to draw
-> Int -- ^ @height@ - height of region to draw
-> IO ()
widgetQueueDrawArea self x y width height =
{# call gtk_widget_queue_draw_area #}
(toWidget self)
(fromIntegral x)
(fromIntegral y)
(fromIntegral width)
(fromIntegral height)
#if GTK_CHECK_VERSION(3,0,0)
-- | Invalidates the area of widget defined by @region@ by calling
-- 'drawWindowInvalidateRegion' on the widget’s window and all its child
-- windows. Once the main loop becomes idle (after the current batch of
-- events has been processed, roughly), the window will receive expose events
-- for the union of all regions that have been invalidated.
--
-- Normally you would only use this function in widget implementations. You
-- might also use it to schedule a redraw of a DrawingArea or some portion
-- thereof.
widgetQueueDrawRegion :: WidgetClass self => self
-> Region
-> IO ()
widgetQueueDrawRegion self region =
withRegion region $ \regionPtr ->
{# call gtk_widget_queue_draw_region #}
(toWidget self)
(castPtr regionPtr)
#endif
#if GTK_MAJOR_VERSION < 3
-- %hash c:5ffb d:3e1a
-- | Recursively resets the shape on this widget and its descendants.
--
widgetResetShapes :: WidgetClass self => self -> IO ()
widgetResetShapes self =
{# call gtk_widget_reset_shapes #}
(toWidget self)
#endif
-- | Sets whether the application intends to draw on the widget in response
-- to an 'onExpose' signal.
--
-- * This is a hint to the widget and does not affect the behavior of the
-- GTK+ core; many widgets ignore this flag entirely. For widgets that do
-- pay attention to the flag, such as 'EventBox' and 'Window', the effect
-- is to suppress default themed drawing of the widget's background.
-- (Children of the widget will still be drawn.) The application is then
-- entirely responsible for drawing the widget background.
--
widgetSetAppPaintable :: WidgetClass self => self
-> Bool -- ^ @appPaintable@ - @True@ if the application will paint on the
-- widget
-> IO ()
widgetSetAppPaintable self appPaintable =
{# call widget_set_app_paintable #}
(toWidget self)
(fromBool appPaintable)
-- %hash c:89b2 d:e14d
-- | Widgets are double buffered by default; you can use this function to turn
-- off the buffering. \"Double buffered\" simply means that
-- 'Graphics.UI.Gtk.Gdk.DrawWindow.drawWindowBeginPaintRegion' and
-- 'Graphics.UI.Gtk.Gdk.DrawWindow.drawWindowEndPaint' are called automatically
-- around expose events sent to the widget.
-- 'Graphics.UI.Gtk.Gdk.DrawWindow.drawWindowBeginPaintRegion' diverts all
-- drawing to a widget's window to an offscreen buffer, and
-- 'Graphics.UI.Gtk.Gdk.DrawWindow.drawWindowEndPaint'
-- draws the buffer to the screen. The result is that users see the window
-- update in one smooth step, and don't see individual graphics primitives
-- being rendered.
--
-- In very simple terms, double buffered widgets don't flicker, so you would
-- only use this function to turn off double buffering if you had special needs
-- and really knew what you were doing.
--
-- Note: if you turn off double-buffering, you have to handle expose events,
-- since even the clearing to the background color or pixmap will not happen
-- automatically (as it is done in
-- 'Graphics.UI.Gtk.Gdk.DrawWindow.drawWindowBeginPaint').
--
widgetSetDoubleBuffered :: WidgetClass self => self
-> Bool -- ^ @doubleBuffered@ - @True@ to double-buffer a widget
-> IO ()
widgetSetDoubleBuffered self doubleBuffered =
{# call gtk_widget_set_double_buffered #}
(toWidget self)
(fromBool doubleBuffered)
-- %hash c:d61 d:ac24
-- | Sets whether the entire widget is queued for drawing when its size
-- allocation changes. By default, this setting is @True@ and the entire widget
-- is redrawn on every size change. If your widget leaves the upper left
-- unchanged when made bigger, turning this setting on will improve
-- performance.
--
-- Note that for \"no window\" widgets setting this flag to @False@ turns off
-- all allocation on resizing: the widget will not even redraw if its position
-- changes; this is to allow containers that don't draw anything to avoid
-- excess invalidations. If you set this flag on a \"no window\" widget that
-- /does/ draw its window, you are responsible for invalidating both
-- the old and new allocation of the widget when the widget is moved and
-- responsible for invalidating regions newly when the widget increases size.
--
widgetSetRedrawOnAllocate :: WidgetClass self => self
-> Bool -- ^ @redrawOnAllocate@ - if @True@, the entire widget will be
-- redrawn when it is allocated to a new size. Otherwise, only the
-- new portion of the widget will be redrawn.
-> IO ()
widgetSetRedrawOnAllocate self redrawOnAllocate =
{# call gtk_widget_set_redraw_on_allocate #}
(toWidget self)
(fromBool redrawOnAllocate)
-- | Sets a widgets composite name. A child widget of a container is
-- composite if it serves as an internal widget and, thus, is not
-- added by the user.
--
widgetSetCompositeName :: (WidgetClass self, GlibString string) => self
-> string -- ^ @name@ - the name to set.
-> IO ()
widgetSetCompositeName self name =
withUTFString name $ \namePtr ->
{# call gtk_widget_set_composite_name #}
(toWidget self)
namePtr
-- | Emits the “mnemonic-activate” signal.
--
-- The default handler for this signal activates the widget if groupCycling
-- is @False@, and just grabs the focus if @groupCycling@ is @True@.
widgetMnemonicActivate :: WidgetClass self => self
-> Bool
-> IO Bool
widgetMnemonicActivate self groupCycling =
liftM toBool $
{# call widget_mnemonic_activate #}
(toWidget self)
(fromBool groupCycling)
#if GTK_MAJOR_VERSION < 3
-- %hash c:5c58 d:6895
-- | For widgets that support scrolling, sets the scroll adjustments and
-- returns @True@. For widgets that don't support scrolling, does nothing and
-- returns @False@. Widgets that don't support scrolling can be scrolled by
-- placing them in a 'Viewport', which does support scrolling.
--
-- Removed in Gtk3.
widgetSetScrollAdjustments :: WidgetClass self => self
-> Maybe Adjustment -- ^ @hadjustment@ - an adjustment for horizontal scrolling, or
-- @Nothing@
-> Maybe Adjustment -- ^ @vadjustment@ - an adjustment for vertical scrolling, or
-- @Nothing@
-> IO Bool -- ^ returns @True@ if the widget supports scrolling
widgetSetScrollAdjustments self hadjustment vadjustment =
liftM toBool $
{# call gtk_widget_set_scroll_adjustments #}
(toWidget self)
(fromMaybe (Adjustment nullForeignPtr) hadjustment)
(fromMaybe (Adjustment nullForeignPtr) vadjustment)
#endif
#if GTK_MAJOR_VERSION < 3
-- | Computes the intersection of a widget's area and @region@, returning
-- the intersection. The result may be empty, use
-- 'Graphics.UI.Gtk.Gdk.Region.regionEmpty' to check.
--
widgetRegionIntersect :: WidgetClass self => self
-> Region -- ^ @region@ - a 'Region' in the same coordinate system as the
-- widget's allocation. That is, relative to the widget's
-- 'DrawWindow' for 'NoWindow' widgets; relative to the parent
-- 'DrawWindow' of the widget's 'DrawWindow' for widgets with
-- their own 'DrawWindow'.
-> IO Region -- ^ returns A region holding the intersection of the widget and
-- @region@. The coordinates of the return value are relative to
-- the widget's 'DrawWindow', if it has one, otherwise
-- it is relative to the parent's 'DrawWindow'.
widgetRegionIntersect self region = do
intersectionPtr <- {# call gtk_widget_region_intersect #}
(toWidget self)
region
makeNewRegion intersectionPtr
#endif
-- %hash c:3c94 d:cdb6
-- | Returns the accessible object that describes the widget to an assistive
-- technology.
--
-- If no accessibility library is loaded (i.e. no ATK implementation library
-- is loaded via GTK_MODULES or via another application library, such as
-- libgnome), then this 'Object' instance may be a no-op. Likewise, if no
-- class-specific 'Object' implementation is available for the widget instance
-- in question, it will inherit an 'Object' implementation from the first
-- ancestor class for which such an implementation is defined.
--
-- The documentation of the ATK library contains more information about
-- accessible objects and their uses.
--
-- Returns a GObject in Gtk3.
widgetGetAccessible :: WidgetClass self => self
#if GTK_MAJOR_VERSION < 3
-> IO Object -- ^ returns the 'Object' associated with @widget@
#else
-> IO GObject -- ^ returns the 'GObject' associated with @widget@
#endif
widgetGetAccessible self =
#if GTK_MAJOR_VERSION < 3
makeNewGObject mkObject $
#else
makeNewGObject mkGObject $
#endif
liftM castPtr $
{# call gtk_widget_get_accessible #}
(toWidget self)
-- %hash c:713d d:c4fc
-- | This function is used by custom widget implementations; if you\'re
-- writing an app, you\'d use 'widgetGrabFocus' to move the focus to a
-- particular widget, and 'containerSetFocusChain' to change the focus tab
-- order. So you may want to investigate those functions instead.
--
-- The \"focus\" default handler for a widget should return @True@ if moving
-- in @direction@ left the focus on a focusable location inside that widget,
-- and @False@ if moving in @direction@ moved the focus outside the widget. If
-- returning @True@, widgets normally call 'widgetGrabFocus' to place the focus
-- accordingly; if returning @False@, they don't modify the current focus
-- location.
--
widgetChildFocus :: WidgetClass self => self
-> DirectionType -- ^ @direction@ - direction of focus movement
-> IO Bool -- ^ returns @True@ if focus ended up inside @widget@
widgetChildFocus self direction =
liftM toBool $
{# call gtk_widget_child_focus #}
(toWidget self)
((fromIntegral . fromEnum) direction)
-- %hash c:de20 d:5300
-- | Gets the value set with 'widgetSetChildVisible'. If you feel a need to
-- use this function, your code probably needs reorganization.
--
-- This function is only useful for container implementations and never
-- should be called by an application.
--
widgetGetChildVisible :: WidgetClass self => self
-> IO Bool -- ^ returns @True@ if the widget is mapped with the parent.
widgetGetChildVisible self =
liftM toBool $
{# call gtk_widget_get_child_visible #}
(toWidget self)
-- %hash c:9320 d:367
-- | Returns the parent container of @widget@.
--
-- * Returns the parent container of @widget@ if it has one.
--
widgetGetParent :: WidgetClass self => self
-> IO (Maybe Widget)
widgetGetParent self = do
parentPtr <- {# call gtk_widget_get_parent #} (toWidget self)
if parentPtr==nullPtr then return Nothing else
liftM Just $ makeNewObject mkWidget (return parentPtr)
-- %hash c:85e3 d:a962
-- | Gets the settings object holding the settings (global property settings,
-- RC file information, etc) used for this widget.
--
-- Note that this function can only be called when the 'Widget' is attached
-- to a toplevel, since the settings object is specific to a particular
-- 'Screen'.
--
widgetGetSettings :: WidgetClass self => self
-> IO Settings -- ^ returns the relevant 'Settings' object
widgetGetSettings self =
makeNewGObject mkSettings $
{# call gtk_widget_get_settings #}
(toWidget self)
#if GTK_CHECK_VERSION(2,2,0)
-- | Returns the clipboard object for the given selection to
-- be used with widget. widget must have a 'Display'
-- associated with it, so must be attached to a toplevel
-- window.
widgetGetClipboard :: WidgetClass self => self
-> SelectionTag -- ^ @selection@ a 'Atom' which identifies the clipboard
-- to use. 'selectionClipboard' gives the
-- default clipboard. Another common value
-- is 'selectionPrimary', which gives
-- the primary X selection.
-> IO Clipboard -- ^ returns the appropriate clipboard object. If no
-- clipboard already exists, a new one will
-- be created.
widgetGetClipboard self (Atom tagPtr) =
makeNewGObject mkClipboard $
{#call gtk_widget_get_clipboard #}
(toWidget self)
tagPtr
-- %hash c:45ed d:52ef
-- | Get the 'Display' for the toplevel window associated with this widget.
-- This function can only be called after the widget has been added to a widget
-- hierarchy with a 'Window' at the top.
--
-- In general, you should only create display specific resources when a
-- widget has been realized, and you should free those resources when the
-- widget is unrealized.
--
-- * Available since Gtk+ version 2.2
--
widgetGetDisplay :: WidgetClass self => self
-> IO Display -- ^ returns the 'Display' for the toplevel for this widget.
widgetGetDisplay self =
makeNewGObject mkDisplay $
{# call gtk_widget_get_display #}
(toWidget self)
-- %hash c:8e4e d:252b
-- | Get the root window where this widget is located. This function can only
-- be called after the widget has been added to a widget heirarchy with
-- 'Window' at the top.
--
-- The root window is useful for such purposes as creating a popup
-- 'DrawWindow' associated with the window. In general, you should only create
-- display specific resources when a widget has been realized, and you should
-- free those resources when the widget is unrealized.
--
-- * Available since Gtk+ version 2.2
--
widgetGetRootWindow :: WidgetClass self => self
-> IO DrawWindow -- ^ returns the 'DrawWindow' root window for the toplevel
-- for this widget.
widgetGetRootWindow self =
makeNewGObject mkDrawWindow $
{# call gtk_widget_get_root_window #}
(toWidget self)
-- %hash c:b929 d:67f0
-- | Get the 'Screen' from the toplevel window associated with this widget.
-- This function can only be called after the widget has been added to a widget
-- hierarchy with a 'Window' at the top.
--
-- In general, you should only create screen specific resources when a
-- widget has been realized, and you should free those resources when the
-- widget is unrealized.
--
-- * Available since Gtk+ version 2.2
--
widgetGetScreen :: WidgetClass self => self
-> IO Screen -- ^ returns the 'Screen' for the toplevel for this widget.
widgetGetScreen self =
makeNewGObject mkScreen $
{# call gtk_widget_get_screen #}
(toWidget self)
-- %hash c:4fab d:aae2
-- | Checks whether there is a 'Screen' is associated with this widget. All
-- toplevel widgets have an associated screen, and all widgets added into a
-- heirarchy with a toplevel window at the top.
--
-- * Available since Gtk+ version 2.2
--
widgetHasScreen :: WidgetClass self => self
-> IO Bool -- ^ returns @True@ if there is a 'Screen' associcated with the
-- widget.
widgetHasScreen self =
liftM toBool $
{# call gtk_widget_has_screen #}
(toWidget self)
#endif
-- %hash c:dabc d:8275
-- | Gets the size request that was explicitly set for the widget using
-- 'widgetSetSizeRequest'. A value of -1 for @width@ or @height@
-- indicates that that dimension has not been set explicitly and the natural
-- requisition of the widget will be used intead. See 'widgetSetSizeRequest'.
-- To get the size a widget will actually use, call 'widgetSizeRequest' instead
-- of this function.
--
widgetGetSizeRequest :: WidgetClass self => self
-> IO (Int, Int) -- ^ @(width, height)@
widgetGetSizeRequest self =
alloca $ \widthPtr ->
alloca $ \heightPtr -> do
{# call gtk_widget_get_size_request #}
(toWidget self)
widthPtr
heightPtr
width <- peek widthPtr
height <- peek heightPtr
return (fromIntegral width, fromIntegral height)
#if GTK_CHECK_VERSION(3,0,0)
-- | Retrieves the minimum and natural size of a widget, taking into account the
-- widget’s preference for height-for-width management.
--
-- This is used to retrieve a suitable size by container widgets which do not
-- impose any restrictions on the child placement. It can be used to deduce
-- toplevel window and menu sizes as well as child widgets in free-form containers
-- such as GtkLayout.
--
-- Handle with care. Note that the natural height of a height-for-width widget
-- will generally be a smaller size than the minimum height, since the required
-- height for the natural width is generally smaller than the required height for
-- the minimum width.
--
-- Use gtk_widget_get_preferred_height_and_baseline_for_width() if you want
-- to support baseline alignment.
--
-- * Available since Gtk+ version 3.0
--
widgetGetPreferredSize :: WidgetClass self => self
-> IO (Requisition, Requisition) -- ^ @(minimumSize, naturalSize)@
widgetGetPreferredSize self =
alloca $ \minReqPtr ->
alloca $ \natReqPtr -> do
{#call gtk_widget_get_preferred_size #} (toWidget self) (castPtr minReqPtr) (castPtr natReqPtr)
min <- peek minReqPtr
nat <- peek natReqPtr
return (min, nat)
#endif
-- %hash c:546d d:3c7f
-- | Sets whether @widget@ should be mapped along with its when its parent is
-- mapped and @widget@ has been shown with 'widgetShow'.
--
-- The child visibility can be set for widget before it is added to a
-- container with 'widgetSetParent', to avoid mapping children unnecessary
-- before immediately unmapping them. However it will be reset to its default
-- state of @True@ when the widget is removed from a container.
--
-- Note that changing the child visibility of a widget does not queue a
-- resize on the widget. Most of the time, the size of a widget is computed
-- from all visible children, whether or not they are mapped. If this is not
-- the case, the container can queue a resize itself.
--
-- This function is only useful for container implementations and never
-- should be called by an application.
--
widgetSetChildVisible :: WidgetClass self => self
-> Bool -- ^ @isVisible@ - if @True@, @widget@ should be mapped along with
-- its parent.
-> IO ()
widgetSetChildVisible self isVisible =
{# call gtk_widget_set_child_visible #}
(toWidget self)
(fromBool isVisible)
-- | Sets the minimum size of a widget; that is, the widget's size request
-- will be @width@ by @height@. You can use this function to force a widget to
-- be either larger or smaller than it normally would be.
--
-- In most cases, 'Graphics.UI.Gtk.Windows.Window.windowSetDefaultSize'
-- is a better choice for toplevel
-- windows than this function; setting the default size will still allow users
-- to shrink the window. Setting the size request will force them to leave the
-- window at least as large as the size request. When dealing with window
-- sizes, 'Graphics.UI.Gtk.Windows.Window.windowSetGeometryHints' can be a
-- useful function as well.
--
-- Note the inherent danger of setting any fixed size - themes, translations
-- into other languages, different fonts, and user action can all change the
-- appropriate size for a given widget. So, it's basically impossible to
-- hardcode a size that will always be correct.
--
-- The size request of a widget is the smallest size a widget can accept
-- while still functioning well and drawing itself correctly. However in some
-- strange cases a widget may be allocated less than its requested size, and in
-- many cases a widget may be allocated more space than it requested.
--
-- If the size request in a given direction is -1 (unset), then the
-- \"natural\" size request of the widget will be used instead.
--
-- Widgets can't actually be allocated a size less than 1 by 1, but you can
-- pass 0,0 to this function to mean \"as small as possible.\"
--
widgetSetSizeRequest :: WidgetClass self => self
-> Int -- ^ @width@ - width @widget@ should request, or -1 to unset
-> Int -- ^ @height@ - height @widget@ should request, or -1 to unset
-> IO ()
widgetSetSizeRequest self width height =
{# call widget_set_size_request #}
(toWidget self)
(fromIntegral width)
(fromIntegral height)
#if GTK_CHECK_VERSION(2,4,0)
-- %hash c:83c3 d:e6f1
-- | Sets the 'noShowAll' property, which determines whether calls to
-- 'widgetShowAll' and 'widgetHideAll' will affect this widget.
--
-- This is mostly for use in constructing widget hierarchies with externally
-- controlled visibility, see 'UIManager'.
--
-- * Available since Gtk+ version 2.4
--
widgetSetNoShowAll :: WidgetClass self => self
-> Bool -- ^ @noShowAll@ - the new value for the 'noShowAll' property
-> IO ()
widgetSetNoShowAll self noShowAll =
{# call gtk_widget_set_no_show_all #}
(toWidget self)
(fromBool noShowAll)
-- %hash c:218d d:e07e
-- | Returns the current value of the 'noShowAll' property, which
-- determines whether calls to 'widgetShowAll' and 'widgetHideAll' will affect
-- this widget.
--
-- * Available since Gtk+ version 2.4
--
widgetGetNoShowAll :: WidgetClass self => self
-> IO Bool -- ^ returns the current value of the \"no_show_all\" property.
widgetGetNoShowAll self =
liftM toBool $
{# call gtk_widget_get_no_show_all #}
(toWidget self)
-- %hash c:205b d:c518
-- | Returns a list of the widgets, normally labels, for which
-- this widget is a the target of a mnemonic (see for example,
-- 'labelSetMnemonicWidget').
--
-- * Available since Gtk+ version 2.4
--
widgetListMnemonicLabels :: WidgetClass self => self
-> IO [Widget] -- ^ returns the list of mnemonic labels
widgetListMnemonicLabels self =
{# call gtk_widget_list_mnemonic_labels #}
(toWidget self)
>>= fromGList
>>= mapM (makeNewGObject mkWidget . return)
-- %hash c:eb76 d:28a2
-- | Adds a widget to the list of mnemonic labels for this widget. (See
-- 'widgetListMnemonicLabels'). Note the list of mnemonic labels for the widget
-- is cleared when the widget is destroyed, so the caller must make sure to
-- update its internal state at this point as well, by using a connection to
-- the 'destroy' signal or a weak notifier.
--
-- * Available since Gtk+ version 2.4
--
widgetAddMnemonicLabel :: (WidgetClass self, WidgetClass label) => self
-> label -- ^ @label@ - a 'Widget' that acts as a mnemonic label for
-- @widget@.
-> IO ()
widgetAddMnemonicLabel self label =
{# call gtk_widget_add_mnemonic_label #}
(toWidget self)
(toWidget label)
-- %hash c:7831 d:d10b
-- | Removes a widget from the list of mnemonic labels for this widget. (See
-- 'widgetListMnemonicLabels'). The widget must have previously been added to
-- the list with 'widgetAddMnemonicLabel'.
--
-- * Available since Gtk+ version 2.4
--
widgetRemoveMnemonicLabel :: (WidgetClass self, WidgetClass label) => self
-> label -- ^ @label@ - a 'Widget' that was previously set as a mnemnic label
-- for @widget@ with 'widgetAddMnemonicLabel'.
-> IO ()
widgetRemoveMnemonicLabel self label =
{# call gtk_widget_remove_mnemonic_label #}
(toWidget self)
(toWidget label)
#if GTK_CHECK_VERSION(2,10,0)
#if GTK_MAJOR_VERSION < 3
-- %hash c:5c70 d:cbf9
-- | Returns the 'Action' that @widget@ is a proxy for. See also
-- 'actionGetProxies'.
--
-- * Available since Gtk+ version 2.10
--
-- Removed in Gtk3.
widgetGetAction :: WidgetClass self => self
-> IO (Maybe Action)
-- ^ returns the action that a widget is a proxy for, or
-- @Nothing@, if it is not attached to an action.
widgetGetAction self = do
ptr <- {# call gtk_widget_get_action #} (toWidget self)
if ptr==nullPtr then return Nothing else liftM Just $
makeNewGObject mkAction (return ptr)
#endif
-- %hash c:7ea0 d:2560
-- | Whether @widget@ can rely on having its alpha channel drawn correctly. On
-- X11 this function returns whether a compositing manager is running for
-- @widget@'s screen
--
-- * Available since Gtk+ version 2.10
--
widgetIsComposited :: WidgetClass self => self
-> IO Bool -- ^ returns @True@ if the widget can rely on its alpha channel
-- being drawn correctly.
widgetIsComposited self =
liftM toBool $
{# call gtk_widget_is_composited #}
(toWidget self)
#endif
#endif
#if GTK_CHECK_VERSION(2,12,0)
-- | Notifies the user about an input-related error on this widget.
-- If the "gtk-error-bell" setting is @True@, it calls 'drawWindowBeep',
-- otherwise it does nothing.
--
-- Note that the effect of 'drawWindow_beep' can be configured in many
-- ways, depending on the windowing backend and the desktop environment
-- or window manager that is used.
widgetErrorBell :: WidgetClass self => self
-> IO ()
widgetErrorBell self =
{# call widget_error_bell #}
(toWidget self)
-- | This function should be called whenever keyboard navigation within
-- a single widget hits a boundary. The function emits the "keynav-failed"
-- signal on the widget and its return value should be interpreted in a
-- way similar to the return value of 'widgetChildFocus':
--
-- When @True@ is returned, stay in the widget, the failed keyboard
-- navigation is Ok and/or there is nowhere we can/should move the
-- focus to.
--
-- When @False@ is returned, the caller should continue with keyboard
-- navigation outside the widget, e.g. by calling 'widgetChildFocus' on
-- the widget’s toplevel.
--
-- The default ::keynav-failed handler returns @True@ for 'DirTabForward'
-- and 'DirTabBackward'. For the other values of 'DirectionType' it
-- returns @False@.
--
-- Whenever the default handler returns @True@, it also calls
-- 'widgetErrorBell' to notify the user of the failed keyboard
-- navigation.
--
-- A use case for providing an own implementation of ::keynav-failed
-- (either by connecting to it or by overriding it) would be a row of
-- 'Entry' widgets where the user should be able to navigate the entire
-- row with the cursor keys, as e.g. known from user interfaces that
-- require entering license keys.
widgetKeynavFailed :: WidgetClass self => self
-> DirectionType -- ^ @direction@ - direction of focus movement
-> IO Bool -- ^ returns @True@ if stopping keyboard navigation is
-- fine, @False@ if the emitting widget should try to handle
-- the keyboard navigation attempt in its parent container(s).
widgetKeynavFailed self direction =
liftM toBool $
{# call widget_keynav_failed #}
(toWidget self)
((fromIntegral . fromEnum) direction)
-- | Gets the contents of the tooltip for widget.
widgetGetTooltipMarkup :: (WidgetClass self, GlibString markup) => self
-> IO (Maybe markup) -- Returns the tooltip text, or Nothing.
widgetGetTooltipMarkup self =
{# call widget_get_tooltip_markup #}
(toWidget self)
>>= maybePeek peekUTFString
-- | Sets @markup@ as the contents of the tooltip, which is marked up with the
-- Pango text markup language.
--
-- This function will take care of setting "has-tooltip" to True and of the
-- default handler for the "query-tooltip" signal.
--
-- See also the "tooltip-markup" property and 'tooltipSetMarkup'.
widgetSetTooltipMarkup :: (WidgetClass self, GlibString markup) => self
-> Maybe markup -- ^ the contents of the tooltip for widget, or @Nothing@.
-> IO ()
widgetSetTooltipMarkup self markup =
maybeWith withUTFString markup $ \ markupPtr ->
{# call widget_set_tooltip_markup #}
(toWidget self)
markupPtr
-- | Gets the contents of the tooltip for widget.
widgetGetTooltipText :: (WidgetClass self, GlibString text) => self
-> IO (Maybe text) -- Returns the tooltip text, or Nothing.
widgetGetTooltipText self =
{# call widget_get_tooltip_text #}
(toWidget self)
>>= maybePeek peekUTFString
-- | Sets @text@ as the contents of the tooltip. This function will take care
-- of setting "has-tooltip" to @True@ and of the default handler for the
-- "query-tooltip" signal.
--
-- See also the "tooltip-text" property and 'tooltipSetText'.
widgetSetTooltipText :: (WidgetClass widget, GlibString text) => widget
-> Maybe text -- ^ the contents of the tooltip for widget, or @Nothing@.
-> IO ()
widgetSetTooltipText widget text =
maybeWith withUTFString text $ \ textPtr ->
{# call widget_set_tooltip_text #}
(toWidget widget)
textPtr
-- | Returns the 'Window' of the current tooltip. This can be the 'Window' created by default, or the
-- custom tooltip window set using 'widgetSetTooltipWindow'.
--
-- * Available since Gtk+ version 2.12
--
widgetGetTooltipWindow :: WidgetClass self => self
-> IO Window -- ^ returns The 'Window' of the current tooltip
widgetGetTooltipWindow self =
makeNewObject mkWindow $
{# call gtk_widget_get_tooltip_window #}
(toWidget self)
-- | Replaces the default, usually yellow, window used for displaying tooltips with @customWindow@. GTK+
-- will take care of showing and hiding @customWindow@ at the right moment, to behave likewise as the
-- default tooltip window. If @customWindow@ is 'Nothing', the default tooltip window will be used.
--
-- If the custom window should have the default theming it needs to have the name 'gtk-tooltip', see
-- 'widgetSetName'.
--
-- * Available since Gtk+ version 2.12
--
widgetSetTooltipWindow :: (WidgetClass self, WindowClass customWindow) => self
-> Maybe customWindow -- ^ @customWindow@ a 'Window', or 'Nothing'. allow-none.
-> IO ()
widgetSetTooltipWindow self customWindow =
{# call gtk_widget_set_tooltip_window #}
(toWidget self)
(maybe (Window nullForeignPtr) toWindow customWindow)
-- | Returns the current value of the has-tooltip property.
-- See 'widgetHasTooltip' for more information.
widgetGetHasTooltip :: WidgetClass widget => widget
-> IO Bool -- ^ current value of 'widgetHasTooltip' on @widget@.
widgetGetHasTooltip widget =
liftM toBool $
{# call widget_get_has_tooltip #}
(toWidget widget)
-- | Sets the has-tooltip property on @widget@ to @hasTooltip@.
-- See 'widgetHasTooltip' for more information.
widgetSetHasTooltip :: WidgetClass widget => widget
-> Bool -- ^ @hasTooltip@ whether or not @widget@ has a tooltip.
-> IO ()
widgetSetHasTooltip widget hasTooltip =
{# call widget_set_has_tooltip #}
(toWidget widget)
(fromBool hasTooltip)
-- | Triggers a tooltip query on the display where the toplevel of @widget@ is
-- located. See 'tooltipTriggerTooltipQuery' for more information.
--
-- * Available since Gtk+ version 2.12
--
widgetTriggerTooltipQuery :: WidgetClass self => self -> IO ()
widgetTriggerTooltipQuery self =
{# call gtk_widget_trigger_tooltip_query #}
(toWidget self)
#endif
#if GTK_CHECK_VERSION(2,14,0)
-- | Returns the widget's window if it is realized, Nothing otherwise
--
-- * Available since Gtk+ version 2.14
--
widgetGetWindow :: WidgetClass self => self -> IO (Maybe DrawWindow)
widgetGetWindow self =
maybeNull (makeNewGObject mkDrawWindow) $
{# call gtk_widget_get_window #}
(toWidget self)
#endif
#if GTK_CHECK_VERSION(3,8,0)
-- | Registers a 'DrawWindow' with the widget and sets it up so that the
-- widget receives events for it. Call 'widgetUnregisterWindow' when
-- destroying the window.
widgetRegisterWindow :: (WidgetClass widget, DrawWindowClass window) => widget
-> window
-> IO ()
widgetRegisterWindow widget window =
{# call widget_register_window #}
(toWidget widget)
(toDrawWindow window)
-- | Unregisters a 'DrawWindow' from the widget that was previously set up
-- with 'widgetRegisterWindow'. You need to call this when the window is no
-- longer used by the widget, such as when you destroy it.
widgetUnregisterWindow :: (WidgetClass widget, DrawWindowClass window) => widget
-> window
-> IO ()
widgetUnregisterWindow widget window =
{# call widget_unregister_window #}
(toWidget widget)
(toDrawWindow window)
#endif
#if GTK_CHECK_VERSION(3,0,0)
-- | This function is supposed to be called in "draw" implementations for
-- widgets that support multiple windows. @cr@ must be untransformed from
-- invoking of the draw function. This function will return @True@ if the
-- contents of the given @window@ are supposed to be drawn and @False@
-- otherwise. Note that when the drawing was not initiated by the windowing
-- system this function will return @True@ for all windows, so you need to
-- draw the bottommost window first. Also, do not use “else if” statements to
-- check which window should be drawn.
cairoShouldDrawWindow :: DrawWindowClass window
=> Cairo -- ^ @cr@ a cairo context
-> window -- ^ @window@ the window to check. @window@ may not be an input-only window.
-> IO Bool
cairoShouldDrawWindow cr window =
liftM toBool $
{# call cairo_should_draw_window #}
(castPtr $ unCairo cr)
(toDrawWindow window)
-- | Transforms the given cairo context @cr@ that from @widget@-relative
-- coordinates to @window@-relative coordinates. If the @widget@’s window is
-- not an ancestor of @window@, no modification will be applied.
--
-- This is the inverse to the transformation GTK applies when preparing an
-- expose event to be emitted with the “draw” signal. It is intended to help
-- porting multiwindow widgets from GTK+ 2 to the rendering architecture of
-- GTK+ 3.
cairoTransformToWindow :: (WidgetClass widget, DrawWindowClass window)
=> Cairo -- ^ @cr@ the cairo context to transform
-> widget -- ^ @widget@ the widget the context is currently centered for
-> window -- ^ @window@ the window to transform the context to
-> IO ()
cairoTransformToWindow cr widget window =
{# call gtk_cairo_transform_to_window #}
(castPtr $ unCairo cr)
(toWidget widget)
(toDrawWindow window)
#endif
-- | Moves a widget from one 'Container' to another.
--
widgetReparent :: (WidgetClass self, WidgetClass newParent) => self
-> newParent -- ^ @newParent@ - a 'Container' to move the widget into
-> IO ()
widgetReparent self newParent =
{# call widget_reparent #}
(toWidget self)
(toWidget newParent)
#if GTK_CHECK_VERSION(2,18,0)
-- | Set if this widget can receive keyboard input.
--
-- * To use the 'keyPress' event, the widget must be allowed
-- to get the input focus. Once it has the input focus all keyboard
-- input is directed to this widget.
--
widgetSetCanFocus :: WidgetClass self => self -> Bool -> IO ()
widgetSetCanFocus = objectSetPropertyBool "can_focus"
-- | Check if this widget can receive keyboard input.
--
widgetGetCanFocus :: WidgetClass self => self -> IO Bool
widgetGetCanFocus = objectGetPropertyBool "can_focus"
-- | Retrieves the widget's allocation.
--
-- * Available since Gtk+ version 2.18
--
widgetGetAllocation :: WidgetClass self => self -> IO Allocation
widgetGetAllocation widget =
alloca $ \ allocationPtr -> do
{#call widget_get_allocation#} (toWidget widget) (castPtr allocationPtr)
peek allocationPtr
#endif
#if GTK_CHECK_VERSION(3,0,0)
-- | Returns the width that has currently been allocated to widget. This function is intended
-- | to be used when implementing handlers for the "draw" function.
widgetGetAllocatedWidth :: WidgetClass self => self -> IO Int
widgetGetAllocatedWidth widget =
liftM fromIntegral $ {#call widget_get_allocated_width#} (toWidget widget)
-- | Returns the height that has currently been allocated to widget. This function is intended
-- | to be used when implementing handlers for the "draw" function.
widgetGetAllocatedHeight :: WidgetClass self => self -> IO Int
widgetGetAllocatedHeight widget =
liftM fromIntegral $ {#call widget_get_allocated_height#} (toWidget widget)
#endif
#if GTK_CHECK_VERSION(3,10,0)
-- | Returns the baseline that has currently been allocated to widget . This function is intended
-- to be used when implementing handlers for the “draw” function, and when allocating child
-- widgets in “size_allocate”.
widgetGetAllocatedBaseline :: WidgetClass self => self -> IO Int
widgetGetAllocatedBaseline widget =
liftM fromIntegral $ {#call widget_get_allocated_baseline#} (toWidget widget)
#endif
#if GTK_CHECK_VERSION(3,14,0)
-- | Retrieves the widget’s clip area.
--
-- The clip area is the area in which all of widget's drawing will happen. Other
-- toolkits call it the bounding box.
--
-- Historically, in GTK+ the clip area has been equal to the allocation retrieved
-- via widgetGetAllocation.
widgetGetClip :: WidgetClass self => self -> IO Allocation
widgetGetClip widget =
alloca $ \ allocationPtr -> do
{#call widget_get_clip#} (toWidget widget) (castPtr allocationPtr)
peek allocationPtr
-- | Sets the widget’s clip. This must not be used directly, but from within a widget’s 'sizeAllocate' method.
--
-- The clip set should be the area that widget draws on. If widget is a GtkContainer, the area
-- must contain all children's clips.
--
-- If this function is not called by widget during a 'sizeAllocate' handler, it is assumed to be
-- equal to the allocation. However, if the function is not called, certain features that might extend
-- a widget's allocation will not be available:
--
-- * The “draw” signal will be clipped to the widget's allocation to avoid overdraw.
--
-- * Calling gtk_render_background() will not draw outset shadows.
--
-- It is therefore suggested that you always call widgetSetClip during a 'sizeAllocate' handler.
widgetSetClip :: WidgetClass self => self
-> Allocation
-> IO ()
widgetSetClip self clip = with clip $ \clipPtr ->
{#call widget_set_clip#} (toWidget self) (castPtr clipPtr)
#endif
#if GTK_CHECK_VERSION(2,18,0)
-- | Determines whether the application intends to draw on the widget in an
-- "draw" handler.
-- See 'widgetSetAppPaintable'.
widgetGetAppPaintable :: WidgetClass widget => widget
-> IO Bool -- ^ Returns @True@ if the @widget@ is app paintable.
widgetGetAppPaintable widget =
liftM toBool $
{#call widget_get_app_paintable #}
(toWidget widget)
-- | Determines whether @widget@ can be a default widget.
-- See 'widgetSetCanDefault'.
widgetGetCanDefault :: WidgetClass widget => widget
-> IO Bool -- ^ Returns @True@ if @widget@ can be a default widget, @False@ otherwise.
widgetGetCanDefault widget =
liftM toBool $
{#call gtk_widget_get_can_default #}
(toWidget widget)
-- | Specifies whether @widget@ can be a default widget.
-- See 'widgetGrabDefault' for details about the meaning of "default".
widgetSetCanDefault :: WidgetClass widget => widget
-> Bool -- ^ @canDefault@ whether or not @widget@ can be a default widget.
-> IO ()
widgetSetCanDefault widget canDefault =
{# call widget_set_can_default #}
(toWidget widget)
(fromBool canDefault)
-- | Determines whether @widget@ has a 'DrawWindow' of its own. See 'widgetSetHasWindow'.
widgetGetHasWindow :: WidgetClass widget => widget
-> IO Bool -- ^ Returns @True@ if @widget@ has a window, @False@ otherwise.
widgetGetHasWindow widget =
liftM toBool $
{#call widget_get_has_window #}
(toWidget widget)
-- | Specifies whether @widget@ has a 'DrawWindow' of its own. Note that all
-- realized widgets have a non-NULL "window" pointer ('widgetGetWindow' never
-- returns a NULL window when a widget is realized), but for many of them it's
-- actually the 'DrawWindow' of one of its parent widgets. Widgets that do not
-- create a window for themselves in "realize" must announce this by calling
-- this function with @hasWindow@ = @False@.
--
-- This function should only be called by widget implementations, and they
-- should call it in their @init()@ function.
widgetSetHasWindow :: WidgetClass widget => widget
-> Bool -- ^ @hasWindow@ whether or not @widget@ has a window.
-> IO ()
widgetSetHasWindow widget hasWindow =
{# call widget_set_has_window #}
(toWidget widget)
(fromBool hasWindow)
-- | Returns the @widget@’s sensitivity (in the sense of returning the value
-- that has been set using 'widgetSetSensitive').
--
-- The effective sensitivity of a widget is however determined by both its own
-- and its parent widget’s sensitivity. See 'widgetIsSensitive'.
widgetGetSensitive :: WidgetClass widget => widget
-> IO Bool -- ^ Returns @True@ if the widget is sensitive.
widgetGetSensitive widget =
liftM toBool $
{#call widget_get_sensitive #}
(toWidget widget)
-- | Returns the widget’s effective sensitivity, which means it is sensitive
-- itself and also its parent widget is sensitive.
widgetIsSensitive :: WidgetClass widget => widget
-> IO Bool -- ^ Returns @True@ if the widget is effectively sensitive.
widgetIsSensitive widget =
liftM toBool $
{#call widget_is_sensitive #}
(toWidget widget)
-- | Retrieve the current state of the widget.
--
-- * The state refers to different modes of user interaction, see
-- 'StateType' for more information.
--
widgetGetState :: WidgetClass self => self -> IO StateType
widgetGetState widget =
liftM (toEnum . fromIntegral) $
{#call widget_get_state#}
(toWidget widget)
-- | Determines whether the widget is visible. If you want to take into
-- account whether the widget’s parent is also marked as visible, use
-- 'widgetIsVisible' instead.
--
-- This function does not check if the widget is obscured in any way.
-- See 'widgetSetVisible'.
widgetGetVisible :: WidgetClass widget => widget
-> IO Bool -- ^ Returns @True@ if the widget is visible.
widgetGetVisible widget =
liftM toBool $
{#call widget_get_visible #}
(toWidget widget)
#endif
#if GTK_CHECK_VERSION(3,8,0)
-- | Determines whether the widget and all its parents are marked as visible.
--
-- This function does not check if the widget is obscured in any way.
--
-- See also 'widgetGetVisible' and 'widgetSetVisible'
widgetIsVisible :: WidgetClass widget => widget
-> IO Bool -- ^ Returns @True@ if the widget and all its parents are visible.
widgetIsVisible widget =
liftM toBool $
{#call widget_is_visible #}
(toWidget widget)
#endif
#if GTK_CHECK_VERSION(3,0,0)
-- | This function is for use in widget implementations. Turns on flag values
-- in the current widget state (insensitive, prelighted, etc.).
--
-- This function accepts the values 'StateFlagDirLtr' and 'StateFlagDirRtl'
-- but ignores them. If you want to set the widget's direction, use
-- 'widgetSetDirection'.
--
-- It is worth mentioning that any other state than StateFlagInsensitive',
-- will be propagated down to all non-internal children if @widget@ is a
-- 'Container', while 'StateFlagInsensitive' itself will be propagated down
-- to all 'Container' children by different means than turning on the state
-- flag down the hierarchy, both 'widgetGetStateFlags' and
-- 'widgetIsSensitive' will make use of these.
widgetSetStateFlags :: WidgetClass widget => widget
-> [StateFlags] -- ^ @flags@ State flags to turn on
-> Bool -- ^ @clear@ Whether to clear state before turning on @flags@
-> IO ()
widgetSetStateFlags widget flags clear =
{# call widget_set_state_flags #}
(toWidget widget)
(fromIntegral $ fromFlags flags)
(fromBool clear)
-- | This function is for use in widget implementations. Turns off flag
-- values for the current widget state (insensitive, prelighted, etc.).
-- See 'widgetSetStateFlags'.
widgetUnsetStateFlags :: WidgetClass widget => widget
-> [StateFlags] -- ^ @flags@ State flags to turn off
-> IO ()
widgetUnsetStateFlags widget flags =
{# call widget_unset_state_flags #}
(toWidget widget)
(fromIntegral $ fromFlags flags)
-- | Returns the widget state as a flag set. It is worth mentioning that the
-- effective StateFlagInsensitive state will be returned, that is, also based
-- on parent insensitivity, even if @widget@ itself is sensitive.
widgetGetStateFlags :: WidgetClass widget => widget
-> IO [StateFlags] -- ^ Returns the state flags for @widget@
widgetGetStateFlags widget =
liftM (toFlags . fromIntegral) $
{# call widget_get_state_flags #}
(toWidget widget)
#endif
#if GTK_CHECK_VERSION(2,18,0)
-- | Determines whether @widget@ is the current default widget within its
-- toplevel. See 'widgetSetCanDefault'.
widgetGetHasDefault :: WidgetClass widget => widget
-> IO Bool -- ^ Returns @True@ if @widget@ is the current default widget within its toplevel, @False@ otherwise.
widgetGetHasDefault widget =
liftM toBool $
{#call widget_has_default #}
(toWidget widget)
-- | Determines if the @widget@ has the global input focus.
-- See 'widgetIsFocus' for the difference between having the global input
-- focus, and only having the focus within a toplevel.
widgetGetHasFocus :: WidgetClass widget => widget
-> IO Bool -- ^ Returns @True@ if @widget@ has the global input focus.
widgetGetHasFocus widget =
liftM toBool $
{#call widget_has_focus #}
(toWidget widget)
#endif
#if GTK_CHECK_VERSION(3,2,0)
-- | Determines if the widget should show a visible indication that it has the
-- global input focus. This is a convenience function for use in ::draw
-- handlers that takes into account whether focus indication should currently
-- be shown in the toplevel window of @widget@. See 'windowGetFocusVisible'
-- for more information about focus indication.
--
-- To find out if the widget has the global input focus, use 'widgetHasFocus'.
widgetHasVisibleFocus :: WidgetClass widget => widget
-> IO Bool -- ^ Returns @True@ if the widget should display a “focus rectangle”
widgetHasVisibleFocus widget =
liftM toBool $
{# call widget_has_visible_focus #}
(toWidget widget)
#endif
#if GTK_CHECK_VERSION(2,18,0)
-- | Determines whether the widget is currently grabbing events, so it is the
-- only widget receiving input events (keyboard and mouse).
--
-- See also 'grabAdd'.
widgetHasGrab :: WidgetClass widget => widget
-> IO Bool -- ^ Returns @True@ if the widget is in the grab_widgets stack
widgetHasGrab widget =
liftM toBool $
{# call widget_has_grab #}
(toWidget widget)
-- | Determines whether @widget@ can be drawn to. A widget can be drawn to if
-- it is mapped and visible.
widgetIsDrawable :: WidgetClass widget => widget
-> IO Bool -- ^ Returns @True@ if @widget@ is drawable, @False@ otherwise
widgetIsDrawable widget =
liftM toBool $
{# call widget_is_drawable #}
(toWidget widget)
-- | Determines whether @widget@ is a toplevel widget.
--
-- Currently only 'Window' and 'Invisible' (and out-of-process 'Plugs') are
-- toplevel widgets. Toplevel widgets have no parent widget.
widgetIsToplevel :: WidgetClass widget => widget
-> IO Bool -- ^ Returns @True@ if @widget@ is a toplevel, @False@ otherwise
widgetIsToplevel widget =
liftM toBool $
{# call widget_is_toplevel #}
(toWidget widget)
-- | Sets a widget’s window. This function should only be used in a widget’s
-- “realize” implementation. The window passed is usually either new window
-- created with 'drawWindowNew', or the window of its parent widget as
-- returned by 'widgetGetParentWindow'.
--
-- Widgets must indicate whether they will create their own 'DrawWindow' by
-- calling 'widgetSetHasWindow'. This is usually done in the widget’s init()
-- function.
--
-- Note that this function does not add any reference to window.
widgetSetWindow :: (WidgetClass widget, DrawWindowClass window) => widget
-> window
-> IO ()
widgetSetWindow widget window =
{# call widget_set_window #}
(toWidget widget)
(toDrawWindow window)
-- | Specifies whether @widget@ will be treated as the default widget within
-- its toplevel when it has the focus, even if another widget is the default.
--
-- See 'widgetGrabDefault' for details about the meaning of “default”.
widgetSetReceivesDefault :: WidgetClass widget => widget
-> Bool -- ^ @receivesDefault@ whether or not widget can be a default widget.
-> IO ()
widgetSetReceivesDefault widget receivesDefault =
{# call widget_set_receives_default #}
(toWidget widget)
(fromBool receivesDefault)
-- | Determines whether @widget@ is always treated as the default widget
-- within its toplevel when it has the focus, even if another widget is the
-- default.
--
-- See 'widgetSetReceivesDefault'.
widgetGetReceivesDefault :: WidgetClass widget => widget
-> IO Bool -- ^ Returns @True@ if @widget@ acts as the default widget when focussed, @False@ otherwise
widgetGetReceivesDefault widget =
liftM toBool $
{# call widget_get_receives_default #}
(toWidget widget)
#endif
#if GTK_CHECK_VERSION(3,0,0)
-- | Returns @True@ if device has been shadowed by a GTK+ device grab on
-- another widget, so it would stop sending events to widget. This may be
-- used in the “grab-notify” signal to check for specific devices.
-- See 'deviceGrabAdd'.
widgetDeviceIsShadowed :: (WidgetClass widget, DeviceClass device) => widget
-> device
-> IO Bool -- ^ Returns @True@ if there is an ongoing grab on device by another 'Widget' than widget.
widgetDeviceIsShadowed widget device =
liftM toBool $
{# call widget_device_is_shadowed #}
(toWidget widget)
(toDevice device)
#endif
#if GTK_CHECK_VERSION(3,4,0)
-- | Returns the modifier mask the @widget@’s windowing system backend uses
-- for a particular purpose.
--
-- See 'keymapGetModifierMask'.
widgetGetModifierMask :: WidgetClass widget => widget
-> ModifierIntent -- ^ @intent@ the use case for the modifier mask
-> IO [Modifier] -- ^ Returns the modifier mask used for @intent@.
widgetGetModifierMask widget intent =
liftM (toFlags . fromIntegral) $
{# call widget_get_modifier_mask #}
(toWidget widget)
((fromIntegral . fromEnum) intent)
#endif
#if GTK_CHECK_VERSION(3,0,0)
-- | Enables or disables multiple pointer awareness. If this setting is
-- @True@, widget will start receiving multiple, per device enter/leave
-- events. Note that if custom 'DrawWindows' are created in “realize”,
-- 'windowSetSupportMultidevice' will have to be called manually on them.
widgetSetSupportMultidevice :: WidgetClass widget => widget
-> Bool -- ^ @supportMultidevice@ @True@ to support input from multiple devices.
-> IO ()
widgetSetSupportMultidevice widget supportMultidevice =
{# call widget_set_support_multidevice #}
(toWidget widget)
(fromBool supportMultidevice)
-- | Returns @True@ if @widget@ is multiple pointer aware.
-- See 'widgetSetSupportMultidevice' for more information.
widgetGetSupportMultidevice :: WidgetClass widget => widget
-> IO Bool -- ^ Returns @True@ if @widget@ is multidevice aware.
widgetGetSupportMultidevice widget =
liftM toBool $
{# call widget_get_support_multidevice #}
(toWidget widget)
#endif
-- | This function is for use in widget implementations. Sets the state of a
-- widget (insensitive, prelighted, etc.) Usually you should set the state
-- using wrapper functions such as 'widgetSetSensitive'.
--
widgetSetState :: WidgetClass self => self -> StateType -> IO ()
widgetSetState widget state =
{#call widget_set_state#}
(toWidget widget)
((fromIntegral . fromEnum) state)
-- | Rarely-used function. This function is used to emit the event signals on a widget (those signals
-- should never be emitted without using this function to do so). If you want to synthesize an event
-- though, don't use this function; instead, use 'mainDoEvent' so the event will behave as if it
-- were in the event queue. Don't synthesize expose events; instead, use 'windowInvalidateRect'
-- to invalidate a region of the window.
widgetEvent :: WidgetClass self => self -> EventM t Bool
widgetEvent widget = do
ptr <- ask
liftIO $ liftM toBool $ {#call widget_event #} (toWidget widget) (castPtr ptr)
--------------------
-- Attributes
-- %hash c:6f7f d:9384
-- | The name of the widget.
--
-- Default value: @Nothing@
--
widgetName :: (WidgetClass self, GlibString string) => Attr self (Maybe string)
widgetName = newAttrFromMaybeStringProperty "name"
widgetMarginLeft :: WidgetClass self => Attr self Int
widgetMarginLeft = newAttrFromIntProperty "margin-left"
widgetMarginRight :: WidgetClass self => Attr self Int
widgetMarginRight = newAttrFromIntProperty "margin-right"
#if GTK_CHECK_VERSION(3,12,0)
widgetMarginStart :: WidgetClass self => Attr self Int
widgetMarginStart = newAttrFromIntProperty "margin-start"
widgetMarginEnd :: WidgetClass self => Attr self Int
widgetMarginEnd = newAttrFromIntProperty "margin-end"
#endif
widgetMarginTop :: WidgetClass self => Attr self Int
widgetMarginTop = newAttrFromIntProperty "margin-top"
widgetMarginBottom :: WidgetClass self => Attr self Int
widgetMarginBottom = newAttrFromIntProperty "margin-bottom"
-- %hash c:1533 d:3213
-- | The parent widget of this widget. Must be a Container widget.
--
widgetParent :: (WidgetClass self, ContainerClass container) => ReadWriteAttr self (Maybe Container) (Maybe container)
widgetParent = newAttrFromMaybeObjectProperty "parent" gTypeContainer
-- %hash c:2b4c d:3c31
-- | Override for width request of the widget, or -1 if natural request should
-- be used.
--
-- Allowed values: >= -1
--
-- Default value: -1
--
widgetWidthRequest :: WidgetClass self => Attr self Int
widgetWidthRequest = newAttrFromIntProperty "width-request"
-- %hash c:fa97 d:172a
-- | Override for height request of the widget, or -1 if natural request
-- should be used.
--
-- Allowed values: >= -1
--
-- Default value: -1
--
widgetHeightRequest :: WidgetClass self => Attr self Int
widgetHeightRequest = newAttrFromIntProperty "height-request"
-- %hash c:70d0 d:e8e2
-- | Whether the widget is visible.
--
-- Default value: @False@
--
widgetVisible :: WidgetClass self => Attr self Bool
widgetVisible = newAttrFromBoolProperty "visible"
-- | The opacity of the widget
--
-- Default value: @1.0@
--
widgetOpacity :: WidgetClass self => Attr self Double
widgetOpacity = newAttrFromDoubleProperty "opacity"
-- %hash c:4dd4 d:594e
-- | Whether the widget responds to input.
--
-- Default value: @True@
--
widgetSensitive :: WidgetClass self => Attr self Bool
widgetSensitive = newAttrFromBoolProperty "sensitive"
-- %hash c:7506 d:1dde
-- | Whether the application will paint directly on the widget.
--
-- Default value: @False@
--
widgetAppPaintable :: WidgetClass self => Attr self Bool
widgetAppPaintable = newAttrFromBoolProperty "app-paintable"
-- %hash c:6289 d:72ab
-- | Whether the widget can accept the input focus.
--
-- Default value: @False@
--
widgetCanFocus :: WidgetClass self => Attr self Bool
widgetCanFocus = newAttrFromBoolProperty "can-focus"
-- %hash c:8e7 d:2645
-- | Whether the widget has the input focus.
--
-- Default value: @False@
--
widgetHasFocus :: WidgetClass self => Attr self Bool
widgetHasFocus = newAttrFromBoolProperty "has-focus"
-- %hash c:7547 d:1d78
-- | Whether the widget is the focus widget within the toplevel.
--
-- Default value: @False@
--
widgetIsFocus :: WidgetClass self => Attr self Bool
widgetIsFocus = newAttrFromBoolProperty "is-focus"
-- %hash c:f2d8 d:1cbb
-- | Whether the widget can be the default widget.
--
-- Default value: @False@
--
widgetCanDefault :: WidgetClass self => Attr self Bool
widgetCanDefault = newAttrFromBoolProperty "can-default"
-- %hash c:836 d:4cbe
-- | Whether the widget is the default widget.
--
-- Default value: @False@
--
widgetHasDefault :: WidgetClass self => Attr self Bool
widgetHasDefault = newAttrFromBoolProperty "has-default"
-- %hash c:f964 d:b62f
-- | If @True@, the widget will receive the default action when it is focused.
--
-- Default value: @False@
--
widgetReceivesDefault :: WidgetClass self => Attr self Bool
widgetReceivesDefault = newAttrFromBoolProperty "receives-default"
-- %hash c:2ca6 d:cad8
-- | Whether the widget is part of a composite widget.
--
-- Default value: @False@
--
widgetCompositeChild :: WidgetClass self => ReadAttr self Bool
widgetCompositeChild = readAttrFromBoolProperty "composite-child"
-- %hash c:4f01 d:bd3
-- | The style of the widget, which contains information about how it will
-- look (colors etc).
--
widgetStyle :: WidgetClass self => Attr self Style
widgetStyle = newAttrFromObjectProperty "style" gTypeStyle
-- | The current visual user interaction state of the widget (insensitive,
-- prelighted, selected etc). See 'StateType' for more information.
--
widgetState :: WidgetClass self => Attr self StateType
widgetState = newAttr
widgetGetState
widgetSetState
-- %hash c:e2a4 d:9296
-- | The event mask that decides what kind of GdkEvents this widget gets.
--
-- Default value: 'StructureMask'
--
widgetEvents :: WidgetClass self => Attr self [EventMask]
widgetEvents = newAttrFromFlagsProperty "events"
{# call pure unsafe gdk_event_mask_get_type #}
#if GTK_MAJOR_VERSION < 3
-- %hash c:ba80
-- | The mask that decides what kind of extension events this widget gets.
--
-- Default value: 'ExtensionEventsNone'
--
-- Removed in Gtk3.
widgetExtensionEvents :: WidgetClass self => Attr self [ExtensionMode]
widgetExtensionEvents = newAttr
widgetGetExtensionEvents
widgetSetExtensionEvents
#endif
-- | Whether to expand in both directions. Setting this sets both 'widgetHExpand' and 'widgetVExpand'
--
-- Default value: @False@
--
widgetExpand :: WidgetClass self => Attr self Bool
widgetExpand = newAttrFromBoolProperty "expand"
-- | Whether to expand horizontally. See 'widgetSetHExpand'
--
-- Default value: @False@
--
widgetHExpand :: WidgetClass self => Attr self Bool
widgetHExpand = newAttrFromBoolProperty "hexpand"
-- | Whether to use the “hexpand” property. See 'widgetGetHExpandSet'.
--
-- Default value: @False@
--
widgetHExpandSet :: WidgetClass self => Attr self Bool
widgetHExpandSet = newAttrFromBoolProperty "hexpand-set"
-- | Whether to expand vertically. See 'widgetSetVExpand'.
--
-- Default value: @False@
--
widgetVExpand :: WidgetClass self => Attr self Bool
widgetVExpand = newAttrFromBoolProperty "vexpand"
-- | Whether to use the “vexpand” property. See 'widgetGetVExpandSet'.
--
-- Default value: @False@
--
widgetVExpandSet :: WidgetClass self => Attr self Bool
widgetVExpandSet = newAttrFromBoolProperty "vexpand-set"
-- %hash c:1605 d:48ea
-- | Whether 'widgetShowAll' should not affect this widget.
--
-- Default value: @False@
--
widgetNoShowAll :: WidgetClass self => Attr self Bool
widgetNoShowAll = newAttrFromBoolProperty "no-show-all"
-- %hash c:cd8d d:59b2
-- | \'childVisible\' property. See 'widgetGetChildVisible' and
-- 'widgetSetChildVisible'
--
widgetChildVisible :: WidgetClass self => Attr self Bool
widgetChildVisible = newAttr
widgetGetChildVisible
widgetSetChildVisible
#if GTK_MAJOR_VERSION < 3
-- %hash c:a20a d:646f
-- | \'colormap\' property. See 'widgetGetColormap' and 'widgetSetColormap'
--
-- Removed in Gtk3.
widgetColormap :: WidgetClass self => Attr self Colormap
widgetColormap = newAttr
widgetGetColormap
widgetSetColormap
#endif
-- %hash c:a7fd d:55b8
-- | \'compositeName\' property. See 'widgetGetCompositeName' and
-- 'widgetSetCompositeName'
--
widgetCompositeName :: (WidgetClass self, GlibString string) => ReadWriteAttr self (Maybe string) string
widgetCompositeName = newAttr
widgetGetCompositeName
widgetSetCompositeName
-- %hash c:6c03 d:ce3b
-- | \'direction\' property. See 'widgetGetDirection' and 'widgetSetDirection'
--
widgetDirection :: WidgetClass self => Attr self TextDirection
widgetDirection = newAttr
widgetGetDirection
widgetSetDirection
-- | Sets the text of tooltip to be the given string, which is marked up with the Pango text markup
-- language. Also see 'tooltipSetMarkup'.
--
-- This is a convenience property which will take care of getting the tooltip shown if the given string
-- is not \"\": 'hasTooltip' will automatically be set to 'True' and there will be taken care of
-- 'queryTooltip' in the default signal handler.
--
-- Default value: \"\"
--
-- * Available since Gtk+ version 2.12
--
widgetTooltipMarkup :: (WidgetClass self, GlibString markup) => Attr self (Maybe markup)
widgetTooltipMarkup = newAttrFromMaybeStringProperty "tooltip-markup"
-- | Sets the text of tooltip to be the given string.
--
-- Also see 'tooltipSetText'.
--
-- This is a convenience property which will take care of getting the tooltip shown if the given string
-- is not \"\": 'hasTooltip' will automatically be set to 'True' and there will be taken care of
-- 'queryTooltip' in the default signal handler.
--
-- Default value: \"\"
--
-- * Available since Gtk+ version 2.12
--
widgetTooltipText :: (WidgetClass self, GlibString string) => Attr self (Maybe string)
widgetTooltipText = newAttrFromMaybeStringProperty "tooltip-text"
-- | Enables or disables the emission of 'queryTooltip' on widget. A value of 'True' indicates that widget
-- can have a tooltip, in this case the widget will be queried using 'queryTooltip' to determine
-- whether it will provide a tooltip or not.
--
-- Note that setting this property to 'True' for the first time will change the event masks of the
-- 'Windows' of this widget to include leave-notify and motion-notify events. This cannot and will not
-- be undone when the property is set to 'False' again.
--
-- Default value: 'False'
--
-- * Available since Gtk+ version 2.12
--
widgetHasTooltip :: WidgetClass self => Attr self Bool
widgetHasTooltip = newAttrFromBoolProperty "has-tooltip"
#if GTK_CHECK_VERSION(2,20,0)
-- | Determines if the widget style has been looked up through the rc mechanism.
widgetHasRcStyle :: WidgetClass self => self
-> IO Bool -- ^ returns 'True' if the widget has been looked up through the rc mechanism, 'False' otherwise.
widgetHasRcStyle self =
liftM toBool $
{#call gtk_widget_has_rc_style #}
(toWidget self)
-- | Determines whether widget is realized.
widgetGetRealized :: WidgetClass self => self
-> IO Bool -- ^ returns 'True' if widget is realized, 'False' otherwise
widgetGetRealized self =
liftM toBool $
{#call gtk_widget_get_realized #}
(toWidget self)
-- | Whether the widget is mapped.
widgetGetMapped :: WidgetClass self => self
-> IO Bool -- ^ returns 'True' if the widget is mapped, 'False' otherwise.
widgetGetMapped self =
liftM toBool $
{#call gtk_widget_get_mapped #}
(toWidget self)
-- | Marks the @widget@ as being realized. This function must only be called
-- after all 'DrawWindows' for the widget have been created and registered.
--
-- This function should only ever be called in a derived widget's “realize”
-- or “unrealize” implementation.
widgetSetRealized :: WidgetClass widget => widget
-> Bool -- ^ @realized@ @True@ to mark the widget realized.
-> IO ()
widgetSetRealized widget realized =
{# call widget_set_realized #}
(toWidget widget)
(fromBool realized)
-- | Marks the @widget@ as being realized.
--
-- This function should only ever be called in a derived widget's “map” or
-- “unmap” implementation.
widgetSetMapped :: WidgetClass widget => widget
-> Bool -- ^ @mapped@ @True@ to mark the widget as mapped.
-> IO ()
widgetSetMapped widget mapped =
{# call widget_set_mapped #}
(toWidget widget)
(fromBool mapped)
#endif
#if GTK_CHECK_VERSION(3,0,0)
-- | Returns the style context associated to @widget@.
widgetGetStyleContext :: WidgetClass widget
=> widget -- ^ @widget@ : a @Widget@
-> IO StyleContext -- ^ a @StyleContext@
widgetGetStyleContext widget =
makeNewGObject mkStyleContext $
{# call gtk_widget_get_style_context #}
(toWidget widget)
-- | Gets the value of the `widgetHAlign` property.
--
-- For backwards compatibility reasons this method will never return AlignBaseline,
-- but instead it will convert it to AlignFill. Baselines are not supported for
-- horizontal alignment.
--
widgetGetHAlign :: WidgetClass self => self -> IO Align
widgetGetHAlign self =
liftM (toEnum . fromIntegral) $
{# call gtk_widget_get_halign #}
(toWidget self)
-- | Sets the horizontal alignment of widget. See the 'widgetHAlign' property.
--
widgetSetHAlign :: WidgetClass self => self -> Align -> IO ()
widgetSetHAlign self align =
{# call gtk_widget_set_halign #}
(toWidget self)
(fromIntegral $ fromEnum align)
-- | Gets the value of the 'widgetVAlign' property.
--
-- For backwards compatibility reasons this method will never return AlignBaseline,
-- but instead it will convert it to AlignFill. If your widget want to support
-- baseline aligned children it must use 'widgetGetVAlignWithBaseline', or
-- 'widgetVAlign', which will also report the true value.
widgetGetVAlign :: WidgetClass self => self -> IO Align
widgetGetVAlign self =
liftM (toEnum . fromIntegral) $
{# call gtk_widget_get_valign #}
(toWidget self)
#if GTK_CHECK_VERSION(3,10,0)
-- | Gets the value of the 'widgetVAlign' property, including AlignBaseline.
widgetGetVAlignWithBaseline :: WidgetClass self => self -> IO Align
widgetGetVAlignWithBaseline self =
liftM (toEnum . fromIntegral) $
{# call gtk_widget_get_valign_with_baseline #}
(toWidget self)
#endif
-- | Sets the vertical alignment of widget . See the 'widgetVAlign' property.
widgetSetVAlign :: WidgetClass self => self -> Align -> IO ()
widgetSetVAlign self align =
{# call gtk_widget_set_valign #}
(toWidget self)
(fromIntegral $ fromEnum align)
#endif
--------------------
-- Signals
-- %hash c:4cf5 d:af3f
-- | The widget appears on screen.
--
mapSignal :: WidgetClass self => Signal self (IO ())
mapSignal = Signal (connect_NONE__NONE "map")
-- %hash c:e33e d:af3f
-- | The widget disappears from the screen.
--
unmapSignal :: WidgetClass self => Signal self (IO ())
unmapSignal = Signal (connect_NONE__NONE "unmap")
-- %hash c:1f7f d:af3f
-- | The widget should allocate any resources needed, in particular, the
-- widget's 'DrawWindow' is created. If you connect to this signal and
-- you rely on some of these resources to be present, you have to use
-- 'System.Glib.Signals.after'.
--
realize :: WidgetClass self => Signal self (IO ())
realize = Signal (connect_NONE__NONE "realize")
-- %hash c:7948 d:af3f
-- | The widget should deallocate any resources. This signal is emitted before
-- the widget is destroyed.
--
unrealize :: WidgetClass self => Signal self (IO ())
unrealize = Signal (connect_NONE__NONE "unrealize")
-- %hash c:9f6f d:af3f
-- | Query the widget for the size it likes to
-- have.
--
-- * A parent container emits this signal to its child to query the needed
-- height and width of the child. There is not guarantee that the widget
-- will actually get this area.
--
sizeRequest :: WidgetClass self => Signal self (IO Requisition)
sizeRequest = Signal (\after w fun ->
connect_PTR__NONE "size-request" after w
(\rqPtr -> fun >>= \req -> unless (rqPtr==nullPtr) $ poke rqPtr req))
-- %hash c:8ec5 d:af3f
-- | Inform widget about the size it has.
--
-- * After querying a widget for the size it wants to have (through emitting
-- the @\"sizeRequest\"@ signal) a container will emit this signal to
-- inform the widget about the real size it should occupy.
--
sizeAllocate :: WidgetClass self => Signal self (Allocation -> IO ())
sizeAllocate = Signal (connect_BOXED__NONE "size-allocate" peek)
-- %hash c:ae3e d:af3f
-- | The widget is shown.
--
showSignal :: WidgetClass self => Signal self (IO ())
showSignal = Signal (connect_NONE__NONE "show")
-- %hash c:f589 d:af3f
-- | The widget is hidden.
--
hideSignal :: WidgetClass self => Signal self (IO ())
hideSignal = Signal (connect_NONE__NONE "hide")
-- %hash c:a285 d:af3f
-- | The widget gains focus via the given user action.
--
focus :: WidgetClass self => Signal self (DirectionType -> IO Bool)
focus = Signal (connect_ENUM__BOOL "focus")
-- %hash c:78ae d:af3f
-- | The state of the widget (input focus, insensitive, etc.) has changed.
--
stateChanged :: WidgetClass self => Signal self (StateType -> IO ())
stateChanged = Signal (connect_ENUM__NONE "state-changed")
#if GTK_CHECK_VERSION(3,0,0)
connect_FLAGS__NONE ::
(Flags a, GObjectClass obj) => SignalName ->
ConnectAfter -> obj ->
([a] -> IO ()) ->
IO (ConnectId obj)
connect_FLAGS__NONE signal after obj user =
connectGeneric signal after obj action
where action :: Ptr GObject -> Int -> IO ()
action _ flags1 =
failOnGError $
user (toFlags flags1)
-- | The state of the widget (input focus, insensitive, etc.) has changed.
--
stateFlagsChanged :: WidgetClass self => Signal self ([StateFlags] -> IO ())
stateFlagsChanged = Signal (connect_FLAGS__NONE "state-flags-changed")
#endif
-- %hash c:bef2 d:1d66
-- | The 'parentSet' signal is emitted when a new parent has been set on a
-- widget. The parameter is the new parent.
--
parentSet :: WidgetClass self => Signal self (Maybe Widget -> IO ())
parentSet = Signal (connect_MOBJECT__NONE "parent-set")
-- %hash c:7e2b d:4049
-- | Emitted when there is a change in the hierarchy to which a widget belong.
-- More precisely, a widget is anchored when its toplevel ancestor is a
-- 'Window'. This signal is emitted when a widget changes from un-anchored to
-- anchored or vice-versa.
--
hierarchyChanged :: WidgetClass self => Signal self (Maybe Widget -> IO ())
hierarchyChanged = Signal (connect_MOBJECT__NONE "hierarchy-changed")
-- %hash c:5894 d:ba10
-- | The 'styleSet' signal is emitted when a new style has been set on a
-- widget. Note that style-modifying functions like 'widgetModifyBase' also
-- cause this signal to be emitted.
--
styleSet :: WidgetClass self => Signal self (Style -> IO ())
styleSet = Signal (connect_OBJECT__NONE "style-set")
-- %hash c:6bb1 d:af3f
-- | The default direction of text writing has changed.
--
directionChanged :: WidgetClass self => Signal self (TextDirection -> IO ())
directionChanged = Signal (connect_ENUM__NONE "direction-changed")
-- %hash c:c28c d:d116
-- | The 'grabNotify' signal is emitted when a widget becomes shadowed by a
-- Gtk+ grab (not a pointer or keyboard grab) on another widget, or when it
-- becomes unshadowed due to a grab being removed.
--
-- A widget is shadowed by a 'grabAdd' when the topmost grab widget in the
-- grab stack of its window group is not its ancestor.
--
grabNotify :: WidgetClass self => Signal self (Bool -> IO ())
grabNotify = Signal (connect_BOOL__NONE "grab-notify")
-- %hash c:e06c d:a681
-- | This signal gets emitted whenever a widget should pop up a
-- context-sensitive menu. This usually happens through the standard key
-- binding mechanism; by pressing a certain key while a widget is focused, the
-- user can cause the widget to pop up a menu. For example, the 'Entry' widget
-- creates a menu with clipboard commands.
--
popupMenuSignal :: WidgetClass self => Signal self (IO Bool)
popupMenuSignal = Signal (connect_NONE__BOOL "popup-menu")
-- | Specify what kind of help the user wants.
{#enum GtkWidgetHelpType as WidgetHelpType {underscoreToCase} deriving (Eq,Show) #}
-- %hash c:b18e d:af3f
-- | Tell the widget to show an explanatory help text. Should return @True@
-- if help has been shown.
--
showHelp :: WidgetClass self => Signal self (WidgetHelpType -> IO Bool)
showHelp = Signal (connect_ENUM__BOOL "show-help")
-- %hash c:6a8f d:af3f
-- | The set of keyboard accelerators has changed.
--
accelClosuresChanged :: WidgetClass self => Signal self (IO ())
accelClosuresChanged = Signal (connect_NONE__NONE "accel-closures-changed")
-- %hash c:5ca d:af3f
-- | The widget moved to a new screen.
--
screenChanged :: WidgetClass self => Signal self (Screen -> IO ())
screenChanged = Signal (connect_OBJECT__NONE "screen-changed")
-- | Emitted when 'hasTooltip' is 'True' and the 'gtkTooltipTimeout' has expired with the cursor
-- hovering "above" widget; or emitted when widget got focus in keyboard mode.
--
-- Using the given coordinates, the signal handler should determine whether a tooltip should be shown
-- for widget. If this is the case 'True' should be returned, 'False' otherwise.
-- Note if widget got focus in keyboard mode, 'Point' is 'Nothing'.
--
-- The signal handler is free to manipulate tooltip with the therefore destined function calls.
--
-- * Available since Gtk+ version 2.12
--
queryTooltip :: WidgetClass self => Signal self (Widget -> Maybe Point -> Tooltip -> IO Bool)
queryTooltip =
Signal (\after model user ->
connect_OBJECT_INT_INT_BOOL_OBJECT__BOOL "query-tooltip"
after model (\widget x y keyb tooltip ->
user widget (if keyb then Nothing else Just (x, y)) tooltip))
#if GTK_CHECK_VERSION(3,0,0)
draw :: WidgetClass self => Signal self (Render ())
draw =
Signal (\after model (Render user) ->
connect_PTR__NONE "draw" after model (\ptr -> runReaderT user (Cairo ptr)))
#endif
-- * Events
--
-- An event is a signal that indicates that some low-level interaction like a
-- button or key press, mouse movement, etc. has occurred. In particular,
-- events relate to operations on 'DrawWindow's which are a concept of the
-- underlying OS rather than the logical widget concept. Some widgets have no
-- window and use their parent to receive these events. Widgets normally
-- synthesize more sophistiacted signals from events. For instance, the
-- 'focusIn' and a 'focusOut' signal indicate that the widget gains or looses
-- the input focus. From these events a 'focus' signal is synthesized that
-- indicates what maneuver lead to the input focus change (i.e. a tab or
-- shift-tab key press).
--
-- For applications it is often sufficient to connect to the high-level
-- signals rather than the low-level events. Only in cases where a custom
-- widget is built based on the 'DarwingArea' skeleton, the functionality of
-- such an application-specific widget needs to be implemented using events.
--
-- Every event is passed an 'Event' structure that contains the data of the
-- event. The return value should be @True@ if the handler has dealt with the
-- event and @False@ if the event should be propagated further. For instance,
-- if a key press event that isn't meaningful in the widget, the handler can
-- return @False@ such that the key is handled by the other widgets (the main
-- menu, for instance).
--
-- Because there are so many similar signals (those that take an Event and
-- return a Bool) we will abstract out the skeleton. As some of these events
-- are emitted at a high rate often a bit has to be set to enable emission.
eventM :: WidgetClass w => SignalName -> [EventMask] ->
ConnectAfter -> w -> (EventM t Bool) -> IO (ConnectId w)
eventM name eMask after obj fun = do
id <- connect_PTR__BOOL name after obj (runReaderT fun)
widgetAddEvents obj eMask
return id
-- %hash c:6cc d:af3f
-- | A mouse button has been depressed while the mouse pointer was within the
-- widget area. Sets the widget's 'ButtonPressMask' flag.
--
buttonPressEvent :: WidgetClass self => Signal self (EventM EButton Bool)
buttonPressEvent = Signal (eventM "button_press_event" [ButtonPressMask])
-- %hash c:62e8 d:af3f
-- | A mouse button has been released. Sets the widget's 'ButtonReleaseMask'
-- flag.
--
buttonReleaseEvent :: WidgetClass self => Signal self (EventM EButton Bool)
buttonReleaseEvent = Signal (eventM "button_release_event" [ButtonReleaseMask])
-- %hash c:23e5 d:af3f
-- | The scroll wheel of the mouse has been used. Sets the widget's
-- 'ScrollMask' flag.
--
scrollEvent :: WidgetClass self => Signal self (EventM EScroll Bool)
scrollEvent = Signal (eventM "scroll_event" [ScrollMask])
-- %hash c:ee92 d:af3f
-- | The mouse pointer has moved. Since receiving all mouse movements is
-- expensive, it is necessary to specify exactly what mouse motions are
-- required by calling 'widgetAddEvents' on this widget with one or more of
-- the following flags:
--
-- * 'PointerMotionMask': Track all movements.
--
-- * 'ButtonMotionMask': Only track movements if a button is depressed.
--
-- * 'Button1MotionMask': Only track movements if the left button is depressed.
--
-- * 'Button2MotionMask': Only track movements if the middle button is depressed.
--
-- * 'Button3MotionMask': Only track movements if the right button is depressed.
-- 'PointerMotionHintMask' is a special flag which can be used in
-- combination with any of the above and is used to reduce the number of
-- 'motionNotifyEvent's received. Normally a 'motionNotifyEvent' event is
-- received each time the mouse moves. However, if the application spends a
-- lot of time processing the event (updating the display, for example), it
-- can lag behind the position of the mouse. When using
-- 'PointerMotionHintMask', fewer 'motionNotifyEvent's will be sent, some of
-- which are marked as a hint. To receive more motion events after a motion
-- hint event, the application needs to asks for more, by calling
-- 'Graphics.UI.Gtk.Gdk.EventM.eventRequestMotions'. This effectively limits
-- the rate at which new motion events are received. (Note that you don't
-- need to check if the hint is set as
-- 'Graphics.UI.Gtk.Gdk.EventM.eventRequestMotions' does so automatically.)
--
motionNotifyEvent :: WidgetClass self => Signal self (EventM EMotion Bool)
motionNotifyEvent = Signal (eventM "motion_notify_event" [])
-- %hash c:8783 d:3e27
-- | The 'deleteEvent' signal is emitted if a user requests that a toplevel
-- window is closed. The default handler for this signal destroys the window.
-- Calling 'widgetHide' and returning @True@ on reception of this signal will
-- cause the window to be hidden instead, so that it can later be shown again
-- without reconstructing it.
--
deleteEvent :: WidgetClass self => Signal self (EventM EAny Bool)
deleteEvent = Signal (eventM "delete_event" [])
-- %hash c:c408 d:5514
-- | The 'destroyEvent' signal is emitted when a 'DrawWindow' is destroyed.
-- You rarely get this signal, because most widgets disconnect themselves from
-- their window before they destroy it, so no widget owns the window at
-- destroy time. However, you might want to connect to the 'objectDestroy'
-- signal of 'Object'.
--
destroyEvent :: WidgetClass self => Signal self (EventM EAny Bool)
destroyEvent = Signal (eventM "destroy_event" [])
-- %hash c:c79e d:af3f
-- | Instructs the widget to redraw.
--
-- * The 'DrawWindow' that needs to be redrawn is available via
-- 'eventWindow'.
--
-- * The part that needs to be redrawn is available via 'eventArea' and
-- 'eventRegion'. The options are, in order of efficiency: (a) redraw the
-- entire window, (b) ask for the 'eventArea' and redraw that rectangle, (c)
-- ask for the 'eventRegion' and redraw each of those rectangles.
--
-- Only the exposed region will be updated; see also
-- 'drawWindowBeginPaintRegion'.
exposeEvent :: WidgetClass self => Signal self (EventM EExpose Bool)
exposeEvent = Signal (eventM "expose_event" [])
-- %hash c:5ccd d:af3f
-- | A key has been depressed. Sets the widget's 'KeyPressMask' flag.
--
keyPressEvent :: WidgetClass self => Signal self (EventM EKey Bool)
keyPressEvent = Signal (eventM "key_press_event" [KeyPressMask])
-- %hash c:bd29 d:af3f
-- | A key has been released. Sets the widget's 'KeyReleaseMask' flag.
--
keyReleaseEvent :: WidgetClass self => Signal self (EventM EKey Bool)
keyReleaseEvent = Signal (eventM "key_release_event" [KeyReleaseMask])
-- %hash c:602e d:af3f
-- | The mouse pointer has entered the widget. Sets the widget's
-- 'EnterNotifyMask' flag.
--
enterNotifyEvent :: WidgetClass self => Signal self (EventM ECrossing Bool)
enterNotifyEvent = Signal (eventM "enter_notify_event" [EnterNotifyMask])
-- %hash c:3bfb d:af3f
-- | The mouse pointer has left the widget. Sets the widget's
-- 'LeaveNotifyMask' flag.
--
leaveNotifyEvent :: WidgetClass self => Signal self (EventM ECrossing Bool)
leaveNotifyEvent = Signal (eventM "leave_notify_event" [LeaveNotifyMask])
-- %hash c:2b64 d:af3f
-- | The size of the window has changed.
--
configureEvent :: WidgetClass self => Signal self (EventM EConfigure Bool)
configureEvent = Signal (eventM "configure_event" [])
-- %hash c:427e d:af3f
-- | The widget gets the input focus. Sets the widget's 'FocusChangeMask' flag.
--
focusInEvent :: WidgetClass self => Signal self (EventM EFocus Bool)
focusInEvent = Signal (eventM "focus_in_event" [FocusChangeMask])
-- %hash c:5281 d:af3f
-- | The widget lost the input focus. Sets the widget's 'FocusChangeMask' flag.
--
focusOutEvent :: WidgetClass self => Signal self (EventM EFocus Bool)
focusOutEvent = Signal (eventM "focus_out_event" [FocusChangeMask])
-- %hash c:63c4 d:af3f
-- | The window is put onto the screen.
--
mapEvent :: WidgetClass self => Signal self (EventM EAny Bool)
mapEvent = Signal (eventM "map_event" [])
-- %hash c:342d d:af3f
-- | The window is taken off the screen.
--
unmapEvent :: WidgetClass self => Signal self (EventM EAny Bool)
unmapEvent = Signal (eventM "unmap_event" [])
-- %hash c:a1dd d:af3f
-- | A 'DrawWindow' may be associated with a set of properties that are
-- identified by a 'PropertyTag'. This event is triggered if a property is
-- changed or deleted. Sets the widget's 'PropertyChangeMask' flag.
--
_propertyNotifyEvent :: WidgetClass self => Signal self (EventM EProperty Bool)
_propertyNotifyEvent = Signal (eventM "property_notify_event" [PropertyChangeMask])
{- not sure if these are useful
-- %hash c:58cc d:af3f
-- |
--
selectionClearEvent :: WidgetClass self => Signal self ({-GdkEventSelection*-} Bool)
selectionClearEvent = Signal (connect_{-GdkEventSelection*-}__BOOL "selection_clear_event")
-- %hash c:4f92 d:af3f
-- |
--
selectionRequestEvent :: WidgetClass self => Signal self ({-GdkEventSelection*-} Bool)
selectionRequestEvent = Signal (connect_{-GdkEventSelection*-}__BOOL "selection_request_event")
-- %hash c:b842 d:af3f
-- |
--
selectionNotifyEvent :: WidgetClass self => Signal self ({-GdkEventSelection*-} Bool)
selectionNotifyEvent = Signal (connect_{-GdkEventSelection*-}__BOOL "selection_notify_event")
-}
-- %hash c:b027 d:af3f
-- | The pen of a graphics tablet was put down. Sets the widget's
-- 'ProximityInMask' flag.
--
proximityInEvent :: WidgetClass self => Signal self (EventM EProximity Bool)
proximityInEvent = Signal (eventM "proximity_in_event" [ProximityInMask])
-- %hash c:faca d:af3f
-- | The pen of a graphics tablet was lifted off the tablet. Sets the widget's
-- 'ProximityOutMask' flag.
--
proximityOutEvent :: WidgetClass self => Signal self (EventM EProximity Bool)
proximityOutEvent = Signal (eventM "proximity_out_event" [ProximityOutMask])
-- %hash c:db2c d:af3f
-- | Emitted when the window visibility status has changed. Sets the widget's
-- 'VisibilityNotifyMask' flag.
--
visibilityNotifyEvent :: WidgetClass self => Signal self (EventM EVisibility Bool)
visibilityNotifyEvent = Signal (eventM "visibility_notify_event" [VisibilityNotifyMask])
{-
-- %hash c:3f5 d:af3f
-- |
--
clientEvent :: WidgetClass self => Signal self ({-GdkEventClient*-} Bool)
clientEvent = Signal (connect_{-GdkEventClient*-}__BOOL "client_event")
-}
-- %hash c:643c d:af3f
-- | Generated when the area of a 'Drawable' being copied using, e.g.
-- 'Graphics.UI.Gtk.Gdk.Drawable.drawDrawable', is completely available.
--
noExposeEvent :: WidgetClass self => Signal self (EventM EAny Bool)
noExposeEvent = Signal (eventM "no_expose_event" [])
-- %hash c:63b6 d:af3f
-- | Emitted when the state of the window changes, i.e. when it is minimized,
-- moved to the top, etc.
--
windowStateEvent :: WidgetClass self => Signal self (EventM EWindowState Bool)
windowStateEvent = Signal (eventM "window_state_event" [])
#if GTK_CHECK_VERSION(2,8,0)
-- %hash c:502a d:e47a
-- | Emitted when a pointer or keyboard grab on a window belonging to @widget@
-- gets broken.
--
-- On X11, this happens when the grab window becomes unviewable (i.e. it or
-- one of its ancestors is unmapped), or if the same application grabs the
-- pointer or keyboard again.
--
-- * Available since Gtk+ version 2.8
--
grabBrokenEvent :: WidgetClass self => Signal self (EventM EGrabBroken Bool)
grabBrokenEvent = Signal (eventM "grab_broken_event" [])
#endif
--------------------
-- Deprecated Signals and Events
#ifndef DISABLE_DEPRECATED
event :: WidgetClass w => SignalName -> [EventMask] ->
ConnectAfter -> w -> (Event -> IO Bool) -> IO (ConnectId w)
event name eMask after obj fun = do
id <- connect_BOXED__BOOL name marshalEvent after obj fun
widgetAddEvents obj eMask
return id
-- | A Button was pressed.
--
-- * This widget is part of a button which was just pressed. The event passed
-- to the user function is a 'Graphics.UI.Gtk.Gdk.Events.Button' event.
--
onButtonPress, afterButtonPress :: WidgetClass w => w -> (Event -> IO Bool) ->
IO (ConnectId w)
onButtonPress = event "button_press_event" [ButtonPressMask] False
afterButtonPress = event "button_press_event" [ButtonPressMask] True
-- | A Button was released.
--
onButtonRelease, afterButtonRelease :: WidgetClass w => w ->
(Event -> IO Bool) -> IO (ConnectId w)
onButtonRelease = event "button_release_event" [ButtonReleaseMask] False
afterButtonRelease = event "button_release_event" [ButtonReleaseMask] True
-- |
--
onClient, afterClient :: WidgetClass w => w -> (Event -> IO Bool) ->
IO (ConnectId w)
onClient = event "client_event" [] False
afterClient = event "client_event" [] True
-- | The widget's status has changed.
--
onConfigure, afterConfigure :: WidgetClass w => w -> (Event -> IO Bool) ->
IO (ConnectId w)
onConfigure = event "configure_event" [] False
afterConfigure = event "configure_event" [] True
-- | This signal is emitted when the close icon on the
-- surrounding window is pressed. The default action is to emit the
-- @\"destroy\"@ signal.
--
onDelete, afterDelete :: WidgetClass w => w -> (Event -> IO Bool) ->
IO (ConnectId w)
onDelete = event "delete_event" [] False
afterDelete = event "delete_event" [] True
-- | The widget will be destroyed.
--
-- * The widget received a destroy event from the window manager.
--
onDestroyEvent, afterDestroyEvent :: WidgetClass w =>
w -> (Event -> IO Bool) ->
IO (ConnectId w)
onDestroyEvent = event "destroy_event" [] False
afterDestroyEvent = event "destroy_event" [] True
-- | The default text direction was changed.
--
onDirectionChanged, afterDirectionChanged :: WidgetClass w => w ->
(Event -> IO Bool) ->
IO (ConnectId w)
onDirectionChanged = event "direction_changed" [] False
afterDirectionChanged = event "direction_changed" [] True
-- | Mouse cursor entered widget.
--
-- * Contains a 'Crossing' event.
--
onEnterNotify, afterEnterNotify :: WidgetClass w => w -> (Event -> IO Bool) ->
IO (ConnectId w)
onEnterNotify = event "enter_notify_event" [EnterNotifyMask] False
afterEnterNotify = event "enter_notify_event" [EnterNotifyMask] True
-- | Mouse cursor leaves widget.
--
-- * Contains a 'Crossing' event.
--
onLeaveNotify, afterLeaveNotify :: WidgetClass w => w -> (Event -> IO Bool) ->
IO (ConnectId w)
onLeaveNotify = event "leave_notify_event" [LeaveNotifyMask] False
afterLeaveNotify = event "leave_notify_event" [LeaveNotifyMask] True
-- | Instructs the widget to redraw.
--
-- * This event is useful for the 'DrawingArea'. On receiving this signal
-- the content of the passed Rectangle or Region needs to be redrawn.
-- The return value should be 'True' if the region was completely redrawn
-- and 'False' if other handlers in the chain should be invoked.
-- If a client will redraw the whole area and is not interested in the
-- extra information in 'Expose', it is more efficient
-- to use 'onExposeRect'.
--
-- * Widgets that are very expensive to re-render, such as an image editor,
-- may prefer to use the 'onExpose' call back which delivers a
-- 'Region' in addition to a 'Rectangle'. A 'Region' consists of several
-- rectangles that need redrawing. The simpler 'onExposeRect' event encodes
-- the area to be redrawn as a bounding rectangle which might be easier
-- to deal with in a particular application.
--
onExpose, afterExpose :: WidgetClass w => w -> (Event -> IO Bool) ->
IO (ConnectId w)
onExpose = event "expose_event" [] False
afterExpose = event "expose_event" [] True
-- | Expose event delivering a 'Rectangle'.
--
onExposeRect, afterExposeRect ::
WidgetClass w => w -> (Rectangle -> IO ()) -> IO (ConnectId w)
onExposeRect w act = connect_BOXED__BOOL "expose_event"
marshExposeRect False w (\r -> act r >> return True)
afterExposeRect w act = connect_BOXED__BOOL "expose_event"
marshExposeRect True w (\r -> act r >> return True)
-- | This signal is called if the widget receives the input focus.
--
onFocus, afterFocus :: WidgetClass w => w -> (DirectionType -> IO Bool) ->
IO (ConnectId w)
onFocus = connect_ENUM__BOOL "focus" False
afterFocus = connect_ENUM__BOOL "focus" True
-- | Widget gains input focus.
--
onFocusIn, afterFocusIn :: WidgetClass w => w -> (Event -> IO Bool) ->
IO (ConnectId w)
onFocusIn = event "focus_in_event" [FocusChangeMask] False
afterFocusIn = event "focus_in_event" [FocusChangeMask] True
-- | Widget looses input focus.
--
onFocusOut, afterFocusOut :: WidgetClass w => w -> (Event -> IO Bool) ->
IO (ConnectId w)
onFocusOut = event "focus_out_event" [FocusChangeMask] False
afterFocusOut = event "focus_out_event" [FocusChangeMask] True
-- | The widget is about to receive all events.
--
-- * It is possible to redirect all input events to one widget to force the
-- user to use only this widget. Such a situation is initiated by
-- 'addGrab'.
--
onGrabFocus, afterGrabFocus :: WidgetClass w => w -> IO () ->
IO (ConnectId w)
onGrabFocus = connect_NONE__NONE "grab_focus" False
afterGrabFocus = connect_NONE__NONE "grab_focus" True
-- | The widget will be destroyed.
--
-- * This is the last signal this widget will receive.
--
onDestroy, afterDestroy :: WidgetClass w => w -> (IO ()) ->
IO (ConnectId w)
onDestroy = connect_NONE__NONE "destroy" False
afterDestroy = connect_NONE__NONE "destroy" True
-- | The widget was asked to hide itself.
--
-- * This signal is emitted each time 'widgetHide' is called. Use
-- 'onUnmap' when your application needs to be informed
-- when the widget is actually removed from screen.
--
onHide, afterHide :: WidgetClass w => w -> IO () -> IO (ConnectId w)
onHide = connect_NONE__NONE "hide" False
afterHide = connect_NONE__NONE "hide" True
-- | The toplevel window changed.
--
-- * When a subtree of widgets is removed or added from a tree with a toplevel
-- window this signal is emitted. It is emitted on each widget in the
-- detached or attached subtree.
--
onHierarchyChanged, afterHierarchyChanged :: WidgetClass w => w -> IO () ->
IO (ConnectId w)
onHierarchyChanged = connect_NONE__NONE "hierarchy_changed" False
afterHierarchyChanged = connect_NONE__NONE "hierarchy_changed" True
-- | A key was pressed.
--
onKeyPress, afterKeyPress :: WidgetClass w => w -> (Event -> IO Bool) ->
IO (ConnectId w)
onKeyPress = event "key_press_event" [KeyPressMask] False
afterKeyPress = event "key_press_event" [KeyPressMask] True
-- | A key was released.
--
onKeyRelease, afterKeyRelease :: WidgetClass w => w -> (Event -> IO Bool) ->
IO (ConnectId w)
onKeyRelease = event "key_release_event" [KeyReleaseMask] False
afterKeyRelease = event "key_release_event" [KeyReleaseMask] True
-- |
--
onMnemonicActivate, afterMnemonicActivate :: WidgetClass w => w ->
(Bool -> IO Bool) ->
IO (ConnectId w)
onMnemonicActivate = connect_BOOL__BOOL "mnemonic_activate" False
afterMnemonicActivate = connect_BOOL__BOOL "mnemonic_activate" True
-- | Track mouse movements.
--
-- * If @hint@ is False, a callback for every movement of the mouse is
-- generated. To avoid a backlog of mouse messages, it is usually sufficient
-- to sent @hint@ to True, generating only one event. The
-- application now has to state that it is ready for the next message by
-- calling 'Graphics.UI.Gtk.Gdk.DrawWindow.drawWindowGetPointer'.
--
onMotionNotify, afterMotionNotify :: WidgetClass w => w -> Bool ->
(Event -> IO Bool) ->
IO (ConnectId w)
onMotionNotify w hint = event "motion_notify_event"
(if hint then [PointerMotionMask, PointerMotionHintMask]
else [PointerMotionMask]) False w
afterMotionNotify w hint = event "motion_notify_event"
(if hint then [PointerMotionMask, PointerMotionHintMask]
else [PointerMotionMask]) True w
-- |
--
onParentSet, afterParentSet :: (WidgetClass w, WidgetClass old) => w ->
(old -> IO ()) -> IO (ConnectId w)
onParentSet = connect_OBJECT__NONE "parent_set" False
afterParentSet = connect_OBJECT__NONE "parent_set" True
-- |
--
onPopupMenu, afterPopupMenu :: WidgetClass w => w -> IO () -> IO (ConnectId w)
onPopupMenu = connect_NONE__NONE "popup_menu" False
afterPopupMenu = connect_NONE__NONE "popup_menu" True
-- | The input device became active.
--
-- * This event indicates that a pen of a graphics tablet or similar device is
-- now touching the tablet.
--
onProximityIn, afterProximityIn :: WidgetClass w => w -> (Event -> IO Bool) ->
IO (ConnectId w)
onProximityIn = event "proximity_in_event" [ProximityInMask] False
afterProximityIn = event "proximity_in_event" [ProximityInMask] True
-- | The input device became inactive.
--
-- * The pen was removed from the graphics tablet's surface.
--
onProximityOut, afterProximityOut :: WidgetClass w => w ->
(Event -> IO Bool) -> IO (ConnectId w)
onProximityOut = event "proximity_out_event" [ProximityOutMask] False
afterProximityOut = event "proximity_out_event" [ProximityOutMask] True
-- | This widget's drawing area is about to be
-- destroyed.
--
onRealize, afterRealize :: WidgetClass w => w -> IO () -> IO (ConnectId w)
onRealize = connect_NONE__NONE "realize" False
afterRealize = connect_NONE__NONE "realize" True
-- | The mouse wheel has turned.
--
-- * The 'Event' is always 'Scroll'.
--
onScroll, afterScroll :: WidgetClass w => w -> (Event -> IO Bool) ->
IO (ConnectId w)
onScroll = event "scroll_event" [ScrollMask] False
afterScroll = event "scroll_event" [ScrollMask] True
-- | The widget was asked to show itself.
--
-- * This signal is emitted each time 'widgetShow' is called. Use
-- 'onMap' when your application needs to be informed when
-- the widget is actually shown.
--
onShow, afterShow :: WidgetClass w => w -> IO () -> IO (ConnectId w)
onShow = connect_NONE__NONE "show" False
afterShow = connect_NONE__NONE "show" True
-- | Inform widget about the size it has.
--
-- * After querying a widget for the size it wants to have (through emitting
-- the @\"sizeRequest\"@ signal) a container will emit this signal to
-- inform the widget about the real size it should occupy.
--
onSizeAllocate, afterSizeAllocate :: WidgetClass w => w ->
(Allocation -> IO ()) -> IO (ConnectId w)
onSizeAllocate = connect_BOXED__NONE "size_allocate" peek False
afterSizeAllocate = connect_BOXED__NONE "size_allocate" peek True
-- | Query the widget for the size it likes to
-- have.
--
-- * A parent container emits this signal to its child to query the needed
-- height and width of the child. There is not guarantee that the widget
-- will actually get this area.
--
onSizeRequest, afterSizeRequest :: WidgetClass w => w -> (IO Requisition) ->
IO (ConnectId w)
onSizeRequest w fun = connect_PTR__NONE "size_request" False w (\rqPtr -> do
req <- fun
unless (rqPtr==nullPtr) $ poke rqPtr req)
afterSizeRequest w fun = connect_PTR__NONE "size_request" True w (\rqPtr -> do
req <- fun
unless (rqPtr==nullPtr) $ poke rqPtr req)
-- |
--
onStateChanged, afterStateChanged :: WidgetClass w => w ->
(StateType -> IO ()) -> IO (ConnectId w)
onStateChanged = connect_ENUM__NONE "state_changed" False
afterStateChanged = connect_ENUM__NONE "state_changed" True
-- | The widget was removed from screen.
--
onUnmap, afterUnmap :: WidgetClass w => w -> IO () -> IO (ConnectId w)
onUnmap = connect_NONE__NONE "unmap" False
afterUnmap = connect_NONE__NONE "unmap" True
-- | This widget's drawing area is about to be
-- destroyed.
--
onUnrealize, afterUnrealize :: WidgetClass w => w -> IO () -> IO (ConnectId w)
onUnrealize = connect_NONE__NONE "unrealize" False
afterUnrealize = connect_NONE__NONE "unrealize" True
-- |
--
onVisibilityNotify, afterVisibilityNotify :: WidgetClass w => w ->
(Event -> IO Bool) ->
IO (ConnectId w)
onVisibilityNotify =
event "visibility_notify_event" [VisibilityNotifyMask] False
afterVisibilityNotify =
event "visibility_notify_event" [VisibilityNotifyMask] True
-- |
--
onWindowState, afterWindowState :: WidgetClass w => w -> (Event -> IO Bool) ->
IO (ConnectId w)
onWindowState = event "window_state_event" [] False
afterWindowState = event "window_state_event" [] True
#endif
|