]> git.lyx.org Git - lyx.git/blob - src/FuncRequest.h
Fixed some lines that were too long. It compiled afterwards.
[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                 MENU, // A menu entry
36                 TOOLBAR, // A toolbar icon
37                 KEYBOARD, // a keyboard binding
38                 COMMANDBUFFER
39         };
40
41         /// just for putting these things in std::container
42         explicit FuncRequest(Origin o = INTERNAL);
43         /// actions without extra argument
44         explicit FuncRequest(kb_action act, Origin o = INTERNAL);
45         /// actions without extra argument
46         FuncRequest(kb_action act, int x, int y, mouse_button::state button,
47                     Origin o = INTERNAL);
48         /// actions with extra argument
49         FuncRequest(kb_action act, docstring const & arg,
50                     Origin o = INTERNAL);
51         /// actions with extra argument. FIXME: remove this
52         FuncRequest(kb_action act, std::string const & arg,
53                     Origin o = INTERNAL);
54         /// for changing requests a bit
55         FuncRequest(FuncRequest const & cmd, docstring const & arg,
56                     Origin o = INTERNAL);
57         /// for changing requests a bit. FIXME: remove this
58         FuncRequest(FuncRequest const & cmd, std::string const & arg,
59                     Origin o = INTERNAL);
60
61         /// access to button
62         mouse_button::state button() const;
63
64         /// argument parsing, extract argument i as std::string
65         std::string getArg(unsigned int i) const;
66
67         /// access the whole argument
68         docstring const & argument() const { return argument_; }
69
70 public:  // should be private
71         /// the action
72         kb_action action;
73 private:
74         /// the action's string argument
75         docstring argument_;
76 public:  // should be private
77         /// who initiated the action
78         Origin origin;
79         /// the x coordinate of a mouse press
80         int x;
81         /// the y coordinate of a mouse press
82         int y;
83         /// some extra information (like button number)
84         mouse_button::state button_;
85 };
86
87
88 bool operator==(FuncRequest const & lhs, FuncRequest const & rhs);
89
90 std::ostream & operator<<(std::ostream &, FuncRequest const &);
91
92
93 } // namespace lyx
94
95 #endif // FUNCREQUEST_H