]> Shamusworld >> Repos - architektonas/blob - src/base/rs_actioninterface.h
Changed RS_Graphic to Drawing; this is less confusing as a drawing is
[architektonas] / src / base / rs_actioninterface.h
1 #ifndef RS_ACTIONINTERFACE_H
2 #define RS_ACTIONINTERFACE_H
3
4 #include <QtCore>
5
6 #include "rs_entitycontainer.h"
7 #include "rs_commandevent.h"
8 //#include "rs_event.h"
9 #include "drawing.h"
10 #include "rs_graphicview.h"
11 #include "rs_snapper.h"
12 #include "rs_preview.h"
13 #include "rs_dialogfactory.h"
14
15 #ifndef RS_NO_QCADCMD
16 #include "commands.h"
17 #endif
18
19 //template<class T> T* instantiate(RS_EntityContainer& container, RS_GraphicView& graphicView) {
20 //      return new T(container, graphicView);
21         //void (*function)() = T::instantiate;
22         //return (*function)();
23 //}
24
25 /**
26  * This is the interface that must be implemented for all
27  * action classes. Action classes handle actions such
28  * as drawing lines, moving entities or zooming in.
29  *
30  * Inherited from QObject for Qt translation features.
31  *
32  * @author Andrew Mustun
33  */
34 class RS_ActionInterface: public QObject, public RS_Snapper
35 {
36 //huh? no slots/signals here...    Q_OBJECT
37
38         public:
39                 RS_ActionInterface(const char * name, RS_EntityContainer & container,
40                         RS_GraphicView & graphicView);
41                 virtual ~RS_ActionInterface();
42
43                 virtual RS2::ActionType rtti();
44
45                 QString getName();
46
47                 virtual void init(int status = 0);
48                 virtual void mouseMoveEvent(QMouseEvent *);
49                 virtual void mousePressEvent(QMouseEvent *);
50
51                 virtual void mouseReleaseEvent(QMouseEvent *);
52                 virtual void keyPressEvent(QKeyEvent * e);
53                 virtual void keyReleaseEvent(QKeyEvent * e);
54                 virtual void coordinateEvent(RS_CoordinateEvent *);
55                 virtual void commandEvent(RS_CommandEvent *);
56                 virtual QStringList getAvailableCommands();
57                 virtual void setStatus(int status);
58                 virtual int getStatus();
59                 virtual void trigger();
60                 virtual void updateMouseButtonHints();
61                 virtual void updateMouseCursor();
62                 virtual void updateToolBar();
63                 virtual bool isFinished();
64                 virtual void setFinished();
65                 virtual void finish();
66                 virtual void setPredecessor(RS_ActionInterface * pre);
67                 virtual void suspend();
68                 virtual void resume();
69                 virtual void hideOptions();
70                 virtual void showOptions();
71                 bool checkCommand(const QString & cmd, const QString & str,
72                         RS2::ActionType action = RS2::ActionNone);
73                 QString command(const QString & cmd);
74                 QString msgAvailableCommands();
75
76         private:
77                 /**
78                 * Current status of the action. After an action has
79                 * been created the action status is set to 0. Actions
80                 * that are terminated have a status of -1. Other status
81                 * numbers can be used to describe the stage this action
82                 * is in. E.g. a window zoom consists of selecting the
83                 * first corner (status 0), and selecting the second
84                 * corner (status 1).
85                 */
86                 int status;
87
88         protected:
89                 /** Action name. Used internally for debugging */
90                 QString name;
91
92                 /**
93                 * This flag is set when the action has terminated and
94                 * can be deleted.
95                 */
96                 bool finished;
97
98                 /**
99                 * Pointer to the graphic is this container is a graphic.
100                 * NULL otherwise
101                 */
102                 Drawing * graphic;
103
104                 /**
105                 * Pointer to the document (graphic or block) or NULL.
106                 */
107                 RS_Document * document;
108
109                 /**
110                 * Pointer to the default mouse cursor for this action or NULL.
111                 */
112                 //RS2::CursorType cursor;
113
114                 /**
115                 * Predecessor of this action or NULL.
116                 */
117                 RS_ActionInterface * predecessor;
118
119                 /**
120                 * String prepended to the help text for currently available commands.
121                 */
122                 //static QString msgAvailableCommands;
123
124                 /**
125                 * Command used for showing help for every action.
126                 */
127                 //static QString cmdHelp;
128
129                 /**
130                 * Command for answering yes to a question.
131                 */
132                 //static QString cmdYes;
133                 //static QString cmdYes2;
134
135                 /**
136                 * Command for answering no to a question.
137                 */
138                 //static QString cmdNo;
139                 //static QString cmdNo2;
140 };
141
142 #endif