8 #include "math_inset.h"
9 #include "mathed/support.h"
10 #include "math_defs.h"
17 MathXArray::MathXArray()
18 : width_(0), ascent_(0), descent_(0), xo_(0), yo_(0), style_(LM_ST_TEXT)
22 void MathXArray::Metrics(MathStyles st, int, int)
25 mathed_char_dim(LM_TC_VAR, st, 'I', ascent_, descent_, width_);
34 // keep last values for scriptInset's need to look back
38 mathed_char_height(LM_TC_VAR, st, 'I', asc, des);
40 for (int pos = 0; pos < data_.size(); data_.next(pos)) {
41 MathInset * p = data_.nextInset(pos);
43 // only MathUpDownInsets will use the asc/des information...
44 p->Metrics(st, asc, des);
49 char cx = data_.GetChar(pos);
50 MathTextCodes fc = data_.GetCode(pos);
51 mathed_char_dim(fc, style_, cx, asc, des, wid);
53 ascent_ = max(ascent_, asc);
54 descent_ = max(descent_, des);
60 void MathXArray::draw(Painter & pain, int x, int y)
66 pain.rectangle(x, y - ascent_, width_, height(), LColor::mathline);
70 for (int pos = 0; pos < data_.size(); data_.next(pos)) {
71 MathInset * p = data_.nextInset(pos);
76 char cx = data_.GetChar(pos);
77 MathTextCodes fc = data_.GetCode(pos);
80 drawStr(pain, fc, style_, x, y, s);
81 x += mathed_char_width(fc, style_, cx);
87 int MathXArray::pos2x(int targetpos) const
90 targetpos = min(targetpos, data_.size());
91 for (int pos = 0; pos < targetpos; data_.next(pos))
97 int MathXArray::x2pos(int targetx) const
100 for (int x = 0; x < targetx && pos < data_.size(); data_.next(pos))
105 int MathXArray::width(int pos) const
107 if (pos >= data_.size())
110 if (data_.isInset(pos))
111 return data_.nextInset(pos)->width();
113 return mathed_char_width(data_.GetCode(pos), style_, data_.GetChar(pos));
116 std::ostream & operator<<(std::ostream & os, MathXArray const & ar)