chalk

kis_tool.h
1/*
2 * Copyright (c) 1999 Matthias Elter <me@kde.org>
3 * Copyright (c) 2002, 2003 Patrick Julien <freak@codepimps.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20#ifndef KIS_TOOL_H_
21#define KIS_TOOL_H_
22
23#include <tqobject.h>
24#include <tqstring.h>
25
26#include <ksharedptr.h>
27#include <tdeaction.h>
28
29#include "kis_shared_ptr_vector.h"
30#include "kis_canvas_observer.h"
31
32class TQCursor;
33class TQEvent;
34class TQKeyEvent;
35class TQRect;
36class TQWidget;
37class TDEActionCollection;
38class TDERadioAction;
39class KDialog;
40class KisBrush;
41class KisGradient;
42class KisPattern;
43class KisButtonPressEvent;
44class KisButtonReleaseEvent;
45class KisDoubleClickEvent;
46class KisMoveEvent;
47class KisCanvasPainter;
48
49enum enumToolType {
50 TOOL_SHAPE = 0, // Geometric shapes like ellipses and lines
51 TOOL_FREEHAND = 1, // Freehand drawing tools
52 TOOL_TRANSFORM = 2, // Tools that transform the layer
53 TOOL_FILL = 3, // Tools that fill parts of the canvas
54 TOOL_VIEW = 4, // Tools that affect the canvas: pan, zoom, etc.
55 TOOL_SELECT = 5
56
57};
58
59const TQ_UINT8 NUMBER_OF_TOOLTYPES = 6;
60
61class KisTool : public TQObject, public KisCanvasObserver, public TDEShared {
62 TQ_OBJECT
63
64
65public:
66 KisTool(const TQString & name);
67 virtual ~KisTool();
68
69public:
70
71 virtual void paint(KisCanvasPainter& gc) = 0;
72 virtual void paint(KisCanvasPainter& gc, const TQRect& rc) = 0;
73
83 virtual void setup(TDEActionCollection *collection) = 0;
84
85 virtual void buttonPress(KisButtonPressEvent *e) = 0;
86 virtual void move(KisMoveEvent *e) = 0;
87 virtual void buttonRelease(KisButtonReleaseEvent *e) = 0;
88 virtual void doubleClick(KisDoubleClickEvent *e) = 0;
89 virtual void keyPress(TQKeyEvent *e) = 0;
90 virtual void keyRelease(TQKeyEvent *e) = 0;
91
92 virtual TQCursor cursor() = 0;
93 virtual void setCursor(const TQCursor& cursor) = 0;
98 virtual TQWidget* createOptionWidget(TQWidget* parent);
102 virtual TQWidget* optionWidget();
103 TDERadioAction *action() const { return m_action; }
104
109 virtual bool wantsAutoScroll() const { return true; }
110
111 // Methods for integration with karbon-style toolbox
112 virtual TQ_UINT32 priority() { return 0; }
113 virtual enumToolType toolType() { return TOOL_FREEHAND; }
114 virtual TQString icon() { return m_action->icon(); }
115 virtual TQString quickHelp() const { return ""; }
116
117public slots:
121 virtual void activate() = 0;
122
127 virtual void deactivate() = 0;
128
129private:
130 KisTool(const KisTool&);
131 KisTool& operator=(const KisTool&);
132
133protected:
134 TDERadioAction *m_action;
135 bool m_ownAction;
136
137private:
138 class KisToolPrivate;
139 KisToolPrivate * d;
140
141};
142
143#endif // KIS_TOOL_H_
144
This is the base interface plugins use to implement the Observer design pattern.