8 #include "math_inset.h"
9 #include "math_scriptinset.h"
10 #include "mathed/support.h"
11 #include "math_defs.h"
16 MathXArray::MathXArray()
17 : width_(0), ascent_(0), descent_(0), xo_(0), yo_(0), size_()
21 void MathXArray::metrics(MathMetricsInfo const & st) const
24 mathed_char_dim(LM_TC_VAR, st, 'I', ascent_, descent_, width_);
29 math_font_max_dim(LM_TC_TEXTRM, st, ascent_, descent_);
32 //lyxerr << "MathXArray::metrics(): '" << data_ << "'\n";
34 for (const_iterator it = begin(); it != end(); ++it) {
35 MathInset const * p = it->nucleus();
36 if (MathScriptInset const * q = data_.asScript(it)) {
38 ascent_ = std::max(ascent_, q->ascent(p));
39 descent_ = std::max(descent_, q->descent(p));
40 width_ += q->width(p);
44 ascent_ = std::max(ascent_, p->ascent());
45 descent_ = std::max(descent_, p->descent());
49 //lyxerr << "MathXArray::metrics(): '" << ascent_ << " "
50 // << descent_ << " " << width_ << "'\n";
54 void MathXArray::draw(Painter & pain, int x, int y) const
60 pain.rectangle(x, y - ascent_, width_, height(), LColor::mathline);
64 for (const_iterator it = begin(); it != end(); ++it) {
65 MathInset const * p = it->nucleus();
66 if (MathScriptInset const * q = data_.asScript(it)) {
67 q->draw(p, pain, x, y);
78 int MathXArray::pos2x(size_type targetpos) const
81 const_iterator target = std::min(begin() + targetpos, end());
82 for (const_iterator it = begin(); it < target; ++it) {
83 MathInset const * p = it->nucleus();
84 if (MathScriptInset const * q = data_.asScript(it)) {
88 else // "half" position
89 x += q->dxx(p) + q->nwid(p);
97 MathArray::size_type MathXArray::x2pos(int targetx) const
99 const_iterator it = begin();
102 for ( ; currx < targetx && it < end(); ++it) {
106 MathInset const * p = it->nucleus();
107 if (MathScriptInset const * q = data_.asScript(it)) {
115 if (abs(lastx - targetx) < abs(currx - targetx) && it != begin())
121 std::ostream & operator<<(std::ostream & os, MathXArray const & ar)