9 #include "math_inset.h"
10 #include "mathed/support.h"
11 #include "math_defs.h"
18 MathXArray::MathXArray()
19 : width_(0), ascent_(0), descent_(0), xo_(0), yo_(0), style_(LM_ST_TEXT)
23 void MathXArray::Metrics(MathStyles st, int, int)
26 mathed_char_dim(LM_TC_VAR, st, 'I', ascent_, descent_, width_);
35 // keep last values for scriptInset's need to look back
39 mathed_char_height(LM_TC_VAR, st, 'I', asc, des);
41 for (int pos = 0; pos < data_.size(); data_.next(pos)) {
42 MathInset * p = data_.nextInset(pos);
44 // only MathUpDownInsets will use the asc/des information...
45 p->Metrics(st, asc, des);
50 char cx = data_.GetChar(pos);
51 MathTextCodes fc = data_.GetCode(pos);
52 mathed_char_dim(fc, style_, cx, asc, des, wid);
54 ascent_ = max(ascent_, asc);
55 descent_ = max(descent_, des);
61 void MathXArray::draw(Painter & pain, int x, int y)
67 pain.rectangle(x, y - ascent_, width_, height(), LColor::mathline);
71 for (int pos = 0; pos < data_.size(); data_.next(pos)) {
72 MathInset * p = data_.nextInset(pos);
77 char cx = data_.GetChar(pos);
78 MathTextCodes fc = data_.GetCode(pos);
81 drawStr(pain, fc, style_, x, y, s);
82 x += mathed_char_width(fc, style_, cx);
88 int MathXArray::pos2x(int targetpos) const
91 targetpos = min(targetpos, data_.size());
92 for (int pos = 0; pos < targetpos; data_.next(pos))
98 int MathXArray::x2pos(int targetx) const
101 for (int x = 0; x < targetx && pos < data_.size(); data_.next(pos))
106 int MathXArray::width(int pos) const
108 if (pos >= data_.size())
111 if (data_.isInset(pos))
112 return data_.nextInset(pos)->width();
114 return mathed_char_width(data_.GetCode(pos), style_, data_.GetChar(pos));
117 std::ostream & operator<<(std::ostream & os, MathXArray const & ar)