2 #ifndef MATH_SCRIPTINSET_H
3 #define MATH_SCRIPTINSET_H
5 #include "math_nestinset.h"
8 /** Inset for super- and subscripts
11 * Full author contact details are available in file CREDITS
14 class MathScriptInset : public MathNestInset {
16 /// create inset without scripts
18 /// create inset with single script
19 explicit MathScriptInset(bool up);
20 /// create inset with single script and given nucleus
21 MathScriptInset(MathAtom const & at, bool up);
23 MathInset * clone() const;
25 void metrics(MetricsInfo & mi) const;
27 void draw(PainterInfo & pi, int x, int y) const;
29 void metricsT(TextMetricsInfo const & mi) const;
31 void drawT(TextPainter & pi, int x, int y) const;
33 /// write LaTeX and Lyx code
34 void write(WriteStream & os) const;
35 /// write normalized content
36 void normalize(NormalStream &) const;
37 /// write content as something readable by Maple
38 void maple(MapleStream &) const;
39 /// write content as something readable by Mathematica
40 void mathematica(MathematicaStream &) const;
41 /// write content as something resembling MathML
42 void mathmlize(MathMLStream &) const;
43 /// write content as something readable by Octave
44 void octave(OctaveStream &) const;
46 bool idxLeft(idx_type &, pos_type &) const;
48 bool idxRight(idx_type &, pos_type &) const;
49 /// move cursor up or down
50 bool idxUpDown(idx_type & idx, pos_type & pos, bool up, int targetx) const;
51 /// Target pos when we enter the inset from the left by pressing "Right"
52 bool idxFirst(idx_type & idx, pos_type & pos) const;
53 /// Target pos when we enter the inset from the right by pressing "Left"
54 bool idxLast(idx_type & idx, pos_type & pos) const;
55 /// can we enter this cell?
56 bool validCell(idx_type i) const { return i == 2 || script_[i]; }
58 /// identifies scriptinsets
59 MathScriptInset const * asScriptInset() const;
61 MathScriptInset * asScriptInset();
64 void limits(int lim) { limits_ = lim; }
66 int limits() const { return limits_; }
68 MathArray const & down() const;
71 /// returns superscript
72 MathArray const & up() const;
73 /// returns superscript
76 MathArray const & nuc() const;
79 /// do we have a superscript?
81 /// do we have a subscript?
83 /// do we have a script?
84 bool has(bool up) const;
86 void removeScript(bool up);
87 /// make sure a script is accessible
89 /// say that we have scripts
90 void infoize(std::ostream & os) const;
91 /// say whether we have displayed limits
92 void infoize2(std::ostream & os) const;
94 dispatch_result dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
97 /// returns x offset for main part
99 /// returns width of nucleus if any
101 /// returns y offset for superscript
103 /// returns y offset for subscript
105 /// returns x offset for superscript
107 /// returns x offset for subscript
109 /// returns ascent of nucleus if any
111 /// returns descent of nucleus if any
113 /// where do we have to draw the scripts?
114 bool hasLimits() const;
115 /// clean up empty cells
116 void notifyCursorLeaves(idx_type idx);
118 /// possible subscript (index 0) and superscript (index 1)
120 /// 1 - "limits", -1 - "nolimits", 0 - "default"