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 "Dimension.h"
29 * Each paragraph is broken up into a number of rows on the screen.
30 * This is a list of such on-screen rows, ordered from the top row
33 typedef std::vector<Row> RowList;
44 /// Helper class for paragraph metrics.
45 class ParagraphMetrics {
47 /// Default constructor (only here for STL containers).
48 ParagraphMetrics() : position_(0), par_(0) {}
49 /// The only useful constructor.
50 explicit ParagraphMetrics(Paragraph const & par);
53 ParagraphMetrics & operator=(ParagraphMetrics const &);
55 void reset(Paragraph const & par);
58 Row const & getRow(pos_type pos, bool boundary) const;
60 size_t pos2row(pos_type pos) const;
62 /// TextMetrics::redoParagraph updates this
63 Dimension const & dim() const { return dim_; }
64 Dimension & dim() { return dim_; }
65 /// total height of paragraph
66 int height() const { return dim_.height(); }
67 /// total width of paragraph, may differ from workwidth
68 int width() const { return dim_.width(); }
69 /// ascend of paragraph above baseline
70 int ascent() const { return dim_.ascent(); }
71 /// descend of paragraph below baseline
72 int descent() const { return dim_.descent(); }
73 /// Text updates the rows using this access point
74 RowList & rows() { return rows_; }
75 /// The painter and others use this
76 RowList const & rows() const { return rows_; }
78 int rightMargin(BufferView const & bv) const;
80 /// dump some information to lyxerr
84 bool hfillExpansion(Row const & row, pos_type pos) const;
87 int position() const { return position_; }
88 void setPosition(int position);
94 mutable RowList rows_;
95 /// cached dimensions of paragraph
98 Paragraph const * par_;
103 #endif // PARAGRAPH_METRICS_H