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
|
/****************************************************************************
**
** Implementation of the TQCommonStyle class
**
** Created : 981231
**
** Copyright (C) 1998-2008 Trolltech ASA. All rights reserved.
**
** This file is part of the widgets module of the TQt GUI Toolkit.
**
** This file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free
** Software Foundation and appearing in the files LICENSE.GPL2
** and LICENSE.GPL3 included in the packaging of this file.
** Alternatively you may (at your option) use any later version
** of the GNU General Public License if such license has been
** publicly approved by Trolltech ASA (or its successors, if any)
** and the KDE Free TQt Foundation.
**
** Please review the following information to ensure GNU General
** Public Licensing requirements will be met:
** http://trolltech.com/products/qt/licenses/licensing/opensource/.
** If you are unsure which license is appropriate for your use, please
** review the following information:
** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
** or contact the sales department at sales@trolltech.com.
**
** This file may be used under the terms of the Q Public License as
** defined by Trolltech ASA and appearing in the file LICENSE.TQPL
** included in the packaging of this file. Licensees holding valid TQt
** Commercial licenses may use this file in accordance with the TQt
** Commercial License Agreement provided with the Software.
**
** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
** herein.
**
**********************************************************************/
#include "ntqcommonstyle.h"
#ifndef QT_NO_STYLE
#include "ntqmenubar.h"
#include "ntqapplication.h"
#include "ntqpainter.h"
#include "ntqdrawutil.h"
#include "ntqpixmap.h"
#include "ntqpushbutton.h"
#include "ntqtabbar.h"
#include "ntqlineedit.h"
#include "ntqscrollbar.h"
#include "ntqtoolbutton.h"
#include "ntqtoolbar.h"
#include "ntqcombobox.h"
#include "ntqdockarea.h"
#include "ntqheader.h"
#include "ntqspinbox.h"
#include "ntqrangecontrol.h"
#include "ntqgroupbox.h"
#include "ntqslider.h"
#include "ntqlistview.h"
#include "ntqcheckbox.h"
#include "ntqradiobutton.h"
#include "ntqbitmap.h"
#include "ntqprogressbar.h"
#include "private/qdialogbuttons_p.h"
#include <limits.h>
#include <ntqpixmap.h>
#include "../widgets/qtitlebar_p.h"
#include <ntqtoolbox.h>
/*!
\class TQCommonStyle ntqcommonstyle.h
\brief The TQCommonStyle class encapsulates the common Look and Feel of a GUI.
\ingroup appearance
This abstract class implements some of the widget's look and feel
that is common to all GUI styles provided and shipped as part of
TQt.
All the functions are documented in \l TQStyle.
*/
/*!
\enum TQt::ArrowType
\value UpArrow
\value DownArrow
\value LeftArrow
\value RightArrow
*/
// the active painter, if any... this is used as an optimzation to
// avoid creating a painter if we have an active one (since
// TQStyle::itemRect() needs a painter to operate correctly
static TQPainter *activePainter = 0;
/*!
Constructs a TQCommonStyle.
*/
TQCommonStyle::TQCommonStyle() : TQStyle()
{
activePainter = 0;
}
/*! \reimp */
TQCommonStyle::~TQCommonStyle()
{
activePainter = 0;
}
static const char * const check_list_controller_xpm[] = {
"16 16 4 1",
" c None",
". c #000000000000",
"X c #FFFFFFFF0000",
"o c #C71BC30BC71B",
" ",
" ",
" .......... ",
" .XXXXXXXX. ",
" .XXXXXXXX.oo ",
" .XXXXXXXX.oo ",
" .XXXXXXXX.oo ",
" .XXXXXXXX.oo ",
" .XXXXXXXX.oo ",
" .XXXXXXXX.oo ",
" .XXXXXXXX.oo ",
" ..........oo ",
" oooooooooo ",
" oooooooooo ",
" ",
" "};
#include <ntqmetaobject.h>
TQStringList getObjectTypeListForObject(const TQObject* object) {
TQStringList objectTypes;
if (object) {
TQMetaObject* objectMetaObject = object->metaObject();
const char* name;
while (objectMetaObject) {
name = objectMetaObject->className();
objectTypes.append(TQString(name));
objectMetaObject = objectMetaObject->superClass();
}
}
return objectTypes;
}
TQStyle::ControlElementFlags getControlElementFlagsForObject(const TQObject* object, TQStringList objectTypeList, const TQStyleOption& opt, bool populateReliantFields) {
TQStyle::ControlElementFlags cef = (TQStyle::ControlElementFlags)0;
if (object) {
if (objectTypeList.contains("TQPushButton")) {
const TQPushButton *button = dynamic_cast<const TQPushButton*>(object);
if (button) {
if (button->isDefault()) cef = cef | TQStyle::CEF_IsDefault;
if (button->autoDefault()) cef = cef | TQStyle::CEF_AutoDefault;
if (button->isMenuButton()) cef = cef | TQStyle::CEF_IsMenuWidget;
if (button->isToggleButton()) cef = cef | TQStyle::CEF_BiState;
if (button->isFlat()) cef = cef | TQStyle::CEF_IsFlat;
}
}
if (objectTypeList.contains("TQToolButton")) {
const TQToolButton *button = dynamic_cast<const TQToolButton*>(object);
if (button) {
if (button->isToggleButton()) cef = cef | TQStyle::CEF_BiState;
if (button->usesTextLabel()) cef = cef | TQStyle::CEF_UsesTextLabel;
if (button->usesBigPixmap()) cef = cef | TQStyle::CEF_UsesBigPixmap;
if (button->popup()) cef = cef | TQStyle::CEF_HasPopupMenu;
}
}
if (objectTypeList.contains("TQButton")) {
const TQButton *button = dynamic_cast<const TQButton*>(object);
if (button) {
if (button->isDown()) cef = cef | TQStyle::CEF_IsDown;
if (button->isOn()) cef = cef | TQStyle::CEF_IsOn;
if (button->isToggleButton()) cef = cef | TQStyle::CEF_BiState;
}
}
if (objectTypeList.contains("TQTabBar")) {
const TQTabBar *tb = dynamic_cast<const TQTabBar*>(object);
TQTab * t = opt.tab();
if ((t) && (tb)) {
if (t->identifier() == tb->currentTab()) cef = cef | TQStyle::CEF_IsActive;
}
}
if (objectTypeList.contains("TQToolBox")) {
const TQToolBox *tb = dynamic_cast<const TQToolBox*>(object);
if (tb) {
if (!tb->currentItem()) cef = cef | TQStyle::CEF_IsContainerEmpty;
}
}
if (objectTypeList.contains("TQProgressBar")) {
const TQProgressBar *pb = dynamic_cast<const TQProgressBar*>(object);
if (pb) {
if (pb->centerIndicator()) cef = cef | TQStyle::CEF_CenterIndicator;
if (pb->indicatorFollowsStyle()) cef = cef | TQStyle::CEF_IndicatorFollowsStyle;
}
}
if (objectTypeList.contains("TQPopupMenu")) {
const TQPopupMenu *pm = dynamic_cast<const TQPopupMenu*>(object);
if (pm) {
if (pm->isCheckable()) cef = cef | TQStyle::CEF_IsCheckable;
}
}
if (objectTypeList.contains("TQComboBox")) {
const TQComboBox *cb = dynamic_cast<const TQComboBox*>(object);
if (cb) {
if (cb->editable()) cef = cef | TQStyle::CEF_IsEditable;
}
}
// Generic flags
const TQWidget* widget = dynamic_cast<const TQWidget*>(object);
if (widget) {
if (widget->isEnabled()) cef = cef | TQStyle::CEF_IsEnabled;
if (widget->parentWidget()) cef = cef | TQStyle::CEF_HasParentWidget;
if (widget->focusProxy()) cef = cef | TQStyle::CEF_HasFocusProxy;
if (widget->hasFocus()) cef = cef | TQStyle::CEF_HasFocus;
if (populateReliantFields) {
if (widget->isActiveWindow()) cef = cef | TQStyle::CEF_IsActiveWindow;
if (widget->isTopLevel()) cef = cef | TQStyle::CEF_IsTopLevel;
if (widget->isVisible()) cef = cef | TQStyle::CEF_IsVisible;
}
}
}
else {
cef = cef | TQStyle::CEF_UseGenericParameters;
}
return cef;
}
TQStyleControlElementData populateControlElementDataFromWidget(const TQWidget* widget, const TQStyleOption& opt, bool populateReliantFields) {
TQStyleControlElementData ceData;
if (widget) {
ceData.widgetObjectTypes = getObjectTypeListForObject(widget);
ceData.allDataPopulated = populateReliantFields;
const TQPixmap* erasePixmap = widget->backgroundPixmap();
if (erasePixmap) {
ceData.bgPixmap = *erasePixmap;
}
if (populateReliantFields) {
ceData.bgBrush = widget->backgroundBrush();
}
ceData.wflags = widget->getWFlags();
if (populateReliantFields) {
ceData.windowState = (TQt::WindowState)(widget->windowState());
}
ceData.bgColor = widget->eraseColor();
ceData.bgOffset = widget->backgroundOffset();
ceData.backgroundMode = widget->backgroundMode();
if (populateReliantFields) {
ceData.fgColor = widget->foregroundColor();
ceData.colorGroup = widget->colorGroup();
}
ceData.geometry = widget->geometry();
ceData.rect = widget->rect();
ceData.pos = widget->pos();
const TQPixmap* icon = widget->icon();
if (icon) {
ceData.icon = *icon;
}
ceData.palette = widget->palette();
ceData.font = widget->font();
if (ceData.widgetObjectTypes.contains("TQPushButton")) {
const TQPushButton *button = dynamic_cast<const TQPushButton*>(widget);
if (button) {
TQIconSet* iconSet = 0;
const TQPixmap* fgPixmap = 0;
iconSet = button->iconSet();
fgPixmap = button->pixmap();
if (iconSet) {
ceData.iconSet = *iconSet;
}
if (fgPixmap) {
ceData.fgPixmap = *fgPixmap;
}
}
}
if (ceData.widgetObjectTypes.contains("TQToolButton")) {
const TQToolButton *button = dynamic_cast<const TQToolButton*>(widget);
if (button) {
const TQPixmap* fgPixmap = 0;
ceData.iconSet = button->iconSet();
fgPixmap = button->pixmap();
if (fgPixmap) {
ceData.fgPixmap = *fgPixmap;
}
ceData.textLabel = button->textLabel();
ceData.toolButtonTextPosition = button->textPosition();
ceData.popupDelay = button->popupDelay();
}
}
if (ceData.widgetObjectTypes.contains("TQCheckBox")) {
const TQCheckBox *button = dynamic_cast<const TQCheckBox*>(widget);
if (button) {
const TQPixmap* fgPixmap = 0;
fgPixmap = button->pixmap();
if (fgPixmap) {
ceData.fgPixmap = *fgPixmap;
}
}
}
if (ceData.widgetObjectTypes.contains("TQRadioButton")) {
const TQRadioButton *button = dynamic_cast<const TQRadioButton*>(widget);
if (button) {
const TQPixmap* fgPixmap = 0;
fgPixmap = button->pixmap();
if (fgPixmap) {
ceData.fgPixmap = *fgPixmap;
}
}
}
if (ceData.widgetObjectTypes.contains("TQButton")) {
const TQButton *button = dynamic_cast<const TQButton*>(widget);
if (button) {
ceData.text = button->text();
}
}
if (ceData.widgetObjectTypes.contains("TQTabBar")) {
const TQTabBar *tb = dynamic_cast<const TQTabBar*>(widget);
if (tb) {
ceData.tabBarData.tabCount = tb->count();
ceData.tabBarData.shape = tb->shape();
ceData.tabBarData.identIndexMap.clear();
const TQTab* currentTab;
for (int i=0; i<tb->count(); ++i) {
currentTab = tb->tabAt(i);
if (currentTab) {
ceData.tabBarData.identIndexMap[currentTab->identifier()] = tb->indexOf(currentTab->identifier());
}
}
}
}
if (ceData.widgetObjectTypes.contains("TQToolBox")) {
const TQToolBox *tb = dynamic_cast<const TQToolBox*>(widget);
if (tb) {
const TQWidget* currentItem = tb->currentItem();
if (currentItem) {
ceData.activeItemPaletteBgColor = currentItem->paletteBackgroundColor();
}
}
}
if (ceData.widgetObjectTypes.contains("TQProgressBar")) {
const TQProgressBar *pb = dynamic_cast<const TQProgressBar*>(widget);
if (pb) {
ceData.currentStep = pb->progress();
ceData.totalSteps = pb->totalSteps();
ceData.progressText = pb->progressString();
ceData.percentageVisible = pb->percentageVisible();
}
}
if (ceData.widgetObjectTypes.contains("TQHeader")) {
const TQHeader *header = dynamic_cast<const TQHeader*>(widget);
if (header) {
int section = opt.headerSection();
TQIconSet* iconSet = 0;
iconSet = header->iconSet(section);
ceData.textLabel = header->label(section);
if (iconSet) {
ceData.iconSet = *iconSet;
}
}
}
// Complex Controls
if (ceData.widgetObjectTypes.contains("TQScrollBar")) {
const TQScrollBar *sb = dynamic_cast<const TQScrollBar*>(widget);
if (sb) {
ceData.orientation = sb->orientation();
ceData.minSteps = sb->minValue();
ceData.maxSteps = sb->maxValue();
ceData.currentStep = sb->value();
ceData.startStep = sb->sliderStart();
ceData.lineStep = sb->lineStep();
ceData.pageStep = sb->pageStep();
if (populateReliantFields) {
ceData.sliderRect = sb->sliderRect();
}
}
}
if (ceData.widgetObjectTypes.contains("TQSlider")) {
const TQSlider *sl = dynamic_cast<const TQSlider*>(widget);
if (sl) {
ceData.orientation = sl->orientation();
ceData.tickMarkSetting = sl->tickmarks();
ceData.tickInterval = sl->tickInterval();
ceData.currentStep = sl->value();
ceData.startStep = sl->sliderStart();
ceData.lineStep = sl->lineStep();
ceData.pageStep = sl->pageStep();
if (populateReliantFields) {
ceData.sliderRect = sl->sliderRect();
}
}
}
if (ceData.widgetObjectTypes.contains("TQDialogButtons")) {
const TQDialogButtons *dlgbtns = dynamic_cast<const TQDialogButtons*>(widget);
if (dlgbtns) {
ceData.orientation = dlgbtns->orientation();
ceData.dlgVisibleButtons = dlgbtns->visibleButtons();
TQDialogButtons::Button btns[] = { TQDialogButtons::All, TQDialogButtons::Reject, TQDialogButtons::Accept, TQDialogButtons::Apply, TQDialogButtons::Retry, TQDialogButtons::Ignore, TQDialogButtons::Abort, TQDialogButtons::Help };
for(unsigned int i = 0; i < (sizeof(btns)/sizeof(btns[0])); i++) {
if (ceData.dlgVisibleButtons & btns[i]) {
ceData.dlgVisibleSizeHints[btns[i]] = dlgbtns->sizeHint(btns[i]);
}
}
}
}
if (ceData.widgetObjectTypes.contains("TQTitleBar")) {
const TQTitleBar *tb = dynamic_cast<const TQTitleBar*>(widget);
if (tb) {
ceData.titleBarData.hasWindow = !!(tb->window());
if (populateReliantFields) {
if (ceData.titleBarData.hasWindow) {
ceData.titleBarData.windowState = (TQt::WindowState)(tb->window()->windowState());
}
ceData.titleBarData.usesActiveColor = tb->usesActiveColor();
}
ceData.titleBarData.visibleText = tb->visibleText();
}
}
if (ceData.widgetObjectTypes.contains("TQSpinWidget")) {
const TQSpinWidget *sw = dynamic_cast<const TQSpinWidget*>(widget);
if (sw) {
ceData.spinWidgetData.buttonSymbols = sw->buttonSymbols();
ceData.spinWidgetData.upRect = sw->upRect();
ceData.spinWidgetData.downRect = sw->downRect();
ceData.spinWidgetData.upEnabled = sw->isUpEnabled();
ceData.spinWidgetData.downEnabled = sw->isDownEnabled();
}
}
if (ceData.widgetObjectTypes.contains("TQListView")) {
const TQListView *lv = dynamic_cast<const TQListView*>(widget);
if (lv) {
ceData.listViewData.rootDecorated = lv->rootIsDecorated();
ceData.listViewData.itemMargin = lv->itemMargin();
TQWidget* viewport = lv->viewport();
if (viewport) {
ceData.viewportData.widgetObjectTypes = getObjectTypeListForObject(viewport);
ceData.viewportData.allDataPopulated = populateReliantFields;
const TQPixmap* erasePixmap = viewport->backgroundPixmap();
if (erasePixmap) {
ceData.viewportData.bgPixmap = *erasePixmap;
}
if (populateReliantFields) {
ceData.viewportData.bgBrush = viewport->backgroundBrush();
}
ceData.viewportData.wflags = viewport->getWFlags();
if (populateReliantFields) {
ceData.viewportData.windowState = (TQt::WindowState)(widget->windowState());
}
ceData.viewportData.bgColor = viewport->eraseColor();
ceData.viewportData.bgOffset = viewport->backgroundOffset();
ceData.viewportData.backgroundMode = viewport->backgroundMode();
if (populateReliantFields) {
ceData.viewportData.fgColor = viewport->foregroundColor();
ceData.viewportData.colorGroup = viewport->colorGroup();
}
ceData.viewportData.geometry = viewport->geometry();
ceData.viewportData.rect = viewport->rect();
ceData.viewportData.pos = viewport->pos();
const TQPixmap* icon = viewport->icon();
if (icon) {
ceData.viewportData.icon = *icon;
}
ceData.viewportData.palette = viewport->palette();
ceData.viewportData.font = viewport->font();
}
}
}
if (ceData.widgetObjectTypes.contains("TQComboBox")) {
const TQComboBox *cb = dynamic_cast<const TQComboBox*>(widget);
if (cb) {
const TQLineEdit* lineEdit = cb->lineEdit();
if (lineEdit) {
ceData.comboBoxLineEditFlags = getControlElementFlagsForObject(lineEdit, ceData.widgetObjectTypes, TQStyleOption::Default);
}
}
}
if (ceData.widgetObjectTypes.contains("TQFrame")) {
const TQFrame *frame = dynamic_cast<const TQFrame*>(widget);
if (frame) {
ceData.frameStyle = frame->frameStyle();
}
}
const TQWidget* parentWidget = widget->parentWidget();
if (parentWidget) {
ceData.parentWidgetData.widgetObjectTypes = getObjectTypeListForObject(parentWidget);
ceData.parentWidgetData.allDataPopulated = populateReliantFields;
const TQPixmap* erasePixmap = parentWidget->backgroundPixmap();
if (erasePixmap) {
ceData.parentWidgetData.bgPixmap = *erasePixmap;
}
if (populateReliantFields) {
ceData.parentWidgetData.bgBrush = parentWidget->backgroundBrush();
}
ceData.parentWidgetData.wflags = parentWidget->getWFlags();
if (populateReliantFields) {
ceData.parentWidgetData.windowState = (TQt::WindowState)(widget->windowState());
}
ceData.parentWidgetData.bgColor = parentWidget->eraseColor();
ceData.parentWidgetData.bgOffset = parentWidget->backgroundOffset();
ceData.parentWidgetData.backgroundMode = parentWidget->backgroundMode();
if (populateReliantFields) {
ceData.parentWidgetData.fgColor = parentWidget->foregroundColor();
ceData.parentWidgetData.colorGroup = parentWidget->colorGroup();
}
ceData.parentWidgetData.geometry = parentWidget->geometry();
ceData.parentWidgetData.rect = parentWidget->rect();
ceData.parentWidgetData.pos = parentWidget->pos();
const TQPixmap* icon = parentWidget->icon();
if (icon) {
ceData.parentWidgetData.icon = *icon;
}
ceData.parentWidgetData.palette = parentWidget->palette();
ceData.parentWidgetData.font = parentWidget->font();
const TQDockWindow * dw = dynamic_cast<const TQDockWindow*>(parentWidget);
if (dw) {
if (dw->area()) {
ceData.dwData.hasDockArea = true;
ceData.dwData.areaOrientation = dw->area()->orientation();
}
else {
ceData.dwData.hasDockArea = false;
}
ceData.dwData.closeEnabled = dw->isCloseEnabled();
}
}
TQCheckListItem *item = opt.checkListItem();
if (item) {
ceData.checkListItemData.dataValid = true;
ceData.checkListItemData.enabled = item->isEnabled();
ceData.checkListItemData.hasParent = ( item->parent() && (item->parent()->rtti() == 1) && (((TQCheckListItem*) item->parent())->type() == TQCheckListItem::Controller) );
ceData.checkListItemData.height = item->height();
}
else {
ceData.checkListItemData.dataValid = false;
}
}
return ceData;
}
TQStyleControlElementData populateControlElementDataFromApplication(const TQApplication* app, const TQStyleOption&, bool) {
TQStyleControlElementData ceData;
if (app) {
ceData.widgetObjectTypes = getObjectTypeListForObject(app);
ceData.palette = app->palette();
ceData.font = app->font();
}
return ceData;
}
/*! \reimp */
void TQCommonStyle::drawPrimitive( PrimitiveElement pe,
TQPainter *p,
TQStyleControlElementData ceData,
ControlElementFlags elementFlags,
const TQRect &r,
const TQColorGroup &cg,
SFlags flags,
const TQStyleOption& opt ) const
{
activePainter = p;
switch (pe) {
#ifndef QT_NO_LISTVIEW
case PE_CheckListController: {
p->drawPixmap(r, TQPixmap((const char **)check_list_controller_xpm));
break; }
case PE_CheckListExclusiveIndicator: {
if(!ceData.checkListItemData.dataValid)
return;
int x = r.x(), y = r.y();
#define TQCOORDARRLEN(x) sizeof(x)/(sizeof(TQCOORD)*2)
static const TQCOORD pts1[] = { // dark lines
1,9, 1,8, 0,7, 0,4, 1,3, 1,2, 2,1, 3,1, 4,0, 7,0, 8,1, 9,1 };
static const TQCOORD pts2[] = { // black lines
2,8, 1,7, 1,4, 2,3, 2,2, 3,2, 4,1, 7,1, 8,2, 9,2 };
static const TQCOORD pts3[] = { // background lines
2,9, 3,9, 4,10, 7,10, 8,9, 9,9, 9,8, 10,7, 10,4, 9,3 };
static const TQCOORD pts4[] = { // white lines
2,10, 3,10, 4,11, 7,11, 8,10, 9,10, 10,9, 10,8, 11,7,
11,4, 10,3, 10,2 };
// static const TQCOORD pts5[] = { // inner fill
// 4,2, 7,2, 9,4, 9,7, 7,9, 4,9, 2,7, 2,4 };
//TQPointArray a;
// p->eraseRect( x, y, w, h );
if ( flags & Style_Enabled )
p->setPen( cg.text() );
else
p->setPen( TQPen( ceData.palette.color( TQPalette::Disabled, TQColorGroup::Text ) ) );
TQPointArray a( TQCOORDARRLEN(pts1), pts1 );
a.translate( x, y );
//p->setPen( cg.dark() );
p->drawPolyline( a );
a.setPoints( TQCOORDARRLEN(pts2), pts2 );
a.translate( x, y );
p->drawPolyline( a );
a.setPoints( TQCOORDARRLEN(pts3), pts3 );
a.translate( x, y );
// p->setPen( black );
p->drawPolyline( a );
a.setPoints( TQCOORDARRLEN(pts4), pts4 );
a.translate( x, y );
// p->setPen( blue );
p->drawPolyline( a );
// a.setPoints( TQCOORDARRLEN(pts5), pts5 );
// a.translate( x, y );
// TQColor fillColor = isDown() ? g.background() : g.base();
// p->setPen( fillColor );
// p->setBrush( fillColor );
// p->drawPolygon( a );
if ( flags & Style_On ) {
p->setPen( NoPen );
p->setBrush( cg.text() );
p->drawRect( x+5, y+4, 2, 4 );
p->drawRect( x+4, y+5, 4, 2 );
}
break; }
case PE_CheckListIndicator: {
if(!ceData.checkListItemData.dataValid)
return;
int x = r.x(), y = r.y(), w = r.width(), h = r.width(), marg = ceData.listViewData.itemMargin;
if ( flags & Style_Enabled )
p->setPen( TQPen( cg.text(), 2 ) );
else
p->setPen( TQPen( ceData.palette.color( TQPalette::Disabled, TQColorGroup::Text ),
2 ) );
if ( flags & Style_Selected && !ceData.listViewData.rootDecorated && !ceData.checkListItemData.hasParent ) {
p->fillRect( 0, 0, x + marg + w + 4, ceData.checkListItemData.height,
cg.brush( TQColorGroup::Highlight ) );
if ( ceData.checkListItemData.enabled )
p->setPen( TQPen( cg.highlightedText(), 2 ) );
}
if ( flags & Style_NoChange )
p->setBrush( cg.brush( TQColorGroup::Button ) );
p->drawRect( x+marg, y+2, w-4, h-4 );
/////////////////////
x++;
y++;
if ( ( flags & Style_On) || ( flags & Style_NoChange ) ) {
TQPointArray a( 7*2 );
int i, xx = x+1+marg, yy=y+5;
for ( i=0; i<3; i++ ) {
a.setPoint( 2*i, xx, yy );
a.setPoint( 2*i+1, xx, yy+2 );
xx++; yy++;
}
yy -= 2;
for ( i=3; i<7; i++ ) {
a.setPoint( 2*i, xx, yy );
a.setPoint( 2*i+1, xx, yy+2 );
xx++; yy--;
}
p->drawLineSegments( a );
}
break; }
#endif
case PE_HeaderArrow:
p->save();
if ( flags & Style_Down ) {
TQPointArray pa( 3 );
p->setPen( cg.light() );
p->drawLine( r.x() + r.width(), r.y(), r.x() + r.width() / 2, r.height() );
p->setPen( cg.dark() );
pa.setPoint( 0, r.x() + r.width() / 2, r.height() );
pa.setPoint( 1, r.x(), r.y() );
pa.setPoint( 2, r.x() + r.width(), r.y() );
p->drawPolyline( pa );
} else {
TQPointArray pa( 3 );
p->setPen( cg.light() );
pa.setPoint( 0, r.x(), r.height() );
pa.setPoint( 1, r.x() + r.width(), r.height() );
pa.setPoint( 2, r.x() + r.width() / 2, r.y() );
p->drawPolyline( pa );
p->setPen( cg.dark() );
p->drawLine( r.x(), r.height(), r.x() + r.width() / 2, r.y() );
}
p->restore();
break;
case PE_StatusBarSection:
qDrawShadeRect( p, r, cg, TRUE, 1, 0, 0 );
break;
case PE_ButtonCommand:
case PE_ButtonBevel:
case PE_ButtonTool:
case PE_ButtonDropDown:
case PE_HeaderSection:
case PE_HeaderSectionMenu:
qDrawShadePanel(p, r, cg, flags & (Style_Sunken | Style_Down | Style_On) , 1,
&cg.brush(TQColorGroup::Button));
break;
case PE_Separator:
qDrawShadeLine( p, r.left(), r.top(), r.right(), r.bottom(), cg,
flags & Style_Sunken, 1, 0);
break;
case PE_FocusRect: {
const TQColor *bg = 0;
if (!opt.isDefault())
bg = &opt.color();
TQPen oldPen = p->pen();
if (bg) {
int h, s, v;
bg->hsv(&h, &s, &v);
if (v >= 128)
p->setPen(TQt::black);
else
p->setPen(TQt::white);
} else
p->setPen(cg.foreground());
if (flags & Style_FocusAtBorder)
p->drawRect(TQRect(r.x() + 1, r.y() + 1, r.width() - 2, r.height() - 2));
else
p->drawRect(r);
p->setPen(oldPen);
break; }
case PE_SpinWidgetPlus:
case PE_SpinWidgetMinus: {
p->save();
int fw = pixelMetric( PM_DefaultFrameWidth, ceData, elementFlags, 0 );
TQRect br;
br.setRect( r.x() + fw, r.y() + fw, r.width() - fw*2,
r.height() - fw*2 );
p->fillRect( br, cg.brush( TQColorGroup::Button ) );
p->setPen( cg.buttonText() );
p->setBrush( cg.buttonText() );
int length;
int x = r.x(), y = r.y(), w = r.width(), h = r.height();
if ( w <= 8 || h <= 6 )
length = TQMIN( w-2, h-2 );
else
length = TQMIN( 2*w / 3, 2*h / 3 );
if ( !(length & 1) )
length -=1;
int xmarg = ( w - length ) / 2;
int ymarg = ( h - length ) / 2;
p->drawLine( x + xmarg, ( y + h / 2 - 1 ),
x + xmarg + length - 1, ( y + h / 2 - 1 ) );
if ( pe == PE_SpinWidgetPlus )
p->drawLine( ( x+w / 2 ) - 1, y + ymarg,
( x+w / 2 ) - 1, y + ymarg + length - 1 );
p->restore();
break; }
case PE_SpinWidgetUp:
case PE_SpinWidgetDown: {
int fw = pixelMetric( PM_DefaultFrameWidth, ceData, elementFlags, 0 );
TQRect br;
br.setRect( r.x() + fw, r.y() + fw, r.width() - fw*2,
r.height() - fw*2 );
p->fillRect( br, cg.brush( TQColorGroup::Button ) );
int x = r.x(), y = r.y(), w = r.width(), h = r.height();
int sw = w-4;
if ( sw < 3 )
break;
else if ( !(sw & 1) )
sw--;
sw -= ( sw / 7 ) * 2; // Empty border
int sh = sw/2 + 2; // Must have empty row at foot of arrow
int sx = x + w / 2 - sw / 2 - 1;
int sy = y + h / 2 - sh / 2 - 1;
TQPointArray a;
if ( pe == PE_SpinWidgetDown )
a.setPoints( 3, 0, 1, sw-1, 1, sh-2, sh-1 );
else
a.setPoints( 3, 0, sh-1, sw-1, sh-1, sh-2, 1 );
int bsx = 0;
int bsy = 0;
if ( flags & Style_Sunken ) {
bsx = pixelMetric(PM_ButtonShiftHorizontal, ceData, elementFlags);
bsy = pixelMetric(PM_ButtonShiftVertical, ceData, elementFlags);
}
p->save();
p->translate( sx + bsx, sy + bsy );
p->setPen( cg.buttonText() );
p->setBrush( cg.buttonText() );
p->drawPolygon( a );
p->restore();
break; }
case PE_Indicator: {
if (flags & Style_NoChange) {
p->setPen(cg.foreground());
p->fillRect(r, cg.brush(TQColorGroup::Button));
p->drawRect(r);
p->drawLine(r.topLeft(), r.bottomRight());
} else
qDrawShadePanel(p, r.x(), r.y(), r.width(), r.height(),
cg, flags & (Style_Sunken | Style_On), 1,
&cg.brush(TQColorGroup::Button));
break; }
case PE_IndicatorMask: {
p->fillRect(r, color1);
break; }
case PE_ExclusiveIndicator: {
TQRect ir = r;
p->setPen(cg.dark());
p->drawArc(r, 0, 5760);
if (flags & (Style_Sunken | Style_On)) {
ir.addCoords(2, 2, -2, -2);
p->setBrush(cg.foreground());
p->drawEllipse(ir);
}
break; }
case PE_ExclusiveIndicatorMask: {
p->setPen(color1);
p->setBrush(color1);
p->drawEllipse(r);
break; }
case PE_DockWindowHandle: {
bool highlight = flags & Style_On;
p->save();
p->translate( r.x(), r.y() );
if ( flags & Style_Horizontal ) {
int x = r.width() / 3;
if ( r.height() > 4 ) {
qDrawShadePanel( p, x, 2, 3, r.height() - 4,
cg, highlight, 1, 0 );
qDrawShadePanel( p, x+3, 2, 3, r.height() - 4,
cg, highlight, 1, 0 );
}
} else {
if ( r.width() > 4 ) {
int y = r.height() / 3;
qDrawShadePanel( p, 2, y, r.width() - 4, 3,
cg, highlight, 1, 0 );
qDrawShadePanel( p, 2, y+3, r.width() - 4, 3,
cg, highlight, 1, 0 );
}
}
p->restore();
break;
}
case PE_DockWindowSeparator: {
TQPoint p1, p2;
if ( flags & Style_Horizontal ) {
p1 = TQPoint( r.width()/2, 0 );
p2 = TQPoint( p1.x(), r.height() );
} else {
p1 = TQPoint( 0, r.height()/2 );
p2 = TQPoint( r.width(), p1.y() );
}
qDrawShadeLine( p, p1, p2, cg, 1, 1, 0 );
break; }
case PE_Panel:
case PE_PanelPopup: {
int lw = opt.isDefault() ? pixelMetric(PM_DefaultFrameWidth, ceData, elementFlags)
: opt.lineWidth();
qDrawShadePanel(p, r, cg, (flags & Style_Sunken), lw);
break; }
case PE_PanelDockWindow: {
int lw = opt.isDefault() ? pixelMetric(PM_DockWindowFrameWidth, ceData, elementFlags)
: opt.lineWidth();
qDrawShadePanel(p, r, cg, FALSE, lw);
break; }
case PE_PanelMenuBar: {
int lw = opt.isDefault() ? pixelMetric(PM_MenuBarFrameWidth, ceData, elementFlags)
: opt.lineWidth();
qDrawShadePanel(p, r, cg, FALSE, lw, &cg.brush(TQColorGroup::Button));
break; }
case PE_SizeGrip: {
p->save();
int x, y, w, h;
r.rect(&x, &y, &w, &h);
int sw = TQMIN( h,w );
if ( h > w )
p->translate( 0, h - w );
else
p->translate( w - h, 0 );
int sx = x;
int sy = y;
int s = sw / 3;
if ( TQApplication::reverseLayout() ) {
sx = x + sw;
for ( int i = 0; i < 4; ++i ) {
p->setPen( TQPen( cg.light(), 1 ) );
p->drawLine( x, sy - 1 , sx + 1, sw );
p->setPen( TQPen( cg.dark(), 1 ) );
p->drawLine( x, sy, sx, sw );
p->setPen( TQPen( cg.dark(), 1 ) );
p->drawLine( x, sy + 1, sx - 1, sw );
sx -= s;
sy += s;
}
} else {
for ( int i = 0; i < 4; ++i ) {
p->setPen( TQPen( cg.light(), 1 ) );
p->drawLine( sx-1, sw, sw, sy-1 );
p->setPen( TQPen( cg.dark(), 1 ) );
p->drawLine( sx, sw, sw, sy );
p->setPen( TQPen( cg.dark(), 1 ) );
p->drawLine( sx+1, sw, sw, sy+1 );
sx += s;
sy += s;
}
}
p->restore();
break; }
case PE_CheckMark: {
const int markW = r.width() > 7 ? 7 : r.width();
const int markH = markW;
int posX = r.x() + ( r.width() - markW )/2 + 1;
int posY = r.y() + ( r.height() - markH )/2;
// Could do with some optimizing/caching...
TQPointArray a( markH*2 );
int i, xx, yy;
xx = posX;
yy = 3 + posY;
for ( i=0; i<markW/2; i++ ) {
a.setPoint( 2*i, xx, yy );
a.setPoint( 2*i+1, xx, yy+2 );
xx++; yy++;
}
yy -= 2;
for ( ; i<markH; i++ ) {
a.setPoint( 2*i, xx, yy );
a.setPoint( 2*i+1, xx, yy+2 );
xx++; yy--;
}
if ( !(flags & Style_Enabled) && !(flags & Style_On)) {
int pnt;
p->setPen( cg.highlightedText() );
TQPoint offset(1,1);
for ( pnt = 0; pnt < (int)a.size(); pnt++ )
a[pnt] += offset;
p->drawLineSegments( a );
for ( pnt = 0; pnt < (int)a.size(); pnt++ )
a[pnt] -= offset;
}
p->setPen( cg.text() );
p->drawLineSegments( a );
break; }
case PE_PanelGroupBox: //We really do not need PE_GroupBoxFrame anymore, nasty holdover ###
drawPrimitive( PE_GroupBoxFrame, p, ceData, elementFlags, r, cg, flags, opt );
break;
case PE_GroupBoxFrame: {
#ifndef QT_NO_FRAME
if ( opt.isDefault() )
break;
int lwidth = opt.lineWidth(), mlwidth = opt.midLineWidth();
if ( flags & (Style_Sunken|Style_Raised))
qDrawShadeRect( p, r.x(), r.y(), r.width(), r.height(), cg, flags & Style_Sunken, lwidth, mlwidth );
else
qDrawPlainRect( p, r.x(), r.y(), r.width(), r.height(), cg.foreground(), lwidth );
#endif
break; }
case PE_ProgressBarChunk:
p->fillRect( r.x(), r.y() + 3, r.width() -2, r.height() - 6,
cg.brush(TQColorGroup::Highlight));
break;
case PE_PanelLineEdit:
case PE_PanelTabWidget:
case PE_WindowFrame:
drawPrimitive( PE_Panel, p, ceData, elementFlags, r, cg, flags, opt );
break;
case PE_RubberBand:
drawPrimitive(PE_FocusRect, p, ceData, elementFlags, r, cg, flags, opt);
break;
default:
break;
}
activePainter = 0;
}
void qt_style_erase_region(TQPainter* p, const TQRegion& region, TQStyleControlElementData ceData) {
TQRegion reg = region;
TQPoint offset = ceData.bgOffset;
int ox = offset.x();
int oy = offset.y();
TQRegion origcr = p->clipRegion();
p->setClipRegion(region);
if (!ceData.bgPixmap.isNull()) {
p->drawTiledPixmap(0, 0, ceData.geometry.width(), ceData.geometry.height(), ceData.bgPixmap, ox, oy);
}
else {
p->fillRect(ceData.rect, ceData.bgColor);
}
p->setClipRegion(origcr);
return;
}
/*! \reimp */
void TQCommonStyle::drawControl( ControlElement element,
TQPainter *p,
TQStyleControlElementData ceData,
ControlElementFlags elementFlags,
const TQRect &r,
const TQColorGroup &cg,
SFlags flags,
const TQStyleOption& opt,
const TQWidget *widget ) const
{
activePainter = p;
switch (element) {
case CE_MenuBarEmptyArea: {
TQRegion reg;
if(p->hasClipping()) //ick
reg = p->clipRegion();
else
reg = r;
qt_style_erase_region(p, reg, ceData);
break; }
case CE_PushButton:
{
#ifndef QT_NO_PUSHBUTTON
TQRect br = r;
int dbi = pixelMetric(PM_ButtonDefaultIndicator, ceData, elementFlags, widget);
if ((elementFlags & CEF_IsDefault) || (elementFlags & CEF_AutoDefault)) {
if (elementFlags & CEF_IsDefault) {
drawPrimitive(PE_ButtonDefault, p, ceData, elementFlags, br, cg, flags);
}
br.setCoords(br.left() + dbi,
br.top() + dbi,
br.right() - dbi,
br.bottom() - dbi);
}
p->save();
p->setBrushOrigin( -ceData.bgOffset.x(),
-ceData.bgOffset.y() );
drawPrimitive(PE_ButtonCommand, p, ceData, elementFlags, br, cg, flags);
p->restore();
#endif
break;
}
case CE_PushButtonLabel:
{
#ifndef QT_NO_PUSHBUTTON
TQRect ir = r;
if ((elementFlags & CEF_IsDown) || (elementFlags & CEF_IsOn)) {
flags |= Style_Sunken;
ir.moveBy(pixelMetric(PM_ButtonShiftHorizontal, ceData, elementFlags, widget),
pixelMetric(PM_ButtonShiftVertical, ceData, elementFlags, widget));
}
if (elementFlags & CEF_IsMenuWidget) {
int mbi = pixelMetric(PM_MenuButtonIndicator, ceData, elementFlags, widget);
TQRect ar(ir.right() - mbi, ir.y() + 2, mbi - 4, ir.height() - 4);
drawPrimitive(PE_ArrowDown, p, ceData, elementFlags, ar, cg, flags, opt);
ir.setWidth(ir.width() - mbi);
}
int tf=AlignVCenter | ShowPrefix;
if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, TQStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, TQStyleOption::Default, 0, widget)) && (!acceleratorsShown())))
tf |= NoAccel;
#ifndef QT_NO_ICONSET
if ( !ceData.iconSet.isNull() ) {
TQIconSet::Mode mode =
(elementFlags & CEF_IsEnabled) ? TQIconSet::Normal : TQIconSet::Disabled;
if ( mode == TQIconSet::Normal && (elementFlags & CEF_HasFocus) )
mode = TQIconSet::Active;
TQIconSet::State state = TQIconSet::Off;
if ( (elementFlags & CEF_BiState) && (elementFlags & CEF_IsOn) )
state = TQIconSet::On;
TQPixmap pixmap = ceData.iconSet.pixmap( TQIconSet::Small, mode, state );
int pixw = pixmap.width();
int pixh = pixmap.height();
//Center the icon if there is neither text nor pixmap
if ( ceData.text.isEmpty() && ceData.fgPixmap.isNull() )
p->drawPixmap( ir.x() + ir.width() / 2 - pixw / 2, ir.y() + ir.height() / 2 - pixh / 2, pixmap );
else
p->drawPixmap( ir.x() + 2, ir.y() + ir.height() / 2 - pixh / 2, pixmap );
ir.moveBy(pixw + 4, 0);
ir.setWidth(ir.width() - (pixw + 4));
// left-align text if there is
if (!ceData.text.isEmpty())
tf |= AlignLeft;
else if (!ceData.fgPixmap.isNull())
tf |= AlignHCenter;
} else
#endif //QT_NO_ICONSET
tf |= AlignHCenter;
drawItem(p, ir, tf, cg,
flags & Style_Enabled, (ceData.fgPixmap.isNull())?NULL:&ceData.fgPixmap, ceData.text,
ceData.text.length(), &(cg.buttonText()) );
if (flags & Style_HasFocus)
drawPrimitive(PE_FocusRect, p, ceData, elementFlags, subRect(SR_PushButtonFocusRect, ceData, elementFlags, widget),
cg, flags);
#endif
break;
}
case CE_CheckBox:
drawPrimitive(PE_Indicator, p, ceData, elementFlags, r, cg, flags, opt);
break;
case CE_CheckBoxLabel:
{
#ifndef QT_NO_CHECKBOX
int alignment = TQApplication::reverseLayout() ? AlignRight : AlignLeft;
if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, TQStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, TQStyleOption::Default, 0, widget)) && (!acceleratorsShown())))
alignment |= NoAccel;
drawItem(p, r, alignment | AlignVCenter | ShowPrefix, cg,
flags & Style_Enabled, (ceData.fgPixmap.isNull())?NULL:&ceData.fgPixmap, ceData.text);
if (flags & Style_HasFocus) {
TQRect fr = visualRect(subRect(SR_CheckBoxFocusRect, ceData, elementFlags, widget), ceData, elementFlags);
drawPrimitive(PE_FocusRect, p, ceData, elementFlags, fr, cg, flags);
}
#endif
break;
}
case CE_RadioButton:
drawPrimitive(PE_ExclusiveIndicator, p, ceData, elementFlags, r, cg, flags, opt);
break;
case CE_RadioButtonLabel:
{
#ifndef QT_NO_RADIOBUTTON
int alignment = TQApplication::reverseLayout() ? AlignRight : AlignLeft;
if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, TQStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, TQStyleOption::Default, 0, widget)) && (!acceleratorsShown())))
alignment |= NoAccel;
drawItem(p, r, alignment | AlignVCenter | ShowPrefix, cg,
flags & Style_Enabled, (ceData.fgPixmap.isNull())?NULL:&ceData.fgPixmap, ceData.text);
if (flags & Style_HasFocus) {
TQRect fr = visualRect(subRect(SR_RadioButtonFocusRect, ceData, elementFlags, widget), ceData, elementFlags);
drawPrimitive(PE_FocusRect, p, ceData, elementFlags, fr, cg, flags);
}
#endif
break;
}
#ifndef QT_NO_TABBAR
case CE_TabBarTab:
{
if ( ceData.tabBarData.shape == TQTabBar::TriangularAbove ||
ceData.tabBarData.shape == TQTabBar::TriangularBelow ) {
// triangular, above or below
int y;
int x;
TQPointArray a( 10 );
a.setPoint( 0, 0, -1 );
a.setPoint( 1, 0, 0 );
y = r.height()-2;
x = y/3;
a.setPoint( 2, x++, y-1 );
a.setPoint( 3, x++, y );
a.setPoint( 3, x++, y++ );
a.setPoint( 4, x, y );
int i;
int right = r.width() - 1;
for ( i = 0; i < 5; i++ )
a.setPoint( 9-i, right - a.point( i ).x(), a.point( i ).y() );
if ( ceData.tabBarData.shape == TQTabBar::TriangularAbove )
for ( i = 0; i < 10; i++ )
a.setPoint( i, a.point(i).x(),
r.height() - 1 - a.point( i ).y() );
a.translate( r.left(), r.top() );
if ( flags & Style_Selected )
p->setBrush( cg.base() );
else
p->setBrush( cg.background() );
p->setPen( cg.foreground() );
p->drawPolygon( a );
p->setBrush( NoBrush );
}
break;
}
case CE_TabBarLabel:
{
if ( opt.isDefault() )
break;
TQTab * t = opt.tab();
TQRect tr = r;
if (elementFlags & CEF_IsActive)
tr.setBottom( tr.bottom() -
pixelMetric( TQStyle::PM_DefaultFrameWidth, ceData, elementFlags, widget ) );
int alignment = AlignCenter | ShowPrefix;
if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, TQStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, TQStyleOption::Default, 0, widget)) && (!acceleratorsShown())))
alignment |= NoAccel;
drawItem( p, tr, alignment, cg,
flags & Style_Enabled, 0, t->text() );
if ( (flags & Style_HasFocus) && !t->text().isEmpty() )
drawPrimitive( PE_FocusRect, p, ceData, elementFlags, r, cg );
break;
}
#endif // QT_NO_TABBAR
#ifndef QT_NO_TOOLBOX
case CE_ToolBoxTab:
{
int d = 20 + r.height() - 3;
TQPointArray a( 7 );
a.setPoint( 0, -1, r.height() + 1 );
a.setPoint( 1, -1, 1 );
a.setPoint( 2, r.width() - d, 1 );
a.setPoint( 3, r.width() - 20, r.height() - 2 );
a.setPoint( 4, r.width() - 1, r.height() - 2 );
a.setPoint( 5, r.width() - 1, r.height() + 1 );
a.setPoint( 6, -1, r.height() + 1 );
if ( flags & Style_Selected && !(elementFlags & CEF_IsContainerEmpty) )
p->setBrush( ceData.activeItemPaletteBgColor );
else
p->setBrush( cg.brush(TQColorGroup::Background) );
p->setPen( cg.mid().dark( 150 ) );
p->drawPolygon( a );
p->setPen( cg.light() );
p->drawLine( 0, 2, r.width() - d, 2 );
p->drawLine( r.width() - d - 1, 2, r.width() - 21, r.height() - 1 );
p->drawLine( r.width() - 20, r.height() - 1, r.width(), r.height() - 1 );
p->setBrush( NoBrush );
break;
}
#endif // QT_NO_TOOLBOX
case CE_ProgressBarGroove:
qDrawShadePanel(p, r, cg, TRUE, 1, &cg.brush(TQColorGroup::Background));
break;
#ifndef QT_NO_PROGRESSBAR
case CE_ProgressBarContents:
{
// Correct the highlight color if same as background,
// or else we cannot see the progress...
TQColorGroup cgh = cg;
if ( cgh.highlight() == cgh.background() )
cgh.setColor( TQColorGroup::Highlight, ceData.palette.active().highlight() );
bool reverse = TQApplication::reverseLayout();
int fw = 2;
int w = r.width() - 2*fw;
if ( !ceData.totalSteps ) {
// draw busy indicator
int x = ceData.currentStep % (w * 2);
if (x > w)
x = 2 * w - x;
x = reverse ? r.right() - x : x + r.x();
p->setPen( TQPen(cgh.highlight(), 4) );
p->drawLine(x, r.y() + 1, x, r.height() - fw);
} else {
const int unit_width = pixelMetric(PM_ProgressBarChunkWidth, ceData, elementFlags, widget);
int u;
if ( unit_width > 1 )
u = (r.width()+unit_width/3) / unit_width;
else
u = w / unit_width;
int p_v = ceData.currentStep;
int t_s = ceData.totalSteps ? ceData.totalSteps : 1;
if ( u > 0 && p_v >= INT_MAX / u && t_s >= u ) {
// scale down to something usable.
p_v /= u;
t_s /= u;
}
// nu < tnu, if last chunk is only a partial chunk
int tnu, nu;
tnu = nu = p_v * u / t_s;
if (nu * unit_width > w)
nu--;
// Draw nu units out of a possible u of unit_width
// width, each a rectangle bordered by background
// color, all in a sunken panel with a percentage text
// display at the end.
int x = 0;
int x0 = reverse ? r.right() - ((unit_width > 1) ?
unit_width : fw) : r.x() + fw;
for (int i=0; i<nu; i++) {
drawPrimitive( PE_ProgressBarChunk, p, ceData, elementFlags,
TQRect( x0+x, r.y(), unit_width, r.height() ),
cgh, Style_Default, opt );
x += reverse ? -unit_width: unit_width;
}
// Draw the last partial chunk to fill up the
// progressbar entirely
if (nu < tnu) {
int pixels_left = w - (nu*unit_width);
int offset = reverse ? x0+x+unit_width-pixels_left : x0+x;
drawPrimitive( PE_ProgressBarChunk, p, ceData, elementFlags,
TQRect( offset, r.y(), pixels_left,
r.height() ), cgh, Style_Default,
opt );
}
}
}
break;
case CE_ProgressBarLabel:
{
TQColor penColor = cg.highlightedText();
TQColor *pcolor = 0;
if ( (elementFlags & CEF_CenterIndicator) && !(elementFlags & CEF_IndicatorFollowsStyle) &&
ceData.currentStep*2 >= ceData.totalSteps )
pcolor = &penColor;
drawItem(p, r, AlignCenter | SingleLine, cg, flags & Style_Enabled, 0,
ceData.progressText, -1, pcolor );
}
break;
#endif // QT_NO_PROGRESSBAR
case CE_MenuBarItem:
{
#ifndef QT_NO_MENUDATA
if (opt.isDefault())
break;
TQMenuItem *mi = opt.menuItem();
int alignment = AlignCenter|ShowPrefix|DontClip|SingleLine;
if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, TQStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, TQStyleOption::Default, 0, widget)) && (!acceleratorsShown())))
alignment |= NoAccel;
drawItem( p, r, alignment, cg,
flags & Style_Enabled, mi->pixmap(), mi->text(), -1,
&cg.buttonText() );
#endif
break;
}
#ifndef QT_NO_TOOLBUTTON
case CE_ToolButtonLabel:
{
TQRect rect = r;
TQt::ArrowType arrowType = opt.isDefault()
? TQt::DownArrow : opt.arrowType();
int shiftX = 0;
int shiftY = 0;
if (flags & (Style_Down | Style_On)) {
shiftX = pixelMetric(PM_ButtonShiftHorizontal, ceData, elementFlags, widget);
shiftY = pixelMetric(PM_ButtonShiftVertical, ceData, elementFlags, widget);
}
if (!opt.isDefault()) {
PrimitiveElement pe;
switch (arrowType) {
case TQt::LeftArrow: pe = PE_ArrowLeft; break;
case TQt::RightArrow: pe = PE_ArrowRight; break;
case TQt::UpArrow: pe = PE_ArrowUp; break;
default:
case TQt::DownArrow: pe = PE_ArrowDown; break;
}
rect.moveBy(shiftX, shiftY);
drawPrimitive(pe, p, ceData, elementFlags, rect, cg, flags, opt);
} else {
TQColor btext = ceData.fgColor;
if (ceData.iconSet.isNull() &&
! ceData.text.isNull() &&
! (elementFlags & CEF_UsesTextLabel)) {
int alignment = AlignCenter | ShowPrefix;
if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, TQStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, TQStyleOption::Default, 0, widget)) && (!acceleratorsShown())))
alignment |= NoAccel;
rect.moveBy(shiftX, shiftY);
drawItem(p, rect, alignment, cg,
flags & Style_Enabled, 0, ceData.text,
ceData.text.length(), &btext);
} else {
TQPixmap pm;
TQIconSet::Size size =
(elementFlags & CEF_UsesBigPixmap) ? TQIconSet::Large : TQIconSet::Small;
TQIconSet::State state =
(elementFlags & CEF_IsOn) ? TQIconSet::On : TQIconSet::Off;
TQIconSet::Mode mode;
if (! (elementFlags & CEF_IsEnabled))
mode = TQIconSet::Disabled;
else if (flags & (Style_Down | Style_On) ||
((flags & Style_Raised) && (flags & Style_AutoRaise)))
mode = TQIconSet::Active;
else
mode = TQIconSet::Normal;
pm = ceData.iconSet.pixmap( size, mode, state );
if (elementFlags & CEF_UsesTextLabel) {
p->setFont( ceData.font );
TQRect pr = rect, tr = rect;
int alignment = ShowPrefix;
if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, TQStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, TQStyleOption::Default, 0, widget)) && (!acceleratorsShown())))
alignment |= NoAccel;
if ( ceData.toolButtonTextPosition == TQToolButton::Under ) {
int fh = p->fontMetrics().height();
pr.addCoords( 0, 1, 0, -fh-3 );
tr.addCoords( 0, pr.bottom(), 0, -3 );
pr.moveBy(shiftX, shiftY);
drawItem( p, pr, AlignCenter, cg, TRUE, &pm, TQString::null );
alignment |= AlignCenter;
} else {
pr.setWidth( pm.width() + 8 );
tr.addCoords( pr.right(), 0, 0, 0 );
pr.moveBy(shiftX, shiftY);
drawItem( p, pr, AlignCenter, cg, TRUE, &pm, TQString::null );
alignment |= AlignLeft | AlignVCenter;
}
tr.moveBy(shiftX, shiftY);
drawItem( p, tr, alignment, cg,
flags & Style_Enabled, 0, ceData.textLabel,
ceData.textLabel.length(), &btext);
} else {
rect.moveBy(shiftX, shiftY);
drawItem( p, rect, AlignCenter, cg, TRUE, &pm, TQString::null );
}
}
}
break;
}
#endif // QT_NO_TOOLBUTTON
#ifndef QT_NO_HEADER
case CE_HeaderLabel:
{
TQRect rect = r;
TQIconSet* icon = &ceData.iconSet;
if ( icon ) {
TQPixmap pixmap = icon->pixmap( TQIconSet::Small,
flags & Style_Enabled ?
TQIconSet::Normal : TQIconSet::Disabled );
int pixw = pixmap.width();
int pixh = pixmap.height();
// "pixh - 1" because of tricky integer division
TQRect pixRect = rect;
pixRect.setY( rect.center().y() - (pixh - 1) / 2 );
drawItem ( p, pixRect, AlignVCenter, cg, flags & Style_Enabled,
&pixmap, TQString::null );
if (TQApplication::reverseLayout())
rect.setRight(rect.right() - pixw - 2);
else
rect.setLeft(rect.left() + pixw + 2);
}
if (rect.isValid())
drawItem ( p, rect, AlignVCenter, cg, flags & Style_Enabled,
0, ceData.textLabel, -1, &(cg.buttonText()) );
}
#endif // QT_NO_HEADER
default:
break;
}
activePainter = 0;
}
/*! \reimp */
void TQCommonStyle::drawControlMask( ControlElement control,
TQPainter *p,
TQStyleControlElementData ceData,
ControlElementFlags elementFlags,
const TQRect &r,
const TQStyleOption& opt,
const TQWidget *widget ) const
{
Q_UNUSED(ceData);
Q_UNUSED(elementFlags);
Q_UNUSED(widget);
activePainter = p;
TQColorGroup cg(color1,color1,color1,color1,color1,color1,color1,color1,color0);
switch (control) {
case CE_PushButton:
drawPrimitive(PE_ButtonCommand, p, ceData, elementFlags, r, cg, Style_Default, opt);
break;
case CE_CheckBox:
drawPrimitive(PE_IndicatorMask, p, ceData, elementFlags, r, cg, Style_Default, opt);
break;
case CE_RadioButton:
drawPrimitive(PE_ExclusiveIndicatorMask, p, ceData, elementFlags, r, cg, Style_Default, opt);
break;
default:
p->fillRect(r, color1);
break;
}
activePainter = 0;
}
/*! \reimp */
TQRect TQCommonStyle::subRect(SubRect r, const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQWidget *widget) const
{
TQRect rect, wrect(ceData.rect);
switch (r) {
#ifndef QT_NO_DIALOGBUTTONS
case SR_DialogButtonAbort:
case SR_DialogButtonRetry:
case SR_DialogButtonIgnore:
case SR_DialogButtonAccept:
case SR_DialogButtonReject:
case SR_DialogButtonApply:
case SR_DialogButtonHelp:
case SR_DialogButtonAll:
case SR_DialogButtonCustom: {
TQDialogButtons::Button srch = TQDialogButtons::None;
if(r == SR_DialogButtonAccept)
srch = TQDialogButtons::Accept;
else if(r == SR_DialogButtonReject)
srch = TQDialogButtons::Reject;
else if(r == SR_DialogButtonAll)
srch = TQDialogButtons::All;
else if(r == SR_DialogButtonApply)
srch = TQDialogButtons::Apply;
else if(r == SR_DialogButtonHelp)
srch = TQDialogButtons::Help;
else if(r == SR_DialogButtonRetry)
srch = TQDialogButtons::Retry;
else if(r == SR_DialogButtonIgnore)
srch = TQDialogButtons::Ignore;
else if(r == SR_DialogButtonAbort)
srch = TQDialogButtons::Abort;
const int bwidth = pixelMetric(PM_DialogButtonsButtonWidth, ceData, elementFlags, widget),
bheight = pixelMetric(PM_DialogButtonsButtonHeight, ceData, elementFlags, widget),
bspace = pixelMetric(PM_DialogButtonsSeparator, ceData, elementFlags, widget),
fw = pixelMetric(PM_DefaultFrameWidth, ceData, elementFlags, widget);
int start = fw;
if(ceData.orientation == Horizontal)
start = wrect.right() - fw;
TQDialogButtons::Button btns[] = { TQDialogButtons::All, TQDialogButtons::Reject, TQDialogButtons::Accept, //reverse order (right to left)
TQDialogButtons::Apply, TQDialogButtons::Retry, TQDialogButtons::Ignore, TQDialogButtons::Abort,
TQDialogButtons::Help };
for(unsigned int i = 0, cnt = 0; i < (sizeof(btns)/sizeof(btns[0])); i++) {
if (ceData.dlgVisibleButtons & btns[i]) {
TQSize szH = ceData.dlgVisibleSizeHints[btns[i]];
int mwidth = TQMAX(bwidth, szH.width()), mheight = TQMAX(bheight, szH.height());
if(ceData.orientation == Horizontal) {
start -= mwidth;
if(cnt)
start -= bspace;
} else if(cnt) {
start += mheight;
start += bspace;
}
cnt++;
if(btns[i] == srch) {
if(ceData.orientation == Horizontal)
return TQRect(start, wrect.bottom() - fw - mheight, mwidth, mheight);
else
return TQRect(fw, start, mwidth, mheight);
}
}
}
if(r == SR_DialogButtonCustom) {
if(ceData.orientation == Horizontal)
return TQRect(fw, fw, start - fw - bspace, wrect.height() - (fw*2));
else
return TQRect(fw, start, wrect.width() - (fw*2), wrect.height() - start - (fw*2));
}
return TQRect(); }
#endif //QT_NO_DIALOGBUTTONS
case SR_PushButtonContents:
{
#ifndef QT_NO_PUSHBUTTON
int dx1, dx2;
dx1 = pixelMetric(PM_DefaultFrameWidth, ceData, elementFlags, widget);
if ((elementFlags & CEF_IsDefault) || (elementFlags & CEF_AutoDefault))
dx1 += pixelMetric(PM_ButtonDefaultIndicator, ceData, elementFlags, widget);
dx2 = dx1 * 2;
rect.setRect(wrect.x() + dx1,
wrect.y() + dx1,
wrect.width() - dx2,
wrect.height() - dx2);
#endif
break;
}
case SR_PushButtonFocusRect:
{
#ifndef QT_NO_PUSHBUTTON
int dbw1 = 0, dbw2 = 0;
if ((elementFlags & CEF_IsDefault) || (elementFlags & CEF_AutoDefault)) {
dbw1 = pixelMetric(PM_ButtonDefaultIndicator, ceData, elementFlags, widget);
dbw2 = dbw1 * 2;
}
int dfw1 = pixelMetric(PM_DefaultFrameWidth, ceData, elementFlags, widget) * 2,
dfw2 = dfw1 * 2;
rect.setRect(wrect.x() + dfw1 + dbw1,
wrect.y() + dfw1 + dbw1,
wrect.width() - dfw2 - dbw2,
wrect.height() - dfw2 - dbw2);
#endif
break;
}
case SR_CheckBoxIndicator:
{
int h = pixelMetric( PM_IndicatorHeight, ceData, elementFlags, widget );
rect.setRect(0, ( wrect.height() - h ) / 2,
pixelMetric( PM_IndicatorWidth, ceData, elementFlags, widget ), h );
break;
}
case SR_CheckBoxContents:
{
#ifndef QT_NO_CHECKBOX
TQRect ir = subRect(SR_CheckBoxIndicator, ceData, elementFlags, widget);
rect.setRect(ir.right() + 6, wrect.y(),
wrect.width() - ir.width() - 6, wrect.height());
#endif
break;
}
case SR_CheckBoxFocusRect:
{
#ifndef QT_NO_CHECKBOX
if ( ceData.fgPixmap.isNull() && ceData.text.isEmpty() ) {
rect = subRect( SR_CheckBoxIndicator, ceData, elementFlags, widget );
rect.addCoords( 1, 1, -1, -1 );
break;
}
TQRect cr = subRect(SR_CheckBoxContents, ceData, elementFlags, widget);
// don't create a painter if we have an active one
TQPainter *p = 0;
if (! activePainter)
p = new TQPainter(widget);
rect = itemRect((activePainter ? activePainter : p),
cr, AlignLeft | AlignVCenter | ShowPrefix,
(elementFlags & CEF_IsEnabled),
(ceData.fgPixmap.isNull())?NULL:&ceData.fgPixmap,
ceData.text);
delete p;
rect.addCoords( -3, -2, 3, 2 );
rect = rect.intersect(wrect);
#endif
break;
}
case SR_RadioButtonIndicator:
{
int h = pixelMetric( PM_ExclusiveIndicatorHeight, ceData, elementFlags, widget );
rect.setRect(0, ( wrect.height() - h ) / 2,
pixelMetric( PM_ExclusiveIndicatorWidth, ceData, elementFlags, widget ), h );
break;
}
case SR_RadioButtonContents:
{
TQRect ir = subRect(SR_RadioButtonIndicator, ceData, elementFlags, widget);
rect.setRect(ir.right() + 6, wrect.y(),
wrect.width() - ir.width() - 6, wrect.height());
break;
}
case SR_RadioButtonFocusRect:
{
#ifndef QT_NO_RADIOBUTTON
if ( ceData.fgPixmap.isNull() && ceData.text.isEmpty() ) {
rect = subRect( SR_RadioButtonIndicator, ceData, elementFlags, widget );
rect.addCoords( 1, 1, -1, -1 );
break;
}
TQRect cr = subRect(SR_RadioButtonContents, ceData, elementFlags, widget);
// don't create a painter if we have an active one
TQPainter *p = 0;
if (! activePainter)
p = new TQPainter(widget);
rect = itemRect((activePainter ? activePainter : p),
cr, AlignLeft | AlignVCenter | ShowPrefix,
(elementFlags & CEF_IsEnabled),
(ceData.fgPixmap.isNull())?NULL:&ceData.fgPixmap,
ceData.text);
delete p;
rect.addCoords( -3, -2, 3, 2 );
rect = rect.intersect(wrect);
#endif
break;
}
case SR_ComboBoxFocusRect:
rect.setRect(3, 3, ceData.rect.width()-6-16, ceData.rect.height()-6);
break;
#ifndef QT_NO_SLIDER
case SR_SliderFocusRect:
{
int tickOffset = pixelMetric( PM_SliderTickmarkOffset, ceData, elementFlags, widget );
int thickness = pixelMetric( PM_SliderControlThickness, ceData, elementFlags, widget );
if ( ceData.orientation == Horizontal )
rect.setRect( 0, tickOffset-1, ceData.rect.width(), thickness+2 );
else
rect.setRect( tickOffset-1, 0, thickness+2, ceData.rect.height() );
rect = rect.intersect( ceData.rect ); // ## is this really necessary?
break;
}
#endif // QT_NO_SLIDER
#ifndef QT_NO_MAINWINDOW
case SR_DockWindowHandleRect:
{
if (!(elementFlags & CEF_HasParentWidget))
break;
if ( !ceData.dwData.hasDockArea || !ceData.dwData.closeEnabled )
rect.setRect( 0, 0, ceData.rect.width(), ceData.rect.height() );
else {
if ( ceData.dwData.areaOrientation == Horizontal )
rect.setRect(0, 15, ceData.rect.width(), ceData.rect.height() - 15);
else
rect.setRect(0, 1, ceData.rect.width() - 15, ceData.rect.height() - 1);
}
break;
}
#endif // QT_NO_MAINWINDOW
case SR_ProgressBarGroove:
case SR_ProgressBarContents:
{
#ifndef QT_NO_PROGRESSBAR
TQFontMetrics fm( ( (!(elementFlags & CEF_UseGenericParameters)) ? TQFontMetrics(ceData.font) :
TQApplication::fontMetrics() ) );
int textw = 0;
if (ceData.percentageVisible)
textw = fm.width("100%") + 6;
if ((elementFlags & CEF_IndicatorFollowsStyle) ||
! (elementFlags & CEF_CenterIndicator))
rect.setCoords(wrect.left(), wrect.top(),
wrect.right() - textw, wrect.bottom());
else
rect = wrect;
#endif
break;
}
case SR_ProgressBarLabel:
{
#ifndef QT_NO_PROGRESSBAR
TQFontMetrics fm( ( (!(elementFlags & CEF_UseGenericParameters)) ? TQFontMetrics(ceData.font) :
TQApplication::fontMetrics() ) );
int textw = 0;
if (ceData.percentageVisible)
textw = fm.width("100%") + 6;
if ((elementFlags & CEF_IndicatorFollowsStyle) ||
! (elementFlags & CEF_CenterIndicator))
rect.setCoords(wrect.right() - textw, wrect.top(),
wrect.right(), wrect.bottom());
else
rect = wrect;
#endif
break;
}
case SR_ToolButtonContents:
rect = querySubControlMetrics(CC_ToolButton, ceData, elementFlags, SC_ToolButton, TQStyleOption::Default, widget);
break;
case SR_ToolBoxTabContents:
rect = wrect;
rect.addCoords( 0, 0, -30, 0 );
break;
default:
rect = wrect;
break;
}
return rect;
}
#ifndef QT_NO_RANGECONTROL
/*
I really need this and I don't want to expose it in TQRangeControl..
*/
static int qPositionFromValue( TQStyleControlElementData ceData, int logical_val,
int span )
{
if ( span <= 0 || logical_val < ceData.minSteps ||
ceData.maxSteps <= ceData.minSteps )
return 0;
if ( logical_val > ceData.maxSteps )
return span;
uint range = ceData.maxSteps - ceData.minSteps;
uint p = logical_val - ceData.minSteps;
if ( range > (uint)INT_MAX/4096 ) {
const int scale = 4096*2;
return ( (p/scale) * span ) / (range/scale);
// ### the above line is probably not 100% correct
// ### but fixing it isn't worth the extreme pain...
} else if ( range > (uint)span ) {
return (2*p*span + range) / (2*range);
} else {
uint div = span / range;
uint mod = span % range;
return p*div + (2*p*mod + range) / (2*range);
}
//equiv. to (p*span)/range + 0.5
// no overflow because of this implicit assumption:
// span <= 4096
}
#endif // QT_NO_RANGECONTROL
/*! \reimp */
void TQCommonStyle::drawComplexControl( ComplexControl control,
TQPainter *p,
TQStyleControlElementData ceData,
ControlElementFlags elementFlags,
const TQRect &r,
const TQColorGroup &cg,
SFlags flags,
SCFlags controls,
SCFlags active,
const TQStyleOption& opt,
const TQWidget *widget ) const
{
activePainter = p;
switch (control) {
#ifndef QT_NO_SCROLLBAR
case CC_ScrollBar:
{
TQRect addline, subline, addpage, subpage, slider, first, last;
bool maxedOut = (ceData.minSteps == ceData.maxSteps);
subline = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarSubLine, opt, widget);
addline = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarAddLine, opt, widget);
subpage = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarSubPage, opt, widget);
addpage = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarAddPage, opt, widget);
slider = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarSlider, opt, widget);
first = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarFirst, opt, widget);
last = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarLast, opt, widget);
if ((controls & SC_ScrollBarSubLine) && subline.isValid())
drawPrimitive(PE_ScrollBarSubLine, p, ceData, elementFlags, subline, cg,
((maxedOut) ? Style_Default : Style_Enabled) |
((active == SC_ScrollBarSubLine) ?
Style_Down : Style_Default) |
((ceData.orientation == TQt::Horizontal) ?
Style_Horizontal : 0));
if ((controls & SC_ScrollBarAddLine) && addline.isValid())
drawPrimitive(PE_ScrollBarAddLine, p, ceData, elementFlags, addline, cg,
((maxedOut) ? Style_Default : Style_Enabled) |
((active == SC_ScrollBarAddLine) ?
Style_Down : Style_Default) |
((ceData.orientation == TQt::Horizontal) ?
Style_Horizontal : 0));
if ((controls & SC_ScrollBarSubPage) && subpage.isValid())
drawPrimitive(PE_ScrollBarSubPage, p, ceData, elementFlags, subpage, cg,
((maxedOut) ? Style_Default : Style_Enabled) |
((active == SC_ScrollBarSubPage) ?
Style_Down : Style_Default) |
((ceData.orientation == TQt::Horizontal) ?
Style_Horizontal : 0));
if ((controls & SC_ScrollBarAddPage) && addpage.isValid())
drawPrimitive(PE_ScrollBarAddPage, p, ceData, elementFlags, addpage, cg,
((maxedOut) ? Style_Default : Style_Enabled) |
((active == SC_ScrollBarAddPage) ?
Style_Down : Style_Default) |
((ceData.orientation == TQt::Horizontal) ?
Style_Horizontal : 0));
if ((controls & SC_ScrollBarFirst) && first.isValid())
drawPrimitive(PE_ScrollBarFirst, p, ceData, elementFlags, first, cg,
((maxedOut) ? Style_Default : Style_Enabled) |
((active == SC_ScrollBarFirst) ?
Style_Down : Style_Default) |
((ceData.orientation == TQt::Horizontal) ?
Style_Horizontal : 0));
if ((controls & SC_ScrollBarLast) && last.isValid())
drawPrimitive(PE_ScrollBarLast, p, ceData, elementFlags, last, cg,
((maxedOut) ? Style_Default : Style_Enabled) |
((active == SC_ScrollBarLast) ?
Style_Down : Style_Default) |
((ceData.orientation == TQt::Horizontal) ?
Style_Horizontal : 0));
if ((controls & SC_ScrollBarSlider) && slider.isValid()) {
drawPrimitive(PE_ScrollBarSlider, p, ceData, elementFlags, slider, cg,
((maxedOut) ? Style_Default : Style_Enabled) |
((active == SC_ScrollBarSlider) ?
Style_Down : Style_Default) |
((ceData.orientation == TQt::Horizontal) ?
Style_Horizontal : 0));
// ### perhaps this should not be able to accept focus if maxedOut?
if (elementFlags & CEF_HasFocus) {
TQRect fr(slider.x() + 2, slider.y() + 2,
slider.width() - 5, slider.height() - 5);
drawPrimitive(PE_FocusRect, p, ceData, elementFlags, fr, cg, Style_Default);
}
}
break;
}
#endif // QT_NO_SCROLLBAR
#ifndef QT_NO_TOOLBUTTON
case CC_ToolButton:
{
TQColorGroup c = cg;
if ( ceData.backgroundMode != PaletteButton )
c.setBrush( TQColorGroup::Button,
ceData.bgColor );
TQRect button, menuarea;
button = visualRect( querySubControlMetrics(control, ceData, elementFlags, SC_ToolButton, opt, widget), ceData, elementFlags );
menuarea = visualRect( querySubControlMetrics(control, ceData, elementFlags, SC_ToolButtonMenu, opt, widget), ceData, elementFlags );
SFlags bflags = flags,
mflags = flags;
if (active & SC_ToolButton)
bflags |= Style_Down;
if (active & SC_ToolButtonMenu)
mflags |= Style_Down;
if (controls & SC_ToolButton) {
if (bflags & (Style_Down | Style_On | Style_Raised)) {
drawPrimitive(PE_ButtonTool, p, ceData, elementFlags, button, c, bflags, opt);
} else if ( (elementFlags & CEF_HasParentWidget) &&
! ceData.parentWidgetData.bgPixmap.isNull() ) {
TQPixmap pixmap =
ceData.parentWidgetData.bgPixmap;
p->drawTiledPixmap( r, pixmap, ceData.pos );
}
}
if (controls & SC_ToolButtonMenu) {
if (mflags & (Style_Down | Style_On | Style_Raised))
drawPrimitive(PE_ButtonDropDown, p, ceData, elementFlags, menuarea, c, mflags, opt);
drawPrimitive(PE_ArrowDown, p, ceData, elementFlags, menuarea, c, mflags, opt);
}
if ((elementFlags & CEF_HasFocus) && !(elementFlags & CEF_HasFocusProxy)) {
TQRect fr = ceData.rect;
fr.addCoords(3, 3, -3, -3);
drawPrimitive(PE_FocusRect, p, ceData, elementFlags, fr, c);
}
break;
}
#endif // QT_NO_TOOLBUTTON
#ifndef QT_NO_TITLEBAR
case CC_TitleBar:
{
if ( controls & SC_TitleBarLabel ) {
TQColorGroup cgroup = (ceData.titleBarData.usesActiveColor) ?
ceData.palette.active() : ceData.palette.inactive();
TQColor left = cgroup.highlight();
TQColor right = cgroup.base();
if ( left != right ) {
double rS = left.red();
double gS = left.green();
double bS = left.blue();
const double rD = double(right.red() - rS) / ceData.rect.width();
const double gD = double(right.green() - gS) / ceData.rect.width();
const double bD = double(right.blue() - bS) / ceData.rect.width();
const int w = ceData.rect.width();
for ( int sx = 0; sx < w; sx++ ) {
rS+=rD;
gS+=gD;
bS+=bD;
p->setPen( TQColor( (int)rS, (int)gS, (int)bS ) );
p->drawLine( sx, 0, sx, ceData.rect.height() );
}
} else {
p->fillRect( ceData.rect, left );
}
TQRect ir = visualRect( querySubControlMetrics( CC_TitleBar, ceData, elementFlags, SC_TitleBarLabel, TQStyleOption::Default, widget ), ceData, elementFlags );
p->setPen( cgroup.highlightedText() );
p->drawText(ir.x()+2, ir.y(), ir.width()-2, ir.height(),
AlignAuto | AlignVCenter | SingleLine, ceData.titleBarData.visibleText );
}
TQRect ir;
bool down = FALSE;
TQPixmap pm;
if ( controls & SC_TitleBarCloseButton ) {
ir = visualRect( querySubControlMetrics( CC_TitleBar, ceData, elementFlags, SC_TitleBarCloseButton, TQStyleOption::Default, widget ), ceData, elementFlags );
down = active & SC_TitleBarCloseButton;
if ( widget->testWFlags( WStyle_Tool )
#ifndef QT_NO_MAINWINDOW
|| ::tqt_cast<TQDockWindow*>(widget)
#endif
)
pm = stylePixmap(SP_DockWindowCloseButton, ceData, elementFlags, TQStyleOption::Default, widget);
else
pm = stylePixmap(SP_TitleBarCloseButton, ceData, elementFlags, TQStyleOption::Default, widget);
drawPrimitive(PE_ButtonTool, p, ceData, elementFlags, ir, ceData.colorGroup,
down ? Style_Down : Style_Raised);
p->save();
if( down )
p->translate( pixelMetric(PM_ButtonShiftHorizontal, ceData, elementFlags, widget),
pixelMetric(PM_ButtonShiftVertical, ceData, elementFlags, widget) );
drawItem( p, ir, AlignCenter, ceData.colorGroup, TRUE, &pm, TQString::null );
p->restore();
}
if ( ceData.titleBarData.hasWindow ) {
if ( controls & SC_TitleBarMaxButton ) {
ir = visualRect( querySubControlMetrics( CC_TitleBar, ceData, elementFlags, SC_TitleBarMaxButton, TQStyleOption::Default, widget ), ceData, elementFlags );
down = active & SC_TitleBarMaxButton;
pm = TQPixmap(stylePixmap(SP_TitleBarMaxButton, ceData, elementFlags, TQStyleOption::Default, widget));
drawPrimitive(PE_ButtonTool, p, ceData, elementFlags, ir, ceData.colorGroup,
down ? Style_Down : Style_Raised);
p->save();
if( down )
p->translate( pixelMetric(PM_ButtonShiftHorizontal, ceData, elementFlags, widget),
pixelMetric(PM_ButtonShiftVertical, ceData, elementFlags, widget) );
drawItem( p, ir, AlignCenter, ceData.colorGroup, TRUE, &pm, TQString::null );
p->restore();
}
if ( controls & SC_TitleBarNormalButton || controls & SC_TitleBarMinButton ) {
ir = visualRect( querySubControlMetrics( CC_TitleBar, ceData, elementFlags, SC_TitleBarMinButton, TQStyleOption::Default, widget ), ceData, elementFlags );
TQStyle::SubControl ctrl = (controls & SC_TitleBarNormalButton ?
SC_TitleBarNormalButton :
SC_TitleBarMinButton);
TQStyle::StylePixmap spixmap = (controls & SC_TitleBarNormalButton ?
SP_TitleBarNormalButton :
SP_TitleBarMinButton);
down = active & ctrl;
pm = TQPixmap(stylePixmap(spixmap, ceData, elementFlags, TQStyleOption::Default, widget));
drawPrimitive(PE_ButtonTool, p, ceData, elementFlags, ir, ceData.colorGroup,
down ? Style_Down : Style_Raised);
p->save();
if( down )
p->translate( pixelMetric(PM_ButtonShiftHorizontal, ceData, elementFlags, widget),
pixelMetric(PM_ButtonShiftVertical, ceData, elementFlags, widget) );
drawItem( p, ir, AlignCenter, ceData.colorGroup, TRUE, &pm, TQString::null );
p->restore();
}
if ( controls & SC_TitleBarShadeButton ) {
ir = visualRect( querySubControlMetrics( CC_TitleBar, ceData, elementFlags, SC_TitleBarShadeButton, TQStyleOption::Default, widget ), ceData, elementFlags );
down = active & SC_TitleBarShadeButton;
pm = TQPixmap(stylePixmap(SP_TitleBarShadeButton, ceData, elementFlags, TQStyleOption::Default, widget));
drawPrimitive(PE_ButtonTool, p, ceData, elementFlags, ir, ceData.colorGroup,
down ? Style_Down : Style_Raised);
p->save();
if( down )
p->translate( pixelMetric(PM_ButtonShiftHorizontal, ceData, elementFlags, widget),
pixelMetric(PM_ButtonShiftVertical, ceData, elementFlags, widget) );
drawItem( p, ir, AlignCenter, ceData.colorGroup, TRUE, &pm, TQString::null );
p->restore();
}
if ( controls & SC_TitleBarUnshadeButton ) {
ir = visualRect( querySubControlMetrics( CC_TitleBar, ceData, elementFlags, SC_TitleBarUnshadeButton, TQStyleOption::Default, widget ), ceData, elementFlags );
down = active & SC_TitleBarUnshadeButton;
pm = TQPixmap(stylePixmap(SP_TitleBarUnshadeButton, ceData, elementFlags, TQStyleOption::Default, widget));
drawPrimitive(PE_ButtonTool, p, ceData, elementFlags, ir, ceData.colorGroup,
down ? Style_Down : Style_Raised);
p->save();
if( down )
p->translate( pixelMetric(PM_ButtonShiftHorizontal, ceData, elementFlags, widget),
pixelMetric(PM_ButtonShiftVertical, ceData, elementFlags, widget) );
drawItem( p, ir, AlignCenter, ceData.colorGroup, TRUE, &pm, TQString::null );
p->restore();
}
}
#ifndef QT_NO_WIDGET_TOPEXTRA
if ( controls & SC_TitleBarSysMenu ) {
if ( !ceData.icon.isNull() ) {
ir = visualRect( querySubControlMetrics( CC_TitleBar, ceData, elementFlags, SC_TitleBarSysMenu, TQStyleOption::Default, widget ), ceData, elementFlags );
drawItem( p, ir, AlignCenter, ceData.colorGroup, TRUE, (ceData.icon.isNull())?NULL:&ceData.icon, TQString::null );
}
}
#endif
break;
}
#endif //QT_NO_TITLEBAR
case CC_SpinWidget: {
#ifndef QT_NO_SPINWIDGET
SFlags flags;
PrimitiveElement pe;
if ( controls & SC_SpinWidgetFrame )
qDrawWinPanel( p, r, cg, TRUE ); //cstyle == Sunken );
if ( controls & SC_SpinWidgetUp ) {
flags = Style_Default | Style_Enabled;
if (active == SC_SpinWidgetUp ) {
flags |= Style_On;
flags |= Style_Sunken;
} else
flags |= Style_Raised;
if ( ceData.spinWidgetData.buttonSymbols == TQSpinWidget::PlusMinus )
pe = PE_SpinWidgetPlus;
else
pe = PE_SpinWidgetUp;
TQRect re = ceData.spinWidgetData.upRect;
TQColorGroup ucg = ceData.spinWidgetData.upEnabled ? cg : ceData.palette.disabled();
drawPrimitive(PE_ButtonBevel, p, ceData, elementFlags, re, ucg, flags);
drawPrimitive(pe, p, ceData, elementFlags, re, ucg, flags);
}
if ( controls & SC_SpinWidgetDown ) {
flags = Style_Default | Style_Enabled;
if (active == SC_SpinWidgetDown ) {
flags |= Style_On;
flags |= Style_Sunken;
} else
flags |= Style_Raised;
if ( ceData.spinWidgetData.buttonSymbols == TQSpinWidget::PlusMinus )
pe = PE_SpinWidgetMinus;
else
pe = PE_SpinWidgetDown;
TQRect re = ceData.spinWidgetData.downRect;
TQColorGroup dcg = ceData.spinWidgetData.downEnabled ? cg : ceData.palette.disabled();
drawPrimitive(PE_ButtonBevel, p, ceData, elementFlags, re, dcg, flags);
drawPrimitive(pe, p, ceData, elementFlags, re, dcg, flags);
}
#endif
break; }
#ifndef QT_NO_SLIDER
case CC_Slider:
switch ( controls ) {
case SC_SliderTickmarks: {
int tickOffset = pixelMetric( PM_SliderTickmarkOffset, ceData, elementFlags, widget );
int ticks = ceData.tickMarkSetting;
int thickness = pixelMetric( PM_SliderControlThickness, ceData, elementFlags, widget );
int len = pixelMetric( PM_SliderLength, ceData, elementFlags, widget );
int available = pixelMetric( PM_SliderSpaceAvailable, ceData, elementFlags, widget );
int interval = ceData.tickInterval;
if ( interval <= 0 ) {
interval = ceData.lineStep;
if ( qPositionFromValue( ceData, interval, available ) -
qPositionFromValue( ceData, 0, available ) < 3 )
interval = ceData.pageStep;
}
int fudge = len / 2;
int pos;
if ( ticks & TQSlider::Above ) {
p->setPen( cg.foreground() );
int v = ceData.minSteps;
if ( !interval )
interval = 1;
while ( v <= ceData.maxSteps + 1 ) {
pos = qPositionFromValue( ceData, v, available ) + fudge;
if ( ceData.orientation == Horizontal )
p->drawLine( pos, 0, pos, tickOffset-2 );
else
p->drawLine( 0, pos, tickOffset-2, pos );
v += interval;
}
}
if ( ticks & TQSlider::Below ) {
p->setPen( cg.foreground() );
int v = ceData.minSteps;
if ( !interval )
interval = 1;
while ( v <= ceData.maxSteps + 1 ) {
pos = qPositionFromValue( ceData, v, available ) + fudge;
if ( ceData.orientation == Horizontal )
p->drawLine( pos, tickOffset+thickness+1, pos,
tickOffset+thickness+1 + available-2 );
else
p->drawLine( tickOffset+thickness+1, pos,
tickOffset+thickness+1 + available-2,
pos );
v += interval;
}
}
break; }
}
break;
#endif // QT_NO_SLIDER
#ifndef QT_NO_LISTVIEW
case CC_ListView:
if ( controls & SC_ListView ) {
p->fillRect( r, ceData.viewportData.bgBrush );
}
break;
#endif //QT_NO_LISTVIEW
default:
break;
}
activePainter = 0;
}
/*! \reimp */
void TQCommonStyle::drawComplexControlMask( ComplexControl control,
TQPainter *p,
const TQStyleControlElementData ceData,
const ControlElementFlags elementFlags,
const TQRect &r,
const TQStyleOption& opt,
const TQWidget *widget ) const
{
Q_UNUSED(control);
Q_UNUSED(ceData);
Q_UNUSED(elementFlags);
Q_UNUSED(widget);
Q_UNUSED(opt);
p->fillRect(r, color1);
}
/*! \reimp */
TQRect TQCommonStyle::querySubControlMetrics( ComplexControl control,
TQStyleControlElementData ceData,
ControlElementFlags elementFlags,
SubControl sc,
const TQStyleOption &opt,
const TQWidget *widget ) const
{
switch ( control ) {
case CC_SpinWidget: {
int fw = pixelMetric( PM_SpinBoxFrameWidth, ceData, elementFlags, widget);
TQSize bs;
bs.setHeight( ceData.rect.height()/2 - fw );
if ( bs.height() < 8 )
bs.setHeight( 8 );
bs.setWidth( TQMIN( bs.height() * 8 / 5, ceData.rect.width() / 4 ) ); // 1.6 -approximate golden mean
bs = bs.expandedTo( TQApplication::globalStrut() );
int y = fw;
int x, lx, rx;
x = ceData.rect.width() - y - bs.width();
lx = fw;
rx = x - fw;
switch ( sc ) {
case SC_SpinWidgetUp:
return TQRect(x, y, bs.width(), bs.height());
case SC_SpinWidgetDown:
return TQRect(x, y + bs.height(), bs.width(), bs.height());
case SC_SpinWidgetButtonField:
return TQRect(x, y, bs.width(), ceData.rect.height() - 2*fw);
case SC_SpinWidgetEditField:
return TQRect(lx, fw, rx, ceData.rect.height() - 2*fw);
case SC_SpinWidgetFrame:
return ceData.rect;
default:
break;
}
break; }
case CC_ComboBox: {
int x = 0, y = 0, wi = ceData.rect.width(), he = ceData.rect.height();
int xpos = x;
xpos += wi - 2 - 16;
switch ( sc ) {
case SC_ComboBoxFrame:
return ceData.rect;
case SC_ComboBoxArrow:
return TQRect(xpos, y+2, 16, he-4);
case SC_ComboBoxEditField:
return TQRect(x+3, y+3, wi-6-16, he-6);
case SC_ComboBoxListBoxPopup:
return opt.rect();
default:
break;
}
break; }
#ifndef QT_NO_SCROLLBAR
case CC_ScrollBar: {
int sliderstart = 0;
int sbextent = pixelMetric(PM_ScrollBarExtent, ceData, elementFlags, widget);
int maxlen = ((ceData.orientation == TQt::Horizontal) ?
ceData.rect.width() : ceData.rect.height()) - (sbextent * 2);
int sliderlen;
sliderstart = ceData.startStep;
// calculate slider length
if (ceData.maxSteps != ceData.minSteps) {
uint range = ceData.maxSteps - ceData.minSteps;
sliderlen = (TQ_LLONG(ceData.pageStep) * maxlen) / (range + ceData.pageStep);
int slidermin = pixelMetric( PM_ScrollBarSliderMin, ceData, elementFlags, widget );
if ( sliderlen < slidermin || range > INT_MAX / 2 )
sliderlen = slidermin;
if ( sliderlen > maxlen )
sliderlen = maxlen;
} else
sliderlen = maxlen;
switch (sc) {
case SC_ScrollBarSubLine: // top/left button
if (ceData.orientation == TQt::Horizontal) {
int buttonWidth = TQMIN(ceData.rect.width()/2, sbextent);
return TQRect( 0, 0, buttonWidth, sbextent );
} else {
int buttonHeight = TQMIN(ceData.rect.height()/2, sbextent);
return TQRect( 0, 0, sbextent, buttonHeight );
}
case SC_ScrollBarAddLine: // bottom/right button
if (ceData.orientation == TQt::Horizontal) {
int buttonWidth = TQMIN(ceData.rect.width()/2, sbextent);
return TQRect( ceData.rect.width() - buttonWidth, 0, buttonWidth, sbextent );
} else {
int buttonHeight = TQMIN(ceData.rect.height()/2, sbextent);
return TQRect( 0, ceData.rect.height() - buttonHeight, sbextent, buttonHeight );
}
case SC_ScrollBarSubPage: // between top/left button and slider
if (ceData.orientation == TQt::Horizontal)
return TQRect(sbextent, 0, sliderstart - sbextent, sbextent);
return TQRect(0, sbextent, sbextent, sliderstart - sbextent);
case SC_ScrollBarAddPage: // between bottom/right button and slider
if (ceData.orientation == TQt::Horizontal)
return TQRect(sliderstart + sliderlen, 0,
maxlen - sliderstart - sliderlen + sbextent, sbextent);
return TQRect(0, sliderstart + sliderlen,
sbextent, maxlen - sliderstart - sliderlen + sbextent);
case SC_ScrollBarGroove:
if (ceData.orientation == TQt::Horizontal)
return TQRect(sbextent, 0, ceData.rect.width() - sbextent * 2,
ceData.rect.height());
return TQRect(0, sbextent, ceData.rect.width(),
ceData.rect.height() - sbextent * 2);
case SC_ScrollBarSlider:
if (ceData.orientation == TQt::Horizontal)
return TQRect(sliderstart, 0, sliderlen, sbextent);
return TQRect(0, sliderstart, sbextent, sliderlen);
default: break;
}
break; }
#endif // QT_NO_SCROLLBAR
#ifndef QT_NO_SLIDER
case CC_Slider: {
int tickOffset = pixelMetric( PM_SliderTickmarkOffset, ceData, elementFlags, widget );
int thickness = pixelMetric( PM_SliderControlThickness, ceData, elementFlags, widget );
switch ( sc ) {
case SC_SliderHandle: {
int sliderPos = 0;
int len = pixelMetric( PM_SliderLength, ceData, elementFlags, widget );
sliderPos = ceData.startStep;
if ( ceData.orientation == Horizontal )
return TQRect( sliderPos, tickOffset, len, thickness );
return TQRect( tickOffset, sliderPos, thickness, len ); }
case SC_SliderGroove: {
if ( ceData.orientation == Horizontal )
return TQRect( 0, tickOffset, ceData.rect.width(), thickness );
return TQRect( tickOffset, 0, thickness, ceData.rect.height() ); }
default:
break;
}
break; }
#endif // QT_NO_SLIDER
#if !defined(QT_NO_TOOLBUTTON) && !defined(QT_NO_POPUPMENU)
case CC_ToolButton: {
int mbi = pixelMetric(PM_MenuButtonIndicator, ceData, elementFlags, widget);
TQRect rect = ceData.rect;
switch (sc) {
case SC_ToolButton:
if ((elementFlags & CEF_HasPopupMenu) && ! ceData.popupDelay)
rect.addCoords(0, 0, -mbi, 0);
return rect;
case SC_ToolButtonMenu:
if ((elementFlags & CEF_HasPopupMenu) && ! ceData.popupDelay)
rect.addCoords(rect.width() - mbi, 0, 0, 0);
return rect;
default: break;
}
break;
}
#endif // QT_NO_TOOLBUTTON && QT_NO_POPUPMENU
#ifndef QT_NO_TITLEBAR
case CC_TitleBar: {
const int controlTop = 2;
const int controlHeight = ceData.rect.height() - controlTop * 2;
switch (sc) {
case SC_TitleBarLabel: {
TQRect ir( 0, 0, ceData.rect.width(), ceData.rect.height() );
if ( ceData.wflags & WStyle_Tool ) {
if ( ceData.wflags & WStyle_SysMenu )
ir.addCoords( 0, 0, -controlHeight-3, 0 );
if ( ceData.wflags & WStyle_MinMax )
ir.addCoords( 0, 0, -controlHeight-2, 0 );
} else {
if ( ceData.wflags & WStyle_SysMenu )
ir.addCoords( controlHeight+3, 0, -controlHeight-3, 0 );
if ( ceData.wflags & WStyle_Minimize )
ir.addCoords( 0, 0, -controlHeight-2, 0 );
if ( ceData.wflags & WStyle_Maximize )
ir.addCoords( 0, 0, -controlHeight-2, 0 );
}
return ir; }
case SC_TitleBarCloseButton:
return TQRect( ceData.rect.width() - ( controlHeight + controlTop ),
controlTop, controlHeight, controlHeight );
case SC_TitleBarMaxButton:
case SC_TitleBarShadeButton:
case SC_TitleBarUnshadeButton:
return TQRect( ceData.rect.width() - ( ( controlHeight + controlTop ) * 2 ),
controlTop, controlHeight, controlHeight );
case SC_TitleBarMinButton:
case SC_TitleBarNormalButton: {
int offset = controlHeight + controlTop;
if ( !( ceData.wflags & WStyle_Maximize ) )
offset *= 2;
else
offset *= 3;
return TQRect( ceData.rect.width() - offset, controlTop, controlHeight, controlHeight );
}
case SC_TitleBarSysMenu:
return TQRect( 3, controlTop, controlHeight, controlHeight);
default: break;
}
break; }
#endif //QT_NO_TITLEBAR
default:
break;
}
return TQRect();
}
/*! \reimp */
TQStyle::SubControl TQCommonStyle::querySubControl(ComplexControl control,
TQStyleControlElementData ceData,
ControlElementFlags elementFlags,
const TQPoint &pos,
const TQStyleOption& opt,
const TQWidget *widget ) const
{
SubControl ret = SC_None;
switch (control) {
#ifndef QT_NO_LISTVIEW
case CC_ListView:
{
if(pos.x() >= 0 && pos.x() <
opt.listViewItem()->listView()->treeStepSize())
ret = SC_ListViewExpand;
break;
}
#endif
#ifndef QT_NO_SCROLLBAR
case CC_ScrollBar:
{
TQRect r;
uint ctrl = SC_ScrollBarAddLine;
// we can do this because subcontrols were designed to be masks as well...
while (ret == SC_None && ctrl <= SC_ScrollBarGroove) {
r = querySubControlMetrics(control, ceData, elementFlags,
(TQStyle::SubControl) ctrl, opt, widget);
if (r.isValid() && r.contains(pos))
ret = (TQStyle::SubControl) ctrl;
ctrl <<= 1;
}
break;
}
#endif
case CC_TitleBar:
{
#ifndef QT_NO_TITLEBAR
TQRect r;
uint ctrl = SC_TitleBarLabel;
// we can do this because subcontrols were designed to be masks as well...
while (ret == SC_None && ctrl <= SC_TitleBarUnshadeButton) {
r = visualRect( querySubControlMetrics( control, ceData, elementFlags, (TQStyle::SubControl) ctrl, opt, widget ), ceData, elementFlags );
if (r.isValid() && r.contains(pos))
ret = (TQStyle::SubControl) ctrl;
ctrl <<= 1;
}
if ( ceData.titleBarData.hasWindow ) {
if ( ceData.wflags & WStyle_Tool ) {
if ( ret == SC_TitleBarMinButton || ret == SC_TitleBarMaxButton ) {
if ( ceData.titleBarData.windowState & WindowMinimized )
ret = SC_TitleBarUnshadeButton;
else
ret = SC_TitleBarShadeButton;
}
} else if ( ret == SC_TitleBarMinButton && (ceData.titleBarData.windowState & WindowMinimized) ) {
ret = TQStyle::SC_TitleBarNormalButton;
}
}
#endif
break;
}
default:
break;
}
return ret;
}
/*! \reimp */
int TQCommonStyle::pixelMetric(PixelMetric m, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQWidget *widget) const
{
int ret;
switch (m) {
case PM_DialogButtonsSeparator:
ret = 5;
break;
case PM_DialogButtonsButtonWidth:
ret = 70;
break;
case PM_DialogButtonsButtonHeight:
ret = 30;
break;
case PM_CheckListControllerSize:
case PM_CheckListButtonSize:
ret = 16;
break;
case PM_TitleBarHeight: {
if ( !(elementFlags & CEF_UseGenericParameters) ) {
if ( ceData.wflags & WStyle_Tool ) {
ret = TQMAX( TQFontMetrics(ceData.font).lineSpacing(), 16 );
#ifndef QT_NO_MAINWINDOW
} else if ( ceData.widgetObjectTypes.contains("TQDockWindow") ) {
ret = TQMAX( TQFontMetrics(ceData.font).lineSpacing(), 13 );
#endif
} else {
ret = TQMAX( TQFontMetrics(ceData.font).lineSpacing(), 18 );
}
}
break; }
case PM_ScrollBarSliderMin:
ret = 9;
break;
case PM_ButtonMargin:
ret = 6;
break;
case PM_ButtonDefaultIndicator:
ret = 0;
break;
case PM_MenuButtonIndicator:
if ( elementFlags & CEF_UseGenericParameters )
ret = 12;
else
ret = TQMAX(12, (ceData.rect.height() - 4) / 3);
break;
case PM_ButtonShiftHorizontal:
case PM_ButtonShiftVertical:
ret = 0;
break;
case PM_SpinBoxFrameWidth:
case PM_DefaultFrameWidth:
ret = 2;
break;
case PM_MDIFrameWidth:
ret = 2;
break;
case PM_MDIMinimizedWidth:
ret = 196;
break;
#ifndef QT_NO_SCROLLBAR
case PM_ScrollBarExtent:
if ( elementFlags & CEF_UseGenericParameters ) {
ret = 16;
} else {
int s = ceData.orientation == TQt::Horizontal ?
TQApplication::globalStrut().height()
: TQApplication::globalStrut().width();
ret = TQMAX( 16, s );
}
break;
#endif
case PM_MaximumDragDistance:
ret = -1;
break;
#ifndef QT_NO_SLIDER
case PM_SliderThickness:
ret = 16;
break;
case PM_SliderTickmarkOffset:
{
if ( elementFlags & CEF_UseGenericParameters ) {
ret = 0;
break;
}
int space = (ceData.orientation == Horizontal) ? ceData.rect.height() :
ceData.rect.width();
int thickness = pixelMetric( PM_SliderControlThickness, ceData, elementFlags, widget );
int ticks = ceData.tickMarkSetting;
if ( ticks == TQSlider::Both )
ret = (space - thickness) / 2;
else if ( ticks == TQSlider::Above )
ret = space - thickness;
else
ret = 0;
break;
}
case PM_SliderSpaceAvailable:
{
if ( ceData.orientation == Horizontal )
ret = ceData.rect.width() - pixelMetric( PM_SliderLength, ceData, elementFlags, widget );
else
ret = ceData.rect.height() - pixelMetric( PM_SliderLength, ceData, elementFlags, widget );
break;
}
#endif // QT_NO_SLIDER
case PM_DockWindowSeparatorExtent:
ret = 6;
break;
case PM_DockWindowHandleExtent:
ret = 8;
break;
case PM_DockWindowFrameWidth:
ret = 1;
break;
case PM_MenuBarFrameWidth:
ret = 2;
break;
case PM_MenuBarItemSpacing:
case PM_ToolBarItemSpacing:
ret = 0;
break;
case PM_TabBarTabOverlap:
ret = 3;
break;
case PM_TabBarBaseHeight:
ret = 0;
break;
case PM_TabBarBaseOverlap:
ret = 0;
break;
case PM_TabBarTabHSpace:
ret = 24;
break;
case PM_TabBarTabShiftHorizontal:
case PM_TabBarTabShiftVertical:
ret = 2;
break;
#ifndef QT_NO_TABBAR
case PM_TabBarTabVSpace:
{
if ( ceData.widgetObjectTypes.contains("TQTabBar") && ( ceData.tabBarData.shape == TQTabBar::RoundedAbove ||
ceData.tabBarData.shape == TQTabBar::RoundedBelow ) )
ret = 10;
else
ret = 0;
break;
}
#endif
case PM_ProgressBarChunkWidth:
ret = 9;
break;
case PM_IndicatorWidth:
ret = 13;
break;
case PM_IndicatorHeight:
ret = 13;
break;
case PM_ExclusiveIndicatorWidth:
ret = 12;
break;
case PM_ExclusiveIndicatorHeight:
ret = 12;
break;
case PM_PopupMenuFrameHorizontalExtra:
case PM_PopupMenuFrameVerticalExtra:
ret = 0;
break;
case PM_HeaderMargin:
ret = 4;
break;
case PM_HeaderMarkSize:
ret = 32;
break;
case PM_HeaderGripMargin:
ret = 4;
break;
case PM_TabBarScrollButtonWidth:
ret = 16;
break;
default:
ret = 0;
break;
}
return ret;
}
/*! \reimp */
TQSize TQCommonStyle::sizeFromContents(ContentsType contents,
TQStyleControlElementData ceData,
ControlElementFlags elementFlags,
const TQSize &contentsSize,
const TQStyleOption& opt,
const TQWidget *widget ) const
{
TQSize sz(contentsSize);
switch (contents) {
#ifndef QT_NO_DIALOGBUTTONS
case CT_DialogButtons: {
int w = contentsSize.width(), h = contentsSize.height();
const int bwidth = pixelMetric(PM_DialogButtonsButtonWidth, ceData, elementFlags, widget),
bspace = pixelMetric(PM_DialogButtonsSeparator, ceData, elementFlags, widget),
bheight = pixelMetric(PM_DialogButtonsButtonHeight, ceData, elementFlags, widget);
if(ceData.orientation == Horizontal) {
if(!w)
w = bwidth;
} else {
if(!h)
h = bheight;
}
TQDialogButtons::Button btns[] = { TQDialogButtons::All, TQDialogButtons::Reject, TQDialogButtons::Accept, //reverse order (right to left)
TQDialogButtons::Apply, TQDialogButtons::Retry, TQDialogButtons::Ignore, TQDialogButtons::Abort,
TQDialogButtons::Help };
for(unsigned int i = 0, cnt = 0; i < (sizeof(btns)/sizeof(btns[0])); i++) {
if (ceData.dlgVisibleButtons & btns[i]) {
TQSize szH = ceData.dlgVisibleSizeHints[btns[i]];
int mwidth = TQMAX(bwidth, szH.width()), mheight = TQMAX(bheight, szH.height());
if(ceData.orientation == Horizontal)
h = TQMAX(h, mheight);
else
w = TQMAX(w, mwidth);
if(cnt)
w += bspace;
cnt++;
if(ceData.orientation == Horizontal)
w += mwidth;
else
h += mheight;
}
}
const int fw = pixelMetric(PM_DefaultFrameWidth, ceData, elementFlags, widget) * 2;
sz = TQSize(w + fw, h + fw);
break; }
#endif //QT_NO_DIALOGBUTTONS
case CT_PushButton:
{
#ifndef QT_NO_PUSHBUTTON
int w = contentsSize.width(),
h = contentsSize.height(),
bm = pixelMetric(PM_ButtonMargin, ceData, elementFlags, widget),
fw = pixelMetric(PM_DefaultFrameWidth, ceData, elementFlags, widget) * 2;
w += bm + fw;
h += bm + fw;
if ((elementFlags & CEF_IsDefault) || (elementFlags & CEF_AutoDefault)) {
int dbw = pixelMetric(PM_ButtonDefaultIndicator, ceData, elementFlags, widget) * 2;
w += dbw;
h += dbw;
}
sz = TQSize(w, h);
#endif
break;
}
case CT_CheckBox:
{
#ifndef QT_NO_CHECKBOX
TQRect irect = subRect(SR_CheckBoxIndicator, ceData, elementFlags, widget);
int h = pixelMetric( PM_IndicatorHeight, ceData, elementFlags, widget );
int margins = (ceData.fgPixmap.isNull() && ceData.text.isEmpty()) ? 0 : 10;
sz += TQSize(irect.right() + margins, 4 );
sz.setHeight( TQMAX( sz.height(), h ) );
#endif
break;
}
case CT_RadioButton:
{
#ifndef QT_NO_RADIOBUTTON
TQRect irect = subRect(SR_RadioButtonIndicator, ceData, elementFlags, widget);
int h = pixelMetric( PM_ExclusiveIndicatorHeight, ceData, elementFlags, widget );
int margins = (ceData.fgPixmap.isNull() && ceData.text.isEmpty()) ? 0 : 10;
sz += TQSize(irect.right() + margins, 4 );
sz.setHeight( TQMAX( sz.height(), h ) );
#endif
break;
}
case CT_ToolButton:
{
sz = TQSize(sz.width() + 6, sz.height() + 5);
break;
}
case CT_ComboBox:
{
int dfw = pixelMetric(PM_DefaultFrameWidth, ceData, elementFlags, widget) * 2;
sz = TQSize(sz.width() + dfw + 21, sz.height() + dfw );
break;
}
case CT_PopupMenuItem:
{
#ifndef QT_NO_POPUPMENU
if (opt.isDefault())
break;
bool checkable = (elementFlags & CEF_IsCheckable);
TQMenuItem *mi = opt.menuItem();
int maxpmw = opt.maxIconWidth();
int w = sz.width(), h = sz.height();
if (mi->custom()) {
w = mi->custom()->sizeHint().width();
h = mi->custom()->sizeHint().height();
if (! mi->custom()->fullSpan())
h += 8;
} else if ( mi->widget() ) {
} else if (mi->isSeparator()) {
w = 10;
h = 2;
} else {
if (mi->pixmap())
h = TQMAX(h, mi->pixmap()->height() + 4);
else
h = TQMAX(h, TQFontMetrics(ceData.font).height() + 8);
if (mi->iconSet() != 0)
h = TQMAX(h, mi->iconSet()->pixmap(TQIconSet::Small,
TQIconSet::Normal).height() + 4);
}
if (! mi->text().isNull()) {
if (mi->text().find('\t') >= 0)
w += 12;
}
if (maxpmw)
w += maxpmw + 6;
if (checkable && maxpmw < 20)
w += 20 - maxpmw;
if (checkable || maxpmw > 0)
w += 2;
w += 12;
sz = TQSize(w, h);
#endif
break;
}
case CT_LineEdit:
case CT_Header:
case CT_Slider:
case CT_ProgressBar:
// just return the contentsSize for now
// fall through intended
default:
break;
}
return sz;
}
/*! \reimp */
int TQCommonStyle::styleHint(StyleHint sh, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQStyleOption &, TQStyleHintReturn *, const TQWidget * w) const
{
Q_UNUSED(w);
int ret;
switch (sh) {
#ifndef QT_NO_DIALOGBUTTONS
case SH_DialogButtons_DefaultButton:
ret = TQDialogButtons::Accept;
break;
#endif
case SH_GroupBox_TextLabelVerticalAlignment:
ret = TQt::AlignVCenter;
break;
case SH_GroupBox_TextLabelColor:
ret = (int) ( (!(elementFlags & CEF_UseGenericParameters)) ? ceData.fgColor.rgb() : 0 );
break;
case SH_ListViewExpand_SelectMouseType:
case SH_TabBar_SelectMouseType:
ret = TQEvent::MouseButtonPress;
break;
case SH_GUIStyle:
ret = WindowsStyle;
break;
case SH_ScrollBar_BackgroundMode:
ret = TQWidget::PaletteBackground;
break;
case SH_TabBar_Alignment:
case SH_Header_ArrowAlignment:
ret = TQt::AlignLeft;
break;
case SH_PopupMenu_SubMenuPopupDelay:
ret = 256;
break;
case SH_ProgressDialog_TextLabelAlignment:
ret = TQt::AlignCenter;
break;
case SH_BlinkCursorWhenTextSelected:
ret = 1;
break;
case SH_Table_GridLineColor:
ret = -1;
break;
case SH_LineEdit_PasswordCharacter:
ret = '*';
break;
case SH_ToolBox_SelectedPageTitleBold:
ret = 1;
break;
case SH_UnderlineAccelerator:
ret = 1;
break;
case SH_ToolButton_Uses3D:
ret = 1;
break;
case SH_HideUnderlineAcceleratorWhenAltUp:
ret = 0;
break;
default:
ret = 0;
break;
}
return ret;
}
/*! \reimp */
TQPixmap TQCommonStyle::stylePixmap(StylePixmap, TQStyleControlElementData, ControlElementFlags, const TQStyleOption&, const TQWidget *) const
{
return TQPixmap();
}
#endif // QT_NO_STYLE
|