wxErlang

wxDC.erl

   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
%        |¯\  /¯               
%\   W X |_/  \_, . E R L 
%%——————————————————————————————————————————————————————————
%%
%%   Copyright Ericsson AB 2008-2013. All Rights Reserved.
%%
%%——————————————————————————————————————————————
%% Whitespace Beautified by ScriptCulture © 2018
%% Sit Back · Feet Up · Learn wxErlang
%% For use as a reference only
%% www.scriptculture.com
%% Not check-summed 
%% wx 1.8 —————————————————————————————————————— 
%%
%% Licensed under the Apache License, 
%% Version 2.0 (the "License"); you may 
%% not use this file except in compliance 
%% with the License. You may obtain a copy 
%% of the License at:
%%
%%     http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by 
%% applicable law or agreed to in writing, software
%% distributed under the License is distributed 
%% on an "AS IS" BASIS, WITHOUT WARRANTIES 
%% OR CONDITIONS OF ANY KIND, either 
%% express or implied. See the 
%% License for the specific 
%% language governing 
%% permissions and
%% limitations 
%% under the 
%% License.
%%%%%%%
%%%%
%%%%%
%% @doc See external documentation: <a href="http://www.wxwidgets.org/manuals/2.8.12/wx_wxdc.html">wxDC</a>.
%% @type wxDC().  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%%   OVERVIEW
%%   ————————
%%   A wxDC is a device context onto which graphics and text 
%%   can be drawn. It is intended to represent a number of output 
%%   devices in a generic way, so a window can have a device 
%%   context associated with it, and a printer also has a device context. 
%%   In this way, the same piece of code may write to a number 
%%   of different devices, if the device context is used as a parameter.
%%   
%%   Notice that wxDC is an abstract base class and can't be created directly, 
%%   please use    wxPaintDC,        wxClientDC,        wxWindowDC, 
%%                wxScreenDC,        wxMemoryDC   or   wxPrinterDC.
%%   
%%   Please note that in addition to the versions of the methods documented here, 
%%   there are also versions which accept single wxPoint parameter instead of 
%%   two wxCoord ones or wxPoint and wxSize instead of four of them.
%%   
%%   SUPPORT FOR TRANSPARENCY / ALPHA CHANNEL
%%   ————————————————————————————————————————
%%   On Mac OS X when using Core Graphics (wx_MAC_USE_CORE_GRAPHICS set to 1) 
%%   colors with alpha are supported, so instances wxPen or wxBrush that 
%%   are built from wxColour use the color's alpha values when stroking or filling.
%%
%%
%%
-module(wxDC).
-include("wxe.hrl").
-export([
                blit / 5 ,                   % Block Information Transfer
                blit / 6 ,                   %

                calcBoundingBox / 3 ,        % Adds a point?
                clear / 1 ,                  % Paints background the background color. 
                computeScaleAndOrigin / 1 ,  % internal use. 
                crossHair / 2 ,              % Draws a + at a point. 

                destroyClippingRegion / 1 ,

                deviceToLogicalX / 2 ,       % used 
                deviceToLogicalXRel / 2 ,    % for
                deviceToLogicalY / 2 ,       % scaling
                deviceToLogicalYRel / 2 ,    % 

                drawArc / 4 ,          %      
                drawBitmap / 3 ,       % 
                drawBitmap / 4 ,       % 
                drawCheckMark / 2 ,
                drawCircle / 3 ,       %
                drawEllipse / 2 ,
                drawEllipse / 3 ,
                drawEllipticArc / 5 ,
                drawIcon / 3 ,
                drawLabel / 3 ,
                drawLabel / 4 ,
                drawLine / 3 ,         %
                drawLines / 2 ,
                drawLines / 3 ,
                drawPoint / 2 ,
                drawPolygon / 2 ,      %
                drawPolygon / 3 ,
                drawRectangle / 2 ,
                drawRectangle / 3 ,
                drawRotatedText / 4 ,  %
                drawRoundedRectangle / 3 ,
                drawRoundedRectangle / 4 ,
                drawText / 3 ,

                endDoc / 1 ,                  % for printer
                endPage / 1 ,                 % use only
                floodFill / 3 ,               % flood fills...
                floodFill / 4 ,               % not implemented on OSX

                getBackground / 1 ,           % get background brush
                getBackgroundMode / 1 ,       % sets the bg to transparent/solid, for behind text, ¿ and clear?

                getBrush / 1 ,
                getCharHeight / 1 ,
                getCharWidth / 1 ,
                getClippingBox / 1 ,   
                getFont / 1 ,
                getLayoutDirection / 1 ,
                getLogicalFunction / 1 ,
                getMapMode / 1 ,
                getMultiLineTextExtent / 2 ,
                getMultiLineTextExtent / 3 ,
                getPPI / 1 ,
                getPartialTextExtents / 2 ,
                getPen / 1 ,
                getPixel / 2 ,     %
                getSize / 1 ,
                getSizeMM / 1 ,
                getTextBackground / 1 ,
                getTextExtent / 2 ,           %
                getTextExtent / 3 ,           %
                getTextForeground / 1 ,
                getUserScale / 1 ,
                gradientFillConcentric / 4 ,  %
                gradientFillConcentric / 5 ,  %
                gradientFillLinear / 4 ,      %
                gradientFillLinear / 5 ,      %

                isOk / 1 ,

                logicalToDeviceX / 2 ,
                logicalToDeviceXRel / 2 ,
                logicalToDeviceY / 2 ,
                logicalToDeviceYRel / 2 ,

                maxX / 1 ,
                maxY / 1 ,
                minX / 1 ,
                minY / 1 ,

                resetBoundingBox / 1 ,

                setAxisOrientation / 3 ,   % you can mess with which corner the x,y coords originate from.
                setBackground / 2 , 
                setBackgroundMode / 2 ,
                setBrush / 2 ,             %
                setClippingRegion / 2 ,    %
                setClippingRegion / 3 ,    %
                setDeviceOrigin / 3 ,
                setFont / 2 ,              %
                setLayoutDirection / 2 ,
                setLogicalFunction / 2 ,
                setMapMode / 2 ,
                setPalette / 2 ,
                setPen / 2 ,
                setTextBackground / 2 ,    %
                setTextForeground / 2 ,    %
                setUserScale / 3 ,         %  FOR ZOOMINGS
                startDoc / 2 ,
                startPage / 1
              ]).


%% inherited exports
-export([parent_class/1]).

-export_type([wxDC/0]).
-deprecated([computeScaleAndOrigin/1]).


%% @hidden
parent_class(_Class) -> erlang:error({badtype, ?MODULE}).




-type wxDC()  ::  wx:wx_object().






          %·%% BLIT %%·%

%%   Copy from a source DC to this DC.
%% 
%%   With this method you can specify the destination coordinates and the size 
%%   of area to copy which will be the same for both the source and target DCs.
%%   If you need to apply scaling while copying, use StretchBlit().
%% 
%%   Notice that source DC coordinates xsrc and ysrc are interpreted using the 
%%   current source DC coordinate system,
%%        i.e. the scale, origin position and axis directions are taken into account
%%                        when transforming them to physical (pixel) coordinates.
%% 
%%
%% Parameters
%%           xdest  Destination device context x position.
%%           ydest  Destination device context y position.
%%           width  Width of source area to be copied.
%%          height  Height of source area to be copied.
%%          source  Source device context.
%%            xsrc  Source device context x position.
%%            ysrc  Source device context y position.
%%     logicalFunc  Logical function to use, see SetLogicalFunction().
%%         useMask  If true, Blit does a transparent blit using the mask that is associated
%%                  with the bitmap selected into the source device context. 
%%                  
%%                  The Windows implementation does the following if MaskBlt cannot be used: 
%%                      Creates a temporary bitmap and copies the destination area into it.
%%                      Copies the source area into the temporary bitmap using the specified
%%                      logical function.
%%                      Sets the masked area in the temporary bitmap to BLACK by ANDing 
%%                      the mask bitmap with the temp bitmap 
%%                      with the foreground colour set to WHITE and the bg colour set to BLACK.
%%
%%                      Sets the unmasked area in the destination area to BLACK by ANDing 
%%                      the mask bitmap with the destination area with the 
%%                      foreground colour set to BLACK and the background colour set to WHITE.
%%                      ORs the temporary bitmap with the destination area.
%%                      Deletes the temporary bitmap.
%% 
%%     This sequence of operations ensures that the source's transparent area need not be black,
%%     and logical functions are supported.
%%
%%     Note: on Windows, blitting with masks can be speeded up considerably by 
%%           compiling wxWidgets with the wxUSE_DC_CACHEING option enabled. 
%%           You can also influence whether MaskBlt or the explicit mask blitting 
%%           code above is used, by using wxSystemOptions and setting the no-maskblt
%%           option to 1.
%%                           xsrcMask  Source x position on the mask. 
%%                                     If both xsrcMask and ysrcMask are -1, xsrc and ysrc will 
%%                                     be assumed for the mask source position. 
%%                                     Currently only implemented on Windows.
%%                           ysrcMask  Source y position on the mask. 
%%                                     If both xsrcMask and ysrcMask are -1, xsrc and ysrc will 
%%                                     be assumed for the mask source position.
%%                                     Currently only implemented on Windows.
%% 
%%           Remarks
%%               There is partial support for Blit() in wxPostScriptDC, under X.
%%
%%              See also
%%                  StretchBlit(), wxMemoryDC, wxBitmap, wxMask 
%%
%%
%% @equiv blit(This,DestPt,Sz,Source,SrcPt, [])
          -spec blit(This, DestPt, Sz, Source, SrcPt) -> boolean()
           when
           This   ::          wxDC(), 
           DestPt :: {X :: integer(), 
                      Y :: integer()}, 
           Sz     :: {W :: integer(), 
                      H :: integer()}, 
           Source ::          wxDC(), 
           SrcPt  :: {X :: integer(), 
                      Y :: integer()}.

blit(This, DestPt={DestPtX, DestPtY}, Sz={SzW, SzH}, Source, SrcPt={SrcPtX, SrcPtY})
           when 
           is_record(This, wx_ref),
           is_integer(DestPtX),
           is_integer(DestPtY),
           is_integer(SzW),
           is_integer(SzH),
           is_record(Source, wx_ref),
           is_integer(SrcPtX),
           is_integer(SrcPtY) -> blit(This,DestPt,Sz,Source,SrcPt, []).



          -spec blit(This, DestPt, Sz, Source, SrcPt, [Option]) -> boolean()
           when
           This   ::          wxDC(), 
           DestPt :: {X :: integer(),
                      Y :: integer()}, 
           Sz     :: {W :: integer(), 
                      H :: integer()}, 
           Source ::          wxDC(), 
           SrcPt  :: {X :: integer(), 
                      Y :: integer()},
           Option :: {rop,                          wx:wx_enum()}   %%<br /> Rop = integer
                   | {useMask,                         boolean()}
                   | {srcPtMask, {X :: integer(), Y :: integer()}}.

blit(#wx_ref{type=ThisT,ref=ThisRef},
                  {DestPtX, DestPtY},
                          {SzW, SzH},
 #wx_ref{type=SourceT,ref=SourceRef},
                    {SrcPtX, SrcPtY},
                            Options)
           when 
           is_integer(DestPtX),
           is_integer(DestPtY),
           is_integer(SzW),
           is_integer(SzH),
           is_integer(SrcPtX),
           is_integer(SrcPtY),
           is_list(   Options) ->
                             ?CLASS(ThisT,   wxDC),
                             ?CLASS(SourceT, wxDC),
                       MOpts = fun({rop, Rop},                           Acc) -> [<<1:32/?UI,Rop:32/?UI>>|Acc];
                                  ({useMask,       UseMask},             Acc) -> [<<2:32/?UI,(wxe_util:from_bool(UseMask)):32/?UI>>|Acc];
                                  ({srcPtMask, {SrcPtMaskX,SrcPtMaskY}}, Acc) -> [<<3:32/?UI,SrcPtMaskX:32/?UI,SrcPtMaskY:32/?UI,0:32>>|Acc];
                                                                  (BadOpt, _) -> erlang:error({badoption, BadOpt})
            end,
                      BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)),
               wxe_util:call(?wxDC_Blit,
               <<ThisRef:32/?UI,DestPtX:32/?UI,DestPtY:32/?UI,SzW:32/?UI,SzH:32/?UI,SourceRef:32/?UI,SrcPtX:32/?UI,SrcPtY:32/?UI, BinOpt/binary>>).






           %·%% CALC BOUNDING BOX %%·%    
%%
%%   Adds the specified point to the bounding box 
%%   which can be retrieved with
%%   MinX(), MaxX() and MinY(), MaxY() functions.
%%
%%See also:
%%ResetBoundingBox() ——

          -spec calcBoundingBox(This, X, Y) -> ok
           when
           This ::    wxDC(),
           X    :: integer(),
           Y    :: integer().

calcBoundingBox(#wx_ref{type=ThisT,ref=ThisRef},X,Y)
           when 
           is_integer(X),
           is_integer(Y)    ->
                             ?CLASS(ThisT,wxDC),
               wxe_util:cast(?wxDC_CalcBoundingBox,
               <<ThisRef:32/?UI,X:32/?UI,Y:32/?UI>>).





          %·%% CLEAR %%·%

%%  Clears the device context using the current background brush.

          -spec clear(This) -> ok
           when
           This :: wxDC().

clear(#wx_ref{type=ThisT,ref=ThisRef}) ->
                                        ?CLASS(ThisT,wxDC),
                          wxe_util:cast(?wxDC_Clear,
                          <<ThisRef:32/?UI>>).






          %·%% COMPUTE SCALE AND ORIGIN %%·%
          
%%  Performs all necessary computations for given platform
%%   and context type after each change of scale and origin parameters. 
%%
%%  Usually called automatically internally after such changes.

          -spec computeScaleAndOrigin(This) -> ok
           when
           This :: wxDC().

computeScaleAndOrigin(#wx_ref{type=ThisT,ref=ThisRef}) ->
                                                        ?CLASS(ThisT,wxDC),
                                          wxe_util:cast(?wxDC_ComputeScaleAndOrigin,
                                          <<ThisRef:32/?UI>>).






           %·%% CROSS HAIR %%·%

%%  Displays a cross hair using the current pen.
%%  This is a vertical and horizontal line 
%%   the height and width of the window, 
%%     centred on the given point.

          -spec crossHair(This, Pt) -> ok
           when
           This :: wxDC(),
           Pt :: {X :: integer(), 
                  Y :: integer()}.

crossHair(#wx_ref{type=ThisT,ref=ThisRef}, {PtX,PtY} )
           when 
           is_integer(PtX),
           is_integer(PtY)  ->
                             ?CLASS(ThisT,wxDC),
               wxe_util:cast(?wxDC_CrossHair,
               <<ThisRef:32/?UI,PtX:32/?UI,PtY:32/?UI>>).





           %·%% DESTROY CLIPPING REGION %%·%
          
%% Destroys the current clipping region so that none of the DC is clipped.
%%
%% See also
%%    SetClippingRegion() 


          -spec destroyClippingRegion(This) -> ok
           when
           This :: wxDC().

destroyClippingRegion(#wx_ref{type=ThisT,ref=ThisRef}) ->
                                                        ?CLASS(ThisT,wxDC),
                                          wxe_util:cast(?wxDC_DestroyClippingRegion,
                                          <<ThisRef:32/?UI>>).





           %·%% DEVICE TO LOGICAL X %%·%
          
%%  Convert device X coordinate to logical coordinate, using the current mapping mode, 
%%  user scale factor, device origin and axis orientation. 

          -spec deviceToLogicalX(This, X) -> integer()
           when
           This ::    wxDC(),
           X    :: integer().

deviceToLogicalX(#wx_ref{type=ThisT,ref=ThisRef}, X)
           when 
           is_integer(X) ->
                          ?CLASS(ThisT,wxDC),
            wxe_util:call(?wxDC_DeviceToLogicalX,
            <<ThisRef:32/?UI,X:32/?UI>>).





           %·%% DEVICE TO LOGICAL X REL %%·%
          
%%  Convert device X coordinate to relative logical coordinate, 
%%  using the current mapping mode and user scale factor but ignoring the axis orientation.
%%
%%  Use this for converting a width, for example.


          -spec deviceToLogicalXRel(This, X) -> integer()
           when
           This ::    wxDC(), 
           X    :: integer().

deviceToLogicalXRel(#wx_ref{type=ThisT,ref=ThisRef}, X )
           when 
           is_integer(X) ->
                          ?CLASS(ThisT,wxDC),
            wxe_util:call(?wxDC_DeviceToLogicalXRel,
            <<ThisRef:32/?UI,X:32/?UI>>).





           %·%% DEVICE TO LOGICAL Y %%·%
          
%%  Converts device Y coordinate to logical coordinate, using the current mapping mode, user scale factor, device origin and axis orientation.

          -spec deviceToLogicalY(This, Y) -> integer()
           when
           This ::    wxDC(),
           Y    :: integer().

deviceToLogicalY(#wx_ref{type=ThisT,ref=ThisRef}, Y )
           when 
           is_integer(Y) ->
                          ?CLASS(ThisT,wxDC),
            wxe_util:call(?wxDC_DeviceToLogicalY,
            <<ThisRef:32/?UI,Y:32/?UI>>).





           %·%% DEVICE TO LOGICAL Y REL %%·%
          
%%  Convert device Y coordinate to relative logical coordinate, using the current mapping mode and user scale factor but 
%%  ignoring the axis orientation. Use this for converting a height, for example.



          -spec deviceToLogicalYRel(This, Y) -> integer()
           when
           This ::    wxDC(),
           Y    :: integer().

deviceToLogicalYRel(#wx_ref{type=ThisT,ref=ThisRef}, Y)
           when 
           is_integer(Y) ->
                          ?CLASS(ThisT,wxDC),
            wxe_util:call(?wxDC_DeviceToLogicalYRel,
            <<ThisRef:32/?UI,Y:32/?UI>>).





           %·%% DRAW ARC %%·%
          
%%  Draws an arc from the given start to the given end point.
%%  Note DrawEllipticArc() has more clear semantics and it is recommended to use it instead of this function.
%%  The arc drawn is an arc of the circle centered at (xc, yc). Its start point is (xStart, yStart) whereas its end 
%%  point is the point of intersection of the line passing by (xc, yc) and (xEnd, yEnd) with the circle passing by (xStart, yStart).
%%  The arc is drawn in a counter-clockwise direction between the start and the end points.
%%  The current pen is used for the outline and the current brush for filling the shape. Notice that unless the brush is transparent, 
%%  the lines connecting the centre of the circle to the end points of the arc are drawn as well.

%%  This rendition of the actual function is this. This is an overloaded member function, provided for convenience. 
%%  It differs from the above function only in what argument(s) it accepts.
%% 

          -spec drawArc(This, Pt1, Pt2, Centre) -> ok
           when
           This   ::                          wxDC(),
           Pt1    :: {X :: integer(), Y :: integer()},
           Pt2    :: {X :: integer(), Y :: integer()},
           Centre :: {X :: integer(), Y :: integer()}.

drawArc(#wx_ref{type=ThisT,ref=ThisRef}, {Pt1X, Pt1Y} , {Pt2X, Pt2Y}, {CentreX, CentreY} )
           when 
           is_integer(Pt1X),
           is_integer(Pt1Y),
           is_integer(Pt2X),
           is_integer(Pt2Y),
           is_integer(CentreX),
           is_integer(CentreY) ->
                                ?CLASS(ThisT,wxDC),
                  wxe_util:cast(?wxDC_DrawArc,
                  <<ThisRef:32/?UI,Pt1X:32/?UI,Pt1Y:32/?UI,Pt2X:32/?UI,
                       Pt2Y:32/?UI,CentreX:32/?UI,CentreY:32/?UI>>).




           %·%% DRAW BITMAP %%·%
          
%%  Draw a bitmap on the device context at the specified point.
%%  If transparent is true and the bitmap has a transparency mask, 
%%  the bitmap will be drawn transparently.
%%  When drawing a mono-bitmap, 
%%  the current text foreground colour will 
%%  be used to draw the foreground of the bitmap 
%%  (all bits set to 1), and the current text 
%%  background colour to draw the background 
%%  (all bits set to 0).
%%
%%  See also
%%      SetTextForeground(), SetTextBackground(), wxMemoryDC 
%%
%% @equiv drawBitmap(This,Bmp,Pt, [])

          -spec drawBitmap(This, Bmp, Pt) -> ok
           when
           This ::              wxDC(),
           Bmp  :: wxBitmap:wxBitmap(),
           Pt   :: {  X  ::  integer(),
                      Y  ::  integer()}.

drawBitmap(This,Bmp,Pt={PtX, PtY})
           when 
           is_record(This, wx_ref),
           is_record(Bmp, wx_ref),
           is_integer(PtX),
           is_integer(PtY)                 -> drawBitmap(This, Bmp, Pt, []).

          
%%  This is an overloaded member function, provided for convenience. 
%%  It differs from the above function only in what argument(s) it accepts
%%
          -spec drawBitmap(This, Bmp, Pt, [Option]) -> ok
           when 
           This    ::               wxDC(), 
           Bmp     ::  wxBitmap:wxBitmap(),
           Pt      ::      {X :: integer(), 
                            Y :: integer()},
           Option  ::  {useMask, boolean()}.

drawBitmap(#wx_ref{type=ThisT,ref=ThisRef},
           #wx_ref{type=BmpT, ref=BmpRef},
                               {PtX, PtY},
                                 Options)
           when 
           is_integer(PtX),
           is_integer(PtY),
           is_list(Options) ->
                             ?CLASS(ThisT,wxDC),
                             ?CLASS(BmpT,wxBitmap),
                   MOpts = fun({useMask, UseMask}, Acc) -> [<<1:32/?UI,(wxe_util:from_bool(UseMask)):32/?UI>>|Acc];
                                            (BadOpt, _) -> erlang:error({badoption, BadOpt})
                           end,
                   BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)),
                                        wxe_util:cast(?wxDC_DrawBitmap,
                                        <<ThisRef:32/?UI,BmpRef:32/?UI,
                                              PtX:32/?UI,   PtY:32/?UI, BinOpt/binary>>).





           %·%% DRAW CHECK MARK %%·%
          
%%  Draws a check mark inside the given rectangle. 

          -spec drawCheckMark(This, Rect) -> ok
           when
           This :: wxDC(), 
           Rect :: {X :: integer(), 
                    Y :: integer(), 
                    W :: integer(), 
                    H :: integer()}.

drawCheckMark(#wx_ref{type=ThisT,ref=ThisRef}, {RectX, RectY, RectW, RectH})
           when 
           is_integer(RectX),
           is_integer(RectY),
           is_integer(RectW),
           is_integer(RectH) ->
                              ?CLASS(ThisT,wxDC),
                wxe_util:cast(?wxDC_DrawCheckMark,
                <<ThisRef:32/?UI,RectX:32/?UI,RectY:32/?UI,RectW:32/?UI,RectH:32/?UI>>).





           %·%% DRAW CIRCLE %%·%
          
%%  Draws a circle with the given centre and radius.
%%  See also: DrawEllipse() 

          -spec drawCircle(This, Pt, Radius) -> ok
           when
           This   ::          wxDC(),
           Pt     :: {X :: integer(),
                      Y :: integer()},
           Radius ::       integer().

drawCircle(#wx_ref{type=ThisT,ref=ThisRef}, {PtX, PtY}, Radius)
           when 
           is_integer(PtX),
           is_integer(PtY),
           is_integer(Radius) ->
                               ?CLASS(ThisT,wxDC),
                 wxe_util:cast(?wxDC_DrawCircle,
                 <<ThisRef:32/?UI,PtX:32/?UI,PtY:32/?UI,Radius:32/?UI>>).





           %·%% DRAW ELLIPSE %%·%
          
%%  Draws an ellipse contained in the rectangle specified either with the given top left corner and the given size or directly.
%%  The current pen is used for the outline and the current brush for filling the shape

          -spec drawEllipse(This, Rect) -> ok
           when
           This :: wxDC(), 
           Rect :: {X :: integer(), 
                    Y :: integer(), 
                    W :: integer(), 
                    H :: integer()}.

drawEllipse(#wx_ref{type=ThisT,ref=ThisRef}, {RectX, RectY, RectW, RectH})
           when 
           is_integer(RectX),
           is_integer(RectY),
           is_integer(RectW),
           is_integer(RectH) ->
                              ?CLASS(ThisT,wxDC),
                wxe_util:cast(?wxDC_DrawEllipse_1,
                <<ThisRef:32/?UI,RectX:32/?UI,RectY:32/?UI,RectW:32/?UI,RectH:32/?UI>>).
          
%%  This is an overloaded member function, provided for convenience. 
%%  It differs from the above function only in what argument(s) it accepts.

          -spec drawEllipse(This, Pt, Sz) -> ok
           when
           This ::          wxDC(), 
           Pt   :: {X :: integer(), 
                    Y :: integer()}, 
           Sz   :: {W :: integer(),
                    H :: integer()}.

drawEllipse(#wx_ref{type=ThisT,ref=ThisRef}, {PtX, PtY}, {SzW, SzH})
           when 
           is_integer(PtX),
           is_integer(PtY),
           is_integer(SzW),
           is_integer(SzH) ->
                            ?CLASS(ThisT,wxDC),
              wxe_util:cast(?wxDC_DrawEllipse_2,
              <<ThisRef:32/?UI,PtX:32/?UI,PtY:32/?UI,SzW:32/?UI,SzH:32/?UI>>).





           %·%% DRAW ELLIPTIC ARC %%·%
          
%%  Draws an arc of an ellipse.
%%  The current pen is used for drawing the arc and the 
%%  current brush is used for drawing the pie.
%%  x and y specify the x and y coordinates of 
%%  the upper-left corner of the rectangle that 
%%  contains the ellipse.
%%  ——width and height 
%%  specify the width and height of the 
%%  rectangle that contains the ellipse.
%%  ——start and end 
%%  specify the end points of the arc relative to the 
%%  three-o'clock position from the center of the rectangle. 
%%  Angles are specified in degrees with 0 degree angle 
%%  corresponding to the positive horizontal axis (3 o'clock) direction.
%%  Independently of whether start is greater 
%%  than or less than end, the arc is drawn 
%%  in the counter-clockwise direction. 
%%  Also, if start is equal to end, 
%%  a complete ellipse is drawn.
%%  Notice that unlike DrawArc(), this function does 
%%  not draw the lines to the arc ends, 
%%  even when using non-transparent brush.

          -spec drawEllipticArc(This, Pt, Sz, Sa, Ea) -> ok
           when
           This ::                          wxDC(), 
           Pt   :: {X :: integer(), Y :: integer()}, 
           Sz   :: {W :: integer(), H :: integer()}, 
           Sa   ::                        number(),
           Ea   ::                        number().

drawEllipticArc(#wx_ref{type=ThisT,ref=ThisRef}, {PtX, PtY}, {SzW, SzH}, Sa, Ea)
           when 
           is_integer(PtX),
           is_integer(PtY),
           is_integer(SzW),
           is_integer(SzH),
           is_number(Sa),
           is_number(Ea) ->
                          ?CLASS(ThisT,wxDC),
            wxe_util:cast(?wxDC_DrawEllipticArc,
            <<ThisRef:32/?UI,PtX:32/?UI,PtY:32/?UI,SzW:32/?UI,SzH:32/?UI,0:32,Sa:64/?F,Ea:64/?F>>).





           %·%% DRAW ICON %%·%
          
%%  Draw an icon on the display 
%%  (does nothing if the device context is PostScript).
%%  This can be the simplest way of drawing bitmaps on a window

          -spec drawIcon(This, Icon, Pt) -> ok
           when
           This ::          wxDC(),
           Icon :: wxIcon:wxIcon(),
           Pt   :: {X :: integer(),
                    Y :: integer()}.

drawIcon(#wx_ref{type=ThisT,ref=ThisRef},
         #wx_ref{type=IconT,ref=IconRef},
                              {PtX, PtY})
           when 
           is_integer(PtX),
           is_integer(PtY) ->
                            ?CLASS(ThisT,wxDC),
                            ?CLASS(IconT,wxIcon),
              wxe_util:cast(?wxDC_DrawIcon,
              <<ThisRef:32/?UI,IconRef:32/?UI,PtX:32/?UI,PtY:32/?UI>>).



           %·%% DRAW LABEL %%·%
          
%%  Draw optional bitmap and the text into the given 
%%  rectangle and aligns it as specified by alignment parameter; 
%%  it also will emphasize the character with the 
%%  given index if it is != -1 and return 
%%  the bounding rectangle if required. 

%% @equiv drawLabel(This,Text,Rect, [])
          -spec drawLabel(This, Text, Rect) -> ok
           when
           This :: wxDC(), 
           Text :: unicode:chardata(), 
           Rect :: {X :: integer(), 
                    Y :: integer(), 
                    W :: integer(), 
                    H :: integer()}.

drawLabel(This,Text,Rect={RectX, RectY, RectW, RectH})
           when 
           is_record(This, wx_ref),
           is_list(Text),
           is_integer(RectX),
           is_integer(RectY),
           is_integer(RectW),
           is_integer(RectH)                 ->  drawLabel(This, Text, Rect, []).


          -spec drawLabel(This, Text, Rect, [Option]) -> ok
           when
           This    :: wxDC(), 
           Text    :: unicode:chardata(), 
           Rect    :: {X :: integer(), 
                       Y :: integer(), 
                       W :: integer(), 
                       H :: integer()},
           Option  ::  {alignment, integer()}
                    | {indexAccel, integer()}.

drawLabel(#wx_ref{type=ThisT,ref=ThisRef}, Text, {RectX, RectY, RectW, RectH}, Options)
           when 
           is_list(Text),
           is_integer(RectX),
           is_integer(RectY),
           is_integer(RectW),
           is_integer(RectH),
           is_list(Options) ->
                             ?CLASS(ThisT,wxDC),
                   Text_UC   = unicode:characters_to_binary([Text,0]),
                   MOpts = fun({alignment,   Alignment}, Acc) -> [<<1:32/?UI,Alignment:32/?UI>>|Acc];
                              ({indexAccel, IndexAccel}, Acc) -> [<<2:32/?UI,IndexAccel:32/?UI>>|Acc];
                                                  (BadOpt, _) -> erlang:error({badoption, BadOpt})
                           end,
                    BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)),
                                         wxe_util:cast(?wxDC_DrawLabel,
                                <<ThisRef:32/?UI,(byte_size(Text_UC)):32/?UI,(Text_UC)/binary, 
                                      0:(((8- ((0+byte_size(Text_UC)) band 16#7)) band 16#7))/unit:8,
                                               RectX:32/?UI,RectY:32/?UI,RectW:32/?UI,RectH:32/?UI, BinOpt/binary>>).





           %·%% DRAW LINE %%·%
          
%%  Draws a line from the first point to the second.  
%%  The current pen is used for drawing the line.
%%  Note that the point (x2, y2) is not part of 
%%  the line and is not drawn by this 
%%  function (this is consistent with 
%%  the behaviour of many other toolkits).


          -spec drawLine(This, Pt1, Pt2) -> ok
           when
           This :: wxDC(),
           Pt1  :: { X :: integer(), 
                     Y :: integer()},
           Pt2  :: { X :: integer(), 
                     Y :: integer()}.

drawLine(#wx_ref{type=ThisT,ref=ThisRef}, {Pt1X, Pt1Y}, {Pt2X, Pt2Y})
           when 
           is_integer(Pt1X),
           is_integer(Pt1Y),
           is_integer(Pt2X),
           is_integer(Pt2Y) ->
                             ?CLASS(ThisT,wxDC),
               wxe_util:cast(?wxDC_DrawLine,
               <<ThisRef:32/?UI,Pt1X:32/?UI,Pt1Y:32/?UI,Pt2X:32/?UI,Pt2Y:32/?UI>>).




           %·%% DRAW LINES %%·%
          
%%  Draws lines using an array of points of size n 
%%  adding the optional offset coordinate.
%%  The current pen is used for drawing the lines

%% @equiv drawLines(This,Points, [])
          -spec drawLines(This, Points) -> ok
           when
           This   ::           wxDC(), 
           Points :: [{X :: integer(), 
                       Y :: integer()}].

drawLines(This, Points)
           when 
           is_record(This, wx_ref),
           is_list(Points)               ->  drawLines(This,Points, []).




          -spec drawLines(This, Points, [Option]) -> ok
           when
           This    ::              wxDC(), 
           Points  :: [ {  X :: integer(), 
                           Y :: integer()}],
           Option  :: {xoffset, integer()}
                    | {yoffset, integer()}.

drawLines(#wx_ref{type=ThisT,ref=ThisRef}, Points, Options)
           when 
           is_list(Points),
           is_list(Options) ->
                             ?CLASS(ThisT,wxDC),
                   MOpts = fun({xoffset, Xoffset}, Acc) -> [<<1:32/?UI,Xoffset:32/?UI>>|Acc];
                              ({yoffset, Yoffset}, Acc) -> [<<2:32/?UI,Yoffset:32/?UI>>|Acc];
                                            (BadOpt, _) -> erlang:error({badoption, BadOpt})
                           end,
                   BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)),
                                        wxe_util:cast(?wxDC_DrawLines,
                               <<ThisRef:32/?UI,(length(Points)):32/?UI,
                        (<< <<X:32/?I,Y:32/?I>> || {X,Y} <- Points>>)/binary, BinOpt/binary>>).






           %·%% DRAW POINT %%·%
          
%%  Draws a point using the color of the current pen.
%%  Note that the other properties of the pen are not used, such as width.


          -spec drawPoint(This, Pt) -> ok
           when
           This ::          wxDC(),
           Pt   :: {X :: integer(),
           Y    ::       integer()}.

drawPoint(#wx_ref{type=ThisT,ref=ThisRef}, {PtX, PtY})
           when 
           is_integer(PtX),
           is_integer(PtY)  ->
                             ?CLASS(ThisT,wxDC),
               wxe_util:cast(?wxDC_DrawPoint,
               <<ThisRef:32/?UI,PtX:32/?UI,PtY:32/?UI>>).







           %·%% DRAW POLYGON %%·%
          
%%  Draws a filled polygon using an array of points of size n, adding the optional offset coordinate.
%%  The first and last points are automatically closed.
%%  The last argument specifies the fill rule: wxODDEVEN_RULE (the default) or wxWINDING_RULE.
%%  The current pen is used for drawing the outline, and the current brush for filling the shape. 
%%  Using a transparent brush suppresses filling.

%% @equiv drawPolygon(This,Points, [])

          -spec drawPolygon(This, Points) -> ok
           when
           This   ::           wxDC(), 
           Points :: [{X :: integer(),   % notice it is a list of points. 
                       Y :: integer()}].

drawPolygon(This,Points)
           when 
           is_record(This, wx_ref),
           is_list(Points)                ->  drawPolygon(This,Points, []).





          -spec drawPolygon(This, Points, [Option]) -> ok
           when
           This    ::           wxDC(), 
           Points  :: [{X :: integer(), 
                        Y :: integer()}],
           Option  :: {xoffset,      integer()}
                    | {yoffset,      integer()}
                    | {fillStyle, wx:wx_enum()}.    %%<br /> FillStyle = integer

drawPolygon(#wx_ref{type=ThisT,ref=ThisRef}, Points, Options)
           when 
           is_list(Points),
           is_list(Options) ->
                             ?CLASS(ThisT,wxDC),
                   MOpts = fun({xoffset,     Xoffset}, Acc) -> [<<1:32/?UI,Xoffset:32/?UI>>|Acc];
                              ({yoffset,     Yoffset}, Acc) -> [<<2:32/?UI,Yoffset:32/?UI>>|Acc];
                              ({fillStyle, FillStyle}, Acc) -> [<<3:32/?UI,FillStyle:32/?UI>>|Acc];
                                                (BadOpt, _) -> erlang:error({badoption, BadOpt})
            end,
                   BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)),
                                        wxe_util:cast(?wxDC_DrawPolygon,
                               <<ThisRef:32/?UI,(length(Points)):32/?UI,
                        (<< <<X:32/?I,Y:32/?I>> || {X,Y} <- Points>>)/binary, BinOpt/binary>>).





           %·%% DRAW RECTANGLE %%·%
          
%%  Draws a rectangle with the given top left corner, 
%%  and with the given size.
%%
%%  The current pen is used for the outline 
%%  and the current brush for filling the shape.


          -spec drawRectangle(This, Rect) -> ok
           when
           This :: wxDC(), 
           Rect :: {X :: integer(), 
                    Y :: integer(), 
                    W :: integer(),
                    H :: integer()}.

drawRectangle(#wx_ref{type=ThisT,ref=ThisRef},{RectX,RectY,RectW,RectH})
           when 
           is_integer(RectX),
           is_integer(RectY),
           is_integer(RectW),
           is_integer(RectH) ->
                              ?CLASS(ThisT,wxDC),
                wxe_util:cast(?wxDC_DrawRectangle_1,
                <<ThisRef:32/?UI,RectX:32/?UI,RectY:32/?UI,RectW:32/?UI,RectH:32/?UI>>).


          -spec drawRectangle(This, Pt, Sz) -> ok
           when
           This   ::          wxDC(),
           Pt     :: {X :: integer(), 
                      Y :: integer()}, 
           Sz     :: {W :: integer(), 
                      H :: integer()}.

drawRectangle(#wx_ref{type=ThisT,ref=ThisRef}, {PtX, PtY}, {SzW, SzH})
           when 
           is_integer(PtX),
           is_integer(PtY),
           is_integer(SzW),
           is_integer(SzH)  ->
                             ?CLASS(ThisT,wxDC),
               wxe_util:cast(?wxDC_DrawRectangle_2,
               <<ThisRef:32/?UI,PtX:32/?UI,PtY:32/?UI,SzW:32/?UI,SzH:32/?UI>>).





           %·%% DRAW ROTATED TEXT %%·%
          
%%  Draws the text rotated by angle degrees 
%%  (positive angles are counterclockwise; 
%%  the full angle is 360 degrees).
%%  
%%  Notice that, as with DrawText(), the text can 
%%  contain multiple lines separated by the new 
%%  line ('\n') characters.
%%  Note:
%%      Under MSW only TrueType fonts can be drawn by this function. 
%%
%%  In particular, a font different from wxNORMAL_FONT should be used as the latter is not a TrueType font. 
%%  wxSWISS_FONT is an example of a font which is.
%%     See also
%%         DrawText() 



          -spec drawRotatedText(This, Text, Pt, Angle) -> ok
           when
           This  ::             wxDC(), 
           Text  :: unicode:chardata(), 
           Pt    :: {X ::    integer(),
                     Y ::    integer()}, 
           Angle ::           number().

drawRotatedText(#wx_ref{type=ThisT,ref=ThisRef}, Text, {PtX, PtY}, Angle)
           when 
           is_list(Text),
           is_integer(PtX),
           is_integer(PtY),
           is_number(Angle) ->
                             ?CLASS(ThisT,wxDC),
  Text_UC = unicode:characters_to_binary([Text,0]),
               wxe_util:cast(?wxDC_DrawRotatedText,
               <<ThisRef:32/?UI,(byte_size(Text_UC)):32/?UI,(Text_UC)/binary,
                    0:(((8- ((0+byte_size(Text_UC)) band 16#7)) band 16#7))/unit:8,PtX:32/?UI,PtY:32/?UI,Angle:64/?F>>).







           %·%% DRAW ROUNDED RECTANGLE %%·%
          
%%  Draws a rectangle with the given top left corner, and with the given size.
%%  The corners are quarter-circles using the given radius. 
%%  The current pen is used for the outline and the current brush for filling the shape.
%%  If radius is positive, the value is assumed to be the radius of the rounded corner. 
%%  If radius is negative,the absolute value is assumed to be the proportion of the smallest dimension of the rectangle. 
%%  This means that the corner can be a sensible size relative to the size of the rectangle, 
%%  and also avoids the strange effects X produces when the corners are too big for the rectangle.


          -spec drawRoundedRectangle(This, R, Radius) -> ok
           when
           This   ::          wxDC(), 
           R      :: {X :: integer(), 
                      Y :: integer(), 
                      W :: integer(), 
                      H :: integer()}, 
           Radius ::        number().

drawRoundedRectangle(#wx_ref{type=ThisT,ref=ThisRef}, {RX, RY, RW, RH}, Radius)
           when 
           is_integer(RX),
           is_integer(RY),
           is_integer(RW),
           is_integer(RH),
           is_number(Radius) ->
                              ?CLASS(ThisT,wxDC),
                wxe_util:cast(?wxDC_DrawRoundedRectangle_2,
                <<ThisRef:32/?UI,RX:32/?UI,RY:32/?UI,RW:32/?UI,RH:32/?UI,0:32,Radius:64/?F>>).







           %·%% DRAW ROUNDED RECTANGLE %%·%
          
%%  

%% @doc See <a href="http://www.wxwidgets.org/manuals/2.8.12/wx_wxdc.html#wxdcdrawroundedrectangle">external documentation</a>.
          -spec drawRoundedRectangle(This, Pt, Sz, Radius) -> ok
           when
           This   ::                          wxDC(), 
           Pt     :: {X :: integer(), Y :: integer()}, 
           Sz     :: {W :: integer(), H :: integer()}, 
           Radius ::                        number().

drawRoundedRectangle(#wx_ref{type=ThisT,ref=ThisRef}, {PtX, PtY}, {SzW, SzH}, Radius)
           when 
           is_integer(PtX),
           is_integer(PtY),
           is_integer(SzW),
           is_integer(SzH),
           is_number(Radius) ->
                              ?CLASS(ThisT,wxDC),
                wxe_util:cast(?wxDC_DrawRoundedRectangle_3,
                <<ThisRef:32/?UI,PtX:32/?UI,PtY:32/?UI,SzW:32/?UI,SzH:32/?UI,0:32,Radius:64/?F>>).





           %·%% DRAW TEXT %%·%
          
%%  Draws a text string at the specified point, using the current text font,
%%  and the current text foreground and background colours.
%%  The coordinates refer to the top-left corner 
%%  of the rectangle bounding the string. 
%%  See GetTextExtent() for how to get the 
%%  dimensions of a text string, which can be 
%%  used to position the text more precisely and DrawLabel() 
%%  if you need to align the string differently.
%%  Starting from wxWidgets 2.9.2 text parameter 
%%  can be a multi-line string, 
%%  i.e. contain new line characters,
%%        and will be rendered correctly.
%%      Note
%%          The current logical function is ignored by this function

          -spec drawText(This, Text, Pt) -> ok
           when
           This :: wxDC(), 
           Text :: unicode:chardata(), 
           Pt   :: {X :: integer(), 
                    Y :: integer()}.

drawText(#wx_ref{type=ThisT,ref=ThisRef}, Text, {PtX, PtY})
           when 
           is_list(Text),
           is_integer(PtX),
           is_integer(PtY)  ->
                             ?CLASS(ThisT,wxDC),
                     Text_UC = unicode:characters_to_binary([Text,0]),
                              wxe_util:cast(?wxDC_DrawText,
                              <<ThisRef:32/?UI,(byte_size(Text_UC)):32/?UI,(Text_UC)/binary, 
                                    0:(((8- ((0+byte_size(Text_UC)) band 16#7)) band 16#7))/unit:8,PtX:32/?UI,PtY:32/?UI>>).





           %·%% END DOC %%·%
          
%%  Ends a document (only relevant when outputting to a printer).

          -spec endDoc(This) -> ok
           when
           This :: wxDC().

endDoc(#wx_ref{type=ThisT,ref=ThisRef}) ->
                                         ?CLASS(ThisT,wxDC),
                           wxe_util:cast(?wxDC_EndDoc,
                           <<ThisRef:32/?UI>>).





           %·%% END PAGE %%·%
          
%%  Ends a document page (only relevant when outputting to a printer).

          -spec endPage(This) -> ok
           when
           This :: wxDC().

endPage(#wx_ref{type=ThisT,ref=ThisRef}) ->
                                          ?CLASS(ThisT,wxDC),
                            wxe_util:cast(?wxDC_EndPage,
                            <<ThisRef:32/?UI>>).





           %·%% FLOOD FILL %%·%
          
%%  Flood fills the device context starting from the given point, 
%%  using the current brush colour, and using a style:
%%
%%    wxFLOOD_SURFACE: The flooding occurs until a colour 
%%                     other than the given colour is encountered.
%%  
%%    wxFLOOD_BORDER: The area to be flooded is
%%                    bounded by the given colour.
%%
%%    Currently this method is not implemented in wxOSX and does nothing there.
%%
%%     Returnsfalse if the operation failed.
%%
%%     Note
%%         The present implementation for non-Windows platforms 
%%         may fail to find colour borders if the pixels 
%%         do not match the colour exactly. 
%%         However the function will still return true.
%%         This method shouldn't be used with wxPaintDC 
%%         under non-Windows platforms as it uses GetPixel() internally 
%%         and this may give wrong results, notably in wxGTK. 
%%         If you need to flood fill wxPaintDC, create a 
%5         temporary wxMemoryDC, flood fill it and then 
%%         blit it to, or draw as a bitmap on, wxPaintDC. 
%%         See the example of doing this in the 
%%         drawing sample and wxBufferedPaintDC class. 




%% @equiv floodFill(This,Pt,Col, [])
          -spec floodFill(This, Pt, Col) ->  boolean()
           when
           This :: wxDC(), 
           Pt :: {X   ::      integer(), 
                  Y   ::      integer()}, 
                  Col :: wx:wx_colour().

floodFill(This,Pt={PtX,PtY},Col)
           when 
           is_record(This, wx_ref),
           is_integer(PtX),
           is_integer(PtY),
           tuple_size(Col) =:= 3; 
           tuple_size(Col) =:= 4          ->  floodFill(This,Pt,Col, []).



          -spec floodFill(This, Pt, Col, [Option]) -> boolean()
           when
           This    ::                wxDC(), 
           Pt      ::       {X :: integer(), 
                             Y :: integer()}, 
           Col     ::        wx:wx_colour(),
           Option  ::  {style, wx:wx_enum()}.   %%<br /> Style = integer

floodFill(#wx_ref{type=ThisT,ref=ThisRef}, {PtX,PtY}, Col, Options)
           when 
           is_integer(PtX),
           is_integer(PtY),
           tuple_size(Col) =:= 3; 
           tuple_size(Col) =:= 4,
           is_list(Options) ->
                             ?CLASS(ThisT,wxDC),
                   MOpts = fun({style,       Style},  Acc) -> [<<1:32/?UI,Style:32/?UI>>|Acc];
                                               (BadOpt, _) -> erlang:error({badoption, BadOpt})
                           end,
                   BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)),
                                           wxe_util:call(?wxDC_FloodFill,
                                           <<ThisRef:32/?UI,PtX:32/?UI,PtY:32/?UI,(wxe_util:colour_bin(Col)):16/binary, 0:32,BinOpt/binary>>).





           %·%% GET BACKGROUND %%·%
          
%%  Gets the brush used for painting the background.

          -spec getBackground(This) -> wxBrush:wxBrush()
           when
           This :: wxDC().

getBackground(#wx_ref{type=ThisT,ref=ThisRef}) ->
                                                ?CLASS(ThisT,wxDC),
                                  wxe_util:call(?wxDC_GetBackground,
                                  <<ThisRef:32/?UI>>).





           %·%% GET BACKGROUND MODE %%·%
          
%%  Returns the current background mode: wxPENSTYLE_SOLID or wxPENSTYLE_TRANSPARENT.

          -spec getBackgroundMode(This) -> integer()
           when
           This :: wxDC().

getBackgroundMode(#wx_ref{type=ThisT,ref=ThisRef}) ->
                                                    ?CLASS(ThisT,wxDC),
                                      wxe_util:call(?wxDC_GetBackgroundMode,
                                      <<ThisRef:32/?UI>>).





           %·%% GET BRUSH %%·%
          
%%  Gets the current brush.
%%  
%%  See also
%%      wxDC::SetBrush() 

          -spec getBrush(This) -> wxBrush:wxBrush()
           when
           This :: wxDC().

getBrush(#wx_ref{type=ThisT,ref=ThisRef}) ->
                                           ?CLASS(ThisT,wxDC),
                             wxe_util:call(?wxDC_GetBrush,
                             <<ThisRef:32/?UI>>).





           %·%% GET CHAR HEIGHT %%·%
          
%%  Gets the character height of the currently set font.

          -spec getCharHeight(This) -> integer()
           when
           This :: wxDC().

getCharHeight(#wx_ref{type=ThisT,ref=ThisRef})  ->
                                                 ?CLASS(ThisT,wxDC),
                                   wxe_util:call(?wxDC_GetCharHeight,
                                   <<ThisRef:32/?UI>>).





           %·%% GET CHAR WIDTH %%·%
          
%%  Gets the average character width of the currently set font.

          -spec getCharWidth(This) -> integer()
           when
           This :: wxDC().

getCharWidth(#wx_ref{type=ThisT,ref=ThisRef}) ->
                                               ?CLASS(ThisT,wxDC),
                                 wxe_util:call(?wxDC_GetCharWidth,
                                 <<ThisRef:32/?UI>>).





           %·%% GET CLIPPING BOX %%·%
          
%%  Gets the rectangle surrounding the current clipping region. 

          -spec getClippingBox(This) -> Result 
           when
           Result  :: {X :: integer(), 
                       Y :: integer(), 
                       W :: integer(), 
                       H :: integer()},
           This :: wxDC().

getClippingBox(#wx_ref{type=ThisT,ref=ThisRef}) ->
                                                 ?CLASS(ThisT,wxDC),
                                   wxe_util:call(?wxDC_GetClippingBox,
                                   <<ThisRef:32/?UI>>).





           %·%% GET FONT %%·%
          
%%  Gets the current font.
%%  Notice that even although each device context 
%%  object has some default font after creation,
%%  this method would return a wxNullFont initially 
%%  and only after calling SetFont() a valid font is returned.


          -spec getFont(This) -> wxFont:wxFont()
           when
           This :: wxDC().
getFont(#wx_ref{type=ThisT,ref=ThisRef}) ->
                                          ?CLASS(ThisT,wxDC),
                            wxe_util:call(?wxDC_GetFont,
                            <<ThisRef:32/?UI>>).





           %·%% GET LAYOUT DIRECTION %%·%
          
%%  Gets the current layout direction of the device context.
%%  On platforms where RTL layout is supported, the 
%%  return value will either be wxLayout_LeftToRight or
%%  wxLayout_RightToLeft. 
%%  If RTL layout is not supported,
%%   the return value will be wxLayout_Default.
%%  
%%    See also
%%        SetLayoutDirection() 




          -spec getLayoutDirection(This) -> wx:wx_enum()
           when
           This :: wxDC().    %%<br /> Res = ?wxLayout_Default | ?wxLayout_LeftToRight 
                              %%                               | ?wxLayout_RightToLeft

getLayoutDirection(#wx_ref{type=ThisT,ref=ThisRef}) ->
                                                     ?CLASS(ThisT,wxDC),
                                       wxe_util:call(?wxDC_GetLayoutDirection,
                                       <<ThisRef:32/?UI>>).





           %·%% GET LOGICAL FUNCTION %%·%
          
%%  Gets the current logical function.

          -spec getLogicalFunction(This) -> integer()
           when
           This :: wxDC().

getLogicalFunction(#wx_ref{type=ThisT,ref=ThisRef}) ->
                                                     ?CLASS(ThisT,wxDC),
                                       wxe_util:call(?wxDC_GetLogicalFunction,
                                       <<ThisRef:32/?UI>>).





           %·%% GET MAP MODE %%·%
          
%%  Gets the current mapping mode for the device context.
%%
%%   GetSizeMM (for a page size in millimeters).
%%   The mapping mode of the device context defines the unit of measurement
%%   used to convert logical units to device units.
%%
%%   For example, in
%%   wxMM_TEXT mode, a user scale value of (1.0, 1.0) 
%%   makes logical and device units identical. By default,
%%   the mapping mode is wxMM_TEXT, and the scale is (1.0, 1.0).
%%  
%%   RC OSX MAVERICKS TESTED  TESTED ———————
%%       -define(wxMM_TEXT, 1).      Each logical unit is 1 pixel. This is the default mode.
%%       -define(wxMM_LOMETRIC, 2).  Each logical unit is 1/10 of a millimeter.  (~3x bigger then Text)
%%       -define(wxMM_HIMETRIC, 3).                                              (~3x smaller/finer than Text)
%%       -define(wxMM_LOENGLISH, 4).                                     ( seemingly the same as HIMETRIC,3 )
%%       -define(wxMM_HIENGLISH, 5).                                     ( seemingly the same as Text )
%%       -define(wxMM_TWIPS, 6).    Each logical unit is 1/20 of a point, or 1/1440 of an inch. ( seemingly the same as Text )
%%       -define(wxMM_ISOTROPIC, 7).                                     ( seemingly the same as Text )
%%       -define(wxMM_ANISOTROPIC, 8).
%%       -define(wxMM_POINTS, 9).    Each logical unit is a point, or 1/72 of an inch.
%%       -define(wxMM_METRIC, 10).   Each logical unit is 1 millimeter.

          -spec getMapMode(This) -> integer()
           when
           This :: wxDC().

getMapMode(#wx_ref{type=ThisT,ref=ThisRef}) ->
                                             ?CLASS(ThisT,wxDC),
                               wxe_util:call(?wxDC_GetMapMode,
                               <<ThisRef:32/?UI>>).





           %·%% GET MULTILINE TEXT EXTENT %%·%
          
%%  Gets the dimensions of the string using the currently selected font.
%%  string is the text string to measure, heightLine, if non NULL, 
%%  is where to store the height of a single line.
%%  The text extent is set in the given w and h pointers.
%%  If the optional parameter font is specified and valid, 
%%  then it is used for the text extent calculation, 
%%  otherwise the currently selected font is used.
%%
%%       Note
%%             This function works with both single-line and multi-line strings.
%%
%%       See also
%%             wxFont, SetFont(), GetPartialTextExtents(), GetTextExtent() 



          -spec getMultiLineTextExtent(This, String) -> {W :: integer(), H :: integer()}
           when
           This :: wxDC(), 
           String :: unicode:chardata().

getMultiLineTextExtent(#wx_ref{type=ThisT,ref=ThisRef}, String)
           when 
           is_list(String) ->
                             ?CLASS(ThisT,wxDC),
                   String_UC = unicode:characters_to_binary([String,0]),
                              wxe_util:call(?wxDC_GetMultiLineTextExtent_1,
                              <<ThisRef:32/?UI,(byte_size(String_UC)):32/?UI,(String_UC)/binary, 
                                    0:(((8- ((0+byte_size(String_UC)) band 16#7)) band 16#7))/unit:8>>).





           %·%% GET MULTI LINE TEXT EXTENT %%·%
          
%%  Gets the dimensions of the string using the currently selected font.
%%  string is the text string to measure, heightLine, 
%%  if non NULL, is where to store the height of a single line.
%%  Returns
%%  The text extent as a wxSize object.
%%
%%       Note
%%           This function works with both single-line and multi-line strings.
%%
%%       See also
%%           wxFont, SetFont(), GetPartialTextExtents(), GetTextExtent() 

          -spec getMultiLineTextExtent(This, String, [Option]) -> {Width :: integer(), Height :: integer(), HeightLine :: integer()}
           when
           This    ::                  wxDC(), 
           String  ::      unicode:chardata(),
           Option  ::  {font, wxFont:wxFont()}.

getMultiLineTextExtent(#wx_ref{type=ThisT,ref=ThisRef}, String, Options)
           when 
           is_list(String),
           is_list(Options) ->
                             ?CLASS(ThisT,wxDC),
                   String_UC = unicode:characters_to_binary([String,0]),
                   MOpts = fun({font, #wx_ref{type=FontT,ref=FontRef}}, Acc) ->   ?CLASS(FontT,wxFont),[<<1:32/?UI,FontRef:32/?UI>>|Acc];
                                                                 (BadOpt, _) -> erlang:error({badoption, BadOpt})
                           end,
                   BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)),
                                        wxe_util:call(?wxDC_GetMultiLineTextExtent_4,
                               <<ThisRef:32/?UI,(byte_size(String_UC)):32/?UI,(String_UC)/binary,
                                     0:(((8- ((0+byte_size(String_UC)) band 16#7)) band 16#7))/unit:8, BinOpt/binary>>).





           %·%% GET PARTIAL TEXT EXTENTS %%·%
          
%%  Fills the widths array with the widths from the beginning 
%%  of text to the corresponding character of text.
%%  The generic version simply builds a running 
%%  total of the widths of each character using GetTextExtent(), 
%%  however if the various platforms have a native API function 
%%  that is faster or more accurate than the generic 
%%  implementation then it should be used instead.
%%
%%       See also
%%           GetMultiLineTextExtent(), GetTextExtent() 

          -spec getPartialTextExtents(This, Text) -> Result 
           when
           Result  :: {Res    ::   boolean(),
                       Widths :: [ integer() ] },
           This    :: wxDC(),
           Text    :: unicode:chardata().

getPartialTextExtents(#wx_ref{type=ThisT,ref=ThisRef}, Text)
           when 
           is_list(Text)  ->
                           ?CLASS(ThisT,wxDC),
                   Text_UC = unicode:characters_to_binary([Text,0]),
                            wxe_util:call(?wxDC_GetPartialTextExtents,
                             <<ThisRef:32/?UI,(byte_size(Text_UC)):32/?UI,(Text_UC)/binary,
                                   0:(((8- ((0+byte_size(Text_UC)) band 16#7)) band 16#7))/unit:8>>).





           %·%% GET PEN %%·%
          
%%  Gets the current pen

          -spec getPen(This) -> wxPen:wxPen()
           when
           This :: wxDC().

getPen(#wx_ref{type=ThisT,ref=ThisRef}) ->
                                         ?CLASS(ThisT,wxDC),
                           wxe_util:call(?wxDC_GetPen,
                           <<ThisRef:32/?UI>>).





           %·%% GET PIXEL %%·%
          
%%  Gets in colour the colour at the specified location.
%%  Not available for wxPostScriptDC or wxMetafileDC.
%%
%%  Note
%%    Setting a pixel can be done using DrawPoint().
%%    This method shouldn't be used with wxPaintDC as
%%    accessing the DC while drawing can result 
%%    in unexpected results, notably in wxGTK. 



          -spec getPixel(This, Pt) -> Result
           when
           Result  :: { Res ::       boolean(),
                        Col :: wx:wx_colour4()},
           This    ::                   wxDC(),
           Pt      :: {   X ::       integer(),
                          Y ::       integer()}.

getPixel(#wx_ref{type=ThisT,ref=ThisRef}, {PtX, PtY})
           when 
           is_integer(PtX),
           is_integer(PtY) ->
                            ?CLASS(ThisT,wxDC),
              wxe_util:call(?wxDC_GetPixel,
              <<ThisRef:32/?UI,PtX:32/?UI,PtY:32/?UI>>).





           %·%% GET PPI %%·%
          
%%  Returns the resolution of the device in pixels per inch.

          -spec getPPI(This) -> {W :: integer(), H :: integer()}
           when
           This :: wxDC().

getPPI(#wx_ref{type=ThisT,ref=ThisRef}) ->
                                         ?CLASS(ThisT,wxDC),
                           wxe_util:call(?wxDC_GetPPI,
                           <<ThisRef:32/?UI>>).





           %·%% GET SIZE %%·%
          
%%  Gets the horizontal and vertical extent of this 
%%  device context in device units.
%%  It can be used to scale graphics to fit the page.
%%  For example, if maxX and maxY represent the maximum 
%%  horizontal and vertical 'pixel' values used in your application,
%%  the following code will scale the graphic to 
%%  fit on the printer page:
%%                     wxCoord w, h;
%%                     dc.GetSize(&w, &h);
%%                     double scaleX = (double)(maxX / w);
%%                     double scaleY = (double)(maxY / h);
%%                     dc.SetUserScale(min(scaleX, scaleY),min(scaleX, scaleY));

          -spec getSize(This) -> {W :: integer(), H :: integer()}
           when
           This :: wxDC().

getSize(#wx_ref{type=ThisT,ref=ThisRef}) ->
                                          ?CLASS(ThisT,wxDC),
                            wxe_util:call(?wxDC_GetSize,
                            <<ThisRef:32/?UI>>).





           %·%% GET SIZE M M %%·%
          
%%  Returns the horizontal and vertical resolution in millimetres.

          -spec getSizeMM(This) -> {W :: integer(), H :: integer()}
           when
           This :: wxDC().

getSizeMM(#wx_ref{type=ThisT,ref=ThisRef})  ->
                                             ?CLASS(ThisT,wxDC),
                               wxe_util:call(?wxDC_GetSizeMM,
                               <<ThisRef:32/?UI>>).





           %·%% GET TEXT BACKGROUND %%·%
          
%%  Gets the current text background colour.

          -spec getTextBackground(This) -> wx:wx_colour4()
           when
           This :: wxDC().

getTextBackground(#wx_ref{type=ThisT,ref=ThisRef}) ->
                                                    ?CLASS(ThisT,wxDC),
                                      wxe_util:call(?wxDC_GetTextBackground,
                                      <<ThisRef:32/?UI>>).





           %·%% GET TEXT EXTENT %%·%
          
%%  Gets the dimensions of the string using the currently selected font.
%%              string  is the text string to measure,
%%             descent  is the dimension from the baseline of the font 
%%                      to the bottom of the descender, &
%%     externalLeading  is any extra vertical space added to the 
%%                      font by the font designer (usually is zero).
%%
%%  The text extent is returned in w and h pointers or as a wxSize 
%%  object depending on which version of this function is used.
%%  If the optional parameter font is specified and valid, 
%%  then it is used for the text extent calculation. 
%%  Otherwise the currently selected font is.
%%
%%      Note
%%          This function only works with single-line strings.
%%
%%      See also
%%          wxFont, SetFont(), GetPartialTextExtents(), GetMultiLineTextExtent() 

          -spec getTextExtent(This, String) -> {W :: integer(), H :: integer()}
           when
           This   ::             wxDC(),
           String :: unicode:chardata().

getTextExtent(#wx_ref{type=ThisT,ref=ThisRef},String)
           when 
           is_list(String)  ->
                             ?CLASS(ThisT,wxDC),
                   String_UC = unicode:characters_to_binary([String,0]),
                              wxe_util:call(?wxDC_GetTextExtent_1,
                              <<ThisRef:32/?UI,(byte_size(String_UC)):32/?UI,(String_UC)/binary,
                                    0:(((8- ((0+byte_size(String_UC)) band 16#7)) band 16#7))/unit:8>>).


          -spec getTextExtent(This, String, [Option]) -> Result
           when
           Result  ::  { X              :: integer(),
                         Y              :: integer(), 
                        Descent         :: integer(),
                        ExternalLeading :: integer()},
           This    ::  wxDC(),
           String  ::  unicode:chardata(),
           Option  ::  {theFont, wxFont:wxFont()}.

getTextExtent(#wx_ref{type=ThisT,ref=ThisRef}, String, Options)
           when 
           is_list(String),
           is_list(Options) ->
                             ?CLASS(ThisT,wxDC),
                   String_UC = unicode:characters_to_binary([String,0]),
                   MOpts = fun({theFont, #wx_ref{type=TheFontT,ref=TheFontRef}}, Acc) ->  ?CLASS(TheFontT,wxFont),[<<1:32/?UI,TheFontRef:32/?UI>>|Acc];
                                                                          (BadOpt, _) -> erlang:error({badoption, BadOpt})
                           end,
                   BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)),
                                        wxe_util:call(?wxDC_GetTextExtent_4,
                               <<ThisRef:32/?UI,(byte_size(String_UC)):32/?UI,(String_UC)/binary,
                                     0:(((8- ((0+byte_size(String_UC)) band 16#7)) band 16#7))/unit:8, BinOpt/binary>>).





           %·%% GET TEXT FOREGROUND %%·%
          
%%  Gets the current text foreground colour.

          -spec getTextForeground(This) -> wx:wx_colour4()
           when
           This :: wxDC().

getTextForeground(#wx_ref{type=ThisT,ref=ThisRef}) ->
                                                    ?CLASS(ThisT,wxDC),
                                      wxe_util:call(?wxDC_GetTextForeground,
                                      <<ThisRef:32/?UI>>).





           %·%% GET USER SCALE %%·%
          
%%  Gets the current user scale factor. 

          -spec getUserScale(This) -> {X :: number(), Y :: number()}
           when
           This :: wxDC().

getUserScale(#wx_ref{type=ThisT,ref=ThisRef}) ->
                                               ?CLASS(ThisT,wxDC),
                                 wxe_util:call(?wxDC_GetUserScale,
                                 <<ThisRef:32/?UI>>).





           %·%% GRADIENT FILL CONCENTRIC %%·%
          
%%  Fill the area specified by rect with a radial gradient, 
%%  starting from initialColour at the centre of the circle 
%%  and fading to destColour on the circle outside.
%%  The circle is placed at the centre of rect.
%%  Note
%%     Currently this function is very slow, don't use it for real-time drawing. 

          -spec gradientFillConcentric(This, Rect, InitialColour, DestColour) -> ok
           when
           This          ::          wxDC(),
           Rect          :: {X :: integer(), 
                             Y :: integer(), 
                             W :: integer(), 
                             H :: integer()},
           InitialColour ::  wx:wx_colour(),
           DestColour    ::  wx:wx_colour().

gradientFillConcentric(#wx_ref{type=ThisT,ref=ThisRef}, {RectX, RectY, RectW, RectH}, InitialColour, DestColour)
           when 
           is_integer(RectX),
           is_integer(RectY),
           is_integer(RectW),
           is_integer(RectH),
           tuple_size(InitialColour) =:= 3; 
           tuple_size(InitialColour) =:= 4,
           tuple_size(DestColour)    =:= 3; 
           tuple_size(DestColour)    =:= 4  ->
                                             ?CLASS(ThisT,wxDC),
                               wxe_util:cast(?wxDC_GradientFillConcentric_3,
                               <<ThisRef:32/?UI,RectX:32/?UI,RectY:32/?UI,RectW:32/?UI,RectH:32/?UI,
                               (wxe_util:colour_bin(InitialColour)):16/binary,
                               (wxe_util:colour_bin(DestColour)):16/binary>>).

          -spec gradientFillConcentric(This, Rect, InitialColour, DestColour, CircleCenter) -> ok
           when
           This          ::          wxDC(), 
           Rect          :: {X :: integer(), 
                             Y :: integer(), 
                             W :: integer(),
                             H :: integer()}, 
           InitialColour ::  wx:wx_colour(),
           DestColour    ::  wx:wx_colour(), 
           CircleCenter  :: {X :: integer(), 
                             Y :: integer()}.

gradientFillConcentric(#wx_ref{type=ThisT,ref=ThisRef}, 
                          {RectX, RectY, RectW, RectH},
                                         InitialColour,
                                            DestColour,
                        {CircleCenterX, CircleCenterY})
           when 
           is_integer(RectX),
           is_integer(RectY),
           is_integer(RectW),
           is_integer(RectH),
           tuple_size(InitialColour) =:= 3;
           tuple_size(InitialColour) =:= 4,
           tuple_size(DestColour)    =:= 3;
           tuple_size(DestColour)    =:= 4,
           is_integer(CircleCenterX),
           is_integer(CircleCenterY)  ->
                                       ?CLASS(ThisT,wxDC),
                         wxe_util:cast(?wxDC_GradientFillConcentric_4,
                         <<ThisRef:32/?UI,RectX:32/?UI,RectY:32/?UI,RectW:32/?UI,RectH:32/?UI,
                         (wxe_util:colour_bin(InitialColour)):16/binary,
                         (wxe_util:colour_bin(DestColour)):16/binary,CircleCenterX:32/?UI,CircleCenterY:32/?UI>>).




           %·%% GRADIENT FILL LINEAR %%·%
          
%%  Fill the area specified by rect with a linear gradient, 
%%  starting from initialColour and eventually fading to destColour.
%%  The nDirection specifies the direction of the colour change, 
%%  default is to use initialColour on the left part of 
%%  the rectangle and destColour on the right one.

%% @equiv gradientFillLinear(This,Rect,InitialColour,DestColour, [])
          -spec gradientFillLinear(This, Rect, InitialColour, DestColour) -> ok
           when
           This          ::          wxDC(), 
           Rect          :: {X :: integer(),
                             Y :: integer(), 
                             W :: integer(), 
                             H :: integer()}, 
           InitialColour ::  wx:wx_colour(), 
           DestColour    ::  wx:wx_colour().

gradientFillLinear(This, Rect={RectX,RectY,RectW,RectH}, InitialColour, DestColour)
           when 
           is_record(This, wx_ref),
           is_integer(RectX),
           is_integer(RectY),
           is_integer(RectW),
           is_integer(RectH),
           tuple_size(InitialColour) =:= 3; 
           tuple_size(InitialColour) =:= 4,
           tuple_size(DestColour)    =:= 3; 
           tuple_size(DestColour)    =:= 4 ->  gradientFillLinear(This,Rect,InitialColour,DestColour, []).



          -spec gradientFillLinear(This, Rect, InitialColour, DestColour, [Option]) -> ok
           when
           This          ::          wxDC(), 
           Rect          :: {X :: integer(), 
                             Y :: integer(), 
                             W :: integer(), 
                             H :: integer()}, 
           InitialColour ::  wx:wx_colour(), 
           DestColour    ::  wx:wx_colour(),
           Option        ::  {nDirection, wx:wx_enum()}.   
           %%<br /> NDirection = ?wxLEFT | ?wxRIGHT | ?wxUP   | ?wxDOWN | ?wxTOP | ?wxBOTTOM |                                               
           %%                   ?wxNORTH | ?wxSOUTH | ?wxWEST | ?wxEAST | ?wxALL


gradientFillLinear(#wx_ref{type=ThisT,ref=ThisRef}, 
                         {RectX,RectY,RectW,RectH}, InitialColour, DestColour, Options)
           when 
           is_integer(RectX),
           is_integer(RectY),
           is_integer(RectW),
           is_integer(RectH),
           tuple_size(InitialColour) =:= 3; 
           tuple_size(InitialColour) =:= 4,
           tuple_size(DestColour)    =:= 3; 
           tuple_size(DestColour)    =:= 4,
           is_list(Options)          ->
                                      ?CLASS(ThisT,wxDC),
                   MOpts = fun({nDirection, NDirection}, Acc) -> [<<1:32/?UI,NDirection:32/?UI>>|Acc];
                                                  (BadOpt, _) -> erlang:error({badoption, BadOpt})
                           end,
                   BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)),
                                        wxe_util:cast(?wxDC_GradientFillLinear,
                                        <<ThisRef:32/?UI,RectX:32/?UI,RectY:32/?UI,RectW:32/?UI,RectH:32/?UI,
                                        (wxe_util:colour_bin(InitialColour)):16/binary,
                                        (wxe_util:colour_bin(DestColour)):16/binary, 
                                                                 0:32,BinOpt/binary>>).





           %·%% LOGICAL TO DEVICE X %%·%
          
%%  Converts logical X coordinate to device coordinate, using the current mapping mode, user scale factor, 
%%  device origin and axis orientation.

          -spec logicalToDeviceX(This, X) -> integer()
           when
           This ::    wxDC(), 
           X    :: integer().

logicalToDeviceX(#wx_ref{type=ThisT,ref=ThisRef}, X)
           when 
           is_integer(X) ->
                          ?CLASS(ThisT,wxDC),
            wxe_util:call(?wxDC_LogicalToDeviceX,
            <<ThisRef:32/?UI,X:32/?UI>>).





           %·%% LOGICAL TO DEVICE X REL %%·%
          
%%  Converts logical X coordinate to relative device coordinate, using the current mapping mode and user scale factor 
%%  but ignoring the axis orientation.
%%
%%  Use this for converting a width, for example.

          -spec logicalToDeviceXRel(This, X) -> integer()
           when
           This ::    wxDC(),
           X    :: integer().

logicalToDeviceXRel(#wx_ref{type=ThisT,ref=ThisRef}, X)
           when 
           is_integer(X) ->
                          ?CLASS(ThisT,wxDC),
            wxe_util:call(?wxDC_LogicalToDeviceXRel,
            <<ThisRef:32/?UI,X:32/?UI>>).





           %·%% LOGICAL TO DEVICE Y %%·%
          
%%  Converts logical Y coordinate to device coordinate, using the current mapping mode, user scale factor, device origin and axis orientation.

          -spec logicalToDeviceY(This, Y) -> integer()
           when
           This :: wxDC(), 
           Y    :: integer().

logicalToDeviceY(#wx_ref{type=ThisT,ref=ThisRef}, Y)
           when 
           is_integer(Y)  ->
                           ?CLASS(ThisT,wxDC),
             wxe_util:call(?wxDC_LogicalToDeviceY,
             <<ThisRef:32/?UI,Y:32/?UI>>).





           %·%% LOGICAL TO DEVICE Y REL %%·%
          
%%  Converts logical Y coordinate to relative device coordinate, using the current mapping 
%%  mode and user scale factor but ignoring the axis orientation.
%%  Use this for converting a height, for example

          -spec logicalToDeviceYRel(This, Y) -> integer()
           when
           This ::    wxDC(), 
           Y    :: integer().

logicalToDeviceYRel(#wx_ref{type=ThisT,ref=ThisRef}, Y)
           when 
           is_integer(Y) ->
                          ?CLASS(ThisT,wxDC),
            wxe_util:call(?wxDC_LogicalToDeviceYRel,
            <<ThisRef:32/?UI,Y:32/?UI>>).





           %·%% MAX X %%·%
          
%%  Gets the maximum horizontal extent used in drawing commands so far

          -spec maxX(This) -> integer()
           when
           This :: wxDC().

maxX(#wx_ref{type=ThisT,ref=ThisRef}) ->
                                       ?CLASS(ThisT,wxDC),
                         wxe_util:call(?wxDC_MaxX,
                         <<ThisRef:32/?UI>>).





           %·%% MAX Y %%·%
          
%%  Gets the maximum vertical extent used in drawing commands so far. 

          -spec maxY(This) -> integer()
           when
           This :: wxDC().

maxY(#wx_ref{type=ThisT,ref=ThisRef}) ->
                                       ?CLASS(ThisT,wxDC),
                         wxe_util:call(?wxDC_MaxY,
                         <<ThisRef:32/?UI>>).





           %·%% MIN X %%·%
          
%%  Gets the minimum horizontal extent used in drawing commands so far.

          -spec minX(This) -> integer()
           when
           This :: wxDC().

minX(#wx_ref{type=ThisT,ref=ThisRef}) ->
                                       ?CLASS(ThisT,wxDC),
                         wxe_util:call(?wxDC_MinX,
                         <<ThisRef:32/?UI>>).





           %·%% MIN Y %%·%
          
%%  Gets the minimum vertical extent used in drawing commands so far. 

          -spec minY(This) -> integer()
           when
           This :: wxDC().

minY(#wx_ref{type=ThisT,ref=ThisRef}) ->
                                       ?CLASS(ThisT,wxDC),
                         wxe_util:call(?wxDC_MinY,
                         <<ThisRef:32/?UI>>).





           %·%% IS OK %%·%
          
%%  Returns true if the DC is ok to use.

          -spec isOk(This) -> boolean()
           when
           This :: wxDC().

isOk(#wx_ref{type=ThisT,ref=ThisRef}) ->
                                       ?CLASS(ThisT,wxDC),
                         wxe_util:call(?wxDC_IsOk,
                         <<ThisRef:32/?UI>>).





           %·%% RESET BOUNDING BOX %%·%

%% Resets the bounding box: after a call to this function, the bounding box doesn't contain anything.
%% 
%% See also
%%     CalcBoundingBox() 



          -spec resetBoundingBox(This) -> ok
           when
           This :: wxDC().

resetBoundingBox(#wx_ref{type=ThisT,ref=ThisRef}) ->
                                                   ?CLASS(ThisT,wxDC),
                                     wxe_util:cast(?wxDC_ResetBoundingBox,
                                     <<ThisRef:32/?UI>>).





           %·%% SET AXIS ORIENTATION %%·%
          
%%  Sets the x and y axis orientation (i.e. the direction 
%%  from lowest to highest values on the axis).
%%  The default orientation is x axis from left to 
%%  right and y axis from top down.
%%  
%%  Parameters
%%      xLeftRight  True to set the x axis orientation to the 
%%      natural left to right orientation, false to invert it.
%%      yBottomUp True to set the y axis orientation to the natural 
%%      bottom up orientation, false to invert it. 

          -spec setAxisOrientation(This, XLeftRight, YBottomUp) -> ok
           when
           This       ::    wxDC(), 
           XLeftRight :: boolean(), 
           YBottomUp  :: boolean().

setAxisOrientation(#wx_ref{type=ThisT,ref=ThisRef}, XLeftRight, YBottomUp)
           when 
           is_boolean(XLeftRight),
           is_boolean(YBottomUp)  ->
                                   ?CLASS(ThisT,wxDC),
                     wxe_util:cast(?wxDC_SetAxisOrientation,
                     <<ThisRef:32/?UI,(wxe_util:from_bool(XLeftRight)):32/?UI,(wxe_util:from_bool(YBottomUp)):32/?UI>>).





           %·%% SET BACKGROUND %%·%
          
%%  Sets the current background brush for the DC

          -spec setBackground(This, Brush) -> ok
           when
           This  ::            wxDC(),
           Brush :: wxBrush:wxBrush().

setBackground(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=BrushT,ref=BrushRef})  ->
                                                                                   ?CLASS(ThisT,wxDC),
                                                                                   ?CLASS(BrushT,wxBrush),
                                                                     wxe_util:cast(?wxDC_SetBackground,
                                                                     <<ThisRef:32/?UI,BrushRef:32/?UI>>).





           %·%% SET BACKGROUND MODE %%·%
          
%%  'mode' may be one of wxPENSTYLE_SOLID and wxPENSTYLE_TRANSPARENT.
%%  This setting determines whether text will be drawn with a background colour or not.

          -spec setBackgroundMode(This, Mode) -> ok
           when
           This ::    wxDC(), 
           Mode :: integer().

setBackgroundMode(#wx_ref{type=ThisT,ref=ThisRef}, Mode)
           when 
           is_integer(Mode) ->
                             ?CLASS(ThisT,wxDC),
               wxe_util:cast(?wxDC_SetBackgroundMode,
               <<ThisRef:32/?UI,Mode:32/?UI>>).





           %·%% SET BRUSH %%·%
          
%%  Sets the current brush for the DC.
%%  If the argument is wxNullBrush 
%%  (or another invalid brush; see wxBrush::IsOk), 
%%  the current brush is selected out of the device context 
%%  (leaving wxDC without any valid brush), 
%%  allowing the current brush to be destroyed safely.
%%
%%  See also
%%     wxBrush, wxMemoryDC 
%%     (for the interpretation of colours when drawing into a monochrome bitmap) 



          -spec setBrush(This, Brush) -> ok
           when
           This  ::            wxDC(), 
           Brush :: wxBrush:wxBrush().

setBrush(#wx_ref{type=ThisT,ref=ThisRef}, 
         #wx_ref{type=BrushT,ref=BrushRef}) ->
                                             ?CLASS(ThisT,wxDC),
                                             ?CLASS(BrushT,wxBrush),
                               wxe_util:cast(?wxDC_SetBrush,
                               <<ThisRef:32/?UI,BrushRef:32/?UI>>).





           %·%% SET CLIPPING REGION %%·%
          
%%  Sets the clipping region for this device context to 
%%  the intersection of the given region described by 
%%  the parameters of this method and the previously set clipping region.
%%  The clipping region is an area to which drawing is restricted. 
%%  Possible uses for the clipping region are for clipping text or 
%%  for speeding up window redraws when only a known area of 
%%  the screen is damaged. Notice that you need to call 
%%  DestroyClippingRegion() if you want to 
%%  set the clipping region exactly to the region specified.
%%
%%  Also note that if the clipping region is empty, 
%%  any previously set clipping region is destroyed, 
%%      i.e. it is equivalent to calling DestroyClippingRegion(), 
%%      and not to clipping out all drawing on the DC as might be expected.
%%
%%                      See also
%%                          DestroyClippingRegion(), wxRegion 
%%
%% <br /> Also:<br />
%% setClippingRegion(This, Rect) -> ok           when<br />
%%             This :: wxDC(), Rect :: {X :: integer(), Y :: integer(), W :: integer(), H :: integer()}.<br />
%% 
          -spec setClippingRegion(This, Region)         -> ok
           when
           This   ::              wxDC(), 
           Region :: wxRegion:wxRegion();

                                 (This, Rect)           -> ok
           when
           This ::          wxDC(), 
           Rect :: {X :: integer(), 
                    Y :: integer(), 
                    W :: integer(), 
                    H :: integer()}.

setClippingRegion(#wx_ref{type=ThisT,ref=ThisRef},
                  #wx_ref{type=RegionT,ref=RegionRef})  ->
                                                         ?CLASS(ThisT,wxDC),
                                                         ?CLASS(RegionT,wxRegion),
                                           wxe_util:cast(?wxDC_SetClippingRegion_1_0,
                                           <<ThisRef:32/?UI,RegionRef:32/?UI>>);

setClippingRegion(#wx_ref{type=ThisT,ref=ThisRef},
                     {RectX, RectY, RectW, RectH})
           when 
           is_integer(RectX),
           is_integer(RectY),
           is_integer(RectW),
           is_integer(RectH) ->
                              ?CLASS(ThisT,wxDC),
                wxe_util:cast(?wxDC_SetClippingRegion_1_1,
                <<ThisRef:32/?UI,RectX:32/?UI,RectY:32/?UI,RectW:32/?UI,RectH:32/?UI>>).



%%   MORE  %·%% SET CLIPPING REGION %%·%  
%%  
%%
          -spec setClippingRegion(This, Pt, Sz) -> ok
           when
           This :: wxDC(), 
           Pt  :: {X ::  integer(), 
                   Y ::  integer()}, 
            Sz :: {W :: integer(), 
                   H :: integer()}.

setClippingRegion(#wx_ref{type=ThisT,ref=ThisRef}, {PtX, PtY}, {SzW, SzH})
           when 
           is_integer(PtX),
           is_integer(PtY),
           is_integer(SzW),
           is_integer(SzH)  ->
                             ?CLASS(ThisT,wxDC),
               wxe_util:cast(?wxDC_SetClippingRegion_2,
               <<ThisRef:32/?UI,PtX:32/?UI,PtY:32/?UI,SzW:32/?UI,SzH:32/?UI>>).





           %·%% SET DEVICE ORIGIN %%·%
          
%%  Sets the device origin 
%%  (i.e. the origin in pixels after scaling has been applied).
%%  This function may be useful in Windows 
%%  printing operations for placing a graphic on a page.

          -spec setDeviceOrigin(This, X, Y) -> ok
           when
           This ::    wxDC(), 
           X    :: integer(), 
           Y    :: integer().

setDeviceOrigin(#wx_ref{type=ThisT,ref=ThisRef}, X, Y)
           when 
           is_integer(X),
           is_integer(Y) ->
                          ?CLASS(ThisT,wxDC),
            wxe_util:cast(?wxDC_SetDeviceOrigin,
            <<ThisRef:32/?UI,X:32/?UI,Y:32/?UI>>).





           %·%% SET FONT %%·%
          
%%  Sets the current font for the DC.
%%  If the argument is wxNullFont 
%%  (or another invalid font; see wxFont::IsOk), 
%%  the current font is selected out of the device context 
%%  (leaving wxDC without any valid font), 
%%  allowing the current font to be destroyed safely.
%%
%%                      See also
%%                          wxFont 



          -spec setFont(This, Font) -> ok
           when
           This ::          wxDC(),
           Font :: wxFont:wxFont().

setFont(#wx_ref{type=ThisT,ref=ThisRef},
        #wx_ref{type=FontT,ref=FontRef}) ->
                                          ?CLASS(ThisT,wxDC),
                                          ?CLASS(FontT,wxFont),
                            wxe_util:cast(?wxDC_SetFont,
                            <<ThisRef:32/?UI,FontRef:32/?UI>>).





           %·%% SET LAYOUT DIRECTION %%·%
          
%%  Sets the current layout direction for the device context.
%%
%%  Parameters
%%      dir May be either wxLayout_Default, wxLayout_LeftToRight or wxLayout_RightToLeft.
%%
%%  See also
%%      GetLayoutDirection() 



%%<br /> Dir = ?wxLayout_Default | ?wxLayout_LeftToRight | ?wxLayout_RightToLeft

          -spec setLayoutDirection(This, Dir) -> ok
           when
           This ::       wxDC(), 
           Dir  :: wx:wx_enum().

setLayoutDirection(#wx_ref{type=ThisT,ref=ThisRef},Dir)
           when 
           is_integer(Dir)  ->
                             ?CLASS(ThisT,wxDC),
               wxe_util:cast(?wxDC_SetLayoutDirection,
               <<ThisRef:32/?UI,Dir:32/?UI>>).





           %·%% SET LOGICAL FUNCTION %%·%
          
%%  Sets the current logical function for the device context.
%%  It determines how a source pixel (from a pen or brush colour, 
%%  or source device context if using Blit()) 
%%  combines with a destination pixel in the current device context. 
%%  Text drawing is not affected by this function.
%%  See wxRasterOperationMode enumeration values for more info.
%%  The default is wxCOPY, which simply draws with the current colour. 
%%  The others combine the current colour and 
%%  the background using a logical operation. 
%%  wxINVERT is commonly used for drawing rubber bands or moving outlines, 
%%                     since drawing twice reverts to the original colour.


%%<br /> Function = integer
          -spec setLogicalFunction(This, Function) -> ok
           when
           This     ::       wxDC(), 
           Function :: wx:wx_enum().

setLogicalFunction(#wx_ref{type=ThisT,ref=ThisRef}, Function)
           when 
           is_integer(Function) ->
                                 ?CLASS(ThisT,wxDC),
                   wxe_util:cast(?wxDC_SetLogicalFunction,
                   <<ThisRef:32/?UI,Function:32/?UI>>).



% 
% -define(wxCLEAR, 0).
% -define(wxROP_BLACK,      ?wxCLEAR).
% -define(wxBLIT_BLACKNESS, ?wxCLEAR).
% 
% -define(wxXOR, (?wxCLEAR+1)).
% 
% -define(wxROP_XORPEN,     ?wxXOR).
% -define(wxBLIT_SRCINVERT, ?wxXOR).
% 
% -define(wxINVERT,  (?wxXOR+1)).
% 
% -define(wxROP_NOT,        ?wxINVERT).
% -define(wxBLIT_DSTINVERT, ?wxINVERT).
% 
% -define(wxOR_REVERSE, (?wxINVERT+1)).
% 
% -define(wxROP_MERGEPENNOT, ?wxOR_REVERSE).
% -define(wxBLIT_00DD0228,   ?wxOR_REVERSE).
% 
% -define(wxAND_REVERSE, (?wxOR_REVERSE+1)).
% 
% -define(wxROP_MASKPENNOT, ?wxAND_REVERSE).
% -define(wxBLIT_SRCERASE,  ?wxAND_REVERSE).
% 
% -define(wxCOPY, (?wxAND_REVERSE+1)).
% 
% -define(wxROP_COPYPEN,  ?wxCOPY).
% -define(wxBLIT_SRCCOPY, ?wxCOPY).
% 
% -define(wxAND, (?wxCOPY+1)).
% 
% -define(wxROP_MASKPEN, ?wxAND).
% -define(wxBLIT_SRCAND, ?wxAND).
% 
% -define(wxAND_INVERT, (?wxAND+1)).
% 
% -define(wxROP_MASKNOTPEN, ?wxAND_INVERT).
% -define(wxBLIT_00220326,  ?wxAND_INVERT).
% 
% -define(wxNO_OP, (?wxAND_INVERT+1)).
% 
% -define(wxROP_NOP,       ?wxNO_OP).
% -define(wxBLIT_00AA0029, ?wxNO_OP).
% 
% -define(wxNOR, (?wxNO_OP+1)).
% 
% -define(wxROP_NOTMERGEPEN,  ?wxNOR).
% -define(wxBLIT_NOTSRCERASE, ?wxNOR).
% 
% -define(wxEQUIV, (?wxNOR+1)).
% 
% -define(wxROP_NOTXORPEN, ?wxEQUIV).
% -define(wxBLIT_00990066, ?wxEQUIV).
% 
% -define(wxSRC_INVERT, (?wxEQUIV+1)).
% 
% -define(wxROP_NOTCOPYPEN,  ?wxSRC_INVERT).
% -define(wxBLIT_NOTSCRCOPY, ?wxSRC_INVERT).
% 
% -define(wxOR_INVERT, (?wxSRC_INVERT+1)).
% 
% -define(wxROP_MERGENOTPEN, ?wxOR_INVERT).
% -define(wxBLIT_MERGEPAINT, ?wxOR_INVERT).
% 
% -define(wxNAND, (?wxOR_INVERT+1)).
% 
% -define(wxROP_NOTMASKPEN, ?wxNAND).
% -define(wxBLIT_007700E6,  ?wxNAND).
% 
% -define(wxOR, (?wxNAND+1)).
% 
% -define(wxROP_MERGEPEN,  ?wxOR).
% -define(wxBLIT_SRCPAINT, ?wxOR).
% 
% -define(wxSET, (?wxOR+1)).
% 
% -define(wxROP_WHITE,      ?wxSET).
% -define(wxBLIT_WHITENESS, ?wxSET).
% 
% 
% 
% 


-define(wxCLEAR,        0 ).
-define(wxXOR,         (?wxCLEAR+1)).         % 1    
-define(wxINVERT,      (?wxXOR+1)).           % 2     
-define(wxOR_REVERSE,  (?wxINVERT+1)).        % 3     
-define(wxAND_REVERSE, (?wxOR_REVERSE+1)).    % 4     
-define(wxCOPY,        (?wxAND_REVERSE+1)).   % 5     
-define(wxAND,         (?wxCOPY+1)).          % 6     
-define(wxAND_INVERT,  (?wxAND+1)).           % 7     
-define(wxNO_OP,       (?wxAND_INVERT+1)).    % 8     
-define(wxNOR,         (?wxNO_OP+1)).         % 9     
-define(wxEQUIV,       (?wxNOR+1)).           % 10     
-define(wxSRC_INVERT,  (?wxEQUIV+1)).         % 11     
-define(wxOR_INVERT,   (?wxSRC_INVERT+1)).    % 12     
-define(wxNAND,        (?wxOR_INVERT+1)).     % 13     
-define(wxOR,          (?wxNAND+1)).          % 14     
-define(wxSET,         (?wxOR+1)).            % 15     








           %·%% SET MAP MODE %%·%
          
%%  The mapping mode of the device context defines the unit 
%%  of measurement used to convert logical units to device units.
%%  Note that in X, text drawing isn't handled consistently 
%%  with the mapping mode; a font is always specified in point size. 
%%  However, setting the user scale (see SetUserScale()) 
%%  scales the text appropriately. 
%%  In Windows, scalable TrueType fonts are always used; 
%%  in X, results depend on availability of fonts, 
%%  but usually a reasonable match is found.
%%  The coordinate origin is always at the top left of the screen/printer.
%%  Drawing to a Windows printer device context uses the current mapping mode, 
%%  but mapping mode is currently ignored for PostScript output.
%%
%%  Mode Numbers documented above in getMapMode()

%%<br /> Mode = integer

          -spec setMapMode(This, Mode) -> ok
           when
           This ::       wxDC(), 
           Mode :: wx:wx_enum().

setMapMode(#wx_ref{type=ThisT,ref=ThisRef}, Mode)
           when 
           is_integer(Mode) ->
                             ?CLASS(ThisT,wxDC),
               wxe_util:cast(?wxDC_SetMapMode,
               <<ThisRef:32/?UI,Mode:32/?UI>>).





           %·%% SET PALETTE %%·%
          
%%   If this is a window DC or memory DC, assigns the given palette 
%%   to the window or bitmap associated with the DC.
%%   If the argument is wxNullPalette, the current 
%%   palette is selected out of the device context, 
%%   and the original palette restored.
%%
%% See also: wxPalette 

          -spec setPalette(This, Palette) -> ok
           when
           This    ::                wxDC(), 
           Palette :: wxPalette:wxPalette().

setPalette(#wx_ref{type=ThisT,ref=ThisRef},
           #wx_ref{type=PaletteT,ref=PaletteRef}) ->
                                                   ?CLASS(ThisT,wxDC),
                                                   ?CLASS(PaletteT,wxPalette),
                                     wxe_util:cast(?wxDC_SetPalette,
                                     <<ThisRef:32/?UI,PaletteRef:32/?UI>>).





           %·%% SET PEN %%·%
          
%%  Sets the current pen for the DC.
%%  If the argument is wxNullPen (or another invalid pen; see wxPen::IsOk), 
%%  the current pen is selected out of the device context 
%%  (leaving wxDC without any valid pen), 
%%  allowing the current pen to be destroyed safely.
%%
%%  See also
%%    wxMemoryDC for the interpretation of colours 
%%    when drawing into a monochrome bitmap. 

          -spec setPen(This, Pen) -> ok
           when
           This ::        wxDC(), 
           Pen  :: wxPen:wxPen().

setPen(#wx_ref{type=ThisT,ref=ThisRef},
       #wx_ref{type=PenT,ref=PenRef}) ->
                                       ?CLASS(ThisT,wxDC),
                                       ?CLASS(PenT,wxPen),
                         wxe_util:cast(?wxDC_SetPen,
                         <<ThisRef:32/?UI,PenRef:32/?UI>>).





           %·%% SET TEXT BACKGROUND %%·%
          
%%  Sets the current text background colour for the DC

          -spec setTextBackground(This, Colour) -> ok
           when
           This   ::         wxDC(), 
           Colour :: wx:wx_colour().

setTextBackground(#wx_ref{type=ThisT,ref=ThisRef}, Colour)
           when 
           tuple_size(Colour) =:= 3;
           tuple_size(Colour) =:= 4 ->
                                     ?CLASS(ThisT,wxDC),
                       wxe_util:cast(?wxDC_SetTextBackground,
                       <<ThisRef:32/?UI,(wxe_util:colour_bin(Colour)):16/binary>>).





           %·%% SET TEXT FOREGROUND %%·%
          
%%  Sets the current text foreground colour for the DC.
%%
%%  See also
%%      wxMemoryDC for the interpretation of colours 
%%      when drawing into a monochrome bitmap. 
%%
          -spec setTextForeground(This, Colour) -> ok
           when
           This   ::         wxDC(), 
           Colour :: wx:wx_colour().

setTextForeground(#wx_ref{type=ThisT,ref=ThisRef}, Colour)
           when 
           tuple_size(Colour) =:= 3;
           tuple_size(Colour) =:= 4 ->
                                     ?CLASS(ThisT,wxDC),
                       wxe_util:cast(?wxDC_SetTextForeground,
                       <<ThisRef:32/?UI,(wxe_util:colour_bin(Colour)):16/binary>>).





           %·%% SET USER SCALE %%·%
          
%%  Sets the user scaling factor, useful for applications which require 'zooming'.

          -spec setUserScale(This, X, Y) -> ok
           when
           This ::   wxDC(), 
           X    :: number(), 
           Y    :: number().

setUserScale(#wx_ref{type=ThisT,ref=ThisRef}, X, Y)
           when 
           is_number(X),
           is_number(Y) ->
                         ?CLASS(ThisT,wxDC),
           wxe_util:cast(?wxDC_SetUserScale,
           <<ThisRef:32/?UI,0:32,X:64/?F,Y:64/?F>>).





           %·%% START DOC %%·%
          
%%  Starts a document (only relevant when outputting to a printer).
%%  message is a message to show while printing.


          -spec startDoc(This, Message) -> boolean()
           when
           This    ::             wxDC(), 
           Message :: unicode:chardata().

startDoc(#wx_ref{type=ThisT,ref=ThisRef}, Message)
           when 
           is_list(Message) ->
                             ?CLASS(ThisT,wxDC),
                   Message_UC = unicode:characters_to_binary([Message,0]),
                               wxe_util:call(?wxDC_StartDoc,
                               <<ThisRef:32/?UI,(byte_size(Message_UC)):32/?UI,(Message_UC)/binary, 
                                     0:(((8- ((0+byte_size(Message_UC)) band 16#7)) band 16#7))/unit:8>>).





           %·%% START PAGE %%·%
          
%%  Starts a document page (only relevant when outputting to a printer)

          -spec startPage(This) -> ok
           when
           This :: wxDC().

startPage(#wx_ref{type=ThisT,ref=ThisRef}) ->
                                            ?CLASS(ThisT,wxDC),
                              wxe_util:cast(?wxDC_StartPage,
                              <<ThisRef:32/?UI>>).