4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
12 #ifndef INSET_SCRIPT_H
13 #define INSET_SCRIPT_H
16 #include "InsetText.h"
21 class InsetScriptParams
28 /// \c type defaults to Subscript
31 void write(std::ostream & os) const;
33 void read(support::Lexer & lex);
35 int shift(FontInfo const & font) const;
41 /////////////////////////////////////////////////////////////////////////
45 /////////////////////////////////////////////////////////////////////////
47 /// The subscript and superscript inset
48 class InsetScript : public InsetText
52 InsetScript(Buffer *, InsetScriptParams const & = InsetScriptParams());
54 InsetScript(Buffer *, std::string const &);
58 static std::string params2string(InsetScriptParams const &);
60 static void string2params(std::string const &, InsetScriptParams &);
62 InsetScriptParams const & params() const { return params_; }
64 /// \name Public functions inherited from Inset class
67 InsetCode lyxCode() const override { return SCRIPT_CODE; }
69 docstring layoutName() const override;
72 int topOffset(BufferView const *) const override { return 0; }
74 int bottomOffset(BufferView const *) const override { return 0; }
76 int leftOffset(BufferView const *) const override { return 0; }
78 int rightOffset(BufferView const *) const override { return 0; }
81 void metrics(MetricsInfo &, Dimension &) const override;
83 void draw(PainterInfo & pi, int x, int y) const override;
85 void cursorPos(BufferView const & bv,
86 CursorSlice const & sl, bool boundary, int & x, int & y) const override;
88 void write(std::ostream &) const override;
90 void read(support::Lexer & lex) override;
92 bool forcePlainLayout(idx_type = 0) const override { return true; }
94 bool allowParagraphCustomization(idx_type = 0) const override { return false; }
96 bool neverIndent() const override { return true; }
98 int plaintext(odocstringstream & ods, OutputParams const & op,
99 size_t max_length = INT_MAX) const override;
101 void docbook(XMLStream &, OutputParams const &) const override;
103 void edit(Cursor & cur, bool front,
104 EntryDirection entry_from = ENTRY_DIRECTION_IGNORE) override;
106 Inset * editXY(Cursor & cur, int x, int y) override;
108 bool insetAllowed(InsetCode code) const override;
110 bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const override;
112 docstring toolTip(BufferView const & bv, int x, int y) const override;
114 Inset * clone() const override { return new InsetScript(*this); }
116 std::string contextMenuName() const override;
119 /// \name Public functions inherited from InsetText class
122 bool allowMultiPar() const override { return false; }
126 /// \name Protected functions inherited from Inset class
129 void doDispatch(Cursor & cur, FuncRequest & cmd) override;
133 /// used by the constructors
136 friend class InsetScriptParams;
138 InsetScriptParams params_;
139 /// The font of containing inset; this is necessary to compute shift
140 mutable FontInfo outer_font_;