3 * \file math_scriptinset.h
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 MATH_SCRIPTINSET_H
13 #define MATH_SCRIPTINSET_H
15 #include "math_nestinset.h"
18 /// An inset for super- and subscripts.
19 class MathScriptInset : public MathNestInset {
21 /// create inset without scripts
23 /// create inset with single script
24 explicit MathScriptInset(bool up);
25 /// create inset with single script and given nucleus
26 MathScriptInset(MathAtom const & at, bool up);
28 std::auto_ptr<InsetBase> clone() const;
30 void metrics(MetricsInfo & mi, Dimension & dim) const;
32 void draw(PainterInfo & pi, int x, int y) const;
34 void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
36 void drawT(TextPainter & pi, int x, int y) const;
39 bool idxLeft(LCursor & cur) const;
41 bool idxRight(LCursor & cur) const;
42 /// move cursor up or down
43 bool idxUpDown(LCursor & cur, bool up) const;
44 /// Target pos when we enter the inset from the left by pressing "Right"
45 bool idxFirst(LCursor & cur) const;
46 /// Target pos when we enter the inset from the right by pressing "Left"
47 bool idxLast(LCursor & cur) const;
48 /// can we enter this cell?
49 bool validCell(idx_type i) const { return i == 2 || script_[i]; }
51 /// write LaTeX and Lyx code
52 void write(WriteStream & os) const;
53 /// write normalized content
54 void normalize(NormalStream &) const;
55 /// write content as something readable by Maple
56 void maple(MapleStream &) const;
57 /// write content as something readable by Mathematica
58 void mathematica(MathematicaStream &) const;
59 /// write content as something resembling MathML
60 void mathmlize(MathMLStream &) const;
61 /// write content as something readable by Octave
62 void octave(OctaveStream &) const;
64 /// identifies scriptinsets
65 MathScriptInset const * asScriptInset() const;
67 MathScriptInset * asScriptInset();
70 void limits(int lim) { limits_ = lim; }
72 int limits() const { return limits_; }
74 MathArray const & down() const;
77 /// returns superscript
78 MathArray const & up() const;
79 /// returns superscript
82 MathArray const & nuc() const;
85 /// do we have a superscript?
87 /// do we have a subscript?
89 /// do we have a script?
90 bool has(bool up) const;
92 void removeScript(bool up);
93 /// make sure a script is accessible
95 /// say that we have scripts
96 void infoize(std::ostream & os) const;
97 /// say whether we have displayed limits
98 void infoize2(std::ostream & os) const;
101 DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
103 /// returns x offset for main part
105 /// returns width of nucleus if any
107 /// returns y offset for superscript
109 /// returns y offset for subscript
111 /// returns x offset for superscript
113 /// returns x offset for subscript
115 /// returns ascent of nucleus if any
117 /// returns descent of nucleus if any
119 /// where do we have to draw the scripts?
120 bool hasLimits() const;
121 /// clean up empty cells
122 void notifyCursorLeaves(idx_type idx);
124 /// possible subscript (index 0) and superscript (index 1)
126 /// 1 - "limits", -1 - "nolimits", 0 - "default"