7 #include "math_scriptinset.h"
8 #include "math_support.h"
13 extern MathScriptInset const * asScript(MathArray::const_iterator it);
16 MathXArray::MathXArray()
17 : width_(0), ascent_(0), descent_(0), xo_(0), yo_(0), size_()
21 void MathXArray::metrics(MathMetricsInfo const & mi) const
24 mathed_char_dim(LM_TC_VAR, mi, 'I', ascent_, descent_, width_);
29 math_font_max_dim(LM_TC_TEXTRM, mi, ascent_, descent_);
32 //lyxerr << "MathXArray::metrics(): '" << data_ << "'\n";
34 for (const_iterator it = begin(); it != end(); ++it) {
35 MathInset const * p = it->nucleus();
36 MathScriptInset const * q = (it + 1 == end()) ? 0 : asScript(it);
39 ascent_ = std::max(ascent_, q->ascent(p));
40 descent_ = std::max(descent_, q->descent(p));
41 width_ += q->width(p);
45 ascent_ = std::max(ascent_, p->ascent());
46 descent_ = std::max(descent_, p->descent());
50 //lyxerr << "MathXArray::metrics(): '" << ascent_ << " "
51 // << descent_ << " " << width_ << "'\n";
55 void MathXArray::draw(Painter & pain, int x, int y) const
61 pain.rectangle(x, y - ascent_, width_, height(), LColor::mathline);
65 for (const_iterator it = begin(); it != end(); ++it) {
66 MathInset const * p = it->nucleus();
67 MathScriptInset const * q = (it + 1 == end()) ? 0 : asScript(it);
69 q->draw(p, pain, x, y);
80 int MathXArray::pos2x(size_type targetpos) const
83 const_iterator target = std::min(begin() + targetpos, end());
84 for (const_iterator it = begin(); it < target; ++it) {
85 MathInset const * p = it->nucleus();
86 MathScriptInset const * q = (it + 1 == end()) ? 0 : asScript(it);
91 else // "half" position
92 x += q->dxx(p) + q->nwid(p);
100 MathArray::size_type MathXArray::x2pos(int targetx) const
102 const_iterator it = begin();
105 for ( ; currx < targetx && it < end(); ++it) {
109 MathInset const * p = it->nucleus();
110 MathScriptInset const * q = 0;
121 if (abs(lastx - targetx) < abs(currx - targetx) && it != begin())