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 #ifndef _SDR_OVERLAY_OVERLAYOBJECT_HXX 25 #define _SDR_OVERLAY_OVERLAYOBJECT_HXX 26 27 #include <basegfx/point/b2dpoint.hxx> 28 #include <basegfx/range/b2drange.hxx> 29 #include <tools/color.hxx> 30 #include <svx/sdr/animation/scheduler.hxx> 31 #include "svx/svxdllapi.h" 32 #include <drawinglayer/primitive2d/baseprimitive2d.hxx> 33 34 #include <vector> 35 36 ////////////////////////////////////////////////////////////////////////////// 37 // predeclarations 38 39 class OutputDevice; 40 41 namespace sdr 42 { 43 namespace overlay 44 { 45 class OverlayManager; 46 } // end of namespace overlay 47 } // end of namespace sdr 48 49 namespace basegfx 50 { 51 class B2DPolygon; 52 class B2DPolyPolygon; 53 class B2DRange; 54 } // end of namespace basegfx 55 56 ////////////////////////////////////////////////////////////////////////////// 57 58 namespace sdr 59 { 60 namespace overlay 61 { 62 class SVX_DLLPUBLIC OverlayObject : private ::boost::noncopyable, public ::sdr::animation::Event 63 { 64 private: 65 // Manager is allowed access to private Member mpOverlayManager 66 friend class OverlayManager; 67 68 // pointer to OverlayManager, if object is added. Changed by 69 // OverlayManager, do not chnge Yourself. 70 OverlayManager* mpOverlayManager; 71 72 // Primitive2DSequence of the OverlayObject 73 drawinglayer::primitive2d::Primitive2DSequence maPrimitive2DSequence; 74 75 protected: 76 // access methods to maPrimitive2DSequence. The usage of this methods may allow 77 // later thread-safe stuff to be added if needed. Only to be used by getPrimitive2DSequence() 78 // implementations for buffering the last decomposition. getPrimitive2DSequence() const79 const drawinglayer::primitive2d::Primitive2DSequence& getPrimitive2DSequence() const { return maPrimitive2DSequence; } setPrimitive2DSequence(const drawinglayer::primitive2d::Primitive2DSequence & rNew)80 void setPrimitive2DSequence(const drawinglayer::primitive2d::Primitive2DSequence& rNew) { maPrimitive2DSequence = rNew; } 81 82 // the creation method for Primitive2DSequence. Called when getPrimitive2DSequence() 83 // sees that maPrimitive2DSequence is empty. Needs to be supported by all 84 // OverlayObject implementations. Default implementation will assert 85 // a missing implementation 86 virtual drawinglayer::primitive2d::Primitive2DSequence createOverlayObjectPrimitive2DSequence(); 87 88 // #i53216# check blink time value range (currently 25 < mnBlinkTime < 10000) 89 sal_uInt32 impCheckBlinkTimeValueRange(sal_uInt32 nBlinkTime) const; 90 91 // region in logical coordinates 92 basegfx::B2DRange maBaseRange; 93 94 // base color of this OverlayObject 95 Color maBaseColor; 96 97 // bitfield 98 // Flag for visibility 99 unsigned mbIsVisible : 1; 100 101 // Flag to control hittability 102 unsigned mbIsHittable : 1; 103 104 // Flag to hold info if this objects supports animation. Default is 105 // false. If true, the Trigger() method should be overloaded 106 // to implement the animation effect and to re-initiate the event. 107 unsigned mbAllowsAnimation : 1; 108 109 // Flag tocontrol if this OverlayObject allows AntiAliased visualisation. 110 // Default is true, but e.g. for selection visualisation in SC and SW, 111 // it is switched to false 112 unsigned mbAllowsAntiAliase : 1; 113 114 // set changed flag. Call after change, since the old range is invalidated 115 // and then the new one is calculated and invalidated, too. This will only 116 // work after the change. 117 virtual void objectChange(); 118 119 // write access to AntiAliase flag. This is protected since 120 // only implementations are allowed to change this, preferably in their 121 // constructor 122 void allowAntiAliase(bool bNew); 123 124 public: 125 OverlayObject(Color aBaseColor); 126 virtual ~OverlayObject(); 127 128 // get OverlayManager getOverlayManager() const129 OverlayManager* getOverlayManager() const { return mpOverlayManager; } 130 131 // the access method for Primitive2DSequence. Will use createPrimitive2DSequence and 132 // setPrimitive2DSequence if needed. Overloading may be used to allow disposal of last 133 // created primitives to react on changed circumstances and to re-create primitives 134 virtual drawinglayer::primitive2d::Primitive2DSequence getOverlayObjectPrimitive2DSequence() const; 135 136 // access to visibility state isVisible() const137 bool isVisible() const { return mbIsVisible; } 138 void setVisible(bool bNew); 139 140 // access to hittable flag isHittable() const141 bool isHittable() const { return mbIsHittable; } 142 void setHittable(bool bNew); 143 144 // read access to AntiAliase flag allowsAntiAliase() const145 bool allowsAntiAliase() const { return mbAllowsAntiAliase; } 146 147 // read access to baseRange. This may trigger createBaseRange() if 148 // object is changed. 149 const basegfx::B2DRange& getBaseRange() const; 150 151 // access to baseColor getBaseColor() const152 Color getBaseColor() const { return maBaseColor; } 153 void setBaseColor(Color aNew); 154 155 // execute event from base class ::sdr::animation::Event. Default 156 // implementation does nothing and does not create a new event. 157 virtual void Trigger(sal_uInt32 nTime); 158 159 // access to AllowsAnimation flag allowsAnimation() const160 bool allowsAnimation() const { return mbAllowsAnimation; } 161 162 // stripe definition has changed. The OverlayManager does have 163 // support data to draw graphics in two colors striped. This 164 // method notifies the OverlayObject if that change takes place. 165 // Default implementation does nothing. 166 virtual void stripeDefinitionHasChanged(); 167 }; 168 169 // typedefs for a vector of OverlayObjects 170 typedef ::std::vector< OverlayObject* > OverlayObjectVector; 171 172 } // end of namespace overlay 173 } // end of namespace sdr 174 175 ////////////////////////////////////////////////////////////////////////////// 176 177 namespace sdr 178 { 179 namespace overlay 180 { 181 class SVX_DLLPUBLIC OverlayObjectWithBasePosition : public OverlayObject 182 { 183 protected: 184 // base position in logical coordinates 185 basegfx::B2DPoint maBasePosition; 186 187 public: 188 OverlayObjectWithBasePosition(const basegfx::B2DPoint& rBasePos, Color aBaseColor); 189 virtual ~OverlayObjectWithBasePosition(); 190 191 // access to basePosition getBasePosition() const192 const basegfx::B2DPoint& getBasePosition() const { return maBasePosition; } 193 void setBasePosition(const basegfx::B2DPoint& rNew); 194 }; 195 } // end of namespace overlay 196 } // end of namespace sdr 197 198 ////////////////////////////////////////////////////////////////////////////// 199 200 #endif //_SDR_OVERLAY_OVERLAYOBJECT_HXX 201 202 // eof 203