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