2 * \file src/TextMetrics.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Asger Alstrup
7 * \author Lars Gullik Bjønnes
8 * \author Jean-Marc Lasgouttes
10 * \author André Pönitz
12 * \author Jürgen Vigna
13 * \author Abdelrazak Younes
15 * Full author contact details are available in file CREDITS.
20 #include "TextMetrics.h"
23 #include "BufferParams.h"
24 #include "BufferView.h"
25 #include "paragraph_funcs.h"
26 #include "ParIterator.h"
27 #include "CoordCache.h"
29 #include "FuncRequest.h"
30 #include "FontIterator.h"
35 #include "MetricsInfo.h"
36 #include "ParagraphParameters.h"
39 #include "frontends/FontMetrics.h"
40 #include "frontends/Painter.h"
48 using frontend::FontMetrics;
52 int numberOfSeparators(Paragraph const & par, Row const & row)
54 pos_type const first = max(row.pos(), par.beginOfBody());
55 pos_type const last = row.endpos() - 1;
57 for (pos_type p = first; p < last; ++p) {
58 if (par.isSeparator(p))
65 int numberOfLabelHfills(Paragraph const & par, Row const & row)
67 pos_type last = row.endpos() - 1;
68 pos_type first = row.pos();
70 // hfill *DO* count at the beginning of paragraphs!
72 while (first < last && par.isHfill(first))
76 last = min(last, par.beginOfBody());
78 for (pos_type p = first; p < last; ++p) {
86 int numberOfHfills(Paragraph const & par, Row const & row)
88 pos_type const last = row.endpos();
89 pos_type first = row.pos();
91 // hfill *DO* count at the beginning of paragraphs!
93 while (first < last && par.isHfill(first))
97 first = max(first, par.beginOfBody());
100 for (pos_type p = first; p < last; ++p) {
109 TextMetrics::TextMetrics(BufferView * bv, LyXText * text)
110 : bv_(bv), text_(text)
113 max_width_ = bv_->workWidth();
114 dim_.wid = max_width_;
118 //text_->updateLabels(*bv->buffer());
122 ParagraphMetrics const & TextMetrics::parMetrics(pit_type pit) const
124 return const_cast<TextMetrics *>(this)->parMetrics(pit, true);
128 ParagraphMetrics & TextMetrics::parMetrics(pit_type pit,
131 ParMetricsCache::iterator pmc_it = par_metrics_.find(pit);
132 if (pmc_it == par_metrics_.end()) {
133 pmc_it = par_metrics_.insert(
134 std::make_pair(pit, ParagraphMetrics(text_->getPar(pit)))).first;
136 if (pmc_it->second.rows().empty() && redo) {
139 return pmc_it->second;
143 bool TextMetrics::metrics(MetricsInfo & mi, Dimension & dim)
145 BOOST_ASSERT(mi.base.textwidth);
146 max_width_ = mi.base.textwidth;
148 //lyxerr << "LyXText::metrics: width: " << mi.base.textwidth
149 // << " maxWidth: " << max_width_ << "\nfont: " << mi.base.font << endl;
151 bool changed = false;
155 for (pit_type pit = 0, n = text_->paragraphs().size(); pit != n; ++pit) {
156 changed |= redoParagraph(pit);
157 ParagraphMetrics const & pm = parMetrics(pit);
164 dim.asc = parMetrics(0).ascent();
165 dim.des = h - dim.asc;
167 changed |= dim_ != dim;
173 int TextMetrics::rightMargin(ParagraphMetrics const & pm) const
175 return main_text_? pm.rightMargin(*bv_->buffer()) : 0;
179 int TextMetrics::rightMargin(pit_type const pit) const
181 return main_text_? par_metrics_[pit].rightMargin(*bv_->buffer()) : 0;
185 bool TextMetrics::redoParagraph(pit_type const pit)
187 Paragraph & par = text_->getPar(pit);
188 ParagraphMetrics pm(par);
189 Buffer & buffer = *bv_->buffer();
190 main_text_ = (text_ == &buffer.text());
191 bool changed = false;
193 // FIXME: this has nothing to do here and is the reason why text_ is not
195 if (par.checkBiblio(buffer.params().trackChanges))
196 const_cast<Cursor &>(bv_->cursor()).posRight();
198 // Optimisation: this is used in the next two loops
199 // so better to calculate that once here.
200 int const right_margin = rightMargin(pm);
203 // FIXME: We should always use getFont(), see documentation of
204 // noFontChange() in Inset.h.
205 Font const bufferfont = buffer.params().getFont();
206 InsetList::const_iterator ii = par.insetlist.begin();
207 InsetList::const_iterator iend = par.insetlist.end();
208 for (; ii != iend; ++ii) {
210 int const w = max_width_ - text_->leftMargin(buffer, max_width_, pit, ii->pos)
212 Font const & font = ii->inset->noFontChange() ?
213 bufferfont : text_->getFont(buffer, par, ii->pos);
214 MetricsInfo mi(bv_, font, w);
215 changed |= ii->inset->metrics(mi, dim);
218 // rebreak the paragraph
221 par.setBeginOfBody();
223 // maximum pixel width of a row
224 int width = max_width_ - right_margin; // - leftMargin(buffer, max_width_, pit, row);
227 rowBreakPoint(width, pit, row);
228 setRowWidth(right_margin, pit, row);
229 setHeightOfRow(pit, row);
230 pm.rows().push_back(row);
231 pm.dim().wid = std::max(pm.dim().wid, row.width());
232 pm.dim().des += row.height();
234 } while (z < par.size());
236 // Make sure that if a par ends in newline, there is one more row
238 // FIXME this is a dirty trick. Now the _same_ position in the
239 // paragraph occurs in _two_ different rows, and has two different
240 // display positions, leading to weird behaviour when moving up/down.
241 if (z > 0 && par.isNewline(z - 1)) {
244 setRowWidth(right_margin, pit, row);
245 setHeightOfRow(pit, row);
246 pm.rows().push_back(row);
247 pm.dim().des += row.height();
250 pm.dim().asc += pm.rows()[0].ascent();
251 pm.dim().des -= pm.rows()[0].ascent();
253 // IMPORTANT NOTE: We pass 'false' explicitely in order to not call
254 // redoParagraph() recursively inside parMetrics.
255 Dimension old_dim = parMetrics(pit, false).dim();
257 changed |= old_dim.height() != pm.dim().height();
259 par_metrics_[pit] = pm;
261 // Update the row change statuses. The painter will need that info
262 // in order to know which row has to be repainted.
263 par_metrics_[pit].updateRowChangeStatus();
268 RowMetrics TextMetrics::computeRowMetrics(pit_type const pit,
269 Row const & row) const
272 Buffer & buffer = *bv_->buffer();
273 Paragraph const & par = text_->getPar(pit);
275 double w = dim_.wid - row.width();
277 bool const is_rtl = text_->isRTL(buffer, par);
279 result.x = rightMargin(pit);
281 result.x = text_->leftMargin(buffer, max_width_, pit, row.pos());
283 // is there a manual margin with a manual label
284 Layout_ptr const & layout = par.layout();
286 if (layout->margintype == MARGIN_MANUAL
287 && layout->labeltype == LABEL_MANUAL) {
288 /// We might have real hfills in the label part
289 int nlh = numberOfLabelHfills(par, row);
291 // A manual label par (e.g. List) has an auto-hfill
292 // between the label text and the body of the
294 // But we don't want to do this auto hfill if the par
299 if (nlh && !par.getLabelWidthString().empty())
300 result.label_hfill = labelFill(par, row) / double(nlh);
303 // are there any hfills in the row?
304 int const nh = numberOfHfills(par, row);
308 result.hfill = w / nh;
309 // we don't have to look at the alignment if it is ALIGN_LEFT and
310 // if the row is already larger then the permitted width as then
311 // we force the LEFT_ALIGN'edness!
312 } else if (int(row.width()) < max_width_) {
313 // is it block, flushleft or flushright?
314 // set x how you need it
316 if (par.params().align() == LYX_ALIGN_LAYOUT)
317 align = layout->align;
319 align = par.params().align();
321 // Display-style insets should always be on a centred row
322 // The test on par.size() is to catch zero-size pars, which
323 // would trigger the assert in Paragraph::getInset().
324 //inset = par.size() ? par.getInset(row.pos()) : 0;
326 && par.isInset(row.pos())
327 && par.getInset(row.pos())->display())
329 align = LYX_ALIGN_CENTER;
333 case LYX_ALIGN_BLOCK: {
334 int const ns = numberOfSeparators(par, row);
335 bool disp_inset = false;
336 if (row.endpos() < par.size()) {
337 Inset const * in = par.getInset(row.endpos());
339 disp_inset = in->display();
341 // If we have separators, this is not the last row of a
342 // par, does not end in newline, and is not row above a
343 // display inset... then stretch it
345 && row.endpos() < par.size()
346 && !par.isNewline(row.endpos() - 1)
349 result.separator = w / ns;
355 case LYX_ALIGN_RIGHT:
358 case LYX_ALIGN_CENTER:
364 text_->bidi.computeTables(par, buffer, row);
366 pos_type body_pos = par.beginOfBody();
367 pos_type end = row.endpos();
370 && (body_pos > end || !par.isLineSeparator(body_pos - 1)))
372 docstring const lsep = from_utf8(layout->labelsep);
373 result.x += theFontMetrics(text_->getLabelFont(buffer, par)).width(lsep);
375 result.x += result.label_hfill;
383 int TextMetrics::labelFill(Paragraph const & par, Row const & row) const
385 Buffer & buffer = *bv_->buffer();
387 pos_type last = par.beginOfBody();
388 BOOST_ASSERT(last > 0);
390 // -1 because a label ends with a space that is in the label
393 // a separator at this end does not count
394 if (par.isLineSeparator(last))
398 for (pos_type i = row.pos(); i <= last; ++i)
399 w += text_->singleWidth(buffer, par, i);
401 docstring const & label = par.params().labelWidthString();
405 FontMetrics const & fm
406 = theFontMetrics(text_->getLabelFont(buffer, par));
408 return max(0, fm.width(label) - w);
414 // this needs special handling - only newlines count as a break point
415 pos_type addressBreakPoint(pos_type i, Paragraph const & par)
417 pos_type const end = par.size();
420 if (par.isNewline(i))
429 int TextMetrics::labelEnd(pit_type const pit) const
431 // labelEnd is only needed if the layout fills a flushleft label.
432 if (text_->getPar(pit).layout()->margintype != MARGIN_MANUAL)
434 // return the beginning of the body
435 return text_->leftMargin(*bv_->buffer(), max_width_, pit);
439 void TextMetrics::rowBreakPoint(int width, pit_type const pit,
442 Buffer & buffer = *bv_->buffer();
443 Paragraph const & par = text_->getPar(pit);
444 pos_type const end = par.size();
445 pos_type const pos = row.pos();
456 Layout_ptr const & layout = par.layout();
458 if (layout->margintype == MARGIN_RIGHT_ADDRESS_BOX) {
459 row.endpos(addressBreakPoint(pos, par));
463 pos_type const body_pos = par.beginOfBody();
466 // Now we iterate through until we reach the right margin
467 // or the end of the par, then choose the possible break
470 int label_end = labelEnd(pit);
471 int const left = text_->leftMargin(buffer, max_width_, pit, pos);
474 // pixel width since last breakpoint
477 FontIterator fi = FontIterator(buffer, *text_, par, pos);
478 pos_type point = end;
480 FontMetrics const & fm = theFontMetrics(text_->getLabelFont(buffer, par));
481 for ( ; i < end; ++i, ++fi) {
482 char_type const c = par.getChar(i);
483 int thiswidth = text_->singleWidth(par, i, c, *fi);
485 // add the auto-hfill from label end to the body
486 if (body_pos && i == body_pos) {
487 docstring lsep = from_utf8(layout->labelsep);
488 int add = fm.width(lsep);
489 if (par.isLineSeparator(i - 1))
490 add -= text_->singleWidth(buffer, par, i - 1);
492 add = std::max(add, label_end - x);
497 chunkwidth += thiswidth;
499 // break before a character that will fall off
500 // the right of the row
502 // if no break before, break here
503 if (point == end || chunkwidth >= width - left) {
510 // exit on last registered breakpoint:
514 if (par.isNewline(i)) {
520 if (par.isInset(i + 1) && par.getInset(i + 1)->display()) {
525 if (par.isInset(i) && par.getInset(i)->display()) {
531 if (!par.isInset(i) || par.getInset(i)->isChar()) {
532 // some insets are line separators too
533 if (par.isLineSeparator(i)) {
534 // register breakpoint:
541 // maybe found one, but the par is short enough.
542 if (i == end && x < width)
545 // manual labels cannot be broken in LaTeX. But we
546 // want to make our on-screen rendering of footnotes
548 if (body_pos && point < body_pos)
555 void TextMetrics::setRowWidth(int right_margin,
556 pit_type const pit, Row & row) const
558 Buffer & buffer = *bv_->buffer();
559 // get the pure distance
560 pos_type const end = row.endpos();
562 Paragraph const & par = text_->getPar(pit);
563 docstring const labelsep = from_utf8(par.layout()->labelsep);
564 int w = text_->leftMargin(buffer, max_width_, pit, row.pos());
565 int label_end = labelEnd(pit);
567 pos_type const body_pos = par.beginOfBody();
568 pos_type i = row.pos();
570 FontMetrics const & fm = theFontMetrics(text_->getLabelFont(buffer, par));
573 FontIterator fi = FontIterator(buffer, *text_, par, i);
574 for ( ; i < end; ++i, ++fi) {
575 if (body_pos > 0 && i == body_pos) {
576 w += fm.width(labelsep);
577 if (par.isLineSeparator(i - 1))
578 w -= text_->singleWidth(buffer, par, i - 1);
579 w = max(w, label_end);
581 char_type const c = par.getChar(i);
582 w += text_->singleWidth(par, i, c, *fi);
586 if (body_pos > 0 && body_pos >= end) {
587 w += fm.width(labelsep);
588 if (end > 0 && par.isLineSeparator(end - 1))
589 w -= text_->singleWidth(buffer, par, end - 1);
590 w = max(w, label_end);
593 row.width(w + right_margin);
597 void TextMetrics::setHeightOfRow(pit_type const pit,
600 Paragraph const & par = text_->getPar(pit);
601 // get the maximum ascent and the maximum descent
602 double layoutasc = 0;
603 double layoutdesc = 0;
604 double const dh = defaultRowHeight();
606 // ok, let us initialize the maxasc and maxdesc value.
607 // Only the fontsize count. The other properties
608 // are taken from the layoutfont. Nicer on the screen :)
609 Layout_ptr const & layout = par.layout();
611 // as max get the first character of this row then it can
612 // increase but not decrease the height. Just some point to
613 // start with so we don't have to do the assignment below too
615 Buffer const & buffer = *bv_->buffer();
616 Font font = text_->getFont(buffer, par, row.pos());
617 Font::FONT_SIZE const tmpsize = font.size();
618 font = text_->getLayoutFont(buffer, pit);
619 Font::FONT_SIZE const size = font.size();
620 font.setSize(tmpsize);
622 Font labelfont = text_->getLabelFont(buffer, par);
624 FontMetrics const & labelfont_metrics = theFontMetrics(labelfont);
625 FontMetrics const & fontmetrics = theFontMetrics(font);
627 // these are minimum values
628 double const spacing_val = layout->spacing.getValue()
629 * text_->spacing(buffer, par);
630 //lyxerr << "spacing_val = " << spacing_val << endl;
631 int maxasc = int(fontmetrics.maxAscent() * spacing_val);
632 int maxdesc = int(fontmetrics.maxDescent() * spacing_val);
634 // insets may be taller
635 InsetList::const_iterator ii = par.insetlist.begin();
636 InsetList::const_iterator iend = par.insetlist.end();
637 for ( ; ii != iend; ++ii) {
638 if (ii->pos >= row.pos() && ii->pos < row.endpos()) {
639 maxasc = max(maxasc, ii->inset->ascent());
640 maxdesc = max(maxdesc, ii->inset->descent());
644 // Check if any custom fonts are larger (Asger)
645 // This is not completely correct, but we can live with the small,
646 // cosmetic error for now.
648 pos_type const pos_end = row.endpos();
650 Font::FONT_SIZE maxsize =
651 par.highestFontInRange(row.pos(), pos_end, size);
652 if (maxsize > font.size()) {
653 font.setSize(maxsize);
654 maxasc = max(maxasc, fontmetrics.maxAscent());
655 maxdesc = max(maxdesc, fontmetrics.maxDescent());
658 // This is nicer with box insets:
663 ParagraphList const & pars = text_->paragraphs();
666 if (row.pos() == 0) {
667 BufferParams const & bufparams = buffer.params();
668 // some parksips VERY EASY IMPLEMENTATION
669 if (bufparams.paragraph_separation
670 == BufferParams::PARSEP_SKIP
672 && ((layout->isParagraph() && par.getDepth() == 0)
673 || (pars[pit - 1].layout()->isParagraph()
674 && pars[pit - 1].getDepth() == 0)))
676 maxasc += bufparams.getDefSkip().inPixels(*bv_);
679 if (par.params().startOfAppendix())
680 maxasc += int(3 * dh);
682 // This is special code for the chapter, since the label of this
683 // layout is printed in an extra row
684 if (layout->counter == "chapter"
685 && !par.params().labelString().empty()) {
686 labeladdon = int(labelfont_metrics.maxHeight()
687 * layout->spacing.getValue()
688 * text_->spacing(buffer, par));
691 // special code for the top label
692 if ((layout->labeltype == LABEL_TOP_ENVIRONMENT
693 || layout->labeltype == LABEL_BIBLIO
694 || layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)
695 && isFirstInSequence(pit, pars)
696 && !par.getLabelstring().empty())
699 labelfont_metrics.maxHeight()
700 * layout->spacing.getValue()
701 * text_->spacing(buffer, par)
702 + (layout->topsep + layout->labelbottomsep) * dh);
705 // Add the layout spaces, for example before and after
706 // a section, or between the items of a itemize or enumerate
709 pit_type prev = depthHook(pit, pars, par.getDepth());
710 Paragraph const & prevpar = pars[prev];
712 && prevpar.layout() == layout
713 && prevpar.getDepth() == par.getDepth()
714 && prevpar.getLabelWidthString()
715 == par.getLabelWidthString()) {
716 layoutasc = layout->itemsep * dh;
717 } else if (pit != 0 || row.pos() != 0) {
718 if (layout->topsep > 0)
719 layoutasc = layout->topsep * dh;
722 prev = outerHook(pit, pars);
723 if (prev != pit_type(pars.size())) {
724 maxasc += int(pars[prev].layout()->parsep * dh);
725 } else if (pit != 0) {
726 Paragraph const & prevpar = pars[pit - 1];
727 if (prevpar.getDepth() != 0 ||
728 prevpar.layout() == layout) {
729 maxasc += int(layout->parsep * dh);
734 // is it a bottom line?
735 if (row.endpos() >= par.size()) {
736 // add the layout spaces, for example before and after
737 // a section, or between the items of a itemize or enumerate
739 pit_type nextpit = pit + 1;
740 if (nextpit != pit_type(pars.size())) {
745 if (pars[cpit].getDepth() > pars[nextpit].getDepth()) {
746 usual = pars[cpit].layout()->bottomsep * dh;
747 cpit = depthHook(cpit, pars, pars[nextpit].getDepth());
748 if (pars[cpit].layout() != pars[nextpit].layout()
749 || pars[nextpit].getLabelWidthString() != pars[cpit].getLabelWidthString())
751 unusual = pars[cpit].layout()->bottomsep * dh;
753 layoutdesc = max(unusual, usual);
754 } else if (pars[cpit].getDepth() == pars[nextpit].getDepth()) {
755 if (pars[cpit].layout() != pars[nextpit].layout()
756 || pars[nextpit].getLabelWidthString() != pars[cpit].getLabelWidthString())
757 layoutdesc = int(pars[cpit].layout()->bottomsep * dh);
762 // incalculate the layout spaces
763 maxasc += int(layoutasc * 2 / (2 + pars[pit].getDepth()));
764 maxdesc += int(layoutdesc * 2 / (2 + pars[pit].getDepth()));
766 // FIXME: the correct way is to do the following is to move the
767 // following code in another method specially tailored for the
768 // main LyXText. The following test is thus bogus.
769 // Top and bottom margin of the document (only at top-level)
771 if (pit == 0 && row.pos() == 0)
773 if (pit + 1 == pit_type(pars.size()) &&
774 row.endpos() == par.size())
778 row.ascent(maxasc + labeladdon);
779 row.descent(maxdesc);
783 // x is an absolute screen coord
784 // returns the column near the specified x-coordinate of the row
785 // x is set to the real beginning of this column
786 pos_type TextMetrics::getColumnNearX(pit_type const pit,
787 Row const & row, int & x, bool & boundary) const
789 Buffer const & buffer = *bv_->buffer();
791 /// For the main LyXText, it is possible that this pit is not
792 /// yet in the CoordCache when moving cursor up.
793 /// x Paragraph coordinate is always 0 for main text anyway.
794 int const xo = main_text_? 0 : bv_->coordCache().get(text_, pit).x_;
796 RowMetrics const r = computeRowMetrics(pit, row);
797 Paragraph const & par = text_->getPar(pit);
799 pos_type vc = row.pos();
800 pos_type end = row.endpos();
802 Layout_ptr const & layout = par.layout();
804 bool left_side = false;
806 pos_type body_pos = par.beginOfBody();
809 double last_tmpx = tmpx;
812 (body_pos > end || !par.isLineSeparator(body_pos - 1)))
815 // check for empty row
821 frontend::FontMetrics const & fm
822 = theFontMetrics(text_->getLabelFont(buffer, par));
824 while (vc < end && tmpx <= x) {
825 c = text_->bidi.vis2log(vc);
827 if (body_pos > 0 && c == body_pos - 1) {
829 docstring const lsep = from_utf8(layout->labelsep);
830 tmpx += r.label_hfill + fm.width(lsep);
831 if (par.isLineSeparator(body_pos - 1))
832 tmpx -= text_->singleWidth(buffer, par, body_pos - 1);
835 if (par.hfillExpansion(row, c)) {
836 tmpx += text_->singleWidth(buffer, par, c);
840 tmpx += r.label_hfill;
841 } else if (par.isSeparator(c)) {
842 tmpx += text_->singleWidth(buffer, par, c);
846 tmpx += text_->singleWidth(buffer, par, c);
851 if ((tmpx + last_tmpx) / 2 > x) {
856 BOOST_ASSERT(vc <= end); // This shouldn't happen.
859 // This (rtl_support test) is not needed, but gives
860 // some speedup if rtl_support == false
861 bool const lastrow = lyxrc.rtl_support && row.endpos() == par.size();
863 // If lastrow is false, we don't need to compute
865 bool const rtl = lastrow ? text_->isRTL(buffer, par) : false;
867 ((rtl && left_side && vc == row.pos() && x < tmpx - 5) ||
868 (!rtl && !left_side && vc == end && x > tmpx + 5)))
870 else if (vc == row.pos()) {
871 c = text_->bidi.vis2log(vc);
872 if (text_->bidi.level(c) % 2 == 1)
875 c = text_->bidi.vis2log(vc - 1);
876 bool const rtl = (text_->bidi.level(c) % 2 == 1);
877 if (left_side == rtl) {
879 boundary = text_->bidi.isBoundary(buffer, par, c);
883 // I believe this code is not needed anymore (Jug 20050717)
885 // The following code is necessary because the cursor position past
886 // the last char in a row is logically equivalent to that before
887 // the first char in the next row. That's why insets causing row
888 // divisions -- Newline and display-style insets -- must be treated
889 // specially, so cursor up/down doesn't get stuck in an air gap -- MV
890 // Newline inset, air gap below:
891 if (row.pos() < end && c >= end && par.isNewline(end - 1)) {
892 if (text_->bidi.level(end -1) % 2 == 0)
893 tmpx -= text_->singleWidth(buffer, par, end - 1);
895 tmpx += text_->singleWidth(buffer, par, end - 1);
899 // Air gap above display inset:
900 if (row.pos() < end && c >= end && end < par.size()
901 && par.isInset(end) && par.getInset(end)->display()) {
904 // Air gap below display inset:
905 if (row.pos() < end && c >= end && par.isInset(end - 1)
906 && par.getInset(end - 1)->display()) {
912 pos_type const col = c - row.pos();
914 if (!c || end == par.size())
917 if (c==end && !par.isLineSeparator(c-1) && !par.isNewline(c-1)) {
922 return min(col, end - 1 - row.pos());
926 pos_type TextMetrics::x2pos(pit_type pit, int row, int x) const
928 ParagraphMetrics const & pm = parMetrics(pit);
929 BOOST_ASSERT(!pm.rows().empty());
930 BOOST_ASSERT(row < int(pm.rows().size()));
932 Row const & r = pm.rows()[row];
933 return r.pos() + getColumnNearX(pit, r, x, bound);
937 //int LyXText::pos2x(pit_type pit, pos_type pos) const
939 // ParagraphMetrics const & pm = parMetrics(pit);
940 // Row const & r = pm.rows()[row];
946 int defaultRowHeight()
948 return int(theFontMetrics(Font(Font::ALL_SANE)).maxHeight() * 1.2);