3 * \file ParagraphMetrics.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Asger Alstrup
8 * \author Lars Gullik Bjønnes
10 * \author André Pönitz
11 * \author Jürgen Vigna
12 * \author Abdelrazak Younes
14 * Full author contact details are available in file CREDITS.
17 #ifndef PARAGRAPH_METRICS_H
18 #define PARAGRAPH_METRICS_H
20 #include "Paragraph.h"
25 * Each paragraph is broken up into a number of rows on the screen.
26 * This is a list of such on-screen rows, ordered from the top row
29 typedef std::vector<Row> RowList;
34 /// Helper class for Paragraph Metrics.
35 class ParagraphMetrics {
37 /// Default constructor (only here for STL containers).
38 ParagraphMetrics(): par_(0) {};
39 /// The only useful constructor.
40 ParagraphMetrics(Paragraph const & par);
43 ParagraphMetrics & operator=(ParagraphMetrics const &);
45 void reset(Paragraph const & par);
48 Row & getRow(pos_type pos, bool boundary);
50 Row const & getRow(pos_type pos, bool boundary) const;
52 size_t pos2row(pos_type pos) const;
54 /// BufferView::redoParagraph updates this
55 Dimension const & dim() const { return dim_; }
56 Dimension & dim() { return dim_; }
57 /// total height of paragraph
58 unsigned int height() const { return dim_.height(); }
59 /// total width of paragraph, may differ from workwidth
60 unsigned int width() const { return dim_.width(); }
61 /// ascend of paragraph above baseline
62 unsigned int ascent() const { return dim_.ascent(); }
63 /// descend of paragraph below baseline
64 unsigned int descent() const { return dim_.descent(); }
65 /// Text updates the rows using this access point
66 RowList & rows() { return rows_; }
67 /// The painter and others use this
68 RowList const & rows() const { return rows_; }
70 int rightMargin(Buffer const & buffer) const;
72 int singleWidth(pos_type pos, Font const & Font) const;
74 /// dump some information to lyxerr
77 void computeRowSignature(Row &, BufferParams const & bparams);
81 mutable RowList rows_;
82 /// cached dimensions of paragraph
85 Paragraph const * par_;
90 #endif // PARAGRAPH_METRICS_H