1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SVX_SDR_OVERLAY_OVERLAYOBJECT_HXX
21 #define INCLUDED_SVX_SDR_OVERLAY_OVERLAYOBJECT_HXX
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>
40 } // end of namespace overlay
54 class SVX_DLLPUBLIC OverlayObject
: public sdr::animation::Event
57 OverlayObject(const OverlayObject
&) SAL_DELETED_FUNCTION
;
58 OverlayObject
& operator=(const OverlayObject
&) SAL_DELETED_FUNCTION
;
60 // Manager is allowed access to private Member mpOverlayManager
61 friend class OverlayManager
;
63 // pointer to OverlayManager, if object is added. Changed by
64 // OverlayManager, do not chnge Yourself.
65 OverlayManager
* mpOverlayManager
;
67 // Primitive2DSequence of the OverlayObject
68 drawinglayer::primitive2d::Primitive2DSequence maPrimitive2DSequence
;
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 const drawinglayer::primitive2d::Primitive2DSequence
& getPrimitive2DSequence() const { return maPrimitive2DSequence
; }
75 void setPrimitive2DSequence(const drawinglayer::primitive2d::Primitive2DSequence
& rNew
) { maPrimitive2DSequence
= rNew
; }
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();
83 // #i53216# check blink time value range (currently 25 < mnBlinkTime < 10000)
84 static sal_uInt32
impCheckBlinkTimeValueRange(sal_uInt64 nBlinkTime
);
86 // region in logical coordinates
87 basegfx::B2DRange maBaseRange
;
89 // base color of this OverlayObject
93 // Flag for visibility
96 // Flag to control hittability
97 bool mbIsHittable
: 1;
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;
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;
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.
114 // write access to AntiAliase flag. This is protected since
115 // only implementations are allowed to change this, preferably in their
117 void allowAntiAliase(bool bNew
);
120 explicit OverlayObject(Color aBaseColor
);
121 virtual ~OverlayObject();
123 // get OverlayManager
124 OverlayManager
* getOverlayManager() const { return mpOverlayManager
; }
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;
131 // access to visibility state
132 bool isVisible() const { return mbIsVisible
; }
133 void setVisible(bool bNew
);
135 // access to hittable flag
136 bool isHittable() const { return mbIsHittable
; }
137 void setHittable(bool bNew
);
139 // read access to AntiAliase flag
140 bool allowsAntiAliase() const { return mbAllowsAntiAliase
; }
142 // read access to baseRange. This may trigger createBaseRange() if
143 // object is changed.
144 const basegfx::B2DRange
& getBaseRange() const;
146 // access to baseColor
147 Color
getBaseColor() const { return maBaseColor
; }
148 void setBaseColor(Color aNew
);
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
;
154 // access to AllowsAnimation flag
155 bool allowsAnimation() const { return mbAllowsAnimation
; }
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();
164 // typedefs for a vector of OverlayObjects
165 typedef ::std::vector
< OverlayObject
* > OverlayObjectVector
;
167 } // end of namespace overlay
168 } // end of namespace sdr
174 class SVX_DLLPUBLIC OverlayObjectWithBasePosition
: public OverlayObject
177 // base position in logical coordinates
178 basegfx::B2DPoint maBasePosition
;
181 OverlayObjectWithBasePosition(const basegfx::B2DPoint
& rBasePos
, Color aBaseColor
);
182 virtual ~OverlayObjectWithBasePosition();
184 // access to basePosition
185 const basegfx::B2DPoint
& getBasePosition() const { return maBasePosition
; }
186 void setBasePosition(const basegfx::B2DPoint
& rNew
);
188 } // end of namespace overlay
189 } // end of namespace sdr
191 #endif // INCLUDED_SVX_SDR_OVERLAY_OVERLAYOBJECT_HXX
193 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */