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"
25 * This class encapsulates a LyX action and its argument
26 * in order to pass it around easily.
31 /// Where the request came from
35 TOOLBAR, // A toolbar icon
36 KEYBOARD, // a keyboard binding
42 /// just for putting these things in std::container
43 explicit FuncRequest(Origin o = INTERNAL);
44 /// actions without extra argument
45 explicit FuncRequest(FuncCode act, Origin o = INTERNAL);
46 /// actions without extra argument
47 FuncRequest(FuncCode act, int x, int y, mouse_button::state button,
49 /// actions with extra argument
50 FuncRequest(FuncCode act, docstring const & arg,
52 /// actions with extra argument. FIXME: remove this
53 FuncRequest(FuncCode act, std::string const & arg,
55 /// for changing requests a bit
56 FuncRequest(FuncRequest const & cmd, docstring const & arg,
58 /// for changing requests a bit. FIXME: remove this
59 FuncRequest(FuncRequest const & cmd, std::string 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 /// argument parsing, extract argument i as std::string
82 std::string getArg(unsigned int i) const;
83 /// argument parsing, extract argument i as std::string,
84 /// eating all characters up to the end of the command line
85 std::string getLongArg(unsigned int i) const;
88 static FuncRequest const unknown;
90 static FuncRequest const noaction;
94 /// the action's string argument
96 /// who initiated the action
98 /// the x coordinate of a mouse press
100 /// the y coordinate of a mouse press
102 /// some extra information (like button number)
103 mouse_button::state button_;
107 bool operator==(FuncRequest const & lhs, FuncRequest const & rhs);
109 std::ostream & operator<<(std::ostream &, FuncRequest const &);
114 #endif // FUNCREQUEST_H