1 /* This file is part of the KDE project
2  *
3  * Copyright (C) 2006-2007 Thomas Zander <zander@kde.org>
4  * Copyright (C) 2006 Thorsten Zachmann <zachmann@kde.org>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB.  If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 #ifndef KOCREATESHAPESTOOL_H
23 #define KOCREATESHAPESTOOL_H
24 
25 #include "KoInteractionTool.h"
26 
27 #include "flake_export.h"
28 
29 #include <QString>
30 
31 class KoCanvasBase;
32 class KoProperties;
33 class KoCreateShapesToolPrivate;
34 
35 #define KoCreateShapesTool_ID "CreateShapesTool"
36 
37 /**
38  * A tool to create shapes with.
39  */
40 class FLAKE_EXPORT KoCreateShapesTool : public KoInteractionTool
41 {
42 Q_OBJECT
43 public:
44     /**
45      * Create a new tool; typically not called by applications, only by the KoToolManager
46      * @param canvas the canvas this tool works for.
47      */
48     explicit KoCreateShapesTool(KoCanvasBase *canvas);
49     /// destructor
50     ~KoCreateShapesTool() override;
51     void mouseReleaseEvent(KoPointerEvent *event) override;
52     void activate(ToolActivation toolActivation, const QSet<KoShape*> &shapes) override;
53 
54     void paint(QPainter &painter, const KoViewConverter &converter) override;
55 
56     /**
57      * Each shape-type has an Id; as found in KoShapeFactoryBase::id().id(), to choose which
58      * shape this controller should actually create; set the id before the user starts to
59      * create the new shape.
60      * @param id the SHAPEID of the to be generated shape
61      */
62     void setShapeId(const QString &id);
63     /**
64      * return the shape Id that is to be created.
65      * @return the shape Id that is to be created.
66      */
67     QString shapeId() const;
68 
69     /**
70      * Set the shape properties that the create controller will use for the next shape it will
71      * create. The tool does not take ownership of the object.
72      * @param properties the properties or 0 if the default shape should be created.
73      */
74     void setShapeProperties(const KoProperties *properties);
75     /**
76      * return the properties to be used for creating the next shape
77      * @return the properties to be used for creating the next shape
78      */
79     const KoProperties *shapeProperties();
80 
81 protected:
82     KoInteractionStrategy *createStrategy(KoPointerEvent *event) override;
83 
84 private:
85     Q_DECLARE_PRIVATE(KoCreateShapesTool)
86 };
87 
88 #endif
89