1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 #include <test/outputdevice.hxx>
18 void drawPolyLineOffset(OutputDevice
& rDevice
, tools::Rectangle
const & rRect
, int nOffset
)
20 tools::Polygon
aPolygon(4);
21 aPolygon
.SetPoint(Point(rRect
.Left() + nOffset
, rRect
.Top() + nOffset
), 0);
22 aPolygon
.SetPoint(Point(rRect
.Right() - nOffset
, rRect
.Top() + nOffset
), 1);
23 aPolygon
.SetPoint(Point(rRect
.Right() - nOffset
, rRect
.Bottom() - nOffset
), 2);
24 aPolygon
.SetPoint(Point(rRect
.Left() + nOffset
, rRect
.Bottom() - nOffset
), 3);
25 aPolygon
.Optimize(PolyOptimizeFlags::CLOSE
);
27 rDevice
.DrawPolyLine(aPolygon
);
30 } // end anonymous namespace
32 Bitmap
OutputDeviceTestPolyLine::setupRectangle(bool bEnableAA
)
34 initialSetup(13, 13, constBackgroundColor
, bEnableAA
);
36 mpVirtualDevice
->SetLineColor(constLineColor
);
37 mpVirtualDevice
->SetFillColor();
39 drawPolyLineOffset(*mpVirtualDevice
, maVDRectangle
, 2);
40 drawPolyLineOffset(*mpVirtualDevice
, maVDRectangle
, 5);
42 return mpVirtualDevice
->GetBitmap(maVDRectangle
.TopLeft(), maVDRectangle
.GetSize());
45 Bitmap
OutputDeviceTestPolyLine::setupDiamond()
47 initialSetup(11, 11, constBackgroundColor
);
49 mpVirtualDevice
->SetLineColor(constLineColor
);
50 mpVirtualDevice
->SetFillColor();
52 Point aPoint1
, aPoint2
, aPoint3
, aPoint4
;
53 OutputDeviceTestCommon::createDiamondPoints(maVDRectangle
, 4, aPoint1
, aPoint2
, aPoint3
, aPoint4
);
55 tools::Polygon
aPolygon(4);
57 aPolygon
.SetPoint(aPoint1
, 0);
58 aPolygon
.SetPoint(aPoint2
, 1);
59 aPolygon
.SetPoint(aPoint3
, 2);
60 aPolygon
.SetPoint(aPoint4
, 3);
61 aPolygon
.Optimize(PolyOptimizeFlags::CLOSE
);
63 mpVirtualDevice
->DrawPolyLine(aPolygon
);
65 return mpVirtualDevice
->GetBitmap(maVDRectangle
.TopLeft(), maVDRectangle
.GetSize());
68 Bitmap
OutputDeviceTestPolyLine::setupLines()
70 initialSetup(13, 13, constBackgroundColor
);
72 mpVirtualDevice
->SetLineColor(constLineColor
);
73 mpVirtualDevice
->SetFillColor();
75 Point aHorizontalLinePoint1
, aHorizontalLinePoint2
;
76 Point aVerticalLinePoint1
, aVerticalLinePoint2
;
77 Point aDiagonalLinePoint1
, aDiagonalLinePoint2
;
79 OutputDeviceTestCommon::createHorizontalVerticalDiagonalLinePoints(
80 maVDRectangle
, aHorizontalLinePoint1
, aHorizontalLinePoint2
,
81 aVerticalLinePoint1
, aVerticalLinePoint2
,
82 aDiagonalLinePoint1
, aDiagonalLinePoint2
);
84 tools::Polygon
aHorizontalPolygon(2);
85 aHorizontalPolygon
.SetPoint(aHorizontalLinePoint1
, 0);
86 aHorizontalPolygon
.SetPoint(aHorizontalLinePoint2
, 1);
87 mpVirtualDevice
->DrawPolyLine(aHorizontalPolygon
);
89 tools::Polygon
aVerticalPolygon(2);
90 aVerticalPolygon
.SetPoint(aVerticalLinePoint1
, 0);
91 aVerticalPolygon
.SetPoint(aVerticalLinePoint2
, 1);
92 mpVirtualDevice
->DrawPolyLine(aVerticalPolygon
);
94 tools::Polygon
aDiagonalPolygon(2);
95 aDiagonalPolygon
.SetPoint(aDiagonalLinePoint1
, 0);
96 aDiagonalPolygon
.SetPoint(aDiagonalLinePoint2
, 1);
97 mpVirtualDevice
->DrawPolyLine(aDiagonalPolygon
);
99 return mpVirtualDevice
->GetBitmap(maVDRectangle
.TopLeft(), maVDRectangle
.GetSize());
102 Bitmap
OutputDeviceTestPolyLine::setupAALines()
104 initialSetup(13, 13, constBackgroundColor
);
106 mpVirtualDevice
->SetAntialiasing(AntialiasingFlags::Enable
);
107 mpVirtualDevice
->SetLineColor(constLineColor
);
108 mpVirtualDevice
->SetFillColor();
110 Point aHorizontalLinePoint1
, aHorizontalLinePoint2
;
111 Point aVerticalLinePoint1
, aVerticalLinePoint2
;
112 Point aDiagonalLinePoint1
, aDiagonalLinePoint2
;
114 OutputDeviceTestCommon::createHorizontalVerticalDiagonalLinePoints(
115 maVDRectangle
, aHorizontalLinePoint1
, aHorizontalLinePoint2
,
116 aVerticalLinePoint1
, aVerticalLinePoint2
,
117 aDiagonalLinePoint1
, aDiagonalLinePoint2
);
119 tools::Polygon
aHorizontalPolygon(2);
120 aHorizontalPolygon
.SetPoint(aHorizontalLinePoint1
, 0);
121 aHorizontalPolygon
.SetPoint(aHorizontalLinePoint2
, 1);
122 mpVirtualDevice
->DrawPolyLine(aHorizontalPolygon
);
124 tools::Polygon
aVerticalPolygon(2);
125 aVerticalPolygon
.SetPoint(aVerticalLinePoint1
, 0);
126 aVerticalPolygon
.SetPoint(aVerticalLinePoint2
, 1);
127 mpVirtualDevice
->DrawPolyLine(aVerticalPolygon
);
129 tools::Polygon
aDiagonalPolygon(2);
130 aDiagonalPolygon
.SetPoint(aDiagonalLinePoint1
, 0);
131 aDiagonalPolygon
.SetPoint(aDiagonalLinePoint2
, 1);
132 mpVirtualDevice
->DrawPolyLine(aDiagonalPolygon
);
134 return mpVirtualDevice
->GetBitmap(maVDRectangle
.TopLeft(), maVDRectangle
.GetSize());
137 } // end namespace vcl::test
139 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */