Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2008 by Sun Microsystems, Inc.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "overlayobject.hxx"
31 : : #include "vcl/outdev.hxx"
32 : : #include "vcl/lineinfo.hxx"
33 : : #include "vcl/window.hxx"
34 : : #include "tools/fract.hxx"
35 : : #include "basegfx/range/b2drange.hxx"
36 : : #include "basegfx/polygon/b2dpolygon.hxx"
37 : : #include "basegfx/polygon/b2dpolygontools.hxx"
38 : : #include "svx/sdr/overlay/overlaymanager.hxx"
39 : : #include "drawinglayer/primitive2d/baseprimitive2d.hxx"
40 : : #include "drawinglayer/primitive2d/polypolygonprimitive2d.hxx"
41 : :
42 : : using ::sdr::overlay::OverlayObject;
43 : : using ::sdr::overlay::OverlayManager;
44 : : using ::drawinglayer::primitive2d::Primitive2DSequence;
45 : :
46 : : #define DASH_UPDATE_INTERVAL 180 // in msec
47 : :
48 : 0 : ScOverlayDashedBorder::ScOverlayDashedBorder(const ::basegfx::B2DRange& rRange, const Color& rColor, Window* pWin) :
49 : : OverlayObject(rColor),
50 : : mpParent(pWin),
51 [ # # ]: 0 : mbToggle(true)
52 : : {
53 : 0 : mbAllowsAnimation = true;
54 : 0 : maRange = rRange;
55 : 0 : }
56 : :
57 : 0 : ScOverlayDashedBorder::~ScOverlayDashedBorder()
58 : : {
59 [ # # ]: 0 : }
60 : :
61 : 0 : void ScOverlayDashedBorder::Trigger(sal_uInt32 nTime)
62 : : {
63 : 0 : OverlayManager* pMgr = getOverlayManager();
64 [ # # ]: 0 : if (pMgr)
65 : : {
66 : 0 : SetTime(nTime + DASH_UPDATE_INTERVAL);
67 : 0 : mbToggle = !mbToggle;
68 : 0 : pMgr->InsertEvent(this);
69 : 0 : objectChange();
70 : : }
71 : 0 : }
72 : :
73 : 0 : void ScOverlayDashedBorder::stripeDefinitionHasChanged()
74 : : {
75 : 0 : objectChange();
76 : 0 : }
77 : :
78 : 0 : Primitive2DSequence ScOverlayDashedBorder::createOverlayObjectPrimitive2DSequence()
79 : : {
80 : : using ::basegfx::B2DPolygon;
81 : : using ::basegfx::B2DPolyPolygon;
82 : :
83 : 0 : OverlayManager* pMgr = getOverlayManager();
84 [ # # ]: 0 : if (!pMgr)
85 [ # # ]: 0 : return Primitive2DSequence();
86 : :
87 : 0 : basegfx::BColor aColorA = pMgr->getStripeColorA().getBColor();
88 : 0 : basegfx::BColor aColorB = pMgr->getStripeColorB().getBColor();
89 [ # # ]: 0 : if (!mbToggle)
90 [ # # ]: 0 : ::std::swap(aColorA, aColorB);
91 : :
92 [ # # ]: 0 : const basegfx::B2DPolygon aPoly = basegfx::tools::createPolygonFromRect(maRange);
93 [ # # ]: 0 : B2DPolyPolygon aPolygon(aPoly);
94 : : const drawinglayer::primitive2d::Primitive2DReference aReference(
95 : : new drawinglayer::primitive2d::PolyPolygonMarkerPrimitive2D(
96 [ # # ][ # # ]: 0 : aPolygon, aColorA, aColorB, pMgr->getStripeLengthPixel()));
[ # # ]
97 : :
98 [ # # ][ # # ]: 0 : return drawinglayer::primitive2d::Primitive2DSequence(&aReference, 1);
[ # # ]
99 : : }
100 : :
101 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|