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