]> git.lyx.org Git - lyx.git/blob - src/funcrequest.h
more action work
[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 #include "support/std_string.h"
18
19 class BufferView;
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, string const & arg);
35         /// actions without extra argument
36         FuncRequest(BufferView * bv, kb_action act);
37         /// actions with extra argument
38         FuncRequest(BufferView * bv, kb_action act, string const & arg);
39         /// for mouse events
40         FuncRequest(BufferView * bv, kb_action act,
41                 int x, int y, mouse_button::state button);
42         /// for changing requests a bit
43         FuncRequest(FuncRequest const & cmd, string const & arg);
44         /// for changing requests a bit
45         FuncRequest(FuncRequest const & cmd, BufferView * bv);
46
47         /// access to the view
48         BufferView * view() const;
49         /// access to the view
50         void setView(BufferView * bv);
51         /// access to button
52         mouse_button::state button() const;
53
54         /// output a message
55         void message(string const & msg) const;
56         /// output an error message
57         void errorMessage(string const & msg) const;
58
59         /// argument parsing, extract argument i as string
60         string getArg(unsigned int i) const;
61
62 private:
63         /// the BufferView we are talking to
64         BufferView * view_;
65 public:  // should be private, too...
66         /// the action
67         kb_action action;
68         /// the action's string argument
69         string argument;
70         /// the x coordinate of a mouse press
71         int x;
72         /// the y coordinate of a mouse press
73         int y;
74         /// some extra information (like button number)
75         mouse_button::state button_;
76 };
77
78
79 inline
80 bool operator==(FuncRequest const & lhs, FuncRequest const & rhs)
81 {
82         return lhs.action == rhs.action && lhs.argument == rhs.argument;
83 }
84
85 #endif // FUNCREQUEST_H