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