]> git.lyx.org Git - lyx.git/blob - src/insets/InsetInfo.h
280303c05cb163d88a6193ec94b63367d606cf9e
[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 "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 as 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.
31 The screen and latex output is the content of the information. An 
32 InsetInfo can have type "shortcut", "lyxrc", "package", "textclass", or
33 "menu". Arguments and outputs vary by type.
34
35 shortcut: name of the LFUN such as "math-insert \alpha". The syntax
36     is the same as what is used in the bind and ui files.
37     The output of this inset is all shortcuts separated by comma.
38
39 lyxrc: name of the rc entry such as "bind_file". Look in src/LyXRC.h
40     for available entries. The output is the content of this RC
41     entry.
42
43 package: name of a latex package such as "listings". The output is
44     "yes" or "no".
45
46 textclass: name of a textclass such as "article". The output is "yes"
47     or "no".
48
49 menu: name of the LFUN such as "paste". The syntax is the same as
50     what is used in the bind and ui files. The output is the
51     menu item that trigger this LFUN. For example, "File > Paste".
52     '>' is actually \lyxarrow (an InsetSpecialChar).
53
54
55 Because this inset is intended to be used only by document maintainers,
56 there is no GUI, no menu entry for this inset. A user can define a 
57 shortcut for "info-insert" (e.g. C-S-I), and
58
59 1. input the type and argument of this inset, e.g. "menu paste", in 
60    the work area.
61 2. select the text and run "info-insert" (e.g. press C-S-I).
62
63 An alternative method is to enter command "info-insert type args" in 
64 the command buffer (view->Toolbar->Command Buffer).
65
66 */
67
68 namespace lyx {
69
70 /** Used to insert index labels
71   */
72 class InsetInfo : public InsetText {
73 public:
74         enum info_type {
75                 UNKNOWN_INFO,   // Invalid type
76                 SHORTCUT_INFO,  // Keyboard shortcut
77                 LYXRC_INFO,     // RC entry
78                 PACKAGE_INFO,   // Availability of package
79                 TEXTCLASS_INFO, // Availability of textclass
80                 MENU_INFO,      // Which menu item is used for certain function
81         };
82
83         ///
84         InsetInfo(BufferParams const & bp, std::string const & info = std::string());
85         ///
86         Inset * editXY(Cursor & cur, int x, int y);
87         ///
88         EDITABLE editable() const { return NOT_EDITABLE; }
89         ///
90         void draw(PainterInfo & pi, int x, int y) const;
91         ///
92         void read(Buffer const &, Lexer & lex);
93         ///
94         void write(Buffer const & buf, std::ostream & os) const;
95         ///
96         void doDispatch(Cursor & cur, FuncRequest & cmd);
97         ///
98         InsetCode lyxCode() const { return INFO_CODE; }
99         ///
100         void setInfo(std::string const & info);
101         ///
102         bool setMouseHover(bool mouse_hover);
103
104 private:
105         /// The translator between the information type enum and corresponding string.
106         Translator<info_type, std::string> const & nameTranslator() const;
107         /// update info_ and text
108         void updateInfo();
109         ///
110         virtual Inset * clone() const { return new InsetInfo(*this); }
111         ///
112         info_type type_;
113         ///
114         std::string name_;
115         /// store the buffer parameter
116         BufferParams const & bp_;
117         ///
118         bool mouse_hover_;
119 };
120
121
122
123 } // namespace lyx
124
125 #endif