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();
91 /// delete superscript
95 /// can we add a super- or subscript?
96 virtual bool allows(bool up) const { return script_[up] == 0; }
97 /// can we add a super- or subscript?
98 virtual bool allowsLimits() const { return true; }
100 void limits(int lim) { limits_ = lim; }
102 int limits() const { return limits_; }
104 bool hasLimits() const;
105 /// true if we have an "inner" position
106 bool hasInner() const;
107 /// returns superscript
108 MathScriptInset * up() const;
109 /// returns subscript
110 MathScriptInset * down() const;
111 /// returns superscript
112 MathScriptInset * & up();
113 /// returns subscript
114 MathScriptInset * & down();
116 MathInset * nucleus() const { return nucleus_; }
118 MathInset * & nucleus() { return nucleus_; }
120 void substitute(const MathMacro &);
122 void write(std::ostream &, bool) const;
124 void writeNormal(std::ostream &) const;
125 /// returns width of nucleus if any
129 /// possible subscript (index 0) and superscript (index 1)
130 MathScriptInset * script_[2];
132 MathInset * nucleus_;
137 /// the following are used for positioning the cursor with the mouse
138 /// cached cursor start position in pixels from the document left
140 /// cached cursor start position in pixels from the document top
144 void copy(MathAtom const & p);
148 /// returns y offset for superscript
150 /// returns y offset for subscript
152 /// returns x offset for main part
154 /// returns x offset for superscript
156 /// returns x offset for subscript
158 /// returns ascent of nucleus if any
160 /// returns descent of nucleus if any
164 std::ostream & operator<<(std::ostream &, MathAtom const &);