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