Prepare ANNOUNCE and NEWS for rc2
[lyx.git] / src / FuncRequest.h
blobde762b0124271a74723286cbf6aaf995c6bc7697
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.
7 * \author André Pönitz
9 * Full author contact details are available in file CREDITS.
12 #ifndef FUNCREQUEST_H
13 #define FUNCREQUEST_H
15 #include "FuncCode.h"
17 #include "support/docstring.h"
19 #include "frontends/mouse_state.h"
22 namespace lyx {
24 /**
25 * This class encapsulates a LyX action and its argument
26 * in order to pass it around easily.
28 class FuncRequest
30 public:
31 /// Where the request came from
32 enum Origin {
33 INTERNAL,
34 MENU, // A menu entry
35 TOOLBAR, // A toolbar icon
36 KEYBOARD, // a keyboard binding
37 COMMANDBUFFER
40 /// just for putting these things in std::container
41 explicit FuncRequest(Origin o = INTERNAL);
42 /// actions without extra argument
43 explicit FuncRequest(FuncCode act, Origin o = INTERNAL);
44 /// actions without extra argument
45 FuncRequest(FuncCode act, int x, int y, mouse_button::state button,
46 Origin o = INTERNAL);
47 /// actions with extra argument
48 FuncRequest(FuncCode act, docstring const & arg,
49 Origin o = INTERNAL);
50 /// actions with extra argument. FIXME: remove this
51 FuncRequest(FuncCode act, std::string const & arg,
52 Origin o = INTERNAL);
53 /// for changing requests a bit
54 FuncRequest(FuncRequest const & cmd, docstring const & arg,
55 Origin o = INTERNAL);
56 /// for changing requests a bit. FIXME: remove this
57 FuncRequest(FuncRequest const & cmd, std::string const & arg,
58 Origin o = INTERNAL);
60 /// access to button
61 mouse_button::state button() const;
63 /// argument parsing, extract argument i as std::string
64 std::string getArg(unsigned int i) const;
66 /// access the whole argument
67 docstring const & argument() const { return argument_; }
69 ///
70 static FuncRequest const unknown;
71 ///
72 static FuncRequest const noaction;
73 public: // should be private
74 /// the action
75 FuncCode action;
76 private:
77 /// the action's string argument
78 docstring argument_;
79 public: // should be private
80 /// who initiated the action
81 Origin origin;
82 /// the x coordinate of a mouse press
83 int x;
84 /// the y coordinate of a mouse press
85 int y;
86 /// some extra information (like button number)
87 mouse_button::state button_;
91 bool operator==(FuncRequest const & lhs, FuncRequest const & rhs);
93 std::ostream & operator<<(std::ostream &, FuncRequest const &);
96 } // namespace lyx
98 #endif // FUNCREQUEST_H