2 #ifndef MATH_SCRIPTINSET_H
3 #define MATH_SCRIPTINSET_H
5 #include "math_nestinset.h"
11 /** Inset for super- and subscripts
15 class MathScriptInset : public MathNestInset {
17 /// create inset without scripts
19 /// create inset with single script
20 explicit MathScriptInset(bool up);
21 /// create inset with single script and given nucleus
22 MathScriptInset(MathAtom const & at, bool up);
24 MathInset * clone() const;
26 void metrics(MathMetricsInfo & mi) const;
28 void draw(MathPainterInfo & pi, int x, int y) const;
30 void metricsT(TextMetricsInfo const & mi) const;
32 void drawT(TextPainter & pi, int x, int y) const;
34 /// write LaTeX and Lyx code
35 void write(WriteStream & os) const;
36 /// write normalized content
37 void normalize(NormalStream &) const;
38 /// write content as something readable by Maple
39 void maplize(MapleStream &) const;
40 /// write content as something readable by Mathematica
41 void mathematicize(MathematicaStream &) const;
42 /// write content as something resembling MathML
43 void mathmlize(MathMLStream &) const;
44 /// write content as something readable by Octave
45 void octavize(OctaveStream &) const;
47 bool idxLeft(idx_type &, pos_type &) const;
49 bool idxRight(idx_type &, pos_type &) const;
50 /// move cursor up or down
51 bool idxUpDown(idx_type & idx, pos_type & pos, bool up, int targetx) const;
52 /// Target pos when we enter the inset from the left by pressing "Right"
53 bool idxFirst(idx_type & idx, pos_type & pos) const;
54 /// Target pos when we enter the inset from the right by pressing "Left"
55 bool idxLast(idx_type & idx, pos_type & pos) const;
56 /// can we enter this cell?
57 bool validCell(idx_type i) const { return script_[i]; }
59 /// identifies scriptinsets
60 MathScriptInset const * asScriptInset() const;
62 MathScriptInset * asScriptInset();
65 void limits(int lim) { limits_ = lim; }
67 int limits() const { return limits_; }
69 MathArray const & down() const;
72 /// returns superscript
73 MathArray const & up() const;
74 /// returns superscript
77 MathArray const & nuc() const;
80 /// do we have a superscript?
82 /// do we have a subscript?
84 /// do we have a script?
85 bool has(bool up) const;
87 void removeScript(bool up);
89 void removeEmptyScripts();
90 /// make sure a script is accessible
93 void infoize(std::ostream & os) const;
95 result_type dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
98 /// returns x offset for main part
100 /// returns width of nucleus if any
102 /// returns y offset for superscript
104 /// returns y offset for subscript
106 /// returns x offset for superscript
108 /// returns x offset for subscript
110 /// returns ascent of nucleus if any
112 /// returns descent of nucleus if any
114 /// where do we have to draw the scripts?
115 bool hasLimits() const;
117 /// possible subscript (index 0) and superscript (index 1)
119 /// 1 - "limits", -1 - "nolimits", 0 - "default"