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 { 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(), 48cdf0e10cSrcweir getCenterY1())); 49cdf0e10cSrcweir 50cdf0e10cSrcweir return drawinglayer::primitive2d::Primitive2DSequence(&aPrimitive, 1); 51cdf0e10cSrcweir } 52cdf0e10cSrcweir else 53cdf0e10cSrcweir { 54cdf0e10cSrcweir const drawinglayer::primitive2d::Primitive2DReference aPrimitive( 55cdf0e10cSrcweir new drawinglayer::primitive2d::OverlayBitmapExPrimitive( 56cdf0e10cSrcweir getBitmapEx2(), 57cdf0e10cSrcweir getBasePosition(), 58cdf0e10cSrcweir getCenterX2(), 59cdf0e10cSrcweir getCenterY2())); 60cdf0e10cSrcweir 61cdf0e10cSrcweir return drawinglayer::primitive2d::Primitive2DSequence(&aPrimitive, 1); 62cdf0e10cSrcweir } 63cdf0e10cSrcweir } 64cdf0e10cSrcweir 65cdf0e10cSrcweir OverlayAnimatedBitmapEx::OverlayAnimatedBitmapEx( 66cdf0e10cSrcweir const basegfx::B2DPoint& rBasePos, 67cdf0e10cSrcweir const BitmapEx& rBitmapEx1, 68cdf0e10cSrcweir const BitmapEx& rBitmapEx2, 69cdf0e10cSrcweir sal_uInt32 nBlinkTime, 70cdf0e10cSrcweir sal_uInt16 nCenX1, 71cdf0e10cSrcweir sal_uInt16 nCenY1, 72cdf0e10cSrcweir sal_uInt16 nCenX2, 73cdf0e10cSrcweir sal_uInt16 nCenY2) 74cdf0e10cSrcweir : OverlayObjectWithBasePosition(rBasePos, Color(COL_WHITE)), 75cdf0e10cSrcweir maBitmapEx1(rBitmapEx1), 76cdf0e10cSrcweir maBitmapEx2(rBitmapEx2), 77cdf0e10cSrcweir mnCenterX1(nCenX1), mnCenterY1(nCenY1), 78cdf0e10cSrcweir mnCenterX2(nCenX2), mnCenterY2(nCenY2), 79cdf0e10cSrcweir mnBlinkTime(nBlinkTime), 80cdf0e10cSrcweir mbOverlayState(false) 81cdf0e10cSrcweir { 82cdf0e10cSrcweir // set AllowsAnimation flag to mark this object as animation capable 83cdf0e10cSrcweir mbAllowsAnimation = true; 84cdf0e10cSrcweir 85cdf0e10cSrcweir // #i53216# check blink time value range 86*1cd65da9SArmin Le Grand mnBlinkTime = impCheckBlinkTimeValueRange(mnBlinkTime); 87cdf0e10cSrcweir } 88cdf0e10cSrcweir 89cdf0e10cSrcweir OverlayAnimatedBitmapEx::~OverlayAnimatedBitmapEx() 90cdf0e10cSrcweir { 91cdf0e10cSrcweir } 92cdf0e10cSrcweir 93cdf0e10cSrcweir void OverlayAnimatedBitmapEx::setBitmapEx1(const BitmapEx& rNew) 94cdf0e10cSrcweir { 95cdf0e10cSrcweir if(rNew != maBitmapEx1) 96cdf0e10cSrcweir { 97cdf0e10cSrcweir // remember new Bitmap 98cdf0e10cSrcweir maBitmapEx1 = rNew; 99cdf0e10cSrcweir 100cdf0e10cSrcweir // register change (after change) 101cdf0e10cSrcweir objectChange(); 102cdf0e10cSrcweir } 103cdf0e10cSrcweir } 104cdf0e10cSrcweir 105cdf0e10cSrcweir void OverlayAnimatedBitmapEx::setBitmapEx2(const BitmapEx& rNew) 106cdf0e10cSrcweir { 107cdf0e10cSrcweir if(rNew != maBitmapEx2) 108cdf0e10cSrcweir { 109cdf0e10cSrcweir // remember new Bitmap 110cdf0e10cSrcweir maBitmapEx2 = rNew; 111cdf0e10cSrcweir 112cdf0e10cSrcweir // register change (after change) 113cdf0e10cSrcweir objectChange(); 114cdf0e10cSrcweir } 115cdf0e10cSrcweir } 116cdf0e10cSrcweir 117cdf0e10cSrcweir void OverlayAnimatedBitmapEx::setCenterXY1(sal_uInt16 nNewX, sal_uInt16 nNewY) 118cdf0e10cSrcweir { 119cdf0e10cSrcweir if(nNewX != mnCenterX1 || nNewY != mnCenterY1) 120cdf0e10cSrcweir { 121cdf0e10cSrcweir // remember new values 122cdf0e10cSrcweir if(nNewX != mnCenterX1) 123cdf0e10cSrcweir { 124cdf0e10cSrcweir mnCenterX1 = nNewX; 125cdf0e10cSrcweir } 126cdf0e10cSrcweir 127cdf0e10cSrcweir if(nNewY != mnCenterY1) 128cdf0e10cSrcweir { 129cdf0e10cSrcweir mnCenterY1 = nNewY; 130cdf0e10cSrcweir } 131cdf0e10cSrcweir 132cdf0e10cSrcweir // register change (after change) 133cdf0e10cSrcweir objectChange(); 134cdf0e10cSrcweir } 135cdf0e10cSrcweir } 136cdf0e10cSrcweir 137cdf0e10cSrcweir void OverlayAnimatedBitmapEx::setCenterXY2(sal_uInt16 nNewX, sal_uInt16 nNewY) 138cdf0e10cSrcweir { 139cdf0e10cSrcweir if(nNewX != mnCenterX2 || nNewY != mnCenterY2) 140cdf0e10cSrcweir { 141cdf0e10cSrcweir // remember new values 142cdf0e10cSrcweir if(nNewX != mnCenterX2) 143cdf0e10cSrcweir { 144cdf0e10cSrcweir mnCenterX2 = nNewX; 145cdf0e10cSrcweir } 146cdf0e10cSrcweir 147cdf0e10cSrcweir if(nNewY != mnCenterY2) 148cdf0e10cSrcweir { 149cdf0e10cSrcweir mnCenterY2 = nNewY; 150cdf0e10cSrcweir } 151cdf0e10cSrcweir 152cdf0e10cSrcweir // register change (after change) 153cdf0e10cSrcweir objectChange(); 154cdf0e10cSrcweir } 155cdf0e10cSrcweir } 156cdf0e10cSrcweir 157cdf0e10cSrcweir void OverlayAnimatedBitmapEx::setBlinkTime(sal_uInt32 nNew) 158cdf0e10cSrcweir { 159cdf0e10cSrcweir if(mnBlinkTime != nNew) 160cdf0e10cSrcweir { 161cdf0e10cSrcweir // remember new value 162cdf0e10cSrcweir mnBlinkTime = nNew; 163cdf0e10cSrcweir 164cdf0e10cSrcweir // #i53216# check blink time value range 165*1cd65da9SArmin Le Grand mnBlinkTime = impCheckBlinkTimeValueRange(mnBlinkTime); 166cdf0e10cSrcweir 167cdf0e10cSrcweir // register change (after change) 168cdf0e10cSrcweir objectChange(); 169cdf0e10cSrcweir } 170cdf0e10cSrcweir } 171cdf0e10cSrcweir 172cdf0e10cSrcweir void OverlayAnimatedBitmapEx::Trigger(sal_uInt32 nTime) 173cdf0e10cSrcweir { 174cdf0e10cSrcweir if(getOverlayManager()) 175cdf0e10cSrcweir { 176cdf0e10cSrcweir // #i53216# produce event after nTime + x 177cdf0e10cSrcweir SetTime(nTime + mnBlinkTime); 178cdf0e10cSrcweir 179cdf0e10cSrcweir // switch state 180cdf0e10cSrcweir if(mbOverlayState) 181cdf0e10cSrcweir { 182cdf0e10cSrcweir mbOverlayState = false; 183cdf0e10cSrcweir } 184cdf0e10cSrcweir else 185cdf0e10cSrcweir { 186cdf0e10cSrcweir mbOverlayState = true; 187cdf0e10cSrcweir } 188cdf0e10cSrcweir 189cdf0e10cSrcweir // re-insert me as event 190cdf0e10cSrcweir getOverlayManager()->InsertEvent(this); 191cdf0e10cSrcweir 192cdf0e10cSrcweir // register change (after change) 193cdf0e10cSrcweir objectChange(); 194cdf0e10cSrcweir } 195cdf0e10cSrcweir } 196cdf0e10cSrcweir } // end of namespace overlay 197cdf0e10cSrcweir } // end of namespace sdr 198cdf0e10cSrcweir 199cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 200cdf0e10cSrcweir // eof 201