]> git.lyx.org Git - lyx.git/blob - src/FuncRequest.h
Remove updateInfo() calls in favor of doing the relevant work
[lyx.git] / src / FuncRequest.h
1 // -*- C++ -*-
2 /**
3  * \file FuncRequest.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author André Pönitz
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef FUNCREQUEST_H
13 #define FUNCREQUEST_H
14
15 #include "FuncCode.h"
16
17 #include "support/docstring.h"
18
19 #include "frontends/KeyModifier.h"
20 #include "frontends/mouse_state.h"
21
22
23 namespace lyx {
24
25 class LyXErr;
26
27 /**
28  * This class encapsulates a LyX action and its argument
29  * in order to pass it around easily.
30  */
31 class FuncRequest
32 {
33 public:
34         /// Where the request came from
35         enum Origin {
36                 INTERNAL,
37                 MENU, // A menu entry
38                 TOOLBAR, // A toolbar icon
39                 KEYBOARD, // a keyboard binding
40                 COMMANDBUFFER,
41                 LYXSERVER,
42                 TOC
43         };
44
45         /// just for putting these things in std::container
46         explicit FuncRequest(Origin o = INTERNAL);
47         /// actions without extra argument
48         explicit FuncRequest(FuncCode act, Origin o = INTERNAL);
49         /// actions without extra argument
50         FuncRequest(FuncCode act, int x, int y, mouse_button::state button,
51                     KeyModifier modifier, Origin o = INTERNAL);
52         /// actions with extra argument
53         FuncRequest(FuncCode act, docstring const & arg,
54                     Origin o = INTERNAL);
55         /// actions with extra argument. FIXME: remove this
56         FuncRequest(FuncCode act, std::string const & arg,
57                     Origin o = INTERNAL);
58         /// for changing requests a bit
59         FuncRequest(FuncRequest const & cmd, docstring const & arg,
60                     Origin o = INTERNAL);
61
62         /// access the whole argument
63         docstring const & argument() const { return argument_; }
64         ///
65         FuncCode action() const { return action_ ; }
66         ///
67         void setAction(FuncCode act) { action_ = act; }
68         ///
69         Origin origin() const { return origin_; }
70         ///
71         void setOrigin(Origin o) { origin_ = o; }
72         ///
73         int x() const { return x_; }
74         ///
75         int y() const { return y_; }
76         ///
77         void set_y(int y) { y_ = y; }
78         ///
79         mouse_button::state button() const { return button_; }
80         ///
81         KeyModifier modifier() { return modifier_; }
82
83         /// argument parsing, extract argument i as std::string
84         std::string getArg(unsigned int i) const;
85         /// argument parsing, extract argument i as std::string,
86         /// eating all characters up to the end of the command line
87         std::string getLongArg(unsigned int i) const;
88
89         ///
90         static FuncRequest const unknown;
91         ///
92         static FuncRequest const noaction;
93 private:
94         /// the action
95         FuncCode action_;
96         /// the action's string argument
97         docstring argument_;
98         /// who initiated the action
99         Origin origin_;
100         /// the x coordinate of a mouse press
101         int x_;
102         /// the y coordinate of a mouse press
103         int y_;
104         /// some extra information (like button number)
105         mouse_button::state button_;
106         ///
107         KeyModifier modifier_;
108 };
109
110
111 bool operator==(FuncRequest const & lhs, FuncRequest const & rhs);
112
113 std::ostream & operator<<(std::ostream &, FuncRequest const &);
114
115 LyXErr & operator<<(LyXErr &, FuncRequest const &);
116
117
118 } // namespace lyx
119
120 #endif // FUNCREQUEST_H