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/KeyModifier.h"
20 #include "frontends/mouse_state.h"
28 * This class encapsulates a LyX action and its argument
29 * in order to pass it around easily.
34 /// Where the request came from
38 TOOLBAR, // A toolbar icon
39 KEYBOARD, // a keyboard binding
45 /// just for putting these things in std::container
46 explicit FuncRequest(Origin o = INTERNAL);
47 /// actions without extra argument
48 explicit FuncRequest(FuncCode act, Origin o = INTERNAL);
49 /// actions without extra argument
50 FuncRequest(FuncCode act, int x, int y, mouse_button::state button,
51 KeyModifier modifier, Origin o = INTERNAL);
52 /// actions with extra argument
53 FuncRequest(FuncCode act, docstring const & arg,
55 /// actions with extra argument. FIXME: remove this
56 FuncRequest(FuncCode act, std::string const & arg,
58 /// for changing requests a bit
59 FuncRequest(FuncRequest const & cmd, docstring const & arg,
62 /// access the whole argument
63 docstring const & argument() const { return argument_; }
65 FuncCode action() const { return action_ ; }
67 void setAction(FuncCode act) { action_ = act; }
69 Origin origin() const { return origin_; }
71 void setOrigin(Origin o) { origin_ = o; }
73 int x() const { return x_; }
75 int y() const { return y_; }
77 void set_y(int y) { y_ = y; }
79 mouse_button::state button() const { return button_; }
81 KeyModifier modifier() { return modifier_; }
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_;
107 KeyModifier modifier_;
111 bool operator==(FuncRequest const & lhs, FuncRequest const & rhs);
113 std::ostream & operator<<(std::ostream &, FuncRequest const &);
115 LyXErr & operator<<(LyXErr &, FuncRequest const &);
120 #endif // FUNCREQUEST_H