karbon

vtool.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2001, 2002, 2003 The Karbon Developers
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef __VTOOL_H__
00021 #define __VTOOL_H__
00022 
00023 #include <qobject.h>
00024 #include <kaction.h>
00025 #include <klocale.h>
00026 #include <KoPoint.h>
00027 #include <koffice_export.h>
00028 class KRadioAction;
00029 class KarbonPart;
00030 class KarbonView;
00031 class QEvent;
00032 class QWidget;
00033 class VPainter;
00034 class VToolController;
00035 
00036 enum enumToolType
00037 {
00038     TOOL_SELECT = 0,       // 
00039     TOOL_FREEHAND = 1,     //
00040     TOOL_SHAPE = 2,        // Geometric shapes like ellipses and lines
00041     TOOL_MANIPULATION = 3, //
00042     TOOL_MISC = 4          //
00043 };
00044 
00051 class KARBONBASE_EXPORT VTool : public QObject
00052 {
00053     Q_OBJECT
00054 
00055 public:
00062     VTool( KarbonView *view, const char* name );
00063     // Make VTool "abstract":
00064     
00068     virtual ~VTool();
00069 
00077     virtual void registerTool( VTool *tool );
00078 
00082     virtual void deactivate() {}
00083 
00087     virtual bool showDialog() const { return false; }
00088 
00092     virtual QString uiname() { return i18n( "Unnamed Tool" ); }
00093 
00097     virtual QString contextHelp() { return i18n( "This tool has no description." ); }
00098 
00102     virtual enumToolType toolType() { return TOOL_MISC; }
00103 
00107     virtual QString statusText() { return ""; }
00108 
00113     virtual uint priority() { return 0; }
00114 
00118     QString icon() { return m_action->icon(); }
00119 
00125     bool mouseEvent( QMouseEvent* event, const KoPoint& );
00126 
00132     bool keyEvent( QEvent* event );
00133 
00137     virtual void refreshUnit() {}
00138 
00143     virtual void setup(KActionCollection *) {}
00144 
00150     KRadioAction *action() const { return m_action; }
00151 
00157     virtual void draw( VPainter* painter ) { Q_UNUSED( painter ); }
00158 
00159 public slots:
00164     virtual void activate();
00165 
00166 protected:
00172     bool isDragging() const { return m_isDragging; }
00173 
00174     virtual void draw( /*VPainter* painter*/ ) {}
00175 
00179     virtual void setCursor() const {}
00180 
00184     virtual void mouseButtonPress() {}
00185 
00189     virtual void rightMouseButtonPress() {}
00190 
00194     virtual void mouseButtonRelease() {}
00195 
00199     virtual void rightMouseButtonRelease() {}
00200 
00204     virtual void mouseButtonDblClick() {}
00205 
00209     virtual void mouseMove() {}
00210 
00214     virtual void mouseDrag() {}
00215 
00219     virtual void mouseDragRelease() {}
00220 
00224     virtual void mouseDragShiftPressed() {}
00225 
00229     virtual void mouseDragCtrlPressed() {}
00230 
00234     virtual void mouseDragShiftReleased() {}
00235 
00239     virtual void mouseDragCtrlReleased() {}
00240 
00244     virtual void arrowKeyReleased( Qt::Key ) {}
00245 
00249     virtual bool keyReleased( Qt::Key ) { return false; }
00250 
00254     virtual void cancel() {}
00255 
00259     virtual void cancelStep() {}
00260 
00264     virtual void accept() {}
00265 
00269 //  KarbonPart* part() const { return m_part; }
00270 
00274     KarbonView* view() const;
00275 
00279     const KoPoint& first() const { return m_firstPoint; }
00280 
00284     const KoPoint& last() const { return m_lastPoint; }
00285 
00291     bool shiftPressed() const { return m_shiftPressed; }
00292 
00298     bool ctrlPressed() const { return m_ctrlPressed; }
00299 
00305     bool altPressed() const { return m_altPressed; }
00306 
00308     KRadioAction *m_action;
00309 
00311     VToolController *toolController() const;
00312 
00313 private:
00316     KarbonView *m_view;
00317 
00321     KoPoint m_firstPoint;
00322 
00326     KoPoint m_lastPoint;
00327 
00331     bool m_mouseButtonIsDown;
00332 
00336     bool m_isDragging;
00337 
00341     bool m_shiftPressed;
00342 
00346     bool m_ctrlPressed;
00347 
00351     bool m_altPressed;
00352 };
00353 
00354 #endif
00355 
KDE Home | KDE Accessibility Home | Description of Access Keys