File indexing completed on 2024-05-12 15:56:50
0001 /* This file is part of the KDE project 0002 * 0003 * SPDX-FileCopyrightText: 2006-2007 Thomas Zander <zander@kde.org> 0004 * SPDX-FileCopyrightText: 2006-2008 Jan Hambrecht <jaham@gmx.net> 0005 * SPDX-FileCopyrightText: 2007, 2009 Thorsten Zachmann <zachmann@kde.org> 0006 * SPDX-FileCopyrightText: 2012 Inge Wallin <inge@lysator.liu.se> 0007 * 0008 * SPDX-License-Identifier: LGPL-2.0-or-later 0009 */ 0010 0011 #ifndef KOSHAPESTROKE_H 0012 #define KOSHAPESTROKE_H 0013 0014 #include "KoFlakeTypes.h" 0015 #include "KoShapeStrokeModel.h" 0016 0017 #include "kritaflake_export.h" 0018 0019 #include <QMetaType> 0020 #include <QColor> 0021 0022 0023 class KoShape; 0024 class QPainter; 0025 class QBrush; 0026 class QPen; 0027 struct KoInsets; 0028 0029 /** 0030 * A border for shapes that draws a single line around the object. 0031 */ 0032 class KRITAFLAKE_EXPORT KoShapeStroke : public KoShapeStrokeModel 0033 { 0034 public: 0035 /// Constructor for a thin line in black 0036 KoShapeStroke(); 0037 0038 /// Copy constructor 0039 KoShapeStroke(const KoShapeStroke &other); 0040 0041 /** 0042 * Constructor for a Stroke 0043 * @param lineWidth the width, in pt 0044 * @param color the color we draw the outline in. 0045 */ 0046 explicit KoShapeStroke(qreal lineWidth, const QColor &color = Qt::black); 0047 ~KoShapeStroke() override; 0048 0049 /// Assignment operator 0050 KoShapeStroke& operator = (const KoShapeStroke &rhs); 0051 0052 /// Sets the lines cap style 0053 void setCapStyle(Qt::PenCapStyle style); 0054 /// Returns the lines cap style 0055 Qt::PenCapStyle capStyle() const; 0056 /// Sets the lines join style 0057 void setJoinStyle(Qt::PenJoinStyle style); 0058 /// Returns the lines join style 0059 Qt::PenJoinStyle joinStyle() const; 0060 /// Sets the line width 0061 void setLineWidth(qreal lineWidth); 0062 /// Returns the line width 0063 qreal lineWidth() const; 0064 /// Sets the miter limit 0065 void setMiterLimit(qreal miterLimit); 0066 /// Returns the miter limit 0067 qreal miterLimit() const; 0068 /// Sets the line style 0069 void setLineStyle(Qt::PenStyle style, const QVector<qreal> &dashes); 0070 /// Returns the line style 0071 Qt::PenStyle lineStyle() const; 0072 /// Returns the line dashes 0073 QVector<qreal> lineDashes() const; 0074 /// Sets the dash offset 0075 void setDashOffset(qreal dashOffset); 0076 /// Returns the dash offset 0077 qreal dashOffset() const; 0078 0079 /// Returns the color 0080 QColor color() const; 0081 /// Sets the color 0082 void setColor(const QColor &color); 0083 0084 /// Sets the strokes brush used to fill strokes of this border 0085 void setLineBrush(const QBrush & brush); 0086 /// Returns the strokes brush 0087 QBrush lineBrush() const; 0088 0089 // pure virtuals from KoShapeStrokeModel implemented here. 0090 void strokeInsets(const KoShape *shape, KoInsets &insets) const override; 0091 qreal strokeMaxMarkersInset(const KoShape *shape) const override; 0092 bool hasTransparency() const override; 0093 void paint(const KoShape *shape, QPainter &painter) const override; 0094 0095 QPen resultLinePen() const; 0096 0097 bool compareFillTo(const KoShapeStrokeModel *other) override; 0098 bool compareStyleTo(const KoShapeStrokeModel *other) override; 0099 bool isVisible() const override; 0100 0101 private: 0102 class Private; 0103 Private * const d; 0104 }; 0105 0106 Q_DECLARE_METATYPE( KoShapeStroke ) 0107 0108 #endif // KOSHAPESTROKE_H