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
|
/****************************************************************************
**
** Implementation of Windows-like style class
**
** Created : 981231
**
** Copyright (C) 1998-2008 Trolltech ASA. All rights reserved.
**
** This file is part of the widgets module of the TQt GUI Toolkit.
**
** This file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free
** Software Foundation and appearing in the files LICENSE.GPL2
** and LICENSE.GPL3 included in the packaging of this file.
** Alternatively you may (at your option) use any later version
** of the GNU General Public License if such license has been
** publicly approved by Trolltech ASA (or its successors, if any)
** and the KDE Free TQt Foundation.
**
** Please review the following information to ensure GNU General
** Public Licensing requirements will be met:
** http://trolltech.com/products/qt/licenses/licensing/opensource/.
** If you are unsure which license is appropriate for your use, please
** review the following information:
** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
** or contact the sales department at [email protected].
**
** This file may be used under the terms of the Q Public License as
** defined by Trolltech ASA and appearing in the file LICENSE.TQPL
** included in the packaging of this file. Licensees holding valid TQt
** Commercial licenses may use this file in accordance with the TQt
** Commercial License Agreement provided with the Software.
**
** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
** herein.
**
**********************************************************************/
#include "ntqwindowsstyle.h"
#if !defined(QT_NO_STYLE_WINDOWS) || defined(QT_PLUGIN)
#include "ntqpopupmenu.h"
#include "ntqapplication.h"
#include "ntqpainter.h"
#include "ntqdrawutil.h" // for now
#include "ntqpixmap.h" // for now
#include "ntqwidget.h"
#include "ntqlabel.h"
#include "ntqimage.h"
#include "ntqpushbutton.h"
#include "ntqcombobox.h"
#include "ntqlistbox.h"
#include "ntqwidget.h"
#include "ntqrangecontrol.h"
#include "ntqscrollbar.h"
#include "ntqslider.h"
#include "ntqtabwidget.h"
#include "ntqtabbar.h"
#include "ntqlistview.h"
#include "ntqbitmap.h"
#include "ntqcleanuphandler.h"
#include "ntqdockwindow.h"
#include "ntqobjectlist.h"
#include "ntqmenubar.h"
#include <limits.h>
static const int windowsItemFrame = 2; // 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 = 2; // 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
static bool use2000style = TRUE;
enum TQSliderDirection { SlUp, SlDown, SlLeft, SlRight };
// A friendly class providing access to TQMenuData's protected member.
class FriendlyMenuData : public TQMenuData
{
friend class TQWindowsStyle;
};
// Private class
class TQWindowsStyle::Private : public TQObject
{
public:
Private(TQWindowsStyle *parent);
bool objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e );
private:
int menuBarTimer;
};
TQWindowsStyle::Private::Private(TQWindowsStyle *parent)
: TQObject(parent, "TQWindowsStylePrivate"), menuBarTimer(0)
{
}
// Records Alt- and Focus events
bool TQWindowsStyle::Private::objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags, void* source, TQEvent *e )
{
if (!(ceData.widgetObjectTypes.contains("TQWidget"))) {
return TRUE;
}
TQWidget *widget = reinterpret_cast<TQWidget*>(source);
switch(e->type()) {
case TQEvent::FocusIn:
case TQEvent::FocusOut:
{
// Menubars toggle based on focus
TQMenuBar *menuBar = ::tqt_cast<TQMenuBar*>(widget);
if (menuBar && !menuBarTimer) // delayed repaint to avoid flicker
menuBarTimer = menuBar->startTimer(0);
}
break;
case TQEvent::Close:
// Reset widget when closing
break;
case TQEvent::Timer:
{
TQMenuBar *menuBar = ::tqt_cast<TQMenuBar*>(widget);
TQTimerEvent *te = (TQTimerEvent*)e;
if (menuBar && te->timerId() == menuBarTimer) {
menuBar->killTimer(te->timerId());
menuBarTimer = 0;
menuBar->repaint(FALSE);
return TRUE;
}
}
break;
default:
break;
}
return TRUE;
}
/*!
\class TQWindowsStyle ntqwindowsstyle.h
\brief The TQWindowsStyle class provides a Microsoft Windows-like look and feel.
\ingroup appearance
This style is TQt's default GUI style on Windows.
*/
/*!
Constructs a TQWindowsStyle
*/
TQWindowsStyle::TQWindowsStyle() : TQCommonStyle(), d(0)
{
#if defined(Q_OS_WIN32)
use2000style = qWinVersion() != TQt::WV_NT && qWinVersion() != TQt::WV_95;
#endif
}
/*! \reimp */
TQWindowsStyle::~TQWindowsStyle()
{
delete d;
}
/*! \reimp */
bool TQWindowsStyle::objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e ) {
if (d) {
return d->objectEventHandler(ceData, elementFlags, source, e);
}
return TRUE;
}
/*! \reimp */
void TQWindowsStyle::applicationPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr)
{
// We only need the overhead when shortcuts are sometimes hidden
if (styleHint(SH_UnderlineAccelerator, TQStyleControlElementData(), CEF_None, 0) && styleHint(SH_HideUnderlineAcceleratorWhenAltUp, TQStyleControlElementData(), CEF_None, 0)) {
d = new Private(this);
installObjectEventHandler(ceData, elementFlags, ptr, this);
}
}
/*! \reimp */
void TQWindowsStyle::applicationUnPolish(TQStyleControlElementData, ControlElementFlags, void *)
{
delete d;
d = 0;
}
/*! \reimp */
void TQWindowsStyle::polish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr)
{
TQCommonStyle::polish(ceData, elementFlags, ptr);
}
/*! \reimp */
void TQWindowsStyle::unPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr)
{
TQCommonStyle::polish(ceData, elementFlags, ptr);
}
/*! \reimp */
void TQWindowsStyle::polish( TQPalette &pal )
{
TQCommonStyle::polish(pal);
}
/*! \reimp */
void TQWindowsStyle::drawPrimitive( PrimitiveElement pe,
TQPainter *p,
TQStyleControlElementData ceData,
ControlElementFlags elementFlags,
const TQRect &r,
const TQColorGroup &cg,
SFlags flags,
const TQStyleOption& opt ) const
{
bool dis = !(flags & Style_Enabled);
bool act = flags & Style_Active;
TQRect rr( r );
switch (pe) {
case PE_ButtonCommand:
{
TQBrush fill;
if (! (flags & Style_Down) && (flags & Style_On))
fill = TQBrush(cg.light(), Dense4Pattern);
else
fill = cg.brush(TQColorGroup::Button);
if (flags & Style_ButtonDefault && flags & Style_Down) {
p->setPen(cg.dark());
p->setBrush(fill);
p->drawRect(r);
} else if (flags & (Style_Raised | Style_Down | Style_On | Style_Sunken))
qDrawWinButton(p, r, cg, flags & (Style_Sunken | Style_Down |
Style_On), &fill);
else
p->fillRect(r, fill);
break;
}
case PE_ButtonBevel:
case PE_HeaderSection:
{
TQBrush fill;
if (! (flags & Style_Down) && (flags & Style_On))
fill = TQBrush(cg.light(), Dense4Pattern);
else
fill = cg.brush(TQColorGroup::Button);
if (flags & (Style_Raised | Style_Down | Style_On | Style_Sunken))
qDrawWinButton(p, r, cg, flags & (Style_Down | Style_On), &fill);
else
p->fillRect(r, fill);
break;
}
case PE_ButtonDefault:
p->setPen(cg.shadow());
p->drawRect(r);
break;
case PE_ButtonTool:
{
TQBrush fill;
bool stippled = FALSE;
if (! (flags & (Style_Down | Style_MouseOver)) &&
(flags & Style_On) &&
use2000style) {
fill = TQBrush(cg.light(), Dense4Pattern);
stippled = TRUE;
} else
fill = cg.brush(TQColorGroup::Button);
if (flags & (Style_Raised | Style_Down | Style_On)) {
if (flags & Style_AutoRaise) {
qDrawShadePanel(p, r, cg, flags & (Style_Down | Style_On),
1, &fill);
if (stippled) {
p->setPen(cg.button());
p->drawRect(r.x() + 1, r.y() + 1, r.width() - 2, r.height() - 2);
}
} else
qDrawWinButton(p, r, cg, flags & (Style_Down | Style_On),
&fill);
} else
p->fillRect(r, fill);
break;
}
case PE_FocusRect:
if (opt.isDefault())
p->drawWinFocusRect(r);
else
p->drawWinFocusRect(r, opt.color());
break;
case PE_Indicator:
{
TQBrush fill;
if (flags & Style_NoChange) {
TQBrush b = p->brush();
TQColor c = p->backgroundColor();
p->setBackgroundMode( TransparentMode );
p->setBackgroundColor( green );
fill = TQBrush(cg.base(), Dense4Pattern);
p->setBackgroundColor( c );
p->setBrush( b );
} else if (flags & Style_Down)
fill = cg.brush( TQColorGroup::Button );
else if (flags & Style_Enabled)
fill = cg.brush( TQColorGroup::Base );
else
fill = cg.brush( TQColorGroup::Background );
qDrawWinPanel( p, r, cg, TRUE, &fill );
if (flags & Style_NoChange )
p->setPen( cg.dark() );
else
p->setPen( cg.text() );
} // FALLTHROUGH
case PE_CheckListIndicator:
if ( pe == PE_CheckListIndicator ) { //since we fall through from PE_Indicator
if ( flags & Style_Enabled )
p->setPen( TQPen( cg.text(), 1 ) );
else
p->setPen( TQPen( cg.dark(), 1 ) );
if ( flags & Style_NoChange )
p->setBrush( cg.brush( TQColorGroup::Button ) );
p->drawRect( r.x()+1, r.y()+1, 11, 11 );
}
if (! (flags & Style_Off)) {
TQPointArray a( 7*2 );
int i, xx, yy;
xx = rr.x() + 3;
yy = rr.y() + 5;
for ( i=0; i<3; i++ ) {
a.setPoint( 2*i, xx, yy );
a.setPoint( 2*i+1, xx, yy+2 );
xx++; yy++;
}
yy -= 2;
for ( i=3; i<7; i++ ) {
a.setPoint( 2*i, xx, yy );
a.setPoint( 2*i+1, xx, yy+2 );
xx++; yy--;
}
p->drawLineSegments( a );
}
break;
case PE_ExclusiveIndicator:
{
#define TQCOORDARRLEN(x) sizeof(x)/(sizeof(TQCOORD)*2)
static const TQCOORD pts1[] = { // dark lines
1,9, 1,8, 0,7, 0,4, 1,3, 1,2, 2,1, 3,1, 4,0, 7,0, 8,1, 9,1 };
static const TQCOORD pts2[] = { // black lines
2,8, 1,7, 1,4, 2,3, 2,2, 3,2, 4,1, 7,1, 8,2, 9,2 };
static const TQCOORD pts3[] = { // background lines
2,9, 3,9, 4,10, 7,10, 8,9, 9,9, 9,8, 10,7, 10,4, 9,3 };
static const TQCOORD pts4[] = { // white lines
2,10, 3,10, 4,11, 7,11, 8,10, 9,10, 10,9, 10,8, 11,7,
11,4, 10,3, 10,2 };
static const TQCOORD pts5[] = { // inner fill
4,2, 7,2, 9,4, 9,7, 7,9, 4,9, 2,7, 2,4 };
// make sure the indicator is square
TQRect ir = r;
if (r.width() < r.height()) {
ir.setTop(r.top() + (r.height() - r.width()) / 2);
ir.setHeight(r.width());
} else if (r.height() < r.width()) {
ir.setLeft(r.left() + (r.width() - r.height()) / 2);
ir.setWidth(r.height());
}
p->eraseRect(ir);
bool down = flags & Style_Down;
bool enabled = flags & Style_Enabled;
bool on = flags & Style_On;
TQPointArray a;
a.setPoints( TQCOORDARRLEN(pts1), pts1 );
a.translate( ir.x(), ir.y() );
p->setPen( cg.dark() );
p->drawPolyline( a );
a.setPoints( TQCOORDARRLEN(pts2), pts2 );
a.translate( ir.x(), ir.y() );
p->setPen( cg.shadow() );
p->drawPolyline( a );
a.setPoints( TQCOORDARRLEN(pts3), pts3 );
a.translate( ir.x(), ir.y() );
p->setPen( cg.midlight() );
p->drawPolyline( a );
a.setPoints( TQCOORDARRLEN(pts4), pts4 );
a.translate( ir.x(), ir.y() );
p->setPen( cg.light() );
p->drawPolyline( a );
a.setPoints( TQCOORDARRLEN(pts5), pts5 );
a.translate( ir.x(), ir.y() );
TQColor fillColor = ( down || !enabled ) ? cg.button() : cg.base();
p->setPen( fillColor );
p->setBrush( fillColor ) ;
p->drawPolygon( a );
if ( on ) {
p->setPen( NoPen );
p->setBrush( cg.text() );
p->drawRect( ir.x() + 5, ir.y() + 4, 2, 4 );
p->drawRect( ir.x() + 4, ir.y() + 5, 4, 2 );
}
break;
}
case PE_Panel:
case PE_PanelPopup:
{
int lw = opt.isDefault() ? pixelMetric(PM_DefaultFrameWidth, ceData, elementFlags)
: opt.lineWidth();
if (lw == 2) {
TQColorGroup popupCG = cg;
if ( pe == PE_PanelPopup ) {
popupCG.setColor( TQColorGroup::Light, cg.background() );
popupCG.setColor( TQColorGroup::Midlight, cg.light() );
}
qDrawWinPanel(p, r, popupCG, flags & Style_Sunken);
} else {
TQCommonStyle::drawPrimitive(pe, p, ceData, elementFlags, r, cg, flags, opt);
}
break;
}
case PE_Splitter:
{
TQPen oldPen = p->pen();
p->setPen( cg.light() );
if ( flags & Style_Horizontal ) {
p->drawLine( r.x() + 1, r.y(), r.x() + 1, r.height() );
p->setPen( cg.dark() );
p->drawLine( r.x(), r.y(), r.x(), r.height() );
p->drawLine( r.right()-1, r.y(), r.right()-1, r.height() );
p->setPen( cg.shadow() );
p->drawLine( r.right(), r.y(), r.right(), r.height() );
} else {
p->drawLine( r.x(), r.y() + 1, r.width(), r.y() + 1 );
p->setPen( cg.dark() );
p->drawLine( r.x(), r.bottom() - 1, r.width(), r.bottom() - 1 );
p->setPen( cg.shadow() );
p->drawLine( r.x(), r.bottom(), r.width(), r.bottom() );
}
p->setPen( oldPen );
break;
}
case PE_DockWindowResizeHandle:
{
TQPen oldPen = p->pen();
p->setPen( cg.light() );
if ( flags & Style_Horizontal ) {
p->drawLine( r.x(), r.y(), r.width(), r.y() );
p->setPen( cg.dark() );
p->drawLine( r.x(), r.bottom() - 1, r.width(), r.bottom() - 1 );
p->setPen( cg.shadow() );
p->drawLine( r.x(), r.bottom(), r.width(), r.bottom() );
} else {
p->drawLine( r.x(), r.y(), r.x(), r.height() );
p->setPen( cg.dark() );
p->drawLine( r.right()-1, r.y(), r.right()-1, r.height() );
p->setPen( cg.shadow() );
p->drawLine( r.right(), r.y(), r.right(), r.height() );
}
p->setPen( oldPen );
break;
}
case PE_ScrollBarSubLine:
if (use2000style) {
if (flags & Style_Down) {
p->setPen( cg.dark() );
p->setBrush( cg.brush( TQColorGroup::Button ) );
p->drawRect( r );
} else
drawPrimitive(PE_ButtonBevel, p, ceData, elementFlags, r, cg, flags | Style_Raised);
} else
drawPrimitive(PE_ButtonBevel, p, ceData, elementFlags, r, cg, (flags & Style_Enabled) |
((flags & Style_Down) ? Style_Down : Style_Raised));
drawPrimitive(((flags & Style_Horizontal) ? PE_ArrowLeft : PE_ArrowUp),
p, ceData, elementFlags, r, cg, flags);
break;
case PE_ScrollBarAddLine:
if (use2000style) {
if (flags & Style_Down) {
p->setPen( cg.dark() );
p->setBrush( cg.brush( TQColorGroup::Button ) );
p->drawRect( r );
} else
drawPrimitive(PE_ButtonBevel, p, ceData, elementFlags, r, cg, flags | Style_Raised);
} else
drawPrimitive(PE_ButtonBevel, p, ceData, elementFlags, r, cg, (flags & Style_Enabled) |
((flags & Style_Down) ? Style_Down : Style_Raised));
drawPrimitive(((flags & Style_Horizontal) ? PE_ArrowRight : PE_ArrowDown),
p, ceData, elementFlags, r, cg, flags);
break;
case PE_ScrollBarAddPage:
case PE_ScrollBarSubPage:
{
TQBrush br;
TQColor c = p->backgroundColor();
p->setPen(NoPen);
p->setBackgroundMode(OpaqueMode);
if (flags & Style_Down) {
br = TQBrush(cg.shadow(), Dense4Pattern);
p->setBackgroundColor( cg.dark() );
p->setBrush( TQBrush(cg.shadow(), Dense4Pattern) );
} else {
br = (cg.brush(TQColorGroup::Light).pixmap() ?
cg.brush(TQColorGroup::Light) :
TQBrush(cg.light(), Dense4Pattern));
p->setBrush(br);
}
p->drawRect(r);
p->setBackgroundColor(c);
break;
}
case PE_ScrollBarSlider:
if (! (flags & Style_Enabled)) {
TQBrush br = (cg.brush(TQColorGroup::Light).pixmap() ?
cg.brush(TQColorGroup::Light) :
TQBrush(cg.light(), Dense4Pattern));
p->setPen(NoPen);
p->setBrush(br);
p->setBackgroundMode(OpaqueMode);
p->drawRect(r);
} else
drawPrimitive(PE_ButtonBevel, p, ceData, elementFlags, r, cg, Style_Enabled | Style_Raised);
break;
case PE_WindowFrame:
{
TQColorGroup popupCG = cg;
popupCG.setColor( TQColorGroup::Light, cg.background() );
popupCG.setColor( TQColorGroup::Midlight, cg.light() );
qDrawWinPanel(p, r, popupCG, flags & Style_Sunken);
}
break;
case PE_MenuItemIndicatorFrame:
{
int x, y, w, h;
r.rect( &x, &y, &w, &h );
int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL);
TQRect vrect = visualRect( TQRect( x, y, checkcol, h ), r );
int xvis = vrect.x();
if ( act && !dis ) {
qDrawShadePanel( p, xvis, y, checkcol, h, cg, TRUE, 1, &cg.brush( TQColorGroup::Button ) );
}
else {
TQBrush fill( cg.light(), Dense4Pattern );
// set the brush origin for the hash pattern to the x/y coordinate
// of the menu item's checkmark... this way, the check marks have
// a consistent look
TQPoint origin = p->brushOrigin();
p->setBrushOrigin( xvis, y );
qDrawShadePanel( p, xvis, y, checkcol, h, cg, TRUE, 1, &fill );
// restore the previous brush origin
p->setBrushOrigin( origin );
}
}
break;
case PE_MenuItemIndicatorIconFrame:
{
int x, y, w, h;
r.rect( &x, &y, &w, &h );
int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL);
TQRect vrect = visualRect( TQRect( x, y, checkcol, h ), r );
int xvis = vrect.x();
qDrawShadePanel( p, xvis, y, w, h, cg, FALSE, 1, &cg.brush( TQColorGroup::Button ) );
}
break;
case PE_MenuItemIndicatorCheck:
{
int x, y, w, h;
r.rect( &x, &y, &w, &h );
int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL);
int xp = x + 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);
}
break;
default:
if (pe >= PE_ArrowUp && pe <= PE_ArrowLeft) {
TQPointArray a;
switch ( pe ) {
case PE_ArrowUp:
a.setPoints( 7, -4,1, 2,1, -3,0, 1,0, -2,-1, 0,-1, -1,-2 );
break;
case PE_ArrowDown:
a.setPoints( 7, -4,-2, 2,-2, -3,-1, 1,-1, -2,0, 0,0, -1,1 );
break;
case PE_ArrowRight:
a.setPoints( 7, -2,-3, -2,3, -1,-2, -1,2, 0,-1, 0,1, 1,0 );
break;
case PE_ArrowLeft:
a.setPoints( 7, 0,-3, 0,3, -1,-2, -1,2, -2,-1, -2,1, -3,0 );
break;
default:
break;
}
if (a.isNull())
return;
p->save();
if ( flags & Style_Down )
p->translate( pixelMetric( PM_ButtonShiftHorizontal, ceData, elementFlags ),
pixelMetric( PM_ButtonShiftVertical, ceData, elementFlags ) );
if ( flags & Style_Enabled ) {
a.translate( r.x() + r.width() / 2, r.y() + r.height() / 2 );
p->setPen( cg.buttonText() );
p->drawLineSegments( a, 0, 3 ); // draw arrow
p->drawPoint( a[6] );
} else {
a.translate( r.x() + r.width() / 2 + 1, r.y() + r.height() / 2 + 1 );
p->setPen( cg.light() );
p->drawLineSegments( a, 0, 3 ); // draw arrow
p->drawPoint( a[6] );
a.translate( -1, -1 );
p->setPen( cg.mid() );
p->drawLineSegments( a, 0, 3 ); // draw arrow
p->drawPoint( a[6] );
}
p->restore();
} else
TQCommonStyle::drawPrimitive(pe, p, ceData, elementFlags, r, cg, flags, opt);
}
}
/*!
\reimp
*/
void TQWindowsStyle::drawControl( ControlElement element,
TQPainter *p,
TQStyleControlElementData ceData,
ControlElementFlags elementFlags,
const TQRect &r,
const TQColorGroup &cg,
SFlags flags,
const TQStyleOption& opt,
const TQWidget *widget ) const
{
switch (element) {
#ifndef QT_NO_TABBAR
case CE_TabBarTab:
{
if ( ( elementFlags & CEF_UseGenericParameters ) || (!( elementFlags & CEF_HasParentWidget )) || !opt.tab() )
break;
const TQTab * t = opt.tab();
bool selected = flags & Style_Selected;
bool lastTab = (ceData.tabBarData.identIndexMap[t->identifier()] == ceData.tabBarData.tabCount-1) ?
TRUE : FALSE;
TQRect r2( r );
if ( ceData.tabBarData.shape == TQTabBar::RoundedAbove ) {
p->setPen( cg.midlight() );
p->drawLine( r2.left(), r2.bottom(), r2.right(), r2.bottom() );
p->setPen( cg.light() );
p->drawLine( r2.left(), r2.bottom()-1, r2.right(), r2.bottom()-1 );
if ( r2.left() == 0 )
p->drawPoint( ceData.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() );
if ( r2.left() > 0 ) {
p->setPen( cg.midlight() );
}
x1 = r2.left();
p->drawPoint( x1, r2.bottom());
p->setPen( cg.midlight() );
x1++;
p->drawLine( x1, r2.bottom(), x1, r2.top() + 2 );
x1++;
p->drawLine( x1, r2.top()+1, x2, r2.top()+1 );
p->setPen( cg.dark() );
x2 = r2.right() - 1;
p->drawLine( x2, r2.top() + 2, x2, r2.bottom() - 1 +
(selected ? 1:-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 ( ceData.tabBarData.shape == TQTabBar::RoundedBelow ) {
bool rightAligned = styleHint( SH_TabBar_Alignment, ceData, elementFlags, TQStyleOption::Default, 0, widget ) == AlignRight;
bool firstTab = ceData.tabBarData.identIndexMap[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.midlight() );
p->drawLine( r2.left() + 1, r2.bottom() - 2,
r2.left() + 1, r2.top() + (selected ? 0 : 2) );
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::drawControl(element, p, ceData, elementFlags, r, cg, flags, opt, widget);
}
break;
}
#endif // QT_NO_TABBAR
case CE_ToolBoxTab:
{
qDrawShadePanel( p, r, cg, flags & (Style_Sunken | Style_Down | Style_On) , 1,
&cg.brush(TQColorGroup::Button));
break;
}
#ifndef QT_NO_POPUPMENU
case CE_PopupMenuItem:
{
if (( elementFlags & CEF_UseGenericParameters ) || opt.isDefault())
break;
TQMenuItem *mi = opt.menuItem();
if ( !mi )
break;
int tab = opt.tabWidth();
int maxpmw = opt.maxIconWidth();
bool dis = !(flags&Style_Enabled);
bool checkable = ( elementFlags & CEF_IsCheckable );
bool act = flags & Style_Active;
int x, y, w, h;
r.rect(&x, &y, &w, &h);
if ( checkable ) {
// space for the checkmarks
if (use2000style)
maxpmw = TQMAX( maxpmw, 20 );
else
maxpmw = TQMAX( maxpmw, 12 );
}
int checkcol = maxpmw;
if ( mi && mi->isSeparator() ) { // draw separator
p->setPen( cg.dark() );
p->drawLine( x, y, x+w, y );
p->setPen( cg.light() );
p->drawLine( x, y+1, x+w, y+1 );
return;
}
TQBrush fill = (act ?
cg.brush( TQColorGroup::Highlight ) :
cg.brush( TQColorGroup::Button ));
p->fillRect( x, y, w, h, fill);
if ( !mi )
return;
int xpos = x;
TQRect vrect = visualRect( TQRect( xpos, y, checkcol, h ), r );
int xvis = vrect.x();
if ( mi->isChecked() ) {
drawPrimitive(PE_MenuItemIndicatorFrame, p, ceData, elementFlags, r, cg, flags, opt);
} else if (! act)
p->fillRect(xvis, y, checkcol , h, cg.brush( TQColorGroup::Button ));
if ( mi->iconSet() ) { // draw 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();
if ( act && !dis && !mi->isChecked() )
drawPrimitive(PE_MenuItemIndicatorIconFrame, p, ceData, elementFlags, r, cg, flags, opt);
TQRect pmr( 0, 0, pixw, pixh );
pmr.moveCenter( vrect.center() );
p->setPen( cg.text() );
p->drawPixmap( pmr.topLeft(), pixmap );
fill = (act ?
cg.brush( TQColorGroup::Highlight ) :
cg.brush( TQColorGroup::Button ));
int xp = xpos + checkcol + 1;
p->fillRect( visualRect( TQRect( xp, y, w - checkcol - 1, h ), r ), fill);
} else if ( checkable ) { // just "checking"...
if ( mi->isChecked() ) {
drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, r, cg, flags, opt);
}
}
p->setPen( act ? cg.highlightedText() : cg.buttonText() );
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();
}
TQString s = mi->text();
if ( !s.isNull() ) { // draw text
int t = s.find( '\t' );
int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine;
if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, TQStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, TQStyleOption::Default, 0, widget)) && (!acceleratorsShown()))) {
text_flags |= NoAccel;
}
text_flags |= (TQApplication::reverseLayout() ? AlignRight : AlignLeft );
if ( t >= 0 ) { // draw tab text
int xp = x + w - tab - windowsItemHMargin - windowsItemFrame + 1;
if ( use2000style )
xp -= 20;
else
xp -= windowsRightBorder;
int xoff = visualRect( TQRect( xp, y+windowsItemVMargin, tab, h-2*windowsItemVMargin ), r ).x();
if ( dis && !act ) {
p->setPen( cg.light() );
p->drawText( xoff+1, y+windowsItemVMargin+1, tab, h-2*windowsItemVMargin, text_flags, s.mid( t+1 ));
p->setPen( discol );
}
p->drawText( xoff, y+windowsItemVMargin, tab, h-2*windowsItemVMargin, text_flags, s.mid( t+1 ) );
s = s.left( t );
}
if ( dis && !act ) {
p->setPen( cg.light() );
p->drawText( xvis+1, y+windowsItemVMargin+1, w-xm-tab+1, h-2*windowsItemVMargin, text_flags, s, t );
p->setPen( discol );
}
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 );
}
if ( mi->popup() ) { // draw sub menu arrow
int dim = (h-2*windowsItemFrame) / 2;
PrimitiveElement arrow;
arrow = ( TQApplication::reverseLayout() ? PE_ArrowLeft : PE_ArrowRight );
xpos = x+w - windowsArrowHMargin - windowsItemFrame - dim;
vrect = visualRect( TQRect(xpos, y + h / 2 - dim / 2, dim, dim), r );
if ( act ) {
TQColorGroup g2 = cg;
g2.setColor( TQColorGroup::ButtonText, g2.highlightedText() );
drawPrimitive(arrow, p, ceData, elementFlags, vrect,
g2, dis ? Style_Default : Style_Enabled);
} else {
drawPrimitive(arrow, p, ceData, elementFlags, vrect,
cg, dis ? Style_Default : Style_Enabled );
}
}
break;
}
#endif
case CE_MenuBarItem:
{
bool active = flags & Style_Active;
bool hasFocus = flags & Style_HasFocus;
bool down = flags & Style_Down;
TQRect pr = r;
p->fillRect( r, cg.brush( TQColorGroup::Button ) );
if ( active || hasFocus ) {
TQBrush b = cg.brush( TQColorGroup::Button );
if ( active && down )
p->setBrushOrigin(p->brushOrigin() + TQPoint(1,1));
if ( active && hasFocus )
qDrawShadeRect( p, r.x(), r.y(), r.width(), r.height(),
cg, active && down, 1, 0, &b );
if ( active && down ) {
pr.moveBy( pixelMetric(PM_ButtonShiftHorizontal, ceData, elementFlags, widget),
pixelMetric(PM_ButtonShiftVertical, ceData, elementFlags, widget) );
p->setBrushOrigin(p->brushOrigin() - TQPoint(1,1));
}
}
TQCommonStyle::drawControl(element, p, ceData, elementFlags, pr, cg, flags, opt, widget);
break;
}
default:
TQCommonStyle::drawControl(element, p, ceData, elementFlags, r, cg, flags, opt, widget);
}
}
/*!
\reimp
*/
int TQWindowsStyle::pixelMetric(PixelMetric metric, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQWidget *widget) const
{
int ret;
switch (metric) {
case PM_ButtonDefaultIndicator:
case PM_ButtonShiftHorizontal:
case PM_ButtonShiftVertical:
ret = 1;
break;
case PM_MaximumDragDistance:
ret = 60;
break;
#ifndef QT_NO_SLIDER
case PM_SliderLength:
ret = 11;
break;
// Returns the number of pixels to use for the business part of the
// slider (i.e., the non-tickmark portion). The remaining space is shared
// equally between the tickmark regions.
case PM_SliderControlThickness:
{
int space = (ceData.orientation == Horizontal) ? ceData.rect.height()
: ceData.rect.width();
int ticks = ceData.tickMarkSetting;
int n = 0;
if ( ticks & TQSlider::Above ) n++;
if ( ticks & TQSlider::Below ) n++;
if ( !n ) {
ret = space;
break;
}
int thick = 6; // Magic constant to get 5 + 16 + 5
if ( ticks != TQSlider::Both && ticks != TQSlider::NoMarks )
thick += pixelMetric( PM_SliderLength, ceData, elementFlags, widget ) / 4;
space -= thick;
//### the two sides may be unequal in size
if ( space > 0 )
thick += (space * 2) / (n + 2);
ret = thick;
break;
}
#endif // QT_NO_SLIDER
case PM_MenuBarFrameWidth:
ret = 0;
break;
case PM_SplitterWidth:
ret = TQMAX( 6, TQApplication::globalStrut().width() );
break;
case PM_MenuIndicatorFrameHBorder:
case PM_MenuIndicatorFrameVBorder:
case PM_MenuIconIndicatorFrameHBorder:
case PM_MenuIconIndicatorFrameVBorder:
ret = windowsItemFrame;
break;
default:
ret = TQCommonStyle::pixelMetric(metric, ceData, elementFlags, widget);
break;
}
return ret;
}
/*!
\reimp
*/
TQSize TQWindowsStyle::sizeFromContents( ContentsType contents,
TQStyleControlElementData ceData,
ControlElementFlags elementFlags,
const TQSize &contentsSize,
const TQStyleOption& opt,
const TQWidget *widget ) const
{
TQSize sz(contentsSize);
switch (contents) {
case CT_PushButton:
{
#ifndef QT_NO_PUSHBUTTON
sz = TQCommonStyle::sizeFromContents(contents, ceData, elementFlags, contentsSize, opt, widget);
int w = sz.width(), h = sz.height();
int defwidth = 0;
if ((elementFlags & CEF_IsDefault) || (elementFlags & CEF_AutoDefault))
defwidth = 2*pixelMetric( PM_ButtonDefaultIndicator, ceData, elementFlags, widget );
if (w < 80+defwidth && ceData.fgPixmap.isNull())
w = 80+defwidth;
if (h < 23+defwidth)
h = 23+defwidth;
sz = TQSize(w, h);
#endif
break;
}
case CT_PopupMenuItem:
{
#ifndef QT_NO_POPUPMENU
if (( elementFlags & CEF_UseGenericParameters ) || opt.isDefault())
break;
bool checkable = ( elementFlags & CEF_IsCheckable );
TQMenuItem *mi = opt.menuItem();
int maxpmw = opt.maxIconWidth();
int w = sz.width(), h = sz.height();
if (mi->custom()) {
w = mi->custom()->sizeHint().width();
h = mi->custom()->sizeHint().height();
if (! mi->custom()->fullSpan())
h += 2*windowsItemVMargin + 2*windowsItemFrame;
} else if ( mi->widget() ) {
} else if (mi->isSeparator()) {
w = 10; // arbitrary
h = windowsSepHeight;
} else {
if (mi->pixmap())
h = TQMAX(h, mi->pixmap()->height() + 2*windowsItemFrame);
else if (! mi->text().isNull())
h = TQMAX(h, TQFontMetrics(ceData.font).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) {
if ( use2000style )
w += 20;
else
w += windowsTabSpacing;
} else if (mi->popup()) {
w += 2*windowsArrowHMargin;
}
if (use2000style) {
if (checkable && maxpmw < 20)
w += 20 - maxpmw;
} else {
if (checkable && maxpmw < windowsCheckMarkWidth)
w += windowsCheckMarkWidth - maxpmw;
}
if (checkable || maxpmw > 0)
w += windowsCheckMarkHMargin;
if (use2000style)
w += 20;
else
w += windowsRightBorder;
sz = TQSize(w, h);
#endif
break;
}
default:
sz = TQCommonStyle::sizeFromContents(contents, ceData, elementFlags, sz, opt, widget);
break;
}
return sz;
}
/*! \reimp
*/
void TQWindowsStyle::polishPopupMenu( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr )
{
#ifndef QT_NO_POPUPMENU
if ( !(ceData.windowState & WState_Polished ) ) {
widgetActionRequest(ceData, elementFlags, ptr, WAR_SetCheckable);
}
#endif
}
#ifndef QT_NO_IMAGEIO_XPM
static const char * const qt_close_xpm[] = {
"12 12 2 1",
"# c #000000",
". c None",
"............",
"............",
"..##....##..",
"...##..##...",
"....####....",
".....##.....",
"....####....",
"...##..##...",
"..##....##..",
"............",
"............",
"............"};
static const char * const qt_maximize_xpm[]={
"12 12 2 1",
"# c #000000",
". c None",
"............",
".#########..",
".#########..",
".#.......#..",
".#.......#..",
".#.......#..",
".#.......#..",
".#.......#..",
".#.......#..",
".#########..",
"............",
"............"};
static const char * const qt_minimize_xpm[] = {
"12 12 2 1",
"# c #000000",
". c None",
"............",
"............",
"............",
"............",
"............",
"............",
"............",
"............",
"..######....",
"..######....",
"............",
"............"};
static const char * const qt_normalizeup_xpm[] = {
"12 12 2 1",
"# c #000000",
". c None",
"............",
"....######..",
"....######..",
"....#....#..",
"..######.#..",
"..######.#..",
"..#....###..",
"..#....#....",
"..#....#....",
"..######....",
"............",
"............"};
static const char * const qt_shade_xpm[] = {
"12 12 2 1",
"# c #000000",
". c None",
"............",
"............",
"............",
"............",
"............",
".....#......",
"....###.....",
"...#####....",
"..#######...",
"............",
"............",
"............"};
static const char * const qt_unshade_xpm[] = {
"12 12 2 1",
"# c #000000",
". c None",
"............",
"............",
"............",
"............",
"..#######...",
"...#####....",
"....###.....",
".....#......",
"............",
"............",
"............",
"............"};
static const char * dock_window_close_xpm[] = {
"8 8 2 1",
"# c #000000",
". c None",
"........",
".##..##.",
"..####..",
"...##...",
"..####..",
".##..##.",
"........",
"........"};
/* XPM */
static const char * const information_xpm[]={
"32 32 5 1",
". c None",
"c c #000000",
"* c #999999",
"a c #ffffff",
"b c #0000ff",
"...........********.............",
"........***aaaaaaaa***..........",
"......**aaaaaaaaaaaaaa**........",
".....*aaaaaaaaaaaaaaaaaa*.......",
"....*aaaaaaaabbbbaaaaaaaac......",
"...*aaaaaaaabbbbbbaaaaaaaac.....",
"..*aaaaaaaaabbbbbbaaaaaaaaac....",
".*aaaaaaaaaaabbbbaaaaaaaaaaac...",
".*aaaaaaaaaaaaaaaaaaaaaaaaaac*..",
"*aaaaaaaaaaaaaaaaaaaaaaaaaaaac*.",
"*aaaaaaaaaabbbbbbbaaaaaaaaaaac*.",
"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
".*aaaaaaaaaaabbbbbaaaaaaaaaac***",
".*aaaaaaaaaaabbbbbaaaaaaaaaac***",
"..*aaaaaaaaaabbbbbaaaaaaaaac***.",
"...caaaaaaabbbbbbbbbaaaaaac****.",
"....caaaaaaaaaaaaaaaaaaaac****..",
".....caaaaaaaaaaaaaaaaaac****...",
"......ccaaaaaaaaaaaaaacc****....",
".......*cccaaaaaaaaccc*****.....",
"........***cccaaaac*******......",
"..........****caaac*****........",
".............*caaac**...........",
"...............caac**...........",
"................cac**...........",
".................cc**...........",
"..................***...........",
"...................**..........."};
/* XPM */
static const char* const warning_xpm[]={
"32 32 4 1",
". c None",
"a c #ffff00",
"* c #000000",
"b c #999999",
".............***................",
"............*aaa*...............",
"...........*aaaaa*b.............",
"...........*aaaaa*bb............",
"..........*aaaaaaa*bb...........",
"..........*aaaaaaa*bb...........",
".........*aaaaaaaaa*bb..........",
".........*aaaaaaaaa*bb..........",
"........*aaaaaaaaaaa*bb.........",
"........*aaaa***aaaa*bb.........",
".......*aaaa*****aaaa*bb........",
".......*aaaa*****aaaa*bb........",
"......*aaaaa*****aaaaa*bb.......",
"......*aaaaa*****aaaaa*bb.......",
".....*aaaaaa*****aaaaaa*bb......",
".....*aaaaaa*****aaaaaa*bb......",
"....*aaaaaaaa***aaaaaaaa*bb.....",
"....*aaaaaaaa***aaaaaaaa*bb.....",
"...*aaaaaaaaa***aaaaaaaaa*bb....",
"...*aaaaaaaaaa*aaaaaaaaaa*bb....",
"..*aaaaaaaaaaa*aaaaaaaaaaa*bb...",
"..*aaaaaaaaaaaaaaaaaaaaaaa*bb...",
".*aaaaaaaaaaaa**aaaaaaaaaaa*bb..",
".*aaaaaaaaaaa****aaaaaaaaaa*bb..",
"*aaaaaaaaaaaa****aaaaaaaaaaa*bb.",
"*aaaaaaaaaaaaa**aaaaaaaaaaaa*bb.",
"*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb",
"*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb",
".*aaaaaaaaaaaaaaaaaaaaaaaaa*bbbb",
"..*************************bbbbb",
"....bbbbbbbbbbbbbbbbbbbbbbbbbbb.",
".....bbbbbbbbbbbbbbbbbbbbbbbbb.."};
/* XPM */
static const char* const critical_xpm[]={
"32 32 4 1",
". c None",
"a c #999999",
"* c #ff0000",
"b c #ffffff",
"...........********.............",
".........************...........",
".......****************.........",
"......******************........",
".....********************a......",
"....**********************a.....",
"...************************a....",
"..*******b**********b*******a...",
"..******bbb********bbb******a...",
".******bbbbb******bbbbb******a..",
".*******bbbbb****bbbbb*******a..",
"*********bbbbb**bbbbb*********a.",
"**********bbbbbbbbbb**********a.",
"***********bbbbbbbb***********aa",
"************bbbbbb************aa",
"************bbbbbb************aa",
"***********bbbbbbbb***********aa",
"**********bbbbbbbbbb**********aa",
"*********bbbbb**bbbbb*********aa",
".*******bbbbb****bbbbb*******aa.",
".******bbbbb******bbbbb******aa.",
"..******bbb********bbb******aaa.",
"..*******b**********b*******aa..",
"...************************aaa..",
"....**********************aaa...",
"....a********************aaa....",
".....a******************aaa.....",
"......a****************aaa......",
".......aa************aaaa.......",
".........aa********aaaaa........",
"...........aaaaaaaaaaa..........",
".............aaaaaaa............"};
/* XPM */
static const char *const question_xpm[] = {
"32 32 5 1",
". c None",
"c c #000000",
"* c #999999",
"a c #ffffff",
"b c #0000ff",
"...........********.............",
"........***aaaaaaaa***..........",
"......**aaaaaaaaaaaaaa**........",
".....*aaaaaaaaaaaaaaaaaa*.......",
"....*aaaaaaaaaaaaaaaaaaaac......",
"...*aaaaaaaabbbbbbaaaaaaaac.....",
"..*aaaaaaaabaaabbbbaaaaaaaac....",
".*aaaaaaaabbaaaabbbbaaaaaaaac...",
".*aaaaaaaabbbbaabbbbaaaaaaaac*..",
"*aaaaaaaaabbbbaabbbbaaaaaaaaac*.",
"*aaaaaaaaaabbaabbbbaaaaaaaaaac*.",
"*aaaaaaaaaaaaabbbbaaaaaaaaaaac**",
"*aaaaaaaaaaaaabbbaaaaaaaaaaaac**",
"*aaaaaaaaaaaaabbaaaaaaaaaaaaac**",
"*aaaaaaaaaaaaabbaaaaaaaaaaaaac**",
"*aaaaaaaaaaaaaaaaaaaaaaaaaaaac**",
".*aaaaaaaaaaaabbaaaaaaaaaaaac***",
".*aaaaaaaaaaabbbbaaaaaaaaaaac***",
"..*aaaaaaaaaabbbbaaaaaaaaaac***.",
"...caaaaaaaaaabbaaaaaaaaaac****.",
"....caaaaaaaaaaaaaaaaaaaac****..",
".....caaaaaaaaaaaaaaaaaac****...",
"......ccaaaaaaaaaaaaaacc****....",
".......*cccaaaaaaaaccc*****.....",
"........***cccaaaac*******......",
"..........****caaac*****........",
".............*caaac**...........",
"...............caac**...........",
"................cac**...........",
".................cc**...........",
"..................***...........",
"...................**...........",
};
#endif //QT_NO_IMAGEIO_XPM
/*!
\reimp
*/
TQPixmap TQWindowsStyle::stylePixmap(StylePixmap stylepixmap,
TQStyleControlElementData ceData,
ControlElementFlags elementFlags,
const TQStyleOption& opt,
const TQWidget *widget) const
{
#ifndef QT_NO_IMAGEIO_XPM
switch (stylepixmap) {
case SP_TitleBarShadeButton:
return TQPixmap( (const char **)qt_shade_xpm );
case SP_TitleBarUnshadeButton:
return TQPixmap( (const char **)qt_unshade_xpm );
case SP_TitleBarNormalButton:
return TQPixmap( (const char **)qt_normalizeup_xpm );
case SP_TitleBarMinButton:
return TQPixmap( (const char **)qt_minimize_xpm );
case SP_TitleBarMaxButton:
return TQPixmap( (const char **)qt_maximize_xpm );
case SP_TitleBarCloseButton:
return TQPixmap( (const char **)qt_close_xpm );
case SP_DockWindowCloseButton:
return TQPixmap( (const char **)dock_window_close_xpm );
case SP_MessageBoxInformation:
return TQPixmap( (const char **)information_xpm);
case SP_MessageBoxWarning:
return TQPixmap( (const char **)warning_xpm );
case SP_MessageBoxCritical:
return TQPixmap( (const char **)critical_xpm );
case SP_MessageBoxQuestion:
return TQPixmap( (const char **)question_xpm );
default:
break;
}
#endif //QT_NO_IMAGEIO_XPM
return TQCommonStyle::stylePixmap(stylepixmap, ceData, elementFlags, opt, widget);
}
/*!\reimp
*/
void TQWindowsStyle::drawComplexControl( ComplexControl ctrl, TQPainter *p,
TQStyleControlElementData ceData,
ControlElementFlags elementFlags,
const TQRect &r,
const TQColorGroup &cg,
SFlags flags,
SCFlags sub,
SCFlags subActive,
const TQStyleOption& opt,
const TQWidget *widget ) const
{
switch (ctrl) {
#ifndef QT_NO_LISTVIEW
case CC_ListView:
{
if ( sub & SC_ListView ) {
TQCommonStyle::drawComplexControl( ctrl, p, ceData, elementFlags, r, cg, flags, sub, subActive, opt, widget );
}
if ( sub & ( SC_ListViewBranch | SC_ListViewExpand ) ) {
if (opt.isDefault())
break;
TQListViewItem *item = opt.listViewItem(),
*child = item->firstChild();
int y = r.y();
int c;
int dotoffset = 0;
TQPointArray dotlines;
if ( subActive == (uint)SC_All && sub == 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
TQListView* v = item->listView();
while ( child && y < r.height() ) {
if (child->isVisible()) {
int lh;
if ( !item->multiLinesEnabled() )
lh = child->height();
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) ) {
// needs a box
p->setPen( cg.mid() );
p->drawRect( bx-4, linebot-4, 9, 9 );
// plus or minus
p->setPen( cg.text() );
p->drawLine( bx - 2, linebot, bx + 2, linebot );
if ( !child->isOpen() )
p->drawLine( bx, linebot - 2, bx, linebot + 2 );
// dotlinery
p->setPen( cg.mid() );
dotlines[c++] = TQPoint( bx, linetop );
dotlines[c++] = TQPoint( bx, linebot - 4 );
dotlines[c++] = TQPoint( bx + 5, linebot );
dotlines[c++] = TQPoint( r.width(), linebot );
linetop = linebot + 5;
} else {
// just dotlinery
dotlines[c++] = TQPoint( bx+1, linebot -1);
dotlines[c++] = TQPoint( r.width(), linebot -1);
}
y += child->totalHeight();
}
child = child->nextSibling();
}
// Expand line height to edge of rectangle if there's any
// visible child below
while ( child && child->height() <= 0)
child = child->nextSibling();
if ( child )
linebot = r.height();
if ( linetop < linebot ) {
dotlines[c++] = TQPoint( bx, linetop );
dotlines[c++] = TQPoint( bx, linebot );
}
}
p->setPen( cg.text() );
static TQBitmap *verticalLine = 0, *horizontalLine = 0;
static TQCleanupHandler<TQBitmap> qlv_cleanup_bitmap;
if ( !verticalLine ) {
// make 128*1 and 1*128 bitmaps that can be used for
// drawing the right sort of lines.
verticalLine = new TQBitmap( 1, 129, 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( color1 );
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( color1 );
p.drawPoints( a );
p.end();
TQApplication::flushX();
horizontalLine->setMask( *horizontalLine );
qlv_cleanup_bitmap.add( &verticalLine );
qlv_cleanup_bitmap.add( &horizontalLine );
}
int line; // index into dotlines
if ( sub & SC_ListViewBranch ) 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_COMBOBOX
case CC_ComboBox:
if ( sub & SC_ComboBoxArrow ) {
SFlags flags = Style_Default;
qDrawWinPanel( p, r, cg, TRUE, ( elementFlags & CEF_IsEnabled ) ?
&cg.brush( TQColorGroup::Base ):
&cg.brush( TQColorGroup::Background ) );
TQRect ar =
TQStyle::visualRect( querySubControlMetrics( CC_ComboBox, ceData, elementFlags,
SC_ComboBoxArrow, TQStyleOption::Default, widget ), ceData, elementFlags );
if ( subActive == SC_ComboBoxArrow ) {
p->setPen( cg.dark() );
p->setBrush( cg.brush( TQColorGroup::Button ) );
p->drawRect( ar );
} else
qDrawWinPanel( p, ar, cg, FALSE,
&cg.brush( TQColorGroup::Button ) );
ar.addCoords( 2, 2, -2, -2 );
if ( elementFlags & CEF_IsEnabled )
flags |= Style_Enabled;
if ( subActive == SC_ComboBoxArrow ) {
flags |= Style_Sunken;
}
drawPrimitive( PE_ArrowDown, p, ceData, elementFlags, ar, cg, flags );
}
if ( sub & SC_ComboBoxEditField ) {
TQRect re =
TQStyle::visualRect( querySubControlMetrics( CC_ComboBox, ceData, elementFlags,
SC_ComboBoxEditField, TQStyleOption::Default, widget ), ceData, elementFlags );
if ( ( elementFlags & CEF_HasFocus ) && (!( elementFlags & CEF_IsEditable )) )
p->fillRect( re.x(), re.y(), re.width(), re.height(),
cg.brush( TQColorGroup::Highlight ) );
if ( elementFlags & CEF_HasFocus ) {
p->setPen( cg.highlightedText() );
p->setBackgroundColor( cg.highlight() );
} else {
p->setPen( cg.text() );
p->setBackgroundColor( cg.background() );
}
if ( ( elementFlags & CEF_HasFocus ) && (!( elementFlags & CEF_IsEditable )) ) {
TQRect re =
TQStyle::visualRect( subRect( SR_ComboBoxFocusRect, ceData, elementFlags, widget ), ceData, elementFlags );
drawPrimitive( PE_FocusRect, p, ceData, elementFlags, re, cg, Style_FocusAtBorder, TQStyleOption(cg.highlight()));
}
}
break;
#endif // QT_NO_COMBOBOX
#ifndef QT_NO_SLIDER
case CC_Slider:
{
int thickness = pixelMetric( PM_SliderControlThickness, ceData, elementFlags, widget );
int len = pixelMetric( PM_SliderLength, ceData, elementFlags, widget );
int ticks = ceData.tickMarkSetting;
TQRect groove = querySubControlMetrics(CC_Slider, ceData, elementFlags, SC_SliderGroove,
opt, widget),
handle = querySubControlMetrics(CC_Slider, ceData, elementFlags, SC_SliderHandle,
opt, widget);
if ((sub & SC_SliderGroove) && groove.isValid()) {
int mid = thickness / 2;
if ( ticks & TQSlider::Above )
mid += len / 8;
if ( ticks & TQSlider::Below )
mid -= len / 8;
p->setPen( cg.shadow() );
if ( ceData.orientation == Horizontal ) {
qDrawWinPanel( p, groove.x(), groove.y() + mid - 2,
groove.width(), 4, cg, TRUE );
p->drawLine( groove.x() + 1, groove.y() + mid - 1,
groove.x() + groove.width() - 3, groove.y() + mid - 1 );
} else {
qDrawWinPanel( p, groove.x() + mid - 2, groove.y(),
4, groove.height(), cg, TRUE );
p->drawLine( groove.x() + mid - 1, groove.y() + 1,
groove.x() + mid - 1,
groove.y() + groove.height() - 3 );
}
}
if (sub & SC_SliderTickmarks)
TQCommonStyle::drawComplexControl(ctrl, p, ceData, elementFlags, r, cg, flags,
SC_SliderTickmarks, subActive,
opt, widget );
if ( sub & SC_SliderHandle ) {
// 4444440
// 4333310
// 4322210
// 4322210
// 4322210
// 4322210
// *43210*
// **410**
// ***0***
const TQColor c0 = cg.shadow();
const TQColor c1 = cg.dark();
// const TQColor c2 = g.button();
const TQColor c3 = cg.midlight();
const TQColor c4 = cg.light();
int x = handle.x(), y = handle.y(),
wi = handle.width(), he = handle.height();
int x1 = x;
int x2 = x+wi-1;
int y1 = y;
int y2 = y+he-1;
Orientation orient = ceData.orientation;
bool tickAbove = ceData.tickMarkSetting == TQSlider::Above;
bool tickBelow = ceData.tickMarkSetting == TQSlider::Below;
p->fillRect( x, y, wi, he, cg.brush( TQColorGroup::Background ) );
if ( flags & Style_HasFocus ) {
TQRect re = subRect( SR_SliderFocusRect, ceData, elementFlags, widget );
drawPrimitive( PE_FocusRect, p, ceData, elementFlags, re, cg );
}
if ( (tickAbove && tickBelow) || (!tickAbove && !tickBelow) ) {
qDrawWinButton( p, TQRect(x,y,wi,he), cg, FALSE,
&cg.brush( TQColorGroup::Button ) );
return;
}
TQSliderDirection dir;
if ( orient == Horizontal )
if ( tickAbove )
dir = SlUp;
else
dir = SlDown;
else
if ( tickAbove )
dir = SlLeft;
else
dir = SlRight;
TQPointArray a;
int d = 0;
switch ( dir ) {
case SlUp:
y1 = y1 + wi/2;
d = (wi + 1) / 2 - 1;
a.setPoints(5, x1,y1, x1,y2, x2,y2, x2,y1, x1+d,y1-d );
break;
case SlDown:
y2 = y2 - wi/2;
d = (wi + 1) / 2 - 1;
a.setPoints(5, x1,y1, x1,y2, x1+d,y2+d, x2,y2, x2,y1 );
break;
case SlLeft:
d = (he + 1) / 2 - 1;
x1 = x1 + he/2;
a.setPoints(5, x1,y1, x1-d,y1+d, x1,y2, x2,y2, x2,y1);
break;
case SlRight:
d = (he + 1) / 2 - 1;
x2 = x2 - he/2;
a.setPoints(5, x1,y1, x1,y2, x2,y2, x2+d,y1+d, x2,y1 );
break;
}
TQBrush oldBrush = p->brush();
p->setBrush( cg.brush( TQColorGroup::Button ) );
p->setPen( NoPen );
p->drawRect( x1, y1, x2-x1+1, y2-y1+1 );
p->drawPolygon( a );
p->setBrush( oldBrush );
if ( dir != SlUp ) {
p->setPen( c4 );
p->drawLine( x1, y1, x2, y1 );
p->setPen( c3 );
p->drawLine( x1, y1+1, x2, y1+1 );
}
if ( dir != SlLeft ) {
p->setPen( c3 );
p->drawLine( x1+1, y1+1, x1+1, y2 );
p->setPen( c4 );
p->drawLine( x1, y1, x1, y2 );
}
if ( dir != SlRight ) {
p->setPen( c0 );
p->drawLine( x2, y1, x2, y2 );
p->setPen( c1 );
p->drawLine( x2-1, y1+1, x2-1, y2-1 );
}
if ( dir != SlDown ) {
p->setPen( c0 );
p->drawLine( x1, y2, x2, y2 );
p->setPen( c1 );
p->drawLine( x1+1, y2-1, x2-1, y2-1 );
}
switch ( dir ) {
case SlUp:
p->setPen( c4 );
p->drawLine( x1, y1, x1+d, y1-d);
p->setPen( c0 );
d = wi - d - 1;
p->drawLine( x2, y1, x2-d, y1-d);
d--;
p->setPen( c3 );
p->drawLine( x1+1, y1, x1+1+d, y1-d );
p->setPen( c1 );
p->drawLine( x2-1, y1, x2-1-d, y1-d);
break;
case SlDown:
p->setPen( c4 );
p->drawLine( x1, y2, x1+d, y2+d);
p->setPen( c0 );
d = wi - d - 1;
p->drawLine( x2, y2, x2-d, y2+d);
d--;
p->setPen( c3 );
p->drawLine( x1+1, y2, x1+1+d, y2+d );
p->setPen( c1 );
p->drawLine( x2-1, y2, x2-1-d, y2+d);
break;
case SlLeft:
p->setPen( c4 );
p->drawLine( x1, y1, x1-d, y1+d);
p->setPen( c0 );
d = he - d - 1;
p->drawLine( x1, y2, x1-d, y2-d);
d--;
p->setPen( c3 );
p->drawLine( x1, y1+1, x1-d, y1+1+d );
p->setPen( c1 );
p->drawLine( x1, y2-1, x1-d, y2-1-d);
break;
case SlRight:
p->setPen( c4 );
p->drawLine( x2, y1, x2+d, y1+d);
p->setPen( c0 );
d = he - d - 1;
p->drawLine( x2, y2, x2+d, y2-d);
d--;
p->setPen( c3 );
p->drawLine( x2, y1+1, x2+d, y1+1+d );
p->setPen( c1 );
p->drawLine( x2, y2-1, x2+d, y2-1-d);
break;
}
}
break;
}
#endif // QT_NO_SLIDER
default:
TQCommonStyle::drawComplexControl( ctrl, p, ceData, elementFlags, r, cg, flags, sub,
subActive, opt, widget );
break;
}
}
/*! \reimp */
int TQWindowsStyle::styleHint( StyleHint hint,
TQStyleControlElementData ceData,
ControlElementFlags elementFlags,
const TQStyleOption &opt,
TQStyleHintReturn *returnData,
const TQWidget *widget ) const
{
int ret;
switch (hint) {
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:
ret = 1;
break;
case SH_ItemView_ChangeHighlightOnFocus:
ret = 0;
break;
case SH_ToolBox_SelectedPageTitleBold:
ret = 0;
break;
case SH_MenuIndicatorColumnWidth:
{
int maxpmw = opt.maxIconWidth();
bool checkable = ( elementFlags & CEF_IsCheckable );
if ( checkable ) {
// space for the checkmarks
if (use2000style)
maxpmw = TQMAX( maxpmw, 20 );
else
maxpmw = TQMAX( maxpmw, 12 );
}
ret = maxpmw;
break;
}
default:
ret = TQCommonStyle::styleHint(hint, ceData, elementFlags, opt, returnData, widget);
break;
}
return ret;
}
/*! \reimp */
TQRect TQWindowsStyle::subRect(SubRect r, const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQWidget *widget) const
{
TQRect rect;
switch (r) {
#ifndef QT_NO_SLIDER
case SR_SliderFocusRect:
{
rect = ceData.rect;
break;
}
#endif // QT_NO_SLIDER
case SR_ToolBoxTabContents:
rect = ceData.rect;
break;
default:
rect = TQCommonStyle::subRect( r, ceData, elementFlags, widget );
break;
}
return rect;
}
#endif
|