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);
42 MathAtom(MathInset * p, MathScriptInset * up, MathScriptInset * down);
46 void operator=(MathAtom const &);
48 void swap(MathAtom &);
50 /// draw the object, sets xo_ and yo_ cached values
51 virtual void draw(Painter &, int x, int y) const;
53 void metrics(MathStyles st) const;
68 void xo(int tx) const;
70 void yo(int ty) const;
74 void getXY(int & x, int & y) const;
76 bool covers(int x, int y) const;
81 void validate(LaTeXFeatures & features) const;
83 void handleFont(MathTextCodes) {}
85 /// make sure superscript is available
86 MathScriptInset * ensure(bool up);
87 /// delete subscript array if empty
88 void removeEmptyScripts();
89 /// can we add a super- or subscript?
90 virtual bool allows(bool up) const { return script_[up] == 0; }
91 /// can we add a super- or subscript?
92 virtual bool allowsLimits() const { return true; }
94 void limits(int lim) { limits_ = lim; }
96 int limits() const { return limits_; }
98 bool hasLimits() const;
99 /// returns superscript
100 MathScriptInset * up() const;
101 /// returns subscript
102 MathScriptInset * down() const;
103 /// returns superscript
104 MathScriptInset * & up();
105 /// returns subscript
106 MathScriptInset * & down();
108 MathInset * nucleus() const { return nucleus_; }
110 void substitute(const MathMacro &);
112 void write(std::ostream &, bool) const;
114 void writeNormal(std::ostream &) const;
117 /// possible subscript (index 0) and superscript (index 1)
118 MathScriptInset * script_[2];
120 MathInset * nucleus_;
125 /// the following are used for positioning the cursor with the mouse
126 /// cached cursor start position in pixels from the document left
128 /// cached cursor start position in pixels from the document top
132 void copy(MathAtom const & p);
136 /// returns y offset for superscript
138 /// returns y offset for subscript
140 /// returns x offset for superscript
142 /// returns x offset for subscript
144 /// returns x offset for main part
146 /// returns width of nucleus if any
148 /// returns ascent of nucleus if any
150 /// returns descent of nucleus if any
154 std::ostream & operator<<(std::ostream &, MathAtom const &);