summaryrefslogtreecommitdiffstats
path: root/style/baghira.cpp
blob: 8434cf14d688c41cf64f0daf853902f79a2df759 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
#include "baghira.h"
#include "bitmaps.h"
#include "pixmaps.h"
//#include "../deco/baghiradecobuttons.h"

#include <tqapplication.h>
#include <tqbitmap.h>
#include <tqbrush.h>
#include <tqbutton.h>
#include <tqcleanuphandler.h>
#include <tqcolor.h>
#include <tqcombobox.h>
//#include <tqevent.h>
#include <tqfont.h>
#include <tqframe.h>
#include <tqgroupbox.h>
#include <tqheader.h>
#include <tqiconset.h>
#include <tqimage.h>
#include <tqlayout.h>
#include <tqlistbox.h>
#include <tqlistview.h>
#include <tqmenubar.h>
#include <tqobject.h>
#include <tqobjectlist.h>
#include <tqpaintdevice.h>
#include <tqpainter.h>
#include <tqpalette.h>
#include <tqpen.h>
#include <tqpoint.h>
#include <tqpopupmenu.h>
#include <tqpushbutton.h>
//#include <tqrangecontrol.h>
#include <tqrect.h>
#include <tqscrollbar.h>
#include <tqscrollview.h>
#include <tqsize.h>
#include <tqslider.h>
#include <tqstring.h>
#include <tqstyleplugin.h>
#include <tqtabbar.h>
#include <tqtabwidget.h>
#include <tqvariant.h>
#include <tdetoolbar.h>
#include <tdetoolbarbutton.h>
#include <kwordwrap.h>
#include "config.h"

#define PRINTDEVICE(p) tqWarning("device is %s", (p->device()->devType() == TQInternal::Widget) ?\
"Widget": (p->device()->devType() == TQInternal::Pixmap) ?\
"Pixmap": (p->device()->devType() == TQInternal::Printer) ?\
"Printer": (p->device()->devType() == TQInternal::Picture) ?\
"Picture": (p->device()->devType() == TQInternal::UndefinedDevice) ?\
"UndefinedDevice": "fuckdevice!" );

#define GCC_VERSION (__GNUC__ * 10000 \
+ __GNUC_MINOR__ * 100 \
+ __GNUC_PATCHLEVEL__)

static const int windowsItemFrame	= 1; // menu item frame width
static const int windowsSepHeight	= 2; // separator item height
static const int windowsItemHMargin	= 3; // menu item hor text margin
static const int windowsItemVMargin	= 1; // menu item ver text margin
static const int windowsArrowHMargin	= 6; // arrow horizontal margin
static const int windowsTabSpacing	= 12; // space between text and tab
static const int windowsCheckMarkHMargin	= 2; // horiz. margins of check mark
static const int windowsRightBorder	= 12; // right border on windows
static const int windowsCheckMarkWidth	= 12; // checkmarks width on windows

// options
int OptionHandler::menuBackground;
int OptionHandler::menuOpacity;
bool OptionHandler::menuColorButton;
bool OptionHandler::shadowText;
//color
TQColor OptionHandler::customButtonColor, OptionHandler::menuStripeColor_;
//widgets
bool OptionHandler::customWidgetColor;
TQColor OptionHandler::customColors[ 10 ];
//menu
bool OptionHandler::useCustomMenuColor;
TQColor OptionHandler::color, OptionHandler::color2, OptionHandler::colorHigh, OptionHandler::fgColor, OptionHandler::fgColorHigh;
//Panel
// bool OptionHandler::panelCustom;
// TQColor OptionHandler::customPanelColor;
//incativeButton
int OptionHandler::inactiveButtonColor;
TQColor OptionHandler::customInactiveButtonColor;

//Design
//stipples
bool OptionHandler::bgStipple, /*OptionHandler::panelStipple,*/ OptionHandler::bevelHighlights_, OptionHandler::drawMenuStripe_, OptionHandler::glossyMenus_;
Style OptionHandler::style_;
int OptionHandler::contrast;
//shadows
bool OptionHandler::groupboxshadow;
int OptionHandler::shadowDarkness;
//istviews;
bool OptionHandler::drawDotlines, OptionHandler::useCustomExpanderColor;
int OptionHandler::expanderStyle;
TQColor OptionHandler::expanderColor, OptionHandler::dotlineColor;
int OptionHandler::dotlineStyle;
//slider
bool OptionHandler::squeezesbslider;
bool OptionHandler::shadowsbslider;
bool OptionHandler::animateSlider;
bool OptionHandler::animateProgress;
//toolbar
bool OptionHandler::reverseBtnColor, OptionHandler::tbFrame;
//tweaks
bool OptionHandler::centerTabs;
bool OptionHandler::smoothListViewHeaders;
bool OptionHandler::smootherLVH;
bool OptionHandler::icyButtons;
Style OptionHandler::_buttonStyle;
int OptionHandler::progressBar;
bool OptionHandler::removeKickerBevel;
Style OptionHandler::_toolbuttonStyle;
bool OptionHandler::drawProgressLabel;
TQColor OptionHandler::brushTint;
TQColor OptionHandler::aDecoColor1_;
TQColor OptionHandler::aDecoColor2_;
TQColor OptionHandler::titleColor_[2];
TQColor OptionHandler::titleButtonColor_[3];
bool OptionHandler::tintBrush;
tabStyle OptionHandler::tabStyle_;
unsigned long OptionHandler::wmDesign;
bool OptionHandler::animateButton;
int OptionHandler::custCols[8];

TQPixmap LiquidStyle::popupBack;

//============

class KAccessToolBarButton : public TDEToolBarButton
{
// to get me access to the toolbbar
   friend class LiquidStyle;
public:
   KAccessToolBarButton( TQWidget* parent=0, const char* name=0 )
      : TDEToolBarButton( parent, name ) {}
};


class LiquidStylePlugin : public TQStylePlugin {
	public:
		LiquidStylePlugin() {
			;
			}
		~LiquidStylePlugin() {
			;
			}

		TQStringList keys() const {
			return ( TQStringList() << "Baghira" );
			}
		TQStyle *create( const TQString & );
	};

TQStyle *LiquidStylePlugin::create( const TQString &s ) {
	if ( s.lower() == "baghira" )
		return ( new LiquidStyle() );
	return ( 0 );
	}

Q_EXPORT_PLUGIN( LiquidStylePlugin )

static const int itemFrame = 1;
static const int itemHMargin = 3;
static const int itemVMargin = 1;
static const int arrowHMargin = 6;
static const int rightBorder = 12;


LiquidStyle::LiquidStyle() : TDEStyle( AllowMenuTransparency | FilledFrameWorkaround, ThreeButtonScrollBar )
{
   TQIntDict<ButtonFadeInfo>bfi(31);// assuming 31 btns will be enough - a pointer list would be more accurate, but we need to lookup this every 50ms...
   TQIntDict<ButtonTile>btnShadowedDict(223);// we need around 10/color, 3 colors/button assuming 10 different colors (e.g. kcalc)
   TQIntDict<ButtonTile>buttonGlowDict(109);
   TQIntDict<ButtonTile>buttonDict(331);
   headerHoverID = -1;
   headerSortID = -1;
	hoveredTabIndex = -1;
	currentTabBar = 0L;
   paintWidget = 0L;
	highlightWidget = 0L;
   currentTaskContainer = 0L;
	taskContainerHover = false;
	isTaskContainer = false;
	isHTMLButton = false;
	inExitPolish = false;
   inactiveRoundFrame = 0L;
   activeRoundFrame = 0L;
   eventKiller = new EventKiller;
   bmShower = 0L; // only if b/m

	btnDict.setAutoDelete( true );
	btnShadowedDict.setAutoDelete( true );
        bfi.setAutoDelete( true );
//	inverseTabDict.setAutoDelete( true );
//	tabDict.setAutoDelete( true );
	initialPaletteLoaded = false;
	qtrcModificationTime = 0;

	// animations kram!
	progAnimShift = 0;
	prog2AnimShift = 0;
	sliderAnimShift = 0;
	TQTimer* timer = new TQTimer( this );
	timer->start(50, false);
//       if (optionHandler->AnimateProgress())
         connect(timer, SIGNAL(timeout()), this, SLOT(updateProgressPos()));
	activeScroller = NULL;
	//--------------------------------------

	tooltipPalette = tqApp->palette();
	tooltipPalette.setBrush( TQColorGroup::Background, TQColor( 255, 255, 220 ) );
	tooltipPalette.setBrush( TQColorGroup::Foreground, TQt::black );

	rMatrix.rotate( 90.0 );
	lMatrix.rotate( 270.0 );
	iMatrix.rotate( 180.0 );
   mMatrix.setMatrix ( -1, 0, 0, 1, 0, 0);
   m2Matrix.setMatrix ( 1, 0, 0, -1, 0, 0);

   optionHandler = new OptionHandler( this );
   if (optionHandler->style() != Milk && optionHandler->AnimateSlider())
      connect(timer, SIGNAL(timeout()), this, SLOT(updateSliderPos()));
   if (optionHandler->style() == Brushed)
      bmShower = new BMShower(this);

   switch (optionHandler->buttonStyle())
   {
   case Jaguar:
      btnBorderImg = new TQImage( uic_findImage("button-jaguar") );
      btnShadowImg = new TQImage( uic_findImage( "button-shadow" ) );
      buttonGlow = new TQImage( uic_findImage( "button-glow" ) );
      combo = new TQImage( uic_findImage("combo-jaguar") );
      comboShadow = new TQImage( uic_findImage( "combo-shadow" ) );
      if (optionHandler->toolbuttonStyle() == Brushed || !optionHandler->SmoothListViewHeaders())
         rectbutton = new TQImage( uic_findImage( "rectbutton" ) );
      else  rectbutton = 0L;
      break;
   case Panther:
   case Tiger:
      btnBorderImg = new TQImage( uic_findImage("button-base") );
      btnShadowImg = new TQImage( uic_findImage( "button-shadow" ) );
      buttonGlow = new TQImage( uic_findImage( "button-glow" ) );
      combo = new TQImage( uic_findImage("combo") );
      comboShadow = new TQImage( uic_findImage( "combo-shadow" ) );
      if (optionHandler->toolbuttonStyle() == Brushed || !optionHandler->SmoothListViewHeaders())
         rectbutton = new TQImage( uic_findImage( "rectbutton" ) );
      else  rectbutton = 0L;
      break;
   case Brushed:
      btnBorderImg = 0L;
      btnShadowImg = 0L;
      buttonGlow = 0L;
      rectbutton = new TQImage( uic_findImage( "rectbutton" ) );
      switch (optionHandler->toolbuttonStyle())
      {
      case Jaguar:
         combo = new TQImage( uic_findImage("combo-jaguar") );
         comboShadow = new TQImage( uic_findImage( "combo-shadow" ) );
         break;
      case Panther:
      case Tiger:
      case Brushed:
         combo = new TQImage( uic_findImage("combo") );
         comboShadow = new TQImage( uic_findImage( "combo-shadow" ) );
         break;
      case Milk:
         combo = new TQImage( uic_findImage("combo-milk") );
         comboShadow = new TQImage( uic_findImage( "combo-shadow" ) );
      default:
         break;
      }
      break;
   case Milk:
      btnBorderImg = new TQImage( uic_findImage("button-milk") );
      btnShadowImg = 0L;
      buttonGlow = 0L;
      combo = new TQImage( uic_findImage("combo-milk") );
      comboShadow = new TQImage( uic_findImage( "combo-shadow" ) );
      if (optionHandler->toolbuttonStyle() == Brushed || !optionHandler->SmoothListViewHeaders())
         rectbutton = new TQImage( uic_findImage( "rectbutton" ) );
      else  rectbutton = 0L;
   default:
      break;
   }

   if ( btnBorderImg && btnBorderImg->depth() < 32 )
		* btnBorderImg = btnBorderImg->convertDepth( 32 );

   if ( btnShadowImg && btnShadowImg->depth() < 32 )
      * btnShadowImg = btnShadowImg->convertDepth( 32 );

   if ( buttonGlow && buttonGlow->depth() < 32 )
      * buttonGlow = buttonGlow->convertDepth( 32 );

   if ( combo && combo->depth() < 32 )
      * combo = combo->convertDepth( 32 );

   if ( comboShadow && comboShadow->depth() < 32 )
      * comboShadow = comboShadow->convertDepth( 32 );

   if ( rectbutton && rectbutton->depth() < 32 )
      * rectbutton = rectbutton->convertDepth( 32 );

   if (optionHandler->style() == Milk)
   {
      slider_top = new TQImage( uic_findImage( "sbslider_top-milk" ) );
      slider_btm = new TQImage( uic_findImage( "sbslider_btm-milk" ) );
   }
   else
   {
      slider_top = new TQImage( uic_findImage( "sbslider_top" ) );
      slider_btm = new TQImage( uic_findImage( "sbslider_btm" ) );
   }

	if ( slider_top->depth() < 32 )
		* slider_top = slider_top->convertDepth( 32 );

	if ( slider_btm->depth() < 32 )
		* slider_btm = slider_btm->convertDepth( 32 );

   if (optionHandler->shadowSbSlider())
   {
      slider_top_shd = new TQImage( uic_findImage( "sbslider_top_shd" ) );
      if ( slider_top_shd->depth() < 32 )
         * slider_top_shd = slider_top_shd->convertDepth( 32 );

      slider_btm_shd = new TQImage( uic_findImage( "sbslider_btm_shd" ) );
      if ( slider_btm_shd->depth() < 32 )
         * slider_btm_shd = slider_btm_shd->convertDepth( 32 );
   }
   else
   {
      slider_top_shd = 0L;
      slider_btm_shd = 0L;
   }

	roundFrame = new TQImage( uic_findImage( "roundFrame" ) );
   if ( roundFrame->depth() < 32 )
      * roundFrame = roundFrame->convertDepth( 32 );

	menuPix = NULL;
	tmpBtnPix = NULL;

	int i;
	for ( i = 0; i < BITMAP_ITEMS; ++i ) {
		pixmaps[ i ] = NULL;
		}

	sbLeft = new TQBitmap( 6, 7, sbarrow_left_bits, true );
	sbLeft->setMask( *sbLeft );
	sbRight = new TQBitmap( 6, 7, sbarrow_right_bits, true );
	sbRight->setMask( *sbRight );
	sbUp = new TQBitmap( 7, 6, sbarrow_up_bits, true );
	sbUp->setMask( *sbUp );
	sbDown = new TQBitmap( 7, 6, sbarrow_down_bits, true );
	sbDown->setMask( *sbDown );
        checkmark = new TQBitmap( 6, 7, checkmark_bits, true );
	checkmark->setMask( *checkmark );

   isKicker = ( qstrcmp( tqApp->argv() [ 0 ], "kicker" ) == 0 ) ||
	           ( qstrcmp( tqApp->argv() [ 0 ], "appletproxy" ) == 0 );
   isOOO = !qstrcmp( tqApp->argv() [ 0 ], "soffice.bin" );

	groupShadow = new TQPixmap( 64, 64 );
   TQColor c;
   optionHandler->custCols[0] != -1 ? c = TQColor(optionHandler->custCols[0]) : c= TQColor(tqApp->palette().color(TQPalette::Active, isKicker?TQColorGroup::Button:TQColorGroup::Background));

	groupShadow->fill( ( c.dark( 100 + optionHandler->ShadowDarkness() ) ).rgb() );
   if ( (optionHandler->style() != Brushed) && optionHandler->useBgStipple() ) {
		TQPainter p;
		p.begin( groupShadow );
		p.setPen( c.dark( 100 + optionHandler->ShadowDarkness() + (int)(optionHandler->stippleContrast()/2) ) );
		for ( int i = 1; i < 64; i += 4 ) {
			p.drawLine( 0, i, 63, i );
			p.drawLine( 0, i+2, 63, i+2 );
		}
                p.setPen( c.dark( 100 + optionHandler->ShadowDarkness() + optionHandler->stippleContrast()) );
                for ( int i = 2; i < 63; i += 4 ) {
                        p.drawLine( 0, i, 63, i );
                        }
	}

   if (optionHandler->style() == Brushed)
   {
      plainBrush = optionHandler->TintBrush() ?
         *tintBrush(uic_findImage( "brushed-tile" ), optionHandler->BrushTint()) :
         uic_findImage( "brushed-tile" );
      gradBrush = optionHandler->TintBrush() ?
         *tintBrush(uic_findImage( "brushed-gradient" ), optionHandler->BrushTint()) :
         uic_findImage( "brushed-gradient" );
   }
}

LiquidStyle::~LiquidStyle() {
// 	btnDict.setAutoDelete(true);
	btnDict.clear();
// 	btnShadowedDict.setAutoDelete(true);
	btnShadowedDict.clear();
// 	buttonGlowDict.setAutoDelete(true);
	buttonGlowDict.clear();
// 	comboDict.setAutoDelete(true);
	comboDict.clear();
// 	comboShadowedDict.setAutoDelete(true);
	comboShadowedDict.clear();
//	if (! tabDict.isEmpty()) tabDict.clear();
//	if (! inverseTabDict.isEmpty()) inverseTabDict.clear();
// 	rectBtnDict.setAutoDelete(true);
	rectBtnDict.clear();
// 	progress2Dict.setAutoDelete(true);
	progress2Dict.clear();
//         bfi.setAutoDelete(true);
   bfi.clear();
//         fadeColorMap.setAutoDelete(true);
   fadeColorMap.clear();

	delete optionHandler;

	delete sbUp;
	delete sbDown;
	delete sbLeft;
	delete sbRight;
   delete checkmark;


	if ( btnBorderImg )
		delete btnBorderImg;
	if ( btnShadowImg )
		delete btnShadowImg;
   if (combo)
      delete combo;
   if (comboShadow)
      delete comboShadow;
   if (buttonGlow)
      delete buttonGlow;
   delete slider_top;
   delete slider_btm;
   if (slider_top_shd)
      delete slider_top_shd;
   if (slider_btm_shd)
      delete slider_btm_shd;
   if (rectbutton)
      delete rectbutton;
   delete roundFrame;

	if ( tmpBtnPix )
		delete tmpBtnPix;
	if ( menuPix )
		delete menuPix;

	int i;
	for ( i = 0; i < BITMAP_ITEMS; ++i ) {
		if ( pixmaps[ i ] )
			delete pixmaps[ i ];
		}
	if ( groupShadow )
		delete groupShadow;

	}

inline void LiquidStyle::updateProgressPos()
{
    progAnimShift = (progAnimShift + 1) % 20;
    prog2AnimShift = (prog2AnimShift + 1) % 38;
    //Update the registered progressbars.
    TQMap<TQWidget*, int>::iterator iter;
    for (iter = progAnimWidgets.begin(); iter != progAnimWidgets.end(); iter++)
    {
        if ( !::tqt_cast<TQProgressBar*>(iter.key()) )
            continue;
        (iter.key())->repaint(false);
    }
}

inline void LiquidStyle::updateSliderPos(){
	sliderAnimShift = (sliderAnimShift + 1) % 32;
        if (activeScroller)
            activeScroller->repaint(false);
}

void LiquidStyle::progressBarDestroyed(TQObject* obj){
    progAnimWidgets.remove(static_cast<TQWidget*>(obj));
}

bool LiquidStyle::isPlain() const {
	return ( !optionHandler->useBgStipple() );
	}


void LiquidStyle::drawPrimitive( PrimitiveElement pe,
                                 TQPainter *p,
                                 const TQStyleControlElementData &ceData,
                                 ControlElementFlags elementFlags,
                                 const TQRect &r,
                                 const TQColorGroup &cg,
                                 SFlags flags,
                                 const TQStyleOption &opt ) const
{
   bool down = flags & Style_Down;
   bool on = flags & Style_On;

   switch ( pe )
   {
   case PE_TabBarBase:
   {
      bool isDialog = false;
      if (p->device() && p->device()->devType() == TQInternal::Widget)
      {
         TQWidget *w = (TQWidget*)p->device();
         if (w && ::tqt_cast<TQTabWidget*>(w) && w->children())
         {
            TQObjectListIt it( *w->children() ); // iterate over the buttons
            TQObject *obj;
            TQTabBar *tabBar = 0L;
            while ( (obj = it.current()) != 0 )
            {
               ++it;
               if (::tqt_cast<TQTabBar*>(obj))
               {
                  tabBar = (TQTabBar*)obj;
                  break;
               }
            }
            if (!tabBar || !tabBar->isVisible())
               break;
         }
         isDialog = optionHandler->TabStyle() == Clever && w->topLevelWidget()->inherits("TQDialog");
      }
      if (isDialog || optionHandler->TabStyle() == Chooser)
      {
         int x = r.x(); int right = r.right(); int bottom = r.bottom(); int y2 = r.y() + 1;
         TQColor bright( cg.background().dark( 110 ) );
         TQColor mid( cg.background().dark( 130 ) );
         TQColor dark( cg.background().dark( 150 ) );
         p->setPen( dark );
         p->drawLine( x + 6, y2, right - 6, y2 );
         p->drawPoint(x+3,y2+1);p->drawPoint(x+4,y2+1);
         p->drawPoint(x+2,y2+2);
         p->drawPoint(x+1,y2+3);
         p->drawPoint(right-3,y2+1);p->drawPoint(right-4,y2+1);
         p->drawPoint(right-2,y2+2);
         p->drawPoint(right-1,y2+3);
         p->drawLine(x,y2+5,x,bottom);
         p->drawLine(right,y2+5,right,bottom);

         p->setPen( mid );
         p->drawPoint(x+4, y2);p->drawPoint(x+5,y2);
         p->drawPoint(right-4, y2);p->drawPoint(right-5,y2);
         p->drawPoint(x+2, y2+1);
         p->drawPoint(right-2, y2+1);
         p->drawLine(x+5,y2 + 1, right - 5, y2 + 1);
         p->drawPoint(x+1,y2+2);
         p->drawPoint(right-1,y2+2);
         p->drawPoint(x+2,y2+3);
         p->drawPoint(right-2,y2+3);
         p->drawPoint(x,y2+4);p->drawPoint(x+1,y2+4);
         p->drawPoint(right,y2+4);p->drawPoint(right+1,y2+4);

         p->setPen(bright);
         p->drawPoint(x+3,y2);p->drawPoint(right-3,y2);
         p->drawLine(x+4,y2+2,right-4,y2+2);
         p->drawPoint(x,y2+3);p->drawPoint(x+3,y2+3);
         p->drawPoint(right,y2+3);p->drawPoint(right-3,y2+3);
         p->drawPoint(x+2,y2+4);p->drawPoint(right-2,y2+4);
         p->drawLine(x+1,y2+5,x+1,bottom);
         p->drawLine(right-1,y2+5,right-1,bottom);
         break;
      }
      else
      {
         drawCombo( p, cg, cg.button(), r.x()+1, r.y()+1, r.width()-2, r.height()+1, false, false, false, center);
         TQPen oldPen = p->pen();
//          p->setClipping ( false );
         p->setPen( cg.button().dark( 158 ) );
         p->drawRect(r);
//          p->fillRect(r, TQt::red);
//          p->flush();
         p->setPen(oldPen);
      }
      break;
   }
   case PE_ButtonCommand:
   case PE_ButtonDefault:
   {
      bool sunken = on || down;
      bool hover = flags & Style_MouseOver;
      bool focused = flags & Style_HasFocus;
      TQColor newColor = sunken ? cg.button().dark( 110 ) : hover || focused ? cg.button() : optionHandler->InactiveButtonColor();
      if (optionHandler->AnimateButton() && (sunken || hover || focused))
      {
         ButtonFadeInfo *bfi_ = /*(::tqt_cast<TQWidget*>(*/opt.widget()/*))*/ ? bfi[opt.widget()->winId()] : 0L;
         if (bfi_)
         {
            int index = bfi_->index;
            newColor = mapFadeColor(newColor, index);
         }
      }

      if (optionHandler->buttonStyle() == Brushed)
      {
         drawRectangularButton( p, cg, newColor, r.x(), r.y(), r.width(), r.height(), sunken, hover, false, full);
      }
      else if ( ( r.width() < 21 || r.height() < 25 ))
      {
         drawCombo( p, cg, newColor, r.x(), r.y(), r.width(), r.height()+2, sunken, hover, false, center, isHTMLButton );
         TQPen oldpen(p->pen());
         p->setPen( newColor.dark(150));
         p->drawRect(r.x(), r.y(), r.width(), r.height());
         if (sunken)
         {
            p->setPen(newColor.dark(180));
            p->drawRect(r.x()+1, r.y()+1, r.width()-2, r.height()-2);
         }
         p->setPen(oldpen);
         break;
      }
      else if (optionHandler->buttonStyle() == Milk)
         drawCombo( p, cg, newColor, r.x(), r.y(), r.width(), r.height(), sunken, hover, false, full, isHTMLButton );
      else
      {
         drawRoundButton( p, cg, newColor, r.x(), r.y(), r.width(), r.height(), sunken, hover, btnOffset.x(), btnOffset.y() );
      }
      break;
   }
   case PE_ButtonBevel:
   case PE_ButtonDropDown:
   {
      bool sunken = on || down;
      bool hover = flags & Style_MouseOver;
      if (optionHandler->buttonStyle() == Brushed)
         drawRectangularButton( p, cg, sunken ? cg.button().dark( 110 ) : hover ? cg.button() : optionHandler->InactiveButtonColor(), r.x(), r.y(), r.width(), r.height(), sunken, hover, false, full);
      else
         drawCombo( p, cg, sunken ? cg.button().dark( 110 ) : hover ? cg.button() : optionHandler->InactiveButtonColor(), r.x(), r.y(), r.width(), r.height(), sunken, hover, false, full );
      break;
   }
   case PE_ButtonTool:
   {
      bool sunken = on || down;
      bool hover = flags & Style_MouseOver;
      if (optionHandler->buttonStyle() == Brushed)
         drawRectangularButton( p, cg, sunken ? cg.button().dark( 110 ) : hover ? cg.button() : optionHandler->InactiveButtonColor(), r.x(), r.y(), r.width(), r.height(), sunken, hover, false, full);
      else
         drawCombo( p, cg, sunken ? cg.button().dark( 110 ) : hover ? cg.button() : optionHandler->InactiveButtonColor(), r.x(), r.y(), r.width(), r.height(), sunken, hover, false, full );
      break;
   }
   case PE_HeaderSection:
   {
      bool sunken = on || down;
      bool hover = flags & Style_MouseOver;
      TQPen oldpen(p->pen());
      if ( isTaskContainer ) // is kicker?
      {
         if (optionHandler->SmoothListViewHeaders())
         {
         drawCombo( p, cg, sunken ? cg.button() : taskContainerHover ? cg.button().light( 110 ) : cg.background(), r.x(), r.y(), r.width(), isKicker ? r.height() + 2 : r.height(), sunken, hover, false, optionHandler->SmootherLVH() ? full : center );
            if (isKicker && !optionHandler->SmootherLVH())
            {
            p->setPen(cg.background().dark(150));
            p->drawRect(r.x(), r.y(), r.width(), r.height());
               if (sunken)
               {
                  p->setPen(cg.background().dark(200));
                  p->drawRect(r.x()+1, r.y()+1, r.width()-2, r.height()-2);
               }
            }
         }
         else
         {
         drawRectangularButton( p, cg, sunken ? cg.button() : taskContainerHover ? cg.button().light( 110 ) : cg.background(), r.x(), r.y(), r.width(), r.height(), sunken, hover, false, center);
            p->setPen(cg.background().dark(150));
            p->drawLine(r.x(),r.y()+1,r.x(),r.height()-2);
         }
         const_cast<LiquidStyle*>( this ) ->isTaskContainer = false;
         const_cast<LiquidStyle*>( this ) ->taskContainerHover = false;
      }
      else
      {
         if ( (p->device() && p->device()->devType() == TQInternal::Widget) && ::tqt_cast<TQHeader*>((TQWidget*)p->device()) )
         {
            TQHeader *header = (TQHeader*)p->device();
            int id = header->orientation() == TQt::Horizontal ? header->sectionAt( r.x() + 2 + header->offset() ) : header->sectionAt( r.y() + 2 + header->offset() );
            hover = ((id != -1) && ((currentHeader == header && id == headerHoverID ) || id == headerSortID));
            if (header->mapToIndex(id) == header->count()-1 && (r.bottom() < header->rect().bottom() || r.right() < header->rect().right()))
            {
               bool hadClip = p->hasClipping();
               p->setClipping( false );
               if (header->orientation() == TQt::Horizontal)
                  p->fillRect(r.right()+1, r.y(), header->width()-r.right(), r.height(), cg.base());
               else
                  p->fillRect(r.x(), r.bottom()+1, r.width(), header->height()-r.bottom(), cg.base());
               p->setClipping( hadClip );
            }
         }
         if (optionHandler->SmoothListViewHeaders())
         {
            drawCombo( p, cg, sunken ? cg.button().dark( 110 ) : hover ? cg.button() : optionHandler->InactiveButtonColor(), r.x(), r.y(), r.width(), r.height(), sunken, hover, false, center);
         }
         else
            drawRectangularButton( p, cg, sunken ? cg.button().dark( 110 ) : hover ? cg.button() : optionHandler->InactiveButtonColor(), r.x(), r.y(), r.width(), r.height(), sunken, hover, false, center);
      }
      p->setPen(oldpen);
      break;
   }
   case PE_FocusRect:
   {
      p->drawWinFocusRect( r );
      break;
   }
   case PE_ScrollBarSlider:
   case PE_ScrollBarAddPage:
   case PE_ScrollBarSubPage:
   {
      TQColor sbBgColor = optionHandler->useCustomColors() ?
                           optionHandler->customColor( CustomSBGroove ) :
                           tqApp->palette().active().background();

      bool isActive = optionHandler->ScrollerActive();
      bool isHover = currentScrollBar->hasMouse();
      bool isPressed = currentScrollBar->draggingSlider();
      bool drawSlider = currentScrollBar->minValue() < currentScrollBar->maxValue();

      // horizontal slider
      if ( flags & Style_Horizontal )
      {
         int extent = currentScrollBar->height();
         TQRect bgR( extent, 0, currentScrollBar->width() - extent * 3 + 1, extent );
         if ( sbBuffer.size() != currentScrollBar->size() )
            const_cast<LiquidStyle*>( this )->sbBuffer.resize( currentScrollBar->size() );
         TQPainter painter;
         painter.begin( &sbBuffer );
         // pixmaps
         if (drawSlider)
         {
            painter.drawPixmap( bgR.x(), bgR.y() + 1, *getPixmap( HSBSliderBtmBg ) );
            painter.drawTiledPixmap( bgR.x() + 7, bgR.y() + 1, bgR.width() - 15, 13, *getPixmap( HSBSliderMidBg ) );
            painter.drawPixmap( bgR.right() - 8, bgR.y() + 1, *getPixmap( HSBSliderTopBg ) );
         }
         else
            painter.drawTiledPixmap( bgR.x(), bgR.y() + 1, bgR.width(), 13, *getPixmap( HSBSliderMidBg ) );

         // lines
         painter.setPen( sbBgColor.dark( 110 ) );
         painter.drawLine( bgR.x(), bgR.y(), bgR.right(), bgR.y());
         painter.drawLine( bgR.x(), bgR.bottom(), bgR.right(), bgR.bottom());

         if ( pe == PE_ScrollBarSlider && drawSlider)
         {
         int offset = isPressed * ( optionHandler->squeezeSbSlider() + optionHandler->shadowSbSlider()*2);
         int offset2 = optionHandler->shadowSbSlider()*2 + (isPressed && optionHandler->squeezeSbSlider());

         painter.drawPixmap( r.x() + offset, r.y() + 1,
               isPressed ? *getPixmap( HSBSliderBtmPressed ) :
               (isHover || isActive || isOOO) ? *getPixmap( HSBSliderBtmActive ) :
               *getPixmap( HSBSliderBtm));

         painter.drawPixmap( r.right() - 6 - offset2, r.y() + 1,
               isPressed ? *getPixmap( HSBSliderTopPressed ) :
               (isHover || isActive || isOOO) ? *getPixmap( HSBSliderTopActive ) :
               *getPixmap( HSBSliderTop ) );
         // mid part last, as i have to redefine clip section
         painter.setClipRect(r.x() + 7 + offset2, r.y() + 1, r.width() - 14 - 2*offset2, 13, TQPainter::CoordPainter);
         painter.drawTiledPixmap( r.x() + 7 + offset2 + ((isHover && !isPressed) ? (sliderAnimShift - 32) : 0), r.y() + 1, r.width() - 14 - 2*offset2 - ((isHover && !isPressed) ?
               (sliderAnimShift - 32) : 0), 13, isPressed ? *getPixmap( HSBSliderMidPressed ) :
               (isHover || isActive || isOOO) ? *getPixmap( HSBSliderMidActive ) :
               *getPixmap( HSBSliderMid ), isPressed?r.x() : 0, 0);
         }

         painter.end();
      }

   // vertical slider
      else
      {
         int extent = currentScrollBar->width();
         TQRect bgR( 0, extent, extent, currentScrollBar->height() - extent * 3 + 1 );

         if ( sbBuffer.size() != currentScrollBar->size() )
            const_cast<LiquidStyle*>( this ) -> sbBuffer.resize( currentScrollBar->size() );
         TQPainter painter;
         painter.begin( &sbBuffer ); // set painter to pixelbuffer
         if (drawSlider)
         {
            // top slidergroove rounder
            painter.drawPixmap( bgR.x() + 1, bgR.y(), *getPixmap( VSBSliderTopBg ) );
            // the groove
            painter.drawTiledPixmap( bgR.x() + 1, bgR.y() + 8, 13, bgR.height() - 15, *getPixmap( VSBSliderMidBg ) );
            // bottom slidergroove rounder
            painter.drawPixmap( bgR.x() + 1, bgR.bottom() - 7, *getPixmap( VSBSliderBtmBg ) );
         }
         else
            painter.drawTiledPixmap( bgR.x() + 1, bgR.y(), 13, bgR.height(), *getPixmap( VSBSliderMidBg ) );

         painter.setPen( sbBgColor.dark( 110 ) );
         painter.drawLine( bgR.x(), bgR.y(), bgR.x(), bgR.bottom() );
         painter.drawLine( bgR.right(), bgR.y(), bgR.right(), bgR.bottom() );

         // here we are, now the slider
         if ( pe == PE_ScrollBarSlider && drawSlider )
         {
            int offset = isPressed * ( optionHandler->squeezeSbSlider() + optionHandler->shadowSbSlider()*2);
            int offset2 = (isPressed * optionHandler->squeezeSbSlider()) + optionHandler->shadowSbSlider()*2;

            painter.drawPixmap( r.x() + 1, r.y() + offset, isPressed ?
                  *getPixmap( VSBSliderTopPressed ) :
                  (isHover || isActive || isOOO) ? *getPixmap( VSBSliderTopActive ) :
                  *getPixmap( VSBSliderTop));
            painter.drawPixmap( r.x() + 1, r.bottom()  - 6 - offset2, isPressed ?
                  *getPixmap( VSBSliderBtmPressed ) :
                  (isHover || isActive || isOOO) ? *getPixmap( VSBSliderBtmActive ) :
                  *getPixmap( VSBSliderBtm ) );
            // mid part last, as i have to redefine clipping section
            painter.setClipRect(r.x() + 1, r.y() + 7+offset2, 13, r.height() - 14 - 2*offset2, TQPainter::CoordPainter);
            painter.drawTiledPixmap( r.x() + 1, r.y() + 7 + offset2 - ((isHover && !isPressed) ? sliderAnimShift : 0),
                  13, r.height() - 14 - 2*offset2 + ((isHover && !isPressed) ?
                  sliderAnimShift : 0), isPressed ? *getPixmap( VSBSliderMidPressed ) :
                  (isHover || isActive || isOOO) ? *getPixmap( VSBSliderMidActive ) :
                  *getPixmap( VSBSliderMid ),0,isPressed?r.y():0 );
         }
         painter.end();
      }
      p->drawPixmap( r.x(), r.y(), sbBuffer, r.x(), r.y(), r.width(), r.height() );
      break;
   }
   case PE_ScrollBarAddLine:
   {
      TQColor c( optionHandler->useCustomColors() ?
            optionHandler->customColor( CustomSBGroove ) :
            tqApp->palette().active().background() );
      TQColor pixColor = flags & Style_Down ? tqApp->palette().active().button() : c;

      bool drawSlider = currentScrollBar->minValue() < currentScrollBar->maxValue();

      if ( flags & Style_Horizontal )
      {
         p->drawTiledPixmap( r.x(), r.y() + 1, r.width(), 13, *getPixmap(drawSlider ? HSBSliderMidBgI : HSBSliderMidBg));
         p->setPen( c.dark( 110 ) );
         p->drawLine( r.x(), r.y(), r.right(), r.y());
         p->drawLine( r.x(), r.bottom(), r.right(), r.bottom());
      }
      else
      {
         p->drawTiledPixmap( r.x() + 1, r.y(), 13, r.height(), *getPixmap(drawSlider ? VSBSliderMidBgI : VSBSliderMidBg));
         p->setPen( c.dark( 110 ) );
         p->drawLine( r.x(), r.y(), r.x(), r.bottom());
         p->drawLine( r.right(), r.y(), r.right(), r.bottom());
      }
      if (drawSlider)
      {
         p->setPen( flags & Style_Down ? cg.button() : TQColor(85,85,85) );
         p->setBrush( flags & Style_Down ? cg.button() : TQColor(85,85,85) );
         p->drawPixmap( r.x() + 4, r.y() + 4, flags & Style_Horizontal ? *sbRight : *sbDown );
      }
      break;
   }
   case PE_ScrollBarSubLine:
   {
      TQColor c( optionHandler->useCustomColors() ?
            optionHandler->customColor( CustomSBGroove ) :
                  tqApp->palette().active().background() );
      TQColor pixColor = flags & Style_Down ? tqApp->palette().active().button() : c;
      bool top = flags & Style_Horizontal ? r.x() == 0 : r.y() == 0;

      bool drawSlider = currentScrollBar->minValue() < currentScrollBar->maxValue();

      if ( flags & Style_Horizontal )
      {
         if ( top )
         {
            p->drawTiledPixmap( r.x(), r.y() + 1, r.width(), 13, *getPixmap(drawSlider ? HSBSliderMidBgI : HSBSliderMidBg));
         }
         else
         {
            p->drawTiledPixmap( r.x(), r.y() + 1, r.width(), 13, *getPixmap(drawSlider ? HSBSliderMidBgI : HSBSliderMidBg));
         }
         p->setPen( c.dark( 110 ) );
         p->drawLine( r.x(), r.y(), r.right(), r.y());
         p->drawLine( r.x(), r.bottom(), r.right(), r.bottom());
      }
      else
      {
         if ( top )
         {
            p->drawTiledPixmap( r.x() + 1, r.y(), 13, r.height(), *getPixmap(drawSlider ? VSBSliderMidBgI : VSBSliderMidBg));
         }
         else
         {
            p->drawTiledPixmap( r.x() + 1, r.y(), 13, r.height(), *getPixmap(drawSlider ? VSBSliderMidBgI : VSBSliderMidBg));
         }
         p->setPen( c.dark( 110 ) );
         p->drawLine( r.x(), r.y(), r.x(), r.bottom());
         p->drawLine( r.right(), r.y(), r.right(), r.bottom());
      }
      if (drawSlider)
      {
         p->setPen( flags & Style_Down ? cg.button() : TQColor(85,85,85) );
         p->setBrush( flags & Style_Down ? cg.button() : TQColor(85,85,85) );
         if (currentScrollBar->minValue() < currentScrollBar->maxValue()) p->drawPixmap( r.x() + 4, r.y() + 4, flags & Style_Horizontal ? *sbLeft : *sbUp );
      }
      break;
   }
   case PE_Indicator:
   {
      bool hover = flags & Style_MouseOver;
      bool pressed = flags & Style_Down;
//       bool isMasked = p->device() && p->device() ->devType() == TQInternal::Widget && ( ( TQWidget * ) p->device() ) ->autoMask();
#if 0
      if ( isMasked )
      {
         if ( !( flags & Style_Off ) )
            p->drawPixmap( r.x(), r.y(),
                  hover ? *getPixmap( HTMLCBDownHover ) :
                  *getPixmap( HTMLCBDown ) );
         else
            p->drawPixmap( r.x(), r.y(), hover ?
                  *getPixmap( HTMLCBHover ) : *getPixmap( HTMLCB ) );
      }
      else
#endif
      {
         if ( flags & Style_On )
            p->drawPixmap( r.x(), r.y(),
                  pressed ? *getPixmap( CBDownPressed ) :
                  hover ? *getPixmap( CBDownHover ) :
                  *getPixmap( CBDown ) );
         else if ( flags & Style_Off )
            p->drawPixmap( r.x(), r.y(),
                  pressed ? *getPixmap( CBPressed ) :
                  hover ? *getPixmap( CBHover ) :
                  *getPixmap( CB ) );
         else //tristate
            p->drawPixmap( r.x(), r.y(),
                  pressed ? *getPixmap( CBTriPressed ) :
                  hover ? *getPixmap( CBTriHover ) :
                  *getPixmap( CBTri ) );
      }
      break;
   }
   case PE_IndicatorMask:
   {
      p->fillRect( r, TQt::color1 );
      break;
   }
   case PE_ExclusiveIndicator:
   {
      bool hover = flags & Style_MouseOver;
      bool pressed = flags & Style_Down;

         if ( on || down )
            p->drawPixmap( r.x(), r.y(),
                  pressed ? *getPixmap( RadioOnPressed ) :
                  hover ? *getPixmap( RadioOnHover ) :
                  *getPixmap( RadioOn ) );
         else
            p->drawPixmap( r.x(), r.y(),
                  pressed ? *getPixmap( RadioOffPressed ) :
                  hover ? *getPixmap( RadioOffHover ) :
                  *getPixmap( RadioOff ) );
      break;
   }
   case PE_ExclusiveIndicatorMask:
   {
      break;
   }
   case PE_Splitter:
   case PE_DockWindowResizeHandle:
   {
      TQPen oldpen(p->pen());
      TQBrush oldbrush(p->brush());
      if (highlightWidget == p->device())
      {
         if (flags & Style_Horizontal)
         { //vertical?
            p->setPen(cg.mid());
            p->drawLine(r.x(), r.y(), r.x(), r.bottom());
            p->drawLine(r.right(), r.y(), r.right(), r.bottom());
            p->setPen(cg.button().dark(140));
            p->setBrush(cg.button().dark(140));
            p->drawEllipse(r.x()+1,r.y() + (int)(r.height() / 2.5), 4, 4);
         }
         else
         {
            p->setPen(cg.mid());
            p->drawLine(r.x(), r.y(), r.right(), r.y());
            p->drawLine(r.x(), r.bottom(), r.right(), r.bottom());
            p->setPen(cg.button().dark(140));
            p->setBrush(cg.button().dark(140));
            p->drawEllipse(r.x()+r.width()/2,r.y() + 1, 4, 4);
         }

      }
      else
      {
         if (flags & Style_Horizontal)
         {
            p->setPen(cg.mid());
            p->drawLine(r.x(), r.y(), r.x(), r.bottom());
            p->drawLine(r.right(), r.y(), r.right(), r.bottom());
            p->setPen(cg.background().dark(130));
            p->setBrush(cg.background().dark(150));
            p->drawEllipse(r.x()+1,r.y() + (int)(r.height() / 2.5), 4, 4);
         }
         else
         {
            p->setPen(cg.mid());
            p->drawLine(r.x(), r.y(), r.right(), r.y());
            p->drawLine(r.x(), r.bottom(), r.right(), r.bottom());
            p->setPen(cg.background().dark(130));
            p->setBrush(cg.background().dark(150));
            p->drawEllipse(r.x()+r.width()/2,r.y() + 1, 4, 4);
         }
      }
      p->setPen(oldpen);
      p->setBrush(oldbrush);
      break;
   }
//    case PE_BoxFrame:
   case PE_PanelGroupBox:
   case PE_GroupBoxFrame:
   {
      TQColor bgColor;
      TQWidget* w = (p->device() && p->device()->devType() == TQInternal::Widget) ?
            (TQWidget*)(p->device()) : 0;
      TQGroupBox* gb = ::tqt_cast<TQGroupBox*>(w);

      optionHandler->drawGroupBoxShadow() ?
            bgColor = TQColor(cg.background().dark( 100 + optionHandler->ShadowDarkness() )) :
            bgColor = TQColor(cg.background());
      TQColor bright( bgColor.dark( 110 ) );
      TQColor mid( bgColor.dark( 130 ) );
      TQColor dark( bgColor.dark( 150 ) );

      int titleHeight = (gb && !gb->title().isEmpty() && pe == PE_PanelGroupBox) ?
         p->fontMetrics().height()+(gb->isCheckable()?4:1) : 0;

      int x = r.x(); int right = r.right(); int bottom = r.bottom();
      int y2 = r.y();

      /***
      ok, to get the sunken look somwhat efficient and less glitchy
      we reset the groupbox brush and only repaint the title
      (saves us from several is item in groupbox checks as well)
      only problem left: draw the parents brush on the title window aligned...
      ***/

      if (gb && titleHeight)
      {
         bool hadClip = p->hasClipping();
         TQRegion oldClip = p->clipRegion();
         if (gb->parentWidget())
         {
            const TQPixmap *pix = gb->parentWidget()->paletteBackgroundPixmap();

            if (optionHandler->drawGroupBoxShadow())
            {
               TQPointArray pa1(3);
               pa1.setPoint(0, x,y2);
               pa1.setPoint(1, x+5,y2);
               pa1.setPoint(2, x,y2+5);
               TQPointArray pa2(3);
               pa2.setPoint(0, right-5,y2);
               pa2.setPoint(1, right,y2);
               pa2.setPoint(2, right,y2+5);
               TQPointArray pa3(3);
               pa3.setPoint(0, right,bottom-5);
               pa3.setPoint(1, right,bottom);
               pa3.setPoint(2, right-5,bottom);
               TQPointArray pa4(3);
               pa4.setPoint(0, x+5,bottom);
               pa4.setPoint(1, x,bottom);
               pa4.setPoint(2, x,bottom-5);

               TQRegion reg2(0,0, r.right(), titleHeight);
               p->setClipRegion(TQRegion(pa1)+TQRegion(pa2)+TQRegion(pa3)+TQRegion(pa4)+reg2);
            }
            else
               p->setClipRect(0,0,r.right(),titleHeight);
            pix ? p->drawTiledPixmap( TQRect( 0, 0, w->width(), w->height()), *pix, w->backgroundOffset()) : p->fillRect(TQRect(0, 0, w->width(), w->height()),w->parentWidget()->backgroundBrush());
         }
         if (gb && !gb->isCheckable())
         {
            TQString title = gb->title();
            TQFont font( p->font() );
            font.setBold( true );
            p->setFont( font );
            drawItem( p, TQRect(10,0,r.width(),titleHeight), ShowPrefix, cg, flags & Style_Enabled, 0, title, -1, &cg.text() );
         }
         p->setClipRegion(oldClip);
         p->setClipping(hadClip);
      }

      //outer rect
      // top
      p->setPen( dark );
      if (pe == PE_PanelGroupBox)
      {
         p->drawLine( x + 6, y2, right - 6, y2 );
         // left points
         p->drawPoint(x+3,y2+1);p->drawPoint(x+4,y2+1);
         p->drawPoint(x+2,y2+2);
         p->drawPoint(x+1,y2+3);
         // right points
         p->drawPoint(right-3,y2+1);p->drawPoint(right-4,y2+1);
         p->drawPoint(right-2,y2+2);
         p->drawPoint(right-1,y2+3);
         // vertcal outer lines
         p->drawLine(x,y2+5,x,bottom-5);
         p->drawLine(right,y2+5,right,bottom-5);
      }
      else
      {
         // vertcal outer lines
         p->drawLine(x,y2,x,bottom-5);
         p->drawLine(right,y2,right,bottom-5);
      }

      p->setPen( mid );
      if (pe == PE_PanelGroupBox)
      {
      // top stuff
         p->drawPoint(x+4, y2);p->drawPoint(x+5,y2);
         p->drawPoint(right-4, y2);p->drawPoint(right-5,y2);
         p->drawPoint(x+2, y2+1);
         p->drawPoint(right-2, y2+1);
         p->drawLine(x+5,y2 + 1, right - 5, y2 + 1);
         p->drawPoint(x+1,y2+2);
         p->drawPoint(right-1,y2+2);
         p->drawPoint(x+2,y2+3);
         p->drawPoint(right-2,y2+3);
         p->drawPoint(x,y2+4);p->drawPoint(x+1,y2+4);
         p->drawPoint(right,y2+4);p->drawPoint(right+1,y2+4);
      }
      // bottom stuff
      p->drawPoint(x,bottom - 4); p->drawPoint(x+1,bottom - 4);
      p->drawPoint(right,bottom - 4); p->drawPoint(right-1,bottom - 4);
      p->drawPoint(x+1,bottom - 3);
      p->drawPoint(right-1,bottom - 3);
      p->drawPoint(x+1,bottom - 2); p->drawPoint(x+2,bottom - 2);
      p->drawPoint(right-1,bottom - 2); p->drawPoint(right-2,bottom - 2);
      p->drawPoint(x+2, bottom - 1); p->drawPoint(x+3, bottom - 1);
      p->drawPoint(right-2, bottom - 1); p->drawPoint(right-3, bottom - 1);
      p->drawLine(x + 4, bottom,right - 4, bottom);

      p->setPen(bright);
      // top stuff
      if (pe == PE_PanelGroupBox)
      {
         p->drawPoint(x+3,y2);p->drawPoint(right-3,y2);
         p->drawLine(x+4,y2+2,right-4,y2+2);
         p->drawPoint(x,y2+3);p->drawPoint(x+3,y2+3);
         p->drawPoint(right,y2+3);p->drawPoint(right-3,y2+3);
         p->drawPoint(x+2,y2+4);p->drawPoint(right-2,y2+4);
         // vertical lines
         p->drawLine(x+1,y2+5,x+1,bottom-5);
         p->drawLine(right-1,y2+5,right-1,bottom-5);
      }
      else
      {
         // vertical lines
         p->drawLine(x+1,y2,x+1,bottom-5);
         p->drawLine(right-1,y2,right-1,bottom-5);
      }
      // bottom stuff
      p->drawPoint(x, bottom-3);p->drawPoint(right, bottom-3);
      p->drawPoint(x+3, bottom);p->drawPoint(right-3, bottom);

      break;
   }
   case PE_StatusBarSection:
   {
      break;
   }
   case PE_WindowFrame:
   {
      drawEditFrame( p, r, cg, false, false, true );
      break;
   }
   case PE_Panel:
   {
      bool sunken = flags & Style_Sunken;
      if (!(isKicker && optionHandler->RemoveKickerBevel()))
         sunken ? drawEditFrame( p, r, cg ) : drawEditFrame( p, r, cg, false, false, true );
      break;
   }
   case PE_PanelTabWidget:
   {
      // don't ask
      bool isDialog = optionHandler->TabStyle() == Clever &&
      (p->device() && p->device()->devType() == TQInternal::Widget)&&
      ((TQWidget*)p->device())->topLevelWidget()->inherits("TQDialog");

      TQColor bright( cg.background().dark( 110 ) );
      TQColor mid( cg.background().dark( 130 ) );
      TQColor dark( cg.background().dark( 150 ) );
      int x = r.x(); int right = r.right(); int bottom = r.bottom(); int y2 = r.y();
      if (isDialog || optionHandler->TabStyle() == Chooser)
      {
         //outer rect
         // top
         p->setPen( dark );
         // vertcal outer lines
         p->drawLine(x,y2,x,bottom-5);
         p->drawLine(right,y2,right,bottom-5);

         p->setPen( mid );
         // bottom stuff
         p->drawPoint(x,bottom - 4); p->drawPoint(x+1,bottom - 4);
         p->drawPoint(right,bottom - 4); p->drawPoint(right-1,bottom - 4);
         p->drawPoint(x+1,bottom - 3);
         p->drawPoint(right-1,bottom - 3);
         p->drawPoint(x+1,bottom - 2); p->drawPoint(x+2,bottom - 2);
         p->drawPoint(right-1,bottom - 2); p->drawPoint(right-2,bottom - 2);
         p->drawPoint(x+2, bottom - 1); p->drawPoint(x+3, bottom - 1);
         p->drawPoint(right-2, bottom - 1); p->drawPoint(right-3, bottom - 1);
         p->drawLine(x + 4, bottom,right - 4, bottom);

         p->setPen(bright);
         // top stuff
         // vertical lines
         p->drawLine(x+1,y2,x+1,bottom-5);
         p->drawLine(right-1,y2,right-1,bottom-5);

         // bottom stuff
         p->drawPoint(x, bottom-3);p->drawPoint(right, bottom-3);
         p->drawPoint(x+3, bottom);p->drawPoint(right-3, bottom);
         break;
      }
      else
      {
         p->setPen( mid );
         p->drawLine( x, y2, x, bottom-2 );
         p->drawLine( right, y2, right, bottom-2 );
         p->setPen( dark );
         p->drawLine( x, bottom-1, right, bottom-1 );
         p->drawLine( x, bottom, right, bottom );
         break;
      }
   }
   case PE_PanelLineEdit:
   {
      bool focused = flags & Style_HasFocus;
      bool isHTML = p->device() && p->device()->devType() == TQInternal::Widget && isHTMLWidget((TQWidget*)p->device());
      drawEditFrame( p, r, cg, isHTML, focused, false);
      break;
   }
   case PE_PanelPopup:
   {
      int x, y, w , h;
      r.rect( &x, &y, &w, &h );
      TQColor c( optionHandler->UseCustomMenuColor()?
            optionHandler->Color():
            optionHandler->MenuColorButton()?
            optionHandler->buttonColor():
            optionHandler->bgColor() );
      p->setPen( c.dark( 140 ) );
      p->drawRect( x, y, w, h );
      p->setPen( c.light( 120 ) );
      p->drawRect( x + 1, y + 1, w - 2, h - 2 );
      break;
   }
   case PE_PanelMenuBar:
   {
      break;
   }
   case PE_PanelDockWindow:
   {
      break;
   }
   case PE_Separator:
   case PE_DockWindowSeparator:
   {
      break; //don't draw anything
      if (!(p->device() && p->device()->devType() == TQInternal::Widget && ::tqt_cast<TQToolBar*>((TQWidget*)p->device())))
      {
         if ( !( flags & Style_Horizontal ) )
         {
            p->setPen( cg.mid() );
            p->drawLine( 4, r.height() / 2, r.width() - 5, r.height() / 2 );
            p->setPen( cg.light() );
            p->drawLine( 4, r.height() / 2 + 1, r.width() - 5, r.height() / 2 + 1 );
         }
         else
         {
            p->setPen( cg.mid() );
            p->drawLine( r.width() / 2, 4, r.width() / 2, r.height() - 5 );
            p->setPen( cg.light() );
            p->drawLine( r.width() / 2 + 1, 4, r.width() / 2 + 1, r.height() - 5 );
         }
      }
      break;
   }
   case PE_SpinWidgetUp:
   case PE_SpinWidgetDown:
   {
      bool sunken = on || down;
      bool hover = flags & Style_MouseOver;
      int x = r.x() + ( r.width() - 7 ) / 2;
      int y = pe == PE_SpinWidgetDown ? r.y() + 1 : r.bottom() - 7;
      TQPen oldPen( p->pen() );
      TQBrush oldBrush( p->brush() );
      p->setPen( sunken ? cg.button() : hover ? cg.mid() : cg.text() );
      p->setBrush( sunken ? cg.button() : hover ? cg.mid() : cg.text() );
      p->drawPixmap( x, y, pe == PE_SpinWidgetUp ? *sbUp : *sbDown );
      p->setBrush( oldBrush );
      p->setPen( oldPen );
      break;
   }
   case PE_CheckMark:
   {
      TQPen oldPen( p->pen() );
      p->setPen( flags & Style_On ? cg.highlightedText() : optionHandler->textColor() );
      p->drawPixmap(r.x() + r.width()/2 - 4,r.y() + r.height()/2 - 4,*checkmark);
      p->setPen( oldPen );
      break;
   }
   default:
   {
      if ( (pe >= PE_ArrowUp && pe <= PE_ArrowLeft ) || pe == PE_HeaderArrow)
      {
         TQBrush oldBrush(p->brush());
         TQColor tmpC = flags & Style_Enabled ? (flags & Style_Down || flags & Style_Sunken) && pe != PE_HeaderArrow ? cg.light() : cg.buttonText() : cg.mid();
         if (tmpC == TQt::black) tmpC = TQColor(85,85,85);
         p->setBrush(tmpC);
         int x = r.width() > 7 ? r.x() + r.width()/2 - 4 : r.right() - 7;
         int y = r.height() > 7 ? r.y() + r.height()/2 - 4 : r.bottom() - 7;

         switch ( pe )
         {
         case PE_ArrowRight:
         {
            p->drawPixmap(x,y,*sbRight);
            break;
         }
         case PE_ArrowUp:
         {
            p->drawPixmap(x,y,*sbUp);
            break;
         }
         case PE_ArrowDown:
         {
            p->drawPixmap(x,y,*sbDown);
            break;
         }
         case PE_HeaderArrow:
         {
            if (flags & Style_Up)
               p->drawPixmap(x,y,*sbUp);
            else
               p->drawPixmap(x,y,*sbDown);
            break;
         }
         default:
         {
            p->drawPixmap(x,y,*sbLeft);
            break;
         }
      }
      p->setBrush( oldBrush );
   }
   else
      TDEStyle::drawPrimitive( pe, p, ceData, elementFlags, r, cg, flags, opt );
   }
   } // general switch
}

void LiquidStyle::drawTDEStylePrimitive( TDEStylePrimitive kpe,
                                         TQPainter* p,
                                         const TQStyleControlElementData &ceData,
                                         ControlElementFlags elementFlags,
                                         const TQRect &r,
                                         const TQColorGroup &cg,
                                         SFlags flags,
                                         const TQStyleOption &opt,
                                         const TQWidget* widget ) const
{
   switch ( kpe )
   {
   case KPE_ToolBarHandle:
   {
      if (widget && widget->parentWidget() && widget->parentWidget()->hasMouse())
      {
         int x, y, w, h;
         r.rect( &x, &y, &w, &h );
         w = (int)((w-3)/2);
         TQColor c( (optionHandler->style() == Brushed) ? cg.background() : cg.background().dark(120) );
         p->setPen(c);
         p->setBrush(c);
         for (int i = 0; i < h-3; i += 5 )
            p->drawEllipse(x+w,y+i,3,3);
      }
      break;
   }
   case KPE_GeneralHandle:
   {
      if (!widget)
         break;
      if ( widget->inherits( "AppletHandleDrag" ) )
      {
         int x, y, w, h;
         r.rect( &x, &y, &w, &h );
         w = (int)((w-3)/2);
         TQColor c( widget->hasMouse() ? cg.button() : cg.background().dark(110) );
         p->setPen(c);
         p->setBrush(c);
         for (int i = 0; i < h-3; i += 5 )
            p->drawEllipse(x+w,y+i,3,3);
         break;
      }
      else if (widget->hasMouse())
      {
         if (optionHandler->style() == Brushed)
         {
            drawCombo( p, cg, cg.button(), r.x(), r.y(), r.width(), r.height()+2, false, false, false, center);
         }
         else
         {
            p->fillRect(r,cg.button());
            p->setPen(cg.button().dark( 100 + optionHandler->stippleContrast() ));
            int x=r.x();
            int y=r.y();
            int w=r.width();
            int h=r.height();
            for (int i = y;i < y+h; i += 4 )
            {
               p->drawLine( x, i, x+w, i );
               p->drawLine( x, i + 1, x+w, i + 1 );
            }
         }
      }
      else if (optionHandler->style() == Brushed && widget->parentWidget()) // needs alignment
      {
         p->drawTiledPixmap(r, *widget->paletteBackgroundPixmap(), widget->parentWidget()->backgroundOffset());
      }
      break;
   }
   case KPE_SliderGroove:
   {
      int x, y, w, h;
      r.rect( &x, &y, &w, &h );
      if (qstrcmp( tqApp->argv() [ 0 ], "kmix" ) == 0) x = x+3;
      if ( ceData.orientation == TQt::Horizontal )
      {
         int x2 = x + w - 1;
         y = y + ( h - 5 ) / 2;
         p->setPen( cg.background().dark( 135 ) );
         p->drawLine( x + 1, y, x2 - 1, y ); //1
         p->drawLine( x, y + 4, x2, y + 4 ); //5
         p->setPen( cg.background().dark( 150 ) );
         p->drawLine( x, y + 1, x2, y + 1 ); //2
         p->setPen( cg.background().dark( 115 ) );
         p->drawLine( x, y + 2, x2, y + 2 ); //3
         p->drawLine( x, y + 3, x2, y + 3 ); //4
         p->setPen( cg.background().light( 130 ) );
         p->drawLine( x + 1, y + 5, x2 - 1, y + 5 ); //6
      }
      else
      {
         int y2 = y + h - 1;
         x = x + ( w - 5 ) / 2;
         p->setPen( cg.background().dark( 135 ) );
         p->drawLine( x, y + 1, x, y2 - 1 );
         p->drawLine( x + 4, y, x + 4, y2 );
         p->setPen( cg.background().dark( 150 ) );
         p->drawLine( x + 1, y, x + 1, y2 );
         p->setPen( cg.background().dark( 115 ) );
         p->drawLine( x + 2, y, x + 2, y2 );
         p->drawLine( x + 3, y, x + 3, y2 );
         p->setPen( cg.background().light( 130 ) );
         p->drawLine( x + 5, y + 1, x + 5, y2 - 1 );
      }
   break;
   }
   case KPE_SliderHandle:
   {
      if (!widget)
      {
         p->drawPixmap( r.x(), r.y(), *getPixmap( flags & Style_Enabled ? RadioOffHover : RadioOff));
         break;
      }
      if ( ceData.orientation == TQt::Horizontal )
         (widget && widget->height() < 17) ? p->drawPixmap( r.x(), r.y(), *getPixmap( flags & Style_Enabled ? RadioOffHover : RadioOff)) : p->drawPixmap( r.x(), (optionHandler->style() == Milk) ? r.y() : r.y()+2, *getPixmap( flags & Style_Enabled ? HSlider : HSliderInactive));
      else
      {
         bool right = (( const TQSlider * ) widget )->tickmarks() == TQSlider::NoMarks || (( const TQSlider * ) widget )->tickmarks() == TQSlider::Right;
         (widget && widget->width() < 17) ? p->drawPixmap( r.x()+2, r.y(), *getPixmap( flags & Style_Enabled ? RadioOffHover : RadioOff)) : p->drawPixmap( (optionHandler->style() == Milk) ? r.x() : right ? r.x()+5 : r.x()-3, r.y(), *getPixmap( flags & Style_Enabled ? (right ? VSlider : VSliderAbove) : (right ? VSliderInactive : VSliderAboveInactive)));
      }
      break;
   }
   case KPE_ListViewExpander:
   {
      p->fillRect(r,TQt::green);
    // 				int radius = ( r.width() - 4 ) / 2;
    // 				int centerx = r.x() + r.width() / 2;
    // 				int centery = r.y() + r.height() / 2;
    //
    // 				int red, green, blue;
    // 				red = ( cg.dark().red() >> 1 ) + ( cg.base().red() >> 1 );
    // 				green = ( cg.dark().green() >> 1 ) + ( cg.base().green() >> 1 );
    // 				blue = ( cg.dark().blue() >> 1 ) + ( cg.base().blue() >> 1 );
    // 				TQColor blendColor( red, green, blue );
    //
    // 				p->setPen( cg.dark() );
    // 				p->drawLine( r.x() + 1, r.y(), r.right() - 1, r.y() );
    // 				p->drawLine( r.x() + 1, r.bottom(), r.right() - 1, r.bottom() );
    // 				p->drawLine( r.x(), r.y() + 1, r.x(), r.bottom() - 1 );
    // 				p->drawLine( r.right(), r.y() + 1, r.right(), r.bottom() - 1 );
    // 				p->setPen( blendColor );
    // 				p->drawPoint( r.x(), r.y() );
    // 				p->drawPoint( r.right(), r.y() );
    // 				p->drawPoint( r.x(), r.bottom() );
    // 				p->drawPoint( r.right(), r.bottom() );
    // 				p->setPen( cg.light() );
    // 				p->drawRect( r.x() + 1, r.y() + 1, r.width() - 2, r.height() - 2 );
    // 				p->fillRect( r.x() + 2, r.y() + 2, r.width() - 4, r.height() - 4,
    // 				             cg.background() );
    // 				p->setPen( cg.text() );
    // 				p->drawLine( centerx - radius, centery, centerx + radius, centery );
    // 				if ( flags & Style_On )
    // 					p->drawLine( centerx, centery - radius, centerx, centery + radius );
      break;
   }
   default:
      TDEStyle::drawTDEStylePrimitive( kpe, p, ceData, elementFlags, r, cg, flags, opt, widget );
   }
}

void LiquidStyle::drawControl( ControlElement element,
                               TQPainter *p,
                               const TQStyleControlElementData &ceData,
                               ControlElementFlags elementFlags,
                               const TQRect &r,
                               const TQColorGroup &cg,
                               SFlags flags,
                               const TQStyleOption &opt,
                               const TQWidget *widget ) const
{
   switch ( element )
   {
   case CE_ProgressBarGroove:
   {
      p->setPen(cg.background().dark(160));
      p->drawRect(r);
      drawCombo( p, cg, cg.background(), r.x()+1, r.y()+1, r.width()-2, r.height()+1, false, false, false, center );
      break;
   }
   case CE_ProgressBarContents:
   {
//	tqWarning("%s - %s,%s : %s,%s",tqApp->argv()[0],widget->className(),widget->name(),widget->parentWidget()->className(),widget->parentWidget()->name());
      const TQProgressBar *progress = ( const TQProgressBar * ) widget;
      TQRect contentsR( subRect( SR_ProgressBarContents, ceData, elementFlags, widget ) );
      double val = progress->progress();
      bool reverse = TQApplication::reverseLayout();
      val = val / progress->totalSteps();
      if ( val > 0.0 )
      {
         int w = TQMIN( contentsR.width(), ( int ) (val * contentsR.width() ) );
         if ( w > 1 )
         {
            int x = contentsR.x();
            int y = contentsR.y();
            TQRect progressRect;
            if (reverse)
               progressRect = TQRect(x+(contentsR.width()-w), y, w, contentsR.height()+1);
            else
               progressRect = TQRect(x, y, w, contentsR.height()+1);
            if (optionHandler->ProgressBar() == liquid)
            {
               int x2 = x + w - 1;
               int y2 = contentsR.bottom();
               //Clip to the old rectangle
               p->setClipRect(progressRect, TQPainter::CoordPainter);
               //Expand
               progressRect.setLeft(progressRect.x() - progAnimShift);
               p->setPen(cg.button().dark(120));
               p->drawLine(x, y, x2, y);
               p->drawLine(x, y, x, y2);
               p->drawLine(x+1, y2+1, x2-1, y2+1);
               p->setPen(cg.button().dark(110));
               p->drawLine(x2, y, x2, y2);
               p->drawLine(x, y2, x2, y2);
               TQPixmap * pix = getPixmap( Progress );
               p->drawTiledPixmap(/*x+1, y+1, w-2, contentsR.height()-2*/progressRect, *pix);
            }
            else if (optionHandler->ProgressBar() == baghira)
            {
               drawCombo( p, cg, cg.button(), r.x()-1, r.y()-1, w, contentsR.height()+5, false, false, false, center);
            }
            else
            {
               ButtonTile *progress2Tile = progress2Dict.find( cg.button().rgb() );
               if ( !progress2Tile )
               {
                  TQPixmap *pix = getPixmap(progress2);
                  progress2Tile = separateTiles( pix, 0, 15, 38, 1, 0, true);
                  if ( !progress2Tile )
                  {
                     tqWarning( "Progress tile is NULL!" );
                     return ;
                  }
                  else
                  {
                     LiquidStyle *ptr = const_cast<LiquidStyle*>( this );
                     ptr->progress2Dict.insert( cg.button().rgb(), progress2Tile );
                  }
               }
               //Clip to the old rectangle
               p->setClipRect(progressRect, TQPainter::CoordPainter);
               //Expand
               progressRect.setLeft(progressRect.x() - 38 + prog2AnimShift);
               int h; /*x, y, w;*/
               progressRect.rect(&x, &y, &w, &h);
               bool tooSmall = h < 32;
               int mid = h/2;
               p->drawTiledPixmap(x,tooSmall ? mid + 1 : progressRect.bottom()-15,w,16, *progress2Tile->pixmap(TileBtm));
               p->drawTiledPixmap(x,tooSmall ? mid : y+15,w,tooSmall ? 1 : h-31, *progress2Tile->pixmap(TileMiddle));
               p->drawTiledPixmap(x,tooSmall ? mid - 15 : y,w,15, *progress2Tile->pixmap(TileTop));
            }
         }
      }
      break;
   }/*
   case CE_ToolButtonLabel:
   {
      const TQToolButton *toolbutton = (const TQToolButton *) widget;
      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 = TQt::black;//(flags & (Style_Down | Style_On)) ? tqApp->palette().color(TQPalette::Active,TQColorGroup::ButtonText) : toolbutton->paletteForegroundColor();

         if (toolbutton->iconSet().isNull() &&
               ! toolbutton->text().isNull() &&
               ! toolbutton->usesTextLabel()) {
                  int alignment = AlignCenter | ShowPrefix;
                  if (!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, TQStyleOption::Default, 0, widget))
                     alignment |= NoAccel;

                  rect.moveBy(shiftX, shiftY);
                  drawItem(p, rect, alignment, cg,
                           flags & Style_Enabled, 0, toolbutton->text(),
                           toolbutton->text().length(), &btext);
               } else {
                  TQPixmap pm;
                  TQIconSet::Size size =
                     toolbutton->usesBigPixmap() ? TQIconSet::Large : TQIconSet::Small;
                  TQIconSet::State state =
                     toolbutton->isOn() ? TQIconSet::On : TQIconSet::Off;
                  TQIconSet::Mode mode;
                  if (! toolbutton->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 = toolbutton->iconSet().pixmap( size, mode, state );

                  if ( toolbutton->usesTextLabel() )
                  {
                     p->setFont( toolbutton->font() );
                     TQRect pr = rect, tr = rect;
                     int alignment = ShowPrefix;
                     if (!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, TQStyleOption::Default, 0, widget))
                        alignment |= NoAccel;

                     if ( toolbutton->textPosition() == 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, toolbutton->textLabel(),
                              toolbutton->textLabel().length(), &btext);
                  }
                  else
                  {
                     rect.moveBy(shiftX, shiftY);
                     drawItem( p, rect, AlignCenter, cg, TRUE, &pm, TQString::null );
                  }
               }
      }

      break;
   }*/

/*
   case CE_HeaderLabel:
   {
      TQRect rect = r;
      const TQHeader* header = (const TQHeader *) widget;
      int section = opt.headerSection();

      TQIconSet* icon = header->iconSet( section );
      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 );
         rect.setLeft( rect.left() + pixw + 2 );
      }
      drawItem ( p, rect, AlignVCenter, cg, flags & Style_Enabled,
                 0, header->label( section ), -1, (isTaskContainer && (flags & Style_MouseOver)) ? &(tqApp->palette().color(TQPalette::Active,TQColorGroup::ButtonText)) :  &(cg.buttonText()) );
      break;
   }*/
   case CE_ProgressBarLabel:
   {
      if (optionHandler->DrawProgressLabel())
      {
         TQRect contentsR( subRect( SR_ProgressBarContents, ceData, elementFlags, widget ) );
         if ( !contentsR.isValid() )
            return ;
         TQFont font( p->font() );
         font.setBold( true );
         p->setFont( font );
         p->setPen( widget->colorGroup().buttonText() );
         p->setClipRect(r, TQPainter::CoordPainter);
	 p->drawText( contentsR, AlignCenter, ( ( const TQProgressBar * ) widget ) ->progressString() );
      }
      break;
   }
   case CE_TabBarTab:
   { // new style with tiled pixmaps
	   if ( !widget || !widget->parentWidget(true) )
		   break;
	   const TQTabBar *tabBar = ( const TQTabBar * ) widget;
	   bool selected = flags & Style_Selected;
	   bool hover = currentTabBar && currentTabBar == tabBar && tabBar->indexOf(opt.tab()->identifier()) == hoveredTabIndex;

	   myPosition pos;
	   if (tabBar->count() == 1)
		   pos = full;
	   else if ((tabBar->indexOf(opt.tab()->identifier()) == 0))
		   pos = left;
	   else if (tabBar->indexOf(opt.tab()->identifier()) == tabBar->count() - 1)
		   pos = right;
	   else
		   pos = center;

	   TQColor c;
	   if (hover || selected)
	   {
		   if (optionHandler->useCustomColors())
			   c = optionHandler->customColor(CustomTabOn);
		   else
			   c = optionHandler->buttonColor();
	   }
	   else
	   {
		   if (optionHandler->useCustomColors())
			   c = optionHandler->customColor(CustomTabOff);
		   else
			   c = optionHandler->InactiveButtonColor();
	   }

	   bool isDialog = optionHandler->TabStyle() == Clever && widget->topLevelWidget()->inherits("TQDialog");
	   if (isDialog || optionHandler->TabStyle() == Chooser)
		   drawCombo( p, cg, c, r.x(), r.y(), r.width(), r.height(), false, false, false, pos );
	   else
	   {
		   LiquidStyle *ptr = const_cast<LiquidStyle*>( this );
		   bool above = tabBar->shape() == TQTabBar::RoundedAbove || tabBar->shape() == TQTabBar::TriangularAbove;
		   TQPixmap *pix;
		   if (above)
			   pix = selected ? getPixmap( TabDown ) : getPixmap( Tab );
		   else
			   pix = selected ? getPixmap( belowTabDown ) : getPixmap( belowTab );
		   ButtonTile *tabTile = above ? tabDict.find( c.rgb() ) : inverseTabDict.find(c.rgb());
		   if ( !tabTile )
			   tabTile = separateTiles( pix, 9, 15, 67, 1, 0, false);
		   if ( !tabTile )
		   {
			   tqWarning( "Tab tile is NULL!" );
			   return ;
		   }
		   else
			   above ? ptr->tabDict.insert( c.rgb(), tabTile ) : ptr->inverseTabDict.insert( c.rgb(), tabTile );

		   int offset;
		   selected ? offset = 0 : offset = 2;

		   if ( r.width() > 18 )
		   {
			   p->drawTiledPixmap( r.x() + 9, r.y() + offset, r.width() - 18, 15, *tabTile->pixmap( TileTop ) );
			   p->drawTiledPixmap( r.x() + 9, r.height() - 11, r.width() - 18, 11, *tabTile->pixmap( TileBtm ) );
		   }
		   if ( r.height() + offset > 26 )
		   {
			   p->drawTiledPixmap( r.x() + 0, r.y() + 15 + offset, 9, r.height() - 26 - offset, *tabTile->pixmap( TileLeft ) );
			   p->drawTiledPixmap( r.right() - 8, r.y() + 15 + offset, 9, r.height() - 26 - offset, *tabTile->pixmap( TileRight ) );
		   }
		   if ( r.width() > 18 && r.height() + offset > 22 )
			   p->drawTiledPixmap( r.x() + 9, r.y() + 15 + offset, r.width() - 18, r.height() - 26 - offset, *tabTile->pixmap( TileMiddle ) );
		   p->drawPixmap( r.x() + 0, r.y() + offset, *tabTile->pixmap( TileTopLeft ) );
		   p->drawPixmap( r.right() - 8, r.y() + offset, *tabTile->pixmap( TileTopRight ) );
		   p->drawPixmap( r.x() + 0, r.height() - 11, *tabTile->pixmap( TileBtmLeft ) );
		   p->drawPixmap( r.right() - 8, r.height() - 11, *tabTile->pixmap( TileBtmRight ) );

		   p->setPen( optionHandler->buttonColor());
		   bool drawPoint = optionHandler->CenterTabs() || pos == center || pos == right;
		   if ( selected )
		   {
			   if (drawPoint) p->drawPoint(r.x(), above ? r.bottom() : r.y());
			   p->drawPoint(r.right(), above ? r.bottom() : r.y());
		   }
		   else
		   {
			   p->drawLine( r.x() + drawPoint ? 0 : 1, above ? r.bottom() : r.y(), r.right(), above ? r.bottom() : r.y() );
			   p->setPen( optionHandler->buttonColor().dark( 158 ));
			   p->drawLine( r.x() + drawPoint ? 0 : 1, above ? r.bottom()-1 : r.y()+1, r.right(), above ? r.bottom()-1 : r.y() + 1 );
		   }
	   }
	   break;
   }
   case CE_TabBarLabel:
   {
	   if ( opt.isDefault() )
		   return ;
	   TQTab *t = opt.tab();
	   const TQTabBar * tb = ( const TQTabBar * ) widget;
	   if ( ( tb->currentTab() != t->identifier() ))
	   {
		   if (optionHandler->TabStyle() == TrueTab ||
				   (optionHandler->TabStyle() == Clever && !(widget->topLevelWidget()->inherits("TQDialog"))))
		   {
			   drawItem( p, TQRect( r.x(), r.y() + 1, r.width(), r.height() ), AlignCenter | ShowPrefix, cg, flags & Style_Enabled, 0, t->text(), -1/*, &cg.text()*/ );
			   break;
		   }
		   drawItem( p, TQRect( r.x(), r.y(), r.width(), r.height() ), AlignCenter | ShowPrefix, cg, flags & Style_Enabled, 0, t->text(), -1/*, &cg.text()*/ );
		   break;
	   }
	   drawItem( p, TQRect( r.x(), r.y(), r.width(), r.height() ), AlignCenter | ShowPrefix, cg, flags & Style_Enabled, 0, t->text(), -1/*, &cg.text()*/ );
	   break;
   }
   case CE_PushButton:
   {
	   //       if (_htmlWidgetWId == widget->winId())
	   //          return;
	   TQPushButton *btn = ( TQPushButton* ) widget;
	   const_cast<LiquidStyle*>( this ) ->isHTMLButton = isHTMLWidget( btn );
	   ButtonFadeInfo *bfi_ = bfi[btn->winId()];
	   if ( widget == highlightWidget || (bfi_ && !bfi_->fadeIn) )
		   flags |= Style_MouseOver;
	   if (btn->isDefault())
		   flags |= Style_HasFocus;
	   // TQt messes this up with WindowOrigin, so we do it ourselves :P
	   if ( !isPlain() && !btn->autoMask() )
		   const_cast<LiquidStyle*>( this ) ->btnOffset = btn->backgroundOffset();
	   const_cast<LiquidStyle*>( this ) ->paintWidget = const_cast<TQWidget*>( widget );
	   drawPrimitive( PE_ButtonDefault, p, ceData, elementFlags, r, cg, flags, TQStyleOption( btn ));
	   const_cast<LiquidStyle*>( this ) ->paintWidget = 0L;
	   const_cast<LiquidStyle*>( this ) ->isHTMLButton = false;
	   break;
   }
   case CE_PushButtonLabel:
   {
	   //       if (_htmlWidgetWId == widget->winId())
	   //          return;
	   const TQPushButton *btn = ( const TQPushButton* ) widget;
	   int x, y, w, h;
	   r.rect( &x, &y, &w, &h );

	   if ( btn->isOn() || btn->isDown() )
		   flags |= Style_Sunken;

	   int xoff = x;
	   if ( btn->iconSet() && !btn->iconSet() ->isNull() )
	   {
		   TQIconSet::Mode mode = btn->isEnabled() ? TQIconSet::Normal : TQIconSet::Disabled;
		   if ( mode == TQIconSet::Normal && btn->hasFocus() )
			   mode = TQIconSet::Active;

		   TQIconSet::State state = TQIconSet::Off;
		   if ( btn->isToggleButton() && btn->isOn() )
			   state = TQIconSet::On;

		   TQPixmap pix( btn->iconSet() ->pixmap( TQIconSet::Small, mode, state ) );
		   xoff += (x<6?8:2);
		   if (btn->text().isEmpty() && !btn->pixmap())
			   p->drawPixmap( x + w/2 - pix.width()/2, y + h / 2 - pix.height() / 2, pix );
		   else
			   p->drawPixmap( x<6?6:x, y + ( h - pix.height() ) / 2, pix );
	   }

	   if ( btn->isMenuButton() )
	   {
		   drawPrimitive( PE_ArrowDown, p, ceData, elementFlags, TQRect( w-14, (int)(h/2), 7, 7 ) , cg, flags, opt );
		   w -= 14;
	   }
	   TQColor tmp;

	   tmp = btn->isDown() && !optionHandler->IcyButtons() ? btn->colorGroup().highlightedText() : btn->colorGroup().buttonText();
	   drawItem( p, TQRect( xoff, optionHandler->style() == Milk ? y-1 : y, w, h ), AlignCenter | ShowPrefix, cg, btn->isEnabled(), btn->pixmap(), btn->text(), -1, &tmp );
	   break;
   }
   case CE_MenuBarItem:
   {
	   TQMenuItem *mi = opt.menuItem();
	   bool active = flags & Style_Active;
	   bool focused = flags & Style_HasFocus;

	   if ( active && focused )
	   {
		   optionHandler->glossyMenus() ?
			   drawCombo( p, cg, cg.highlight(), r.x(), r.y()-1, r.width(), r.height() + 5, false, false, false, center ) :
			   p->fillRect(r,cg.highlight());
	   }

	   //       TQColor tmpColor( cg.background().dark( 120 ) );
	   if ( optionHandler->useShadowText() && !( active && focused ))
	   {
		   p->setPen(cg.background().dark( 120 ));
		   p->drawText(r, AlignCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, mi->text());
	   }
	   //          drawItem( p, TQRect( r.x() + 1, r.y() + 1, r.width(), r.height() ), AlignCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, cg, flags & Style_Enabled, mi->pixmap(), mi->text(), -1, &tmpColor );

	   //       drawItem( p, r, AlignCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, cg, flags & Style_Enabled, mi->pixmap(), mi->text(), -1, active && focused ? &(cg.highlightedText()) : &(cg.text()) );
	   p->setPen(active && focused ? cg.highlightedText() : cg.text());
	   p->drawText(r, AlignCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, mi->text());
	   break;
   }
   case CE_PopupMenuItem:
   {
	   int x,y,w, h;
	   r.rect( &x, &y, &w, &h );

	   const TQPopupMenu *popupmenu = ( const TQPopupMenu * ) widget;
	   TQMenuItem *mi = opt.menuItem();

	   int tab = opt.tabWidth();
	   int maxpmw = opt.maxIconWidth();
	   bool dis = mi && !mi->isEnabled();
	   bool checkable = popupmenu->isCheckable();
	   bool act = flags & Style_Active;
	   bool enabled = flags & Style_Enabled;
	   int checkcol = maxpmw;

	   TQColor menuBgColor(  optionHandler->UseCustomMenuColor() ? optionHandler->Color() : optionHandler->bgColor() );

	   if ( checkable )
		   checkcol = TQMAX( maxpmw, 20 );

	   if ( mi && mi->isSeparator() )
	   {
		   p->setPen( menuBgColor.dark( 130 ) );
		   p->drawLine( x + 1, y, x + w - 1, y );
		   p->setPen( menuBgColor.light( 120 ) );
		   p->drawLine( x+1, y + 1, x + w - 1 , y + 1 );
		   return ;
	   }
	   if ( act && mi && enabled)
	   {
		   optionHandler->glossyMenus() ?
			   drawCombo( p, cg, cg.highlight(), r.x(), r.y(), r.width(), r.height() + 2, false/*sunken*/, false/*hover*/, false, center ) :
			   p->fillRect(x,y,w,h,cg.highlight());
	   }
	   else
	   {
		   if (popupBack.isNull())
			   p->fillRect( x, y, w, h, popupmenu->backgroundBrush() );
		   else
			   p->drawTiledPixmap( x, y, w, h, popupBack );

		   if (act)
		   {
			   p->setPen(cg.highlight());
			   p->drawRect(x,y,w,h);
		   }
	   }
	   if ( !mi )
		   return ;

	   // Menu contents drawing code based on TQt's styles. TQt is property of
	   // TrollTech: www.trolltech.com. Used with permission.
	   int xpos = x;
	   TQRect vrect = visualRect( TQRect( xpos, y, checkcol, h ), r );
	   int xvis = vrect.x();

	   // icon
	   if (optionHandler->drawMenuStripe())
		   p->fillRect(x,y,h,h, optionHandler->menuStripeColor());
	   if ( mi->iconSet() )
	   {
		   TQIconSet::Mode mode = dis ? TQIconSet::Disabled : TQIconSet::Normal;
		   if ( act && !dis )
			   mode = TQIconSet::Active;
		   TQPixmap pixmap;
		   if ( checkable && mi->isChecked() )
			   pixmap = mi->iconSet() ->pixmap( TQIconSet::Small, mode, TQIconSet::On );
		   else
			   pixmap = mi->iconSet() ->pixmap( TQIconSet::Small, mode );
		   int pixw = pixmap.width();
		   int pixh = pixmap.height();
		   TQRect pmr( 0, 0, pixw, pixh );
		   pmr.moveCenter( vrect.center() );
		   p->setPen( cg.text() );
		   p->drawPixmap( pmr.topLeft(), pixmap );
	   }
	   else if ( checkable )
	   {
		   if ( mi->isChecked() )
		   {
			   int xp = xpos + windowsItemFrame;

			   SFlags cflags = Style_Default;
			   if ( !dis )
				   cflags |= Style_Enabled;
			   if ( act )
				   cflags |= Style_On;
			   drawPrimitive( PE_CheckMark, p, ceData, elementFlags, visualRect( TQRect( xp, y + windowsItemFrame, checkcol - 2 * windowsItemFrame, h - 2 * windowsItemFrame ), r ), cg, cflags );
		   }
	   }
	   TQColor discol;
	   if ( dis )
	   {
		   discol = cg.text();
		   p->setPen( discol );
	   }

	   int xm = windowsItemFrame + checkcol + windowsItemHMargin;
	   xpos += xm;

	   vrect = visualRect( TQRect( xpos, y + windowsItemVMargin, w - xm - tab + 1, h - 2 * windowsItemVMargin ), r );
	   xvis = vrect.x();
	   if ( mi->custom() )
	   {
		   p->save();
		   if ( dis && !act )
		   {
			   p->setPen( cg.light() );
			   mi->custom() ->paint( p, cg, act, !dis, xvis + 1, y + windowsItemVMargin + 1, w - xm - tab + 1, h - 2 * windowsItemVMargin );
			   p->setPen( discol );
		   }
		   mi->custom() ->paint( p, cg, act, !dis, xvis, y + windowsItemVMargin, w - xm - tab + 1, h - 2 * windowsItemVMargin );
		   p->restore();
	   }

	   // Text
	   TQString s = mi->text();
	   if ( !s.isNull() )
	   {
		   TQColor textColor, shadowColor;
		   shadowColor = optionHandler->bgColor().dark( 130 );

		   if ( dis )
			   textColor = shadowColor.light( 115 );
		   else if (/*!optionHandler->glossyMenus() && */act && mi)
			   textColor = cg.highlightedText();
		   else if ( optionHandler->UseCustomMenuColor())
			   textColor = optionHandler->textColor();
		   else
			   textColor = cg.text();

		   int t = s.find( '\t' );
		   int text_flags = AlignVCenter | ShowPrefix | DontClip | SingleLine;
		   text_flags |= ( TQApplication::reverseLayout() ? AlignRight : AlignLeft );
		   if ( t >= 0 )
		   {                         // draw tab text
			   int xp;
			   xp = x + w - tab - 20 - windowsItemHMargin - windowsItemFrame + 1;
			   TQString tabStr( s.right( s.length() - t - 1 ) );
			   if ( !tabStr.isEmpty() )
			   {
				   if ( optionHandler->useShadowText() )
				   {
					   p->setPen( shadowColor );
					   p->drawText( xp + 1, y + windowsItemVMargin + 1, w - xm - tab + 1, h - 2 * windowsItemVMargin, text_flags, tabStr );
				   }
				   p->setPen( textColor );
				   p->drawText( xp, y + windowsItemVMargin, w - xm - tab + 1, h - 2 * windowsItemVMargin, text_flags, tabStr );
			   }
			   s = s.left( t );
		   }
		   if ( optionHandler->useShadowText() && !(act && mi) )
		   {
			   p->setPen( shadowColor );
			   p->drawText( xvis + 1, y + windowsItemVMargin + 1, w - xm - tab + 1, h - 2 * windowsItemVMargin, text_flags, s, t );
		   }
		   p->setPen( textColor );
		   p->drawText( xvis, y + windowsItemVMargin, w - xm - tab + 1, h - 2 * windowsItemVMargin, text_flags, s, t );
	   }
	   else if ( mi->pixmap() )
		   // draw pixmap
	   {
		   TQPixmap * pixmap = mi->pixmap();
		   if ( pixmap->depth() == 1 )
			   p->setBackgroundMode( OpaqueMode );
		   p->drawPixmap( xvis, y + windowsItemFrame, *pixmap );
		   if ( pixmap->depth() == 1 )
			   p->setBackgroundMode( TransparentMode );
	   }
	   // Child menu
	   if ( mi->popup() )
	   {
		   int dim = (int)((float)( h - 2 * windowsItemFrame ) / 2);
		   PrimitiveElement arrow;
		   arrow = ( TQApplication::reverseLayout() ? PE_ArrowLeft : PE_ArrowRight );
		   xpos = x + w - windowsArrowHMargin - windowsItemFrame/* - dim*/-8;
		   vrect = visualRect( TQRect( xpos, y + h / 2 - dim / 2, /*dim*/8, dim ), r );
		   if ( act )
		   {
			   if ( !dis )
				   discol = cg.highlightedText();
			   TQColorGroup g2( discol, cg.highlight(), white, white, dis ? discol : white, discol, white );
			   drawPrimitive( arrow, p, ceData, elementFlags, vrect, g2, Style_Enabled );
		   }
		   else
		   {
			   if ( !dis )
				   discol = optionHandler->textColor();
			   TQColorGroup g2( discol, cg.background(), white, white, dis ? discol : white, discol, white );
			   drawPrimitive( arrow, p, ceData, elementFlags, vrect, g2, mi->isEnabled() ? Style_Enabled : Style_Default );
		   }
	   }
	   break;
   }
   /*
      case CE_ToolBoxTab:
      {
      break;
      }*/
   default:
   TDEStyle::drawControl( element, p, ceData, elementFlags, r, cg, flags, opt, widget );
   }
}


// void LiquidStyle::drawControlMask( ControlElement element, TQPainter *p, const TQWidget *widget, const TQRect &r, const TQStyleOption& opt ) const {
// 	switch ( element ) {
// 			case CE_PushButton: {
// 				p->fillRect( r, TQt::color1 );
// 				break;
// 				}
// 			default:
// 			TDEStyle::drawControlMask( element, p, widget, r, opt );
// 			break;
// 		}
// 	}

// void LiquidStyle::drawComplexControlMask( ComplexControl control, TQPainter *p, const TQWidget *widget, const TQRect &r, const TQStyleOption &opt ) const {
// // 	switch ( control ) {
// // 			case CC_ComboBox: {
// // 				drawControlMask( CE_PushButton, p, widget, r, opt );
// // 				break;
// // 				}
// // 			default:
// 			TDEStyle::drawComplexControlMask( control, p, widget, r, opt );
// //		}
// 	}

void LiquidStyle::drawComplexControl( ComplexControl control,
                                      TQPainter *p,
                                      const TQStyleControlElementData &ceData,
                                      ControlElementFlags elementFlags,
                                      const TQRect &r,
                                      const TQColorGroup &cg,
                                      SFlags flags,
                                      SCFlags controls,
                                      SCFlags active,
                                      const TQStyleOption &opt,
                                      const TQWidget *widget ) const
{
   switch ( control )
   {
   case CC_ComboBox:
   {
      bool sunken = (active & SC_ComboBoxArrow);// || (flags & Style_Active) || (flags & Style_Sunken) || (active & SC_ComboBoxListBoxPopup);
      bool hovered = (widget == highlightWidget) || (flags & Style_HasFocus);
      //       bool isHtml = isHTMLWidget( widget );
      const_cast<LiquidStyle*>( this ) ->paintWidget = const_cast<TQWidget*>( widget );
      TQPen oldPen( p->pen() );
      if ( controls & SC_ComboBoxArrow )
      {
         if ( controls & SC_ComboBoxEditField && ( ( const TQComboBox * ) widget ) ->editable())
         { // editable?
#if 0
						if ( optionHandler->buttonStyle() == Brushed )
						{ // rectangular?
							drawRectangularButton( p, cg, sunken ? cg.button().light( 110 ) : cg.button(), r.x(), r.y(), r.width(), r.height(), sunken, hovered, true, full/*, isHtml*/);
							p->fillRect( r.x() + 6, r.y() +2, r.width()-32, r.height() - 7, cg.background());
							p->setPen( oldPen );
							return ;
						}
						else
#endif
            { // round frame
               drawRoundFrame( p, r, cg, (flags & Style_HasFocus) || sunken , widget->backgroundOffset());
               p->setPen(cg.mid());
               p->drawPixmap(r.right() - 16, r.height()/2 - 2, *sbDown);
               p->setPen( oldPen );
               //                return;
            }
#if 0
						else
						{ // default!
							drawCombo( p, cg, active == SC_ComboBoxArrow ? cg.button().light( 110 ) : cg.button(), r.x(), r.y(), r.width(), r.height(), sunken, hovered, true, full );
							p->fillRect( r.x() + 6, r.y() +2, r.width()-32, r.height() - 7, cg.background());
							p->setPen( oldPen );
							return;
						}
#endif
         }
         else
         { // end editable - default handling
            if ( optionHandler->buttonStyle() == Brushed )
            { // retangular?
               drawRectangularButton( p, cg, sunken ? cg.button().light( 110 ) : cg.button(), r.x(), r.y(), r.width(), r.height(), sunken, hovered, true, full, isHTMLWidget( widget ));
               //                p->setPen( oldPen );
               //                return ;
            }
            else
            { //default plain good old combobox... ;)
               drawCombo( p, cg, active == SC_ComboBoxArrow ? cg.button().light( 110 ) : cg.button(), r.x(), r.y(), r.width(), r.height(), sunken, hovered, true, full, isHTMLWidget( widget ) );
                     //                p->setPen( oldPen );
                     //                return;
            }
         }
      }
      const_cast<LiquidStyle*>( this ) ->paintWidget = 0L;
      break;
   }
   case CC_ToolButton:
   {
      const TQToolButton *toolbutton = ( const TQToolButton * ) widget;
      const_cast<LiquidStyle*>( this ) ->paintWidget = const_cast<TQWidget*>( widget );
      const KAccessToolBarButton *toolbutton2 = 0L;
      TQRect button, menuarea;
      button = querySubControlMetrics( control, ceData, elementFlags, SC_ToolButton, opt, widget );
      menuarea = querySubControlMetrics( control, ceData, elementFlags, SC_ToolButtonMenu, opt, widget );
      if (::tqt_cast<TDEToolBarButton*>(toolbutton))
      {
               toolbutton2 = (const KAccessToolBarButton*)toolbutton;
#if GCC_VERSION < 40000
               if (toolbutton2->iconTextMode() == 3)
                     button.setBottom(button.bottom() - p->fontMetrics().height() - 1);
#endif
      }
      else if (toolbutton->usesTextLabel() && toolbutton->textPosition() == TQToolButton::BelowIcon)
               button.setBottom(button.bottom() - p->fontMetrics().height());
      menuarea.setX(menuarea.x() - 1);
      SFlags bflags = flags, mflags = flags;

      if ( active & SC_ToolButton )
               bflags |= Style_Down;
      if ( active & SC_ToolButtonMenu )
               mflags |= Style_Down;

      if ( widget == highlightWidget )
               bflags |= Style_MouseOver;
      if ( controls & SC_ToolButton )
      {
         bool sunken = mflags & ( Style_Down /*| Style_On*/ );
         bool hover = bflags & (Style_MouseOver | Style_On );

         if ( !optionHandler->useToolButtonFrame())// || !(toolbutton->parentWidget() &&  ( ::tqt_cast<TQToolBar*>(toolbutton->parentWidget()) || toolbutton->parentWidget()->inherits("KonqFrameTabs"))))
         {
            if ((!(hover || sunken) || (toolbutton->usesTextLabel() && toolbutton->textPosition() == TQToolButton::BelowIcon)) && toolbutton->parentWidget() &&                 !::tqt_cast<TQToolBar*>(toolbutton->parent()) &&                 toolbutton->parentWidget()->paletteBackgroundPixmap() &&                !toolbutton->parentWidget()->paletteBackgroundPixmap()->isNull())
            {
               TQPixmap pixmap = *(toolbutton->parentWidget()->paletteBackgroundPixmap());
               if (hover || sunken)
                        p->drawTiledPixmap( r.x(), button.bottom()+1, r.width(), p->fontMetrics().height(), pixmap, toolbutton->x(), toolbutton->y()+button.height() );
               else
                        p->drawTiledPixmap( r, pixmap, toolbutton->pos() );
            }
            if (hover || sunken)
            {
               const_cast<LiquidStyle*>( this ) ->paintWidget = const_cast<TQWidget*>( widget );
               if (optionHandler->toolbuttonStyle() != Brushed)
                  drawCombo( p, cg, sunken ? cg.button().light( 110 ) :
                           (hover ||  (cg.button() != tqApp->palette().active().button())) ? cg.button() :
                           optionHandler->InactiveButtonColor(), button.x(), button.y(), button.width(),
                           button.height(), sunken, hover, false, full );
               else
                  drawRectangularButton( p, cg, sunken ? cg.button().light( 110 ) : cg.button(),
                           button.x(), button.y(), button.width(), button.height(),
                           sunken, hover, false);
               const_cast<LiquidStyle*>( this ) ->paintWidget = 0L;
            }
         }
         else
         {
            myPosition pos = full;
            TDEToolBar *bar = NULL;

            if (toolbutton2 && toolbutton2->parentWidget() && ::tqt_cast<TDEToolBar*>(toolbutton2->parentWidget()) )
            { //position calculation - would be nice if tdetoolbarbutton provided this as flag
               bar = (TDEToolBar*)toolbutton2->parentWidget();
               int buttonId = toolbutton2->id();
               int buttonIndex = bar->itemIndex(buttonId);

               // ok, this is a very hackish heck of a hack...
               // kbookmarkbar (e.g. used by konqueror) accesses the iterator of the toolbar
               // this confuses the iterator of the toolbar a bit, as it is used from the bookmark stuff and my function at the same time (seems, as if kbookmarkbar acts on shown toolbars)
               // unfortunately, there's no way to figure out if it does for this specific toolbar
               // so i check for the toolbars name, knowing this will work for current konqueror - but may fail on further versions
               // even worse - the stuff is hardcoded (assuming first item to be left aligned, last one right and the rest centered)
               // this is crap at all - so if the best thing would be to patch qtoolbutton to provide conjuncted buttons - i'll ask them (maybe qt4)
               if (bar && ( qstrcmp( bar->name(), "bookmarkToolBar" ) == 0 ))
               {
                        return;
                        buttonIndex == 0 ?
                              pos = left :
                              buttonIndex == bar->count() - 1 ?
                              pos = right :
                              pos = center;
               }
               else if (bar->orientation() == TQt::Horizontal)
               {
                  if (buttonIndex == 0)
                  {
                     TDEToolBarButton *tmpButton = bar->getButton(bar->idAt(buttonIndex+1));
                     (tmpButton && tmpButton->x() == toolbutton2->x()+toolbutton2->width()) ? pos = left : pos = full;
                  }
                  else if (buttonIndex == bar->count() - 1)
                  {
                     TDEToolBarButton *tmpButton = NULL;
                     tmpButton = bar->getButton(bar->idAt(buttonIndex-1));
                     (tmpButton && tmpButton->x() + tmpButton->width() == toolbutton2->x()) ? pos = right : pos = full;
                  }
                  else
                  {
                     TDEToolBarButton *tmpButton1 = bar->getButton(bar->idAt(buttonIndex-1));
                     TDEToolBarButton *tmpButton2 = bar->getButton(bar->idAt(buttonIndex+1));
                     tmpButton1 && tmpButton1->x() + tmpButton1->width() == toolbutton2->x() ?
                              pos = center : pos = left;
                     if (!(tmpButton2 && tmpButton2->x() == toolbutton2->x()+toolbutton2->width()))
                        pos == left ?  pos = full :  pos = right;
                  }
               }
               else
               {
                  if (buttonIndex == 0)
                  {
                     TDEToolBarButton *tmpButton = bar->getButton(bar->idAt(buttonIndex+1));
                     (tmpButton && tmpButton->y() == toolbutton2->y()+toolbutton2->height()) ?
                              pos = left : pos = full;
                  }
                  else if (buttonIndex == bar->count() - 1)
                  {
                     TDEToolBarButton *tmpButton = NULL;
                     tmpButton = bar->getButton(bar->idAt(buttonIndex-1));
                     (tmpButton && tmpButton->y() + tmpButton->height() == toolbutton2->y()) ?
                              pos = right : pos = full;
                  }
                  else
                  {
                     TDEToolBarButton *tmpButton1 = bar->getButton(bar->idAt(buttonIndex-1));
                     TDEToolBarButton *tmpButton2 = bar->getButton(bar->idAt(buttonIndex+1));
                     tmpButton1 && tmpButton1->y() + tmpButton1->height() == toolbutton2->y() ?
                              pos = center : pos = left;
                     if (!(tmpButton2 && tmpButton2->y() == toolbutton2->y()+toolbutton2->height()))
                              pos == left ?  pos = full :  pos = right;
                  }
               }
            }

            if (optionHandler->toolbuttonStyle() != Brushed)
            {
               (bar && bar->orientation() == TQt::Vertical) ?
                     drawCombo( p, cg, sunken ? cg.button().light( 110 ) : (hover ||  (cg.button() != tqApp->palette().active().button())) ? cg.button() : optionHandler->InactiveButtonColor(), button.x(), (pos == full || pos == left) ? button.y() : button.y() - 7, button.width(), (pos == full) ? button.height()+2 : (pos == center) ? button.height()+16 : button.height()+9, sunken, hover, false, center ) :
                     drawCombo( p, cg, sunken ? cg.button().light( 110 ) : (hover ||  (cg.button() != tqApp->palette().active().button())) ? cg.button() : optionHandler->InactiveButtonColor(), button.x(), button.y(), button.width(), button.height()/*+2*/, sunken, hover, false, pos );
            }
            else
            {
               (bar && bar->orientation() == TQt::Vertical) ?
                     drawRectangularButton( p, cg, sunken ? cg.button().light( 110 ) : (hover ||  (cg.button() != tqApp->palette().active().button())) ? cg.button() : optionHandler->InactiveButtonColor(), button.x(), (pos == full || pos == left) ? button.y() : button.y()-4, button.width(), (pos == full) ? button.height() : (pos == center) ? button.height()+8 : button.height()+4, sunken, hover, false) :
                     drawRectangularButton( p, cg, sunken ? cg.button().light( 110 ) : (hover ||  (cg.button() != tqApp->palette().active().button())) ? cg.button() : optionHandler->InactiveButtonColor(), button.x(), button.y(), button.width(), button.height(), sunken, hover, false, pos);
            }
         }
      }
      // Draw a toolbutton menu indicator if required
      if ( controls & SC_ToolButtonMenu )
      {
               if ( mflags & ( Style_Down | Style_On | Style_Raised ) )
                     drawPrimitive( PE_ButtonDropDown, p, ceData, elementFlags, menuarea, cg, mflags, opt );
               drawPrimitive( PE_ArrowDown, p, ceData, elementFlags, menuarea, cg, mflags, opt );
      }
#if 0
      if ( toolbutton->hasFocus() && !toolbutton->focusProxy() )
      {
               TQRect fr = toolbutton->rect();
               fr.addCoords( 3, 3, -3, -3 );
               drawPrimitive( PE_FocusRect, p, ceData, elementFlags, fr, cg );
      }
#endif
      const_cast<LiquidStyle*>( this ) ->paintWidget = 0L;
      break;
   }
		case CC_ScrollBar:
			{
				const_cast<LiquidStyle*>( this ) ->currentScrollBar = ( TQScrollBar * ) widget;
				TDEStyle::drawComplexControl( control, p, ceData, elementFlags, r, cg, flags, controls, active, opt, widget );
				break;
			}
		case CC_SpinWidget: {
					    const TQSpinWidget * sw = (const TQSpinWidget *) widget;
					    SFlags flags;
					    PrimitiveElement pe;

					    if ( controls & SC_SpinWidgetFrame )
						    drawEditFrame( p, r, cg, false, sw->hasFocus());

					    if ( controls & SC_SpinWidgetUp ) {
						    flags = Style_Default | Style_Enabled;
						    if (active == SC_SpinWidgetUp ) {
							    flags |= Style_On;
							    flags |= Style_Sunken;
						    } else
							    flags |= Style_Raised;
						    pe = PE_SpinWidgetUp;

						    TQRect re = sw->upRect();
						    TQColorGroup ucg = sw->isUpEnabled() ? cg : sw->palette().disabled();
						    p->fillRect(re, ucg.base());
						    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;
						    pe = PE_SpinWidgetDown;

						    TQRect re = sw->downRect();
						    TQColorGroup dcg = sw->isDownEnabled() ? cg : sw->palette().disabled();
						    p->fillRect(re, dcg.base());
						    drawPrimitive(pe, p, ceData, elementFlags, re, dcg, flags);
					    }
					    break; }

					    // SLIDER - KDE code for double buffering
					    // -------------------------------------------------------------------
		case CC_Slider: {
					const TQSlider* slider = (const TQSlider*)widget;
					TQRect groove = querySubControlMetrics(CC_Slider, ceData, elementFlags, SC_SliderGroove, opt, widget);
					TQRect handle = querySubControlMetrics(CC_Slider, ceData, elementFlags, SC_SliderHandle, opt, widget);

					// Double-buffer slider for no flicker
					TQPixmap pix(widget->size());
					TQPainter p2;
					p2.begin(&pix);
					if ( slider->parentWidget() &&
							(slider->parentWidget()->paletteBackgroundPixmap() && !slider->parentWidget()->paletteBackgroundPixmap()->isNull() )) {
						TQPixmap pixmap = *(slider->parentWidget()->backgroundPixmap());
						if (TQWidget *topDaddy = slider->topLevelWidget()){
							TQPoint zero = TQPoint(0,0);
#if 0
							zero = slider->mapTo(topDaddy, zero);
							int zxmpw = zero.x()%pixmap.width();
							int zymph;
#endif
							// probably due to argb mismatches in drawpixmap, this fails on kompmgr startups
							p2.drawTiledPixmap(r, pixmap, slider->mapTo(topDaddy, zero));
#if 0
							for (int dx = 0; dx < pix.width(); dx += pixmap.width())
							{
								zymph = zero.y()%pixmap.height();
								for (int dy = 0; dy < pix.height(); dy += pixmap.height())
								{
									copyBlt (&pix, dx, dy, &pixmap,
											zxmpw, zymph,
											pix.width()-dx>pixmap.width()-zxmpw?pixmap.width()-zxmpw:pix.width()-dx, pix.height()-dy>pixmap.height()-zymph?pixmap.height()-zymph:pix.height()-dy);
									zymph=0;
								}
								zxmpw=0;
							}
#endif
						} else
						{
							// probably due to argb mismatches in drawpixmap, this fails on kompmgr startups
							p2.drawTiledPixmap(r, pixmap, slider->pos());
#if 0
							for (int dx = 0; dx < pix.width(); dx += pixmap.width())
								for (int dy = 0; dy < pix.height(); dy += pixmap.height())
									copyBlt (&pix, dx, dy, &pixmap, 0, 0,
											pix.width()-dx>pixmap.width()?pixmap.width():pix.width()-dx, pix.height()-dy>pixmap.height()?pixmap.height():pix.height()-dy);
#endif
						}
						//                                 p2.begin(&pix);
					} else{
						//                                      p2.begin(&pix);
						pix.fill(cg.background());
					}

					// Draw slider groove
					if ((controls & SC_SliderGroove) && groove.isValid()) {
						drawTDEStylePrimitive( KPE_SliderGroove, &p2, ceData, elementFlags, groove, cg, flags, opt, widget );

						// Draw the focus rect around the groove
						/*				if (slider->hasFocus())
										drawPrimitive(PE_FocusRect, &p2, ceData, elementFlags, groove, cg);*/
					}

					// Draw the tickmarks
					if (controls & SC_SliderTickmarks)
						TQCommonStyle::drawComplexControl(control, &p2, ceData, elementFlags,
								r, cg, flags, SC_SliderTickmarks, active, opt, widget);

					// Draw the slider handle
					if ((controls & SC_SliderHandle) && handle.isValid()) {
						if (active == SC_SliderHandle)
							flags |= Style_Active;
						drawTDEStylePrimitive( KPE_SliderHandle, &p2, ceData, elementFlags, handle, cg, flags, opt, widget );
					}

					p2.end();
					bitBlt((TQWidget*)widget, r.x(), r.y(), &pix);
					break;
				}

#ifndef QT_NO_LISTVIEW
		case CC_ListView: {
					  if ( controls & SC_ListView ) {
						  TQCommonStyle::drawComplexControl( control, p, ceData, elementFlags, r, cg, flags, controls, active, opt, widget );
					  }
					  if ( controls & ( SC_ListViewBranch | SC_ListViewExpand ) ) {
						  if ( opt.isDefault() )
							  break;

						  TQListViewItem *item = opt.listViewItem();
						  TQListViewItem *child = item->firstChild();
						  TQListView* v = item->listView();
						  bool drawDotlines = optionHandler->DrawDotlines();
						  static TQBitmap *verticalLine = 0, *horizontalLine = 0;
						  static TQCleanupHandler<TQBitmap> qlv_cleanup_bitmap;
						  int dotoffset = 0;

						  if (drawDotlines && (optionHandler->DotlineStyle() == Dots)){
							  if ( !verticalLine ) {
								  // make 128*1 and 1*128 bitmaps that can be used for
								  // drawing the right sort of lines.
								  verticalLine = new TQBitmap( 1, 128, TRUE );
								  horizontalLine = new TQBitmap( 128, 1, TRUE );
								  TQPointArray a( 64 );
								  TQPainter p;
								  p.begin( verticalLine );
								  int i;
								  for( i=0; i<64; i++ )
									  a.setPoint( i, 0, i*2+1 );
								  p.setPen( optionHandler->DotlineColor() );
								  p.drawPoints( a );
								  p.end();
								  TQApplication::flushX();
								  verticalLine->setMask( *verticalLine );
								  p.begin( horizontalLine );
								  for( i=0; i<64; i++ )
									  a.setPoint( i, i*2+1, 0 );
								  p.setPen( optionHandler->DotlineColor() );
								  p.drawPoints( a );
								  p.end();
								  TQApplication::flushX();
								  horizontalLine->setMask( *horizontalLine );
								  qlv_cleanup_bitmap.add( &verticalLine );
								  qlv_cleanup_bitmap.add( &horizontalLine );
							  }
						  }


						  int y = r.y();
						  int c;
						  TQPointArray dotlines;
						  if ( drawDotlines && active == SC_All && controls == SC_ListViewExpand ) {
							  c = 2;
							  dotlines.resize( 2 );
							  dotlines[ 0 ] = TQPoint( r.right(), r.top() );
							  dotlines[ 1 ] = TQPoint( r.right(), r.bottom() );
						  }
						  else {
							  int linetop = 0, linebot = 0;
							  // each branch needs at most two lines, ie. four end points
							  dotoffset = (item->itemPos() + item->height() - y) %2;
							  dotlines.resize( item->childCount() * 4 );
							  c = 0;

							  // skip the stuff above the exposed rectangle
							  while ( child && y + child->height() <= 0 ) {
								  y += child->totalHeight();
								  child = child->nextSibling();
							  }

							  int bx = r.width() / 2;

							  // paint stuff in the magical area
							  while ( child && y < r.height() ) {
								  int lh;
								  if ( !item->multiLinesEnabled() )
									  lh = child ? child->height() : 0;
								  else
									  lh = p->fontMetrics().height() + 2 * v->itemMargin();
								  lh = TQMAX( lh, TQApplication::globalStrut().height() );
								  if ( lh % 2 > 0 )
									  lh++;
								  linebot = y + lh / 2;
								  if ( ( child->isExpandable() || child->childCount() ) && ( child->height() > 0 ) ) {
									  if ( optionHandler->ExpanderStyle() == MS ) { // f****** M$ +/- style :-(
										  // needs a box
										  p->setPen( optionHandler->DotlineColor() );
										  p->drawRect( bx - 4, linebot - 4, 9, 9 );
										  // plus or minus
										  p->setPen( optionHandler->UseCustomExpanderColor() ? optionHandler->CustomExpanderColor() : cg.text() );
										  p->drawLine( bx - 2, linebot, bx + 2, linebot );
										  if ( !child->isOpen() )
											  p->drawLine( bx, linebot - 2, bx, linebot + 2 );
									  } else { // ultracool triangles ;-)
										  TQPointArray a;
										  p->setPen( optionHandler->UseCustomExpanderColor() ? optionHandler->CustomExpanderColor() : cg.text() );
										  if ( child->isOpen() ) {
											  a.setPoints( 3, bx - 4, linebot - 2,
													  bx, linebot + 2,
													  bx + 4, linebot - 2 );
										  } //DownArrow
										  else {
											  a.setPoints( 3, bx - 2, linebot - 4,
													  bx + 2, linebot,
													  bx - 2, linebot + 4 );
										  } //RightArrow
										  p->setBrush( optionHandler->UseCustomExpanderColor() ? optionHandler->CustomExpanderColor() : cg.text() );
										  p->drawPolygon( a );

										  p->setBrush( NoBrush );
									  }
									  // dotlinery
									  if ( drawDotlines ) {
										  dotlines[ c++ ] = TQPoint( bx, linetop );
										  dotlines[ c++ ] = TQPoint( bx, linebot - (/* optionHandler->plusMinus() ? 4 : */5 ) );
										  dotlines[ c++ ] = TQPoint( bx + 5, linebot );
										  dotlines[ c++ ] = TQPoint( r.width(), linebot );
										  linetop = linebot + 5;
									  }
								  } else {
									  // just dotlinery
									  if ( drawDotlines ) {
										  dotlines[ c++ ] = TQPoint( bx + 2, linebot );
										  dotlines[ c++ ] = TQPoint( r.width(), linebot );
									  }
								  }

								  y += child->totalHeight();
								  child = child->nextSibling();
							  }

							  // Expand line height to edge of rectangle if there's a
							  // child, and it's visible
							  if ( child && ( child->height() > 0 ) ) {
								  linebot = r.height();
							  }

							  if ( drawDotlines ) {
								  if ( linetop < linebot ) {
									  dotlines[ c++ ] = TQPoint( bx, linetop );
									  dotlines[ c++ ] = TQPoint( bx, linebot );
								  }
							  }
						  }

						  if ( drawDotlines && optionHandler->DotlineStyle() == Line) {
							  int line; // index into dotlines
							  p->setPen( optionHandler->DotlineColor() );

							  if ( controls & SC_ListViewBranch )
								  for ( line = 0; line < c; line += 2 ) {
									  p->drawLine( dotlines[ line ].x(), dotlines[ line ].y(),
											  dotlines[ line + 1 ].x(), dotlines[ line + 1 ].y() );
								  }

						  }
						  else if (drawDotlines && (optionHandler->DotlineStyle() == Dots)) {
							  int line; // index into dotlines
							  if ( controls & SC_ListViewBranch ){
								  p->setPen( optionHandler->DotlineColor() );
								  for( line = 0; line < c; line += 2 ) {
									  // assumptions here: lines are horizontal or vertical.
									  // lines always start with the numerically lowest
									  // coordinate.

									  // point ... relevant coordinate of current point
									  // end ..... same coordinate of the end of the current line
									  // other ... the other coordinate of the current point/line
									  if ( dotlines[line].y() == dotlines[line+1].y() ) {
										  int end = dotlines[line+1].x();
										  int point = dotlines[line].x();
										  int other = dotlines[line].y();
										  while( point < end ) {
											  int i = 128;
											  if ( i+point > end )
												  i = end-point;
											  p->drawPixmap( point, other, *horizontalLine, 0, 0, i, 1 );
											  point += i;
										  }
									  }
									  else {
										  int end = dotlines[line+1].y();
										  int point = dotlines[line].y();
										  int other = dotlines[line].x();
										  int pixmapoffset = ((point & 1) != dotoffset ) ? 1 : 0;
										  while( point < end ) {
											  int i = 128;
											  if ( i+point > end )
												  i = end-point;
											  p->drawPixmap( other, point, *verticalLine, 0, pixmapoffset, 1, i );
											  point += i;
										  }
									  }
								  }
							  }
						  }
					  }

					  break;
				  }
#endif // QT_NO_LISTVIEW

#ifndef QT_NO_TITLEBAR
		case CC_TitleBar:
				  {
					  switch (optionHandler->style())
					  {
						  case Jaguar:
							  if (!widget->isActiveWindow()) p->drawTiledPixmap(r, *getPixmap( TitleBar ));
							  p->setPen(optionHandler->titleColor(1).dark(180));
							  p->drawLine(r.left(), r.bottom(), r.right(), r.bottom());
							  break;
						  case Panther:
						  case Tiger:
						  case Milk:
							  {
								  if (widget->isActiveWindow()) p->drawTiledPixmap(r, *getPixmap( TitleBar ));
								  p->setPen(optionHandler->titleColor(1).dark(180));
								  p->drawLine(r.left(), r.bottom(), r.right(), r.bottom());
								  break;
							  }
						  case Brushed:
							  break;
					  }
					  if ( controls & SC_TitleBarLabel )
					  {
						  TQRect ir = visualRect( querySubControlMetrics( CC_TitleBar, ceData, elementFlags, SC_TitleBarLabel, TQStyleOption::Default, widget ), widget );
						  p->setPen( cg.text() );
						  p->drawText(ir.x()+2, ir.y(), ir.width()-2, ir.height(), AlignCenter | AlignVCenter | SingleLine, widget->caption() );
					  }

					  TQRect ir;
					  bool down = FALSE;
					  TQPixmap pm;

					  if ( controls & SC_TitleBarCloseButton )
					  {
						  ir = visualRect( querySubControlMetrics( CC_TitleBar, ceData, elementFlags, SC_TitleBarCloseButton, TQStyleOption::Default, widget ), widget );
						  down = active & SC_TitleBarCloseButton;
						  if (optionHandler->buttonStyle() == Brushed)
							  drawRectangularButton( p, cg, down ? optionHandler->titleButtonColor(0).dark(120) : optionHandler->titleButtonColor(0), ir.x(), ir.y(), ir.width(), ir.height(), down, false, false, full);
						  else
							  drawCombo( p, cg, down ? optionHandler->titleButtonColor(0).dark(120) : optionHandler->titleButtonColor(0), ir.x(), ir.y(), ir.width(), ir.height()+2, down, false, false, full );
					  }
					  if ( controls & SC_TitleBarSysMenu )
					  {
						  ir = visualRect( querySubControlMetrics( CC_TitleBar, ceData, elementFlags, SC_TitleBarSysMenu, TQStyleOption::Default, widget ), widget );
						  down = active & SC_TitleBarSysMenu;
						  if (optionHandler->buttonStyle() == Brushed)
							  drawRectangularButton( p, cg, down ? cg.button().dark(120) : cg.button(), ir.x(), ir.y(), ir.width(), ir.height(), down, false, false, full);
						  else
							  drawCombo( p, cg, down ? cg.button().dark(120) : cg.button(), ir.x(), ir.y(), ir.width(), ir.height()+2, down, false, false, full );
					  }

					  if ( controls & SC_TitleBarMaxButton )
					  {
						  ir = visualRect( querySubControlMetrics( CC_TitleBar, ceData, elementFlags, SC_TitleBarMaxButton, TQStyleOption::Default, widget ), widget );
						  down = active & SC_TitleBarMaxButton;
						  if (optionHandler->buttonStyle() == Brushed)
							  drawRectangularButton( p, cg, down ? optionHandler->titleButtonColor(2).dark(120) : optionHandler->titleButtonColor(2), ir.x(), ir.y(), ir.width(), ir.height(), down, false, false, full);
						  else
							  drawCombo( p, cg, down ? optionHandler->titleButtonColor(2).dark(120) : optionHandler->titleButtonColor(2), ir.x(), ir.y(), ir.width(), ir.height()+2, down, false, false, full );
					  }

					  if ( controls & SC_TitleBarMinButton )
					  {
						  ir = visualRect( querySubControlMetrics( CC_TitleBar, ceData, elementFlags, SC_TitleBarMinButton, TQStyleOption::Default, widget ), widget );
						  down = active & SC_TitleBarMinButton;
						  if (optionHandler->buttonStyle() == Brushed)
							  drawRectangularButton( p, cg, down ? optionHandler->titleButtonColor(1).dark(120) : optionHandler->titleButtonColor(1), ir.x(), ir.y(), ir.width(), ir.height(), down, false, false, full);
						  else
							  drawCombo( p, cg, down ? optionHandler->titleButtonColor(1).dark(120) : optionHandler->titleButtonColor(1), ir.x(), ir.y(), ir.width(), ir.height()+2, down, false, false, full );
					  }
					  if ( controls & SC_TitleBarNormalButton )
					  {
						  ir = visualRect( querySubControlMetrics( CC_TitleBar, ceData, elementFlags, SC_TitleBarNormalButton, TQStyleOption::Default, widget ), widget );
						  down = active & SC_TitleBarNormalButton;
						  if (optionHandler->buttonStyle() == Brushed)
							  drawRectangularButton( p, cg, down ? optionHandler->titleButtonColor(1).dark(120) : optionHandler->titleButtonColor(1), ir.x(), ir.y(), ir.width(), ir.height(), down, false, false, full);
						  else
							  drawCombo( p, cg, down ? optionHandler->titleButtonColor(1).dark(120) : optionHandler->titleButtonColor(1), ir.x(), ir.y(), ir.width(), ir.height()+2, down, false, false, full );
					  }

					  if ( controls & SC_TitleBarShadeButton )
					  {
						  ir = visualRect( querySubControlMetrics( CC_TitleBar, ceData, elementFlags, SC_TitleBarShadeButton, TQStyleOption::Default, widget ), widget );
						  down = active & SC_TitleBarShadeButton;
						  if (optionHandler->buttonStyle() == Brushed)
							  drawRectangularButton( p, cg, down ? cg.button().dark(120) : cg.button(), ir.x(), ir.y(), ir.width(), ir.height(), down, false, false, full);
						  else
							  drawCombo( p, cg, down ? cg.button().dark(120) : cg.button(), ir.x(), ir.y(), ir.width(), ir.height()+2, down, false, false, full );
					  }

					  if ( controls & SC_TitleBarUnshadeButton )
					  {
						  ir = visualRect( querySubControlMetrics( CC_TitleBar, ceData, elementFlags, SC_TitleBarUnshadeButton, TQStyleOption::Default, widget ), widget );
						  down = active & SC_TitleBarUnshadeButton;
						  if (optionHandler->buttonStyle() == Brushed)
							  drawRectangularButton( p, cg, down ? cg.button().dark(120) : cg.button(), ir.x(), ir.y(), ir.width(), ir.height(), down, false, false, full);
						  else
							  drawCombo( p, cg, down ? cg.button().dark(120) : cg.button(), ir.x(), ir.y(), ir.width(), ir.height()+2, down, false, false, full );
					  }
					  break;
				  }
#endif //QT_NO_TITLEBAR

		default:
				  TDEStyle::drawComplexControl( control, p, ceData, elementFlags,
						  r, cg, flags, controls, active, opt, widget );
				  break;
	}
}

int LiquidStyle::styleHint(StyleHint sh,
                           const TQStyleControlElementData &ceData,
                           ControlElementFlags elementFlags,
                           const TQStyleOption & opt,
                           TQStyleHintReturn * shr,
                           const TQWidget * w) const
{
	switch (sh)
	{
		case TQStyle::SH_GUIStyle:
			//       if (w && ::tqt_cast<TQMenuBar*>(w))
			//          return WindowsStyle;
			return MacStyle;
		case TQStyle::SH_TabBar_Alignment:
			if (optionHandler->CenterTabs() && !TQApplication::reverseLayout())
				return AlignHCenter;
			else
				return TDEStyle::styleHint(sh, ceData, elementFlags, opt, shr, w);
		default:
			return TDEStyle::styleHint(sh, ceData, elementFlags, opt, shr, w);
	}
}

TQRect LiquidStyle::subRect( SubRect r,
                             const TQStyleControlElementData &ceData,
                             ControlElementFlags elementFlags,
                             const TQWidget *widget ) const {
	if (r == SR_ComboBoxFocusRect){
		return querySubControlMetrics( CC_ComboBox, ceData, elementFlags, SC_ComboBoxEditField, TQStyleOption::Default, widget );
	}
	return ( TDEStyle::subRect( r, ceData, elementFlags, widget ) );
}

int LiquidStyle::pixelMetric( PixelMetric m,
                              const TQStyleControlElementData &ceData,
                              ControlElementFlags elementFlags,
                              const TQWidget *widget ) const
{
	switch ( m )
	{
		case PM_ButtonMargin:
			return ( 5 );
		case PM_ButtonDefaultIndicator:
			return ( 0 );
		case PM_ExclusiveIndicatorWidth:
		case PM_ExclusiveIndicatorHeight:
			return ( 16 );
		case PM_IndicatorWidth:
		case PM_IndicatorHeight:
			return ( 16 );
		case PM_ScrollBarExtent:
			return ( 15 );
		case PM_ScrollBarSliderMin:
			if (isOOO) return 10; return ( 40 );
		case PM_SplitterWidth:
			return 6;
		case PM_SliderControlThickness:
			return(15);
		case PM_SliderThickness:
			return ( 22 );
			/*          if (widget && (widget->width() < widget->height() && widget->width() < 17) || (widget->width() > widget->height() && widget->height() < 17))
				    return (16);*/
		case PM_SliderLength:
			return ( optionHandler->style() == Milk ? 15 : 13 );
		case PM_TabBarTabOverlap:
			return 0;
		case PM_DefaultFrameWidth:
			{
				/*
					   if (widget && ::tqt_cast<TQFrame*>(widget) && ((TQFrame*)widget)->frameShape() == TQFrame::LineEditPanel)
					   return 6;*/
				if (widget && widget->parentWidget() && ::tqt_cast<TQTabWidget*>(widget->parentWidget()) && widget->parentWidget()->parentWidget() && (widget->parentWidget()->parentWidget()->inherits("KonqMainWindow") || widget->parentWidget()->parentWidget()->inherits("KonqFrameContainer"))) //for the konqueror statusbar offset, thanks konqueror team... ... ... f***f***f***!!!
					return 0;
				return 2;
			}
      case PM_TabBarBaseOverlap:
      case PM_TabBarBaseHeight:
      {
         if (!widget || !::tqt_cast<TQTabWidget*>(widget) || !widget->children())
            return 0;
         TQObjectListIt it( *widget->children() ); // iterate over the buttons
         TQObject *obj;
         TQTabBar *tabBar = 0L;
         while ( (obj = it.current()) != 0 )
         {
            ++it;
            if (::tqt_cast<TQTabBar*>(obj))
            {
               tabBar = (TQTabBar*)obj;
               break;
            }
         }
         if (!tabBar || !tabBar->isVisible())
            return 0;
         if (optionHandler->TabStyle() == Chooser || (optionHandler->TabStyle() == Clever && widget && widget->topLevelWidget()->inherits("TQDialog")))
            return 12;
         if (m == PM_TabBarBaseOverlap)
            return 2;
         return 7;
      }
		case PM_TabBarTabHSpace:
			if (optionHandler->TabStyle() == Chooser || (optionHandler->TabStyle() == Clever && widget && widget->topLevelWidget()->inherits("TQDialog"))) return 18;
			return 24;
		case PM_TabBarTabVSpace:
			{
				if (optionHandler->TabStyle() == Chooser || (optionHandler->TabStyle() == Clever && widget && widget->topLevelWidget()->inherits("TQDialog"))) return 6;
				return 10;
			}
		case PM_TabBarTabShiftHorizontal:
			return 0;
		case PM_TabBarTabShiftVertical:
			if (optionHandler->TabStyle() == Chooser || (optionHandler->TabStyle() == Clever && widget && widget->topLevelWidget()->inherits("TQDialog"))) return 0;
			return 2;
		case PM_ButtonShiftHorizontal:
			return 0;
		case PM_ButtonShiftVertical:
			return 0;
		default:
			return TDEStyle::pixelMetric( m, ceData, elementFlags, widget );
	}
}

TQSize LiquidStyle::sizeFromContents( ContentsType contents,
		const TQStyleControlElementData &ceData,
		ControlElementFlags elementFlags,
		const TQSize &contentSize,
		const TQStyleOption& opt,
		const TQWidget *widget ) const {
	switch ( contents ) {
		case CT_PushButton: {
					    // this is a little funky - we give values not based on pixelMetric
					    // because we want a custom width/height and we can only give one
					    // value in pixelMetric (used in sizeHint). Odd but works well
					    const TQPushButton * button = ( const TQPushButton* ) widget;

					    int w = contentSize.width() + 26 > 80 ? contentSize.width() + 26 : 80;
					    int h = contentSize.height() > 24 ? contentSize.height() : 25;

					    if ( button->text().isEmpty() )
						    return ( TQSize( contentSize.width() + 2 * pixelMetric( PM_ButtonMargin, ceData, elementFlags, widget ), h ) );

					    return ( TQSize( w, h ) );
				    }

		case CT_ToolButton: {
					    if (widget->parentWidget() && ::tqt_cast<TQTabWidget*>(widget->parentWidget())){
						    return TQSize(contentSize.width() + 6, contentSize.height() + 5);
					    }
					    else{
						    int w = contentSize.width() + 6;
						    int sh = contentSize.height() + 5;
						    int sw = (int)(1.3*sh);
						    if (w < sw)
							    return TQSize(sw, sh);
						    else
							    return TQSize(w, sh);
					    }
				    }

		case CT_Slider: {
					int h = contentSize.height() > 24 ? contentSize.height() : 24;
					return ( TQSize( contentSize.width(), h ) );
				}

		case CT_ComboBox: {
					  // 				TQSize sz = TDEStyle::sizeFromContents( contents, ceData, elementFlags, contentSize, opt, widget );
					  // 				return ( TQSize( sz.width()+3, sz.height() > 25 ? sz.height() : 25 ) );
					  if (  ::tqt_cast<const TQComboBox *>(widget) && ((const TQComboBox *)widget)->editable())
						  return ( TQSize( contentSize.width()+27, contentSize.height() + 4 > 22 ? contentSize.height()  + 4 : 26 ) );
					  else
						  return ( TQSize( contentSize.width()+27, contentSize.height() + 2 > 24 ? contentSize.height() + 2 : 24 ) );
				  }
		case CT_PopupMenuItem: {
					       if ( ! widget || opt.isDefault() )
						       break;

					       const TQPopupMenu *popup = ( const TQPopupMenu * ) widget;
					       bool checkable = popup->isCheckable();
					       TQMenuItem *mi = opt.menuItem();
					       int maxpmw = opt.maxIconWidth();
					       int w = contentSize.width();
					       int h = contentSize.height();

					       if ( mi->custom() ) {
						       w = mi->custom() ->sizeHint().width();
						       h = mi->custom() ->sizeHint().height();
						       if ( !mi->custom() ->fullSpan() )
							       h += 2 * windowsItemVMargin + 2 * windowsItemFrame;
					       } else if ( mi->widget() ) {}
					       else if ( mi->isSeparator() ) {
						       w = 10;
						       h = windowsSepHeight;
					       } else {
						       if ( mi->pixmap() )
							       h = TQMAX( h, mi->pixmap() ->height() + 2 * windowsItemFrame );
						       else if ( ! mi->text().isNull() )
							       h = TQMAX( h, popup->fontMetrics().height() + 2 * windowsItemVMargin +
									       2 * windowsItemFrame );
						       if ( mi->iconSet() != 0 )
							       h = TQMAX( h, mi->iconSet() ->pixmap( TQIconSet::Small,
										       TQIconSet::Normal ).height() +
									       2 * windowsItemFrame );
					       }
					       if ( !mi->text().isNull() && mi->text().find( '\t' ) >= 0 )
						       w += windowsTabSpacing;
					       else if ( mi->popup() )
						       w += 2 * windowsArrowHMargin;
					       if ( checkable && maxpmw < 20 )
						       w += 20 - maxpmw;
					       if ( maxpmw )
						       w += maxpmw + 6;
					       if ( checkable || maxpmw > 0 )
						       w += windowsCheckMarkHMargin;
					       w += 20;
					       return ( TQSize( w, h ) );
				       }
		default:
				       break;
	}
	return TDEStyle::sizeFromContents( contents, ceData, elementFlags, contentSize, opt, widget );
}


TQPixmap LiquidStyle::stylePixmap( StylePixmap stylepixmap,
		const TQStyleControlElementData &ceData,
		ControlElementFlags elementFlags,
		const TQStyleOption& opt,
		const TQWidget* widget ) const {
	return TDEStyle::stylePixmap( stylepixmap, ceData, elementFlags, opt, widget );
}

#include "eventfilter.cpp"

TQRect LiquidStyle::querySubControlMetrics( ComplexControl control,
                                            const TQStyleControlElementData &ceData,
                                            ControlElementFlags elementFlags,
                                            SubControl subcontrol,
                                            const TQStyleOption &opt,
                                            const TQWidget *widget ) const
{
	if ( control == CC_ComboBox && subcontrol == SC_ComboBoxEditField )
		return TQRect( 8, 3, widget->width() - 32, widget->height() - 7 );
	if (control == CC_TitleBar)
	{
		switch (subcontrol)
		{
			case SC_TitleBarSysMenu:
				return TQRect( widget->width() - 24, 1, 16, 16 );
			case SC_TitleBarMinButton:
				return TQRect( 26, 1, 16, 16 );
			case SC_TitleBarMaxButton:
				return TQRect( 47, 1, 16, 16 );
			case SC_TitleBarCloseButton:
				return TQRect( 5, 1, 16, 16 );
			case SC_TitleBarLabel:
				return TQRect( 68, 1, widget->width() - 107, 16 );
			case SC_TitleBarNormalButton:
				return TQRect( 26, 1, 16, 16 );
			case SC_TitleBarShadeButton:
				return TQRect( widget->width() - 29, 1, 24, 16 );
			case SC_TitleBarUnshadeButton:
				return TQRect( widget->width() - 29, 1, 24, 16 );
			default:
				return ( TDEStyle::querySubControlMetrics( control, ceData, elementFlags, subcontrol, opt, widget ) );
		}
	}
	else
		return ( TDEStyle::querySubControlMetrics( control, ceData, elementFlags, subcontrol, opt, widget ) );
}

TQImage LiquidStyle::fetchImage( const char *name ){
	return uic_findImage( name );
}

TQColor LiquidStyle::mapFadeColor(TQColor &color, int index) const
{
	TQRgb **rgb = fadeColorMap.find(color.rgb());
	if (rgb)
		return TQColor((*rgb)[index]);
	// no color map found, create one and return the queried value
	rgb = new TQRgb*;
	*rgb = new TQRgb[10];
	int iRed = optionHandler->InactiveButtonColor().red();
	int iGreen = optionHandler->InactiveButtonColor().green();
	int iBlue = optionHandler->InactiveButtonColor().blue();
	int cRed = color.red();
	int cGreen = color.green();
	int cBlue = color.blue();
	for (int i = 10; i < 20; i++)
	{
		(*rgb)[i-10] = tqRgb( iRed + (cRed-iRed)*(i)/20, iGreen + (cGreen-iGreen)*(i)/20, iBlue + (cBlue-iBlue)*(i)/20);
	}
	LiquidStyle *ptr = const_cast<LiquidStyle*>( this );
	ptr->fadeColorMap.insert(color.rgb(), rgb);
	return TQColor((*rgb)[index]);
}

TQPixmap* LiquidStyle::processEmbedded( const char *label, const TQColor &c, bool blend, const TQColor *bg ) const {
	TQImage img( uic_findImage( label ) );
	img.detach();
	if ( img.isNull() ) { // shouldn't happen, been tested
		tqWarning( "Invalid embedded label %s", label );
		return ( NULL );
	}
	return ( adjustHSV( img, c, bg ) );
}

TQPixmap* LiquidStyle::getPixmap( BitmapData item ) const
{
	if ( pixmaps[ item ] )
		return ( pixmaps[ item ] );
	TQColor bgColor( optionHandler->InactiveButtonColor() );
	TQColor btnColor( isOOO ? optionHandler->CustomButtonColor() : tqApp->palette().active().button() );
	TQColor btnHoverColor( isOOO ? optionHandler->CustomButtonColor().light(120) : btnColor.light( 120 ) );
	TQColor sbGrooveColor( optionHandler->useCustomColors() ?
			optionHandler->customColor( CustomSBGroove ) : bgColor );
	TQColor sbSliderColor( optionHandler->useCustomColors() ?
			optionHandler->customColor( CustomSBSlider ) : bgColor );
	TQColor sbSliderHoverColor( optionHandler->useCustomColors() ?
			optionHandler->customColor( CustomSBSliderHover ) : isOOO?optionHandler->CustomButtonColor():btnColor );
	TQColor sbSliderPressedColor( optionHandler->useCustomColors() ?
			optionHandler->customColor( CustomSBSliderPressed ) : btnColor.dark(110) );
	LiquidStyle *ptr = const_cast<LiquidStyle*>( this );
	switch ( item )
	{
		case RadioOn:
			ptr->pixmaps[ RadioOn ] = processEmbedded( (optionHandler->style() == Milk) ?  "radio_down-milk" : "radio_down", optionHandler->useCustomColors() ? optionHandler->customColor( CustomRadioOn ) : btnColor, true );
			break;
		case RadioOff:
			ptr->pixmaps[ RadioOff ] = processEmbedded( (optionHandler->style() == Milk) ?  "radio-milk" : "radio", optionHandler->useCustomColors() ? optionHandler->customColor( CustomRadioOff ) : bgColor, true );
			break;
		case RadioOnHover:
			ptr->pixmaps[ RadioOnHover ] = processEmbedded( (optionHandler->style() == Milk) ?  "radio_down-milk" : "radio_down", optionHandler->useCustomColors() ? optionHandler->customColor( CustomRadioOn ).light( 110 ) : btnHoverColor, true );
			break;
		case RadioOffHover:
			ptr->pixmaps[ RadioOffHover ] = processEmbedded( (optionHandler->style() == Milk) ?  "radio-milk" : "radio", optionHandler->useCustomColors() ? optionHandler->customColor( CustomRadioOn ) : btnColor, true );
		case RadioOnPressed:
			ptr->pixmaps[ RadioOnPressed ] = processEmbedded( (optionHandler->style() == Milk) ?  "radio_down-milk" : "radio_down", optionHandler->useCustomColors() ? optionHandler->customColor( CustomRadioOn ).dark( 120 ) : btnHoverColor.dark( 120 ), true );
			break;
		case RadioOffPressed:
			ptr->pixmaps[ RadioOffPressed ] = processEmbedded( (optionHandler->style() == Milk) ?  "radio-milk" : "radio", optionHandler->useCustomColors() ? optionHandler->customColor( CustomRadioOn ).dark( 120 ) : btnColor.dark( 120 ), true );
			break;
		case Tab:
			ptr->pixmaps[ Tab ] = processEmbedded( (optionHandler->style() == Jaguar) ? "tab-jaguar" : (optionHandler->style() == Milk) ? "tab-milk" : "tab", optionHandler->useCustomColors() ? optionHandler->customColor( CustomTabOff ) : optionHandler->InactiveButtonColor(), true );
			break;
		case belowTab:
			ptr->pixmaps[ belowTab ] = processEmbedded( (optionHandler->style() == Jaguar) ? "tab-jaguar" : (optionHandler->style() == Milk) ? "tab-milk" : "tab", optionHandler->useCustomColors() ? optionHandler->customColor( CustomTabOff ) : optionHandler->InactiveButtonColor(), true );
			*ptr->pixmaps[ belowTab ] = ptr->pixmaps[ belowTab ] ->xForm( iMatrix );
			break;
		case TabDown:
			ptr->pixmaps[ TabDown ] = processEmbedded( (optionHandler->style() == Jaguar) ? "tab-jaguar" : (optionHandler->style() == Milk) ? "tab-milk" : "tab", optionHandler->useCustomColors() ? optionHandler->customColor( CustomTabOn ) : btnColor, true );
			break;
		case belowTabDown:
			ptr->pixmaps[ belowTabDown ] = processEmbedded( (optionHandler->style() == Jaguar) ? "tab-jaguar" : (optionHandler->style() == Milk) ? "tab-milk" : "tab", optionHandler->useCustomColors() ? optionHandler->customColor( CustomTabOn ) : btnColor, true );
			*ptr->pixmaps[ belowTabDown ] = ptr->pixmaps[ belowTabDown ] ->xForm( iMatrix );
			break;
		case TabFocus:
			ptr->pixmaps[ TabFocus ] = processEmbedded( (optionHandler->style() == Jaguar) ? "tab-jaguar" : (optionHandler->style() == Milk) ? "tab-milk" : "tab", optionHandler->useCustomColors() ? optionHandler->customColor( CustomTabOn ).light( 120 ) : btnHoverColor, true );
			break;
		case CB:
			ptr->pixmaps[ CB ] = processEmbedded( (optionHandler->style() == Milk) ? "checkbox-milk" : "checkbox", optionHandler->useCustomColors() ? optionHandler->customColor( CustomCBOff ) : bgColor, true );
			break;
		case CBDown:
			ptr->pixmaps[ CBDown ] = processEmbedded( (optionHandler->style() == Milk) ? "checkboxdown-milk" : "checkboxdown", optionHandler->useCustomColors() ? optionHandler->customColor( CustomCBOn ) : btnColor, true );
			break;
		case CBDownHover:
			ptr->pixmaps[ CBDownHover ] = processEmbedded( (optionHandler->style() == Milk) ? "checkboxdown-milk" : "checkboxdown", optionHandler->useCustomColors() ? optionHandler->customColor( CustomCBOn ).light( 110 ) : btnHoverColor, true );
			break;
		case CBTri:
			ptr->pixmaps[ CBTri ] = processEmbedded( (optionHandler->style() == Milk) ? "checkboxdown-milk" : "checkboxdown", optionHandler->useCustomColors() ? optionHandler->customColor( CustomCBOn ) : btnColor, true );
			*ptr->pixmaps[ CBTri ] = ptr->pixmaps[ CBTri ] ->xForm( mMatrix );
			break;
		case CBTriHover:
			ptr->pixmaps[ CBTriHover ] = processEmbedded( (optionHandler->style() == Milk) ? "checkboxdown-milk" : "checkboxdown", optionHandler->useCustomColors() ? optionHandler->customColor( CustomCBOn ).light( 110 ) : btnHoverColor, true );
			*ptr->pixmaps[ CBTriHover ] = ptr->pixmaps[ CBTriHover ] ->xForm( mMatrix );
			break;
		case CBHover:
			ptr->pixmaps[ CBHover ] = processEmbedded( (optionHandler->style() == Milk) ? "checkbox-milk" : "checkbox", optionHandler->useCustomColors() ? optionHandler->customColor( CustomCBOn ) : btnColor, true );
			break;
		case CBDownPressed:
			ptr->pixmaps[ CBDownPressed ] = processEmbedded( (optionHandler->style() == Milk) ? "checkboxdown-milk" : "checkboxdown", optionHandler->useCustomColors() ? optionHandler->customColor( CustomCBOn ).dark( 120 ) : btnHoverColor.dark( 120 ), true );
			break;
		case CBTriPressed:
			ptr->pixmaps[ CBTriPressed ] = processEmbedded( (optionHandler->style() == Milk) ? "checkboxdown-milk" : "checkboxdown", optionHandler->useCustomColors() ? optionHandler->customColor( CustomCBOn ).dark( 120 ) : btnHoverColor.dark( 120 ), true );
			*ptr->pixmaps[ CBTriPressed ] = ptr->pixmaps[ CBTriPressed ] ->xForm( mMatrix );
			break;
		case CBPressed:
			ptr->pixmaps[ CBPressed ] = processEmbedded( (optionHandler->style() == Milk) ? "checkbox-milk" : "checkbox", optionHandler->useCustomColors() ? optionHandler->customColor( CustomCBOn ).dark( 120 ) : btnColor.dark( 120 ), true );
			break;
		case HSlider:
			ptr->pixmaps[ HSlider ] = processEmbedded( (optionHandler->style() == Milk) ? "sliderarrow-milk" : "sliderarrow", btnColor, true );
			break;
		case VSlider:
			ptr->pixmaps[ VSlider ] = processEmbedded( (optionHandler->style() == Milk) ? "sliderarrow-milk" : "sliderarrow", btnColor, true );
			*ptr->pixmaps[ VSlider ] = ptr->pixmaps[ VSlider ] ->xForm( lMatrix );
			break;
		case VSliderAbove:
			ptr->pixmaps[ VSliderAbove ] = processEmbedded( (optionHandler->style() == Milk) ? "sliderarrow-milk" : "sliderarrow", btnColor, true );
			*ptr->pixmaps[ VSliderAbove ] = ptr->pixmaps[ VSliderAbove ] ->xForm( rMatrix );
			break;
		case HSliderInactive:
			ptr->pixmaps[ HSliderInactive ] = processEmbedded( (optionHandler->style() == Milk) ? "sliderarrow-milk" : "sliderarrow", bgColor, true );
			break;
		case VSliderInactive:
			ptr->pixmaps[ VSliderInactive ] = processEmbedded( (optionHandler->style() == Milk) ? "sliderarrow-milk" : "sliderarrow", bgColor, true );
			*ptr->pixmaps[ VSliderInactive ] = ptr->pixmaps[ VSliderInactive ] ->xForm( lMatrix );
			break;
		case VSliderAboveInactive:
			ptr->pixmaps[ VSliderAboveInactive ] = processEmbedded( (optionHandler->style() == Milk) ? "sliderarrow-milk" : "sliderarrow", bgColor, true );
			*ptr->pixmaps[ VSliderAboveInactive ] = ptr->pixmaps[ VSliderAboveInactive ] ->xForm( rMatrix );
			break;
		case VSBSliderTop:
			ptr->pixmaps[ VSBSliderTop ] = optionHandler->shadowSbSlider() ? createSliderEnd( sbSliderColor, sbGrooveColor.dark( 120 ), true) : processEmbedded( (optionHandler->style() == Milk) ? "sbslider_top-milk" : "sbslider_top", sbSliderColor, true, &sbGrooveColor );
			break;
		case VSBSliderBtm:
			ptr->pixmaps[ VSBSliderBtm ] = optionHandler->shadowSbSlider() ? createSliderEnd( sbSliderColor, sbGrooveColor.dark( 120 ), false) : processEmbedded( (optionHandler->style() == Milk) ? "sbslider_btm-milk" : "sbslider_btm", sbSliderColor, true, &sbGrooveColor );
			break;
		case VSBSliderMid:
			ptr->pixmaps[ VSBSliderMid ] = processEmbedded( (optionHandler->style() == Milk) ? "sbslider_mid-milk" : "sbIslider_mid", sbSliderColor, &sbGrooveColor );
			break;
		case VSBSliderTopActive:
			ptr->pixmaps[ VSBSliderTopActive ] = optionHandler->shadowSbSlider() ? createSliderEnd( sbSliderHoverColor, sbGrooveColor.dark( 120 ), true) : processEmbedded( (optionHandler->style() == Milk) ? "sbslider_top-milk" : "sbslider_top", sbSliderHoverColor, true, &sbGrooveColor );
			break;
		case VSBSliderBtmActive:
			ptr->pixmaps[ VSBSliderBtmActive ] = optionHandler->shadowSbSlider() ? createSliderEnd( sbSliderHoverColor, sbGrooveColor.dark( 120 ), false) : processEmbedded( (optionHandler->style() == Milk) ? "sbslider_btm-milk" : "sbslider_btm", sbSliderHoverColor, true, &sbGrooveColor );
			break;
		case VSBSliderMidActive:
			ptr->pixmaps[ VSBSliderMidActive ] = processEmbedded( (optionHandler->style() == Milk) ? "sbslider_mid-milk" : "sbslider_mid", sbSliderHoverColor, false, &sbGrooveColor );
			break;
		case VSBSliderTopPressed:
			ptr->pixmaps[ VSBSliderTopPressed ] = processEmbedded( (optionHandler->style() == Milk) ? "sbslider_top-milk" : "sbslider_top", sbSliderPressedColor, true, &sbGrooveColor );
			*ptr->pixmaps[ VSBSliderTopPressed ] = ptr->pixmaps[ VSBSliderTopPressed ] ->xForm( mMatrix );
			break;
		case VSBSliderBtmPressed:
			ptr->pixmaps[ VSBSliderBtmPressed ] = processEmbedded( (optionHandler->style() == Milk) ? "sbslider_btm-milk" : "sbslider_btm", sbSliderPressedColor, true, &sbGrooveColor );
			*ptr->pixmaps[ VSBSliderBtmPressed ] = ptr->pixmaps[ VSBSliderBtmPressed ] ->xForm( mMatrix );
			break;
		case VSBSliderMidPressed:
			ptr->pixmaps[ VSBSliderMidPressed ] = processEmbedded( (optionHandler->style() == Milk) ? "sbslider_mid-milk" : "sbslider_mid", sbSliderPressedColor, false, &sbGrooveColor );
			if (optionHandler->style() == Milk)
				*ptr->pixmaps[ VSBSliderMidPressed ] = ptr->pixmaps[ VSBSliderMidPressed ] ->xForm( iMatrix );
			break;

		case HSBSliderTop:
			ptr->pixmaps[ HSBSliderTop ] = optionHandler->shadowSbSlider() ? createSliderEnd( sbSliderColor, sbGrooveColor.dark( 120 ), true) : processEmbedded( (optionHandler->style() == Milk) ? "sbslider_top-milk" : "sbslider_top", sbSliderColor, true, &sbGrooveColor );
			*ptr->pixmaps[ HSBSliderTop ] = ptr->pixmaps[ HSBSliderTop ]->xForm( rMatrix );
			break;
		case HSBSliderBtm:
			ptr->pixmaps[ HSBSliderBtm ] = optionHandler->shadowSbSlider() ? createSliderEnd( sbSliderColor, sbGrooveColor.dark( 120 ), false) : processEmbedded( (optionHandler->style() == Milk) ? "sbslider_btm-milk" : "sbslider_btm", sbSliderColor, true, &sbGrooveColor );
			*ptr->pixmaps[ HSBSliderBtm ] = ptr->pixmaps[ HSBSliderBtm ] ->xForm( rMatrix );
			break;
		case HSBSliderMid:
			ptr->pixmaps[ HSBSliderMid ] = processEmbedded( (optionHandler->style() == Milk) ? "sbslider_mid-milk" : "sbIslider_mid", sbSliderColor, false, &sbGrooveColor );
			*ptr->pixmaps[ HSBSliderMid ] = ptr->pixmaps[ HSBSliderMid ]->xForm( rMatrix );
			break;
		case HSBSliderTopActive:
			ptr->pixmaps[ HSBSliderTopActive ] = optionHandler->shadowSbSlider() ? createSliderEnd( sbSliderHoverColor, sbGrooveColor.dark( 120 ), true) : processEmbedded( (optionHandler->style() == Milk) ? "sbslider_top-milk" : "sbslider_top", sbSliderHoverColor, true, &sbGrooveColor );
			*ptr->pixmaps[ HSBSliderTopActive ] = ptr->pixmaps[ HSBSliderTopActive ] ->xForm( rMatrix );
			break;
		case HSBSliderBtmActive:
			ptr->pixmaps[ HSBSliderBtmActive ] = optionHandler->shadowSbSlider() ? createSliderEnd( sbSliderHoverColor, sbGrooveColor.dark( 120 ), false) : processEmbedded( (optionHandler->style() == Milk) ? "sbslider_btm-milk" : "sbslider_btm", sbSliderHoverColor, true, &sbGrooveColor );
			*ptr->pixmaps[ HSBSliderBtmActive ] = ptr->pixmaps[ HSBSliderBtmActive ] ->xForm( rMatrix );
			break;
		case HSBSliderMidActive:
			ptr->pixmaps[ HSBSliderMidActive ] = processEmbedded( (optionHandler->style() == Milk) ? "sbslider_mid-milk" : "sbslider_mid", sbSliderHoverColor, false, &sbGrooveColor );
			*ptr->pixmaps[ HSBSliderMidActive ] = ptr->pixmaps[ HSBSliderMidActive ] ->xForm( rMatrix );
			break;
		case HSBSliderTopPressed:
			ptr->pixmaps[ HSBSliderTopPressed ] = processEmbedded( (optionHandler->style() == Milk) ? "sbslider_top-milk" : "sbslider_top", sbSliderPressedColor, true, &sbGrooveColor );
			*ptr->pixmaps[ HSBSliderTopPressed ] = ptr->pixmaps[ HSBSliderTopPressed ] ->xForm( mMatrix );
			*ptr->pixmaps[ HSBSliderTopPressed ] = ptr->pixmaps[ HSBSliderTopPressed ] ->xForm( rMatrix );
			break;
		case HSBSliderBtmPressed:
			ptr->pixmaps[ HSBSliderBtmPressed ] = processEmbedded( (optionHandler->style() == Milk) ? "sbslider_btm-milk" : "sbslider_btm", sbSliderPressedColor, true, &sbGrooveColor );
			*ptr->pixmaps[ HSBSliderBtmPressed ] = ptr->pixmaps[ HSBSliderBtmPressed ] ->xForm( mMatrix );
			*ptr->pixmaps[ HSBSliderBtmPressed ] = ptr->pixmaps[ HSBSliderBtmPressed ] ->xForm( rMatrix );
			break;
		case HSBSliderMidPressed:
			ptr->pixmaps[ HSBSliderMidPressed ] = processEmbedded( (optionHandler->style() == Milk) ? "sbslider_mid-milk" : "sbslider_mid", sbSliderPressedColor, false, &sbGrooveColor );
			if (optionHandler->style() == Milk)
				*ptr->pixmaps[ HSBSliderMidPressed ] = ptr->pixmaps[ HSBSliderMidPressed ] ->xForm( lMatrix );
			else
				*ptr->pixmaps[ HSBSliderMidPressed ] = ptr->pixmaps[ HSBSliderMidPressed ] ->xForm( rMatrix );
			break;
		case VSBSliderTopBg:
			ptr->pixmaps[ VSBSliderTopBg ] = processEmbedded( (optionHandler->style() == Milk) ? "sbgroove_top-milk" : "sbgroove_top", sbGrooveColor, true, &sbGrooveColor );
			break;
		case VSBSliderBtmBg:
			ptr->pixmaps[ VSBSliderBtmBg ] = processEmbedded( (optionHandler->style() == Milk) ? "sbgroove_btm-milk" : "sbgroove_btm", sbGrooveColor, true, &sbGrooveColor );
			break;
		case VSBSliderMidBg:
			ptr->pixmaps[ VSBSliderMidBg ] = processEmbedded( (optionHandler->style() == Milk) ? "sbgroove_mid-milk" : "sbgroove_mid", sbGrooveColor, false, &sbGrooveColor );
			break;
		case VSBSliderMidBgI:
			ptr->pixmaps[ VSBSliderMidBgI ] = processEmbedded( (optionHandler->style() == Milk) ? "sb_subadd-milk" : "sb_subadd", sbGrooveColor, false, &sbGrooveColor );
			break;
		case HSBSliderTopBg:
			ptr->pixmaps[ HSBSliderTopBg ] = processEmbedded( (optionHandler->style() == Milk) ? "sbgroove_top-milk" : "sbgroove_top", sbGrooveColor, true, &sbGrooveColor );
			*ptr->pixmaps[ HSBSliderTopBg ] = ptr->pixmaps[ HSBSliderTopBg ] ->xForm( rMatrix );
			break;
		case HSBSliderBtmBg:
			ptr->pixmaps[ HSBSliderBtmBg ] = processEmbedded( (optionHandler->style() == Milk) ? "sbgroove_btm-milk" : "sbgroove_btm", sbGrooveColor, true, &sbGrooveColor );
			*ptr->pixmaps[ HSBSliderBtmBg ] = ptr->pixmaps[ HSBSliderBtmBg ] ->xForm( rMatrix );
			break;
		case HSBSliderMidBg:
			ptr->pixmaps[ HSBSliderMidBg ] = processEmbedded( (optionHandler->style() == Milk) ? "sbgroove_mid-milk" : "sbgroove_mid", sbGrooveColor, false, &sbGrooveColor );
			*ptr->pixmaps[ HSBSliderMidBg ] = ptr->pixmaps[ HSBSliderMidBg ] ->xForm( rMatrix );
			break;
		case HSBSliderMidBgI:
			ptr->pixmaps[ HSBSliderMidBgI ] = processEmbedded( (optionHandler->style() == Milk) ? "sb_subadd-milk" : "sb_subadd", sbGrooveColor, false, &sbGrooveColor );
			*ptr->pixmaps[ HSBSliderMidBgI ] = ptr->pixmaps[ HSBSliderMidBgI ] ->xForm( rMatrix );
			break;

		case Progress:
      ptr->pixmaps[ Progress ] = processEmbedded( "progress", btnColor );
      break;
   case progress2:
      ptr->pixmaps[ progress2 ] = processEmbedded( "progress2", btnColor );
      break;

   case TitleBar:
   {
      if (optionHandler->style() == Jaguar)
      {
         ptr->pixmaps[ TitleBar ] = new TQPixmap(32,22);
         ptr->pixmaps[ TitleBar ]->fill( optionHandler->titleColor(0) );
         TQPainter p;
         p.begin( ptr->pixmaps[ TitleBar ] );
         p.setPen( TQColor(
               (optionHandler->titleColor(0).red()+optionHandler->titleColor(1).red())/2,
               (optionHandler->titleColor(0).green()+optionHandler->titleColor(1).green())/2,
               (optionHandler->titleColor(0).blue()+optionHandler->titleColor(1).blue())/2 ));
         for ( int i = 1; i < 22; i += 4 )
         {
            p.drawLine( 0, i, 31, i );
            p.drawLine( 0, i+2, 31, i+2 );
         }
         p.setPen( optionHandler->titleColor(1));
         for ( int i = 2; i < 22; i += 4 )
            p.drawLine( 0, i, 31, i );
         p.end();
      }
      else
         ptr->pixmaps[ TitleBar ] = &KPixmapEffect::gradient (*((KPixmap*)(new TQPixmap(32,22))), optionHandler->titleColor(0), optionHandler->titleColor(1), KPixmapEffect::VerticalGradient, 22);
      break;
   }
   default:
      break;
   }
   return ( pixmaps[ item ] );
}


#include "baghira.moc"