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
|
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the either Technology Preview License Agreement or the
** Beta Release License Agreement.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qwindowsstyle.h"
#include "qwindowsstyle_p.h"
#include <private/qpixmapdata_p.h>
#include <private/qstylehelper_p.h>
#if !defined(QT_NO_STYLE_WINDOWS) || defined(QT_PLUGIN)
#include "qlibrary.h"
#include "qapplication.h"
#include "qbitmap.h"
#include "qdrawutil.h" // for now
#include "qevent.h"
#include "qmenu.h"
#include "qmenubar.h"
#include <private/qmenubar_p.h>
#include "qpaintengine.h"
#include "qpainter.h"
#include "qprogressbar.h"
#include "qrubberband.h"
#include "qstyleoption.h"
#include "qtabbar.h"
#include "qwidget.h"
#include "qdebug.h"
#include "qmainwindow.h"
#include "qfile.h"
#include "qtextstream.h"
#include "qpixmapcache.h"
#include "qwizard.h"
#include "qlistview.h"
#include <private/qmath_p.h>
#include <qmath.h>
#ifdef Q_WS_X11
#include "qfileinfo.h"
#include "qdir.h"
#include <private/qt_x11_p.h>
#endif
QT_BEGIN_NAMESPACE
#if defined(Q_WS_WIN)
QT_BEGIN_INCLUDE_NAMESPACE
#include "qt_windows.h"
QT_END_INCLUDE_NAMESPACE
# ifndef COLOR_GRADIENTACTIVECAPTION
# define COLOR_GRADIENTACTIVECAPTION 27
# endif
# ifndef COLOR_GRADIENTINACTIVECAPTION
# define COLOR_GRADIENTINACTIVECAPTION 28
# endif
typedef struct
{
DWORD cbSize;
HICON hIcon;
int iSysImageIndex;
int iIcon;
WCHAR szPath[MAX_PATH];
} QSHSTOCKICONINFO;
#define _SHGFI_SMALLICON 0x000000001
#define _SHGFI_LARGEICON 0x000000000
#define _SHGFI_ICON 0x000000100
#define _SIID_SHIELD 77
typedef HRESULT (WINAPI *PtrSHGetStockIconInfo)(int siid, int uFlags, QSHSTOCKICONINFO *psii);
static PtrSHGetStockIconInfo pSHGetStockIconInfo = 0;
#endif //Q_WS_WIN
QT_BEGIN_INCLUDE_NAMESPACE
#include <limits.h>
QT_END_INCLUDE_NAMESPACE
static const int windowsItemFrame = 2; // menu item frame width
static const int windowsSepHeight = 9; // separator item height
static const int windowsItemHMargin = 3; // menu item hor text margin
static const int windowsItemVMargin = 2; // menu item ver text margin
static const int windowsArrowHMargin = 6; // arrow horizontal margin
static const int windowsRightBorder = 15; // right border on windows
static const int windowsCheckMarkWidth = 12; // checkmarks width on windows
enum QSliderDirection { SlUp, SlDown, SlLeft, SlRight };
/*
\internal
*/
QWindowsStylePrivate::QWindowsStylePrivate()
: alt_down(false), menuBarTimer(0), animationFps(10), animateTimer(0), animateStep(0)
{
#if defined(Q_WS_WIN) && !defined(Q_OS_WINCE)
if ((QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA
&& QSysInfo::WindowsVersion < QSysInfo::WV_NT_based)) {
QLibrary shellLib(QLatin1String("shell32"));
pSHGetStockIconInfo = (PtrSHGetStockIconInfo)shellLib.resolve("SHGetStockIconInfo");
}
#endif
}
// Returns true if the toplevel parent of \a widget has seen the Alt-key
bool QWindowsStylePrivate::hasSeenAlt(const QWidget *widget) const
{
widget = widget->window();
return seenAlt.contains(widget);
}
/*!
\reimp
*/
void QWindowsStyle::timerEvent(QTimerEvent *event)
{
#ifndef QT_NO_PROGRESSBAR
Q_D(QWindowsStyle);
if (event->timerId() == d->animateTimer) {
Q_ASSERT(d->animationFps> 0);
d->animateStep = d->startTime.elapsed() / (1000 / d->animationFps);
foreach (QProgressBar *bar, d->bars) {
if ((bar->minimum() == 0 && bar->maximum() == 0))
bar->update();
}
}
#endif // QT_NO_PROGRESSBAR
event->ignore();
}
/*!
\reimp
*/
bool QWindowsStyle::eventFilter(QObject *o, QEvent *e)
{
// Records Alt- and Focus events
if (!o->isWidgetType())
return QObject::eventFilter(o, e);
QWidget *widget = qobject_cast<QWidget*>(o);
Q_D(QWindowsStyle);
switch(e->type()) {
case QEvent::KeyPress:
if (static_cast<QKeyEvent *>(e)->key() == Qt::Key_Alt) {
widget = widget->window();
// Alt has been pressed - find all widgets that care
QList<QWidget *> l = qFindChildren<QWidget *>(widget);
for (int pos=0 ; pos < l.size() ; ++pos) {
QWidget *w = l.at(pos);
if (w->isWindow() || !w->isVisible() ||
w->style()->styleHint(SH_UnderlineShortcut, 0, w))
l.removeAt(pos);
}
// Update states before repainting
d->seenAlt.append(widget);
d->alt_down = true;
// Repaint all relevant widgets
for (int pos = 0; pos < l.size(); ++pos)
l.at(pos)->update();
}
break;
case QEvent::KeyRelease:
if (static_cast<QKeyEvent*>(e)->key() == Qt::Key_Alt) {
widget = widget->window();
// Update state and repaint the menu bars.
d->alt_down = false;
#ifndef QT_NO_MENUBAR
QList<QMenuBar *> l = qFindChildren<QMenuBar *>(widget);
for (int i = 0; i < l.size(); ++i)
l.at(i)->update();
#endif
}
break;
case QEvent::Close:
// Reset widget when closing
d->seenAlt.removeAll(widget);
d->seenAlt.removeAll(widget->window());
break;
#ifndef QT_NO_PROGRESSBAR
case QEvent::StyleChange:
case QEvent::Show:
if (QProgressBar *bar = qobject_cast<QProgressBar *>(o)) {
d->bars << bar;
if (d->bars.size() == 1) {
Q_ASSERT(d->animationFps> 0);
d->animateTimer = startTimer(1000 / d->animationFps);
}
}
break;
case QEvent::Destroy:
case QEvent::Hide:
// reinterpret_cast because there is no type info when getting
// the destroy event. We know that it is a QProgressBar.
if (QProgressBar *bar = reinterpret_cast<QProgressBar *>(o)) {
d->bars.removeAll(bar);
if (d->bars.isEmpty() && d->animateTimer) {
killTimer(d->animateTimer);
d->animateTimer = 0;
}
}
break;
#endif // QT_NO_PROGRESSBAR
default:
break;
}
return QCommonStyle::eventFilter(o, e);
}
/*!
\class QWindowsStyle
\brief The QWindowsStyle class provides a Microsoft Windows-like look and feel.
\ingroup appearance
This style is Qt's default GUI style on Windows.
\img qwindowsstyle.png
\sa QWindowsXPStyle, QMacStyle, QPlastiqueStyle, QCDEStyle, QMotifStyle
*/
/*!
Constructs a QWindowsStyle object.
*/
QWindowsStyle::QWindowsStyle() : QCommonStyle(*new QWindowsStylePrivate)
{
}
/*!
\internal
Constructs a QWindowsStyle object.
*/
QWindowsStyle::QWindowsStyle(QWindowsStylePrivate &dd) : QCommonStyle(dd)
{
}
/*! Destroys the QWindowsStyle object. */
QWindowsStyle::~QWindowsStyle()
{
}
#ifdef Q_WS_WIN
static inline QRgb colorref2qrgb(COLORREF col)
{
return qRgb(GetRValue(col), GetGValue(col), GetBValue(col));
}
#endif
/*! \reimp */
void QWindowsStyle::polish(QApplication *app)
{
QCommonStyle::polish(app);
QWindowsStylePrivate *d = const_cast<QWindowsStylePrivate*>(d_func());
// We only need the overhead when shortcuts are sometimes hidden
if (!proxy()->styleHint(SH_UnderlineShortcut, 0) && app)
app->installEventFilter(this);
d->activeCaptionColor = app->palette().highlight().color();
d->activeGradientCaptionColor = app->palette().highlight() .color();
d->inactiveCaptionColor = app->palette().dark().color();
d->inactiveGradientCaptionColor = app->palette().dark().color();
d->inactiveCaptionText = app->palette().background().color();
#if defined(Q_WS_WIN) //fetch native title bar colors
if(app->desktopSettingsAware()){
DWORD activeCaption = GetSysColor(COLOR_ACTIVECAPTION);
DWORD gradientActiveCaption = GetSysColor(COLOR_GRADIENTACTIVECAPTION);
DWORD inactiveCaption = GetSysColor(COLOR_INACTIVECAPTION);
DWORD gradientInactiveCaption = GetSysColor(COLOR_GRADIENTINACTIVECAPTION);
DWORD inactiveCaptionText = GetSysColor(COLOR_INACTIVECAPTIONTEXT);
d->activeCaptionColor = colorref2qrgb(activeCaption);
d->activeGradientCaptionColor = colorref2qrgb(gradientActiveCaption);
d->inactiveCaptionColor = colorref2qrgb(inactiveCaption);
d->inactiveGradientCaptionColor = colorref2qrgb(gradientInactiveCaption);
d->inactiveCaptionText = colorref2qrgb(inactiveCaptionText);
}
#endif
}
/*! \reimp */
void QWindowsStyle::unpolish(QApplication *app)
{
QCommonStyle::unpolish(app);
app->removeEventFilter(this);
}
/*! \reimp */
void QWindowsStyle::polish(QWidget *widget)
{
QCommonStyle::polish(widget);
#ifndef QT_NO_PROGRESSBAR
if (qobject_cast<QProgressBar *>(widget))
widget->installEventFilter(this);
#endif
}
/*! \reimp */
void QWindowsStyle::unpolish(QWidget *widget)
{
QCommonStyle::unpolish(widget);
#ifndef QT_NO_PROGRESSBAR
if (QProgressBar *bar=qobject_cast<QProgressBar *>(widget)) {
Q_D(QWindowsStyle);
widget->removeEventFilter(this);
d->bars.removeAll(bar);
}
#endif
}
/*!
\reimp
*/
void QWindowsStyle::polish(QPalette &pal)
{
QCommonStyle::polish(pal);
}
/*!
\reimp
*/
int QWindowsStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QWidget *widget) const
{
int ret;
switch (pm) {
case PM_ButtonDefaultIndicator:
case PM_ButtonShiftHorizontal:
case PM_ButtonShiftVertical:
case PM_MenuHMargin:
case PM_MenuVMargin:
ret = 1;
break;
#ifndef QT_NO_TABBAR
case PM_TabBarTabShiftHorizontal:
ret = 0;
break;
case PM_TabBarTabShiftVertical:
ret = 2;
break;
#endif
case PM_MaximumDragDistance:
#if defined(Q_WS_WIN)
{
HDC hdcScreen = GetDC(0);
int dpi = GetDeviceCaps(hdcScreen, LOGPIXELSX);
ReleaseDC(0, hdcScreen);
ret = (int)(dpi * 1.375);
}
#else
ret = 60;
#endif
break;
#ifndef QT_NO_SLIDER
case PM_SliderLength:
ret = int(QStyleHelper::dpiScaled(11.));
break;
// Returns the number of pixels to use for the business part of the
// slider (i.e., the non-tickmark portion). The remaining space is shared
// equally between the tickmark regions.
case PM_SliderControlThickness:
if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
int space = (sl->orientation == Qt::Horizontal) ? sl->rect.height() : sl->rect.width();
int ticks = sl->tickPosition;
int n = 0;
if (ticks & QSlider::TicksAbove)
++n;
if (ticks & QSlider::TicksBelow)
++n;
if (!n) {
ret = space;
break;
}
int thick = 6; // Magic constant to get 5 + 16 + 5
if (ticks != QSlider::TicksBothSides && ticks != QSlider::NoTicks)
thick += proxy()->pixelMetric(PM_SliderLength, sl, widget) / 4;
space -= thick;
if (space > 0)
thick += (space * 2) / (n + 2);
ret = thick;
} else {
ret = 0;
}
break;
#endif // QT_NO_SLIDER
#ifndef QT_NO_MENU
case PM_MenuBarHMargin:
ret = 0;
break;
case PM_MenuBarVMargin:
ret = 0;
break;
case PM_MenuBarPanelWidth:
ret = 0;
break;
case PM_SmallIconSize:
ret = int(QStyleHelper::dpiScaled(16.));
break;
case PM_LargeIconSize:
ret = int(QStyleHelper::dpiScaled(32.));
break;
case PM_IconViewIconSize:
ret = proxy()->pixelMetric(PM_LargeIconSize, opt, widget);
break;
case PM_ToolBarIconSize:
ret = int(QStyleHelper::dpiScaled(24.));
break;
case PM_DockWidgetTitleMargin:
ret = int(QStyleHelper::dpiScaled(2.));
break;
case PM_DockWidgetTitleBarButtonMargin:
ret = int(QStyleHelper::dpiScaled(4.));
break;
#if defined(Q_WS_WIN)
case PM_DockWidgetFrameWidth:
#if defined(Q_OS_WINCE)
ret = GetSystemMetrics(SM_CXDLGFRAME);
#else
ret = GetSystemMetrics(SM_CXFRAME);
#endif
break;
#else
case PM_DockWidgetFrameWidth:
ret = 4;
break;
#endif // Q_WS_WIN
break;
#endif // QT_NO_MENU
#if defined(Q_WS_WIN)
case PM_TitleBarHeight:
#ifdef QT3_SUPPORT
// qt3 dockwindow height should be equal to tool windows
if (widget && widget->inherits("Q3DockWindowTitleBar")) {
ret = GetSystemMetrics(SM_CYSMCAPTION) - 1;
} else
#endif
if (widget && (widget->windowType() == Qt::Tool)) {
// MS always use one less than they say
#if defined(Q_OS_WINCE)
ret = GetSystemMetrics(SM_CYCAPTION) - 1;
#else
ret = GetSystemMetrics(SM_CYSMCAPTION) - 1;
#endif
} else {
ret = GetSystemMetrics(SM_CYCAPTION) - 1;
}
break;
case PM_ScrollBarExtent:
{
#ifndef Q_OS_WINCE
NONCLIENTMETRICS ncm;
ncm.cbSize = sizeof(NONCLIENTMETRICS);
if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0))
ret = qMax(ncm.iScrollHeight, ncm.iScrollWidth);
else
#endif
ret = QCommonStyle::pixelMetric(pm, opt, widget);
}
break;
#endif // Q_WS_WIN
case PM_SplitterWidth:
ret = qMax(4, QApplication::globalStrut().width());
break;
#if defined(Q_WS_WIN)
case PM_MdiSubWindowFrameWidth:
#if defined(Q_OS_WINCE)
ret = GetSystemMetrics(SM_CYDLGFRAME);
#else
ret = GetSystemMetrics(SM_CYFRAME);
#endif
break;
case PM_TextCursorWidth: {
DWORD caretWidth = 1;
#if defined(SPI_GETCARETWIDTH)
SystemParametersInfo(SPI_GETCARETWIDTH, 0, &caretWidth, 0);
#endif
ret = (int)caretWidth;
break; }
#endif
case PM_ToolBarItemMargin:
ret = 1;
break;
case PM_ToolBarItemSpacing:
ret = 0;
break;
case PM_ToolBarHandleExtent:
ret = int(QStyleHelper::dpiScaled(10.));
break;
default:
ret = QCommonStyle::pixelMetric(pm, opt, widget);
break;
}
return ret;
}
#ifndef QT_NO_IMAGEFORMAT_XPM
/* XPM */
static const char * const qt_menu_xpm[] = {
"16 16 72 1",
" c None",
". c #65AF36",
"+ c #66B036",
"@ c #77B94C",
"# c #A7D28C",
"$ c #BADBA4",
"% c #A4D088",
"& c #72B646",
"* c #9ACB7A",
"= c #7FBD56",
"- c #85C05F",
"; c #F4F9F0",
"> c #FFFFFF",
", c #E5F1DC",
"' c #ECF5E7",
") c #7ABA50",
"! c #83BF5C",
"~ c #AED595",
"{ c #D7EACA",
"] c #A9D28D",
"^ c #BCDDA8",
"/ c #C4E0B1",
"( c #81BE59",
"_ c #D0E7C2",
": c #D4E9C6",
"< c #6FB542",
"[ c #6EB440",
"} c #88C162",
"| c #98CA78",
"1 c #F4F9F1",
"2 c #8FC56C",
"3 c #F1F8EC",
"4 c #E8F3E1",
"5 c #D4E9C7",
"6 c #74B748",
"7 c #80BE59",
"8 c #73B747",
"9 c #6DB43F",
"0 c #CBE4BA",
"a c #80BD58",
"b c #6DB33F",
"c c #FEFFFE",
"d c #68B138",
"e c #F9FCF7",
"f c #91C66F",
"g c #E8F3E0",
"h c #DCEDD0",
"i c #91C66E",
"j c #A3CF86",
"k c #C9E3B8",
"l c #B0D697",
"m c #E3F0DA",
"n c #95C873",
"o c #E6F2DE",
"p c #9ECD80",
"q c #BEDEAA",
"r c #C7E2B6",
"s c #79BA4F",
"t c #6EB441",
"u c #BCDCA7",
"v c #FAFCF8",
"w c #F6FAF3",
"x c #84BF5D",
"y c #EDF6E7",
"z c #FAFDF9",
"A c #88C263",
"B c #98CA77",
"C c #CDE5BE",
"D c #67B037",
"E c #D9EBCD",
"F c #6AB23C",
"G c #77B94D",
" .++++++++++++++",
".+++++++++++++++",
"+++@#$%&+++*=+++",
"++-;>,>')+!>~+++",
"++{>]+^>/(_>:~<+",
"+[>>}+|>123>456+",
"+7>>8+->>90>~+++",
"+a>>b+a>c[0>~+++",
"+de>=+f>g+0>~+++",
"++h>i+j>k+0>~+++",
"++l>mno>p+q>rst+",
"++duv>wl++xy>zA+",
"++++B>Cb++++&D++",
"+++++0zE++++++++",
"++++++FG+++++++.",
"++++++++++++++. "};
static const char * const qt_close_xpm[] = {
"10 10 2 1",
"# c #000000",
". c None",
"..........",
".##....##.",
"..##..##..",
"...####...",
"....##....",
"...####...",
"..##..##..",
".##....##.",
"..........",
".........."};
static const char * const qt_maximize_xpm[]={
"10 10 2 1",
"# c #000000",
". c None",
"#########.",
"#########.",
"#.......#.",
"#.......#.",
"#.......#.",
"#.......#.",
"#.......#.",
"#.......#.",
"#########.",
".........."};
static const char * const qt_minimize_xpm[] = {
"10 10 2 1",
"# c #000000",
". c None",
"..........",
"..........",
"..........",
"..........",
"..........",
"..........",
"..........",
".#######..",
".#######..",
".........."};
static const char * const qt_normalizeup_xpm[] = {
"10 10 2 1",
"# c #000000",
". c None",
"...######.",
"...######.",
"...#....#.",
".######.#.",
".######.#.",
".#....###.",
".#....#...",
".#....#...",
".######...",
".........."};
static const char * const qt_help_xpm[] = {
"10 10 2 1",
". c None",
"# c #000000",
"..........",
"..######..",
".##....##.",
"......##..",
".....##...",
"....##....",
"....##....",
"..........",
"....##....",
".........."};
static const char * const qt_shade_xpm[] = {
"10 10 2 1",
"# c #000000",
". c None",
"..........",
"..........",
"..........",
"..........",
"....#.....",
"...###....",
"..#####...",
".#######..",
"..........",
".........."};
static const char * const qt_unshade_xpm[] = {
"10 10 2 1",
"# c #000000",
". c None",
"..........",
"..........",
"..........",
".#######..",
"..#####...",
"...###....",
"....#.....",
"..........",
"..........",
".........."};
static const char * dock_widget_close_xpm[] = {
"8 8 2 1",
"# c #000000",
". c None",
"........",
".##..##.",
"..####..",
"...##...",
"..####..",
".##..##.",
"........",
"........"};
/* XPM */
static const char * const information_xpm[]={
"32 32 5 1",
". c None",
"c c #000000",
"* c #999999",
"a c #ffffff",
"b c #0000ff",
"...........********.............",
"........***aaaaaaaa***..........",
"......**aaaaaaaaaaaaaa**........",
".....*aaaaaaaaaaaaaaaaaa*.......",
"....*aaaaaaaabbbbaaaaaaaac......",
"...*aaaaaaaabbbbbbaaaaaaaac.....",
"..*aaaaaaaaabbbbbbaaaaaaaaac....",
".*aaaaaaaaaaabbbbaaaaaaaaaaac...",
".*aaaaaaaaaaaaaaaaaaaaaaaaaac*..",
"*aaaaaaaaaaaaaaaaaaaaaaaaaaaac*.",
"*aaaaaaaaaabbbbbbbaaaaaaaaaaac*.",
"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
".*aaaaaaaaaaabbbbbaaaaaaaaaac***",
".*aaaaaaaaaaabbbbbaaaaaaaaaac***",
"..*aaaaaaaaaabbbbbaaaaaaaaac***.",
"...caaaaaaabbbbbbbbbaaaaaac****.",
"....caaaaaaaaaaaaaaaaaaaac****..",
".....caaaaaaaaaaaaaaaaaac****...",
"......ccaaaaaaaaaaaaaacc****....",
".......*cccaaaaaaaaccc*****.....",
"........***cccaaaac*******......",
"..........****caaac*****........",
".............*caaac**...........",
"...............caac**...........",
"................cac**...........",
".................cc**...........",
"..................***...........",
"...................**..........."};
/* XPM */
static const char* const warning_xpm[]={
"32 32 4 1",
". c None",
"a c #ffff00",
"* c #000000",
"b c #999999",
".............***................",
"............*aaa*...............",
"...........*aaaaa*b.............",
"...........*aaaaa*bb............",
"..........*aaaaaaa*bb...........",
"..........*aaaaaaa*bb...........",
".........*aaaaaaaaa*bb..........",
".........*aaaaaaaaa*bb..........",
"........*aaaaaaaaaaa*bb.........",
"........*aaaa***aaaa*bb.........",
".......*aaaa*****aaaa*bb........",
".......*aaaa*****aaaa*bb........",
"......*aaaaa*****aaaaa*bb.......",
"......*aaaaa*****aaaaa*bb.......",
".....*aaaaaa*****aaaaaa*bb......",
".....*aaaaaa*****aaaaaa*bb......",
"....*aaaaaaaa***aaaaaaaa*bb.....",
"....*aaaaaaaa***aaaaaaaa*bb.....",
"...*aaaaaaaaa***aaaaaaaaa*bb....",
"...*aaaaaaaaaa*aaaaaaaaaa*bb....",
"..*aaaaaaaaaaa*aaaaaaaaaaa*bb...",
"..*aaaaaaaaaaaaaaaaaaaaaaa*bb...",
".*aaaaaaaaaaaa**aaaaaaaaaaa*bb..",
".*aaaaaaaaaaa****aaaaaaaaaa*bb..",
"*aaaaaaaaaaaa****aaaaaaaaaaa*bb.",
"*aaaaaaaaaaaaa**aaaaaaaaaaaa*bb.",
"*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb",
"*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb",
".*aaaaaaaaaaaaaaaaaaaaaaaaa*bbbb",
"..*************************bbbbb",
"....bbbbbbbbbbbbbbbbbbbbbbbbbbb.",
".....bbbbbbbbbbbbbbbbbbbbbbbbb.."};
/* XPM */
static const char* const critical_xpm[]={
"32 32 4 1",
". c None",
"a c #999999",
"* c #ff0000",
"b c #ffffff",
"...........********.............",
".........************...........",
".......****************.........",
"......******************........",
".....********************a......",
"....**********************a.....",
"...************************a....",
"..*******b**********b*******a...",
"..******bbb********bbb******a...",
".******bbbbb******bbbbb******a..",
".*******bbbbb****bbbbb*******a..",
"*********bbbbb**bbbbb*********a.",
"**********bbbbbbbbbb**********a.",
"***********bbbbbbbb***********aa",
"************bbbbbb************aa",
"************bbbbbb************aa",
"***********bbbbbbbb***********aa",
"**********bbbbbbbbbb**********aa",
"*********bbbbb**bbbbb*********aa",
".*******bbbbb****bbbbb*******aa.",
".******bbbbb******bbbbb******aa.",
"..******bbb********bbb******aaa.",
"..*******b**********b*******aa..",
"...************************aaa..",
"....**********************aaa...",
"....a********************aaa....",
".....a******************aaa.....",
"......a****************aaa......",
".......aa************aaaa.......",
".........aa********aaaaa........",
"...........aaaaaaaaaaa..........",
".............aaaaaaa............"};
/* XPM */
static const char *const question_xpm[] = {
"32 32 5 1",
". c None",
"c c #000000",
"* c #999999",
"a c #ffffff",
"b c #0000ff",
"...........********.............",
"........***aaaaaaaa***..........",
"......**aaaaaaaaaaaaaa**........",
".....*aaaaaaaaaaaaaaaaaa*.......",
"....*aaaaaaaaaaaaaaaaaaaac......",
"...*aaaaaaaabbbbbbaaaaaaaac.....",
"..*aaaaaaaabaaabbbbaaaaaaaac....",
".*aaaaaaaabbaaaabbbbaaaaaaaac...",
".*aaaaaaaabbbbaabbbbaaaaaaaac*..",
"*aaaaaaaaabbbbaabbbbaaaaaaaaac*.",
"*aaaaaaaaaabbaabbbbaaaaaaaaaac*.",
"*aaaaaaaaaaaaabbbbaaaaaaaaaaac**",
"*aaaaaaaaaaaaabbbaaaaaaaaaaaac**",
"*aaaaaaaaaaaaabbaaaaaaaaaaaaac**",
"*aaaaaaaaaaaaabbaaaaaaaaaaaaac**",
"*aaaaaaaaaaaaaaaaaaaaaaaaaaaac**",
".*aaaaaaaaaaaabbaaaaaaaaaaaac***",
".*aaaaaaaaaaabbbbaaaaaaaaaaac***",
"..*aaaaaaaaaabbbbaaaaaaaaaac***.",
"...caaaaaaaaaabbaaaaaaaaaac****.",
"....caaaaaaaaaaaaaaaaaaaac****..",
".....caaaaaaaaaaaaaaaaaac****...",
"......ccaaaaaaaaaaaaaacc****....",
".......*cccaaaaaaaaccc*****.....",
"........***cccaaaac*******......",
"..........****caaac*****........",
".............*caaac**...........",
"...............caac**...........",
"................cac**...........",
".................cc**...........",
"..................***...........",
"...................**..........."};
#endif //QT_NO_IMAGEFORMAT_XPM
/*!
\reimp
*/
QPixmap QWindowsStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
const QWidget *widget) const
{
#if defined(Q_WS_WIN) && !defined(Q_OS_WINCE)
QPixmap desktopIcon;
switch(standardPixmap) {
case SP_DriveCDIcon:
case SP_DriveDVDIcon:
{
desktopIcon = loadIconFromShell32(12, 16);
break;
}
case SP_DriveNetIcon:
{
desktopIcon = loadIconFromShell32(10, 16);
break;
}
case SP_DriveHDIcon:
{
desktopIcon = loadIconFromShell32(9, 16);
break;
}
case SP_DriveFDIcon:
{
desktopIcon = loadIconFromShell32(7, 16);
break;
}
case SP_FileIcon:
{
desktopIcon = loadIconFromShell32(1, 16);
break;
}
case SP_FileLinkIcon:
{
desktopIcon = loadIconFromShell32(1, 16);
QPainter painter(&desktopIcon);
QPixmap link = loadIconFromShell32(30, 16);
painter.drawPixmap(0, 0, 16, 16, link);
break;
}
case SP_DirLinkIcon:
{
desktopIcon = loadIconFromShell32(4, 16);
QPainter painter(&desktopIcon);
QPixmap link = loadIconFromShell32(30, 16);
painter.drawPixmap(0, 0, 16, 16, link);
break;
}
case SP_DirClosedIcon:
{
desktopIcon = loadIconFromShell32(4, 16);
break;
}
case SP_DesktopIcon:
{
desktopIcon = loadIconFromShell32(35, 16);
break;
}
case SP_ComputerIcon:
{
desktopIcon = loadIconFromShell32(16, 16);
break;
}
case SP_DirOpenIcon:
{
desktopIcon = loadIconFromShell32(5, 16);
break;
}
case SP_FileDialogNewFolder:
{
desktopIcon = loadIconFromShell32(319, 16);
break;
}
case SP_DirHomeIcon:
{
desktopIcon = loadIconFromShell32(235, 16);
break;
}
case SP_TrashIcon:
{
desktopIcon = loadIconFromShell32(191, 16);
break;
}
case SP_MessageBoxInformation:
{
HICON iconHandle = LoadIcon(NULL, IDI_INFORMATION);
desktopIcon = convertHIconToPixmap( iconHandle );
DestroyIcon(iconHandle);
break;
}
case SP_MessageBoxWarning:
{
HICON iconHandle = LoadIcon(NULL, IDI_WARNING);
desktopIcon = convertHIconToPixmap( iconHandle );
DestroyIcon(iconHandle);
break;
}
case SP_MessageBoxCritical:
{
HICON iconHandle = LoadIcon(NULL, IDI_ERROR);
desktopIcon = convertHIconToPixmap( iconHandle );
DestroyIcon(iconHandle);
break;
}
case SP_MessageBoxQuestion:
{
HICON iconHandle = LoadIcon(NULL, IDI_QUESTION);
desktopIcon = convertHIconToPixmap( iconHandle );
DestroyIcon(iconHandle);
break;
}
case SP_VistaShield:
{
if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA
&& QSysInfo::WindowsVersion < QSysInfo::WV_NT_based
&& pSHGetStockIconInfo)
{
QPixmap pixmap;
QSHSTOCKICONINFO iconInfo;
memset(&iconInfo, 0, sizeof(iconInfo));
iconInfo.cbSize = sizeof(iconInfo);
if (pSHGetStockIconInfo(_SIID_SHIELD, _SHGFI_ICON | _SHGFI_SMALLICON, &iconInfo) == S_OK) {
pixmap = convertHIconToPixmap(iconInfo.hIcon);
DestroyIcon(iconInfo.hIcon);
return pixmap;
}
}
}
break;
default:
break;
}
if (!desktopIcon.isNull()) {
return desktopIcon;
}
#endif
#ifndef QT_NO_IMAGEFORMAT_XPM
switch (standardPixmap) {
case SP_TitleBarMenuButton:
return QPixmap(qt_menu_xpm);
case SP_TitleBarShadeButton:
return QPixmap(qt_shade_xpm);
case SP_TitleBarUnshadeButton:
return QPixmap(qt_unshade_xpm);
case SP_TitleBarNormalButton:
return QPixmap(qt_normalizeup_xpm);
case SP_TitleBarMinButton:
return QPixmap(qt_minimize_xpm);
case SP_TitleBarMaxButton:
return QPixmap(qt_maximize_xpm);
case SP_TitleBarCloseButton:
return QPixmap(qt_close_xpm);
case SP_TitleBarContextHelpButton:
return QPixmap(qt_help_xpm);
case SP_DockWidgetCloseButton:
return QPixmap(dock_widget_close_xpm);
case SP_MessageBoxInformation:
return QPixmap(information_xpm);
case SP_MessageBoxWarning:
return QPixmap(warning_xpm);
case SP_MessageBoxCritical:
return QPixmap(critical_xpm);
case SP_MessageBoxQuestion:
return QPixmap(question_xpm);
default:
break;
}
#endif //QT_NO_IMAGEFORMAT_XPM
return QCommonStyle::standardPixmap(standardPixmap, opt, widget);
}
/*! \reimp */
int QWindowsStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QWidget *widget,
QStyleHintReturn *returnData) const
{
int ret = 0;
switch (hint) {
case SH_EtchDisabledText:
case SH_Slider_SnapToValue:
case SH_PrintDialog_RightAlignButtons:
case SH_FontDialog_SelectAssociatedText:
case SH_Menu_AllowActiveAndDisabled:
case SH_MenuBar_AltKeyNavigation:
case SH_MenuBar_MouseTracking:
case SH_Menu_MouseTracking:
case SH_ComboBox_ListMouseTracking:
case SH_ScrollBar_StopMouseOverSlider:
case SH_MainWindow_SpaceBelowMenuBar:
ret = 1;
break;
case SH_ItemView_ShowDecorationSelected:
#ifndef QT_NO_LISTVIEW
if (qobject_cast<const QListView*>(widget))
ret = 1;
#endif
break;
case SH_ItemView_ChangeHighlightOnFocus:
ret = 1;
break;
case SH_ToolBox_SelectedPageTitleBold:
ret = 0;
break;
#if defined(Q_WS_WIN)
case SH_UnderlineShortcut:
{
ret = 1;
BOOL cues = false;
SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &cues, 0);
ret = int(cues);
// Do nothing if we always paint underlines
Q_D(const QWindowsStyle);
if (!ret && widget && d) {
#ifndef QT_NO_MENUBAR
const QMenuBar *menuBar = qobject_cast<const QMenuBar *>(widget);
if (!menuBar && qobject_cast<const QMenu *>(widget)) {
QWidget *w = QApplication::activeWindow();
if (w && w != widget)
menuBar = qFindChild<QMenuBar *>(w);
}
// If we paint a menu bar draw underlines if is in the keyboardState
if (menuBar) {
if (menuBar->d_func()->keyboardState || d->altDown())
ret = 1;
// Otherwise draw underlines if the toplevel widget has seen an alt-press
} else
#endif // QT_NO_MENUBAR
if (d->hasSeenAlt(widget)) {
ret = 1;
}
}
break;
}
#endif
#ifndef QT_NO_RUBBERBAND
case SH_RubberBand_Mask:
if (const QStyleOptionRubberBand *rbOpt = qstyleoption_cast<const QStyleOptionRubberBand *>(opt)) {
ret = 0;
if (rbOpt->shape == QRubberBand::Rectangle) {
ret = true;
if(QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask*>(returnData)) {
mask->region = opt->rect;
int size = 1;
if (widget && widget->isWindow())
size = 4;
mask->region -= opt->rect.adjusted(size, size, -size, -size);
}
}
}
break;
#endif // QT_NO_RUBBERBAND
case SH_LineEdit_PasswordCharacter:
{
#ifdef Q_WS_WIN
if (widget && (QSysInfo::WindowsVersion >= QSysInfo::WV_XP && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based)) {
const QFontMetrics &fm = widget->fontMetrics();
if (fm.inFont(QChar(0x25CF)))
ret = 0x25CF;
else if (fm.inFont(QChar(0x2022)))
ret = 0x2022;
}
#endif
if (!ret)
ret = '*';
}
break;
#ifndef QT_NO_WIZARD
case SH_WizardStyle:
ret = QWizard::ModernStyle;
break;
#endif
case SH_ItemView_ArrowKeysNavigateIntoChildren:
ret = true;
break;
default:
ret = QCommonStyle::styleHint(hint, opt, widget, returnData);
break;
}
return ret;
}
/*! \reimp */
void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
const QWidget *w) const
{
// Used to restore across fallthrough cases. Currently only used in PE_IndicatorCheckBox
bool doRestore = false;
switch (pe) {
#ifndef QT_NO_TOOLBAR
case PE_IndicatorToolBarSeparator:
{
QRect rect = opt->rect;
const int margin = 2;
QPen oldPen = p->pen();
if(opt->state & State_Horizontal){
const int offset = rect.width()/2;
p->setPen(QPen(opt->palette.dark().color()));
p->drawLine(rect.bottomLeft().x() + offset,
rect.bottomLeft().y() - margin,
rect.topLeft().x() + offset,
rect.topLeft().y() + margin);
p->setPen(QPen(opt->palette.light().color()));
p->drawLine(rect.bottomLeft().x() + offset + 1,
rect.bottomLeft().y() - margin,
rect.topLeft().x() + offset + 1,
rect.topLeft().y() + margin);
}
else{ //Draw vertical separator
const int offset = rect.height()/2;
p->setPen(QPen(opt->palette.dark().color()));
p->drawLine(rect.topLeft().x() + margin ,
rect.topLeft().y() + offset,
rect.topRight().x() - margin,
rect.topRight().y() + offset);
p->setPen(QPen(opt->palette.light().color()));
p->drawLine(rect.topLeft().x() + margin ,
rect.topLeft().y() + offset + 1,
rect.topRight().x() - margin,
rect.topRight().y() + offset + 1);
}
p->setPen(oldPen);
}
break;
case PE_IndicatorToolBarHandle:
p->save();
p->translate(opt->rect.x(), opt->rect.y());
if (opt->state & State_Horizontal) {
int x = opt->rect.width() / 2 - 4;
if (opt->direction == Qt::RightToLeft)
x -= 2;
if (opt->rect.height() > 4) {
qDrawShadePanel(p, x, 2, 3, opt->rect.height() - 4,
opt->palette, false, 1, 0);
qDrawShadePanel(p, x + 3, 2, 3, opt->rect.height() - 4,
opt->palette, false, 1, 0);
}
} else {
if (opt->rect.width() > 4) {
int y = opt->rect.height() / 2 - 4;
qDrawShadePanel(p, 2, y, opt->rect.width() - 4, 3,
opt->palette, false, 1, 0);
qDrawShadePanel(p, 2, y + 3, opt->rect.width() - 4, 3,
opt->palette, false, 1, 0);
}
}
p->restore();
break;
#endif // QT_NO_TOOLBAR
case PE_FrameButtonTool:
case PE_PanelButtonTool: {
QPen oldPen = p->pen();
#ifndef QT_NO_DOCKWIDGET
if (w && w->inherits("QDockWidgetTitleButton")) {
if (const QWidget *dw = w->parentWidget())
if (dw->isWindow()){
qDrawWinButton(p, opt->rect.adjusted(1, 1, 0, 0), opt->palette, opt->state & (State_Sunken | State_On),
&opt->palette.button());
return;
}
}
#endif // QT_NO_DOCKWIDGET
QBrush fill;
bool stippled;
bool panel = (pe == PE_PanelButtonTool);
if ((!(opt->state & State_Sunken ))
&& (!(opt->state & State_Enabled)
|| !(opt->state & State_MouseOver && opt->state & State_AutoRaise))
&& (opt->state & State_On)) {
fill = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
stippled = true;
} else {
fill = opt->palette.brush(QPalette::Button);
stippled = false;
}
if (opt->state & (State_Raised | State_Sunken | State_On)) {
if (opt->state & State_AutoRaise) {
if(opt->state & (State_Enabled | State_Sunken | State_On)){
if (panel)
qDrawShadePanel(p, opt->rect, opt->palette,
opt->state & (State_Sunken | State_On), 1, &fill);
else
qDrawShadeRect(p, opt->rect, opt->palette,
opt->state & (State_Sunken | State_On), 1);
}
if (stippled) {
p->setPen(opt->palette.button().color());
p->drawRect(opt->rect.adjusted(1,1,-2,-2));
}
} else {
qDrawWinButton(p, opt->rect, opt->palette,
opt->state & (State_Sunken | State_On), panel ? &fill : 0);
}
} else {
p->fillRect(opt->rect, fill);
}
p->setPen(oldPen);
break; }
case PE_PanelButtonCommand:
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
QBrush fill;
State flags = opt->state;
QPalette pal = opt->palette;
QRect r = opt->rect;
if (! (flags & State_Sunken) && (flags & State_On))
fill = QBrush(pal.light().color(), Qt::Dense4Pattern);
else
fill = pal.brush(QPalette::Button);
if (btn->features & QStyleOptionButton::DefaultButton && flags & State_Sunken) {
p->setPen(pal.dark().color());
p->setBrush(fill);
p->drawRect(r.adjusted(0, 0, -1, -1));
} else if (flags & (State_Raised | State_Sunken | State_On | State_Sunken)) {
qDrawWinButton(p, r, pal, flags & (State_Sunken | State_On),
&fill);
} else {
p->fillRect(r, fill);
}
}
break;
case PE_FrameDefaultButton: {
QPen oldPen = p->pen();
p->setPen(opt->palette.shadow().color());
QRect rect = opt->rect;
rect.adjust(0, 0, -1, -1);
p->drawRect(rect);
p->setPen(oldPen);
break;
}
case PE_IndicatorArrowUp:
case PE_IndicatorArrowDown:
case PE_IndicatorArrowRight:
case PE_IndicatorArrowLeft:
{
if (opt->rect.width() <= 1 || opt->rect.height() <= 1)
break;
QRect r = opt->rect;
int size = qMin(r.height(), r.width());
QPixmap pixmap;
QString pixmapName = QStyleHelper::uniqueName(QLatin1String("$qt_ia-") + QLatin1String(metaObject()->className()), opt, QSize(size, size))
+ QLatin1Char('-') + QString::number(pe);
if (!QPixmapCache::find(pixmapName, pixmap)) {
int border = size/5;
int sqsize = 2*(size/2);
QImage image(sqsize, sqsize, QImage::Format_ARGB32);
image.fill(Qt::transparent);
QPainter imagePainter(&image);
QPolygon a;
switch (pe) {
case PE_IndicatorArrowUp:
a.setPoints(3, border, sqsize/2, sqsize/2, border, sqsize - border, sqsize/2);
break;
case PE_IndicatorArrowDown:
a.setPoints(3, border, sqsize/2, sqsize/2, sqsize - border, sqsize - border, sqsize/2);
break;
case PE_IndicatorArrowRight:
a.setPoints(3, sqsize - border, sqsize/2, sqsize/2, border, sqsize/2, sqsize - border);
break;
case PE_IndicatorArrowLeft:
a.setPoints(3, border, sqsize/2, sqsize/2, border, sqsize/2, sqsize - border);
break;
default:
break;
}
int bsx = 0;
int bsy = 0;
if (opt->state & State_Sunken) {
bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt, w);
bsy = proxy()->pixelMetric(PM_ButtonShiftVertical, opt, w);
}
QRect bounds = a.boundingRect();
int sx = sqsize / 2 - bounds.center().x() - 1;
int sy = sqsize / 2 - bounds.center().y() - 1;
imagePainter.translate(sx + bsx, sy + bsy);
imagePainter.setPen(opt->palette.buttonText().color());
imagePainter.setBrush(opt->palette.buttonText());
if (!(opt->state & State_Enabled)) {
imagePainter.translate(1, 1);
imagePainter.setBrush(opt->palette.light().color());
imagePainter.setPen(opt->palette.light().color());
imagePainter.drawPolygon(a);
imagePainter.translate(-1, -1);
imagePainter.setBrush(opt->palette.mid().color());
imagePainter.setPen(opt->palette.mid().color());
}
imagePainter.drawPolygon(a);
imagePainter.end();
pixmap = QPixmap::fromImage(image);
QPixmapCache::insert(pixmapName, pixmap);
}
int xOffset = r.x() + (r.width() - size)/2;
int yOffset = r.y() + (r.height() - size)/2;
p->drawPixmap(xOffset, yOffset, pixmap);
}
break;
case PE_IndicatorCheckBox: {
QBrush fill;
if (opt->state & State_NoChange)
fill = QBrush(opt->palette.base().color(), Qt::Dense4Pattern);
else if (opt->state & State_Sunken)
fill = opt->palette.button();
else if (opt->state & State_Enabled)
fill = opt->palette.base();
else
fill = opt->palette.background();
p->save();
doRestore = true;
qDrawWinPanel(p, opt->rect, opt->palette, true, &fill);
if (opt->state & State_NoChange)
p->setPen(opt->palette.dark().color());
else
p->setPen(opt->palette.text().color());
} // Fall through!
case PE_IndicatorViewItemCheck:
case PE_Q3CheckListIndicator:
if (!doRestore) {
p->save();
doRestore = true;
}
if (pe == PE_Q3CheckListIndicator || pe == PE_IndicatorViewItemCheck) {
const QStyleOptionViewItem *itemViewOpt = qstyleoption_cast<const QStyleOptionViewItem *>(opt);
p->setPen(itemViewOpt
&& itemViewOpt->showDecorationSelected
&& opt->state & State_Selected
? opt->palette.highlightedText().color()
: opt->palette.text().color());
if (opt->state & State_NoChange)
p->setBrush(opt->palette.brush(QPalette::Button));
p->drawRect(opt->rect.x() + 1, opt->rect.y() + 1, 11, 11);
}
if (!(opt->state & State_Off)) {
QLineF lines[7];
int i, xx, yy;
xx = opt->rect.x() + 3;
yy = opt->rect.y() + 5;
for (i = 0; i < 3; ++i) {
lines[i] = QLineF(xx, yy, xx, yy + 2);
++xx;
++yy;
}
yy -= 2;
for (i = 3; i < 7; ++i) {
lines[i] = QLineF(xx, yy, xx, yy + 2);
++xx;
--yy;
}
p->drawLines(lines, 7);
}
if (doRestore)
p->restore();
break;
case PE_FrameFocusRect:
if (const QStyleOptionFocusRect *fropt = qstyleoption_cast<const QStyleOptionFocusRect *>(opt)) {
//### check for d->alt_down
if (!(fropt->state & State_KeyboardFocusChange) && !proxy()->styleHint(SH_UnderlineShortcut, opt))
return;
QRect r = opt->rect;
p->save();
p->setBackgroundMode(Qt::TransparentMode);
QColor bg_col = fropt->backgroundColor;
if (!bg_col.isValid())
bg_col = p->background().color();
// Create an "XOR" color.
QColor patternCol((bg_col.red() ^ 0xff) & 0xff,
(bg_col.green() ^ 0xff) & 0xff,
(bg_col.blue() ^ 0xff) & 0xff);
p->setBrush(QBrush(patternCol, Qt::Dense4Pattern));
p->setBrushOrigin(r.topLeft());
p->setPen(Qt::NoPen);
p->drawRect(r.left(), r.top(), r.width(), 1); // Top
p->drawRect(r.left(), r.bottom(), r.width(), 1); // Bottom
p->drawRect(r.left(), r.top(), 1, r.height()); // Left
p->drawRect(r.right(), r.top(), 1, r.height()); // Right
p->restore();
}
break;
case PE_IndicatorRadioButton:
{
#define PTSARRLEN(x) sizeof(x)/(sizeof(QPoint))
static const QPoint pts1[] = { // dark lines
QPoint(1, 9), QPoint(1, 8), QPoint(0, 7), QPoint(0, 4), QPoint(1, 3), QPoint(1, 2),
QPoint(2, 1), QPoint(3, 1), QPoint(4, 0), QPoint(7, 0), QPoint(8, 1), QPoint(9, 1)
};
static const QPoint pts2[] = { // black lines
QPoint(2, 8), QPoint(1, 7), QPoint(1, 4), QPoint(2, 3), QPoint(2, 2), QPoint(3, 2),
QPoint(4, 1), QPoint(7, 1), QPoint(8, 2), QPoint(9, 2)
};
static const QPoint pts3[] = { // background lines
QPoint(2, 9), QPoint(3, 9), QPoint(4, 10), QPoint(7, 10), QPoint(8, 9), QPoint(9, 9),
QPoint(9, 8), QPoint(10, 7), QPoint(10, 4), QPoint(9, 3)
};
static const QPoint pts4[] = { // white lines
QPoint(2, 10), QPoint(3, 10), QPoint(4, 11), QPoint(7, 11), QPoint(8, 10),
QPoint(9, 10), QPoint(10, 9), QPoint(10, 8), QPoint(11, 7), QPoint(11, 4),
QPoint(10, 3), QPoint(10, 2)
};
static const QPoint pts5[] = { // inner fill
QPoint(4, 2), QPoint(7, 2), QPoint(9, 4), QPoint(9, 7), QPoint(7, 9), QPoint(4, 9),
QPoint(2, 7), QPoint(2, 4)
};
// make sure the indicator is square
QRect ir = opt->rect;
if (opt->rect.width() < opt->rect.height()) {
ir.setTop(opt->rect.top() + (opt->rect.height() - opt->rect.width()) / 2);
ir.setHeight(opt->rect.width());
} else if (opt->rect.height() < opt->rect.width()) {
ir.setLeft(opt->rect.left() + (opt->rect.width() - opt->rect.height()) / 2);
ir.setWidth(opt->rect.height());
}
p->save();
bool down = opt->state & State_Sunken;
bool enabled = opt->state & State_Enabled;
bool on = opt->state & State_On;
QPolygon a;
//center when rect is larger than indicator size
int xOffset = 0;
int yOffset = 0;
int indicatorWidth = proxy()->pixelMetric(PM_ExclusiveIndicatorWidth);
int indicatorHeight = proxy()->pixelMetric(PM_ExclusiveIndicatorWidth);
if (ir.width() > indicatorWidth)
xOffset += (ir.width() - indicatorWidth)/2;
if (ir.height() > indicatorHeight)
yOffset += (ir.height() - indicatorHeight)/2;
p->translate(xOffset, yOffset);
p->translate(ir.x(), ir.y());
p->setPen(opt->palette.dark().color());
p->drawPolyline(pts1, PTSARRLEN(pts1));
p->setPen(opt->palette.shadow().color());
p->drawPolyline(pts2, PTSARRLEN(pts2));
p->setPen(opt->palette.midlight().color());
p->drawPolyline(pts3, PTSARRLEN(pts3));
p->setPen(opt->palette.light().color());
p->drawPolyline(pts4, PTSARRLEN(pts4));
QColor fillColor = (down || !enabled)
? opt->palette.button().color()
: opt->palette.base().color();
p->setPen(fillColor);
p->setBrush(fillColor) ;
p->drawPolygon(pts5, PTSARRLEN(pts5));
p->translate(-ir.x(), -ir.y()); // restore translate
if (on) {
p->setPen(Qt::NoPen);
p->setBrush(opt->palette.text());
p->drawRect(ir.x() + 5, ir.y() + 4, 2, 4);
p->drawRect(ir.x() + 4, ir.y() + 5, 4, 2);
}
p->restore();
break;
}
#ifndef QT_NO_FRAME
case PE_Frame:
case PE_FrameMenu:
if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
if (frame->lineWidth == 2 || pe == PE_Frame) {
QPalette popupPal = frame->palette;
if (pe == PE_FrameMenu) {
popupPal.setColor(QPalette::Light, frame->palette.background().color());
popupPal.setColor(QPalette::Midlight, frame->palette.light().color());
}
if (pe == PE_Frame && (frame->state & State_Raised))
qDrawWinButton(p, frame->rect, popupPal, frame->state & State_Sunken);
else if (pe == PE_Frame && (frame->state & State_Sunken))
{
popupPal.setColor(QPalette::Midlight, frame->palette.background().color());
qDrawWinPanel(p, frame->rect, popupPal, frame->state & State_Sunken);
}
else
qDrawWinPanel(p, frame->rect, popupPal, frame->state & State_Sunken);
} else {
QCommonStyle::drawPrimitive(pe, opt, p, w);
}
} else {
QPalette popupPal = opt->palette;
popupPal.setColor(QPalette::Light, opt->palette.background().color());
popupPal.setColor(QPalette::Midlight, opt->palette.light().color());
qDrawWinPanel(p, opt->rect, popupPal, opt->state & State_Sunken);
}
break;
#endif // QT_NO_FRAME
case PE_IndicatorBranch: {
// This is _way_ too similar to the common style.
static const int decoration_size = 9;
int mid_h = opt->rect.x() + opt->rect.width() / 2;
int mid_v = opt->rect.y() + opt->rect.height() / 2;
int bef_h = mid_h;
int bef_v = mid_v;
int aft_h = mid_h;
int aft_v = mid_v;
if (opt->state & State_Children) {
int delta = decoration_size / 2;
bef_h -= delta;
bef_v -= delta;
aft_h += delta;
aft_v += delta;
p->drawLine(bef_h + 2, bef_v + 4, bef_h + 6, bef_v + 4);
if (!(opt->state & State_Open))
p->drawLine(bef_h + 4, bef_v + 2, bef_h + 4, bef_v + 6);
QPen oldPen = p->pen();
p->setPen(opt->palette.dark().color());
p->drawRect(bef_h, bef_v, decoration_size - 1, decoration_size - 1);
p->setPen(oldPen);
}
QBrush brush(opt->palette.dark().color(), Qt::Dense4Pattern);
if (opt->state & State_Item) {
if (opt->direction == Qt::RightToLeft)
p->fillRect(opt->rect.left(), mid_v, bef_h - opt->rect.left(), 1, brush);
else
p->fillRect(aft_h, mid_v, opt->rect.right() - aft_h + 1, 1, brush);
}
if (opt->state & State_Sibling)
p->fillRect(mid_h, aft_v, 1, opt->rect.bottom() - aft_v + 1, brush);
if (opt->state & (State_Open | State_Children | State_Item | State_Sibling))
p->fillRect(mid_h, opt->rect.y(), 1, bef_v - opt->rect.y(), brush);
break; }
case PE_FrameButtonBevel:
case PE_PanelButtonBevel: {
QBrush fill;
bool panel = pe != PE_FrameButtonBevel;
p->setBrushOrigin(opt->rect.topLeft());
if (!(opt->state & State_Sunken) && (opt->state & State_On))
fill = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
else
fill = opt->palette.brush(QPalette::Button);
if (opt->state & (State_Raised | State_On | State_Sunken)) {
qDrawWinButton(p, opt->rect, opt->palette, opt->state & (State_Sunken | State_On),
panel ? &fill : 0);
} else {
if (panel)
p->fillRect(opt->rect, fill);
else
p->drawRect(opt->rect);
}
break; }
case PE_FrameWindow: {
QPalette popupPal = opt->palette;
popupPal.setColor(QPalette::Light, opt->palette.background().color());
popupPal.setColor(QPalette::Midlight, opt->palette.light().color());
qDrawWinPanel(p, opt->rect, popupPal, opt->state & State_Sunken);
break; }
#ifndef QT_NO_DOCKWIDGET
case PE_IndicatorDockWidgetResizeHandle: {
QPen oldPen = p->pen();
p->setPen(opt->palette.light().color());
if (opt->state & State_Horizontal) {
p->drawLine(opt->rect.left(), opt->rect.top(),
opt->rect.right(), opt->rect.top());
p->setPen(opt->palette.dark().color());
p->drawLine(opt->rect.left(), opt->rect.bottom() - 1,
opt->rect.right(), opt->rect.bottom() - 1);
p->setPen(opt->palette.shadow().color());
p->drawLine(opt->rect.left(), opt->rect.bottom(),
opt->rect.right(), opt->rect.bottom());
} else {
p->drawLine(opt->rect.left(), opt->rect.top(),
opt->rect.left(), opt->rect.bottom());
p->setPen(opt->palette.dark().color());
p->drawLine(opt->rect.right() - 1, opt->rect.top(),
opt->rect.right() - 1, opt->rect.bottom());
p->setPen(opt->palette.shadow().color());
p->drawLine(opt->rect.right(), opt->rect.top(),
opt->rect.right(), opt->rect.bottom());
}
p->setPen(oldPen);
break; }
case PE_FrameDockWidget:
if (qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
proxy()->drawPrimitive(QStyle::PE_FrameWindow, opt, p, w);
}
break;
#endif // QT_NO_DOCKWIDGET
case PE_FrameStatusBarItem:
qDrawShadePanel(p, opt->rect, opt->palette, true, 1, 0);
break;
#ifndef QT_NO_PROGRESSBAR
case PE_IndicatorProgressChunk:
{
bool vertical = false, inverted = false;
if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) {
vertical = (pb2->orientation == Qt::Vertical);
inverted = pb2->invertedAppearance;
}
int space = 2;
int chunksize = proxy()->pixelMetric(PM_ProgressBarChunkWidth, opt, w) - space;
if (!vertical) {
if (opt->rect.width() <= chunksize)
space = 0;
if (inverted)
p->fillRect(opt->rect.x() + space, opt->rect.y(), opt->rect.width() - space, opt->rect.height(),
opt->palette.brush(QPalette::Highlight));
else
p->fillRect(opt->rect.x(), opt->rect.y(), opt->rect.width() - space, opt->rect.height(),
opt->palette.brush(QPalette::Highlight));
} else {
if (opt->rect.height() <= chunksize)
space = 0;
if (inverted)
p->fillRect(opt->rect.x(), opt->rect.y(), opt->rect.width(), opt->rect.height() - space,
opt->palette.brush(QPalette::Highlight));
else
p->fillRect(opt->rect.x(), opt->rect.y() + space, opt->rect.width(), opt->rect.height() - space,
opt->palette.brush(QPalette::Highlight));
}
}
break;
#endif // QT_NO_PROGRESSBAR
case PE_FrameTabWidget: {
QRect rect = opt->rect;
QPalette pal = opt->palette;
qDrawWinButton(p, opt->rect, opt->palette, false, 0);
break;
}
default:
QCommonStyle::drawPrimitive(pe, opt, p, w);
}
}
/*! \reimp */
void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter *p,
const QWidget *widget) const
{
switch (ce) {
#ifndef QT_NO_RUBBERBAND
case CE_RubberBand:
if (qstyleoption_cast<const QStyleOptionRubberBand *>(opt)) {
// ### workaround for slow general painter path
QPixmap tiledPixmap(16, 16);
QPainter pixmapPainter(&tiledPixmap);
pixmapPainter.setPen(Qt::NoPen);
pixmapPainter.setBrush(Qt::Dense4Pattern);
pixmapPainter.setBackground(Qt::white);
pixmapPainter.setBackgroundMode(Qt::OpaqueMode);
pixmapPainter.drawRect(0, 0, tiledPixmap.width(), tiledPixmap.height());
pixmapPainter.end();
tiledPixmap = QPixmap::fromImage(tiledPixmap.toImage());
p->save();
QRect r = opt->rect;
QStyleHintReturnMask mask;
if (proxy()->styleHint(QStyle::SH_RubberBand_Mask, opt, widget, &mask))
p->setClipRegion(mask.region);
p->drawTiledPixmap(r.x(), r.y(), r.width(), r.height(), tiledPixmap);
p->restore();
return;
}
break;
#endif // QT_NO_RUBBERBAND
#if !defined(QT_NO_MENU) && !defined(QT_NO_MAINWINDOW)
case CE_MenuBarEmptyArea:
if (widget && qobject_cast<const QMainWindow *>(widget->parentWidget())) {
p->fillRect(opt->rect, opt->palette.button());
QPen oldPen = p->pen();
p->setPen(QPen(opt->palette.dark().color()));
p->drawLine(opt->rect.bottomLeft(), opt->rect.bottomRight());
p->setPen(oldPen);
}
break;
#endif
#ifndef QT_NO_MENU
case CE_MenuItem:
if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
int x, y, w, h;
menuitem->rect.getRect(&x, &y, &w, &h);
int tab = menuitem->tabWidth;
bool dis = !(menuitem->state & State_Enabled);
bool checked = menuitem->checkType != QStyleOptionMenuItem::NotCheckable
? menuitem->checked : false;
bool act = menuitem->state & State_Selected;
// windows always has a check column, regardless whether we have an icon or not
int checkcol = qMax(menuitem->maxIconWidth, windowsCheckMarkWidth);
QBrush fill = menuitem->palette.brush(act ? QPalette::Highlight : QPalette::Button);
p->fillRect(menuitem->rect.adjusted(0, 0, -1, 0), fill);
if (menuitem->menuItemType == QStyleOptionMenuItem::Separator){
int yoff = y-1 + h / 2;
p->setPen(menuitem->palette.dark().color());
p->drawLine(x + 2, yoff, x + w - 4, yoff);
p->setPen(menuitem->palette.light().color());
p->drawLine(x + 2, yoff + 1, x + w - 4, yoff + 1);
return;
}
QRect vCheckRect = visualRect(opt->direction, menuitem->rect, QRect(menuitem->rect.x(), menuitem->rect.y(), checkcol, menuitem->rect.height()));
if (checked) {
if (act && !dis) {
qDrawShadePanel(p, vCheckRect,
menuitem->palette, true, 1,
&menuitem->palette.brush(QPalette::Button));
} else {
QBrush fill(menuitem->palette.light().color(), Qt::Dense4Pattern);
qDrawShadePanel(p, vCheckRect, menuitem->palette, true, 1, &fill);
}
} else if (!act) {
p->fillRect(vCheckRect, menuitem->palette.brush(QPalette::Button));
}
// On Windows Style, if we have a checkable item and an icon we
// draw the icon recessed to indicate an item is checked. If we
// have no icon, we draw a checkmark instead.
if (!menuitem->icon.isNull()) {
QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
if (act && !dis)
mode = QIcon::Active;
QPixmap pixmap;
if (checked)
pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, opt, widget), mode, QIcon::On);
else
pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, opt, widget), mode);
int pixw = pixmap.width();
int pixh = pixmap.height();
if (act && !dis && !checked)
qDrawShadePanel(p, vCheckRect, menuitem->palette, false, 1,
&menuitem->palette.brush(QPalette::Button));
QRect pmr(0, 0, pixw, pixh);
pmr.moveCenter(vCheckRect.center());
p->setPen(menuitem->palette.text().color());
p->drawPixmap(pmr.topLeft(), pixmap);
} else if (checked) {
QStyleOptionMenuItem newMi = *menuitem;
newMi.state = State_None;
if (!dis)
newMi.state |= State_Enabled;
if (act)
newMi.state |= State_On;
newMi.rect = visualRect(opt->direction, menuitem->rect, QRect(menuitem->rect.x() + windowsItemFrame, menuitem->rect.y() + windowsItemFrame,
checkcol - 2 * windowsItemFrame, menuitem->rect.height() - 2*windowsItemFrame));
proxy()->drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, p, widget);
}
p->setPen(act ? menuitem->palette.highlightedText().color() : menuitem->palette.buttonText().color());
QColor discol;
if (dis) {
discol = menuitem->palette.text().color();
p->setPen(discol);
}
int xm = windowsItemFrame + checkcol + windowsItemHMargin;
int xpos = menuitem->rect.x() + xm;
QRect textRect(xpos, y + windowsItemVMargin, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin);
QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect);
QString s = menuitem->text;
if (!s.isEmpty()) { // draw text
p->save();
int t = s.indexOf(QLatin1Char('\t'));
int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
if (!proxy()->styleHint(SH_UnderlineShortcut, menuitem, widget))
text_flags |= Qt::TextHideMnemonic;
text_flags |= Qt::AlignLeft;
if (t >= 0) {
QRect vShortcutRect = visualRect(opt->direction, menuitem->rect,
QRect(textRect.topRight(), QPoint(menuitem->rect.right(), textRect.bottom())));
if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, opt, widget)) {
p->setPen(menuitem->palette.light().color());
p->drawText(vShortcutRect.adjusted(1,1,1,1), text_flags, s.mid(t + 1));
p->setPen(discol);
}
p->drawText(vShortcutRect, text_flags, s.mid(t + 1));
s = s.left(t);
}
QFont font = menuitem->font;
if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem)
font.setBold(true);
p->setFont(font);
if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, opt, widget)) {
p->setPen(menuitem->palette.light().color());
p->drawText(vTextRect.adjusted(1,1,1,1), text_flags, s.left(t));
p->setPen(discol);
}
p->drawText(vTextRect, text_flags, s.left(t));
p->restore();
}
if (menuitem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow
int dim = (h - 2 * windowsItemFrame) / 2;
PrimitiveElement arrow;
arrow = (opt->direction == Qt::RightToLeft) ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight;
xpos = x + w - windowsArrowHMargin - windowsItemFrame - dim;
QRect vSubMenuRect = visualRect(opt->direction, menuitem->rect, QRect(xpos, y + h / 2 - dim / 2, dim, dim));
QStyleOptionMenuItem newMI = *menuitem;
newMI.rect = vSubMenuRect;
newMI.state = dis ? State_None : State_Enabled;
if (act)
newMI.palette.setColor(QPalette::ButtonText,
newMI.palette.highlightedText().color());
proxy()->drawPrimitive(arrow, &newMI, p, widget);
}
}
break;
#endif // QT_NO_MENU
#ifndef QT_NO_MENUBAR
case CE_MenuBarItem:
if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
bool active = mbi->state & State_Selected;
bool hasFocus = mbi->state & State_HasFocus;
bool down = mbi->state & State_Sunken;
QStyleOptionMenuItem newMbi = *mbi;
p->fillRect(mbi->rect, mbi->palette.brush(QPalette::Button));
if (active || hasFocus) {
QBrush b = mbi->palette.brush(QPalette::Button);
if (active && down)
p->setBrushOrigin(p->brushOrigin() + QPoint(1, 1));
if (active && hasFocus)
qDrawShadeRect(p, mbi->rect.x(), mbi->rect.y(), mbi->rect.width(),
mbi->rect.height(), mbi->palette, active && down, 1, 0, &b);
if (active && down) {
newMbi.rect.translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, mbi, widget),
proxy()->pixelMetric(PM_ButtonShiftVertical, mbi, widget));
p->setBrushOrigin(p->brushOrigin() - QPoint(1, 1));
}
}
QCommonStyle::drawControl(ce, &newMbi, p, widget);
}
break;
#endif // QT_NO_MENUBAR
#ifndef QT_NO_TABBAR
case CE_TabBarTabShape:
if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
bool rtlHorTabs = (tab->direction == Qt::RightToLeft
&& (tab->shape == QTabBar::RoundedNorth
|| tab->shape == QTabBar::RoundedSouth));
bool selected = tab->state & State_Selected;
bool lastTab = ((!rtlHorTabs && tab->position == QStyleOptionTab::End)
|| (rtlHorTabs
&& tab->position == QStyleOptionTab::Beginning));
bool firstTab = ((!rtlHorTabs
&& tab->position == QStyleOptionTab::Beginning)
|| (rtlHorTabs
&& tab->position == QStyleOptionTab::End));
bool onlyOne = tab->position == QStyleOptionTab::OnlyOneTab;
bool previousSelected =
((!rtlHorTabs
&& tab->selectedPosition == QStyleOptionTab::PreviousIsSelected)
|| (rtlHorTabs
&& tab->selectedPosition == QStyleOptionTab::NextIsSelected));
bool nextSelected =
((!rtlHorTabs
&& tab->selectedPosition == QStyleOptionTab::NextIsSelected)
|| (rtlHorTabs
&& tab->selectedPosition
== QStyleOptionTab::PreviousIsSelected));
int tabBarAlignment = proxy()->styleHint(SH_TabBar_Alignment, tab, widget);
bool leftAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignLeft)
|| (rtlHorTabs
&& tabBarAlignment == Qt::AlignRight);
bool rightAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignRight)
|| (rtlHorTabs
&& tabBarAlignment == Qt::AlignLeft);
QColor light = tab->palette.light().color();
QColor midlight = tab->palette.midlight().color();
QColor dark = tab->palette.dark().color();
QColor shadow = tab->palette.shadow().color();
QColor background = tab->palette.background().color();
int borderThinkness = proxy()->pixelMetric(PM_TabBarBaseOverlap, tab, widget);
if (selected)
borderThinkness /= 2;
QRect r2(opt->rect);
int x1 = r2.left();
int x2 = r2.right();
int y1 = r2.top();
int y2 = r2.bottom();
switch (tab->shape) {
default:
QCommonStyle::drawControl(ce, tab, p, widget);
break;
case QTabBar::RoundedNorth: {
if (!selected) {
y1 += 2;
x1 += onlyOne || firstTab ? borderThinkness : 0;
x2 -= onlyOne || lastTab ? borderThinkness : 0;
}
p->fillRect(QRect(x1 + 1, y1 + 1, (x2 - x1) - 1, (y2 - y1) - 2), tab->palette.background());
// Delete border
if (selected) {
p->fillRect(QRect(x1,y2-1,x2-x1,1), tab->palette.background());
p->fillRect(QRect(x1,y2,x2-x1,1), tab->palette.background());
}
// Left
if (firstTab || selected || onlyOne || !previousSelected) {
p->setPen(light);
p->drawLine(x1, y1 + 2, x1, y2 - ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness));
p->drawPoint(x1 + 1, y1 + 1);
}
// Top
{
int beg = x1 + (previousSelected ? 0 : 2);
int end = x2 - (nextSelected ? 0 : 2);
p->setPen(light);
p->drawLine(beg, y1, end, y1);
}
// Right
if (lastTab || selected || onlyOne || !nextSelected) {
p->setPen(shadow);
p->drawLine(x2, y1 + 2, x2, y2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
p->drawPoint(x2 - 1, y1 + 1);
p->setPen(dark);
p->drawLine(x2 - 1, y1 + 2, x2 - 1, y2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
}
break; }
case QTabBar::RoundedSouth: {
if (!selected) {
y2 -= 2;
x1 += firstTab ? borderThinkness : 0;
x2 -= lastTab ? borderThinkness : 0;
}
p->fillRect(QRect(x1 + 1, y1 + 2, (x2 - x1) - 1, (y2 - y1) - 1), tab->palette.background());
// Delete border
if (selected) {
p->fillRect(QRect(x1, y1 + 1, (x2 - 1)-x1, 1), tab->palette.background());
p->fillRect(QRect(x1, y1, (x2 - 1)-x1, 1), tab->palette.background());
}
// Left
if (firstTab || selected || onlyOne || !previousSelected) {
p->setPen(light);
p->drawLine(x1, y2 - 2, x1, y1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness));
p->drawPoint(x1 + 1, y2 - 1);
}
// Bottom
{
int beg = x1 + (previousSelected ? 0 : 2);
int end = x2 - (nextSelected ? 0 : 2);
p->setPen(shadow);
p->drawLine(beg, y2, end, y2);
p->setPen(dark);
p->drawLine(beg, y2 - 1, end, y2 - 1);
}
// Right
if (lastTab || selected || onlyOne || !nextSelected) {
p->setPen(shadow);
p->drawLine(x2, y2 - 2, x2, y1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
p->drawPoint(x2 - 1, y2 - 1);
p->setPen(dark);
p->drawLine(x2 - 1, y2 - 2, x2 - 1, y1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
}
break; }
case QTabBar::RoundedWest: {
if (!selected) {
x1 += 2;
y1 += firstTab ? borderThinkness : 0;
y2 -= lastTab ? borderThinkness : 0;
}
p->fillRect(QRect(x1 + 1, y1 + 1, (x2 - x1) - 2, (y2 - y1) - 1), tab->palette.background());
// Delete border
if (selected) {
p->fillRect(QRect(x2 - 1, y1, 1, y2-y1), tab->palette.background());
p->fillRect(QRect(x2, y1, 1, y2-y1), tab->palette.background());
}
// Top
if (firstTab || selected || onlyOne || !previousSelected) {
p->setPen(light);
p->drawLine(x1 + 2, y1, x2 - ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness), y1);
p->drawPoint(x1 + 1, y1 + 1);
}
// Left
{
int beg = y1 + (previousSelected ? 0 : 2);
int end = y2 - (nextSelected ? 0 : 2);
p->setPen(light);
p->drawLine(x1, beg, x1, end);
}
// Bottom
if (lastTab || selected || onlyOne || !nextSelected) {
p->setPen(shadow);
p->drawLine(x1 + 3, y2, x2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2);
p->drawPoint(x1 + 2, y2 - 1);
p->setPen(dark);
p->drawLine(x1 + 3, y2 - 1, x2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2 - 1);
p->drawPoint(x1 + 1, y2 - 1);
p->drawPoint(x1 + 2, y2);
}
break; }
case QTabBar::RoundedEast: {
if (!selected) {
x2 -= 2;
y1 += firstTab ? borderThinkness : 0;
y2 -= lastTab ? borderThinkness : 0;
}
p->fillRect(QRect(x1 + 2, y1 + 1, (x2 - x1) - 1, (y2 - y1) - 1), tab->palette.background());
// Delete border
if (selected) {
p->fillRect(QRect(x1 + 1, y1, 1, (y2 - 1)-y1),tab->palette.background());
p->fillRect(QRect(x1, y1, 1, (y2-1)-y1), tab->palette.background());
}
// Top
if (firstTab || selected || onlyOne || !previousSelected) {
p->setPen(light);
p->drawLine(x2 - 2, y1, x1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness), y1);
p->drawPoint(x2 - 1, y1 + 1);
}
// Right
{
int beg = y1 + (previousSelected ? 0 : 2);
int end = y2 - (nextSelected ? 0 : 2);
p->setPen(shadow);
p->drawLine(x2, beg, x2, end);
p->setPen(dark);
p->drawLine(x2 - 1, beg, x2 - 1, end);
}
// Bottom
if (lastTab || selected || onlyOne || !nextSelected) {
p->setPen(shadow);
p->drawLine(x2 - 2, y2, x1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2);
p->drawPoint(x2 - 1, y2 - 1);
p->setPen(dark);
p->drawLine(x2 - 2, y2 - 1, x1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2 - 1);
}
break; }
}
}
break;
#endif // QT_NO_TABBAR
case CE_ToolBoxTabShape:
qDrawShadePanel(p, opt->rect, opt->palette,
opt->state & (State_Sunken | State_On), 1,
&opt->palette.brush(QPalette::Button));
break;
#ifndef QT_NO_SPLITTER
case CE_Splitter:
p->eraseRect(opt->rect);
break;
#endif // QT_NO_SPLITTER
#ifndef QT_NO_SCROLLBAR
case CE_ScrollBarSubLine:
case CE_ScrollBarAddLine: {
if ((opt->state & State_Sunken)) {
p->setPen(opt->palette.dark().color());
p->setBrush(opt->palette.brush(QPalette::Button));
p->drawRect(opt->rect.adjusted(0, 0, -1, -1));
} else {
QStyleOption buttonOpt = *opt;
if (!(buttonOpt.state & State_Sunken))
buttonOpt.state |= State_Raised;
QPalette pal(opt->palette);
pal.setColor(QPalette::Button, opt->palette.light().color());
pal.setColor(QPalette::Light, opt->palette.button().color());
qDrawWinButton(p, opt->rect, pal, opt->state & (State_Sunken | State_On),
&opt->palette.brush(QPalette::Button));
}
PrimitiveElement arrow;
if (opt->state & State_Horizontal) {
if (ce == CE_ScrollBarAddLine)
arrow = opt->direction == Qt::LeftToRight ? PE_IndicatorArrowRight : PE_IndicatorArrowLeft;
else
arrow = opt->direction == Qt::LeftToRight ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight;
} else {
if (ce == CE_ScrollBarAddLine)
arrow = PE_IndicatorArrowDown;
else
arrow = PE_IndicatorArrowUp;
}
QStyleOption arrowOpt = *opt;
arrowOpt.rect = opt->rect.adjusted(4, 4, -4, -4);
proxy()->drawPrimitive(arrow, &arrowOpt, p, widget);
break; }
case CE_ScrollBarAddPage:
case CE_ScrollBarSubPage: {
QBrush br;
QBrush bg = p->background();
Qt::BGMode bg_mode = p->backgroundMode();
p->setPen(Qt::NoPen);
p->setBackgroundMode(Qt::OpaqueMode);
if (opt->state & State_Sunken) {
br = QBrush(opt->palette.shadow().color(), Qt::Dense4Pattern);
p->setBackground(opt->palette.dark().color());
p->setBrush(br);
} else {
QPixmap pm = opt->palette.brush(QPalette::Light).texture();
br = !pm.isNull() ? QBrush(pm) : QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
p->setBackground(opt->palette.background().color());
p->setBrush(br);
}
p->drawRect(opt->rect);
p->setBackground(bg);
p->setBackgroundMode(bg_mode);
break; }
case CE_ScrollBarSlider:
if (!(opt->state & State_Enabled)) {
QPixmap pm = opt->palette.brush(QPalette::Light).texture();
QBrush br = !pm.isNull() ? QBrush(pm) : QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
p->setPen(Qt::NoPen);
p->setBrush(br);
p->setBackgroundMode(Qt::OpaqueMode);
p->drawRect(opt->rect);
} else {
QStyleOptionButton buttonOpt;
buttonOpt.QStyleOption::operator=(*opt);
buttonOpt.state = State_Enabled | State_Raised;
QPalette pal(opt->palette);
pal.setColor(QPalette::Button, opt->palette.light().color());
pal.setColor(QPalette::Light, opt->palette.button().color());
qDrawWinButton(p, opt->rect, pal, false, &opt->palette.brush(QPalette::Button));
}
break;
#endif // QT_NO_SCROLLBAR
case CE_HeaderSection: {
QBrush fill;
if (opt->state & State_On)
fill = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
else
fill = opt->palette.brush(QPalette::Button);
if (opt->state & (State_Raised | State_Sunken)) {
qDrawWinButton(p, opt->rect, opt->palette, opt->state & State_Sunken, &fill);
} else {
p->fillRect(opt->rect, fill);
}
break; }
#ifndef QT_NO_TOOLBAR
case CE_ToolBar:
if (const QStyleOptionToolBar *toolbar = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) {
QRect rect = opt->rect;
bool paintLeftBorder = true;
bool paintRightBorder = true;
bool paintBottomBorder = true;
switch (toolbar->toolBarArea){
case Qt::BottomToolBarArea :
switch(toolbar->positionOfLine){
case QStyleOptionToolBar::Beginning:
case QStyleOptionToolBar::OnlyOne:
paintBottomBorder = false;
default:
break;
}
case Qt::TopToolBarArea :
switch(toolbar->positionWithinLine){
case QStyleOptionToolBar::Beginning:
paintLeftBorder = false;
break;
case QStyleOptionToolBar::End:
paintRightBorder = false;
break;
case QStyleOptionToolBar::OnlyOne:
paintRightBorder = false;
paintLeftBorder = false;
default:
break;
}
if(opt->direction == Qt::RightToLeft){ //reverse layout changes the order of Beginning/end
bool tmp = paintLeftBorder;
paintRightBorder=paintLeftBorder;
paintLeftBorder=tmp;
}
break;
case Qt::RightToolBarArea :
switch (toolbar->positionOfLine){
case QStyleOptionToolBar::Beginning:
case QStyleOptionToolBar::OnlyOne:
paintRightBorder = false;
break;
default:
break;
}
break;
case Qt::LeftToolBarArea :
switch (toolbar->positionOfLine){
case QStyleOptionToolBar::Beginning:
case QStyleOptionToolBar::OnlyOne:
paintLeftBorder = false;
break;
default:
break;
}
break;
default:
break;
}
//draw top border
p->setPen(QPen(opt->palette.light().color()));
p->drawLine(rect.topLeft().x(),
rect.topLeft().y(),
rect.topRight().x(),
rect.topRight().y());
if (paintLeftBorder){
p->setPen(QPen(opt->palette.light().color()));
p->drawLine(rect.topLeft().x(),
rect.topLeft().y(),
rect.bottomLeft().x(),
rect.bottomLeft().y());
}
if (paintRightBorder){
p->setPen(QPen(opt->palette.dark().color()));
p->drawLine(rect.topRight().x(),
rect.topRight().y(),
rect.bottomRight().x(),
rect.bottomRight().y());
}
if (paintBottomBorder){
p->setPen(QPen(opt->palette.dark().color()));
p->drawLine(rect.bottomLeft().x(),
rect.bottomLeft().y(),
rect.bottomRight().x(),
rect.bottomRight().y());
}
}
break;
#endif // QT_NO_TOOLBAR
#ifndef QT_NO_PROGRESSBAR
case CE_ProgressBarContents:
if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
QRect rect = pb->rect;
bool vertical = false;
bool inverted = false;
// Get extra style options if version 2
const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt);
if (pb2) {
vertical = (pb2->orientation == Qt::Vertical);
inverted = pb2->invertedAppearance;
}
QMatrix m;
if (vertical) {
rect = QRect(rect.y(), rect.x(), rect.height(), rect.width()); // flip width and height
m.rotate(90);
m.translate(0, -(rect.height() + rect.y()*2));
}
QPalette pal2 = pb->palette;
// Correct the highlight color if it is the same as the background
if (pal2.highlight() == pal2.background())
pal2.setColor(QPalette::Highlight, pb->palette.color(QPalette::Active,
QPalette::Highlight));
bool reverse = ((!vertical && (pb->direction == Qt::RightToLeft)) || vertical);
if (inverted)
reverse = !reverse;
int w = rect.width();
if (pb->minimum == 0 && pb->maximum == 0) {
Q_D(const QWindowsStyle);
const int unit_width = proxy()->pixelMetric(PM_ProgressBarChunkWidth, pb, widget);
QStyleOptionProgressBarV2 pbBits = *pb;
Q_ASSERT(unit_width >0);
pbBits.rect = rect;
pbBits.palette = pal2;
int chunkCount = w / unit_width + 1;
int step = d->animateStep%chunkCount;
int chunksInRow = 5;
int myY = pbBits.rect.y();
int myHeight = pbBits.rect.height();
int chunksToDraw = chunksInRow;
if(step > chunkCount - 5)chunksToDraw = (chunkCount - step);
p->save();
p->setClipRect(m.mapRect(QRectF(rect)).toRect());
int x0 = reverse ? rect.left() + rect.width() - unit_width*(step) - unit_width : rect.left() + unit_width * step;
int x = 0;
for (int i = 0; i < chunksToDraw ; ++i) {
pbBits.rect.setRect(x0 + x, myY, unit_width, myHeight);
pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect();
proxy()->drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p, widget);
x += reverse ? -unit_width : unit_width;
}
//Draw wrap-around chunks
if( step > chunkCount-5){
x0 = reverse ? rect.left() + rect.width() - unit_width : rect.left() ;
x = 0;
int chunksToDraw = step - (chunkCount - chunksInRow);
for (int i = 0; i < chunksToDraw ; ++i) {
pbBits.rect.setRect(x0 + x, myY, unit_width, myHeight);
pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect();
proxy()->drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p, widget);
x += reverse ? -unit_width : unit_width;
}
}
p->restore(); //restore state
}
else {
QCommonStyle::drawControl(ce, opt, p, widget);
}
}
break;
#endif // QT_NO_PROGRESSBAR
#ifndef QT_NO_DOCKWIDGET
case CE_DockWidgetTitle:
if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(opt)) {
Q_D(const QWindowsStyle);
const QStyleOptionDockWidgetV2 *v2
= qstyleoption_cast<const QStyleOptionDockWidgetV2*>(opt);
bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
QRect rect = dwOpt->rect;
QRect r = rect;
if (verticalTitleBar) {
QSize s = r.size();
s.transpose();
r.setSize(s);
p->save();
p->translate(r.left(), r.top() + r.width());
p->rotate(-90);
p->translate(-r.left(), -r.top());
}
bool floating = false;
bool active = dwOpt->state & State_Active;
QColor inactiveCaptionTextColor = d->inactiveCaptionText;
if (dwOpt->movable) {
QColor left, right;
//Titlebar gradient
if (widget && widget->isWindow()) {
floating = true;
if (active) {
left = d->activeCaptionColor;
right = d->activeGradientCaptionColor;
} else {
left = d->inactiveCaptionColor;
right = d->inactiveGradientCaptionColor;
}
QBrush fillBrush(left);
if (left != right) {
QPoint p1(r.x(), r.top() + r.height()/2);
QPoint p2(rect.right(), r.top() + r.height()/2);
QLinearGradient lg(p1, p2);
lg.setColorAt(0, left);
lg.setColorAt(1, right);
fillBrush = lg;
}
p->fillRect(r.adjusted(0, 0, 0, -3), fillBrush);
}
p->setPen(dwOpt->palette.color(QPalette::Light));
if (!widget || !widget->isWindow()) {
p->drawLine(r.topLeft(), r.topRight());
p->setPen(dwOpt->palette.color(QPalette::Dark));
p->drawLine(r.bottomLeft(), r.bottomRight()); }
}
if (!dwOpt->title.isEmpty()) {
QFont oldFont = p->font();
if (floating) {
QFont font = oldFont;
font.setBold(true);
p->setFont(font);
}
QPalette palette = dwOpt->palette;
palette.setColor(QPalette::Window, inactiveCaptionTextColor);
QRect titleRect = subElementRect(SE_DockWidgetTitleBarText, opt, widget);
if (verticalTitleBar) {
titleRect = QRect(r.left() + rect.bottom()
- titleRect.bottom(),
r.top() + titleRect.left() - rect.left(),
titleRect.height(), titleRect.width());
}
proxy()->drawItemText(p, titleRect,
Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic, palette,
dwOpt->state & State_Enabled, dwOpt->title,
floating ? (active ? QPalette::BrightText : QPalette::Window) : QPalette::WindowText);
p->setFont(oldFont);
}
if (verticalTitleBar)
p->restore();
}
return;
#endif // QT_NO_DOCKWIDGET
default:
QCommonStyle::drawControl(ce, opt, p, widget);
}
}
/*! \reimp */
QRect QWindowsStyle::subElementRect(SubElement sr, const QStyleOption *opt, const QWidget *w) const
{
QRect r;
switch (sr) {
case SE_SliderFocusRect:
case SE_ToolBoxTabContents:
r = visualRect(opt->direction, opt->rect, opt->rect);
break;
case SE_DockWidgetTitleBarText: {
r = QCommonStyle::subElementRect(sr, opt, w);
const QStyleOptionDockWidgetV2 *v2
= qstyleoption_cast<const QStyleOptionDockWidgetV2*>(opt);
bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
int m = proxy()->pixelMetric(PM_DockWidgetTitleMargin, opt, w);
if (verticalTitleBar) {
r.adjust(0, 0, 0, -m);
} else {
if (opt->direction == Qt::LeftToRight)
r.adjust(m, 0, 0, 0);
else
r.adjust(0, 0, -m, 0);
}
break;
}
case SE_ProgressBarContents:
r = QCommonStyle::subElementRect(SE_ProgressBarGroove, opt, w);
r.adjust(3, 3, -3, -3);
break;
default:
r = QCommonStyle::subElementRect(sr, opt, w);
}
return r;
}
#ifdef QT3_SUPPORT
Q_GLOBAL_STATIC_WITH_ARGS(QBitmap, globalVerticalLine, (1, 129))
Q_GLOBAL_STATIC_WITH_ARGS(QBitmap, globalHorizontalLine, (128, 1))
#endif
/*! \reimp */
void QWindowsStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
QPainter *p, const QWidget *widget) const
{
switch (cc) {
#ifndef QT_NO_SLIDER
case CC_Slider:
if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider, widget);
int len = proxy()->pixelMetric(PM_SliderLength, slider, widget);
int ticks = slider->tickPosition;
QRect groove = proxy()->subControlRect(CC_Slider, slider, SC_SliderGroove, widget);
QRect handle = proxy()->subControlRect(CC_Slider, slider, SC_SliderHandle, widget);
if ((slider->subControls & SC_SliderGroove) && groove.isValid()) {
int mid = thickness / 2;
if (ticks & QSlider::TicksAbove)
mid += len / 8;
if (ticks & QSlider::TicksBelow)
mid -= len / 8;
p->setPen(slider->palette.shadow().color());
if (slider->orientation == Qt::Horizontal) {
qDrawWinPanel(p, groove.x(), groove.y() + mid - 2,
groove.width(), 4, slider->palette, true);
p->drawLine(groove.x() + 1, groove.y() + mid - 1,
groove.x() + groove.width() - 3, groove.y() + mid - 1);
} else {
qDrawWinPanel(p, groove.x() + mid - 2, groove.y(),
4, groove.height(), slider->palette, true);
p->drawLine(groove.x() + mid - 1, groove.y() + 1,
groove.x() + mid - 1, groove.y() + groove.height() - 3);
}
}
if (slider->subControls & SC_SliderTickmarks) {
QStyleOptionSlider tmpSlider = *slider;
tmpSlider.subControls = SC_SliderTickmarks;
QCommonStyle::drawComplexControl(cc, &tmpSlider, p, widget);
}
if (slider->subControls & SC_SliderHandle) {
// 4444440
// 4333310
// 4322210
// 4322210
// 4322210
// 4322210
// *43210*
// **410**
// ***0***
const QColor c0 = slider->palette.shadow().color();
const QColor c1 = slider->palette.dark().color();
// const QColor c2 = g.button();
const QColor c3 = slider->palette.midlight().color();
const QColor c4 = slider->palette.light().color();
QBrush handleBrush;
if (slider->state & State_Enabled) {
handleBrush = slider->palette.color(QPalette::Button);
} else {
handleBrush = QBrush(slider->palette.color(QPalette::Button),
Qt::Dense4Pattern);
}
int x = handle.x(), y = handle.y(),
wi = handle.width(), he = handle.height();
int x1 = x;
int x2 = x+wi-1;
int y1 = y;
int y2 = y+he-1;
Qt::Orientation orient = slider->orientation;
bool tickAbove = slider->tickPosition == QSlider::TicksAbove;
bool tickBelow = slider->tickPosition == QSlider::TicksBelow;
if (slider->state & State_HasFocus) {
QStyleOptionFocusRect fropt;
fropt.QStyleOption::operator=(*slider);
fropt.rect = subElementRect(SE_SliderFocusRect, slider, widget);
proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);
}
if ((tickAbove && tickBelow) || (!tickAbove && !tickBelow)) {
Qt::BGMode oldMode = p->backgroundMode();
p->setBackgroundMode(Qt::OpaqueMode);
qDrawWinButton(p, QRect(x, y, wi, he), slider->palette, false,
&handleBrush);
p->setBackgroundMode(oldMode);
return;
}
QSliderDirection dir;
if (orient == Qt::Horizontal)
if (tickAbove)
dir = SlUp;
else
dir = SlDown;
else
if (tickAbove)
dir = SlLeft;
else
dir = SlRight;
QPolygon a;
int d = 0;
switch (dir) {
case SlUp:
y1 = y1 + wi/2;
d = (wi + 1) / 2 - 1;
a.setPoints(5, x1,y1, x1,y2, x2,y2, x2,y1, x1+d,y1-d);
break;
case SlDown:
y2 = y2 - wi/2;
d = (wi + 1) / 2 - 1;
a.setPoints(5, x1,y1, x1,y2, x1+d,y2+d, x2,y2, x2,y1);
break;
case SlLeft:
d = (he + 1) / 2 - 1;
x1 = x1 + he/2;
a.setPoints(5, x1,y1, x1-d,y1+d, x1,y2, x2,y2, x2,y1);
break;
case SlRight:
d = (he + 1) / 2 - 1;
x2 = x2 - he/2;
a.setPoints(5, x1,y1, x1,y2, x2,y2, x2+d,y1+d, x2,y1);
break;
}
QBrush oldBrush = p->brush();
p->setPen(Qt::NoPen);
p->setBrush(handleBrush);
Qt::BGMode oldMode = p->backgroundMode();
p->setBackgroundMode(Qt::OpaqueMode);
p->drawRect(x1, y1, x2-x1+1, y2-y1+1);
p->drawPolygon(a);
p->setBrush(oldBrush);
p->setBackgroundMode(oldMode);
if (dir != SlUp) {
p->setPen(c4);
p->drawLine(x1, y1, x2, y1);
p->setPen(c3);
p->drawLine(x1, y1+1, x2, y1+1);
}
if (dir != SlLeft) {
p->setPen(c3);
p->drawLine(x1+1, y1+1, x1+1, y2);
p->setPen(c4);
p->drawLine(x1, y1, x1, y2);
}
if (dir != SlRight) {
p->setPen(c0);
p->drawLine(x2, y1, x2, y2);
p->setPen(c1);
p->drawLine(x2-1, y1+1, x2-1, y2-1);
}
if (dir != SlDown) {
p->setPen(c0);
p->drawLine(x1, y2, x2, y2);
p->setPen(c1);
p->drawLine(x1+1, y2-1, x2-1, y2-1);
}
switch (dir) {
case SlUp:
p->setPen(c4);
p->drawLine(x1, y1, x1+d, y1-d);
p->setPen(c0);
d = wi - d - 1;
p->drawLine(x2, y1, x2-d, y1-d);
d--;
p->setPen(c3);
p->drawLine(x1+1, y1, x1+1+d, y1-d);
p->setPen(c1);
p->drawLine(x2-1, y1, x2-1-d, y1-d);
break;
case SlDown:
p->setPen(c4);
p->drawLine(x1, y2, x1+d, y2+d);
p->setPen(c0);
d = wi - d - 1;
p->drawLine(x2, y2, x2-d, y2+d);
d--;
p->setPen(c3);
p->drawLine(x1+1, y2, x1+1+d, y2+d);
p->setPen(c1);
p->drawLine(x2-1, y2, x2-1-d, y2+d);
break;
case SlLeft:
p->setPen(c4);
p->drawLine(x1, y1, x1-d, y1+d);
p->setPen(c0);
d = he - d - 1;
p->drawLine(x1, y2, x1-d, y2-d);
d--;
p->setPen(c3);
p->drawLine(x1, y1+1, x1-d, y1+1+d);
p->setPen(c1);
p->drawLine(x1, y2-1, x1-d, y2-1-d);
break;
case SlRight:
p->setPen(c4);
p->drawLine(x2, y1, x2+d, y1+d);
p->setPen(c0);
d = he - d - 1;
p->drawLine(x2, y2, x2+d, y2-d);
d--;
p->setPen(c3);
p->drawLine(x2, y1+1, x2+d, y1+1+d);
p->setPen(c1);
p->drawLine(x2, y2-1, x2+d, y2-1-d);
break;
}
}
}
break;
#endif // QT_NO_SLIDER
#ifndef QT_NO_SCROLLBAR
case CC_ScrollBar:
if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
QStyleOptionSlider newScrollbar = *scrollbar;
if (scrollbar->minimum == scrollbar->maximum)
newScrollbar.state &= ~State_Enabled; //do not draw the slider.
QCommonStyle::drawComplexControl(cc, &newScrollbar, p, widget);
}
break;
#endif // QT_NO_SCROLLBAR
#ifdef QT3_SUPPORT
case CC_Q3ListView:
if (const QStyleOptionQ3ListView *lv = qstyleoption_cast<const QStyleOptionQ3ListView *>(opt)) {
int i;
if (lv->subControls & SC_Q3ListView)
QCommonStyle::drawComplexControl(cc, lv, p, widget);
if (lv->subControls & (SC_Q3ListViewBranch | SC_Q3ListViewExpand)) {
if (lv->items.isEmpty())
break;
QStyleOptionQ3ListViewItem item = lv->items.at(0);
int y = lv->rect.y();
int c;
int dotoffset = 0;
QPolygon dotlines;
if ((lv->activeSubControls & SC_All) && (lv->subControls & SC_Q3ListViewExpand)) {
c = 2;
dotlines.resize(2);
dotlines[0] = QPoint(lv->rect.right(), lv->rect.top());
dotlines[1] = QPoint(lv->rect.right(), lv->rect.bottom());
} else {
int linetop = 0, linebot = 0;
// each branch needs at most two lines, ie. four end points
dotoffset = (item.itemY + item.height - y) % 2;
dotlines.resize(item.childCount * 4);
c = 0;
// skip the stuff above the exposed rectangle
for (i = 1; i < lv->items.size(); ++i) {
QStyleOptionQ3ListViewItem child = lv->items.at(i);
if (child.height + y > 0)
break;
y += child.totalHeight;
}
int bx = lv->rect.width() / 2;
// paint stuff in the magical area
while (i < lv->items.size() && y < lv->rect.height()) {
QStyleOptionQ3ListViewItem child = lv->items.at(i);
if (child.features & QStyleOptionQ3ListViewItem::Visible) {
int lh;
if (!(item.features & QStyleOptionQ3ListViewItem::MultiLine))
lh = child.height;
else
lh = p->fontMetrics().height() + 2 * lv->itemMargin;
lh = qMax(lh, QApplication::globalStrut().height());
if (lh % 2 > 0)
++lh;
linebot = y + lh / 2;
if (child.features & QStyleOptionQ3ListViewItem::Expandable
|| (child.childCount > 0 && child.height > 0)) {
// needs a box
p->setPen(lv->palette.mid().color());
p->drawRect(bx - 4, linebot - 4, 8, 8);
// plus or minus
p->setPen(lv->palette.text().color());
p->drawLine(bx - 2, linebot, bx + 2, linebot);
if (!(child.state & State_Open))
p->drawLine(bx, linebot - 2, bx, linebot + 2);
// dotlinery
p->setPen(lv->palette.mid().color());
dotlines[c++] = QPoint(bx, linetop);
dotlines[c++] = QPoint(bx, linebot - 4);
dotlines[c++] = QPoint(bx + 5, linebot);
dotlines[c++] = QPoint(lv->rect.width(), linebot);
linetop = linebot + 5;
} else {
// just dotlinery
dotlines[c++] = QPoint(bx+1, linebot -1);
dotlines[c++] = QPoint(lv->rect.width(), linebot -1);
}
y += child.totalHeight;
}
++i;
}
// Expand line height to edge of rectangle if there's any
// visible child below
while (i < lv->items.size() && lv->items.at(i).height <= 0)
++i;
if (i < lv->items.size())
linebot = lv->rect.height();
if (linetop < linebot) {
dotlines[c++] = QPoint(bx, linetop);
dotlines[c++] = QPoint(bx, linebot);
}
}
p->setPen(lv->palette.text().color());
QBitmap *verticalLine = globalVerticalLine();
QBitmap *horizontalLine = globalHorizontalLine();
static bool isInit = false;
if (!isInit) {
isInit = true;
// make 128*1 and 1*128 bitmaps that can be used for
// drawing the right sort of lines.
verticalLine->clear();
horizontalLine->clear();
QPolygon a(64);
QPainter p;
p.begin(verticalLine);
for(i = 0; i < 64; ++i)
a.setPoint(i, 0, i * 2 + 1);
p.setPen(Qt::color1);
p.drawPoints(a);
p.end();
QApplication::flush();
verticalLine->setMask(*verticalLine);
p.begin(horizontalLine);
for(i = 0; i < 64; ++i)
a.setPoint(i, i * 2 + 1, 0);
p.setPen(Qt::color1);
p.drawPoints(a);
p.end();
QApplication::flush();
horizontalLine->setMask(*horizontalLine);
}
int line; // index into dotlines
if (lv->subControls & SC_Q3ListViewBranch) for(line = 0; line < c; line += 2) {
// assumptions here: lines are horizontal or vertical.
// lines always start with the numerically lowest
// coordinate.
// point ... relevant coordinate of current point
// end ..... same coordinate of the end of the current line
// other ... the other coordinate of the current point/line
if (dotlines[line].y() == dotlines[line+1].y()) {
int end = dotlines[line + 1].x();
int point = dotlines[line].x();
int other = dotlines[line].y();
while (point < end) {
int i = 128;
if (i + point > end)
i = end-point;
p->drawPixmap(point, other, *horizontalLine, 0, 0, i, 1);
point += i;
}
} else {
int end = dotlines[line + 1].y();
int point = dotlines[line].y();
int other = dotlines[line].x();
int pixmapoffset = ((point & 1) != dotoffset) ? 1 : 0;
while(point < end) {
int i = 128;
if (i + point > end)
i = end-point;
p->drawPixmap(other, point, *verticalLine, 0, pixmapoffset, 1, i);
point += i;
}
}
}
}
}
break;
#endif // QT3_SUPPORT
#ifndef QT_NO_COMBOBOX
case CC_ComboBox:
if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
QBrush editBrush = cmb->palette.brush(QPalette::Base);
if ((cmb->subControls & SC_ComboBoxFrame)) {
if (cmb->frame) {
QPalette shadePal = opt->palette;
shadePal.setColor(QPalette::Midlight, shadePal.button().color());
qDrawWinPanel(p, opt->rect, shadePal, true, &editBrush);
}
else {
p->fillRect(opt->rect, editBrush);
}
}
if (cmb->subControls & SC_ComboBoxArrow) {
State flags = State_None;
QRect ar = proxy()->subControlRect(CC_ComboBox, cmb, SC_ComboBoxArrow, widget);
bool sunkenArrow = cmb->activeSubControls == SC_ComboBoxArrow
&& cmb->state & State_Sunken;
if (sunkenArrow) {
p->setPen(cmb->palette.dark().color());
p->setBrush(cmb->palette.brush(QPalette::Button));
p->drawRect(ar.adjusted(0,0,-1,-1));
} else {
// Make qDrawWinButton use the right colors for drawing the shade of the button
QPalette pal(cmb->palette);
pal.setColor(QPalette::Button, cmb->palette.light().color());
pal.setColor(QPalette::Light, cmb->palette.button().color());
qDrawWinButton(p, ar, pal, false,
&cmb->palette.brush(QPalette::Button));
}
ar.adjust(2, 2, -2, -2);
if (opt->state & State_Enabled)
flags |= State_Enabled;
if (sunkenArrow)
flags |= State_Sunken;
QStyleOption arrowOpt(0);
arrowOpt.rect = ar.adjusted(1, 1, -1, -1);
arrowOpt.palette = cmb->palette;
arrowOpt.state = flags;
proxy()->drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, p, widget);
}
if (cmb->subControls & SC_ComboBoxEditField) {
QRect re = proxy()->subControlRect(CC_ComboBox, cmb, SC_ComboBoxEditField, widget);
if (cmb->state & State_HasFocus && !cmb->editable)
p->fillRect(re.x(), re.y(), re.width(), re.height(),
cmb->palette.brush(QPalette::Highlight));
if (cmb->state & State_HasFocus) {
p->setPen(cmb->palette.highlightedText().color());
p->setBackground(cmb->palette.highlight());
} else {
p->setPen(cmb->palette.text().color());
p->setBackground(cmb->palette.background());
}
if (cmb->state & State_HasFocus && !cmb->editable) {
QStyleOptionFocusRect focus;
focus.QStyleOption::operator=(*cmb);
focus.rect = subElementRect(SE_ComboBoxFocusRect, cmb, widget);
focus.state |= State_FocusAtBorder;
focus.backgroundColor = cmb->palette.highlight().color();
proxy()->drawPrimitive(PE_FrameFocusRect, &focus, p, widget);
}
}
}
break;
#endif // QT_NO_COMBOBOX
#ifndef QT_NO_SPINBOX
case CC_SpinBox:
if (const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
QStyleOptionSpinBox copy = *sb;
PrimitiveElement pe;
bool enabled = opt->state & State_Enabled;
if (sb->frame && (sb->subControls & SC_SpinBoxFrame)) {
QBrush editBrush = sb->palette.brush(QPalette::Base);
QRect r = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxFrame, widget);
QPalette shadePal = sb->palette;
shadePal.setColor(QPalette::Midlight, shadePal.button().color());
qDrawWinPanel(p, r, shadePal, true, &editBrush);
}
QPalette shadePal(opt->palette);
shadePal.setColor(QPalette::Button, opt->palette.light().color());
shadePal.setColor(QPalette::Light, opt->palette.button().color());
if (sb->subControls & SC_SpinBoxUp) {
copy.subControls = SC_SpinBoxUp;
QPalette pal2 = sb->palette;
if (!(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled)) {
pal2.setCurrentColorGroup(QPalette::Disabled);
copy.state &= ~State_Enabled;
}
copy.palette = pal2;
if (sb->activeSubControls == SC_SpinBoxUp && (sb->state & State_Sunken)) {
copy.state |= State_On;
copy.state |= State_Sunken;
} else {
copy.state |= State_Raised;
copy.state &= ~State_Sunken;
}
pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinPlus
: PE_IndicatorSpinUp);
copy.rect = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxUp, widget);
qDrawWinButton(p, copy.rect, shadePal, copy.state & (State_Sunken | State_On),
©.palette.brush(QPalette::Button));
copy.rect.adjust(4, 1, -5, -1);
if (!enabled || !(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled) ) {
QStyleOptionSpinBox lightCopy = copy;
lightCopy.rect.adjust(1, 1, 1, 1);
lightCopy.palette.setBrush(QPalette::ButtonText, copy.palette.light());
proxy()->drawPrimitive(pe, &lightCopy, p, widget);
}
proxy()->drawPrimitive(pe, ©, p, widget);
}
if (sb->subControls & SC_SpinBoxDown) {
copy.subControls = SC_SpinBoxDown;
copy.state = sb->state;
QPalette pal2 = sb->palette;
if (!(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled)) {
pal2.setCurrentColorGroup(QPalette::Disabled);
copy.state &= ~State_Enabled;
}
copy.palette = pal2;
if (sb->activeSubControls == SC_SpinBoxDown && (sb->state & State_Sunken)) {
copy.state |= State_On;
copy.state |= State_Sunken;
} else {
copy.state |= State_Raised;
copy.state &= ~State_Sunken;
}
pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinMinus
: PE_IndicatorSpinDown);
copy.rect = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxDown, widget);
qDrawWinButton(p, copy.rect, shadePal, copy.state & (State_Sunken | State_On),
©.palette.brush(QPalette::Button));
copy.rect.adjust(4, 0, -5, -1);
if (!enabled || !(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled) ) {
QStyleOptionSpinBox lightCopy = copy;
lightCopy.rect.adjust(1, 1, 1, 1);
lightCopy.palette.setBrush(QPalette::ButtonText, copy.palette.light());
proxy()->drawPrimitive(pe, &lightCopy, p, widget);
}
proxy()->drawPrimitive(pe, ©, p, widget);
}
}
break;
#endif // QT_NO_SPINBOX
default:
QCommonStyle::drawComplexControl(cc, opt, p, widget);
}
}
/*! \reimp */
QSize QWindowsStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
const QSize &csz, const QWidget *widget) const
{
QSize sz(csz);
switch (ct) {
case CT_PushButton:
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget);
int w = sz.width(),
h = sz.height();
int defwidth = 0;
if (btn->features & QStyleOptionButton::AutoDefaultButton)
defwidth = 2 * proxy()->pixelMetric(PM_ButtonDefaultIndicator, btn, widget);
int minwidth = int(QStyleHelper::dpiScaled(75.));
int minheight = int(QStyleHelper::dpiScaled(23.));
#ifndef QT_QWS_SMALL_PUSHBUTTON
if (w < minwidth + defwidth && !btn->text.isEmpty())
w = minwidth + defwidth;
if (h < minheight + defwidth)
h = minheight + defwidth;
#endif
sz = QSize(w, h);
}
break;
#ifndef QT_NO_MENU
case CT_MenuItem:
if (const QStyleOptionMenuItem *mi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
int w = sz.width();
sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget);
if (mi->menuItemType == QStyleOptionMenuItem::Separator) {
sz = QSize(10, windowsSepHeight);
}
else if (mi->icon.isNull()) {
sz.setHeight(sz.height() - 2);
w -= 6;
}
if (mi->menuItemType != QStyleOptionMenuItem::Separator && !mi->icon.isNull()) {
int iconExtent = proxy()->pixelMetric(PM_SmallIconSize, opt, widget);
sz.setHeight(qMax(sz.height(),
mi->icon.actualSize(QSize(iconExtent, iconExtent)).height()
+ 2 * windowsItemFrame));
}
int maxpmw = mi->maxIconWidth;
int tabSpacing = 20;
if (mi->text.contains(QLatin1Char('\t')))
w += tabSpacing;
else if (mi->menuItemType == QStyleOptionMenuItem::SubMenu)
w += 2 * windowsArrowHMargin;
else if (mi->menuItemType == QStyleOptionMenuItem::DefaultItem) {
// adjust the font and add the difference in size.
// it would be better if the font could be adjusted in the initStyleOption qmenu func!!
QFontMetrics fm(mi->font);
QFont fontBold = mi->font;
fontBold.setBold(true);
QFontMetrics fmBold(fontBold);
w += fmBold.width(mi->text) - fm.width(mi->text);
}
int checkcol = qMax(maxpmw, windowsCheckMarkWidth); // Windows always shows a check column
w += checkcol;
w += windowsRightBorder + 10;
sz.setWidth(w);
}
break;
#endif // QT_NO_MENU
#ifndef QT_NO_MENUBAR
case CT_MenuBarItem:
if (!sz.isEmpty())
sz += QSize(windowsItemHMargin * 4, windowsItemVMargin * 2);
break;
#endif
// Otherwise, fall through
case CT_ToolButton:
if (qstyleoption_cast<const QStyleOptionToolButton *>(opt))
return sz += QSize(7, 6);
// Otherwise, fall through
default:
sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget);
}
return sz;
}
/*!
\internal
*/
QIcon QWindowsStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option,
const QWidget *widget) const
{
QIcon icon;
QPixmap pixmap;
#ifdef Q_OS_WIN
switch (standardIcon) {
case SP_FileDialogNewFolder:
{
for (int size = 16 ; size <= 32 ; size += 16) {
pixmap = loadIconFromShell32(319, size);
icon.addPixmap(pixmap, QIcon::Normal);
}
break;
}
case SP_DirHomeIcon:
{
for (int size = 16 ; size <= 32 ; size += 16) {
pixmap = loadIconFromShell32(235, size);
icon.addPixmap(pixmap, QIcon::Normal);
}
break;
}
case SP_DirIcon:
for (int size = 16 ; size <= 32 ; size += 16) {
pixmap = loadIconFromShell32(4, size);
icon.addPixmap(pixmap, QIcon::Normal, QIcon::Off);
pixmap = loadIconFromShell32(5, size);
icon.addPixmap(pixmap, QIcon::Normal, QIcon::On);
}
break;
case SP_DirLinkIcon:
for (int size = 16 ; size <= 32 ; size += 16) {
QPixmap link = loadIconFromShell32(30, size);
pixmap = loadIconFromShell32(4, size);
if (!pixmap.isNull() && !link.isNull()) {
QPainter painter(&pixmap);
painter.drawPixmap(0, 0, size, size, link);
icon.addPixmap(pixmap, QIcon::Normal, QIcon::Off);
}
link = loadIconFromShell32(30, size);
pixmap = loadIconFromShell32(5, size);
if (!pixmap.isNull() && !link.isNull()) {
QPainter painter(&pixmap);
painter.drawPixmap(0, 0, size, size, link);
icon.addPixmap(pixmap, QIcon::Normal, QIcon::On);
}
}
break;
case SP_FileIcon:
for (int size = 16 ; size <= 32 ; size += 16) {
pixmap = loadIconFromShell32(1, size);
icon.addPixmap(pixmap, QIcon::Normal);
}
break;
case SP_ComputerIcon:
for (int size = 16 ; size <= 32 ; size += 16) {
pixmap = loadIconFromShell32(16, size);
icon.addPixmap(pixmap, QIcon::Normal);
}
break;
case SP_DesktopIcon:
for (int size = 16 ; size <= 32 ; size += 16) {
pixmap = loadIconFromShell32(35, size);
icon.addPixmap(pixmap, QIcon::Normal);
}
break;
case SP_DriveCDIcon:
case SP_DriveDVDIcon:
for (int size = 16 ; size <= 32 ; size += 16) {
pixmap = loadIconFromShell32(12, size);
icon.addPixmap(pixmap, QIcon::Normal);
}
break;
case SP_DriveNetIcon:
for (int size = 16 ; size <= 32 ; size += 16) {
pixmap = loadIconFromShell32(10, size);
icon.addPixmap(pixmap, QIcon::Normal);
}
break;
case SP_DriveHDIcon:
for (int size = 16 ; size <= 32 ; size += 16) {
pixmap = loadIconFromShell32(9, size);
icon.addPixmap(pixmap, QIcon::Normal);
}
break;
case SP_DriveFDIcon:
for (int size = 16 ; size <= 32 ; size += 16) {
pixmap = loadIconFromShell32(7, size);
icon.addPixmap(pixmap, QIcon::Normal);
}
break;
case SP_FileLinkIcon:
for (int size = 16 ; size <= 32 ; size += 16) {
QPixmap link;
link = loadIconFromShell32(30, size);
pixmap = loadIconFromShell32(1, size);
if (!pixmap.isNull() && !link.isNull()) {
QPainter painter(&pixmap);
painter.drawPixmap(0, 0, size, size, link);
icon.addPixmap(pixmap, QIcon::Normal);
}
}
break;
case SP_VistaShield:
{
if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA
&& QSysInfo::WindowsVersion < QSysInfo::WV_NT_based
&& pSHGetStockIconInfo)
{
icon.addPixmap(proxy()->standardPixmap(SP_VistaShield, option, widget)); //fetches small icon
QSHSTOCKICONINFO iconInfo; //append large icon
memset(&iconInfo, 0, sizeof(iconInfo));
iconInfo.cbSize = sizeof(iconInfo);
if (pSHGetStockIconInfo(_SIID_SHIELD, _SHGFI_ICON | _SHGFI_LARGEICON, &iconInfo) == S_OK) {
icon.addPixmap(convertHIconToPixmap(iconInfo.hIcon));
DestroyIcon(iconInfo.hIcon);
}
}
}
break;
default:
break;
}
#endif
if (icon.isNull())
icon = QCommonStyle::standardIconImplementation(standardIcon, option, widget);
return icon;
}
QT_END_NAMESPACE
#endif // QT_NO_STYLE_WINDOWS
|