]> git.lyx.org Git - lyx.git/blob - src/FuncRequest.h
* src/frontends/GuiDocument.{cpp,h}:
[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
21 namespace lyx {
22
23
24 /**
25  * This class encapsulates a LyX action and its argument
26  * in order to pass it around easily.
27  */
28 class FuncRequest {
29 public:
30         /// Where the request came from
31         enum Origin {
32                 INTERNAL,
33                 MENU, // A menu entry
34                 TOOLBAR, // A toolbar icon
35                 KEYBOARD, // a keyboard binding
36                 COMMANDBUFFER
37         };
38
39         /// just for putting these things in std::container
40         explicit FuncRequest(Origin o = INTERNAL);
41         /// actions without extra argument
42         explicit FuncRequest(kb_action act, Origin o = INTERNAL);
43         /// actions without extra argument
44         FuncRequest(kb_action act, int x, int y, mouse_button::state button,
45                     Origin o = INTERNAL);
46         /// actions with extra argument
47         FuncRequest(kb_action act, docstring const & arg,
48                     Origin o = INTERNAL);
49         /// actions with extra argument. FIXME: remove this
50         FuncRequest(kb_action act, std::string const & arg,
51                     Origin o = INTERNAL);
52         /// for changing requests a bit
53         FuncRequest(FuncRequest const & cmd, docstring const & arg,
54                     Origin o = INTERNAL);
55         /// for changing requests a bit. FIXME: remove this
56         FuncRequest(FuncRequest const & cmd, std::string const & arg,
57                     Origin o = INTERNAL);
58
59         /// access to button
60         mouse_button::state button() const;
61
62         /// argument parsing, extract argument i as std::string
63         std::string getArg(unsigned int i) const;
64
65         /// access the whole argument
66         docstring const & argument() const { return argument_; }
67
68         /// 
69         static FuncRequest const unknown;
70         /// 
71         static FuncRequest const noaction;
72 public:  // should be private
73         /// the action
74         kb_action action;
75 private:
76         /// the action's string argument
77         docstring argument_;
78 public:  // should be private
79         /// who initiated the action
80         Origin origin;
81         /// the x coordinate of a mouse press
82         int x;
83         /// the y coordinate of a mouse press
84         int y;
85         /// some extra information (like button number)
86         mouse_button::state button_;
87 };
88
89
90 bool operator==(FuncRequest const & lhs, FuncRequest const & rhs);
91
92 std::ostream & operator<<(std::ostream &, FuncRequest const &);
93
94
95 } // namespace lyx
96
97 #endif // FUNCREQUEST_H