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