Version 7.1.7.1, tag libreoffice-7.1.7.1
[LibreOffice.git] / sfx2 / source / sidebar / DrawHelper.cxx
blobceb4d23717d6e5ccac01f99baa0a0abe254f42ca
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 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sidebar/DrawHelper.hxx>
22 #include <tools/svborder.hxx>
24 namespace sfx2::sidebar {
26 void DrawHelper::DrawBorder(vcl::RenderContext& rRenderContext, const tools::Rectangle& rBox, const SvBorder& rBorderSize,
27 const Color& rHorizontalColor, const Color& rVerticalColor)
29 // Draw top line.
30 DrawHorizontalLine(rRenderContext, rBox.Left(), rBox.Right(),
31 rBox.Top(), rBorderSize.Top(), rHorizontalColor);
33 // Draw bottom line.
34 DrawHorizontalLine(rRenderContext, rBox.Left() + rBorderSize.Left(), rBox.Right(),
35 rBox.Bottom() - rBorderSize.Bottom() + 1, rBorderSize.Bottom(),
36 rHorizontalColor);
37 // Draw left line.
38 DrawVerticalLine(rRenderContext, rBox.Top() + rBorderSize.Top(), rBox.Bottom(),
39 rBox.Left(), rBorderSize.Left(), rVerticalColor);
40 // Draw right line.
41 DrawVerticalLine(rRenderContext, rBox.Top() + rBorderSize.Top(), rBox.Bottom() - rBorderSize.Bottom(),
42 rBox.Right() - rBorderSize.Right() + 1, rBorderSize.Right(), rVerticalColor);
45 void DrawHelper::DrawHorizontalLine(vcl::RenderContext& rRenderContext, const sal_Int32 nLeft, const sal_Int32 nRight,
46 const sal_Int32 nY, const sal_Int32 nHeight, const Color& rColor)
48 rRenderContext.SetLineColor(rColor);
49 for (sal_Int32 nYOffset = 0; nYOffset < nHeight; ++nYOffset)
51 rRenderContext.DrawLine(Point(nLeft, nY + nYOffset),
52 Point(nRight, nY + nYOffset));
56 void DrawHelper::DrawVerticalLine(vcl::RenderContext& rRenderContext, const sal_Int32 nTop, const sal_Int32 nBottom,
57 const sal_Int32 nX, const sal_Int32 nWidth, const Color& rColor)
59 rRenderContext.SetLineColor(rColor);
60 for (sal_Int32 nXOffset = 0; nXOffset < nWidth; ++nXOffset)
62 rRenderContext.DrawLine(Point(nX + nXOffset, nTop),
63 Point(nX + nXOffset, nBottom));
67 } // end of namespace sfx2::sidebar
69 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */