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_INC_SDR_OVERLAY_OVERLAYTOOLS_HXX
21 : #define INCLUDED_SVX_INC_SDR_OVERLAY_OVERLAYTOOLS_HXX
22 :
23 : #include <drawinglayer/primitive2d/primitivetools2d.hxx>
24 : #include <vcl/bitmapex.hxx>
25 :
26 :
27 : // Overlay helper class which holds a BotmapEx which is to be visualized
28 : // at the given logic position with the Bitmap's pixel size, unscaled and
29 : // unrotated (like a marker). The discrete pixel on the bitmap assocciated
30 : // with the target position is given in discrete X,Y coordinates
31 : namespace drawinglayer
32 : {
33 : namespace primitive2d
34 : {
35 980 : class OverlayBitmapExPrimitive : public DiscreteMetricDependentPrimitive2D
36 : {
37 : private:
38 : // The BitmapEx to use, PixelSize is used
39 : BitmapEx maBitmapEx;
40 :
41 : // The logic position
42 : basegfx::B2DPoint maBasePosition;
43 :
44 : // The pixel inside the BitmapEx which is assocciated with
45 : // the target position (offset in the bitmap)
46 : sal_uInt16 mnCenterX;
47 : sal_uInt16 mnCenterY;
48 :
49 : // evtl. rotation and shear around center
50 : double mfShearX;
51 : double mfRotation;
52 :
53 : protected:
54 : virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const SAL_OVERRIDE;
55 :
56 : public:
57 : OverlayBitmapExPrimitive(
58 : const BitmapEx& rBitmapEx,
59 : const basegfx::B2DPoint& rBasePosition,
60 : sal_uInt16 nCenterX,
61 : sal_uInt16 nCenterY,
62 : double fShearX = 0.0,
63 : double fRotation = 0.0);
64 :
65 : // data access
66 980 : const BitmapEx& getBitmapEx() const { return maBitmapEx; }
67 980 : const basegfx::B2DPoint& getBasePosition() const { return maBasePosition; }
68 980 : sal_uInt16 getCenterX() const { return mnCenterX; }
69 980 : sal_uInt16 getCenterY() const { return mnCenterY; }
70 490 : double getShearX() const { return mfShearX; }
71 490 : double getRotation() const { return mfRotation; }
72 :
73 : // compare operator
74 : virtual bool operator==( const BasePrimitive2D& rPrimitive ) const SAL_OVERRIDE;
75 :
76 : DeclPrimitive2DIDBlock()
77 : };
78 : } // end of namespace primitive2d
79 : } // end of namespace drawinglayer
80 :
81 :
82 : // Overlay helper class for a crosshair
83 : namespace drawinglayer
84 : {
85 : namespace primitive2d
86 : {
87 0 : class OverlayCrosshairPrimitive : public ViewportDependentPrimitive2D
88 : {
89 : private:
90 : // The logic position
91 : basegfx::B2DPoint maBasePosition;
92 :
93 : // The stripe colors and legth
94 : basegfx::BColor maRGBColorA;
95 : basegfx::BColor maRGBColorB;
96 : double mfDiscreteDashLength;
97 :
98 : protected:
99 : virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const SAL_OVERRIDE;
100 :
101 : public:
102 : OverlayCrosshairPrimitive(
103 : const basegfx::B2DPoint& rBasePosition,
104 : const basegfx::BColor& rRGBColorA,
105 : const basegfx::BColor& rRGBColorB,
106 : double fDiscreteDashLength);
107 :
108 : // data access
109 0 : const basegfx::B2DPoint& getBasePosition() const { return maBasePosition; }
110 0 : const basegfx::BColor& getRGBColorA() const { return maRGBColorA; }
111 0 : const basegfx::BColor& getRGBColorB() const { return maRGBColorB; }
112 0 : double getDiscreteDashLength() const { return mfDiscreteDashLength; }
113 :
114 : // compare operator
115 : virtual bool operator==( const BasePrimitive2D& rPrimitive ) const SAL_OVERRIDE;
116 :
117 : DeclPrimitive2DIDBlock()
118 : };
119 : } // end of namespace primitive2d
120 : } // end of namespace drawinglayer
121 :
122 :
123 : // Overlay helper class for a hatch rectangle as used e.g. for text object
124 : // selection hilighting
125 : namespace drawinglayer
126 : {
127 : namespace primitive2d
128 : {
129 0 : class OverlayRectanglePrimitive : public DiscreteMetricDependentPrimitive2D
130 : {
131 : private:
132 : // the logic rectangle definition
133 : basegfx::B2DRange maObjectRange;
134 :
135 : // the graphic definition
136 : basegfx::BColor maColor;
137 : double mfTransparence;
138 :
139 : // the dscrete grow and shrink of the box
140 : double mfDiscreteGrow;
141 : double mfDiscreteShrink;
142 :
143 : // the rotation of the primitive itself
144 : double mfRotation;
145 :
146 : protected:
147 : virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const SAL_OVERRIDE;
148 :
149 : public:
150 : OverlayRectanglePrimitive(
151 : const basegfx::B2DRange& rObjectRange,
152 : const basegfx::BColor& rColor,
153 : double fTransparence,
154 : double fDiscreteGrow,
155 : double fDiscreteShrink,
156 : double fRotation);
157 :
158 : // data access
159 0 : const basegfx::B2DRange& getObjectRange() const { return maObjectRange; }
160 0 : const basegfx::BColor& getColor() const { return maColor; }
161 0 : double getTransparence() const { return mfTransparence; }
162 0 : double getDiscreteGrow() const { return mfDiscreteGrow; }
163 0 : double getDiscreteShrink() const { return mfDiscreteShrink; }
164 0 : double getRotation() const { return mfRotation; }
165 :
166 : // compare operator
167 : virtual bool operator==( const BasePrimitive2D& rPrimitive ) const SAL_OVERRIDE;
168 :
169 : DeclPrimitive2DIDBlock()
170 : };
171 : } // end of namespace primitive2d
172 : } // end of namespace drawinglayer
173 :
174 :
175 : // Overlay helper class for a striped helpline
176 :
177 : namespace drawinglayer
178 : {
179 : namespace primitive2d
180 : {
181 : enum HelplineStyle
182 : {
183 : HELPLINESTYLE_POINT,
184 : HELPLINESTYLE_VERTICAL,
185 : HELPLINESTYLE_HORIZONTAL
186 : };
187 :
188 0 : class OverlayHelplineStripedPrimitive : public ViewportDependentPrimitive2D
189 : {
190 : private:
191 : // The logic position
192 : basegfx::B2DPoint maBasePosition;
193 :
194 : // the style
195 : HelplineStyle meStyle;
196 :
197 : // The stripe colors and legth
198 : basegfx::BColor maRGBColorA;
199 : basegfx::BColor maRGBColorB;
200 : double mfDiscreteDashLength;
201 :
202 : protected:
203 : virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const SAL_OVERRIDE;
204 :
205 : public:
206 : OverlayHelplineStripedPrimitive(
207 : const basegfx::B2DPoint& rBasePosition,
208 : HelplineStyle eStyle,
209 : const basegfx::BColor& rRGBColorA,
210 : const basegfx::BColor& rRGBColorB,
211 : double fDiscreteDashLength);
212 :
213 : // data access
214 0 : const basegfx::B2DPoint& getBasePosition() const { return maBasePosition; }
215 0 : HelplineStyle getStyle() const { return meStyle; }
216 0 : const basegfx::BColor& getRGBColorA() const { return maRGBColorA; }
217 0 : const basegfx::BColor& getRGBColorB() const { return maRGBColorB; }
218 0 : double getDiscreteDashLength() const { return mfDiscreteDashLength; }
219 :
220 : // compare operator
221 : virtual bool operator==( const BasePrimitive2D& rPrimitive ) const SAL_OVERRIDE;
222 :
223 : DeclPrimitive2DIDBlock()
224 : };
225 : } // end of namespace primitive2d
226 : } // end of namespace drawinglayer
227 :
228 :
229 : // Overlay helper class for rolling rectangle helplines. This primitive is
230 : // only for the extended lines to the ends of the view
231 :
232 : namespace drawinglayer
233 : {
234 : namespace primitive2d
235 : {
236 0 : class OverlayRollingRectanglePrimitive : public ViewportDependentPrimitive2D
237 : {
238 : private:
239 : // The logic range
240 : basegfx::B2DRange maRollingRectangle;
241 :
242 : // The stripe colors and legth
243 : basegfx::BColor maRGBColorA;
244 : basegfx::BColor maRGBColorB;
245 : double mfDiscreteDashLength;
246 :
247 : protected:
248 : virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const SAL_OVERRIDE;
249 :
250 : public:
251 : OverlayRollingRectanglePrimitive(
252 : const basegfx::B2DRange& aRollingRectangle,
253 : const basegfx::BColor& rRGBColorA,
254 : const basegfx::BColor& rRGBColorB,
255 : double fDiscreteDashLength);
256 :
257 : // data access
258 0 : const basegfx::B2DRange& getRollingRectangle() const { return maRollingRectangle; }
259 0 : const basegfx::BColor& getRGBColorA() const { return maRGBColorA; }
260 0 : const basegfx::BColor& getRGBColorB() const { return maRGBColorB; }
261 0 : double getDiscreteDashLength() const { return mfDiscreteDashLength; }
262 :
263 : // compare operator
264 : virtual bool operator==( const BasePrimitive2D& rPrimitive ) const SAL_OVERRIDE;
265 :
266 : DeclPrimitive2DIDBlock()
267 : };
268 : } // end of namespace primitive2d
269 : } // end of namespace drawinglayer
270 :
271 :
272 :
273 : #endif // INCLUDED_SVX_INC_SDR_OVERLAY_OVERLAYTOOLS_HXX
274 :
275 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|