9 #include "math_inset.h"
10 #include "mathed/support.h"
11 #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)
25 mathed_char_dim(LM_TC_VAR, st, 'I', ascent_, descent_, width_);
34 for (int pos = 0; pos < data_.size(); data_.next(pos)) {
35 MathInset * p = data_.GetInset(pos);
38 ascent_ = max(ascent_, p->ascent());
39 descent_ = max(descent_, p->descent());
42 char cx = data_.GetChar(pos);
43 MathTextCodes fc = data_.GetCode(pos);
47 mathed_char_dim(fc, style_, cx, asc, des, wid);
48 ascent_ = max(ascent_, asc);
49 descent_ = max(descent_, des);
56 void MathXArray::draw(Painter & pain, int x, int y)
62 pain.rectangle(x, y - ascent_, width_, height(), LColor::mathline);
66 for (int pos = 0; pos < data_.size(); data_.next(pos)) {
67 MathInset * p = data_.GetInset(pos);
72 char cx = data_.GetChar(pos);
73 MathTextCodes fc = data_.GetCode(pos);
76 drawStr(pain, fc, style_, x, y, s);
77 x += mathed_char_width(fc, style_, cx);
83 int MathXArray::pos2x(int targetpos) const
86 targetpos = min(targetpos, data_.size());
87 for (int pos = 0; pos < targetpos; data_.next(pos))
93 int MathXArray::x2pos(int targetx) const
96 for (int x = 0; x < targetx && pos < data_.size(); data_.next(pos))
101 int MathXArray::width(int pos) const
103 if (pos >= data_.size())
106 if (data_.isInset(pos))
107 return data_.GetInset(pos)->width();
109 return mathed_char_width(data_.GetCode(pos), style_, data_.GetChar(pos));
112 std::ostream & operator<<(std::ostream & os, MathXArray const & ar)