Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

[r8593]: ooDialog / trunk / ooDialog / oodToolTip.cpp Maximize Restore History

Download this file

oodToolTip.cpp    2780 lines (2397 with data), 84.5 kB

   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
/*----------------------------------------------------------------------------*/
/* */
/* Copyright (c) 2012-2012 Rexx Language Association. All rights reserved. */
/* */
/* This program and the accompanying materials are made available under */
/* the terms of the Common Public License v1.0 which accompanies this */
/* distribution. A copy is also available at the following address: */
/* http://www.oorexx.org/license.html */
/* */
/* Redistribution and use in source and binary forms, with or */
/* without modification, are permitted provided that the following */
/* conditions are met: */
/* */
/* Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in */
/* the documentation and/or other materials provided with the distribution. */
/* */
/* Neither the name of Rexx Language Association nor the names */
/* of its contributors may be used to endorse or promote products */
/* derived from this software without specific prior written permission. */
/* */
/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
/* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */
/* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
/* */
/*----------------------------------------------------------------------------*/
/**
* oodToolTipp.cpp
*
* Contains methods for the ToolTip control.
*/
#include "ooDialog.hpp" // Must be first, includes windows.h, commctrl.h, and oorexxapi.h
#include <shlwapi.h>
#include <WindowsX.h>
#include "APICommon.hpp"
#include "oodCommon.hpp"
#include "oodMessaging.hpp"
#include "oodControl.hpp"
#include "oodResources.hpp"
/**
* Convert TTF_* flags into a string of keywwords specific to a TTN_NEEDTEXT
* notification.
*
* @param flags
*
* @return RexxStringObject
*
* @remarks This is an extern fucntion, not static.
*/
RexxStringObject ttdiFlags2keyword(RexxThreadContext *c, uint32_t flags)
{
char buf[512];
*buf = '\0';
if ( flags & TTF_IDISHWND ) strcat(buf, "IDISHWND ");
if ( flags & TTF_RTLREADING ) strcat(buf, "RTLREADING ");
if ( flags & TTF_DI_SETITEM ) strcat(buf, "DI_SETITEM ");
if ( *buf != '\0' )
{
*(buf + strlen(buf) - 1) = '\0';
}
return c->String(buf);
}
/**
* Parse TTF_X keywords into the corresponding value specific to a TTN_NEEDTEXT
* notification..
*
* @param flags Keyword string to parse
*
* @return The combined flag value
*/
static uint32_t keyword2ttdiFlags(CSTRING flags)
{
uint32_t f = 0;
if ( StrStrI(flags, "IDISHWND" ) != NULL ) f |= TTF_IDISHWND;
if ( StrStrI(flags, "RTLREADING" ) != NULL ) f |= TTF_RTLREADING;
if ( StrStrI(flags, "DI_SETITEM" ) != NULL ) f |= TTF_DI_SETITEM;
return f;
}
/**
* Convert a mouse window message code to a name.
*/
static RexxStringObject mousemsg2name(RexxThreadContext *c, uint32_t msg)
{
switch ( msg )
{
case WM_MOUSEMOVE : return c->String("mouseMove ");
case WM_LBUTTONDOWN : return c->String("lButtonDown ");
case WM_LBUTTONUP : return c->String("lButtonUp ");
case WM_LBUTTONDBLCLK : return c->String("lButtonDblClk");
case WM_RBUTTONDOWN : return c->String("rButtonDown ");
case WM_RBUTTONUP : return c->String("rButtonUp ");
case WM_RBUTTONDBLCLK : return c->String("rButtonDblClk");
case WM_MBUTTONDOWN : return c->String("mButtonDown ");
case WM_MBUTTONUP : return c->String("mButtonUp ");
case WM_MBUTTONDBLCLK : return c->String("mButtonDblClk");
case WM_XBUTTONDOWN : return c->String("xButtonDown ");
case WM_XBUTTONUP : return c->String("xButtonUp ");
case WM_XBUTTONDBLCLK : return c->String("xButtonDblClk");
case WM_MOUSEWHEEL : return c->String("mouseWheel ");
}
return c->String("unknown");
}
/**
* Allocates a Rexx buffer to be used, ultimately, for a .ToolInfo object.
* Optionally, allocate a buffer for the TOOLINFO.lpszText field
*
* @param c
* @param allocTextBuf
*
* @return The Rexx buffer object on success, .nil on error.
*
* @remarks If the allocation for the text buffer fails, we return NULLOBJECT.
* The Rexx buffer object will not be protected anywhere, so it will
* immediately be elgible for garbage collection
*/
static RexxBufferObject rexxBufferForToolInfo(RexxMethodContext *c, LPTOOLINFO *ppTI, bool allocTextBuf)
{
RexxBufferObject tiBuf = c->NewBuffer(sizeof(TOOLINFO));
if ( tiBuf == NULLOBJECT )
{
outOfMemoryException(c->threadContext);
return NULLOBJECT;
}
LPTOOLINFO pTI = (LPTOOLINFO)c->BufferData(tiBuf);
memset(pTI, 0, sizeof(TOOLINFO));
pTI->cbSize = sizeof(TOOLINFO);
if ( allocTextBuf )
{
pTI->lpszText = (char *)LocalAlloc(LPTR, MAX_TOOLINFO_TEXT_LENGTH + 1);
if ( pTI->lpszText == NULL )
{
outOfMemoryException(c->threadContext);
c->ReleaseLocalReference(tiBuf);
return NULLOBJECT;
}
}
*ppTI = pTI;
return tiBuf;
}
/**
* Attempts to return the Rexx objects that represents the TOOLINFO.hwnd and the
* TOOLINFO.uId fields.
*
* @param c
* @param pTI
* @param hwndSupplier
* @param idSupplier
*
* @remarks Currently, we are called with a pTI that was obtained from the
* operating system. I don't think that can change. I'm not sure to
* trust the TTF_IDISHWND flag or not. It would seem that has to be
* correct, or the tool tip would not be functioning correctly.
*
* If we can trust TTF_IDISHWND, then if it is present, uId has to be
* the hwnd of a dialog control and hwnd has to be the hwnd of a
* dialog.
*
* If it is absent, then uId is a number and hwnd could be a dialog or
* a dialog control.
*
* For now, we will trust the flag, but this is something to check if
* we see odd results.
*
* Also, currently, it is not possible to add a tool to a tool tip
* from Rexx code without using a Rexx dialog control object, if the
* TOOLINFO.hwnd is a dialog control. This means that the
* pCDialogControl pointer must exist in the control's window words.
*/
void getToolIdentifiers(RexxMethodContext *c, LPTOOLINFO pTI, RexxObjectPtr *hwndSupplier, RexxObjectPtr *idSupplier)
{
RexxObjectPtr rxHwnd = TheNilObj;
RexxObjectPtr rxID = TheNilObj;
SetLastError(0);
if ( pTI->uFlags & TTF_IDISHWND )
{
pCPlainBaseDialog pcpbd = (pCPlainBaseDialog)getWindowPtr(pTI->hwnd, GWLP_USERDATA);
oodControl_t ctrType = control2controlType((HWND)pTI->uId);
rxHwnd = pcpbd->rexxSelf;
rxID = createControlFromHwnd(c, pcpbd, (HWND)pTI->uId, ctrType, true);
}
else
{
rxID = c->Uintptr(pTI->uId);
// If ctrlType is winUnknown, the hwnd must be a dialog.
oodControl_t ctrlType = control2controlType(pTI->hwnd);
if ( ctrlType == winUnknown )
{
pCPlainBaseDialog pcpbd = (pCPlainBaseDialog)getWindowPtr(pTI->hwnd, GWLP_USERDATA);
rxHwnd = pcpbd->rexxSelf;
}
else
{
rxHwnd = (RexxObjectPtr)getWindowPtr(pTI->hwnd, GWLP_USERDATA);
}
}
*hwndSupplier = rxHwnd;
*idSupplier = rxID;
}
/**
* Uses a pointer to a TOOLINFO struct and a Rexx buffer to instantiate a new
* .ToolInfo.
*
* @param c
* @param tiBuf
* @param pTI
* @param memAllocated If true signals that a buffer was allocated for th text
* field of the TOOLINFO struct.
*
* @return RexxObjectPtr
*/
static RexxObjectPtr ti2rexxToolInfo(RexxMethodContext *c, RexxBufferObject tiBuf, LPTOOLINFO pTI, bool memAllocated)
{
RexxObjectPtr result = TheNilObj;
RexxClassObject tiCls = rxGetContextClass(c, "TOOLINFO");
if ( tiCls != NULLOBJECT )
{
RexxObjectPtr hwndSupplier;
RexxObjectPtr idSupplier;
getToolIdentifiers(c, pTI, &hwndSupplier, &idSupplier);
RexxArrayObject args = c->NewArray(5);
c->ArrayPut(args, tiBuf, 1);
c->ArrayPut(args, hwndSupplier, 2);
c->ArrayPut(args, idSupplier, 5);
result = c->SendMessage(tiCls, "NEW", args);
if ( result == NULLOBJECT )
{
goto done_out;
}
if ( memAllocated )
{
c->SendMessage1(result, "TEXTMEMORYISALLOCATED=", TheTrueObj);
}
}
done_out:
return result;
}
/**
* Methods for the .ToolTip class.
*/
#define TOOLTIP_CLASS "ToolTip"
static bool lazyInitToolTipTable(RexxMethodContext *c, pCPlainBaseDialog pcpbd)
{
pcpbd->ToolTipTab = (TOOLTIPTABLEENTRY *)LocalAlloc(LPTR, sizeof(TOOLTIPTABLEENTRY) * DEF_MAX_TTT_ENTRIES);
if ( ! pcpbd->ToolTipTab )
{
outOfMemoryException(c->threadContext);
return false;
}
pcpbd->TTT_size = DEF_MAX_TTT_ENTRIES;
pcpbd->TTT_nextIndex = 0;
return true;
}
/**
* Adds a new tool tip entry to the tool tip table, allocating a bigger table if
* needed.
*
* @param c
* @param pcpbd
* @param toolTip
* @param hToolTip
* @param id
*
* @return bool
*/
static bool addToolTipToTable(RexxMethodContext *c, pCPlainBaseDialog pcpbd, RexxObjectPtr toolTip, HWND hToolTip, uint32_t id)
{
if ( pcpbd->TTT_nextIndex >= pcpbd->TTT_size )
{
HLOCAL temp = LocalReAlloc(pcpbd->ToolTipTab, sizeof(TOOLTIPTABLEENTRY) * pcpbd->TTT_size * 2, LMEM_ZEROINIT | LMEM_MOVEABLE);
if ( temp == NULL )
{
char buf[512];
_snprintf(buf, sizeof(buf), "ToolTip controles have exceeded the maximum\n"
"number of allocated table entries, and the table\n"
"could not be expanded.\n\n"
" System error code: %d\n\n"
"No ToolTip control can be added.", GetLastError());
MessageBox(NULL, buf, "Error", MB_OK | MB_ICONHAND);
return false;
}
pcpbd->TTT_size *= 2;
pcpbd->ToolTipTab = (TOOLTIPTABLEENTRY *)temp;
}
setWindowPtr(hToolTip, GWLP_USERDATA, (LONG_PTR)toolTip);
c->SendMessage1(pcpbd->rexxSelf, "PUTCONTROL", toolTip);
pCDialogControl pcdc = controlToCSelf(c, toolTip);
pcpbd->ToolTipTab[pcpbd->TTT_nextIndex].id = id;
pcpbd->ToolTipTab[pcpbd->TTT_nextIndex].hToolTip = hToolTip;
pcpbd->ToolTipTab[pcpbd->TTT_nextIndex].rexxSelf = toolTip;
pcdc->toolTipEntry = &pcpbd->ToolTipTab[pcpbd->TTT_nextIndex];
pcpbd->TTT_nextIndex++;
return true;
}
/**
* Parses a list of tool tip style keywords and retuns the corresponding style
* flag.
*
* @param flags
*
* @return uint32_t
*
* @remarks flags may be null.
*/
static uint32_t parseToolTipStyle(CSTRING flags)
{
uint32_t style = WS_POPUP;
if ( flags == NULL )
{
style |= TTS_NOPREFIX | TTS_ALWAYSTIP;
goto done_out;
}
if ( StrStrI(flags, "ALWAYSTIP" ) != NULL ) style |= TTS_ALWAYSTIP;
if ( StrStrI(flags, "BALLOON" ) != NULL ) style |= TTS_BALLOON;
if ( StrStrI(flags, "NOANIMATE" ) != NULL ) style |= TTS_NOANIMATE;
if ( StrStrI(flags, "CLOSE" ) != NULL ) style |= TTS_CLOSE;
if ( StrStrI(flags, "NOFADE" ) != NULL ) style |= TTS_NOFADE;
if ( StrStrI(flags, "NOPREFIX" ) != NULL ) style |= TTS_NOPREFIX;
if ( StrStrI(flags, "USEVISUALSTYLE") != NULL ) style |= TTS_USEVISUALSTYLE;
done_out:
return style;
}
/**
* Parse TTF_X keywords into the corresponding value.
*
* @param flags Keyword string to parse
*
* @return The combined flag value
*/
static uint32_t keyword2ttfFlags(CSTRING flags)
{
uint32_t f = 0;
if ( StrStrI(flags, "ABSOLUTE" ) != NULL ) f |= TTF_ABSOLUTE;
if ( StrStrI(flags, "CENTERTIP" ) != NULL ) f |= TTF_CENTERTIP;
if ( StrStrI(flags, "IDISHWND" ) != NULL ) f |= TTF_IDISHWND;
if ( StrStrI(flags, "PARSELINKS" ) != NULL ) f |= TTF_PARSELINKS;
if ( StrStrI(flags, "RTLREADING" ) != NULL ) f |= TTF_RTLREADING;
if ( StrStrI(flags, "SUBCLASS" ) != NULL ) f |= TTF_SUBCLASS;
if ( StrStrI(flags, "TRACK" ) != NULL ) f |= TTF_TRACK;
if ( StrStrI(flags, "TRANSPARENT") != NULL ) f |= TTF_TRANSPARENT;
return f;
}
/**
* Convert TTF_* flags into a string of keywwords.
*
* @param flags
*
* @return RexxStringObject
*/
static RexxStringObject ttfFlags2keyword(RexxMethodContext *c, uint32_t flags)
{
char buf[512];
*buf = '\0';
if ( flags & TTF_ABSOLUTE ) strcat(buf, "ABSOLUTE ");
if ( flags & TTF_CENTERTIP ) strcat(buf, "CENTERTIP ");
if ( flags & TTF_IDISHWND ) strcat(buf, "IDISHWND ");
if ( flags & TTF_PARSELINKS ) strcat(buf, "PARSELINKS ");
if ( flags & TTF_RTLREADING ) strcat(buf, "RTLREADING ");
if ( flags & TTF_SUBCLASS ) strcat(buf, "SUBCLASS ");
if ( flags & TTF_TRACK ) strcat(buf, "TRACK ");
if ( flags & TTF_TRANSPARENT) strcat(buf, "TRANSPARENT ");
if ( *buf != '\0' )
{
*(buf + strlen(buf) - 1) = '\0';
}
return c->String(buf);
}
/**
* Generic function to fill in the hwnd and uID fields of the tool info struct.
* Called from several of the methods that deal with tool tips.
*
* If rxObj is a ToolInfo object, then we have all the information we need.
*
* When rxObj is not a ToolInfo object and uID is omitted, then rxObj must be a
* dialog control. The owner dialog of the dialog control is set as hwnd and
* the dialog control hwnd is set as the uID.
*
* Otherwise, rxObj could be a dialog or a dialog control and uID could be a
* dialog control or a numeric ID.
*
* @param c
* @param rxObj
* @param uID
* @param pTI
* @param hwndSupplier
* @param uIDSupplier
*
* @return True on success, false on failure.
*
* @remarks In some cases this function is invoked when instantiating a new
* ToolInfo object. In those cases, it is convenient to return the
* hwndSupplier and uIDSupplier, and rxObj will never be a Rexx
* ToolInfo object.
*
* When rxObj is already a Rexx ToolInfo, then the caller has no need
* of hwndSupplier or uIDSupplier and so we completely ignore
* hwndSupplier and uIDSupplier.
*/
static bool genericToolID(RexxMethodContext *c, RexxObjectPtr rxObj, RexxObjectPtr rxID, LPTOOLINFO pTI,
RexxObjectPtr *hwndSupplier, RexxObjectPtr *uIDSupplier)
{
bool success = false;
if ( c->IsOfType(rxObj, "TOOLINFO") )
{
LPTOOLINFO pToolInfo = (LPTOOLINFO)c->ObjectToCSelf(rxObj);
pTI->hwnd = pToolInfo->hwnd;
pTI->uId = pToolInfo->uId;
success = true;
goto done_out;
}
if ( rxID == NULLOBJECT )
{
if ( ! requiredClass(c->threadContext, rxObj, "DIALOGCONTROL", 1) )
{
goto done_out;
}
pCDialogControl pcdc = controlToCSelf(c, rxObj);
pTI->hwnd = pcdc->hDlg;
pTI->uId = (UINT_PTR)pcdc->hCtrl;
pTI->uFlags |= TTF_IDISHWND;
if ( hwndSupplier != NULL )
{
*hwndSupplier = pcdc->oDlg;
*uIDSupplier = pcdc->rexxSelf;
}
success = true;
goto done_out;
}
if ( c->IsOfType(rxObj, "PLAINBASEDIALOG") )
{
pCPlainBaseDialog pcpbd = dlgToCSelf(c, rxObj);
pTI->hwnd = pcpbd->hDlg;
if ( hwndSupplier != NULL )
{
*hwndSupplier = rxObj;
}
if ( c->IsOfType(rxID, "DIALOGCONTROL") )
{
pCDialogControl pcdc = controlToCSelf(c, rxID);
pTI->uId = (UINT_PTR)pcdc->hCtrl;
pTI->uFlags |= TTF_IDISHWND;
}
else
{
uint32_t id = oodResolveSymbolicID(c->threadContext, pcpbd->rexxSelf, rxID, -1, 2, false);
if ( id == OOD_ID_EXCEPTION )
{
goto done_out;
}
pTI->uId = (UINT_PTR)id;
}
if ( uIDSupplier != NULL )
{
*uIDSupplier = rxID;
}
success = true;
}
else if ( c->IsOfType(rxObj, "DIALOGCONTROL") )
{
pCDialogControl pcdc = controlToCSelf(c, rxObj);
uint32_t id = oodResolveSymbolicID(c->threadContext, pcdc->oDlg, rxID, -1, 2, false);
if ( id == OOD_ID_EXCEPTION )
{
goto done_out;
}
pTI->hwnd = pcdc->hCtrl;
pTI->uId = (UINT_PTR)id;
if ( hwndSupplier != NULL )
{
*hwndSupplier = rxObj;
*uIDSupplier = rxID;
}
success = true;
}
else
{
userDefinedMsgException(c, "Invalid tool ID specification");
}
done_out:
return success;
}
static uint32_t matchEvent2index(RexxMethodContext *c, CSTRING evtName, CSTRING *mthName, size_t i)
{
if ( StrCmpI(evtName, "RELAY") == 0 )
{
*mthName = "onRelay";
return RE_RELAYEVENT_IDX;
}
else if ( StrCmpI(evtName, "NEEDTEXT") == 0 )
{
*mthName = "onNeedText";
return RE_NEEDTEXT_IDX;
}
else if ( StrCmpI(evtName, "SHOW") == 0 )
{
*mthName = "onShow";
return RE_SHOW_IDX;
}
else if ( StrCmpI(evtName, "POP") == 0 )
{
*mthName = "onPop";
return RE_POP_IDX;
}
else if ( StrCmpI(evtName, "LINKCLICK") == 0 )
{
*mthName = "onLinkClick";
return RE_LINKCLICK_IDX;
}
return OOD_ID_EXCEPTION;
}
void freeRelayData(pSubClassData pSCData)
{
EnterCriticalSection(&crit_sec);
if ( pSCData )
{
pRelayEventData pred = (pRelayEventData)pSCData->pData;
if ( pred )
{
for ( size_t i = 0; i < RE_COUNT_RELAYEVENTS; i++ )
{
safeLocalFree((void *)pred->methods[i]);
}
LocalFree((void *)pred);
}
if ( pSCData->pcdc != NULL )
{
pSCData->pcdc->pRelayEvent = NULL;
}
LocalFree(pSCData);
}
LeaveCriticalSection(&crit_sec);
}
/**
* Checks that reply is not null and that the context does not have a pending
* condition.
*
* @param c
* @param pcpbd
* @param reply
* @param methodName
* @param clear
*
* @return True if reply is not null and there is no pending condition.
*
* @note If there is a condition, it is just printed, but the dialog is not
* ended. This results in a message to the screen, if the user is
* running from a console window, but the dialog keeps running.
*
* @note The call to checkForCondition() after noMsgReturnException() is what
* causes the condition to be printed to the screen.
*/
bool checkReplyIsGood(RexxThreadContext *c, pCPlainBaseDialog pcpbd, RexxObjectPtr reply, CSTRING methodName, bool clear)
{
bool haveCondition = checkForCondition(c, clear);
if ( ! haveCondition && reply == NULLOBJECT )
{
noMsgReturnException(c, methodName);
haveCondition = true;
checkForCondition(c, clear);
}
return ! haveCondition;
}
/**
* Checks that no condition has been raised, and that reply is either true or
* false. If not, an exception is raised.
*
* @param c
* @param pcpbd
* @param reply
* @param method
* @param clear
*
* @return TheTrueObj or TheFalseObj on success, NULLOBJECT on failure.
*
* @note The local reference to the reply object is always released in this
* function.
*/
RexxObjectPtr checkForBoolean(RexxThreadContext *c, pCPlainBaseDialog pcpbd, RexxObjectPtr reply,
CSTRING method, bool clear)
{
RexxObjectPtr result = NULLOBJECT;
if ( checkReplyIsGood(c, pcpbd, reply, method, false) )
{
result = convertToTrueOrFalse(c, reply);
if ( result == NULLOBJECT )
{
wrongReplyNotBooleanException(c, method, reply);
checkForCondition(c, false);
}
}
if ( reply != NULLOBJECT )
{
c->ReleaseLocalReference(reply);
}
return result;
}
LRESULT CALLBACK ManageAtypicalToolProc(HWND hwnd, uint32_t msg, WPARAM wParam, LPARAM lParam, UINT_PTR id, DWORD_PTR dwData)
{
pSubClassData pData = (pSubClassData)dwData;
pRelayEventData pred = (pRelayEventData)pData->pData;
RexxThreadContext *c = pData->pcpbd->dlgProcContext;
if ( (msg >= WM_MOUSEFIRST && msg <= WM_MOUSELAST) || msg == WM_NCMOUSEMOVE)
{
MSG _msg;
_msg.hwnd = hwnd;
_msg.message = msg;
_msg.wParam = wParam;
_msg.lParam = lParam;
if ( pred->doEvent[RE_RELAYEVENT_IDX] )
{
CSTRING method = pred->methods[RE_RELAYEVENT_IDX];
RexxObjectPtr rxPoint = rxNewPoint(c, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
RexxObjectPtr rxMMsg = mousemsg2name(c, msg);
RexxArrayObject args = c->ArrayOfFour(pred->rxToolTip, rxPoint, rxMMsg, pData->pcdc->rexxSelf);
RexxObjectPtr reply = c->SendMessage(pData->pcpbd->rexxSelf, method, args);
if ( msgReplyIsGood(c, pData->pcpbd, reply, method, false) )
{
c->ReleaseLocalReference(reply);
c->ReleaseLocalReference(rxPoint);
c->ReleaseLocalReference(rxMMsg);
c->ReleaseLocalReference(args);
}
}
SendMessage(pred->hToolTip, TTM_RELAYEVENT, 0, (LPARAM)&_msg);
}
if ( msg == WM_NOTIFY )
{
uint32_t code = ((NMHDR *)lParam)->code;
switch ( code )
{
case TTN_SHOW :
{
if ( pred->doEvent[RE_SHOW_IDX] )
{
CSTRING method = pred->methods[RE_SHOW_IDX];
LPARAM result = FALSE;
RexxArrayObject args = c->ArrayOfTwo(pred->rxToolTip, pData->pcdc->rexxSelf);
RexxObjectPtr reply = c->SendMessage(pData->pcpbd->rexxSelf, method, args);
reply = checkForBoolean(c, pData->pcpbd, reply, method, false);
if ( reply == NULLOBJECT )
{
c->ReleaseLocalReference(args);
SendMessage(pred->hToolTip, TTM_ACTIVATE, 0, 0);
endDialogPremature(pData->pcpbd, pData->pcpbd->hDlg, RexxConditionRaised);
return FALSE;
}
if ( reply == TheTrueObj )
{
result = TRUE;
}
c->ReleaseLocalReference(args);
return result;
}
}
break;
case TTN_GETDISPINFOW :
{
if ( pred->doEvent[RE_NEEDTEXT_IDX] )
{
LPNMTTDISPINFO nmtdi = (LPNMTTDISPINFO)lParam;
CSTRING method = pred->methods[RE_NEEDTEXT_IDX];
RexxDirectoryObject info = c->NewDirectory();
c->DirectoryPut(info, c->NullString(), "TEXT");
RexxObjectPtr userData = nmtdi->lParam == NULL ? TheNilObj : (RexxObjectPtr)nmtdi->lParam;
RexxStringObject flags = ttdiFlags2keyword(c, nmtdi->uFlags);
RexxArrayObject args = c->ArrayOfFour(pred->rxToolTip, pData->pcdc->rexxSelf, info, userData);
c->ArrayPut(args, flags, 5);
RexxObjectPtr reply = c->SendMessage(pData->pcpbd->rexxSelf, method, args);
reply = checkForBoolean(c, pData->pcpbd, reply, method, false);
if ( reply == NULLOBJECT )
{
c->ReleaseLocalReference(args);
SendMessage(pred->hToolTip, TTM_ACTIVATE, 0, 0);
endDialogPremature(pData->pcpbd, pData->pcpbd->hDlg, RexxConditionRaised);
return FALSE;
}
RexxObjectPtr _text = c->DirectoryAt(info, "TEXT");
CSTRING text = c->ObjectToStringValue(_text);
size_t len = strlen(text);
if ( len > MAX_TOOLINFO_TEXT_LENGTH )
{
c->ReleaseLocalReference(args);
SendMessage(pred->hToolTip, TTM_ACTIVATE, 0, 0);
stringTooLongException(c, 1, MAX_TOOLINFO_TEXT_LENGTH, len);
checkForCondition(c, false);
endDialogPremature(pData->pcpbd, pData->pcpbd->hDlg, RexxConditionRaised);
return FALSE;
}
if ( len > 0 )
{
pCDialogControl pcdc = controlToCSelf(c, pred->rxToolTip);
safeLocalFree(pcdc->toolTipEntry->wcharBuf);
pcdc->toolTipEntry->wcharBuf = ansi2unicode(text);
nmtdi->lpszText = (LPSTR)pcdc->toolTipEntry->wcharBuf;
}
if ( reply == TheTrueObj )
{
nmtdi->uFlags |= TTF_DI_SETITEM;
}
c->ReleaseLocalReference(reply);
c->ReleaseLocalReference(_text);
c->ReleaseLocalReference(flags);
c->ReleaseLocalReference(info);
c->ReleaseLocalReference(args);
return TRUE;
}
}
break;
default :
break;
}
}
if ( msg == WM_DESTROY )
{
SendMessage(pred->hToolTip, TTM_ACTIVATE, 0, 0);
//printf("Got WM_DESTROY for tool tip\n");
}
if ( msg == WM_NCDESTROY )
{
/* The window is being destroyed, remove the subclass, clean up memory.
* Note that with the current ooDialog architecture, this message,
* usually, never gets here. Freeing the subclass data struct has to be
* done in the dialog control uninit() for those cases. So, we just
* always do it from the uninit().
*/
BOOL success = RemoveWindowSubclass(hwnd, ManageAtypicalToolProc, id);
//printf("Got WM_NCDESTROY for tool tip success=%d\n", success);
return TRUE;
}
return DefSubclassProc(hwnd, msg, wParam, lParam);
}
/** PlainBaseDialog::newToolTip()
*
* Creates the Windows tool tip control and instantiates the Rexx ToolTip
* object.
*
* @param context
* @param rxID
* @param styleFlags
* @param pcpbd
*
* @return The Rexx ToolTip object on success, the .nil object on error.
*
* @notes ToolTip controls are somewhat different than other dialog controls in
* that they are not part of the dialog template, but rather independent
* windows owned by the dialog. Because of this, if the .nil object is
* returned on error, it is possible that the .systemErrorCode may be of
* help in determining the cause of the error.
*
* Sets the .systemErrorCode.
*
* @note All other dialog controls are instantiated through pbdlg_newControl
* which carries the legacy baggage of having to accomadate the
* deprecated CategoryDialog. The newer ToolTip control has a number of
* differences from other dialog controls, so it has its own 'new' method
* here. The newToolTip() method is still a PlainBaseDialog method, we
* just put it here to keep the ToolTip stuff together. We need to
* remember that the context is not the DialogControl context, it is the
* PlainBaseDialog context.
*
* Tool tip controls are different than most other Window controls in
* that they are actually popup windows owned by the dialog, rather than
* child windows of the dialog. Because of this we need to keep track of
* them by adding them to a table.
*
* Because they are popup windows, we can not find an existing tool tip
* through GetDlgItem(). So, we add each created tool tip to a table and
* look up an existing tool tip through its ID. The sole purpose of this
* is to allow the Rexx programmer to do: newToolTip(ID) at any point in
* her program and get back the same object, as is possible with other
* dialog controls.
*/
RexxMethod3(RexxObjectPtr, pbdlg_newToolTip, RexxObjectPtr, rxID, OPTIONAL_CSTRING, styleFlags, CSELF, pCSelf)
{
oodResetSysErrCode(context->threadContext);
RexxObjectPtr toolTip = TheNilObj;
CREATETOOLTIP ctt = {0};
if ( pCSelf == NULL )
{
baseClassInitializationException(context);
goto out;
}
pCPlainBaseDialog pcpbd = (pCPlainBaseDialog)pCSelf;
uint32_t id = oodResolveSymbolicID(context->threadContext, pcpbd->rexxSelf, rxID, -1, 1, true);
if ( id == OOD_ID_EXCEPTION )
{
goto out;
}
if ( pcpbd->ToolTipTab == NULL && ! lazyInitToolTipTable(context, pcpbd) )
{
goto out;
}
PTOOLTIPTABLEENTRY ptte = findToolTipForID(pcpbd, id);
if ( ptte != NULL )
{
toolTip = ptte->rexxSelf;
goto out;
}
RexxClassObject controlCls = oodClass4controlType(context, winToolTip);
if ( controlCls == NULLOBJECT )
{
goto out;
}
uint32_t style = parseToolTipStyle(styleFlags);
HWND hDlg = pcpbd->hDlg;
HWND hToolTip = NULL;
// Tool tips need to be created on the same thread as the dialog window procedure.
if ( isDlgThread(pcpbd) )
{
hToolTip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, style, CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT, hDlg, NULL, pcpbd->hInstance, NULL);
ctt.errRC = GetLastError();
}
else
{
ctt.hInstance = pcpbd->hInstance;
ctt.style = style;
hToolTip = (HWND)SendMessage(hDlg, WM_USER_CREATETOOLTIP, (WPARAM)&ctt, 0);
}
if ( hToolTip == NULL )
{
oodSetSysErrCode(context->threadContext, ctt.errRC);
goto out;
}
SetWindowPos(hToolTip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
PNEWCONTROLPARAMS pArgs = (PNEWCONTROLPARAMS)malloc(sizeof(NEWCONTROLPARAMS));
if ( pArgs == NULL )
{
outOfMemoryException(context->threadContext);
goto out;
}
pArgs->isCatDlg = false;
pArgs->controlType = winToolTip;
pArgs->hwnd = hToolTip;
pArgs->pcpbd = pcpbd;
pArgs->id = id;
RexxObjectPtr result = context->SendMessage1(controlCls, "NEW", context->NewPointer(pArgs));
free(pArgs);
if ( result != NULLOBJECT && result != TheNilObj )
{
if ( addToolTipToTable(context, pcpbd, result, hToolTip, id) )
{
toolTip = result;
}
}
out:
return toolTip;
}
/** ToolTip::activate()
*
* Activates or deactivates this tool tip.
*
* @param activate [optional] If true activates this tool tip, if false
* deactivates this tool tip. The default if omitted is true.
*
* @return 0, always.
*
*/
RexxMethod2(uint32_t, tt_activate, OPTIONAL_logical_t, activate, CSELF, pCSelf)
{
pCDialogControl pcdc = validateDCCSelf(context, pCSelf);
if ( pcdc == NULL )
{
return FALSE;
}
if ( argumentOmitted(1) )
{
activate = TRUE;
}
SendMessage(pcdc->hCtrl, TTM_ACTIVATE, activate, 0);
return 0;
}
/** ToolTip::addTool()
*
* Adds a tool to this tool tip.
*
* @param tool [required] The dialog control that defines the tool being
* added.
*
* @param text [optional] Text for the tool. If omitted, or the empty
* string, or the string: TEXTCALLBACK then the tool tip sends
* the NEEDTEXT notification and the program supplies the text.
*
* The maximum length of the text is 1023 characters, which
* includes any possible 0x0D0A sequences.
*
* @param flags [optional] Keywords for the TTF_* flags. If omitted flags are
* automatically set to TTF_IDISHWND | TTF_SUBCLASS. If not
* omitted, flags are set to whatever is specified. However,
* TTF_IDISHWND is always set. (Because uID is always set to
* hwnd of tool.
*
* @param userData [optional] A user data value to be associated with the
* tool. Note that the value is associated with the tool, not
* the tool tip.
*
* @return True on success, false on error.
*
* @notes The addTool() method is intended to be a convenient method for use
* in the most common case of adding a tool. The case where the tool
* is a simple dialog control. Use addToolRect() or addToolEx() to
* add a tool with characteristics that need to be more explicitly
* defined.
*
* Many methods require the indentity of the tool. A tool id is
* defined by a hwnd and a unique ID. For a tool added through
* addTool(), the identity will always be the hwnd of the owner
* dialog of the tool (the dialog control passed in as the tool arg)
* and the unique ID is always the hwnd of the tool (the dialog
* control passed in as the tool arg.)
*/
RexxMethod5(logical_t, tt_addTool, RexxObjectPtr, tool, OPTIONAL_CSTRING, text, OPTIONAL_CSTRING, _flags,
OPTIONAL_RexxObjectPtr, userData, CSELF, pCSelf)
{
pCDialogControl pcdc = validateDCCSelf(context, pCSelf);
if ( pcdc == NULL )
{
return FALSE;
}
if ( ! requiredClass(context->threadContext, tool, "DIALOGCONTROL", 1) )
{
return FALSE;
}
pCDialogControl pcdcTool = controlToCSelf(context, tool);
if ( argumentOmitted(2) )
{
text = "";
}
size_t l = strlen(text);
if ( l > MAX_TOOLINFO_TEXT_LENGTH )
{
stringTooLongException(context->threadContext, 2, MAX_TOOLINFO_TEXT_LENGTH, l);
return false;
}
if ( l == 0 || StrCmpI("TEXTCALLBACK", text) == 0 )
{
text = LPSTR_TEXTCALLBACK;
}
uint32_t flags = TTF_IDISHWND;
if ( argumentOmitted(3) )
{
flags |= TTF_SUBCLASS;
}
else
{
flags |= keyword2ttfFlags(_flags);
}
TOOLINFO ti = { sizeof(ti) };
ti.uFlags = flags;
ti.uId = (UINT_PTR)pcdcTool->hCtrl;
ti.hwnd = pcdc->hDlg;
ti.lpszText = (LPSTR)text;
ti.lParam = (LPARAM)(argumentExists(4) ? userData : 0);
return SendMessage(pcdc->hCtrl, TTM_ADDTOOL, 0, (LPARAM)&ti);
}
/** ToolTip::addToolEx()
*
* Adds the tool specified to this tool tip.
*
* @param toolInfo [required] A .ToolInfo object that defines the tool being
* added.
*
* @return True on success, false on error.
*
* @notes There are a number of different attributes that can be set when
* adding a tool to a tool tip. The addToolEx() method is designed to
* let the programmer specify any valid combination of attributes
* allowed by the operating system. To do this, it requires the
* specifier of the tool to be a .ToolInfo object. The programmer is
* responsible for setting the tool attriubtes as he wishes.
*
* For the simple case of adding a tool that is a dialog control, the
* addTool() is a more convenient method.
*/
RexxMethod2(logical_t, tt_addToolEx, RexxObjectPtr, toolInfo, CSELF, pCSelf)
{
pCDialogControl pcdc = validateDCCSelf(context, pCSelf);
if ( pcdc == NULL )
{
return FALSE;
}
if ( ! requiredClass(context->threadContext, toolInfo, "ToolInfo", 1) )
{
return FALSE;
}
LPTOOLINFO pTI = (LPTOOLINFO)context->ObjectToCSelf(toolInfo);
return SendMessage(pcdc->hCtrl, TTM_ADDTOOL, 0, (LPARAM)pTI);
}
/** ToolTip::addToolRect()
*
* Adds a tool that uses a rectangular area in the dialog as its trigger point.
*
* @param dlg The dialog the tool belongs to.
* @param id An ID that uniquely identifies the tool being added.
* @param rect The rectangle, relative to the client area of the dialog,
* that the tool tip shows for.
* @param text The text for the tool tip.
* @param flags The flags for the tool tip.
* @param userData User data to associate with the tool. Note that the user
* data is associated with the tool, not the tool tip.
*
*/
RexxMethod7(logical_t, tt_addToolRect, RexxObjectPtr, dlg, RexxObjectPtr, rxID, RexxObjectPtr, _rect,
OPTIONAL_CSTRING, text, OPTIONAL_CSTRING, _flags, OPTIONAL_RexxObjectPtr, userData, CSELF, pCSelf)
{
pCDialogControl pcdc = validateDCCSelf(context, pCSelf);
if ( pcdc == NULL )
{
return FALSE;
}
if ( ! requiredClass(context->threadContext, dlg, "PLAINBASEDIALOG", 1) )
{
return FALSE;
}
pCPlainBaseDialog pcpbd = dlgToCSelf(context, dlg);
uint32_t id = oodResolveSymbolicID(context->threadContext, pcpbd->rexxSelf, rxID, -1, 2, false);
if ( id == OOD_ID_EXCEPTION )
{
return FALSE;
}
PRECT pRect = rxGetRect(context, _rect, 3);
if ( pRect == NULL )
{
return FALSE;
}
if ( argumentOmitted(4) )
{
text = "";
}
size_t l = strlen(text);
if ( l > MAX_TOOLINFO_TEXT_LENGTH )
{
stringTooLongException(context->threadContext, 4, MAX_TOOLINFO_TEXT_LENGTH, l);
return FALSE;
}
if ( l == 0 || StrCmpI("TEXTCALLBACK", text) == 0 )
{
text = LPSTR_TEXTCALLBACK;
}
uint32_t flags = TTF_SUBCLASS;
if ( argumentExists(5) )
{
flags |= keyword2ttfFlags(_flags);
flags &= ~TTF_IDISHWND;
}
TOOLINFO ti = {sizeof(ti)};
ti.uFlags = flags;
ti.hwnd = pcdc->hDlg;
ti.uId = id;
ti.lpszText = (LPSTR)text;
CopyRect(&ti.rect, pRect);
if ( argumentExists(6) )
{
ti.lParam = (LPARAM)userData;
}
return SendMessage(pcdc->hCtrl, TTM_ADDTOOL, 0, (LPARAM)&ti);
}
/** ToolTip::adjustRect()
*
* Calculates a ToolTip control's text display rectangle from its window
* rectangle, or the ToolTip window rectangle needed to display a specified
* text display rectangle.
*
* @param rect [required] A Rectangle object used to specify the rectangle to
* adjust. On a successful return, the co-ordinates in the
* rectangle will be adjusted as specified byt the larger arguent.
*
* @param larger [optional] True or false to specify how the rectangle is
* adjusted. If omitted, the default is false.
*
* If true, rect is used to specify a text-display rectangle and
* it receives the corresponding window rectangle. The received
* rectangle is *larger* in this case. If false, rect is used
* to specify a window rectangle and it receives the
* corresponding text display rectangle.
*/
RexxMethod3(logical_t, tt_adjustRect, RexxObjectPtr, _rect, logical_t, larger, CSELF, pCSelf)
{
pCDialogControl pcdc = validateDCCSelf(context, pCSelf);
if ( pcdc == NULL )
{
return FALSE;
}
PRECT r = rxGetRect(context, _rect, 1);
if ( r == NULL )
{
return FALSE;
}
return SendMessage(pcdc->hCtrl, TTM_ADJUSTRECT, larger, (LPARAM)r);
}
/** ToolTip::delTool()
*
* Removes the specified tool from this tool tip.
*
* @param toolHwnd [required]
*
* @param toolID [optional]
*
* @return Returns 0 always.
*
* @notes toolHwnd and toolId are the Rexx object combination that uniquely
* specifies a tool to this tool tip.
*
*/
RexxMethod3(uint32_t, tt_delTool, RexxObjectPtr, toolID, OPTIONAL_RexxObjectPtr, uID, CSELF, pCSelf)
{
TOOLINFO ti = { sizeof(ti) };
pCDialogControl pcdc = validateDCCSelf(context, pCSelf);
if ( pcdc == NULL )
{
goto done_out;
}
if ( ! genericToolID(context, toolID, uID, &ti, NULL, NULL) )
{
goto done_out;
}
SendMessage(pcdc->hCtrl, TTM_DELTOOL, 0, (LPARAM)&ti);
done_out:
return 0;
}
/** ToolTip::enumTools()
*
* Retrieves a .ToolInfo object for the tool at the specified index.
*
* @param index [optional] Index of the tool to retrieve. MSDN does not
* specify, but it seems to be zero-based indexes. We will use
* 1-based indexes. If omitted, defaults to index 1.
*
* @return The tool at the specified index, as a .ToolInfo object, or .nil if
* no tool exists at the index.
*/
RexxMethod2(RexxObjectPtr, tt_enumTools, OPTIONAL_uint32_t, index, CSELF, pCSelf)
{
RexxObjectPtr result = TheNilObj;
pCDialogControl pcdc = validateDCCSelf(context, pCSelf);
if ( pcdc == NULL )
{
goto done_out;
}
if ( argumentExists(1) )
{
if ( index < 1 )
{
wrongRangeException(context, 1, 1, UINT32_MAX, index);
goto done_out;
}
index--;
}
else
{
index = 1;
}
LPTOOLINFO pTI;
RexxBufferObject tiBuf = rexxBufferForToolInfo(context, &pTI, true);
if ( tiBuf == NULLOBJECT )
{
goto done_out;
}
if ( SendMessage(pcdc->hCtrl, TTM_ENUMTOOLS, index, (LPARAM)pTI) )
{
result = ti2rexxToolInfo(context, tiBuf, pTI, true);
}
if ( result == TheNilObj )
{
safeLocalFree(pTI->lpszText);
}
done_out:
return result;
}
/** ToolTip::getBubbleSize()
*
* Returns the width and height, as a .Size object, of a tool tip control.
*
* @param toolHwnd [required]
*
* @param toolID [optional]
*
* @returns A .Size object specifying the width and height of this tool tip
* control.
*
* @notes toolHwnd and toolId are the Rexx object combination that uniquely
* specifies a tool to this tool tip.
*/
RexxMethod3(RexxObjectPtr, tt_getBubbleSize, RexxObjectPtr, toolHwnd, OPTIONAL_RexxObjectPtr, toolID, CSELF, pCSelf)
{
RexxObjectPtr size = TheNilObj;
TOOLINFO ti = { sizeof(ti) };
pCDialogControl pcdc = validateDCCSelf(context, pCSelf);
if ( pcdc == NULL )
{
goto done_out;
}
LPTOOLINFO pTI = &ti;
if ( context->IsOfType(toolHwnd, "TOOLINFO") )
{
pTI = (LPTOOLINFO)context->ObjectToCSelf(toolHwnd);
}
else if ( ! genericToolID(context, toolHwnd, toolID, pTI, NULL, NULL) )
{
goto done_out;
}
LPARAM lResult = SendMessage(pcdc->hCtrl, TTM_GETBUBBLESIZE, 0, (LPARAM)pTI);
size = rxNewSize(context, LOWORD(lResult), HIWORD(lResult));
done_out:
return size;
}
/** ToolTip::getCurrentTool()
*
* Retrieves a .ToolInfo object whose attributes represent the current tool in
* this tool tip.
*
* @return Returns the current tool as a .ToolInfo object, if one exists, or
* the .nil object if there is not a current tool.
*
* @remarks We use getToolIdentifiers() to try and obtain the Rexx objects
* that would represent TOOLINFO.hwnd and TOOLINFO.uID. This is not
* foolproof, so if the function fails, it sets hwndSupplier and
* idSupplier to the .nil objects.
*/
RexxMethod1(RexxObjectPtr, tt_getCurrentTool, CSELF, pCSelf)
{
RexxObjectPtr result = TheNilObj;
pCDialogControl pcdc = validateDCCSelf(context, pCSelf);
if ( pcdc == NULL )
{
goto done_out;
}
LPTOOLINFO pTI;
RexxBufferObject tiBuf = rexxBufferForToolInfo(context, &pTI, true);
if ( tiBuf == NULLOBJECT )
{
goto done_out;
}
if ( SendMessage(pcdc->hCtrl, TTM_GETCURRENTTOOL, 0, (LPARAM)pTI) )
{
result = ti2rexxToolInfo(context, tiBuf, pTI, true);
}
if ( result == TheNilObj )
{
safeLocalFree(pTI->lpszText);
}
done_out:
return result;
}
/** ToolTip::getDelayTime()
*
* Retrieves one of the 3 delay times currently set for this tool tip.
*
* @param [optional] Keyword indicating which of the 3 possible delay times is
* sought. If omitted, defaults to AUTOPOP. Valid keywords are:
* AUTOPOP, INITIAL, RESHOW, case is not significant.
*
* @return The delay time for the specified event in milliseconds.
*
* @notes A tool tip sets timers for 3 diffent events. They are:
*
* AUTOPOP - The amount of time the ToolTip window remains visible if
* the pointer is stationary within a tool's bounding rectangle.
*
* INITIAL - The amount of time the pointer must remain stationary
* within a tool's bounding rectangle before the ToolTip window
* appears.
*
* RESHOW - The amount of time it takes for subsequent ToolTip windows
* to appear as the pointer moves from one tool to another.
*
* Raises a syntax condition if an incorrect keyword is used.
*/
RexxMethod2(int32_t, tt_getDelayTime, OPTIONAL_CSTRING, type, CSELF, pCSelf)
{
pCDialogControl pcdc = validateDCCSelf(context, pCSelf);
if ( pcdc == NULL )
{
return FALSE;
}
uint32_t flag = TTDT_AUTOPOP;
if ( argumentExists(1) )
{
if ( StrCmpI(type, "AUTOPOP") == 0 ) flag = TTDT_AUTOPOP;
else if ( StrCmpI(type, "INITIAL") == 0 ) flag = TTDT_INITIAL;
else if ( StrCmpI(type, "RESHOW" ) == 0 ) flag = TTDT_RESHOW;
else
{
wrongArgValueException(context->threadContext, 1, "AUTOPOP, INITIAL, or RESHOW", type);
return 0;
}
}
return (int32_t)SendMessage(pcdc->hCtrl, TTM_GETDELAYTIME, flag, 0);
}
/** ToolTip::getMargin()
*
* Returns a rectangle that describes the margins of the tool tip.
*
* @notes The attributes of the returned rectangle do not define a bounding
* rectangle. For the purpose of this method, the structure members are
* interpreted as follows:
*
* top - Distance between top border and top of ToolTip text, in
* pixels.
*
* left - Distance between left border and left end of ToolTip
* text, in pixels.
*
* bottom - Distance between bottom border and bottom of ToolTip text,
* in pixels.
*
* right - Distance between right border and right end of ToolTip
* text, in pixels.
*
*/
RexxMethod1(RexxObjectPtr, tt_getMargin, CSELF, pCSelf)
{
pCDialogControl pcdc = validateDCCSelf(context, pCSelf);
if ( pcdc == NULL )
{
return FALSE;
}
RECT r;
SendMessage(pcdc->hCtrl, TTM_GETMARGIN, 0, (LPARAM)&r);
return rxNewRect(context, &r);
}
/** ToolTip::getMaxTipWidth()
*
* Retrieves the maximum width for a ToolTip window.
*
* @return Returns a whole number value that represents the maximum ToolTip
* width, in pixels. If no maximum width was set previously, the
* method returns -1.
*
* @note The maximum ToolTip width value does not indicate a ToolTip window's
* actual width. Rather, if a ToolTip string exceeds the maximum width,
* the control breaks the text into multiple lines, using spaces or
* newline characters to determine line breaks. If the text cannot be
* segmented into multiple lines, it will be displayed on a single
* line. The length of this line may exceed the maximum ToolTip width.
*/
RexxMethod1(int32_t, tt_getMaxTipWidth, CSELF, pCSelf)
{
pCDialogControl pcdc = validateDCCSelf(context, pCSelf);
if ( pcdc == NULL )
{
return FALSE;
}
return (int32_t)SendMessage(pcdc->hCtrl, TTM_GETMAXTIPWIDTH, 0, 0);
}
/** ToolTip::getText()
*
* Retrieves the text information this ToolTip control maintains about the
* specified tool.
*
* @param toolHwnd [required]
*
* @param toolID [optional]
*
* @return The text string for the specified tool
*
* @notes toolHwnd and toolId are the Rexx object combination that uniquely
* specifies a tool to this tool tip.
*
* @remarks It appears that even if the TOOLINF.lpszText for a tool is set to
* LPSTR_TEXTCALLBACK, the TTM_GETTEXT message will not set
* TOOLINFO.lpszText to that value. It would seem we could rely on
* an empty string, and not need worry aobut getting
* LPSTR_TEXTCALLBACK. Still, we leave the check in, it seems little
* cost to ensure the interpreter does not blow up for someone.
*/
RexxMethod3(RexxObjectPtr, tt_getText, RexxObjectPtr, toolID, OPTIONAL_RexxObjectPtr, uID, CSELF, pCSelf)
{
RexxObjectPtr result = context->NullString();
TOOLINFO ti = { sizeof(ti) };
pCDialogControl pcdc = validateDCCSelf(context, pCSelf);
if ( pcdc == NULL )
{
goto done_out;
}
if ( ! genericToolID(context, toolID, uID, &ti, NULL, NULL) )
{
goto done_out;
}
ti.lpszText = (LPSTR)LocalAlloc(LPTR, MAX_TOOLINFO_TEXT_LENGTH + 1);
if ( ti.lpszText == NULL )
{
outOfMemoryException(context->threadContext);
goto done_out;
}
if ( _isAtLeastVista() )
{
SendMessage(pcdc->hCtrl, TTM_GETTEXT, MAX_TOOLINFO_TEXT_LENGTH + 1, (LPARAM)&ti);
}
else
{
SendMessage(pcdc->hCtrl, TTM_GETTEXT, 0, (LPARAM)&ti);
}
if ( ti.lpszText == LPSTR_TEXTCALLBACK )
{
result = context->String("TextCallBack");
}
else
{
result = context->String(ti.lpszText);
}
LocalFree(ti.lpszText);
done_out:
return result;
}
/** ToolTip::getTipBkColor()
*
* Retrieves the background color for this ToolTip window.
*
* @return A COLORREF value that represents the background color.
*/
RexxMethod1(uint32_t, tt_getTipBkColor, CSELF, pCSelf)
{
pCDialogControl pcdc = validateDCCSelf(context, pCSelf);
if ( pcdc == NULL )
{
return 0;
}
return (uint32_t)SendMessage(pcdc->hCtrl, TTM_GETTIPBKCOLOR, 0, 0);
}
/** ToolTip::getTipTextColor()
*
* Retrieves the text color fot this ToolTip window.
*
* @return A COLORREF value that represents the text color.
*/
RexxMethod1(uint32_t, tt_getTipTextColor, CSELF, pCSelf)
{
pCDialogControl pcdc = validateDCCSelf(context, pCSelf);
if ( pcdc == NULL )
{
return 0;
}
return (uint32_t)SendMessage(pcdc->hCtrl, TTM_GETTIPTEXTCOLOR, 0, 0);
}
/** ToolTip::getTitle()
*
* Retrieve information concerning the title and icon of this ToolTip control.
*
* @return A directory object whose indexes contain the title and icon
* information for this ToolTip. Indexes are:
*
* TITLE - The title text.
*
* ICON - The image icon, or the keyword if the icon is a system
* icon.
*
* ISKEYWORD - True if the value at index ICON is a keyword, false if
* it is an icon image
*
* @note The underlying Windows API for getTitle appears to be idiosyncratic.
*
* In testing, when setting the icon to an actual icon image, getting
* the icon always returns the INFOLARGE keyword, rather than the icon
* image. In addition, when setting the icon to any of the LARGE keyword
* values, getting the icon always returns the non-large keyword. This
* anomly is mentioned is several places on the web. The following
* shows this behaviour:
*
* setTitle icon value -> hIcon getTitle -> INFOLARGE
*
* setTitle icon value -> INFOLARGE getTitle -> INFO
*
* setTitle icon value -> WARNIGNLARGE getTitle -> WARNING
*
* setTitle icon value -> ERRORLARGE getTitle -> ERROR
*/
RexxMethod1(RexxObjectPtr, tt_getTitle, CSELF, pCSelf)
{
pCDialogControl pcdc = validateDCCSelf(context, pCSelf);
if ( pcdc == NULL )
{
return 0;
}
WCHAR buf[TT_CCH_TOOLTITLE_BUF] = { 0 };
TTGETTITLE tt = { 0 };
tt.dwSize = sizeof(TTGETTITLE);
tt.pszTitle = buf;
tt.cch = TT_CCH_TOOLTITLE_BUF;
SendMessage(pcdc->hCtrl, TTM_GETTITLE, 0, (LPARAM)&tt);
RexxObjectPtr rxIcon;
RexxObjectPtr isKeyword = TheTrueObj;
if ( tt.uTitleBitmap > TT_MAX_ICON_KEYWORD )
{
SIZE s = {16, 16};
rxIcon = rxNewValidImage(context, (HWND)tt.uTitleBitmap, IMAGE_ICON, &s, 0, false);
if ( rxIcon == NULLOBJECT )
{
rxIcon = TheNilObj;
}
isKeyword = TheFalseObj;
}
else
{
CSTRING str = "";
if ( tt.uTitleBitmap == TTI_NONE ) str = "NONE";
else if ( tt.uTitleBitmap == TTI_ERROR ) str = "ERROR";
else if ( tt.uTitleBitmap == TTI_ERROR_LARGE ) str = "ERRORLARGE";
else if ( tt.uTitleBitmap == TTI_INFO ) str = "INFO";
else if ( tt.uTitleBitmap == TTI_INFO_LARGE ) str = "INFOLARGE";
else if ( tt.uTitleBitmap == TTI_WARNING ) str = "WARNING";
else if ( tt.uTitleBitmap == TTI_WARNING_LARGE ) str = "WARNINGLARGE";
rxIcon = context->String(str);
}
RexxDirectoryObject d = context->NewDirectory();
context->DirectoryPut(d, unicode2string(context, buf), "TITLE");
context->DirectoryPut(d, rxIcon, "ICON");
context->DirectoryPut(d, isKeyword, "ISKEYWORD");
return d;
}
/** ToolTip::getToolCount()
*
* Retrieves the number of tools this tool tip contains.
*
* @return The number of tools this tool tip contains.
*/
RexxMethod1(uint32_t, tt_getToolCount, CSELF, pCSelf)
{
pCDialogControl pcdc = validateDCCSelf(context, pCSelf);
if ( pcdc == NULL )
{
return 0;
}
return (uint32_t)SendMessage(pcdc->hCtrl, TTM_GETTOOLCOUNT, 0, 0);
}
/** ToolTip::getToolInfo()
*
* Retrieves the information, as a .ToolInfo object, that this tool tip control
* maintains about the specified tool.
*
* @param toolHwnd [required]
*
* @param toolID [optional]
*
* @return A .ToolInfo object whose attributes reflect the information that
* this tool tip maintains about the specified tool. On error, .nil
* is returned.
*
* @notes toolHwnd and toolId are the Rexx object combination that uniquely
* specifies a tool to this tool tip.
*/
RexxMethod3(RexxObjectPtr, tt_getToolInfo, RexxObjectPtr, toolHwnd, OPTIONAL_RexxObjectPtr, toolID, CSELF, pCSelf)
{
RexxObjectPtr result = TheNilObj;
pCDialogControl pcdc = validateDCCSelf(context, pCSelf);
if ( pcdc == NULL )
{
goto done_out;
}
LPTOOLINFO pTI;
RexxBufferObject tiBuf = rexxBufferForToolInfo(context, &pTI, true);
if ( tiBuf == NULLOBJECT )
{
goto done_out;
}
if ( ! genericToolID(context, toolHwnd, toolID, pTI, NULL, NULL) )
{
goto done_out;
}
if ( SendMessage(pcdc->hCtrl, TTM_GETTOOLINFO, 0, (LPARAM)pTI) )
{
result = ti2rexxToolInfo(context, tiBuf, pTI, true);
}
if ( result == TheNilObj )
{
safeLocalFree(pTI->lpszText);
}
done_out:
return result;
}
/** ToolTip::hasCurrentTool()
*
* Tests if this tool tip has a current tool.
*
* @return True if there is a current tool, false if there is not.
*
* @notes In essence, this convenience method tests if getCurrentTool()
* will return a .ToolInfo object or the .nil object.
*/
RexxMethod1(logical_t, tt_hasCurrentTool, CSELF, pCSelf)
{
pCDialogControl pcdc = validateDCCSelf(context, pCSelf);
if ( pcdc == NULL )
{
return 0;
}
return SendMessage(pcdc->hCtrl, TTM_GETCURRENTTOOL, 0, NULL);
}
/** ToolTip::hitTest()
*
* Tests a point to determine whether it is within the bounding rectangle of a
* tool within the window specified and, if it is, retrieves information about
* the tool.
*
* @param toolInfo [required in / out] A .ToolInfo object whose rexxHwnd
* attribute specifies which tool window to test.
*
* If the point tested is within a tool of the tool window,
* the retrieved tool information is returned in this
* object. The tool info object should be instantiated
* using the ToolInfo::forHitTest() class method.
*
* @param pointArgs [required] The position to test, in client coordinates
* of the window specified in the toolInfo argument.
*
* The position can be specified in these formats:
*
* Form 1: A .Point object.
* Form 2: x, y
*
* @return True if the point being tested is within the window specified,
* otherwise false.
*
* @notes
*/
RexxMethod3(logical_t, tt_hitTest, RexxObjectPtr, toolInfo, ARGLIST, args, CSELF, pCSelf)
{
TTHITTESTINFO hi = { 0 };
pCDialogControl pcdc = validateDCCSelf(context, pCSelf);
if ( pcdc == NULL )
{
goto err_out;
}
if ( ! context->IsOfType(toolInfo, "TOOLINFO") )
{
wrongClassException(context->threadContext, 1, "ToolInfo", toolInfo);
goto err_out;
}
size_t arraySize;
size_t argsUsed;
POINT point;
if ( ! getPointFromArglist(context, args, &point, 2, 3, &arraySize, &argsUsed) )
{
goto err_out;
}
LPTOOLINFO pTI = (LPTOOLINFO)context->ObjectToCSelf(toolInfo);
hi.ti.lpszText = (LPSTR)LocalAlloc(LPTR, MAX_TOOLINFO_TEXT_LENGTH + 1);
if ( hi.ti.lpszText == NULL )
{
outOfMemoryException(context->threadContext);
goto err_out;
}
hi.ti.cbSize = sizeof(TOOLINFO);
hi.pt.x = point.x;
hi.pt.y = point.y;
hi.hwnd = pTI->hwnd;
memset(pTI, 0, sizeof(TOOLINFO));
pTI->cbSize = sizeof(TOOLINFO);
if ( SendMessage(pcdc->hCtrl, TTM_HITTEST, 0, (LPARAM)(LPHITTESTINFO)&hi) )
{
memcpy(pTI, &hi.ti, sizeof(TOOLINFO));
RexxObjectPtr hwndSupplier;
RexxObjectPtr uIDSupplier;
getToolIdentifiers(context, pTI, &hwndSupplier, &uIDSupplier);
context->SendMessage2(toolInfo, "HITTESTHELPER", hwndSupplier, uIDSupplier);
return TRUE;
}
else
{
LocalFree(hi.ti.lpszText);
}
err_out:
return FALSE;
}
/** ToolTip::manageAtypicalTool
*
* Initiates the management of a tool tip tool that is a dialog control.
*
* @param toolObject [required] The tool dialog control to be managed
*
* @param events [optional] The tool tip events that should invoke a
* method in the Rexx dialog. The array can not be sparse.
* Each index in the array should contain the keyword for a
* tool tip event. If an event keyword is present at an
* index, then that event is connected to a method in the
* Rexx dialog. By default the event is connect to these
* methods:
*
* RELAY -> onRelay
* NEEDTEXT -> onNeedText
* SHOW -> onShow
* POP -> onPop
* LINKCLICK -> onLinkClick
*
* If the default method name is not suitable, for whatever
* reason, then the programmer can supply her own name in
* the methods array. The alternative method name must be
* at the same position in the methods array as the
* keywords postion in the events array.
*
* E.g., if at the keyword SHOW is present at index 2 in
* the events array and the programmer wants to over-ride
* the default method name of onNeedText, the this can be
* done by putting the alternative method name at index 2
* in the methods array. There is no requirement to put
* any name at index 1.
*
* @param methods [optional] Alternative method names to use for the
* matching event in the events arguemnt. This array can
* be sparse. For each event in the events array, if the
* same index in the methods array has a value, then that
* value is used as the method to be invoked for that
* event.
*
* @notes Requires common control library 6.0. Raises a syntax condition if
* incorrect usage is detected.
*
* The management of the tool *always* relays the mouse events to the
* the tool tip control. If the optional events and methods arguments
* are omitted, then the only thing done is the relay event.
* @remarks
*/
RexxMethod4(logical_t, tt_manageAtypicalTool, RexxObjectPtr, toolObject, OPTIONAL_RexxArrayObject, events,
OPTIONAL_RexxArrayObject, methods, CSELF, pCSelf)
{
pCDialogControl subClassCtrl = NULL;
pCDialogControl pcdc = validateDCCSelf(context, pCSelf);
if ( pcdc == NULL )
{
goto err_out;
}
if ( ! requiredComCtl32Version(context, "manageAtypicalTool", COMCTL32_6_0) )
{
goto err_out;
}
if ( context->IsOfType(toolObject, "PLAINBASEDIALOG") )
{
userDefinedMsgException(context->threadContext, 1, "manageAtypicalTool() can not be used on dialog tools");
goto err_out;
}
else if ( context->IsOfType(toolObject, "DIALOGCONTROL") )
{
subClassCtrl = controlToCSelf(context, toolObject);
}
else
{
wrongClassListException(context->threadContext, 1, "PlainBaseDialog or DialogControl", toolObject);
goto err_out;
}
if ( subClassCtrl->pRelayEvent != NULL )
{
char buf[256];
_snprintf(buf, sizeof(buf), "the windows %s tool is already managed",
controlType2winName(subClassCtrl->controlType));
userDefinedMsgException(context, 1, buf);
goto err_out;
}
pSubClassData pSCData = (pSubClassData)LocalAlloc(LPTR, sizeof(SubClassData));
if ( pSCData == NULL )
{
outOfMemoryException(context->threadContext);
goto err_out;
}
pSCData->pcpbd = subClassCtrl->pcpbd;
pSCData->pcdc = subClassCtrl;
pSCData->hCtrl = subClassCtrl->hCtrl;
pSCData->id = subClassCtrl->id;
pcdc->pRelayEvent = pSCData;
pRelayEventData pred = (pRelayEventData)LocalAlloc(LPTR, sizeof(RelayEventData));
if ( pred == NULL )
{
freeRelayData(pSCData);
outOfMemoryException(context->threadContext);
goto err_out;
}
pSCData->pData = pred;
pSCData->pfn = freeRelayData;
pred->hToolTip = pcdc->hCtrl;
pred->rxToolTip = pcdc->rexxSelf;
if ( argumentExists(2) )
{
size_t count = context->ArrayItems(events);
for ( size_t i = 1; i <= count; i++ )
{
RexxObjectPtr eventName = context->ArrayAt(events, i);
if ( eventName == NULLOBJECT )
{
sparseArrayException(context->threadContext, 2, i);
goto err_out;
}
CSTRING mthName;
CSTRING evtName = context->ObjectToStringValue(eventName);
uint32_t idx = matchEvent2index(context, evtName, &mthName, i);
if ( idx == OOD_ID_EXCEPTION )
{
goto err_out;
}
if ( argumentExists(3) )
{
RexxObjectPtr rxName = context->ArrayAt(methods, i);
if ( rxName != NULLOBJECT )
{
mthName = context->ObjectToStringValue(rxName);
}
}
pred->doEvent[idx] = true;
pred->methods[idx] = (char *)LocalAlloc(LPTR, strlen(mthName) + 1);
if ( pred->methods[idx] == NULL )
{
outOfMemoryException(context->threadContext);
goto err_out;
}
strcpy(pred->methods[idx], mthName);
}
}
BOOL success;
if ( isDlgThread(pcdc->pcpbd) )
{
success = SetWindowSubclass(pcdc->hCtrl, ManageAtypicalToolProc, pcdc->id, (DWORD_PTR)pSCData);
}
else
{
success = (BOOL)SendMessage(pcdc->pcpbd->hDlg, WM_USER_SUBCLASS, (WPARAM)ManageAtypicalToolProc, (LPARAM)pSCData);
}
if ( ! success )
{
systemServiceExceptionCode(context->threadContext, API_FAILED_MSG, "SetWindowSubclass");
goto err_out;
}
return TRUE;
err_out:
freeRelayData(pSCData);
return FALSE;
}
/** ToolTip::newToolRect()
*
* Sets a new bounding rectangle for a tool.
*
* @param toolHwnd [required]
*
* @param toolID [optional]
*
* @param rect [required] The new bounding rectangle for the tool.
*
* @return Returns 0 always.
*
* @notes toolHwnd and toolId are the Rexx object combination that uniquely
* specifies a tool to this tool tip.
*
*/
RexxMethod4(uint32_t, tt_newToolRect, RexxObjectPtr, toolID, OPTIONAL_RexxObjectPtr, uID, RexxObjectPtr, r, CSELF, pCSelf)
{
TOOLINFO ti = { sizeof(ti) };
pCDialogControl pcdc = validateDCCSelf(context, pCSelf);
if ( pcdc == NULL )
{
goto done_out;
}
if ( ! genericToolID(context, toolID, uID, &ti, NULL, NULL) )
{
goto done_out;
}
PRECT pRect = rxGetRect(context, r, 3);
if ( pRect == NULL )
{
goto done_out;
}
CopyRect(&ti.rect, pRect);
SendMessage(pcdc->hCtrl, TTM_NEWTOOLRECT, 0, (LPARAM)&ti);
done_out:
return 0;
}
/** ToolTip::pop()
*
* Removes a displayed ToolTip window from view.
*
* @return 0, always.
*/
RexxMethod1(uint32_t, tt_pop, CSELF, pCSelf)
{
pCDialogControl pcdc = validateDCCSelf(context, pCSelf);
if ( pcdc == NULL )
{
return 0;
}
SendMessage(pcdc->hCtrl, TTM_POP, 0, 0);
return 0;
}
/** ToolTip::popUp()
*
* Causes this ToolTip to display at the coordinates of the last mouse message.
*
* @return 0, always.
*/
RexxMethod1(uint32_t, tt_popUp, CSELF, pCSelf)
{
pCDialogControl pcdc = validateDCCSelf(context, pCSelf);
if ( pcdc == NULL )
{
return 0;
}
SendMessage(pcdc->hCtrl, TTM_POPUP, 0, 0);
return 0;
}
/** ToolTip::setMaxTipWidth()
*
*
*/
RexxMethod2(int32_t, tt_setMaxTipWidth, int32_t, max, CSELF, pCSelf)
{
pCDialogControl pcdc = validateDCCSelf(context, pCSelf);
if ( pcdc == NULL )
{
return 0;
}
return (int32_t)SendMessage(pcdc->hCtrl, TTM_SETMAXTIPWIDTH, 0, max);
}
/** ToolTip::setTitle()
*
* Adds a title string and optionally a standard icon to this ToolTip.
*
* @param title [required] The title for this ToolTip.
*
* @param icon [optional] Either an icon .Image object, or one of the
* following keywords to use a system icon: NONE ERROR ERRORLARGE INFO
* INFOLARGE WARNING WARNINGLARGE. If this argument is omitted it
* defaults to NONE.
*
* @return True on success, othewise false.
*/
RexxMethod3(logical_t, tt_setTitle, CSTRING, title, OPTIONAL_RexxObjectPtr, _icon, CSELF, pCSelf)
{
pCDialogControl pcdc = validateDCCSelf(context, pCSelf);
if ( pcdc == NULL )
{
goto err_out;
}
size_t l = strlen(title);
if ( l > MAX_TOOLTITLE_TEXT_LENGTH )
{
stringTooLongException(context->threadContext, 1, MAX_TOOLTITLE_TEXT_LENGTH, l);
goto err_out;
}
uintptr_t icon = TTI_NONE;
if ( argumentExists(2) )
{
if ( context->IsOfType(_icon, "IMAGE") )
{
POODIMAGE oi = rxGetImageIcon(context, _icon, 2);
if ( oi == NULL )
{
goto err_out;
}
icon = (uintptr_t)oi->hImage;
}
else
{
CSTRING keyWord = context->ObjectToStringValue(_icon);
if ( StrCmpI(keyWord, "NONE" ) == 0 ) icon = TTI_NONE;
else if ( StrCmpI(keyWord, "ERROR" ) == 0 ) icon = TTI_ERROR;
else if ( StrCmpI(keyWord, "ERRORLARGE" ) == 0 ) icon = TTI_ERROR_LARGE;
else if ( StrCmpI(keyWord, "INFO" ) == 0 ) icon = TTI_INFO;
else if ( StrCmpI(keyWord, "INFOLARGE" ) == 0 ) icon = TTI_INFO_LARGE;
else if ( StrCmpI(keyWord, "WARNING" ) == 0 ) icon = TTI_WARNING;
else if ( StrCmpI(keyWord, "WARNINGLARGE" ) == 0 ) icon = TTI_WARNING_LARGE;
else
{
wrongArgValueException(context->threadContext, 2, TT_VALID_ICON_VALUES, _icon);
goto err_out;
}
}
}
return SendMessage(pcdc->hCtrl, TTM_SETTITLE, (WPARAM)icon, (LPARAM)title);
err_out:
return FALSE;
}
/** ToolTip::trackActivate()
*
*
*/
RexxMethod4(uint32_t, tt_trackActivate, RexxObjectPtr, toolID, OPTIONAL_RexxObjectPtr, uID,
OPTIONAL_logical_t, activate, CSELF, pCSelf)
{
TOOLINFO ti = { sizeof(ti) };
pCDialogControl pcdc = validateDCCSelf(context, pCSelf);
if ( pcdc == NULL )
{
goto done_out;
}
if ( ! genericToolID(context, toolID, uID, &ti, NULL, NULL) )
{
goto done_out;
}
if ( argumentOmitted(3) )
{
activate = TRUE;
}
SendMessage(pcdc->hCtrl, TTM_TRACKACTIVATE, activate, (LPARAM)&ti);
done_out:
return 0;
}
/** ToolTip::trackPosition()
*
* Sets the position of a tracking ToolTip.
*
* @param coordinates The position (x, y) to set.
*
* Form 1: A .Point object.
* Form 2: x, y
*
* @return 0, always.
*
*/
RexxMethod2(uint32_t, tt_trackPosition, ARGLIST, args, CSELF, pCSelf)
{
pCDialogControl pcdc = validateDCCSelf(context, pCSelf);
if ( pcdc == NULL )
{
return 0;;
}
size_t countArgs;
size_t argsUsed;
POINT point;
if ( ! getPointFromArglist(context, args, &point, 1, 2, &countArgs, &argsUsed) )
{
return 0;
}
if ( countArgs > argsUsed )
{
tooManyArgsException(context->threadContext, argsUsed + 1);
return 0;
}
SendMessage(pcdc->hCtrl, TTM_TRACKPOSITION, 0, (LPARAM)MAKELONG(point.x, point.y));
return 0;
}
/**
* Methods for the .ToolInfo class.
*/
#define TOOLINFO_CLASS "ToolInfo"
/**
* Allocates a buffer for the tool info struct and copies the specified text
* into it.
*
* @param c
* @param pTI
* @param text
* @param argPos
*
* @return bool
*/
static bool setToolInfoText(RexxMethodContext *c, LPTOOLINFO pTI, CSTRING text, size_t argPos)
{
size_t l = strlen(text);
if ( l > MAX_TOOLINFO_TEXT_LENGTH )
{
stringTooLongException(c->threadContext, argPos, MAX_TOOLINFO_TEXT_LENGTH, l);
return false;
}
if ( l == 0 || StrCmpI("TEXTCALLBACK", text) == 0 )
{
pTI->lpszText = LPSTR_TEXTCALLBACK;
}
else
{
pTI->lpszText = (LPSTR)LocalAlloc(LPTR, MAX_TOOLINFO_TEXT_LENGTH + 1);
if ( pTI->lpszText == NULL )
{
outOfMemoryException(c->threadContext);
return false;
}
c->SetObjectVariable(TOOLINFO_MEMALLOCATED_VAR, TheTrueObj);
strcpy(pTI->lpszText, text);
}
return true;
}
/** ToolInfo::forHitTest() [class]
*
* Returns a new .ToolInfo object to be used in the ToolTip::hitTest() method.
*
* @param hwndObj [required] The tool or object that contains a tool that is
* going to be hit tested.
*
* @notes The new ToolInfo object is especially constructed to be of use in
* the ToolTip::hitTest() method. To be explicit, the ToolInfo
* returned is initialized to an empty state and the normal tool
* indentifiers are not set. The returned ToolInfo object is not
* suitable to be used in any other methods that required a ToolInfo
* object, except the hitTest() method.
*/
RexxMethod2(RexxObjectPtr, ti_forHitTest_cls, RexxObjectPtr, hwndObj, OSELF, self)
{
RexxObjectPtr result = TheNilObj;
LPTOOLINFO pTI;
RexxBufferObject tiBuf = rexxBufferForToolInfo(context, &pTI, false);
if ( tiBuf == NULLOBJECT )
{
goto done_out;
}
if ( context->IsOfType(hwndObj, "PLAINBASEDIALOG") )
{
pCPlainBaseDialog pcpbd = dlgToCSelf(context, hwndObj);
pTI->hwnd = pcpbd->hDlg;
}
else if ( context->IsOfType(hwndObj, "DIALOGCONTROL") )
{
pCDialogControl pcdc = controlToCSelf(context, hwndObj);
pTI->hwnd = pcdc->hCtrl;
}
else
{
wrongClassListException(context->threadContext, 1, "PlainBaseDialog or DialogControl", hwndObj);
goto done_out;
}
RexxArrayObject args = context->NewArray(5);
context->ArrayPut(args, tiBuf, 1);
context->ArrayPut(args, hwndObj, 2);
context->ArrayPut(args, TheNilObj, 5);
result = context->SendMessage(self, "NEW", args);
done_out:
return result;
}
/** ToolInfo::forID() [class]
*
* Returns a new .ToolInfo object to be used as a tool Identifier.
*
* @remarks The intent of this method is to quickly return an object that can
* be used as a tool indentifier. So, no other setting of the
* TOOLINFO struct is done.
*/
RexxMethod3(RexxObjectPtr, ti_forID_cls, RexxObjectPtr, hwndObj, OPTIONAL_RexxObjectPtr, rxID, OSELF, self)
{
RexxObjectPtr result = TheNilObj;
LPTOOLINFO pTI;
RexxBufferObject tiBuf = rexxBufferForToolInfo(context, &pTI, false);
if ( tiBuf == NULLOBJECT )
{
goto done_out;
}
RexxObjectPtr hwndSupplier;
RexxObjectPtr uIDSupplier;
if ( ! genericToolID(context, hwndObj, rxID, pTI, &hwndSupplier, &uIDSupplier) )
{
goto done_out;
}
RexxArrayObject args = context->NewArray(5);
context->ArrayPut(args, tiBuf, 1);
context->ArrayPut(args, hwndSupplier, 2);
context->ArrayPut(args, uIDSupplier, 5);
result = context->SendMessage(self, "NEW", args);
done_out:
return result;
}
/** ToolInfo::uninit()
*
*/
RexxMethod1(RexxObjectPtr, ti_unInit, CSELF, pCSelf)
{
#if 0
printf("In ti_unInit() pCSelf=%p\n", pCSelf);
#endif
if ( pCSelf != NULLOBJECT )
{
LPTOOLINFO pTI = (LPTOOLINFO)pCSelf;
#if 0
printf("In ti_unInit() lpszText=%p\n", pTI->lpszText != NULL ? pTI->lpszText : "null");
#endif
if ( context->GetObjectVariable(TOOLINFO_MEMALLOCATED_VAR) == TheTrueObj )
{
#if 0
printf("In ti_unInit() will safeLocalFree() on text\n");
#endif
safeLocalFree(pTI->lpszText);
}
}
return NULLOBJECT;
}
/** ToolInfo::init()
*
* @param dlg [required] Dialog ojbect. May be a Buffer object to create
* a .ToolInfo from native code. I
*
* @param uID [optional]
*
* @param text [optional]
*
* @param flags [optional]
*
* @param _resource [reserved] This is reserved for a future enhancement.
* If we ever add the ability to use string resources to the
* .Resource class, then this argument will be a .Resource
* object and text will be changed to a Rexx object. At
* that time, if _resource is used, text will be assumed to
* be a resource identifier. For now it is ignored.
*
* @remarks Note that genericToolID will set the TTF_IDISHWND flag when it
* determines that the uID filed of the TOOLINFO struct is the hwnd
* of a dialog control. So, we need to or the return from
* keyword2ttfflags() with the existing setting. It may be that the
* user could incorrectly add the TTF_IDISHWND flag and cause a crash
* if the uID is not a hwnd.
*
* When creating from native code, set arg 1 to the TOOLINFO buffer,
* set arg 2 to the object supplying the hwnd field of the struct,
* and set arg 5 to the object supplying the uID field of the struct.
* The hwnd and uID supplying objects are set as context variables so
* that they can be returned from the attributes of the ToolInfo
* object.
*/
RexxMethod7(RexxObjectPtr, ti_init, RexxObjectPtr, hwndObj, OPTIONAL_RexxObjectPtr, rxID, OPTIONAL_CSTRING, text,
OPTIONAL_CSTRING, _flags, OPTIONAL_RexxObjectPtr, userData, OPTIONAL_RexxObjectPtr, _rect,
OPTIONAL_RexxObjectPtr, _resource)
{
if ( context->IsBuffer(hwndObj) )
{
context->SetObjectVariable("CSELF", hwndObj);
context->SetObjectVariable(TOOLINFO_HWND_OBJECT_VAR, rxID);
context->SetObjectVariable(TOOLINFO_UID_OBJECT_VAR, userData);
goto done_out;
}
LPTOOLINFO pTI;
RexxBufferObject bufObj = rexxBufferForToolInfo(context, &pTI, false);
if ( bufObj == NULLOBJECT )
{
goto done_out;
}
context->SetObjectVariable("CSELF", bufObj);
RexxObjectPtr hwndSupplier;
RexxObjectPtr uIDSupplier;
if ( ! genericToolID(context, hwndObj, rxID, pTI, &hwndSupplier, &uIDSupplier) )
{
goto done_out;
}
context->SetObjectVariable(TOOLINFO_HWND_OBJECT_VAR, hwndSupplier);
context->SetObjectVariable(TOOLINFO_UID_OBJECT_VAR, uIDSupplier);
// TODO decide if user must explicitly set this flag or not? Here we remove it.
pTI->uFlags &= ~TTF_IDISHWND;
if ( argumentExists(3) )
{
if ( ! setToolInfoText(context, pTI, text, 3) )
{
goto done_out;
}
}
else
{
pTI->lpszText = LPSTR_TEXTCALLBACK;
}
if ( argumentExists(4) )
{
pTI->uFlags |= keyword2ttfFlags(_flags);
}
if ( argumentExists(5) )
{
pTI->lParam = (LPARAM)userData;
}
if ( argumentExists(6) )
{
PRECT r = rxGetRect(context, _rect, 6);
if ( r == NULL )
{
goto done_out;
}
CopyRect(&pTI->rect, r);
}
done_out:
return NULLOBJECT;
}
/** ToolInfo::flags [attribute]
*/
RexxMethod1(RexxStringObject, ti_flags, CSELF, pTI)
{
return ttfFlags2keyword(context, ((LPTOOLINFO)pTI)->uFlags);
}
RexxMethod2(RexxObjectPtr, ti_setFlags, CSTRING, flags, CSELF, pTI)
{
((LPTOOLINFO)pTI)->uFlags = keyword2ttfFlags(flags);
return NULLOBJECT;
}
/** ToolInfo::rect [attribute]
*
* @note The return can be an empty rect.
*/
RexxMethod1(RexxObjectPtr, ti_rect, CSELF, cSelf)
{
LPTOOLINFO pTI = (LPTOOLINFO)cSelf;
PRECT pRect = &pTI->rect;
return rxNewRect(context, pRect);
}
RexxMethod2(RexxObjectPtr, ti_setRect, RexxObjectPtr, rect, CSELF, cSelf)
{
LPTOOLINFO pTI = (LPTOOLINFO)cSelf;
PRECT pRect = &pTI->rect;
PRECT r = rxGetRect(context, rect, 1);
if ( r != NULL )
{
CopyRect(&pTI->rect, r);
}
return NULLOBJECT;
}
/** ToolInfo::resource [attribute]
*
* The resource attribute is reserved at this time. If the .Resource class is
* enhanced to work with string resources (a good possibility) then this
* attribute will be used for the hinst field of the tool info struct.
*
* @remarks For now, we always return .nil and do not allow the user to set
* the attribute.
*/
RexxMethod1(RexxObjectPtr, ti_resource, CSELF, cSelf)
{
return TheNilObj;
}
/** ToolInfo::rexxHwnd [attribute]
*
* @note No setter for this attribute.
*/
RexxMethod1(RexxObjectPtr, ti_rexxHwnd, CSELF, pTI)
{
RexxObjectPtr hwndObj = context->GetObjectVariable(TOOLINFO_HWND_OBJECT_VAR);
return (hwndObj ? hwndObj : TheNilObj);
}
/** ToolInfo::rexxID [attribute]
*
* @note No setter for this attribute.
*/
RexxMethod1(RexxObjectPtr, ti_rexxID, CSELF, pTI)
{
RexxObjectPtr idObj = context->GetObjectVariable(TOOLINFO_UID_OBJECT_VAR);
return (idObj ? idObj : TheNilObj);
}
/** ToolInfo::text [attribute]
*
* @remarks When getting the text attribute we need to determine if the call
* back feature is in use. It is also possible that pTI->lpszText is
* NULL.
*
* When setting the text attribute, it could be that new text is
* replacing existing text. In that case, we need to determine if
* the old text was allocated, and if so, free the old text buffer.
*/
RexxMethod1(RexxObjectPtr, ti_text, CSELF, cSelf)
{
LPTOOLINFO pTI = (LPTOOLINFO)cSelf;
if ( pTI->lpszText == NULL )
{
return context->NullString();
}
else if ( pTI->lpszText == LPSTR_TEXTCALLBACK )
{
return context->String("TextCallBack");
}
else
{
return context->String(pTI->lpszText);
}
}
RexxMethod2(RexxObjectPtr, ti_setText, CSTRING, text, CSELF, cSelf)
{
LPTOOLINFO pTI = (LPTOOLINFO)cSelf;
if ( context->GetObjectVariable(TOOLINFO_MEMALLOCATED_VAR) == TheTrueObj )
{
safeLocalFree(pTI->lpszText);
}
setToolInfoText(context, pTI, text, 1);
return NULLOBJECT;
}
/** ToolInfo::userData [attribute]
*/
RexxMethod1(RexxObjectPtr, ti_userData, CSELF, pTI)
{
return ( ((LPTOOLINFO)pTI)->lParam ? (RexxObjectPtr)((LPTOOLINFO)pTI)->lParam : TheNilObj );
}
RexxMethod2(RexxObjectPtr, ti_setUserData, RexxObjectPtr, userData, CSELF, pTI)
{
((LPTOOLINFO)pTI)->lParam = (LPARAM)userData;
return NULLOBJECT;
}
/**
* Internal use only. Allows native code to instantiate a new ToolInfo object
* and set the text memory is allocted flag.
*/
RexxMethod1(RexxObjectPtr, ti_setTextMemoryIsAllocated, RexxObjectPtr, allocated)
{
context->SetObjectVariable(TOOLINFO_MEMALLOCATED_VAR, allocated == TheTrueObj ? TheTrueObj : TheFalseObj);
return NULLOBJECT;
}
/**
* Internal use only. Allows native code to reset the context variables for
* rexxHwnd and rexxID. Memory for the text attribute has always been allocated
* in ToolTip::hitTest().
*/
RexxMethod2(RexxObjectPtr, ti_hitTestHelper, RexxObjectPtr, hwndSupplier, RexxObjectPtr, idSupplier)
{
context->SetObjectVariable(TOOLINFO_MEMALLOCATED_VAR, TheTrueObj);
context->SetObjectVariable(TOOLINFO_HWND_OBJECT_VAR, hwndSupplier);
context->SetObjectVariable(TOOLINFO_UID_OBJECT_VAR, idSupplier);
return TheTrueObj;
}