]> Shamusworld >> Repos - architektonas/blob - src/base/rs_actioninterface.h
Last checkin before major refactor...
[architektonas] / src / base / rs_actioninterface.h
1 #ifndef RS_ACTIONINTERFACE_H
2 #define RS_ACTIONINTERFACE_H
3
4 #include <QtGui>
5 #include "rs_snapper.h"
6
7 class RS_CommandEvent;
8 class RS_Document;
9 class Drawing;
10 class RS_EntityContainer;
11 class GraphicView;
12 class Vector;
13
14 /**
15  * This is the interface that must be implemented for all
16  * action classes. Action classes handle actions such
17  * as drawing lines, moving entities or zooming in.
18  *
19  * Inherited from QObject for Qt translation features.
20  *
21  * @author Andrew Mustun
22  */
23 class RS_ActionInterface: public QObject, public RS_Snapper
24 {
25 //huh? no slots/signals here...    Q_OBJECT
26 //WHY derive from QObject???
27 //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                 RS_ActionInterface(const char * name, RS_EntityContainer & container,
32                         GraphicView & graphicView);
33                 virtual ~RS_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(RS_ActionInterface * pre);
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
65         private:
66                 /**
67                  * Current status of the action. After an action has
68                  * been created the action status is set to 0. Actions
69                  * that are terminated have a status of -1. Other status
70                  * numbers can be used to describe the stage this action
71                  * is in. E.g. a window zoom consists of selecting the
72                  * first corner (status 0), and selecting the second
73                  * corner (status 1).
74                  */
75                 int status;
76
77         protected:
78                 /** Action name. Used internally for debugging */
79                 QString name;
80
81                 /**
82                  * This flag is set when the action has terminated and
83                  * can be deleted.
84                  */
85                 bool finished;
86
87                 /**
88                  * Pointer to the graphic is this container is a graphic.
89                  * NULL otherwise
90                  */
91                 Drawing * graphic;
92
93                 /**
94                  * Pointer to the document (graphic or block) or NULL.
95                  */
96                 RS_Document * document;
97
98                 /**
99                  * Predecessor of this action or NULL.
100                  */
101                 RS_ActionInterface * predecessor;
102 };
103
104 #endif