2 #ifndef MATH_SCRIPTINSET_H
3 #define MATH_SCRIPTINSET_H
5 #include "math_nestinset.h"
11 /** Inset for super- and subscripts
12 * \author André Pönitz
14 * Full author contact details are available in file CREDITS
17 class MathScriptInset : public MathNestInset {
19 /// create inset without scripts
21 /// create inset with single script
22 explicit MathScriptInset(bool up);
23 /// create inset with single script and given nucleus
24 MathScriptInset(MathAtom const & at, bool up);
26 MathInset * clone() const;
28 void metrics(MathMetricsInfo & mi) const;
30 void draw(MathPainterInfo & pi, int x, int y) const;
32 void metricsT(TextMetricsInfo const & mi) const;
34 void drawT(TextPainter & pi, int x, int y) const;
36 /// write LaTeX and Lyx code
37 void write(WriteStream & os) const;
38 /// write normalized content
39 void normalize(NormalStream &) const;
40 /// write content as something readable by Maple
41 void maplize(MapleStream &) const;
42 /// write content as something readable by Mathematica
43 void mathematicize(MathematicaStream &) const;
44 /// write content as something resembling MathML
45 void mathmlize(MathMLStream &) const;
46 /// write content as something readable by Octave
47 void octavize(OctaveStream &) const;
49 bool idxLeft(idx_type &, pos_type &) const;
51 bool idxRight(idx_type &, pos_type &) const;
52 /// move cursor up or down
53 bool idxUpDown(idx_type & idx, pos_type & pos, bool up, int targetx) const;
54 /// Target pos when we enter the inset from the left by pressing "Right"
55 bool idxFirst(idx_type & idx, pos_type & pos) const;
56 /// Target pos when we enter the inset from the right by pressing "Left"
57 bool idxLast(idx_type & idx, pos_type & pos) const;
58 /// can we enter this cell?
59 bool validCell(idx_type i) const { return script_[i]; }
61 /// identifies scriptinsets
62 MathScriptInset const * asScriptInset() const;
64 MathScriptInset * asScriptInset();
67 void limits(int lim) { limits_ = lim; }
69 int limits() const { return limits_; }
71 MathArray const & down() const;
74 /// returns superscript
75 MathArray const & up() const;
76 /// returns superscript
79 MathArray const & nuc() const;
82 /// do we have a superscript?
84 /// do we have a subscript?
86 /// do we have a script?
87 bool has(bool up) const;
89 void removeScript(bool up);
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;
116 /// clean up empty cells
117 void notifyCursorLeaves(idx_type idx);
119 /// possible subscript (index 0) and superscript (index 1)
121 /// 1 - "limits", -1 - "nolimits", 0 - "default"