LibreOffice Module svx (master) 1
overlayobject.hxx
Go to the documentation of this file.
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
25#include <tools/color.hxx>
27#include <svx/svxdllapi.h>
29
30#include <vector>
31
32class OutputDevice;
33
34namespace sdr::overlay
35{
36 class OverlayManager;
37}
38namespace basegfx
39{
40 class B2DPolygon;
41 class B2DPolyPolygon;
42 class B2DRange;
43}
44
45namespace sdr::overlay
46 {
48 {
49 private:
50 OverlayObject(const OverlayObject&) = delete;
52
53 // Manager is allowed access to private Member mpOverlayManager
54 friend class OverlayManager;
55
56 // pointer to OverlayManager, if object is added. Changed by
57 // OverlayManager, do not change Yourself.
59
60 // Primitive2DContainer of the OverlayObject
62
63 // Possible Offset added to the geometry (automatically in
64 // createOverlayObjectPrimitive2DSequence()). Usually zero, may
65 // be used e.g. from calc when GridOffset is needed
67
68 protected:
69 // access methods to maPrimitive2DSequence. The usage of this methods may allow
70 // later thread-safe stuff to be added if needed. Only to be used by getPrimitive2DSequence()
71 // implementations for buffering the last decomposition.
72 // Resetting is allowed e.g. in ::getOverlayObjectPrimitive2DSequence() implementations
73 // if the conditions have changed to force a re-creation in calling the base implementation.
74 // The only allowed setter of maPrimitive2DSequence is
75 // OverlayObject::getOverlayObjectPrimitive2DSequence() which should be called by calling
76 // the base implementation in derived functions. That one will use the result of
77 // createOverlayObjectPrimitive2DSequence() to provide the geometry.
78 const drawinglayer::primitive2d::Primitive2DContainer& getPrimitive2DSequence() const { return maPrimitive2DSequence; }
79 void resetPrimitive2DSequence() { maPrimitive2DSequence.clear(); }
80
81 // the creation method for Primitive2DContainer. Called when getPrimitive2DSequence()
82 // sees that maPrimitive2DSequence is empty. Needs to be supported by all
83 // OverlayObject implementations. Default implementation will assert
84 // a missing implementation
85 virtual drawinglayer::primitive2d::Primitive2DContainer createOverlayObjectPrimitive2DSequence();
86
87 // #i53216# check blink time value range (currently 25 < mnBlinkTime < 10000)
88 static sal_uInt32 impCheckBlinkTimeValueRange(sal_uInt64 nBlinkTime);
89
90 // region in logical coordinates
92
93 // base color of this OverlayObject
95
96 // Flag for visibility
97 bool mbIsVisible : 1;
98
99 // Flag to control hittability
100 bool mbIsHittable : 1;
101
102 // Flag to hold info if this objects supports animation. Default is
103 // false. If true, the Trigger() method should be overridden
104 // to implement the animation effect and to re-initiate the event.
106
107 // Flag to control if this OverlayObject allows AntiAliased visualisation.
108 // Default is true, but e.g. for selection visualisation in SC and SW,
109 // it is switched to false
111
112 // In High Contrast mode all fg and bg are forced to a pair of normal
113 // high contrast colors. If this flag is set, then in High Contrast mode
114 // the colors are instead forced to the high contrast selection fg/bg pair.
115 // Default is false.
117
118 // set changed flag. Call after change, since the old range is invalidated
119 // and then the new one is calculated and invalidated, too. This will only
120 // work after the change.
121 void objectChange();
122
123 // write access to AntiAliase flag. This is protected since
124 // only implementations are allowed to change this, preferably in their
125 // constructor
126 void allowAntiAliase(bool bNew);
127
128 public:
129 explicit OverlayObject(Color aBaseColor);
130 virtual ~OverlayObject() override;
131
132 // get OverlayManager
133 OverlayManager* getOverlayManager() const { return mpOverlayManager; }
134
135 // the access method for Primitive2DContainer. Will use createPrimitive2DSequence and
136 // setPrimitive2DSequence if needed. Overriding may be used to allow disposal of last
137 // created primitives to react on changed circumstances and to re-create primitives
138 virtual drawinglayer::primitive2d::Primitive2DContainer getOverlayObjectPrimitive2DSequence() const;
139
140 // access to visibility state
141 bool isVisible() const { return mbIsVisible; }
142 void setVisible(bool bNew);
143
144 // access to hittable flag
145 bool isHittable() const { return mbIsHittable; }
146 void setHittable(bool bNew);
147
148 // read access to AntiAliase flag
149 bool allowsAntiAliase() const { return mbAllowsAntiAliase; }
150
151 // read access to DrawModeSettings flag
152 bool isHighContrastSelection() const { return mbHighContrastSelection; }
153
154 // read access to baseRange. This may trigger createBaseRange() if
155 // object is changed.
156 const basegfx::B2DRange& getBaseRange() const;
157
158 // access to baseColor
159 const Color& getBaseColor() const { return maBaseColor; }
160 void setBaseColor(Color aNew);
161
162 // access to Offset
163 const basegfx::B2DVector& getOffset() const { return maOffset; }
164 void setOffset(const basegfx::B2DVector& rOffset);
165
166 // execute event from base class sdr::animation::Event. Default
167 // implementation does nothing and does not create a new event.
168 virtual void Trigger(sal_uInt32 nTime) override;
169
170 // access to AllowsAnimation flag
171 bool allowsAnimation() const { return mbAllowsAnimation; }
172
173 // stripe definition has changed. The OverlayManager does have
174 // support data to draw graphics in two colors striped. This
175 // method notifies the OverlayObject if that change takes place.
176 // Default implementation does nothing.
177 virtual void stripeDefinitionHasChanged();
178 };
179
180 // typedefs for a vector of OverlayObjects
181 typedef ::std::vector< OverlayObject* > OverlayObjectVector;
182
183} // end of namespace sdr::overlay
184
185namespace sdr::overlay
186 {
188 {
189 protected:
190 // base position in logical coordinates
192
193 public:
194 OverlayObjectWithBasePosition(const basegfx::B2DPoint& rBasePos, Color aBaseColor);
195 virtual ~OverlayObjectWithBasePosition() override;
196
197 // access to basePosition
199 void setBasePosition(const basegfx::B2DPoint& rNew);
200 };
201
202} // end of namespace sdr::overlay
203
204#endif // INCLUDED_SVX_SDR_OVERLAY_OVERLAYOBJECT_HXX
205
206/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
basegfx::B2DPoint maBasePosition
const basegfx::B2DPoint & getBasePosition() const
drawinglayer::primitive2d::Primitive2DContainer maPrimitive2DSequence
const basegfx::B2DVector & getOffset() const
const Color & getBaseColor() const
OverlayObject & operator=(const OverlayObject &)=delete
basegfx::B2DRange maBaseRange
OverlayManager * getOverlayManager() const
OverlayManager * mpOverlayManager
basegfx::B2DVector maOffset
const drawinglayer::primitive2d::Primitive2DContainer & getPrimitive2DSequence() const
OverlayObject(const OverlayObject &)=delete
::std::vector< OverlayObject * > OverlayObjectVector
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35