]> git.lyx.org Git - features.git/blob - src/insets/InsetScript.h
fix bug 3008: Add subscript/superscript inset for text
[features.git] / src / insets / InsetScript.h
1 // -*- C++ -*-
2 /**
3  * \file InsetScript.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Georg Baum
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef INSET_SCRIPT_H
13 #define INSET_SCRIPT_H
14
15 #include "InsetText.h"
16
17
18 namespace lyx {
19
20 class InsetScriptParams
21 {
22 public:
23         enum Type {
24                 Subscript,
25                 Superscript
26         };
27         /// \c type defaults to Subscript
28         InsetScriptParams();
29         ///
30         void write(std::ostream & os) const;
31         ///
32         void read(Lexer & lex);
33         ///
34         int shift(FontInfo const & font) const;
35         ///
36         Type type;
37 };
38
39
40 /////////////////////////////////////////////////////////////////////////
41 //
42 // InsetScript
43 //
44 /////////////////////////////////////////////////////////////////////////
45
46 /// The subscript and superscript inset
47 class InsetScript : public InsetText
48 {
49 public:
50         ///
51         InsetScript(Buffer *, InsetScriptParams const & = InsetScriptParams());
52         ///
53         InsetScript(Buffer *, std::string const &);
54         ///
55         ~InsetScript();
56         ///
57         static std::string params2string(InsetScriptParams const &);
58         ///
59         static void string2params(std::string const &, InsetScriptParams &);
60         ///
61         InsetScriptParams const & params() const { return params_; }
62 private:
63         ///
64         InsetCode lyxCode() const { return SCRIPT_CODE; }
65         ///
66         docstring name() const;
67         ///
68         DisplayType display() const;
69         ///
70         void metrics(MetricsInfo &, Dimension &) const;
71         ///
72         void draw(PainterInfo & pi, int x, int y) const;
73         ///
74         virtual void cursorPos(BufferView const & bv,
75                 CursorSlice const & sl, bool boundary, int & x, int & y) const;
76         ///
77         void write(std::ostream &) const;
78         ///
79         void read(Lexer & lex);
80         ///
81         bool neverIndent() const { return true; }
82         ///
83         virtual bool forcePlainLayout(idx_type = 0) const { return true; }
84         ///
85         virtual bool allowMultiPar() const { return false; }
86         ///
87         virtual bool allowParagraphCustomization(idx_type = 0) const { return false; }
88         ///
89         virtual void validate(LaTeXFeatures &) const;
90         ///
91         int latex(odocstream &, OutputParams const &) const;
92         ///
93         int plaintext(odocstream &, OutputParams const &) const;
94         ///
95         int docbook(odocstream &, OutputParams const &) const;
96         ///
97         docstring xhtml(XHTMLStream &, OutputParams const &) const;
98         ///
99         void edit(Cursor & cur, bool front,
100                   EntryDirection entry_from = ENTRY_DIRECTION_IGNORE);
101         ///
102         Inset * editXY(Cursor & cur, int x, int y);
103         ///
104         virtual bool insetAllowed(InsetCode code) const;
105         ///
106         bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
107         ///
108         void doDispatch(Cursor & cur, FuncRequest & cmd);
109         ///
110         docstring toolTip(BufferView const & bv, int x, int y) const;
111         ///
112         Inset * clone() const { return new InsetScript(*this); }
113         /// used by the constructors
114         void init();
115         ///
116         docstring contextMenu(BufferView const & bv, int x, int y) const;
117         ///
118         friend class InsetScriptParams;
119
120         ///
121         InsetScriptParams params_;
122 };
123
124
125 } // namespace lyx
126
127 #endif