karbon

vtool.h
1/* This file is part of the KDE project
2 Copyright (C) 2001, 2002, 2003 The Karbon Developers
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#ifndef __VTOOL_H__
21#define __VTOOL_H__
22
23#include <tqobject.h>
24#include <tdeaction.h>
25#include <tdelocale.h>
26#include <KoPoint.h>
27#include <koffice_export.h>
28class TDERadioAction;
29class KarbonPart;
30class KarbonView;
31class TQEvent;
32class TQWidget;
33class VPainter;
34class VToolController;
35
36enum enumToolType
37{
38 TOOL_SELECT = 0, //
39 TOOL_FREEHAND = 1, //
40 TOOL_SHAPE = 2, // Geometric shapes like ellipses and lines
41 TOOL_MANIPULATION = 3, //
42 TOOL_MISC = 4 //
43};
44
51class KARBONBASE_EXPORT VTool : public TQObject
52{
53 TQ_OBJECT
54
55
56public:
63 VTool( KarbonView *view, const char* name );
64 // Make VTool "abstract":
65
69 virtual ~VTool();
70
78 virtual void registerTool( VTool *tool );
79
83 virtual void deactivate() {}
84
88 virtual bool showDialog() const { return false; }
89
93 virtual TQString uiname() { return i18n( "Unnamed Tool" ); }
94
98 virtual TQString contextHelp() { return i18n( "This tool has no description." ); }
99
103 virtual enumToolType toolType() { return TOOL_MISC; }
104
108 virtual TQString statusText() { return ""; }
109
114 virtual uint priority() { return 0; }
115
119 TQString icon() { return m_action->icon(); }
120
126 bool mouseEvent( TQMouseEvent* event, const KoPoint& );
127
133 bool keyEvent( TQEvent* event );
134
138 virtual void refreshUnit() {}
139
144 virtual void setup(TDEActionCollection *) {}
145
151 TDERadioAction *action() const { return m_action; }
152
158 virtual void draw( VPainter* painter ) { Q_UNUSED( painter ); }
159
160public slots:
165 virtual void activate();
166
167protected:
173 bool isDragging() const { return m_isDragging; }
174
175 virtual void draw( /*VPainter* painter*/ ) {}
176
180 virtual void setCursor() const {}
181
185 virtual void mouseButtonPress() {}
186
190 virtual void rightMouseButtonPress() {}
191
195 virtual void mouseButtonRelease() {}
196
200 virtual void rightMouseButtonRelease() {}
201
205 virtual void mouseButtonDblClick() {}
206
210 virtual void mouseMove() {}
211
215 virtual void mouseDrag() {}
216
220 virtual void mouseDragRelease() {}
221
225 virtual void mouseDragShiftPressed() {}
226
230 virtual void mouseDragCtrlPressed() {}
231
235 virtual void mouseDragShiftReleased() {}
236
240 virtual void mouseDragCtrlReleased() {}
241
245 virtual void arrowKeyReleased( TQt::Key ) {}
246
250 virtual bool keyReleased( TQt::Key ) { return false; }
251
255 virtual void cancel() {}
256
260 virtual void cancelStep() {}
261
265 virtual void accept() {}
266
270// KarbonPart* part() const { return m_part; }
271
275 KarbonView* view() const;
276
280 const KoPoint& first() const { return m_firstPoint; }
281
285 const KoPoint& last() const { return m_lastPoint; }
286
292 bool shiftPressed() const { return m_shiftPressed; }
293
299 bool ctrlPressed() const { return m_ctrlPressed; }
300
306 bool altPressed() const { return m_altPressed; }
307
309 TDERadioAction *m_action;
310
312 VToolController *toolController() const;
313
314private:
317 KarbonView *m_view;
318
322 KoPoint m_firstPoint;
323
327 KoPoint m_lastPoint;
328
332 bool m_mouseButtonIsDown;
333
337 bool m_isDragging;
338
342 bool m_shiftPressed;
343
347 bool m_ctrlPressed;
348
352 bool m_altPressed;
353};
354
355#endif
356
Keeps track of visual per document properties.
Definition karbon_part.h:46
virtual void mouseDragRelease()
Mouse button release.
Definition vtool.h:220
virtual void mouseButtonPress()
Left mouse button press.
Definition vtool.h:185
const KoPoint & last() const
The last mouse coordinate.
Definition vtool.h:285
virtual bool keyReleased(TQt::Key)
Specified key released.
Definition vtool.h:250
const KoPoint & first() const
Most tools need to know the first mouse coordinate.
Definition vtool.h:280
bool altPressed() const
The status of the alt key.
Definition vtool.h:306
virtual void rightMouseButtonRelease()
Right mouse button release.
Definition vtool.h:200
virtual void mouseButtonDblClick()
Mouse button double click.
Definition vtool.h:205
virtual void mouseButtonRelease()
Left mouse button release.
Definition vtool.h:195
bool ctrlPressed() const
The status of the ctrl key.
Definition vtool.h:299
virtual void arrowKeyReleased(TQt::Key)
"Arrow" key released up, down, left, right
Definition vtool.h:245
virtual void draw(VPainter *painter)
Draws the actual tool state.
Definition vtool.h:158
virtual void mouseDragCtrlReleased()
"Ctrl" key released while mouse drag.
Definition vtool.h:240
VToolController * toolController() const
Helper function.
Definition vtool.cpp:60
virtual TQString uiname()
The name of the tool.
Definition vtool.h:93
TDERadioAction * action() const
Returns the tool's associated action object.
Definition vtool.h:151
virtual void accept()
Terminates the current tool drawing (if any).
Definition vtool.h:265
virtual void cancel()
Cancels all tool operations.
Definition vtool.h:255
virtual TQString statusText()
The tool status text.
Definition vtool.h:108
virtual void registerTool(VTool *tool)
Registers the specified tool at the connected part.
Definition vtool.cpp:54
virtual void deactivate()
Deactivates the tool.
Definition vtool.h:83
bool shiftPressed() const
The status of the shift key.
Definition vtool.h:292
virtual void mouseDragCtrlPressed()
Mouse drag with "Ctrl" key pressed at the same time.
Definition vtool.h:230
TQString icon()
The tool icon name.
Definition vtool.h:119
TDERadioAction * m_action
The tool's action object.
Definition vtool.h:309
virtual uint priority()
Position in toolbox.
Definition vtool.h:114
virtual void mouseDragShiftPressed()
Mouse drag with "Shift" key pressed at the same time.
Definition vtool.h:225
bool isDragging() const
Returns the current dagging state.
Definition vtool.h:173
virtual void refreshUnit()
This function is called when the documents unit setting were changed.
Definition vtool.h:138
VTool(KarbonView *view, const char *name)
Constructs a new tool connected to the specified karbon view.
Definition vtool.cpp:34
virtual void mouseDragShiftReleased()
"Shift" key released while mouse drag.
Definition vtool.h:235
virtual TQString contextHelp()
The context help of the tool.
Definition vtool.h:98
virtual void setup(TDEActionCollection *)
Called after tool creation.
Definition vtool.h:144
virtual void setCursor() const
This function is called on each mouse event the tool receives.
Definition vtool.h:180
virtual enumToolType toolType()
The tool type.
Definition vtool.h:103
virtual void mouseMove()
Mouse move.
Definition vtool.h:210
virtual void rightMouseButtonPress()
Right mouse button press.
Definition vtool.h:190
virtual void mouseDrag()
Mouse drag.
Definition vtool.h:215
KarbonView * view() const
Returns the connected karbon part.
Definition vtool.cpp:66
virtual bool showDialog() const
Shows the tools option dialog.
Definition vtool.h:88
virtual void cancelStep()
Cancels the last tool step (if any).
Definition vtool.h:260