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);
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 ascent2(MathInset const * nuc) const;
39 int descent2(MathInset const * nuc) const;
41 int width2(MathInset const * nuc) const;
44 bool idxLeft(idx_type &, pos_type &) const;
46 bool idxRight(idx_type &, pos_type &) const;
48 /// identifies scriptinsets
49 MathScriptInset const * asScriptInset() const;
51 MathScriptInset * asScriptInset();
54 void limits(int lim) { limits_ = lim; }
56 int limits() const { return limits_; }
57 /// true if we have an "inner" position
58 MathXArray const & up() const;
60 MathXArray const & down() const;
61 /// returns superscript
65 /// do we have a superscript?
67 /// do we have a subscript?
69 /// do we have a script?
70 bool has(bool up) const;
71 /// do we have a anything?
74 void removeScript(bool up);
76 void removeEmptyScripts();
77 /// make sure a script is accessible
80 // call these methods ...2 to make compaq cxx in anal mode happy...
81 /// suppresses empty braces if necessary
82 virtual void write2(MathInset const * nuc, WriteStream & os) const;
83 virtual void normalize2(MathInset const * nuc, NormalStream & os) const;
84 virtual void octavize2(MathInset const * nuc, OctaveStream & os) const;
85 virtual void maplize2(MathInset const * nuc, MapleStream & os) const;
86 virtual void mathmlize2(MathInset const * nuc, MathMLStream & os) const;
89 /// returns x offset for main part
90 int dxx(MathInset const * nuc) const;
91 /// returns width of nucleus if any
92 int nwid(MathInset const * nuc) const;
94 /// returns y offset for superscript
95 int dy0(MathInset const * nuc) const;
96 /// returns y offset for subscript
97 int dy1(MathInset const * nuc) const;
98 /// returns x offset for superscript
99 int dx0(MathInset const * nuc) const;
100 /// returns x offset for subscript
101 int dx1(MathInset const * nuc) const;
102 /// returns ascent of nucleus if any
103 int nasc(MathInset const * nuc) const;
104 /// returns descent of nucleus if any
105 int ndes(MathInset const * nuc) const;
106 /// where do we have to draw the scripts?
107 bool hasLimits(MathInset const * nuc) const;
109 /// possible subscript (index 0) and superscript (index 1)
111 /// 1 - "limits", -1 - "nolimits", 0 - "default"
113 /// cached MathMetricsInfo
114 mutable MathMetricsInfo mi_;