]> git.lyx.org Git - lyx.git/blob - src/funcrequest.h
some integer type changes for inset unification
[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 class BufferView;
22
23 /**
24  * This class encapsulates a LyX action and its argument
25  * in order to pass it around easily.
26  */
27 class FuncRequest {
28 public:
29         /// just for putting thes things in std::container
30         FuncRequest();
31         /// actions without extra argument
32         explicit FuncRequest(kb_action act);
33         /// actions without extra argument
34         FuncRequest(kb_action act, int x, int y, mouse_button::state button);
35         /// actions with extra argument
36         FuncRequest(kb_action act, std::string const & arg);
37         /// actions without extra argument
38         FuncRequest(BufferView * bv, kb_action act);
39         /// actions with extra argument
40         FuncRequest(BufferView * bv, kb_action act, std::string const & arg);
41         /// for mouse events
42         FuncRequest(BufferView * bv, kb_action act,
43                 int x, int y, mouse_button::state button);
44         /// for changing requests a bit
45         FuncRequest(FuncRequest const & cmd, std::string const & arg);
46         /// for changing requests a bit
47         FuncRequest(FuncRequest const & cmd, BufferView * bv);
48
49         /// access to the view
50         BufferView * view() const;
51         /// access to the view
52         void setView(BufferView * bv);
53         /// access to button
54         mouse_button::state button() const;
55
56         /// output a message
57         void message(std::string const & msg) const;
58         /// output an error message
59         void errorMessage(std::string const & msg) const;
60
61         /// argument parsing, extract argument i as std::string
62         std::string getArg(unsigned int i) const;
63
64 private:
65         /// the BufferView we are talking to
66         BufferView * view_;
67 public:  // should be private, too...
68         /// the action
69         kb_action action;
70         /// the action's std::string argument
71         std::string argument;
72         /// the x coordinate of a mouse press
73         int x;
74         /// the y coordinate of a mouse press
75         int y;
76         /// some extra information (like button number)
77         mouse_button::state button_;
78 };
79
80
81 bool operator==(FuncRequest const & lhs, FuncRequest const & rhs);
82
83 std::ostream & operator<<(std::ostream &, FuncRequest const &);
84
85 #endif // FUNCREQUEST_H