File: CH02.xml

package info (click to toggle)
libxt 1%3A1.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 5,916 kB
  • ctags: 3,438
  • sloc: xml: 36,754; ansic: 33,551; sh: 11,349; makefile: 631
file content (4538 lines) | stat: -rw-r--r-- 143,010 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
<chapter id='Widget_Instantiation'>
<title>Widget Instantiation</title>
<para>
A hierarchy of widget instances constitutes a widget tree.
The shell widget returned by
<xref linkend='XtAppCreateShell' xrefstyle='select: title'/>
is the root of the widget tree instance.
The widgets with one or more children are the intermediate nodes of that tree,
and the widgets with no children of any kind are the leaves of the widget tree.
With the exception of pop-up children (see <xref linkend='Pop_Up_Widgets' />),
this widget tree instance defines the associated X Window tree.
</para>

<para>
Widgets can be either composite or primitive.
Both kinds of widgets can contain children,
but the Intrinsics provide a set of management mechanisms for constructing
and interfacing between composite widgets, their children, and
other clients.
</para>

<para>
Composite widgets, that is, members of the class
<function>compositeWidgetClass</function>,
are containers for an arbitrary,
but widget implementation-defined, collection of children,
which may be instantiated by the composite widget itself,
by other clients, or by a combination of the two.
Composite widgets also contain methods for managing the geometry (layout)
of any child widget.
Under unusual circumstances,
a composite widget may have zero children,
but it usually has at least one.
By contrast,
primitive widgets that contain children typically instantiate
specific children of known classes themselves and do not expect external
clients to do so.
Primitive widgets also do not have general geometry management methods.
</para>

<para>
In addition,
the Intrinsics recursively perform many operations
(for example, realization and destruction)
on composite widgets and all their children.
Primitive widgets that have children must be prepared
to perform the recursive operations themselves on behalf of their children.
</para>

<para>
A widget tree is manipulated by several Intrinsics functions.
For example,
<xref linkend='XtRealizeWidget' xrefstyle='select: title'/>
traverses the tree downward and recursively realizes all
pop-up widgets and children of composite widgets.
<xref linkend='XtDestroyWidget' xrefstyle='select: title'/>
traverses the tree downward and destroys all pop-up widgets
and children of composite widgets.
The functions that fetch and modify resources traverse the tree upward
and determine the inheritance of resources from a widget's ancestors.
<xref linkend='XtMakeGeometryRequest' xrefstyle='select: title'/>
traverses the tree up one level and calls the geometry manager
that is responsible for a widget child's geometry.
</para>

<para>
To facilitate upward traversal of the widget tree,
each widget has a pointer to its parent widget.
The
Shell
widget that
<xref linkend='XtAppCreateShell' xrefstyle='select: title'/>
returns has a <emphasis remap='I'>parent</emphasis> pointer of NULL.
</para>

<para>
To facilitate downward traversal of the widget tree,
the <emphasis remap='I'>children</emphasis> field of
each composite widget is a pointer to an array of child widgets,
which includes all normal children created,
not just the subset of children that are managed by the composite widget's
geometry manager.
Primitive widgets
that instantiate children are entirely responsible for all operations
that require downward traversal below themselves.
In addition,
every widget has a pointer to an array of pop-up children.
</para>

<sect1 id="Initializing_the_tk">
<title>Initializing the X Toolkit</title>
<para>
Before an application can call any Intrinsics function
other than
<function>XtSetLanguageProc</function>
and
<xref linkend='XtToolkitThreadInitialize' xrefstyle='select: title'/>,
it must initialize the Intrinsics by using
</para>
<itemizedlist spacing='compact'>
  <listitem>
    <para>
<xref linkend='XtToolkitInitialize' xrefstyle='select: title'/>,
which initializes the Intrinsics internals
    </para>
  </listitem>
  <listitem>
    <para>
<xref linkend='XtCreateApplicationContext' xrefstyle='select: title'/>,
which initializes the per-application state
    </para>
  </listitem>
  <listitem>
    <para>
<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/>
or
<xref linkend='XtOpenDisplay' xrefstyle='select: title'/>,
which initializes the per-display state
    </para>
  </listitem>
  <listitem>
    <para>
<xref linkend='XtAppCreateShell' xrefstyle='select: title'/>,
which creates the root of a widget tree
    </para>
  </listitem>
</itemizedlist>
<para>
Or an application can call the convenience procedure
<xref linkend='XtOpenApplication' xrefstyle='select: title'/>,
which combines the functions of the preceding procedures.
An application wishing to use the ANSI C locale mechanism should call
<function>XtSetLanguageProc</function>
prior to calling
<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/>,
<xref linkend='XtOpenDisplay' xrefstyle='select: title'/>,
<xref linkend='XtOpenApplication' xrefstyle='select: title'/>,
or
<xref linkend='XtAppInitialize' xrefstyle='select: title'/>.
</para>

<para>
Multiple instances of X Toolkit applications may be implemented
in a single address space.
Each instance needs to be able to read
input and dispatch events independently of any other instance.
Further, an application instance may need multiple display connections
to have widgets on multiple displays.
From the application's point of view, multiple display connections
usually are treated together as a single unit
for purposes of event dispatching.
To accommodate both requirements,
the Intrinsics define application contexts,
each of which provides the information needed to distinguish one application
instance from another.
The major component of an application context is a list of one or more X
<function>Display</function>
pointers for that application.
The Intrinsics handle all display connections within a single application
context simultaneously, handling input in a round-robin fashion.
The application context type
<function>XtAppContext</function>
is opaque to clients.
</para>

<para>
To initialize the Intrinsics internals, use
<xref linkend='XtToolkitInitialize' xrefstyle='select: title'/>.
</para>

<funcsynopsis id='XtToolkitInitialize'>
<funcprototype>
  <funcdef>void <function>XtToolkitInitialize</function></funcdef>
  <paramdef> <parameter></parameter></paramdef>
</funcprototype>
</funcsynopsis>

<para>
If
<xref linkend='XtToolkitInitialize' xrefstyle='select: title'/>
was previously called, it returns immediately.
When
<xref linkend='XtToolkitThreadInitialize' xrefstyle='select: title'/>
is called before
<xref linkend='XtToolkitInitialize' xrefstyle='select: title'/>,
the latter is protected against
simultaneous activation by multiple threads.
</para>

<para>
To create an application context, use
<xref linkend='XtCreateApplicationContext' xrefstyle='select: title'/>.
</para>

<funcsynopsis id='XtCreateApplicationContext'>
<funcprototype>
  <funcdef>XtAppContext <function>XtCreateApplicationContext</function></funcdef>
  <paramdef> <parameter></parameter></paramdef>
</funcprototype>
</funcsynopsis>


<para>
The
<xref linkend='XtCreateApplicationContext' xrefstyle='select: title'/>
function returns an application context,
which is an opaque type.
Every application must have at least one application context.
</para>

<para>
To destroy an application context and close any
remaining display connections in it, use
<xref linkend='XtDestroyApplicationContext' xrefstyle='select: title'/>.
</para>

<funcsynopsis id='XtDestroyApplicationContext'>
<funcprototype>
  <funcdef>void <function>XtDestroyApplicationContext</function></funcdef>
  <paramdef>XtAppContext <parameter>app_context</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>app_context</emphasis>
    </term>
    <listitem>
      <para>
Specifies the application context.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
The
<xref linkend='XtDestroyApplicationContext' xrefstyle='select: title'/>
function destroys the specified application context.
If called from within an event dispatch (for example, in a callback procedure),
<xref linkend='XtDestroyApplicationContext' xrefstyle='select: title'/>
does not destroy the application context until the dispatch is complete.
</para>

<para>
To get the application context in which a given widget was created, use
<xref linkend='XtWidgetToApplicationContext' xrefstyle='select: title'/>.
</para>

<funcsynopsis id='XtWidgetToApplicationContext'>
<funcprototype>
  <funcdef>XtAppContext <function>XtWidgetToApplicationContext</function></funcdef>
  <paramdef>Widget <parameter>w</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>w</emphasis>
    </term>
    <listitem>
      <para>
Specifies the widget for which you want the application context.  Must be of class Object or any subclass thereof.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
The
<xref linkend='XtWidgetToApplicationContext' xrefstyle='select: title'/>
function returns the application context for the specified widget.
</para>

<para>
To initialize a display and add it to an application context, use
<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/>.
</para>

<funcsynopsis id='XtDisplayInitialize'>
<funcprototype>
  <funcdef>void  <function>XtDisplayInitialize</function></funcdef>
      <paramdef>XtAppContext <parameter>app_context</parameter></paramdef>
      <paramdef>Display * <parameter>display</parameter></paramdef>
      <paramdef>String <parameter>application_name</parameter></paramdef>
      <paramdef>String <parameter>application_class</parameter></paramdef>
      <paramdef>XrmOptionDescRec * <parameter>options</parameter></paramdef>
      <paramdef>Cardinal <parameter>num_options</parameter></paramdef>
      <paramdef>int * <parameter>argc</parameter></paramdef>
      <paramdef>String * <parameter>argv</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>app_context</emphasis>
    </term>
    <listitem>
      <para>
Specifies the application context.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies a previously opened display connection.  Note that a single
display connection can be in at most one application context.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>application_name</emphasis>
    </term>
    <listitem>
      <para>
Specifies the name of the application instance.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>application_class</emphasis>
    </term>
    <listitem>
      <para>
Specifies the class name of this application,
which is usually the generic name for all instances of this application.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>options</emphasis>
    </term>
    <listitem>
      <para>
Specifies how to parse the command line for any application-specific resources.
The <emphasis remap='I'>options</emphasis> argument is passed as a parameter to
<function>XrmParseCommand</function>.
For further information,
see <olink targetdoc='libX11' targetptr='Parsing_Command_Line_Options'>Parsing Command Line Options</olink> in <olink targetdoc='libX11' targetptr='libX11'>Xlib — C Language X Interface</olink> and <xref linkend='Parsing_the_Command_Line' /> of this specification.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>num_options</emphasis>
    </term>
    <listitem>
      <para>
Specifies the number of entries in the options list.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>argc</emphasis>
    </term>
    <listitem>
      <para>
Specifies a pointer to the number of command line parameters.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>argv</emphasis>
    </term>
    <listitem>
      <para>
Specifies the list of command line parameters.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
The
<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/>
function retrieves the language string to be
used for the specified display (see <xref linkend='Finding_File_Names' />),
calls the language procedure (if set) with that language string,
builds the resource database for the default screen, calls the Xlib
<function>XrmParseCommand</function>
function to parse the command line,
and performs other per-display initialization.
After
<function>XrmParseCommand</function>
has been called,
<emphasis remap='I'>argc</emphasis> and <emphasis remap='I'>argv</emphasis> contain only those parameters that
were not in the standard option table or in the table specified by the
<emphasis remap='I'>options</emphasis> argument.
If the modified <emphasis remap='I'>argc</emphasis> is not zero,
most applications simply print out the modified <emphasis remap='I'>argv</emphasis> along with a message
listing the allowable options.
On POSIX-based systems,
the application name is usually the final component of <emphasis remap='I'>argv</emphasis>[0].
If the synchronous resource is
<function>True</function>,
<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/>
calls the Xlib
<function>XSynchronize</function>
function to put Xlib into synchronous mode for this display connection
and any others currently open in the application context.
See <xref linkend='Loading_the_Resource_Database' />
and <xref linkend='Parsing_the_Command_Line' />
for details on the <emphasis remap='I'>application_name</emphasis>,
<emphasis remap='I'>application_class</emphasis>, <emphasis remap='I'>options</emphasis>, and <emphasis remap='I'>num_options</emphasis> arguments.
</para>

<para>
<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/>
calls
<function>XrmSetDatabase</function>
to associate the resource database of the default screen with the
display before returning.
</para>

<para>
To open a display, initialize it, and then
add it to an application context, use
<xref linkend='XtOpenDisplay' xrefstyle='select: title'/>.
</para>

<funcsynopsis id='XtOpenDisplay'>
<funcprototype>
  <funcdef>Display <function>*XtOpenDisplay</function></funcdef>
       <paramdef>XtAppContext <parameter>app_context</parameter></paramdef>
       <paramdef>String <parameter>display_string</parameter></paramdef>
       <paramdef>String <parameter>application_name</parameter></paramdef>
       <paramdef>String <parameter>application_class</parameter></paramdef>
       <paramdef>XrmOptionDescRec * <parameter>options</parameter></paramdef>
       <paramdef>Cardinal <parameter>num_options</parameter></paramdef>
       <paramdef>int * <parameter>argc</parameter></paramdef>
       <paramdef>String * <parameter>argv</parameter></paramdef>
</funcprototype>
</funcsynopsis>




<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>app_context</emphasis>
    </term>
    <listitem>
      <para>
Specifies the application context.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>display_string</emphasis>
    </term>
    <listitem>
      <para>
Specifies the display string, or NULL.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>application_name</emphasis>
    </term>
    <listitem>
      <para>
Specifies the name of the application instance, or NULL.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>application_class</emphasis>
    </term>
    <listitem>
      <para>
Specifies the class name of this application,
which is usually the generic name for all instances of this application.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>options</emphasis>
    </term>
    <listitem>
      <para>
Specifies how to parse the command line for any application-specific resources.
The options argument is passed as a parameter to
<function>XrmParseCommand</function>.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>num_options</emphasis>
    </term>
    <listitem>
      <para>
Specifies the number of entries in the options list.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>argc</emphasis>
    </term>
    <listitem>
      <para>
Specifies a pointer to the number of command line parameters.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>argv</emphasis>
    </term>
    <listitem>
      <para>
Specifies the list of command line parameters.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
The
<xref linkend='XtOpenDisplay' xrefstyle='select: title'/>
function calls
<function>XOpenDisplay</function>
with the specified <emphasis remap='I'>display_string</emphasis>.
If <emphasis remap='I'>display_string</emphasis> is NULL,
<xref linkend='XtOpenDisplay' xrefstyle='select: title'/>
uses the current value of the \-display option specified in <emphasis remap='I'>argv</emphasis>.
If no display is specified in <emphasis remap='I'>argv</emphasis>,
the user's default display is retrieved from the environment.
On POSIX-based systems,
this is the value of the
<emphasis role='strong'>DISPLAY</emphasis>
environment variable.
</para>

<para>
If this succeeds,
<xref linkend='XtOpenDisplay' xrefstyle='select: title'/>
then calls
<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/>
and passes it the opened display and
the value of the \-name option specified in <emphasis remap='I'>argv</emphasis> as the application name.
If no \-name option is specified
and <emphasis remap='I'>application_name</emphasis> is
non-NULL, <emphasis remap='I'>application_name</emphasis> is passed to
<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/>.
If <emphasis remap='I'>application_name</emphasis> is NULL and if the environment variable
<emphasis role='strong'>RESOURCE_NAME</emphasis>
is set, the value of
<emphasis role='strong'>RESOURCE_NAME</emphasis>
is used.  Otherwise, the application
name is the name used to invoke the program.  On implementations that
conform to ANSI C Hosted Environment support, the application name will
be <emphasis remap='I'>argv</emphasis>[0] less any directory and file type components, that is, the
final component of <emphasis remap='I'>argv</emphasis>[0], if specified.  If <emphasis remap='I'>argv</emphasis>[0] does not exist or
is the empty string, the application name is ``main''.
<xref linkend='XtOpenDisplay' xrefstyle='select: title'/>
returns the newly opened display or NULL if it failed.
</para>

<para>
See <xref linkend='Using_the_Intrinsics_in_a_Multi_Threaded_Environment' />
for information regarding the use of
<xref linkend='XtOpenDisplay' xrefstyle='select: title'/>
in multiple threads.
</para>

<para>
To close a display and remove it from an application context, use
<xref linkend='XtCloseDisplay' xrefstyle='select: title'/>.
</para>

<funcsynopsis id='XtCloseDisplay'>
<funcprototype>
  <funcdef>void <function>XtCloseDisplay</function></funcdef>
       <paramdef>Display * <parameter>display</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the display.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
The
<xref linkend='XtCloseDisplay' xrefstyle='select: title'/>
function calls
<function>XCloseDisplay</function>
with the specified <emphasis remap='I'>display</emphasis> as soon as it is safe to do so.
If called from within an event dispatch (for example, a callback procedure),
<xref linkend='XtCloseDisplay' xrefstyle='select: title'/>
does not close the display until the dispatch is complete.
Note that applications need only call
<xref linkend='XtCloseDisplay' xrefstyle='select: title'/>
if they are to continue executing after closing the display;
otherwise, they should call
<xref linkend='XtDestroyApplicationContext' xrefstyle='select: title'/>.
</para>

<para>
See <xref linkend='Using_the_Intrinsics_in_a_Multi_Threaded_Environment' />
for information regarding the use of
<xref linkend='XtCloseDisplay' xrefstyle='select: title'/>
in multiple threads.
</para>
</sect1>

<sect1 id="Establishing_the_Locale">
<title>Establishing the Locale</title>
<para>
Resource databases are specified to be created in the current process
locale.  During display initialization prior to creating the
per-screen resource database, the Intrinsics will call out to a specified
application procedure to set the locale according to options found on
the command line or in the per-display resource specifications.
</para>

<para>
The callout procedure provided by the application is of type
<function>XtLanguageProc</function>.
</para>

<funcsynopsis>
<funcprototype>
  <funcdef>typedef String <function>(*XtLanguageProc)</function></funcdef>
  <paramdef>Display <parameter>display</parameter></paramdef>
  <paramdef>String <parameter>language</parameter></paramdef>
  <paramdef>XtPointer <parameter>client_data</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Passes the display.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>language</emphasis>
    </term>
    <listitem>
      <para>
Passes the initial language value obtained from the command line
or server per-display resource specifications.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>client_data</emphasis>
    </term>
    <listitem>
      <para>
Passes the additional client data specified in the call to
<function>XtSetLanguageProc</function>.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
The language procedure allows an application to set the locale to
the value of the language resource determined by
<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/>.
The function returns a new language string that
will be subsequently used by
<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/>
to establish the path for loading resource files.  The returned
string  will be copied by the Intrinsics into new memory.
</para>

<para>
Initially, no language procedure is set by the Intrinsics.
To set the language procedure for use by
<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/>,
use
<function>XtSetLanguageProc</function>.
</para>

<funcsynopsis>
<funcprototype>
  <funcdef>XtLanguageProc <function>XtSetLanguageProc</function></funcdef>
  <paramdef>XtAppContext <parameter>app_context</parameter></paramdef>
  <paramdef>XtLanguageProc <parameter>proc</parameter></paramdef>
  <paramdef>XtPointer <parameter>client_data</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>app_context</emphasis>
    </term>
    <listitem>
      <para>
Specifies the application context in which the language procedure is
to be used, or NULL.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>proc</emphasis>
    </term>
    <listitem>
      <para>
Specifies the language procedure.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>client_data</emphasis>
    </term>
    <listitem>
      <para>
Specifies additional client data to be passed to the language
procedure when it is called.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
<function>XtSetLanguageProc</function>
sets the language procedure that will be called from
<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/>
for all subsequent Displays initialized in the specified application
context.   If <emphasis remap='I'>app_context</emphasis> is NULL, the specified language
procedure is registered in all application contexts created by the
calling process, including any future application contexts that may
be created.   If <emphasis remap='I'>proc</emphasis> is NULL, a default language procedure is
registered.
<function>XtSetLanguageProc</function>
returns the previously registered language procedure.
If a language procedure has not yet been registered, the return value
is unspecified, but if this return value is used in a subsequent call to
<function>XtSetLanguageProc</function>,
it will cause the default language procedure to be registered.
</para>

<para>
The default language procedure does the following:
</para>
<itemizedlist spacing='compact'>
  <listitem>
    <para>
Sets the locale according to the environment.  On ANSI C-based
systems this is done by calling
<function>setlocale</function>(
<function>LC_ALL</function>,
<emphasis remap='I'>language</emphasis> ).
If an error is encountered, a warning message is issued with
<xref linkend='XtWarning' xrefstyle='select: title'/>.
    </para>
  </listitem>
  <listitem>
    <para>
Calls
<function>XSupportsLocale</function>
to verify that the current locale is supported.
If the locale is not supported, a warning message is issued with
<xref linkend='XtWarning' xrefstyle='select: title'/>
and the locale is set to ``C''.
    </para>
  </listitem>
  <listitem>
    <para>
Calls
<function>XSetLocaleModifiers</function>
specifying the empty string.
    </para>
  </listitem>
  <listitem>
    <para>
Returns the value of the current locale.  On ANSI C-based systems this
is the return value from a final call to
<function>setlocale</function>(
<function>LC_ALL</function>,
NULL ).
    </para>
  </listitem>
</itemizedlist>
<para>
A client wishing to use this mechanism to establish locale can do so
by calling
<function>XtSetLanguageProc</function>
prior to
<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/>,
as in the following example.
</para>
<literallayout>
	Widget top;
	XtSetLanguageProc(NULL, NULL, NULL);
	top = XtOpenApplication(...);
	...
</literallayout>
</sect1>

<sect1 id="Loading_the_Resource_Database">
<title>Loading the Resource Database</title>
<para>
The
<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/>
function first determines the language
string to be used for the specified display.  It then
creates a resource database for the default screen of the display by
combining the following sources in order, with the entries in the
first named source having highest precedence:
</para>
<itemizedlist spacing='compact'>
  <listitem>
    <para>
Application command line (<emphasis remap='I'>argc</emphasis>, <emphasis remap='I'>argv</emphasis>).
    </para>
  </listitem>
  <listitem>
    <para>
Per-host user environment resource file on the local host.
    </para>
  </listitem>
  <listitem>
    <para>
Per-screen resource specifications from the server.
    </para>
  </listitem>
  <listitem>
    <para>
Per-display resource specifications from the server or from
the user preference file on the local host.
    </para>
  </listitem>
  <listitem>
    <para>
Application-specific user resource file on the local host.
    </para>
  </listitem>
  <listitem>
    <para>
Application-specific class resource file on the local host.
    </para>
  </listitem>
</itemizedlist>
<para>
When the resource database for a particular screen on the display
is needed (either internally, or when
<xref linkend='XtScreenDatabase' xrefstyle='select: title'/>
is called),
it is created in the following manner using the sources listed
above in the same order:
</para>
<itemizedlist spacing='compact'>
  <listitem>
    <para>
A temporary database, the ``server resource database'', is
created from the string returned by
<function>XResourceManagerString</function>
or, if
<function>XResourceManagerString</function>
returns NULL, the contents of a resource file in the user's home
directory.  On POSIX-based systems, the usual name for this user
preference resource file is $HOME/<function>.Xdefaults</function>.
    </para>
  </listitem>
  <listitem>
    <para>
If a language procedure has been set,
<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/>
first searches the command line for the option ``-xnlLanguage'', or
for a -xrm option that specifies the xnlLanguage/XnlLanguage resource,
as specified by Section 2.4.
If such a resource is found, the value is assumed to be
entirely in XPCS, the X Portable Character Set.  If neither option is
specified on the command line,
<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/>
queries the server resource database (which is assumed to be entirely
in XPCS) for the resource
<emphasis remap='I'>name</emphasis><function>.xnlLanguage</function>, class <emphasis remap='I'>Class</emphasis><function>.XnlLanguage</function>
where <emphasis remap='I'>name</emphasis>
and <emphasis remap='I'>Class</emphasis> are the <emphasis remap='I'>application_name</emphasis> and
<emphasis remap='I'>application_class</emphasis> specified to
<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/>.
The language procedure is then invoked with
the resource value if found, else the empty string.  The
string returned from the language procedure is saved for all future
references in the Intrinsics that require the per-display language string.
    </para>
  </listitem>
  <listitem>
    <para>
The screen resource database is initialized by parsing the command
line in the manner specified by Section 2.4.
    </para>
  </listitem>
  <listitem>
    <para>
If a language procedure has not been set,
the initial database is then queried for the resource
<emphasis remap='I'>name</emphasis><function>.xnlLanguage</function>, class <emphasis remap='I'>Class</emphasis><function>.XnlLanguage</function>
as specified above.
If this database query fails, the server resource database is
queried; if this query also fails, the language is determined from
the environment; on POSIX-based systems, this is done by retrieving the
value of the
<emphasis role='strong'>LANG</emphasis>
environment variable.  If no language string is
found, the empty string is used.
This language string is saved for all future references in the Intrinsics
that require the per-display language string.
    </para>
  </listitem>
  <listitem>
    <para>
After determining the language string, the user's environment resource
file is then merged into the initial resource database if the file exists.
This file is user-, host-, and process-specific and is expected to
contain user preferences that are to override those specifications in
the per-display and per-screen resources.
On POSIX-based systems, the user's environment resource file name is
specified by the value of the
<emphasis role='strong'>XENVIRONMENT</emphasis>
environment variable.
If this environment variable does not exist, the user's home directory
is searched for a file named
<function>.Xdefaults-</function><emphasis>host</emphasis>,
where <emphasis remap='I'>host</emphasis> is the host name of the machine on which the
application is running.
    </para>
  </listitem>
  <listitem>
    <para>
The per-screen resource specifications are then merged into the screen
resource database, if they exist.  These specifications are the string
returned by
<function>XScreenResourceString</function>
for the respective screen and are owned entirely by the user.
    </para>
  </listitem>
  <listitem>
    <para>
Next, the server resource database created earlier is merged into the
screen resource database.  The server property, and corresponding user
preference file, are owned and constructed entirely by the user.
    </para>
  </listitem>
  <listitem>
    <para>
The application-specific user resource file from the local host is
then merged into the screen resource database.
This file contains user customizations and is stored
in a directory owned by the user.
Either the user or the application or both can store resource specifications
in the file.  Each should be prepared to find and respect entries made
by the other.
The file name is found by calling
<function>XrmSetDatabase</function>
with the current screen resource database, after preserving the
original display-associated database, then calling
<xref linkend='XtResolvePathname' xrefstyle='select: title'/>
with the parameters
(<emphasis remap='I'>display</emphasis>, NULL, NULL, NULL, <emphasis remap='I'>path</emphasis>, NULL, 0, NULL),
where <emphasis remap='I'>path</emphasis> is defined in an operating-system-specific way.
On POSIX-based systems, <emphasis remap='I'>path</emphasis> is defined to be the value
of the environment variable
<emphasis role='strong'>XUSERFILESEARCHPATH</emphasis>
if this is defined.  If
<emphasis role='strong'>XUSERFILESEARCHPATH</emphasis>
is not defined, an implementation-dependent default value is used.
This default value is constrained in the following manner:
    </para>
  </listitem>
  <listitem>
    <itemizedlist spacing='compact'>
      <listitem>
        <para>
If the environment variable
<emphasis role='strong'>XAPPLRESDIR</emphasis>
is not defined, the default
<emphasis role='strong'>XUSERFILESEARCHPATH</emphasis>
must contain at least six entries.  These entries must contain
$HOME as the directory prefix, plus the following substitutions:
        </para>
<literallayout>
      1.	%C, %N, %L	or	%C, %N, %l, %t, %c
      2.	%C, %N, %l
      3.	%C, %N
      4.	%N, %L	or	%N, %l, %t, %c
      5.	%N, %l
      6.	%N
</literallayout>
        <para>
The order of these six entries within the path must be as given above.
The order and use of substitutions within a given entry are
implementation-dependent.
        </para>
      </listitem>
      <listitem>
        <para> If
<emphasis role='strong'>XAPPLRESDIR</emphasis>
is defined, the default
<emphasis role='strong'>XUSERFILESEARCHPATH</emphasis>
must contain at least seven entries.  These entries must contain the
following directory prefixes and substitutions:
        </para>
<literallayout>
      1.	$XAPPLRESDIR	with	%C, %N, %L	or	%C, %N, %l, %t, %c
      2.	$XAPPLRESDIR	with	%C, %N, %l
      3.	$XAPPLRESDIR	with	%C, %N
      4.	$XAPPLRESDIR	with	%N, %L	or	%N, %l, %t, %c
      5.	$XAPPLRESDIR	with	%N, %l
      6.	$XAPPLRESDIR	with	%N
      7.	$HOME	with	%N
</literallayout>
        <para>
The order of these seven entries within the path must be as given above.
The order and use of substitutions within a given entry are
implementation-dependent.
        </para>
      </listitem>
    </itemizedlist>
  </listitem>
  <listitem>
    <para>
Last, the application-specific class resource file from the local
host is merged into the screen resource database.
This file is owned by the application and is usually installed in
a system directory when the application is installed.
It may contain sitewide customizations specified by the system manager.
The name of the application class resource file is found by calling
<xref linkend='XtResolvePathname' xrefstyle='select: title'/>
with the parameters
(<emphasis remap='I'>display</emphasis>, ``app-defaults'', NULL, NULL, NULL, NULL, 0, NULL).
This file is expected to be provided by the developer of the application
and may be required for the application to function properly.
A simple application that wants to be assured of having a minimal
set of resources in the absence of its class resource file can declare
fallback resource specifications with
<xref linkend='XtAppSetFallbackResources' xrefstyle='select: title'/>.
Note that the customization substitution string is retrieved
dynamically by
<xref linkend='XtResolvePathname' xrefstyle='select: title'/>
so that the resolved file name of the application class resource file
can be affected by any of the earlier sources for the screen resource
database, even though the contents of the class resource file have
lowest precedence.  After calling
<xref linkend='XtResolvePathname' xrefstyle='select: title'/>,
the original display-associated database is restored.
    </para>
  </listitem>
</itemizedlist>

<para>
To obtain the resource database for a particular screen, use
<xref linkend='XtScreenDatabase' xrefstyle='select: title'/>.
</para>

<funcsynopsis id='XtScreenDatabase'>
<funcprototype>
  <funcdef>XrmDatabase <function>XtScreenDatabase</function></funcdef>
      <paramdef>Screen * <parameter>screen</parameter></paramdef>
</funcprototype>
</funcsynopsis>


<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>screen</emphasis>
    </term>
    <listitem>
      <para>
Specifies the screen whose resource database is to be returned.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
The
<xref linkend='XtScreenDatabase' xrefstyle='select: title'/>
function returns the fully merged resource database as specified above,
associated with the specified screen.  If the specified <emphasis remap='I'>screen</emphasis>
does not belong to a
<function>Display</function>
initialized by
<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/>,
the results are undefined.
</para>

<para>
To obtain the default resource database associated with a particular display, use
<xref linkend='XtDatabase' xrefstyle='select: title'/>.
</para>


<funcsynopsis id='XtDatabase'>
<funcprototype>
  <funcdef>XrmDatabase <function>XtDatabase</function></funcdef>
      <paramdef>Display * <parameter>display</parameter></paramdef>
</funcprototype>
</funcsynopsis>


<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the display.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
The
<xref linkend='XtDatabase' xrefstyle='select: title'/>
function is equivalent to
<function>XrmGetDatabase</function>.
It returns the database associated with the specified display, or
NULL if a database has not been set.
</para>

<para>
To specify a default set of resource values that will be used to
initialize the resource database if no application-specific class
resource file is found (the last of the six sources listed above),
use
<xref linkend='XtAppSetFallbackResources' xrefstyle='select: title'/>.
</para>

<funcsynopsis id='XtAppSetFallbackResources'>
<funcprototype>
  <funcdef>void <function>XtAppSetFallbackResources</function></funcdef>
      <paramdef>XtAppContext * <parameter>app_context</parameter></paramdef>
      <paramdef>String * <parameter>specification_list</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>app_context</emphasis>
    </term>
    <listitem>
      <para>
Specifies the application context in which
the fallback specifications will be used.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>specification_list</emphasis>
    </term>
    <listitem>
      <para>
Specifies a NULL-terminated list of
resource specifications to preload
the database, or NULL.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
Each entry in <emphasis remap='I'>specification_list</emphasis> points to a string in the format of
<function>XrmPutLineResource</function>.
Following a call to
<xref linkend='XtAppSetFallbackResources' xrefstyle='select: title'/>,
when a resource database is being created for a particular screen and
the Intrinsics are not able
to find or read an application-specific class resource file according to the
rules given above and if <emphasis remap='I'>specification_list</emphasis> is not NULL, the
resource specifications in <emphasis remap='I'>specification_list</emphasis> will be merged
into the screen resource database in place of the application-specific
class resource file.
<xref linkend='XtAppSetFallbackResources' xrefstyle='select: title'/>
is not
required to copy <emphasis remap='I'>specification_list</emphasis>; the caller must ensure that the
contents of the list and of the strings addressed by the list remain
valid until all displays are initialized or until
<xref linkend='XtAppSetFallbackResources' xrefstyle='select: title'/>
is called again.  The value NULL for
<emphasis remap='I'>specification_list</emphasis> removes any previous fallback resource specification
for the application context.  The intended use for fallback resources
is to provide a minimal
number of resources that will make the application usable (or at
least terminate with helpful diagnostic messages) when some problem
exists in finding and loading the application defaults file.
</para>
</sect1>

<sect1 id="Parsing_the_Command_Line">
<title>Parsing the Command Line</title>
<para>
The
<xref linkend='XtOpenDisplay' xrefstyle='select: title'/>
function first parses the command line for the following options:
<variablelist>
  <varlistentry>
    <term>-display</term>
    <listitem>
      <para>
Specifies the display name for
<function>XOpenDisplay</function>.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>-name</term>
    <listitem>
      <para>
Sets the resource name prefix,
which overrides the application name passed to
<xref linkend='XtOpenDisplay' xrefstyle='select: title'/>.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>-xnllanguage</term>
    <listitem>
      <para>
Specifies the initial language string for establishing locale
and for finding application class resource files.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
</para>

<para>
<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/>
has a table of standard command line options that are passed to
<function>XrmParseCommand</function>
for adding resources to the resource database,
and it takes as a parameter additional
application-specific resource abbreviations.
The format of this table is described in Section 15.9 in <emphasis remap='I'>Xlib — C Language X Interface</emphasis>.
</para>
<literallayout>
typedef enum {
        XrmoptionNoArg,	/* Value is specified in OptionDescRec.value */
        XrmoptionIsArg,	/* Value is the option string itself */
        XrmoptionStickyArg,	/* Value is characters immediately following option */
        XrmoptionSepArg,	/* Value is next argument in argv */
        XrmoptionResArg,	/* Use the next argument as input to XrmPutLineResource*/
        XrmoptionSkipArg,	/* Ignore this option and the next argument in argv */
        XrmoptionSkipNArgs,	/* Ignore this option and the next */
                                /* OptionDescRec.value arguments in argv */
        XrmoptionSkipLine	/* Ignore this option and the rest of argv */
} XrmOptionKind;
typedef struct {
        char *option;	/* Option name in argv */
        char *specifier;	/* Resource name (without application name) */
        XrmOptionKind argKind;	/* Location of the resource value */
        XPointer value;	/* Value to provide if XrmoptionNoArg */
} XrmOptionDescRec, *XrmOptionDescList;
</literallayout>
<para>The standard table contains the following entries:</para>

<informaltable frame='topbot'>
  <?dbfo keep-together="always" ?>
  <tgroup cols='4' align='left' colsep='0' rowsep='0'>
  <colspec colwidth='1.0*' colname='c1'/>
  <colspec colwidth='1.0*' colname='c2'/>
  <colspec colwidth='1.0*' colname='c3'/>
  <colspec colwidth='1.0*' colname='c4'/>
  <thead>
    <row rowsep='1'>
      <entry>Option String</entry>
      <entry>Resource Name</entry>
      <entry>Argument Kind</entry>
      <entry>Resource Value</entry>
    </row>
  </thead>
  <tbody>
    <row>
      <entry>−background</entry>
      <entry>*background</entry>
      <entry>SepArg</entry>
      <entry>next argument</entry>
    </row>
    <row>
      <entry>−bd</entry>
      <entry>*borderColor</entry>
      <entry>SepArg</entry>
      <entry>next argument</entry>
    </row>
    <row>
      <entry>−bg</entry>
      <entry>*background</entry>
      <entry>SepArg</entry>
      <entry>next argument</entry>
    </row>
    <row>
      <entry>−borderwidth</entry>
      <entry>.borderWidth</entry>
      <entry>SepArg</entry>
      <entry>next argument</entry>
    </row>
    <row>
      <entry>−bordercolor</entry>
      <entry>*borderColor</entry>
      <entry>SepArg</entry>
      <entry>next argument</entry>
    </row>
    <row>
      <entry>−bw</entry>
      <entry>.borderWidth</entry>
      <entry>SepArg</entry>
      <entry>next argument</entry>
    </row>
    <row>
      <entry>−display</entry>
      <entry>.display</entry>
      <entry>SepArg</entry>
      <entry>next argument</entry>
    </row>
    <row>
      <entry>−fg</entry>
      <entry>*foreground</entry>
      <entry>SepArg</entry>
      <entry>next argument</entry>
    </row>
    <row>
      <entry>−fn</entry>
      <entry>*font</entry>
      <entry>SepArg</entry>
      <entry>next argument</entry>
    </row>
    <row>
      <entry>−font</entry>
      <entry>*font</entry>
      <entry>SepArg</entry>
      <entry>next argument</entry>
    </row>
    <row>
      <entry>−foreground</entry>
      <entry>*foreground</entry>
      <entry>SepArg</entry>
      <entry>next argument</entry>
    </row>
    <row>
      <entry>−geometry</entry>
      <entry>.geometry</entry>
      <entry>SepArg</entry>
      <entry>next argument</entry>
    </row>
    <row>
      <entry>−iconic</entry>
      <entry>.iconic</entry>
      <entry>NoArg</entry>
      <entry>"true"</entry>
    </row>
    <row>
      <entry>−name</entry>
      <entry>.name</entry>
      <entry>SepArg</entry>
      <entry>next argument</entry>
    </row>
    <row>
      <entry>−reverse</entry>
      <entry>.reverseVideo</entry>
      <entry>NoArg</entry>
      <entry>"on"</entry>
    </row>
    <row>
      <entry>−rv</entry>
      <entry>.reverseVideo</entry>
      <entry>NoArg</entry>
      <entry>"on"</entry>
    </row>
    <row>
      <entry>+rv</entry>
      <entry>.reverseVideo</entry>
      <entry>NoArg</entry>
      <entry>"off"</entry>
    </row>
    <row>
      <entry>−selectionTimeout</entry>
      <entry>.selectionTimeout</entry>
      <entry>SepArg</entry>
      <entry>next argument</entry>
    </row>
    <row>
      <entry>−synchronous</entry>
      <entry>.synchronous</entry>
      <entry>NoArg</entry>
      <entry>"on"</entry>
    </row>
    <row>
      <entry>+synchronous</entry>
      <entry>.synchronous</entry>
      <entry>NoArg</entry>
      <entry>"off"</entry>
    </row>
    <row>
      <entry>−title</entry>
      <entry>.title</entry>
      <entry>SepArg</entry>
      <entry>next argument</entry>
    </row>
    <row>
      <entry>−xnllanguage</entry>
      <entry>.xnlLanguage</entry>
      <entry>SepArg</entry>
      <entry>next argument</entry>
    </row>
    <row>
      <entry>−xrm</entry>
      <entry>next argument</entry>
      <entry>ResArg</entry>
      <entry>next argument</entry>
    </row>
    <row>
      <entry>−xtsessionID</entry>
      <entry>.sessionID</entry>
      <entry>SepArg</entry>
      <entry>next argument</entry>
    </row>
  </tbody>
  </tgroup>
</informaltable>

<para>
Note that any unique abbreviation for an option name in the standard table
or in the application table is accepted.
</para>

<para>
If reverseVideo is
<function>True</function>,
the values of
<function>XtDefaultForeground</function>
and
<function>XtDefaultBackground</function>
are exchanged for all screens on the Display.
</para>

<para>
The value of the synchronous resource specifies whether or not
Xlib is put into synchronous mode.  If a value is found in the resource
database during display initialization,
<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/>
makes a call to
<function>XSynchronize</function>
for all display
connections currently open in the application context.  Therefore,
when multiple displays are initialized in the same application
context, the most recent value specified for the synchronous resource
is used for all displays in the application context.
</para>

<para>
The value of the selectionTimeout resource applies to all displays
opened in the same application context.  When multiple displays are
initialized in the same application context, the most recent value
specified is used for all displays in the application context.
</para>

<para>
The -xrm option provides a method of setting any resource in an application.
The next argument should be a quoted string identical in format to a line in
the user resource file.
For example,
to give a red background to all command buttons in an application named
<function>xmh</function>,
you can start it up as
</para>
<literallayout>
xmh -xrm 'xmh*Command.background: red'
</literallayout>
<para>
When it parses the command line,
<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/>
merges the application option table with the standard option table
before calling the Xlib
<function>XrmParseCommand</function>
function.
An entry in the application table with the same name as an entry
in the standard table overrides the standard table entry.
If an option name is a prefix of another option name,
both names are kept in the merged table.
The Intrinsics reserve all option names
beginning with the characters ``-xt'' for future standard uses.
</para>
</sect1>

<sect1 id="Creating_Widgets">
<title>Creating Widgets</title>
<para>
The creation of widget instances is a three-phase process:
</para>

<orderedlist>
  <listitem>
    <para>
The widgets are allocated and initialized with resources
and are optionally added to the managed subset of their parent.
    </para>
  </listitem>
  <listitem>
    <para>
All composite widgets are notified of their managed children
in a bottom-up traversal of the widget tree.
    </para>
  </listitem>
  <listitem>
    <para>
The widgets create X windows, which then are mapped.
    </para>
  </listitem>
</orderedlist>
<para>
To start the first phase,
the application calls
<xref linkend='XtCreateWidget' xrefstyle='select: title'/>
for all its widgets and adds some (usually, most or all) of its widgets
to their respective parents' managed set by calling
<xref linkend='XtManageChild' xrefstyle='select: title'/>.
To avoid an O(n<superscript>2</superscript>) creation process where each composite widget
lays itself out each time a widget is created and managed,
parent widgets are not notified of changes in their managed set
during this phase.
</para>

<para>
After all widgets have been created,
the application calls
<xref linkend='XtRealizeWidget' xrefstyle='select: title'/>
with the top-level widget to execute the second and third phases.
<xref linkend='XtRealizeWidget' xrefstyle='select: title'/>
first recursively traverses the widget tree in a postorder (bottom-up)
traversal and then notifies each composite widget with one
or more managed children by means of its change_managed procedure.
</para>

<para>
Notifying a parent about its managed set involves geometry layout and
possibly geometry negotiation.
A parent deals with constraints on its size imposed from above
(for example, when a user specifies the application window size)
and suggestions made from below (for example,
when a primitive child computes its preferred size).
One difference between the two can cause geometry changes to ripple
in both directions through the widget tree.
The parent may force some of its children to change size and position
and may issue geometry requests to its own parent in order to better
accommodate all its children.
You cannot predict where anything will go on the screen
until this process finishes.
</para>

<para>
Consequently, in the first and second phases,
no X windows are actually created, because it is likely
that they will get moved around after creation.
This avoids unnecessary requests to the X server.
</para>

<para>
Finally,
<xref linkend='XtRealizeWidget' xrefstyle='select: title'/>
starts the third phase by making a preorder (top-down) traversal
of the widget tree, allocates an X window to each widget by means of
its realize procedure, and finally maps the widgets that are managed.
</para>

<sect2 id="Creating_and_Merging_Argument_Lists">
<title>Creating and Merging Argument Lists</title>
<para>
Many Intrinsics functions may be passed pairs of resource names and
values.
These are passed as an arglist, a pointer to an array of
<function>Arg</function>
structures, which contains
</para>
<literallayout>
typedef struct {
	String name;
	XtArgVal value;
} Arg, *ArgList;
</literallayout>
<para>
where
<function>XtArgVal</function>
is as defined in Section 1.5.
</para>

<para>
If the size of the resource is less than or equal to the size of an
<function>XtArgVal</function>,
the resource value is stored directly in <emphasis remap='I'>value</emphasis>;
otherwise, a pointer to it is stored in <emphasis remap='I'>value</emphasis>.
</para>

<para>
To set values in an
<function>ArgList</function>,
use
<xref linkend='XtSetArg' xrefstyle='select: title'/>.
</para>

<funcsynopsis id='XtSetArg'>
<funcprototype>
  <funcdef>void <function>XtSetArg</function></funcdef>
  <paramdef>Arg <parameter>arg</parameter></paramdef>
  <paramdef>String <parameter>name</parameter></paramdef>
  <paramdef>XtArgVal <parameter>value</parameter></paramdef>
</funcprototype>
</funcsynopsis>


<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>arg</emphasis>
    </term>
    <listitem>
      <para>
Specifies the <emphasis remap='I'>name/value</emphasis> pair to set.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>name</emphasis>
    </term>
    <listitem>
      <para>
Specifies the name of the resource.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>value</emphasis>
    </term>
    <listitem>
      <para>
Specifies the value of the resource if it will fit in an
<function>XtArgVal</function>,
else the address.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
The
<xref linkend='XtSetArg' xrefstyle='select: title'/>
function is usually used in a highly stylized manner to
minimize the probability of making a mistake; for example:
</para>
<literallayout>
Arg args[20];
int n;
n = 0;
XtSetArg(args[n], XtNheight, 100);	n++;
XtSetArg(args[n], XtNwidth, 200);	n++;
XtSetValues(widget, args, n);
</literallayout>
<para>
Alternatively, an application can statically declare the argument list
and use
<xref linkend='XtNumber' xrefstyle='select: title'/>:
</para>
<literallayout>
static Args args[] = {
	{XtNheight, (XtArgVal) 100},
	{XtNwidth, (XtArgVal) 200},
};
XtSetValues(Widget, args, XtNumber(args));
</literallayout>
<para>
Note that you should not use expressions with side effects such as
auto-increment or auto-decrement
within the first argument to
<xref linkend='XtSetArg' xrefstyle='select: title'/>.
<xref linkend='XtSetArg' xrefstyle='select: title'/>
can be implemented as a macro that evaluates the first argument twice.
</para>

<para>
To merge two
arglist arrays, use
<xref linkend='XtMergeArgLists' xrefstyle='select: title'/>.
</para>

<funcsynopsis id='XtMergeArgLists'>
<funcprototype>
  <funcdef>ArgList <function>XtMergeArgLists</function></funcdef>
     <paramdef>ArgList <parameter>args1</parameter></paramdef>
     <paramdef>Cardinal <parameter>num_args1</parameter></paramdef>
     <paramdef>ArgList <parameter>args2</parameter></paramdef>
     <paramdef>Cardinal <parameter>num_args2</parameter></paramdef>
</funcprototype>
</funcsynopsis>


<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>args1</emphasis>
    </term>
    <listitem>
      <para>
Specifies the first argument list.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>num_args1</emphasis>
    </term>
    <listitem>
      <para>
Specifies the number of entries in the first argument list.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>args2</emphasis>
    </term>
    <listitem>
      <para>
Specifies the second argument list.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>num_args2</emphasis>
    </term>
    <listitem>
      <para>
Specifies the number of entries in the second argument list.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
The
<xref linkend='XtMergeArgLists' xrefstyle='select: title'/>
function allocates enough storage to hold the combined
arglist arrays and copies them into it.
Note that it does not check for duplicate entries.
The length of the returned list is the sum of the lengths of the
specified lists.
When it is no longer needed,
free the returned storage by using
<xref linkend='XtFree' xrefstyle='select: title'/>.
</para>

<para>
All Intrinsics interfaces that require
<function>ArgList</function>
arguments have analogs
conforming to the ANSI C variable argument list
(traditionally called ``varargs'')
calling convention.  The name of the analog is formed by prefixing
``Va'' to the name of the corresponding
<function>ArgList</function>
procedure; e.g.,
<xref linkend='XtVaCreateWidget' xrefstyle='select: title'/>.
Each procedure named <function>XtVa</function><emphasis remap='I'>something</emphasis> takes as its
last arguments, in place of the corresponding
<function>ArgList</function>/
<function>Cardinal</function>
parameters, a variable parameter list of resource name and
value pairs where each name is of type
<function>String</function>
and each value is of type
<function>XtArgVal</function>.
The end of the list is identified by a <emphasis remap='I'>name</emphasis> entry
containing NULL.  Developers writing in the C language wishing to pass
resource name and value pairs to any of these interfaces may use the
<function>ArgList</function>
and varargs forms interchangeably.
</para>

<para>
Two special names are defined for use only in varargs lists:
<function>XtVaTypedArg</function>
and
<function>XtVaNestedList</function>.
</para>
<literallayout>
#define XtVaTypedArg "XtVaTypedArg"
</literallayout>
<para>
If the name
<function>XtVaTypedArg</function>
is specified in place of a resource
name, then the following four arguments are interpreted as a
<emphasis remap='I'>name/type/value/size</emphasis> tuple <emphasis remap='I'>where</emphasis> name is of type
<function>String</function>,
<emphasis remap='I'>type</emphasis> is of type
<function>String</function>,
<emphasis remap='I'>value</emphasis> is of type
<function>XtArgVal</function>,
and <emphasis remap='I'>size</emphasis> is of type int.  When a varargs list containing
<function>XtVaTypedArg</function>
is processed, a resource type
conversion (see <xref linkend='Resource_Conversions' />) is performed if necessary to convert the
value into the format required by the associated resource.  If <emphasis remap='I'>type</emphasis> is
XtRString, then <emphasis remap='I'>value</emphasis> contains a pointer to the string and <emphasis remap='I'>size</emphasis>
contains the number of bytes allocated, including the trailing null
byte.  If <emphasis remap='I'>type</emphasis> is not XtRString, then <emphasis remap='I'>if</emphasis> size is
less than or equal to
<function>sizeof</function>(<function>XtArgVal</function>), the value should be the data cast to the type
<function>XtArgVal</function>,
otherwise <emphasis remap='I'>value</emphasis> is a pointer to the data.  If the type
conversion fails for any reason, a warning message is issued and the
list entry is skipped.
</para>
<literallayout>
#define XtVaNestedList  "XtVaNestedList"
</literallayout>
<para>
If the name
<function>XtVaNestedList</function>
is specified in place of a resource name,
then the following argument is interpreted as an
<function>XtVarArgsList</function>
value, which specifies another
varargs list that is logically inserted into the original list at the
point of declaration.  The end of the nested list is identified with a
name entry containing NULL.  Varargs lists may nest to any depth.
</para>

<para>
To dynamically allocate a varargs list for use with
<function>XtVaNestedList</function>
in multiple calls, use
<xref linkend='XtVaCreateArgsList' xrefstyle='select: title'/>.
</para>
<literallayout>
typedef XtPointer XtVarArgsList;
</literallayout>

<funcsynopsis id='XtVaCreateArgsList'>
<funcprototype>
  <funcdef>XtVarArgsList <function>XtVaCreateArgsList</function></funcdef>
     <paramdef>XtPointer <parameter>unused</parameter></paramdef>
     <paramdef> <parameter>...</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>unused</emphasis>
    </term>
    <listitem>
      <para>
This argument is not currently used and must be specified as NULL.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      ...
    </term>
    <listitem>
      <para>
Specifies a variable parameter list of resource
name and value pairs.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
The
<xref linkend='XtVaCreateArgsList' xrefstyle='select: title'/>
function allocates memory and copies its arguments into a
single list pointer, which may be used with
<function>XtVaNestedList</function>.
The end of
both lists is identified by a <emphasis remap='I'>name</emphasis> entry containing NULL.  Any entries
of type
<function>XtVaTypedArg</function>
are copied as specified without applying
conversions.  Data passed by reference (including Strings) are not
copied, only the pointers themselves; the caller must ensure that the
data remain valid for the lifetime of the created varargs list.  The
list should be freed using
<xref linkend='XtFree' xrefstyle='select: title'/>
when no longer needed.
</para>

<para>
Use of resource files and of the resource database is generally
encouraged over lengthy arglist or varargs lists whenever possible in
order to permit modification without recompilation.
</para>
</sect2>

<sect2 id="Creating_a_Widget_Instance">
<title>Creating a Widget Instance</title>
<para>
To create an instance of a widget, use
<xref linkend='XtCreateWidget' xrefstyle='select: title'/>.
</para>

<funcsynopsis id='XtCreateWidget'>
<funcprototype>
  <funcdef>Widget <function>XtCreateWidget</function></funcdef>
      <paramdef>String <parameter>name</parameter></paramdef>
      <paramdef>WidgetClass <parameter>object_class</parameter></paramdef>
      <paramdef>Widget <parameter>parent</parameter></paramdef>
      <paramdef>ArgList <parameter>args</parameter></paramdef>
      <paramdef>Cardinal <parameter>num_args</parameter></paramdef>
</funcprototype>
</funcsynopsis>


<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>name</emphasis>
    </term>
    <listitem>
      <para>
Specifies the resource instance name for the created widget,
which is used for retrieving resources
and, for that reason, should not be the same as any other widget
that is a child of the same parent.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>object_class</emphasis>
    </term>
    <listitem>
      <para>
Specifies the widget class pointer for the created object.  Must be <emphasis role='strong'>objectClass</emphasis> or any subclass thereof.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>parent</emphasis>
    </term>
    <listitem>
      <para>
Specifies the parent widget.  Must be of class Object or any subclass thereof.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>args</emphasis>
    </term>
    <listitem>
      <para>
Specifies the argument list to override any other resource specifications.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>num_args</emphasis>
    </term>
    <listitem>
      <para>
Specifies the number of entries in the argument list.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
The
<xref linkend='XtCreateWidget' xrefstyle='select: title'/>
function performs all the boilerplate operations of widget
creation, doing the following in order:
</para>
<itemizedlist spacing='compact'>
  <listitem>
    <para>
Checks to see if the class_initialize procedure has been called for this class
and for all superclasses and, if not, calls those necessary in a
superclass-to-subclass order.
    </para>
  </listitem>
  <listitem>
    <para>
If the specified class is not
<function>coreWidgetClass</function>
or a subclass thereof,
and the parent's class is a subclass of
<function>compositeWidgetClass</function>
and either no extension record in
the parent's composite class part extension field exists with the
<emphasis remap='I'>record_type</emphasis>
<emphasis role='strong'>NULLQUARK</emphasis>
or the <emphasis remap='I'>accepts_objects</emphasis> field in the extension
record is
<function>False</function>,
<xref linkend='XtCreateWidget' xrefstyle='select: title'/>
issues a fatal error; see <xref linkend='Addition_of_Children_to_a_Composite_Widget_The_insert_child_Procedure' /> and <xref linkend='Nonwidget_Objects' />.
    </para>
  </listitem>
  <listitem>
    <para>
If the specified class contains an extension record in the object class
part <emphasis remap='I'>extension</emphasis> field with <emphasis remap='I'>record_type</emphasis>
<emphasis role='strong'>NULLQUARK</emphasis>
and the <emphasis remap='I'>allocate</emphasis> field is not NULL,
the procedure is invoked to allocate memory
for the widget instance.  If the parent is a member of the class
<function>constraintWidgetClass</function>,
the procedure also allocates memory for the
parent's constraints and stores the address of this memory into the
<emphasis remap='I'>constraints</emphasis> field.  If no allocate procedure is found, the Intrinsics
allocate memory for the widget and, when applicable, the constraints,
and initializes the <emphasis remap='I'>constraints</emphasis> field.
    </para>
  </listitem>
  <listitem>
    <para>
Initializes the Core nonresource data fields
<emphasis remap='I'>self</emphasis>, <emphasis remap='I'>parent</emphasis>, <emphasis remap='I'>widget_class</emphasis>, <emphasis remap='I'>being_destroyed</emphasis>,
<emphasis remap='I'>name</emphasis>, <emphasis remap='I'>managed</emphasis>, <emphasis remap='I'>window</emphasis>, <emphasis remap='I'>visible</emphasis>,
<emphasis remap='I'>popup_list</emphasis>, and <emphasis remap='I'>num_popups</emphasis>.
    </para>
  </listitem>
  <listitem>
    <para>
Initializes the resource fields (for example, <emphasis remap='I'>background_pixel</emphasis>)
by using the
<function>CoreClassPart</function>
resource lists specified for this class and all superclasses.
    </para>
  </listitem>
  <listitem>
    <para>
If the parent is a member of the class
<function>constraintWidgetClass</function>,
initializes the resource fields of the constraints record
by using the
<function>ConstraintClassPart</function>
resource lists specified for the parent's class
and all superclasses up to
<function>constraintWidgetClass</function>.
    </para>
  </listitem>
  <listitem>
    <para>
Calls the initialize procedures for the widget starting at the
Object
initialize procedure on down to the widget's initialize procedure.
    </para>
  </listitem>
  <listitem>
    <para>
If the parent is a member of the class
<function>constraintWidgetClass</function>,
calls the
<function>ConstraintClassPart</function>
initialize procedures,
starting at
<function>constraintWidgetClass</function>
on down to the parent's
<function>ConstraintClassPart</function>
initialize procedure.
    </para>
  </listitem>
  <listitem>
    <para>
If the parent is a member of the class
<function>compositeWidgetClass</function>,
puts the widget into its parent's children list by calling its parent's
insert_child procedure.
For further information,
see <xref linkend='Addition_of_Children_to_a_Composite_Widget_The_insert_child_Procedure' />.
    </para>
  </listitem>
</itemizedlist>
<para>
To create an instance of a widget using varargs lists, use
<xref linkend='XtVaCreateWidget' xrefstyle='select: title'/>.
</para>

<funcsynopsis id='XtVaCreateWidget'>
<funcprototype>
  <funcdef>Widget <function>XtVaCreateWidget</function></funcdef>
      <paramdef>String <parameter>name</parameter></paramdef>
      <paramdef>WidgetClass <parameter>object_class</parameter></paramdef>
      <paramdef>Widget <parameter>parent</parameter></paramdef>
      <paramdef> <parameter>...</parameter></paramdef>
</funcprototype>
</funcsynopsis>


<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>name</emphasis>
    </term>
    <listitem>
      <para>
Specifies the resource name for the created widget.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>object_class</emphasis>
    </term>
    <listitem>
      <para>
Specifies the widget class pointer for the created object.  Must be <emphasis role='strong'>objectClass</emphasis> or any subclass thereof.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>parent</emphasis>
    </term>
    <listitem>
      <para>
Specifies the parent widget.  Must be of class Object or any subclass thereof.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      ...
    </term>
    <listitem>
      <para>
Specifies the variable argument list to override any other
resource specifications.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
The
<xref linkend='XtVaCreateWidget' xrefstyle='select: title'/>
procedure is identical in function to
<xref linkend='XtCreateWidget' xrefstyle='select: title'/>
with the <emphasis remap='I'>args</emphasis> and <emphasis remap='I'>num_args</emphasis> parameters replaced by a varargs list,
as described
in Section 2.5.1.
</para>
</sect2>

<sect2 id="Creating_an_Application_Shell_Instance">
<title>Creating an Application Shell Instance</title>
<para>
An application can have multiple top-level widgets, each of which
specifies a unique widget tree
that can potentially be on different screens or displays.
An application uses
<xref linkend='XtAppCreateShell' xrefstyle='select: title'/>
to create independent widget trees.
</para>

<funcsynopsis id='XtAppCreateShell'>
<funcprototype>
  <funcdef>Widget <function>XtAppCreateShell</function></funcdef>
      <paramdef>String <parameter>name</parameter></paramdef>
      <paramdef>String <parameter>application_class</parameter></paramdef>
      <paramdef>WidgetClass <parameter>widget_class</parameter></paramdef>
      <paramdef>Display * <parameter>display</parameter></paramdef>
      <paramdef>ArgList <parameter>args</parameter></paramdef>
      <paramdef>Cardinal <parameter>num_args</parameter></paramdef>
</funcprototype>
</funcsynopsis>


<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>name</emphasis>
    </term>
    <listitem>
      <para>
Specifies the instance name of the shell widget.
If <emphasis remap='I'>name</emphasis> is NULL,
the application name passed to
<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/>
is used.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>application_class</emphasis>
    </term>
    <listitem>
      <para>
Specifies the resource class string to be used in
place of the widget <emphasis remap='I'>class_name</emphasis> string when
<emphasis remap='I'>widget_class</emphasis> is
<function>applicationShellWidgetClass</function>
or a subclass thereof.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>widget_class</emphasis>
    </term>
    <listitem>
      <para>
Specifies the widget class for the top-level widget (e.g.,
<function>applicationShellWidgetClass ).</function>
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the display for the default screen
and for the resource database used to retrieve
the shell widget resources.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>args</emphasis>
    </term>
    <listitem>
      <para>
Specifies the argument list to override any other resource specifications.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>num_args</emphasis>
    </term>
    <listitem>
      <para>
Specifies the number of entries in the argument list.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
The
<xref linkend='XtAppCreateShell' xrefstyle='select: title'/>
function
creates a new shell widget instance as the root of a widget tree.
The screen resource for this widget is determined by first scanning
<emphasis remap='I'>args</emphasis> for the XtNscreen argument.  If no XtNscreen argument is
found, the resource database associated with the default screen of
the specified display is queried for the resource <emphasis remap='I'>name</emphasis>.screen,
class <emphasis remap='I'>Class</emphasis>.Screen where <emphasis remap='I'>Class</emphasis> is the specified
<emphasis remap='I'>application_class</emphasis> if <emphasis remap='I'>widget_class</emphasis> is
<function>applicationShellWidgetClass</function>
or a subclass thereof.  If <emphasis remap='I'>widget_class</emphasis> is not
<function>application\%Shell\%Widget\%Class</function>
or a subclass, <emphasis remap='I'>Class</emphasis> is the <emphasis remap='I'>class_name</emphasis>
field from the
<function>CoreClassPart</function>
of the specified <emphasis remap='I'>widget_class</emphasis>.
If this query fails, the default
screen of the specified display is used.  Once the screen is determined,
the resource database associated with that screen is used to retrieve
all remaining resources for the shell widget not specified in
<emphasis remap='I'>args</emphasis>.  The widget name and <emphasis remap='I'>Class</emphasis> as determined above are
used as the leftmost (i.e., root) components in all fully qualified
resource names for objects within this widget tree.
</para>

<para>
If the specified widget class is a subclass of WMShell, the name and
<emphasis remap='I'>Class</emphasis> as determined above will be stored into the
<emphasis role='strong'>WM_CLASS</emphasis>
property on the widget's window when it becomes realized.
If the specified <emphasis remap='I'>widget_class</emphasis> is
<function>applicationShellWidgetClass</function>
or a subclass thereof, the
<emphasis role='strong'>WM_COMMAND</emphasis>
property will also be set from the values of the XtNargv and
XtNargc resources.
</para>

<para>
To create multiple top-level shells within a single (logical)
application,
you can use one of two methods:
</para>
<itemizedlist spacing='compact'>
  <listitem>
    <para>
Designate one shell as the real top-level shell and
create the others as pop-up children of it by using
<xref linkend='XtCreatePopupShell' xrefstyle='select: title'/>.
    </para>
  </listitem>
  <listitem>
    <para>
Have all shells as pop-up children of an unrealized top-level shell.
    </para>
  </listitem>
</itemizedlist>
<para>
The first method,
which is best used when there is a clear choice for what is the main window,
leads to resource specifications like the following:
</para>
<literallayout>
xmail.geometry:...	(the main window)
xmail.read.geometry:...	(the read window)
xmail.compose.geometry:...	(the compose window)
</literallayout>
<para>
The second method,
which is best if there is no main window,
leads to resource specifications like the following:
</para>
<literallayout>
xmail.headers.geometry:...	(the headers window)
xmail.read.geometry:...	(the read window)
xmail.compose.geometry:...	(the compose window)
</literallayout>
<para>
To create a top-level widget that is the root of a widget tree using
varargs lists, use
<xref linkend='XtVaAppCreateShell' xrefstyle='select: title'/>.
</para>

<funcsynopsis id='XtVaAppCreateShell'>
<funcprototype>
  <funcdef>Widget <function>XtVaAppCreateShell</function></funcdef>
      <paramdef>String <parameter>name</parameter></paramdef>
      <paramdef>String <parameter>application_class</parameter></paramdef>
      <paramdef>WidgetClass <parameter>widget_class</parameter></paramdef>
      <paramdef>Display * <parameter>display</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>name</emphasis>
    </term>
    <listitem>
      <para>
Specifies the instance name of the shell widget.
If <emphasis remap='I'>name</emphasis> is NULL,
the application name passed to
<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/>
is used.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>application_class</emphasis>
    </term>
    <listitem>
      <para>
Specifies the resource class string to be used in
place of the widget <emphasis remap='I'>class_name</emphasis> string when
<emphasis remap='I'>widget_class</emphasis> is
<function>applicationShellWidgetClass</function>
or a subclass thereof.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>widget_class</emphasis>
    </term>
    <listitem>
      <para>
Specifies the widget class for the top-level widget.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the display for the default screen
and for the resource database used to retrieve
the shell widget resources.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      ...
    </term>
    <listitem>
      <para>
Specifies the variable argument list to override any other
resource specifications.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
The
<xref linkend='XtVaAppCreateShell' xrefstyle='select: title'/>
procedure is identical in function to
<xref linkend='XtAppCreateShell' xrefstyle='select: title'/>
with the <emphasis remap='I'>args</emphasis> and <emphasis remap='I'>num_args</emphasis> parameters replaced by a varargs list, as
described in Section 2.5.1.
</para>
</sect2>

<sect2 id="Convenience_Procedure_to_Initialize_an_Application">
<title>Convenience Procedure to Initialize an Application</title>
<para>
To initialize the Intrinsics internals, create an application context,
open and initialize a display, and create the initial root shell
instance, an application may use
<xref linkend='XtOpenApplication' xrefstyle='select: title'/>
or
<xref linkend='XtVaOpenApplication' xrefstyle='select: title'/>.
</para>

<funcsynopsis id='XtOpenApplication'>
<funcprototype>
  <funcdef>Widget <function>XtOpenApplication</function></funcdef>
      <paramdef>XtAppContext * <parameter>app_context_return</parameter></paramdef>
      <paramdef>String <parameter>application_class</parameter></paramdef>
      <paramdef>XrmOptionDescList <parameter>options</parameter></paramdef>
      <paramdef>Cardinal <parameter>num_options</parameter></paramdef>
      <paramdef>int * <parameter>argc_in_out</parameter></paramdef>
      <paramdef>String * <parameter>argv_in_out</parameter></paramdef>
      <paramdef>String * <parameter>fallback_resources</parameter></paramdef>
      <paramdef>WidgetClass <parameter>widget_class</parameter></paramdef>
      <paramdef>ArgList <parameter>args</parameter></paramdef>
      <paramdef>Cardinal <parameter>num_args</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>app_context_return</emphasis>
    </term>
    <listitem>
      <para>
Returns the application context, if non-NULL.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>application_class</emphasis>
    </term>
    <listitem>
      <para>
Specifies the class name of the application.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>options</emphasis>
    </term>
    <listitem>
      <para>
Specifies the command line options table.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>num_options</emphasis>
    </term>
    <listitem>
      <para>
Specifies the number of entries in <emphasis remap='I'>options</emphasis>.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>argc_in_out</emphasis>
    </term>
    <listitem>
      <para>
Specifies a pointer to the number of command line arguments.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>argv_in_out</emphasis>
    </term>
    <listitem>
      <para>
Specifies a pointer to the command line arguments.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>fallback_resources</emphasis>
    </term>
    <listitem>
      <para>
Specifies resource values to be used if the application class resource
file cannot be opened or read, or NULL.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>widget_class</emphasis>
    </term>
    <listitem>
      <para>
Specifies the class of the widget to be created.  Must be shellWidgetClass
or a subclass.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>args</emphasis>
    </term>
    <listitem>
      <para>
Specifies the argument list to override any
other resource specifications for the created shell widget.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>num_args</emphasis>
    </term>
    <listitem>
      <para>
Specifies the number of entries in the argument list.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
The
<xref linkend='XtOpenApplication' xrefstyle='select: title'/>
function calls
<xref linkend='XtToolkitInitialize' xrefstyle='select: title'/>
followed by
<xref linkend='XtCreateApplicationContext' xrefstyle='select: title'/>,
then calls
<xref linkend='XtOpenDisplay' xrefstyle='select: title'/>
with <emphasis remap='I'>display_string</emphasis> NULL and
<emphasis remap='I'>application_name</emphasis> NULL, and finally calls
<xref linkend='XtAppCreateShell' xrefstyle='select: title'/>
with <emphasis remap='I'>name</emphasis> NULL, the specified <emphasis remap='I'>widget_class</emphasis>,
an argument list and count,
and returns the created shell.
The recommended <emphasis remap='I'>widget_class</emphasis> is
<function>sessionShellWidgetClass</function>.
The argument list and count are created by merging
the specified <emphasis remap='I'>args</emphasis> and <emphasis remap='I'>num_args</emphasis> with a list
containing the specified <emphasis remap='I'>argc</emphasis> and <emphasis remap='I'>argv</emphasis>.
The modified <emphasis remap='I'>argc</emphasis> and <emphasis remap='I'>argv</emphasis> returned by
<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/>
are returned in <emphasis remap='I'>argc_in_out</emphasis> and <emphasis remap='I'>argv_in_out</emphasis>.  If
<emphasis remap='I'>app_context_return</emphasis> is not NULL, the created application context is
also returned.  If the display specified by the command line cannot be
opened, an error message is issued and
<xref linkend='XtOpenApplication' xrefstyle='select: title'/>
terminates the application.  If <emphasis remap='I'>fallback_resources</emphasis> is non-NULL,
<xref linkend='XtAppSetFallbackResources' xrefstyle='select: title'/>
is called with the value prior to calling
<xref linkend='XtOpenDisplay' xrefstyle='select: title'/>.
</para>

<funcsynopsis id='XtVaOpenApplication'>
<funcprototype>
  <funcdef>Widget <function>XtVaOpenApplication</function></funcdef>
      <paramdef>XtAppContext * <parameter>app_context_return</parameter></paramdef>
      <paramdef>String <parameter>application_class</parameter></paramdef>
      <paramdef>XrmOptionDescList <parameter>options</parameter></paramdef>
      <paramdef>Cardinal <parameter>num_options</parameter></paramdef>
      <paramdef>int * <parameter>argc_in_out</parameter></paramdef>
      <paramdef>String * <parameter>argv_in_out</parameter></paramdef>
      <paramdef>String * <parameter>fallback_resources</parameter></paramdef>
      <paramdef>WidgetClass <parameter>widget_class</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>app_context_return</emphasis>
    </term>
    <listitem>
      <para>
Returns the application context, if non-NULL.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>application_class</emphasis>
    </term>
    <listitem>
      <para>
Specifies the class name of the application.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>options</emphasis>
    </term>
    <listitem>
      <para>
Specifies the command line options table.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>num_options</emphasis>
    </term>
    <listitem>
      <para>
Specifies the number of entries in <emphasis remap='I'>options</emphasis>.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>argc_in_out</emphasis>
    </term>
    <listitem>
      <para>
Specifies a pointer to the number of command line arguments.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>argv_in_out</emphasis>
    </term>
    <listitem>
      <para>
Specifies the command line arguments array.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>fallback_resources</emphasis>
    </term>
    <listitem>
      <para>
Specifies resource values to be used if the application class
resource file cannot be opened, or NULL.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>widget_class</emphasis>
    </term>
    <listitem>
      <para>
Specifies the class of the widget to be created.  Must be shellWidgetClass
or a subclass.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      ...
    </term>
    <listitem>
      <para>
Specifies the variable argument list to override any other
resource specifications for the created shell.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
The
<xref linkend='XtVaOpenApplication' xrefstyle='select: title'/>
procedure is identical in function to
<xref linkend='XtOpenApplication' xrefstyle='select: title'/>
with the <emphasis remap='I'>args</emphasis> and <emphasis remap='I'>num_args</emphasis> parameters replaced by a varargs list,
as described
in Section 2.5.1.
</para>
</sect2>

<sect2 id="Widget_Instance_Allocation_The_allocate_Procedure">
<title>Widget Instance Allocation: The allocate Procedure</title>
<para>
A widget class may optionally provide an instance allocation procedure
in the
<function>ObjectClassExtension</function>
record.
</para>

<para>
When the call to create a widget includes a varargs list containing
<function>XtVaTypedArg</function>,
these arguments will be passed to the allocation procedure in an
<function>XtTypedArgList</function>.
</para>
<literallayout>
typedef struct {
	String name;
	String type;
	XtArgVal value;
	int size;
} XtTypedArg, *XtTypedArgList;
</literallayout>
<para>
The allocate procedure pointer in the
<function>ObjectClassExtension</function>
record is of type
<xref linkend='XtAllocateProc' xrefstyle='select: title'/>.
</para>

<funcsynopsis id='XtAllocateProc'>
<funcprototype>
  <funcdef>typedef void <function>(*AllocateProc)</function></funcdef>
      <paramdef>WidgetClass <parameter>widget_class</parameter></paramdef>
      <paramdef>Cardinal* <parameter>constraint_size</parameter></paramdef>
      <paramdef>Cardinal* <parameter>more_bytes</parameter></paramdef>
      <paramdef>ArgList <parameter>args</parameter></paramdef>
      <paramdef>Cardinal* <parameter>num_args</parameter></paramdef>
      <paramdef>XtTypedArgList <parameter>typed_args</parameter></paramdef>
      <paramdef>Cardinal* <parameter>num_typed_args</parameter></paramdef>
      <paramdef>Widget* <parameter>new_return</parameter></paramdef>
      <paramdef>XtPointer* <parameter>more_bytes_return</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>widget_class</emphasis>
    </term>
    <listitem>
      <para>
Specifies the widget class of the instance to allocate.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>constraint_size</emphasis>
    </term>
    <listitem>
      <para>
Specifies the size of the constraint record to allocate, or 0.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>more_bytes</emphasis>
    </term>
    <listitem>
      <para>
Specifies the number of auxiliary bytes of memory to allocate.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>args</emphasis>
    </term>
    <listitem>
      <para>
Specifies the argument list as given in the call to create the widget.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>num_args</emphasis>
    </term>
    <listitem>
      <para>
Specifies the number of arguments.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>typed_args</emphasis>
    </term>
    <listitem>
      <para>
Specifies the list of typed arguments given in the call to create the widget.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>num_typed_args</emphasis>
    </term>
    <listitem>
      <para>
Specifies the number of typed arguments.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>new_return</emphasis>
    </term>
    <listitem>
      <para>
Returns a pointer to the newly allocated instance, or NULL in case of error.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>more_bytes_return</emphasis>
    </term>
    <listitem>
      <para>
Returns the auxiliary memory if it was requested, or NULL
if requested and an error occurred; otherwise, unchanged.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
At widget allocation time, if an extension record with <emphasis remap='I'>record_type</emphasis>
equal to
<emphasis role='strong'>NULLQUARK</emphasis>
is located through the object class part <emphasis remap='I'>extension</emphasis> field
and the <emphasis remap='I'>allocate</emphasis> field is not NULL, the
<xref linkend='XtAllocateProc' xrefstyle='select: title'/>
will be invoked to allocate memory for the widget.  If no ObjectClassPart
extension record is declared with <emphasis remap='I'>record_type equal</emphasis> to
<emphasis role='strong'>NULLQUARK</emphasis>,
then
<function>XtInheritAllocate</function>
and
<function>XtInheritDeallocate</function>
are assumed.
If no
<xref linkend='XtAllocateProc' xrefstyle='select: title'/>
is found, the Intrinsics will allocate memory for the widget.
</para>

<para>
An
<xref linkend='XtAllocateProc' xrefstyle='select: title'/>
must perform the following:
</para>
<itemizedlist spacing='compact'>
  <listitem>
    <para>
Allocate memory for the widget instance and return it in <emphasis remap='I'>new_return</emphasis>.
The memory must be at least <emphasis remap='I'>wc-&gt;core_class.widget_size</emphasis> bytes in length,
double-word aligned.
    </para>
  </listitem>
  <listitem>
    <para>
Initialize the <emphasis remap='I'>core.constraints</emphasis> field in the instance record to NULL
or to point to a constraint record.  If <emphasis remap='I'>constraint_size</emphasis>
is not 0, the procedure must allocate memory for the constraint record.
The memory must be double-word aligned.
    </para>
  </listitem>
  <listitem>
    <para>
If <emphasis remap='I'>more_bytes</emphasis> is not 0, then the address of a block of memory
at least <emphasis remap='I'>more_bytes</emphasis> in size, double-word aligned, must be
returned in the <emphasis remap='I'>more_bytes_return</emphasis> parameter,
or NULL to indicate an error.
    </para>
  </listitem>
</itemizedlist>
<para>
A class allocation procedure that envelops the allocation procedure of a
superclass must rely on the enveloped procedure to perform the instance
and constraint allocation.
Allocation procedures should refrain from initializing fields in the
widget record except to store pointers to newly allocated additional memory.
Under no circumstances should an allocation procedure that envelopes
its superclass allocation procedure modify fields in the
instance part of any superclass.
</para>
</sect2>

<sect2 id="Widget_Instance_Initialization_The_initialize_Procedure">
<title>Widget Instance Initialization: The initialize Procedure</title>
<para>
The initialize procedure pointer in a widget class is of type
<xref linkend='XtInitProc' xrefstyle='select: title'/>.
</para>

<funcsynopsis id='XtInitProc'>
<funcprototype>
  <funcdef>typedef void <function>(*XtInitProc)</function></funcdef>
  <paramdef>Widget <parameter>request</parameter></paramdef>
  <paramdef>Widget <parameter>new</parameter></paramdef>
  <paramdef>ArgList <parameter>args</parameter></paramdef>
  <paramdef>Cardinal * <parameter>num_args</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>request</emphasis>
    </term>
    <listitem>
      <para>
Specifies a copy of the widget with resource values as requested by the
argument list, the resource database, and the widget defaults.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>new</emphasis>
    </term>
    <listitem>
      <para>
Specifies the widget with the new values, both resource and nonresource,
that are actually allowed.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>args</emphasis>
    </term>
    <listitem>
      <para>
Specifies the argument list passed by the client, for
computing derived resource values.
If the client created the widget using a varargs form, any resources
specified via
<function>XtVaTypedArg</function>
are converted to the widget representation and the list is transformed
into the
<function>ArgList</function>
format.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>num_args</emphasis>
    </term>
    <listitem>
      <para>
Specifies the number of entries in the argument list.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
An initialization procedure performs the following:
</para>
<itemizedlist spacing='compact'>
  <listitem>
    <para>
Allocates space for and copies any resources referenced by address
that the client is allowed to free or modify
after the widget has been created.
For example,
if a widget has a field that is a
<function>String</function>,
it may choose not to
depend on the characters at that address remaining constant
but dynamically allocate space for the string and copy it to the new space.
Widgets that do not copy one or more resources referenced
by address should clearly so state in their user documentation.
<note><para>
It is not necessary to allocate space for or to copy callback lists.
</para></note>
    </para>
  </listitem>
  <listitem>
    <para>
Computes values for unspecified resource fields.
For example, if <emphasis remap='I'>width</emphasis> and <emphasis remap='I'>height</emphasis> are zero,
the widget should compute an appropriate width and height
based on its other resources.
<note><para>
A widget may directly assign only
its own <emphasis remap='I'>width</emphasis> and <emphasis remap='I'>height</emphasis> within the initialize, initialize_hook,
set_values, and
set_values_hook procedures; see <xref linkend='Geometry_Management' />.
</para></note>
    </para>
  </listitem>
  <listitem>
    <para>
Computes values for uninitialized nonresource fields that are derived from
resource fields.
For example, graphics contexts (GCs) that the widget uses are derived from
resources like background, foreground, and font.
    </para>
  </listitem>
</itemizedlist>
<para>
An initialization procedure also can check certain fields for
internal consistency.
For example, it makes no sense to specify a colormap for a depth
that does not support that colormap.
</para>

<para>
Initialization procedures are called in superclass-to-subclass order
after all fields specified in the resource lists have been
initialized.  The initialize procedure does not need to examine
<emphasis remap='I'>args</emphasis> and <emphasis remap='I'>num_args</emphasis>
if all public resources are declared in the resource list.
Most of the initialization code for a specific widget class deals with fields
defined in that class and not with fields defined in its superclasses.
</para>

<para>
If a subclass does not need an initialization procedure
because it does not need to perform any of the above operations,
it can specify NULL for the <emphasis remap='I'>initialize</emphasis> field in the class record.
</para>

<para>
Sometimes a subclass may want to overwrite values filled in by its
superclass.
In particular, size calculations of a superclass often are
incorrect for a subclass, and in this case,
the subclass must modify or recalculate fields declared
and computed by its superclass.
</para>

<para>
As an example,
a subclass can visually surround its superclass display.
In this case, the width and height calculated by the superclass initialize
procedure are too small and need to be incremented by the size of the surround.
The subclass needs to know if its superclass's size was calculated by the
superclass or was specified explicitly.
All widgets must place themselves into whatever size is explicitly given,
but they should compute a reasonable size if no size is requested.
</para>

<para>
The <emphasis remap='I'>request</emphasis> and <emphasis remap='I'>new</emphasis> arguments provide the necessary information for
a subclass to determine the difference between an explicitly specified field
and a field computed by a superclass.
The <emphasis remap='I'>request</emphasis> widget is a copy of the widget as initialized by the
arglist and resource database.
The <emphasis remap='I'>new</emphasis> widget starts with the values in the request,
but it has been updated by all superclass initialization procedures called
so far.
A subclass initialize procedure can compare these two to resolve
any potential conflicts.
</para>

<para>
In the above example,
the subclass with the visual surround can see
if the <emphasis remap='I'>width</emphasis> and <emphasis remap='I'>height</emphasis> in the <emphasis remap='I'>request</emphasis> widget are zero.
If so,
it adds its surround size to the <emphasis remap='I'>width</emphasis> and <emphasis remap='I'>height</emphasis>
fields in the <emphasis remap='I'>new</emphasis> widget.
If not, it must make do with the size originally specified.
</para>

<para>
The <emphasis remap='I'>new</emphasis> widget will become the actual widget instance record.
Therefore,
the initialization procedure should do all its work on the <emphasis remap='I'>new</emphasis> widget;
the <emphasis remap='I'>request</emphasis> widget should never be modified.
If the initialize procedure
needs to call any routines that operate on a widget,
it should specify <emphasis remap='I'>new</emphasis> as the widget instance.
</para>
</sect2>

<sect2 id="Constraint_Instance_Initialization_The_ConstraintClassPart_initialize_Procedure">
<title>Constraint Instance Initialization: The ConstraintClassPart initialize Procedure</title>
<para>
The constraint initialization procedure pointer, found in the
<function>ConstraintClassPart</function>
<emphasis remap='I'>initialize</emphasis> field of the widget class record, is of type
<xref linkend='XtInitProc' xrefstyle='select: title'/>.
The values passed to the parent constraint initialization procedures
are the same as those passed to the child's class widget initialization
procedures.
</para>

<para>
The <emphasis remap='I'>constraints</emphasis> field of the <emphasis remap='I'>request</emphasis> widget points to a copy of the
constraints record as initialized by the arglist and resource database.
</para>

<para>
The constraint initialization procedure should compute any constraint fields
derived from constraint resources.
It can make further changes to the <emphasis remap='I'>new</emphasis> widget to make the widget
and any other constraint fields
conform to the specified constraints, for example,
changing the widget's size or position.
</para>

<para>
If a constraint class does not need a constraint initialization procedure,
it can specify NULL for the <emphasis remap='I'>initialize</emphasis> field of the
<function>ConstraintClassPart</function>
in the class record.
</para>
</sect2>

<sect2 id="Nonwidget_Data_Initialization_The_initialize_hook_Procedure">
<title>Nonwidget Data Initialization: The initialize_hook Procedure</title>
<note>
<para>
The initialize_hook procedure is obsolete, as the same information
is now available to the initialize procedure.  The procedure has been
retained for those widgets that used it in previous releases.
</para>
</note>

<para>
The initialize_hook procedure pointer is of type
<xref linkend='XtArgsProc' xrefstyle='select: title'/>:
</para>

<funcsynopsis id='XtArgsProc'>
<funcprototype>
  <funcdef>typedef void<function>(*XtArgsProc)</function></funcdef>
  <paramdef>Widget <parameter>w</parameter></paramdef>
  <paramdef>ArgList <parameter>args</parameter></paramdef>
  <paramdef>Cardinal * <parameter>num_args</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>w</emphasis>
    </term>
    <listitem>
      <para>
Specifies the widget.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>args</emphasis>
    </term>
    <listitem>
      <para>
Specifies the argument list passed by the client.
If the client created the widget using a varargs form, any resources
specified via
<function>XtVaTypedArg</function>
are converted to the widget representation and the list is transformed
into the
<function>ArgList</function>
format.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>num_args</emphasis>
    </term>
    <listitem>
      <para>
Specifies the number of entries in the argument list.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
If this procedure is not NULL,
it is called immediately after the corresponding initialize
procedure or in its place if the <emphasis remap='I'>initialize</emphasis> field is NULL.
</para>

<para>
The initialize_hook procedure allows a widget instance to initialize
nonresource data using information from the specified argument list
as if it were a resource.
</para>
</sect2>
</sect1>

<sect1 id="Realizing_Widgets">
<title>Realizing Widgets</title>
<para>
To realize a widget instance, use
<xref linkend='XtRealizeWidget' xrefstyle='select: title'/>.
</para>

<funcsynopsis id='XtRealizeWidget'>
<funcprototype>
  <funcdef>void <function>XtRealizeWidget</function></funcdef>
  <paramdef>Widget <parameter>w</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>w</emphasis>
    </term>
    <listitem>
      <para>
Specifies the widget.  Must be of class Core or any subclass thereof.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
If the widget is already realized,
<xref linkend='XtRealizeWidget' xrefstyle='select: title'/>
simply returns.
Otherwise it performs the following:
</para>
<itemizedlist spacing='compact'>
  <listitem>
    <para>
Binds all action names in the widget's
translation table to procedures (see <xref linkend='Action_Names_to_Procedure_Translations' />).
    </para>
  </listitem>
  <listitem>
    <para>
Makes a postorder traversal of the widget tree rooted
at the specified widget and calls each non-NULL change_managed procedure
of all composite widgets that have one or more managed children.
    </para>
  </listitem>
  <listitem>
    <para>
Constructs an
<function>XSetWindowAttributes</function>
structure filled in with information derived from the
Core
widget fields and calls the realize procedure for the widget,
which adds any widget-specific attributes and creates the X window.
    </para>
  </listitem>
  <listitem>
    <para>
If the widget is
not a subclass of
<function>compositeWidgetClass</function>,
<xref linkend='XtRealizeWidget' xrefstyle='select: title'/>
returns; otherwise it continues and performs the following:
    </para>
  </listitem>
  <listitem>
    <itemizedlist spacing='compact'>
      <listitem>
        <para>
Descends recursively to each of the widget's
managed children and calls the realize procedures.
Primitive widgets that instantiate children are responsible for realizing
those children themselves.
        </para>
      </listitem>
      <listitem>
        <para>
Maps all of the managed children windows that have <emphasis remap='I'>mapped_when_managed</emphasis>
<function>True</function>.
If a widget is managed but <emphasis remap='I'>mapped_when_managed</emphasis> is
<function>False</function>,
the widget is allocated visual space but is not displayed.
        </para>
      </listitem>
    </itemizedlist>
  </listitem>
</itemizedlist>
<para>
If the widget is a top-level shell widget (that is, it has no parent), and
<emphasis remap='I'>mapped_when_managed</emphasis> is
<function>True</function>,
<xref linkend='XtRealizeWidget' xrefstyle='select: title'/>
maps the widget window.
</para>

<para>
<xref linkend='XtCreateWidget' xrefstyle='select: title'/>,
<xref linkend='XtVaCreateWidget' xrefstyle='select: title'/>,
<xref linkend='XtRealizeWidget' xrefstyle='select: title'/>,
<xref linkend='XtManageChildren' xrefstyle='select: title'/>,
<function>XtUnmanage\%Children</function>,
<xref linkend='XtUnrealizeWidget' xrefstyle='select: title'/>,
<xref linkend='XtSetMappedWhenManaged' xrefstyle='select: title'/>,
and
<function>XtDestroy\%Widget</function>
maintain the following invariants:
</para>
<itemizedlist spacing='compact'>
  <listitem>
    <para>
If a composite widget is realized, then all its managed children are realized.
    </para>
  </listitem>
  <listitem>
    <para>
If a composite widget is realized, then all its managed children that have
<emphasis remap='I'>mapped_when_managed</emphasis>
<function>True</function>
are mapped.
    </para>
  </listitem>
</itemizedlist>
<para>
All Intrinsics functions and all widget routines should accept
either realized or unrealized widgets.
When calling the realize or change_managed
procedures for children of a composite
widget,
<xref linkend='XtRealizeWidget' xrefstyle='select: title'/>
calls the procedures in reverse order of
appearance in the
<function>CompositePart</function>
<emphasis remap='I'>children</emphasis> list.  By default, this
ordering of the realize procedures will
result in the stacking order of any newly created subwindows being
top-to-bottom in the order of appearance on the list, and the most
recently created child will be at the bottom.
</para>

<para>
To check whether or not a widget has been realized, use
<xref linkend='XtIsRealized' xrefstyle='select: title'/>.
</para>

<funcsynopsis id='XtIsRealized'>
<funcprototype>
  <funcdef>Boolean <function>XtIsRealized</function></funcdef>
  <paramdef>Widget <parameter>w</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>w</emphasis>
    </term>
    <listitem>
      <para>
Specifies the widget.  Must be of class Object or any subclass thereof.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
The
<xref linkend='XtIsRealized' xrefstyle='select: title'/>
function returns
<function>True</function>
if the widget has been realized,
that is, if the widget has a nonzero window ID.
If the specified object is not a widget, the state of the nearest
widget ancestor is returned.
</para>

<para>
Some widget procedures (for example, set_values) might wish to
operate differently
after the widget has been realized.
</para>
<sect2 id="Widget_Instance_Window_Creation_The_realize_Procedure">
<title>Widget Instance Window Creation: The realize Procedure</title>
<para>
The realize procedure pointer in a widget class is of type
<xref linkend='XtRealizeProc' xrefstyle='select: title'/>.
</para>

<funcsynopsis id='XtRealizeProc'>
<funcprototype>
  <funcdef>typedef void <function>(*XtRealizeProc)</function></funcdef>
  <paramdef>Widget <parameter>w</parameter></paramdef>
  <paramdef>XtValueMask <parameter>value_mask</parameter></paramdef>
  <paramdef>XSetWindowAttributes <parameter>attributes</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>w</emphasis>
    </term>
    <listitem>
      <para>
Specifies the widget.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>value_mask</emphasis>
    </term>
    <listitem>
      <para>
Specifies which fields in the <emphasis remap='I'>attributes</emphasis> structure are used.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>attributes</emphasis>
    </term>
    <listitem>
      <para>
Specifies the window attributes to use in the
<function>XCreateWindow</function>
call.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
The realize procedure must create the widget's window.
</para>

<para>
Before calling the class realize procedure, the generic
<xref linkend='XtRealizeWidget' xrefstyle='select: title'/>
function fills in a mask and a corresponding
<function>XSetWindowAttributes</function>
structure.
It sets the following fields in <emphasis remap='I'>attributes</emphasis> and
corresponding bits in <emphasis remap='I'>value_mask</emphasis>
based on information in the widget
core
structure:
</para>
<itemizedlist spacing='compact'>
  <listitem>
    <para>
The <emphasis remap='I'>background_pixmap</emphasis> (or <emphasis remap='I'>background_pixel</emphasis> if <emphasis remap='I'>background_pixmap</emphasis> is
<function>XtUnspecifiedPixmap</function>)
is filled in from the corresponding field.
    </para>
  </listitem>
  <listitem>
    <para>
The <emphasis remap='I'>border_pixmap</emphasis> (or <emphasis remap='I'>border_pixel</emphasis> if <emphasis remap='I'>border_pixmap</emphasis> is
<function>XtUnspecifiedPixmap</function>)
is filled in from the corresponding field.
    </para>
  </listitem>
  <listitem>
    <para>
The <emphasis remap='I'>colormap</emphasis> is filled in from the corresponding field.
    </para>
  </listitem>
  <listitem>
    <para>
The <emphasis remap='I'>event_mask</emphasis> is filled in based on the event handlers registered,
the event translations specified, whether the <emphasis remap='I'>expose</emphasis> field is non-NULL,
and whether <emphasis remap='I'>visible_interest</emphasis> is
<function>True</function>.
    </para>
  </listitem>
  <listitem>
    <para>
The <emphasis remap='I'>bit_gravity</emphasis> is set to
<function>NorthWestGravity</function>
if the <emphasis remap='I'>expose</emphasis> field is NULL.
    </para>
  </listitem>
</itemizedlist>
<para>
These or any other fields in attributes and the corresponding bits in
<emphasis remap='I'>value_mask</emphasis> can be set by the realize procedure.
</para>

<para>
Note that because realize is not a chained operation,
the widget class realize procedure must update the
<function>XSetWindowAttributes</function>
structure with all the appropriate fields from
non-Core
superclasses.
</para>

<para>
A widget class can inherit its realize procedure from its superclass
during class initialization.
The realize procedure defined for
<function>coreWidgetClass</function>
calls
<xref linkend='XtCreateWindow' xrefstyle='select: title'/>
with the passed <emphasis remap='I'>value_mask</emphasis> and <emphasis remap='I'>attributes</emphasis>
and with <emphasis remap='I'>window_class</emphasis> and <emphasis remap='I'>visual</emphasis> set to
<function>CopyFromParent</function>.
Both
<function>compositeWidgetClass</function>
and
<function>constraintWidgetClass</function>
inherit this realize procedure, and most new widget subclasses
can do the same (see <xref linkend='Inheritance_of_Superclass_Operations' />).
</para>

<para>
The most common noninherited realize procedures set <emphasis remap='I'>bit_gravity</emphasis> in the mask
and attributes to the appropriate value and then create the window.
For example, depending on its justification, Label might set <emphasis remap='I'>bit_gravity</emphasis> to
<function>WestGravity</function>,
<function>CenterGravity</function>,
or
<function>EastGravity</function>.
Consequently, shrinking it would just move the bits appropriately,
and no
exposure
event is needed for repainting.
</para>

<para>
If a composite widget's children should be realized in an order other
than that specified
(to control the stacking order, for example),
it should call
<xref linkend='XtRealizeWidget' xrefstyle='select: title'/>
on its children itself in the appropriate order from within its own
realize procedure.
</para>

<para>
Widgets that have children and whose class is not a subclass of
<function>compositeWidgetClass</function>
are responsible for calling
<xref linkend='XtRealizeWidget' xrefstyle='select: title'/>
on their children, usually from within the realize procedure.
</para>

<para>
Realize procedures cannot manage or unmanage their descendants.
</para>
</sect2>

<sect2 id="Window_Creation_Convenience_Routine">
<title>Window Creation Convenience Routine</title>
<para>
Rather than call the Xlib
<function>XCreateWindow</function>
function explicitly, a realize procedure should normally call the Intrinsics analog
<xref linkend='XtCreateWindow' xrefstyle='select: title'/>,
which simplifies the creation of windows for widgets.
</para>

<funcsynopsis id='XtCreateWindow'>
<funcprototype>
  <funcdef>void <function>XtCreateWindow</function></funcdef>
  <paramdef>Widget <parameter>w</parameter></paramdef>
  <paramdef>unsigned int <parameter>window_class</parameter></paramdef>
  <paramdef>Visual * <parameter>visual</parameter></paramdef>
  <paramdef>XtValueMask <parameter>value_mask</parameter></paramdef>
  <paramdef>XSetWindowAttributes <parameter>attributes</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>w</emphasis>
    </term>
    <listitem>
      <para>
Specifies the widget that defines the additional window attributed.  Must be of class Core or any subclass thereof.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>window_class</emphasis>
    </term>
    <listitem>
      <para>
Specifies the Xlib window class (for example,
<function>InputOutput</function>,
<function>InputOnly</function>,
or
<function>CopyFromParent ).</function>
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>visual</emphasis>
    </term>
    <listitem>
      <para>
Specifies the visual type (usually
<function>CopyFromParent ).</function>
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>value_mask</emphasis>
    </term>
    <listitem>
      <para>
Specifies which fields in the <emphasis remap='I'>attributes</emphasis> structure are used.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>attributes</emphasis>
    </term>
    <listitem>
      <para>
Specifies the window attributes to use in the
<function>XCreateWindow</function>
call.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
The
<xref linkend='XtCreateWindow' xrefstyle='select: title'/>
function calls the Xlib
<function>XCreateWindow</function>
function with values from the widget structure and the passed parameters.
Then, it assigns the created window to the widget's <emphasis remap='I'>window</emphasis> field.
</para>

<para>
<xref linkend='XtCreateWindow' xrefstyle='select: title'/>
evaluates the following fields of the widget core
structure: <emphasis remap='I'>depth</emphasis>, <emphasis remap='I'>screen</emphasis>, <emphasis remap='I'>parent-&gt;core.window</emphasis>, <emphasis remap='I'>x</emphasis>,
<emphasis remap='I'>y</emphasis>, <emphasis remap='I'>width</emphasis>, <emphasis remap='I'>height</emphasis>, and
<emphasis remap='I'>border_width</emphasis>.
</para>
</sect2>
</sect1>

<sect1 id="Obtaining_Window_Information_from_a_Widget">
<title>Obtaining Window Information from a Widget</title>
<para>
The
Core
widget class definition contains the screen and window ids.
The <emphasis remap='I'>window</emphasis> field may be NULL for a while
(see <xref linkend='Creating_Widgets' /> and <xref linkend='Realizing_Widgets' />).
</para>

<para>
The display pointer, the parent widget, screen pointer,
and window of a widget are available to the widget writer by means of macros
and to the application writer by means of functions.
</para>

<funcsynopsis>
<funcprototype>
  <funcdef>Display <function>XtDisplay</function></funcdef>
  <paramdef>Widget <parameter>w</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>w</emphasis>
    </term>
    <listitem>
      <para>
Specifies the widget.  Must be of class Core or any subclass thereof.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
<function>XtDisplay</function>
returns the display pointer for the specified widget.
</para>

<funcsynopsis>
<funcprototype>
  <funcdef>Widget <function>XtParent</function></funcdef>
  <paramdef>Widget <parameter>w</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>w</emphasis>
    </term>
    <listitem>
      <para>
Specifies the widget.  Must be of class Object or any subclass thereof.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
<function>XtParent</function>
returns the parent object for the specified widget. The returned object
will be of class Object or a subclass.
</para>

<funcsynopsis id='XtScreen'>
<funcprototype>
  <funcdef>Screen <function>*XtScreen</function></funcdef>
  <paramdef>Widget <parameter>w</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>w</emphasis>
    </term>
    <listitem>
      <para>
Specifies the widget.  Must be of class Core or any subclass thereof.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
<xref linkend='XtScreen' xrefstyle='select: title'/>
returns the screen pointer for the specified widget.
</para>

<funcsynopsis id='XtWindow'>
<funcprototype>
  <funcdef>Window <function>XtWindow</function></funcdef>
  <paramdef>Widget <parameter>w</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>w</emphasis>
    </term>
    <listitem>
      <para>
Specifies the widget.  Must be of class Core or any subclass thereof.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
<xref linkend='XtWindow' xrefstyle='select: title'/>
returns the window of the specified widget.
</para>

<para>
The display pointer, screen pointer, and window of a widget or
of the closest widget ancestor of a nonwidget object are available
by means of
<xref linkend='XtDisplayOfObject' xrefstyle='select: title'/>,
<xref linkend='XtScreenOfObject' xrefstyle='select: title'/>,
and
<xref linkend='XtWindowOfObject' xrefstyle='select: title'/>.
</para>

<funcsynopsis id='XtDisplayOfObject'>
<funcprototype>
  <funcdef>Display <function>*XtDisplayOfObject</function></funcdef>
  <paramdef>Widget <parameter>w</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>object</emphasis>
    </term>
    <listitem>
      <para>
Specifies the object.  Must be of class Object or any subclass thereof.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
<xref linkend='XtDisplayOfObject' xrefstyle='select: title'/>
is identical in function to
<function>XtDisplay</function>
if the object is a widget; otherwise
<xref linkend='XtDisplayOfObject' xrefstyle='select: title'/>
returns the display
pointer for the nearest ancestor of <emphasis remap='I'>object</emphasis> that is of class
Widget or a subclass thereof.
</para>

<funcsynopsis id='XtScreenOfObject'>
<funcprototype>
  <funcdef>Screen <function>*XtScreenOfObject</function></funcdef>
  <paramdef>Widget <parameter>object</parameter></paramdef>
</funcprototype>
</funcsynopsis>


<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>object</emphasis>
    </term>
    <listitem>
      <para>
Specifies the object.  Must be of class Object or any subclass thereof.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
<xref linkend='XtScreenOfObject' xrefstyle='select: title'/>
is identical in function to
<xref linkend='XtScreen' xrefstyle='select: title'/>
if the object is a widget; otherwise
<xref linkend='XtScreenOfObject' xrefstyle='select: title'/>
returns the screen pointer
for the nearest ancestor of <emphasis remap='I'>object</emphasis> that is of class
Widget or a subclass thereof.
</para>

<funcsynopsis id='XtWindowOfObject'>
<funcprototype>
  <funcdef>Window <function>XtWindowOfObject</function></funcdef>
  <paramdef>Widget <parameter>object</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>object</emphasis>
    </term>
    <listitem>
      <para>
Specifies the object.  Must be of class Object or any subclass thereof.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
<xref linkend='XtWindowOfObject' xrefstyle='select: title'/>
is identical in function to
<xref linkend='XtWindow' xrefstyle='select: title'/>
if the object is a widget; otherwise
<xref linkend='XtWindowOfObject' xrefstyle='select: title'/>
returns the window for the nearest ancestor of <emphasis remap='I'>object</emphasis> that is of class
Widget or a subclass thereof.
</para>

<para>
To retrieve the instance name of an object, use
<xref linkend='XtName' xrefstyle='select: title'/>.
</para>

<funcsynopsis id='XtName'>
<funcprototype>
  <funcdef>String <function>XtName</function></funcdef>
  <paramdef>Widget <parameter>object</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>object</emphasis>
    </term>
    <listitem>
      <para>
Specifies the object whose name is desired.  Must be of class Object or any subclass thereof.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
<xref linkend='XtName' xrefstyle='select: title'/>
returns a pointer to the instance name of the specified object.
The storage is owned by the Intrinsics and must not be modified.  The
name is not qualified by the names of any of the object's ancestors.
</para>

<para>
Several window attributes are locally cached in the widget instance.
Thus, they can be set by the resource manager and
<xref linkend='XtSetValues' xrefstyle='select: title'/>
as well as used by routines that derive structures from these values
(for example, <emphasis remap='I'>depth</emphasis> for deriving pixmaps,
<emphasis remap='I'>background_pixel</emphasis> for deriving GCs, and so on) or in the
<xref linkend='XtCreateWindow' xrefstyle='select: title'/>
call.
</para>

<para>
The <emphasis remap='I'>x</emphasis>, <emphasis remap='I'>y</emphasis>, <emphasis remap='I'>width</emphasis>, <emphasis remap='I'>height</emphasis>, and <emphasis remap='I'>border_width</emphasis>
window attributes are available to
geometry managers.
These fields are maintained synchronously inside the Intrinsics.
When an
<function>XConfigureWindow</function>
is issued by the Intrinsics on the widget's window (on request of its parent),
these values are updated immediately rather than some time later
when the server generates a
<function>ConfigureNotify</function>
event.
(In fact, most widgets do not select
<function>SubstructureNotify</function>
events.)
This ensures that all geometry calculations are based on the internally
consistent toolkit world rather than on either
an inconsistent world updated by asynchronous
<function>ConfigureNotify</function>
events or a consistent, but slow, world in which geometry managers
ask the server
for window sizes whenever they need to lay out their managed children
(see <xref linkend='Geometry_Management' />).
</para>
<sect2 id="Unrealizing_Widgets">
<title>Unrealizing Widgets</title>
<para>
To destroy the windows associated with a widget and its
non-pop-up descendants, use
<xref linkend='XtUnrealizeWidget' xrefstyle='select: title'/>.
</para>

<funcsynopsis id='XtUnrealizeWidget'>
<funcprototype>
  <funcdef>void <function>XtUnrealizeWidget</function></funcdef>
  <paramdef>Widget <parameter>w</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>w</emphasis>
    </term>
    <listitem>
      <para>
Specifies the widget.  Must be of class Core or any subclass thereof.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
If the widget is currently unrealized,
<xref linkend='XtUnrealizeWidget' xrefstyle='select: title'/>
simply returns.  Otherwise it performs the following:
</para>
<itemizedlist spacing='compact'>
  <listitem>
    <para>
Unmanages the widget if the widget is managed.
    </para>
  </listitem>
  <listitem>
    <para>
Makes a postorder (child-to-parent) traversal of the widget tree
rooted at the specified widget and, for each widget that has
declared a callback list resource named ``unrealizeCallback'', executes the
procedures on the
XtNunrealizeCallback
list.
    </para>
  </listitem>
  <listitem>
    <para>
Destroys the widget's window and any subwindows by calling
<function>XDestroyWindow</function>
with the specified widget's <emphasis remap='I'>window</emphasis> field.
    </para>
  </listitem>
</itemizedlist>
<para>
Any events in the queue or which arrive following a call to
<xref linkend='XtUnrealizeWidget' xrefstyle='select: title'/>
will be dispatched as if the window(s) of the
unrealized widget(s) had never existed.
</para>
</sect2>
</sect1>

<sect1 id="Destroying_Widgets">
<title>Destroying Widgets</title>
<para>
The Intrinsics provide support
</para>
<itemizedlist spacing='compact'>
  <listitem>
    <para>
To destroy all the pop-up children of the widget being destroyed
and destroy all children of composite widgets.
    </para>
  </listitem>
  <listitem>
    <para>
To remove (and unmap) the widget from its parent.
    </para>
  </listitem>
  <listitem>
    <para>
To call the callback procedures that have been registered to trigger
when the widget is destroyed.
    </para>
  </listitem>
  <listitem>
    <para>
To minimize the number of things a widget has to deallocate when destroyed.
    </para>
  </listitem>
  <listitem>
    <para>
To minimize the number of
<function>XDestroyWindow</function>
calls when destroying a widget tree.
    </para>
  </listitem>
</itemizedlist>
<para>
To destroy a widget instance, use
<xref linkend='XtDestroyWidget' xrefstyle='select: title'/>.
</para>


<funcsynopsis id='XtDestroyWidget'>
<funcprototype>
  <funcdef>void <function>XtDestroyWidget</function></funcdef>
  <paramdef>Widget <parameter>w</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>w</emphasis>
    </term>
    <listitem>
      <para>
Specifies the widget.  Must be of class Object or any subclass thereof.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
The
<xref linkend='XtDestroyWidget' xrefstyle='select: title'/>
function provides the only method of destroying a widget,
including widgets that need to destroy themselves.
It can be called at any time,
including from an application callback routine of the widget being destroyed.
This requires a two-phase destroy process in order to avoid dangling
references to destroyed widgets.
</para>

<para>
In phase 1,
<xref linkend='XtDestroyWidget' xrefstyle='select: title'/>
performs the following:
</para>
<itemizedlist spacing='compact'>
  <listitem>
    <para>
If the <emphasis remap='I'>being_destroyed</emphasis> field of the widget is
<function>True</function>,
it returns immediately.
    </para>
  </listitem>
  <listitem>
    <para>
Recursively descends the widget tree and
sets the <emphasis remap='I'>being_destroyed</emphasis> field to
<function>True</function>
for the widget and all normal and pop-up children.
    </para>
  </listitem>
  <listitem>
    <para>
Adds the widget to a list of widgets (the destroy list) that should be
destroyed when it is safe to do so.
    </para>
  </listitem>
</itemizedlist>
<para>
Entries on the destroy list satisfy the invariant that
if w2 occurs after w1 on the destroy list, then w2 is not a descendent,
either normal or pop-up, of w1.
</para>

<para>
Phase 2 occurs when all procedures that should execute as a result of
the current event have been called, including all procedures registered with
the event and translation managers,
that is, when the current invocation of
<xref linkend='XtDispatchEvent' xrefstyle='select: title'/>
is about to return, or immediately if not in
<xref linkend='XtDispatchEvent' xrefstyle='select: title'/>.
</para>

<para>
In phase 2,
<xref linkend='XtDestroyWidget' xrefstyle='select: title'/>
performs the following on each entry in the destroy list in the order
specified:
</para>
<itemizedlist spacing='compact'>
  <listitem>
    <para>
If the widget is not a pop-up child and the widget's parent is a subclass of
<function>composite\%WidgetClass</function>,
and if the parent is not being destroyed,
it calls
<xref linkend='XtUnmanageChild' xrefstyle='select: title'/>
on the widget and then calls the widget's parent's delete_child procedure
(see <xref linkend='Deletion_of_Children_The_delete_child_Procedure' />).
    </para>
  </listitem>
  <listitem>
    <para>
Calls the destroy callback procedures registered on the widget
and all normal and pop-up descendants in postorder (it calls child
callbacks before parent callbacks).
    </para>
  </listitem>
</itemizedlist>
<para>
The
<xref linkend='XtDestroyWidget' xrefstyle='select: title'/>
function then makes second traversal of the widget and all normal
and pop-up descendants to perform the following three items on each
widget in postorder:
</para>
<itemizedlist spacing='compact'>
  <listitem>
    <para>
If the widget is not a pop-up child and the widget's parent is a subclass of
<function>constraint\%WidgetClass</function>,
it calls the
<function>ConstraintClassPart</function>
destroy procedure for the parent,
then for the parent's superclass,
until finally it calls the
<function>ConstraintClassPart</function>
destroy procedure for
<function>constraintWidgetClass</function>.
    </para>
  </listitem>
  <listitem>
    <para>
Calls the
<function>CoreClassPart</function>
destroy procedure declared in the widget class,
then the destroy procedure declared in its superclass,
until finally it calls the destroy procedure declared in the Object
class record.  Callback lists are deallocated.
    </para>
  </listitem>
  <listitem>
    <para>
If the widget class object class part contains an
<function>ObjectClassExtension</function>
record with the record_type
<emphasis role='strong'>NULLQUARK</emphasis>
and the <emphasis remap='I'>deallocate</emphasis> field is not NULL,
calls the deallocate procedure to deallocate the instance and if one
exists, the constraint record.  Otherwise, the Intrinsics will deallocate
the widget instance record and if one exists, the constraint record.
    </para>
  </listitem>
  <listitem>
    <para>
Calls
<function>XDestroyWindow</function>
if the specified widget is realized (that is, has an X window).
The server recursively destroys all normal descendant windows.
(Windows of realized pop-up Shell children, and their
descendants, are destroyed by a shell class destroy procedure.)
    </para>
  </listitem>
</itemizedlist>
<sect2 id="Adding_and_Removing_Destroy_Callbacks">
<title>Adding and Removing Destroy Callbacks</title>
<para>
When an application needs to perform additional processing during the
destruction of a widget,
it should register a destroy callback procedure for the widget.
The destroy callback procedures use the mechanism described in
<xref linkend='Callbacks' />.
The destroy callback list is identified by the resource name
XtNdestroyCallback.
</para>

<para>
For example, the following adds an application-supplied destroy callback
procedure <emphasis remap='I'>ClientDestroy</emphasis> with client data to a widget by calling
<xref linkend='XtAddCallback' xrefstyle='select: title'/>.
</para>

<literallayout>
XtAddCallback(<emphasis remap='I'>w</emphasis>, XtNdestroyCallback, <emphasis remap='I'>ClientDestroy</emphasis>, <emphasis remap='I'>client_data</emphasis>)
</literallayout>

<para>
Similarly, the following removes the application-supplied destroy callback
procedure <emphasis remap='I'>ClientDestroy</emphasis> by calling
<xref linkend='XtRemoveCallback' xrefstyle='select: title'/>.
</para>

<literallayout>
XtRemoveCallback(<emphasis remap='I'>w</emphasis>, XtNdestroyCallback, <emphasis remap='I'>ClientDestroy</emphasis>, <emphasis remap='I'>client_data</emphasis>)
</literallayout>
<para>
The <emphasis remap='I'>ClientDestroy</emphasis> argument is of type
<xref linkend='XtCallbackProc' xrefstyle='select: title'/>;
see <xref linkend='Using_Callback_Procedure_and_Callback_List_Definitions' />.
</para>
</sect2>

<sect2 id="Dynamic_Data_Deallocation_The_destroy_Procedure">
<title>Dynamic Data Deallocation: The destroy Procedure</title>
<para>
The destroy procedure pointers in the
<function>ObjectClassPart</function>,
<function>RectObjClassPart</function>,
and
<function>CoreClassPart</function>
structures are of type
<xref linkend='XtWidgetProc' xrefstyle='select: title'/>.
</para>

<funcsynopsis id='XtWidgetProc'>
<funcprototype>
  <funcdef>typedef void <function>XtWidgetProc</function></funcdef>
  <paramdef>Widget <parameter>w</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>w</emphasis>
    </term>
    <listitem>
      <para>
Specifies the widget being destroyed.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
The destroy procedures are called in subclass-to-superclass order.
Therefore, a widget's destroy procedure should deallocate only storage
that is specific to the subclass and should ignore the storage
allocated by any of its superclasses.
The destroy procedure should deallocate only resources that have been
explicitly created by the subclass.
Any resource that was obtained from the resource database
or passed in an argument list was not created by the widget
and therefore should not be destroyed by it.
If a widget does not need to deallocate any storage,
the destroy procedure entry in its class record can be NULL.
</para>

<para>
Deallocating storage includes, but is not limited to,
the following steps:
</para>
<itemizedlist spacing='compact'>
  <listitem>
    <para>
Calling
<xref linkend='XtFree' xrefstyle='select: title'/>
on dynamic storage allocated with
<xref linkend='XtMalloc' xrefstyle='select: title'/>,
<xref linkend='XtCalloc' xrefstyle='select: title'/>,
and so on.
    </para>
  </listitem>
  <listitem>
    <para>
Calling
<function>XFreePixmap</function>
on pixmaps created with direct X calls.
    </para>
  </listitem>
  <listitem>
    <para>
Calling
<xref linkend='XtReleaseGC' xrefstyle='select: title'/>
on GCs allocated with
<xref linkend='XtGetGC' xrefstyle='select: title'/>.
    </para>
  </listitem>
  <listitem>
    <para>
Calling
<function>XFreeGC</function>
on GCs allocated with direct X calls.
    </para>
  </listitem>
  <listitem>
    <para>
Calling
<xref linkend='XtRemoveEventHandler' xrefstyle='select: title'/>
on event handlers added to other widgets.
    </para>
  </listitem>
  <listitem>
    <para>
Calling
<xref linkend='XtRemoveTimeOut' xrefstyle='select: title'/>
on timers created with
<xref linkend='XtAppAddTimeOut' xrefstyle='select: title'/>.
    </para>
  </listitem>
  <listitem>
    <para>
Calling
<xref linkend='XtDestroyWidget' xrefstyle='select: title'/>
for each child if the widget has children
and is not a subclass of
<function>compositeWidgetClass</function>.
    </para>
  </listitem>
</itemizedlist>
<para>
During destroy phase 2 for each widget, the Intrinsics remove the widget
from the modal cascade, unregister all event handlers, remove all key,
keyboard, button, and pointer grabs and remove all callback procedures
registered on the widget.  Any outstanding selection transfers will time out.
</para>
</sect2>

<sect2 id="Dynamic_Constraint_Data_Deallocation_The_ConstraintClassPart_destroy_Procedure">
<title>Dynamic Constraint Data Deallocation: The ConstraintClassPart destroy Procedure</title>
<para>
The constraint destroy procedure identified in the
<function>ConstraintClassPart</function>
<function>constraintWidgetClass</function>.
This constraint destroy procedure pointer is of type
<xref linkend='XtWidgetProc' xrefstyle='select: title'/>.
The constraint destroy procedures are called in subclass-to-superclass order,
starting at the class of the widget's parent and ending at
<function>constraint\%WidgetClass</function>.
Therefore, a parent's constraint destroy procedure should deallocate only
storage that is specific to the constraint subclass
and not storage allocated by any of its superclasses.
</para>

<para>
If a parent does not need to deallocate any constraint storage,
the constraint destroy procedure entry
in its class record can be NULL.
</para>
</sect2>

<sect2 id="Widget_Instance_Deallocation_The_deallocate_Procedure">
<title>Widget Instance Deallocation: The deallocate Procedure</title>
<para>
The deallocate procedure pointer in the
<function>ObjectClassExtension</function>
record is of type
<function>XtDeallocateProc</function>.
</para>

<funcsynopsis>
<funcprototype>
  <funcdef>typedef void <function>(*XtDeallocateProc)</function></funcdef>
  <paramdef>Widget <parameter>widget</parameter></paramdef>
  <paramdef>XtPointer <parameter>more_bytes</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>widget</emphasis>
    </term>
    <listitem>
      <para>
Specifies the widget being destroyed.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>more_bytes</emphasis>
    </term>
    <listitem>
      <para>
Specifies the auxiliary memory received from the corresponding allocator
along with the widget, or NULL.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
When a widget is destroyed, if an
<function>ObjectClassExtension</function>
record exists in the object class part <emphasis remap='I'>extension</emphasis> field
with <emphasis remap='I'>record_type</emphasis>
<emphasis role='strong'>NULLQUARK</emphasis>
and the <emphasis remap='I'>deallocate</emphasis> field is not NULL, the
<function>XtDeallocateProc</function>
will be called.
If no ObjectClassPart extension record is declared with <emphasis remap='I'>record_type</emphasis>
equal to
<emphasis role='strong'>NULLQUARK</emphasis>,
then
<function>XtInheritAllocate</function>
and
<function>XtInheritDeallocate</function>
are assumed.
The responsibilities of the deallocate procedure are to deallocate the
memory specified by <emphasis remap='I'>more_bytes</emphasis> if it is not NULL,
to deallocate the constraints record as specified by the
widget's <emphasis remap='I'>core.constraints</emphasis> field if it is
not NULL, and to deallocate the widget instance itself.
</para>

<para>
If no
<function>XtDeallocateProc</function>
is found, it is assumed that the Intrinsics
originally allocated the memory and is responsible for freeing it.
</para>
</sect2>
</sect1>

<sect1 id="Exiting_from_an_Application">
<title>Exiting from an Application</title>
<para>
All X Toolkit applications should terminate
by calling
<xref linkend='XtDestroyApplicationContext' xrefstyle='select: title'/>
and then exiting
using the
standard method for their operating system (typically, by calling
<function>exit</function>
for POSIX-based systems).
The quickest way to make the windows disappear while exiting is to call
<xref linkend='XtUnmapWidget' xrefstyle='select: title'/>
on each top-level shell widget.
The Intrinsics have no resources beyond those in the program image,
and the X server will free its resources when its connection
to the application is broken.
</para>

<para>
Depending upon the widget set in use, it may be necessary to explicitly
destroy individual widgets or widget trees with
<xref linkend='XtDestroyWidget' xrefstyle='select: title'/>
before calling
<xref linkend='XtDestroyApplicationContext' xrefstyle='select: title'/>
in order to ensure that any
required widget cleanup is properly executed.  The application developer
must refer to the widget documentation to learn if a widget needs to
perform cleanup beyond that performed automatically by the
operating system.  If the client is a session participant
(see <xref linkend='Session_Participation' />), then the client may wish to resign from the session
before exiting.  See <xref linkend='Resigning_from_a_Session' /> for details.
</para>
</sect1>
</chapter>