tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / vcl / backendtest / outputdevice / rectangle.cxx
blobf35285f28220ae9ed860ba009edd95a9e1ad28fb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
9 */
11 #include <test/outputdevice.hxx>
13 namespace vcl::test
15 namespace
17 void drawRectOffset(OutputDevice& rDevice, tools::Rectangle const& rRect, int nOffset)
19 int nMidOffset = rRect.Left() + (rRect.Right() - rRect.Left()) / 2;
20 rDevice.DrawRect(
21 tools::Rectangle(rRect.Left() + nOffset - (nOffset + 1) / 2, rRect.Top() + nOffset - 1,
22 rRect.Right() - nMidOffset - nOffset / 3, rRect.Bottom() - nOffset + 1));
25 void drawInvertOffset(OutputDevice& rDevice, tools::Rectangle const& rRect, int nOffset,
26 InvertFlags eFlags)
28 tools::Rectangle aRectangle(rRect.Left() + nOffset, rRect.Top() + nOffset,
29 rRect.Right() - nOffset, rRect.Bottom() - nOffset);
30 rDevice.Invert(aRectangle, eFlags);
33 } // end anonymous namespace
35 Bitmap OutputDeviceTestRect::setupFilledRectangle(bool useLineColor)
37 initialSetup(13, 13, constBackgroundColor);
39 if (useLineColor)
40 mpVirtualDevice->SetLineColor(constLineColor);
41 else
42 mpVirtualDevice->SetLineColor();
43 mpVirtualDevice->SetFillColor(constFillColor);
45 drawRectOffset(*mpVirtualDevice, maVDRectangle, 2);
47 return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize());
50 Bitmap OutputDeviceTestRect::setupRectangle(bool bEnableAA)
52 initialSetup(13, 13, constBackgroundColor, bEnableAA);
54 mpVirtualDevice->SetLineColor(constLineColor);
55 mpVirtualDevice->SetFillColor();
57 drawRectOffset(*mpVirtualDevice, maVDRectangle, 2);
58 drawRectOffset(*mpVirtualDevice, maVDRectangle, 5);
60 return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize());
63 Bitmap OutputDeviceTestRect::setupInvert_NONE()
65 initialSetup(20, 20, COL_WHITE);
67 mpVirtualDevice->SetLineColor();
68 mpVirtualDevice->SetFillColor(COL_LIGHTRED);
69 mpVirtualDevice->DrawRect(tools::Rectangle(Point(2, 2), Size(8, 8)));
70 mpVirtualDevice->SetFillColor(COL_LIGHTGREEN);
71 mpVirtualDevice->DrawRect(tools::Rectangle(Point(10, 2), Size(8, 8)));
72 mpVirtualDevice->SetFillColor(COL_LIGHTBLUE);
73 mpVirtualDevice->DrawRect(tools::Rectangle(Point(2, 10), Size(8, 8)));
75 drawInvertOffset(*mpVirtualDevice, maVDRectangle, 2, InvertFlags::NONE);
77 return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize());
80 Bitmap OutputDeviceTestRect::setupInvert_N50()
82 initialSetup(20, 20, COL_WHITE);
84 mpVirtualDevice->SetLineColor();
85 mpVirtualDevice->SetFillColor(COL_LIGHTRED);
86 mpVirtualDevice->DrawRect(tools::Rectangle(Point(2, 2), Size(8, 8)));
87 mpVirtualDevice->SetFillColor(COL_LIGHTGREEN);
88 mpVirtualDevice->DrawRect(tools::Rectangle(Point(10, 2), Size(8, 8)));
89 mpVirtualDevice->SetFillColor(COL_LIGHTBLUE);
90 mpVirtualDevice->DrawRect(tools::Rectangle(Point(2, 10), Size(8, 8)));
92 drawInvertOffset(*mpVirtualDevice, maVDRectangle, 2, InvertFlags::N50);
94 return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize());
97 Bitmap OutputDeviceTestRect::setupInvert_TrackFrame()
99 initialSetup(20, 20, COL_WHITE);
101 mpVirtualDevice->SetLineColor();
102 mpVirtualDevice->SetFillColor(COL_LIGHTRED);
103 mpVirtualDevice->DrawRect(tools::Rectangle(Point(2, 2), Size(8, 8)));
104 mpVirtualDevice->SetFillColor(COL_LIGHTGREEN);
105 mpVirtualDevice->DrawRect(tools::Rectangle(Point(10, 2), Size(8, 8)));
106 mpVirtualDevice->SetFillColor(COL_LIGHTBLUE);
107 mpVirtualDevice->DrawRect(tools::Rectangle(Point(2, 10), Size(8, 8)));
109 drawInvertOffset(*mpVirtualDevice, maVDRectangle, 2, InvertFlags::TrackFrame);
111 return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize());
114 Bitmap OutputDeviceTestRect::setupRectangleOnSize1028()
116 initialSetup(1028, 1028, constBackgroundColor);
118 mpVirtualDevice->SetLineColor(constLineColor);
119 mpVirtualDevice->SetFillColor();
121 drawRectOffset(*mpVirtualDevice, maVDRectangle, 2);
122 drawRectOffset(*mpVirtualDevice, maVDRectangle, 5);
124 return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize());
127 Bitmap OutputDeviceTestRect::setupRectangleOnSize4096()
129 initialSetup(4096, 4096, constBackgroundColor);
131 mpVirtualDevice->SetLineColor(constLineColor);
132 mpVirtualDevice->SetFillColor();
134 drawRectOffset(*mpVirtualDevice, maVDRectangle, 2);
135 drawRectOffset(*mpVirtualDevice, maVDRectangle, 5);
137 return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize());
140 } // end namespace vcl::test
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */