Warning, file /office/calligra/libs/flake/KoPatternBackground.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2008 Jan Hambrecht <jaham@gmx.net>
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Library General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2 of the License, or (at your option) any later version.
0008  *
0009  * This library is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012  * Library General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU Library General Public License
0015  * along with this library; see the file COPYING.LIB.  If not, write to
0016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018  */
0019 
0020 #ifndef KOPATTERNBACKGROUND_H
0021 #define KOPATTERNBACKGROUND_H
0022 
0023 #include "KoShapeBackground.h"
0024 #include "flake_export.h"
0025 
0026 class KoImageCollection;
0027 class KoOdfLoadingContext;
0028 class KoPatternBackgroundPrivate;
0029 class KoImageData;
0030 
0031 class QTransform;
0032 class QImage;
0033 class QPointF;
0034 class QRectF;
0035 
0036 /// A pattern shape background
0037 class FLAKE_EXPORT KoPatternBackground : public KoShapeBackground
0038 {
0039 public:
0040     /// Pattern rendering style
0041     enum PatternRepeat {
0042         Original,
0043         Tiled,
0044         Stretched
0045     };
0046     /// Pattern reference point
0047     enum ReferencePoint {
0048         TopLeft,
0049         Top,
0050         TopRight,
0051         Left,
0052         Center,
0053         Right,
0054         BottomLeft,
0055         Bottom,
0056         BottomRight
0057     };
0058 
0059     /// Constructs a new pattern background utilizing the given image collection
0060     explicit KoPatternBackground(KoImageCollection *collection);
0061 
0062     ~KoPatternBackground() override;
0063 
0064     /// Sets the transform matrix
0065     void setTransform(const QTransform &matrix);
0066 
0067     /// Returns the transform matrix
0068     QTransform transform() const;
0069 
0070     /// Sets a new pattern
0071     void setPattern(const QImage &pattern);
0072 
0073     /// Sets a new pattern. imageData memory is deleted inside this class
0074     void setPattern(KoImageData *imageData);
0075 
0076     /// Returns the pattern
0077     QImage pattern() const;
0078 
0079     /// Sets the pattern repeatgfl
0080     void setRepeat(PatternRepeat repeat);
0081 
0082     /// Returns the pattern repeat
0083     PatternRepeat repeat() const;
0084 
0085     /// Returns the pattern reference point identifier
0086     ReferencePoint referencePoint() const;
0087 
0088     /// Sets the pattern reference point
0089     void setReferencePoint(ReferencePoint referencePoint);
0090 
0091     /// Returns reference point offset in percent of the pattern display size
0092     QPointF referencePointOffset() const;
0093 
0094     /// Sets the reference point offset in percent of the pattern display size
0095     void setReferencePointOffset(const QPointF &offset);
0096 
0097     /// Returns tile repeat offset in percent of the pattern display size
0098     QPointF tileRepeatOffset() const;
0099 
0100     /// Sets the tile repeat offset in percent of the pattern display size
0101     void setTileRepeatOffset(const QPointF &offset);
0102 
0103     /// Returns the pattern display size
0104     QSizeF patternDisplaySize() const;
0105 
0106     /// Sets pattern display size
0107     void setPatternDisplaySize(const QSizeF &size);
0108 
0109     /// Returns the original image size
0110     QSizeF patternOriginalSize() const;
0111 
0112     /// reimplemented from KoShapeBackground
0113     void paint(QPainter &painter, const KoViewConverter &converter, KoShapePaintingContext &context, const QPainterPath &fillPath) const override;
0114     /// reimplemented from KoShapeBackground
0115     void fillStyle(KoGenStyle &style, KoShapeSavingContext &context) override;
0116     /// reimplemented from KoShapeBackground
0117     bool loadStyle(KoOdfLoadingContext &context, const QSizeF &shapeSize) override;
0118 
0119     /// Returns the bounding rect of the pattern image based on the given fill size
0120     QRectF patternRectFromFillSize(const QSizeF &size);
0121 private:
0122     Q_DECLARE_PRIVATE(KoPatternBackground)
0123     Q_DISABLE_COPY(KoPatternBackground)
0124 };
0125 
0126 #endif // KOPATTERNBACKGROUND_H