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
|
/*******************************************************************************
* Copyright (c) 2000, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.swt.widgets;
import org.eclipse.swt.internal.wpf.*;
import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
/**
* Instances of this class are responsible for managing the
* connection between SWT and the underlying operating
* system. Their most important function is to implement
* the SWT event loop in terms of the platform event model.
* They also provide various methods for accessing information
* about the operating system, and have overall control over
* the operating system resources which SWT allocates.
* <p>
* Applications which are built with SWT will <em>almost always</em>
* require only a single display. In particular, some platforms
* which SWT supports will not allow more than one <em>active</em>
* display. In other words, some platforms do not support
* creating a new display if one already exists that has not been
* sent the <code>dispose()</code> message.
* <p>
* In SWT, the thread which creates a <code>Display</code>
* instance is distinguished as the <em>user-interface thread</em>
* for that display.
* </p>
* The user-interface thread for a particular display has the
* following special attributes:
* <ul>
* <li>
* The event loop for that display must be run from the thread.
* </li>
* <li>
* Some SWT API methods (notably, most of the public methods in
* <code>Widget</code> and its subclasses), may only be called
* from the thread. (To support multi-threaded user-interface
* applications, class <code>Display</code> provides inter-thread
* communication methods which allow threads other than the
* user-interface thread to request that it perform operations
* on their behalf.)
* </li>
* <li>
* The thread is not allowed to construct other
* <code>Display</code>s until that display has been disposed.
* (Note that, this is in addition to the restriction mentioned
* above concerning platform support for multiple displays. Thus,
* the only way to have multiple simultaneously active displays,
* even on platforms which support it, is to have multiple threads.)
* </li>
* </ul>
* Enforcing these attributes allows SWT to be implemented directly
* on the underlying operating system's event model. This has
* numerous benefits including smaller footprint, better use of
* resources, safer memory management, clearer program logic,
* better performance, and fewer overall operating system threads
* required. The down side however, is that care must be taken
* (only) when constructing multi-threaded applications to use the
* inter-thread communication mechanisms which this class provides
* when required.
* </p><p>
* All SWT API methods which may only be called from the user-interface
* thread are distinguished in their documentation by indicating that
* they throw the "<code>ERROR_THREAD_INVALID_ACCESS</code>"
* SWT exception.
* </p>
* <dl>
* <dt><b>Styles:</b></dt>
* <dd>(none)</dd>
* <dt><b>Events:</b></dt>
* <dd>Close, Dispose, OpenDocument, Settings, Skin</dd>
* </dl>
* <p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
* @see #syncExec
* @see #asyncExec
* @see #wake
* @see #readAndDispatch
* @see #sleep
* @see Device#dispose
* @see <a href="http://www.eclipse.org/swt/snippets/#display">Display snippets</a>
* @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
* @noextend This class is not intended to be subclassed by clients.
*/
public class Display extends Device {
int application, dispatcher, frame, jniRef, nameScope;
boolean idle;
int sleepOperation, operation;
int operationCount;
/* Windows and Events */
Event [] eventQueue;
EventTable eventTable, filterTable;
int lastKey;
char lastChar;
boolean deadChar;
/* Track Mouse Control */
Control mouseControl;
/* Focus */
Control focusControl;
/* Menus */
Menu [] popups;
/* Sync/Async Widget Communication */
Synchronizer synchronizer = new Synchronizer (this);
Thread thread;
/* Display Shutdown */
Runnable [] disposeList;
/* Deferred Layout list */
Composite[] layoutDeferred;
int layoutDeferredCount;
/* System Tray */
Tray tray;
/* Timers */
int timerHandler;
int [] timerHandles;
Runnable [] timerList;
// /* System Resources */
Font systemFont;
Image errorImage, infoImage, questionImage, warningIcon;
Cursor [] cursors = new Cursor [SWT.CURSOR_HAND + 1];
Color [] colors;
/* Sort Indicators */
// Image upArrow, downArrow;
/* Color dialog custom dialgos */
int customColors;
/* Display Data */
Object data;
String [] keys;
Object [] values;
/* DragDetect */
boolean dragging;
int dragDetectFrame, dragRect, dragMouseDown;
Control[] invalidate;
int invalidateHandler;
boolean ignoreRender;
Shell [] shells;
/* Key Mappings */
static final int [] [] KeyTable = {
/* Keyboard and Mouse Masks */
{OS.Key_LeftAlt, SWT.ALT},
{OS.Key_RightAlt, SWT.ALT},
{OS.Key_LeftShift, SWT.SHIFT},
{OS.Key_RightShift, SWT.SHIFT},
{OS.Key_LeftCtrl, SWT.CONTROL},
{OS.Key_RightCtrl, SWT.CONTROL},
// {OS.VK_????, SWT.COMMAND},
/* NOT CURRENTLY USED */
// {OS.VK_LBUTTON, SWT.BUTTON1},
// {OS.VK_MBUTTON, SWT.BUTTON3},
// {OS.VK_RBUTTON, SWT.BUTTON2},
/* Non-Numeric Keypad Keys */
{OS.Key_Up, SWT.ARROW_UP},
{OS.Key_Down, SWT.ARROW_DOWN},
{OS.Key_Left, SWT.ARROW_LEFT},
{OS.Key_Right, SWT.ARROW_RIGHT},
{OS.Key_PageUp, SWT.PAGE_UP},
{OS.Key_PageDown, SWT.PAGE_DOWN},
{OS.Key_Home, SWT.HOME},
{OS.Key_End, SWT.END},
{OS.Key_Insert, SWT.INSERT},
/* Virtual and Ascii Keys */
{OS.Key_Back, SWT.BS},
{OS.Key_Return, SWT.CR},
{OS.Key_Delete, SWT.DEL},
{OS.Key_Escape, SWT.ESC},
{OS.Key_Return, SWT.LF},
{OS.Key_Tab, SWT.TAB},
/* Functions Keys */
{OS.Key_F1, SWT.F1},
{OS.Key_F2, SWT.F2},
{OS.Key_F3, SWT.F3},
{OS.Key_F4, SWT.F4},
{OS.Key_F5, SWT.F5},
{OS.Key_F6, SWT.F6},
{OS.Key_F7, SWT.F7},
{OS.Key_F8, SWT.F8},
{OS.Key_F9, SWT.F9},
{OS.Key_F10, SWT.F10},
{OS.Key_F11, SWT.F11},
{OS.Key_F12, SWT.F12},
{OS.Key_F13, SWT.F13},
{OS.Key_F14, SWT.F14},
{OS.Key_F15, SWT.F15},
{OS.Key_F16, SWT.F16},
{OS.Key_F17, SWT.F17},
{OS.Key_F18, SWT.F18},
{OS.Key_F19, SWT.F19},
{OS.Key_F20, SWT.F20},
/* Numeric Keypad Keys */
{OS.Key_Multiply, SWT.KEYPAD_MULTIPLY},
{OS.Key_Add, SWT.KEYPAD_ADD},
{OS.Key_Return, SWT.KEYPAD_CR},
{OS.Key_Subtract, SWT.KEYPAD_SUBTRACT},
{OS.Key_Decimal, SWT.KEYPAD_DECIMAL},
{OS.Key_Divide, SWT.KEYPAD_DIVIDE},
{OS.Key_NumPad0, SWT.KEYPAD_0},
{OS.Key_NumPad1, SWT.KEYPAD_1},
{OS.Key_NumPad2, SWT.KEYPAD_2},
{OS.Key_NumPad3, SWT.KEYPAD_3},
{OS.Key_NumPad4, SWT.KEYPAD_4},
{OS.Key_NumPad5, SWT.KEYPAD_5},
{OS.Key_NumPad6, SWT.KEYPAD_6},
{OS.Key_NumPad7, SWT.KEYPAD_7},
{OS.Key_NumPad8, SWT.KEYPAD_8},
{OS.Key_NumPad9, SWT.KEYPAD_9},
// {OS.VK_????, SWT.KEYPAD_EQUAL},
/* Other keys */
{OS.Key_CapsLock, SWT.CAPS_LOCK},
{OS.Key_NumLock, SWT.NUM_LOCK},
{OS.Key_Scroll, SWT.SCROLL_LOCK},
{OS.Key_Pause, SWT.PAUSE},
{OS.Key_Cancel, SWT.BREAK},
{OS.Key_PrintScreen, SWT.PRINT_SCREEN},
// {OS.VK_????, SWT.HELP},
{OS.Key_D0, '0'},
{OS.Key_D1, '1'},
{OS.Key_D2, '2'},
{OS.Key_D3, '3'},
{OS.Key_D4, '4'},
{OS.Key_D5, '5'},
{OS.Key_D6, '6'},
{OS.Key_D7, '7'},
{OS.Key_D8, '8'},
{OS.Key_D9, '9'},
{OS.Key_A, 'a'},
{OS.Key_B, 'b'},
{OS.Key_C, 'c'},
{OS.Key_D, 'd'},
{OS.Key_E, 'e'},
{OS.Key_F, 'f'},
{OS.Key_G, 'g'},
{OS.Key_H, 'h'},
{OS.Key_I, 'i'},
{OS.Key_J, 'j'},
{OS.Key_K, 'k'},
{OS.Key_L, 'l'},
{OS.Key_M, 'm'},
{OS.Key_N, 'n'},
{OS.Key_O, 'o'},
{OS.Key_P, 'p'},
{OS.Key_Q, 'q'},
{OS.Key_R, 'r'},
{OS.Key_S, 's'},
{OS.Key_T, 't'},
{OS.Key_U, 'u'},
{OS.Key_V, 'v'},
{OS.Key_W, 'w'},
{OS.Key_X, 'x'},
{OS.Key_Y, 'y'},
{OS.Key_Z, 'z'},
{OS.Key_OemTilde, '`'},
{OS.Key_OemMinus, '-'},
{OS.Key_OemPlus, '='},
{OS.Key_Oem4, '['},
{OS.Key_Oem6, ']'},
{OS.Key_OemPipe, '\\'},
{OS.Key_OemSemicolon, ';'},
{OS.Key_Oem7, '\''},
{OS.Key_OemComma, ','},
{OS.Key_OemPeriod, '.'},
{OS.Key_Oem2, '/'},
};
/* Multiple Displays */
static Display Default;
static Display [] Displays = new Display [4];
/* Multiple Monitors */
static Monitor[] monitors = null;
static int monitorCount = 0;
/* Modality */
Shell [] modalShells;
// Shell modalDialogShell;
/* Skinning support */
static final int GROW_SIZE = 1024;
Widget [] skinList = new Widget [GROW_SIZE];
int skinCount;
/* Package Name */
static final String PACKAGE_PREFIX = "org.eclipse.swt.widgets."; //$NON-NLS-1$
/*
* This code is intentionally commented. In order
* to support CLDC, .class cannot be used because
* it does not compile on some Java compilers when
* they are targeted for CLDC.
*/
// static {
// String name = Display.class.getName ();
// int index = name.lastIndexOf ('.');
// PACKAGE_PREFIX = name.substring (0, index + 1);
// }
/*
* TEMPORARY CODE. Install the runnable that
* gets the current display. This code will
* be removed in the future.
*/
static {
DeviceFinder = new Runnable () {
public void run () {
Device device = getCurrent ();
if (device == null) {
device = getDefault ();
}
setDevice (device);
}
};
}
/*
* TEMPORARY CODE.
*/
static void setDevice (Device device) {
CurrentDevice = device;
}
/**
* Constructs a new instance of this class.
* <p>
* Note: The resulting display is marked as the <em>current</em>
* display. If this is the first display which has been
* constructed since the application started, it is also
* marked as the <em>default</em> display.
* </p>
*
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if called from a thread that already created an existing display</li>
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*
* @see #getCurrent
* @see #getDefault
* @see Widget#checkSubclass
* @see Shell
*/
public Display () {
this (null);
}
/**
* Constructs a new instance of this class using the parameter.
*
* @param data the device data
*/
public Display (DeviceData data) {
super (data);
}
Control _getFocusControl () {
int focusedElement = OS.Keyboard_FocusedElement ();
Control control = null;
if (focusedElement != 0) {
Widget widget = getWidget (focusedElement);
if (widget instanceof Menu) {
Shell shell = ((Menu)widget).getShell();
OS.GCHandle_Free (focusedElement);
focusedElement = OS.FocusManager_GetFocusedElement (shell.shellHandle);
if (focusedElement == 0) return null;
widget = getWidget (focusedElement);
}
if (widget != null) control = widget.getWidgetControl ();
OS.GCHandle_Free (focusedElement);
}
return control;
}
void addWidget (int handle, Widget widget) {
if (handle == 0) return;
int tag = OS.gcnew_IntPtr (widget.jniRef);
OS.FrameworkElement_Tag (handle, tag);
OS.GCHandle_Free (tag);
}
/**
* Adds the listener to the collection of listeners who will
* be notified when an event of the given type occurs anywhere
* in a widget. The event type is one of the event constants
* defined in class <code>SWT</code>. When the event does occur,
* the listener is notified by sending it the <code>handleEvent()</code>
* message.
* <p>
* Setting the type of an event to <code>SWT.None</code> from
* within the <code>handleEvent()</code> method can be used to
* change the event type and stop subsequent Java listeners
* from running. Because event filters run before other listeners,
* event filters can both block other listeners and set arbitrary
* fields within an event. For this reason, event filters are both
* powerful and dangerous. They should generally be avoided for
* performance, debugging and code maintenance reasons.
* </p>
*
* @param eventType the type of event to listen for
* @param listener the listener which should be notified when the event occurs
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @see Listener
* @see SWT
* @see #removeFilter
* @see #removeListener
*
* @since 3.0
*/
public void addFilter (int eventType, Listener listener) {
checkDevice ();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (filterTable == null) filterTable = new EventTable ();
filterTable.hook (eventType, listener);
}
void addInvalidate (Control control) {
if (invalidate == null) invalidate = new Control [4];
int length = invalidate.length;
for (int i=0; i<length; i++) {
if (invalidate [i] == control) return;
}
int index = 0;
while (index < length) {
if (invalidate [index] == null) break;
index++;
}
if (index == length) {
Control [] temp = new Control [length + 4];
System.arraycopy (invalidate, 0, temp, 0, length);
invalidate = temp;
}
invalidate [index] = control;
if (invalidateHandler == 0) {
int handler = invalidateHandler = OS.gcnew_NoArgsDelegate (jniRef, "invalidateHandler");
int operation = OS.Dispatcher_BeginInvoke (dispatcher, OS.DispatcherPriority_Send, handler);
OS.GCHandle_Free (operation);
OS.GCHandle_Free (handler);
}
}
void addLayoutDeferred (Composite comp) {
if (layoutDeferred == null) layoutDeferred = new Composite [64];
if (layoutDeferredCount == layoutDeferred.length) {
Composite [] temp = new Composite [layoutDeferred.length + 64];
System.arraycopy (layoutDeferred, 0, temp, 0, layoutDeferred.length);
layoutDeferred = temp;
}
layoutDeferred[layoutDeferredCount++] = comp;
}
/**
* Adds the listener to the collection of listeners who will
* be notified when an event of the given type occurs. The event
* type is one of the event constants defined in class <code>SWT</code>.
* When the event does occur in the display, the listener is notified by
* sending it the <code>handleEvent()</code> message.
*
* @param eventType the type of event to listen for
* @param listener the listener which should be notified when the event occurs
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @see Listener
* @see SWT
* @see #removeListener
*
* @since 2.0
*/
public void addListener (int eventType, Listener listener) {
checkDevice ();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) eventTable = new EventTable ();
eventTable.hook (eventType, listener);
}
void addPopup (Menu menu) {
if (popups == null) popups = new Menu [4];
int length = popups.length;
for (int i=0; i<length; i++) {
if (popups [i] == menu) return;
}
int index = 0;
while (index < length) {
if (popups [index] == null) break;
index++;
}
if (index == length) {
Menu [] newPopups = new Menu [length + 4];
System.arraycopy (popups, 0, newPopups, 0, length);
popups = newPopups;
}
popups [index] = menu;
}
void addShell (Shell shell) {
if (shells == null) shells = new Shell [4];
int length = shells.length;
for (int i=0; i<length; i++) {
if (shells [i] == shell) return;
}
int index = 0;
while (index < length) {
if (shells [index] == null) break;
index++;
}
if (index == length) {
Shell [] temp = new Shell [length + 4];
System.arraycopy (shells, 0, temp, 0, length);
shells = temp;
}
shells [index] = shell;
}
void addSkinnableWidget (Widget widget) {
if (skinCount >= skinList.length) {
Widget[] newSkinWidgets = new Widget [skinList.length + GROW_SIZE];
System.arraycopy (skinList, 0, newSkinWidgets, 0, skinList.length);
skinList = newSkinWidgets;
}
skinList [skinCount++] = widget;
}
/**
* Causes the <code>run()</code> method of the runnable to
* be invoked by the user-interface thread at the next
* reasonable opportunity. The caller of this method continues
* to run in parallel, and is not notified when the
* runnable has completed. Specifying <code>null</code> as the
* runnable simply wakes the user-interface thread when run.
* <p>
* Note that at the time the runnable is invoked, widgets
* that have the receiver as their display may have been
* disposed. Therefore, it is necessary to check for this
* case inside the runnable before accessing the widget.
* </p>
*
* @param runnable code to run on the user-interface thread or <code>null</code>
*
* @exception SWTException <ul>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @see #syncExec
*/
public void asyncExec (Runnable runnable) {
synchronized (Device.class) {
if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
synchronizer.asyncExec (runnable);
}
}
/**
* Causes the system hardware to emit a short sound
* (if it supports this capability).
*
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public void beep () {
checkDevice ();
OS.Console_Beep ();
}
/**
* Checks that this class can be subclassed.
* <p>
* IMPORTANT: See the comment in <code>Widget.checkSubclass()</code>.
* </p>
*
* @exception SWTException <ul>
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*
* @see Widget#checkSubclass
*/
protected void checkSubclass () {
if (!isValidClass (getClass ())) error (SWT.ERROR_INVALID_SUBCLASS);
}
protected void checkDevice () {
if (thread == null) error (SWT.ERROR_WIDGET_DISPOSED);
if (thread != Thread.currentThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
}
static void checkDisplay (Thread thread, boolean multiple) {
synchronized (Device.class) {
for (int i=0; i<Displays.length; i++) {
if (Displays [i] != null) {
if (!multiple) SWT.error (SWT.ERROR_NOT_IMPLEMENTED, null, " [multiple displays]");
if (Displays [i].thread == thread) SWT.error (SWT.ERROR_THREAD_INVALID_ACCESS);
}
}
}
}
void clearModal (Shell shell) {
if (modalShells == null) return;
int index = 0, length = modalShells.length;
while (index < length) {
if (modalShells [index] == shell) break;
if (modalShells [index] == null) return;
index++;
}
if (index == length) return;
System.arraycopy (modalShells, index + 1, modalShells, index, --length - index);
modalShells [length] = null;
if (index == 0 && modalShells [0] == null) modalShells = null;
Shell [] shells = getShells ();
for (int i=0; i<shells.length; i++) shells [i].updateModal ();
}
/**
* Requests that the connection between SWT and the underlying
* operating system be closed.
*
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @see Device#dispose
*
* @since 2.0
*/
public void close () {
checkDevice ();
Event event = new Event ();
sendEvent (SWT.Close, event);
if (event.doit) dispose ();
}
/**
* Creates the device in the operating system. If the device
* does not have a handle, this method may do nothing depending
* on the device.
* <p>
* This method is called before <code>init</code>.
* </p>
*
* @param data the DeviceData which describes the receiver
*
* @see #init
*/
protected void create (DeviceData data) {
checkSubclass ();
checkDisplay (thread = Thread.currentThread (), true);
createDisplay (data);
register (this);
if (Default == null) Default = this;
}
void createDisplay (DeviceData data) {
Win32.OleInitialize (0);
application = OS.gcnew_Application();
if (application == 0) SWT.error(SWT.ERROR_NO_HANDLES);
OS.Application_ShutdownMode (application, OS.ShutdownMode_OnExplicitShutdown);
nameScope = OS.gcnew_NameScope ();
if (nameScope == 0) SWT.error (SWT.ERROR_NO_HANDLES);
}
static void deregister (Display display) {
synchronized (Device.class) {
for (int i=0; i<Displays.length; i++) {
if (display == Displays [i]) Displays [i] = null;
}
}
}
/**
* Destroys the device in the operating system and releases
* the device's handle. If the device does not have a handle,
* this method may do nothing depending on the device.
* <p>
* This method is called after <code>release</code>.
* </p>
* @see Device#dispose
* @see #release
*/
protected void destroy () {
if (this == Default) Default = null;
deregister (this);
destroyDisplay ();
}
void destroyDisplay () {
OS.GCHandle_Dump();
}
/**
* Causes the <code>run()</code> method of the runnable to
* be invoked by the user-interface thread just before the
* receiver is disposed. Specifying a <code>null</code> runnable
* is ignored.
*
* @param runnable code to run at dispose time.
*
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public void disposeExec (Runnable runnable) {
checkDevice ();
if (disposeList == null) disposeList = new Runnable [4];
for (int i=0; i<disposeList.length; i++) {
if (disposeList [i] == null) {
disposeList [i] = runnable;
return;
}
}
Runnable [] newDisposeList = new Runnable [disposeList.length + 4];
System.arraycopy (disposeList, 0, newDisposeList, 0, disposeList.length);
newDisposeList [disposeList.length] = runnable;
disposeList = newDisposeList;
}
/**
* Does whatever display specific cleanup is required, and then
* uses the code in <code>SWTError.error</code> to handle the error.
*
* @param code the descriptive error code
*
* @see SWT#error(int)
*/
void error (int code) {
SWT.error (code);
}
boolean filterEvent (Event event) {
if (filterTable != null) filterTable.sendEvent (event);
return false;
}
boolean filters (int eventType) {
if (filterTable == null) return false;
return filterTable.hooks (eventType);
}
/**
* Given the operating system handle for a widget, returns
* the instance of the <code>Widget</code> subclass which
* represents it in the currently running application, if
* such exists, or null if no matching widget can be found.
* <p>
* <b>IMPORTANT:</b> This method should not be called from
* application code. The arguments are platform-specific.
* </p>
*
* @param handle the handle for the widget
* @return the SWT widget that the handle represents
*
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @noreference This method is not intended to be referenced by clients.
*/
public Widget findWidget (int handle) {
checkDevice ();
return getWidget (handle);
}
/**
* Given the operating system handle for a widget,
* and widget-specific id, returns the instance of
* the <code>Widget</code> subclass which represents
* the handle/id pair in the currently running application,
* if such exists, or null if no matching widget can be found.
* <p>
* <b>IMPORTANT:</b> This method should not be called from
* application code. The arguments are platform-specific.
* </p>
*
* @param handle the handle for the widget
* @param id the id for the subwidget (usually an item)
* @return the SWT widget that the handle/id pair represents
*
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @noreference This method is not intended to be referenced by clients.
*
* @since 3.1
*/
public Widget findWidget (int handle, int id) {
checkDevice ();
return null;
}
/**
* Given a widget and a widget-specific id, returns the
* instance of the <code>Widget</code> subclass which represents
* the widget/id pair in the currently running application,
* if such exists, or null if no matching widget can be found.
*
* @param widget the widget
* @param id the id for the subwidget (usually an item)
* @return the SWT subwidget (usually an item) that the widget/id pair represents
*
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @since 3.3
*/
public Widget findWidget (Widget widget, int id) {
checkDevice ();
return null;
}
/**
* Returns the display which the given thread is the
* user-interface thread for, or null if the given thread
* is not a user-interface thread for any display. Specifying
* <code>null</code> as the thread will return <code>null</code>
* for the display.
*
* @param thread the user-interface thread
* @return the display for the given thread
*/
public static Display findDisplay (Thread thread) {
synchronized (Device.class) {
for (int i=0; i<Displays.length; i++) {
Display display = Displays [i];
if (display != null && display.thread == thread) {
return display;
}
}
return null;
}
}
/**
* Returns the currently active <code>Shell</code>, or null
* if no shell belonging to the currently running application
* is active.
*
* @return the active shell or null
*
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public Shell getActiveShell () {
checkDevice ();
int windows = OS.Application_Windows (application);
int count = OS.WindowCollection_Count (windows);
int activeWindow = 0;
if (count != 0) {
int enumerator = OS.WindowCollection_GetEnumerator (windows);
while (OS.IEnumerator_MoveNext (enumerator)) {
int window = OS.WindowCollection_Current (enumerator);
if (OS.Window_IsActive (window)) {
activeWindow = window;
break;
}
OS.GCHandle_Free (window);
}
OS.GCHandle_Free (enumerator);
}
OS.GCHandle_Free (windows);
Shell shell = (Shell)getWidget (activeWindow);
if (activeWindow != 0) OS.GCHandle_Free (activeWindow);
return shell;
}
/**
* Returns a rectangle describing the receiver's size and location. Note that
* on multi-monitor systems the origin can be negative.
*
* @return the bounding rectangle
*
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public Rectangle getBounds () {
checkDevice ();
int x = (int) OS.SystemParameters_VirtualScreenLeft ();
int y = (int) OS.SystemParameters_VirtualScreenTop ();
int width = (int) OS.SystemParameters_VirtualScreenWidth ();
int height = (int) OS.SystemParameters_VirtualScreenHeight ();
return new Rectangle (x, y, width, height);
}
/**
* Returns the display which the currently running thread is
* the user-interface thread for, or null if the currently
* running thread is not a user-interface thread for any display.
*
* @return the current display
*/
public static Display getCurrent () {
return findDisplay (Thread.currentThread ());
}
/**
* Returns a rectangle which describes the area of the
* receiver which is capable of displaying data.
*
* @return the client area
*
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @see #getBounds
*/
public Rectangle getClientArea () {
checkDevice ();
// if (true/*OS.GetSystemMetrics (OS.SM_CMONITORS) < 2*/) {
int rect = OS.SystemParameters_WorkArea ();
int x = (int) OS.Rect_X (rect);
int y = (int) OS.Rect_Y (rect);
int width = (int) OS.Rect_Width (rect);
int height = (int) OS.Rect_Height (rect);
OS.GCHandle_Free (rect);
return new Rectangle (x, y, width, height);
// }
// int x = (int) OS.SystemParameters_VirtualScreenLeft ();
// int y = (int) OS.SystemParameters_VirtualScreenTop ();
// int width = (int) OS.SystemParameters_VirtualScreenWidth ();
// int height = (int) OS.SystemParameters_VirtualScreenHeight ();
// return new Rectangle (x, y, width, height);
}
Widget getWidget (int handle) {
if (handle == 0) return null;
int frameworkElementType = OS.FrameworkElement_typeid ();
int frameworkContentElementType = OS.FrameworkContentElement_typeid ();
int widget = handle;
int jniRef = 0;
do {
int parent = 0;
if (OS.Type_IsInstanceOfType (frameworkElementType, widget)) {
int tag = OS.FrameworkElement_Tag (widget);
if (tag != 0) {
jniRef = OS.IntPtr_ToInt32 (tag);
OS.GCHandle_Free (tag);
break;
}
parent = OS.FrameworkElement_Parent (widget);
if (parent == 0) {
parent = OS.VisualTreeHelper_GetParent (widget);
}
} else {
if (OS.Type_IsInstanceOfType (frameworkContentElementType, widget)) {
parent = OS.FrameworkContentElement_Parent (widget);
}
}
if (widget != handle) OS.GCHandle_Free (widget);
widget = parent;
} while (widget != 0);
if (widget != handle && widget != 0) OS.GCHandle_Free (widget);
OS.GCHandle_Free (frameworkElementType);
OS.GCHandle_Free (frameworkContentElementType);
return jniRef != 0 ? (Widget) OS.JNIGetObject (jniRef) : null;
}
/**
* Returns the control which the on-screen pointer is currently
* over top of, or null if it is not currently over one of the
* controls built by the currently running application.
*
* @return the control under the cursor
*
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public Control getCursorControl () {
checkDevice ();
int inputElement = 0;
int captured = OS.Mouse_Captured ();
if (captured != 0) {
int sources = OS.PresentationSource_CurrentSources ();
int enumerator = OS.IEnumerable_GetEnumerator (sources);
while (OS.IEnumerator_MoveNext (enumerator) && inputElement == 0) {
int current = OS.IEnumerator_Current (enumerator);
int root = OS.PresentationSource_RootVisual (current);
if (root != 0) {
int pt = OS.Mouse_GetPosition (root);
inputElement = OS.UIElement_InputHitTest (root, pt);
OS.GCHandle_Free (pt);
OS.GCHandle_Free (root);
}
OS.GCHandle_Free (current);
}
OS.GCHandle_Free (enumerator);
OS.GCHandle_Free (sources);
OS.GCHandle_Free (captured);
} else {
inputElement = OS.Mouse_DirectlyOver ();
}
if (inputElement != 0) {
Widget widget = getWidget (inputElement);
OS.GCHandle_Free (inputElement);
if (widget != null) return widget.getWidgetControl ();
}
return null;
}
/**
* Returns the location of the on-screen pointer relative
* to the top left corner of the screen.
*
* @return the cursor location
*
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public Point getCursorLocation () {
checkDevice ();
POINT pt = new POINT ();
Win32.GetCursorPos (pt);
return new Point (pt.x, pt.y);
}
/**
* Returns an array containing the recommended cursor sizes.
*
* @return the array of cursor sizes
*
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @since 3.0
*/
public Point [] getCursorSizes () {
checkDevice ();
// return new Point [] {
// new Point (OS.GetSystemMetrics (OS.SM_CXCURSOR), OS.GetSystemMetrics (OS.SM_CYCURSOR))};
return null;
}
/**
* Returns the default display. One is created (making the
* thread that invokes this method its user-interface thread)
* if it did not already exist.
*
* @return the default display
*/
public static Display getDefault () {
synchronized (Device.class) {
if (Default == null) Default = new Display ();
return Default;
}
}
static boolean isValidClass (Class clazz) {
String name = clazz.getName ();
int index = name.lastIndexOf ('.');
return name.substring (0, index + 1).equals (PACKAGE_PREFIX);
}
/**
* Returns the application defined property of the receiver
* with the specified name, or null if it has not been set.
* <p>
* Applications may have associated arbitrary objects with the
* receiver in this fashion. If the objects stored in the
* properties need to be notified when the display is disposed
* of, it is the application's responsibility to provide a
* <code>disposeExec()</code> handler which does so.
* </p>
*
* @param key the name of the property
* @return the value of the property or null if it has not been set
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the key is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @see #setData(String, Object)
* @see #disposeExec(Runnable)
*/
public Object getData (String key) {
checkDevice ();
if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
// if (key.equals (RUN_MESSAGES_IN_IDLE_KEY)) {
// return new Boolean (runMessagesInIdle);
// }
if (keys == null) return null;
for (int i=0; i<keys.length; i++) {
if (keys [i].equals (key)) return values [i];
}
return null;
}
/**
* Returns the application defined, display specific data
* associated with the receiver, or null if it has not been
* set. The <em>display specific data</em> is a single,
* unnamed field that is stored with every display.
* <p>
* Applications may put arbitrary objects in this field. If
* the object stored in the display specific data needs to
* be notified when the display is disposed of, it is the
* application's responsibility to provide a
* <code>disposeExec()</code> handler which does so.
* </p>
*
* @return the display specific data
*
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @see #setData(Object)
* @see #disposeExec(Runnable)
*/
public Object getData () {
checkDevice ();
return data;
}
/**
* Returns the button dismissal alignment, one of <code>LEFT</code> or <code>RIGHT</code>.
* The button dismissal alignment is the ordering that should be used when positioning the
* default dismissal button for a dialog. For example, in a dialog that contains an OK and
* CANCEL button, on platforms where the button dismissal alignment is <code>LEFT</code>, the
* button ordering should be OK/CANCEL. When button dismissal alignment is <code>RIGHT</code>,
* the button ordering should be CANCEL/OK.
*
* @return the button dismissal order
*
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @since 2.1
*/
public int getDismissalAlignment () {
checkDevice ();
return SWT.LEFT;
}
/**
* Returns the longest duration, in milliseconds, between
* two mouse button clicks that will be considered a
* <em>double click</em> by the underlying operating system.
*
* @return the double click time
*
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public int getDoubleClickTime () {
checkDevice ();
//TODO
return 500;
}
/**
* Returns the control which currently has keyboard focus,
* or null if keyboard events are not currently going to
* any of the controls built by the currently running
* application.
*
* @return the control under the cursor
*
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public Control getFocusControl () {
checkDevice ();
if (focusControl != null && !focusControl.isDisposed ()) {
return focusControl;
}
return _getFocusControl ();
}
/**
* Returns true when the high contrast mode is enabled.
* Otherwise, false is returned.
* <p>
* Note: This operation is a hint and is not supported on
* platforms that do not have this concept.
* </p>
*
* @return the high contrast mode
*
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @since 3.0
*/
public boolean getHighContrast () {
checkDevice ();
return OS.SystemParameters_HighContrast ();
}
/**
* Returns the maximum allowed depth of icons on this display, in bits per pixel.
* On some platforms, this may be different than the actual depth of the display.
*
* @return the maximum icon depth
*
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @see Device#getDepth
*/
public int getIconDepth () {
checkDevice ();
// if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (5, 1)) {
// if (getDepth () >= 24) return 32;
// }
//
// /* Use the character encoding for the default locale */
// TCHAR buffer1 = new TCHAR (0, "Control Panel\\Desktop\\WindowMetrics", true); //$NON-NLS-1$
//
// int [] phkResult = new int [1];
// int result = OS.RegOpenKeyEx (OS.HKEY_CURRENT_USER, buffer1, 0, OS.KEY_READ, phkResult);
// if (result != 0) return 4;
int depth = 4;
// int [] lpcbData = new int [1];
//
// /* Use the character encoding for the default locale */
// TCHAR buffer2 = new TCHAR (0, "Shell Icon BPP", true); //$NON-NLS-1$
// result = OS.RegQueryValueEx (phkResult [0], buffer2, 0, null, (TCHAR) null, lpcbData);
// if (result == 0) {
// TCHAR lpData = new TCHAR (0, lpcbData [0] / TCHAR.sizeof);
// result = OS.RegQueryValueEx (phkResult [0], buffer2, 0, null, lpData, lpcbData);
// if (result == 0) {
// try {
// depth = Integer.parseInt (lpData.toString (0, lpData.strlen ()));
// } catch (NumberFormatException e) {}
// }
// }
// OS.RegCloseKey (phkResult [0]);
return depth;
}
/**
* Returns an array containing the recommended icon sizes.
*
* @return the array of icon sizes
*
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @see Decorations#setImages(Image[])
*
* @since 3.0
*/
public Point [] getIconSizes () {
checkDevice ();
//TODO
// return new Point [] {
// new Point (OS.GetSystemMetrics (OS.SM_CXSMICON), OS.GetSystemMetrics (OS.SM_CYSMICON)),
// new Point (OS.GetSystemMetrics (OS.SM_CXICON), OS.GetSystemMetrics (OS.SM_CYICON)),
// };
return null;
}
int getLastEventTime () {
//TODO - use OS
return (int)System.currentTimeMillis();
}
int getMessageCount () {
return synchronizer.getMessageCount ();
}
Shell getModalShell () {
if (modalShells == null) return null;
int index = modalShells.length;
while (--index >= 0) {
Shell shell = modalShells [index];
if (shell != null) return shell;
}
return null;
}
//Shell getModalDialogShell () {
// if (modalDialogShell != null && modalDialogShell.isDisposed ()) modalDialogShell = null;
// return modalDialogShell;
//}
/**
* Returns an array of monitors attached to the device.
*
* @return the array of monitors
*
* @since 3.0
*/
public Monitor [] getMonitors () {
checkDevice ();
int screens = OS.Screen_AllScreens ();
if (screens == 0) error (SWT.ERROR_NO_HANDLES);
int screenCount = OS.ICollection_Count (screens);
Monitor [] monitors = new Monitor [screenCount];
for (int i=0; i<screenCount; i++) {
int screen = OS.IList_default (screens, i);
int bounds = OS.Screen_Bounds (screen);
int workingArea = OS.Screen_WorkingArea (screen);
Monitor monitor = new Monitor ();
monitor.x = OS.Rectangle_X (bounds);
monitor.y = OS.Rectangle_Y (bounds);
monitor.width = OS.Rectangle_Width (bounds);
monitor.height = OS.Rectangle_Height (bounds);
monitor.clientX = OS.Rectangle_X (workingArea);
monitor.clientY = OS.Rectangle_Y (workingArea);
monitor.clientWidth = OS.Rectangle_Width (workingArea);
monitor.clientHeight = OS.Rectangle_Height (workingArea);
monitors [i] = monitor;
OS.GCHandle_Free (workingArea);
OS.GCHandle_Free (bounds);
OS.GCHandle_Free (screen);
}
OS.GCHandle_Free (screens);
return monitors;
}
/**
* Returns the primary monitor for that device.
*
* @return the primary monitor
*
* @since 3.0
*/
public Monitor getPrimaryMonitor () {
checkDevice ();
int screen = OS.Screen_PrimaryScreen ();
if (screen == 0) error (SWT.ERROR_NO_HANDLES);
int bounds = OS.Screen_Bounds (screen);
int workingArea = OS.Screen_WorkingArea (screen);
Monitor monitor = new Monitor ();
monitor.x = OS.Rectangle_X (bounds);
monitor.y = OS.Rectangle_Y (bounds);
monitor.width = OS.Rectangle_Width (bounds);
monitor.height = OS.Rectangle_Height (bounds);
monitor.clientX = OS.Rectangle_X (workingArea);
monitor.clientY = OS.Rectangle_Y (workingArea);
monitor.clientWidth = OS.Rectangle_Width (workingArea);
monitor.clientHeight = OS.Rectangle_Height (workingArea);
OS.GCHandle_Free (workingArea);
OS.GCHandle_Free (bounds);
OS.GCHandle_Free (screen);
return monitor;
}
/**
* Returns a (possibly empty) array containing all shells which have
* not been disposed and have the receiver as their display.
*
* @return the receiver's shells
*
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public Shell [] getShells () {
checkDevice ();
if (shells == null) return new Shell [0];
int length = 0;
for (int i=0; i<shells.length; i++) {
if (shells [i] != null) length++;
}
int index = 0;
Shell [] result = new Shell [length];
for (int i=0; i<shells.length; i++) {
Shell widget = shells [i];
if (widget != null) result [index++] = widget;
}
return result;
}
/**
* Gets the synchronizer used by the display.
*
* @return the receiver's synchronizer
*
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @since 3.4
*/
public Synchronizer getSynchronizer () {
checkDevice ();
return synchronizer;
}
/**
* Returns the thread that has invoked <code>syncExec</code>
* or null if no such runnable is currently being invoked by
* the user-interface thread.
* <p>
* Note: If a runnable invoked by asyncExec is currently
* running, this method will return null.
* </p>
*
* @return the receiver's sync-interface thread
*
* @exception SWTException <ul>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public Thread getSyncThread () {
synchronized (Device.class) {
if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
return synchronizer.syncThread;
}
}
/**
* Returns the matching standard color for the given
* constant, which should be one of the color constants
* specified in class <code>SWT</code>. Any value other
* than one of the SWT color constants which is passed
* in will result in the color black. This color should
* not be free'd because it was allocated by the system,
* not the application.
*
* @param id the color constant
* @return the matching color
*
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @see SWT
*/
public Color getSystemColor (int id) {
checkDevice ();
Color color = null;
if (0 <= id && id < colors.length) {
color = colors [id];
}
return color != null ? color : super.getSystemColor (id);
}
/**
* Returns the matching standard platform cursor for the given
* constant, which should be one of the cursor constants
* specified in class <code>SWT</code>. This cursor should
* not be free'd because it was allocated by the system,
* not the application. A value of <code>null</code> will
* be returned if the supplied constant is not an SWT cursor
* constant.
*
* @param id the SWT cursor constant
* @return the corresponding cursor or <code>null</code>
*
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @see SWT#CURSOR_ARROW
* @see SWT#CURSOR_WAIT
* @see SWT#CURSOR_CROSS
* @see SWT#CURSOR_APPSTARTING
* @see SWT#CURSOR_HELP
* @see SWT#CURSOR_SIZEALL
* @see SWT#CURSOR_SIZENESW
* @see SWT#CURSOR_SIZENS
* @see SWT#CURSOR_SIZENWSE
* @see SWT#CURSOR_SIZEWE
* @see SWT#CURSOR_SIZEN
* @see SWT#CURSOR_SIZES
* @see SWT#CURSOR_SIZEE
* @see SWT#CURSOR_SIZEW
* @see SWT#CURSOR_SIZENE
* @see SWT#CURSOR_SIZESE
* @see SWT#CURSOR_SIZESW
* @see SWT#CURSOR_SIZENW
* @see SWT#CURSOR_UPARROW
* @see SWT#CURSOR_IBEAM
* @see SWT#CURSOR_NO
* @see SWT#CURSOR_HAND
*
* @since 3.0
*/
public Cursor getSystemCursor (int id) {
checkDevice ();
if (!(0 <= id && id < cursors.length)) return null;
if (cursors [id] == null) {
cursors [id] = new Cursor (this, id);
}
return cursors [id];
}
/**
* Returns the matching standard platform image for the given
* constant, which should be one of the icon constants
* specified in class <code>SWT</code>. This image should
* not be free'd because it was allocated by the system,
* not the application. A value of <code>null</code> will
* be returned either if the supplied constant is not an
* SWT icon constant or if the platform does not define an
* image that corresponds to the constant.
*
* @param id the SWT icon constant
* @return the corresponding image or <code>null</code>
*
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @see SWT#ICON_ERROR
* @see SWT#ICON_INFORMATION
* @see SWT#ICON_QUESTION
* @see SWT#ICON_WARNING
* @see SWT#ICON_WORKING
*
* @since 3.0
*/
public Image getSystemImage (int id) {
checkDevice ();
switch (id) {
case SWT.ICON_ERROR: {
if (errorImage != null) return errorImage;
int hIcon = Win32.LoadImage (0, Win32.OIC_HAND, Win32.IMAGE_ICON, 0, 0, Win32.LR_SHARED);
int empty = OS.Int32Rect_Empty ();
int source = OS.Imaging_CreateBitmapSourceFromHIcon (hIcon, empty, 0);
errorImage = Image.wpf_new (this, SWT.BITMAP, source);
OS.GCHandle_Free (empty);
Win32.DestroyIcon (hIcon);
return errorImage;
}
case SWT.ICON_WORKING:
case SWT.ICON_INFORMATION: {
if (infoImage != null) return infoImage;
int hIcon = Win32.LoadImage (0, Win32.OIC_INFORMATION, Win32.IMAGE_ICON, 0, 0, Win32.LR_SHARED);
int empty = OS.Int32Rect_Empty ();
int source = OS.Imaging_CreateBitmapSourceFromHIcon (hIcon, empty, 0);
infoImage = Image.wpf_new (this, SWT.BITMAP, source);
OS.GCHandle_Free (empty);
Win32.DestroyIcon (hIcon);
return infoImage;
}
case SWT.ICON_QUESTION: {
if (questionImage != null) return questionImage;
int hIcon = Win32.LoadImage (0, Win32.OIC_QUES, Win32.IMAGE_ICON, 0, 0, Win32.LR_SHARED);
int empty = OS.Int32Rect_Empty ();
int source = OS.Imaging_CreateBitmapSourceFromHIcon (hIcon, empty, 0);
questionImage = Image.wpf_new (this, SWT.BITMAP, source);
OS.GCHandle_Free (empty);
Win32.DestroyIcon (hIcon);
return questionImage;
}
case SWT.ICON_WARNING: {
if (warningIcon != null) return warningIcon;
int hIcon = Win32.LoadImage (0, Win32.OIC_BANG, Win32.IMAGE_ICON, 0, 0, Win32.LR_SHARED);
int empty = OS.Int32Rect_Empty ();
int source = OS.Imaging_CreateBitmapSourceFromHIcon (hIcon, empty, 0);
warningIcon = Image.wpf_new (this, SWT.BITMAP, source);
OS.GCHandle_Free (empty);
Win32.DestroyIcon (hIcon);
return warningIcon;
}
}
return null;
}
/**
* Returns the single instance of the system taskBar or null
* when there is no system taskBar available for the platform.
*
* @return the system taskBar or <code>null</code>
*
* @exception SWTException <ul>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @since 3.6
*/
public TaskBar getSystemTaskBar () {
checkDevice ();
return null;
}
/**
* Returns the single instance of the system tray or null
* when there is no system tray available for the platform.
*
* @return the system tray or <code>null</code>
*
* @exception SWTException <ul>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @since 3.0
*/
public Tray getSystemTray () {
checkDevice ();
if (tray != null) return tray;
tray = new Tray (this, SWT.NONE);
return tray;
}
/**
* Returns the user-interface thread for the receiver.
*
* @return the receiver's user-interface thread
*
* @exception SWTException <ul>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public Thread getThread () {
synchronized (Device.class) {
if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
return thread;
}
}
/**
* Invokes platform specific functionality to allocate a new GC handle.
* <p>
* <b>IMPORTANT:</b> This method is <em>not</em> part of the public
* API for <code>Display</code>. It is marked public only so that it
* can be shared within the packages provided by SWT. It is not
* available on all platforms, and should never be called from
* application code.
* </p>
*
* @param data the platform specific GC data
* @return the platform specific GC handle
*
* @exception SWTException <ul>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
* @exception SWTError <ul>
* <li>ERROR_NO_HANDLES if a handle could not be obtained for gc creation</li>
* </ul>
*
* @noreference This method is not intended to be referenced by clients.
*/
public int internal_new_GC (GCData data) {
if (isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
//TODO - for now, return a drawing context that can measure text
if (data == null) return 0;
int visual = OS.gcnew_DrawingVisual();
if (visual == 0) SWT.error(SWT.ERROR_NO_HANDLES);
int dc = OS.DrawingVisual_RenderOpen (visual);
if (dc == 0) SWT.error (SWT.ERROR_NO_HANDLES);
data.visual = visual;
data.font = getSystemFont ();
return dc;
}
/**
* Initializes any internal resources needed by the
* device.
* <p>
* This method is called after <code>create</code>.
* </p>
*
* @see #create
*/
protected void init () {
super.init ();
dispatcher = OS.Application_Dispatcher (application);
if (dispatcher == 0) SWT.error (SWT.ERROR_NO_HANDLES);
frame = OS.gcnew_DispatcherFrame ();
if (frame == 0) SWT.error (SWT.ERROR_NO_HANDLES);
jniRef = OS.NewGlobalRef (this);
if (jniRef == 0) SWT.error (SWT.ERROR_NO_HANDLES);
int hooks = OS.Dispatcher_Hooks (dispatcher);
int handler = OS.gcnew_EventHandler (jniRef, "HandleDispatcherInactive");
OS.DispatcherHooks_DispatcherInactive (hooks, handler);
OS.GCHandle_Free (handler);
handler = OS.gcnew_DispatcherHookEventHandler (jniRef, "HandleOperationCompleted");
OS.DispatcherHooks_OperationCompleted (hooks, handler);
OS.GCHandle_Free (handler);
handler = OS.gcnew_DispatcherHookEventHandler (jniRef, "HandleOperationPosted");
OS.DispatcherHooks_OperationPosted (hooks, handler);
OS.GCHandle_Free (handler);
OS.GCHandle_Free (hooks);
timerHandler = OS.gcnew_TimerHandler(jniRef, "timerProc");
/* Create the standard colors */
colors = new Color [SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT + 1];
colors [SWT.COLOR_WIDGET_DARK_SHADOW] = Color.wpf_new( this, OS.SystemColors_ControlDarkDarkColor ());
colors [SWT.COLOR_WIDGET_NORMAL_SHADOW] = Color.wpf_new (this, OS.SystemColors_ControlDarkColor ());
colors [SWT.COLOR_WIDGET_LIGHT_SHADOW] = Color.wpf_new (this, OS.SystemColors_ControlLightColor ());
colors [SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW] = Color.wpf_new (this, OS.SystemColors_ControlLightLightColor ());
colors [SWT.COLOR_WIDGET_FOREGROUND] = Color.wpf_new (this, OS.SystemColors_ControlTextColor ());
colors [SWT.COLOR_WIDGET_BACKGROUND] = Color.wpf_new (this, OS.SystemColors_ControlColor ());
colors [SWT.COLOR_WIDGET_BORDER] = Color.wpf_new (this, OS.SystemColors_ActiveBorderColor ());
colors [SWT.COLOR_LIST_FOREGROUND] = Color.wpf_new (this, OS.SystemColors_WindowTextColor ());
colors [SWT.COLOR_LIST_BACKGROUND] = Color.wpf_new (this, OS.SystemColors_WindowColor ());
colors [SWT.COLOR_LIST_SELECTION] = Color.wpf_new (this, OS.SystemColors_HighlightColor ());
colors [SWT.COLOR_LIST_SELECTION_TEXT] = Color.wpf_new (this, OS.SystemColors_HighlightTextColor ());
colors [SWT.COLOR_INFO_FOREGROUND] = Color.wpf_new (this, OS.SystemColors_InfoTextColor ());
colors [SWT.COLOR_INFO_BACKGROUND] = Color.wpf_new (this, OS.SystemColors_InfoColor ());
colors [SWT.COLOR_TITLE_FOREGROUND] = Color.wpf_new (this, OS.SystemColors_ActiveCaptionTextColor ());
colors [SWT.COLOR_TITLE_BACKGROUND] = Color.wpf_new (this, OS.SystemColors_ActiveCaptionColor ());
colors [SWT.COLOR_TITLE_BACKGROUND_GRADIENT] = Color.wpf_new (this, OS.SystemColors_GradientActiveCaptionColor ());
colors [SWT.COLOR_TITLE_INACTIVE_FOREGROUND] = Color.wpf_new (this, OS.SystemColors_InactiveCaptionTextColor ());
colors [SWT.COLOR_TITLE_INACTIVE_BACKGROUND] = Color.wpf_new (this, OS.SystemColors_InactiveCaptionColor ());
colors [SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT] = Color.wpf_new (this, OS.SystemColors_GradientInactiveCaptionColor ());
}
void invalidateHandler () {
invalidateHandler = 0;
if (invalidate != null) {
Control[] invalidate = this.invalidate;
this.invalidate = null;
for (int i = 0; i < invalidate.length; i++) {
Control control = invalidate [i];
if (control != null && !control.isDisposed()) {
control.redraw (true);
}
}
}
}
void HandleDispatcherInactive (int sender, int e) {
if (runAsyncMessages (false)) wakeThread ();
}
void HandleOperationCompleted (int sender, int e) {
if (operation != 0) {
int current = OS.DispatcherHookEventArgs_Operation(e);
int priority = OS.DispatcherOperation_Priority(current);
if (priority == 5) OS.DispatcherOperation_Abort(operation);
OS.GCHandle_Free(current);
}
}
void HandleOperationPosted (int sender, int e) {
if (sleepOperation != 0) OS.DispatcherOperation_Priority(sleepOperation, OS.DispatcherPriority_Send);
}
/**
* Invokes platform specific functionality to dispose a GC handle.
* <p>
* <b>IMPORTANT:</b> This method is <em>not</em> part of the public
* API for <code>Display</code>. It is marked public only so that it
* can be shared within the packages provided by SWT. It is not
* available on all platforms, and should never be called from
* application code.
* </p>
*
* @param hDC the platform specific GC handle
* @param data the platform specific GC data
*
* @noreference This method is not intended to be referenced by clients.
*/
public void internal_dispose_GC (int dc, GCData data) {
//TODO - the wrong drawing context was created
if (data != null && data.drawingContext == 0) {
OS.DrawingContext_Close (dc);
OS.GCHandle_Free (dc);
OS.GCHandle_Free (data.visual);
}
}
boolean isValidThread () {
return thread == Thread.currentThread ();
}
/**
* Maps a point from one coordinate system to another.
* When the control is null, coordinates are mapped to
* the display.
* <p>
* NOTE: On right-to-left platforms where the coordinate
* systems are mirrored, special care needs to be taken
* when mapping coordinates from one control to another
* to ensure the result is correctly mirrored.
*
* Mapping a point that is the origin of a rectangle and
* then adding the width and height is not equivalent to
* mapping the rectangle. When one control is mirrored
* and the other is not, adding the width and height to a
* point that was mapped causes the rectangle to extend
* in the wrong direction. Mapping the entire rectangle
* instead of just one point causes both the origin and
* the corner of the rectangle to be mapped.
* </p>
*
* @param from the source <code>Control</code> or <code>null</code>
* @param to the destination <code>Control</code> or <code>null</code>
* @param point to be mapped
* @return point with mapped coordinates
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the point is null</li>
* <li>ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @since 2.1.2
*/
public Point map (Control from, Control to, Point point) {
checkDevice ();
if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
return map (from, to, point.x, point.y);
}
/**
* Maps a point from one coordinate system to another.
* When the control is null, coordinates are mapped to
* the display.
* <p>
* NOTE: On right-to-left platforms where the coordinate
* systems are mirrored, special care needs to be taken
* when mapping coordinates from one control to another
* to ensure the result is correctly mirrored.
*
* Mapping a point that is the origin of a rectangle and
* then adding the width and height is not equivalent to
* mapping the rectangle. When one control is mirrored
* and the other is not, adding the width and height to a
* point that was mapped causes the rectangle to extend
* in the wrong direction. Mapping the entire rectangle
* instead of just one point causes both the origin and
* the corner of the rectangle to be mapped.
* </p>
*
* @param from the source <code>Control</code> or <code>null</code>
* @param to the destination <code>Control</code> or <code>null</code>
* @param x coordinates to be mapped
* @param y coordinates to be mapped
* @return point with mapped coordinates
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @since 2.1.2
*/
public Point map (Control from, Control to, int x, int y) {
checkDevice ();
if (from != null && from.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
if (to != null && to.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
if (from == to) return new Point (x, y);
int newX, newY;
if (from != null && to != null) {
int point = OS.gcnew_Point (x, y);
int newPoint = OS.UIElement_TranslatePoint (from.handle, point, to.handle);
newX = (int) (OS.Point_X (newPoint) + 0.5);
newY = (int) (OS.Point_Y (newPoint) + 0.5);
OS.GCHandle_Free (point);
OS.GCHandle_Free (newPoint);
} else {
if (from == null) {
int toHandle = to.handle;
to.updateLayout (toHandle);
int source = OS.PresentationSource_FromVisual (toHandle);
int window = OS.PresentationSource_RootVisual (source);
OS.GCHandle_Free (source);
int point = OS.gcnew_Point (x, y);
int temp = OS.Visual_PointFromScreen (window, point);
int newPoint = OS.UIElement_TranslatePoint (window, temp, toHandle);
newX = (int) OS.Point_X (newPoint);
newY = (int) OS.Point_Y (newPoint);
OS.GCHandle_Free (temp);
OS.GCHandle_Free (point);
OS.GCHandle_Free (newPoint);
OS.GCHandle_Free (window);
} else {
int fromHandle = from.handle;
from.updateLayout (fromHandle);
int source = OS.PresentationSource_FromVisual (fromHandle);
int window = OS.PresentationSource_RootVisual (source);
OS.GCHandle_Free (source);
int point = OS.gcnew_Point (x, y);
int temp = OS.UIElement_TranslatePoint (fromHandle, point, window);
int newPoint = OS.Visual_PointToScreen (window, temp);
newX = (int) OS.Point_X (newPoint);
newY = (int) OS.Point_Y (newPoint);
OS.GCHandle_Free (temp);
OS.GCHandle_Free (point);
OS.GCHandle_Free (newPoint);
OS.GCHandle_Free (window);
}
}
return new Point (newX, newY);
}
/**
* Maps a point from one coordinate system to another.
* When the control is null, coordinates are mapped to
* the display.
* <p>
* NOTE: On right-to-left platforms where the coordinate
* systems are mirrored, special care needs to be taken
* when mapping coordinates from one control to another
* to ensure the result is correctly mirrored.
*
* Mapping a point that is the origin of a rectangle and
* then adding the width and height is not equivalent to
* mapping the rectangle. When one control is mirrored
* and the other is not, adding the width and height to a
* point that was mapped causes the rectangle to extend
* in the wrong direction. Mapping the entire rectangle
* instead of just one point causes both the origin and
* the corner of the rectangle to be mapped.
* </p>
*
* @param from the source <code>Control</code> or <code>null</code>
* @param to the destination <code>Control</code> or <code>null</code>
* @param rectangle to be mapped
* @return rectangle with mapped coordinates
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the rectangle is null</li>
* <li>ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @since 2.1.2
*/
public Rectangle map (Control from, Control to, Rectangle rectangle) {
checkDevice ();
if (rectangle == null) error (SWT.ERROR_NULL_ARGUMENT);
return map (from, to, rectangle.x, rectangle.y, rectangle.width, rectangle.height);
}
/**
* Maps a point from one coordinate system to another.
* When the control is null, coordinates are mapped to
* the display.
* <p>
* NOTE: On right-to-left platforms where the coordinate
* systems are mirrored, special care needs to be taken
* when mapping coordinates from one control to another
* to ensure the result is correctly mirrored.
*
* Mapping a point that is the origin of a rectangle and
* then adding the width and height is not equivalent to
* mapping the rectangle. When one control is mirrored
* and the other is not, adding the width and height to a
* point that was mapped causes the rectangle to extend
* in the wrong direction. Mapping the entire rectangle
* instead of just one point causes both the origin and
* the corner of the rectangle to be mapped.
* </p>
*
* @param from the source <code>Control</code> or <code>null</code>
* @param to the destination <code>Control</code> or <code>null</code>
* @param x coordinates to be mapped
* @param y coordinates to be mapped
* @param width coordinates to be mapped
* @param height coordinates to be mapped
* @return rectangle with mapped coordinates
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @since 2.1.2
*/
public Rectangle map (Control from, Control to, int x, int y, int width, int height) {
checkDevice ();
if (from != null && from.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
if (to != null && to.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
if (from == to) return new Rectangle (x, y, width, height);
//TODO
Point point = map (from, to, x, y);
return new Rectangle (point.x, point.y, width, height);
}
/**
* Generate a low level system event.
*
* <code>post</code> is used to generate low level keyboard
* and mouse events. The intent is to enable automated UI
* testing by simulating the input from the user. Most
* SWT applications should never need to call this method.
* <p>
* Note that this operation can fail when the operating system
* fails to generate the event for any reason. For example,
* this can happen when there is no such key or mouse button
* or when the system event queue is full.
* </p>
* <p>
* <b>Event Types:</b>
* <p>KeyDown, KeyUp
* <p>The following fields in the <code>Event</code> apply:
* <ul>
* <li>(in) type KeyDown or KeyUp</li>
* <p> Either one of:
* <li>(in) character a character that corresponds to a keyboard key</li>
* <li>(in) keyCode the key code of the key that was typed,
* as defined by the key code constants in class <code>SWT</code></li>
* </ul>
* <p>MouseDown, MouseUp</p>
* <p>The following fields in the <code>Event</code> apply:
* <ul>
* <li>(in) type MouseDown or MouseUp
* <li>(in) button the button that is pressed or released
* </ul>
* <p>MouseMove</p>
* <p>The following fields in the <code>Event</code> apply:
* <ul>
* <li>(in) type MouseMove
* <li>(in) x the x coordinate to move the mouse pointer to in screen coordinates
* <li>(in) y the y coordinate to move the mouse pointer to in screen coordinates
* </ul>
* <p>MouseWheel</p>
* <p>The following fields in the <code>Event</code> apply:
* <ul>
* <li>(in) type MouseWheel
* <li>(in) detail either SWT.SCROLL_LINE or SWT.SCROLL_PAGE
* <li>(in) count the number of lines or pages to scroll
* </ul>
* </dl>
*
* @param event the event to be generated
*
* @return true if the event was generated or false otherwise
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the event is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @since 3.0
*
*/
public boolean post (Event event) {
synchronized (Device.class) {
if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
if (event == null) error (SWT.ERROR_NULL_ARGUMENT);
// int type = event.type;
// switch (type){
// case SWT.KeyDown:
// case SWT.KeyUp: {
// KEYBDINPUT inputs = new KEYBDINPUT ();
// inputs.wVk = (short) untranslateKey (event.keyCode);
// if (inputs.wVk == 0) {
// char key = event.character;
// switch (key) {
// case SWT.BS: inputs.wVk = (short) OS.VK_BACK; break;
// case SWT.CR: inputs.wVk = (short) OS.VK_RETURN; break;
// case SWT.DEL: inputs.wVk = (short) OS.VK_DELETE; break;
// case SWT.ESC: inputs.wVk = (short) OS.VK_ESCAPE; break;
// case SWT.TAB: inputs.wVk = (short) OS.VK_TAB; break;
// /*
// * Since there is no LF key on the keyboard, do not attempt
// * to map LF to CR or attempt to post an LF key.
// */
// // case SWT.LF: inputs.wVk = (short) OS.VK_RETURN; break;
// case SWT.LF: return false;
// default: {
// if (OS.IsWinCE) {
// inputs.wVk = OS.CharUpper ((short) key);
// } else {
// inputs.wVk = OS.VkKeyScan ((short) wcsToMbcs (key, 0));
// if (inputs.wVk == -1) return false;
// inputs.wVk &= 0xFF;
// }
// }
// }
// }
// inputs.dwFlags = type == SWT.KeyUp ? OS.KEYEVENTF_KEYUP : 0;
// int hHeap = OS.GetProcessHeap ();
// int pInputs = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, INPUT.sizeof);
// OS.MoveMemory(pInputs, new int[] {OS.INPUT_KEYBOARD}, 4);
// OS.MoveMemory (pInputs + 4, inputs, KEYBDINPUT.sizeof);
// boolean result = OS.SendInput (1, pInputs, INPUT.sizeof) != 0;
// OS.HeapFree (hHeap, 0, pInputs);
// return result;
// }
// case SWT.MouseDown:
// case SWT.MouseMove:
// case SWT.MouseUp: {
// MOUSEINPUT inputs = new MOUSEINPUT ();
// if (type == SWT.MouseMove){
// inputs.dwFlags = OS.MOUSEEVENTF_MOVE | OS.MOUSEEVENTF_ABSOLUTE;
// inputs.dx = event.x * 65535 / (OS.GetSystemMetrics (OS.SM_CXSCREEN) - 1);
// inputs.dy = event.y * 65535 / (OS.GetSystemMetrics (OS.SM_CYSCREEN) - 1);
// } else {
// switch (event.button) {
// case 1: inputs.dwFlags = type == SWT.MouseDown ? OS.MOUSEEVENTF_LEFTDOWN : OS.MOUSEEVENTF_LEFTUP; break;
// case 2: inputs.dwFlags = type == SWT.MouseDown ? OS.MOUSEEVENTF_MIDDLEDOWN : OS.MOUSEEVENTF_MIDDLEUP; break;
// case 3: inputs.dwFlags = type == SWT.MouseDown ? OS.MOUSEEVENTF_RIGHTDOWN : OS.MOUSEEVENTF_RIGHTUP; break;
// default: return false;
// }
// }
// int hHeap = OS.GetProcessHeap ();
// int pInputs = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, INPUT.sizeof);
// OS.MoveMemory(pInputs, new int[] {OS.INPUT_MOUSE}, 4);
// OS.MoveMemory (pInputs + 4, inputs, MOUSEINPUT.sizeof);
// boolean result = OS.SendInput (1, pInputs, INPUT.sizeof) != 0;
// OS.HeapFree (hHeap, 0, pInputs);
// return result;
// }
// }
return false;
}
}
void postEvent (Event event) {
/*
* Place the event at the end of the event queue.
* This code is always called in the Display's
* thread so it must be re-enterant but does not
* need to be synchronized.
*/
if (eventQueue == null) eventQueue = new Event [4];
int index = 0;
int length = eventQueue.length;
while (index < length) {
if (eventQueue [index] == null) break;
index++;
}
if (index == length) {
Event [] newQueue = new Event [length + 4];
System.arraycopy (eventQueue, 0, newQueue, 0, length);
eventQueue = newQueue;
}
eventQueue [index] = event;
}
void removePopup (Menu menu) {
if (popups == null) return;
for (int i=0; i<popups.length; i++) {
if (popups [i] == menu) {
popups [i] = null;
return;
}
}
}
void removeShell (Shell shell) {
if (shells == null) return;
for (int i=0; i<shells.length; i++) {
if (shells [i] == shell) {
shells [i] = null;
return;
}
}
}
/**
* Reads an event from the operating system's event queue,
* dispatches it appropriately, and returns <code>true</code>
* if there is potentially more work to do, or <code>false</code>
* if the caller can sleep until another event is placed on
* the event queue.
* <p>
* In addition to checking the system event queue, this method also
* checks if any inter-thread messages (created by <code>syncExec()</code>
* or <code>asyncExec()</code>) are waiting to be processed, and if
* so handles them before returning.
* </p>
*
* @return <code>false</code> if the caller can sleep upon return from this method
*
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_FAILED_EXEC - if an exception occurred while running an inter-thread message</li>
* </ul>
*
* @see #sleep
* @see #wake
*/
public boolean readAndDispatch () {
checkDevice ();
runSkin ();
runDeferredLayouts ();
runPopups ();
idle = false;
int handler = OS.gcnew_NoArgsDelegate(jniRef, "setIdleHandler");
operation = OS.Dispatcher_BeginInvoke(dispatcher, 2, handler);
OS.DispatcherOperation_Wait(operation);
OS.GCHandle_Free(handler);
OS.GCHandle_Free(operation);
operation = 0;
if (!idle) {
runDeferredEvents();
return true;
}
return isDisposed () || runAsyncMessages(false);
}
static void register (Display display) {
synchronized (Device.class) {
for (int i=0; i<Displays.length; i++) {
if (Displays [i] == null) {
Displays [i] = display;
return;
}
}
Display [] newDisplays = new Display [Displays.length + 4];
System.arraycopy (Displays, 0, newDisplays, 0, Displays.length);
newDisplays [Displays.length] = display;
Displays = newDisplays;
}
}
/**
* Releases any internal resources back to the operating
* system and clears all fields except the device handle.
* <p>
* Disposes all shells which are currently open on the display.
* After this method has been invoked, all related related shells
* will answer <code>true</code> when sent the message
* <code>isDisposed()</code>.
* </p><p>
* When a device is destroyed, resources that were acquired
* on behalf of the programmer need to be returned to the
* operating system. For example, if the device allocated a
* font to be used as the system font, this font would be
* freed in <code>release</code>. Also,to assist the garbage
* collector and minimize the amount of memory that is not
* reclaimed when the programmer keeps a reference to a
* disposed device, all fields except the handle are zero'd.
* The handle is needed by <code>destroy</code>.
* </p>
* This method is called before <code>destroy</code>.
*
* @see Device#dispose
* @see #destroy
*/
protected void release () {
sendEvent (SWT.Dispose, new Event ());
Shell [] shells = getShells ();
for (int i=0; i<shells.length; i++) {
Shell shell = shells [i];
if (!shell.isDisposed ()) shell.dispose ();
}
if (tray != null) tray.dispose ();
tray = null;
//hack... readAndDispatch Always returns true right now, prevents apps from shutting down.
//while (readAndDispatch ()) {}
if (disposeList != null) {
for (int i=0; i<disposeList.length; i++) {
if (disposeList [i] != null) disposeList [i].run ();
}
}
disposeList = null;
synchronizer.releaseSynchronizer ();
synchronizer = null;
releaseDisplay ();
super.release ();
}
void releaseDisplay () {
/* Release the timers */
OS.GCHandle_Free (timerHandler);
timerHandler = 0;
if (timerHandles != null) {
for (int i = 0; i < timerHandles.length; i++) {
int timer = timerHandles [i];
if (timer != 0) {
OS.DispatcherTimer_Stop (timer);
OS.GCHandle_Free (timer);
}
}
}
timerHandles = null;
timerList = null;
if (nameScope != 0) OS.GCHandle_Free (nameScope);
nameScope = 0;
if (application != 0) {
OS.Application_Shutdown (application);
OS.GCHandle_Free (application);
}
application = 0;
if (dispatcher != 0) OS.GCHandle_Free (dispatcher);
dispatcher = 0;
if (frame != 0) OS.GCHandle_Free (frame);
frame = 0;
if (jniRef != 0) OS.DeleteGlobalRef (jniRef);
jniRef = 0;
for (int i = 0; i < colors.length; i++) {
if (colors [i] != null) colors [i].dispose ();
}
colors = null;
// /* Release the System fonts */
// if (systemFont != null) systemFont.dispose ();
// systemFont = null;
// lfSystemFont = null;
/* Release the System Images */
if (errorImage != null) errorImage.dispose ();
if (infoImage != null) infoImage.dispose ();
if (questionImage != null) questionImage.dispose ();
if (warningIcon != null) warningIcon.dispose ();
errorImage = infoImage = questionImage = warningIcon = null;
/* Release the System Cursors */
for (int i = 0; i < cursors.length; i++) {
if (cursors [i] != null) cursors [i].dispose ();
}
cursors = null;
// /* Release Acquired Resources */
// if (resources != null) {
// for (int i=0; i<resources.length; i++) {
// if (resources [i] != null) resources [i].dispose ();
// }
// resources = null;
// }
//
/* Release Custom Colors for ChooseColor */
if (customColors != 0) OS.GCHandle_Free (customColors);
customColors = 0;
/* Release references */
thread = null;
// modalDialogShell = null;
modalShells = null;
data = null;
keys = null;
values = null;
popups = null;
mouseControl = null;
shells = null;
eventTable = filterTable = null;
/* Uninitialize OLE */
Win32.OleUninitialize ();
}
/**
* Removes the listener from the collection of listeners who will
* be notified when an event of the given type occurs anywhere in
* a widget. The event type is one of the event constants defined
* in class <code>SWT</code>.
*
* @param eventType the type of event to listen for
* @param listener the listener which should no longer be notified when the event occurs
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see Listener
* @see SWT
* @see #addFilter
* @see #addListener
*
* @since 3.0
*/
public void removeFilter (int eventType, Listener listener) {
checkDevice ();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (filterTable == null) return;
filterTable.unhook (eventType, listener);
if (filterTable.size () == 0) filterTable = null;
}
/**
* Removes the listener from the collection of listeners who will
* be notified when an event of the given type occurs. The event type
* is one of the event constants defined in class <code>SWT</code>.
*
* @param eventType the type of event to listen for
* @param listener the listener which should no longer be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @see Listener
* @see SWT
* @see #addListener
*
* @since 2.0
*/
public void removeListener (int eventType, Listener listener) {
checkDevice ();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook (eventType, listener);
}
Widget removeWidget (int handle) {
if (handle == 0) return null;
int tag = OS.FrameworkElement_Tag (handle), ref = 0;
if (tag != 0) {
ref = OS.IntPtr_ToInt32(tag);
OS.GCHandle_Free(tag);
}
Widget widget = null;
if (ref != 0) {
OS.FrameworkElement_Tag (handle, 0);
widget = (Widget) OS.JNIGetObject (ref);
}
return widget;
}
boolean runAsyncMessages (boolean all) {
return synchronizer.runAsyncMessages (all);
}
boolean runDeferredEvents () {
boolean run = false;
/*
* Run deferred events. This code is always
* called in the Display's thread so it must
* be re-enterant but need not be synchronized.
*/
while (eventQueue != null) {
/* Take an event off the queue */
Event event = eventQueue [0];
if (event == null) break;
int length = eventQueue.length;
System.arraycopy (eventQueue, 1, eventQueue, 0, --length);
eventQueue [length] = null;
/* Run the event */
Widget widget = event.widget;
if (widget != null && !widget.isDisposed ()) {
Widget item = event.item;
if (item == null || !item.isDisposed ()) {
run = true;
widget.sendEvent (event);
}
}
/*
* At this point, the event queue could
* be null due to a recursive invokation
* when running the event.
*/
}
/* Clear the queue */
eventQueue = null;
return run;
}
boolean runDeferredLayouts () {
if (layoutDeferredCount != 0) {
Composite[] temp = layoutDeferred;
int count = layoutDeferredCount;
layoutDeferred = null;
layoutDeferredCount = 0;
for (int i = 0; i < count; i++) {
Composite comp = temp[i];
if (!comp.isDisposed()) comp.setLayoutDeferred (false);
}
return true;
}
return false;
}
boolean runPopups () {
if (popups == null) return false;
boolean result = false;
while (popups != null) {
Menu menu = popups [0];
if (menu == null) break;
int length = popups.length;
System.arraycopy (popups, 1, popups, 0, --length);
popups [length] = null;
runDeferredEvents ();
if (!menu.isDisposed()) menu._setVisible (true);
result = true;
}
popups = null;
return result;
}
void runSettings () {
Font oldFont = getSystemFont ();
saveResources ();
// updateImages ();
sendEvent (SWT.Settings, null);
Font newFont = getSystemFont ();
boolean sameFont = oldFont.equals (newFont);
Shell [] shells = getShells ();
for (int i=0; i<shells.length; i++) {
Shell shell = shells [i];
if (!shell.isDisposed ()) {
if (!sameFont) {
shell.updateFont (oldFont, newFont);
}
/* This code is intentionally commented */
//shell.redraw (true);
shell.layout (true, true);
}
}
}
boolean runSkin () {
if (skinCount > 0) {
Widget [] oldSkinWidgets = skinList;
int count = skinCount;
skinList = new Widget[GROW_SIZE];
skinCount = 0;
if (eventTable != null && eventTable.hooks(SWT.Skin)) {
for (int i = 0; i < count; i++) {
Widget widget = oldSkinWidgets[i];
if (widget != null && !widget.isDisposed()) {
widget.state &= ~Widget.SKIN_NEEDED;
oldSkinWidgets[i] = null;
Event event = new Event ();
event.widget = widget;
sendEvent (SWT.Skin, event);
}
}
}
return true;
}
return false;
}
void saveResources () {
// int resourceCount = 0;
// if (resources == null) {
// resources = new Resource [RESOURCE_SIZE];
// } else {
// resourceCount = resources.length;
// Resource [] newResources = new Resource [resourceCount + RESOURCE_SIZE];
// System.arraycopy (resources, 0, newResources, 0, resourceCount);
// resources = newResources;
// }
// if (systemFont != null) {
// if (!OS.IsWinCE) {
// NONCLIENTMETRICS info = OS.IsUnicode ? (NONCLIENTMETRICS) new NONCLIENTMETRICSW () : new NONCLIENTMETRICSA ();
// info.cbSize = NONCLIENTMETRICS.sizeof;
// if (OS.SystemParametersInfo (OS.SPI_GETNONCLIENTMETRICS, 0, info, 0)) {
// LOGFONT logFont = OS.IsUnicode ? (LOGFONT) ((NONCLIENTMETRICSW)info).lfMessageFont : ((NONCLIENTMETRICSA)info).lfMessageFont;
// if (lfSystemFont == null ||
// logFont.lfCharSet != lfSystemFont.lfCharSet ||
// logFont.lfHeight != lfSystemFont.lfHeight ||
// logFont.lfWidth != lfSystemFont.lfWidth ||
// logFont.lfEscapement != lfSystemFont.lfEscapement ||
// logFont.lfOrientation != lfSystemFont.lfOrientation ||
// logFont.lfWeight != lfSystemFont.lfWeight ||
// logFont.lfItalic != lfSystemFont.lfItalic ||
// logFont.lfUnderline != lfSystemFont.lfUnderline ||
// logFont.lfStrikeOut != lfSystemFont.lfStrikeOut ||
// logFont.lfCharSet != lfSystemFont.lfCharSet ||
// logFont.lfOutPrecision != lfSystemFont.lfOutPrecision ||
// logFont.lfClipPrecision != lfSystemFont.lfClipPrecision ||
// logFont.lfQuality != lfSystemFont.lfQuality ||
// logFont.lfPitchAndFamily != lfSystemFont.lfPitchAndFamily ||
// !getFontName (logFont).equals (getFontName (lfSystemFont))) {
// resources [resourceCount++] = systemFont;
// lfSystemFont = logFont;
// systemFont = null;
// }
// }
// }
// }
// if (errorImage != null) resources [resourceCount++] = errorImage;
// if (infoImage != null) resources [resourceCount++] = infoImage;
// if (questionImage != null) resources [resourceCount++] = questionImage;
// if (warningIcon != null) resources [resourceCount++] = warningIcon;
// errorImage = infoImage = questionImage = warningIcon = null;
// for (int i=0; i<cursors.length; i++) {
// if (cursors [i] != null) resources [resourceCount++] = cursors [i];
// cursors [i] = null;
// }
// if (resourceCount < RESOURCE_SIZE) {
// Resource [] newResources = new Resource [resourceCount];
// System.arraycopy (resources, 0, newResources, 0, resourceCount);
// resources = newResources;
// }
}
void sendEvent (int eventType, Event event) {
if (eventTable == null && filterTable == null) {
return;
}
if (event == null) event = new Event ();
event.display = this;
event.type = eventType;
if (event.time == 0) event.time = getLastEventTime ();
if (!filterEvent (event)) {
if (eventTable != null) eventTable.sendEvent (event);
}
}
/**
* Sets the location of the on-screen pointer relative to the top left corner
* of the screen. <b>Note: It is typically considered bad practice for a
* program to move the on-screen pointer location.</b>
*
* @param x the new x coordinate for the cursor
* @param y the new y coordinate for the cursor
*
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @since 2.1
*/
public void setCursorLocation (int x, int y) {
checkDevice ();
Win32.SetCursorPos (x, y);
}
/**
* Sets the location of the on-screen pointer relative to the top left corner
* of the screen. <b>Note: It is typically considered bad practice for a
* program to move the on-screen pointer location.</b>
*
* @param point new position
*
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_NULL_ARGUMENT - if the point is null
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @since 2.0
*/
public void setCursorLocation (Point point) {
checkDevice ();
if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
setCursorLocation (point.x, point.y);
}
/**
* Sets the application defined property of the receiver
* with the specified name to the given argument.
* <p>
* Applications may have associated arbitrary objects with the
* receiver in this fashion. If the objects stored in the
* properties need to be notified when the display is disposed
* of, it is the application's responsibility provide a
* <code>disposeExec()</code> handler which does so.
* </p>
*
* @param key the name of the property
* @param value the new value for the property
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the key is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @see #getData(String)
* @see #disposeExec(Runnable)
*/
public void setData (String key, Object value) {
checkDevice ();
if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
// if (key.equals (RUN_MESSAGES_IN_IDLE_KEY)) {
// Boolean data = (Boolean) value;
// runMessagesInIdle = data != null && data.booleanValue ();
// return;
// }
/* Remove the key/value pair */
if (value == null) {
if (keys == null) return;
int index = 0;
while (index < keys.length && !keys [index].equals (key)) index++;
if (index == keys.length) return;
if (keys.length == 1) {
keys = null;
values = null;
} else {
String [] newKeys = new String [keys.length - 1];
Object [] newValues = new Object [values.length - 1];
System.arraycopy (keys, 0, newKeys, 0, index);
System.arraycopy (keys, index + 1, newKeys, index, newKeys.length - index);
System.arraycopy (values, 0, newValues, 0, index);
System.arraycopy (values, index + 1, newValues, index, newValues.length - index);
keys = newKeys;
values = newValues;
}
return;
}
/* Add the key/value pair */
if (keys == null) {
keys = new String [] {key};
values = new Object [] {value};
return;
}
for (int i=0; i<keys.length; i++) {
if (keys [i].equals (key)) {
values [i] = value;
return;
}
}
String [] newKeys = new String [keys.length + 1];
Object [] newValues = new Object [values.length + 1];
System.arraycopy (keys, 0, newKeys, 0, keys.length);
System.arraycopy (values, 0, newValues, 0, values.length);
newKeys [keys.length] = key;
newValues [values.length] = value;
keys = newKeys;
values = newValues;
}
/**
* Sets the application defined, display specific data
* associated with the receiver, to the argument.
* The <em>display specific data</em> is a single,
* unnamed field that is stored with every display.
* <p>
* Applications may put arbitrary objects in this field. If
* the object stored in the display specific data needs to
* be notified when the display is disposed of, it is the
* application's responsibility provide a
* <code>disposeExec()</code> handler which does so.
* </p>
*
* @param data the new display specific data
*
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @see #getData()
* @see #disposeExec(Runnable)
*/
public void setData (Object data) {
checkDevice ();
this.data = data;
}
/**
* Sets the application name to the argument.
* <p>
* The application name can be used in several ways,
* depending on the platform and tools being used.
* On Motif, for example, this can be used to set
* the name used for resource lookup. Accessibility
* tools may also ask for the application name.
* </p><p>
* Specifying <code>null</code> for the name clears it.
* </p>
*
* @param name the new app name or <code>null</code>
*/
public static void setAppName (String name) {
/* Do nothing */
}
//void setModalDialogShell (Shell modalDailog) {
// if (modalDialogShell != null && modalDialogShell.isDisposed ()) modalDialogShell = null;
// this.modalDialogShell = modalDailog;
// Shell [] shells = getShells ();
// for (int i=0; i<shells.length; i++) shells [i].updateModal ();
//}
void setIdleHandler () {
idle = true;
}
void setModalShell (Shell shell) {
if (modalShells == null) modalShells = new Shell [4];
int index = 0, length = modalShells.length;
while (index < length) {
if (modalShells [index] == shell) return;
if (modalShells [index] == null) break;
index++;
}
if (index == length) {
Shell [] newModalShells = new Shell [length + 4];
System.arraycopy (modalShells, 0, newModalShells, 0, length);
modalShells = newModalShells;
}
modalShells [index] = shell;
Shell [] shells = getShells ();
for (int i=0; i<shells.length; i++) shells [i].updateModal ();
}
/**
* Sets the synchronizer used by the display to be
* the argument, which can not be null.
*
* @param synchronizer the new synchronizer for the display (must not be null)
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the synchronizer is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_FAILED_EXEC - if an exception occurred while running an inter-thread message</li>
* </ul>
*/
public void setSynchronizer (Synchronizer synchronizer) {
checkDevice ();
if (synchronizer == null) error (SWT.ERROR_NULL_ARGUMENT);
if (synchronizer == this.synchronizer) return;
Synchronizer oldSynchronizer;
synchronized (Device.class) {
oldSynchronizer = this.synchronizer;
this.synchronizer = synchronizer;
}
if (oldSynchronizer != null) {
oldSynchronizer.runAsyncMessages(true);
}
}
/**
* Causes the user-interface thread to <em>sleep</em> (that is,
* to be put in a state where it does not consume CPU cycles)
* until an event is received or it is otherwise awakened.
*
* @return <code>true</code> if an event requiring dispatching was placed on the queue.
*
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @see #wake
*/
public boolean sleep () {
checkDevice ();
int handler = OS.gcnew_NoArgsDelegate (jniRef, "sleep_noop");
sleepOperation = OS.Dispatcher_BeginInvoke(dispatcher, OS.DispatcherPriority_Inactive, handler);
OS.DispatcherOperation_Wait(sleepOperation);
OS.GCHandle_Free(handler);
OS.GCHandle_Free(sleepOperation);
sleepOperation = 0;
return true;
}
void sleep_noop() {
}
/**
* Causes the <code>run()</code> method of the runnable to
* be invoked by the user-interface thread at the next
* reasonable opportunity. The thread which calls this method
* is suspended until the runnable completes. Specifying <code>null</code>
* as the runnable simply wakes the user-interface thread.
* <p>
* Note that at the time the runnable is invoked, widgets
* that have the receiver as their display may have been
* disposed. Therefore, it is necessary to check for this
* case inside the runnable before accessing the widget.
* </p>
*
* @param runnable code to run on the user-interface thread or <code>null</code>
*
* @exception SWTException <ul>
* <li>ERROR_FAILED_EXEC - if an exception occurred when executing the runnable</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @see #asyncExec
*/
public void syncExec (Runnable runnable) {
Synchronizer synchronizer;
synchronized (Device.class) {
if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
synchronizer = this.synchronizer;
}
synchronizer.syncExec (runnable);
}
/**
* Causes the <code>run()</code> method of the runnable to
* be invoked by the user-interface thread after the specified
* number of milliseconds have elapsed. If milliseconds is less
* than zero, the runnable is not executed.
* <p>
* Note that at the time the runnable is invoked, widgets
* that have the receiver as their display may have been
* disposed. Therefore, it is necessary to check for this
* case inside the runnable before accessing the widget.
* </p>
*
* @param milliseconds the delay before running the runnable
* @param runnable code to run on the user-interface thread
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the runnable is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @see #asyncExec
*/
public void timerExec (int milliseconds, Runnable runnable) {
checkDevice ();
if (runnable == null) error (SWT.ERROR_NULL_ARGUMENT);
if (timerList == null) timerList = new Runnable [4];
if (timerHandles == null) timerHandles = new int [4];
int index = 0;
while (index < timerList.length) {
if (timerList [index] == runnable) break;
index++;
}
int timer = 0;
if (index != timerList.length) {
timer = timerHandles [index];
if (milliseconds < 0) {
OS.DispatcherTimer_Stop (timer);
timerList [index] = null;
OS.GCHandle_Free (timer);
timerHandles [index] = 0;
return;
}
} else {
if (milliseconds < 0) return;
index = 0;
while (index < timerList.length) {
if (timerList [index] == null) break;
index++;
}
if (index == timerList.length) {
Runnable [] newTimerList = new Runnable [timerList.length + 4];
System.arraycopy (timerList, 0, newTimerList, 0, timerList.length);
timerList = newTimerList;
int [] newTimerHandles = new int [timerHandles.length + 4];
System.arraycopy (timerHandles, 0, newTimerHandles, 0, timerHandles.length);
timerHandles = newTimerHandles;
}
}
if (timer == 0) timer = OS.gcnew_DispatcherTimer();
if (timer != 0) {
OS.DispatcherTimer_Tag (timer, index);
int timeSpan = OS.TimeSpan_FromMilliseconds (milliseconds);
OS.DispatcherTimer_Interval(timer, timeSpan);
OS.DispatcherTimer_Tick (timer, timerHandler);
OS.DispatcherTimer_Start (timer);
timerList [index] = runnable;
timerHandles [index] = timer;
OS.GCHandle_Free (timeSpan);
}
}
void timerProc (int index, int e) {
if (0 <= index && index < timerHandles.length) {
int timer = timerHandles [index];
if (timer != 0) {
OS.DispatcherTimer_Stop (timer);
OS.GCHandle_Free (timer);
timerHandles [index] = 0;
Runnable runnable = timerList [index];
timerList [index] = null;
runnable.run ();
}
}
}
static int translateKey (int key) {
for (int i=0; i<KeyTable.length; i++) {
if (KeyTable [i] [0] == key) return KeyTable [i] [1];
}
return 0;
}
static int untranslateKey (int key) {
for (int i=0; i<KeyTable.length; i++) {
if (KeyTable [i] [1] == key) return KeyTable [i] [0];
}
return 0;
}
/**
* Forces all outstanding paint requests for the display
* to be processed before this method returns.
*
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @see Control#update()
*/
public void update() {
checkDevice ();
Shell[] shells = getShells ();
for (int i=0; i<shells.length; i++) {
Shell shell = shells [i];
if (!shell.isDisposed ()) shell.update (true);
}
}
/**
* If the receiver's user-interface thread was <code>sleep</code>ing,
* causes it to be awakened and start running again. Note that this
* method may be called from any thread.
*
* @exception SWTException <ul>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @see #sleep
*/
public void wake () {
synchronized (Device.class) {
if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
if (thread == Thread.currentThread ()) return;
wakeThread ();
}
}
void wakeThreadHandler () {
}
void wakeThread () {
int handler = OS.gcnew_NoArgsDelegate (jniRef, "wakeThreadHandler");
int operation = OS.Dispatcher_BeginInvoke (dispatcher, OS.DispatcherPriority_Normal, handler);
OS.GCHandle_Free (operation);
OS.GCHandle_Free (handler);
}
}
|