1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public 6 * License, v. 2.0. If a copy of the MPL was not distributed with this 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 11 * Licensed to the Apache Software Foundation (ASF) under one or more 12 * contributor license agreements. See the NOTICE file distributed 13 * with this work for additional information regarding copyright 14 * ownership. The ASF licenses this file to you under the Apache 15 * License, Version 2.0 (the "License"); you may not use this file 16 * except in compliance with the License. You may obtain a copy of 17 * the License at http://www.apache.org/licenses/LICENSE-2.0 . 18 */ 19 20 #ifndef INCLUDED_SVX_SDR_OVERLAY_OVERLAYMANAGER_HXX 21 #define INCLUDED_SVX_SDR_OVERLAY_OVERLAYMANAGER_HXX 22 23 #include <rtl/ref.hxx> 24 #include <svx/sdr/animation/scheduler.hxx> 25 #include <svx/sdr/overlay/overlayobject.hxx> 26 #include <tools/color.hxx> 27 #include <tools/gen.hxx> 28 #include <svx/svxdllapi.h> 29 #include <svtools/optionsdrawinglayer.hxx> 30 #include <basegfx/matrix/b2dhommatrix.hxx> 31 #include <drawinglayer/geometry/viewinformation2d.hxx> 32 #include <salhelper/simplereferenceobject.hxx> 33 34 class OutputDevice; 35 class SdrModel; 36 namespace vcl { class Region; } 37 38 namespace sdr { namespace overlay { 39 class OverlayObject; 40 }} 41 42 namespace basegfx { 43 class B2DRange; 44 } 45 46 namespace sdr 47 { 48 namespace overlay 49 { 50 class SVX_DLLPUBLIC OverlayManager 51 : protected sdr::animation::Scheduler 52 , public salhelper::SimpleReferenceObject 53 { 54 private: 55 OverlayManager(const OverlayManager&) = delete; 56 OverlayManager& operator=(const OverlayManager&) = delete; 57 58 protected: 59 // the OutputDevice to work on, set on construction and not to be changed 60 OutputDevice& mrOutputDevice; 61 62 // the vector of registered OverlayObjects 63 OverlayObjectVector maOverlayObjects; 64 65 // Stripe support. All striped OverlayObjects use these stripe 66 // values. Changes change all those objects. 67 Color maStripeColorA; // defaults to COL_BLACK 68 Color maStripeColorB; // defaults to COL_WHITE 69 sal_uInt32 mnStripeLengthPixel; // defaults to 4L 70 71 // hold an incarnation of Drawinglayer configuration options 72 SvtOptionsDrawinglayer const maDrawinglayerOpt; 73 74 // hold buffered the logic length of discrete vector (1.0, 0.0) and the 75 // view transformation belonging to it. Update happens in getDiscreteOne() 76 basegfx::B2DHomMatrix maViewTransformation; 77 drawinglayer::geometry::ViewInformation2D maViewInformation2D; 78 double mfDiscreteOne; 79 80 // internal 81 void ImpDrawMembers(const basegfx::B2DRange& rRange, OutputDevice& rDestinationDevice) const; 82 void ImpStripeDefinitionChanged(); 83 void impApplyRemoveActions(OverlayObject& rTarget); 84 void impApplyAddActions(OverlayObject& rTarget); 85 86 // return mfDiscreteOne to derivations, but also check for buffered local 87 // ViewTransformation and evtl. correct mfDiscreteOne 88 double getDiscreteOne() const; 89 90 tools::Rectangle RangeToInvalidateRectangle(const basegfx::B2DRange& rRange) const; 91 92 OverlayManager(OutputDevice& rOutputDevice); 93 virtual ~OverlayManager() override; 94 95 public: 96 static rtl::Reference<OverlayManager> create(OutputDevice& rOutputDevice); 97 98 // access to current ViewInformation2D; this call checks and evtl. updates ViewInformation2D 99 drawinglayer::geometry::ViewInformation2D const & getCurrentViewInformation2D() const; 100 101 // complete redraw 102 virtual void completeRedraw(const vcl::Region& rRegion, OutputDevice* pPreRenderDevice = nullptr) const; 103 104 // flush. Do buffered updates. 105 virtual void flush(); 106 107 // get the OutputDevice getOutputDevice() const108 OutputDevice& getOutputDevice() const { return mrOutputDevice; } 109 110 // add and remove OverlayObjects 111 void add(OverlayObject& rOverlayObject); 112 void remove(OverlayObject& rOverlayObject); 113 114 // invalidate the given range at local OutputDevice 115 virtual void invalidateRange(const basegfx::B2DRange& rRange); 116 117 // stripe support ColA getStripeColorA() const118 const Color& getStripeColorA() const { return maStripeColorA; } 119 void setStripeColorA(Color aNew); 120 121 // stripe support ColB getStripeColorB() const122 const Color& getStripeColorB() const { return maStripeColorB; } 123 void setStripeColorB(Color aNew); 124 125 // stripe support StripeLengthPixel getStripeLengthPixel() const126 sal_uInt32 getStripeLengthPixel() const { return mnStripeLengthPixel; } 127 void setStripeLengthPixel(sal_uInt32 nNew); 128 129 // access to maDrawinglayerOpt getDrawinglayerOpt() const130 const SvtOptionsDrawinglayer& getDrawinglayerOpt() const { return maDrawinglayerOpt; } 131 InsertEvent(sdr::animation::Event & rNew)132 void InsertEvent(sdr::animation::Event& rNew) { Scheduler::InsertEvent(rNew); } 133 }; 134 } // end of namespace overlay 135 } // end of namespace sdr 136 137 #endif // INCLUDED_SVX_SDR_OVERLAY_OVERLAYMANAGER_HXX 138 139 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 140