]> git.lyx.org Git - lyx.git/blob - src/funcrequest.h
cleanup after svn hang-up, #undef CursorShape. Should be compilable ganin now.
[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 #include <iosfwd>
21
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         /// Where the request came from
30         enum Origin {
31                 INTERNAL,
32                 UI, // The menu or the toolbar
33                 KEYBOARD, // a keyboard binding
34                 COMMANDBUFFER
35         };
36
37         /// just for putting these things in std::container
38         explicit FuncRequest(Origin o = INTERNAL);
39         /// actions without extra argument
40         explicit FuncRequest(kb_action act, Origin o = INTERNAL);
41         /// actions without extra argument
42         FuncRequest(kb_action act, int x, int y, mouse_button::state button,
43                     Origin o = INTERNAL);
44         /// actions with extra argument
45         FuncRequest(kb_action act, lyx::docstring const & arg,
46                     Origin o = INTERNAL);
47         /// actions with extra argument. FIXME: remove this
48         FuncRequest(kb_action act, std::string const & arg,
49                     Origin o = INTERNAL);
50         /// for changing requests a bit
51         FuncRequest(FuncRequest const & cmd, lyx::docstring const & arg,
52                     Origin o = INTERNAL);
53         /// for changing requests a bit. FIXME: remove this
54         FuncRequest(FuncRequest const & cmd, std::string const & arg,
55                     Origin o = INTERNAL);
56
57         /// access to button
58         mouse_button::state button() const;
59
60         /// argument parsing, extract argument i as std::string
61         std::string getArg(unsigned int i) const;
62
63         /// access the whole argument
64         lyx::docstring const & argument() const { return argument_; }
65
66 public:  // should be private
67         /// the action
68         kb_action action;
69 private:
70         /// the action's string argument
71         lyx::docstring argument_;
72 public:  // should be private
73         /// who initiated the action
74         Origin origin;
75         /// the x coordinate of a mouse press
76         int x;
77         /// the y coordinate of a mouse press
78         int y;
79         /// some extra information (like button number)
80         mouse_button::state button_;
81 };
82
83
84 bool operator==(FuncRequest const & lhs, FuncRequest const & rhs);
85
86 std::ostream & operator<<(std::ostream &, FuncRequest const &);
87
88 #endif // FUNCREQUEST_H