13 #include "math_defs.h"
16 The 'atom' is the major blob in math typesetting. And 'atom' consists
17 of a nucleus, an optional superscript, and an optional subscript.
19 Exactly where the subscript and superscript are drawn depends on the
20 size, and type, of the nucleus they are attached to.
27 class MathScriptInset;
38 MathAtom(MathAtom const &);
40 explicit MathAtom(MathInset * p);
44 void operator=(MathAtom const &);
46 void swap(MathAtom &);
48 /// draw the object, sets xo_ and yo_ cached values
49 virtual void draw(Painter &, int x, int y) const;
51 void metrics(MathStyles st) const;
66 void xo(int tx) const;
68 void yo(int ty) const;
72 void getXY(int & x, int & y) const;
74 bool covers(int x, int y) const;
79 void validate(LaTeXFeatures & features) const;
81 void handleFont(MathTextCodes) {}
83 /// make sure superscript is available
84 MathScriptInset * ensure(bool up);
85 /// delete subscript array if empty
86 void removeEmptyScripts();
87 /// can we add a super- or subscript?
88 virtual bool allows(bool up) const { return script_[up] == 0; }
89 /// can we add a super- or subscript?
90 virtual bool allowsLimits() const { return true; }
92 void limits(int lim) { limits_ = lim; }
94 int limits() const { return limits_; }
96 bool hasLimits() const;
97 /// returns superscript
98 MathScriptInset * up() const;
100 MathScriptInset * down() const;
102 MathInset * nucleus() const { return nucleus_; }
104 void substitute(MathArray &, const MathMacro &) const;
106 void write(std::ostream &, bool) const;
108 void writeNormal(std::ostream &) const;
111 /// possible subscript (index 0) and superscript (index 1)
112 MathScriptInset * script_[2];
114 MathInset * nucleus_;
119 /// the following are used for positioning the cursor with the mouse
120 /// cached cursor start position in pixels from the document left
122 /// cached cursor start position in pixels from the document top
126 void copy(MathAtom const & p);
130 /// returns y offset for superscript
132 /// returns y offset for subscript
134 /// returns x offset for superscript
136 /// returns x offset for subscript
138 /// returns x offset for main part
140 /// returns width of nucleus if any
142 /// returns ascent of nucleus if any
144 /// returns descent of nucleus if any
148 std::ostream & operator<<(std::ostream &, MathAtom const &);