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