krita

kis_tool.h

00001 /*
00002  *  Copyright (c) 1999 Matthias Elter  <me@kde.org>
00003  *  Copyright (c) 2002, 2003 Patrick Julien <freak@codepimps.org>
00004  *
00005  *  This program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018  */
00019 
00020 #ifndef KIS_TOOL_H_
00021 #define KIS_TOOL_H_
00022 
00023 #include <qobject.h>
00024 #include <qstring.h>
00025 
00026 #include <ksharedptr.h>
00027 #include <kaction.h>
00028 
00029 #include "kis_shared_ptr_vector.h"
00030 #include "kis_canvas_observer.h"
00031 
00032 class QCursor;
00033 class QEvent;
00034 class QKeyEvent;
00035 class QRect;
00036 class QWidget;
00037 class KActionCollection;
00038 class KRadioAction;
00039 class KDialog;
00040 class KisBrush;
00041 class KisGradient;
00042 class KisPattern;
00043 class KisButtonPressEvent;
00044 class KisButtonReleaseEvent;
00045 class KisDoubleClickEvent;
00046 class KisMoveEvent;
00047 class KisCanvasPainter;
00048 
00049 enum enumToolType {
00050     TOOL_SHAPE = 0,   // Geometric shapes like ellipses and lines
00051     TOOL_FREEHAND = 1, // Freehand drawing tools
00052     TOOL_TRANSFORM = 2, // Tools that transform the layer
00053     TOOL_FILL = 3, // Tools that fill parts of the canvas
00054     TOOL_VIEW = 4,   // Tools that affect the canvas: pan, zoom, etc.
00055     TOOL_SELECT = 5
00056 
00057 };
00058 
00059 const Q_UINT8 NUMBER_OF_TOOLTYPES = 6;
00060 
00061 class KisTool : public QObject, public KisCanvasObserver, public KShared {
00062     Q_OBJECT
00063 
00064 public:
00065     KisTool(const QString & name);
00066     virtual ~KisTool();
00067 
00068 public:
00069 
00070     virtual void paint(KisCanvasPainter& gc) = 0;
00071     virtual void paint(KisCanvasPainter& gc, const QRect& rc) = 0;
00072 
00082     virtual void setup(KActionCollection *collection) = 0;
00083 
00084     virtual void buttonPress(KisButtonPressEvent *e) = 0;
00085     virtual void move(KisMoveEvent *e) = 0;
00086     virtual void buttonRelease(KisButtonReleaseEvent *e) = 0;
00087     virtual void doubleClick(KisDoubleClickEvent *e) = 0;
00088     virtual void keyPress(QKeyEvent *e) = 0;
00089     virtual void keyRelease(QKeyEvent *e) = 0;
00090 
00091     virtual QCursor cursor() = 0;
00092     virtual void setCursor(const QCursor& cursor) = 0;
00097     virtual QWidget* createOptionWidget(QWidget* parent);
00101     virtual QWidget* optionWidget();
00102     KRadioAction *action() const { return m_action; }
00103 
00108     virtual bool wantsAutoScroll() const { return true; }
00109 
00110     // Methods for integration with karbon-style toolbox
00111     virtual Q_UINT32 priority() { return 0; }
00112     virtual enumToolType toolType() { return TOOL_FREEHAND; }
00113     virtual QString icon() { return m_action->icon(); }
00114     virtual QString quickHelp() const { return ""; }
00115 
00116 public slots:
00120     virtual void activate() = 0;
00121     
00126     virtual void deactivate() = 0;
00127 
00128 private:
00129     KisTool(const KisTool&);
00130     KisTool& operator=(const KisTool&);
00131 
00132 protected:
00133     KRadioAction *m_action;
00134     bool m_ownAction;
00135 
00136 private:
00137     class KisToolPrivate;
00138     KisToolPrivate * d;
00139     
00140 };
00141 
00142 #endif // KIS_TOOL_H_
00143 
KDE Home | KDE Accessibility Home | Description of Access Keys