]> git.lyx.org Git - lyx.git/blob - src/FuncRequest.h
Translations for listings insets
[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 "FuncCode.h"
16
17 #include "support/docstring.h"
18
19 #include "frontends/mouse_state.h"
20
21
22 namespace lyx {
23
24 /**
25  * This class encapsulates a LyX action and its argument
26  * in order to pass it around easily.
27  */
28 class FuncRequest
29 {
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, 
38                 TOC
39         };
40
41         /// just for putting these things in std::container
42         explicit FuncRequest(Origin o = INTERNAL);
43         /// actions without extra argument
44         explicit FuncRequest(FuncCode act, Origin o = INTERNAL);
45         /// actions without extra argument
46         FuncRequest(FuncCode act, int x, int y, mouse_button::state button,
47                     Origin o = INTERNAL);
48         /// actions with extra argument
49         FuncRequest(FuncCode act, docstring const & arg,
50                     Origin o = INTERNAL);
51         /// actions with extra argument. FIXME: remove this
52         FuncRequest(FuncCode act, std::string const & arg,
53                     Origin o = INTERNAL);
54         /// for changing requests a bit
55         FuncRequest(FuncRequest const & cmd, docstring const & arg,
56                     Origin o = INTERNAL);
57         /// for changing requests a bit. FIXME: remove this
58         FuncRequest(FuncRequest const & cmd, std::string const & arg,
59                     Origin o = INTERNAL);
60
61         /// access the whole argument
62         docstring const & argument() const { return argument_; }
63         ///
64         FuncCode action() const { return action_ ; }
65         ///
66         void setAction(FuncCode act) { action_ = act; }
67         ///
68         Origin origin() const { return origin_; }
69         ///
70         void setOrigin(Origin o) { origin_ = o; }
71         ///
72         int x() const { return x_; }
73         ///
74         int y() const { return y_; }
75         ///
76         void set_y(int y) { y_ = y; }
77         /// 
78         mouse_button::state button() const { return button_; }
79
80         /// argument parsing, extract argument i as std::string
81         std::string getArg(unsigned int i) const;
82         /// argument parsing, extract argument i as std::string,
83         /// eating all characters up to the end of the command line
84         std::string getLongArg(unsigned int i) const;
85
86         /// 
87         static FuncRequest const unknown;
88         /// 
89         static FuncRequest const noaction;
90 private:
91         /// the action
92         FuncCode action_;
93         /// the action's string argument
94         docstring argument_;
95         /// who initiated the action
96         Origin origin_;
97         /// the x coordinate of a mouse press
98         int x_;
99         /// the y coordinate of a mouse press
100         int y_;
101         /// some extra information (like button number)
102         mouse_button::state button_;
103 };
104
105
106 bool operator==(FuncRequest const & lhs, FuncRequest const & rhs);
107
108 std::ostream & operator<<(std::ostream &, FuncRequest const &);
109
110
111 } // namespace lyx
112
113 #endif // FUNCREQUEST_H