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/.
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 <sdr/overlay/overlayrollingrectangle.hxx>
21 #include <sdr/overlay/overlaytools.hxx>
22 #include <svx/sdr/overlay/overlaymanager.hxx>
23 #include <basegfx/polygon/b2dpolygontools.hxx>
24 #include <basegfx/polygon/b2dpolygon.hxx>
25 #include <drawinglayer/primitive2d/PolyPolygonMarkerPrimitive2D.hxx>
26 #include <drawinglayer/primitive2d/PolyPolygonSelectionPrimitive2D.hxx>
27 #include <svtools/optionsdrawinglayer.hxx>
29 namespace sdr::overlay
31 drawinglayer::primitive2d::Primitive2DContainer
OverlayRollingRectangleStriped::createOverlayObjectPrimitive2DSequence()
33 drawinglayer::primitive2d::Primitive2DContainer aRetval
;
35 if(getOverlayManager() && (mbShowBounds
|| mbExtendedLines
))
37 const basegfx::BColor
aRGBColorA(getOverlayManager()->getStripeColorA().getBColor());
38 const basegfx::BColor
aRGBColorB(getOverlayManager()->getStripeColorB().getBColor());
39 const double fStripeLengthPixel(getOverlayManager()->getStripeLengthPixel());
40 const basegfx::B2DRange
aRollingRectangle(getBasePosition(), getSecondPosition());
44 // view-independent part, create directly
45 const basegfx::B2DPolygon
aPolygon(basegfx::utils::createPolygonFromRect(aRollingRectangle
));
48 aRetval
[0] = new drawinglayer::primitive2d::PolyPolygonMarkerPrimitive2D(
49 basegfx::B2DPolyPolygon(aPolygon
),
54 const basegfx::BColor
aHilightColor(SvtOptionsDrawinglayer::getHilightColor().getBColor());
55 const double fTransparence(SvtOptionsDrawinglayer::GetTransparentSelectionPercent() * 0.01);
57 aRetval
[1] = new drawinglayer::primitive2d::PolyPolygonSelectionPrimitive2D(
58 basegfx::B2DPolyPolygon(aPolygon
),
67 // view-dependent part, use helper primitive
68 const drawinglayer::primitive2d::Primitive2DReference
aReference(
69 new drawinglayer::primitive2d::OverlayRollingRectanglePrimitive(
75 aRetval
.push_back(aReference
);
82 void OverlayRollingRectangleStriped::stripeDefinitionHasChanged()
84 // react on OverlayManager's stripe definition change
88 OverlayRollingRectangleStriped::OverlayRollingRectangleStriped(
89 const basegfx::B2DPoint
& rBasePos
,
90 const basegfx::B2DPoint
& rSecondPos
,
93 : OverlayObjectWithBasePosition(rBasePos
, COL_BLACK
),
94 maSecondPosition(rSecondPos
),
95 mbExtendedLines(bExtendedLines
),
96 mbShowBounds(bShowBounds
)
100 OverlayRollingRectangleStriped::~OverlayRollingRectangleStriped()
104 void OverlayRollingRectangleStriped::setSecondPosition(const basegfx::B2DPoint
& rNew
)
106 if(rNew
!= maSecondPosition
)
108 // remember new value
109 maSecondPosition
= rNew
;
111 // register change (after change)
115 } // end of namespace
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */