8 #include "math_inset.h"
9 #include "mathed/support.h"
10 #include "math_defs.h"
15 MathXArray::MathXArray()
16 : width_(0), ascent_(0), descent_(0), xo_(0), yo_(0), style_(LM_ST_TEXT)
20 void MathXArray::metrics(MathStyles 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";
32 for (size_type pos = 0; pos < data_.size(); ++pos) {
33 MathAtom const * p = data_.at(pos);
35 ascent_ = std::max(ascent_, p->ascent());
36 descent_ = std::max(descent_, p->descent());
39 //lyxerr << "MathXArray::metrics(): '" << ascent_ << " "
40 // << descent_ << " " << width_ << "'\n";
44 void MathXArray::draw(Painter & pain, int x, int y) const
50 pain.rectangle(x, y - ascent_, width_, height(), LColor::mathline);
54 for (size_type pos = 0; pos < data_.size(); ++pos) {
55 MathAtom const * p = data_.at(pos);
62 int MathXArray::pos2x(size_type targetpos) const
65 targetpos = std::min(targetpos, data_.size());
66 for (size_type pos = 0; pos < targetpos; ++pos)
72 MathArray::size_type MathXArray::x2pos(int targetx) const
77 for ( ; currx < targetx && pos < data_.size(); ++pos) {
81 if (abs(lastx - targetx) < abs(currx - targetx) && pos > 0)
87 int MathXArray::width(size_type pos) const
89 MathAtom const * t = data_.at(pos);
90 return t ? t->width() : 0;
94 std::ostream & operator<<(std::ostream & os, MathXArray const & ar)