4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
17 #include "support/docstring.h"
19 #include "frontends/mouse_state.h"
27 * This class encapsulates a LyX action and its argument
28 * in order to pass it around easily.
33 /// Where the request came from
37 TOOLBAR, // A toolbar icon
38 KEYBOARD, // a keyboard binding
44 /// just for putting these things in std::container
45 explicit FuncRequest(Origin o = INTERNAL);
46 /// actions without extra argument
47 explicit FuncRequest(FuncCode act, Origin o = INTERNAL);
48 /// actions without extra argument
49 FuncRequest(FuncCode act, int x, int y, mouse_button::state button,
51 /// actions with extra argument
52 FuncRequest(FuncCode act, docstring const & arg,
54 /// actions with extra argument. FIXME: remove this
55 FuncRequest(FuncCode act, std::string const & arg,
57 /// for changing requests a bit
58 FuncRequest(FuncRequest const & cmd, docstring const & arg,
60 /// for changing requests a bit. FIXME: remove this
61 FuncRequest(FuncRequest const & cmd, std::string const & arg,
64 /// access the whole argument
65 docstring const & argument() const { return argument_; }
67 FuncCode action() const { return action_ ; }
69 void setAction(FuncCode act) { action_ = act; }
71 Origin origin() const { return origin_; }
73 void setOrigin(Origin o) { origin_ = o; }
75 int x() const { return x_; }
77 int y() const { return y_; }
79 void set_y(int y) { y_ = y; }
81 mouse_button::state button() const { return button_; }
83 /// argument parsing, extract argument i as std::string
84 std::string getArg(unsigned int i) const;
85 /// argument parsing, extract argument i as std::string,
86 /// eating all characters up to the end of the command line
87 std::string getLongArg(unsigned int i) const;
90 static FuncRequest const unknown;
92 static FuncRequest const noaction;
96 /// the action's string argument
98 /// who initiated the action
100 /// the x coordinate of a mouse press
102 /// the y coordinate of a mouse press
104 /// some extra information (like button number)
105 mouse_button::state button_;
109 bool operator==(FuncRequest const & lhs, FuncRequest const & rhs);
111 std::ostream & operator<<(std::ostream &, FuncRequest const &);
113 LyXErr & operator<<(LyXErr &, FuncRequest const &);
118 #endif // FUNCREQUEST_H