]> git.lyx.org Git - lyx.git/blob - src/funcrequest.h
8224d29460e857cdc41e92648cec43c2f0ad9fb2
[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 <string>
19 #include <iosfwd>
20
21 /**
22  * This class encapsulates a LyX action and its argument
23  * in order to pass it around easily.
24  */
25 class FuncRequest {
26 public:
27         /// just for putting thes things in std::container
28         FuncRequest();
29         /// actions without extra argument
30         explicit FuncRequest(kb_action act);
31         /// actions without extra argument
32         FuncRequest(kb_action act, int x, int y, mouse_button::state button);
33         /// actions with extra argument
34         FuncRequest(kb_action act, std::string const & arg);
35         /// for changing requests a bit
36         FuncRequest(FuncRequest const & cmd, std::string const & arg);
37
38         /// access to button
39         mouse_button::state button() const;
40
41         /// output a message
42         void message(std::string const & msg) const;
43         /// output an error message
44         void errorMessage(std::string const & msg) const;
45
46         /// argument parsing, extract argument i as std::string
47         std::string getArg(unsigned int i) const;
48
49 public:  // should be private
50         /// the action
51         kb_action action;
52         /// the action's std::string argument
53         std::string argument;
54         /// the x coordinate of a mouse press
55         int x;
56         /// the y coordinate of a mouse press
57         int y;
58         /// some extra information (like button number)
59         mouse_button::state button_;
60 };
61
62
63 bool operator==(FuncRequest const & lhs, FuncRequest const & rhs);
64
65 std::ostream & operator<<(std::ostream &, FuncRequest const &);
66
67 #endif // FUNCREQUEST_H