+ p->metrics(mi);
+ p->dimensions(ww, aa, dd);
+ v.push_back(Row());
+ v.back().dim = Dimension(ww, aa, dd);
+ }
+ }
+
+ //lyxerr << "MathXArray::metrics(): '" << dim_ << "\n";
+}
+
+
+void MathXArray::draw(MathPainterInfo & pi, int x, int y) const
+{
+ //if (drawn_ && x == xo_ && y == yo_)
+ // return;
+
+ //lyxerr << "x: " << x << " y: " << y << " " << pain.workAreaHeight() << endl;
+
+ xo_ = x;
+ yo_ = y;
+ drawn_ = true;
+
+ if (y + descent() <= 0) // don't draw above the workarea
+ return;
+ if (y - ascent() >= pi.pain.paperHeight()) // don't draw below the workarea
+ return;
+ if (x + width() <= 0) // don't draw left of workarea
+ return;
+ if (x >= pi.pain.paperWidth()) // don't draw right of workarea
+ return;
+
+ const_iterator it = begin(), et = end();
+
+ if (it == et) {
+ pi.pain.rectangle(x, y - ascent(), width(), height(), LColor::mathline);
+ return;
+ }
+
+ for (; it != et; ++it) {
+ MathInset const * p = it->nucleus();
+ MathScriptInset const * q = (it + 1 == et) ? 0 : asScript(it);
+ if (q) {
+ q->draw(p, pi, x, y);
+ x += q->width2(p);
+ ++it;
+ } else {
+ p->draw(pi, x, y);
+ x += p->width();
+ }
+ }
+}
+
+
+void MathXArray::drawExternal(MathPainterInfo & pi, int x, int y,
+ std::vector<Row> const & v) const
+{
+ for (size_type r = 0, pos = 0; r != v.size(); ++r) {
+ int xx = x;
+ int yy = y + v[r].yo;
+ for ( ; pos != v[r].end; ++pos) {
+ MathInset const * p = data_[pos].nucleus();
+ MathScriptInset const * q = 0;
+ if (pos + 1 != data_.size())
+ q = asScript(begin() + pos + 1);
+ if (q) {
+ q->draw(p, pi, xx, yy);
+ xx += q->width2(p);
+ ++pos;
+ } else {
+ p->draw(pi, xx, yy);
+ xx += p->width();
+ }
+ }
+ }
+}
+
+
+void MathXArray::metricsT(TextMetricsInfo const & mi) const
+{
+ //if (clean_)
+ // return;
+ dim_.clear();
+ for (const_iterator it = begin(); it != end(); ++it) {
+ MathInset const * p = it->nucleus();
+ MathScriptInset const * q = (it + 1 == end()) ? 0 : asScript(it);
+ int ww, aa, dd;
+ if (q) {
+ q->metricsT(p, mi);
+ q->dimensions2(p, ww, aa, dd);
+ ++it;
+ } else {
+ p->metricsT(mi);
+ p->dimensions(ww, aa, dd);
+ }
+ dim_ += Dimension(ww, aa, dd);
+ }
+}
+
+
+void MathXArray::drawT(TextPainter & pain, int x, int y) const
+{
+ //if (drawn_ && x == xo_ && y == yo_)
+ // return;
+
+ //lyxerr << "x: " << x << " y: " << y << " " << pain.workAreaHeight() << endl;
+
+ xo_ = x;
+ yo_ = y;
+ drawn_ = true;
+
+ const_iterator it = begin(), et = end();
+
+ for (; it != et; ++it) {
+ MathInset const * p = it->nucleus();
+ MathScriptInset const * q = (it + 1 == et) ? 0 : asScript(it);
+ if (q) {
+ q->drawT(p, pain, x, y);
+ x += q->width2(p);
+ ++it;
+ } else {
+ p->drawT(pain, x, y);