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