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
15 #include "InsetText.h"
20 class InsetScriptParams
27 /// \c type defaults to Subscript
30 void write(std::ostream & os) const;
32 void read(Lexer & lex);
34 int shift(FontInfo const & font) const;
40 /////////////////////////////////////////////////////////////////////////
44 /////////////////////////////////////////////////////////////////////////
46 /// The subscript and superscript inset
47 class InsetScript : public InsetText
51 InsetScript(Buffer *, InsetScriptParams const & = InsetScriptParams());
53 InsetScript(Buffer *, std::string const &);
57 static std::string params2string(InsetScriptParams const &);
59 static void string2params(std::string const &, InsetScriptParams &);
61 InsetScriptParams const & params() const { return params_; }
63 /// \name Public functions inherited from Inset class
66 InsetCode lyxCode() const { return SCRIPT_CODE; }
68 docstring layoutName() const;
70 DisplayType display() const;
73 int topOffset(BufferView const *) const { return 0; }
75 int bottomOffset(BufferView const *) const { return 0; }
77 int leftOffset(BufferView const *) const { return 0; }
79 int rightOffset(BufferView const *) const { return 0; }
82 void metrics(MetricsInfo &, Dimension &) const;
84 void draw(PainterInfo & pi, int x, int y) const;
86 void cursorPos(BufferView const & bv,
87 CursorSlice const & sl, bool boundary, int & x, int & y) const;
89 void write(std::ostream &) const;
91 void read(Lexer & lex);
93 bool forcePlainLayout(idx_type = 0) const { return true; }
95 bool allowParagraphCustomization(idx_type = 0) const { return false; }
97 bool neverIndent() const { return true; }
99 bool inheritFont() const { return true; }
101 int plaintext(odocstringstream & ods, OutputParams const & op,
102 size_t max_length = INT_MAX) const;
104 int docbook(odocstream &, OutputParams const &) const;
106 void edit(Cursor & cur, bool front,
107 EntryDirection entry_from = ENTRY_DIRECTION_IGNORE);
109 Inset * editXY(Cursor & cur, int x, int y);
111 bool insetAllowed(InsetCode code) const;
113 bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
115 docstring toolTip(BufferView const & bv, int x, int y) const;
117 Inset * clone() const { return new InsetScript(*this); }
119 std::string contextMenuName() const;
122 /// \name Public functions inherited from InsetText class
125 bool allowMultiPar() const { return false; }
129 /// \name Protected functions inherited from Inset class
132 void doDispatch(Cursor & cur, FuncRequest & cmd);
136 /// used by the constructors
139 friend class InsetScriptParams;
141 InsetScriptParams params_;
142 /// The font of containing inset; this is necessary to compute shift
143 mutable FontInfo outer_font_;