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(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(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 bool inheritFont() const override { return true; }
100 int plaintext(odocstringstream & ods, OutputParams const & op,
101 size_t max_length = INT_MAX) const override;
103 void docbook(XMLStream &, OutputParams const &) const override;
105 void edit(Cursor & cur, bool front,
106 EntryDirection entry_from = ENTRY_DIRECTION_IGNORE) override;
108 Inset * editXY(Cursor & cur, int x, int y) override;
110 bool insetAllowed(InsetCode code) const override;
112 bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const override;
114 docstring toolTip(BufferView const & bv, int x, int y) const override;
116 Inset * clone() const override { return new InsetScript(*this); }
118 std::string contextMenuName() const override;
121 /// \name Public functions inherited from InsetText class
124 bool allowMultiPar() const override { return false; }
128 /// \name Protected functions inherited from Inset class
131 void doDispatch(Cursor & cur, FuncRequest & cmd) override;
135 /// used by the constructors
138 friend class InsetScriptParams;
140 InsetScriptParams params_;
141 /// The font of containing inset; this is necessary to compute shift
142 mutable FontInfo outer_font_;