1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: overlayanimatedbitmapex.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
33 #include <svx/sdr/overlay/overlayanimatedbitmapex.hxx>
34 #include <vcl/salbtype.hxx>
35 #include <vcl/outdev.hxx>
36 #include <svx/sdr/overlay/overlaymanager.hxx>
37 #include <basegfx/matrix/b2dhommatrix.hxx>
38 #include <svx/sdr/overlay/overlaytools.hxx>
40 //////////////////////////////////////////////////////////////////////////////
46 // #i53216# check blink time value range
47 void OverlayAnimatedBitmapEx::impCheckBlinkTimeValueRange()
53 else if(mnBlinkTime
> 10000)
59 drawinglayer::primitive2d::Primitive2DSequence
OverlayAnimatedBitmapEx::createOverlayObjectPrimitive2DSequence()
63 const drawinglayer::primitive2d::Primitive2DReference
aPrimitive(
64 new drawinglayer::primitive2d::OverlayBitmapExPrimitive(
70 return drawinglayer::primitive2d::Primitive2DSequence(&aPrimitive
, 1);
74 const drawinglayer::primitive2d::Primitive2DReference
aPrimitive(
75 new drawinglayer::primitive2d::OverlayBitmapExPrimitive(
81 return drawinglayer::primitive2d::Primitive2DSequence(&aPrimitive
, 1);
85 OverlayAnimatedBitmapEx::OverlayAnimatedBitmapEx(
86 const basegfx::B2DPoint
& rBasePos
,
87 const BitmapEx
& rBitmapEx1
,
88 const BitmapEx
& rBitmapEx2
,
89 sal_uInt32 nBlinkTime
,
94 : OverlayObjectWithBasePosition(rBasePos
, Color(COL_WHITE
)),
95 maBitmapEx1(rBitmapEx1
),
96 maBitmapEx2(rBitmapEx2
),
97 mnCenterX1(nCenX1
), mnCenterY1(nCenY1
),
98 mnCenterX2(nCenX2
), mnCenterY2(nCenY2
),
99 mnBlinkTime(nBlinkTime
),
100 mbOverlayState(false)
102 // set AllowsAnimation flag to mark this object as animation capable
103 mbAllowsAnimation
= true;
105 // #i53216# check blink time value range
106 impCheckBlinkTimeValueRange();
109 OverlayAnimatedBitmapEx::~OverlayAnimatedBitmapEx()
113 void OverlayAnimatedBitmapEx::setBitmapEx1(const BitmapEx
& rNew
)
115 if(rNew
!= maBitmapEx1
)
117 // remember new Bitmap
120 // register change (after change)
125 void OverlayAnimatedBitmapEx::setBitmapEx2(const BitmapEx
& rNew
)
127 if(rNew
!= maBitmapEx2
)
129 // remember new Bitmap
132 // register change (after change)
137 void OverlayAnimatedBitmapEx::setCenterXY1(sal_uInt16 nNewX
, sal_uInt16 nNewY
)
139 if(nNewX
!= mnCenterX1
|| nNewY
!= mnCenterY1
)
141 // remember new values
142 if(nNewX
!= mnCenterX1
)
147 if(nNewY
!= mnCenterY1
)
152 // register change (after change)
157 void OverlayAnimatedBitmapEx::setCenterXY2(sal_uInt16 nNewX
, sal_uInt16 nNewY
)
159 if(nNewX
!= mnCenterX2
|| nNewY
!= mnCenterY2
)
161 // remember new values
162 if(nNewX
!= mnCenterX2
)
167 if(nNewY
!= mnCenterY2
)
172 // register change (after change)
177 void OverlayAnimatedBitmapEx::setBlinkTime(sal_uInt32 nNew
)
179 if(mnBlinkTime
!= nNew
)
181 // remember new value
184 // #i53216# check blink time value range
185 impCheckBlinkTimeValueRange();
187 // register change (after change)
192 void OverlayAnimatedBitmapEx::Trigger(sal_uInt32 nTime
)
194 if(getOverlayManager())
196 // #i53216# produce event after nTime + x
197 SetTime(nTime
+ mnBlinkTime
);
202 mbOverlayState
= false;
206 mbOverlayState
= true;
209 // re-insert me as event
210 getOverlayManager()->InsertEvent(this);
212 // register change (after change)
216 } // end of namespace overlay
217 } // end of namespace sdr
219 //////////////////////////////////////////////////////////////////////////////