]> git.lyx.org Git - lyx.git/blob - src/insets/InsetInfo.h
* Inset: Prepare for an eventual merge of updateLabels() and addToToc()
[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 "support/gettext.h"
18 #include "Cursor.h"
19 #include "support/Translator.h"
20
21 /* InsetInfo displays shortcuts, lyxrc, package and textclass 
22 availability and menu information in a non-editable boxed InsetText.
23
24 Output of such an inset may vary from system to system, depending
25 on LyX and LaTeX configurations. Two LyX help files, LaTeXConfig.lyx
26 and Shortcuts.lyx make heavy use of this inset. The former uses it
27 to display the availability of packages and textclasses, the latter
28 uses it to display currently used shortcuts.
29
30 This inset has two arguments: the type and argument of the information. The
31 screen and latex output is the content of the information. An InsetInfo can
32 have type "shortcut", "lyxrc", "package", "textclass", "menu", or "buffer".
33 Arguments and outputs vary by type.
34
35 shortcut: argument of this type of InsetInfo is the name of the LFUN such as
36     "math-insert \alpha". The syntax is the same as what is used in the bind
37     and ui files. The output of this inset is all shortcuts for this LFUN
38     separated by comma.
39
40 lyxrc: argument is the name of the rc entry such as "bind_file". Look in 
41     src/LyXRC.h for available entries. The output is the content of this RC
42     entry.
43
44 package: argument is the name of a latex package such as "listings". The
45     output is "yes" or "no", indicating the availability of this package.
46
47 textclass: argument is the name a textclass such as "article". The output is
48     "yes" or "no", indicating the availability of this textclass.
49
50 menu: argument is the name of the LFUN such as "paste". The syntax is the same
51     as what is used in the bind and ui files. The output is the menu item that
52     triggers this LFUN. For example, "File > Paste", where '>' is actually
53     \lyxarrow (an InsetSpecialChar).
54
55 buffer: argument can be one of "name", "path", "class". This inset output the 
56     filename, path, and textclass of this buffer.
57
58 There is currently no GUI, no menu entry for this inset. A user can define a 
59 shortcut for "info-insert" (e.g. C-S-I), and
60
61 1. input the type and argument of this inset, e.g. "menu paste", in 
62    the work area.
63 2. select the text and run "info-insert" (e.g. press C-S-I).
64
65 An alternative method is to enter command "info-insert type arg" in 
66 the command buffer (view->Toolbar->Command Buffer).
67
68 */
69
70 namespace lyx {
71
72 /** Used to insert index labels
73   */
74 class InsetInfo : public InsetText {
75 public:
76         enum info_type {
77                 UNKNOWN_INFO,   // Invalid type
78                 SHORTCUT_INFO,  // Keyboard shortcut
79                 LYXRC_INFO,     // RC entry
80                 PACKAGE_INFO,   // Availability of package
81                 TEXTCLASS_INFO, // Availability of textclass
82                 MENU_INFO,      // Which menu item is used for certain function
83                 BUFFER_INFO,    // Buffer related information
84         };
85
86         ///
87         InsetInfo(BufferParams const & bp, std::string const & info = std::string());
88         ///
89         Inset * editXY(Cursor & cur, int x, int y);
90         ///
91         EDITABLE editable() const { return NOT_EDITABLE; }
92         ///
93         void draw(PainterInfo & pi, int x, int y) const;
94         ///
95         void read(Buffer const &, Lexer & lex);
96         ///
97         void write(Buffer const & buf, std::ostream & os) const;
98         ///
99         void doDispatch(Cursor & cur, FuncRequest & cmd);
100         ///
101         InsetCode lyxCode() const { return INFO_CODE; }
102         ///
103         void setInfo(std::string const & info);
104         /// update info_ and text
105         void updateInfo(Buffer const &);
106         ///
107         bool setMouseHover(bool mouse_hover);
108
109 private:
110         /// The translator between the information type enum and corresponding string.
111         Translator<info_type, std::string> const & nameTranslator() const;
112         ///
113         virtual Inset * clone() const { return new InsetInfo(*this); }
114         ///
115         info_type type_;
116         ///
117         std::string name_;
118         ///
119         bool mouse_hover_;
120 };
121
122
123
124 } // namespace lyx
125
126 #endif