1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
|
/*************************************************************************
*
* $RCSfile: dlgctrl.cxx,v $
*
* $Revision: 1.19 $
*
* last change: $Author: hr $ $Date: 2003-03-27 15:00:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
// include ---------------------------------------------------------------
#ifndef _SHL_HXX //autogen
#include <tools/shl.hxx>
#endif
#ifndef _APP_HXX //autogen
#include <vcl/svapp.hxx>
#endif
#pragma hdrstop
#include "xoutx.hxx"
#include "xtable.hxx"
#include "xpool.hxx"
#include "dialogs.hrc"
#include "accessibility.hrc"
#include "dlgctrl.hxx"
#include "dialmgr.hxx"
#ifndef _SV_POLY_HXX
#include <vcl/poly.hxx>
#endif
#ifndef _SV_REGION_HXX
#include <vcl/region.hxx>
#endif
#ifndef _SV_GRADIENT_HXX
#include <vcl/gradient.hxx>
#endif
#ifndef _SV_HATCH_HXX
#include <vcl/hatch.hxx>
#endif
#ifndef INCLUDED_SVTOOLS_COLORCFG_HXX
#include <svtools/colorcfg.hxx>
#endif
#include "svxrectctaccessiblecontext.hxx"
#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_
#include <com/sun/star/lang/XUnoTunnel.hpp>
#endif
#define OUTPUT_DRAWMODE_COLOR (DRAWMODE_DEFAULT)
#define OUTPUT_DRAWMODE_CONTRAST (DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT)
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
using namespace ::drafts::com::sun::star::accessibility;
/*************************************************************************
|*
|* Control zur Darstellung und Auswahl der Eckpunkte (und Mittelpunkt)
|* eines Objekts
|*
\************************************************************************/
inline Bitmap* SvxRectCtl::GetBitmap( void )
{
if( !pBitmap )
InitBitmap();
return pBitmap;
}
SvxRectCtl::SvxRectCtl( Window* pParent, const ResId& rResId, RECT_POINT eRpt,
USHORT nBorder, USHORT nCircle, CTL_STYLE eStyle ) :
Control( pParent, rResId ),
pAccContext ( NULL ),
eDefRP ( eRpt ),
nBorderWidth( nBorder ),
nRadius ( nCircle),
m_nState ( 0 ),
eCS ( eStyle ),
pBitmap ( NULL ),
mbCompleteDisable(sal_False)
{
SetMapMode( MAP_100TH_MM );
Resize_Impl();
}
// -----------------------------------------------------------------------
SvxRectCtl::~SvxRectCtl()
{
delete pBitmap;
if( pAccContext )
pAccContext->release();
}
// -----------------------------------------------------------------------
void SvxRectCtl::Resize()
{
Resize_Impl();
Control::Resize();
}
// -----------------------------------------------------------------------
void SvxRectCtl::Resize_Impl()
{
aSize = GetOutputSize();
switch( eCS )
{
case CS_RECT:
case CS_ANGLE:
case CS_SHADOW:
aPtLT = Point( 0 + nBorderWidth, 0 + nBorderWidth );
aPtMT = Point( aSize.Width() / 2, 0 + nBorderWidth );
aPtRT = Point( aSize.Width() - nBorderWidth, 0 + nBorderWidth );
aPtLM = Point( 0 + nBorderWidth, aSize.Height() / 2 );
aPtMM = Point( aSize.Width() / 2, aSize.Height() / 2 );
aPtRM = Point( aSize.Width() - nBorderWidth, aSize.Height() / 2 );
aPtLB = Point( 0 + nBorderWidth, aSize.Height() - nBorderWidth );
aPtMB = Point( aSize.Width() / 2, aSize.Height() - nBorderWidth );
aPtRB = Point( aSize.Width() - nBorderWidth, aSize.Height() - nBorderWidth );
break;
case CS_LINE:
aPtLT = Point( 0 + 3 * nBorderWidth, 0 + nBorderWidth );
aPtMT = Point( aSize.Width() / 2, 0 + nBorderWidth );
aPtRT = Point( aSize.Width() - 3 * nBorderWidth, 0 + nBorderWidth );
aPtLM = Point( 0 + 3 * nBorderWidth, aSize.Height() / 2 );
aPtMM = Point( aSize.Width() / 2, aSize.Height() / 2 );
aPtRM = Point( aSize.Width() - 3 * nBorderWidth, aSize.Height() / 2 );
aPtLB = Point( 0 + 3 * nBorderWidth, aSize.Height() - nBorderWidth );
aPtMB = Point( aSize.Width() / 2, aSize.Height() - nBorderWidth );
aPtRB = Point( aSize.Width() - 3 * nBorderWidth, aSize.Height() - nBorderWidth );
break;
}
Reset();
InitSettings( TRUE, TRUE );
}
// -----------------------------------------------------------------------
void SvxRectCtl::InitBitmap( void )
{
if( pBitmap )
delete pBitmap;
const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
svtools::ColorConfig aColorConfig;
pBitmap = new Bitmap( SVX_RES( RID_SVXCTRL_RECTBTNS ) );
// set bitmap-colors
long aTempAry1[(7*sizeof(Color))/sizeof(long)];
long aTempAry2[(7*sizeof(Color))/sizeof(long)];
Color* pColorAry1 = (Color*)aTempAry1;
Color* pColorAry2 = (Color*)aTempAry2;
pColorAry1[0] = Color( 0xC0, 0xC0, 0xC0 ); // light-gray
pColorAry1[1] = Color( 0xFF, 0xFF, 0x00 ); // yellow
pColorAry1[2] = Color( 0xFF, 0xFF, 0xFF ); // white
pColorAry1[3] = Color( 0x80, 0x80, 0x80 ); // dark-gray
pColorAry1[4] = Color( 0x00, 0x00, 0x00 ); // black
pColorAry1[5] = Color( 0x00, 0xFF, 0x00 ); // green
pColorAry1[6] = Color( 0x00, 0x00, 0xFF ); // blue
pColorAry2[0] = rStyles.GetDialogColor(); // background
pColorAry2[1] = rStyles.GetWindowColor();
pColorAry2[2] = rStyles.GetLightColor();
pColorAry2[3] = rStyles.GetShadowColor();
pColorAry2[4] = rStyles.GetDarkShadowColor();
pColorAry2[5] = Color( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
pColorAry2[6] = rStyles.GetDialogColor();
#ifdef DBG_UTIL
static BOOL bModify = FALSE;
BOOL& rModify = bModify;
if( rModify )
{
static int n = 0;
static UINT8 r = 0xFF;
static UINT8 g = 0x00;
static UINT8 b = 0xFF;
int& rn = n;
UINT8& rr = r;
UINT8& rg = g;
UINT8& rb = b;
pColorAry2[ rn ] = Color( rr, rg, rb );
}
#endif
pBitmap->Replace( pColorAry1, pColorAry2, 7, NULL );
}
// -----------------------------------------------------------------------
void SvxRectCtl::InitSettings( BOOL bForeground, BOOL bBackground )
{
const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
if( bForeground )
{
svtools::ColorConfig aColorConfig;
Color aTextColor( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
if ( IsControlForeground() )
aTextColor = GetControlForeground();
SetTextColor( aTextColor );
}
if( bBackground )
{
if ( IsControlBackground() )
SetBackground( GetControlBackground() );
else
SetBackground( rStyleSettings.GetWindowColor() );
}
delete pBitmap;
pBitmap = NULL; // forces new creating of bitmap
Invalidate();
}
/*************************************************************************
|*
|* Das angeklickte Rechteck (3 x 3) wird ermittelt und der Parent (Dialog)
|* wird benachrichtigt, dass der Punkt geaendert wurde
|*
\************************************************************************/
void SvxRectCtl::MouseButtonDown( const MouseEvent& rMEvt )
{
// #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl
if(!IsCompletelyDisabled())
{
Point aPtLast = aPtNew;
aPtNew = GetApproxLogPtFromPixPt( rMEvt.GetPosPixel() );
if( aPtNew == aPtMM && ( eCS == CS_SHADOW || eCS == CS_ANGLE ) )
{
aPtNew = aPtLast;
}
else
{
Invalidate( Rectangle( aPtLast - Point( nRadius, nRadius ),
aPtLast + Point( nRadius, nRadius ) ) );
Invalidate( Rectangle( aPtNew - Point( nRadius, nRadius ),
aPtNew + Point( nRadius, nRadius ) ) );
eRP = GetRPFromPoint( aPtNew );
SetActualRP( eRP );
if( WINDOW_TABPAGE == GetParent()->GetType() )
( (SvxTabPage*) GetParent() )->PointChanged( this, eRP );
}
}
}
// -----------------------------------------------------------------------
void SvxRectCtl::KeyInput( const KeyEvent& rKeyEvt )
{
// #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl
if(!IsCompletelyDisabled())
{
RECT_POINT eNewRP = eRP;
BOOL bUseMM = (eCS != CS_SHADOW) && (eCS != CS_ANGLE);
switch( rKeyEvt.GetKeyCode().GetCode() )
{
case KEY_DOWN:
{
if( !(m_nState & CS_NOVERT) )
switch( eNewRP )
{
case RP_LT: eNewRP = RP_LM; break;
case RP_MT: eNewRP = bUseMM ? RP_MM : RP_MB; break;
case RP_RT: eNewRP = RP_RM; break;
case RP_LM: eNewRP = RP_LB; break;
case RP_MM: eNewRP = RP_MB; break;
case RP_RM: eNewRP = RP_RB; break;
}
}
break;
case KEY_UP:
{
if( !(m_nState & CS_NOVERT) )
switch( eNewRP )
{
case RP_LM: eNewRP = RP_LT; break;
case RP_MM: eNewRP = RP_MT; break;
case RP_RM: eNewRP = RP_RT; break;
case RP_LB: eNewRP = RP_LM; break;
case RP_MB: eNewRP = bUseMM ? RP_MM : RP_MT; break;
case RP_RB: eNewRP = RP_RM; break;
}
}
break;
case KEY_LEFT:
{
if( !(m_nState & CS_NOHORZ) )
switch( eNewRP )
{
case RP_MT: eNewRP = RP_LT; break;
case RP_RT: eNewRP = RP_MT; break;
case RP_MM: eNewRP = RP_LM; break;
case RP_RM: eNewRP = bUseMM ? RP_MM : RP_LM; break;
case RP_MB: eNewRP = RP_LB; break;
case RP_RB: eNewRP = RP_MB; break;
}
}
break;
case KEY_RIGHT:
{
if( !(m_nState & CS_NOHORZ) )
switch( eNewRP )
{
case RP_LT: eNewRP = RP_MT; break;
case RP_MT: eNewRP = RP_RT; break;
case RP_LM: eNewRP = bUseMM ? RP_MM : RP_RM; break;
case RP_MM: eNewRP = RP_RM; break;
case RP_LB: eNewRP = RP_MB; break;
case RP_MB: eNewRP = RP_RB; break;
}
}
break;
default:
Control::KeyInput( rKeyEvt );
return;
}
if( eNewRP != eRP )
{
SetActualRP( eNewRP );
if( WINDOW_TABPAGE == GetParent()->GetType() )
( (SvxTabPage*) GetParent() )->PointChanged( this, eRP );
SetFocusRect();
}
}
}
// -----------------------------------------------------------------------
void SvxRectCtl::StateChanged( StateChangedType nType )
{
if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
InitSettings( TRUE, FALSE );
else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
InitSettings( FALSE, TRUE );
Window::StateChanged( nType );
}
// -----------------------------------------------------------------------
void SvxRectCtl::DataChanged( const DataChangedEvent& rDCEvt )
{
if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
InitSettings( TRUE, TRUE );
else
Window::DataChanged( rDCEvt );
}
/*************************************************************************
|*
|* Zeichnet das Control (Rechteck mit 9 Kreisen)
|*
\************************************************************************/
void SvxRectCtl::Paint( const Rectangle& rRect )
{
Point aPtDiff( PixelToLogic( Point( 1, 1 ) ) );
const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
SetLineColor( rStyles.GetDialogColor() );
SetFillColor( rStyles.GetDialogColor() );
DrawRect( Rectangle( Point(0,0), GetOutputSize() ) );
if( IsEnabled() )
SetLineColor( rStyles.GetLabelTextColor() );
else
SetLineColor( rStyles.GetShadowColor() );
SetFillColor();
switch( eCS )
{
case CS_RECT:
case CS_SHADOW:
if( !IsEnabled() )
{
Color aOldCol = GetLineColor();
SetLineColor( rStyles.GetLightColor() );
DrawRect( Rectangle( aPtLT + aPtDiff, aPtRB + aPtDiff ) );
SetLineColor( aOldCol );
}
DrawRect( Rectangle( aPtLT, aPtRB ) );
break;
case CS_LINE:
if( !IsEnabled() )
{
Color aOldCol = GetLineColor();
SetLineColor( rStyles.GetLightColor() );
DrawLine( aPtLM - Point( 2 * nBorderWidth, 0) + aPtDiff,
aPtRM + Point( 2 * nBorderWidth, 0 ) + aPtDiff );
SetLineColor( aOldCol );
}
DrawLine( aPtLM - Point( 2 * nBorderWidth, 0),
aPtRM + Point( 2 * nBorderWidth, 0 ) );
break;
case CS_ANGLE:
if( !IsEnabled() )
{
Color aOldCol = GetLineColor();
SetLineColor( rStyles.GetLightColor() );
DrawLine( aPtLT + aPtDiff, aPtRB + aPtDiff );
DrawLine( aPtLB + aPtDiff, aPtRT + aPtDiff );
DrawLine( aPtLM + aPtDiff, aPtRM + aPtDiff );
DrawLine( aPtMT + aPtDiff, aPtMB + aPtDiff );
SetLineColor( aOldCol );
}
DrawLine( aPtLT, aPtRB );
DrawLine( aPtLB, aPtRT );
DrawLine( aPtLM, aPtRM );
DrawLine( aPtMT, aPtMB );
break;
default:
break;
}
SetFillColor( GetBackground().GetColor() );
Size aBtnSize( 11, 11 );
Size aDstBtnSize( PixelToLogic( aBtnSize ) );
Point aToCenter( aDstBtnSize.Width() >> 1, aDstBtnSize.Height() >> 1);
Point aBtnPnt1( IsEnabled()?0:22,0 );
Point aBtnPnt2( 11,0 );
Point aBtnPnt3( 22,0 );
BOOL bNoHorz = (m_nState & CS_NOHORZ) != 0;
BOOL bNoVert = (m_nState & CS_NOVERT) != 0;
Bitmap& rBitmap = *GetBitmap();
// #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl
if(IsCompletelyDisabled())
{
DrawBitmap( aPtLT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
DrawBitmap( aPtMT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
DrawBitmap( aPtRT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
DrawBitmap( aPtLM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
if( eCS == CS_RECT || eCS == CS_LINE )
DrawBitmap( aPtMM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
DrawBitmap( aPtRM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
DrawBitmap( aPtLB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
DrawBitmap( aPtMB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
DrawBitmap( aPtRB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
}
else
{
DrawBitmap( aPtLT - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
DrawBitmap( aPtMT - aToCenter, aDstBtnSize, bNoVert?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
DrawBitmap( aPtRT - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
DrawBitmap( aPtLM - aToCenter, aDstBtnSize, bNoHorz?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
// Mittelpunkt bei Rechteck und Linie
if( eCS == CS_RECT || eCS == CS_LINE )
DrawBitmap( aPtMM - aToCenter, aDstBtnSize, aBtnPnt1, aBtnSize, rBitmap );
DrawBitmap( aPtRM - aToCenter, aDstBtnSize, bNoHorz?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
DrawBitmap( aPtLB - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
DrawBitmap( aPtMB - aToCenter, aDstBtnSize, bNoVert?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
DrawBitmap( aPtRB - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
}
// draw active button, avoid center pos for angle
// #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl
if(!IsCompletelyDisabled())
{
if( IsEnabled() && (eCS != CS_ANGLE || aPtNew != aPtMM) )
{
Point aCenterPt( aPtNew );
aCenterPt -= aToCenter;
DrawBitmap( aCenterPt, aDstBtnSize, aBtnPnt2, aBtnSize, rBitmap );
}
}
}
/*************************************************************************
|*
|* Konvertiert RECT_POINT in Point
|*
\************************************************************************/
Point SvxRectCtl::GetPointFromRP( RECT_POINT eRP) const
{
switch( eRP )
{
case RP_LT: return aPtLT;
case RP_MT: return aPtMT;
case RP_RT: return aPtRT;
case RP_LM: return aPtLM;
case RP_MM: return aPtMM;
case RP_RM: return aPtRM;
case RP_LB: return aPtLB;
case RP_MB: return aPtMB;
case RP_RB: return aPtRB;
}
return( aPtMM ); // default
}
void SvxRectCtl::SetFocusRect( const Rectangle* pRect )
{
HideFocus();
if( pRect )
ShowFocus( *pRect );
else
ShowFocus( CalculateFocusRectangle() );
}
Point SvxRectCtl::SetActualRPWithoutInvalidate( RECT_POINT eNewRP )
{
Point aPtLast = aPtNew;
aPtNew = GetPointFromRP( eNewRP );
if( (m_nState & CS_NOHORZ) != 0 )
aPtNew.X() = aPtMM.X();
if( (m_nState & CS_NOVERT) != 0 )
aPtNew.Y() = aPtMM.Y();
eNewRP = GetRPFromPoint( aPtNew );
eDefRP = eNewRP;
eRP = eNewRP;
return aPtLast;
}
void SvxRectCtl::GetFocus()
{
SetFocusRect();
}
void SvxRectCtl::LoseFocus()
{
HideFocus();
}
Point SvxRectCtl::GetApproxLogPtFromPixPt( const Point& rPt ) const
{
Point aPt = PixelToLogic( rPt );
long x;
long y;
if( ( m_nState & CS_NOHORZ ) == 0 )
{
if( aPt.X() < aSize.Width() / 3 )
x = aPtLT.X();
else if( aPt.X() < aSize.Width() * 2 / 3 )
x = aPtMM.X();
else
x = aPtRB.X();
}
else
x = aPtMM.X();
if( ( m_nState & CS_NOVERT ) == 0 )
{
if( aPt.Y() < aSize.Height() / 3 )
y = aPtLT.Y();
else if( aPt.Y() < aSize.Height() * 2 / 3 )
y = aPtMM.Y();
else
y = aPtRB.Y();
}
else
y = aPtMM.Y();
return Point( x, y );
}
/*************************************************************************
|*
|* Konvertiert Point in RECT_POINT
|*
\************************************************************************/
RECT_POINT SvxRectCtl::GetRPFromPoint( Point aPt ) const
{
if ( aPt == aPtLT) return RP_LT;
else if( aPt == aPtMT) return RP_MT;
else if( aPt == aPtRT) return RP_RT;
else if( aPt == aPtLM) return RP_LM;
else if( aPt == aPtRM) return RP_RM;
else if( aPt == aPtLB) return RP_LB;
else if( aPt == aPtMB) return RP_MB;
else if( aPt == aPtRB) return RP_RB;
else
return RP_MM; // default
}
/*************************************************************************
|*
|* Bewirkt den Ursprungszustand des Controls
|*
\************************************************************************/
void SvxRectCtl::Reset()
{
aPtNew = GetPointFromRP( eDefRP );
eRP = eDefRP;
Invalidate();
}
/*************************************************************************
|*
|* Gibt den aktuell ausgewaehlten RECT_POINT zurck
|*
\************************************************************************/
RECT_POINT SvxRectCtl::GetActualRP() const
{
return( eRP );
}
/*************************************************************************
|*
|* Gibt den aktuell ausgewaehlten RECT_POINT zurck
|*
\************************************************************************/
void SvxRectCtl::SetActualRP( RECT_POINT eNewRP )
{
Point aPtLast( SetActualRPWithoutInvalidate( eNewRP ) );
Invalidate( Rectangle( aPtLast - Point( nRadius, nRadius ), aPtLast + Point( nRadius, nRadius ) ) );
Invalidate( Rectangle( aPtNew - Point( nRadius, nRadius ), aPtNew + Point( nRadius, nRadius ) ) );
// notify accessability object about change
if( pAccContext )
pAccContext->selectChild( eNewRP );
}
void SvxRectCtl::SetState( CTL_STATE nState )
{
m_nState = nState;
Point aPtLast( GetPointFromRP( eRP ) );
Point aPtNew( aPtLast );
if( (m_nState & CS_NOHORZ) != 0 )
aPtNew.X() = aPtMM.X();
if( (m_nState & CS_NOVERT) != 0 )
aPtNew.Y() = aPtMM.Y();
eRP = GetRPFromPoint( aPtNew );
Invalidate();
if( WINDOW_TABPAGE == GetParent()->GetType() )
( (SvxTabPage*) GetParent() )->PointChanged( this, eRP );
}
UINT8 SvxRectCtl::GetNumOfChilds( void ) const
{
return ( eCS == CS_ANGLE )? 8 : 9;
}
Rectangle SvxRectCtl::CalculateFocusRectangle( void ) const
{
Size aDstBtnSize( PixelToLogic( Size( 15, 15 ) ) );
return Rectangle( aPtNew - Point( aDstBtnSize.Width() >> 1, aDstBtnSize.Height() >> 1 ), aDstBtnSize );
}
Rectangle SvxRectCtl::CalculateFocusRectangle( RECT_POINT eRectPoint ) const
{
Rectangle aRet;
RECT_POINT eOldRectPoint = GetActualRP();
if( eOldRectPoint == eRectPoint )
aRet = CalculateFocusRectangle();
else
{
SvxRectCtl* pThis = const_cast< SvxRectCtl* >( this );
pThis->SetActualRPWithoutInvalidate( eRectPoint ); // no invalidation because it's only temporary!
aRet = CalculateFocusRectangle();
pThis->SetActualRPWithoutInvalidate( eOldRectPoint ); // no invalidation because nothing has changed!
}
return aRet;
}
Reference< XAccessible > SvxRectCtl::CreateAccessible()
{
Window* pParent = GetAccessibleParentWindow();
DBG_ASSERT( pParent, "-SvxRectCtl::CreateAccessible(): No Parent!" );
Reference< XAccessible > xAccParent = pParent->GetAccessible();
if( xAccParent.is() )
{
pAccContext = new SvxRectCtlAccessibleContext( xAccParent, *this );
pAccContext->acquire();
SetActualRP( GetActualRP() );
return pAccContext;
}
else
return Reference< XAccessible >();
}
RECT_POINT SvxRectCtl::GetApproxRPFromPixPt( const ::com::sun::star::awt::Point& r ) const
{
return GetRPFromPoint( GetApproxLogPtFromPixPt( Point( r.X, r.Y ) ) );
}
// #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl
void SvxRectCtl::DoCompletelyDisable(sal_Bool bNew)
{
mbCompleteDisable = bNew;
Invalidate();
}
/*************************************************************************
|*
|* Konstruktor ohne Size-Parameter
|*
\************************************************************************/
SvxAngleCtl::SvxAngleCtl( Window* pParent, const ResId& rResId ) :
SvxRectCtl( pParent, rResId ),
aFont( Application::GetSettings().GetStyleSettings().GetAppFont() )
{
aFontSize = Size( 250, 400 );
Initialize();
}
/*************************************************************************
|*
|* Konstruktor mit Size-Parameter
|*
\************************************************************************/
SvxAngleCtl::SvxAngleCtl( Window* pParent, const ResId& rResId, Size aSize ) :
SvxRectCtl( pParent, rResId ),
aFont( Application::GetSettings().GetStyleSettings().GetAppFont() )
{
aFontSize = aSize;
Initialize();
}
/*************************************************************************
|*
|* Initialisierung
|*
\************************************************************************/
void SvxAngleCtl::Initialize()
{
bPositive = TRUE;
// aFont.SetName( "Helvetica" );
aFont.SetSize( aFontSize );
aFont.SetWeight( WEIGHT_NORMAL );
aFont.SetTransparent( FALSE );
SetFont( aFont );
}
/*************************************************************************
|*
|* Zeichnet das (Mini-)Koordinatensystem
|*
\************************************************************************/
void SvxAngleCtl::Paint( const Rectangle& rRect )
{
SetLineColor( Color( COL_BLACK ) ); // PEN_DOT ???
DrawLine( aPtLT - Point( 0, 0), aPtRB + Point( 0, 0 ) );
DrawLine( aPtLB - Point( 0, 0), aPtRT + Point( 0, 0 ) );
SetLineColor( Color( COL_BLACK ) );
DrawLine( aPtLM - Point( 0, 0), aPtRM + Point( 0, 0 ) );
DrawLine( aPtMT - Point( 0, 0), aPtMB + Point( 0, 0 ) );
Point aDiff(aFontSize.Width() / 2, aFontSize.Height() / 2);
DrawText( aPtLT - aDiff, UniString::CreateFromAscii(
RTL_CONSTASCII_STRINGPARAM( "135" ) ) );
DrawText( aPtLM - aDiff, UniString::CreateFromAscii(
RTL_CONSTASCII_STRINGPARAM( "180" ) ) );
if ( bPositive )
DrawText( aPtLB - aDiff, UniString::CreateFromAscii(
RTL_CONSTASCII_STRINGPARAM( "225" ) ) );
else
DrawText( aPtLB - aDiff, UniString::CreateFromAscii(
RTL_CONSTASCII_STRINGPARAM( "-135" ) ) );
aDiff.X() = aFontSize.Width();
DrawText( aPtMT - aDiff, UniString::CreateFromAscii(
RTL_CONSTASCII_STRINGPARAM( "90" ) ) );
DrawText( aPtRT - aDiff, UniString::CreateFromAscii(
RTL_CONSTASCII_STRINGPARAM( "45" ) ) );
aDiff.X() = aDiff .X() * 3 / 2;
if ( bPositive )
DrawText( aPtMB - aDiff, UniString::CreateFromAscii(
RTL_CONSTASCII_STRINGPARAM( "270" ) ) );
else
DrawText( aPtMB - aDiff, UniString::CreateFromAscii(
RTL_CONSTASCII_STRINGPARAM( "-90" ) ) );
DrawText( aPtRM - Point( 0, aDiff.Y() ), UniString::CreateFromAscii(
RTL_CONSTASCII_STRINGPARAM( "0" ) ) );
aDiff.X() = aFontSize.Width() * 2;
if ( bPositive )
DrawText( aPtRB - aDiff, UniString::CreateFromAscii(
RTL_CONSTASCII_STRINGPARAM( "315" ) ) );
else
DrawText( aPtRB - aDiff, UniString::CreateFromAscii(
RTL_CONSTASCII_STRINGPARAM( "-45" ) ) );
}
/*************************************************************************
|*
|* Control zum Editieren von Bitmaps
|*
\************************************************************************/
SvxPixelCtl::SvxPixelCtl( Window* pParent, const ResId& rResId, USHORT nNumber ) :
Control ( pParent, rResId ),
nLines ( nNumber ),
bPaintable ( TRUE )
{
// SetMapMode( MAP_100TH_MM );
aRectSize = GetOutputSize();
SetPixelColor( Color( COL_BLACK ) );
SetBackgroundColor( Color( COL_WHITE ) );
SetLineColor( Application::GetSettings().GetStyleSettings().GetShadowColor() );
nSquares = nLines * nLines;
pPixel = new USHORT[ nSquares ];
// Reset(); <-- wird vom Dialog aufgerufen
}
/*************************************************************************
|*
|* Destruktor dealociert dyn. Array
|*
\************************************************************************/
SvxPixelCtl::~SvxPixelCtl( )
{
delete []pPixel;
}
/*************************************************************************
|*
|* Wechselt die Vordergrund- ,bzw. Hintergrundfarbe
|*
\************************************************************************/
void SvxPixelCtl::ChangePixel( USHORT nPixel )
{
if( *( pPixel + nPixel) == 0 )
*( pPixel + nPixel) = 1; // koennte erweitert werden auf mehrere Farben
else
*( pPixel + nPixel) = 0;
}
/*************************************************************************
|*
|* Das angeklickte Rechteck wird ermittelt um die Farbe zu wechseln
|*
\************************************************************************/
void SvxPixelCtl::MouseButtonDown( const MouseEvent& rMEvt )
{
Point aPt = PixelToLogic( rMEvt.GetPosPixel() );
Point aPtTl, aPtBr;
USHORT nX, nY;
nX = (USHORT) ( aPt.X() * nLines / aRectSize.Width() );
nY = (USHORT) ( aPt.Y() * nLines / aRectSize.Height() );
ChangePixel( nX + nY * nLines );
aPtTl.X() = aRectSize.Width() * nX / nLines + 1;
aPtBr.X() = aRectSize.Width() * (nX + 1) / nLines - 1;
aPtTl.Y() = aRectSize.Height() * nY / nLines + 1;
aPtBr.Y() = aRectSize.Height() * (nY + 1) / nLines - 1;
Invalidate( Rectangle( aPtTl, aPtBr ) );
if( WINDOW_TABPAGE == GetParent()->GetType() )
( (SvxTabPage*) GetParent() )->PointChanged( this, RP_MM ); // RectPoint ist dummy
}
/*************************************************************************
|*
|* Zeichnet das Control (Rechteck mit 9 Kreisen)
|*
\************************************************************************/
void SvxPixelCtl::Paint( const Rectangle& rRect )
{
USHORT i, j, nTmp;
Point aPtTl, aPtBr;
if( bPaintable )
{
// Linien Zeichnen
Control::SetLineColor( aLineColor );
for( i = 1; i < nLines; i++)
{
// horizontal
nTmp = (USHORT) ( aRectSize.Height() * i / nLines );
DrawLine( Point( 0, nTmp ), Point( aRectSize.Width(), nTmp ) );
// vertikal
nTmp = (USHORT) ( aRectSize.Width() * i / nLines );
DrawLine( Point( nTmp, 0 ), Point( nTmp, aRectSize.Height() ) );
}
// Rechtecke (Quadrate) zeichnen
Control::SetLineColor();
USHORT nLastPixel = *pPixel ? 0 : 1;
for( i = 0; i < nLines; i++)
{
aPtTl.Y() = aRectSize.Height() * i / nLines + 1;
aPtBr.Y() = aRectSize.Height() * (i + 1) / nLines - 1;
for( j = 0; j < nLines; j++)
{
aPtTl.X() = aRectSize.Width() * j / nLines + 1;
aPtBr.X() = aRectSize.Width() * (j + 1) / nLines - 1;
if ( *( pPixel + i * nLines + j ) != nLastPixel )
{
nLastPixel = *( pPixel + i * nLines + j );
// Farbe wechseln: 0 -> Hintergrundfarbe
SetFillColor( nLastPixel ? aPixelColor : aBackgroundColor );
}
DrawRect( Rectangle( aPtTl, aPtBr ) );
}
}
} // bPaintable
else
{
SetBackground( Wallpaper( Color( COL_LIGHTGRAY ) ) );
Control::SetLineColor( Color( COL_LIGHTRED ) );
DrawLine( Point( 0, 0 ), Point( aRectSize.Width(), aRectSize.Height() ) );
DrawLine( Point( 0, aRectSize.Height() ), Point( aRectSize.Width(), 0 ) );
}
}
/*************************************************************************
|*
|*
|*
\************************************************************************/
void SvxPixelCtl::SetXBitmap( const XOBitmap& rXBmp )
{
if( rXBmp.GetBitmapType() == XBITMAP_8X8 )
{
aPixelColor = rXBmp.GetPixelColor();
aBackgroundColor = rXBmp.GetBackgroundColor();
USHORT* pArray = rXBmp.GetPixelArray();
for( USHORT i = 0; i < nSquares; i++ )
*( pPixel + i ) = *( pArray + i );
}
}
/*************************************************************************
|*
|* Gibt ein bestimmtes Pixel zurueck
|*
\************************************************************************/
USHORT SvxPixelCtl::GetPixel( const USHORT nPixel )
{
return( *( pPixel + nPixel ) );
}
/*************************************************************************
|*
|* Bewirkt den Ursprungszustand des Controls
|*
\************************************************************************/
void SvxPixelCtl::Reset()
{
// Initialisierung des Arrays
for( USHORT i = 0; i < nSquares; i++)
*(pPixel + i) = 0;
Invalidate();
}
/*************************************************************************
|*
|* Ctor: BitmapCtl fuer SvxPixelCtl
|*
\************************************************************************/
SvxBitmapCtl::SvxBitmapCtl( Window* pParent, const Size& rSize )
{
aSize = rSize;
// aVD.SetOutputSizePixel( aSize );
}
/*************************************************************************
|*
|* Dtor
|*
\************************************************************************/
SvxBitmapCtl::~SvxBitmapCtl()
{
}
/*************************************************************************
|*
|* BitmapCtl: Gibt die Bitmap zurueck
|*
\************************************************************************/
XOBitmap SvxBitmapCtl::GetXBitmap()
{
XOBitmap aXOBitmap( pBmpArray, aPixelColor, aBackgroundColor );
return( aXOBitmap );
}
/*************************************************************************
|*
|* Fuellt die Listbox mit Farben und Strings
|*
\************************************************************************/
void ColorLB::Fill( const XColorTable* pColorTab )
{
long nCount = pColorTab->Count();
XColorEntry* pEntry;
SetUpdateMode( FALSE );
for( long i = 0; i < nCount; i++ )
{
pEntry = pColorTab->Get( i );
InsertEntry( pEntry->GetColor(), pEntry->GetName() );
}
SetUpdateMode( TRUE );
}
/************************************************************************/
void ColorLB::Append( XColorEntry* pEntry, Bitmap* pBmp )
{
InsertEntry( pEntry->GetColor(), pEntry->GetName() );
}
/************************************************************************/
void ColorLB::Modify( XColorEntry* pEntry, USHORT nPos, Bitmap* pBmp )
{
RemoveEntry( nPos );
InsertEntry( pEntry->GetColor(), pEntry->GetName(), nPos );
}
/*************************************************************************
|*
|* Fuellt die Listbox mit Farben und Strings
|*
\************************************************************************/
void FillAttrLB::Fill( const XColorTable* pColorTab )
{
long nCount = pColorTab->Count();
XColorEntry* pEntry;
SetUpdateMode( FALSE );
for( long i = 0; i < nCount; i++ )
{
pEntry = pColorTab->Get( i );
InsertEntry( pEntry->GetColor(), pEntry->GetName() );
}
SetUpdateMode( TRUE );
}
/*************************************************************************
|*
|* Fuellt die Listbox (vorlaeufig) mit Strings
|*
\************************************************************************/
HatchingLB::HatchingLB( Window* pParent, ResId Id, BOOL bUserDraw /*= TRUE*/ )
: ListBox( pParent, Id ),
mpList ( NULL ),
mbUserDraw( bUserDraw )
{
EnableUserDraw( mbUserDraw );
}
HatchingLB::HatchingLB( Window* pParent, WinBits aWB, BOOL bUserDraw /*= TRUE*/ )
: ListBox( pParent, aWB ),
mpList ( NULL ),
mbUserDraw( bUserDraw )
{
EnableUserDraw( mbUserDraw );
}
void HatchingLB::Fill( const XHatchList* pList )
{
mpList = (XHatchList*)pList;
XHatchEntry* pEntry;
long nCount = pList->Count();
SetUpdateMode( FALSE );
if( mbUserDraw )
{
for( long i = 0; i < nCount; i++ )
InsertEntry( pList->Get( i )->GetName() );
}
else
{
for( long i = 0; i < nCount; i++ )
{
pEntry = pList->Get( i );
Bitmap* pBitmap = pList->GetBitmap( i );
if( pBitmap )
InsertEntry( pEntry->GetName(), *pBitmap );
else
InsertEntry( pEntry->GetName() );
}
}
SetUpdateMode( TRUE );
}
void HatchingLB::UserDraw( const UserDrawEvent& rUDEvt )
{
if( mpList != NULL )
{
// Draw gradient with borderrectangle
const Rectangle& rDrawRect = rUDEvt.GetRect();
Rectangle aRect( rDrawRect.nLeft+1, rDrawRect.nTop+1, rDrawRect.nLeft+33, rDrawRect.nBottom-1 );
USHORT nId = rUDEvt.GetItemId();
if( nId >= 0 && nId <= mpList->Count() )
{
OutputDevice* pDevice = rUDEvt.GetDevice();
ULONG nOldDrawMode = pDevice->GetDrawMode();
pDevice->SetDrawMode( GetDisplayBackground().GetColor().IsDark() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR );
XHatch& rXHatch = mpList->Get( rUDEvt.GetItemId() )->GetHatch();
MapMode aMode( MAP_100TH_MM );
Hatch aHatch( (HatchStyle) rXHatch.GetHatchStyle(),
rXHatch.GetColor(),
rUDEvt.GetDevice()->LogicToPixel( Point( rXHatch.GetDistance(), 0 ), aMode ).X(),
rXHatch.GetAngle() );
const Polygon aPolygon( aRect );
const PolyPolygon aPolypoly( aPolygon );
pDevice->DrawHatch( aPolypoly, aHatch );
pDevice->SetLineColor( COL_BLACK );
pDevice->SetFillColor();
pDevice->DrawRect( aRect );
pDevice->SetDrawMode( nOldDrawMode );
// Draw name
pDevice->DrawText( Point( aRect.nRight+7, aRect.nTop-1 ), mpList->Get( rUDEvt.GetItemId() )->GetName() );
}
}
}
/************************************************************************/
void HatchingLB::Append( XHatchEntry* pEntry, Bitmap* pBmp )
{
if( pBmp )
InsertEntry( pEntry->GetName(), *pBmp );
else
InsertEntry( pEntry->GetName() );
}
/************************************************************************/
void HatchingLB::Modify( XHatchEntry* pEntry, USHORT nPos, Bitmap* pBmp )
{
RemoveEntry( nPos );
if( pBmp )
InsertEntry( pEntry->GetName(), *pBmp, nPos );
else
InsertEntry( pEntry->GetName(), nPos );
}
/************************************************************************/
void HatchingLB::SelectEntryByList( const XHatchList* pList, const String& rStr,
const XHatch& rHatch, USHORT nDist )
{
long nCount = pList->Count();
XHatchEntry* pEntry;
BOOL bFound = FALSE;
String aStr;
long i;
for( i = 0; i < nCount && !bFound; i++ )
{
pEntry = pList->Get( i );
aStr = pEntry->GetName();
if( rStr == aStr && rHatch == pEntry->GetHatch() )
bFound = TRUE;
}
if( bFound )
SelectEntryPos( (USHORT) ( i - 1 + nDist ) );
}
/*************************************************************************
|*
|* Fuellt die Listbox (vorlaeufig) mit Strings
|*
\************************************************************************/
void FillAttrLB::Fill( const XHatchList* pList )
{
long nCount = pList->Count();
XHatchEntry* pEntry;
ListBox::SetUpdateMode( FALSE );
for( long i = 0; i < nCount; i++ )
{
pEntry = pList->Get( i );
Bitmap* pBitmap = pList->GetBitmap( i );
if( pBitmap )
ListBox::InsertEntry( pEntry->GetName(), *pBitmap );
else
InsertEntry( pEntry->GetName() );
}
ListBox::SetUpdateMode( TRUE );
}
/*************************************************************************
|*
|* Fuellt die Listbox (vorlaeufig) mit Strings
|*
\************************************************************************/
GradientLB::GradientLB( Window* pParent, ResId Id, BOOL bUserDraw /*= TRUE*/ )
: ListBox( pParent, Id ),
mpList(NULL),
mbUserDraw( bUserDraw )
{
EnableUserDraw( mbUserDraw);
}
GradientLB::GradientLB( Window* pParent, WinBits aWB, BOOL bUserDraw /*= TRUE*/ )
: ListBox( pParent, aWB ),
mpList(NULL),
mbUserDraw( bUserDraw )
{
EnableUserDraw( mbUserDraw );
}
void GradientLB::Fill( const XGradientList* pList )
{
mpList = (XGradientList*)pList;
XGradientEntry* pEntry;
long nCount = pList->Count();
SetUpdateMode( FALSE );
if( mbUserDraw )
{
for( long i = 0; i < nCount; i++ )
InsertEntry( pList->Get( i )->GetName() );
}
else
{
for( long i = 0; i < nCount; i++ )
{
pEntry = pList->Get( i );
Bitmap* pBitmap = pList->GetBitmap( i );
if( pBitmap )
InsertEntry( pEntry->GetName(), *pBitmap );
else
InsertEntry( pEntry->GetName() );
}
}
SetUpdateMode( TRUE );
}
void GradientLB::UserDraw( const UserDrawEvent& rUDEvt )
{
if( mpList != NULL )
{
// Draw gradient with borderrectangle
const Rectangle& rDrawRect = rUDEvt.GetRect();
Rectangle aRect( rDrawRect.nLeft+1, rDrawRect.nTop+1, rDrawRect.nLeft+33, rDrawRect.nBottom-1 );
USHORT nId = rUDEvt.GetItemId();
if( nId >= 0 && nId <= mpList->Count() )
{
OutputDevice* pDevice = rUDEvt.GetDevice();
XGradient& rXGrad = mpList->Get( rUDEvt.GetItemId() )->GetGradient();
Gradient aGradient( (GradientStyle) rXGrad.GetGradientStyle(), rXGrad.GetStartColor(), rXGrad.GetEndColor() );
aGradient.SetAngle( (USHORT)rXGrad.GetAngle() );
aGradient.SetBorder( rXGrad.GetBorder() );
aGradient.SetOfsX( rXGrad.GetXOffset() );
aGradient.SetOfsY( rXGrad.GetYOffset() );
aGradient.SetStartIntensity( rXGrad.GetStartIntens() );
aGradient.SetEndIntensity( rXGrad.GetEndIntens() );
aGradient.SetSteps( 255 );
pDevice->DrawGradient( aRect, aGradient );
pDevice->SetLineColor( COL_BLACK );
pDevice->SetFillColor();
pDevice->DrawRect( aRect );
// Draw name
pDevice->DrawText( Point( aRect.nRight+7, aRect.nTop-1 ), mpList->Get( rUDEvt.GetItemId() )->GetName() );
}
}
}
/************************************************************************/
void GradientLB::Append( XGradientEntry* pEntry, Bitmap* pBmp )
{
if( pBmp )
InsertEntry( pEntry->GetName(), *pBmp );
else
InsertEntry( pEntry->GetName() );
}
/************************************************************************/
void GradientLB::Modify( XGradientEntry* pEntry, USHORT nPos, Bitmap* pBmp )
{
RemoveEntry( nPos );
if( pBmp )
InsertEntry( pEntry->GetName(), *pBmp, nPos );
else
InsertEntry( pEntry->GetName(), nPos );
}
/************************************************************************/
void GradientLB::SelectEntryByList( const XGradientList* pList, const String& rStr,
const XGradient& rGradient, USHORT nDist )
{
long nCount = pList->Count();
XGradientEntry* pEntry;
BOOL bFound = FALSE;
String aStr;
long i;
for( i = 0; i < nCount && !bFound; i++ )
{
pEntry = pList->Get( i );
aStr = pEntry->GetName();
if( rStr == aStr && rGradient == pEntry->GetGradient() )
bFound = TRUE;
}
if( bFound )
SelectEntryPos( (USHORT) ( i - 1 + nDist ) );
}
/*************************************************************************
|*
|* Fuellt die Listbox (vorlaeufig) mit Strings
|*
\************************************************************************/
void FillAttrLB::Fill( const XGradientList* pList )
{
long nCount = pList->Count();
XGradientEntry* pEntry;
ListBox::SetUpdateMode( FALSE );
for( long i = 0; i < nCount; i++ )
{
pEntry = pList->Get( i );
Bitmap* pBitmap = pList->GetBitmap( i );
if( pBitmap )
ListBox::InsertEntry( pEntry->GetName(), *pBitmap );
else
InsertEntry( pEntry->GetName() );
}
ListBox::SetUpdateMode( TRUE );
}
/*************************************************************************
|*
|* Konstruktor von BitmapLB
|*
\************************************************************************/
BitmapLB::BitmapLB( Window* pParent, ResId Id, BOOL bUserDraw /*= TRUE*/ )
: ListBox( pParent, Id ),
mpList( NULL ),
mbUserDraw( bUserDraw )
{
aVD.SetOutputSizePixel( Size( 32, 16 ) );
EnableUserDraw( mbUserDraw );
}
/************************************************************************/
void BitmapLB::SetVirtualDevice()
{
if( aBitmap.GetSizePixel().Width() > 8 ||
aBitmap.GetSizePixel().Height() > 8 )
{
aVD.DrawBitmap( Point( 0, 0 ), Size( 32, 16 ), aBitmap );
}
else
{
aVD.DrawBitmap( Point( 0, 0 ), aBitmap );
aVD.DrawBitmap( Point( 8, 0 ), aBitmap );
aVD.DrawBitmap( Point( 16, 0 ), aBitmap );
aVD.DrawBitmap( Point( 24, 0 ), aBitmap );
aVD.DrawBitmap( Point( 0, 8 ), aBitmap );
aVD.DrawBitmap( Point( 8, 8 ), aBitmap );
aVD.DrawBitmap( Point( 16, 8 ), aBitmap );
aVD.DrawBitmap( Point( 24, 8 ), aBitmap );
}
}
/************************************************************************/
void BitmapLB::Fill( const XBitmapList* pList )
{
mpList = (XBitmapList*)pList;
XBitmapEntry* pEntry;
long nCount = pList->Count();
SetUpdateMode( FALSE );
if( mbUserDraw )
{
for( long i = 0; i < nCount; i++ )
InsertEntry( pList->Get( i )->GetName() );
}
else
{
for( long i = 0; i < nCount; i++ )
{
pEntry = pList->Get( i );
aBitmap = pEntry->GetXBitmap().GetBitmap();
SetVirtualDevice();
InsertEntry( pEntry->GetName(), aVD.GetBitmap( Point( 0, 2 ), Size( 32, 12 ) ) );
}
}
SetUpdateMode( TRUE );
}
void BitmapLB::UserDraw( const UserDrawEvent& rUDEvt )
{
if( mpList != NULL )
{
// Draw bitmap
const Rectangle& rDrawRect = rUDEvt.GetRect();
Rectangle aRect( rDrawRect.nLeft+1, rDrawRect.nTop+1, rDrawRect.nLeft+33, rDrawRect.nBottom-1 );
USHORT nId = rUDEvt.GetItemId();
if( nId >= 0 && nId <= mpList->Count() )
{
Rectangle aClipRect( rDrawRect.nLeft+1, rDrawRect.nTop+1, rDrawRect.nRight-1, rDrawRect.nBottom-1 );
OutputDevice* pDevice = rUDEvt.GetDevice();
pDevice->SetClipRegion( Region( aClipRect ) );
aBitmap = mpList->Get( nId )->GetXBitmap().GetBitmap();
long nPosBaseX = aRect.nLeft;
long nPosBaseY = aRect.nTop;
if( aBitmap.GetSizePixel().Width() > 8 ||
aBitmap.GetSizePixel().Height() > 8 )
{
pDevice->DrawBitmap( Point( nPosBaseX, nPosBaseY ), Size( 32, 16 ), aBitmap );
}
else
{
pDevice->DrawBitmap( Point( nPosBaseX+ 0, nPosBaseY+0 ), aBitmap );
pDevice->DrawBitmap( Point( nPosBaseX+ 8, nPosBaseY+0 ), aBitmap );
pDevice->DrawBitmap( Point( nPosBaseX+16, nPosBaseY+0 ), aBitmap );
pDevice->DrawBitmap( Point( nPosBaseX+24, nPosBaseY+0 ), aBitmap );
pDevice->DrawBitmap( Point( nPosBaseX+ 0, nPosBaseY+8 ), aBitmap );
pDevice->DrawBitmap( Point( nPosBaseX+ 8, nPosBaseY+8 ), aBitmap );
pDevice->DrawBitmap( Point( nPosBaseX+16, nPosBaseY+8 ), aBitmap );
pDevice->DrawBitmap( Point( nPosBaseX+24, nPosBaseY+8 ), aBitmap );
}
pDevice->SetClipRegion();
// Draw name
pDevice->DrawText( Point( aRect.nRight+7, aRect.nTop-1 ), mpList->Get( nId )->GetName() );
}
}
}
/************************************************************************/
void BitmapLB::Append( XBitmapEntry* pEntry, Bitmap* pBmp )
{
if( pBmp )
{
aBitmap = pEntry->GetXBitmap().GetBitmap();
SetVirtualDevice();
InsertEntry( pEntry->GetName(), aVD.GetBitmap( Point( 0, 2 ), Size( 32, 12 ) ) );
}
else
InsertEntry( pEntry->GetName() );
}
/************************************************************************/
void BitmapLB::Modify( XBitmapEntry* pEntry, USHORT nPos, Bitmap* pBmp )
{
RemoveEntry( nPos );
if( pBmp )
{
aBitmap = pEntry->GetXBitmap().GetBitmap();
SetVirtualDevice();
InsertEntry( pEntry->GetName(), aVD.GetBitmap( Point( 0, 2 ), Size( 32, 12 ) ), nPos );
}
else
InsertEntry( pEntry->GetName() );
}
/************************************************************************/
void BitmapLB::SelectEntryByList( const XBitmapList* pList, const String& rStr,
const Bitmap& rBmp)
{
long nCount = pList->Count();
XBitmapEntry* pEntry;
BOOL bFound = FALSE;
long i;
for( i = 0; i < nCount && !bFound; i++ )
{
pEntry = pList->Get( i );
String aStr = pEntry->GetName();
// Bitmap aBmp = pEntry->GetBitmap();
if( rStr == aStr )
{
bFound = TRUE;
}
}
if( bFound )
SelectEntryPos( (USHORT) ( i - 1 ) );
}
/*************************************************************************
|*
|* Konstruktor von FillAttrLB
|*
\************************************************************************/
FillAttrLB::FillAttrLB( Window* pParent, ResId Id ) :
ColorListBox( pParent, Id )
{
aVD.SetOutputSizePixel( Size( 32, 16 ) );
}
/************************************************************************/
FillAttrLB::FillAttrLB( Window* pParent, WinBits aWB ) :
ColorListBox( pParent, aWB )
{
aVD.SetOutputSizePixel( Size( 32, 16 ) );
}
/************************************************************************/
void FillAttrLB::SetVirtualDevice()
{
if( aBitmap.GetSizePixel().Width() > 8 ||
aBitmap.GetSizePixel().Height() > 8 )
{
aVD.DrawBitmap( Point( 0, 0 ), Size( 32, 16 ), aBitmap );
}
else
{
aVD.DrawBitmap( Point( 0, 0 ), aBitmap );
aVD.DrawBitmap( Point( 8, 0 ), aBitmap );
aVD.DrawBitmap( Point( 16, 0 ), aBitmap );
aVD.DrawBitmap( Point( 24, 0 ), aBitmap );
aVD.DrawBitmap( Point( 0, 8 ), aBitmap );
aVD.DrawBitmap( Point( 8, 8 ), aBitmap );
aVD.DrawBitmap( Point( 16, 8 ), aBitmap );
aVD.DrawBitmap( Point( 24, 8 ), aBitmap );
}
}
/************************************************************************/
void FillAttrLB::Fill( const XBitmapList* pList )
{
long nCount = pList->Count();
XBitmapEntry* pEntry;
ListBox::SetUpdateMode( FALSE );
for( long i = 0; i < nCount; i++ )
{
pEntry = pList->Get( i );
aBitmap = pEntry->GetXBitmap().GetBitmap();
SetVirtualDevice();
ListBox::InsertEntry( pEntry->GetName(), aVD.GetBitmap( Point( 0, 2 ), Size( 32, 12 ) ) );
}
ListBox::SetUpdateMode( TRUE );
}
/************************************************************************/
void FillAttrLB::SelectEntryByList( const XBitmapList* pList, const String& rStr,
const Bitmap& rBmp)
{
long nCount = pList->Count();
XBitmapEntry* pEntry;
BOOL bFound = FALSE;
long i;
for( i = 0; i < nCount && !bFound; i++ )
{
pEntry = pList->Get( i );
String aStr = pEntry->GetName();
// Bitmap aBmp = pEntry->GetBitmap();
if( rStr == aStr )
{
bFound = TRUE;
}
/*
if( rStr == aStr && rBmp == aBmp )
bFound = TRUE; */
}
if( bFound )
SelectEntryPos( (USHORT) ( i - 1 ) );
}
/*************************************************************************
|*
|* Fuellt die Listbox (vorlaeufig) mit Strings
|*
\************************************************************************/
void FillTypeLB::Fill()
{
ResMgr* pMgr = DIALOG_MGR();
SetUpdateMode( FALSE );
InsertEntry( String( ResId( RID_SVXSTR_INVISIBLE, pMgr ) ) );
InsertEntry( String( ResId( RID_SVXSTR_COLOR, pMgr ) ) );
InsertEntry( String( ResId( RID_SVXSTR_GRADIENT, pMgr ) ) );
InsertEntry( String( ResId( RID_SVXSTR_HATCH, pMgr ) ) );
InsertEntry( String( ResId( RID_SVXSTR_BITMAP, pMgr ) ) );
SetUpdateMode( TRUE );
}
/*************************************************************************
|*
|* Fuellt die Listbox (vorlaeufig) mit Strings
|*
\************************************************************************/
void LineLB::Fill( const XDashList* pList )
{
long nCount = pList->Count();
XDashEntry* pEntry;
SetUpdateMode( FALSE );
for( long i = 0; i < nCount; i++ )
{
pEntry = pList->Get( i );
Bitmap* pBitmap = const_cast<XDashList*>(pList)->CreateBitmapForUI( i );
if( pBitmap )
{
InsertEntry( pEntry->GetName(), *pBitmap );
delete pBitmap;
}
else
InsertEntry( pEntry->GetName() );
}
SetUpdateMode( TRUE );
}
/************************************************************************/
void LineLB::Append( XDashEntry* pEntry, Bitmap* pBmp )
{
if( pBmp )
InsertEntry( pEntry->GetName(), *pBmp );
else
InsertEntry( pEntry->GetName() );
}
/************************************************************************/
void LineLB::Modify( XDashEntry* pEntry, USHORT nPos, Bitmap* pBmp )
{
RemoveEntry( nPos );
if( pBmp )
InsertEntry( pEntry->GetName(), *pBmp, nPos );
else
InsertEntry( pEntry->GetName(), nPos );
}
/************************************************************************/
void LineLB::SelectEntryByList( const XDashList* pList, const String& rStr,
const XDash& rDash, USHORT nDist )
{
long nCount = pList->Count();
XDashEntry* pEntry;
BOOL bFound = FALSE;
String aStr;
XDash aDash;
long i;
for( i = 0; i < nCount && !bFound; i++ )
{
pEntry = pList->Get( i );
aStr = pEntry->GetName();
aDash = pEntry->GetDash();
if( rStr == aStr && rDash == aDash )
bFound = TRUE;
}
if( bFound )
SelectEntryPos( (USHORT) ( i - 1 + nDist ) );
}
/*************************************************************************
|*
|* Fuellt die Listbox (vorlaeufig) mit Strings
|*
\************************************************************************/
void LineEndLB::Fill( const XLineEndList* pList, BOOL bStart )
{
long nCount = pList->Count();
XLineEndEntry* pEntry;
VirtualDevice aVD;
SetUpdateMode( FALSE );
for( long i = 0; i < nCount; i++ )
{
pEntry = pList->Get( i );
Bitmap* pBitmap = const_cast<XLineEndList*>(pList)->CreateBitmapForUI( i );
if( pBitmap )
{
Size aBmpSize( pBitmap->GetSizePixel() );
aVD.SetOutputSizePixel( aBmpSize, FALSE );
aVD.DrawBitmap( Point(), *pBitmap );
InsertEntry( pEntry->GetName(),
aVD.GetBitmap( bStart ? Point() : Point( aBmpSize.Width() / 2, 0 ),
Size( aBmpSize.Width() / 2, aBmpSize.Height() ) ) );
delete pBitmap;
}
else
InsertEntry( pEntry->GetName() );
}
SetUpdateMode( TRUE );
}
/************************************************************************/
void LineEndLB::Append( XLineEndEntry* pEntry, Bitmap* pBmp,
BOOL bStart )
{
if( pBmp )
{
VirtualDevice aVD;
Size aBmpSize( pBmp->GetSizePixel() );
aVD.SetOutputSizePixel( aBmpSize, FALSE );
aVD.DrawBitmap( Point(), *pBmp );
InsertEntry( pEntry->GetName(),
aVD.GetBitmap( bStart ? Point() : Point( aBmpSize.Width() / 2, 0 ),
Size( aBmpSize.Width() / 2, aBmpSize.Height() ) ) );
}
else
InsertEntry( pEntry->GetName() );
}
/************************************************************************/
void LineEndLB::Modify( XLineEndEntry* pEntry, USHORT nPos, Bitmap* pBmp,
BOOL bStart )
{
RemoveEntry( nPos );
if( pBmp )
{
VirtualDevice aVD;
Size aBmpSize( pBmp->GetSizePixel() );
aVD.SetOutputSizePixel( aBmpSize, FALSE );
aVD.DrawBitmap( Point(), *pBmp );
InsertEntry( pEntry->GetName(),
aVD.GetBitmap( bStart ? Point() : Point( aBmpSize.Width() / 2, 0 ),
Size( aBmpSize.Width() / 2, aBmpSize.Height() ) ), nPos );
}
else
InsertEntry( pEntry->GetName(), nPos );
}
/*************************************************************************
|*
|* SvxXLinePreview::SvxXLinePreview()
|*
*************************************************************************/
SvxXLinePreview::SvxXLinePreview( Window* pParent, const ResId& rResId, XOutputDevice* pXOut ) :
Control ( pParent, rResId ),
pXOutDev ( pXOut ),
bWithSymbol ( FALSE ),
pGraphic ( NULL )
{
SetMapMode( MAP_100TH_MM );
Size aSize = GetOutputSize();
aPtA = Point( 500, aSize.Height() / 2 );
aPtB = Point( aSize.Width() - 500, aSize.Height() / 2 );
InitSettings( TRUE, TRUE );
// Draw the control's border as a flat thin black line.
SetBorderStyle (WINDOW_BORDER_MONO);
SetDrawMode( GetDisplayBackground().GetColor().IsDark() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR );
}
// -----------------------------------------------------------------------
void SvxXLinePreview::InitSettings( BOOL bForeground, BOOL bBackground )
{
const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
if ( bForeground )
{
svtools::ColorConfig aColorConfig;
Color aTextColor( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
if ( IsControlForeground() )
aTextColor = GetControlForeground();
SetTextColor( aTextColor );
}
if ( bBackground )
{
if ( IsControlBackground() )
SetBackground( GetControlBackground() );
else
SetBackground( rStyleSettings.GetWindowColor() );
}
Invalidate();
}
// -----------------------------------------------------------------------
void SvxXLinePreview::SetSymbol(Graphic* p,const Size& s)
{
pGraphic = p;
aSymbolSize = s;
}
// -----------------------------------------------------------------------
void SvxXLinePreview::ResizeSymbol(const Size& s)
{
if ( s != aSymbolSize )
{
aSymbolSize = s;
Invalidate();
}
}
// -----------------------------------------------------------------------
void SvxXLinePreview::Paint( const Rectangle& rRect )
{
pXOutDev->DrawLine( aPtA, aPtB );
if ( bWithSymbol && pGraphic )
{
Point aPos = Point( GetOutputSize().Width() / 2, GetOutputSize().Height() / 2 );
aPos.X() -= aSymbolSize.Width() / 2;
aPos.Y() -= aSymbolSize.Height() / 2;
pGraphic->Draw( this, aPos, aSymbolSize );
}
}
// -----------------------------------------------------------------------
void SvxXLinePreview::StateChanged( StateChangedType nType )
{
if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
InitSettings( TRUE, FALSE );
else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
InitSettings( FALSE, TRUE );
Control::StateChanged( nType );
}
// -----------------------------------------------------------------------
void SvxXLinePreview::DataChanged( const DataChangedEvent& rDCEvt )
{
if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
InitSettings( TRUE, TRUE );
else
Control::DataChanged( rDCEvt );
SetDrawMode( GetDisplayBackground().GetColor().IsDark() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR );
}
/*************************************************************************
|*
|* SvxXRectPreview::SvxXRectPreview()
|*
*************************************************************************/
SvxXRectPreview::SvxXRectPreview( Window* pParent, const ResId& rResId, XOutputDevice* pXOut ) :
Control ( pParent, rResId ),
pXOutDev( pXOut )
{
SetBorderStyle( WINDOW_BORDER_MONO );
SetMapMode( MAP_100TH_MM );
aRect = Rectangle( Point(), GetOutputSize() );
InitSettings( TRUE, TRUE );
}
// -----------------------------------------------------------------------
void SvxXRectPreview::InitSettings( BOOL bForeground, BOOL bBackground )
{
const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
if ( bForeground )
{
svtools::ColorConfig aColorConfig;
Color aTextColor( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
if ( IsControlForeground() )
aTextColor = GetControlForeground();
SetTextColor( aTextColor );
}
if ( bBackground )
{
if ( IsControlBackground() )
SetBackground( GetControlBackground() );
else
SetBackground( rStyleSettings.GetWindowColor() );
}
Invalidate();
}
// -----------------------------------------------------------------------
void SvxXRectPreview::Paint( const Rectangle& rRect )
{
pXOutDev->SetLineColor( Color( COL_TRANSPARENT ) );
pXOutDev->DrawRect( aRect );
}
// -----------------------------------------------------------------------
void SvxXRectPreview::StateChanged( StateChangedType nType )
{
if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
InitSettings( TRUE, FALSE );
else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
InitSettings( FALSE, TRUE );
Control::StateChanged( nType );
}
// -----------------------------------------------------------------------
void SvxXRectPreview::DataChanged( const DataChangedEvent& rDCEvt )
{
if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
InitSettings( TRUE, TRUE );
else
Control::DataChanged( rDCEvt );
}
/*************************************************************************
|*
|* SvxXShadowPreview::SvxXShadowPreview()
|*
*************************************************************************/
SvxXShadowPreview::SvxXShadowPreview( Window* pParent, const ResId& rResId,
XOutputDevice* pXOut, XOutdevItemPool* pXInPool ) :
Control ( pParent, rResId ),
pXOutDev ( pXOut ),
pXPool ( pXInPool ),
pRectItem ( NULL ),
pShadowItem ( NULL )
{
SetMapMode( MAP_100TH_MM );
Size aSize = GetOutputSize();
aSize.Width() = aSize.Width() / 3;
aSize.Height() = aSize.Height() / 3;
aRect = Rectangle( Point( aSize.Width(), aSize.Height() ), aSize );
aShadow = Rectangle( Point( aSize.Width(), aSize.Height() ), aSize );
InitSettings( TRUE, TRUE );
// Draw the control's border as a flat thin black line.
SetBorderStyle (WINDOW_BORDER_MONO);
}
// -----------------------------------------------------------------------
SvxXShadowPreview::~SvxXShadowPreview()
{
delete pRectItem;
}
// -----------------------------------------------------------------------
void SvxXShadowPreview::InitSettings( BOOL bForeground, BOOL bBackground )
{
const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
if ( bForeground )
{
svtools::ColorConfig aColorConfig;
Color aTextColor( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
if ( IsControlForeground() )
aTextColor = GetControlForeground();
SetTextColor( aTextColor );
}
if ( bBackground )
{
if ( IsControlBackground() )
SetBackground( GetControlBackground() );
else
SetBackground( rStyleSettings.GetWindowColor() );
}
Invalidate();
}
// -----------------------------------------------------------------------
void SvxXShadowPreview::Paint( const Rectangle& rRect )
{
aShadow.SetPos( aShadowPos + Point( aRect.GetWidth(), aRect.GetHeight() ) );
if ( pShadowItem )
pXOutDev->SetFillAttr( pShadowItem->GetItemSet() );
pXOutDev->DrawRect( aShadow );
if ( pRectItem )
pXOutDev->SetFillAttr( pRectItem->GetItemSet() );
pXOutDev->DrawRect( aRect );
}
// -----------------------------------------------------------------------
void SvxXShadowPreview::SetRectAttr( XFillAttrSetItem* pSetItem )
{
if( pRectItem )
delete pRectItem;
pRectItem = (XFillAttrSetItem*) pSetItem->Clone( pXPool );
}
// -----------------------------------------------------------------------
void SvxXShadowPreview::SetShadowAttr( XFillAttrSetItem* pSetItem )
{
pShadowItem = pSetItem;
}
// -----------------------------------------------------------------------
void SvxXShadowPreview::StateChanged( StateChangedType nType )
{
if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
InitSettings( TRUE, FALSE );
else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
InitSettings( FALSE, TRUE );
Control::StateChanged( nType );
}
// -----------------------------------------------------------------------
void SvxXShadowPreview::DataChanged( const DataChangedEvent& rDCEvt )
{
if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
InitSettings( TRUE, TRUE );
else
Control::DataChanged( rDCEvt );
}
|