LibreOffice Module reportdesign (master)  1
EndMarker.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 #include <EndMarker.hxx>
20 #include <ColorChanger.hxx>
21 #include <SectionWindow.hxx>
22 
23 #include <vcl/settings.hxx>
24 #include <vcl/svapp.hxx>
25 #include <vcl/gradient.hxx>
26 #include <vcl/lineinfo.hxx>
27 #include <vcl/event.hxx>
28 
29 
30 #define CORNER_SPACE 5
31 
32 namespace rptui
33 {
34 
35 OEndMarker::OEndMarker(vcl::Window* _pParent ,const OUString& _sColorEntry)
36  : OColorListener(_pParent, _sColorEntry)
37 {
39 }
40 
42 {
43 }
44 
45 void OEndMarker::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& /*rRect*/)
46 {
47  Fraction aCornerSpace(tools::Long(CORNER_SPACE));
48  aCornerSpace *= rRenderContext.GetMapMode().GetScaleX();
49  const tools::Long nCornerSpace = tools::Long(aCornerSpace);
50 
51  Size aSize = GetSizePixel();
52  aSize.AdjustWidth(nCornerSpace );
53  tools::Rectangle aWholeRect(Point(-nCornerSpace,0),aSize);
54  tools::PolyPolygon aPoly;
55  aPoly.Insert( tools::Polygon(aWholeRect,nCornerSpace,nCornerSpace));
56 
57  Color aStartColor(m_nColor);
58  aStartColor.IncreaseLuminance(10);
59  sal_uInt16 nHue = 0;
60  sal_uInt16 nSat = 0;
61  sal_uInt16 nBri = 0;
62  aStartColor.RGBtoHSB(nHue, nSat, nBri);
63  nSat += 40;
64  Color aEndColor(Color::HSBtoRGB(nHue, nSat, nBri));
65  Gradient aGradient(GradientStyle::Linear, aStartColor, aEndColor);
66  aGradient.SetSteps(static_cast<sal_uInt16>(aSize.Height()));
67 
68  rRenderContext.DrawGradient(PixelToLogic(aPoly), aGradient);
69  if (m_bMarked)
70  {
71  tools::Rectangle aRect(Point(-nCornerSpace, nCornerSpace),
72  Size(aSize.Width() - nCornerSpace,
73  aSize.Height() - nCornerSpace - nCornerSpace));
75  rRenderContext.DrawPolyLine( tools::Polygon(PixelToLogic(aRect)), LineInfo(LineStyle::Solid, 2));
76  }
77 }
78 
80 {
82  SetParentClipMode( ParentClipMode::NoClip );
83  SetPaintTransparent( true );
84 
86  GetOutDev()->SetFillColor( Application::GetSettings().GetStyleSettings().GetShadowColor() );
87 }
88 
90 {
91  if ( !rMEvt.IsLeft() && !rMEvt.IsRight())
92  return;
93  static_cast<OSectionWindow*>(GetParent())->showProperties();
94 }
95 
96 }
97 
98 
99 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const Fraction & GetScaleX() const
void SetBackground()
long Long
static const AllSettings & GetSettings()
virtual Size GetSizePixel() const
void DrawPolyLine(const tools::Polygon &rPoly)
const MapMode & GetMapMode() const
void SetParentClipMode(ParentClipMode nMode=ParentClipMode::NONE)
#define CORNER_SPACE
Definition: EndMarker.cxx:30
constexpr tools::Long Width() const
void SetSteps(sal_uInt16 nSteps)
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: EndMarker.cxx:45
void Insert(const tools::Polygon &rPoly, sal_uInt16 nPos=POLYPOLY_APPEND)
void IncreaseLuminance(sal_uInt8 cLumInc)
static Color HSBtoRGB(sal_uInt16 nHue, sal_uInt16 nSaturation, sal_uInt16 nBrightness)
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: EndMarker.cxx:89
void SetFillColor()
void SetPaintTransparent(bool bTransparent)
Point PixelToLogic(const Point &rDevicePt) const
vcl::Window * GetParent() const
OEndMarker(OEndMarker const &)=delete
constexpr tools::Long Height() const
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_WHITE
::OutputDevice const * GetOutDev() const
void EnableChildTransparentMode(bool bEnable=true)
bool IsLeft() const
tools::Long AdjustWidth(tools::Long n)
virtual void ImplInitSettings() override
Definition: EndMarker.cxx:79
void RGBtoHSB(sal_uInt16 &nHue, sal_uInt16 &nSaturation, sal_uInt16 &nBrightness) const
bool IsRight() const
void DrawGradient(const tools::Rectangle &rRect, const Gradient &rGradient)
virtual ~OEndMarker() override
Definition: EndMarker.cxx:41