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
|
/*
* KDE3 asteroid style (version 1.0)
*
* Copyright (C) 2003, Chris Lee <clee@kde.org>
* Modified by David Chester in 2004 for Munjoy Linux
*
* See LICENSE for details about copying.
*/
/* Required. Period. */
#include <tqstyleplugin.h>
#include <tqstylefactory.h>
#include <tqpainter.h>
#include <tqapplication.h>
#include <tqpopupmenu.h>
#include <tqmenubar.h>
#include <tqheader.h>
#include <tqcombobox.h>
#include <tqlistbox.h>
#include <tqslider.h>
#include <tqpushbutton.h>
#include <tqtextedit.h>
#include <tqlineedit.h>
#include <tqtoolbar.h>
#include <tqradiobutton.h>
#include <tqprogressbar.h>
#include <tqtabwidget.h>
#include <tqtabbar.h>
#include <tqgroupbox.h>
#include <tqtoolbutton.h>
#include <tqdockwindow.h>
#include <tqtooltip.h>
#include <tqdrawutil.h>
#include <kpixmap.h>
#include <tqbitmap.h>
#define u_arrow -4,1, 2,1, -3,0, 1,0, -2,-1, 0,-1, -1,-2
#define d_arrow -4,-2, 2,-2, -3,-1, 1,-1, -2,0, 0,0, -1,1
#define l_arrow 0,-3, 0,3, -1,-2, -1,2, -2,-1, -2,1, -3,0
#define r_arrow -2,-3, -2,3, -1,-2, -1,2, 0,-1, 0,1, 1,0
#include <../../kutils/kmultitabbar.h>
#include "asteroid.h"
// #define MINIMUM_PUSHBUTTON_WIDTH 75;
// #define MINIMUM_PUSHBUTTON_HEIGHT 23;
#define MINIMUM_PUSHBUTTON_WIDTH 73;
#define MINIMUM_PUSHBUTTON_HEIGHT 21;
#define ETCH_X_OFFSET 1
#define ETCH_Y_OFFSET 1
//#define POPUPMENUITEM_TEXT_ETCH_CONDITIONS ( etchtext && !enabled && !active )
#define POPUPMENUITEM_TEXT_ETCH_CONDITIONS ( etchtext && !enabled )
#define PUSHBUTTON_TEXT_ETCH_CONDITIONS ( etchtext && !enabled )
#define HEADER_TEXT_ETCH_CONDITIONS ( etchtext && !enabled )
#define TABBAR_TEXT_ETCH_CONDITIONS ( etchtext && !enabled )
/* Hackery to make metasources work */
#include "asteroid.moc"
/* TQStyleFactory stuff. Required. */
class AsteroidStylePlugin : public TQStylePlugin
{
public:
AsteroidStylePlugin() {}
~AsteroidStylePlugin() {}
TQStringList keys() const {
return TQStringList() << "Asteroid";
}
TQStyle *create(const TQString &key) {
if (key == "asteroid") {
return new AsteroidStyle;
}
return 0;
}
};
TQ_EXPORT_PLUGIN(AsteroidStylePlugin);
/* Ok, now we get to the good stuff. */
AsteroidStyle::AsteroidStyle() : KStyle(AllowMenuTransparency)
{
if (tqApp->inherits("KApplication")) {
connect(tqApp, TQT_SIGNAL(kdisplayPaletteChanged()), TQT_SLOT(paletteChanged()));
}
backwards = TQApplication::reverseLayout();
}
AsteroidStyle::~AsteroidStyle()
{
/* The destructor is empty for now, but any member pointers should
* get deleted here. */
}
void AsteroidStyle::polish(TQWidget *w)
{
/* Screwing with the palette is fun! and required in order to make it feel
authentic. -clee */
TQPalette wp = w->tqpalette();
//wp.setColor(TQColorGroup::Dark, wp.active().color(TQColorGroup::Button).dark(350));
wp.setColor(TQColorGroup::Dark, TQColor(128, 128, 128));
wp.setColor(TQColorGroup::Mid, wp.active().color(TQColorGroup::Button).dark(150)); // Which GUI element(s) does this correspond to?
if ( ::tqqt_cast<TQLineEdit*>(w) || ::tqqt_cast<TQTextEdit*>(w) || ::tqqt_cast<TQMenuBar*>(w) || ::tqqt_cast<TQPushButton*>(w) || ::tqqt_cast<TQRadioButton*>(w) || ::tqqt_cast<TQTabBar*>(w) || ::tqqt_cast<TQToolBar*>(w) || ::tqqt_cast<TQProgressBar*>(w) || ::tqqt_cast<TQTabWidget*>(w) /*|| ::tqqt_cast<TQHeader*>(w) || ::tqqt_cast<TQComboBox*>(w) || ::tqqt_cast<TQFrame*>(w) || ::tqqt_cast<TQGroupBox*>(w) || ::tqqt_cast<TQPopupMenu*>(w) || ::tqqt_cast<TQToolButton*>(w) || ::tqqt_cast<TQDockWindow*>(w)|| ::tqqt_cast<TQButton*>(w)*/)
w->setPalette(wp);
if (w->inherits(TQPUSHBUTTON_OBJECT_NAME_STRING)) {
w->installEventFilter(this);
} else {
KStyle::polish(w);
}
}
void AsteroidStyle::unPolish(TQWidget *w)
{
KStyle::unPolish(w);
}
/*!
\reimp
Changes some application-wide settings
*/
void
AsteroidStyle::polish( TQApplication* app)
{
TQPalette wp = TQApplication::tqpalette();
wp.setColor(TQColorGroup::Dark, TQColor(128, 128, 128));
wp.setColor(TQColorGroup::Mid, wp.active().color(TQColorGroup::Button).dark(150)); // Which GUI element(s) does this correspond to?
TQApplication::tqsetPalette( wp, TRUE );
}
/*! \reimp
*/
void
AsteroidStyle::unPolish( TQApplication* /* app */ )
{
TQFont f = TQApplication::font();
TQApplication::tqsetFont( f, TRUE ); // get rid of the special fonts for special widget classes
}
void AsteroidStyle::renderMenuBlendPixmap(KPixmap &pix,
const TQColorGroup &cg,
const TQPopupMenu *) const
{
TQPainter p(&pix);
p.fillRect(0, 0, pix.width(), pix.height(), cg.background());
}
void AsteroidStyle::drawKStylePrimitive(KStylePrimitive ksp,
TQPainter *p,
const TQWidget *w,
const TQRect &r,
const TQColorGroup &cg,
SFlags sf,
const TQStyleOption &o) const
{
switch (ksp) {
case KPE_SliderGroove: {
const TQSlider* slider = (const TQSlider*)w;
int x, y, v, h;
r.rect(&x, &y, &v, &h);
bool horizontal = slider->orientation() ==Qt::Horizontal;
int gcenter = (horizontal ? h : v) / 2;
int pad = 3;
/*p->setPen(cg.background());
p->setBrush(cg.background());
p->drawRect(r);*/
if (horizontal) {
gcenter += y;
p->setPen (cg.background().dark());
p->drawLine(x+pad, gcenter-1, x+v-pad, gcenter-1);
p->drawPoint(x+pad, gcenter);
p->setPen (cg.background().light());
p->drawLine(x+pad, gcenter+1, x+v-pad, gcenter+1);
p->drawLine(x+v-pad, gcenter, x+v-pad, gcenter-1);
} else {
gcenter += x;
p->setPen (cg.background().dark());
p->drawLine(gcenter-1, y+pad, gcenter-1, y+h-pad);
p->drawPoint(gcenter, y+pad);
p->setPen (cg.background().light());
p->drawLine(gcenter+1, y+pad, gcenter+1, y+h-pad);
p->drawLine(gcenter, y+h-pad, gcenter-1, y+h-pad);
}
break;
}
case KPE_SliderHandle: {
const TQSlider* slider = (const TQSlider*)w;
int x, y, x2, y2, xmin, xmax, ymin, ymax, v, h;
int pcenter, gcenter;
r.coords(&xmin, &ymin, &xmax, &ymax);
r.rect(&x, &y, &v, &h);
bool horizontal = slider->orientation() ==Qt::Horizontal;
if (horizontal) {
gcenter = h / 2;
x = v / 5 + xmin;
x2 = v * 4 / 5 + xmin;
if (((x2 - x) % 2)) x2--;
y2 = ymax - (x2 - x - 1) / 2;
y = ymax - y2 + ymin;
pcenter = (x2 - x) / 2 + x;
p->setPen(cg.background());
p->setBrush(cg.background());
TQRect hr(x-1, y, x2-x+2, y2-y);
p->drawRect(hr);
p->setPen(cg.light());
p->drawLine(x, y, x2-1, y);
p->drawLine(x, y, x, y2);
p->drawLine(x, y2, pcenter-1, ymax);
p->setPen(cg.mid());
p->drawLine(x2-1, y+1, x2-1, y2);
p->drawLine(x2-1, y2, pcenter, ymax);
p->setPen(cg.dark());
p->drawLine(x2, y, x2, y2);
p->drawLine(x2, y2, pcenter+1, ymax);
} else {
gcenter = v / 2;
y = h / 5 + ymin;
y2 = h * 4 / 5 + ymin;
if (((y2 - y) % 2)) y2--;
x2 = xmax - (y2 - y - 1) / 2;
x = (xmax-x2) + xmin;
pcenter = (y2 - y)/2 + y;
p->setPen(cg.background());
p->setBrush(cg.background());
TQRect hr(x, y-1, x2-x, y2-y+2);
p->drawRect(hr);
p->setPen(cg.light());
p->drawLine(x, y, x2-1, y);
p->drawLine(x, y, x, y2-1);
p->drawLine(x2, y, xmax, pcenter-1);
p->setPen(cg.mid());
p->drawLine(x2-1, y2-1, x+1, y2-1);
p->drawLine(x2, y2-1, xmax, pcenter);
p->setPen(cg.dark());
p->drawLine(x, y2, x2, y2);
p->drawLine(x2, y2, xmax, pcenter+1);
}
break;
}
default: {
KStyle::drawKStylePrimitive(ksp, p, w, r, cg, sf, o);
}
}
}
int AsteroidStyle::tqstyleHint( TQ_StyleHint stylehint,
const TQWidget *widget,
const TQStyleOption &option,
TQStyleHintReturn* returnData ) const
{
switch (stylehint) {
case SH_EtchDisabledText:
// case SH_Slider_SnapToValue:
// case SH_PrintDialog_RightAlignButtons:
// case SH_MainWindow_SpaceBelowMenuBar:
// case SH_FontDialog_SelectAssociatedText:
// case SH_PopupMenu_AllowActiveAndDisabled:
// case SH_MenuBar_AltKeyNavigation:
// case SH_MenuBar_MouseTracking:
// case SH_PopupMenu_MouseTracking:
// case SH_ComboBox_ListMouseTracking:
// case SH_ScrollBar_StopMouseOverSlider:
return 1;
default:
return KStyle::tqstyleHint(stylehint, widget, option, returnData);
}
}
void AsteroidStyle::tqdrawPrimitive(TQ_PrimitiveElement pe,
TQPainter *p,
const TQRect &r,
const TQColorGroup &cg,
SFlags sf,
const TQStyleOption &o) const
{
int x, y, x2, y2, w, h;
r.coords(&x, &y, &x2, &y2);
r.rect(&x, &y, &w, &h);
switch (pe) {
/* Primitives to draw are:
PE_ButtonCommand
PE_ButtonDropDown
PE_DockWindowSeparator
PE_DockWindowResizeHandle
PE_Splitter
PE_PanelGroupBox
PE_PanelTabWidget
PE_TabBarBase
PE_ProgressBarChunk
PE_GroupBoxFrame
PE_WindowFrame
PE_SizeGrip
PE_CheckMark
PE_CheckListController
PE_CheckListIndicator
PE_CheckListExclusiveIndicator
PE_ScrollBarFirst
PE_ScrollBarLast
*/
case PE_FocusRect: {
p->drawWinFocusRect(r);
break;
}
case PE_HeaderSection: {
p->setPen(cg.shadow());
p->setBrush(cg.background());
p->drawRect(r);
// if (sf & Style_On) {
// p->setPen(cg.mid());
// p->setBrush(TQBrush(cg.light(),TQt::Dense4Pattern));
// p->drawRect(r);
// p->setPen(cg.buttonText());
// } else if (sf & Style_Down) {
p->setPen(cg.mid());
p->drawRect(r);
p->setPen(cg.buttonText());
// } else {
// p->setPen(cg.light());
// p->drawLine(x, y, x2-1, y);
// p->drawLine(x, y, x, y2-1);
//
// p->setPen(cg.mid());
// p->drawLine(x2-1, y2-1, x+1, y2-1);
// p->drawLine(x2-1, y2-1, x2-1, y+1);
// }
break;
}
case PE_ButtonBevel: {
p->setPen(cg.shadow());
p->setBrush(cg.background());
p->drawRect(r);
if (sf & Style_On) {
p->setPen(cg.mid());
p->setBrush(TQBrush(cg.light(),TQt::Dense4Pattern));
p->drawRect(r);
p->setPen(cg.buttonText());
} else if (sf & Style_Down) {
p->setPen(cg.mid());
p->drawRect(r);
p->setPen(cg.buttonText());
} else {
p->setPen(cg.light());
p->drawLine(x, y, x2-1, y);
p->drawLine(x, y, x, y2-1);
p->setPen(cg.mid());
p->drawLine(x2-1, y2-1, x+1, y2-1);
p->drawLine(x2-1, y2-1, x2-1, y+1);
}
break;
}
case PE_ButtonDefault: {
p->setPen(cg.shadow());
p->drawRect(r);
break;
}
case PE_ButtonTool: {
p->setPen(sf & Style_On || sf & Style_Down ? cg.mid() : cg.light());
p->drawRect(r);
p->setPen(sf & Style_On || sf & Style_Down ? cg.light() : cg.mid());
p->drawLine(r.bottomRight(), r.topRight());
p->drawLine(r.bottomRight(), r.bottomLeft());
p->setPen(cg.buttonText());
break;
}
case PE_ScrollBarSlider: {
if (sf & Style_Enabled) {
p->fillRect(r, cg.background());
p->setPen(cg.light());
p->drawLine(x+1, y+1, x2-2, y+1);
p->drawLine(x+1, y+1, x+1, y2-2);
p->setPen(cg.mid());
p->drawLine(x2-1, y2-1, x+1, y2-1);
p->drawLine(x2-1, y2-1, x2-1, y+1);
p->setPen(cg.dark());
p->drawLine(x2, y2, x, y2);
p->drawLine(x2, y2, x2, y);
} else {
p->fillRect(r, cg.background());
p->fillRect(r, TQBrush(cg.light(), Dense4Pattern));
}
break;
}
case PE_StatusBarSection: {
p->fillRect(r, cg.background());
p->setPen(cg.mid());
p->drawLine(x, y, x2-1, y);
p->drawLine(x, y, x, y2-1);
p->setPen(cg.light());
p->drawLine(x2, y2, x, y2);
p->drawLine(x2, y2, x2, y);
break;
}
case PE_CheckMark: {
int x = r.center().x() - 3, y = r.center().y() - 3;
const TQCOORD check[] = { x, y + 2, x, y + 4, x + 2, y + 6, x + 6, y + 2, x + 6, y, x + 2, y + 4 };
const TQPointArray a(6, check);
p->setPen(cg.text());
p->setBrush(cg.text());
p->drawPolygon(a);
break;
}
case PE_Indicator: {
p->setPen(cg.mid());
p->setBrush(sf & Style_Down ? cg.background() : cg.base());
p->drawRect(r);
p->setPen(cg.mid());
p->drawLine(x, y, x2, y);
p->drawLine(x, y, x, y2);
p->setPen(cg.dark());
p->drawLine(x+1, y+1, x2-1, y+1);
p->drawLine(x+1, y+1, x+1, y2-1);
p->setPen(cg.background());
p->drawLine(x2-1, y2-1, x2-1, y+1);
p->drawLine(x2-1, y2-1, x+1, y2-1);
p->setPen(cg.light());
p->drawLine(x2, y2, x, y2);
p->drawLine(x2, y2, x2, y);
break;
}
case PE_IndicatorMask: {
p->fillRect (r, color1);
break;
}
case PE_ExclusiveIndicator: {
const TQCOORD outside[] = { 1, 9, 1, 8, 0, 7, 0, 4, 1, 3, 1, 2, 2, 1, 3, 1, 4, 0, 7, 0, 8, 1, 9, 1, 10, 2, 10, 3, 11, 4, 11, 7, 10, 8, 10, 9, 9, 10, 8, 10, 7, 11, 4, 11, 3, 10, 2, 10 };
const TQCOORD inside[] = { 2, 8, 1, 7, 1, 4, 2, 3, 2, 2, 3, 2, 4, 1, 7, 1, 8, 2, 9, 2, 9, 3, 10, 4, 10, 7, 9, 8, 9, 9, 8, 9, 7, 10, 4, 10, 3, 9, 2, 9 };
p->fillRect(r, cg.background());
if (sf & Style_Enabled && !(sf & Style_Down)) {
p->setPen(TQPen::NoPen);
p->setBrush(cg.base());
p->drawPolygon(TQPointArray(24, outside));
}
p->setPen(cg.mid());
p->tqdrawPolyline(TQPointArray(24, outside), 0, 12);
p->setPen(cg.light());
p->tqdrawPolyline(TQPointArray(24, outside), 12, 12);
p->setPen(cg.dark());
p->tqdrawPolyline(TQPointArray(20, inside), 0, 10);
p->setPen(cg.background());
p->tqdrawPolyline(TQPointArray(20, inside), 10, 10);
break;
}
case PE_ExclusiveIndicatorMask: {
const TQCOORD outside[] = { 1, 9, 1, 8, 0, 7, 0, 4, 1, 3, 1, 2, 2, 1, 3, 1, 4, 0, 7, 0, 8, 1, 9, 1, 10, 2, 10, 3, 11, 4, 11, 7, 10, 8, 10, 9, 9, 10, 8, 10, 7, 11, 4, 11, 3, 10, 2, 10 };
p->fillRect(r, color0);
p->setPen(color1);
p->setBrush(color1);
p->drawPolygon(TQPointArray(24, outside));
break;
}
case PE_WindowFrame:
case PE_Panel: {
bool sunken = sf & Style_Sunken;
p->setPen(sunken ? cg.mid() : cg.light());
p->drawLine(x, y, x2-1, y);
p->drawLine(x, y, x, y2-1);
p->setPen(sunken ? cg.dark() : cg.background());
p->drawLine(x+1, y+1, x2-1, y+1);
p->drawLine(x+1, y+1, x+1, y2-1);
p->setPen(sunken ? cg.light() : cg.mid());
p->drawLine(x2-1, y2-1, x+1, y2-1);
p->drawLine(x2-1, y2-1, x2-1, y+1);
p->setPen(sunken ? cg.background() : cg.dark());
p->drawLine(x2, y2, x, y2);
p->drawLine(x2, y2, x2, y);
break;
}
case PE_PanelLineEdit: {
p->fillRect(r, cg.base());
p->setPen(cg.light());
p->drawLine(x2, y2, x, y2);
p->drawLine(x2, y2, x2, y);
p->setPen(cg.background());
p->drawLine(x2-1, y2-1, x, y2-1);
p->drawLine(x2-1, y2-1, x2-1, y);
p->setPen(cg.mid());
p->drawLine(x, y, x2, y);
p->drawLine(x, y, x, y2);
p->setPen(cg.dark());
p->drawLine(x+1, y+1, x2-1, y+1);
p->drawLine(x+1, y+1, x+1, y2-1);
break;
}
case PE_PanelDockWindow: {
p->setPen(cg.mid());
p->drawLine(r.bottomLeft(), r.bottomRight());
p->setPen(cg.light());
p->drawLine(r.topLeft(), r.topRight());
break;
}
case PE_PanelMenuBar: {
p->setPen(cg.mid());
p->drawLine(r.bottomLeft(), r.bottomRight());
break;
}
case PE_ScrollBarAddPage:
case PE_ScrollBarSubPage: {
if (sf & Style_On || sf & Style_Down) {
p->fillRect(r, cg.mid().dark());
} else {
p->fillRect(r, cg.background());
}
p->fillRect(r, TQBrush(cg.light(), Dense4Pattern));
break;
}
case PE_ScrollBarAddLine: {
p->fillRect(r, cg.background());
if (sf & Style_Down) {
p->setPen(cg.mid());
p->drawRect(r);
} else {
p->setPen(cg.light());
p->drawLine(x+1, y+1, x2-2, y+1);
p->drawLine(x+1, y+1, x+1, y2-2);
p->setPen(cg.mid());
p->drawLine(x2-1, y2-1, x+1, y2-1);
p->drawLine(x2-1, y2-1, x2-1, y+1);
p->setPen(cg.dark());
p->drawLine(x2, y2, x, y2);
p->drawLine(x2, y2, x2, y);
}
p->setPen(cg.foreground());
if (sf & Style_Enabled) {
tqdrawPrimitive(sf & Style_Horizontal ? PE_ArrowRight : PE_ArrowDown, p, r, cg, sf);
} else {
p->setPen(cg.light());
tqdrawPrimitive(sf & Style_Horizontal ? PE_ArrowRight : PE_ArrowDown, p, TQRect(x+1, y+1, w-1, h-1), cg, sf);
tqdrawPrimitive(sf & Style_Horizontal ? PE_ArrowRight : PE_ArrowDown, p, r, cg, sf);
}
break;
}
case PE_ScrollBarSubLine: {
p->fillRect(r, cg.background());
if (sf & Style_Down) {
p->setPen(cg.mid());
p->drawRect(r);
} else {
p->setPen(cg.light());
p->drawLine(x+1, y+1, x2-2, y+1);
p->drawLine(x+1, y+1, x+1, y2-2);
p->setPen(cg.mid());
p->drawLine(x2-1, y2-1, x+1, y2-1);
p->drawLine(x2-1, y2-1, x2-1, y+1);
p->setPen(cg.dark());
p->drawLine(x2, y2, x, y2);
p->drawLine(x2, y2, x2, y);
}
p->setPen(cg.foreground());
tqdrawPrimitive(sf & Style_Horizontal ? PE_ArrowLeft : PE_ArrowUp, p, r, cg, sf);
break;
}
case PE_DockWindowHandle: {
p->setPen(cg.light());
if (sf & Style_Horizontal) {
TQRect hr(0, 0, 3, r.height()-6);
hr.moveCenter(r.center());
p->fillRect(r, cg.background());
p->drawRect(hr);
p->setPen(cg.mid());
p->drawLine(hr.bottomRight(), hr.topRight());
p->drawLine(hr.bottomRight(), hr.bottomLeft());
} else {
TQRect hr(0, 0, r.width()-6, 3);
hr.moveCenter(r.center());
p->fillRect(r, cg.background());
p->drawRect(hr);
p->setPen(cg.mid());
p->drawLine(hr.bottomLeft(), hr.bottomRight());
p->drawLine(hr.topRight(), hr.bottomRight());
}
break;
}
case PE_Separator:
case PE_DockWindowSeparator: {
p->fillRect(r, cg.background());
if (!(sf & Style_Horizontal)) {
p->setPen(cg.mid());
p->drawLine(x + 2, y , x2 - 2, y);
p->setPen(cg.light());
p->drawLine(x + 2, y + 1, x2 - 2, y + 1);
}
else
{
p->setPen(cg.mid());
p->drawLine(x + 2, y + 2, x + 2, y2 - 2);
p->setPen(cg.light());
p->drawLine(x + 3, y + 2, x + 3, y2 - 2);
}
break;
}
case PE_DockWindowResizeHandle: {
p->fillRect(r, cg.mid());
break;
}
case PE_PanelPopup: {
p->setPen(cg.background());
p->setBrush(cg.background());
p->drawRect(r);
p->setPen(cg.dark());
p->drawLine(x2, y2, x, y2);
p->drawLine(x2, y2, x2, y);
p->setPen(cg.light());
p->drawLine(x+1, y+1, x+1, y2-1);
p->drawLine(x+1, y+1, x2-1, y+1);
p->setPen(cg.mid());
p->drawLine(x2-1, y2-1, x+1, y2-1);
p->drawLine(x2-1, y2-1, x2-1, y+1);
break;
}
case PE_HeaderArrow:
case PE_ArrowUp:
case PE_ArrowDown:
case PE_ArrowLeft:
case PE_ArrowRight: {
TQPointArray a;
switch (pe) {
case PE_ArrowUp: {
a.setPoints(7, u_arrow);
break;
}
case PE_ArrowDown: {
a.setPoints(7, d_arrow);
break;
}
case PE_ArrowLeft: {
a.setPoints(7, l_arrow);
break;
}
case PE_ArrowRight: {
a.setPoints(7, r_arrow);
break;
}
default: {
if (sf & Style_Up) {
a.setPoints(7, u_arrow);
} else {
a.setPoints(7, d_arrow);
}
}
}
if (p->pen() == Qt::NoPen) {
p->setPen(sf & Style_Enabled ? cg.foreground() : cg.light());
}
if (sf & Style_Down) {
p->translate(tqpixelMetric(PM_ButtonShiftHorizontal),
tqpixelMetric(PM_ButtonShiftVertical));
}
a.translate((x + w/2), (y + (h-1)/2));
p->drawLineSegments(a, 0, 3);
p->drawPoint(a[6]);
if (sf & Style_Down) {
p->translate(-tqpixelMetric(PM_ButtonShiftHorizontal),
-tqpixelMetric(PM_ButtonShiftVertical));
}
break;
}
default: {
KStyle::tqdrawPrimitive(pe, p, r, cg, sf, o);
}
}
}
void AsteroidStyle::tqdrawControl(TQ_ControlElement ce,
TQPainter *p,
const TQWidget *w,
const TQRect &r,
const TQColorGroup &cg,
SFlags sf,
const TQStyleOption &o) const
{
int x, y, x2, y2, sw, sh;
r.coords(&x, &y, &x2, &y2);
r.rect(&x, &y, &sw, &sh);
switch (ce) {
/* TQ_ControlElements to draw are:
CE_CheckBoxLabel
CE_RadioButtonLabel
CE_TabBarTab
CE_TabBarLabel
CE_ProgressBarGroove
CE_ProgressBarContents
CE_ProgressBarLabel
CE_PopupMenuScroller
CE_PopupMenuHorizontalExtra
CE_PopupMenuVerticalExtra
CE_MenuBarEmptyArea
CE_DockWindowEmptyArea
CE_ToolButtonLabel
CE_ToolBoxTab
*/
#ifndef TQT_NO_TABBAR
case CE_TabBarTab:
{
if ( !w || !w->parentWidget() || !o.tab() )
break;
const TQTabBar * tb = (const TQTabBar *) w;
const TQTab * t = o.tab();
bool selected = sf & Style_Selected;
bool lastTab = (tb->indexOf( t->identifier() ) == tb->count()-1) ?
TRUE : FALSE;
TQRect r2( r );
if ( tb->tqshape() == TQTabBar::RoundedAbove ) {
p->setPen( cg.light() );
p->drawLine( r2.left(), r2.bottom()-1, r2.right(), r2.bottom()-1 );
if ( r2.left() == 0 )
p->drawPoint( tb->rect().bottomLeft() );
if ( selected ) {
p->fillRect( TQRect( r2.left()+1, r2.bottom()-1, r2.width()-3, 2),
cg.brush( TQColorGroup::Background ));
p->setPen( cg.background() );
p->drawLine( r2.left()+1, r2.bottom(), r2.left()+1, r2.top()+2 );
p->setPen( cg.light() );
} else {
p->setPen( cg.light() );
r2.setRect( r2.left() + 2, r2.top() + 2,
r2.width() - 4, r2.height() - 2 );
}
int x1, x2;
x1 = r2.left();
x2 = r2.right() - 2;
p->drawLine( x1, r2.bottom()-1, x1, r2.top() + 2 );
x1++;
p->drawPoint( x1, r2.top() + 1 );
x1++;
p->drawLine( x1, r2.top(), x2, r2.top() );
x1 = r2.left();
p->setPen( cg.dark() );
x2 = r2.right() - 1;
p->drawLine( x2, r2.top() + 2, x2, r2.bottom() - 1 +
(selected ? 0:-1) );
p->setPen( cg.shadow() );
p->drawPoint( x2, r2.top() + 1 );
p->drawPoint( x2, r2.top() + 1 );
x2++;
p->drawLine( x2, r2.top() + 2, x2, r2.bottom() -
(selected ? (lastTab ? 0:1) :2));
} else if ( tb->tqshape() == TQTabBar::RoundedBelow ) {
bool rightAligned = tqstyleHint( SH_TabBar_Alignment, tb ) == TQt::AlignRight;
bool firstTab = tb->indexOf( t->identifier() ) == 0;
if ( selected ) {
p->fillRect( TQRect( r2.left()+1, r2.top(), r2.width()-3, 1),
cg.brush( TQColorGroup::Background ));
p->setPen( cg.background() );
p->drawLine( r2.left()+1, r2.top(), r2.left()+1, r2.bottom()-2 );
p->setPen( cg.dark() );
} else {
p->setPen( cg.shadow() );
p->drawLine( r2.left() +
(rightAligned && firstTab ? 0 : 1),
r2.top() + 1,
r2.right() - (lastTab ? 0 : 2),
r2.top() + 1 );
if ( rightAligned && lastTab )
p->drawPoint( r2.right(), r2.top() );
p->setPen( cg.dark() );
p->drawLine( r2.left(), r2.top(), r2.right() - 1,
r2.top() );
r2.setRect( r2.left() + 2, r2.top(),
r2.width() - 4, r2.height() - 2 );
}
p->drawLine( r2.right() - 1, r2.top() + (selected ? 0: 2),
r2.right() - 1, r2.bottom() - 2 );
p->drawPoint( r2.right() - 2, r2.bottom() - 2 );
p->drawLine( r2.right() - 2, r2.bottom() - 1,
r2.left() + 1, r2.bottom() - 1 );
p->setPen( cg.shadow() );
p->drawLine( r2.right(),
r2.top() + (lastTab && rightAligned &&
selected) ? 0 : 1,
r2.right(), r2.bottom() - 1 );
p->drawPoint( r2.right() - 1, r2.bottom() - 1 );
p->drawLine( r2.right() - 1, r2.bottom(),
r2.left() + 2, r2.bottom() );
p->setPen( cg.light() );
p->drawLine( r2.left(), r2.top() + (selected ? 0 : 2),
r2.left(), r2.bottom() - 2 );
} else {
TQCommonStyle::tqdrawControl(ce, p, w, r, cg, sf, o);
}
break;
}
case CE_TabBarLabel:
{
if ( o.isDefault() )
break;
const TQTabBar * tb = (const TQTabBar *) w;
TQTab * t = o.tab();
const bool enabled = sf & Style_Enabled;
bool etchtext = tqstyleHint( SH_EtchDisabledText );
TQRect tr = r;
if ( t->identifier() == tb->currentTab() )
tr.setBottom( tr.bottom() -
tqpixelMetric( TQStyle::PM_DefaultFrameWidth, tb ) );
int tqalignment = TQt::AlignCenter | TQt::ShowPrefix;
if (!tqstyleHint(SH_UnderlineAccelerator, w, TQStyleOption::Default, 0))
tqalignment |= TQt::NoAccel;
tr.setWidth(tr.width()+4); // Compensate for text appearing too far to the left
TQRect tr_offset = TQRect(tr.x()+ETCH_X_OFFSET, tr.y()+ETCH_Y_OFFSET, tr.width(), tr.height());
if TABBAR_TEXT_ETCH_CONDITIONS {
TQPen savePen = p->pen();
p->setPen( cg.light() );
TQColorGroup etchedcg = cg;
etchedcg.setColor( TQColorGroup::Text, cg.light() );
etchedcg.setColor( TQColorGroup::Mid, cg.light() );
etchedcg.setColor( TQColorGroup::Midlight, cg.light() );
etchedcg.setColor( TQColorGroup::Foreground, cg.light() );
etchedcg.setColor( TQColorGroup::HighlightedText, cg.light() );
etchedcg.setColor( TQColorGroup::BrightText, cg.light() );
etchedcg.setColor( TQColorGroup::ButtonText, cg.light() );
drawItem( p, tr_offset, tqalignment, etchedcg, enabled, 0, t->text() );
p->setPen(savePen);
}
drawItem( p, tr, tqalignment, cg, enabled, 0, t->text() );
if ( (sf & Style_HasFocus) && !t->text().isEmpty() )
tqdrawPrimitive( TQStyle::PE_FocusRect, p, r, cg );
break;
}
#endif // TQT_NO_TABBAR
// case CE_CheckBoxLabel:
// {
// #ifndef TQT_NO_CHECKBOX
// const TQCheckBox *checkbox = (const TQCheckBox *) w;
//
// const bool enabled = sf & Style_Enabled;
// bool etchtext = tqstyleHint( SH_EtchDisabledText );
//
// int tqalignment = TQApplication::reverseLayout() ? TQt::AlignRight : TQt::AlignLeft;
// if (!tqstyleHint(SH_UnderlineAccelerator, w, TQStyleOption::Default, 0))
// tqalignment |= TQt::NoAccel;
//
// TQRect r_offset = TQRect(r.x()+ETCH_X_OFFSET, r.y()+ETCH_Y_OFFSET, r.width(), r.height());
// if CHECKBOX_TEXT_ETCH_CONDITIONS {
// TQPen savePen = p->pen();
// p->setPen( cg.light() );
// TQColorGroup etchedcg = cg;
// etchedcg.setColor( TQColorGroup::Text, cg.light() );
// etchedcg.setColor( TQColorGroup::Mid, cg.light() );
// etchedcg.setColor( TQColorGroup::Midlight, cg.light() );
// etchedcg.setColor( TQColorGroup::Foreground, cg.light() );
// etchedcg.setColor( TQColorGroup::HighlightedText, cg.light() );
// etchedcg.setColor( TQColorGroup::BrightText, cg.light() );
// etchedcg.setColor( TQColorGroup::ButtonText, cg.light() );
// drawItem(p, r_offset, tqalignment | TQt::AlignVCenter | TQt::ShowPrefix, cg, sf & Style_Enabled, checkbox->pixmap(), checkbox->text());
// p->setPen(savePen);
// }
// drawItem(p, r, tqalignment | TQt::AlignVCenter | TQt::ShowPrefix, cg, sf & Style_Enabled, checkbox->pixmap(), checkbox->text());
//
// if (sf & Style_HasFocus) {
// TQRect fr = tqvisualRect(subRect(SR_CheckBoxFocusRect, w), w);
// tqdrawPrimitive(TQStyle::PE_FocusRect, p, fr, cg, sf);
// }
// #endif
// break;
// }
// case CE_RadioButtonLabel:
// {
// #ifndef TQT_NO_RADIOBUTTON
// const TQRadioButton *radiobutton = (const TQRadioButton *) w;
//
// const bool enabled = sf & Style_Enabled;
// bool etchtext = tqstyleHint( SH_EtchDisabledText );
//
// int tqalignment = TQApplication::reverseLayout() ? TQt::AlignRight : TQt::AlignLeft;
// if (!tqstyleHint(SH_UnderlineAccelerator, w, TQStyleOption::Default, 0))
// tqalignment |= TQt::NoAccel;
//
// TQRect r_offset = TQRect(r.x()+ETCH_X_OFFSET, r.y()+ETCH_Y_OFFSET, r.width(), r.height());
// if RADIOBUTTON_TEXT_ETCH_CONDITIONS {
// TQPen savePen = p->pen();
// p->setPen( cg.light() );
// TQColorGroup etchedcg = cg;
// etchedcg.setColor( TQColorGroup::Text, cg.light() );
// etchedcg.setColor( TQColorGroup::Mid, cg.light() );
// etchedcg.setColor( TQColorGroup::Midlight, cg.light() );
// etchedcg.setColor( TQColorGroup::Foreground, cg.light() );
// etchedcg.setColor( TQColorGroup::HighlightedText, cg.light() );
// etchedcg.setColor( TQColorGroup::BrightText, cg.light() );
// etchedcg.setColor( TQColorGroup::ButtonText, cg.light() );
// drawItem(p, r_offset, tqalignment | TQt::AlignVCenter | TQt::ShowPrefix, cg, enabled, radiobutton->pixmap(), radiobutton->text());
// p->setPen(savePen);
// }
// drawItem(p, r, tqalignment | TQt::AlignVCenter | TQt::ShowPrefix, cg, enabled, radiobutton->pixmap(), radiobutton->text());
//
// if (sf & Style_HasFocus) {
// TQRect fr = tqvisualRect(subRect(SR_RadioButtonFocusRect, w), w);
// tqdrawPrimitive(TQStyle::PE_FocusRect, p, fr, cg, sf);
// }
// #endif
// break;
// }
case CE_ToolBoxTab:
{
qDrawShadePanel( p, r, cg, sf & (Style_Sunken | Style_Down | Style_On) , 1,
&cg.brush(TQColorGroup::Button));
break;
}
case CE_ProgressBarContents: {
// ### Take into account totalSteps() for busy indicator
const TQProgressBar* pb = (const TQProgressBar*)w;
TQRect cr = subRect(SR_ProgressBarContents, w);
double progress = pb->progress();
bool reverse = TQApplication::reverseLayout();
int steps = pb->totalSteps();
if (!cr.isValid())
return;
p->setPen(cg.light());
p->setBrush(cg.light());
p->drawRect(r);
// Draw progress bar
if (progress > 0 || steps == 0) {
double pg = (steps == 0) ? 0.1 : progress / steps;
int width = TQMIN(cr.width(), (int)(pg * cr.width()));
if (steps == 0) { //Busy indicator
if (width < 1) width = 1; //A busy indicator with width 0 is kind of useless
int remWidth = cr.width() - width; //Never disappear completely
if (remWidth <= 0) remWidth = 1; //Do something non-crashy when too small...
int pstep = int(progress) % ( 2 * remWidth );
if ( pstep > remWidth ) {
//Bounce about.. We're remWidth + some delta, we want to be remWidth - delta...
// - ( (remWidth + some delta) - 2* remWidth ) = - (some deleta - remWidth) = remWidth - some delta..
pstep = - (pstep - 2 * remWidth );
}
if (reverse)
p->fillRect(cr.x() + cr.width() - width - pstep, cr.y(), width, cr.height(),
cg.brush(TQColorGroup::Highlight));
else
p->fillRect(cr.x() + pstep, cr.y(), width, cr.height(),
cg.brush(TQColorGroup::Highlight));
return;
}
if (reverse)
p->fillRect(cr.x()+(cr.width()-width), cr.y(), width, cr.height(),
cg.brush(TQColorGroup::Highlight));
else
p->fillRect(cr.x(), cr.y(), width, cr.height(),
cg.brush(TQColorGroup::Highlight));
}
break;
}
case CE_CheckBox: {
tqdrawPrimitive(PE_Indicator, p, r, cg, sf);
if (sf & Style_On) {
tqdrawPrimitive(PE_CheckMark, p, r, cg, sf);
}
break;
}
case CE_RadioButton: {
tqdrawPrimitive(PE_ExclusiveIndicator, p, r, cg, sf);
if (sf & Style_On) {
TQCOORD center[] = { 4, 5, 4, 6, 5, 7, 6, 7, 7, 6, 7, 5, 6, 4, 5, 4 };
TQPointArray c(8, center);
p->setPen(cg.text());
p->setBrush(cg.text());
p->drawPolygon(c);
}
break;
}
case CE_PushButton: {
const TQPushButton *pb = dynamic_cast<const TQPushButton *>(w);
if ( ::tqqt_cast<KMultiTabBarButton*>(w) ) {
p->setPen(cg.mid());
p->setBrush(cg.background());
p->drawRect(r);
if (sf & Style_On) {
p->setPen(cg.mid());
p->setBrush(TQBrush(cg.light(),TQt::Dense4Pattern));
p->drawRect(r);
p->setPen(cg.buttonText());
} else if (sf & Style_Down) {
p->setPen(cg.mid());
p->drawRect(r);
p->setPen(cg.buttonText());
} else {
p->setPen(cg.mid());
p->drawLine(x, y, x2-1, y);
p->drawLine(x, y, x, y2-1);
}
}
else {
if (pb->isDefault()) {
tqdrawPrimitive(PE_ButtonDefault, p, r, cg, sf);
tqdrawPrimitive(PE_ButtonBevel, p, TQRect(x+1, y+1, sw-2, sh-2), cg, sf);
} else {
tqdrawPrimitive(PE_ButtonBevel, p, r, cg, sf);
}
}
break;
}
case CE_MenuBarItem: {
bool active = sf & Style_Active;
bool focused = sf & Style_HasFocus;
bool down = sf & Style_Down;
bool enabled = sf & Style_Enabled;
bool etchtext = tqstyleHint( SH_EtchDisabledText );
const int text_flags = AlignVCenter | AlignHCenter | ShowPrefix | DontClip | SingleLine;
if (active && focused) {
p->setBrush(cg.background());
p->setPen(cg.background());
p->drawRect(r);
if (down) {
p->setPen(cg.mid());
p->drawLine(x, y, x2, y);
p->drawLine(x, y, x, y2);
p->setPen(cg.light());
p->drawLine(x2, y2, x, y2);
p->drawLine(x2, y2, x2, y);
/*p->translate(1, 1);*/
} else {
p->setPen(cg.light());
p->drawLine(x, y, x2, y);
p->drawLine(x, y, x, y2);
p->setPen(cg.mid());
p->drawLine(x2, y2, x, y2);
p->drawLine(x2, y2, x2, y);
}
}
p->setPen(cg.foreground());
TQRect r_offset = TQRect(r.x()+ETCH_X_OFFSET, r.y()+ETCH_Y_OFFSET, r.width(), r.height());
if POPUPMENUITEM_TEXT_ETCH_CONDITIONS {
TQPen savePen = p->pen();
p->setPen( cg.light() );
p->drawText(r_offset, text_flags, o.menuItem()->text());
p->setPen(savePen);
}
p->drawText(r, text_flags, o.menuItem()->text());
/*if (active && focused && down) {
p->translate(-1, -1);
}*/
break;
}
case CE_PushButtonLabel: {
const TQPushButton *pb = dynamic_cast<const TQPushButton *>(w);
const bool enabled = sf & Style_Enabled;
bool etchtext = tqstyleHint( SH_EtchDisabledText );
const int text_flags = AlignVCenter | AlignHCenter | ShowPrefix | DontClip | SingleLine;
int dx = 0;
if (sf & Style_Down) {
p->translate(tqpixelMetric(PM_ButtonShiftHorizontal),
tqpixelMetric(PM_ButtonShiftVertical));
}
if (pb->iconSet() && !pb->iconSet()->isNull()) {
TQIconSet::Mode mode = enabled ? TQIconSet::Normal : TQIconSet::Disabled;
TQPixmap pixmap = pb->iconSet()->pixmap(TQIconSet::Small, mode);
TQRect pr(0, 0, pixmap.width(), pixmap.height());
if (pb->text().isNull())
dx = r.center().x()-(pixmap.width()/2);
else
dx = (r.height() - pixmap.height())/2;
if ( ::tqqt_cast<KMultiTabBarButton*>(pb) ) {
pr.moveCenter(TQPoint(((pixmap.width()/2)+dx), r.center().y()));
dx = (pixmap.width()+dx+(dx*0.5));
}
else {
pr.moveCenter(TQPoint(((pixmap.width()/2)+dx), r.center().y()));
dx = (pixmap.width()+dx+(dx*0.5));
}
p->drawPixmap(pr.topLeft(), pixmap);
} else if (pb->pixmap() && !pb->text()) {
TQRect pr(0, 0, pb->pixmap()->width(), pb->pixmap()->height());
pr.moveCenter(r.center());
p->drawPixmap(pr.topLeft(), *pb->pixmap());
}
if (!pb->text().isNull()) {
p->setPen(enabled ? cg.buttonText() : pb->tqpalette().disabled().buttonText());
if (pb->iconSet() && !pb->iconSet()->isNull()) {
TQRect tpr(dx, r.y(), r.width()-dx, r.height());
TQRect tr(p->boundingRect(tpr, text_flags, pb->text()));
TQRect tr_offset = TQRect(tr.x()+ETCH_X_OFFSET, tr.y()+ETCH_Y_OFFSET, tr.width(), tr.height());
if PUSHBUTTON_TEXT_ETCH_CONDITIONS {
TQPen savePen = p->pen();
p->setPen( cg.light() );
p->drawText(tr_offset, text_flags, pb->text());
p->setPen(savePen);
}
p->drawText(tr, text_flags, pb->text());
} else {
TQRect r_offset = TQRect(r.x()+ETCH_X_OFFSET, r.y()+ETCH_Y_OFFSET, r.width(), r.height());
if PUSHBUTTON_TEXT_ETCH_CONDITIONS {
TQPen savePen = p->pen();
p->setPen( cg.light() );
p->drawText(r_offset, text_flags, pb->text());
p->setPen(savePen);
}
p->drawText(r, text_flags, pb->text());
}
}
break;
}
/* Note: This is very poorly documented by TT. I'm disappointed. -clee */
case CE_HeaderLabel: {
const TQHeader *hw = dynamic_cast<const TQHeader *>(w);
int hs = o.headerSection();
const bool enabled = sf & Style_Enabled;
bool etchtext = tqstyleHint( SH_EtchDisabledText );
const int text_flags = AlignVCenter | ShowPrefix | DontClip | SingleLine;
TQIconSet *is = hw->iconSet(hs);
if (is) {
TQPixmap pm = is->pixmap(TQIconSet::Small, sf & Style_Enabled ? TQIconSet::Normal : TQIconSet::Disabled);
TQRect pr(0, 0, pm.width(), pm.height());
pr.moveCenter(r.center());
pr.setLeft(r.center().y() - (pm.height() - 1) / 2);
p->drawPixmap(pr.topLeft(), pm);
pr = TQRect(pr.width(), r.top(), r.width() - pr.width(), r.height());
TQRect pr_offset = TQRect(pr.x()+ETCH_X_OFFSET, pr.y()+ETCH_Y_OFFSET, pr.width(), pr.height());
if HEADER_TEXT_ETCH_CONDITIONS {
TQPen savePen = p->pen();
p->setPen( cg.light() );
p->drawText(pr_offset, text_flags, hw->label(hs));
p->setPen(savePen);
}
p->drawText(pr, text_flags, hw->label(hs));
} else {
p->setPen(cg.buttonText());
TQRect r_offset = TQRect(r.x()+ETCH_X_OFFSET, r.y()+ETCH_Y_OFFSET, r.width(), r.height());
if HEADER_TEXT_ETCH_CONDITIONS {
TQPen savePen = p->pen();
p->setPen( cg.light() );
p->drawText(r_offset, text_flags, hw->label(hs));
p->setPen(savePen);
}
p->drawText(r, text_flags, hw->label(hs));
}
break;
}
case CE_PopupMenuItem: {
TQMenuItem *mi = o.menuItem();
if (!mi) {
return;
}
const TQPopupMenu *pum = dynamic_cast<const TQPopupMenu *>(w);
static const int itemFrame = 2;
static const int itemHMargin = 3;
static const int itemVMargin = 3;
static const int arrowHMargin = 4;
static const int rightBorder = 16;
const int tab = o.tabWidth();
int checkcol = TQMAX(o.maxIconWidth(), 12);
bool active = sf & Style_Active;
bool disabled = !mi->isEnabled();
bool checkable = pum->isCheckable();
bool enabled = mi->isEnabled();
bool etchtext = tqstyleHint( SH_EtchDisabledText );
int xpos = x;
int xm = itemFrame + checkcol + itemHMargin;
if (pum->erasePixmap() && !pum->erasePixmap()->isNull()) {
p->drawPixmap(x, y, *pum->erasePixmap(), x, y, sw, sh);
} else {
p->fillRect(x, y, sw, sh, cg.background());
}
if (mi->widget()) {
/* nOOOOOOOOOOOP */
} else if (mi->isSeparator()) {
p->setPen(cg.mid());
p->drawLine(x + 1, y + 3, x2 - 1, y + 3);
p->setPen(cg.light());
p->drawLine(x + 1, y + 4, x2 - 1, y + 4);
return;
}
if (active && !disabled && !mi->isSeparator()) {
p->setBrush(cg.highlight());
p->fillRect(r, cg.highlight());
p->setPen(cg.highlightedText());
}
if (mi->iconSet()) {
TQIconSet::Mode mode =
disabled ? TQIconSet::Disabled : TQIconSet::Normal;
TQPixmap pixmap = mi->iconSet()->pixmap(TQIconSet::Small, mode);
int pixw = pixmap.width();
int pixh = pixmap.height();
TQRect cr(xpos, y, o.maxIconWidth(), sh);
TQRect pmr(0, 0, pixw, pixh);
pmr.moveCenter(cr.center());
if (backwards)
pmr = tqvisualRect(pmr, r);
p->setPen(cg.highlightedText());
p->drawPixmap(pmr.topLeft(), pixmap);
} else if (checkable) {
if (mi->isChecked()) {
int xp = xpos;
SFlags cflags = Style_Default;
if (disabled) {
cflags |= Style_On;
} else {
cflags |= Style_Enabled;
}
p->setPen(active ? cg.highlightedText() : cg.buttonText());
TQRect rr = TQRect(xp, y, checkcol, sh);
if (backwards) {
rr = tqvisualRect(rr, r);
}
tqdrawPrimitive(PE_CheckMark, p, rr, cg, cflags);
}
}
xpos += xm;
if (mi->custom()) {
int m = itemVMargin;
p->setPen(cg.foreground());
if POPUPMENUITEM_TEXT_ETCH_CONDITIONS {
TQPen savePen = p->pen();
p->setPen( cg.light() );
TQColorGroup etchedcg = cg;
etchedcg.setColor( TQColorGroup::Text, cg.light() );
etchedcg.setColor( TQColorGroup::Mid, cg.light() );
etchedcg.setColor( TQColorGroup::Midlight, cg.light() );
etchedcg.setColor( TQColorGroup::Foreground, cg.light() );
etchedcg.setColor( TQColorGroup::HighlightedText, cg.light() );
etchedcg.setColor( TQColorGroup::BrightText, cg.light() );
etchedcg.setColor( TQColorGroup::ButtonText, cg.light() );
mi->custom()->paint(p, etchedcg, active, !disabled, x+xm+ETCH_X_OFFSET, y+m+ETCH_Y_OFFSET, sw-xm-tab+1, sh-2*m);
p->setPen(savePen);
}
mi->custom()->paint(p, cg, active, !disabled, x+xm, y+m, sw-xm-tab+1, sh-2*m);
return;
} else {
p->setPen(active ? cg.highlightedText() : cg.buttonText());
TQString s = mi->text();
if(!s.isNull()) {
int t = s.tqfind('\t');
int m = itemVMargin;
int text_flags = AlignVCenter | ShowPrefix | DontClip | SingleLine;
if (active && !disabled) {
p->setPen(cg.highlightedText());
} else if (disabled) {
p->setPen(cg.mid().light(110));
} else {
p->setPen(cg.text());
}
if (t >= 0) {
int xp = x + sw - tab - rightBorder - itemHMargin - itemFrame + 1;
TQRect rr = TQRect(xp, y+m, tab, sh-(2*m));
TQRect rr_offset = TQRect(xp+ETCH_X_OFFSET, y+m+ETCH_Y_OFFSET, tab, sh-(2*m));
if (backwards) {
rr = tqvisualRect(rr, r);
rr_offset = tqvisualRect(rr_offset, r);
}
if POPUPMENUITEM_TEXT_ETCH_CONDITIONS {
TQPen savePen = p->pen();
p->setPen( cg.light() );
p->drawText(rr_offset, text_flags, s.mid(t+1));
p->setPen(savePen);
}
p->drawText(rr, text_flags, s.mid(t+1));
s = s.left(t);
}
TQRect rr = TQRect(xpos, y+m, sw-xm-tab+1, sh-(2*m));
TQRect rr_offset = TQRect(xpos+ETCH_X_OFFSET, y+m+ETCH_Y_OFFSET, sw-xm-tab+1, sh-(2*m));
if (backwards) {
rr = tqvisualRect(rr, r);
rr_offset = tqvisualRect(rr_offset, r);
text_flags |= AlignRight;
}
if POPUPMENUITEM_TEXT_ETCH_CONDITIONS {
TQPen savePen = p->pen();
p->setPen( cg.light() );
p->drawText(rr_offset, text_flags, s);
p->setPen(savePen);
}
p->drawText(rr, text_flags, s);
} else if (mi->pixmap()) {
TQPixmap *pixmap = mi->pixmap();
if (pixmap->depth() == 1) {
p->setBackgroundMode(Qt::OpaqueMode);
}
p->drawPixmap(xpos, y, *pixmap);
if (pixmap->depth() == 1) {
p->setBackgroundMode(Qt::TransparentMode);
}
}
}
if (mi->popup()) {
int dim = tqpixelMetric(PM_MenuButtonIndicator);
xpos = x + sw - arrowHMargin - 2 * itemFrame - dim;
if (active && !disabled) {
p->setPen(cg.highlightedText());
} else {
p->setPen(cg.text());
}
TQRect rr = TQRect(xpos, y + sh/2 - dim/2, dim, dim);
if (backwards)
rr = tqvisualRect(rr, r);
tqdrawPrimitive((backwards ? PE_ArrowLeft : PE_ArrowRight), p, rr, cg, Style_Enabled);
}
break;
}
default: {
KStyle::tqdrawControl(ce, p, w, r, cg, sf, o);
}
}
}
void AsteroidStyle::tqdrawControlMask(TQ_ControlElement ce,
TQPainter *p,
const TQWidget *w,
const TQRect &r,
const TQStyleOption &o) const
{
switch (ce) {
/*
TQ_ControlElements to draw are:
CE_PushButton
CE_PushButtonLabel
CE_CheckBox
CE_CheckBoxLabel
CE_RadioButton
CE_RadioButtonLabel
CE_TabBarTab
CE_TabBarLabel
CE_ProgressBarGroove
CE_ProgressBarContents
CE_ProgressBarLabel
CE_PopupMenuScroller
CE_PopupMenuHorizontalExtra
CE_PopupMenuVerticalExtra
CE_PopupMenuItem
CE_MenuBarItem
CE_MenuBarEmptyArea
CE_DockWindowEmptyArea
CE_ToolButtonLabel
CE_ToolBoxTab
CE_HeaderLabel
*/
default: {
KStyle::tqdrawControlMask(ce, p, w, r, o);
}
}
}
void AsteroidStyle::tqdrawComplexControl(TQ_ComplexControl cc,
TQPainter *p,
const TQWidget *w,
const TQRect &r,
const TQColorGroup &cg,
SFlags sf,
SCFlags sc,
SCFlags sa,
const TQStyleOption &o) const
{
switch (cc) {
/* TQ_ComplexControls available are:
CC_SpinWidget
CC_ScrollBar
CC_Slider
CC_ToolButton
CC_TitleBar
CC_ListView
*/
case CC_ComboBox: {
int x, y, x2, y2, sw, sh;
const TQComboBox *cb = dynamic_cast<const TQComboBox *>(w);
r.rect(&x, &y, &sw, &sh);
r.coords(&x, &y, &x2, &y2);
if (sa & Style_Sunken) {
sf |= Style_Sunken;
}
static const unsigned char downarrow_bits[] = {
0x7f, 0xbe, 0x9c, 0x08, 0x00, 0x00, 0x00, 0x28,
0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0xb8
};
static const unsigned int handle_width = 16;
static const unsigned int handle_offset = handle_width + 1;
TQBitmap downArrow = TQBitmap(7, 4, downarrow_bits, true);
downArrow.setMask(downArrow);
// Draw the frame around the text.
p->setPen(cg.mid());
p->setBrush(cg.dark());
p->drawRect(r);
p->setPen(cg.light());
p->drawLine(x2, y2, x2, y);
p->drawLine(x2, y2, x, y2);
p->setPen(cg.background());
p->drawLine(x2-1, y2-1, x2-1, y+1);
p->drawLine(x2-1, y2-1, x+1, y2-1);
// Fill in the area behind the text.
p->fillRect(querySubControlMetrics(cc, w, SC_ComboBoxEditField), cg.base());
p->setBrush(cg.background());
// Draw the box on the right.
TQRect hr(sw - handle_offset-1, y+2, handle_width, sh-4);
int hrx, hry, hrx2, hry2;
hr.coords(&hrx, &hry, &hrx2, &hry2);
if (backwards) { hr = tqvisualRect(hr, r); }
p->drawRect(hr);
if (cb->listBox() && cb->listBox()->isVisible()) {
p->setPen(cg.mid());
p->drawRect(hr);
} else {
p->setPen(cg.light());
p->drawLine(hrx+1, hry+1, hrx2-1, hry+1);
p->drawLine(hrx+1, hry+1, hrx+1, hry2-1);
p->setPen(cg.mid());
p->drawLine(hrx2-1, hry2-1, hrx+1, hry2-1);
p->drawLine(hrx2-1, hry2-1, hrx2-1, hry+1);
p->setPen(cg.dark());
p->drawLine(hrx2, hry2, hrx, hry2);
p->drawLine(hrx2, hry2, hrx2, hry);
}
TQRect cr(sw - handle_offset-1, y+2, handle_width, sh - 4);
TQRect pmr(0, 0, 7, 4);
pmr.moveCenter(cr.center());
if (cb->listBox() && cb->listBox()->isVisible()) {
pmr.moveBy(1, 1);
}
if (backwards) { pmr = tqvisualRect(pmr, r); }
p->setPen(cg.foreground());
p->drawPixmap(pmr.topLeft(), downArrow);
break;
}
#ifndef TQT_NO_TOOLBUTTON
case CC_ToolButton:
{
const TQToolButton *toolbutton = (const TQToolButton *) w;
TQColorGroup c = cg;
if ( toolbutton->backgroundMode() != TQt::PaletteButton )
c.setBrush( TQColorGroup::Button, toolbutton->paletteBackgroundColor() );
TQRect button, menuarea;
button = tqvisualRect( querySubControlMetrics(cc, w, SC_ToolButton, o), w );
menuarea = tqvisualRect( querySubControlMetrics(cc, w, SC_ToolButtonMenu, o), w );
SFlags bflags = sf;
SFlags mflags = sf;
if (sa & SC_ToolButton)
bflags |= Style_Down;
if (sa & SC_ToolButtonMenu)
mflags |= Style_Down;
if (sc & SC_ToolButton) {
if (bflags & (Style_Down | Style_On | Style_Raised)) {
tqdrawPrimitive(TQStyle::PE_ButtonTool, p, button, c, bflags, o);
} else if ( toolbutton->parentWidget() && toolbutton->parentWidget()->backgroundPixmap() && ! toolbutton->parentWidget()->backgroundPixmap()->isNull() ) {
TQPixmap pixmap =
*(toolbutton->parentWidget()->backgroundPixmap());
p->drawTiledPixmap( r, pixmap, toolbutton->pos() );
}
}
if (sc & SC_ToolButtonMenu) {
if (mflags & (Style_Down | Style_On | Style_Raised))
tqdrawPrimitive(TQStyle::PE_ButtonDropDown, p, menuarea, c, mflags, o);
tqdrawPrimitive(TQStyle::PE_ArrowDown, p, menuarea, c, mflags, o);
}
if (toolbutton->hasFocus() && !toolbutton->focusProxy()) {
TQRect fr = toolbutton->rect();
fr.addCoords(3, 3, -3, -3);
tqdrawPrimitive(TQStyle::PE_FocusRect, p, fr, c);
}
break;
}
#endif // TQT_NO_TOOLBUTTON
case CC_Slider: {
const TQSlider* slider = (const TQSlider*)w;
TQRect groove = querySubControlMetrics(CC_Slider, w, SC_SliderGroove, o);
TQRect handle = querySubControlMetrics(CC_Slider, w, SC_SliderHandle, o);
// Double-buffer slider for no flicker
TQPixmap pix(w->size());
TQPainter p2;
p2.begin(&pix);
if ( slider->parentWidget() &&
slider->parentWidget()->backgroundPixmap() &&
!slider->parentWidget()->backgroundPixmap()->isNull() ) {
TQPixmap pixmap = *(slider->parentWidget()->backgroundPixmap());
p2.drawTiledPixmap(r, pixmap, slider->pos());
} else
pix.fill(cg.background());
// Draw slider groove
if ((sc & SC_SliderGroove) && groove.isValid()) {
drawKStylePrimitive( KPE_SliderGroove, &p2, w, groove, cg, sf, o );
// Draw the focus rect around the groove
if (slider->hasFocus())
tqdrawPrimitive(PE_FocusRect, &p2, groove, cg);
}
/* Turn these off for now */
// Draw the tickmarks
/*if (controls & SC_SliderTickmarks)
TQCommonStyle::tqdrawComplexControl(control, &p2,
r, cg, flags, SC_SliderTickmarks, sa, o);*/
// Draw the slider handle
if ((sc & SC_SliderHandle) && handle.isValid()) {
if (sa == SC_SliderHandle)
sf |= Style_Active;
drawKStylePrimitive( KPE_SliderHandle, &p2, w, handle, cg, sf, o );
}
p2.end();
bitBlt((TQWidget*)w, r.x(), r.y(), &pix);
break;
}
case CC_SpinWidget: {
int x, y, x2, y2, w, h;
int aw = 12; // arrow button width
r.coords(&x, &y, &x2, &y2);
r.rect(&x, &y, &w, &h);
TQRect arrowup(x2-aw, y+2, aw, h/2-1);
TQRect arrowdn(x2-aw, h/2+1, aw, h/2-2);
// Draw the frame around the text
p->setPen(cg.mid());
p->setBrush(cg.dark());
p->drawRect(r);
p->setPen(cg.light());
p->drawLine(x2, y2, x2, y);
p->drawLine(x2, y2, x, y2);
p->setPen(cg.background());
p->drawLine(x2-1, y2-1, x2-1, y+2);
p->drawLine(x2-1, y2-1, x+1, y2-1);
// Draw the arrow buttons
p->drawLine(x2-aw-1, y+2, x2-aw-1, y2-1);
tqdrawPrimitive(PE_ButtonBevel, p, arrowup, cg, sf, o);
tqdrawPrimitive(PE_ButtonBevel, p, arrowdn, cg, sf, o);
tqdrawPrimitive(PE_SpinWidgetUp, p, arrowup, cg, sf, o);
tqdrawPrimitive(PE_SpinWidgetDown, p, arrowdn, cg, sf, o);
break;
}
default: {
KStyle::tqdrawComplexControl(cc, p, w, r, cg, sf, sc, sa, o);
}
}
}
void AsteroidStyle::tqdrawComplexControlMask(TQ_ComplexControl cc,
TQPainter *p,
const TQWidget *w,
const TQRect &r,
const TQStyleOption &o) const
{
switch (cc) {
/* TQ_ComplexControls available are:
CC_SpinWidget
CC_ComboBox
CC_ScrollBar
CC_Slider
CC_ToolButton
CC_TitleBar
CC_ListView
*/
default: {
KStyle::tqdrawComplexControlMask(cc, p, w, r, o);
}
}
}
int AsteroidStyle::tqpixelMetric(PixelMetric pm, const TQWidget *w) const
{
switch (pm) {
/* PixelMetrics available are:
PM_ButtonMargin
PM_ButtonDefaultIndicator
PM_SpinBoxFrameWidth
PM_MDIFrameWidth
PM_MDIMinimizedWidth
PM_MaximumDragDistance
PM_ScrollBarExtent
PM_ScrollBarSliderMin
PM_SliderThickness
PM_SliderControlThickness
PM_SliderLength
PM_SliderTickmarkOffset
PM_SliderSpaceAvailable
PM_DockWindowSeparatorExtent
PM_DockWindowHandleExtent
PM_TabBarTabOverlap
PM_TabBarTabHSpace
PM_TabBarTabVSpace
PM_TabBarBaseHeight
PM_TabBarBaseOverlap
PM_ProgressBarChunkWidth
PM_SplitterWidth
PM_TitleBarHeight
PM_CheckListButtonSize
PM_CheckListControllerSize
PM_PopupMenuFrameHorizontalExtra
PM_PopupMenuFrameVerticalExtra
PM_PopupMenuScrollerHeight
PM_HeaderMarkSize
PM_TabBarTabShiftHorizontal
PM_TabBarTabShiftVertical
*/
case PM_ExclusiveIndicatorWidth:
case PM_ExclusiveIndicatorHeight: {
return 12;
}
case PM_IndicatorWidth:
case PM_IndicatorHeight: {
return 13;
}
case PM_MenuBarFrameWidth: {
return 2;
}
case PM_ButtonShiftHorizontal:
case PM_ButtonShiftVertical: {
return 1;
}
case PM_HeaderGripMargin:
case PM_HeaderMargin: {
return 3;
}
case PM_DialogButtonsButtonWidth: {
return MINIMUM_PUSHBUTTON_WIDTH;
}
case PM_DialogButtonsButtonHeight: {
return MINIMUM_PUSHBUTTON_HEIGHT;
}
case PM_DockWindowSeparatorExtent:
case PM_MenuButtonIndicator:
case PM_DockWindowFrameWidth:
case PM_DialogButtonsSeparator: {
return 6;
}
case PM_DefaultFrameWidth: {
if (w && w->inherits(TQPOPUPMENU_OBJECT_NAME_STRING)) {
return 3;
} else {
return KStyle::tqpixelMetric(pm, w);
}
}
case PM_TabBarTabOverlap:
return 4;
case PM_TabBarBaseHeight:
return 0;
case PM_TabBarBaseOverlap:
return 0;
case PM_TabBarTabHSpace:
return 24;
case PM_TabBarTabShiftHorizontal:
return 4;
case PM_TabBarTabShiftVertical:
return 2;
default: {
return KStyle::tqpixelMetric(pm, w);
}
}
}
TQRect AsteroidStyle::subRect(SubRect sr, const TQWidget *w) const
{
switch (sr) {
/* SubRects to calculate are:
SR_PushButtonContents
SR_PushButtonFocusRect
SR_CheckBoxIndicator
SR_CheckBoxContents
SR_CheckBoxFocusRect
SR_RadioButtonIndicator
SR_RadioButtonContents
SR_RadioButtonFocusRect
SR_ComboBoxFocusRect
SR_SliderFocusRect
SR_DockWindowHandleRect
SR_ProgressBarGroove
SR_ProgressBarContents
SR_ProgressBarLabel
SR_ToolButtonContents
SR_ToolBoxTabContents
SR_DialogButtonAccept
SR_DialogButtonReject
SR_DialogButtonApply
SR_DialogButtonHelp
SR_DialogButtonAll
SR_DialogButtonAbort
SR_DialogButtonIgnore
SR_DialogButtonRetry
SR_DialogButtonCustom
*/
default: {
return KStyle::subRect(sr, w);
}
}
}
TQRect AsteroidStyle::querySubControlMetrics(TQ_ComplexControl cc,
const TQWidget *w,
SubControl sc,
const TQStyleOption &o) const
{
switch (cc) {
/* Available SubControls are:
SC_ScrollBarAddLine
SC_ScrollBarSubLine
SC_ScrollBarAddPage
SC_ScrollBarSubPage
SC_ScrollBarFirst
SC_ScrollBarLast
SC_ScrollBarSlider
SC_ScrollBarGroove
SC_SpinWidgetUp
SC_SpinWidgetDown
SC_SpinWidgetFrame
SC_SpinWidgetEditField
SC_SpinWidgetButtonField
SC_ComboBoxFrame
SC_ComboBoxArrow
SC_ComboBoxListBoxPopup
SC_SliderGroove
SC_SliderHandle
SC_SliderTickmarks
SC_ToolButton
SC_ToolButtonMenu
SC_TitleBarLabel
SC_TitleBarSysMenu
SC_TitleBarMinButton
SC_TitleBarMaxButton
SC_TitleBarCloseButton
SC_TitleBarNormalButton
SC_TitleBarShadeButton
SC_TitleBarUnshadeButton
SC_ListView
SC_ListViewBranch
SC_ListViewExpand
*/
case CC_ComboBox: {
if (!w) {
return TQRect();
}
TQRect r(w->rect());
switch (sc) {
case SC_ComboBoxEditField: {
return TQRect(r.x()+2, r.y()+2, r.width()-20, r.height()-4);
}
default: {
return KStyle::querySubControlMetrics(cc, w, sc, o);
}
}
break;
}
default: {
return KStyle::querySubControlMetrics(cc, w, sc, o);
}
}
}
TQSize AsteroidStyle::tqsizeFromContents(ContentsType ct,
const TQWidget *w,
const TQSize &s,
const TQStyleOption &o) const
{
switch (ct) {
/* ContentsType values can be:
CT_CheckBox
CT_RadioButton
CT_Splitter
CT_DockWindow
CT_ProgressBar
CT_TabBarTab
CT_Slider
CT_LineEdit
CT_SpinBox
CT_SizeGrip
CT_TabWidget
CT_DialogButtons
*/
case CT_ToolButton: {
return TQSize(s.width() + 8, s.height() + 8);
}
case CT_PushButton: {
const TQPushButton *pb = dynamic_cast<const TQPushButton *>(w);
const TQSize ret = KStyle::tqsizeFromContents(ct, w, s, o);
int rw = ret.width(), rh = ret.height();
int mw;
int mh;
if (pb->text().length() > 0) {
mw = MINIMUM_PUSHBUTTON_WIDTH;
mh = MINIMUM_PUSHBUTTON_HEIGHT;
}
else {
mw = 1;
mh = 1;
}
if (pb->text().length() > 0) {
if (pb->iconSet() && !pb->iconSet()->isNull()) {
rw += ((pb->iconSet()->pixmap(TQIconSet::Small, TQIconSet::Normal).width())*2.0);
} else if (pb->pixmap() && !pb->pixmap()->isNull()) {
rw += ((pb->pixmap()->width())*2.0);
}
}
else {
if (pb->iconSet() && !pb->iconSet()->isNull()) {
rw += ((pb->iconSet()->pixmap(TQIconSet::Small, TQIconSet::Normal).width())*0.0);
} else if (pb->pixmap() && !pb->pixmap()->isNull()) {
rw += ((pb->pixmap()->width())*0.0);
}
}
return TQSize((rw < mw ? mw : rw), (rh < mh ? mh : rh));
}
case CT_ComboBox: {
int padding = (tqpixelMetric(PM_DefaultFrameWidth, w) * 2) + 1;
return TQSize(s.width() + 21, s.height() + padding);
}
case CT_PopupMenuItem: {
if (!w || o.isDefault()) {
return TQSize(0, 0);
}
int sw = s.width(), sh = s.height();
const TQPopupMenu *popup = dynamic_cast<const TQPopupMenu *>(w);
TQMenuItem *mi = o.menuItem();
if (mi->custom()) {
sw = mi->custom()->tqsizeHint().width();
sh = mi->custom()->tqsizeHint().height();
} else if (mi->widget()) {
/* This is a do-nothing branch */
} else if (mi->isSeparator()) {
sw = 0, sh = 9;
} else {
if (mi->pixmap()) {
sh = TQMAX(sh, mi->pixmap()->height() + 2);
} else if (mi->iconSet()) {
sh = TQMAX(sh, mi->iconSet()->pixmap(TQIconSet::Small, TQIconSet::Normal).height() + 2);
}
sh = TQMAX(sh, w->fontMetrics().height() + 4);
}
if (!mi->text().isNull()) {
if ((mi->text().tqfind('\t') >= 0)) {
sw += 16;
} else if (mi->popup()) {
sw += 8;
}
}
int miw = o.maxIconWidth();
if (miw) {
sw += miw;
if (popup->isCheckable()) {
sw += 20 - miw;
}
}
sw += 20;
return TQSize(sw, sh);
}
case CT_MenuBar: {
const TQMenuBar *mb = dynamic_cast<const TQMenuBar *>(w);
int sh = TQFontInfo(mb->font()).pixelSize() + 4;
int sw = 10;
return TQSize(sw, sh);
}
case CT_Header: {
// Fall through is intentional
// const TQHeader *hw = dynamic_cast<const TQHeader *>(w);
// int sh = TQFontInfo(hw->font()).pixelSize() + 8;
// int sw = 10;
// return TQSize(sw, sh);
}
default: {
return KStyle::tqsizeFromContents(ct, w, s, o);
}
}
}
void AsteroidStyle::paletteChanged()
{
}
bool AsteroidStyle::eventFilter(TQObject *o, TQEvent *e)
{
/* Win2K has this interesting behaviour where it sets the current
default button to whatever pushbutton the user presses the mouse
on. I _think_ this emulates that properly. -clee */
if (o->inherits(TQPUSHBUTTON_OBJECT_NAME_STRING)) {
if (e->type() == TQEvent::MouseButtonPress) {
TQPushButton *pb = dynamic_cast<TQPushButton *>(o);
pb->setDefault(TRUE);
}
}
return false;
}
|