tool_select.h
1/*
2 * Kivio - Visual Modelling and Flowcharting
3 * Copyright (C) 2000-2001 theKompany.com & Dave Marotti
4 * Copyright (C) 2003-2005 Peter Simonsson <psn@linux.se>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program 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
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 */
20#ifndef TOOL_SELECT_H
21#define TOOL_SELECT_H
22
23#include <tqptrlist.h>
24#include <KoPoint.h>
25#include <KoRect.h>
26#include "kivio_mousetool.h"
27
28class KivioView;
29class KivioPage;
30class TQMouseEvent;
31class TQKeyEvent;
32class TDEPopupMenu;
33class TDERadioAction;
34class TDEAction;
35
36class KivioStencil;
37
38class KivioSelectDragData
39{
40 public:
41 KoRect rect;
42};
43
44enum {
45 stCut=1,
46 stCopy,
47 stPaste,
48 stSendToBack,
49 stBringToFront,
50 stGroup,
51 stUngroup
52};
53
54class SelectTool : public Kivio::MouseTool
55{
56 TQ_OBJECT
57
58 public:
59 SelectTool( KivioView* parent );
60 ~SelectTool();
61
62 virtual bool processEvent(TQEvent* e);
63
64 void select(const TQRect&);
65
66 public slots:
67 void setActivated(bool a);
68
69 signals:
70 void operationDone();
71
72 protected slots:
73 void editText(TQPtrList<KivioStencil>* stencils);
74 void showProperties();
75 void editStencilText();
76
77 protected:
78 void mousePress(const TQPoint&);
79 void mouseMove(TQMouseEvent*);
80 void mouseRelease(const TQPoint&);
81 void leftDoubleClick(const TQPoint&);
82
83 bool startResizing(const TQPoint&);
84 bool startDragging(const TQPoint&, bool);
85 bool startCustomDragging(const TQPoint&, bool);
86 bool startRubberBanding(const TQPoint&);
87
88 void continueDragging(const TQPoint&, bool ignoreGridGuides = false);
89 void continueCustomDragging(const TQPoint&);
90 void continueResizing(const TQPoint&, bool ignoreGridGuides = false);
91 void continueRubberBanding(const TQPoint&);
92
93 void endResizing(const TQPoint&);
94 void endDragging(const TQPoint&);
95 void endCustomDragging(const TQPoint&);
96 void endRubberBanding(const TQPoint&);
97
98 void showPopupMenu(const TQPoint&);
99
100 void changeMouseCursor(const TQPoint&);
101 int isOverResizeHandle( KivioStencil *pStencil, const double x, const double y );
102
103 void keyPress(TQKeyEvent* e);
104
105 TQPoint m_startPoint, m_releasePoint;
106 KoPoint m_lastPoint;
107 KoPoint m_origPoint;
108
109 // Select Tool Mode
110 enum {
111 stmNone,
112 stmDrawRubber,
113 stmDragging,
114 stmCustomDragging,
115 stmResizing
116 };
117
118 private:
119 int m_mode; // Flag to indicate that we are drawing a rubber band
120 KivioStencil *m_pResizingStencil;
121 KivioStencil *m_pCustomDraggingStencil;
122 int m_resizeHandle;
123 bool m_controlKey;
124 int m_customDragID;
125 TQPtrList <KivioSelectDragData> m_lstOldGeometry;
126 KoRect m_selectedRect;
127 KoPoint m_customDragOrigPoint;
128
129 TDERadioAction* m_selectAction;
130 TDEAction* m_arrowHeadAction;
131 TDEAction* m_textEditAction;
132
133 bool m_firstTime;
134};
135
136#endif
Baseclass for mouse tools (like eg the select tool)