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"
27 /// Helper class for Paragraph Metrics.
28 class ParagraphMetrics {
30 /// Default constructor (only here for STL containers).
31 ParagraphMetrics(): par_(0) {};
32 /// The only useful constructor.
33 ParagraphMetrics(Paragraph const & par);
36 /// Important note: We don't copy \c row_change_status_ and
37 /// \c row_signature_ because those are updated externally with
38 /// \c updateRowChangeStatus() in TextMetrics::redoParagraph().
39 ParagraphMetrics & operator=(ParagraphMetrics const &);
42 Row & getRow(pos_type pos, bool boundary);
44 Row const & getRow(pos_type pos, bool boundary) const;
46 size_t pos2row(pos_type pos) const;
48 /// BufferView::redoParagraph updates this
49 Dimension const & dim() const { return dim_; }
50 Dimension & dim() { return dim_; }
51 /// total height of paragraph
52 unsigned int height() const { return dim_.height(); }
53 /// total width of paragraph, may differ from workwidth
54 unsigned int width() const { return dim_.width(); }
55 /// ascend of paragraph above baseline
56 unsigned int ascent() const { return dim_.ascent(); }
57 /// descend of paragraph below baseline
58 unsigned int descent() const { return dim_.descent(); }
59 /// LyXText updates the rows using this access point
60 RowList & rows() { return rows_; }
61 /// The painter and others use this
62 RowList const & rows() const { return rows_; }
63 /// The painter and others use this
64 std::vector<bool> const & rowChangeStatus() const
65 { return row_change_status_; }
67 void updateRowChangeStatus();
69 int rightMargin(Buffer const & buffer) const;
71 /// dump some information to lyxerr
76 size_type calculateRowSignature(Row const &);
78 mutable RowList rows_;
80 RowSignature row_signature_;
82 std::vector<bool> row_change_status_;
83 /// cached dimensions of paragraph
86 Paragraph const * par_;
91 #endif // PARAGRAPH_METRICS_H