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 {
20 explicit MathScriptInset(bool up);
22 MathInset * clone() const;
24 void write(WriteStream & os) const;
26 void normalize(NormalStream & os) const;
28 void metrics(MathMetricsInfo const & st) const;
30 void draw(Painter &, int x, int y) const;
33 void metrics(MathInset const * nuc, MathMetricsInfo const & st) const;
35 void draw(MathInset const * nuc, Painter &, int x, int y) const;
37 int ascent(MathInset const * nuc) const;
39 int descent(MathInset const * nuc) const;
41 int width(MathInset const * nuc) const;
44 bool idxLeft(idx_type &, pos_type &) const;
46 bool idxRight(idx_type &, pos_type &) const;
48 bool idxFirstUp(idx_type &, pos_type &) const;
50 bool idxFirstDown(idx_type &, pos_type &) const;
52 bool idxLastUp(idx_type &, pos_type &) const;
54 bool idxLastDown(idx_type &, pos_type &) const;
57 MathScriptInset const * asScriptInset() const;
59 MathScriptInset * asScriptInset();
62 void limits(int lim) { limits_ = lim; }
64 int limits() const { return limits_; }
66 bool hasLimits(MathInset const * nuc) const;
67 /// true if we have an "inner" position
68 MathXArray const & up() const;
70 MathXArray const & down() const;
71 /// returns superscript
75 /// do we have a superscript?
77 /// do we have a subscript?
79 /// do we have a script?
80 bool has(bool up) const;
82 void removeScript(bool up);
84 void removeEmptyScripts();
88 // call these methods ...2 to make compaq cxx in anal mode happy...
89 /// suppresses empty braces if necessary
90 virtual void write2(MathInset const * nuc, WriteStream & os) const;
92 virtual void normalize2(MathInset const * nuc, NormalStream & os) const;
94 virtual void octavize2(MathInset const * nuc, OctaveStream & os) const;
96 virtual void maplize2(MathInset const * nuc, MapleStream & os) const;
98 virtual void mathmlize2(MathInset const * nuc, MathMLStream & os) const;
101 /// returns x offset for main part
102 int dxx(MathInset const * nuc) const;
103 /// returns width of nucleus if any
104 int nwid(MathInset const * nuc) const;
106 /// returns y offset for superscript
107 int dy0(MathInset const * nuc) const;
108 /// returns y offset for subscript
109 int dy1(MathInset const * nuc) const;
110 /// returns x offset for superscript
111 int dx0(MathInset const * nuc) const;
112 /// returns x offset for subscript
113 int dx1(MathInset const * nuc) const;
114 /// returns ascent of nucleus if any
115 int nasc(MathInset const * nuc) const;
116 /// returns descent of nucleus if any
117 int ndes(MathInset const * nuc) const;
119 /// possible subscript (index 0) and superscript (index 1)
124 mutable MathMetricsInfo mi_;