7 #include "math_inset.h"
8 #include "math_scriptinset.h"
9 #include "math_support.h"
10 #include "math_defs.h"
15 MathXArray::MathXArray()
16 : width_(0), ascent_(0), descent_(0), xo_(0), yo_(0), size_()
20 void MathXArray::metrics(MathMetricsInfo const & st) const
23 mathed_char_dim(LM_TC_VAR, st, 'I', ascent_, descent_, width_);
28 math_font_max_dim(LM_TC_TEXTRM, st, ascent_, descent_);
31 //lyxerr << "MathXArray::metrics(): '" << data_ << "'\n";
33 for (const_iterator it = begin(); it != end(); ++it) {
34 MathInset const * p = it->nucleus();
35 if (MathScriptInset const * q = data_.asScript(it)) {
37 ascent_ = std::max(ascent_, q->ascent(p));
38 descent_ = std::max(descent_, q->descent(p));
39 width_ += q->width(p);
43 ascent_ = std::max(ascent_, p->ascent());
44 descent_ = std::max(descent_, p->descent());
48 //lyxerr << "MathXArray::metrics(): '" << ascent_ << " "
49 // << descent_ << " " << width_ << "'\n";
53 void MathXArray::draw(Painter & pain, int x, int y) const
59 pain.rectangle(x, y - ascent_, width_, height(), LColor::mathline);
63 for (const_iterator it = begin(); it != end(); ++it) {
64 MathInset const * p = it->nucleus();
65 if (MathScriptInset const * q = data_.asScript(it)) {
66 q->draw(p, pain, x, y);
77 int MathXArray::pos2x(size_type targetpos) const
80 const_iterator target = std::min(begin() + targetpos, end());
81 for (const_iterator it = begin(); it < target; ++it) {
82 MathInset const * p = it->nucleus();
83 if (MathScriptInset const * q = data_.asScript(it)) {
87 else // "half" position
88 x += q->dxx(p) + q->nwid(p);
96 MathArray::size_type MathXArray::x2pos(int targetx) const
98 const_iterator it = begin();
101 for ( ; currx < targetx && it < end(); ++it) {
105 MathInset const * p = it->nucleus();
106 if (MathScriptInset const * q = data_.asScript(it)) {
114 if (abs(lastx - targetx) < abs(currx - targetx) && it != begin())