]> Shamusworld >> Repos - architektonas/blob - src/base/actioninterface.h
In the middle of major refactoring...
[architektonas] / src / base / actioninterface.h
1 #ifndef __ACTIONINTERFACE_H__
2 #define __ACTIONINTERFACE_H__
3
4 #include <QtGui>
5 #include "rs.h"
6
7 class RS_CommandEvent;
8 class RS_Document;
9 class Drawing;
10 class RS_Entity;
11 class RS_EntityContainer;
12 class GraphicView;
13 class Vector;
14
15 /**
16  * This is the interface that must be implemented for all action classes.
17  * Action classes handle actions such as drawing lines, moving entities or
18  * zooming in.
19  *
20  * Inherited from QObject for Qt translation features.
21  *
22  * @author James Hammons
23  * @author Andrew Mustun
24  */
25 class ActionInterface: public QObject
26 {
27 //WHY derive from QObject??? for the TR macro???
28 //mebbe... Well, that's what he says above. Though it would be just as easy to
29 //prefix a QObject::tr in front of translated strings...
30         public:
31                 ActionInterface(const char * name, RS_EntityContainer &,
32                         GraphicView &);
33                 virtual ~ActionInterface();
34
35                 virtual RS2::ActionType rtti();
36                 QString getName();
37                 virtual void init(int status = 0);
38                 virtual void mouseMoveEvent(QMouseEvent *);
39                 virtual void mousePressEvent(QMouseEvent *);
40                 virtual void mouseReleaseEvent(QMouseEvent *);
41                 virtual void keyPressEvent(QKeyEvent * e);
42                 virtual void keyReleaseEvent(QKeyEvent * e);
43                 virtual void coordinateEvent(Vector *);
44                 virtual void commandEvent(RS_CommandEvent *);
45                 virtual QStringList getAvailableCommands();
46                 virtual void setStatus(int status);
47                 virtual int getStatus();
48                 virtual void trigger();
49                 virtual void updateMouseButtonHints();
50                 virtual void updateMouseCursor();
51                 virtual void updateToolBar();
52                 virtual bool isFinished();
53                 virtual void setFinished();
54                 virtual void finish();
55                 virtual void setPredecessor(ActionInterface *);
56                 virtual void suspend();
57                 virtual void resume();
58                 virtual void hideOptions();
59                 virtual void showOptions();
60                 bool checkCommand(const QString & cmd, const QString & str,
61                         RS2::ActionType action = RS2::ActionNone);
62                 QString command(const QString & cmd);
63                 QString msgAvailableCommands();
64                 //built-in for now, we'll see how it goes...
65                 Vector snapPoint(QMouseEvent *);
66                 RS_Entity * catchEntity(QMouseEvent *, RS2::ResolveLevel level = RS2::ResolveNone);
67                 RS_Entity * catchEntity(Vector, RS2::ResolveLevel level = RS2::ResolveNone);
68 #warning "!!! The following functions are DEPRECATED and only in place to help with porting.. !!!"
69                 void drawSnapper(void);
70                 void deleteSnapper(void);
71                 void drawPreview(void);
72                 void clearPreview(void);
73                 void deletePreview(void);
74
75         private:
76                 /**
77                  * Current status of the action. After an action has been created the
78                  * action status is set to 0. Actions that are terminated have a status
79                  * of -1. Other status numbers can be used to describe the stage this
80                  * action is in. E.g. a window zoom consists of selecting the first
81                  * corner (status 0), and selecting the second corner (status 1).
82                  */
83                 int status;
84
85         protected:
86                 /** Action name. Used internally for debugging */
87                 QString name;
88
89                 /**
90                  * This flag is set when the action has terminated and can be deleted.
91                  */
92                 bool finished;
93
94                 /**
95                  * Pointer to the graphic is this container is a graphic. NULL otherwise
96                  */
97                 Drawing * graphic;
98
99                 /**
100                  * Pointer to the document (graphic or block) or NULL.
101                  */
102                 RS_Document * document;
103
104                 /**
105                  * Predecessor of this action or NULL.
106                  */
107                 ActionInterface * predecessor;
108
109                 GraphicView * graphicView;
110                 RS_EntityContainer * container;
111 };
112
113 #endif  // __ACTIONINTERFACE_H__