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