]> git.lyx.org Git - lyx.git/blob - src/insets/InsetInfo.h
Change the "empty layout" to the "plain layout", to try to avoid confusion.
[lyx.git] / src / insets / InsetInfo.h
1 // -*- C++ -*-
2 /**
3  * \file InsetInfo.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Bo Peng
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef INSET_INFO_H
13 #define INSET_INFO_H
14
15 #include "InsetText.h"
16 #include "RenderButton.h"
17 #include "Cursor.h"
18
19 #include "support/gettext.h"
20 #include "support/Translator.h"
21
22 /* InsetInfo displays shortcuts, lyxrc, package and textclass
23 availability and menu information in a non-editable boxed InsetText.
24
25 Output of such an inset may vary from system to system, depending
26 on LyX and LaTeX configurations. Two LyX help files, LaTeXConfig.lyx
27 and Shortcuts.lyx make heavy use of this inset. The former uses it
28 to display the availability of packages and textclasses, the latter
29 uses it to display currently used shortcuts.
30
31 This inset has two arguments: the type and argument of the information. The
32 screen and latex output is the content of the information. An InsetInfo can
33 have type "shortcuts", "shortcut", "lyxrc", "package", "textclass", "menu",
34 or "buffer". Arguments and outputs vary by type.
35
36 shortcuts: argument of this type of InsetInfo is the name of the LFUN such as
37     "math-insert \alpha". The syntax is the same as what is used in the bind
38     and ui files. The output of this inset is all shortcuts for this LFUN
39     separated by comma.
40
41 shortcut: the same as shortcuts, but only output the last shortcut.
42
43 lyxrc: argument is the name of the rc entry such as "bind_file". Look in
44     src/LyXRC.h for available entries. The output is the content of this RC
45     entry.
46
47 package: argument is the name of a latex package such as "listings". The
48     output is "yes" or "no", indicating the availability of this package.
49
50 textclass: argument is the name a textclass such as "article". The output is
51     "yes" or "no", indicating the availability of this textclass.
52
53 menu: argument is the name of the LFUN such as "paste". The syntax is the same
54     as what is used in the bind and ui files. The output is the menu item that
55     triggers this LFUN. For example, "File > Paste", where '>' is actually
56     \lyxarrow (an InsetSpecialChar).
57
58 icon: argument is the name of the LFUN such as "paste". The syntax is the same
59     as what is used in the bind and ui files. The output is the icon use in
60     the toolbar for this LFUN.
61
62 buffer: argument can be one of "name", "path", "class". This inset output the
63     filename, path, and textclass of this buffer.
64
65 There is currently no GUI, no menu entry for this inset. A user can define a
66 shortcut for "info-insert" (e.g. C-S-I), and
67
68 1. input the type and argument of this inset, e.g. "menu paste", in
69    the work area.
70 2. select the text and run "info-insert" (e.g. press C-S-I).
71
72 An alternative method is to enter command "info-insert type arg" in
73 the command buffer (view->Toolbar->Command Buffer).
74
75 */
76
77 namespace lyx {
78
79 /** Used to insert index labels
80   */
81 class InsetInfo : public InsetText {
82 public:
83         enum info_type {
84                 UNKNOWN_INFO,   // Invalid type
85                 SHORTCUTS_INFO, // Keyboard shortcuts
86                 SHORTCUT_INFO,  // Keyboard shortcut
87                 LYXRC_INFO,     // RC entry
88                 PACKAGE_INFO,   // Availability of package
89                 TEXTCLASS_INFO, // Availability of textclass
90                 MENU_INFO,      // Which menu item is used for certain function
91                 ICON_INFO,      // which toolbar icon is used for certain function
92                 BUFFER_INFO,    // Buffer related information
93         };
94
95         ///
96         InsetInfo(Buffer const & buf, std::string const & info = std::string());
97         ///
98         Inset * editXY(Cursor & cur, int x, int y);
99         ///
100         EDITABLE editable() const { return NOT_EDITABLE; }
101         ///
102         void draw(PainterInfo & pi, int x, int y) const;
103         ///
104         void read(Lexer & lex);
105         ///
106         void write(std::ostream & os) const;
107         ///
108         std::string infoType() const;
109         ///
110         std::string infoName() const { return name_; }
111         ///
112         bool validate(docstring const & argument) const;
113         ///
114         bool showInsetDialog(BufferView * bv) const;
115         ///
116         bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
117         ///
118         void doDispatch(Cursor & cur, FuncRequest & cmd);
119         ///
120         InsetCode lyxCode() const { return INFO_CODE; }
121         ///
122         void setInfo(std::string const & info);
123         /// update info_ and text
124         void updateInfo();
125         ///
126         bool setMouseHover(bool mouse_hover);
127         ///
128         docstring toolTip(BufferView const & bv, int x, int y) const;
129         ///
130         docstring contextMenu(BufferView const &, int, int) const;
131
132 private:
133         /// The translator between the information type enum and corresponding string.
134         Translator<info_type, std::string> const & nameTranslator() const;
135         ///
136         virtual Inset * clone() const { return new InsetInfo(*this); }
137         ///
138         void error(std::string const & err);
139         ///
140         void setText(docstring const & str);
141         ///
142         info_type type_;
143         ///
144         std::string name_;
145         ///
146         bool mouse_hover_;
147 };
148
149
150
151 } // namespace lyx
152
153 #endif