File indexing completed on 2024-05-12 15:56:41
0001 /* This file is part of the KDE project 0002 * SPDX-FileCopyrightText: 2008 Jan Hambrecht <jaham@gmx.net> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KOGRADIENTBACKGROUND_H 0008 #define KOGRADIENTBACKGROUND_H 0009 0010 #include "KoShapeBackground.h" 0011 #include "kritaflake_export.h" 0012 0013 #include <QTransform> 0014 #include <QSharedDataPointer> 0015 0016 class QGradient; 0017 0018 /// A gradient shape background 0019 class KRITAFLAKE_EXPORT KoGradientBackground : public KoShapeBackground 0020 { 0021 public: 0022 /** 0023 * Creates new gradient background from given gradient. 0024 * The background takes ownership of the given gradient. 0025 */ 0026 explicit KoGradientBackground(QGradient *gradient, const QTransform &matrix = QTransform()); 0027 0028 /** 0029 * Create new gradient background from the given gradient. 0030 * A clone of the given gradient is used. 0031 */ 0032 explicit KoGradientBackground(const QGradient &gradient, const QTransform &matrix = QTransform()); 0033 0034 /// Destroys the background 0035 ~KoGradientBackground() override; 0036 0037 // Work around MSVC inability to generate copy ops with QSharedDataPointer. 0038 KoGradientBackground(const KoGradientBackground &); 0039 KoGradientBackground &operator=(const KoGradientBackground &); 0040 0041 bool compareTo(const KoShapeBackground *other) const override; 0042 0043 /// Sets the transform matrix 0044 void setTransform(const QTransform &matrix); 0045 0046 /// Returns the transform matrix 0047 QTransform transform() const; 0048 0049 /** 0050 * Sets a new gradient. 0051 * A clone of the given gradient is used. 0052 */ 0053 void setGradient(const QGradient &gradient); 0054 0055 /// Returns the gradient 0056 const QGradient *gradient() const; 0057 0058 /// reimplemented from KoShapeBackground 0059 void paint(QPainter &painter, const QPainterPath &fillPath) const override; 0060 private: 0061 class Private; 0062 QSharedDataPointer<Private> d; 0063 }; 0064 0065 #endif // KOGRADIENTBACKGROUND_H