]> git.lyx.org Git - lyx.git/blob - src/funcrequest.h
* Painter.h:
[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 "lfuns.h"
16 #include "frontends/mouse_state.h"
17
18 #include "support/docstring.h"
19
20 #include <iosfwd>
21
22
23 namespace lyx {
24
25
26 /**
27  * This class encapsulates a LyX action and its argument
28  * in order to pass it around easily.
29  */
30 class FuncRequest {
31 public:
32         /// Where the request came from
33         enum Origin {
34                 INTERNAL,
35                 UI, // The menu or the toolbar
36                 KEYBOARD, // a keyboard binding
37                 COMMANDBUFFER
38         };
39
40         /// just for putting these things in std::container
41         explicit FuncRequest(Origin o = INTERNAL);
42         /// actions without extra argument
43         explicit FuncRequest(kb_action act, Origin o = INTERNAL);
44         /// actions without extra argument
45         FuncRequest(kb_action act, int x, int y, mouse_button::state button,
46                     Origin o = INTERNAL);
47         /// actions with extra argument
48         FuncRequest(kb_action act, docstring const & arg,
49                     Origin o = INTERNAL);
50         /// actions with extra argument. FIXME: remove this
51         FuncRequest(kb_action act, std::string const & arg,
52                     Origin o = INTERNAL);
53         /// for changing requests a bit
54         FuncRequest(FuncRequest const & cmd, docstring const & arg,
55                     Origin o = INTERNAL);
56         /// for changing requests a bit. FIXME: remove this
57         FuncRequest(FuncRequest const & cmd, std::string const & arg,
58                     Origin o = INTERNAL);
59
60         /// access to button
61         mouse_button::state button() const;
62
63         /// argument parsing, extract argument i as std::string
64         std::string getArg(unsigned int i) const;
65
66         /// access the whole argument
67         docstring const & argument() const { return argument_; }
68
69 public:  // should be private
70         /// the action
71         kb_action action;
72 private:
73         /// the action's string argument
74         docstring argument_;
75 public:  // should be private
76         /// who initiated the action
77         Origin origin;
78         /// the x coordinate of a mouse press
79         int x;
80         /// the y coordinate of a mouse press
81         int y;
82         /// some extra information (like button number)
83         mouse_button::state button_;
84 };
85
86
87 bool operator==(FuncRequest const & lhs, FuncRequest const & rhs);
88
89 std::ostream & operator<<(std::ostream &, FuncRequest const &);
90
91
92 } // namespace lyx
93
94 #endif // FUNCREQUEST_H