1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
/*
* Rebar control
*
* Copyright 1998, 1999 Eric Kohl
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* NOTES
*
* This code was audited for completeness against the documented features
* of Comctl32.dll version 6.0 on Oct. 19, 2004, by Robert Shearman.
*
* Unless otherwise noted, we believe this code to be complete, as per
* the specification mentioned above.
* If you discover missing features or bugs please note them below.
*
* TODO
* Styles:
* - RBS_DBLCLKTOGGLE
* - RBS_FIXEDORDER
* - RBS_REGISTERDROP
* - RBS_TOOLTIPS
* - CCS_NORESIZE
* - CCS_NOMOVEX
* - CCS_NOMOVEY
* Messages:
* - RB_BEGINDRAG
* - RB_DRAGMOVE
* - RB_ENDDRAG
* - RB_GETBANDMARGINS
* - RB_GETCOLORSCHEME
* - RB_GETDROPTARGET
* - RB_GETPALETTE
* - RB_SETCOLORSCHEME
* - RB_SETPALETTE
* - RB_SETTOOLTIPS
* - WM_CHARTOITEM
* - WM_LBUTTONDBLCLK
* - WM_MEASUREITEM
* - WM_PALETTECHANGED
* - WM_PRINTCLIENT
* - WM_QUERYNEWPALETTE
* - WM_RBUTTONDOWN
* - WM_RBUTTONUP
* - WM_SYSCOLORCHANGE
* - WM_VKEYTOITEM
* - WM_WININICHANGE
* Notifications:
* - NM_HCHITTEST
* - NM_RELEASEDCAPTURE
* - RBN_AUTOBREAK
* - RBN_GETOBJECT
* - RBN_MINMAX
* Band styles:
* - RBBS_FIXEDBMP
* Native uses (on each draw!!) SM_CYBORDER (or SM_CXBORDER for CCS_VERT)
* to set the size of the separator width (the value SEP_WIDTH_SIZE
* in here). Should be fixed!!
*/
/*
* Testing: set to 1 to make background brush *always* green
*/
#define GLATESTING 0
/*
*
* 2. At "FIXME: problem # 2" WinRAR:
* if "#if 1" then last band draws in separate row
* if "#if 0" then last band draws in previous row *** just like native ***
*
*/
#define PROBLEM2 0
/*
* 3. REBAR_MoveChildWindows should have a loop because more than
* one pass is made (together with the RBN_CHILDSIZEs) is made on
* at least RB_INSERTBAND
*/
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "wine/unicode.h"
#include "winuser.h"
#include "winnls.h"
#include "commctrl.h"
#include "comctl32.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(rebar);
typedef struct
{
UINT fStyle;
UINT fMask;
COLORREF clrFore;
COLORREF clrBack;
INT iImage;
HWND hwndChild;
UINT cxMinChild; /* valid if _CHILDSIZE */
UINT cyMinChild; /* valid if _CHILDSIZE */
UINT cx; /* valid if _SIZE */
HBITMAP hbmBack;
UINT wID;
UINT cyChild; /* valid if _CHILDSIZE */
UINT cyMaxChild; /* valid if _CHILDSIZE */
UINT cyIntegral; /* valid if _CHILDSIZE */
UINT cxIdeal;
LPARAM lParam;
UINT cxHeader;
UINT lcx; /* minimum cx for band */
UINT ccx; /* current cx for band */
UINT hcx; /* maximum cx for band */
UINT lcy; /* minimum cy for band */
UINT ccy; /* current cy for band */
UINT hcy; /* maximum cy for band */
SIZE offChild; /* x,y offset if child is not FIXEDSIZE */
UINT uMinHeight;
INT iRow; /* zero-based index of the row this band assigned to */
UINT fStatus; /* status flags, reset only by _Validate */
UINT fDraw; /* drawing flags, reset only by _Layout */
UINT uCDret; /* last return from NM_CUSTOMDRAW */
RECT rcoldBand; /* previous calculated band rectangle */
RECT rcBand; /* calculated band rectangle */
RECT rcGripper; /* calculated gripper rectangle */
RECT rcCapImage; /* calculated caption image rectangle */
RECT rcCapText; /* calculated caption text rectangle */
RECT rcChild; /* calculated child rectangle */
RECT rcChevron; /* calculated chevron rectangle */
LPWSTR lpText;
HWND hwndPrevParent;
} REBAR_BAND;
/* fStatus flags */
#define HAS_GRIPPER 0x00000001
#define HAS_IMAGE 0x00000002
#define HAS_TEXT 0x00000004
/* fDraw flags */
#define DRAW_GRIPPER 0x00000001
#define DRAW_IMAGE 0x00000002
#define DRAW_TEXT 0x00000004
#define DRAW_RIGHTSEP 0x00000010
#define DRAW_BOTTOMSEP 0x00000020
#define DRAW_CHEVRONHOT 0x00000040
#define DRAW_CHEVRONPUSHED 0x00000080
#define DRAW_LAST_IN_ROW 0x00000100
#define DRAW_FIRST_IN_ROW 0x00000200
#define NTF_INVALIDATE 0x01000000
typedef struct
{
COLORREF clrBk; /* background color */
COLORREF clrText; /* text color */
COLORREF clrBtnText; /* system color for BTNTEXT */
COLORREF clrBtnFace; /* system color for BTNFACE */
HIMAGELIST himl; /* handle to imagelist */
UINT uNumBands; /* # of bands in rebar (first=0, last=uNumBands-1 */
UINT uNumRows; /* # of rows of bands (first=1, last=uNumRows */
HWND hwndSelf; /* handle of REBAR window itself */
HWND hwndToolTip; /* handle to the tool tip control */
HWND hwndNotify; /* notification window (parent) */
HFONT hDefaultFont;
HFONT hFont; /* handle to the rebar's font */
SIZE imageSize; /* image size (image list) */
DWORD dwStyle; /* window style */
SIZE calcSize; /* calculated rebar size */
SIZE oldSize; /* previous calculated rebar size */
BOOL bUnicode; /* TRUE if this window is W type */
BOOL NtfUnicode; /* TRUE if parent wants notify in W format */
BOOL DoRedraw; /* TRUE to acutally draw bands */
UINT fStatus; /* Status flags (see below) */
HCURSOR hcurArrow; /* handle to the arrow cursor */
HCURSOR hcurHorz; /* handle to the EW cursor */
HCURSOR hcurVert; /* handle to the NS cursor */
HCURSOR hcurDrag; /* handle to the drag cursor */
INT iVersion; /* version number */
POINT dragStart; /* x,y of button down */
POINT dragNow; /* x,y of this MouseMove */
INT iOldBand; /* last band that had the mouse cursor over it */
INT ihitoffset; /* offset of hotspot from gripper.left */
POINT origin; /* left/upper corner of client */
INT ichevronhotBand; /* last band that had a hot chevron */
INT iGrabbedBand;/* band number of band whose gripper was grabbed */
REBAR_BAND *bands; /* pointer to the array of rebar bands */
} REBAR_INFO;
/* fStatus flags */
#define BEGIN_DRAG_ISSUED 0x00000001
#define AUTO_RESIZE 0x00000002
#define RESIZE_ANYHOW 0x00000004
#define NTF_HGHTCHG 0x00000008
#define BAND_NEEDS_LAYOUT 0x00000010
#define BAND_NEEDS_REDRAW 0x00000020
#define CREATE_RUNNING 0x00000040
/* ---- REBAR layout constants. Mostly determined by ---- */
/* ---- experiment on WIN 98. ---- */
/* Width (or height) of separators between bands (either horz. or */
/* vert.). True only if RBS_BANDBORDERS is set */
#define SEP_WIDTH_SIZE 2
#define SEP_WIDTH ((infoPtr->dwStyle & RBS_BANDBORDERS) ? SEP_WIDTH_SIZE : 0)
/* Blank (background color) space between Gripper (if present) */
/* and next item (image, text, or window). Always present */
#define REBAR_ALWAYS_SPACE 4
/* Blank (background color) space after Image (if present). */
#define REBAR_POST_IMAGE 2
/* Blank (background color) space after Text (if present). */
#define REBAR_POST_TEXT 4
/* Height of vertical gripper in a CCS_VERT rebar. */
#define GRIPPER_HEIGHT 16
/* Blank (background color) space before Gripper (if present). */
#define REBAR_PRE_GRIPPER 2
/* Width (of normal vertical gripper) or height (of horz. gripper) */
/* if present. */
#define GRIPPER_WIDTH 3
/* Width of the chevron button if present */
#define CHEVRON_WIDTH 10
/* Height of divider for Rebar if not disabled (CCS_NODIVIDER) */
/* either top or bottom */
#define REBAR_DIVIDER 2
/* minimium vertical height of a normal bar */
/* or minimum width of a CCS_VERT bar - from experiment on Win2k */
#define REBAR_MINSIZE 23
/* This is the increment that is used over the band height */
#define REBARSPACE(a) ((a->fStyle & RBBS_CHILDEDGE) ? 2*REBAR_DIVIDER : 0)
/* ---- End of REBAR layout constants. ---- */
#define RB_GETBANDINFO_OLD (WM_USER+5) /* obsoleted after IE3, but we have to support it anyway */
/* The following 6 defines return the proper rcBand element */
/* depending on whether CCS_VERT was set. */
#define rcBlt(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.top : b->rcBand.left)
#define rcBrb(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.bottom : b->rcBand.right)
#define rcBw(b) ((infoPtr->dwStyle & CCS_VERT) ? (b->rcBand.bottom - b->rcBand.top) : \
(b->rcBand.right - b->rcBand.left))
#define ircBlt(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.left : b->rcBand.top)
#define ircBrb(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.right : b->rcBand.bottom)
#define ircBw(b) ((infoPtr->dwStyle & CCS_VERT) ? (b->rcBand.right - b->rcBand.left) : \
(b->rcBand.bottom - b->rcBand.top))
/* The following define determines if a given band is hidden */
#define HIDDENBAND(a) (((a)->fStyle & RBBS_HIDDEN) || \
((infoPtr->dwStyle & CCS_VERT) && \
((a)->fStyle & RBBS_NOVERT)))
/* The following defines adjust the right or left end of a rectangle */
#define READJ(b,i) do { if(infoPtr->dwStyle & CCS_VERT) b->rcBand.bottom+=(i); \
else b->rcBand.right += (i); } while(0)
#define LEADJ(b,i) do { if(infoPtr->dwStyle & CCS_VERT) b->rcBand.top+=(i); \
else b->rcBand.left += (i); } while(0)
#define REBAR_GetInfoPtr(wndPtr) ((REBAR_INFO *)GetWindowLongPtrW (hwnd, 0))
/* "constant values" retrieved when DLL was initialized */
/* FIXME we do this when the classes are registered. */
static UINT mindragx = 0;
static UINT mindragy = 0;
static const char *band_stylename[] = {
"RBBS_BREAK", /* 0001 */
"RBBS_FIXEDSIZE", /* 0002 */
"RBBS_CHILDEDGE", /* 0004 */
"RBBS_HIDDEN", /* 0008 */
"RBBS_NOVERT", /* 0010 */
"RBBS_FIXEDBMP", /* 0020 */
"RBBS_VARIABLEHEIGHT", /* 0040 */
"RBBS_GRIPPERALWAYS", /* 0080 */
"RBBS_NOGRIPPER", /* 0100 */
NULL };
static const char *band_maskname[] = {
"RBBIM_STYLE", /* 0x00000001 */
"RBBIM_COLORS", /* 0x00000002 */
"RBBIM_TEXT", /* 0x00000004 */
"RBBIM_IMAGE", /* 0x00000008 */
"RBBIM_CHILD", /* 0x00000010 */
"RBBIM_CHILDSIZE", /* 0x00000020 */
"RBBIM_SIZE", /* 0x00000040 */
"RBBIM_BACKGROUND", /* 0x00000080 */
"RBBIM_ID", /* 0x00000100 */
"RBBIM_IDEALSIZE", /* 0x00000200 */
"RBBIM_LPARAM", /* 0x00000400 */
"RBBIM_HEADERSIZE", /* 0x00000800 */
NULL };
static CHAR line[200];
static CHAR *
REBAR_FmtStyle( UINT style)
{
INT i = 0;
*line = 0;
while (band_stylename[i]) {
if (style & (1<<i)) {
if (*line != 0) strcat(line, " | ");
strcat(line, band_stylename[i]);
}
i++;
}
return line;
}
static CHAR *
REBAR_FmtMask( UINT mask)
{
INT i = 0;
*line = 0;
while (band_maskname[i]) {
if (mask & (1<<i)) {
if (*line != 0) strcat(line, " | ");
strcat(line, band_maskname[i]);
}
i++;
}
return line;
}
static VOID
REBAR_DumpBandInfo( LPREBARBANDINFOA pB)
{
if( !TRACE_ON(rebar) ) return;
TRACE("band info: ");
if (pB->fMask & RBBIM_ID);
TRACE("ID=%u, ", pB->wID);
TRACE("size=%u, child=%p", pB->cbSize, pB->hwndChild);
if (pB->fMask & RBBIM_COLORS)
TRACE(", clrF=0x%06lx, clrB=0x%06lx", pB->clrFore, pB->clrBack);
TRACE("\n");
TRACE("band info: mask=0x%08x (%s)\n", pB->fMask, REBAR_FmtMask(pB->fMask));
if (pB->fMask & RBBIM_STYLE)
TRACE("band info: style=0x%08x (%s)\n", pB->fStyle, REBAR_FmtStyle(pB->fStyle));
if (pB->fMask & (RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_HEADERSIZE | RBBIM_LPARAM )) {
TRACE("band info:");
if (pB->fMask & RBBIM_SIZE)
TRACE(" cx=%u", pB->cx);
if (pB->fMask & RBBIM_IDEALSIZE)
TRACE(" xIdeal=%u", pB->cxIdeal);
if (pB->fMask & RBBIM_HEADERSIZE)
TRACE(" xHeader=%u", pB->cxHeader);
if (pB->fMask & RBBIM_LPARAM)
TRACE(" lParam=0x%08lx", pB->lParam);
TRACE("\n");
}
if (pB->fMask & RBBIM_CHILDSIZE)
TRACE("band info: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
pB->cxMinChild,
pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral);
}
static VOID
REBAR_DumpBand (REBAR_INFO *iP)
{
REBAR_BAND *pB;
UINT i;
if(! TRACE_ON(rebar) ) return;
TRACE("hwnd=%p: color=%08lx/%08lx, bands=%u, rows=%u, cSize=%ld,%ld\n",
iP->hwndSelf, iP->clrText, iP->clrBk, iP->uNumBands, iP->uNumRows,
iP->calcSize.cx, iP->calcSize.cy);
TRACE("hwnd=%p: flags=%08x, dragStart=%ld,%ld, dragNow=%ld,%ld, iGrabbedBand=%d\n",
iP->hwndSelf, iP->fStatus, iP->dragStart.x, iP->dragStart.y,
iP->dragNow.x, iP->dragNow.y,
iP->iGrabbedBand);
TRACE("hwnd=%p: style=%08lx, I'm Unicode=%s, notify in Unicode=%s, redraw=%s\n",
iP->hwndSelf, iP->dwStyle, (iP->bUnicode)?"TRUE":"FALSE",
(iP->NtfUnicode)?"TRUE":"FALSE", (iP->DoRedraw)?"TRUE":"FALSE");
for (i = 0; i < iP->uNumBands; i++) {
pB = &iP->bands[i];
TRACE("band # %u:", i);
if (pB->fMask & RBBIM_ID);
TRACE(" ID=%u", pB->wID);
if (pB->fMask & RBBIM_CHILD)
TRACE(" child=%p", pB->hwndChild);
if (pB->fMask & RBBIM_COLORS)
TRACE(" clrF=0x%06lx clrB=0x%06lx", pB->clrFore, pB->clrBack);
TRACE("\n");
TRACE("band # %u: mask=0x%08x (%s)\n", i, pB->fMask, REBAR_FmtMask(pB->fMask));
if (pB->fMask & RBBIM_STYLE)
TRACE("band # %u: style=0x%08x (%s)\n",
i, pB->fStyle, REBAR_FmtStyle(pB->fStyle));
TRACE("band # %u: uMinH=%u xHeader=%u",
i, pB->uMinHeight, pB->cxHeader);
if (pB->fMask & (RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_LPARAM )) {
if (pB->fMask & RBBIM_SIZE)
TRACE(" cx=%u", pB->cx);
if (pB->fMask & RBBIM_IDEALSIZE)
TRACE(" xIdeal=%u", pB->cxIdeal);
if (pB->fMask & RBBIM_LPARAM)
TRACE(" lParam=0x%08lx", pB->lParam);
}
TRACE("\n");
if (RBBIM_CHILDSIZE)
TRACE("band # %u: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
i, pB->cxMinChild, pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral);
if (pB->fMask & RBBIM_TEXT)
TRACE("band # %u: text=%s\n",
i, (pB->lpText) ? debugstr_w(pB->lpText) : "(null)");
TRACE("band # %u: lcx=%u, ccx=%u, hcx=%u, lcy=%u, ccy=%u, hcy=%u, offChild=%ld,%ld\n",
i, pB->lcx, pB->ccx, pB->hcx, pB->lcy, pB->ccy, pB->hcy, pB->offChild.cx, pB->offChild.cy);
TRACE("band # %u: fStatus=%08x, fDraw=%08x, Band=(%ld,%ld)-(%ld,%ld), Grip=(%ld,%ld)-(%ld,%ld)\n",
i, pB->fStatus, pB->fDraw,
pB->rcBand.left, pB->rcBand.top, pB->rcBand.right, pB->rcBand.bottom,
pB->rcGripper.left, pB->rcGripper.top, pB->rcGripper.right, pB->rcGripper.bottom);
TRACE("band # %u: Img=(%ld,%ld)-(%ld,%ld), Txt=(%ld,%ld)-(%ld,%ld), Child=(%ld,%ld)-(%ld,%ld)\n",
i,
pB->rcCapImage.left, pB->rcCapImage.top, pB->rcCapImage.right, pB->rcCapImage.bottom,
pB->rcCapText.left, pB->rcCapText.top, pB->rcCapText.right, pB->rcCapText.bottom,
pB->rcChild.left, pB->rcChild.top, pB->rcChild.right, pB->rcChild.bottom);
}
}
static void
REBAR_DrawChevron (HDC hdc, INT left, INT top, INT colorRef)
{
INT x, y;
HPEN hPen, hOldPen;
if (!(hPen = CreatePen( PS_SOLID, 1, GetSysColor( colorRef )))) return;
hOldPen = SelectObject ( hdc, hPen );
x = left + 2;
y = top;
MoveToEx (hdc, x, y, NULL);
LineTo (hdc, x+5, y++); x++;
MoveToEx (hdc, x, y, NULL);
LineTo (hdc, x+3, y++); x++;
MoveToEx (hdc, x, y, NULL);
LineTo (hdc, x+1, y++);
SelectObject( hdc, hOldPen );
DeleteObject( hPen );
}
static HWND
REBAR_GetNotifyParent (REBAR_INFO *infoPtr)
{
HWND parent, owner;
parent = infoPtr->hwndNotify;
if (!parent) {
parent = GetParent (infoPtr->hwndSelf);
owner = GetWindow (infoPtr->hwndSelf, GW_OWNER);
if (owner) parent = owner;
}
return parent;
}
static INT
REBAR_Notify (NMHDR *nmhdr, REBAR_INFO *infoPtr, UINT code)
{
HWND parent;
parent = REBAR_GetNotifyParent (infoPtr);
nmhdr->idFrom = GetDlgCtrlID (infoPtr->hwndSelf);
nmhdr->hwndFrom = infoPtr->hwndSelf;
nmhdr->code = code;
TRACE("window %p, code=%08x, %s\n", parent, code,
(infoPtr->NtfUnicode) ? "via Unicode" : "via ANSI");
if (infoPtr->NtfUnicode)
return SendMessageW (parent, WM_NOTIFY, (WPARAM) nmhdr->idFrom,
(LPARAM)nmhdr);
else
return SendMessageA (parent, WM_NOTIFY, (WPARAM) nmhdr->idFrom,
(LPARAM)nmhdr);
}
static INT
REBAR_Notify_NMREBAR (REBAR_INFO *infoPtr, UINT uBand, UINT code)
{
NMREBAR notify_rebar;
REBAR_BAND *lpBand;
notify_rebar.dwMask = 0;
if (uBand!=-1) {
lpBand = &infoPtr->bands[uBand];
if (lpBand->fMask & RBBIM_ID) {
notify_rebar.dwMask |= RBNM_ID;
notify_rebar.wID = lpBand->wID;
}
if (lpBand->fMask & RBBIM_LPARAM) {
notify_rebar.dwMask |= RBNM_LPARAM;
notify_rebar.lParam = lpBand->lParam;
}
if (lpBand->fMask & RBBIM_STYLE) {
notify_rebar.dwMask |= RBNM_STYLE;
notify_rebar.fStyle = lpBand->fStyle;
}
}
notify_rebar.uBand = uBand;
return REBAR_Notify ((NMHDR *)¬ify_rebar, infoPtr, code);
}
static VOID
REBAR_DrawBand (HDC hdc, REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
{
HFONT hOldFont = 0;
INT oldBkMode = 0;
NMCUSTOMDRAW nmcd;
if (lpBand->fDraw & DRAW_TEXT) {
hOldFont = SelectObject (hdc, infoPtr->hFont);
oldBkMode = SetBkMode (hdc, TRANSPARENT);
}
/* should test for CDRF_NOTIFYITEMDRAW here */
nmcd.dwDrawStage = CDDS_ITEMPREPAINT;
nmcd.hdc = hdc;
nmcd.rc = lpBand->rcBand;
nmcd.rc.right = lpBand->rcCapText.right;
nmcd.rc.bottom = lpBand->rcCapText.bottom;
nmcd.dwItemSpec = lpBand->wID;
nmcd.uItemState = 0;
nmcd.lItemlParam = lpBand->lParam;
lpBand->uCDret = REBAR_Notify ((NMHDR *)&nmcd, infoPtr, NM_CUSTOMDRAW);
if (lpBand->uCDret == CDRF_SKIPDEFAULT) {
if (oldBkMode != TRANSPARENT)
SetBkMode (hdc, oldBkMode);
SelectObject (hdc, hOldFont);
return;
}
/* draw gripper */
if (lpBand->fDraw & DRAW_GRIPPER)
DrawEdge (hdc, &lpBand->rcGripper, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
/* draw caption image */
if (lpBand->fDraw & DRAW_IMAGE) {
POINT pt;
/* center image */
pt.y = (lpBand->rcCapImage.bottom + lpBand->rcCapImage.top - infoPtr->imageSize.cy)/2;
pt.x = (lpBand->rcCapImage.right + lpBand->rcCapImage.left - infoPtr->imageSize.cx)/2;
ImageList_Draw (infoPtr->himl, lpBand->iImage, hdc,
pt.x, pt.y,
ILD_TRANSPARENT);
}
/* draw caption text */
if (lpBand->fDraw & DRAW_TEXT) {
/* need to handle CDRF_NEWFONT here */
INT oldBkMode = SetBkMode (hdc, TRANSPARENT);
COLORREF oldcolor = CLR_NONE;
COLORREF new;
if (lpBand->clrFore != CLR_NONE) {
new = (lpBand->clrFore == CLR_DEFAULT) ? infoPtr->clrBtnText :
lpBand->clrFore;
oldcolor = SetTextColor (hdc, new);
}
DrawTextW (hdc, lpBand->lpText, -1, &lpBand->rcCapText,
DT_CENTER | DT_VCENTER | DT_SINGLELINE);
if (oldBkMode != TRANSPARENT)
SetBkMode (hdc, oldBkMode);
if (lpBand->clrFore != CLR_NONE)
SetTextColor (hdc, oldcolor);
SelectObject (hdc, hOldFont);
}
if (!IsRectEmpty(&lpBand->rcChevron))
{
if (lpBand->fDraw & DRAW_CHEVRONPUSHED)
{
DrawEdge(hdc, &lpBand->rcChevron, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE);
REBAR_DrawChevron(hdc, lpBand->rcChevron.left+1, lpBand->rcChevron.top + 11, COLOR_WINDOWFRAME);
}
else if (lpBand->fDraw & DRAW_CHEVRONHOT)
{
DrawEdge(hdc, &lpBand->rcChevron, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
REBAR_DrawChevron(hdc, lpBand->rcChevron.left, lpBand->rcChevron.top + 10, COLOR_WINDOWFRAME);
}
else
REBAR_DrawChevron(hdc, lpBand->rcChevron.left, lpBand->rcChevron.top + 10, COLOR_WINDOWFRAME);
}
if (lpBand->uCDret == (CDRF_NOTIFYPOSTPAINT | CDRF_NOTIFYITEMDRAW)) {
nmcd.dwDrawStage = CDDS_ITEMPOSTPAINT;
nmcd.hdc = hdc;
nmcd.rc = lpBand->rcBand;
nmcd.rc.right = lpBand->rcCapText.right;
nmcd.rc.bottom = lpBand->rcCapText.bottom;
nmcd.dwItemSpec = lpBand->wID;
nmcd.uItemState = 0;
nmcd.lItemlParam = lpBand->lParam;
lpBand->uCDret = REBAR_Notify ((NMHDR *)&nmcd, infoPtr, NM_CUSTOMDRAW);
}
}
static VOID
REBAR_Refresh (REBAR_INFO *infoPtr, HDC hdc)
{
REBAR_BAND *lpBand;
UINT i;
if (!infoPtr->DoRedraw) return;
for (i = 0; i < infoPtr->uNumBands; i++) {
lpBand = &infoPtr->bands[i];
if (HIDDENBAND(lpBand)) continue;
/* now draw the band */
TRACE("[%p] drawing band %i, flags=%08x\n",
infoPtr->hwndSelf, i, lpBand->fDraw);
REBAR_DrawBand (hdc, infoPtr, lpBand);
}
}
static void
REBAR_FixVert (REBAR_INFO *infoPtr, UINT rowstart, UINT rowend,
INT mcy)
/* Function: */
/* Cycle through bands in row and fix height of each band. */
/* Also determine whether each band has changed. */
/* On entry: */
/* all bands at desired size. */
/* start and end bands are *not* hidden */
{
REBAR_BAND *lpBand;
INT i;
for (i = (INT)rowstart; i<=(INT)rowend; i++) {
lpBand = &infoPtr->bands[i];
if (HIDDENBAND(lpBand)) continue;
/* adjust height of bands in row to "mcy" value */
if (infoPtr->dwStyle & CCS_VERT) {
if (lpBand->rcBand.right != lpBand->rcBand.left + mcy)
lpBand->rcBand.right = lpBand->rcBand.left + mcy;
}
else {
if (lpBand->rcBand.bottom != lpBand->rcBand.top + mcy)
lpBand->rcBand.bottom = lpBand->rcBand.top + mcy;
}
/* mark whether we need to invalidate this band and trace */
if ((lpBand->rcoldBand.left !=lpBand->rcBand.left) ||
(lpBand->rcoldBand.top !=lpBand->rcBand.top) ||
(lpBand->rcoldBand.right !=lpBand->rcBand.right) ||
(lpBand->rcoldBand.bottom !=lpBand->rcBand.bottom)) {
lpBand->fDraw |= NTF_INVALIDATE;
TRACE("band %d row=%d: changed to (%ld,%ld)-(%ld,%ld) from (%ld,%ld)-(%ld,%ld)\n",
i, lpBand->iRow,
lpBand->rcBand.left, lpBand->rcBand.top,
lpBand->rcBand.right, lpBand->rcBand.bottom,
lpBand->rcoldBand.left, lpBand->rcoldBand.top,
lpBand->rcoldBand.right, lpBand->rcoldBand.bottom);
}
else
TRACE("band %d row=%d: unchanged (%ld,%ld)-(%ld,%ld)\n",
i, lpBand->iRow,
lpBand->rcBand.left, lpBand->rcBand.top,
lpBand->rcBand.right, lpBand->rcBand.bottom);
}
}
static void
REBAR_AdjustBands (REBAR_INFO *infoPtr, UINT rowstart, UINT rowend,
INT maxx, INT mcy)
/* Function: This routine distributes the extra space in a row. */
/* See algorithm below. */
/* On entry: */
/* all bands @ ->cxHeader size */
/* start and end bands are *not* hidden */
{
REBAR_BAND *lpBand;
UINT xsep, extra, curwidth, fudge;
INT x, i, last_adjusted;
TRACE("start=%u, end=%u, max x=%d, max y=%d\n",
rowstart, rowend, maxx, mcy);
/* ******************* Phase 1 ************************ */
/* Alg: */
/* For each visible band with valid child */
/* a. inflate band till either all extra space used */
/* or band's ->ccx reached. */
/* If any band modified, add any space left to last band */
/* adjusted. */
/* */
/* ****************************************************** */
lpBand = &infoPtr->bands[rowend];
extra = maxx - rcBrb(lpBand);
x = 0;
last_adjusted = -1;
for (i=(INT)rowstart; i<=(INT)rowend; i++) {
lpBand = &infoPtr->bands[i];
if (HIDDENBAND(lpBand)) continue;
xsep = (x == 0) ? 0 : SEP_WIDTH;
curwidth = rcBw(lpBand);
/* set new left/top point */
if (infoPtr->dwStyle & CCS_VERT)
lpBand->rcBand.top = x + xsep;
else
lpBand->rcBand.left = x + xsep;
/* compute new width */
if ((lpBand->hwndChild && extra) && !(lpBand->fStyle & RBBS_FIXEDSIZE)) {
/* set to the "current" band size less the header */
fudge = lpBand->ccx;
last_adjusted = i;
if ((lpBand->fMask & RBBIM_SIZE) && (lpBand->cx > 0) &&
(fudge > curwidth)) {
TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d, extra=%d\n",
i, fudge-curwidth, fudge, curwidth, extra);
if ((fudge - curwidth) > extra)
fudge = curwidth + extra;
extra -= (fudge - curwidth);
curwidth = fudge;
}
else {
TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d\n",
i, extra, fudge, curwidth);
curwidth += extra;
extra = 0;
}
}
/* set new right/bottom point */
if (infoPtr->dwStyle & CCS_VERT)
lpBand->rcBand.bottom = lpBand->rcBand.top + curwidth;
else
lpBand->rcBand.right = lpBand->rcBand.left + curwidth;
TRACE("Phase 1 band %d, (%ld,%ld)-(%ld,%ld), orig x=%d, xsep=%d\n",
i, lpBand->rcBand.left, lpBand->rcBand.top,
lpBand->rcBand.right, lpBand->rcBand.bottom, x, xsep);
x = rcBrb(lpBand);
}
if ((x >= maxx) || (last_adjusted != -1)) {
if (x > maxx) {
ERR("Phase 1 failed, x=%d, maxx=%d, start=%u, end=%u\n",
x, maxx, rowstart, rowend);
}
/* done, so spread extra space */
if (x < maxx) {
fudge = maxx - x;
TRACE("Need to spread %d on last adjusted band %d\n",
fudge, last_adjusted);
for (i=(INT)last_adjusted; i<=(INT)rowend; i++) {
lpBand = &infoPtr->bands[i];
if (HIDDENBAND(lpBand)) continue;
/* set right/bottom point */
if (i != last_adjusted) {
if (infoPtr->dwStyle & CCS_VERT)
lpBand->rcBand.top += fudge;
else
lpBand->rcBand.left += fudge;
}
/* set left/bottom point */
if (infoPtr->dwStyle & CCS_VERT)
lpBand->rcBand.bottom += fudge;
else
lpBand->rcBand.right += fudge;
}
}
TRACE("Phase 1 succeeded, used x=%d\n", x);
REBAR_FixVert (infoPtr, rowstart, rowend, mcy);
return;
}
/* ******************* Phase 2 ************************ */
/* Alg: */
/* Find first visible band, put all */
/* extra space there. */
/* */
/* ****************************************************** */
x = 0;
for (i=(INT)rowstart; i<=(INT)rowend; i++) {
lpBand = &infoPtr->bands[i];
if (HIDDENBAND(lpBand)) continue;
xsep = (x == 0) ? 0 : SEP_WIDTH;
curwidth = rcBw(lpBand);
/* set new left/top point */
if (infoPtr->dwStyle & CCS_VERT)
lpBand->rcBand.top = x + xsep;
else
lpBand->rcBand.left = x + xsep;
/* compute new width */
if (extra) {
curwidth += extra;
extra = 0;
}
/* set new right/bottom point */
if (infoPtr->dwStyle & CCS_VERT)
lpBand->rcBand.bottom = lpBand->rcBand.top + curwidth;
else
lpBand->rcBand.right = lpBand->rcBand.left + curwidth;
TRACE("Phase 2 band %d, (%ld,%ld)-(%ld,%ld), orig x=%d, xsep=%d\n",
i, lpBand->rcBand.left, lpBand->rcBand.top,
lpBand->rcBand.right, lpBand->rcBand.bottom, x, xsep);
x = rcBrb(lpBand);
}
if (x >= maxx) {
if (x > maxx) {
ERR("Phase 2 failed, x=%d, maxx=%d, start=%u, end=%u\n",
x, maxx, rowstart, rowend);
}
/* done, so spread extra space */
TRACE("Phase 2 succeeded, used x=%d\n", x);
REBAR_FixVert (infoPtr, rowstart, rowend, mcy);
return;
}
/* ******************* Phase 3 ************************ */
/* at this point everything is back to ->cxHeader values */
/* and should not have gotten here. */
/* ****************************************************** */
lpBand = &infoPtr->bands[rowstart];
ERR("Serious problem adjusting row %d, start band %d, end band %d\n",
lpBand->iRow, rowstart, rowend);
REBAR_DumpBand (infoPtr);
return;
}
static void
REBAR_CalcHorzBand (REBAR_INFO *infoPtr, UINT rstart, UINT rend, BOOL notify)
/* Function: this routine initializes all the rectangles in */
/* each band in a row to fit in the adjusted rcBand rect. */
/* *** Supports only Horizontal bars. *** */
{
REBAR_BAND *lpBand;
UINT i, xoff, yoff;
HWND parenthwnd;
RECT oldChild, work;
/* MS seems to use GetDlgCtrlID() for above GetWindowLong call */
parenthwnd = GetParent (infoPtr->hwndSelf);
for(i=rstart; i<rend; i++){
lpBand = &infoPtr->bands[i];
if (HIDDENBAND(lpBand)) {
SetRect (&lpBand->rcChild,
lpBand->rcBand.right, lpBand->rcBand.top,
lpBand->rcBand.right, lpBand->rcBand.bottom);
continue;
}
oldChild = lpBand->rcChild;
/* set initial gripper rectangle */
SetRect (&lpBand->rcGripper, lpBand->rcBand.left, lpBand->rcBand.top,
lpBand->rcBand.left, lpBand->rcBand.bottom);
/* calculate gripper rectangle */
if ( lpBand->fStatus & HAS_GRIPPER) {
lpBand->fDraw |= DRAW_GRIPPER;
lpBand->rcGripper.left += REBAR_PRE_GRIPPER;
lpBand->rcGripper.right = lpBand->rcGripper.left + GRIPPER_WIDTH;
lpBand->rcGripper.top += 2;
lpBand->rcGripper.bottom -= 2;
SetRect (&lpBand->rcCapImage,
lpBand->rcGripper.right+REBAR_ALWAYS_SPACE, lpBand->rcBand.top,
lpBand->rcGripper.right+REBAR_ALWAYS_SPACE, lpBand->rcBand.bottom);
}
else { /* no gripper will be drawn */
xoff = 0;
if (lpBand->fStatus & (HAS_IMAGE | HAS_TEXT))
/* if no gripper but either image or text, then leave space */
xoff = REBAR_ALWAYS_SPACE;
SetRect (&lpBand->rcCapImage,
lpBand->rcBand.left+xoff, lpBand->rcBand.top,
lpBand->rcBand.left+xoff, lpBand->rcBand.bottom);
}
/* image is visible */
if (lpBand->fStatus & HAS_IMAGE) {
lpBand->fDraw |= DRAW_IMAGE;
lpBand->rcCapImage.right += infoPtr->imageSize.cx;
lpBand->rcCapImage.bottom = lpBand->rcCapImage.top + infoPtr->imageSize.cy;
/* set initial caption text rectangle */
SetRect (&lpBand->rcCapText,
lpBand->rcCapImage.right+REBAR_POST_IMAGE, lpBand->rcBand.top+1,
lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.bottom-1);
/* update band height
if (lpBand->uMinHeight < infoPtr->imageSize.cy + 2) {
lpBand->uMinHeight = infoPtr->imageSize.cy + 2;
lpBand->rcBand.bottom = lpBand->rcBand.top + lpBand->uMinHeight;
} */
}
else {
/* set initial caption text rectangle */
SetRect (&lpBand->rcCapText, lpBand->rcCapImage.right, lpBand->rcBand.top+1,
lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.bottom-1);
}
/* text is visible */
if ((lpBand->fStatus & HAS_TEXT) && !(lpBand->fStyle & RBBS_HIDETITLE)) {
lpBand->fDraw |= DRAW_TEXT;
lpBand->rcCapText.right = max(lpBand->rcCapText.left,
lpBand->rcCapText.right-REBAR_POST_TEXT);
}
/* set initial child window rectangle if there is a child */
if (lpBand->fMask & RBBIM_CHILD) {
xoff = lpBand->offChild.cx;
yoff = lpBand->offChild.cy;
SetRect (&lpBand->rcChild,
lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.top+yoff,
lpBand->rcBand.right-xoff, lpBand->rcBand.bottom-yoff);
if ((lpBand->fStyle & RBBS_USECHEVRON) && (lpBand->rcChild.right - lpBand->rcChild.left < lpBand->cxIdeal))
{
lpBand->rcChild.right -= CHEVRON_WIDTH;
SetRect(&lpBand->rcChevron, lpBand->rcChild.right,
lpBand->rcChild.top, lpBand->rcChild.right + CHEVRON_WIDTH,
lpBand->rcChild.bottom);
}
}
else {
SetRect (&lpBand->rcChild,
lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.top,
lpBand->rcBand.right, lpBand->rcBand.bottom);
}
/* flag if notify required and invalidate rectangle */
if (notify &&
((oldChild.right-oldChild.left != lpBand->rcChild.right-lpBand->rcChild.left) ||
(oldChild.bottom-oldChild.top != lpBand->rcChild.bottom-lpBand->rcChild.top))) {
TRACE("Child rectangle changed for band %u\n", i);
TRACE(" from (%ld,%ld)-(%ld,%ld) to (%ld,%ld)-(%ld,%ld)\n",
oldChild.left, oldChild.top,
oldChild.right, oldChild.bottom,
lpBand->rcChild.left, lpBand->rcChild.top,
lpBand->rcChild.right, lpBand->rcChild.bottom);
}
if (lpBand->fDraw & NTF_INVALIDATE) {
TRACE("invalidating (%ld,%ld)-(%ld,%ld)\n",
lpBand->rcBand.left,
lpBand->rcBand.top,
lpBand->rcBand.right + ((lpBand->fDraw & DRAW_RIGHTSEP) ? SEP_WIDTH_SIZE : 0),
lpBand->rcBand.bottom + ((lpBand->fDraw & DRAW_BOTTOMSEP) ? SEP_WIDTH_SIZE : 0));
lpBand->fDraw &= ~NTF_INVALIDATE;
work = lpBand->rcBand;
if (lpBand->fDraw & DRAW_RIGHTSEP) work.right += SEP_WIDTH_SIZE;
if (lpBand->fDraw & DRAW_BOTTOMSEP) work.bottom += SEP_WIDTH_SIZE;
InvalidateRect(infoPtr->hwndSelf, &work, TRUE);
}
}
}
static VOID
REBAR_CalcVertBand (REBAR_INFO *infoPtr, UINT rstart, UINT rend, BOOL notify)
/* Function: this routine initializes all the rectangles in */
/* each band in a row to fit in the adjusted rcBand rect. */
/* *** Supports only Vertical bars. *** */
{
REBAR_BAND *lpBand;
UINT i, xoff, yoff;
HWND parenthwnd;
RECT oldChild, work;
/* MS seems to use GetDlgCtrlID() for above GetWindowLong call */
parenthwnd = GetParent (infoPtr->hwndSelf);
for(i=rstart; i<rend; i++){
lpBand = &infoPtr->bands[i];
if (HIDDENBAND(lpBand)) continue;
oldChild = lpBand->rcChild;
/* set initial gripper rectangle */
SetRect (&lpBand->rcGripper, lpBand->rcBand.left, lpBand->rcBand.top,
lpBand->rcBand.right, lpBand->rcBand.top);
/* calculate gripper rectangle */
if (lpBand->fStatus & HAS_GRIPPER) {
lpBand->fDraw |= DRAW_GRIPPER;
if (infoPtr->dwStyle & RBS_VERTICALGRIPPER) {
/* vertical gripper */
lpBand->rcGripper.left += 3;
lpBand->rcGripper.right = lpBand->rcGripper.left + GRIPPER_WIDTH;
lpBand->rcGripper.top += REBAR_PRE_GRIPPER;
lpBand->rcGripper.bottom = lpBand->rcGripper.top + GRIPPER_HEIGHT;
/* initialize Caption image rectangle */
SetRect (&lpBand->rcCapImage, lpBand->rcBand.left,
lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE,
lpBand->rcBand.right,
lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE);
}
else {
/* horizontal gripper */
lpBand->rcGripper.left += 2;
lpBand->rcGripper.right -= 2;
lpBand->rcGripper.top += REBAR_PRE_GRIPPER;
lpBand->rcGripper.bottom = lpBand->rcGripper.top + GRIPPER_WIDTH;
/* initialize Caption image rectangle */
SetRect (&lpBand->rcCapImage, lpBand->rcBand.left,
lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE,
lpBand->rcBand.right,
lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE);
}
}
else { /* no gripper will be drawn */
xoff = 0;
if (lpBand->fStatus & (HAS_IMAGE | HAS_TEXT))
/* if no gripper but either image or text, then leave space */
xoff = REBAR_ALWAYS_SPACE;
/* initialize Caption image rectangle */
SetRect (&lpBand->rcCapImage,
lpBand->rcBand.left, lpBand->rcBand.top+xoff,
lpBand->rcBand.right, lpBand->rcBand.top+xoff);
}
/* image is visible */
if (lpBand->fStatus & HAS_IMAGE) {
lpBand->fDraw |= DRAW_IMAGE;
lpBand->rcCapImage.right = lpBand->rcCapImage.left + infoPtr->imageSize.cx;
lpBand->rcCapImage.bottom += infoPtr->imageSize.cy;
/* set initial caption text rectangle */
SetRect (&lpBand->rcCapText,
lpBand->rcBand.left, lpBand->rcCapImage.bottom+REBAR_POST_IMAGE,
lpBand->rcBand.right, lpBand->rcBand.top+lpBand->cxHeader);
/* update band height *
if (lpBand->uMinHeight < infoPtr->imageSize.cx + 2) {
lpBand->uMinHeight = infoPtr->imageSize.cx + 2;
lpBand->rcBand.right = lpBand->rcBand.left + lpBand->uMinHeight;
} */
}
else {
/* set initial caption text rectangle */
SetRect (&lpBand->rcCapText,
lpBand->rcBand.left, lpBand->rcCapImage.bottom,
lpBand->rcBand.right, lpBand->rcBand.top+lpBand->cxHeader);
}
/* text is visible */
if ((lpBand->fStatus & HAS_TEXT) && !(lpBand->fStyle & RBBS_HIDETITLE)) {
lpBand->fDraw |= DRAW_TEXT;
lpBand->rcCapText.bottom = max(lpBand->rcCapText.top,
lpBand->rcCapText.bottom);
}
/* set initial child window rectangle if there is a child */
if (lpBand->fMask & RBBIM_CHILD) {
yoff = lpBand->offChild.cx;
xoff = lpBand->offChild.cy;
SetRect (&lpBand->rcChild,
lpBand->rcBand.left+xoff, lpBand->rcBand.top+lpBand->cxHeader,
lpBand->rcBand.right-xoff, lpBand->rcBand.bottom-yoff);
}
else {
SetRect (&lpBand->rcChild,
lpBand->rcBand.left, lpBand->rcBand.top+lpBand->cxHeader,
lpBand->rcBand.right, lpBand->rcBand.bottom);
}
/* flag if notify required and invalidate rectangle */
if (notify &&
((oldChild.right-oldChild.left != lpBand->rcChild.right-lpBand->rcChild.left) ||
(oldChild.bottom-oldChild.top != lpBand->rcChild.bottom-lpBand->rcChild.top))) {
TRACE("Child rectangle changed for band %u\n", i);
TRACE(" from (%ld,%ld)-(%ld,%ld) to (%ld,%ld)-(%ld,%ld)\n",
oldChild.left, oldChild.top,
oldChild.right, oldChild.bottom,
lpBand->rcChild.left, lpBand->rcChild.top,
lpBand->rcChild.right, lpBand->rcChild.bottom);
}
if (lpBand->fDraw & NTF_INVALIDATE) {
TRACE("invalidating (%ld,%ld)-(%ld,%ld)\n",
lpBand->rcBand.left,
lpBand->rcBand.top,
lpBand->rcBand.right + ((lpBand->fDraw & DRAW_BOTTOMSEP) ? SEP_WIDTH_SIZE : 0),
lpBand->rcBand.bottom + ((lpBand->fDraw & DRAW_RIGHTSEP) ? SEP_WIDTH_SIZE : 0));
lpBand->fDraw &= ~NTF_INVALIDATE;
work = lpBand->rcBand;
if (lpBand->fDraw & DRAW_RIGHTSEP) work.bottom += SEP_WIDTH_SIZE;
if (lpBand->fDraw & DRAW_BOTTOMSEP) work.right += SEP_WIDTH_SIZE;
InvalidateRect(infoPtr->hwndSelf, &work, TRUE);
}
}
}
static VOID
REBAR_ForceResize (REBAR_INFO *infoPtr)
/* Function: This changes the size of the REBAR window to that */
/* calculated by REBAR_Layout. */
{
RECT rc;
INT x, y, width, height;
INT xedge = GetSystemMetrics(SM_CXEDGE);
INT yedge = GetSystemMetrics(SM_CYEDGE);
GetClientRect (infoPtr->hwndSelf, &rc);
TRACE( " old [%ld x %ld], new [%ld x %ld], client [%ld x %ld]\n",
infoPtr->oldSize.cx, infoPtr->oldSize.cy,
infoPtr->calcSize.cx, infoPtr->calcSize.cy,
rc.right, rc.bottom);
/* If we need to shrink client, then skip size test */
if ((infoPtr->calcSize.cy >= rc.bottom) &&
(infoPtr->calcSize.cx >= rc.right)) {
/* if size did not change then skip process */
if ((infoPtr->oldSize.cx == infoPtr->calcSize.cx) &&
(infoPtr->oldSize.cy == infoPtr->calcSize.cy) &&
!(infoPtr->fStatus & RESIZE_ANYHOW))
{
TRACE("skipping reset\n");
return;
}
}
infoPtr->fStatus &= ~RESIZE_ANYHOW;
/* Set flag to ignore next WM_SIZE message */
infoPtr->fStatus |= AUTO_RESIZE;
width = 0;
height = 0;
x = 0;
y = 0;
if (infoPtr->dwStyle & WS_BORDER) {
width = 2 * xedge;
height = 2 * yedge;
}
if (!(infoPtr->dwStyle & CCS_NOPARENTALIGN)) {
INT mode = infoPtr->dwStyle & (CCS_VERT | CCS_TOP | CCS_BOTTOM);
RECT rcPcl;
GetClientRect(GetParent(infoPtr->hwndSelf), &rcPcl);
switch (mode) {
case CCS_TOP:
/* _TOP sets width to parents width */
width += (rcPcl.right - rcPcl.left);
height += infoPtr->calcSize.cy;
x += ((infoPtr->dwStyle & WS_BORDER) ? -xedge : 0);
y += ((infoPtr->dwStyle & WS_BORDER) ? -yedge : 0);
y += ((infoPtr->dwStyle & CCS_NODIVIDER) ? 0 : REBAR_DIVIDER);
break;
case CCS_BOTTOM:
/* FIXME: wrong wrong wrong */
/* _BOTTOM sets width to parents width */
width += (rcPcl.right - rcPcl.left);
height += infoPtr->calcSize.cy;
x += -xedge;
y = rcPcl.bottom - height + 1;
break;
case CCS_LEFT:
/* _LEFT sets height to parents height */
width += infoPtr->calcSize.cx;
height += (rcPcl.bottom - rcPcl.top);
x += ((infoPtr->dwStyle & WS_BORDER) ? -xedge : 0);
x += ((infoPtr->dwStyle & CCS_NODIVIDER) ? 0 : REBAR_DIVIDER);
y += ((infoPtr->dwStyle & WS_BORDER) ? -yedge : 0);
break;
case CCS_RIGHT:
/* FIXME: wrong wrong wrong */
/* _RIGHT sets height to parents height */
width += infoPtr->calcSize.cx;
height += (rcPcl.bottom - rcPcl.top);
x = rcPcl.right - width + 1;
y = -yedge;
break;
default:
width += infoPtr->calcSize.cx;
height += infoPtr->calcSize.cy;
}
}
else {
width += infoPtr->calcSize.cx;
height += infoPtr->calcSize.cy;
x = infoPtr->origin.x;
y = infoPtr->origin.y;
}
TRACE("hwnd %p, style=%08lx, setting at (%d,%d) for (%d,%d)\n",
infoPtr->hwndSelf, infoPtr->dwStyle,
x, y, width, height);
SetWindowPos (infoPtr->hwndSelf, 0, x, y, width, height,
SWP_NOZORDER);
infoPtr->fStatus &= ~AUTO_RESIZE;
}
static VOID
REBAR_MoveChildWindows (REBAR_INFO *infoPtr, UINT start, UINT endplus)
{
const static WCHAR strComboBox[] = { 'C','o','m','b','o','B','o','x',0 };
REBAR_BAND *lpBand;
WCHAR szClassName[40];
UINT i;
NMREBARCHILDSIZE rbcz;
NMHDR heightchange;
HDWP deferpos;
if (!(deferpos = BeginDeferWindowPos(infoPtr->uNumBands)))
ERR("BeginDeferWindowPos returned NULL\n");
for (i = start; i < endplus; i++) {
lpBand = &infoPtr->bands[i];
if (HIDDENBAND(lpBand)) continue;
if (lpBand->hwndChild) {
TRACE("hwndChild = %p\n", lpBand->hwndChild);
/* Always geterate the RBN_CHILDSIZE even it child
did not change */
rbcz.uBand = i;
rbcz.wID = lpBand->wID;
rbcz.rcChild = lpBand->rcChild;
rbcz.rcBand = lpBand->rcBand;
if (infoPtr->dwStyle & CCS_VERT)
rbcz.rcBand.top += lpBand->cxHeader;
else
rbcz.rcBand.left += lpBand->cxHeader;
REBAR_Notify ((NMHDR *)&rbcz, infoPtr, RBN_CHILDSIZE);
if (!EqualRect (&lpBand->rcChild, &rbcz.rcChild)) {
TRACE("Child rect changed by NOTIFY for band %u\n", i);
TRACE(" from (%ld,%ld)-(%ld,%ld) to (%ld,%ld)-(%ld,%ld)\n",
lpBand->rcChild.left, lpBand->rcChild.top,
lpBand->rcChild.right, lpBand->rcChild.bottom,
rbcz.rcChild.left, rbcz.rcChild.top,
rbcz.rcChild.right, rbcz.rcChild.bottom);
lpBand->rcChild = rbcz.rcChild; /* *** ??? */
}
/* native (IE4 in "Favorites" frame **1) does:
* SetRect (&rc, -1, -1, -1, -1)
* EqualRect (&rc,band->rc???)
* if ret==0
* CopyRect (band->rc????, &rc)
* set flag outside of loop
*/
GetClassNameW (lpBand->hwndChild, szClassName, sizeof(szClassName)/sizeof(szClassName[0]));
if (!lstrcmpW (szClassName, strComboBox) ||
!lstrcmpW (szClassName, WC_COMBOBOXEXW)) {
INT nEditHeight, yPos;
RECT rc;
/* special placement code for combo or comboex box */
/* get size of edit line */
GetWindowRect (lpBand->hwndChild, &rc);
nEditHeight = rc.bottom - rc.top;
yPos = (lpBand->rcChild.bottom + lpBand->rcChild.top - nEditHeight)/2;
/* center combo box inside child area */
TRACE("moving child (Combo(Ex)) %p to (%ld,%d) for (%ld,%d)\n",
lpBand->hwndChild,
lpBand->rcChild.left, yPos,
lpBand->rcChild.right - lpBand->rcChild.left,
nEditHeight);
deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP,
lpBand->rcChild.left,
/*lpBand->rcChild.top*/ yPos,
lpBand->rcChild.right - lpBand->rcChild.left,
nEditHeight,
SWP_NOZORDER);
if (!deferpos)
ERR("DeferWindowPos returned NULL\n");
}
else {
TRACE("moving child (Other) %p to (%ld,%ld) for (%ld,%ld)\n",
lpBand->hwndChild,
lpBand->rcChild.left, lpBand->rcChild.top,
lpBand->rcChild.right - lpBand->rcChild.left,
lpBand->rcChild.bottom - lpBand->rcChild.top);
deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP,
lpBand->rcChild.left,
lpBand->rcChild.top,
lpBand->rcChild.right - lpBand->rcChild.left,
lpBand->rcChild.bottom - lpBand->rcChild.top,
SWP_NOZORDER);
if (!deferpos)
ERR("DeferWindowPos returned NULL\n");
}
}
}
if (!EndDeferWindowPos(deferpos))
ERR("EndDeferWindowPos returned NULL\n");
if (infoPtr->DoRedraw)
UpdateWindow (infoPtr->hwndSelf);
if (infoPtr->fStatus & NTF_HGHTCHG) {
infoPtr->fStatus &= ~NTF_HGHTCHG;
/*
* We need to force a resize here, because some applications
* try to get the rebar size during processing of the
* RBN_HEIGHTCHANGE notification.
*/
REBAR_ForceResize (infoPtr);
REBAR_Notify (&heightchange, infoPtr, RBN_HEIGHTCHANGE);
}
/* native (from **1 above) does:
* UpdateWindow(rebar)
* REBAR_ForceResize
* RBN_HEIGHTCHANGE if necessary
* if ret from any EqualRect was 0
* Goto "BeginDeferWindowPos"
*/
}
static VOID
REBAR_Layout (REBAR_INFO *infoPtr, LPRECT lpRect, BOOL notify, BOOL resetclient)
/* Function: This routine is resposible for laying out all */
/* the bands in a rebar. It assigns each band to a row and*/
/* determines when to start a new row. */
{
REBAR_BAND *lpBand, *prevBand;
RECT rcClient, rcAdj;
INT initx, inity, x, y, cx, cxsep, mmcy, mcy, clientcx, clientcy;
INT adjcx, adjcy, row, rightx, bottomy, origheight;
UINT i, j, rowstart, origrows, cntonrow;
BOOL dobreak;
if (!(infoPtr->fStatus & BAND_NEEDS_LAYOUT)) {
TRACE("no layout done. No band changed.\n");
REBAR_DumpBand (infoPtr);
return;
}
infoPtr->fStatus &= ~BAND_NEEDS_LAYOUT;
if (!infoPtr->DoRedraw) infoPtr->fStatus |= BAND_NEEDS_REDRAW;
GetClientRect (infoPtr->hwndSelf, &rcClient);
TRACE("Client is (%ld,%ld)-(%ld,%ld)\n",
rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
if (lpRect) {
rcAdj = *lpRect;
TRACE("adjustment rect is (%ld,%ld)-(%ld,%ld)\n",
rcAdj.left, rcAdj.top, rcAdj.right, rcAdj.bottom);
}
else {
CopyRect (&rcAdj, &rcClient);
}
clientcx = rcClient.right - rcClient.left;
clientcy = rcClient.bottom - rcClient.top;
adjcx = rcAdj.right - rcAdj.left;
adjcy = rcAdj.bottom - rcAdj.top;
if (resetclient) {
TRACE("window client rect will be set to adj rect\n");
clientcx = adjcx;
clientcy = adjcy;
}
if (!infoPtr->DoRedraw && (clientcx == 0) && (clientcy == 0)) {
ERR("no redraw and client is zero, skip layout\n");
infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
return;
}
/* save height of original control */
if (infoPtr->dwStyle & CCS_VERT)
origheight = infoPtr->calcSize.cx;
else
origheight = infoPtr->calcSize.cy;
origrows = infoPtr->uNumRows;
initx = 0;
inity = 0;
/* ******* Start Phase 1 - all bands on row at minimum size ******* */
TRACE("band loop constants, clientcx=%d, clientcy=%d, adjcx=%d, adjcy=%d\n",
clientcx, clientcy, adjcx, adjcy);
x = initx;
y = inity;
row = 0;
cx = 0;
mcy = 0;
rowstart = 0;
prevBand = NULL;
cntonrow = 0;
for (i = 0; i < infoPtr->uNumBands; i++) {
lpBand = &infoPtr->bands[i];
lpBand->fDraw = 0;
lpBand->iRow = row;
SetRectEmpty(&lpBand->rcChevron);
if (HIDDENBAND(lpBand)) continue;
lpBand->rcoldBand = lpBand->rcBand;
/* Set the offset of the child window */
if ((lpBand->fMask & RBBIM_CHILD) &&
!(lpBand->fStyle & RBBS_FIXEDSIZE)) {
lpBand->offChild.cx = ((lpBand->fStyle & RBBS_CHILDEDGE) ? 4 : 0);
}
lpBand->offChild.cy = ((lpBand->fStyle & RBBS_CHILDEDGE) ? 2 : 0);
/* separator from previous band */
cxsep = (cntonrow == 0) ? 0 : SEP_WIDTH;
cx = lpBand->lcx;
if (infoPtr->dwStyle & CCS_VERT)
dobreak = (y + cx + cxsep > adjcy);
else
dobreak = (x + cx + cxsep > adjcx);
/* This is the check for whether we need to start a new row */
if ( ( (lpBand->fStyle & RBBS_BREAK) && (i != 0) ) ||
( ((infoPtr->dwStyle & CCS_VERT) ? (y != 0) : (x != 0)) && dobreak)) {
for (j = rowstart; j < i; j++) {
REBAR_BAND *lpB;
lpB = &infoPtr->bands[j];
if (infoPtr->dwStyle & CCS_VERT) {
lpB->rcBand.right = lpB->rcBand.left + mcy;
}
else {
lpB->rcBand.bottom = lpB->rcBand.top + mcy;
}
}
TRACE("P1 Spliting to new row %d on band %u\n", row+1, i);
if (infoPtr->dwStyle & CCS_VERT) {
y = inity;
x += (mcy + SEP_WIDTH);
}
else {
x = initx;
y += (mcy + SEP_WIDTH);
}
mcy = 0;
cxsep = 0;
row++;
lpBand->iRow = row;
prevBand = NULL;
rowstart = i;
cntonrow = 0;
}
if (mcy < lpBand->lcy + REBARSPACE(lpBand))
mcy = lpBand->lcy + REBARSPACE(lpBand);
/* if boundary rect specified then limit mcy */
if (lpRect) {
if (infoPtr->dwStyle & CCS_VERT) {
if (x+mcy > adjcx) {
mcy = adjcx - x;
TRACE("P1 row %u limiting mcy=%d, adjcx=%d, x=%d\n",
i, mcy, adjcx, x);
}
}
else {
if (y+mcy > adjcy) {
mcy = adjcy - y;
TRACE("P1 row %u limiting mcy=%d, adjcy=%d, y=%d\n",
i, mcy, adjcy, y);
}
}
}
TRACE("P1 band %u, row %d, x=%d, y=%d, cxsep=%d, cx=%d\n",
i, row,
x, y, cxsep, cx);
if (infoPtr->dwStyle & CCS_VERT) {
/* bound the bottom side if we have a bounding rectangle */
rightx = clientcx;
bottomy = (lpRect) ? min(clientcy, y+cxsep+cx) : y+cxsep+cx;
lpBand->rcBand.left = x;
lpBand->rcBand.right = x + min(mcy,
lpBand->lcy+REBARSPACE(lpBand));
lpBand->rcBand.top = min(bottomy, y + cxsep);
lpBand->rcBand.bottom = bottomy;
lpBand->uMinHeight = lpBand->lcy;
y = bottomy;
}
else {
/* bound the right side if we have a bounding rectangle */
rightx = (lpRect) ? min(clientcx, x+cxsep+cx) : x+cxsep+cx;
bottomy = clientcy;
lpBand->rcBand.left = min(rightx, x + cxsep);
lpBand->rcBand.right = rightx;
lpBand->rcBand.top = y;
lpBand->rcBand.bottom = y + min(mcy,
lpBand->lcy+REBARSPACE(lpBand));
lpBand->uMinHeight = lpBand->lcy;
x = rightx;
}
TRACE("P1 band %u, row %d, (%ld,%ld)-(%ld,%ld)\n",
i, row,
lpBand->rcBand.left, lpBand->rcBand.top,
lpBand->rcBand.right, lpBand->rcBand.bottom);
prevBand = lpBand;
cntonrow++;
} /* for (i = 0; i < infoPtr->uNumBands... */
if (infoPtr->dwStyle & CCS_VERT)
x += mcy;
else
y += mcy;
for (j = rowstart; j < infoPtr->uNumBands; j++) {
lpBand = &infoPtr->bands[j];
if (infoPtr->dwStyle & CCS_VERT) {
lpBand->rcBand.right = lpBand->rcBand.left + mcy;
}
else {
lpBand->rcBand.bottom = lpBand->rcBand.top + mcy;
}
}
if (infoPtr->uNumBands)
infoPtr->uNumRows = row + 1;
/* ******* End Phase 1 - all bands on row at minimum size ******* */
/* ******* Start Phase 1a - Adjust heights for RBS_VARHEIGHT off ******* */
mmcy = 0;
if (!(infoPtr->dwStyle & RBS_VARHEIGHT)) {
INT xy;
/* get the max height of all bands */
for (i=0; i<infoPtr->uNumBands; i++) {
lpBand = &infoPtr->bands[i];
if (HIDDENBAND(lpBand)) continue;
if (infoPtr->dwStyle & CCS_VERT)
mmcy = max(mmcy, lpBand->rcBand.right - lpBand->rcBand.left);
else
mmcy = max(mmcy, lpBand->rcBand.bottom - lpBand->rcBand.top);
}
/* now adjust all rectangles by using the height found above */
xy = 0;
row = 0;
for (i=0; i<infoPtr->uNumBands; i++) {
lpBand = &infoPtr->bands[i];
if (HIDDENBAND(lpBand)) continue;
if (lpBand->iRow != row)
xy += (mmcy + SEP_WIDTH);
if (infoPtr->dwStyle & CCS_VERT) {
lpBand->rcBand.left = xy;
lpBand->rcBand.right = xy + mmcy;
}
else {
lpBand->rcBand.top = xy;
lpBand->rcBand.bottom = xy + mmcy;
}
}
/* set the x/y values to the correct maximum */
if (infoPtr->dwStyle & CCS_VERT)
x = xy + mmcy;
else
y = xy + mmcy;
}
/* ******* End Phase 1a - Adjust heights for RBS_VARHEIGHT off ******* */
/* ******* Start Phase 2 - split rows till adjustment height full ******* */
/* assumes that the following variables contain: */
/* y/x current height/width of all rows */
if (lpRect) {
INT i, prev_rh, new_rh, adj_rh, prev_idx, current_idx;
REBAR_BAND *prev, *current, *walk;
UINT j;
/* FIXME: problem # 2 */
if (((infoPtr->dwStyle & CCS_VERT) ?
#if PROBLEM2
(x < adjcx) : (y < adjcy)
#else
(adjcx - x > 5) : (adjcy - y > 4)
#endif
) &&
(infoPtr->uNumBands > 1)) {
for (i=(INT)infoPtr->uNumBands-2; i>=0; i--) {
TRACE("P2 adjcx=%d, adjcy=%d, x=%d, y=%d\n",
adjcx, adjcy, x, y);
/* find the current band (starts at i+1) */
current = &infoPtr->bands[i+1];
current_idx = i+1;
while (HIDDENBAND(current)) {
i--;
if (i < 0) break; /* out of bands */
current = &infoPtr->bands[i+1];
current_idx = i+1;
}
if (i < 0) break; /* out of bands */
/* now find the prev band (starts at i) */
prev = &infoPtr->bands[i];
prev_idx = i;
while (HIDDENBAND(prev)) {
i--;
if (i < 0) break; /* out of bands */
prev = &infoPtr->bands[i];
prev_idx = i;
}
if (i < 0) break; /* out of bands */
prev_rh = ircBw(prev);
if (prev->iRow == current->iRow) {
new_rh = (infoPtr->dwStyle & RBS_VARHEIGHT) ?
current->lcy + REBARSPACE(current) :
mmcy;
adj_rh = new_rh + SEP_WIDTH;
infoPtr->uNumRows++;
current->fDraw |= NTF_INVALIDATE;
current->iRow++;
if (infoPtr->dwStyle & CCS_VERT) {
current->rcBand.top = inity;
current->rcBand.bottom = clientcy;
current->rcBand.left += (prev_rh + SEP_WIDTH);
current->rcBand.right = current->rcBand.left + new_rh;
x += adj_rh;
}
else {
current->rcBand.left = initx;
current->rcBand.right = clientcx;
current->rcBand.top += (prev_rh + SEP_WIDTH);
current->rcBand.bottom = current->rcBand.top + new_rh;
y += adj_rh;
}
TRACE("P2 moving band %d to own row at (%ld,%ld)-(%ld,%ld)\n",
current_idx,
current->rcBand.left, current->rcBand.top,
current->rcBand.right, current->rcBand.bottom);
TRACE("P2 prev band %d at (%ld,%ld)-(%ld,%ld)\n",
prev_idx,
prev->rcBand.left, prev->rcBand.top,
prev->rcBand.right, prev->rcBand.bottom);
TRACE("P2 values: prev_rh=%d, new_rh=%d, adj_rh=%d\n",
prev_rh, new_rh, adj_rh);
/* for bands below current adjust row # and top/bottom */
for (j = current_idx+1; j<infoPtr->uNumBands; j++) {
walk = &infoPtr->bands[j];
if (HIDDENBAND(walk)) continue;
walk->fDraw |= NTF_INVALIDATE;
walk->iRow++;
if (infoPtr->dwStyle & CCS_VERT) {
walk->rcBand.left += adj_rh;
walk->rcBand.right += adj_rh;
}
else {
walk->rcBand.top += adj_rh;
walk->rcBand.bottom += adj_rh;
}
}
if ((infoPtr->dwStyle & CCS_VERT) ? (x >= adjcx) : (y >= adjcy))
break; /* all done */
}
}
}
}
/* ******* End Phase 2 - split rows till adjustment height full ******* */
/* ******* Start Phase 2a - mark first and last band in each ******* */
prevBand = NULL;
for (i = 0; i < infoPtr->uNumBands; i++) {
lpBand = &infoPtr->bands[i];
if (HIDDENBAND(lpBand))
continue;
if( !prevBand ) {
lpBand->fDraw |= DRAW_FIRST_IN_ROW;
prevBand = lpBand;
}
else if( prevBand->iRow == lpBand->iRow )
prevBand = lpBand;
else {
prevBand->fDraw |= DRAW_LAST_IN_ROW;
lpBand->fDraw |= DRAW_FIRST_IN_ROW;
prevBand = lpBand;
}
}
if( prevBand )
prevBand->fDraw |= DRAW_LAST_IN_ROW;
/* ******* End Phase 2a - mark first and last band in each ******* */
/* ******* Start Phase 2b - adjust all bands for height full ******* */
/* assumes that the following variables contain: */
/* y/x current height/width of all rows */
/* clientcy/clientcx height/width of client area */
if (((infoPtr->dwStyle & CCS_VERT) ? clientcx > x : clientcy > y) &&
infoPtr->uNumBands) {
INT diff, i;
UINT j;
diff = (infoPtr->dwStyle & CCS_VERT) ? clientcx - x : clientcy - y;
/* iterate backwards thru the rows */
for (i = infoPtr->uNumBands-1; i>=0; i--) {
lpBand = &infoPtr->bands[i];
if(HIDDENBAND(lpBand)) continue;
/* if row has more than 1 band, ignore it */
if( !(lpBand->fDraw&DRAW_FIRST_IN_ROW) )
continue;
if( !(lpBand->fDraw&DRAW_LAST_IN_ROW) )
continue;
/* FIXME: this next line is wrong, but fixing it to be inverted causes IE's sidebars to be the wrong size */
if (lpBand->fMask & RBBS_VARIABLEHEIGHT) continue;
if (((INT)lpBand->cyMaxChild < 1) ||
((INT)lpBand->cyIntegral < 1)) {
if (lpBand->cyMaxChild + lpBand->cyIntegral == 0) continue;
ERR("P2b band %u RBBS_VARIABLEHEIGHT set but cyMax=%d, cyInt=%d\n",
i, lpBand->cyMaxChild, lpBand->cyIntegral);
continue;
}
/* j is now the maximum height/width in the client area */
j = ((diff / lpBand->cyIntegral) * lpBand->cyIntegral) +
ircBw(lpBand);
if (j > lpBand->cyMaxChild + REBARSPACE(lpBand))
j = lpBand->cyMaxChild + REBARSPACE(lpBand);
diff -= (j - ircBw(lpBand));
if (infoPtr->dwStyle & CCS_VERT)
lpBand->rcBand.right = lpBand->rcBand.left + j;
else
lpBand->rcBand.bottom = lpBand->rcBand.top + j;
TRACE("P2b band %d, row %d changed to (%ld,%ld)-(%ld,%ld)\n",
i, lpBand->iRow,
lpBand->rcBand.left, lpBand->rcBand.top,
lpBand->rcBand.right, lpBand->rcBand.bottom);
if (diff <= 0) break;
}
if (diff < 0) {
ERR("P2b allocated more than available, diff=%d\n", diff);
diff = 0;
}
if (infoPtr->dwStyle & CCS_VERT)
x = clientcx - diff;
else
y = clientcy - diff;
}
/* ******* End Phase 2b - adjust all bands for height full ******* */
/* ******* Start Phase 3 - adjust all bands for width full ******* */
if (infoPtr->uNumBands) {
int startband;
/* If RBS_BANDBORDERS set then indicate to draw bottom separator */
/* on all bands in all rows but last row. */
/* Also indicate to draw the right separator for each band in */
/* each row but the rightmost band. */
if (infoPtr->dwStyle & RBS_BANDBORDERS) {
for (i=0; i<infoPtr->uNumBands; i++) {
lpBand = &infoPtr->bands[i];
if (HIDDENBAND(lpBand))
continue;
/* not righthand bands */
if( !(lpBand->fDraw & DRAW_LAST_IN_ROW) )
lpBand->fDraw |= DRAW_RIGHTSEP;
/* not the last row */
if( lpBand->iRow != infoPtr->uNumRows )
lpBand->fDraw |= DRAW_BOTTOMSEP;
}
}
/* Distribute the extra space on the horizontal and adjust */
/* all bands in row to same height. */
mcy = 0;
startband = -1;
for (i=0; i<infoPtr->uNumBands; i++) {
lpBand = &infoPtr->bands[i];
if( lpBand->fDraw & DRAW_FIRST_IN_ROW )
{
startband = i;
mcy = 0;
}
if ( (mcy < ircBw(lpBand)) && !HIDDENBAND(lpBand) )
mcy = ircBw(lpBand);
if( lpBand->fDraw & DRAW_LAST_IN_ROW )
{
TRACE("P3 processing row %d, starting band %d, ending band %d\n",
lpBand->iRow, startband, i);
if( startband < 0 )
ERR("Last band %d with no first, row %d\n", i, lpBand->iRow);
REBAR_AdjustBands (infoPtr, startband, i,
(infoPtr->dwStyle & CCS_VERT) ?
clientcy : clientcx, mcy);
}
}
/* Calculate the other rectangles in each band */
if (infoPtr->dwStyle & CCS_VERT) {
REBAR_CalcVertBand (infoPtr, 0, infoPtr->uNumBands,
notify);
}
else {
REBAR_CalcHorzBand (infoPtr, 0, infoPtr->uNumBands,
notify);
}
}
/* ******* End Phase 3 - adjust all bands for width full ******* */
/* now compute size of Rebar itself */
infoPtr->oldSize = infoPtr->calcSize;
if (infoPtr->uNumBands == 0) {
/* we have no bands, so make size the size of client */
x = clientcx;
y = clientcy;
}
if (infoPtr->dwStyle & CCS_VERT) {
if( x < REBAR_MINSIZE )
x = REBAR_MINSIZE;
infoPtr->calcSize.cx = x;
infoPtr->calcSize.cy = clientcy;
TRACE("vert, notify=%d, x=%d, origheight=%d\n",
notify, x, origheight);
if (notify && (x != origheight)) infoPtr->fStatus |= NTF_HGHTCHG;
}
else {
if( y < REBAR_MINSIZE )
y = REBAR_MINSIZE;
infoPtr->calcSize.cx = clientcx;
infoPtr->calcSize.cy = y;
TRACE("horz, notify=%d, y=%d, origheight=%d\n",
notify, y, origheight);
if (notify && (y != origheight)) infoPtr->fStatus |= NTF_HGHTCHG;
}
REBAR_DumpBand (infoPtr);
REBAR_MoveChildWindows (infoPtr, 0, infoPtr->uNumBands);
REBAR_ForceResize (infoPtr);
}
static VOID
REBAR_ValidateBand (REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
/* Function: This routine evaluates the band specs supplied */
/* by the user and updates the following 5 fields in */
/* the internal band structure: cxHeader, lcx, lcy, hcx, hcy*/
{
UINT header=0;
UINT textheight=0;
UINT i, nonfixed;
REBAR_BAND *tBand;
lpBand->fStatus = 0;
lpBand->lcx = 0;
lpBand->lcy = 0;
lpBand->ccx = 0;
lpBand->ccy = 0;
lpBand->hcx = 0;
lpBand->hcy = 0;
/* Data comming in from users into the cx... and cy... fields */
/* may be bad, just garbage, because the user never clears */
/* the fields. RB_{SET|INSERT}BAND{A|W} just passes the data */
/* along if the fields exist in the input area. Here we must */
/* determine if the data is valid. I have no idea how MS does */
/* the validation, but it does because the RB_GETBANDINFO */
/* returns a 0 when I know the sample program passed in an */
/* address. Here I will use the algorithim that if the value */
/* is greater than 65535 then it is bad and replace it with */
/* a zero. Feel free to improve the algorithim. - GA 12/2000 */
if (lpBand->cxMinChild > 65535) lpBand->cxMinChild = 0;
if (lpBand->cyMinChild > 65535) lpBand->cyMinChild = 0;
if (lpBand->cx > 65535) lpBand->cx = 0;
if (lpBand->cyChild > 65535) lpBand->cyChild = 0;
if (lpBand->cyMaxChild > 65535) lpBand->cyMaxChild = 0;
if (lpBand->cyIntegral > 65535) lpBand->cyIntegral = 0;
if (lpBand->cxIdeal > 65535) lpBand->cxIdeal = 0;
if (lpBand->cxHeader > 65535) lpBand->cxHeader = 0;
/* FIXME: probably should only set NEEDS_LAYOUT flag when */
/* values change. Till then always set it. */
TRACE("setting NEEDS_LAYOUT\n");
infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
/* Header is where the image, text and gripper exist */
/* in the band and precede the child window. */
/* count number of non-FIXEDSIZE and non-Hidden bands */
nonfixed = 0;
for (i=0; i<infoPtr->uNumBands; i++){
tBand = &infoPtr->bands[i];
if (!HIDDENBAND(tBand) && !(tBand->fStyle & RBBS_FIXEDSIZE))
nonfixed++;
}
/* calculate gripper rectangle */
if ( (!(lpBand->fStyle & RBBS_NOGRIPPER)) &&
( (lpBand->fStyle & RBBS_GRIPPERALWAYS) ||
( !(lpBand->fStyle & RBBS_FIXEDSIZE) && (nonfixed > 1)))
) {
lpBand->fStatus |= HAS_GRIPPER;
if (infoPtr->dwStyle & CCS_VERT)
if (infoPtr->dwStyle & RBS_VERTICALGRIPPER)
header += (GRIPPER_HEIGHT + REBAR_PRE_GRIPPER);
else
header += (GRIPPER_WIDTH + REBAR_PRE_GRIPPER);
else
header += (REBAR_PRE_GRIPPER + GRIPPER_WIDTH);
/* Always have 4 pixels before anything else */
header += REBAR_ALWAYS_SPACE;
}
/* image is visible */
if ((lpBand->fMask & RBBIM_IMAGE) && (infoPtr->himl)) {
lpBand->fStatus |= HAS_IMAGE;
if (infoPtr->dwStyle & CCS_VERT) {
header += (infoPtr->imageSize.cy + REBAR_POST_IMAGE);
lpBand->lcy = infoPtr->imageSize.cx + 2;
}
else {
header += (infoPtr->imageSize.cx + REBAR_POST_IMAGE);
lpBand->lcy = infoPtr->imageSize.cy + 2;
}
}
/* text is visible */
if ((lpBand->fMask & RBBIM_TEXT) && (lpBand->lpText) &&
!(lpBand->fStyle & RBBS_HIDETITLE)) {
HDC hdc = GetDC (0);
HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
SIZE size;
lpBand->fStatus |= HAS_TEXT;
GetTextExtentPoint32W (hdc, lpBand->lpText,
lstrlenW (lpBand->lpText), &size);
header += ((infoPtr->dwStyle & CCS_VERT) ? (size.cy + REBAR_POST_TEXT) : (size.cx + REBAR_POST_TEXT));
textheight = (infoPtr->dwStyle & CCS_VERT) ? 0 : size.cy;
SelectObject (hdc, hOldFont);
ReleaseDC (0, hdc);
}
/* if no gripper but either image or text, then leave space */
if ((lpBand->fStatus & (HAS_IMAGE | HAS_TEXT)) &&
!(lpBand->fStatus & HAS_GRIPPER)) {
header += REBAR_ALWAYS_SPACE;
}
/* check if user overrode the header value */
if (!(lpBand->fMask & RBBIM_HEADERSIZE))
lpBand->cxHeader = header;
/* Now compute minimum size of child window */
lpBand->offChild.cx = 0;
lpBand->offChild.cy = 0;
lpBand->lcy = textheight;
lpBand->ccy = lpBand->lcy;
if (lpBand->fMask & RBBIM_CHILDSIZE) {
lpBand->lcx = lpBand->cxMinChild;
/* Set the .cy values for CHILDSIZE case */
lpBand->lcy = max(lpBand->lcy, lpBand->cyMinChild);
lpBand->ccy = lpBand->lcy;
lpBand->hcy = lpBand->lcy;
if (lpBand->cyMaxChild != 0xffffffff) {
lpBand->hcy = lpBand->cyMaxChild;
}
if (lpBand->cyChild != 0xffffffff)
lpBand->ccy = max (lpBand->cyChild, lpBand->lcy);
TRACE("_CHILDSIZE\n");
}
if (lpBand->fMask & RBBIM_SIZE) {
lpBand->hcx = max (lpBand->cx-lpBand->cxHeader, lpBand->lcx);
TRACE("_SIZE\n");
}
else
lpBand->hcx = lpBand->lcx;
lpBand->ccx = lpBand->hcx;
/* make ->.cx include header size for _Layout */
lpBand->lcx += lpBand->cxHeader;
lpBand->ccx += lpBand->cxHeader;
lpBand->hcx += lpBand->cxHeader;
}
static BOOL
REBAR_CommonSetupBand (HWND hwnd, LPREBARBANDINFOA lprbbi, REBAR_BAND *lpBand)
/* Function: This routine copies the supplied values from */
/* user input (lprbbi) to the internal band structure. */
/* It returns true if something changed and false if not. */
{
BOOL bChanged = FALSE;
lpBand->fMask |= lprbbi->fMask;
if( (lprbbi->fMask & RBBIM_STYLE) &&
(lpBand->fStyle != lprbbi->fStyle ) )
{
lpBand->fStyle = lprbbi->fStyle;
bChanged = TRUE;
}
if( (lprbbi->fMask & RBBIM_COLORS) &&
( ( lpBand->clrFore != lprbbi->clrFore ) ||
( lpBand->clrBack != lprbbi->clrBack ) ) )
{
lpBand->clrFore = lprbbi->clrFore;
lpBand->clrBack = lprbbi->clrBack;
bChanged = TRUE;
}
if( (lprbbi->fMask & RBBIM_IMAGE) &&
( lpBand->iImage != lprbbi->iImage ) )
{
lpBand->iImage = lprbbi->iImage;
bChanged = TRUE;
}
if( (lprbbi->fMask & RBBIM_CHILD) &&
(lprbbi->hwndChild != lpBand->hwndChild ) )
{
if (lprbbi->hwndChild) {
lpBand->hwndChild = lprbbi->hwndChild;
lpBand->hwndPrevParent =
SetParent (lpBand->hwndChild, hwnd);
/* below in trace fro WinRAR */
ShowWindow(lpBand->hwndChild, SW_SHOWNOACTIVATE | SW_SHOWNORMAL);
/* above in trace fro WinRAR */
}
else {
TRACE("child: %p prev parent: %p\n",
lpBand->hwndChild, lpBand->hwndPrevParent);
lpBand->hwndChild = 0;
lpBand->hwndPrevParent = 0;
}
bChanged = TRUE;
}
if( (lprbbi->fMask & RBBIM_CHILDSIZE) &&
( (lpBand->cxMinChild != lprbbi->cxMinChild) ||
(lpBand->cyMinChild != lprbbi->cyMinChild ) ||
( (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) &&
( (lpBand->cyChild != lprbbi->cyChild ) ||
(lpBand->cyMaxChild != lprbbi->cyMaxChild ) ||
(lpBand->cyIntegral != lprbbi->cyIntegral ) ) ) ||
( (lprbbi->cbSize < sizeof (REBARBANDINFOA)) &&
( (lpBand->cyChild ||
lpBand->cyMaxChild ||
lpBand->cyIntegral ) ) ) ) )
{
lpBand->cxMinChild = lprbbi->cxMinChild;
lpBand->cyMinChild = lprbbi->cyMinChild;
if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
lpBand->cyChild = lprbbi->cyChild;
lpBand->cyMaxChild = lprbbi->cyMaxChild;
lpBand->cyIntegral = lprbbi->cyIntegral;
}
else { /* special case - these should be zeroed out since */
/* RBBIM_CHILDSIZE added these in WIN32_IE >= 0x0400 */
lpBand->cyChild = 0;
lpBand->cyMaxChild = 0;
lpBand->cyIntegral = 0;
}
bChanged = TRUE;
}
if( (lprbbi->fMask & RBBIM_SIZE) &&
(lpBand->cx != lprbbi->cx ) )
{
lpBand->cx = lprbbi->cx;
bChanged = TRUE;
}
if( (lprbbi->fMask & RBBIM_BACKGROUND) &&
( lpBand->hbmBack != lprbbi->hbmBack ) )
{
lpBand->hbmBack = lprbbi->hbmBack;
bChanged = TRUE;
}
if( (lprbbi->fMask & RBBIM_ID) &&
(lpBand->wID != lprbbi->wID ) )
{
lpBand->wID = lprbbi->wID;
bChanged = TRUE;
}
/* check for additional data */
if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
if( (lprbbi->fMask & RBBIM_IDEALSIZE) &&
( lpBand->cxIdeal != lprbbi->cxIdeal ) )
{
lpBand->cxIdeal = lprbbi->cxIdeal;
bChanged = TRUE;
}
if( (lprbbi->fMask & RBBIM_LPARAM) &&
(lpBand->lParam != lprbbi->lParam ) )
{
lpBand->lParam = lprbbi->lParam;
bChanged = TRUE;
}
if( (lprbbi->fMask & RBBIM_HEADERSIZE) &&
(lpBand->cxHeader != lprbbi->cxHeader ) )
{
lpBand->cxHeader = lprbbi->cxHeader;
bChanged = TRUE;
}
}
return bChanged;
}
static LRESULT
REBAR_InternalEraseBkGnd (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam, RECT *clip)
/* Function: This erases the background rectangle by drawing */
/* each band with its background color (or the default) and */
/* draws each bands right separator if necessary. The row */
/* separators are drawn on the first band of the next row. */
{
REBAR_BAND *lpBand;
UINT i;
INT oldrow;
HDC hdc = (HDC)wParam;
RECT rect;
COLORREF old = CLR_NONE, new;
oldrow = -1;
for(i=0; i<infoPtr->uNumBands; i++) {
lpBand = &infoPtr->bands[i];
if (HIDDENBAND(lpBand)) continue;
/* draw band separator between rows */
if (lpBand->iRow != oldrow) {
oldrow = lpBand->iRow;
if (lpBand->fDraw & DRAW_BOTTOMSEP) {
RECT rcRowSep;
rcRowSep = lpBand->rcBand;
if (infoPtr->dwStyle & CCS_VERT) {
rcRowSep.right += SEP_WIDTH_SIZE;
rcRowSep.bottom = infoPtr->calcSize.cy;
DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_RIGHT);
}
else {
rcRowSep.bottom += SEP_WIDTH_SIZE;
rcRowSep.right = infoPtr->calcSize.cx;
DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_BOTTOM);
}
TRACE ("drawing band separator bottom (%ld,%ld)-(%ld,%ld)\n",
rcRowSep.left, rcRowSep.top,
rcRowSep.right, rcRowSep.bottom);
}
}
/* draw band separator between bands in a row */
if (lpBand->fDraw & DRAW_RIGHTSEP) {
RECT rcSep;
rcSep = lpBand->rcBand;
if (infoPtr->dwStyle & CCS_VERT) {
rcSep.bottom += SEP_WIDTH_SIZE;
DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_BOTTOM);
}
else {
rcSep.right += SEP_WIDTH_SIZE;
DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_RIGHT);
}
TRACE("drawing band separator right (%ld,%ld)-(%ld,%ld)\n",
rcSep.left, rcSep.top, rcSep.right, rcSep.bottom);
}
/* draw the actual background */
if (lpBand->clrBack != CLR_NONE) {
new = (lpBand->clrBack == CLR_DEFAULT) ? infoPtr->clrBtnFace :
lpBand->clrBack;
#if GLATESTING
/* testing only - make background green to see it */
new = RGB(0,128,0);
#endif
}
else {
/* In the absence of documentation for Rebar vs. CLR_NONE,
* we will use the default BtnFace color. Note documentation
* exists for Listview and Imagelist.
*/
new = infoPtr->clrBtnFace;
#if GLATESTING
/* testing only - make background green to see it */
new = RGB(0,128,0);
#endif
}
old = SetBkColor (hdc, new);
rect = lpBand->rcBand;
TRACE("%s background color=0x%06lx, band (%ld,%ld)-(%ld,%ld), clip (%ld,%ld)-(%ld,%ld)\n",
(lpBand->clrBack == CLR_NONE) ? "none" :
((lpBand->clrBack == CLR_DEFAULT) ? "dft" : ""),
GetBkColor(hdc),
lpBand->rcBand.left,lpBand->rcBand.top,
lpBand->rcBand.right,lpBand->rcBand.bottom,
clip->left, clip->top,
clip->right, clip->bottom);
ExtTextOutW (hdc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, 0);
if (lpBand->clrBack != CLR_NONE)
SetBkColor (hdc, old);
}
return TRUE;
}
static void
REBAR_InternalHitTest (REBAR_INFO *infoPtr, const LPPOINT lpPt, UINT *pFlags, INT *pBand)
{
REBAR_BAND *lpBand;
RECT rect;
UINT iCount;
GetClientRect (infoPtr->hwndSelf, &rect);
*pFlags = RBHT_NOWHERE;
if (PtInRect (&rect, *lpPt))
{
if (infoPtr->uNumBands == 0) {
*pFlags = RBHT_NOWHERE;
if (pBand)
*pBand = -1;
TRACE("NOWHERE\n");
return;
}
else {
/* somewhere inside */
for (iCount = 0; iCount < infoPtr->uNumBands; iCount++) {
lpBand = &infoPtr->bands[iCount];
if (HIDDENBAND(lpBand)) continue;
if (PtInRect (&lpBand->rcBand, *lpPt)) {
if (pBand)
*pBand = iCount;
if (PtInRect (&lpBand->rcGripper, *lpPt)) {
*pFlags = RBHT_GRABBER;
TRACE("ON GRABBER %d\n", iCount);
return;
}
else if (PtInRect (&lpBand->rcCapImage, *lpPt)) {
*pFlags = RBHT_CAPTION;
TRACE("ON CAPTION %d\n", iCount);
return;
}
else if (PtInRect (&lpBand->rcCapText, *lpPt)) {
*pFlags = RBHT_CAPTION;
TRACE("ON CAPTION %d\n", iCount);
return;
}
else if (PtInRect (&lpBand->rcChild, *lpPt)) {
*pFlags = RBHT_CLIENT;
TRACE("ON CLIENT %d\n", iCount);
return;
}
else if (PtInRect (&lpBand->rcChevron, *lpPt)) {
*pFlags = RBHT_CHEVRON;
TRACE("ON CHEVRON %d\n", iCount);
return;
}
else {
*pFlags = RBHT_NOWHERE;
TRACE("NOWHERE %d\n", iCount);
return;
}
}
}
*pFlags = RBHT_NOWHERE;
if (pBand)
*pBand = -1;
TRACE("NOWHERE\n");
return;
}
}
else {
*pFlags = RBHT_NOWHERE;
if (pBand)
*pBand = -1;
TRACE("NOWHERE\n");
return;
}
}
static INT
REBAR_Shrink (REBAR_INFO *infoPtr, REBAR_BAND *band, INT movement, INT i)
/* Function: This attempts to shrink the given band by the */
/* the amount in "movement". A shrink to the left is indi- */
/* cated by "movement" being negative. "i" is merely the */
/* band index for trace messages. */
{
INT Leadjust, Readjust, avail, ret;
/* Note: a left drag is indicated by "movement" being negative. */
/* Similarly, a right drag is indicated by "movement" */
/* being positive. "movement" should never be 0, but if */
/* it is then the band does not move. */
avail = rcBw(band) - band->lcx;
/* now compute the Left End adjustment factor and Right End */
/* adjustment factor. They may be different if shrinking. */
if (avail <= 0) {
/* if this band is not shrinkable, then just move it */
Leadjust = Readjust = movement;
ret = movement;
}
else {
if (movement < 0) {
/* Drag to left */
if (avail <= abs(movement)) {
Readjust = movement;
Leadjust = movement + avail;
ret = Leadjust;
}
else {
Readjust = movement;
Leadjust = 0;
ret = 0;
}
}
else {
/* Drag to right */
if (avail <= abs(movement)) {
Leadjust = movement;
Readjust = movement - avail;
ret = Readjust;
}
else {
Leadjust = movement;
Readjust = 0;
ret = 0;
}
}
}
/* Reasonability Check */
if (rcBlt(band) + Leadjust < 0) {
ERR("adjustment will fail, band %d: left=%d, right=%d, move=%d, rtn=%d\n",
i, Leadjust, Readjust, movement, ret);
}
LEADJ(band, Leadjust);
READJ(band, Readjust);
TRACE("band %d: left=%d, right=%d, move=%d, rtn=%d, rcBand=(%ld,%ld)-(%ld,%ld)\n",
i, Leadjust, Readjust, movement, ret,
band->rcBand.left, band->rcBand.top,
band->rcBand.right, band->rcBand.bottom);
return ret;
}
static void
REBAR_HandleLRDrag (REBAR_INFO *infoPtr, const POINT *ptsmove)
/* Function: This will implement the functionality of a */
/* Gripper drag within a row. It will not implement "out- */
/* of-row" drags. (They are detected and handled in */
/* REBAR_MouseMove.) */
/* **** FIXME Switching order of bands in a row not **** */
/* **** yet implemented. **** */
{
REBAR_BAND *hitBand, *band, *mindBand, *maxdBand;
RECT newrect;
INT imindBand = -1, imaxdBand, ihitBand, i, movement;
INT RHeaderSum = 0, LHeaderSum = 0;
INT compress;
/* on first significant mouse movement, issue notify */
if (!(infoPtr->fStatus & BEGIN_DRAG_ISSUED)) {
if (REBAR_Notify_NMREBAR (infoPtr, -1, RBN_BEGINDRAG)) {
/* Notify returned TRUE - abort drag */
infoPtr->dragStart.x = 0;
infoPtr->dragStart.y = 0;
infoPtr->dragNow = infoPtr->dragStart;
infoPtr->iGrabbedBand = -1;
ReleaseCapture ();
return ;
}
infoPtr->fStatus |= BEGIN_DRAG_ISSUED;
}
ihitBand = infoPtr->iGrabbedBand;
hitBand = &infoPtr->bands[ihitBand];
imaxdBand = ihitBand; /* to suppress warning message */
/* find all the bands in the row of the one whose Gripper was seized */
for (i=0; i<infoPtr->uNumBands; i++) {
band = &infoPtr->bands[i];
if (HIDDENBAND(band)) continue;
if (band->iRow == hitBand->iRow) {
imaxdBand = i;
if (imindBand == -1) imindBand = i;
/* minimum size of each band is size of header plus */
/* size of minimum child plus offset of child from header plus */
/* one to separate each band. */
if (i < ihitBand)
LHeaderSum += (band->lcx + SEP_WIDTH);
else
RHeaderSum += (band->lcx + SEP_WIDTH);
}
}
if (RHeaderSum) RHeaderSum -= SEP_WIDTH; /* no separator after last band */
mindBand = &infoPtr->bands[imindBand];
maxdBand = &infoPtr->bands[imaxdBand];
if (imindBand == imaxdBand) return; /* nothing to drag against */
if (imindBand == ihitBand) return; /* first band in row, can't drag */
/* limit movement to inside adjustable bands - Left */
if ( (ptsmove->x < mindBand->rcBand.left) ||
(ptsmove->x > maxdBand->rcBand.right) ||
(ptsmove->y < mindBand->rcBand.top) ||
(ptsmove->y > maxdBand->rcBand.bottom))
return; /* should swap bands */
if (infoPtr->dwStyle & CCS_VERT)
movement = ptsmove->y - ((hitBand->rcBand.top+REBAR_PRE_GRIPPER) -
infoPtr->ihitoffset);
else
movement = ptsmove->x - ((hitBand->rcBand.left+REBAR_PRE_GRIPPER) -
infoPtr->ihitoffset);
infoPtr->dragNow = *ptsmove;
TRACE("before: movement=%d (%ld,%ld), imindBand=%d, ihitBand=%d, imaxdBand=%d, LSum=%d, RSum=%d\n",
movement, ptsmove->x, ptsmove->y, imindBand, ihitBand,
imaxdBand, LHeaderSum, RHeaderSum);
REBAR_DumpBand (infoPtr);
if (movement < 0) {
/* *** Drag left/up *** */
compress = rcBlt(hitBand) - rcBlt(mindBand) -
LHeaderSum;
if (compress < abs(movement)) {
TRACE("limiting left drag, was %d changed to %d\n",
movement, -compress);
movement = -compress;
}
for (i=ihitBand; i>=imindBand; i--) {
band = &infoPtr->bands[i];
if (HIDDENBAND(band)) continue;
if (i == ihitBand) {
LEADJ(band, movement);
}
else
movement = REBAR_Shrink (infoPtr, band, movement, i);
band->ccx = rcBw(band);
}
}
else {
BOOL first = TRUE;
/* *** Drag right/down *** */
compress = rcBrb(maxdBand) - rcBlt(hitBand) -
RHeaderSum;
if (compress < abs(movement)) {
TRACE("limiting right drag, was %d changed to %d\n",
movement, compress);
movement = compress;
}
for (i=ihitBand-1; i<=imaxdBand; i++) {
band = &infoPtr->bands[i];
if (HIDDENBAND(band)) continue;
if (first) {
first = FALSE;
READJ(band, movement);
}
else
movement = REBAR_Shrink (infoPtr, band, movement, i);
band->ccx = rcBw(band);
}
}
/* recompute all rectangles */
if (infoPtr->dwStyle & CCS_VERT) {
REBAR_CalcVertBand (infoPtr, imindBand, imaxdBand+1,
FALSE);
}
else {
REBAR_CalcHorzBand (infoPtr, imindBand, imaxdBand+1,
FALSE);
}
TRACE("bands after adjustment, see band # %d, %d\n",
imindBand, imaxdBand);
REBAR_DumpBand (infoPtr);
SetRect (&newrect,
mindBand->rcBand.left,
mindBand->rcBand.top,
maxdBand->rcBand.right,
maxdBand->rcBand.bottom);
REBAR_MoveChildWindows (infoPtr, imindBand, imaxdBand+1);
InvalidateRect (infoPtr->hwndSelf, &newrect, TRUE);
UpdateWindow (infoPtr->hwndSelf);
}
/* << REBAR_BeginDrag >> */
static LRESULT
REBAR_DeleteBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
UINT uBand = (UINT)wParam;
HWND childhwnd = 0;
REBAR_BAND *lpBand;
if (uBand >= infoPtr->uNumBands)
return FALSE;
TRACE("deleting band %u!\n", uBand);
lpBand = &infoPtr->bands[uBand];
REBAR_Notify_NMREBAR (infoPtr, uBand, RBN_DELETINGBAND);
if (infoPtr->uNumBands == 1) {
TRACE(" simple delete!\n");
if ((lpBand->fMask & RBBIM_CHILD) && lpBand->hwndChild)
childhwnd = lpBand->hwndChild;
Free (infoPtr->bands);
infoPtr->bands = NULL;
infoPtr->uNumBands = 0;
}
else {
REBAR_BAND *oldBands = infoPtr->bands;
TRACE("complex delete! [uBand=%u]\n", uBand);
if ((lpBand->fMask & RBBIM_CHILD) && lpBand->hwndChild)
childhwnd = lpBand->hwndChild;
infoPtr->uNumBands--;
infoPtr->bands = Alloc (sizeof (REBAR_BAND) * infoPtr->uNumBands);
if (uBand > 0) {
memcpy (&infoPtr->bands[0], &oldBands[0],
uBand * sizeof(REBAR_BAND));
}
if (uBand < infoPtr->uNumBands) {
memcpy (&infoPtr->bands[uBand], &oldBands[uBand+1],
(infoPtr->uNumBands - uBand) * sizeof(REBAR_BAND));
}
Free (oldBands);
}
if (childhwnd)
ShowWindow (childhwnd, SW_HIDE);
REBAR_Notify_NMREBAR (infoPtr, -1, RBN_DELETEDBAND);
/* if only 1 band left the re-validate to possible eliminate gripper */
if (infoPtr->uNumBands == 1)
REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
TRACE("setting NEEDS_LAYOUT\n");
infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
infoPtr->fStatus |= RESIZE_ANYHOW;
REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
return TRUE;
}
/* << REBAR_DragMove >> */
/* << REBAR_EndDrag >> */
static LRESULT
REBAR_GetBandBorders (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
LPRECT lpRect = (LPRECT)lParam;
REBAR_BAND *lpBand;
if (!lParam)
return 0;
if ((UINT)wParam >= infoPtr->uNumBands)
return 0;
lpBand = &infoPtr->bands[(UINT)wParam];
/* FIXME - the following values were determined by experimentation */
/* with the REBAR Control Spy. I have guesses as to what the 4 and */
/* 1 are, but I am not sure. There doesn't seem to be any actual */
/* difference in size of the control area with and without the */
/* style. - GA */
if (infoPtr->dwStyle & RBS_BANDBORDERS) {
if (infoPtr->dwStyle & CCS_VERT) {
lpRect->left = 1;
lpRect->top = lpBand->cxHeader + 4;
lpRect->right = 1;
lpRect->bottom = 0;
}
else {
lpRect->left = lpBand->cxHeader + 4;
lpRect->top = 1;
lpRect->right = 0;
lpRect->bottom = 1;
}
}
else {
lpRect->left = lpBand->cxHeader;
}
return 0;
}
inline static LRESULT
REBAR_GetBandCount (REBAR_INFO *infoPtr)
{
TRACE("band count %u!\n", infoPtr->uNumBands);
return infoPtr->uNumBands;
}
static LRESULT
REBAR_GetBandInfoA (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
REBAR_BAND *lpBand;
if (lprbbi == NULL)
return FALSE;
if (lprbbi->cbSize < REBARBANDINFOA_V3_SIZE)
return FALSE;
if ((UINT)wParam >= infoPtr->uNumBands)
return FALSE;
TRACE("index %u\n", (UINT)wParam);
/* copy band information */
lpBand = &infoPtr->bands[(UINT)wParam];
if (lprbbi->fMask & RBBIM_STYLE)
lprbbi->fStyle = lpBand->fStyle;
if (lprbbi->fMask & RBBIM_COLORS) {
lprbbi->clrFore = lpBand->clrFore;
lprbbi->clrBack = lpBand->clrBack;
if (lprbbi->clrBack == CLR_DEFAULT)
lprbbi->clrBack = infoPtr->clrBtnFace;
}
if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
if (lpBand->lpText && (lpBand->fMask & RBBIM_TEXT))
{
if (!WideCharToMultiByte( CP_ACP, 0, lpBand->lpText, -1,
lprbbi->lpText, lprbbi->cch, NULL, NULL ))
lprbbi->lpText[lprbbi->cch-1] = 0;
}
else
*lprbbi->lpText = 0;
}
if (lprbbi->fMask & RBBIM_IMAGE) {
if (lpBand->fMask & RBBIM_IMAGE)
lprbbi->iImage = lpBand->iImage;
else
lprbbi->iImage = -1;
}
if (lprbbi->fMask & RBBIM_CHILD)
lprbbi->hwndChild = lpBand->hwndChild;
if (lprbbi->fMask & RBBIM_CHILDSIZE) {
lprbbi->cxMinChild = lpBand->cxMinChild;
lprbbi->cyMinChild = lpBand->cyMinChild;
if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
lprbbi->cyChild = lpBand->cyChild;
lprbbi->cyMaxChild = lpBand->cyMaxChild;
lprbbi->cyIntegral = lpBand->cyIntegral;
}
}
if (lprbbi->fMask & RBBIM_SIZE)
lprbbi->cx = lpBand->cx;
if (lprbbi->fMask & RBBIM_BACKGROUND)
lprbbi->hbmBack = lpBand->hbmBack;
if (lprbbi->fMask & RBBIM_ID)
lprbbi->wID = lpBand->wID;
/* check for additional data */
if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
if (lprbbi->fMask & RBBIM_IDEALSIZE)
lprbbi->cxIdeal = lpBand->cxIdeal;
if (lprbbi->fMask & RBBIM_LPARAM)
lprbbi->lParam = lpBand->lParam;
if (lprbbi->fMask & RBBIM_HEADERSIZE)
lprbbi->cxHeader = lpBand->cxHeader;
}
REBAR_DumpBandInfo (lprbbi);
return TRUE;
}
static LRESULT
REBAR_GetBandInfoW (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
REBAR_BAND *lpBand;
if (lprbbi == NULL)
return FALSE;
if (lprbbi->cbSize < REBARBANDINFOW_V3_SIZE)
return FALSE;
if ((UINT)wParam >= infoPtr->uNumBands)
return FALSE;
TRACE("index %u\n", (UINT)wParam);
/* copy band information */
lpBand = &infoPtr->bands[(UINT)wParam];
if (lprbbi->fMask & RBBIM_STYLE)
lprbbi->fStyle = lpBand->fStyle;
if (lprbbi->fMask & RBBIM_COLORS) {
lprbbi->clrFore = lpBand->clrFore;
lprbbi->clrBack = lpBand->clrBack;
if (lprbbi->clrBack == CLR_DEFAULT)
lprbbi->clrBack = infoPtr->clrBtnFace;
}
if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
if (lpBand->lpText && (lpBand->fMask & RBBIM_TEXT))
lstrcpynW (lprbbi->lpText, lpBand->lpText, lprbbi->cch);
else
*lprbbi->lpText = 0;
}
if (lprbbi->fMask & RBBIM_IMAGE) {
if (lpBand->fMask & RBBIM_IMAGE)
lprbbi->iImage = lpBand->iImage;
else
lprbbi->iImage = -1;
}
if (lprbbi->fMask & RBBIM_CHILD)
lprbbi->hwndChild = lpBand->hwndChild;
if (lprbbi->fMask & RBBIM_CHILDSIZE) {
lprbbi->cxMinChild = lpBand->cxMinChild;
lprbbi->cyMinChild = lpBand->cyMinChild;
if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) {
lprbbi->cyChild = lpBand->cyChild;
lprbbi->cyMaxChild = lpBand->cyMaxChild;
lprbbi->cyIntegral = lpBand->cyIntegral;
}
}
if (lprbbi->fMask & RBBIM_SIZE)
lprbbi->cx = lpBand->cx;
if (lprbbi->fMask & RBBIM_BACKGROUND)
lprbbi->hbmBack = lpBand->hbmBack;
if (lprbbi->fMask & RBBIM_ID)
lprbbi->wID = lpBand->wID;
/* check for additional data */
if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) {
if (lprbbi->fMask & RBBIM_IDEALSIZE)
lprbbi->cxIdeal = lpBand->cxIdeal;
if (lprbbi->fMask & RBBIM_LPARAM)
lprbbi->lParam = lpBand->lParam;
if (lprbbi->fMask & RBBIM_HEADERSIZE)
lprbbi->cxHeader = lpBand->cxHeader;
}
REBAR_DumpBandInfo ((LPREBARBANDINFOA)lprbbi);
return TRUE;
}
static LRESULT
REBAR_GetBarHeight (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
INT nHeight;
nHeight = (infoPtr->dwStyle & CCS_VERT) ? infoPtr->calcSize.cx : infoPtr->calcSize.cy;
TRACE("height = %d\n", nHeight);
return nHeight;
}
static LRESULT
REBAR_GetBarInfo (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
LPREBARINFO lpInfo = (LPREBARINFO)lParam;
if (lpInfo == NULL)
return FALSE;
if (lpInfo->cbSize < sizeof (REBARINFO))
return FALSE;
TRACE("getting bar info!\n");
if (infoPtr->himl) {
lpInfo->himl = infoPtr->himl;
lpInfo->fMask |= RBIM_IMAGELIST;
}
return TRUE;
}
inline static LRESULT
REBAR_GetBkColor (REBAR_INFO *infoPtr)
{
COLORREF clr = infoPtr->clrBk;
if (clr == CLR_DEFAULT)
clr = infoPtr->clrBtnFace;
TRACE("background color 0x%06lx!\n", clr);
return clr;
}
/* << REBAR_GetColorScheme >> */
/* << REBAR_GetDropTarget >> */
static LRESULT
REBAR_GetPalette (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
FIXME("empty stub!\n");
return 0;
}
static LRESULT
REBAR_GetRect (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
INT iBand = (INT)wParam;
LPRECT lprc = (LPRECT)lParam;
REBAR_BAND *lpBand;
if ((iBand < 0) && ((UINT)iBand >= infoPtr->uNumBands))
return FALSE;
if (!lprc)
return FALSE;
lpBand = &infoPtr->bands[iBand];
CopyRect (lprc, &lpBand->rcBand);
TRACE("band %d, (%ld,%ld)-(%ld,%ld)\n", iBand,
lprc->left, lprc->top, lprc->right, lprc->bottom);
return TRUE;
}
inline static LRESULT
REBAR_GetRowCount (REBAR_INFO *infoPtr)
{
TRACE("%u\n", infoPtr->uNumRows);
return infoPtr->uNumRows;
}
static LRESULT
REBAR_GetRowHeight (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
INT iRow = (INT)wParam;
int j = 0, ret = 0;
UINT i;
REBAR_BAND *lpBand;
for (i=0; i<infoPtr->uNumBands; i++) {
lpBand = &infoPtr->bands[i];
if (HIDDENBAND(lpBand)) continue;
if (lpBand->iRow != iRow) continue;
if (infoPtr->dwStyle & CCS_VERT)
j = lpBand->rcBand.right - lpBand->rcBand.left;
else
j = lpBand->rcBand.bottom - lpBand->rcBand.top;
if (j > ret) ret = j;
}
TRACE("row %d, height %d\n", iRow, ret);
return ret;
}
inline static LRESULT
REBAR_GetTextColor (REBAR_INFO *infoPtr)
{
TRACE("text color 0x%06lx!\n", infoPtr->clrText);
return infoPtr->clrText;
}
inline static LRESULT
REBAR_GetToolTips (REBAR_INFO *infoPtr)
{
return (LRESULT)infoPtr->hwndToolTip;
}
inline static LRESULT
REBAR_GetUnicodeFormat (REBAR_INFO *infoPtr)
{
TRACE("%s hwnd=%p\n",
infoPtr->bUnicode ? "TRUE" : "FALSE", infoPtr->hwndSelf);
return infoPtr->bUnicode;
}
inline static LRESULT
REBAR_GetVersion (REBAR_INFO *infoPtr)
{
TRACE("version %d\n", infoPtr->iVersion);
return infoPtr->iVersion;
}
static LRESULT
REBAR_HitTest (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
LPRBHITTESTINFO lprbht = (LPRBHITTESTINFO)lParam;
if (!lprbht)
return -1;
REBAR_InternalHitTest (infoPtr, &lprbht->pt, &lprbht->flags, &lprbht->iBand);
return lprbht->iBand;
}
static LRESULT
REBAR_IdToIndex (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
UINT i;
if (infoPtr == NULL)
return -1;
if (infoPtr->uNumBands < 1)
return -1;
for (i = 0; i < infoPtr->uNumBands; i++) {
if (infoPtr->bands[i].wID == (UINT)wParam) {
TRACE("id %u is band %u found!\n", (UINT)wParam, i);
return i;
}
}
TRACE("id %u is not found\n", (UINT)wParam);
return -1;
}
static LRESULT
REBAR_InsertBandA (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
UINT uIndex = (UINT)wParam;
REBAR_BAND *lpBand;
if (infoPtr == NULL)
return FALSE;
if (lprbbi == NULL)
return FALSE;
if (lprbbi->cbSize < REBARBANDINFOA_V3_SIZE)
return FALSE;
/* trace the index as signed to see the -1 */
TRACE("insert band at %d!\n", (INT)uIndex);
REBAR_DumpBandInfo (lprbbi);
if (infoPtr->uNumBands == 0) {
infoPtr->bands = (REBAR_BAND *)Alloc (sizeof (REBAR_BAND));
uIndex = 0;
}
else {
REBAR_BAND *oldBands = infoPtr->bands;
infoPtr->bands =
(REBAR_BAND *)Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
uIndex = infoPtr->uNumBands;
/* pre insert copy */
if (uIndex > 0) {
memcpy (&infoPtr->bands[0], &oldBands[0],
uIndex * sizeof(REBAR_BAND));
}
/* post copy */
if (uIndex < infoPtr->uNumBands) {
memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
(infoPtr->uNumBands - uIndex) * sizeof(REBAR_BAND));
}
Free (oldBands);
}
infoPtr->uNumBands++;
TRACE("index %u!\n", uIndex);
/* initialize band (infoPtr->bands[uIndex])*/
lpBand = &infoPtr->bands[uIndex];
lpBand->fMask = 0;
lpBand->fStatus = 0;
lpBand->clrFore = infoPtr->clrText;
lpBand->clrBack = infoPtr->clrBk;
lpBand->hwndChild = 0;
lpBand->hwndPrevParent = 0;
REBAR_CommonSetupBand (infoPtr->hwndSelf, lprbbi, lpBand);
lpBand->lpText = NULL;
if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
INT len = MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, NULL, 0 );
if (len > 1) {
lpBand->lpText = (LPWSTR)Alloc (len*sizeof(WCHAR));
MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, lpBand->lpText, len );
}
}
REBAR_ValidateBand (infoPtr, lpBand);
/* On insert of second band, revalidate band 1 to possible add gripper */
if (infoPtr->uNumBands == 2)
REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
REBAR_DumpBand (infoPtr);
REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
InvalidateRect(infoPtr->hwndSelf, 0, 1);
return TRUE;
}
static LRESULT
REBAR_InsertBandW (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
UINT uIndex = (UINT)wParam;
REBAR_BAND *lpBand;
if (infoPtr == NULL)
return FALSE;
if (lprbbi == NULL)
return FALSE;
if (lprbbi->cbSize < REBARBANDINFOW_V3_SIZE)
return FALSE;
/* trace the index as signed to see the -1 */
TRACE("insert band at %d!\n", (INT)uIndex);
REBAR_DumpBandInfo ((LPREBARBANDINFOA)lprbbi);
if (infoPtr->uNumBands == 0) {
infoPtr->bands = (REBAR_BAND *)Alloc (sizeof (REBAR_BAND));
uIndex = 0;
}
else {
REBAR_BAND *oldBands = infoPtr->bands;
infoPtr->bands =
(REBAR_BAND *)Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
uIndex = infoPtr->uNumBands;
/* pre insert copy */
if (uIndex > 0) {
memcpy (&infoPtr->bands[0], &oldBands[0],
uIndex * sizeof(REBAR_BAND));
}
/* post copy */
if (uIndex <= infoPtr->uNumBands - 1) {
memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
(infoPtr->uNumBands - uIndex) * sizeof(REBAR_BAND));
}
Free (oldBands);
}
infoPtr->uNumBands++;
TRACE("index %u!\n", uIndex);
/* initialize band (infoPtr->bands[uIndex])*/
lpBand = &infoPtr->bands[uIndex];
lpBand->fMask = 0;
lpBand->fStatus = 0;
lpBand->clrFore = infoPtr->clrText;
lpBand->clrBack = infoPtr->clrBk;
lpBand->hwndChild = 0;
lpBand->hwndPrevParent = 0;
REBAR_CommonSetupBand (infoPtr->hwndSelf, (LPREBARBANDINFOA)lprbbi, lpBand);
lpBand->lpText = NULL;
if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
INT len = lstrlenW (lprbbi->lpText);
if (len > 0) {
lpBand->lpText = (LPWSTR)Alloc ((len + 1)*sizeof(WCHAR));
strcpyW (lpBand->lpText, lprbbi->lpText);
}
}
REBAR_ValidateBand (infoPtr, lpBand);
/* On insert of second band, revalidate band 1 to possible add gripper */
if (infoPtr->uNumBands == 2)
REBAR_ValidateBand (infoPtr, &infoPtr->bands[uIndex ? 0 : 1]);
REBAR_DumpBand (infoPtr);
REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
InvalidateRect(infoPtr->hwndSelf, 0, 1);
return TRUE;
}
static LRESULT
REBAR_MaximizeBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
REBAR_BAND *lpBand;
UINT uBand = (UINT) wParam;
/* Validate */
if ((infoPtr->uNumBands == 0) ||
((INT)uBand < 0) || (uBand >= infoPtr->uNumBands)) {
/* error !!! */
ERR("Illegal MaximizeBand, requested=%d, current band count=%d\n",
(INT)uBand, infoPtr->uNumBands);
return FALSE;
}
lpBand = &infoPtr->bands[uBand];
if (lParam && (lpBand->fMask & RBBIM_IDEALSIZE)) {
/* handle setting ideal size */
lpBand->ccx = lpBand->cxIdeal;
}
else {
/* handle setting to max */
FIXME("(uBand = %u fIdeal = %s) case not coded\n",
(UINT)wParam, lParam ? "TRUE" : "FALSE");
return FALSE;
}
infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
REBAR_Layout (infoPtr, 0, TRUE, TRUE);
InvalidateRect (infoPtr->hwndSelf, 0, TRUE);
return TRUE;
}
static LRESULT
REBAR_MinimizeBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
REBAR_BAND *band, *lpBand;
UINT uBand = (UINT) wParam;
RECT newrect;
INT imindBand, imaxdBand, iprevBand, startBand, endBand;
INT movement, i;
/* A "minimize" band is equivalent to "dragging" the gripper
* of than band to the right till the band is only the size
* of the cxHeader.
*/
/* Validate */
if ((infoPtr->uNumBands == 0) ||
((INT)uBand < 0) || (uBand >= infoPtr->uNumBands)) {
/* error !!! */
ERR("Illegal MinimizeBand, requested=%d, current band count=%d\n",
(INT)uBand, infoPtr->uNumBands);
return FALSE;
}
/* compute amount of movement and validate */
lpBand = &infoPtr->bands[uBand];
if (infoPtr->dwStyle & CCS_VERT)
movement = lpBand->rcBand.bottom - lpBand->rcBand.top -
lpBand->cxHeader;
else
movement = lpBand->rcBand.right - lpBand->rcBand.left -
lpBand->cxHeader;
if (movement < 0) {
ERR("something is wrong, band=(%ld,%ld)-(%ld,%ld), cxheader=%d\n",
lpBand->rcBand.left, lpBand->rcBand.top,
lpBand->rcBand.right, lpBand->rcBand.bottom,
lpBand->cxHeader);
return FALSE;
}
imindBand = -1;
imaxdBand = -1;
iprevBand = -1; /* to suppress warning message */
/* find the first band in row of the one whose is being minimized */
for (i=0; i<infoPtr->uNumBands; i++) {
band = &infoPtr->bands[i];
if (HIDDENBAND(band)) continue;
if (band->iRow == lpBand->iRow) {
imaxdBand = i;
if (imindBand == -1) imindBand = i;
}
}
/* if the selected band is first in row then need to expand */
/* next visible band */
if (imindBand == uBand) {
band = NULL;
movement = -movement;
/* find the first visible band to the right of the selected band */
for (i=uBand+1; i<=imaxdBand; i++) {
band = &infoPtr->bands[i];
if (!HIDDENBAND(band)) {
iprevBand = i;
LEADJ(band, movement);
band->ccx = rcBw(band);
break;
}
}
/* what case is this */
if (iprevBand == -1) {
ERR("no previous visible band\n");
return FALSE;
}
startBand = uBand;
endBand = iprevBand;
SetRect (&newrect,
lpBand->rcBand.left,
lpBand->rcBand.top,
band->rcBand.right,
band->rcBand.bottom);
}
/* otherwise expand previous visible band */
else {
band = NULL;
/* find the first visible band to the left of the selected band */
for (i=uBand-1; i>=imindBand; i--) {
band = &infoPtr->bands[i];
if (!HIDDENBAND(band)) {
iprevBand = i;
READJ(band, movement);
band->ccx = rcBw(band);
break;
}
}
/* what case is this */
if (iprevBand == -1) {
ERR("no previous visible band\n");
return FALSE;
}
startBand = iprevBand;
endBand = uBand;
SetRect (&newrect,
band->rcBand.left,
band->rcBand.top,
lpBand->rcBand.right,
lpBand->rcBand.bottom);
}
REBAR_Shrink (infoPtr, lpBand, movement, uBand);
/* recompute all rectangles */
if (infoPtr->dwStyle & CCS_VERT) {
REBAR_CalcVertBand (infoPtr, startBand, endBand+1,
FALSE);
}
else {
REBAR_CalcHorzBand (infoPtr, startBand, endBand+1,
FALSE);
}
TRACE("bands after minimize, see band # %d, %d\n",
startBand, endBand);
REBAR_DumpBand (infoPtr);
REBAR_MoveChildWindows (infoPtr, startBand, endBand+1);
InvalidateRect (infoPtr->hwndSelf, &newrect, TRUE);
UpdateWindow (infoPtr->hwndSelf);
return FALSE;
}
static LRESULT
REBAR_MoveBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
REBAR_BAND *oldBands = infoPtr->bands;
REBAR_BAND holder;
UINT uFrom = (UINT)wParam;
UINT uTo = (UINT)lParam;
/* Validate */
if ((infoPtr->uNumBands == 0) ||
((INT)uFrom < 0) || (uFrom >= infoPtr->uNumBands) ||
((INT)uTo < 0) || (uTo >= infoPtr->uNumBands)) {
/* error !!! */
ERR("Illegal MoveBand, from=%d, to=%d, current band count=%d\n",
(INT)uFrom, (INT)uTo, infoPtr->uNumBands);
return FALSE;
}
/* save one to be moved */
memcpy (&holder, &oldBands[uFrom], sizeof(REBAR_BAND));
/* close up rest of bands (pseudo delete) */
if (uFrom < infoPtr->uNumBands - 1) {
memcpy (&oldBands[uFrom], &oldBands[uFrom+1],
(infoPtr->uNumBands - uFrom - 1) * sizeof(REBAR_BAND));
}
/* allocate new space and copy rest of bands into it */
infoPtr->bands =
(REBAR_BAND *)Alloc ((infoPtr->uNumBands)*sizeof(REBAR_BAND));
/* pre insert copy */
if (uTo > 0) {
memcpy (&infoPtr->bands[0], &oldBands[0],
uTo * sizeof(REBAR_BAND));
}
/* set moved band */
memcpy (&infoPtr->bands[uTo], &holder, sizeof(REBAR_BAND));
/* post copy */
if (uTo < infoPtr->uNumBands - 1) {
memcpy (&infoPtr->bands[uTo+1], &oldBands[uTo],
(infoPtr->uNumBands - uTo - 1) * sizeof(REBAR_BAND));
}
Free (oldBands);
TRACE("moved band %d to index %d\n", uFrom, uTo);
REBAR_DumpBand (infoPtr);
infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
/* **************************************************** */
/* */
/* We do not do a REBAR_Layout here because the native */
/* control does not do that. The actual layout and */
/* repaint is done by the *next* real action, ex.: */
/* RB_INSERTBAND, RB_DELETEBAND, RB_SIZETORECT, etc. */
/* */
/* **************************************************** */
return TRUE;
}
/* return TRUE if two strings are different */
static BOOL
REBAR_strdifW( LPCWSTR a, LPCWSTR b )
{
return ( (a && !b) || (b && !a) || (a && b && lstrcmpW(a, b) ) );
}
static LRESULT
REBAR_SetBandInfoA (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
REBAR_BAND *lpBand;
BOOL bChanged;
if (lprbbi == NULL)
return FALSE;
if (lprbbi->cbSize < REBARBANDINFOA_V3_SIZE)
return FALSE;
if ((UINT)wParam >= infoPtr->uNumBands)
return FALSE;
TRACE("index %u\n", (UINT)wParam);
REBAR_DumpBandInfo (lprbbi);
/* set band information */
lpBand = &infoPtr->bands[(UINT)wParam];
bChanged = REBAR_CommonSetupBand (infoPtr->hwndSelf, lprbbi, lpBand);
if (lprbbi->fMask & RBBIM_TEXT) {
LPWSTR wstr = NULL;
if (lprbbi->lpText)
{
INT len;
len = MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, NULL, 0 );
if (len > 1)
wstr = (LPWSTR)Alloc (len*sizeof(WCHAR));
if (wstr)
MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, wstr, len );
}
if (REBAR_strdifW(lpBand->lpText, wstr)) {
if (lpBand->lpText) {
Free (lpBand->lpText);
lpBand->lpText = NULL;
}
if (wstr) {
lpBand->lpText = wstr;
wstr = NULL;
}
bChanged = TRUE;
}
if (wstr)
Free (wstr);
}
REBAR_ValidateBand (infoPtr, lpBand);
REBAR_DumpBand (infoPtr);
if (bChanged && (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE))) {
REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
InvalidateRect(infoPtr->hwndSelf, 0, 1);
}
return TRUE;
}
static LRESULT
REBAR_SetBandInfoW (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
REBAR_BAND *lpBand;
BOOL bChanged;
if (lprbbi == NULL)
return FALSE;
if (lprbbi->cbSize < REBARBANDINFOW_V3_SIZE)
return FALSE;
if ((UINT)wParam >= infoPtr->uNumBands)
return FALSE;
TRACE("index %u\n", (UINT)wParam);
REBAR_DumpBandInfo ((LPREBARBANDINFOA)lprbbi);
/* set band information */
lpBand = &infoPtr->bands[(UINT)wParam];
bChanged = REBAR_CommonSetupBand (infoPtr->hwndSelf, (LPREBARBANDINFOA)lprbbi, lpBand);
if( (lprbbi->fMask & RBBIM_TEXT) &&
REBAR_strdifW( lpBand->lpText, lprbbi->lpText ) ) {
if (lpBand->lpText) {
Free (lpBand->lpText);
lpBand->lpText = NULL;
}
if (lprbbi->lpText) {
INT len = lstrlenW (lprbbi->lpText);
if (len > 0)
{
lpBand->lpText = (LPWSTR)Alloc ((len + 1)*sizeof(WCHAR));
strcpyW (lpBand->lpText, lprbbi->lpText);
}
}
bChanged = TRUE;
}
REBAR_ValidateBand (infoPtr, lpBand);
REBAR_DumpBand (infoPtr);
if ( bChanged && (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE)) ) {
REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
InvalidateRect(infoPtr->hwndSelf, 0, 1);
}
return TRUE;
}
static LRESULT
REBAR_SetBarInfo (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
LPREBARINFO lpInfo = (LPREBARINFO)lParam;
REBAR_BAND *lpBand;
UINT i;
if (lpInfo == NULL)
return FALSE;
if (lpInfo->cbSize < sizeof (REBARINFO))
return FALSE;
TRACE("setting bar info!\n");
if (lpInfo->fMask & RBIM_IMAGELIST) {
infoPtr->himl = lpInfo->himl;
if (infoPtr->himl) {
INT cx, cy;
ImageList_GetIconSize (infoPtr->himl, &cx, &cy);
infoPtr->imageSize.cx = cx;
infoPtr->imageSize.cy = cy;
}
else {
infoPtr->imageSize.cx = 0;
infoPtr->imageSize.cy = 0;
}
TRACE("new image cx=%ld, cy=%ld\n", infoPtr->imageSize.cx,
infoPtr->imageSize.cy);
}
/* revalidate all bands to reset flags for images in headers of bands */
for (i=0; i<infoPtr->uNumBands; i++) {
lpBand = &infoPtr->bands[i];
REBAR_ValidateBand (infoPtr, lpBand);
}
return TRUE;
}
static LRESULT
REBAR_SetBkColor (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
COLORREF clrTemp;
clrTemp = infoPtr->clrBk;
infoPtr->clrBk = (COLORREF)lParam;
TRACE("background color 0x%06lx!\n", infoPtr->clrBk);
return clrTemp;
}
/* << REBAR_SetColorScheme >> */
/* << REBAR_SetPalette >> */
static LRESULT
REBAR_SetParent (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
HWND hwndTemp = infoPtr->hwndNotify;
infoPtr->hwndNotify = (HWND)wParam;
return (LRESULT)hwndTemp;
}
static LRESULT
REBAR_SetTextColor (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
COLORREF clrTemp;
clrTemp = infoPtr->clrText;
infoPtr->clrText = (COLORREF)lParam;
TRACE("text color 0x%06lx!\n", infoPtr->clrText);
return clrTemp;
}
/* << REBAR_SetTooltips >> */
inline static LRESULT
REBAR_SetUnicodeFormat (REBAR_INFO *infoPtr, WPARAM wParam)
{
BOOL bTemp = infoPtr->bUnicode;
TRACE("to %s hwnd=%p, was %s\n",
((BOOL)wParam) ? "TRUE" : "FALSE", infoPtr->hwndSelf,
(bTemp) ? "TRUE" : "FALSE");
infoPtr->bUnicode = (BOOL)wParam;
return bTemp;
}
static LRESULT
REBAR_SetVersion (REBAR_INFO *infoPtr, INT iVersion)
{
INT iOldVersion = infoPtr->iVersion;
if (iVersion > COMCTL32_VERSION)
return -1;
infoPtr->iVersion = iVersion;
TRACE("new version %d\n", iVersion);
return iOldVersion;
}
static LRESULT
REBAR_ShowBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
REBAR_BAND *lpBand;
if (((INT)wParam < 0) || ((INT)wParam > infoPtr->uNumBands))
return FALSE;
lpBand = &infoPtr->bands[(INT)wParam];
if ((BOOL)lParam) {
TRACE("show band %d\n", (INT)wParam);
lpBand->fStyle = lpBand->fStyle & ~RBBS_HIDDEN;
if (IsWindow (lpBand->hwndChild))
ShowWindow (lpBand->hwndChild, SW_SHOW);
}
else {
TRACE("hide band %d\n", (INT)wParam);
lpBand->fStyle = lpBand->fStyle | RBBS_HIDDEN;
if (IsWindow (lpBand->hwndChild))
ShowWindow (lpBand->hwndChild, SW_HIDE);
}
infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
InvalidateRect(infoPtr->hwndSelf, 0, 1);
return TRUE;
}
static LRESULT
REBAR_SizeToRect (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
LPRECT lpRect = (LPRECT)lParam;
RECT t1;
if (lpRect == NULL)
return FALSE;
TRACE("[%ld %ld %ld %ld]\n",
lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
/* what is going on???? */
GetWindowRect(infoPtr->hwndSelf, &t1);
TRACE("window rect [%ld %ld %ld %ld]\n",
t1.left, t1.top, t1.right, t1.bottom);
GetClientRect(infoPtr->hwndSelf, &t1);
TRACE("client rect [%ld %ld %ld %ld]\n",
t1.left, t1.top, t1.right, t1.bottom);
/* force full _Layout processing */
TRACE("setting NEEDS_LAYOUT\n");
infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
REBAR_Layout (infoPtr, lpRect, TRUE, FALSE);
InvalidateRect (infoPtr->hwndSelf, NULL, TRUE);
return TRUE;
}
static LRESULT
REBAR_Create (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
LPCREATESTRUCTW cs = (LPCREATESTRUCTW) lParam;
RECT wnrc1, clrc1;
if (TRACE_ON(rebar)) {
GetWindowRect(infoPtr->hwndSelf, &wnrc1);
GetClientRect(infoPtr->hwndSelf, &clrc1);
TRACE("window=(%ld,%ld)-(%ld,%ld) client=(%ld,%ld)-(%ld,%ld) cs=(%d,%d %dx%d)\n",
wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
cs->x, cs->y, cs->cx, cs->cy);
}
TRACE("created!\n");
return 0;
}
static LRESULT
REBAR_Destroy (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
REBAR_BAND *lpBand;
UINT i;
/* free rebar bands */
if ((infoPtr->uNumBands > 0) && infoPtr->bands) {
/* clean up each band */
for (i = 0; i < infoPtr->uNumBands; i++) {
lpBand = &infoPtr->bands[i];
/* delete text strings */
if (lpBand->lpText) {
Free (lpBand->lpText);
lpBand->lpText = NULL;
}
/* destroy child window */
DestroyWindow (lpBand->hwndChild);
}
/* free band array */
Free (infoPtr->bands);
infoPtr->bands = NULL;
}
DestroyCursor (infoPtr->hcurArrow);
DestroyCursor (infoPtr->hcurHorz);
DestroyCursor (infoPtr->hcurVert);
DestroyCursor (infoPtr->hcurDrag);
if(infoPtr->hDefaultFont) DeleteObject (infoPtr->hDefaultFont);
SetWindowLongPtrW (infoPtr->hwndSelf, 0, 0);
/* free rebar info data */
Free (infoPtr);
TRACE("destroyed!\n");
return 0;
}
static LRESULT
REBAR_EraseBkGnd (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
RECT cliprect;
if (GetClipBox ( (HDC)wParam, &cliprect))
return REBAR_InternalEraseBkGnd (infoPtr, wParam, lParam, &cliprect);
return 0;
}
static LRESULT
REBAR_GetFont (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
return (LRESULT)infoPtr->hFont;
}
static LRESULT
REBAR_PushChevron(REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
if (wParam >= 0 && (UINT)wParam < infoPtr->uNumBands)
{
NMREBARCHEVRON nmrbc;
REBAR_BAND *lpBand = &infoPtr->bands[wParam];
TRACE("Pressed chevron on band %d\n", wParam);
/* redraw chevron in pushed state */
lpBand->fDraw |= DRAW_CHEVRONPUSHED;
RedrawWindow(infoPtr->hwndSelf, &lpBand->rcChevron,0,
RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
/* notify app so it can display a popup menu or whatever */
nmrbc.uBand = wParam;
nmrbc.wID = lpBand->wID;
nmrbc.lParam = lpBand->lParam;
nmrbc.rc = lpBand->rcChevron;
nmrbc.lParamNM = lParam;
REBAR_Notify((NMHDR*)&nmrbc, infoPtr, RBN_CHEVRONPUSHED);
/* redraw chevron in previous state */
lpBand->fDraw &= ~DRAW_CHEVRONPUSHED;
InvalidateRect(infoPtr->hwndSelf, &lpBand->rcChevron, TRUE);
return TRUE;
}
return FALSE;
}
static LRESULT
REBAR_LButtonDown (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
REBAR_BAND *lpBand;
UINT htFlags;
UINT iHitBand;
POINT ptMouseDown;
ptMouseDown.x = (INT)LOWORD(lParam);
ptMouseDown.y = (INT)HIWORD(lParam);
REBAR_InternalHitTest(infoPtr, &ptMouseDown, &htFlags, &iHitBand);
lpBand = &infoPtr->bands[iHitBand];
if (htFlags == RBHT_CHEVRON)
{
REBAR_PushChevron(infoPtr, iHitBand, 0);
}
else if (htFlags == RBHT_GRABBER || htFlags == RBHT_CAPTION)
{
TRACE("Starting drag\n");
SetCapture (infoPtr->hwndSelf);
infoPtr->iGrabbedBand = iHitBand;
/* save off the LOWORD and HIWORD of lParam as initial x,y */
infoPtr->dragStart.x = (short)LOWORD(lParam);
infoPtr->dragStart.y = (short)HIWORD(lParam);
infoPtr->dragNow = infoPtr->dragStart;
if (infoPtr->dwStyle & CCS_VERT)
infoPtr->ihitoffset = infoPtr->dragStart.y - (lpBand->rcBand.top+REBAR_PRE_GRIPPER);
else
infoPtr->ihitoffset = infoPtr->dragStart.x - (lpBand->rcBand.left+REBAR_PRE_GRIPPER);
}
return 0;
}
static LRESULT
REBAR_LButtonUp (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
if (infoPtr->iGrabbedBand >= 0)
{
NMHDR layout;
RECT rect;
infoPtr->dragStart.x = 0;
infoPtr->dragStart.y = 0;
infoPtr->dragNow = infoPtr->dragStart;
ReleaseCapture ();
if (infoPtr->fStatus & BEGIN_DRAG_ISSUED) {
REBAR_Notify(&layout, infoPtr, RBN_LAYOUTCHANGED);
REBAR_Notify_NMREBAR (infoPtr, infoPtr->iGrabbedBand, RBN_ENDDRAG);
infoPtr->fStatus &= ~BEGIN_DRAG_ISSUED;
}
infoPtr->iGrabbedBand = -1;
GetClientRect(infoPtr->hwndSelf, &rect);
InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
}
return 0;
}
static LRESULT
REBAR_MouseLeave (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
if (infoPtr->ichevronhotBand >= 0)
{
REBAR_BAND *lpChevronBand = &infoPtr->bands[infoPtr->ichevronhotBand];
if (lpChevronBand->fDraw & DRAW_CHEVRONHOT)
{
lpChevronBand->fDraw &= ~DRAW_CHEVRONHOT;
InvalidateRect(infoPtr->hwndSelf, &lpChevronBand->rcChevron, TRUE);
}
}
infoPtr->iOldBand = -1;
infoPtr->ichevronhotBand = -2;
return TRUE;
}
static LRESULT
REBAR_MouseMove (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
REBAR_BAND *lpChevronBand;
POINT ptMove;
ptMove.x = (short)LOWORD(lParam);
ptMove.y = (short)HIWORD(lParam);
/* if we are currently dragging a band */
if (infoPtr->iGrabbedBand >= 0)
{
REBAR_BAND *band1, *band2;
if (GetCapture() != infoPtr->hwndSelf)
ERR("We are dragging but haven't got capture?!?\n");
band1 = &infoPtr->bands[infoPtr->iGrabbedBand-1];
band2 = &infoPtr->bands[infoPtr->iGrabbedBand];
/* if mouse did not move much, exit */
if ((abs(ptMove.x - infoPtr->dragNow.x) <= mindragx) &&
(abs(ptMove.y - infoPtr->dragNow.y) <= mindragy)) return 0;
/* Test for valid drag case - must not be first band in row */
if (infoPtr->dwStyle & CCS_VERT) {
if ((ptMove.x < band2->rcBand.left) ||
(ptMove.x > band2->rcBand.right) ||
((infoPtr->iGrabbedBand > 0) && (band1->iRow != band2->iRow))) {
FIXME("Cannot drag to other rows yet!!\n");
}
else {
REBAR_HandleLRDrag (infoPtr, &ptMove);
}
}
else {
if ((ptMove.y < band2->rcBand.top) ||
(ptMove.y > band2->rcBand.bottom) ||
((infoPtr->iGrabbedBand > 0) && (band1->iRow != band2->iRow))) {
FIXME("Cannot drag to other rows yet!!\n");
}
else {
REBAR_HandleLRDrag (infoPtr, &ptMove);
}
}
}
else
{
INT iHitBand;
UINT htFlags;
TRACKMOUSEEVENT trackinfo;
REBAR_InternalHitTest(infoPtr, &ptMove, &htFlags, &iHitBand);
if (infoPtr->iOldBand >= 0 && infoPtr->iOldBand == infoPtr->ichevronhotBand)
{
lpChevronBand = &infoPtr->bands[infoPtr->ichevronhotBand];
if (lpChevronBand->fDraw & DRAW_CHEVRONHOT)
{
lpChevronBand->fDraw &= ~DRAW_CHEVRONHOT;
InvalidateRect(infoPtr->hwndSelf, &lpChevronBand->rcChevron, TRUE);
}
infoPtr->ichevronhotBand = -2;
}
if (htFlags == RBHT_CHEVRON)
{
/* fill in the TRACKMOUSEEVENT struct */
trackinfo.cbSize = sizeof(TRACKMOUSEEVENT);
trackinfo.dwFlags = TME_QUERY;
trackinfo.hwndTrack = infoPtr->hwndSelf;
trackinfo.dwHoverTime = 0;
/* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
_TrackMouseEvent(&trackinfo);
/* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
if(!(trackinfo.dwFlags & TME_LEAVE))
{
trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */
/* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
/* and can properly deactivate the hot chevron */
_TrackMouseEvent(&trackinfo);
}
lpChevronBand = &infoPtr->bands[iHitBand];
if (!(lpChevronBand->fDraw & DRAW_CHEVRONHOT))
{
lpChevronBand->fDraw |= DRAW_CHEVRONHOT;
InvalidateRect(infoPtr->hwndSelf, &lpChevronBand->rcChevron, TRUE);
infoPtr->ichevronhotBand = iHitBand;
}
}
infoPtr->iOldBand = iHitBand;
}
return 0;
}
inline static LRESULT
REBAR_NCCalcSize (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
if (infoPtr->dwStyle & WS_BORDER) {
InflateRect((LPRECT)lParam, -GetSystemMetrics(SM_CXEDGE),
-GetSystemMetrics(SM_CYEDGE));
}
TRACE("new client=(%ld,%ld)-(%ld,%ld)\n",
((LPRECT)lParam)->left, ((LPRECT)lParam)->top,
((LPRECT)lParam)->right, ((LPRECT)lParam)->bottom);
return 0;
}
static LRESULT
REBAR_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
{
LPCREATESTRUCTW cs = (LPCREATESTRUCTW) lParam;
REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
RECT wnrc1, clrc1;
NONCLIENTMETRICSW ncm;
HFONT tfont;
INT i;
if (infoPtr != NULL) {
ERR("Strange info structure pointer *not* NULL\n");
return FALSE;
}
if (TRACE_ON(rebar)) {
GetWindowRect(hwnd, &wnrc1);
GetClientRect(hwnd, &clrc1);
TRACE("window=(%ld,%ld)-(%ld,%ld) client=(%ld,%ld)-(%ld,%ld) cs=(%d,%d %dx%d)\n",
wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
cs->x, cs->y, cs->cx, cs->cy);
}
/* allocate memory for info structure */
infoPtr = (REBAR_INFO *)Alloc (sizeof(REBAR_INFO));
SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr);
/* initialize info structure - initial values are 0 */
infoPtr->clrBk = CLR_NONE;
infoPtr->clrText = CLR_NONE;
infoPtr->clrBtnText = GetSysColor (COLOR_BTNTEXT);
infoPtr->clrBtnFace = GetSysColor (COLOR_BTNFACE);
infoPtr->iOldBand = -1;
infoPtr->ichevronhotBand = -2;
infoPtr->iGrabbedBand = -1;
infoPtr->hwndSelf = hwnd;
infoPtr->DoRedraw = TRUE;
infoPtr->hcurArrow = LoadCursorW (0, (LPWSTR)IDC_ARROW);
infoPtr->hcurHorz = LoadCursorW (0, (LPWSTR)IDC_SIZEWE);
infoPtr->hcurVert = LoadCursorW (0, (LPWSTR)IDC_SIZENS);
infoPtr->hcurDrag = LoadCursorW (0, (LPWSTR)IDC_SIZE);
infoPtr->bUnicode = IsWindowUnicode (hwnd);
infoPtr->fStatus = CREATE_RUNNING;
infoPtr->hFont = GetStockObject (SYSTEM_FONT);
/* issue WM_NOTIFYFORMAT to get unicode status of parent */
i = SendMessageW(REBAR_GetNotifyParent (infoPtr),
WM_NOTIFYFORMAT, (WPARAM)hwnd, NF_QUERY);
if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", i);
i = NFR_ANSI;
}
infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
/* add necessary styles to the requested styles */
infoPtr->dwStyle = cs->style | WS_VISIBLE | CCS_TOP;
SetWindowLongW (hwnd, GWL_STYLE, infoPtr->dwStyle);
/* get font handle for Caption Font */
ncm.cbSize = sizeof(ncm);
SystemParametersInfoW (SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0);
/* if the font is bold, set to normal */
if (ncm.lfCaptionFont.lfWeight > FW_NORMAL) {
ncm.lfCaptionFont.lfWeight = FW_NORMAL;
}
tfont = CreateFontIndirectW (&ncm.lfCaptionFont);
if (tfont) {
infoPtr->hFont = infoPtr->hDefaultFont = tfont;
}
/* native does:
GetSysColor (numerous);
GetSysColorBrush (numerous) (see WM_SYSCOLORCHANGE);
*GetStockObject (SYSTEM_FONT);
*SetWindowLong (hwnd, 0, info ptr);
*WM_NOTIFYFORMAT;
*SetWindowLong (hwnd, GWL_STYLE, style+0x10000001);
WS_VISIBLE = 0x10000000;
CCS_TOP = 0x00000001;
*SystemParametersInfo (SPI_GETNONCLIENTMETRICS...);
*CreateFontIndirect (lfCaptionFont from above);
GetDC ();
SelectObject (hdc, fontabove);
GetTextMetrics (hdc, ); guessing is tmHeight
SelectObject (hdc, oldfont);
ReleaseDC ();
GetWindowRect ();
MapWindowPoints (0, parent, rectabove, 2);
GetWindowRect ();
GetClientRect ();
ClientToScreen (clientrect);
SetWindowPos (hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER);
*/
return TRUE;
}
static LRESULT
REBAR_NCHitTest (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
NMMOUSE nmmouse;
POINT clpt;
INT i;
UINT scrap;
LRESULT ret = HTCLIENT;
/*
* Differences from doc at MSDN (as observed with version 4.71 of
* comctl32.dll
* 1. doc says nmmouse.pt is in screen coord, trace shows client coord.
* 2. if band is not identified .dwItemSpec is 0xffffffff.
* 3. native always seems to return HTCLIENT if notify return is 0.
*/
clpt.x = (short)LOWORD(lParam);
clpt.y = (short)HIWORD(lParam);
ScreenToClient (infoPtr->hwndSelf, &clpt);
REBAR_InternalHitTest (infoPtr, &clpt, &scrap,
(INT *)&nmmouse.dwItemSpec);
nmmouse.dwItemData = 0;
nmmouse.pt = clpt;
nmmouse.dwHitInfo = 0;
if ((i = REBAR_Notify((NMHDR *) &nmmouse, infoPtr, NM_NCHITTEST))) {
TRACE("notify changed return value from %ld to %d\n",
ret, i);
ret = (LRESULT) i;
}
TRACE("returning %ld, client point (%ld,%ld)\n", ret, clpt.x, clpt.y);
return ret;
}
static LRESULT
REBAR_NCPaint (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
RECT rcWindow;
HDC hdc;
if (infoPtr->dwStyle & WS_MINIMIZE)
return 0; /* Nothing to do */
if (infoPtr->dwStyle & WS_BORDER) {
/* adjust rectangle and draw the necessary edge */
if (!(hdc = GetDCEx( infoPtr->hwndSelf, 0, DCX_USESTYLE | DCX_WINDOW )))
return 0;
GetWindowRect (infoPtr->hwndSelf, &rcWindow);
OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
TRACE("rect (%ld,%ld)-(%ld,%ld)\n",
rcWindow.left, rcWindow.top,
rcWindow.right, rcWindow.bottom);
DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_RECT);
ReleaseDC( infoPtr->hwndSelf, hdc );
}
return 0;
}
static LRESULT
REBAR_NotifyFormat (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
INT i;
if (lParam == NF_REQUERY) {
i = SendMessageW(REBAR_GetNotifyParent (infoPtr),
WM_NOTIFYFORMAT, (WPARAM)infoPtr->hwndSelf, NF_QUERY);
if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", i);
i = NFR_ANSI;
}
infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
return (LRESULT)i;
}
return (LRESULT)((infoPtr->bUnicode) ? NFR_UNICODE : NFR_ANSI);
}
static LRESULT
REBAR_Paint (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
RECT rc;
GetClientRect(infoPtr->hwndSelf, &rc);
hdc = wParam==0 ? BeginPaint (infoPtr->hwndSelf, &ps) : (HDC)wParam;
TRACE("painting (%ld,%ld)-(%ld,%ld) client (%ld,%ld)-(%ld,%ld)\n",
ps.rcPaint.left, ps.rcPaint.top,
ps.rcPaint.right, ps.rcPaint.bottom,
rc.left, rc.top, rc.right, rc.bottom);
if (ps.fErase) {
/* Erase area of paint if requested */
REBAR_InternalEraseBkGnd (infoPtr, wParam, lParam, &ps.rcPaint);
}
REBAR_Refresh (infoPtr, hdc);
if (!wParam)
EndPaint (infoPtr->hwndSelf, &ps);
return 0;
}
static LRESULT
REBAR_SetCursor (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
POINT pt;
UINT flags;
TRACE("code=0x%X id=0x%X\n", LOWORD(lParam), HIWORD(lParam));
GetCursorPos (&pt);
ScreenToClient (infoPtr->hwndSelf, &pt);
REBAR_InternalHitTest (infoPtr, &pt, &flags, NULL);
if (flags == RBHT_GRABBER) {
if ((infoPtr->dwStyle & CCS_VERT) &&
!(infoPtr->dwStyle & RBS_VERTICALGRIPPER))
SetCursor (infoPtr->hcurVert);
else
SetCursor (infoPtr->hcurHorz);
}
else if (flags != RBHT_CLIENT)
SetCursor (infoPtr->hcurArrow);
return 0;
}
static LRESULT
REBAR_SetFont (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
RECT rcClient;
REBAR_BAND *lpBand;
UINT i;
infoPtr->hFont = (HFONT)wParam;
/* revalidate all bands to change sizes of text in headers of bands */
for (i=0; i<infoPtr->uNumBands; i++) {
lpBand = &infoPtr->bands[i];
REBAR_ValidateBand (infoPtr, lpBand);
}
if (LOWORD(lParam)) {
GetClientRect (infoPtr->hwndSelf, &rcClient);
REBAR_Layout (infoPtr, &rcClient, FALSE, TRUE);
}
return 0;
}
inline static LRESULT
REBAR_SetRedraw (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
/*****************************************************
*
* Function;
* Handles the WM_SETREDRAW message.
*
* Documentation:
* According to testing V4.71 of COMCTL32 returns the
* *previous* status of the redraw flag (either 0 or -1)
* instead of the MSDN documented value of 0 if handled
*
*****************************************************/
{
BOOL oldredraw = infoPtr->DoRedraw;
TRACE("set to %s, fStatus=%08x\n",
(wParam) ? "TRUE" : "FALSE", infoPtr->fStatus);
infoPtr->DoRedraw = (BOOL) wParam;
if (wParam) {
if (infoPtr->fStatus & BAND_NEEDS_REDRAW) {
REBAR_MoveChildWindows (infoPtr, 0, infoPtr->uNumBands);
REBAR_ForceResize (infoPtr);
InvalidateRect (infoPtr->hwndSelf, 0, TRUE);
}
infoPtr->fStatus &= ~BAND_NEEDS_REDRAW;
}
return (oldredraw) ? -1 : 0;
}
static LRESULT
REBAR_Size (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
RECT rcClient;
/* auto resize deadlock check */
if (infoPtr->fStatus & AUTO_RESIZE) {
infoPtr->fStatus &= ~AUTO_RESIZE;
TRACE("AUTO_RESIZE was set, reset, fStatus=%08x lparam=%08lx\n",
infoPtr->fStatus, lParam);
return 0;
}
if (infoPtr->fStatus & CREATE_RUNNING) {
/* still in CreateWindow */
RECT rcWin;
if ((INT)wParam != SIZE_RESTORED) {
ERR("WM_SIZE in create and flags=%08x, lParam=%08lx\n",
wParam, lParam);
}
TRACE("still in CreateWindow\n");
infoPtr->fStatus &= ~CREATE_RUNNING;
GetWindowRect ( infoPtr->hwndSelf, &rcWin);
TRACE("win rect (%ld,%ld)-(%ld,%ld)\n",
rcWin.left, rcWin.top, rcWin.right, rcWin.bottom);
if ((lParam == 0) && (rcWin.right-rcWin.left == 0) &&
(rcWin.bottom-rcWin.top == 0)) {
/* native control seems to do this */
GetClientRect (GetParent(infoPtr->hwndSelf), &rcClient);
TRACE("sizing rebar, message and client zero, parent client (%ld,%ld)\n",
rcClient.right, rcClient.bottom);
}
else {
INT cx, cy;
cx = rcWin.right - rcWin.left;
cy = rcWin.bottom - rcWin.top;
if ((cx == LOWORD(lParam)) && (cy == HIWORD(lParam))) {
return 0;
}
/* do the actual WM_SIZE request */
GetClientRect (infoPtr->hwndSelf, &rcClient);
TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%ld,%ld)\n",
infoPtr->calcSize.cx, infoPtr->calcSize.cy,
LOWORD(lParam), HIWORD(lParam),
rcClient.right, rcClient.bottom);
}
}
else {
if ((INT)wParam != SIZE_RESTORED) {
ERR("WM_SIZE out of create and flags=%08x, lParam=%08lx\n",
wParam, lParam);
}
/* Handle cases when outside of the CreateWindow process */
GetClientRect (infoPtr->hwndSelf, &rcClient);
if ((lParam == 0) && (rcClient.right + rcClient.bottom != 0) &&
(infoPtr->dwStyle & RBS_AUTOSIZE)) {
/* on a WM_SIZE to zero and current client not zero and AUTOSIZE */
/* native seems to use the current client rect for the size */
infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
TRACE("sizing rebar to client (%ld,%ld) size is zero but AUTOSIZE set\n",
rcClient.right, rcClient.bottom);
}
else {
TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%ld,%ld)\n",
infoPtr->calcSize.cx, infoPtr->calcSize.cy,
LOWORD(lParam), HIWORD(lParam),
rcClient.right, rcClient.bottom);
}
}
if (infoPtr->dwStyle & RBS_AUTOSIZE) {
NMRBAUTOSIZE autosize;
GetClientRect(infoPtr->hwndSelf, &autosize.rcTarget);
autosize.fChanged = 0; /* ??? */
autosize.rcActual = autosize.rcTarget; /* ??? */
REBAR_Notify((NMHDR *) &autosize, infoPtr, RBN_AUTOSIZE);
TRACE("RBN_AUTOSIZE client=(%ld,%ld), lp=%08lx\n",
autosize.rcTarget.right, autosize.rcTarget.bottom, lParam);
}
if ((infoPtr->calcSize.cx != rcClient.right) ||
(infoPtr->calcSize.cy != rcClient.bottom))
infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
REBAR_Layout (infoPtr, &rcClient, TRUE, TRUE);
return 0;
}
static LRESULT
REBAR_StyleChanged (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
STYLESTRUCT *ss = (STYLESTRUCT *)lParam;
TRACE("current style=%08lx, styleOld=%08lx, style being set to=%08lx\n",
infoPtr->dwStyle, ss->styleOld, ss->styleNew);
infoPtr->dwStyle = ss->styleNew;
return FALSE;
}
static LRESULT
REBAR_WindowPosChanged (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{
WINDOWPOS *lpwp = (WINDOWPOS *)lParam;
LRESULT ret;
RECT rc;
/* Save the new origin of this window - used by _ForceResize */
infoPtr->origin.x = lpwp->x;
infoPtr->origin.y = lpwp->y;
ret = DefWindowProcW(infoPtr->hwndSelf, WM_WINDOWPOSCHANGED,
wParam, lParam);
GetWindowRect(infoPtr->hwndSelf, &rc);
TRACE("hwnd %p new pos (%ld,%ld)-(%ld,%ld)\n",
infoPtr->hwndSelf, rc.left, rc.top, rc.right, rc.bottom);
return ret;
}
static LRESULT WINAPI
REBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n",
hwnd, uMsg, wParam, lParam);
if (!infoPtr && (uMsg != WM_NCCREATE))
return DefWindowProcW (hwnd, uMsg, wParam, lParam);
switch (uMsg)
{
/* case RB_BEGINDRAG: */
case RB_DELETEBAND:
return REBAR_DeleteBand (infoPtr, wParam, lParam);
/* case RB_DRAGMOVE: */
/* case RB_ENDDRAG: */
case RB_GETBANDBORDERS:
return REBAR_GetBandBorders (infoPtr, wParam, lParam);
case RB_GETBANDCOUNT:
return REBAR_GetBandCount (infoPtr);
case RB_GETBANDINFO_OLD:
case RB_GETBANDINFOA:
return REBAR_GetBandInfoA (infoPtr, wParam, lParam);
case RB_GETBANDINFOW:
return REBAR_GetBandInfoW (infoPtr, wParam, lParam);
case RB_GETBARHEIGHT:
return REBAR_GetBarHeight (infoPtr, wParam, lParam);
case RB_GETBARINFO:
return REBAR_GetBarInfo (infoPtr, wParam, lParam);
case RB_GETBKCOLOR:
return REBAR_GetBkColor (infoPtr);
/* case RB_GETCOLORSCHEME: */
/* case RB_GETDROPTARGET: */
case RB_GETPALETTE:
return REBAR_GetPalette (infoPtr, wParam, lParam);
case RB_GETRECT:
return REBAR_GetRect (infoPtr, wParam, lParam);
case RB_GETROWCOUNT:
return REBAR_GetRowCount (infoPtr);
case RB_GETROWHEIGHT:
return REBAR_GetRowHeight (infoPtr, wParam, lParam);
case RB_GETTEXTCOLOR:
return REBAR_GetTextColor (infoPtr);
case RB_GETTOOLTIPS:
return REBAR_GetToolTips (infoPtr);
case RB_GETUNICODEFORMAT:
return REBAR_GetUnicodeFormat (infoPtr);
case CCM_GETVERSION:
return REBAR_GetVersion (infoPtr);
case RB_HITTEST:
return REBAR_HitTest (infoPtr, wParam, lParam);
case RB_IDTOINDEX:
return REBAR_IdToIndex (infoPtr, wParam, lParam);
case RB_INSERTBANDA:
return REBAR_InsertBandA (infoPtr, wParam, lParam);
case RB_INSERTBANDW:
return REBAR_InsertBandW (infoPtr, wParam, lParam);
case RB_MAXIMIZEBAND:
return REBAR_MaximizeBand (infoPtr, wParam, lParam);
case RB_MINIMIZEBAND:
return REBAR_MinimizeBand (infoPtr, wParam, lParam);
case RB_MOVEBAND:
return REBAR_MoveBand (infoPtr, wParam, lParam);
case RB_PUSHCHEVRON:
return REBAR_PushChevron (infoPtr, wParam, lParam);
case RB_SETBANDINFOA:
return REBAR_SetBandInfoA (infoPtr, wParam, lParam);
case RB_SETBANDINFOW:
return REBAR_SetBandInfoW (infoPtr, wParam, lParam);
case RB_SETBARINFO:
return REBAR_SetBarInfo (infoPtr, wParam, lParam);
case RB_SETBKCOLOR:
return REBAR_SetBkColor (infoPtr, wParam, lParam);
/* case RB_SETCOLORSCHEME: */
/* case RB_SETPALETTE: */
/* return REBAR_GetPalette (infoPtr, wParam, lParam); */
case RB_SETPARENT:
return REBAR_SetParent (infoPtr, wParam, lParam);
case RB_SETTEXTCOLOR:
return REBAR_SetTextColor (infoPtr, wParam, lParam);
/* case RB_SETTOOLTIPS: */
case RB_SETUNICODEFORMAT:
return REBAR_SetUnicodeFormat (infoPtr, wParam);
case CCM_SETVERSION:
return REBAR_SetVersion (infoPtr, (INT)wParam);
case RB_SHOWBAND:
return REBAR_ShowBand (infoPtr, wParam, lParam);
case RB_SIZETORECT:
return REBAR_SizeToRect (infoPtr, wParam, lParam);
/* Messages passed to parent */
case WM_COMMAND:
case WM_DRAWITEM:
case WM_NOTIFY:
if (infoPtr->NtfUnicode)
return SendMessageW (REBAR_GetNotifyParent (infoPtr),
uMsg, wParam, lParam);
else
return SendMessageA (REBAR_GetNotifyParent (infoPtr),
uMsg, wParam, lParam);
/* case WM_CHARTOITEM: supported according to ControlSpy */
case WM_CREATE:
return REBAR_Create (infoPtr, wParam, lParam);
case WM_DESTROY:
return REBAR_Destroy (infoPtr, wParam, lParam);
case WM_ERASEBKGND:
return REBAR_EraseBkGnd (infoPtr, wParam, lParam);
case WM_GETFONT:
return REBAR_GetFont (infoPtr, wParam, lParam);
/* case WM_LBUTTONDBLCLK: supported according to ControlSpy */
case WM_LBUTTONDOWN:
return REBAR_LButtonDown (infoPtr, wParam, lParam);
case WM_LBUTTONUP:
return REBAR_LButtonUp (infoPtr, wParam, lParam);
/* case WM_MEASUREITEM: supported according to ControlSpy */
case WM_MOUSEMOVE:
return REBAR_MouseMove (infoPtr, wParam, lParam);
case WM_MOUSELEAVE:
return REBAR_MouseLeave (infoPtr, wParam, lParam);
case WM_NCCALCSIZE:
return REBAR_NCCalcSize (infoPtr, wParam, lParam);
case WM_NCCREATE:
return REBAR_NCCreate (hwnd, wParam, lParam);
case WM_NCHITTEST:
return REBAR_NCHitTest (infoPtr, wParam, lParam);
case WM_NCPAINT:
return REBAR_NCPaint (infoPtr, wParam, lParam);
case WM_NOTIFYFORMAT:
return REBAR_NotifyFormat (infoPtr, wParam, lParam);
case WM_PAINT:
return REBAR_Paint (infoPtr, wParam, lParam);
/* case WM_PALETTECHANGED: supported according to ControlSpy */
/* case WM_PRINTCLIENT: supported according to ControlSpy */
/* case WM_QUERYNEWPALETTE:supported according to ControlSpy */
/* case WM_RBUTTONDOWN: supported according to ControlSpy */
/* case WM_RBUTTONUP: supported according to ControlSpy */
case WM_SETCURSOR:
return REBAR_SetCursor (infoPtr, wParam, lParam);
case WM_SETFONT:
return REBAR_SetFont (infoPtr, wParam, lParam);
case WM_SETREDRAW:
return REBAR_SetRedraw (infoPtr, wParam, lParam);
case WM_SIZE:
return REBAR_Size (infoPtr, wParam, lParam);
case WM_STYLECHANGED:
return REBAR_StyleChanged (infoPtr, wParam, lParam);
/* case WM_SYSCOLORCHANGE: supported according to ControlSpy */
/* "Applications that have brushes using the existing system colors
should delete those brushes and recreate them using the new
system colors." per MSDN */
/* case WM_VKEYTOITEM: supported according to ControlSpy */
/* case WM_WININICHANGE: */
case WM_WINDOWPOSCHANGED:
return REBAR_WindowPosChanged (infoPtr, wParam, lParam);
default:
if ((uMsg >= WM_USER) && (uMsg < WM_APP))
ERR("unknown msg %04x wp=%08x lp=%08lx\n",
uMsg, wParam, lParam);
return DefWindowProcW (hwnd, uMsg, wParam, lParam);
}
}
VOID
REBAR_Register (void)
{
WNDCLASSW wndClass;
ZeroMemory (&wndClass, sizeof(WNDCLASSW));
wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
wndClass.lpfnWndProc = REBAR_WindowProc;
wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = sizeof(REBAR_INFO *);
wndClass.hCursor = 0;
wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
#if GLATESTING
wndClass.hbrBackground = CreateSolidBrush(RGB(0,128,0));
#endif
wndClass.lpszClassName = REBARCLASSNAMEW;
RegisterClassW (&wndClass);
mindragx = GetSystemMetrics (SM_CXDRAG);
mindragy = GetSystemMetrics (SM_CYDRAG);
}
VOID
REBAR_Unregister (void)
{
UnregisterClassW (REBARCLASSNAMEW, NULL);
}