xref: /trunk/main/svx/source/sdr/overlay/overlayanimatedbitmapex.cxx (revision cf6516809c57e1bb0a940545cca99cdad54d4ce2)
1f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f6e50924SAndrew Rist  * distributed with this work for additional information
6f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17f6e50924SAndrew Rist  * specific language governing permissions and limitations
18f6e50924SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20f6e50924SAndrew Rist  *************************************************************/
21f6e50924SAndrew Rist 
22f6e50924SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir #include <svx/sdr/overlay/overlayanimatedbitmapex.hxx>
27cdf0e10cSrcweir #include <vcl/salbtype.hxx>
28cdf0e10cSrcweir #include <vcl/outdev.hxx>
29cdf0e10cSrcweir #include <svx/sdr/overlay/overlaymanager.hxx>
30cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx>
31cdf0e10cSrcweir #include <svx/sdr/overlay/overlaytools.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
34cdf0e10cSrcweir 
35cdf0e10cSrcweir namespace sdr
36cdf0e10cSrcweir {
37cdf0e10cSrcweir     namespace overlay
38cdf0e10cSrcweir     {
createOverlayObjectPrimitive2DSequence()39cdf0e10cSrcweir         drawinglayer::primitive2d::Primitive2DSequence OverlayAnimatedBitmapEx::createOverlayObjectPrimitive2DSequence()
40cdf0e10cSrcweir         {
41cdf0e10cSrcweir             if(mbOverlayState)
42cdf0e10cSrcweir             {
43cdf0e10cSrcweir                 const drawinglayer::primitive2d::Primitive2DReference aPrimitive(
44cdf0e10cSrcweir                     new drawinglayer::primitive2d::OverlayBitmapExPrimitive(
45cdf0e10cSrcweir                         getBitmapEx1(),
46cdf0e10cSrcweir                         getBasePosition(),
47cdf0e10cSrcweir                         getCenterX1(),
48*414a0e15SArmin Le Grand                         getCenterY1(),
49*414a0e15SArmin Le Grand                         getShearX(),
50*414a0e15SArmin Le Grand                         getRotation()));
51cdf0e10cSrcweir 
52cdf0e10cSrcweir                 return drawinglayer::primitive2d::Primitive2DSequence(&aPrimitive, 1);
53cdf0e10cSrcweir             }
54cdf0e10cSrcweir             else
55cdf0e10cSrcweir             {
56cdf0e10cSrcweir                 const drawinglayer::primitive2d::Primitive2DReference aPrimitive(
57cdf0e10cSrcweir                     new drawinglayer::primitive2d::OverlayBitmapExPrimitive(
58cdf0e10cSrcweir                         getBitmapEx2(),
59cdf0e10cSrcweir                         getBasePosition(),
60cdf0e10cSrcweir                         getCenterX2(),
61*414a0e15SArmin Le Grand                         getCenterY2(),
62*414a0e15SArmin Le Grand                         getShearX(),
63*414a0e15SArmin Le Grand                         getRotation()));
64cdf0e10cSrcweir 
65cdf0e10cSrcweir                 return drawinglayer::primitive2d::Primitive2DSequence(&aPrimitive, 1);
66cdf0e10cSrcweir             }
67cdf0e10cSrcweir         }
68cdf0e10cSrcweir 
OverlayAnimatedBitmapEx(const basegfx::B2DPoint & rBasePos,const BitmapEx & rBitmapEx1,const BitmapEx & rBitmapEx2,sal_uInt32 nBlinkTime,sal_uInt16 nCenX1,sal_uInt16 nCenY1,sal_uInt16 nCenX2,sal_uInt16 nCenY2,double fShearX,double fRotation)69cdf0e10cSrcweir         OverlayAnimatedBitmapEx::OverlayAnimatedBitmapEx(
70cdf0e10cSrcweir             const basegfx::B2DPoint& rBasePos,
71cdf0e10cSrcweir             const BitmapEx& rBitmapEx1,
72cdf0e10cSrcweir             const BitmapEx& rBitmapEx2,
73cdf0e10cSrcweir             sal_uInt32 nBlinkTime,
74cdf0e10cSrcweir             sal_uInt16 nCenX1,
75cdf0e10cSrcweir             sal_uInt16 nCenY1,
76cdf0e10cSrcweir             sal_uInt16 nCenX2,
77*414a0e15SArmin Le Grand             sal_uInt16 nCenY2,
78*414a0e15SArmin Le Grand             double fShearX,
79*414a0e15SArmin Le Grand             double fRotation)
80cdf0e10cSrcweir         :   OverlayObjectWithBasePosition(rBasePos, Color(COL_WHITE)),
81cdf0e10cSrcweir             maBitmapEx1(rBitmapEx1),
82cdf0e10cSrcweir             maBitmapEx2(rBitmapEx2),
83cdf0e10cSrcweir             mnCenterX1(nCenX1), mnCenterY1(nCenY1),
84cdf0e10cSrcweir             mnCenterX2(nCenX2), mnCenterY2(nCenY2),
85cdf0e10cSrcweir             mnBlinkTime(nBlinkTime),
86*414a0e15SArmin Le Grand             mfShearX(fShearX),
87*414a0e15SArmin Le Grand             mfRotation(fRotation),
88cdf0e10cSrcweir             mbOverlayState(false)
89cdf0e10cSrcweir         {
90cdf0e10cSrcweir             // set AllowsAnimation flag to mark this object as animation capable
91cdf0e10cSrcweir             mbAllowsAnimation = true;
92cdf0e10cSrcweir 
93cdf0e10cSrcweir             // #i53216# check blink time value range
941cd65da9SArmin Le Grand             mnBlinkTime = impCheckBlinkTimeValueRange(mnBlinkTime);
95cdf0e10cSrcweir         }
96cdf0e10cSrcweir 
~OverlayAnimatedBitmapEx()97cdf0e10cSrcweir         OverlayAnimatedBitmapEx::~OverlayAnimatedBitmapEx()
98cdf0e10cSrcweir         {
99cdf0e10cSrcweir         }
100cdf0e10cSrcweir 
setBitmapEx1(const BitmapEx & rNew)101cdf0e10cSrcweir         void OverlayAnimatedBitmapEx::setBitmapEx1(const BitmapEx& rNew)
102cdf0e10cSrcweir         {
103cdf0e10cSrcweir             if(rNew != maBitmapEx1)
104cdf0e10cSrcweir             {
105cdf0e10cSrcweir                 // remember new Bitmap
106cdf0e10cSrcweir                 maBitmapEx1 = rNew;
107cdf0e10cSrcweir 
108cdf0e10cSrcweir                 // register change (after change)
109cdf0e10cSrcweir                 objectChange();
110cdf0e10cSrcweir             }
111cdf0e10cSrcweir         }
112cdf0e10cSrcweir 
setBitmapEx2(const BitmapEx & rNew)113cdf0e10cSrcweir         void OverlayAnimatedBitmapEx::setBitmapEx2(const BitmapEx& rNew)
114cdf0e10cSrcweir         {
115cdf0e10cSrcweir             if(rNew != maBitmapEx2)
116cdf0e10cSrcweir             {
117cdf0e10cSrcweir                 // remember new Bitmap
118cdf0e10cSrcweir                 maBitmapEx2 = rNew;
119cdf0e10cSrcweir 
120cdf0e10cSrcweir                 // register change (after change)
121cdf0e10cSrcweir                 objectChange();
122cdf0e10cSrcweir             }
123cdf0e10cSrcweir         }
124cdf0e10cSrcweir 
setCenterXY1(sal_uInt16 nNewX,sal_uInt16 nNewY)125cdf0e10cSrcweir         void OverlayAnimatedBitmapEx::setCenterXY1(sal_uInt16 nNewX, sal_uInt16 nNewY)
126cdf0e10cSrcweir         {
127cdf0e10cSrcweir             if(nNewX != mnCenterX1 || nNewY != mnCenterY1)
128cdf0e10cSrcweir             {
129cdf0e10cSrcweir                 // remember new values
130cdf0e10cSrcweir                 if(nNewX != mnCenterX1)
131cdf0e10cSrcweir                 {
132cdf0e10cSrcweir                     mnCenterX1 = nNewX;
133cdf0e10cSrcweir                 }
134cdf0e10cSrcweir 
135cdf0e10cSrcweir                 if(nNewY != mnCenterY1)
136cdf0e10cSrcweir                 {
137cdf0e10cSrcweir                     mnCenterY1 = nNewY;
138cdf0e10cSrcweir                 }
139cdf0e10cSrcweir 
140cdf0e10cSrcweir                 // register change (after change)
141cdf0e10cSrcweir                 objectChange();
142cdf0e10cSrcweir             }
143cdf0e10cSrcweir         }
144cdf0e10cSrcweir 
setCenterXY2(sal_uInt16 nNewX,sal_uInt16 nNewY)145cdf0e10cSrcweir         void OverlayAnimatedBitmapEx::setCenterXY2(sal_uInt16 nNewX, sal_uInt16 nNewY)
146cdf0e10cSrcweir         {
147cdf0e10cSrcweir             if(nNewX != mnCenterX2 || nNewY != mnCenterY2)
148cdf0e10cSrcweir             {
149cdf0e10cSrcweir                 // remember new values
150cdf0e10cSrcweir                 if(nNewX != mnCenterX2)
151cdf0e10cSrcweir                 {
152cdf0e10cSrcweir                     mnCenterX2 = nNewX;
153cdf0e10cSrcweir                 }
154cdf0e10cSrcweir 
155cdf0e10cSrcweir                 if(nNewY != mnCenterY2)
156cdf0e10cSrcweir                 {
157cdf0e10cSrcweir                     mnCenterY2 = nNewY;
158cdf0e10cSrcweir                 }
159cdf0e10cSrcweir 
160cdf0e10cSrcweir                 // register change (after change)
161cdf0e10cSrcweir                 objectChange();
162cdf0e10cSrcweir             }
163cdf0e10cSrcweir         }
164cdf0e10cSrcweir 
setBlinkTime(sal_uInt32 nNew)165cdf0e10cSrcweir         void OverlayAnimatedBitmapEx::setBlinkTime(sal_uInt32 nNew)
166cdf0e10cSrcweir         {
167cdf0e10cSrcweir             if(mnBlinkTime != nNew)
168cdf0e10cSrcweir             {
169cdf0e10cSrcweir                 // remember new value
170cdf0e10cSrcweir                 mnBlinkTime = nNew;
171cdf0e10cSrcweir 
172cdf0e10cSrcweir                 // #i53216# check blink time value range
1731cd65da9SArmin Le Grand                 mnBlinkTime = impCheckBlinkTimeValueRange(mnBlinkTime);
174cdf0e10cSrcweir 
175cdf0e10cSrcweir                 // register change (after change)
176cdf0e10cSrcweir                 objectChange();
177cdf0e10cSrcweir             }
178cdf0e10cSrcweir         }
179cdf0e10cSrcweir 
Trigger(sal_uInt32 nTime)180cdf0e10cSrcweir         void OverlayAnimatedBitmapEx::Trigger(sal_uInt32 nTime)
181cdf0e10cSrcweir         {
182cdf0e10cSrcweir             if(getOverlayManager())
183cdf0e10cSrcweir             {
184cdf0e10cSrcweir                 // #i53216# produce event after nTime + x
185cdf0e10cSrcweir                 SetTime(nTime + mnBlinkTime);
186cdf0e10cSrcweir 
187cdf0e10cSrcweir                 // switch state
188cdf0e10cSrcweir                 if(mbOverlayState)
189cdf0e10cSrcweir                 {
190cdf0e10cSrcweir                     mbOverlayState = false;
191cdf0e10cSrcweir                 }
192cdf0e10cSrcweir                 else
193cdf0e10cSrcweir                 {
194cdf0e10cSrcweir                     mbOverlayState = true;
195cdf0e10cSrcweir                 }
196cdf0e10cSrcweir 
197cdf0e10cSrcweir                 // re-insert me as event
198cdf0e10cSrcweir                 getOverlayManager()->InsertEvent(this);
199cdf0e10cSrcweir 
200cdf0e10cSrcweir                 // register change (after change)
201cdf0e10cSrcweir                 objectChange();
202cdf0e10cSrcweir             }
203cdf0e10cSrcweir         }
204cdf0e10cSrcweir     } // end of namespace overlay
205cdf0e10cSrcweir } // end of namespace sdr
206cdf0e10cSrcweir 
207cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
208cdf0e10cSrcweir // eof
209