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_OVERLAYMANAGER_HXX
25 #define _SDR_OVERLAY_OVERLAYMANAGER_HXX
26 
27 #include <svx/sdr/animation/scheduler.hxx>
28 #include <svx/sdr/overlay/overlayobject.hxx>
29 #include <vcl/mapmod.hxx>
30 #include <tools/color.hxx>
31 #include "svx/svxdllapi.h"
32 #include <svtools/optionsdrawinglayer.hxx>
33 #include <basegfx/matrix/b2dhommatrix.hxx>
34 #include <drawinglayer/geometry/viewinformation2d.hxx>
35 
36 //////////////////////////////////////////////////////////////////////////////
37 // predeclarations
38 
39 class OutputDevice;
40 class Region;
41 
42 namespace sdr { namespace overlay {
43     class OverlayObject;
44 }}
45 
46 namespace basegfx {
47 	class B2DRange;
48 }
49 
50 //////////////////////////////////////////////////////////////////////////////
51 
52 namespace sdr
53 {
54 	namespace overlay
55 	{
56 		class SVX_DLLPUBLIC OverlayManager : public ::sdr::animation::Scheduler
57 		{
58 		protected:
59 			// the OutputDevice to work on, set on construction and not to be changed
60 			OutputDevice&							    rmOutputDevice;
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 Color(COL_BLACK)
68 			Color									    maStripeColorB; // defaults to Color(COL_WHITE)
69 			sal_uInt32								    mnStripeLengthPixel; // defaults to 4L
70 
71 			// hold an incarnation of Drawinglayer configuration options
72 			SvtOptionsDrawinglayer				    	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 		public:
91 			OverlayManager(OutputDevice& rOutputDevice);
92 			virtual ~OverlayManager();
93 
94 			// access to current ViewInformation2D; this call checks and evtl. updates ViewInformation2D
95 			const drawinglayer::geometry::ViewInformation2D getCurrentViewInformation2D() const;
96 
97 			// complete redraw
98 			virtual void completeRedraw(const Region& rRegion, OutputDevice* pPreRenderDevice = 0) const;
99 
100 			// flush. Do buffered updates.
101 			virtual void flush();
102 
103 			// #i68597# part of content gets copied, react on it
104 			virtual void copyArea(const Point& rDestPt, const Point& rSrcPt, const Size& rSrcSize);
105 
106 			// restore part of background. Implemented form buffered versions only.
107 			virtual void restoreBackground(const Region& rRegion) const;
108 
109 			// get the OutputDevice
getOutputDevice() const110 			OutputDevice& getOutputDevice() const { return rmOutputDevice; }
111 
112 			// add and remove OverlayObjects
113 			void add(OverlayObject& rOverlayObject);
114 			void remove(OverlayObject& rOverlayObject);
115 
116 			// invalidate the given range at local OutputDevice
117 			virtual void invalidateRange(const basegfx::B2DRange& rRange);
118 
119 			// stripe support ColA
getStripeColorA() const120 			Color getStripeColorA() const { return maStripeColorA; }
121 			void setStripeColorA(Color aNew= Color(COL_BLACK));
122 
123 			// stripe support ColB
getStripeColorB() const124 			Color getStripeColorB() const { return maStripeColorB; }
125 			void setStripeColorB(Color aNew = Color(COL_WHITE));
126 
127 			// stripe support StripeLengthPixel
getStripeLengthPixel() const128 			sal_uInt32 getStripeLengthPixel() const { return mnStripeLengthPixel; }
129 			void setStripeLengthPixel(sal_uInt32 nNew = 5L);
130 
131             // access to maDrawinglayerOpt
getDrawinglayerOpt() const132             const SvtOptionsDrawinglayer& getDrawinglayerOpt() const { return maDrawinglayerOpt; }
133 		};
134 	} // end of namespace overlay
135 } // end of namespace sdr
136 
137 //////////////////////////////////////////////////////////////////////////////
138 
139 #endif //_SDR_OVERLAY_OVERLAYMANAGER_HXX
140 
141 // eof
142