]> git.lyx.org Git - lyx.git/blob - src/insets/InsetScript.h
Move Lexer to support/ directory (and lyx::support namespace)
[lyx.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 "FontInfo.h"
16 #include "InsetText.h"
17
18
19 namespace lyx {
20
21 class InsetScriptParams
22 {
23 public:
24         enum Type {
25                 Subscript,
26                 Superscript
27         };
28         /// \c type defaults to Subscript
29         InsetScriptParams();
30         ///
31         void write(std::ostream & os) const;
32         ///
33         void read(support::Lexer & lex);
34         ///
35         int shift(FontInfo const & font) const;
36         ///
37         Type type;
38 };
39
40
41 /////////////////////////////////////////////////////////////////////////
42 //
43 // InsetScript
44 //
45 /////////////////////////////////////////////////////////////////////////
46
47 /// The subscript and superscript inset
48 class InsetScript : public InsetText
49 {
50 public:
51         ///
52         InsetScript(Buffer *, InsetScriptParams const & = InsetScriptParams());
53         ///
54         InsetScript(Buffer *, std::string const &);
55         ///
56         ~InsetScript();
57         ///
58         static std::string params2string(InsetScriptParams const &);
59         ///
60         static void string2params(std::string const &, InsetScriptParams &);
61         ///
62         InsetScriptParams const & params() const { return params_; }
63
64         /// \name Public functions inherited from Inset class
65         //@{
66         ///
67         InsetCode lyxCode() const override { return SCRIPT_CODE; }
68         ///
69         docstring layoutName() const override;
70
71         ///
72         int topOffset(BufferView const *) const override { return 0; }
73         ///
74         int bottomOffset(BufferView const *) const override { return 0; }
75         ///
76         int leftOffset(BufferView const *) const override { return 0; }
77         ///
78         int rightOffset(BufferView const *) const override { return 0; }
79
80         ///
81         void metrics(MetricsInfo &, Dimension &) const override;
82         ///
83         void draw(PainterInfo & pi, int x, int y) const override;
84         ///
85         void cursorPos(BufferView const & bv,
86                 CursorSlice const & sl, bool boundary, int & x, int & y) const override;
87         ///
88         void write(std::ostream &) const override;
89         ///
90         void read(support::Lexer & lex) override;
91         ///
92         bool forcePlainLayout(idx_type = 0) const override { return true; }
93         ///
94         bool allowParagraphCustomization(idx_type = 0) const override { return false; }
95         ///
96         bool neverIndent() const override { return true; }
97         ///
98         int plaintext(odocstringstream & ods, OutputParams const & op,
99                       size_t max_length = INT_MAX) const override;
100         ///
101         void docbook(XMLStream &, OutputParams const &) const override;
102         ///
103         void edit(Cursor & cur, bool front,
104                   EntryDirection entry_from = ENTRY_DIRECTION_IGNORE) override;
105         ///
106         Inset * editXY(Cursor & cur, int x, int y) override;
107         ///
108         bool insetAllowed(InsetCode code) const override;
109         ///
110         bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const override;
111         ///
112         docstring toolTip(BufferView const & bv, int x, int y) const override;
113         ///
114         Inset * clone() const override { return new InsetScript(*this); }
115         ///
116         std::string contextMenuName() const override;
117         //@}
118
119         /// \name Public functions inherited from InsetText class
120         //@{
121         ///
122         bool allowMultiPar() const override { return false; }
123         //@}
124
125 protected:
126         /// \name Protected functions inherited from Inset class
127         //@{
128         ///
129         void doDispatch(Cursor & cur, FuncRequest & cmd) override;
130         //@}
131
132 private:
133         /// used by the constructors
134         void init();
135         ///
136         friend class InsetScriptParams;
137         ///
138         InsetScriptParams params_;
139         /// The font of containing inset; this is necessary to compute shift
140         mutable FontInfo outer_font_;
141 };
142
143
144 } // namespace lyx
145
146 #endif